4 Replies Latest reply on Jan 21, 2013 7:43 AM by Thomas Setiabudi

    How to show process diagram displaying all nodes executed in that process instance?

    Thomas Setiabudi Expert

      Hi,

       

      How do we show a process diagram displaying not just the current active node (like the one in jbpm-console), but also displaying / marking all the nodes that has been executed in that given process instance.

       

      The goal is to give the user a good idea on how this process instance executed or what are the path taken in this process instance.

       

       

      I think of some ways to do this:

      1. parsing the bpmn process definition, store all the x, y, width, and height of nodes in a table, later on, join this table with NodeInstanceLog and then somehow use the x and y coordinates to overlay a picture or div on top of static png process image.

       

      2. I am not sure about this, but maybe it is possible to use the process designer, display the process and put some overlay there based on information I got in NodeInstanceLog. Possible? how?

       

       

      Anyone has a solution for this?

       

       

       

      Regards,

      Thomas Setiabudi

        • 1. Re: How to show process diagram displaying all nodes executed in that process instance?
          Murat Kilic Newbie

          I am also  working on something similar. My project requires showing the completed node information and the upcoming potential owners. I got the idea of overlaying the image file by an icon (red triangle) from the console using different z-indexes. Current active nodes info added to the data found in NodeInstanceLog should provide much of the information required.

           

          I am assuming one can parse the bpmn file using an xml parser, but I would prefer using KnowledgeBase APIs to find out the nodes, node parameters and metadata. You can get height,width,UniqueId,y,x  using org.drools.definition.process.Node.getMetaData()  (http://docs.jboss.org/jbpm/v5.3/javadocs/org/drools/definition/process/Node.html).

           

          By the way, WorkItemInfo does not keep completed task data, so when a task is completed, there is no way to know who executed task of  a certain node. What I am doing is storing the actor information  (processInstanceId,nodeId,actor) in a table just before an actor is completing the task before it is lost forever.

           

          Where I am struggling is getting potential owners from the process definition.I know potentialOwners does not represent the actual actor that will be completing a task but it would be nice to be able to show who (person or group) is tasked to do certain work. So far I have not found a method that provides this.

          • 2. Re: How to show process diagram displaying all nodes executed in that process instance?
            Tihomir Surdilovic Master

            If you are using jBPM Designer to model your processes you can genearte and save the process image as SVG or PNG. With SVG you can then either do your own overlays using one of many SVG manipulation libs, use existing open source projects such as https://github.com/esteban-aliverti/jBPM-Process-Image-Processor or use the jBPM Designer JS api to dynamically overlay things ontop of it.

             

            HTH

            1 of 1 people found this helpful
            • 3. Re: How to show process diagram displaying all nodes executed in that process instance?
              Shobhit Tyagi Master

              There you go :

              //You probably have just the process instance id. so you need to get teh proc def id
                String processDefId = JPAProcessInstanceDbLog.findProcessInstance(Long.parseLong(processInstanceId)).getProcessId();
              // And process name to get a process object. I maintain an XML file to map process ids with process names and process image file names. So that i dont have to hard code process id or name anywhere. You can get the name whichever way you like...
                String processName = ........
                logger.info("Process Name : "+processName);
              // FInally you need a process object. using process def id and process name.. 
              // read your knowledge base feeding it your process name
                readKnowledgeBase(processName);
                process = kbase.getProcess(processDefId);
              
              //Now you can get the nodes and coordinates using following code.  
                ArrayList<Object> coordinates = new ArrayList<Object>();
                try
                {
                 List<NodeInstanceLog> nodeInstanceLogList;
                 for (Node node : (Node[])((WorkflowProcessImpl) process).getNodes())
                 {
                  nodeInstanceLogList = JPAProcessInstanceDbLog.findNodeInstances(Long.parseLong(processInstanceId), new Long(node.getId()).toString());
                  if(nodeInstanceLogList.size() == 1)
                  {
                   logger.info("Name of the Node : "+node.getName());
                   coordinates.add(node.getMetaData().get("x"));
                   coordinates.add(node.getMetaData().get("y"));
                   coordinates.add(node.getMetaData().get("height"));
                   coordinates.add(node.getMetaData().get("width"));
                  }
                 }
                 coordinates.add(processName);
                }
              
              

              Code above gives you the coordinates of the active workitem.

               

              In your jsp you can have an image of your process in a div and another div to create a box or an arrow or whatever using the coordinates from the method above.

               

              Regards.

              1 of 1 people found this helpful
              • 4. Re: How to show process diagram displaying all nodes executed in that process instance?
                Thomas Setiabudi Expert

                Thank you for all the answers

                 

                I will give it a try

                 

                 

                Regards,

                Thomas Setiabudi