1 2 Previous Next 18 Replies Latest reply on Nov 11, 2010 7:32 AM by LX T

    start-state

    Ricardo Marques Novice

      Hi guys, i'm having a problem with start-states, i had looked at the docs but still i'm a bit confused.

      I tried to run this process, and i got nothing on user task list. when I removed the start-state (because I had read somewhere that wasn't mandatory), and still i hadn't nothing on the tasklist.

      Is start-state mandatory?

      Then I tried to keep start-state but with a task, and then it appears, but the user must set it as done, not quite the behavior that I was expecting.

      For my purpuse, state-state would be just a model representation, the first task on my user task list should be "inserir destinatario".

      But on jbpm examples, there's examples where exist start-states without task.

      I just wanna define a representative start state, where I don't put any action, and he just transitate to the next one.

      My process definition:

      ...
       <swimlane name="default">
       <assignment expression="user(grover)"></assignment>
      ...
       <task-node name="decidir o destinatario">
       <task name="inserir destinatario" swimlane="default">
       <controller>
       <variable name="destinatario" access="read,write,required"></variable>
       <variable name="tipo" access="read,write,required"></variable>
       </controller>
       </task>
       <transition name="t erro" to="Escreve erro na consola">
       <condition>tipo != 'mail'</condition>
       </transition>
       <transition name="t mail" to="envia email">
       <condition>tipo== 'mail'</condition>
       </transition>
       </task-node>
       <start-state name="start">
       <transition name="t start" to="decidir o destinatario"></transition>
       </start-state>
      ...
      


      I'm creating the instance with:

      cmd = new NewProcessInstanceCommand();
      cmd.setProcessId(Long.parseLong(pid));
      cmd.setActorId(getUser().getName());
      cmd.setCreateStartTask(true);
      



      Could anyone clarify a bit this issue.

      Thanks in advance.

        • 1. Re: start-state
          Vt Ysh Newbie

          Maybe you should signal to the process instance after creation to move from start state to first task node? Or try to add some actions to start-state, for example on node enter and perform signaling in it. But it is only in theory, i didn't use models without a task in start state.

          • 3. Re: start-state
            Andreas Schienagel Newbie

            hmm...

            Maybe I am wrong, but I tested the node-enter behaviour on start-state and it seems, that this event is never executed:

            <process-definition
             xmlns="" name="test5">
             <start-state name="start">
             <task name="task"></task>
             <event type="node-enter">
             <script>
             <expression>
             System.out.println("NODE-ENTER");
             </expression>
             </script>
             </event>
             <event type="node-leave">
             <script>
             <expression>
             System.out.println("NODE-LEAVE");
             </expression>
             </script>
             </event>
             <transition name="" to="end1"></transition>
             </start-state>
             <end-state name="end1"></end-state>
            </process-definition>


            I get only "NODE-LEAVE" output on my console. Is that correct?!?

            • 4. Re: start-state
              Vt Ysh Newbie

              Seems that start-state doesn't have a node-enter event.

              For ricardomarques: maybe you should use StartProcessInstanceCommand instead NewProcessInstanceCommand with cmd.setCreateStartTask(false);

              • 5. Re: start-state
                Andreas Schienagel Newbie

                That's not really a good solution because you can't specify the behaviour by processdefinition.

                While searching the source code i found:

                public static final String[] supportedEventTypes = new String[]{
                 Event.EVENTTYPE_NODE_LEAVE,
                 Event.EVENTTYPE_AFTER_SIGNAL
                 };
                


                for start-state. So there really seems to be no ENTER event. But why? Anybody knows?

                • 6. Re: start-state
                  Vt Ysh Newbie

                  You can use NewProcessInstanceCommand with createStartTask as true, if returned value will be null then you will know, that process doesn't contain a start task. Then you can use SignalCommand or some other one to move process from start state to first task node.

                  • 7. Re: start-state
                    Andreas Schienagel Newbie

                    Ok. Should work this way.

                    • 8. Re: start-state
                      Koen Aers Master

                      The node enter event gets fired when the token enters a node. As for the start-state, the token never enters it. Rather the token is *positioned* in the start-state when the process starts executing. So the event you want to look at is the process-start event.
                      Btw. Performing a signal on the current token from an action handler is not a good practice. Action handlers that are configured on events should not try to modify the execution of the token.

                      Regards,
                      Koen

                      • 9. Re: start-state
                        Edward Staub Expert

                         

                        "koen.aers@jboss.com" wrote:
                        Performing a signal on the current token from an action handler is not a good practice.


                        Koen,

                        You mean that to apply only to event-handling ActionHandlers, correct?

                        Node-execution ActionHandlers can signal, yes?

                        Thanks,
                        -Ed Staub

                        • 10. Re: start-state
                          Andreas Schienagel Newbie

                          Thank you for the hint! Process-Start-Event works fine.

                          Anyway, there seems to be no elegant way to skip the start-state except the programmatically
                          way that was mentioned by vtysh. And since there is no role assignment possible in start-state,
                          every workflow has to be signalled by initiator.

                          (Would be nice if there were a few more possibilites to use the start-state than now)

                          • 11. Re: start-state
                            Ricardo Marques Novice

                             

                            "vtysh" wrote:
                            You can use NewProcessInstanceCommand with createStartTask as true, if returned value will be null then you will know, that process doesn't contain a start task. Then you can use SignalCommand or some other one to move process from start state to first task node.


                            i have take your idea and my my own Command based on NewProcessInstanceCommand to do this, this part is working now.


                            thanks for the feedback

                            • 12. Re: start-state
                              Ronald van Kuijk Master

                              @ed: Yes, correct...

                              • 13. Re: start-state
                                Koen Aers Master

                                Node-execution ActionHandlers should typically not call signal() but leaveNode(). The differences are minor though, if I remember correctly signal() only wraps leaveNode() adding the before-signal and after-signal event handling. But normally these events should not be handled on the node level.

                                Thanks,
                                Koen

                                • 14. Re: start-state
                                  Koen Aers Master

                                  As for skipping the start-state. You can start the process in any node from jPDL 3.2 on. Just do not model a start-state and add initial="true" as an attribute on the node (state, mail-node, process-state, etc) that you want to be the first node in the process-definition.

                                  Regards,
                                  Koen

                                  1 2 Previous Next