6 Replies Latest reply on Mar 29, 2006 5:20 AM by koen.aers

    Get all nodes in process definition when a SuperState is def

    hiata

      When I call the method processDefinition.getNodes() in org.jbpm.graph.def.ProcessDefinition, the node collection retrieved contains just nodes in superstate "mobile". I need to get all nodes in process definition.
      Can anybody help me, please?

      My process is defined like this:

      <process-definition name='SuperState2'>
      <start-state name='start'>

      </start-state>
      <end-state name='end'></end-state>
      <super-state name='fixe'>






      </super-state>

      <super-state name='mobile'>















      <task-node name='Aceitar'>

      </task-node>








      </super-state>

      </process-definition>


      Sorry, but the XML is not ok in the post. :(


      <process-definition name='SuperState2'
      <start-state name='start'
      </start-state><end-state name='end'></end-state><super-state name='fixe'
      <node name='Criar OS'
      <node name='Ver Status OS'
      </super-state><super-state name='mobile'
      <node name='Caixa de Entrada'
      <node name='Lista OS'
      <node name='Ler OS'
      <decision name='OS Aceita'
      <node name='Responder'
      <task-node name='Aceitar'
      </task-node><decision name='Ja Atribuida'
      <node name='Definir Resposta'
      </super-state></process-definition>

        • 1. Re: Get all nodes in process definition when a SuperState is
          mjm_uk

          I'm having the same issue...

          Process Definition =
          <?xml version="1.0" encoding="UTF-8"?>

          <process-definition name="test">
          <start-state name="start">

          </start-state>
          <end-state name="end1"></end-state>

          <super-state name="super1">






          </super-state>

          <super-state name="super2">






          </super-state>

          <super-state name="super3">






          </super-state>




          </process-definition>

          Code to get the nodes =
          ProcessDefinition def1 = jbpmContext.getGraphSession().findLatestProcessDefinition("test");
          System.err.println("*********** GET THE NODES ********** " + def1.getNodes().size());
          for (Iterator i = def1.getNodes().iterator(); i.hasNext();) {
          Node val = (Node)i.next();
          System.err.println("Got node : " + val.getFullyQualifiedName());
          }
          System.err.println("*********** ALL OF THE NODES ********");


          Result of Code =
          19:21:18,777 INFO [STDOUT] *********** GET THE NODES ********** 6
          19:21:18,777 INFO [STDOUT] Got node : super3/state5
          19:21:18,777 INFO [STDOUT] Got node : super3/state6
          19:21:18,777 INFO [STDOUT] Got node : super1
          19:21:18,777 INFO [STDOUT] Got node : super2
          19:21:18,777 INFO [STDOUT] Got node : super3
          19:21:18,777 INFO [STDOUT] Got node : state7
          19:21:18,777 INFO [STDOUT] *********** ALL OF THE NODES ********


          If I change my code to: -
          ProcessDefinition def1 = jbpmContext.getGraphSession().findLatestProcessDefinition("test");
          System.err.println("*********** GET THE NODES ********** " + def1.getNodes().size());
          for (Iterator i = def1.getNodes().iterator(); i.hasNext();) {
          Node val = (Node)i.next();

          if (val instanceof SuperState) {
          for (Iterator j = ((SuperState)val).getNodes().iterator(); j.hasNext();) {
          Node val1 = (Node)j.next();
          System.err.println("Got node : " + val1.getFullyQualifiedName());
          }
          }
          System.err.println("Got node : " + val.getFullyQualifiedName());
          }
          System.err.println("*********** ALL OF THE NODES ********");

          I get: -
          19:25:51,720 INFO [STDOUT] *********** GET THE NODES ********** 6
          19:25:51,720 INFO [STDOUT] Got node : super3/state5
          19:25:51,720 INFO [STDOUT] Got node : super3/state6

          19:25:51,720 INFO [STDOUT] Got node : super1/state1
          19:25:51,720 INFO [STDOUT] Got node : super1/state2
          19:25:51,720 INFO [STDOUT] Got node : super1
          19:25:51,720 INFO [STDOUT] Got node : super2/state3
          19:25:51,720 INFO [STDOUT] Got node : super2/state4
          19:25:51,720 INFO [STDOUT] Got node : super2
          19:25:51,720 INFO [STDOUT] Got node : super3/state5
          19:25:51,720 INFO [STDOUT] Got node : super3/state6

          19:25:51,720 INFO [STDOUT] Got node : super3
          19:25:51,720 INFO [STDOUT] Got node : state7
          19:25:51,720 INFO [STDOUT] *********** ALL OF THE NODES ********

          Which is still not totally correct because super3 is displayed twice.

          • 2. Re: Get all nodes in process definition when a SuperState is
            mjm_uk

            Their is also a BUG here!!!

            If there are more than 24 states e.g.

            start

            super1
            state1
            state2


            super2
            state3
            state4

            super3
            state5
            state6

            state7
            state8
            state9
            state10
            state11
            state12
            state13
            state14
            state15
            state16
            state17
            state19
            state20
            state21
            state22
            state23

            super4
            state24
            state25
            state26
            state27

            state28

            end1

            The output is (for the non nested version): -

            10:04:55,488 INFO [STDOUT] *********** GET THE NODES ********** 24
            10:04:55,488 INFO [STDOUT] Got node : super4/state24
            10:04:55,488 INFO [STDOUT] Got node : super4/state25
            10:04:55,488 INFO [STDOUT] Got node : super4/state26
            10:04:55,488 INFO [STDOUT] Got node : super4/state27
            10:04:55,488 INFO [STDOUT] Got node : state7
            10:04:55,488 INFO [STDOUT] Got node : state8
            10:04:55,488 INFO [STDOUT] Got node : state9
            10:04:55,488 INFO [STDOUT] Got node : state10
            10:04:55,488 INFO [STDOUT] Got node : state11
            10:04:55,488 INFO [STDOUT] Got node : state12
            10:04:55,488 INFO [STDOUT] Got node : state13
            10:04:55,488 INFO [STDOUT] Got node : state14
            10:04:55,488 INFO [STDOUT] Got node : state15
            10:04:55,488 INFO [STDOUT] Got node : state16
            10:04:55,488 INFO [STDOUT] Got node : state17
            10:04:55,488 INFO [STDOUT] Got node : state18
            10:04:55,488 INFO [STDOUT] Got node : state19
            10:04:55,488 INFO [STDOUT] Got node : state20
            10:04:55,488 INFO [STDOUT] Got node : state21
            10:04:55,488 INFO [STDOUT] Got node : state22
            10:04:55,488 INFO [STDOUT] Got node : state23
            10:04:55,488 INFO [STDOUT] Got node : super4
            10:04:55,488 INFO [STDOUT] Got node : state28
            10:04:55,488 INFO [STDOUT] Got node : end1
            10:04:55,488 INFO [STDOUT] *********** ALL OF THE NODES ********

            As can be seen super states 1, 2 and 3, are not found (and their child nodes), and the start state ?start?, when a ?findNode? is called on the process definition for ?super1/state1? it is not found where as ?super4/state25? is found.

            It seems that the super state is ?overwriting? the other nodes.

            This is VERY urgent for me. Any ideas? Is this caused by hibernate? As the addNode on the process definition seems to be working correctly. I traced it though when deploying the definition above and the nodeList looked correct (iw all the start, end, super, and states not contained in the super state), but the version of the ProcessDefinition retrieved from hibernate has the issues described above.

            Any help would be appreciated; and this needs to raised as a bug!

            • 3. Re: Get all nodes in process definition when a SuperState is
              mjm_uk

              Well I've got a fix for this, can this be added as an issue?

              The issue is that the ProcessDefinition.hbm.xml has: -



              <list-index column="NODECOLLECTIONINDEX_" />
              <one-to-many class="org.jbpm.graph.def.Node" />


              This means that super states nodes and normal nodes that both have an nodecollectionindex_ of 0, 1 .... will get overriden by the last one loaded.

              To resolve this issue I have added

              where="SUPERSTATE_ is null"
              to the list criteria.

              This is probably not the best way to go (I don't really know hibernate, but a filter looked like it might be more preferable).

              • 4. Re: Get all nodes in process definition when a SuperState is
                hiata

                 

                "mjm_uk" wrote:
                Well I've got a fix for this, can this be added as an issue?

                To resolve this issue I have added

                where="SUPERSTATE_ is null"
                to the list criteria.

                This is probably not the best way to go (I don't really know hibernate, but a filter looked like it might be more preferable).


                Great!!
                Could you show me where you have added the criteria code?
                I´ll implement it and make the analysis of this change.

                Best regards,

                Hiata Anderson


                • 5. Re: Get all nodes in process definition when a SuperState is
                  mjm_uk

                  Sorry I should have said, it's in the

                  \build\classes.jbpm\org\jbpm\graph\def\ProcessDefinition.hbm.xml
                  Change the nodes list: -

                  <list name="nodes" cascade="all" where="SUPERSTATE_ is null">.

                  Mark

                  • 6. Re: Get all nodes in process definition when a SuperState is
                    koen.aers

                    Can you please provide a JUnit test demonstrating the error in JIRA?

                    Regards,
                    Koen