5 Replies Latest reply on May 15, 2006 8:07 AM by Chris Knowles

    How do I assign a task within a start node without user inte

    Chris Knowles Newbie

      I would like to know if is possible to assign a task within a start node to a particular user. The idea is that only a particular user can kick a process off. In this case it is when a product is bought and information is entered. Since only one person can buy products for the office, I only want that user to be able to start the process.

      I have tried several different ways, swimlanes with expressions, custom handlers.. nothing seems to work, as the task appears in the start process list of every user.

      <swimlane name="starter">
       <assignment expression="user(buyer)"></assignment>
      </swimlane>
      
      <start-state name="start">
       <task name="start task">
       <assignment class="assignment.BuyerAssignmentHandler"></assignment>
       <controller>
       <variable name="manufacturer" access="read,write,required"></variable>
       <variable name="name" access="read,write,required"></variable>
       </controller>
       </task>
       <transition name="started" to="item bought"></transition>
      </start-state>


        • 1. Re: How do I assign a task within a start node without user
          Ronald van Kuijk Master

          Without changing the jBPM core, you have to do this by changing the userinterface backingbeans and filtering you all tasks that the current user should not be allowed to start.

          • 2. Re: How do I assign a task within a start node without user
            Amit Kumar Newbie

            Hi, I am facing the same problem as cknowles. I do understand the swimlance assigned to user(buyer). But could not follow the assignment.BuyerAssignmentHandler class. Kindly provide the code for this class. Thanks.

            • 3. Re: How do I assign a task within a start node without user
              Chris Knowles Newbie

              Thanks kukeltje, I suspected as much. I dont think much to the provided interface. I realise it was put together very quickly but it lacks so many basic features.

              amitjava2004, the code for assignment.BuyerAssignmentHandler simply tries to do the same thing as the swimlane (the swimlane and assignment handler dont actually do quite the same thing):

              package assignment;
              
              import org.jbpm.graph.def.ActionHandler;
              import org.jbpm.graph.exe.ExecutionContext;
              import org.jbpm.taskmgmt.def.AssignmentHandler;
              import org.jbpm.taskmgmt.exe.Assignable;
              
              public class StevePAssignmentHandler implements AssignmentHandler {
              
               private static final long serialVersionUID = 1L;
              
               public void assign(Assignable assignable, ExecutionContext executionContext) throws Exception {
               assignable.setActorId("Steve P");
               }
              }


              • 4. Re: How do I assign a task within a start node without user
                Chris Knowles Newbie

                Ooops, "Steve P" in that last post is supposed to be "buyer" to correspond to my first post.

                • 5. Re: How do I assign a task within a start node without user
                  Chris Knowles Newbie

                  I now have the problem of trying to write the filtering code, so users do not see the start of processes they are not supposed to be starting.. The problem is that is I get the actor expressions, or use a swimlane and get them via that, but they are all null. Obviously this is all from definitions and not from instances since a process that hasn't started does not have instances.

                  I have modified the following inside the HomeBean:

                  public List getLatestProcessDefinitions() {
                   List allProcesses = graphSession.findLatestProcessDefinitions();
                  
                   for (int i=0; i<allProcesses.size(); i++) {
                   ProcessDefinition processDefinition = (ProcessDefinition) allProcesses.get(i);
                  
                   TaskMgmtDefinition taskMgmtDefinition = processDefinition.getTaskMgmtDefinition();
                   log.info("Name = " + taskMgmtDefinition.getStartTask().getName());
                   log.info("Actor id expression = " + taskMgmtDefinition.getStartTask().getActorIdExpression());
                   log.info("Pooled actors expression = " + taskMgmtDefinition.getStartTask().getPooledActorsExpression());
                  
                   if (taskMgmtDefinition.getStartTask().getSwimlane() != null) {
                   log.info(taskMgmtDefinition.getStartTask().getSwimlane().getName());
                   log.info(taskMgmtDefinition.getStartTask().getSwimlane().getActorIdExpression());
                   log.info(taskMgmtDefinition.getStartTask().getSwimlane().getPooledActorsExpression());
                   } else {
                   log.info("swimlane is null");
                   }
                   }
                   return allProcesses;
                  }


                  This prints out the name of the start task and the swimlane fine, but all the actor expressions are null.