6 Replies Latest reply on Dec 10, 2009 11:47 AM by sri r

    Extracting information from a jpdl file

    Ajay Gautam Newbie

      I have a state diagram in a jpdl file.

      I need to extract possible transition strings from the current state, so that the UI can figure out which string to send back to the jbpm process.

      Can't seem to find an easy way to do this.
      What am I missing? Its seems to be a basic thing to do.

      Any help / pointers will be greatly appreciated.

      Thanks

      Ajay
      (Using jbpm 4.2)

        • 1. Re: Extracting information from a jpdl file
          Sebastian Schneider Master

          Should be a basic thing to do but the API does not offer it yet. However there is a JIRA issue about it and it should be included in the upcoming 4.3-release.

          Please vote here and maybe also state your use case:
          https://jira.jboss.org/jira/browse/JBPM-2609

          I don't know if there is a workaround right now.

          • 2. Re: Extracting information from a jpdl file
            Santanu Saraswati Novice

            It is possible to get the outcomes if your current wait node is a task node. Since task node is the node for manual tasks, it might somewhat serve your purpose. This is the code for getting outcome for a task node:

            taskService.getOutcomes(task.getId())
            


            If the wait node is some other wait node like "state" node, then there is no standard way to get the outcome. However you can still manage to get them, but the code may not look as clean.

            //executionImpl can be obtained in multiple ways
            //typically it can be obtained by type casting current process instance
            //ExecutionImpl executionImpl = (ExecutionImpl)processInstance;
            executionImpl.getActivity().getOutgoingTransitions();
            



            • 3. Re: Extracting information from a jpdl file
              Sebastian Schneider Master

              Thanks for clarifying this, Santanu. For the workaround you have supplied IMHO there should be a "clean" way to do it using the API. If you have not yet done it maybe you want to vote for the issue.

              • 4. Re: Extracting information from a jpdl file
                Ajay Gautam Newbie

                Thanks Santanu.

                getOutcomes does work, but the overhead of convert states to tasks is way too much...

                getOutgoingTransitions() always returns an empty list! - I think its broken - or maybe I am not using it correctly.

                Anyway...

                The requirement has changed: Now, we (me) need to supply the UI with the entire map at startup. As in: The UI starts up, and requests for the "action map" -> which is a list of who can perform which transitions.

                Unfortunately, I cannot find any easy way of storing role information with the diagram itself: the who can do what part. So, for now, I am thinking of adding an "allowedRoles" to each transition element. Will have to parse the jpdl file myself to get this information out of the file, but I will have all the data in one place.

                The unfortunate downside is that I won't be able to use the UI to edit the jpdl diagram...

                Is there an alternative way?

                Thanks

                Ajay

                • 5. Re: Extracting information from a jpdl file
                  Santanu Saraswati Novice

                  Sebastian,
                  I completely agree with you. The code I have given there is nothing more than a work around. There should be some method may be part of either Execution/OpenExecution interface and/or ExecutionService which does the job properly. And I have already voted for the issue.

                  Ajay,
                  If your requirement is to show all the tasks possible by an user even if the task is not currently active, then that will be fairly difficult to achieve. Data model of Jbpm4 does not support that. So you will have to change there. Since "Task" is the representation of manual tasks in Jbpm4, it makes sense to have actors/roles/swimlanes for tasks. Actors with something else does not make much sense.

                  • 6. Re: Extracting information from a jpdl file
                    sri r Newbie

                    If you are using spring, then it should be easy with getoutcomes as well.. just cache at application level using aop the following items - initial state, transition to outcome state, process definition and version