Search in sources :

Example 1 with ProcessInstanceLog

use of org.jbpm.process.audit.ProcessInstanceLog in project jbpm by kiegroup.

the class AuditTaskDeleteTest method buildCompletedProcessInstance.

private ProcessInstanceLog buildCompletedProcessInstance(long processInstanceId) {
    ProcessInstanceLog pil = new ProcessInstanceLog(processInstanceId, "test");
    pil.setDuration(0L);
    pil.setExternalId("none");
    pil.setIdentity("none");
    pil.setOutcome("");
    pil.setParentProcessInstanceId(-1L);
    pil.setProcessId("test");
    pil.setProcessName("test process");
    pil.setProcessVersion("1");
    pil.setStatus(2);
    pil.setStart(null);
    pil.setEnd(null);
    return pil;
}
Also used : ProcessInstanceLog(org.jbpm.process.audit.ProcessInstanceLog)

Example 2 with ProcessInstanceLog

use of org.jbpm.process.audit.ProcessInstanceLog in project jbpm by kiegroup.

the class ManagedAuditEventBuilderImpl method buildEvent.

@Override
public AuditEvent buildEvent(ProcessStartedEvent pse) {
    ProcessInstanceLog log = (ProcessInstanceLog) super.buildEvent(pse);
    log.setExternalId(ownerId);
    return log;
}
Also used : ProcessInstanceLog(org.jbpm.process.audit.ProcessInstanceLog)

Example 3 with ProcessInstanceLog

use of org.jbpm.process.audit.ProcessInstanceLog in project jbpm by kiegroup.

the class ManagedAuditEventBuilderImpl method buildEvent.

@Override
public AuditEvent buildEvent(ProcessCompletedEvent pce, Object log) {
    ProcessInstanceLog instanceLog = (ProcessInstanceLog) super.buildEvent(pce, log);
    instanceLog.setExternalId(ownerId);
    return instanceLog;
}
Also used : ProcessInstanceLog(org.jbpm.process.audit.ProcessInstanceLog)

Example 4 with ProcessInstanceLog

use of org.jbpm.process.audit.ProcessInstanceLog in project jbpm by kiegroup.

the class ActivityTest method testCallActivitySkipAbortParent.

@Test
@RequirePersistence
public void testCallActivitySkipAbortParent() throws Exception {
    KieBase kbase = createKnowledgeBase("BPMN2-CallActivitySkipAbortParent.bpmn2", "BPMN2-UserTask.bpmn2");
    ksession = createKnowledgeSession(kbase);
    TestWorkItemHandler workItemHandler = new TestWorkItemHandler();
    ksession.getWorkItemManager().registerWorkItemHandler("Human Task", workItemHandler);
    Map<String, Object> params = new HashMap<String, Object>();
    params.put("x", "oldValue");
    ProcessInstance processInstance = ksession.startProcess("ParentProcess", params);
    assertProcessInstanceActive(processInstance);
    ksession = restoreSession(ksession, true);
    WorkItem workItem = workItemHandler.getWorkItem();
    assertNotNull(workItem);
    assertEquals("john", workItem.getParameter("ActorId"));
    long childPI = workItem.getProcessInstanceId();
    assertNotEquals("Child process instance must be different", processInstance.getId(), childPI);
    ksession.abortProcessInstance(childPI);
    assertProcessInstanceFinished(processInstance, ksession);
    ProcessInstanceLog log = logService.findProcessInstance(childPI);
    assertNotNull(log);
    assertEquals(ProcessInstance.STATE_ABORTED, log.getStatus().intValue());
    // parent process instance should not be aborted
    log = logService.findProcessInstance(processInstance.getId());
    assertNotNull(log);
    assertEquals("Parent process should be completed and not aborted", ProcessInstance.STATE_COMPLETED, log.getStatus().intValue());
}
Also used : TestWorkItemHandler(org.jbpm.bpmn2.objects.TestWorkItemHandler) HashMap(java.util.HashMap) KieBase(org.kie.api.KieBase) ProcessInstance(org.kie.api.runtime.process.ProcessInstance) WorkflowProcessInstance(org.kie.api.runtime.process.WorkflowProcessInstance) WorkItem(org.kie.api.runtime.process.WorkItem) ProcessInstanceLog(org.jbpm.process.audit.ProcessInstanceLog) Test(org.junit.Test) RequirePersistence(org.jbpm.bpmn2.test.RequirePersistence)

Example 5 with ProcessInstanceLog

use of org.jbpm.process.audit.ProcessInstanceLog in project jbpm by kiegroup.

the class ActivityTest method testScriptTaskWithHistoryLog.

@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();
}
Also used : JPAAuditLogService(org.jbpm.process.audit.JPAAuditLogService) AuditLogService(org.jbpm.process.audit.AuditLogService) NodeInstanceLog(org.jbpm.process.audit.NodeInstanceLog) KieBase(org.kie.api.KieBase) JPAAuditLogService(org.jbpm.process.audit.JPAAuditLogService) ProcessInstance(org.kie.api.runtime.process.ProcessInstance) WorkflowProcessInstance(org.kie.api.runtime.process.WorkflowProcessInstance) ProcessInstanceLog(org.jbpm.process.audit.ProcessInstanceLog) Test(org.junit.Test) RequirePersistence(org.jbpm.bpmn2.test.RequirePersistence)

Aggregations

ProcessInstanceLog (org.jbpm.process.audit.ProcessInstanceLog)27 Test (org.junit.Test)9 NodeInstanceLog (org.jbpm.process.audit.NodeInstanceLog)8 KieBase (org.kie.api.KieBase)8 ProcessInstance (org.kie.api.runtime.process.ProcessInstance)8 JPAAuditLogService (org.jbpm.process.audit.JPAAuditLogService)7 HashMap (java.util.HashMap)6 EntityManager (javax.persistence.EntityManager)6 EntityManagerFactory (javax.persistence.EntityManagerFactory)6 AuditLogService (org.jbpm.process.audit.AuditLogService)6 KieSession (org.kie.api.runtime.KieSession)6 Calendar (java.util.Calendar)5 GregorianCalendar (java.util.GregorianCalendar)5 StandaloneJtaStrategy (org.jbpm.process.audit.strategy.StandaloneJtaStrategy)5 AbstractBaseTest (org.jbpm.test.util.AbstractBaseTest)5 PersistenceUtil.createEnvironment (org.jbpm.persistence.util.PersistenceUtil.createEnvironment)4 AbstractAuditLogServiceTest.createKieSession (org.jbpm.process.audit.AbstractAuditLogServiceTest.createKieSession)4 AbstractAuditLogger (org.jbpm.process.audit.AbstractAuditLogger)4 Environment (org.kie.api.runtime.Environment)4 RequirePersistence (org.jbpm.bpmn2.test.RequirePersistence)3