7 Replies Latest reply on Jul 17, 2009 9:43 PM by rujimethut

    jBPM 4 : Can we get Task by using ProcessInstance?

    rujimethut

      I am very new in jBPM. and starting up one new project using jBPM 4.
      We have problems understand its api uasge. help please.


      Is there anyway to get task instance by not using findPersonalTasks() or findGroupTasks()?

      We keep processInstanceId in our business model object. Can we use it to retrieve these values:

      1. all active Tasks which belong to this processInstance

      2.Process Definition which contains activity and Task definition


      I did search in the api and it is very limit to get these kind of information.


      Thank you.

        • 1. Re: jBPM 4 : Can we get Task by using ProcessInstance?
          rujimethut

          Or we have to keep taskId in our business model as well? if so how to get this taskId and assign it to our model?

          We want to do something like

          1. create new model
          2. start process
          3. assign processInstance and active taskIds to model.

          4.when user view/edit the business model we display process information(eg. history completed task, current task, future task) which belong to that process instance, and also offer button to take/complete the current Task (of course if that user is one of that task's candidates)

          Is it possible to to this in jBPM 4?

          • 2. Re: jBPM 4 : Can we get Task by using ProcessInstance?
            shekharv

            There was some discussion that the addition of this feature where you could pull the tasks related to a processInstance from within the TaskService API itself,
            I do not think this is in the release as yet,

            So in the meanwhile you could always do this, fairly simple and quick to implement:
            You could only assign the processInstance ID to your model and whenever you want to load tasks, you would use that value to fire off a custom query to jbpm4_task that would give you the list of tasks for that processInstance.

            something like:

            FROM Task t where t.PROCINST_ = ?

            get the drift?

            • 3. Re: jBPM 4 : Can we get Task by using ProcessInstance?
              rujimethut

              Thank you for your quick response, shekharv.
              Now I think I see the way to do it as your suggestion.

              One more question.

              1.When the process start, Does it create/persist all task defined int the process definition or it create/persist only the current active tasks?


              2.How does the jBPM keep orignal process definition?
              If It keep in database Is it possible to query and reconstruct?

              We just want to show user the simple process diagram like:
              previous task - current task - next task

              Thank you & appreciate your help

              • 4. Re: jBPM 4 : Can we get Task by using ProcessInstance?
                rujimethut

                Sorry those are 2 more question :)

                • 5. Re: jBPM 4 : Can we get Task by using ProcessInstance?
                  jbarrez

                  You don't have to rely on Hibernate/SQL queries. Acquiring tasks using a process instance id is covered by the API:

                  List<Task> tasks = taskService.createTaskQuery().processInstanceId(processInstanceId).list();


                  1.When the process start, Does it create/persist all task defined int the process definition or it create/persist only the current active tasks?


                  Tasks are only persisted when the process instance has arrived at the task activity.

                  2.How does the jBPM keep orignal process definition?
                  If It keep in database Is it possible to query and reconstruct?


                  The process definition is persisted in the database, as a deployment lob. So you can query it an reconstruct it (this is what the engine does).

                  • 6. Re: jBPM 4 : Can we get Task by using ProcessInstance?
                    shekharv

                    Yes!
                    This was not in CR!, but did make it to GA, I knew there was a discussion to add it, but then I guess I looked in the wrong place when I checked :P.

                    • 7. Re: jBPM 4 : Can we get Task by using ProcessInstance?
                      rujimethut

                      Yes, when I change from CR to GA I can see the api of querying task by the process Id




                      Thank you all for your help.