10 Replies Latest reply on Jun 25, 2012 9:50 PM by gigazhang

    How to get taskId defined in BPMN file

    devinderpal

      First I thought it should be fairly simple to get ID of the node defined in bpmn file. But doesn't seem like that.

      Basically I want to get task ID of the current node that's been active in the processInstance. Not the long value which is returned from TaskSummary or from NodeInstance object. But the String value defined in BPMN file. For instance, from below example,  I want some method that returns "_2", given NodeInstance or ProcessInstance objects

       

      <userTask id="_2" name="Self Evaluation">

       

      Anyone has ideas?

        • 1. Re: How to get taskId defined in BPMN file
          swiderski.maciej

          If you would like to get this in on-entry or on-exit action I believe you could do something like this:

           

          kcontext.getNodeInstance().getNode().getId();
          

           

          HTH

          • 2. Re: How to get taskId defined in BPMN file
            devinderpal

            But this method doesn't return string id specified in bpmn file. It returns some long value. Please let me know if you have any other ideas.

            • 3. Re: How to get taskId defined in BPMN file
              salaboy21

              Why do you want that ID? I'm sure that you can resolve your problem without it   I just want to know the background of your request in order to understand if you are approaching it correctly.

              Cheers

              • 4. Re: How to get taskId defined in BPMN file
                swiderski.maciej

                aaa, right to get the id from the bpmn tag you should use:

                 

                kcontext.getNodeInstance().getNode().getMetaData("UniqueId");

                 

                but Mauricio point is very good cheers

                • 5. Re: How to get taskId defined in BPMN file
                  salaboy21

                  hehe.. I think maciej get the background of my question.. If you base your application on the model internal IDs and then you someone changes the model, remove and add a node later on, you application which uses the models ID will explode in a billon pieces   to put it in a nice way

                  • 6. Re: How to get taskId defined in BPMN file
                    devinderpal

                    I want to keep some mapping between web pages to be shown and corresponding id defined in BPMN file. I want to show a different web page for user to feed in data based on what human task is pending. Once I define this mapping, I can get HTML page to be shown based on the id of the pending human task. ID defined in BPMN file is the only task ID I have. Other long IDs that are generated by jBPM engine can't be used for this mapping, as I don't know what's the algorithm for generating those IDs. And I didn't really get your logic of why application with blow up. IDs are defined manually by a developer who writes the BPMN file, why will it change while adding other nodes?

                    • 7. Re: How to get taskId defined in BPMN file
                      devinderpal

                      Thanks Maciej,

                        It works!

                      • 8. Re: How to get taskId defined in BPMN file
                        salaboy21

                        "I want to keep some mapping between web pages to be shown and corresponding id defined in BPMN file" That doesn't sounds as a good idea...

                        When you say: "IDs are defined manually by a developer who writes the BPMN file" this is true when you have a controlled scenario that will never change. The IDs will change because if you remove and add a new one with the graphical editor the ID will be incremented and the new node will not have the old ID. As you mention you cannot rely on the other ID (the long one) because you don't know the algorithm used to generate that. You are creating a strong binding from the process to the BPMN file which is not a good idea. Why not using a Task List Oriented Approach, where the user picks the tasks from a list of pending tasks, and if the user just have one task, that task is automatically displayed?

                         

                        Cheers

                        • 9. Re: How to get taskId defined in BPMN file
                          devinderpal

                          i have been using Eclipse based BPMN editor, one mentioned in jBPM docs, and it never changes the task IDs already defined in the BPMN file. It would be a bad idea for any editor to change existing IDs of BPMN file when a file in imported. In my view, it's will be a bad  editor design. Hopefully, we wouldn't come across that kind of editor

                          • 10. Re: How to get taskId defined in BPMN file
                            gigazhang

                            If I got the id,,maybe can create a path to any other node...