6 Replies Latest reply on Feb 27, 2013 4:58 AM by Rahul Agrawal

    NodeInstanceLog and Human Tasks relationship

    Rahul Agrawal Newbie

      How to get the data about who acted on a task using the NodeInstanceLog Table.


           The NodeInstanceLog table will give the entries about a processInstance regarding the nodes that were entered and exited. If, in the process, there is a Human Task node and during the execution of the process the flow reaches at the human task node, an entry is creates in NodeInstanceLog table, task is created etc, then some user acts upon it and completes the task, again another entry is created in the NodeInstanceLog showing the exit information of the node.

           But I am not able to find out who has acted upon the task. This information is present in the Task table but there is no relationship between this table and NodeInstanceLog.

      How should I relate them?

        • 1. Re: NodeInstanceLog and Human Tasks relationship
          Murat Kilic Newbie

          Hi Rahul,


          I am also struggling to find a solution to to the same issue. I am trying to find which actor completed a node of a process. I have been looking into the tables (I am persisting both the process info and task service), but could not figure out a way to relate the process node information with the task information. Have you found a solution?

          • 2. Re: NodeInstanceLog and Human Tasks relationship
            Maciej Swiderski Master

            As you already noticed NodeInstanceLog table keeps only information relevant to the runtime engine which means only on node level - and not the details of each node (in case of human task - work item).


            the relationship between runtime engine and task service is via work item id. Unfortunately it seems it is not stored anywhere after task(work item) is completed. It looks like a good feature request to be added so runtime data and task data can be matched later on too. Please file a jira issue for this.


            And as workaround (potential contribution as well) is to extend the current logger to save work item id as part of the nodeinstancelog if present.



            • 3. Re: NodeInstanceLog and Human Tasks relationship
              Murat Kilic Newbie

              Thanks for explanation.


              I understand WorkItemInfo does not keep data after task is completed, but even for currently reserved tasks, I can not associate the Node from the process with the workItemId. Task table refers workItemId and processInstanceId but nowhere in WorkItemInfo does  not have node ID as far as I can see. It has processInstanceId and name (which is always Human Task) , not the task name. Does the workItemByteArray keep that info, either node ID or task name? If so how can I get that info out of that? It looks like a serialized array or object.


              Thanks in advance

              • 5. Re: NodeInstanceLog and Human Tasks relationship
                Murat Kilic Newbie

                Thank you Rahul. Very much appreciated. Let's see how this goes...

                • 6. Re: NodeInstanceLog and Human Tasks relationship
                  Rahul Agrawal Newbie

                  I tried to implement it in the following way.


                  It works fine.


                  List<NodeInstanceLog> nodeInstancesList = dbLog.findNodeInstances(processInstanceId);


                                      List<HistoryRecord> objLstHistoryList =  new ArrayList<HistoryRecord>();


                                      Map<String, NodeInstanceLog> nodeInstances = new HashMap<String, NodeInstanceLog>();


                                      for (NodeInstanceLog nodeInstance : nodeInstancesList) {

                                                if (nodeInstance.getType() == NodeInstanceLog.TYPE_ENTER) {



                                                } else {

                                                          NodeInstanceLog enterLog = nodeInstances.get(nodeInstance.getNodeInstanceId());


                                                          HistoryRecord objHistoryRecord = null;

                                                          objHistoryRecord = new HistoryRecord();






                                                          long lOrgDiff = nodeInstance.getDate().getTime() - enterLog.getDate().getTime() ;

                                                           long lDiff = 0;

                                                           lDiff = lOrgDiff / (60*60*1000);

                                                           if(lDiff == 0)


                                                                     lDiff = lOrgDiff / (60*1000);

                                                                     if (lDiff ==0 )


                                                                               lDiff = lOrgDiff / 1000;

                                                                               if(lDiff == 0)


                                                                                         objHistoryRecord.setStrDuration (lOrgDiff + " milisec.");



                                                                                         objHistoryRecord.setStrDuration (lDiff + " sec.");




                                                                               objHistoryRecord.setStrDuration (lDiff + " min.");


                                                           } else if(lDiff >= 24)


                                                                     lDiff = lOrgDiff / (24*60*60*1000);

                                                                     objHistoryRecord.setStrDuration ( lDiff + " days.");




                                                                     objHistoryRecord.setStrDuration (lDiff + " hrs.");          


                                                          //Use the enterLog and nodeInstance object to get the duration field







                                      EntityManagerFactory emf = getEntityManagerFactory(processName);

                                      EntityManager em = emf.createEntityManager();



                                      Query resultQuery = em.createQuery("SELECT t.taskData.actualOwner FROM NodeInstanceLog n ,org.jbpm.task.Task t left join t.names as i "+

                                                          "WHERE n.id = :nodeinstanceid AND " +

                                                          " n.nodeName = i.text AND " +

                                                          "n.processInstanceId = t.taskData.processInstanceId AND " +

                                                          "t.taskData.status = 'Completed'");


                                      java.util.Iterator<HistoryRecord> lstIterator = objLstHistoryList.iterator();





                                                          HistoryRecord hstryObj = lstIterator.next();

                                                          User user = (User)resultQuery.setParameter("nodeinstanceid", hstryObj.getId()).getSingleResult();



                                                catch (Exception e) {

                                                                    // TODO: handle exception



                                      return objLstHistoryList;

                  1 of 1 people found this helpful