use of org.jbpm.process.instance.impl.ProcessInstanceImpl in project jbpm by kiegroup.
the class JPAWorkingMemoryDbLogger method afterProcessCompleted.
@Override
public void afterProcessCompleted(ProcessCompletedEvent event) {
long processInstanceId = event.getProcessInstance().getId();
EntityManager em = getEntityManager(event);
Object tx = joinTransaction(em);
ProcessInstanceLog log = (ProcessInstanceLog) ((ProcessInstanceImpl) event.getProcessInstance()).getMetaData().get("ProcessInstanceLog");
if (log == null) {
List<ProcessInstanceLog> result = em.createQuery("from ProcessInstanceLog as log where log.processInstanceId = :piId and log.end is null").setParameter("piId", processInstanceId).getResultList();
if (result != null && result.size() != 0) {
log = result.get(result.size() - 1);
}
}
if (log != null) {
log = (ProcessInstanceLog) builder.buildEvent(event, log);
em.merge(log);
}
leaveTransaction(em, tx);
}
use of org.jbpm.process.instance.impl.ProcessInstanceImpl in project jbpm by kiegroup.
the class DefaultAuditEventBuilderImpl method buildEvent.
@Override
public AuditEvent buildEvent(ProcessStartedEvent pse) {
ProcessInstanceImpl pi = (ProcessInstanceImpl) pse.getProcessInstance();
ProcessInstanceLog log = new ProcessInstanceLog(pi.getId(), pi.getProcessId());
log.setExternalId("" + ((KieSession) pse.getKieRuntime()).getIdentifier());
log.setProcessName(pi.getProcess().getName());
log.setProcessVersion(pi.getProcess().getVersion());
log.setStatus(ProcessInstance.STATE_ACTIVE);
log.setProcessInstanceDescription(pi.getDescription());
log.setProcessType(((WorkflowProcess) pi.getProcess()).getProcessType());
log.setSlaCompliance(pi.getSlaCompliance());
log.setSlaDueDate(pi.getSlaDueDate());
// store correlation key in its external form
CorrelationKey correlationKey = (CorrelationKey) pi.getMetaData().get("CorrelationKey");
if (correlationKey != null) {
log.setCorrelationKey(correlationKey.toExternalForm());
}
long parentProcessInstanceId = (Long) pi.getMetaData().getOrDefault("ParentProcessInstanceId", -1L);
log.setParentProcessInstanceId(parentProcessInstanceId);
return log;
}
use of org.jbpm.process.instance.impl.ProcessInstanceImpl in project jbpm by kiegroup.
the class DefaultAuditEventBuilderImpl method buildEvent.
@Override
public AuditEvent buildEvent(ProcessCompletedEvent pce, Object log) {
ProcessInstanceImpl pi = (ProcessInstanceImpl) pce.getProcessInstance();
ProcessInstanceLog logEvent = null;
if (log != null) {
logEvent = (ProcessInstanceLog) log;
} else {
logEvent = new ProcessInstanceLog(pi.getId(), pi.getProcessId());
}
logEvent.setOutcome(pi.getOutcome());
logEvent.setStatus(pi.getState());
logEvent.setEnd(pce.getEventDate());
logEvent.setDuration(logEvent.getEnd().getTime() - logEvent.getStart().getTime());
logEvent.setProcessInstanceDescription(pi.getDescription());
logEvent.setSlaCompliance(pi.getSlaCompliance());
return logEvent;
}
use of org.jbpm.process.instance.impl.ProcessInstanceImpl 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.process.instance.impl.ProcessInstanceImpl 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