12 Replies Latest reply on Jun 13, 2007 11:17 AM by roccolocko

    Canceling an task instance

    ricardomarques

      Hi Guys

      I want to cancel a task without ending it. But from the code on TaskInstance.java I can't see how can I do that out of the box.

      What I need to do is: a user start's a work on a task but then cancel's it, and the task doesn't signal and return's do the user tasklist.


      Thanks in advance.

        • 1. Re: Canceling an task instance
          kukeltje

          you don't... if you do not do a transition or a cancel in the api, it stays in the tasklist. So a 'cancel' on the user level means doing nothing in with the api. Look at the webconsole source .... has this identical functionality

          • 2. Re: Canceling an task instance
            ricardomarques

            yes, but if I cancel it from the API, the task instance is terminated and it moves to the next node. I want that it stays in the same node, where the cancel action was called.

            • 3. Re: Canceling an task instance
              kukeltje

              that is why I said you do NOT cancel it on the api, just do NOTHING.

              • 4. Re: Canceling an task instance
                ricardomarques

                Sorry I haven't get that. But doing so... I get the task instance out of the tasklist, i think that is because i'm starting the work on the task, and leave it open.

                • 5. Re: Canceling an task instance
                  kukeltje

                  ?????

                  • 6. Re: Canceling an task instance
                    ricardomarques

                    Probally my english wasn't clear, let me try again.


                    If I do nothing, the task doesn't continue, but also doesn't appear on my tasklist, do i need to suspend or resume ? Or those methods aren't fit to that?

                    • 7. Re: Canceling an task instance
                      kukeltje

                      your english was clear... You cannot get tasks out of your own tasklist. They are always in there. I'm not sure what you mean by 'leave it open'. if it is open (from my point of view) it is in your tasklist. So please show some code on what you are trying to achieve

                      suspending and resuming are on a completely different level.


                      • 8. Re: Canceling an task instance
                        ricardomarques

                        For now... I had resolved the problem the following way (not sure that's the correct one), until now I get a task from the task list then start the work on the task and when the user had filled up the form i ended the task. This was giving me problems on canceling (if doing nothing), because on the moment that I start the work on the task using this code:

                        Command cmd = new StartWorkOnTaskCommand(getTid(), false);
                        Object result = getEjbClient().getCommandService().execute(cmd);
                        


                        When i retrive the task list using:

                        try {
                         cmd = new GetTaskListCommand(name,true);
                         List result = (List) getEjbClient().getCommandService().execute(cmd);
                        
                         DataModel data = new ListDataModel(result);
                         return data;
                         }
                        


                        I haven't the task on the tasklist (visible at least).

                        I had resolved the problem by starting the work and ending the work when user submit's the form. Probally i'm going to optimize this to make only one call to the ejb.



                        • 9. Re: Canceling an task instance
                          kukeltje

                          ahh... ok... you use the command interface. Could be a bug in the implementation of the GetTaskListCommand. Maybe that returns only unstarted tasks.

                          This is exactely the reason that it is most of the time better to also post code....

                          • 10. Re: Canceling an task instance
                            ricardomarques

                            Ok, thanks for the feedback.

                            • 11. Re: Canceling an task instance
                              kukeltje

                              I just had a look and cannot find a reason for the behaviour you see. The implementation in both commands seems correct.

                              • 12. Re: Canceling an task instance
                                roccolocko

                                Once you get a task, you don't have to do anything to start using it. And only when you're done you have to make an END or a CANCEL if you wish, but if you DO NOTHING like kukeltje said, your task should be exactly in the same place where you left it.
                                Perhaps if you post a little code of what your doing.