1 2 Previous Next 21 Replies Latest reply on Jun 3, 2008 10:02 AM by pochi Go to original post
      • 15. Re: Dynamic task creation

         

        "scull" wrote:
        hello massimiliano_cuccia
        I see you
        I recommend you, that you should create an ActionHandler and asosiate it with node-enter event in tasks nodes after fork-node


        Scull, doesn't work, or maybe I don't understand.

        The node after fork-node is ChiusuraInterpello.
        I moved the actionIstruttoriaInterpello to the node-enter of ChiusuraInterpello, But doing so, the actionChusuraInterpello is ignored.

        After this test I commented all the code of actionIstruttoriaInterpello, the action actually just do some output. It seems that the dynamic creation of the tasks generates some problem to the process instance ... but i don't understand.

        • 16. Re: Dynamic task creation
          pochi

          hello massimiliano_cuccia ,
          sorry my english is bad.
          You have reason.

          "the dynamic creation of the tasks generates some problem to the process instance"

          i was testing the task creation through action hanlders after a fork-node and this not work.

          First i create one tasknode before a fork and 2 tasknodes after the fork and asociate 1 ActionHandler in node-enter event per taskNode.

          In constructor's of task after the fork i put some outputs for trace the execution e.g( " building action handler 1", and "building action handler2"). Late in the exute method i put all code for task creation and some outputs for trace it e.g("execute method 1", and "execute method 2").

          Later i cerate a process instance and few taskIntances before a fork node with signal="first-wait" and run this code and the output is in this order

          "building action handler 1"

          "building action handler2"

          "execute method 1"

          and the the output never show "execute method 2" , but the ActionHandler create a taskInstance.

          this is for the first taskInstance finish in the node before the fork, but when i end oder taskInstance in that node the execution NOT create anything in oder tasknodes.
          I have an idea but, i'm not test it yet.
          i go to create nodes after fork and then i go to create
          the TaskNodes.

          Test it

          sorry is my english is Bad






          • 17. solved - Re: Dynamic task creation

            Scull, I doesn't understood. But now It works.

            At the end of all my attempts I resolved. Continue reading to know all the story.. Hope this will help someone.

            I moved The action that creates all the dynamic tasks to the node-enter of the task to "clone" (if you followed the example in the previous post, the task in tCompDoc)
            This is the code of dynamic creation:

             Token token = executionContext.getToken();
             TaskMgmtInstance tmi = executionContext.getTaskMgmtInstance();
             TaskNode taskNode = (TaskNode) executionContext.getNode();
             Task task = taskNode.getTask("task compilazione");
             TaskInstance taskInstance = tmi.createTaskInstance(task, executionContext);
             taskInstance.setActorId(user);
            

            But the important part of this is the execution point. Remembar "node-enter of the cloning task". Elsewhere will cause errors and token scramble.

            In my sample I need a task to close every dynamic task created early, still not ended, I put this code to the node-leave of chiusura-interpello.
            This is the relevant part of code:
             if (!ti.hasEnded())
             ti.cancel();
            


            thanks to every one helped me to achieve this goal
            Hoping this will help someone else.

            If you have any question, ask.
            bye

            • 18. Re: Dynamic task creation
              pochi

              Hello massimiliano_cuccia,

              thank you for your reply a was to test it.

              • 19. Re: Dynamic task creation
                pochi

                Hello massimiliano_cuccia

                I cant pu to work my process yet, I test it with your code but not work,
                and i'm not understand you whit

                if(!ti.hasEnded())
                ti.cancel()

                please help me.

                • 20. Re: Dynamic task creation
                  pochi

                  Hello for all,

                  i go to explain again my problem, there is my proccess

                  <process-definition xmlns="urn:jbpm.org:jpdl-3.2" name="Flujo">
                  
                  
                   <start-state name="start-state1">
                   <transition to="crear_tarea"></transition>
                   </start-state>
                  
                  
                   <task-node name="crear_tarea" signal="first-wait" create-tasks="false" >
                   <task name="crear_tarea"></task>
                   <event type="node-enter">
                   <action class="com.ahora.CrearTareaHandler"></action>
                   </event>
                   <transition to="fork1" name="to_fork1"></transition>
                   </task-node>
                  
                   <fork name="fork1">
                   <event type="node-leave"></event>
                   <transition to="redactar_tarea" name="to_redactar_tarea"></transition>
                   <transition to="tomar_fotos" name="to_tomarFotos"></transition>
                   </fork>
                  
                   <task-node name="tomar_fotos" signal="first-wait" create-tasks="false" >
                   <task name="toma_fotos"></task>
                   <event type="node-enter">
                   <action class="com.ahora.CrearTareasFotografoHandler"></action>
                   </event>
                   <transition to="revisar_fotos_ej"></transition>
                   </task-node>
                  
                   <task-node name="redactar_tarea" signal="first-wait" create-tasks="false" >
                   <task name="redactar_tarea">
                   </task>
                   <event type="node-enter">
                   <action class="com.ahora.CrearTPeriodistasHandler"></action>
                   </event>
                   <transition to="revisar_tareas_ej" name="to_revisar_ej"></transition>
                   </task-node>
                  continue ....
                  

                  In my first task node "crear_tarea" i create many taskInstances for one user( work fine ), after that, this user perform the first task in your task list and the execution continue ok and create 1 task in "tomar_fotos" and 1 task in "redactar_tarea"( work fine), but when the user perform the second task in "crear_tarea" the execution ignore the action handlers in "tomar_fotos" and "redactar_tarea" and not create the taskInstances in thats taskNodes. Finally the execution create on task peer node("redactar_tarea" and "tomar_fotos" ) when the user perform your first task in "crear_tarea" but ingore that when the user perform another of your tasks in "crear_tarea".

                  Please Helpmeeee

                  • 21. Re: Dynamic task creation
                    pochi

                    i'm waiting for your replies

                    1 2 Previous Next