Search in sources :

Example 21 with ProcessInstanceLog

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

the class AuditDeleteTest method createTestNodeInstanceLogData.

private NodeInstanceLog[] createTestNodeInstanceLogData() {
    StandaloneJtaStrategy jtaHelper = new StandaloneJtaStrategy(emf);
    EntityManager em = jtaHelper.getEntityManager();
    int numEntities = 9;
    NodeInstanceLog[] testData = new NodeInstanceLog[numEntities];
    ProcessInstanceLog[] testDataPI = new ProcessInstanceLog[numEntities];
    Calendar cal = randomCal();
    for (int i = 0; i < numEntities; ++i) {
        NodeInstanceLog nil = new NodeInstanceLog();
        nil.setProcessInstanceId(randomLong());
        nil.setProcessId(randomString());
        cal.add(Calendar.SECOND, 1);
        nil.setDate(cal.getTime());
        nil.setType(Math.abs(random.nextInt()));
        nil.setNodeInstanceId(randomString());
        nil.setNodeId(randomString());
        nil.setNodeName(randomString());
        nil.setNodeType(randomString());
        nil.setWorkItemId(randomLong());
        nil.setConnection(randomString());
        nil.setExternalId(randomString());
        testData[i] = nil;
        ProcessInstanceLog pLog = buildCompletedProcessInstance(nil.getProcessInstanceId());
        testDataPI[i] = pLog;
    }
    for (int i = 0; i < numEntities; ++i) {
        switch(i) {
            case 1:
                testData[i - 1].setDate(testData[i].getDate());
                break;
            case 2:
                testData[i - 1].setNodeId(testData[i].getNodeId());
                break;
            case 3:
                testData[i - 1].setNodeInstanceId(testData[i].getNodeInstanceId());
                break;
            case 4:
                testData[i - 1].setNodeName(testData[i].getNodeName());
                break;
            case 5:
                testData[i - 1].setNodeType(testData[i].getNodeType());
                break;
            case 6:
                testData[i - 1].setProcessId(testData[i].getProcessId());
                break;
            case 7:
                testData[i - 1].setProcessInstanceId(testData[i].getProcessInstanceId());
                break;
            case 8:
                testData[i - 1].setWorkItemId(testData[i].getWorkItemId());
                break;
        }
    }
    Object tx = jtaHelper.joinTransaction(em);
    for (int i = 0; i < numEntities; ++i) {
        em.persist(testDataPI[i]);
        em.persist(testData[i]);
    }
    jtaHelper.leaveTransaction(em, tx);
    return testData;
}
Also used : StandaloneJtaStrategy(org.jbpm.process.audit.strategy.StandaloneJtaStrategy) EntityManager(javax.persistence.EntityManager) NodeInstanceLog(org.jbpm.process.audit.NodeInstanceLog) Calendar(java.util.Calendar) GregorianCalendar(java.util.GregorianCalendar) ProcessInstanceLog(org.jbpm.process.audit.ProcessInstanceLog)

Example 22 with ProcessInstanceLog

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

the class AuditDeleteTest method buildCompletedProcessInstance.

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

Example 23 with ProcessInstanceLog

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

the class AuditDeleteTest method createTestVariableInstanceLogData.

private VariableInstanceLog[] createTestVariableInstanceLogData() {
    StandaloneJtaStrategy jtaHelper = new StandaloneJtaStrategy(emf);
    EntityManager em = jtaHelper.getEntityManager();
    int numEntities = 8;
    VariableInstanceLog[] testData = new VariableInstanceLog[numEntities];
    ProcessInstanceLog[] testDataPI = new ProcessInstanceLog[numEntities];
    Calendar cal = randomCal();
    for (int i = 0; i < numEntities; ++i) {
        VariableInstanceLog vil = new VariableInstanceLog();
        vil.setProcessInstanceId(randomLong());
        vil.setProcessId(randomString());
        cal.add(Calendar.MINUTE, 1);
        vil.setDate(cal.getTime());
        vil.setVariableInstanceId(randomString());
        vil.setVariableId(randomString());
        vil.setValue(randomString());
        vil.setOldValue(randomString());
        vil.setExternalId(randomString());
        testData[i] = vil;
        ProcessInstanceLog pLog = buildCompletedProcessInstance(vil.getProcessInstanceId());
        testDataPI[i] = pLog;
    }
    for (int i = 0; i < numEntities; ++i) {
        switch(i) {
            case 1:
                testData[i - 1].setDate(testData[i].getDate());
                break;
            case 2:
                testData[i - 1].setOldValue(testData[i].getOldValue());
                break;
            case 3:
                testData[i - 1].setProcessId(testData[i].getProcessId());
                break;
            case 4:
                testData[i - 1].setProcessInstanceId(testData[i].getProcessInstanceId());
                break;
            case 5:
                testData[i - 1].setValue(testData[i].getValue());
                break;
            case 6:
                testData[i - 1].setVariableId(testData[i].getVariableId());
                break;
            case 7:
                testData[i - 1].setVariableInstanceId(testData[i].getVariableInstanceId());
                break;
        }
    }
    Object tx = jtaHelper.joinTransaction(em);
    for (int i = 0; i < numEntities; ++i) {
        em.persist(testDataPI[i]);
        em.persist(testData[i]);
    }
    jtaHelper.leaveTransaction(em, tx);
    return testData;
}
Also used : VariableInstanceLog(org.jbpm.process.audit.VariableInstanceLog) StandaloneJtaStrategy(org.jbpm.process.audit.strategy.StandaloneJtaStrategy) EntityManager(javax.persistence.EntityManager) Calendar(java.util.Calendar) GregorianCalendar(java.util.GregorianCalendar) ProcessInstanceLog(org.jbpm.process.audit.ProcessInstanceLog)

Example 24 with ProcessInstanceLog

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

the class AsyncAuditLogProducer method beforeProcessStarted.

@Override
public void beforeProcessStarted(ProcessStartedEvent event) {
    ProcessInstanceLog log = (ProcessInstanceLog) builder.buildEvent(event);
    sendMessage(log, BEFORE_START_EVENT_TYPE);
}
Also used : ProcessInstanceLog(org.jbpm.process.audit.ProcessInstanceLog)

Example 25 with ProcessInstanceLog

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

the class AsyncAuditLogProducer method afterProcessCompleted.

@Override
public void afterProcessCompleted(ProcessCompletedEvent event) {
    ProcessInstanceLog log = (ProcessInstanceLog) builder.buildEvent(event, null);
    sendMessage(log, AFTER_COMPLETE_EVENT_TYPE);
}
Also used : ProcessInstanceLog(org.jbpm.process.audit.ProcessInstanceLog)

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