8 Replies Latest reply on Mar 30, 2006 9:34 AM by david.trattnig

    How to get the current node-type?

    david.trattnig

      Hey!

      I hope you could help: how can i get the type of the current node from a given Process Instance. I'd like to check if it is a "Node" or a "Task Node". if the "Task Node" matches I'd create a new Task Instance and assign it to a user.
      Or is there a better way to do this?

      Thanks in advance!

      Regards,
      david

        • 1. Re: How to get the current node-type?
          camunda

          Hi David,

          why do you not use the standard jbpm way?

           <task-node name="MyTask">
           <task swimlane="Group"/>
           <transition name="RETRY" to="A"></transition>
           <transition name="DONE" to="B"></transition>
           </task-node>
          


          Then a TaskInstance is automatically created for you by jbpm!

          By the way: You can get the Node-Type by the jbpm API, just look which type (Class) the Node has...

          • 2. Re: How to get the current node-type?
            david.trattnig

            Thanks a lot for your reply.

            Yes, i also thought about the way to define the task in the process definition. But then i've the same problem: The task is created automatically, but then I've to assign it to a user at runtime. In other words: Not later than now I need to know at which node the Process Instance is - If task node --> assign the task.. with your mentioned "class lookup".

            anyway, is there a better way?

            thx again.
            david

            • 3. Re: How to get the current node-type?
              aguizar

              The way Bernd proposes is the right one. You can use an assignment handler which jBPM will invoke at runtime so that you can assign your task to suit your needs.

              The jBPM user guide, section 11.3, Assignment describes the jBPM task assingment model in detail. Please take a look at it and let us know if it fulfills your needs.

              • 4. Re: How to get the current node-type?
                david.trattnig

                I've got a dialog where the user chooses if he/she wants to create a pooled task or a task for a specific user of the predefined group.

                When the user submits, I perform the "signal()", the task node will be enterd and the assignment handler will be called. Right? But where I get the previously defined User-Assignment-Data from (In the Assignment Handler)?

                • 5. Re: How to get the current node-type?
                  david.trattnig

                  Is there nobody who assigned a task to a user/group by user's choice? I mean the assignment should not be done automatically by the AssignmentHandler.

                  @alex.guizar: This issue isn't captured by the Assignment-Section of the user guide isn't it?

                  • 6. Re: How to get the current node-type?
                    koen.aers

                    David,

                    In this case, you should set the createTasks attribute of the task node to false and create and assign the tasks in an actionHandler you associate with the node-enter event of the task node.
                    The actionHandler has access to all the variables of the processinstance through the execution context. So you can store the user's choice in a variable and retrieve it in the actionHandler to perform the task creation and assignment.

                    Regards,
                    Koen

                    • 7. Re: How to get the current node-type?
                      david.trattnig

                      Thank you Koen,
                      you helped a lot.

                      Regards,
                      david

                      • 8. Re: How to get the current node-type?
                        david.trattnig

                        Look here: http://jboss.org/index.html?module=bb&op=viewtopic&p=3933716#3933716
                        ...If you also want to create & assign a TaskInstance in an Action-Handler --> there are several problems with this issue!

                        Cheers,
                        david