[jboss-user] [jBPM] - Access to variable via EL ?

Jaber C. Mourad do-not-reply at jboss.com
Mon Jun 7 03:56:33 EDT 2010


Jaber C. Mourad [http://community.jboss.org/people/newbeewan] replied to the discussion

"Access to variable via EL ?"

To view the discussion, visit: http://community.jboss.org/message/546401#546401

--------------------------------------------------------------
Hi,

My need seems to be pretty simple !

First :

I'have a task, owned by a user.

At the end of the task, I want to record the userid of the owner into a process variable using :

public class TaskAssigneeEventListener implements EventListener {
 
    ...
 
    @Override
    public void notify(EventListenerExecution execution) throws Exception {
        TaskService taskService = processEngine.getTaskService();
        Task task = taskService.createTaskQuery().processInstanceId(execution.getProcessInstance().getId()).uniqueResult();
        if (task == null) {
            logger.warn("No task found for ProcessInstance {}", execution.getProcessInstance().getId());
        } else {
            logger.trace("task name {} ; assignee ", task.getName(),task.getAssignee());
            execution.createVariable("MyLastTaskAssignee", task.getAssignee());
        }
 
    }
}


Second : I want to retreive that value into an assignment handler to assign that task to that user :
public class MyAssignementHandler implements AssignmentHandler {
     //Field I want to inject from my process
      private String previousUserId;
 
      @Override
      public void assign(Assignable assignable, OpenExecution execution) throws Exception {
            logger.trace("Value of previousUserId {} ", previousUserId);
            if (previousUserId != null) {
                  assignable.setAssignee(previousUserId);
            } else {
                  logger.warn("No assignee from the last task !!");
            }
      }
}


My tasks :
<task assignee="john" g="174,75,92,52" name="taskUser">
        <on event="end">
            <event-listener expr="#{taskAssigneeEventListener}">
            </event-listener>
        </on>

        <transition name="to taskManager" to="taskManager" g="-126,-24" />
    </task>
    <task g="337,173,92,52" name="taskManager">
        <assignment-handler expr="#{myAssignementHandler}">
            <field name="previousUserId">
                  <object expr="#{variables['MyLastTaskAssignee'}"/>
            </field>
        </assignment-handler>
        <transition name="to end1" to="end1" g="-65,-24" />
    </task>


Is it better to understand my need ?

Regards

--------------------------------------------------------------

Reply to this message by going to Community
[http://community.jboss.org/message/546401#546401]

Start a new discussion in jBPM at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034]

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20100607/25b6b80f/attachment.html 


More information about the jboss-user mailing list