8 Replies Latest reply on Mar 31, 2010 1:27 PM by Maciej Swiderski

    How can i get the execution pointer in a process?

    Sameeh Harfoush Expert

      Hello

       

      I need to know the position of the execution in the workflow.

      As the workflow process is executing, I need to query the process instance to know what is being currently executed

      Can I do that, any examples?

       

      Thanks

        • 1. Re: How can i get the execution pointer in a process?
          Maciej Swiderski Master

          Hi,

          you can get that information by invoking findActiveActivityNames on your process instance.

           

          Next you can use the names returned to get execution objects by executing findActiveExecutionIn(activityName) again on your process instance.

           

          Cheers,

          Maciej

          1 of 1 people found this helpful
          • 2. Re: How can i get the execution pointer in a process?
            Sameeh Harfoush Expert

            Hello Maciej,

            Thank you for the reply,

             

            I am executing processInstance.findActiveActivityNames() while executing my workflow tasks and jobs,

            on every call of findActiveActivityNames is returning only the name of the first Task in my workflow throughout all my workflow execution

            any idea why?

             

            thank you

            • 3. Re: How can i get the execution pointer in a process?
              Maciej Swiderski Master

              Hi,

               

              make sure that if you signal your execution to move forward you need to take the processInstance object that is returned by that method. Otherwise you will work on old reference.

              If you are working with tasks you most likely need to run following method after you complete your task:

               

              procesInstance = executionService.findProcessInstanceById(processInstance.getId());
              

               

              And after that you invoke findActiveActivityNames and you should get correct results.

               

              Cheers,

              Maciej

              • 4. Re: How can i get the execution pointer in a process?
                Sameeh Harfoush Expert

                it worked

                Thank you

                 

                Do you have by any chance a link to good tutorial on how to query JPBM 4?

                • 5. Re: How can i get the execution pointer in a process?
                  Sameeh Harfoush Expert

                  Is there a way to get the type of execution the execution pointer is on?

                  i need to know if the execution is on a Task, state, decision, mail...etc

                   

                  Thanks

                  • 6. Re: How can i get the execution pointer in a process?
                    Maciej Swiderski Master

                    you could do that by casting you active execution instance to ExecutionImpl and then use method getActivity().getType().

                     

                    Cheers

                    Maciej

                    • 7. Re: How can i get the execution pointer in a process?
                      Sameeh Harfoush Expert

                      ok

                      here is what i did

                       

                      ((ExecutionImpl)pi.findActiveExecutionIn(pi.findActiveActivityNames().iterator().next())).getActivity().getName()

                       

                      where "pi" is my process instance

                       

                      i am getting the below exception

                       

                      ### EXCEPTION ###########################################
                      15:16:35,000 SEV   | [BaseJbpmTestCase] TEST THROWS EXCEPTION: no environment to get org.jbpm.pvm.internal.session.RepositorySession
                      org.jbpm.api.JbpmException: no environment to get org.jbpm.pvm.internal.session.RepositorySession
                          at org.jbpm.pvm.internal.env.EnvironmentImpl.getFromCurrent(EnvironmentImpl.java:197)
                          at org.jbpm.pvm.internal.env.EnvironmentImpl.getFromCurrent(EnvironmentImpl.java:190)
                          at org.jbpm.pvm.internal.model.ExecutionImpl.getProcessDefinition(ExecutionImpl.java:1121)
                          at org.jbpm.pvm.internal.model.ExecutionImpl.getActivity(ExecutionImpl.java:1143)
                          at com.roxana.test.jpdl.EmployeeTimesheetTest.executeTransitionInTask(EmployeeTimesheetTest.java:169)
                          at com.roxana.test.jpdl.EmployeeTimesheetTest.testManagerRejectTimesheet(EmployeeTimesheetTest.java:115)
                          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                          at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
                          at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
                          at java.lang.reflect.Method.invoke(Unknown Source)
                          at junit.framework.TestCase.runTest(TestCase.java:164)
                          at org.jbpm.test.BaseJbpmTestCase.runTest(BaseJbpmTestCase.java:80)
                          at junit.framework.TestCase.runBare(TestCase.java:130)
                          at junit.framework.TestResult$1.protect(TestResult.java:106)
                          at junit.framework.TestResult.runProtected(TestResult.java:124)
                          at junit.framework.TestResult.run(TestResult.java:109)
                          at junit.framework.TestCase.run(TestCase.java:120)
                          at junit.framework.TestSuite.runTest(TestSuite.java:230)
                          at junit.framework.TestSuite.run(TestSuite.java:225)
                          at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
                          at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
                          at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
                          at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
                          at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
                          at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
                      ### EXCEPTION ###########################################
                      15:16:35,000 SEV   | [BaseJbpmTestCase]

                       

                      i couldnt find ExecutionImpl in the JPBM API docs, i had to check it from the source

                       

                      thanks again

                      • 8. Re: How can i get the execution pointer in a process?
                        Maciej Swiderski Master

                        could you post your unit test that fails?!