use of org.jbpm.process.audit.NodeInstanceLog in project jbpm by kiegroup.
the class AuditQueryDataUtil method createTestNodeInstanceLogData.
static NodeInstanceLog[] createTestNodeInstanceLogData(EntityManagerFactory emf) {
StandaloneJtaStrategy jtaHelper = new StandaloneJtaStrategy(emf);
EntityManager em = jtaHelper.getEntityManager();
int numEntities = 9;
NodeInstanceLog[] testData = new NodeInstanceLog[numEntities];
Calendar cal = randomCal();
for (int i = 0; i < numEntities; ++i) {
NodeInstanceLog nil = new NodeInstanceLog();
nil.setProcessInstanceId(randomLong());
nil.setProcessId(randomString());
cal.add(Calendar.SECOND, 1);
nil.setDate(cal.getTime());
nil.setType(Math.abs(random.nextInt()));
nil.setNodeInstanceId(randomString());
nil.setNodeId(randomString());
nil.setNodeName(randomString());
nil.setNodeType(randomString());
nil.setWorkItemId(randomLong());
nil.setConnection(randomString());
nil.setExternalId(randomString());
testData[i] = nil;
}
for (int i = 0; i < numEntities; ++i) {
switch(i) {
case 1:
testData[i - 1].setDate(testData[i].getDate());
break;
case 2:
testData[i - 1].setNodeId(testData[i].getNodeId());
break;
case 3:
testData[i - 1].setNodeInstanceId(testData[i].getNodeInstanceId());
break;
case 4:
testData[i - 1].setNodeName(testData[i].getNodeName());
break;
case 5:
testData[i - 1].setNodeType(testData[i].getNodeType());
break;
case 6:
testData[i - 1].setProcessId(testData[i].getProcessId());
break;
case 7:
testData[i - 1].setProcessInstanceId(testData[i].getProcessInstanceId());
break;
case 8:
testData[i - 1].setWorkItemId(testData[i].getWorkItemId());
break;
}
}
Object tx = jtaHelper.joinTransaction(em);
for (int i = 0; i < numEntities; ++i) {
em.persist(testData[i]);
}
jtaHelper.leaveTransaction(em, tx);
createdEntities.addAll(Arrays.asList(testData));
return testData;
}
use of org.jbpm.process.audit.NodeInstanceLog in project jbpm by kiegroup.
the class AsyncAuditLogProducer method afterNodeLeft.
@Override
public void afterNodeLeft(ProcessNodeLeftEvent event) {
NodeInstanceLog log = (NodeInstanceLog) builder.buildEvent(event, null);
sendMessage(log, AFTER_NODE_LEFT_EVENT_TYPE);
}
use of org.jbpm.process.audit.NodeInstanceLog in project jbpm by kiegroup.
the class AsyncAuditLogProducer method afterNodeTriggered.
@Override
public void afterNodeTriggered(ProcessNodeTriggeredEvent event) {
// trigger this to record some of the data (like work item id) after activity was triggered
NodeInstanceLog log = (NodeInstanceLog) ((NodeInstanceImpl) event.getNodeInstance()).getMetaData().get("NodeInstanceLog");
NodeInstanceLog logUpdated = (NodeInstanceLog) builder.buildEvent(event, log);
if (logUpdated != null) {
sendMessage(log, AFTER_NODE_ENTER_EVENT_TYPE);
}
}
use of org.jbpm.process.audit.NodeInstanceLog in project jbpm by kiegroup.
the class JbpmBpmn2TestCase method assertNodeActive.
public void assertNodeActive(long processInstanceId, KieSession ksession, String... name) {
List<String> names = new ArrayList<String>();
for (String n : name) {
names.add(n);
}
ProcessInstance processInstance = ksession.getProcessInstance(processInstanceId);
if (processInstance instanceof WorkflowProcessInstance) {
if (sessionPersistence) {
// ENTER -> EXIT is correctly ordered
List<? extends NodeInstanceLog> logs = logService.findNodeInstances(processInstanceId);
if (logs != null) {
List<String> activeNodes = new ArrayList<String>();
for (NodeInstanceLog l : logs) {
String nodeName = l.getNodeName();
if (l.getType() == NodeInstanceLog.TYPE_ENTER && names.contains(nodeName)) {
activeNodes.add(nodeName);
}
if (l.getType() == NodeInstanceLog.TYPE_EXIT && names.contains(nodeName)) {
activeNodes.remove(nodeName);
}
}
names.removeAll(activeNodes);
}
} else {
assertNodeActive((WorkflowProcessInstance) processInstance, names);
}
}
if (!names.isEmpty()) {
String s = names.get(0);
for (int i = 1; i < names.size(); i++) {
s += ", " + names.get(i);
}
fail("Node(s) not active: " + s);
}
}
use of org.jbpm.process.audit.NodeInstanceLog in project jbpm by kiegroup.
the class JbpmBpmn2TestCase method getCompletedNodes.
protected List<String> getCompletedNodes(long processInstanceId) {
List<String> names = new ArrayList<String>();
if (sessionPersistence) {
AuditLogService auditLogService = new JPAAuditLogService(emf);
List<NodeInstanceLog> logs = auditLogService.findNodeInstances(processInstanceId);
if (logs != null) {
for (NodeInstanceLog l : logs) {
names.add(l.getNodeId());
}
}
} else {
for (LogEvent event : logger.getLogEvents()) {
if (event instanceof RuleFlowNodeLogEvent) {
if (event.getType() == 27) {
names.add(((RuleFlowNodeLogEvent) event).getNodeId());
}
}
}
}
return names;
}
Aggregations