5 Replies Latest reply on Jan 6, 2010 8:21 PM by Ronald van Kuijk

    Getting the List of Subprocesses deployed

    T T Newbie

      We are trying to implement JBPM 4.2 for our next release. We have a requirement to display the list sub-processes as UI elements. At any point, we want to get the deployed sub-processes for a master process instance. Do we have an API to get all the nodes(including subprocesses, tasks, states) that are deployed as part of a process definition? I know that we can get the active executions but we need to display all the subprocesses at any time.

       

      Any help is appreciated.

        • 1. Re: Getting the List of Subprocesses deployed
          Ronald van Kuijk Master

          I've been looking a little into this, but every thing is way out of api usage. So you are completely on your own regarding support.

           

                  ProcessDefinition pd = repositoryService.createProcessDefinitionQuery().processDefinitionId(processInstance.getProcessDefinitionId()).uniqueResult();
                  Map<String, Activity> am = ((ProcessDefinitionImpl)pd).getActivitiesMap();
                  Set<String> as = am.keySet();
                  for (String string : as) {
                      Activity a = am.get(string);
                      if (a.getType().equals("sub-process")) {
                          System.out.println(    ((SubProcessActivity)((ActivityImpl)a).getActivityBehaviour()).....); // no option to get the sub-process-key
                      }
                      
                  }
          
          

           

          In the end, there are methods missing on SubProcessActivity to get the sub-process-key, so you can not display it, or check if it is deployed at all.

          1 of 1 people found this helpful
          • 2. Re: Getting the List of Subprocesses deployed
            T T Newbie
            Thanks Ronald. This was so helpful!!! I just tested the code and works fine for me....
            • 3. Re: Getting the List of Subprocesses deployed
              Ronald van Kuijk Master
              huh??? But you can't get to the sub process name... that is what you wanted right? So I'm very curious as how this was helpful
              • 4. Re: Getting the List of Subprocesses deployed
                T T Newbie

                I just changed the code to:

                 

                ProcessDefinition pd = repositoryService.createProcessDefinitionQuery().processDefinitionId(processInstance.getProcessDefinitionId()).uniqueResult();
                            Map<String, Activity> am = ((ProcessDefinitionImpl)pd).getActivitiesMap();
                            Set<String> as = am.keySet();
                            for (String string : as) {
                                Activity a = am.get(string);
                                if (a.getType().equals("sub-process")) {
                                    System.out.println(a.getName()); // no option to get the sub-process-key
                                }
                                if (a.getType().equals("task")) {
                                    System.out.println(a.getName()); // no option to get the sub-process-key
                                }
                               
                            }

                 

                 

                We need to get the sub process name or the DBID and this code gets me both. So we need the name to map it to the UI element.

                • 5. Re: Getting the List of Subprocesses deployed
                  Ronald van Kuijk Master

                  This does not give you the sub process name, it gives you the sub-process node name. The real process is a different attribute (see the code of SubProcessImpl in the source. But if you keep them manually the same, it does kind of work.

                   

                  But keep in mind... NO guarantees that this keeps working in future versions, since you use non-api things.