use of org.jbpm.workflow.instance.node.WorkItemNodeInstance in project jbpm by kiegroup.
the class RuntimeDataServiceImplTest method testGetTaskAudit.
@Test
public void testGetTaskAudit() {
processInstanceId = processService.startProcess(deploymentUnit.getIdentifier(), "org.jbpm.writedocument");
assertNotNull(processInstanceId);
ProcessInstance instance = processService.getProcessInstance(processInstanceId);
assertNotNull(instance);
Collection<NodeInstance> activeNodes = ((WorkflowProcessInstanceImpl) instance).getNodeInstances();
assertNotNull(activeNodes);
assertEquals(1, activeNodes.size());
NodeInstance node = activeNodes.iterator().next();
assertNotNull(node);
assertTrue(node instanceof WorkItemNodeInstance);
Long workItemId = ((WorkItemNodeInstance) node).getWorkItemId();
assertNotNull(workItemId);
List<AuditTask> auditTasks = runtimeDataService.getAllAuditTask("salaboy", new QueryFilter(0, 10));
assertNotNull(auditTasks);
assertEquals(1, auditTasks.size());
assertEquals("Write a Document", auditTasks.get(0).getName());
processService.abortProcessInstance(processInstanceId);
processInstanceId = null;
}
use of org.jbpm.workflow.instance.node.WorkItemNodeInstance in project jbpm by kiegroup.
the class RuntimeDataServiceImplTest method testGetTaskByWorkItemId.
@Test
public void testGetTaskByWorkItemId() {
processInstanceId = processService.startProcess(deploymentUnit.getIdentifier(), "org.jbpm.writedocument");
assertNotNull(processInstanceId);
ProcessInstance instance = processService.getProcessInstance(processInstanceId);
assertNotNull(instance);
Collection<NodeInstance> activeNodes = ((WorkflowProcessInstanceImpl) instance).getNodeInstances();
assertNotNull(activeNodes);
assertEquals(1, activeNodes.size());
NodeInstance node = activeNodes.iterator().next();
assertNotNull(node);
assertTrue(node instanceof WorkItemNodeInstance);
Long workItemId = ((WorkItemNodeInstance) node).getWorkItemId();
assertNotNull(workItemId);
UserTaskInstanceDesc userTask = runtimeDataService.getTaskByWorkItemId(workItemId);
assertNotNull(userTask);
assertEquals(processInstanceId, userTask.getProcessInstanceId());
assertEquals("Write a Document", userTask.getName());
}
use of org.jbpm.workflow.instance.node.WorkItemNodeInstance in project jbpm by kiegroup.
the class DefaultAuditEventBuilderImpl method buildEvent.
@Override
public AuditEvent buildEvent(ProcessNodeTriggeredEvent pnte, Object log) {
NodeInstanceImpl nodeInstance = (NodeInstanceImpl) pnte.getNodeInstance();
NodeInstanceLog logEvent = null;
if (log != null) {
logEvent = (NodeInstanceLog) log;
if (nodeInstance instanceof WorkItemNodeInstance && ((WorkItemNodeInstance) nodeInstance).getWorkItem() != null) {
logEvent.setWorkItemId(((WorkItemNodeInstance) nodeInstance).getWorkItem().getId());
}
if (nodeInstance instanceof SubProcessNodeInstance) {
logEvent.setReferenceId(((SubProcessNodeInstance) nodeInstance).getProcessInstanceId());
}
return logEvent;
}
return null;
}
use of org.jbpm.workflow.instance.node.WorkItemNodeInstance in project jbpm by kiegroup.
the class DefaultAuditEventBuilderImpl method buildEvent.
@Override
public AuditEvent buildEvent(ProcessNodeTriggeredEvent pnte) {
ProcessInstanceImpl pi = (ProcessInstanceImpl) pnte.getProcessInstance();
NodeInstanceImpl nodeInstance = (NodeInstanceImpl) pnte.getNodeInstance();
Node node = nodeInstance.getNode();
String nodeId = null;
String nodeType = null;
String nodeContainerId = null;
if (node != null) {
nodeId = (String) node.getMetaData().get("UniqueId");
nodeType = node.getClass().getSimpleName();
nodeContainerId = getNodeContainerId(node.getNodeContainer());
} else {
nodeId = Long.toString(nodeInstance.getNodeId());
nodeType = (String) nodeInstance.getMetaData("NodeType");
}
NodeInstanceLog log = new NodeInstanceLog(NodeInstanceLog.TYPE_ENTER, pi.getId(), pi.getProcessId(), Long.toString(nodeInstance.getId()), nodeId, nodeInstance.getNodeName());
if (nodeInstance instanceof WorkItemNodeInstance && ((WorkItemNodeInstance) nodeInstance).getWorkItem() != null) {
log.setWorkItemId(((WorkItemNodeInstance) nodeInstance).getWorkItem().getId());
}
if (nodeInstance instanceof SubProcessNodeInstance) {
log.setReferenceId(((SubProcessNodeInstance) nodeInstance).getProcessInstanceId());
}
String connection = (String) nodeInstance.getMetaData().get("IncomingConnection");
log.setConnection(connection);
log.setExternalId("" + ((KieSession) pnte.getKieRuntime()).getIdentifier());
log.setNodeType(nodeType);
log.setNodeContainerId(nodeContainerId);
log.setDate(pnte.getEventDate());
log.setSlaCompliance(nodeInstance.getSlaCompliance());
log.setSlaDueDate(nodeInstance.getSlaDueDate());
return log;
}
use of org.jbpm.workflow.instance.node.WorkItemNodeInstance in project jbpm by kiegroup.
the class DefaultAuditEventBuilderImpl method buildEvent.
@Override
public AuditEvent buildEvent(ProcessNodeLeftEvent pnle, Object log) {
ProcessInstanceImpl pi = (ProcessInstanceImpl) pnle.getProcessInstance();
NodeInstanceImpl nodeInstance = (NodeInstanceImpl) pnle.getNodeInstance();
Node node = nodeInstance.getNode();
String nodeId = null;
String nodeType = null;
String nodeContainerId = null;
if (node != null) {
nodeId = (String) node.getMetaData().get("UniqueId");
nodeType = node.getClass().getSimpleName();
nodeContainerId = getNodeContainerId(node.getNodeContainer());
} else {
nodeId = Long.toString(nodeInstance.getNodeId());
nodeType = (String) nodeInstance.getMetaData("NodeType");
}
NodeInstanceLog logEvent = null;
if (log != null) {
logEvent = (NodeInstanceLog) log;
} else {
logEvent = new NodeInstanceLog(NodeInstanceLog.TYPE_EXIT, pi.getId(), pi.getProcessId(), Long.toString(nodeInstance.getId()), nodeId, nodeInstance.getNodeName());
}
if (nodeInstance instanceof WorkItemNodeInstance && ((WorkItemNodeInstance) nodeInstance).getWorkItem() != null) {
logEvent.setWorkItemId(((WorkItemNodeInstance) nodeInstance).getWorkItem().getId());
}
if (nodeInstance instanceof SubProcessNodeInstance) {
logEvent.setReferenceId(((SubProcessNodeInstance) nodeInstance).getProcessInstanceId());
}
String connection = (String) nodeInstance.getMetaData().get("OutgoingConnection");
logEvent.setConnection(connection);
logEvent.setExternalId("" + ((KieSession) pnle.getKieRuntime()).getIdentifier());
logEvent.setNodeType(nodeType);
logEvent.setNodeContainerId(nodeContainerId);
logEvent.setDate(pnle.getEventDate());
logEvent.setSlaCompliance(nodeInstance.getSlaCompliance());
logEvent.setSlaDueDate(nodeInstance.getSlaDueDate());
return logEvent;
}
Aggregations