-
1. Re: NodeInstanceLog and Human Tasks relationship
mkilic Jan 2, 2013 10:33 PM (in response to rahulamt)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
swiderski.maciej Jan 3, 2013 5:11 AM (in response to rahulamt)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.
HTH
-
3. Re: NodeInstanceLog and Human Tasks relationship
mkilic Jan 5, 2013 11:20 AM (in response to rahulamt)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
-
4. Re: NodeInstanceLog and Human Tasks relationship
rahulamt Feb 15, 2013 1:58 AM (in response to swiderski.maciej)Created a JIRA issue for this.
-
5. Re: NodeInstanceLog and Human Tasks relationship
mkilic Feb 15, 2013 9:06 AM (in response to rahulamt)Thank you Rahul. Very much appreciated. Let's see how this goes...
-
6. Re: NodeInstanceLog and Human Tasks relationship
rahulamt Feb 27, 2013 4:58 AM (in response to mkilic)1 of 1 people found this helpfulI 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) {
nodeInstances.put(nodeInstance.getNodeInstanceId(),
nodeInstance);
} else {
NodeInstanceLog enterLog = nodeInstances.get(nodeInstance.getNodeInstanceId());
HistoryRecord objHistoryRecord = null;
objHistoryRecord = new HistoryRecord();
objHistoryRecord.setId(enterLog.getId());
objHistoryRecord.setStrNodeName(enterLog.getNodeName());
objHistoryRecord.setStrActedTime(nodeInstance.getDate().toString());
objHistoryRecord.setStrComment("Approved");
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.");
}
else
objHistoryRecord.setStrDuration (lDiff + " sec.");
}
else
{
objHistoryRecord.setStrDuration (lDiff + " min.");
}
} else if(lDiff >= 24)
{
lDiff = lOrgDiff / (24*60*60*1000);
objHistoryRecord.setStrDuration ( lDiff + " days.");
}
else
{
objHistoryRecord.setStrDuration (lDiff + " hrs.");
}
//Use the enterLog and nodeInstance object to get the duration field
objLstHistoryList.add(objHistoryRecord);
nodeInstances.remove(nodeInstance.getNodeInstanceId());
}
}
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();
while(lstIterator.hasNext())
{
try{
HistoryRecord hstryObj = lstIterator.next();
User user = (User)resultQuery.setParameter("nodeinstanceid", hstryObj.getId()).getSingleResult();
hstryObj.setStrActedBy(user.getId());
}
catch (Exception e) {
// TODO: handle exception
}
}
return objLstHistoryList;