public List<NodeInstanceLog> execute(Context cntxt) { setLogEnvironment(cntxt); if( nodeId == null || nodeId.isEmpty() ) { return this.auditLogService.findNodeInstances(processInstanceId); } else { return this.auditLogService.findNodeInstances(processInstanceId, nodeId); } }
if (processInstance instanceof WorkflowProcessInstance) { if (sessionPersistence) { List<? extends NodeInstanceLog> logs = logService.findNodeInstances(processInstanceId); // ENTER -> EXIT is correctly ordered if (logs != null) { List<String> activeNodes = new ArrayList<String>();
.findNodeInstances(processInstanceId); if (logs != null) { for (NodeInstanceLog l : logs) {
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; }
Assertions.assertThat(processInstance.getProcessId()).isEqualTo("com.sample.ruleflow"); Assertions.assertThat(processInstance.getStatus().intValue()).isEqualTo(ProcessInstance.STATE_COMPLETED); List<NodeInstanceLog> nodeInstances = auditLogService.findNodeInstances(processInstanceId); Assertions.assertThat(nodeInstances.size()).isEqualTo(6); for (NodeInstanceLog nodeInstance: nodeInstances) {
private int getSLAComplianceForNodeInstance(long processInstanceId, org.jbpm.workflow.instance.NodeInstance nodeInstance, int logType) { int slaCompliance = -1; if (sessionPersistence) { List<NodeInstanceLog> logs = logService.findNodeInstances(processInstanceId); if (logs != null) { for (NodeInstanceLog log : logs) { if (log.getType() == logType && log.getNodeInstanceId().equals(String.valueOf(nodeInstance.getId()))) { slaCompliance = log.getSlaCompliance(); break; } } } } else { slaCompliance = nodeInstance.getSlaCompliance(); } return slaCompliance; } }
List<ProcessInstanceLog> processInstances = logService.findProcessInstances("com.sample.ruleflow"); Assertions.assertThat(processInstances.size()).isEqualTo(1); List<NodeInstanceLog> nodeInstances = logService.findNodeInstances(processInstance.getId()); Assertions.assertThat(nodeInstances.size()).isEqualTo(6); for (NodeInstanceLog nodeInstance: nodeInstances) {
public static void runTestLogger3(KieSession session, AuditLogService auditLogService) { session.getWorkItemManager().registerWorkItemHandler("Human Task", new SystemOutWorkItemHandler()); // record the initial count to compare to later List<ProcessInstanceLog> processInstances = auditLogService.findProcessInstances("com.sample.ruleflow"); int initialProcessInstanceSize = processInstances.size(); // start process instance long processInstanceId = session.startProcess("com.sample.ruleflow2").getId(); logger.debug("Checking process instances for process 'com.sample.ruleflow2'"); processInstances = auditLogService.findProcessInstances("com.sample.ruleflow2"); Assertions.assertThat(processInstances.size()).isEqualTo(initialProcessInstanceSize + 1); ProcessInstanceLog processInstance = processInstances.get(initialProcessInstanceSize); logger.debug("{} -> {} - {}", processInstance.toString(), processInstance.getStart(), processInstance.getEnd()); Assertions.assertThat(processInstance.getStart()).isNotNull(); Assertions.assertThat(processInstance.getEnd()).isNotNull().withFailMessage("ProcessInstanceLog does not contain end date."); Assertions.assertThat(processInstance.getProcessInstanceId().longValue()).isEqualTo(processInstanceId); Assertions.assertThat(processInstance.getProcessId()).isEqualTo("com.sample.ruleflow2"); List<NodeInstanceLog> nodeInstances = auditLogService.findNodeInstances(processInstanceId); for (NodeInstanceLog nodeInstance: nodeInstances) { logger.debug("{} -> {}", nodeInstance.toString(), nodeInstance.getDate()); Assertions.assertThat(processInstance.getProcessInstanceId().longValue()).isEqualTo(processInstanceId); Assertions.assertThat(processInstance.getProcessId()).isEqualTo("com.sample.ruleflow2"); Assertions.assertThat(nodeInstance.getDate()).isNotNull(); } Assertions.assertThat(nodeInstances.size()).isEqualTo(14); auditLogService.clear(); }
Assertions.assertThat(processInstance.getProcessInstanceId().longValue()).isEqualTo(processInstanceId); Assertions.assertThat(processInstance.getProcessId()).isEqualTo("com.sample.ruleflow"); List<NodeInstanceLog> nodeInstances = auditLogService.findNodeInstances(processInstanceId); Assertions.assertThat(nodeInstances.size()).isEqualTo(6); for (NodeInstanceLog nodeInstance: nodeInstances) {
public static void runTestLogger2(KieSession session, AuditLogService auditLogService) { session.getWorkItemManager().registerWorkItemHandler("Human Task", new SystemOutWorkItemHandler()); // record the initial count to compare to later List<ProcessInstanceLog> processInstances = auditLogService.findProcessInstances("com.sample.ruleflow"); int initialProcessInstanceSize = processInstances.size(); // start process instance session.startProcess("com.sample.ruleflow"); session.startProcess("com.sample.ruleflow"); logger.debug("Checking process instances for process 'com.sample.ruleflow'"); processInstances = auditLogService.findProcessInstances("com.sample.ruleflow"); Assertions.assertThat(processInstances.size()).isEqualTo(initialProcessInstanceSize + 2); for (ProcessInstanceLog processInstance: processInstances) { logger.debug("{} -> {} - {}", processInstance.toString(), processInstance.getStart(), processInstance.getEnd()); List<NodeInstanceLog> nodeInstances = auditLogService.findNodeInstances(processInstance.getProcessInstanceId()); for (NodeInstanceLog nodeInstance: nodeInstances) { logger.debug("{} -> {}",nodeInstance.toString(), nodeInstance.getDate()); } Assertions.assertThat(nodeInstances.size()).isEqualTo(6); } auditLogService.clear(); }
public int getNumberOfNodeTriggered(long processInstanceId, String node) { int counter = 0; if (sessionPersistence) { List<NodeInstanceLog> logs = logService.findNodeInstances(processInstanceId); if (logs != null) { for (NodeInstanceLog l : logs) { String nodeName = l.getNodeName(); if ((l.getType() == NodeInstanceLog.TYPE_ENTER || l.getType() == NodeInstanceLog.TYPE_EXIT) && node.equals(nodeName)) { counter++; } } } } else { for (LogEvent event : logger.getLogEvents()) { if (event instanceof RuleFlowNodeLogEvent) { String nodeName = ((RuleFlowNodeLogEvent) event).getNodeName(); if (node.equals(nodeName)) { counter++; } } } } return counter; }
List<ProcessInstanceLog> processInstances = logService.findProcessInstances("com.sample.ruleflow"); Assertions.assertThat(processInstances.size()).isEqualTo(1); List<NodeInstanceLog> nodeInstances = logService.findNodeInstances(processInstance.getId()); Assertions.assertThat(nodeInstances.size()).isEqualTo(6); for (NodeInstanceLog nodeInstance: nodeInstances) {
@Test public void testLogger2() { // start process instance startProcess("com.sample.ruleflow"); startProcess("com.sample.ruleflow"); logger.debug("Checking process instances for process 'com.sample.ruleflow'"); List<ProcessInstanceLog> processInstances = logService.findProcessInstances("com.sample.ruleflow"); assertEquals(2, processInstances.size()); for (ProcessInstanceLog processInstance: processInstances) { logger.debug("{}", processInstance); logger.debug(" -> {} - {}", processInstance.getStart(), processInstance.getEnd()); List<NodeInstanceLog> nodeInstances = logService.findNodeInstances(processInstance.getProcessInstanceId()); for (NodeInstanceLog nodeInstance: nodeInstances) { logger.debug("{}", nodeInstance); logger.debug(" -> {}", nodeInstance.getDate()); } assertEquals(6, nodeInstances.size()); assertRuleFlowSampleLogsSorting(nodeInstances, processInstance.getProcessInstanceId()); } logService.clear(); }
List<ProcessInstanceLog> processInstances = logService.findProcessInstances("com.sample.ruleflow3"); Assertions.assertThat(processInstances.size()).isEqualTo(1); List<NodeInstanceLog> nodeInstances = logService.findNodeInstances(processInstance.getId()); Assertions.assertThat(nodeInstances.size()).isEqualTo(12); for (NodeInstanceLog nodeInstance: nodeInstances) {
List<ProcessInstanceLog> processInstances = logService.findProcessInstances("com.sample.ruleflow3"); Assertions.assertThat(processInstances.size()).isEqualTo(1); List<NodeInstanceLog> nodeInstances = logService.findNodeInstances(processInstance.getId()); Assertions.assertThat(nodeInstances.size()).isEqualTo(6); for (NodeInstanceLog nodeInstance: nodeInstances) {
@Test public void testLogger3() { long processInstanceId = startProcess("com.sample.ruleflow2").getId(); logger.debug("Checking process instances for process 'com.sample.ruleflow2'"); List<ProcessInstanceLog> processInstances = logService.findProcessInstances("com.sample.ruleflow2"); assertEquals(1, processInstances.size()); ProcessInstanceLog processInstance = processInstances.get(0); logger.debug("{}", processInstance); logger.debug(" -> {} - {} ", processInstance.getStart(), processInstance.getEnd()); assertNotNull(processInstance.getStart()); assertNotNull(processInstance.getEnd()); assertEquals(processInstanceId, processInstance.getProcessInstanceId().longValue()); assertEquals("com.sample.ruleflow2", processInstance.getProcessId()); List<NodeInstanceLog> nodeInstances = logService.findNodeInstances(processInstanceId); for (NodeInstanceLog nodeInstance: nodeInstances) { logger.debug("{}", nodeInstance); logger.debug(" -> {}", nodeInstance.getDate()); assertEquals(processInstanceId, processInstance.getProcessInstanceId().longValue()); assertEquals("com.sample.ruleflow2", processInstance.getProcessId()); assertNotNull(nodeInstance.getDate()); } assertEquals(14, nodeInstances.size()); logService.clear(); }
@Test public void testLogger1() { // start process instance long processInstanceId = startProcess("com.sample.ruleflow").getId(); logger.debug("Checking process instances for process 'com.sample.ruleflow'"); List<ProcessInstanceLog> processInstances = logService.findProcessInstances("com.sample.ruleflow"); assertEquals(1, processInstances.size()); ProcessInstanceLog processInstance = processInstances.get(0); logger.debug("{}", processInstance); assertNotNull(processInstance.getStart()); assertNotNull(processInstance.getEnd()); assertEquals(processInstanceId, processInstance.getProcessInstanceId().longValue()); assertEquals("com.sample.ruleflow", processInstance.getProcessId()); List<NodeInstanceLog> nodeInstances = logService.findNodeInstances(processInstanceId); assertEquals(6, nodeInstances.size()); for (NodeInstanceLog nodeInstance: nodeInstances) { logger.debug("{}", nodeInstance); assertEquals(processInstanceId, processInstance.getProcessInstanceId().longValue()); assertEquals("com.sample.ruleflow", processInstance.getProcessId()); assertNotNull(nodeInstance.getDate()); } assertRuleFlowSampleLogsSorting(nodeInstances, processInstanceId); logService.clear(); }
@Test @RequirePersistence public void testScriptTaskWithHistoryLog() throws Exception { KieBase kbase = createKnowledgeBase("BPMN2-ScriptTask.bpmn2"); ksession = createKnowledgeSession(kbase); ProcessInstance processInstance = ksession.startProcess("ScriptTask"); assertProcessInstanceCompleted(processInstance); AuditLogService logService = new JPAAuditLogService(ksession.getEnvironment()); List<NodeInstanceLog> logs = logService.findNodeInstances(processInstance.getId()); assertNotNull(logs); assertEquals(6, logs.size()); for (NodeInstanceLog log : logs) { assertNotNull(log.getDate()); } ProcessInstanceLog pilog = logService.findProcessInstance(processInstance.getId()); assertNotNull(pilog); assertNotNull(pilog.getEnd()); List<ProcessInstanceLog> pilogs = logService.findActiveProcessInstances(processInstance.getProcessId()); assertNotNull(pilogs); assertEquals(0, pilogs.size()); logService.dispose(); }
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; }
private int getSLAComplianceForNodeInstance(long processInstanceId, org.jbpm.workflow.instance.NodeInstance nodeInstance, int logType) { int slaCompliance = -1; if (sessionPersistence) { List<NodeInstanceLog> logs = logService.findNodeInstances(processInstanceId); if (logs != null) { for (NodeInstanceLog log : logs) { if (log.getType() == logType && log.getNodeInstanceId().equals(String.valueOf(nodeInstance.getId()))) { slaCompliance = log.getSlaCompliance(); break; } } } } else { slaCompliance = nodeInstance.getSlaCompliance(); } return slaCompliance; } }