Search in sources :

Example 1 with StandaloneJtaStrategy

use of org.jbpm.process.audit.strategy.StandaloneJtaStrategy in project jbpm by kiegroup.

the class AuditTaskDeleteTest method setUp.

@Before
public void setUp() throws Exception {
    context = setupWithPoolingDataSource("org.jbpm.services.task", "jdbc/jbpm-ds");
    emf = (EntityManagerFactory) context.get(ENTITY_MANAGER_FACTORY);
    this.persistenceStrategy = new StandaloneJtaStrategy(emf);
    produceTaskInstances();
}
Also used : StandaloneJtaStrategy(org.jbpm.process.audit.strategy.StandaloneJtaStrategy) Before(org.junit.Before)

Example 2 with StandaloneJtaStrategy

use of org.jbpm.process.audit.strategy.StandaloneJtaStrategy in project jbpm by kiegroup.

the class AuditDeleteTest method setUp.

@Before
public void setUp() throws Exception {
    context = setupWithPoolingDataSource(JBPM_PERSISTENCE_UNIT_NAME);
    emf = (EntityManagerFactory) context.get(ENTITY_MANAGER_FACTORY);
    this.persistenceStrategy = new StandaloneJtaStrategy(emf);
    if (firstRun) {
        clearTables(ProcessInstanceLog.class, VariableInstanceLog.class, NodeInstanceLog.class);
        firstRun = false;
    }
    if (pilTestData == null) {
        pilTestData = createTestProcessInstanceLogData();
        vilTestData = createTestVariableInstanceLogData();
        nilTestData = createTestNodeInstanceLogData();
    }
}
Also used : StandaloneJtaStrategy(org.jbpm.process.audit.strategy.StandaloneJtaStrategy) Before(org.junit.Before)

Example 3 with StandaloneJtaStrategy

use of org.jbpm.process.audit.strategy.StandaloneJtaStrategy in project jbpm by kiegroup.

the class AuditDeleteTest method createTestProcessInstanceLogData.

private ProcessInstanceLog[] createTestProcessInstanceLogData() {
    StandaloneJtaStrategy jtaHelper = new StandaloneJtaStrategy(emf);
    EntityManager em = jtaHelper.getEntityManager();
    int numEntities = 11;
    ProcessInstanceLog[] testData = new ProcessInstanceLog[numEntities];
    Calendar cal = randomCal();
    for (int i = 0; i < numEntities; ++i) {
        ProcessInstanceLog pil = new ProcessInstanceLog(randomLong(), 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(random.nextInt());
        cal.add(Calendar.MINUTE, 1);
        pil.setStart(cal.getTime());
        cal.add(Calendar.DAY_OF_YEAR, 1);
        pil.setEnd(cal.getTime());
        testData[i] = pil;
    }
    for (int i = 0; i < numEntities; ++i) {
        switch(i) {
            case 1:
                testData[i - 1].setDuration(testData[i].getDuration());
                break;
            case 2:
                testData[i - 1].setEnd(testData[i].getEnd());
                break;
            case 3:
                testData[i - 1].setIdentity(testData[i].getIdentity());
                break;
            case 4:
                testData[i - 1].setProcessId(testData[i].getProcessId());
                break;
            case 5:
                testData[i - 1].setProcessInstanceId(testData[i].getProcessInstanceId());
                break;
            case 6:
                testData[i - 1].setProcessName(testData[i].getProcessName());
                break;
            case 7:
                testData[i - 1].setProcessVersion(testData[i].getProcessVersion());
                break;
            case 8:
                testData[i - 1].setStart(testData[i].getStart());
                break;
            case 9:
                testData[i - 1].setStatus(testData[i].getStatus());
                break;
            case 10:
                testData[i - 1].setOutcome(testData[i].getOutcome());
                break;
        }
    }
    Object tx = jtaHelper.joinTransaction(em);
    for (int i = 0; i < numEntities; ++i) {
        em.persist(testData[i]);
    }
    jtaHelper.leaveTransaction(em, tx);
    return testData;
}
Also used : 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 4 with StandaloneJtaStrategy

use of org.jbpm.process.audit.strategy.StandaloneJtaStrategy in project jbpm by kiegroup.

the class AuditQueryCoverageTest method setUp.

@Before
public void setUp() throws Exception {
    if (pilTestData == null) {
        // this is not really necessary..
        pilTestData = createTestProcessInstanceLogData(emf);
        vilTestData = createTestVariableInstanceLogData(emf);
        nilTestData = createTestNodeInstanceLogData(emf);
    }
    this.persistenceStrategy = new StandaloneJtaStrategy(emf);
}
Also used : StandaloneJtaStrategy(org.jbpm.process.audit.strategy.StandaloneJtaStrategy) Before(org.junit.Before)

Example 5 with StandaloneJtaStrategy

use of org.jbpm.process.audit.strategy.StandaloneJtaStrategy in project jbpm by kiegroup.

the class AuditQueryDataUtil method createTestProcessInstanceLogData.

static ProcessInstanceLog[] createTestProcessInstanceLogData(EntityManagerFactory emf) {
    StandaloneJtaStrategy jtaHelper = new StandaloneJtaStrategy(emf);
    EntityManager em = jtaHelper.getEntityManager();
    int numEntities = 11;
    ProcessInstanceLog[] testData = new ProcessInstanceLog[numEntities];
    Calendar cal = randomCal();
    for (int i = 0; i < numEntities; ++i) {
        ProcessInstanceLog pil = new ProcessInstanceLog(randomLong(), 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(random.nextInt());
        pil.setCorrelationKey(randomString());
        cal.add(Calendar.MINUTE, 1);
        pil.setStart(cal.getTime());
        cal.add(Calendar.DAY_OF_YEAR, 1);
        pil.setEnd(cal.getTime());
        testData[i] = pil;
    }
    for (int i = 0; i < numEntities; ++i) {
        switch(i) {
            case 1:
                testData[i - 1].setDuration(testData[i].getDuration());
                break;
            case 2:
                testData[i - 1].setEnd(testData[i].getEnd());
                break;
            case 3:
                testData[i - 1].setIdentity(testData[i].getIdentity());
                break;
            case 4:
                testData[i - 1].setProcessId(testData[i].getProcessId());
                break;
            case 5:
                testData[i - 1].setProcessInstanceId(testData[i].getProcessInstanceId());
                break;
            case 6:
                testData[i - 1].setProcessName(testData[i].getProcessName());
                break;
            case 7:
                testData[i - 1].setProcessVersion(testData[i].getProcessVersion());
                break;
            case 8:
                testData[i - 1].setStart(testData[i].getStart());
                break;
            case 9:
                testData[i - 1].setStatus(testData[i].getStatus());
                break;
            case 10:
                testData[i - 1].setOutcome(testData[i].getOutcome());
                break;
        }
    }
    Object tx = jtaHelper.joinTransaction(em);
    for (int i = 0; i < numEntities; ++i) {
        em.persist(testData[i]);
    }
    jtaHelper.leaveTransaction(em, tx);
    createdEntities.addAll(Arrays.asList(testData));
    return testData;
}
Also used : StandaloneJtaStrategy(org.jbpm.process.audit.strategy.StandaloneJtaStrategy) EntityManager(javax.persistence.EntityManager) GregorianCalendar(java.util.GregorianCalendar) Calendar(java.util.Calendar) ProcessInstanceLog(org.jbpm.process.audit.ProcessInstanceLog)

Aggregations

StandaloneJtaStrategy (org.jbpm.process.audit.strategy.StandaloneJtaStrategy)15 EntityManager (javax.persistence.EntityManager)10 Calendar (java.util.Calendar)7 GregorianCalendar (java.util.GregorianCalendar)7 ProcessInstanceLog (org.jbpm.process.audit.ProcessInstanceLog)5 Before (org.junit.Before)4 VariableInstanceLog (org.jbpm.process.audit.VariableInstanceLog)3 NodeInstanceLog (org.jbpm.process.audit.NodeInstanceLog)2 ArrayList (java.util.ArrayList)1 JPATaskLifeCycleEventListener (org.jbpm.services.task.audit.JPATaskLifeCycleEventListener)1 BAMTaskEventListener (org.jbpm.services.task.lifecycle.listeners.BAMTaskEventListener)1 TaskFluent (org.jbpm.services.task.utils.TaskFluent)1 Task (org.kie.api.task.model.Task)1 AuditTask (org.kie.internal.task.api.AuditTask)1 InternalTaskService (org.kie.internal.task.api.InternalTaskService)1