10 Replies Latest reply on May 8, 2014 1:18 AM by cescobar

    how to a Human Task by using the kie API

    cescobar

      Hi everyone,

       

      I have 2 questions:

       

      1) Does someone know how to reject a human task by using jBPM 6 by using kie API. I am using MySQL 5 as DB and deployed on jBoss 6 eap.

       

      2) Why does Task table always has the taskInitiator_id null when every task is created.

       

       

      P.D.  I used as a base the rewards-basic web application example.

        • 1. Re: how to a Human Task by using the kie API
          arif.mohammed

          What do you mean by rejecting, can you be more specific ? You can go through the API documentation for org.kie.api.task.TaskService and see which methods you can use.Along with that you can go through the task life cycle diagram(see attachment). I believe you might need fail/exit methods and for that you need to have taskId and userId. Following is the code fragment to get the TaskService object

           

          RuntimeEngine engine = runtimeManager.getRuntimeEngine(ProcessInstanceIdContext.get(processInstanceId)); //In case if you are using session per process instance strategy.Where processInstanceId is the id //associated to process for this task and runtimeManager depends on how you configure jBPM in your environment.

           

          TaskService localTaskService = engine.getTaskService();

          localTaskService.fail(taskId,userId,null);

          1 of 1 people found this helpful
          • 2. Re: how to a Human Task by using the kie API
            cescobar

            Hi Arif,

             

            Thanks for you soon respond.

             

            I actually need a method to revoke the current task to previous state.  The fail method does that? Or there is another method to do it?

            • 3. Re: how to a Human Task by using the kie API
              arif.mohammed

              Hi Carlos,

               

                 I dont think so you can goto previous state in human task as per the task life cycle. But I will leave it to experts to provide advice.

              • 4. Re: how to a Human Task by using the kie API
                cescobar

                Hmmm... But How can I revoke a task? what would be the method from taskService?

                • 5. Re: how to a Human Task by using the kie API
                  calca

                  mmm what do you mean by go back to a previous state? could you please give an example of what you are trying to achieve?

                   

                  You can release a task that is assigned to someone, which will go back to reserved state (this is the human task life cycle http://dcalca.files.wordpress.com/2011/05/screenshot-11.png?w=645&h=438). But I am not sure what you are trying to achieve..

                   

                  Demian

                  • 6. Re: how to a Human Task by using the kie API
                    cescobar

                    Hi Demian,

                     

                    I wan to achieve the following, for example:

                     

                    1. Task A assigneed to Carlos with status "Ready".  When Carlos completes it, this task automatically is assigneed to the following actor (Mary)

                    2. Now Task B  assigneed to Mary with status "Ready", in this case I want to return or revoke or reject this task to Carlos again, due to the task does not accomplish with some criterials.

                    3. When Carlos logs in, its task list will show the task again with status Ready, which was completed before.

                    • 7. Re: how to a Human Task by using the kie API
                      lakshjee

                      Hi Carols,

                      I think this will be useful..

                      1. first you need to add "Database Exclusive Gateway" in between start node and Task A.

                      2. Then you need to again add "Database Exclusive Gateway" in between Task B and End node.

                      3. The gateway which connect to end node should be connect to first gateway which is connected to Task A.

                      4. All gateways should have three directions connectivities.

                      5. The add following scripts to the second gateways if it is completed then go to end ("return KieFunctions.isTrue(TaskA.getApproval())==true;") (please note that this is an example and you have to create TaskA and .Approval in the data modeler.

                      6. if it is rejected then add this script to the directions of the second gateway which is connected to first gateway ("return KieFunctions.isTrue(TaskA.getApproval())==false;")

                       

                      your diagram should be as follows.BP.jpg

                      • 8. Re: how to a Human Task by using the kie API
                        cescobar

                        Thanks so much

                        Jeewani Lakshani

                         

                        I will try this.. that makes sense for me

                        • 9. Re: how to a Human Task by using the kie API
                          arif.mohammed

                          But keep in mind if the out come of task B is negative(in your case rejecting) it will complete the instance of Task B and will create a new instance of Task A in DB. You can not change the state of Task B instance nor Task A instance to previous state. Hope you understood that.

                          • 10. Re: how to a Human Task by using the kie API
                            cescobar

                            Hi everyone.

                             

                            I have the following issue when I complete a user task. The flow should get to conditional gateway as the picture below.

                             

                            But the problem is no matter what values the variables values into the condition, The flow always goes to sequence named "Rejected".

                            Please someone has any idea which will be the problem

                             

                            Thanks in advance.

                            Screenshot from 2014-05-07 23:48:13.png

                             

                            Screenshot from 2014-05-08 00:06:37.png