7 Replies Latest reply on Sep 25, 2008 10:22 PM by shansari

    Current state of the process instance using APIs

    shansari

      Hi,

      How to get the current status of the process instance using APIs.

      I need to start the process, if it is not running.
      I need to signal the tasks in the process, if the process is already running.

      Kindly help to get API listing to get this.

      With Regs
      :Ansari S.H

        • 1. Re: Current state of the process instance using APIs
          kukeltje

          look at the testcases in the source. many 'examples' of these kinds of things

          • 2. Re: Current state of the process instance using APIs
            shansari

            Hi Ronald,

            Thanks for your response.
            I read through the examples.

            Shows create the process instance first, on same process manipulates the nodes traversal.

            I'm trying to get the process instance of the process already running.

            I'm using the below code
            JbpmConfiguration jbpmConfiguration = JbpmConfiguration.getInstance();
            jbpmContext = jbpmConfiguration.createJbpmContext();
            GraphSession graphSession = jbpmContext.getGraphSession();
            ProcessDefinition pd = graphSession.findLatestProcessDefinition(processName);
            ProcessInstance processInstance = jbpmContext.getProcessInstance(pd.getId());
            System.out.println(" processInstance :"+processInstance);

            I'm getting process instance is null.

            Kindly help

            With Regs
            :Ansari S.H

            • 3. Re: Current state of the process instance using APIs
              kukeltje

              The result you get is correct in combination with the wrong way of using it. There is a difference between a definition and instance. You cannot use the id of a definition to load an instance this way. Instances have there own id when you start an instance

              • 4. Re: Current state of the process instance using APIs
                shansari

                Hi Ronald,

                Thanks for your response.

                When I tried to get the Process Instance from the Process definition, I do get the process Id, what I see in the Web Console.

                Kindly help me to get the right APIs to get the ProcessInstance, So as I can get the current status.

                With Regs
                :Ansari S.H

                • 5. Re: Current state of the process instance using APIs
                  kukeltje

                  WHAT process instance? There can be hundreds, thousands of process instances for ONE process definition... So gettging THE process instance is kind of hard?

                  Normal usage is that you have a 'business key' in your domain model and set that in a process instance when you start it. You can retrieve THAT SPECIFIC process instance then by using that key.

                  • 6. Re: Current state of the process instance using APIs
                    kukeltje

                    but if you want them ALL (which I cannot imagine in a running server) you can use something like

                    jbpmContext.getGraphSession().findProcessInstances(processDefinitionId);

                    • 7. Re: Current state of the process instance using APIs
                      shansari

                      Hi Ronald,

                      Thanks a lot, It works.

                      In our requirement, at any point of time that particular process will be having one process instance or zero.

                      With Regs
                      :Ansari S.H