4 Replies Latest reply on Oct 16, 2007 1:11 AM by Subramanyam Ramanathan

    process image display highlights wrong end node if task is e

    Subramanyam Ramanathan Newbie

      [jbpm 3.1.3, jboss4.0.5 ]

      I have a wierd problem - with some of my process definitions, the end node that gets highlighted at the end of the process is the wrong node ! This happens when I end my task instance is ended within the assignment handler itself. I need to do such a thing because the business logic demands it - based on a certain check, I need to end the task instead of assigning pooled actors to it.

      Lets say I have a node X, and two end states Y and Z that can be reached from it - what I find is that always the node that is specified by the first transition gets highlighted - that is, if the transition to Z is first , then that is the one that gets highlighted, else it is Y.
      This, in spite of me explicitly passing in the transition name when I end the task in the assignment handler.


      Why does this happen ? Does this have something to do with ending the task in the assignment handler ? If I should not end the task there, what would your suggestions be to end the task elsewhere ? (I don't want the task instance to show up at all - I want to be implicitly ended)

      Thanks in advance,
      Subbu

        • 1. Re: process image display highlights wrong end node if task
          David Roberts Apprentice

          AFAIK, If a task that has more than one transition ends, and you havent specified which transition to take, (eg: taskInstance.end("MyTransition");), the default transition will be taken, and that default is the first transition defined in the processdefinition.xml.

          So it sounds like the task instance isn't being ended correctly, or is not being ended with a transition name.

          Why it's doing this, is anyones guess, unless we can see what you are doing. Perhaps you should post the code that you use to end the task, so we can take a look, or create a unit test to display the behaviour, then im sure someone can help you.

          • 2. Re: process image display highlights wrong end node if task
            Subramanyam Ramanathan Newbie

            Actually, If I had specified the wrong transition, it would have gone to the wrong node - but I don't find that happening ! The transition name is correct, and it also goes to the right node - as evidenced by my logs, where I print the name of the last node from my action handler on event 'process-end'.

            As for my code - it's very simple:

            
            public class GenericAssignmentHandler implements AssignmentHandler {
            
             public void assign(Assignable assignable, ExecutionContext executionContext)
             throws Exception {
            
            ...
            ...
            
            
             if (startAndEndTask) {
            
             log.info("-----------starting and ending task-------------");
            
             // start and finish the task right here.
             ((TaskInstance) assignable).start();
            
             ((TaskInstance) assignable)
             .end("Approved");
             }
             log.info("------------done assignment handler----------");
            
            }
            
            
            


            And my process definition looks like:

            
            <?xml version="1.0" encoding="UTF-8"?>
            
            <process-definition xmlns="" name="NewSimpleProcess">
             <start-state name="start">
             <transition name="" to="Level1Approval"></transition>
             </start-state>
            
            
            
             <task-node name="Level1Approval">
            
             <task name="Level1ApprovalTask">
            
             <assignment
             class="GenericAssignmentHandler">
             </assignment>
            
            
            
             </task>
            
            
             <transition name="Approved" to="Level2Approval"></transition>
             <transition name="Denied" to="Denied"></transition>
             </task-node>
            
            
            
             <task-node name="Level2Approval">
            
             <task name="Level2ApprovalTask">
             <assignment
             class="GenericAssignmentHandler">
            
             </task>
            
            
            
             <transition name="Denied" to="Denied"></transition>
             <transition name="Approved" to="Approved"></transition>
             </task-node>
            
            
            
             <end-state name="Approved"></end-state>
             <end-state name="Denied"></end-state>
            
             <event type="process-end">
             <action
             class="GenericProcessEndHandler">
             </action>
             </event>
            
            
            </process-definition>
            


            Now, if I place transition Denied before Approved in my last node, it highlights denied, and if Approved appears first, it highlights approved !! And I *am* passing the transition name when I end the task. Am I making some obvious blunder here ?

            • 3. Re: process image display highlights wrong end node if task
              Ronald van Kuijk Master

              I cannot imagine BL demands ending a task in an assignmenthandler. Besides that, ending tasks in assignmenthandlers feels wrong. I'd personally model it completely different, e.g. a decision with to legs, one to the task and one that bypasses it.

              • 4. Re: process image display highlights wrong end node if task
                Subramanyam Ramanathan Newbie

                Let me explain the business case in more detail - We have a series of such similar (same assignment handler class) task nodes in our process definition - At each task node, the assignment handler talks finds out who the assisgnees are and assisgns them. The assignees may be different at each task node.

                If, say, assignee A completes the task at one node, and further down, the same assignee again resolves as one of the assignees, then the task should be considered "implicitly" finished by him - This was the reason why I was having a check in my assignment handler and ending the task right there.

                If not in the assignment handler - is there anywhere else, or on some other event, that I can end the task ?

                We may have as many as 10 - 15 task nodes - If I were to have a decision before each such task node, wouldn't that make it look more complicated ? Is there a better way out ?