6 Replies Latest reply on Mar 6, 2008 2:00 PM by Sandeep Reddy

    Do we really need "Transition"?

    Rudi Adianto Newbie

      Does a transition really needed in a bpm framework?
      I've just realized that the need to explicitly define transitions from a node is lessening the framework's expressiveness quite bad.
      I can't found an easy way to implement a complex flow, one of which is like
      a -> b -> c -> ttt -> d -> e
      where node ttt can move anywhere in the flow based on certain condition.
      if "Transition" is optional, implementing this is an easy case.

      anyone has any idea on the easiest way to implement this in latest stable release of JBPM?

        • 1. Re: Do we really need
          pojomonkey Newbie

          It IS possible to simply move token into arbitrary nodes (of course these would HAVE to be nodes with wait-states...) but that seems an awfully ham-fisted way of using jBPM!

          And how transitions can 'lessen the expressiveness' of a graph execution environment is beyond my comprehension. It also suggests that perhaps you're not fully grasping what jBPM is about.

          • 2. Re: Do we really need
            Rudi Adianto Newbie

             

            "pojomonkey" wrote:
            It also suggests that perhaps you're not fully grasping what jBPM is about.


            quite possibly.
            maybe I'm not looking the problem from the jBPM perspective.

            what i meant by not needing any "Transition" is that we can "officially" move token into arbitrary nodes, without regarded as being using jBPM in an ham-fisted way.

            a -> b -> c -> ttt -> d -> e

            if ttt is to be placed dynamically, then we can just make it
            a -> b -> c -> d -> e
            ttt
            nowhere in the other nodes we have to declare

            we can legally 'jump' to it from anywhere, and from ttt back to where we came from (or anywhere, of course).
            in current jBPM implementation i cant find any way to easily achieve this without cluttering my html with s.
            it would be much nicer if transition element is optional.

            • 3. Re: Do we really need
              Ronald van Kuijk Master

              think the other way around..... do not move the node, move the tokens. Give each a none meaningful transition (or even use a decsionnode, even better....)

              • 4. Re: Do we really need
                Rudi Adianto Newbie

                 

                "kukeltje" wrote:
                think the other way around..... do not move the node, move the tokens. Give each a none meaningful transition (or even use a decsionnode, even better....)


                yes, i used decision node and transitions, and moved the tokens instead of the node. but then my xml is full of
                <transition/>
                and
                <decision/>
                placed after each node. the transition web looks even worse in gpd.

                btw, i forgot to use [ code ] tags on my previous post. it should be



                nowhere in the other nodes we have to declare

                should be

                nowhere in the other nodes we have to declare
                <transition to="ttt"/>


                and

                ...without cluttering my html with s

                should be

                ...without cluttering my html with
                <transition/>



                • 5. Re: Do we really need
                  Ronald van Kuijk Master

                  Then build a full custom node which does not need a transition.

                  • 6. Re: Do we really need
                    Sandeep Reddy Newbie

                    Hi bungrudi ,

                    I was trying to do something similar to what you are talking about. My idea is to have a node using which I should be able to define the transitions at runtime.

                    Have a look at the sample process definition below, if you observe state 3 does not have any transition.

                    <?xml version="1.0" encoding="UTF-8"?>
                    <process-definition xmlns="" name="statetrans">
                     <start-state name="start-state1">
                     <transition to="state1"></transition>
                     </start-state>
                    
                     <state name="state1">
                     <transition to="state2"></transition>
                     </state>
                    
                     <state name="state2">
                     <transition to="end-state1"></transition>
                     <transition to="state1" name="to state1"></transition>
                     </state>
                    
                     <state name="state3"></state>
                    
                     <end-state name="end-state1"></end-state>
                    </process-definition>


                    In the below test case, I tried to added the transition at runtime and it worked :) . Now I am in the process of building my custom node :)

                    public void testAddingTransitionsToState3AtRuntime() {
                     Node node3 = processDefinition.getNode("state3");
                     Node node2 = processDefinition.getNode("state2");
                     Node end = processDefinition.getNode("end-state1");
                    
                    
                     Token token = processInstance.getRootToken();
                     assertEquals("start-state1", token.getNode().getName());
                    
                     processInstance.signal();
                     assertEquals("state1", token.getNode().getName());
                    
                     //Ideally I would like to add new transition from state1 to state3
                     Transition trans = processInstance.getRootToken().getNode()
                     .getDefaultLeavingTransition();
                     Node to = trans.getTo();
                     Node from = trans.getFrom();
                     System.out.println("from " + from.getName() + " to " + to.getName());
                    
                     trans.setTo(node3);
                     processInstance.signal();
                     assertEquals("state3", token.getNode().getName());
                     //As state 3 does not have any transition defined it will return null
                     Transition leavingTransitionState3 = processInstance.getRootToken().getNode()
                     .getDefaultLeavingTransition();
                     //Creating new transition.
                     leavingTransitionState3 = new Transition("test");
                     leavingTransitionState3.setTo(node2);
                     leavingTransitionState3.setFrom(node3);
                     processInstance.getRootToken().getNode().addLeavingTransition(leavingTransitionState3);
                     System.out.println("from " + leavingTransitionState3.getFrom().getName() + " to " + leavingTransitionState3.getTo().getName());
                    
                     processInstance.signal();
                     assertEquals("state2", token.getNode().getName());
                     processInstance.signal();
                     assertEquals("end-state1", token.getNode().getName());
                     }
                    
                    [/url]

                    Hope it helped.

                    Thanks
                    Sandeep