4 Replies Latest reply on Sep 28, 2010 11:01 AM by Kareem Ergawy

    Process Definition MetaData

    Kareem Ergawy Newbie

      Hi All,

      I want to know how to explore the metadata of a particular process definition in jBPM4. Actually I know about the task service and that I can use it to search for tasks in the currently running process instances. But what I need is how to know what tasks in a particular process definition with creating a process instance of that definition. I tried to search to forum but I found nothing about that.

      Sorry if my question sound naive but I tried whatever I can

        • 1. Re: Process Definition MetaData
          HuiSheng Xu Master

          Hi Kareem,


            Do you mean that you want a way to query process definition?  I suggest you to have a try ProcessDefinitionQuery.

          • 2. Re: Process Definition MetaData
            Kareem Ergawy Newbie

            Thanks for your reply. I know about ProcessDefinitionQuery. But the problem is that ProcessDefinition object doesn't contain any methods to get the nodes (tasks) in the process definition. That's what I need to know.

            • 3. Re: Process Definition MetaData
              Michael Wohlfart Expert

              i guess what you want to do is something like this:


              public class ProcessDefinitionTaskQueryTest extends JbpmTestCase {
                public void testQueryProcessDefinitionTasks() {
                    "<process name='findMyTasks'>" +
                    "  <start name='start' />" +
                    "  <task name='do something' >" +
                    "  </task>" +
                    "  <task name='do something else' >" +
                    "  </task>" +
                  ProcessDefinitionImpl processDefinition = (ProcessDefinitionImpl) repositoryService.createProcessDefinitionQuery()
                    .processDefinitionKey(QueryOperator.EQUALS, "findMyTasks")
                  Map<String, ?> activities = processDefinition.getActivitiesMap();
                  Set<Entry<String, ?>> entries = (Set)activities.entrySet();
                  for (Entry entry : entries) {
                    System.err.println(entry.getKey() + " -> " + entry.getValue());


              this gives you the task nodes and the start node:


              do something -> activity(do something)
              do something else -> activity(do something else)
              start -> activity(start)

              • 4. Re: Process Definition MetaData
                Kareem Ergawy Newbie

                Thanks a lot Michael your solution solved my problem