use of org.jbpm.process.audit.NodeInstanceLog in project jbpm by kiegroup.
the class ServicesAwareAuditEventBuilder method buildEvent.
@Override
public AuditEvent buildEvent(ProcessNodeTriggeredEvent pnte) {
NodeInstanceLog nodeInstanceLog = (NodeInstanceLog) super.buildEvent(pnte);
nodeInstanceLog.setExternalId(deploymentUnitId);
return nodeInstanceLog;
}
use of org.jbpm.process.audit.NodeInstanceLog in project jbpm by kiegroup.
the class AsyncAuditLogProducer method beforeNodeTriggered.
@Override
public void beforeNodeTriggered(ProcessNodeTriggeredEvent event) {
NodeInstanceLog log = (NodeInstanceLog) builder.buildEvent(event);
sendMessage(log, BEFORE_NODE_ENTER_EVENT_TYPE);
((NodeInstanceImpl) event.getNodeInstance()).getMetaData().put("NodeInstanceLog", log);
}
use of org.jbpm.process.audit.NodeInstanceLog in project jbpm by kiegroup.
the class AsyncAuditLogReceiver method onMessage.
@SuppressWarnings("unchecked")
@Override
public void onMessage(Message message) {
if (message instanceof TextMessage) {
EntityManager em = getEntityManager();
TextMessage textMessage = (TextMessage) message;
try {
String messageContent = textMessage.getText();
Integer eventType = textMessage.getIntProperty("EventType");
Object event = xstream.fromXML(messageContent);
switch(eventType) {
case AbstractAuditLogger.AFTER_NODE_ENTER_EVENT_TYPE:
NodeInstanceLog nodeAfterEnterEvent = (NodeInstanceLog) event;
if (nodeAfterEnterEvent.getWorkItemId() != null) {
List<NodeInstanceLog> result = em.createQuery("from NodeInstanceLog as log where log.nodeInstanceId = :nodeId and log.type = 0").setParameter("nodeId", nodeAfterEnterEvent.getNodeInstanceId()).getResultList();
if (result != null && result.size() != 0) {
NodeInstanceLog log = result.get(result.size() - 1);
log.setWorkItemId(nodeAfterEnterEvent.getWorkItemId());
em.merge(log);
}
}
break;
case AbstractAuditLogger.AFTER_COMPLETE_EVENT_TYPE:
ProcessInstanceLog processCompletedEvent = (ProcessInstanceLog) event;
List<ProcessInstanceLog> result = em.createQuery("from ProcessInstanceLog as log where log.processInstanceId = :piId and log.end is null").setParameter("piId", processCompletedEvent.getProcessInstanceId()).getResultList();
if (result != null && result.size() != 0) {
ProcessInstanceLog log = result.get(result.size() - 1);
log.setOutcome(processCompletedEvent.getOutcome());
log.setStatus(processCompletedEvent.getStatus());
log.setEnd(processCompletedEvent.getEnd());
log.setDuration(processCompletedEvent.getDuration());
em.merge(log);
}
break;
default:
em.persist(event);
break;
}
em.flush();
em.close();
} catch (JMSException e) {
e.printStackTrace();
throw new RuntimeException("Exception when receiving audit event event", e);
}
}
}
use of org.jbpm.process.audit.NodeInstanceLog 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.process.audit.NodeInstanceLog 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;
}
Aggregations