9 Replies Latest reply on Aug 13, 2007 9:20 AM by Donald Warf

    task-node attribute create-tasks

    Donald Warf Newbie

      I'm currently working in a jbpm3.1.3 environment. I have run into an unexplained behavior with the create-tasks attribute of the task-node element.

      In a process definition where task-nodes do NOT contain this attribute, instantiating a new process instance and task instances, then signalling the processinstance, works as expected. It reaches the end state and creates new taskinstances along the way.

      In a process definition where task-nodes DO contain this attribute, instantiating a new process instance and task instances, then signalling the processinstance, does not work as expected. It ignores the transitons included in the signal and takes the default transition for every task node.

      The only difference is the addition of the create-tasks attribute using the eclipse plugin.

      Any and all ideas, suggestions, or criticisms are welcome.

      dhw



        • 1. Re: task-node attribute create-tasks
          Arjun Balraj Newbie

          If i understand this right, when you specify the create-tasks attribute for a task node in the process defintion, it automatically creates a taskinstance when the processinstances enters the node. Then it depends on the signalling flag(Rule to exit the node on task completion) of the node 'last', 'last-wait' etc to exit the node to the specified transition.

          If the create-task attribute is specified, all you got to do it get it from the list of taskinstances using TaskMgmtInstance. If you create a taskinstance on your own in this case, you will have duplicate taskinstances and the node will not exit until both are completed.

          Hope this helps!

          • 2. Re: task-node attribute create-tasks
            Donald Warf Newbie

            I'll try to explain better.

            When I *do not* specify the "create-tasks" attribute, a new taskinstance is created when the processinstance enters the task-node. This is as expected, but not what I'm trying to accomplish.

            When I *do* specify the "create-tasks='false'" attribute within the task-node element, *no* taskinstance is created when the processinstance enters the task-node. This is the behavior I'm looking for.

            What I'm not clear on is why the processinstance then takes the default transitions intead of the transitions specified in processinstance.signal(mytransition).

            Hope this clarifiies my question.

            • 3. Re: task-node attribute create-tasks
              Ronald van Kuijk Master

              could be just a bug... look in the sourcecode if you can confirm this is a task created manually via the api after the nod e nas been entered or not?

              • 4. Re: task-node attribute create-tasks
                Donald Warf Newbie

                A good point "...after the node has been entered...". The api is used to:

                ProcessInstance pi = context.newProcessInstanceForUpdate("myProcess");
                 pid = pi.getId();
                 context.close();
                
                context = getContext();
                
                 ProcessInstance pi = context.getProcessInstance(processInstanceId);
                
                 TaskMgmtInstance tmi = pi.getTaskMgmtInstance();
                
                 TaskMgmtDefinition tmd = tmi.getTaskMgmtDefinition();
                
                 Task t = tmd.getTask(taskName);
                
                 TaskInstance ti = tmi.createTaskInstance(t);
                 ti.setActorId(actorId);
                 ti.setName(taskInstanceName);
                 ti.setDescription(taskInstanceDescription);
                 ti.start();
                
                 context.save(ti);
                 context.save(pi);
                 context.close();
                
                


                This happens programmatically before the processinstance has been signalled to leave the start state. The big picture is that for any given processdefinition (project) we want to post a list of all the taskinstances associated with it.

                So in answer to your question, no, the task has not been created manually w/api after the node was entered. It was created manually w/api before the node was entered. Bug had not crossed my mind. It was more of a "I'm not using it correctly" concern.

                • 5. Re: task-node attribute create-tasks
                  Donald Warf Newbie

                  It seems that the task instance is not getting acknowledged even though the association in the db seems to be correct.

                  • 6. Re: task-node attribute create-tasks
                    Donald Warf Newbie

                    On the chance that the taskinstance is not associated with the processinstance, I tried to add the taskinstance after entering the task-node. The error message indicates it is already associated:


                    Caused by: org.hibernate.NonUniqueObjectException: a different object with the same identifier value was already associated with the session: [org.jbpm.taskmgmt.exe.TaskInstance#2656]


                    Comments, criticisms or advice welcome.

                    • 7. Re: task-node attribute create-tasks
                      Donald Warf Newbie

                      Resolved the problem by not creating the taskinstance before processinstance enters the task-node.

                      Thanks for the suggestions and comments.

                      • 8. Re: task-node attribute create-tasks
                        Ronald van Kuijk Master

                        hey... when I said 'could be a bug' I meant could be a bug on OUR side... eventually you solved it yourself. Thanks btw for reporting back in detail so others can learn.

                        • 9. Re: task-node attribute create-tasks
                          Donald Warf Newbie

                          Your welcome, though the thanks are due to you, since it was your suggestion that pointed me in the direction of the solution.

                          'til next time.