-
1. Re: how to get all tokens from processinstance
saraswati.santanu Nov 8, 2009 6:53 AM (in response to peterbasutkar)In JBPM 3.x Token of a process instance is like an iterator which is pointing to the current node of the process. So the node associated with the token is the currently active node, which is the TaskNode for your case. In JBPM 3.x "Task" is not a node.
If you need to get the current active tasks then you can use TaskManagementInstance.ProcessInstance processInstance= getProcessInstance(); //get the task management instance of the process instance TaskMgmtInstance taskManagementInstance = processInstance.getTaskMgmtInstance(); //find the unfinished tasks Collection taskInstances = taskManagementInstance.getUnfinishedTasks(processInstance.getRootToken());
You can also get a "Set" of tasks from the node obtained from the current token.Token rootToken = processInstance.getRootToken(); Node node = rootToken.getNode(); if (node instanceof TaskNode) { Set<Task> tasks = ((TaskNode)node).getTasks(); }
-
2. Re: how to get all tokens from processinstance
peterbasutkar Nov 8, 2009 7:55 AM (in response to peterbasutkar)i dont want only running task............i am using following this code for getting completed and pending token(task node) as well as running token information but this is keeping track of token data(means previously completed and currenrently running task) if an only if we are performing any signaling,but i want all completed and pending token information irrespective of signaling,means it should give me information when task is started,when it is ended for that processInstance
ProcessInstance processInstance = getProcessInstance();
LoggingInstance loggingInstance = processInstance.getLoggingInstance();
List logs = loggingInstance.getLogs(SignalLog.class);
for (SignalLog signalLog : logs) {
List children = signalLog.getChildren();
if(children.get(0) != null){
if(children.get(0) instanceof TransitionLog){
TransitionLog transitionLog = (TransitionLog)children.get(0);
System.out.println("Node Name:::"+transitionLog.getSourceNode().getName());
System.out.println("Node Start Time:::");
System.out.println("Node End Time:::"+transitionLog.getDate());
System.out.println("=====================================================");
}
if(children.get(0) instanceof NodeLog){
NodeLog nodeLog = (NodeLog)children.get(0);
System.out.println("Node Name:::"+nodeLog.getNode().getName());
System.out.println("Node Start Time:::"+nodeLog.getEnter());
System.out.println("Node End Time:::"+nodeLog.getLeave());
System.out.println("=====================================================");
}
}
}
return "success";
} -
3. Re: how to get all tokens from processinstance
saraswati.santanu Nov 9, 2009 7:20 AM (in response to peterbasutkar)LoggingInstance is not persisted. So you cannot really get the history data from it after the transaction is over. For that you need LoggingSession. If you are saving the logs then you can get the information using LoggingSession.
//create a LoggingSession. getSession() here returns a Hibernate session LoggingSession logginSession = new LoggingSession(getSession()); //this map contains Token vs List of logs Map logs = logginSession.findLogsByProcessInstance(processInstance.getId()); //Iterate and do whaterver you need to Set<Entry> entries = logs.entrySet(); for (Entry entry : entries) { List<ProcessLog> processLogs = (List<ProcessLog>)entry.getValue(); for (ProcessLog log:processLogs) { System.out.println("Log type : " + log.getClass().getSimpleName()); } }
So far I remember, along with the code above, you need to calljbpmContext.save(processInstance);
everytime after you do the signalling/task execution. This call saves the logs in db. -
4. Re: how to get all tokens from processinstance
peterbasutkar Nov 11, 2009 11:29 PM (in response to peterbasutkar)i am using jsf consol for jbpm,How to activate r start LoggingSession in my scenario ?