6 Replies Latest reply on Oct 22, 2009 5:21 PM by kukeltje

    how to programatically list actitities from one activity

      === Environment ==============================
      - jBPM Version : jbpm 4.1 on WinXP
      - Database : Mysql 5.1
      - JDK : 1.5.0.11
      - Container : Tomcat 6.0.20
      - Configuration : importing files from the jbpm.jar
      - Libraries : I had to replace el-jar from tomcat with juel* from jbpm
      === Process ==================================
      < process name="StateSequence" xmlns="http://jbpm.org/4.0/jpdl" >

      < start g="16,18,48,48" >
      < transition to="a" / >
      < /start >

      < state name="a" g="96,16,75,52" >
      < transition to="b" / >
      < transition to="c" / >
      < /state >

      < state name="b" g="203,16,73,52" >
      < transition to="c" / >
      < /state >

      < end name="c" g="308,16,76,52" / >

      < /process >

      === Problem description =========================
      How do I do to know programatically that state "a" has to two transitions: "b" and "c"?

      because :
      Execution.getExecutions(): Only lists active executions
      Execution.findActiveActivityNames(): Only lists active activities

      I need something like:
      Execution.listActivities(): List activities of current activity so I'd get transtion "b" and "c".

      Thanks in advance.

        • 1. Re: how to programatically list actitities from one activity

          Take a Look at GetOutcomes.java


          ExecutionImpl execution = (task != null ? task.getExecution() : null);
          ActivityImpl activity = (execution != null ? execution.getActivity() : null);
          List<Transition> outgoingTransitions = (activity != null ? activity.getOutgoingTransitions() : null);
          
          if (outgoingTransitions != null) {
           for (Transition transition : outgoingTransitions) {
           //transition.getName() is transition name (name on arrow)
           //transition.getDestination().getName() is final end node where
           }
          }
          


          • 2. Re: how to programatically list actitities from one activity

            Interesting.... Thanks rams.rapo for your time...

            But this means I have to use some classes of internal pvm, for instance :
            org.jbpm.pvm.internal.cmd.GetOutcomes.java , and GetOutComes needs an instance of Environment in its execute method...
            "...
            public Set execute(Environment environment) {
            ..."
            I've been looking at the code of org.jbpm.pvm.internal.cmd and it seems simple to use. Besides, I've been reading the developer's guide and this enlightment came to me:
            "...
            JbpmConfiguration jbpmcfg = new JbpmConfiguration();
            ProcessEngine proceng = jbpmcfg.buildProcessEngine();
            EnvironmentImpl envimpl = jbpmcfg.openEnvironment();

            GetOutcomes goc = new GetOutcomes( )
            Set outcome = goc.execute( envimpl );
            ..."

            Is this what you've tried to tell me?

            Also, I've got some questions about this:

            1) Is the order of statements correct? I mean :

            JbpmConfiguration jbpmcfg = new JbpmConfiguration();
            ProcessEngine proceng = jbpmcfg.buildProcessEngine();
            EnvironmentImpl envimpl = jbpmcfg.openEnvironment();

            2) I'm supposing I can do the same with commands that make reads to the database like: GetStartActivityNamesCmd.java, is this right?

            3) Will there be any problems in this way because I'm not using the User API directly? With problems I mean: exceptions, runtime exceptions, logic errors made by jbpm. It's obvious that this will change in future.

            Any comments would be appreciated.






            • 3. Re: how to programatically list actitities from one activity

              The code is wrong when instanciating the GetOutcomes class.
              It is supposed that, by using ProcessEngine I'll get the taskid, and then I pass it to GetOutcomes on its constructor like this:

              GetOutcomes goc = new GetOutcomes( taskid ) ;

              • 4. Re: how to programatically list actitities from one activity

                You would need to extend few jbpm classes and override the GetOutcomes behaviour.

                At a very high level:

                a) Extend WireDescriptorBinding, implement corresponding descriptor by extending ObjectDescriptor, etc

                b) Add entry for extended WireDescriptorBinding class in jbpm.wire.bindings.xml.

                c) Extend jbpm springconfiguration class, override the buildProcessEngine, getTaskService methods.
                getTaskService should return the class which you extend from TaskService.

                d) Extend AbstractCommand and pass in custom taskservice class created in above step. Here you override the behaviour...

                p.s: search the forum, i remember few threads explaining more in detail on this implementation.

                • 5. Re: how to programatically list actitities from one activity

                  thanks!!!

                  • 6. Re: how to programatically list actitities from one activity
                    kukeltje

                    Would be a nice subject for a blog entry if you achieve this ;-)