Search in sources :

Example 61 with HistoricProcessInstance

use of org.activiti.engine.history.HistoricProcessInstance in project Activiti by Activiti.

the class HistoryServiceTest method testHistoricProcessInstanceQueryByDeploymentIdIn.

@Deployment(resources = { "org/activiti/engine/test/api/oneTaskProcess.bpmn20.xml", "org/activiti/engine/test/api/runtime/oneTaskProcess2.bpmn20.xml" })
public void testHistoricProcessInstanceQueryByDeploymentIdIn() {
    org.activiti.engine.repository.Deployment deployment = repositoryService.createDeploymentQuery().singleResult();
    HashSet<String> processInstanceIds = new HashSet<String>();
    for (int i = 0; i < 4; i++) {
        processInstanceIds.add(runtimeService.startProcessInstanceByKey("oneTaskProcess", i + "").getId());
    }
    processInstanceIds.add(runtimeService.startProcessInstanceByKey("oneTaskProcess2", "1").getId());
    List<String> deploymentIds = new ArrayList<String>();
    deploymentIds.add(deployment.getId());
    deploymentIds.add("invalid");
    HistoricProcessInstanceQuery processInstanceQuery = historyService.createHistoricProcessInstanceQuery().deploymentIdIn(deploymentIds);
    assertEquals(5, processInstanceQuery.count());
    List<HistoricProcessInstance> processInstances = processInstanceQuery.list();
    assertNotNull(processInstances);
    assertEquals(5, processInstances.size());
    deploymentIds = new ArrayList<String>();
    deploymentIds.add("invalid");
    processInstanceQuery = historyService.createHistoricProcessInstanceQuery().deploymentIdIn(deploymentIds);
    assertEquals(0, processInstanceQuery.count());
}
Also used : HistoricProcessInstanceQuery(org.activiti.engine.history.HistoricProcessInstanceQuery) HistoricProcessInstance(org.activiti.engine.history.HistoricProcessInstance) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) Deployment(org.activiti.engine.test.Deployment)

Example 62 with HistoricProcessInstance

use of org.activiti.engine.history.HistoricProcessInstance in project Activiti by Activiti.

the class HistoryServiceTest method testExcludeSubprocesses.

@Deployment(resources = { "org/activiti/examples/bpmn/callactivity/orderProcess.bpmn20.xml", "org/activiti/examples/bpmn/callactivity/checkCreditProcess.bpmn20.xml" })
public void testExcludeSubprocesses() {
    ProcessInstance pi = runtimeService.startProcessInstanceByKey("orderProcess");
    HistoricProcessInstance historicProcessInstance = historyService.createHistoricProcessInstanceQuery().excludeSubprocesses(true).singleResult();
    assertNotNull(historicProcessInstance);
    assertEquals(pi.getId(), historicProcessInstance.getId());
    List<HistoricProcessInstance> instanceList = historyService.createHistoricProcessInstanceQuery().excludeSubprocesses(false).list();
    assertEquals(2, instanceList.size());
}
Also used : HistoricProcessInstance(org.activiti.engine.history.HistoricProcessInstance) HistoricProcessInstance(org.activiti.engine.history.HistoricProcessInstance) ProcessInstance(org.activiti.engine.runtime.ProcessInstance) Deployment(org.activiti.engine.test.Deployment)

Example 63 with HistoricProcessInstance

use of org.activiti.engine.history.HistoricProcessInstance in project Activiti by Activiti.

the class HistoricProcessInstanceAndVariablesQueryTest method testOrQueryByprocessDefinition.

public void testOrQueryByprocessDefinition() {
    if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.ACTIVITY)) {
        // DeploymentId
        String deploymentId = repositoryService.createDeploymentQuery().list().get(0).getId();
        HistoricProcessInstanceQuery historicprocessInstanceQuery = historyService.createHistoricProcessInstanceQuery().includeProcessVariables().or().variableValueEquals("anothertest", "invalid").deploymentId(deploymentId).endOr();
        assertEquals(6, historicprocessInstanceQuery.list().size());
        assertEquals(6, historicprocessInstanceQuery.count());
        Map<String, Object> variableMap = historicprocessInstanceQuery.list().get(4).getProcessVariables();
        assertEquals(1, variableMap.size());
        assertEquals(123, variableMap.get("anothertest"));
        for (HistoricProcessInstance processInstance : historicprocessInstanceQuery.list()) {
            assertEquals(deploymentId, processInstance.getDeploymentId());
        }
        HistoricProcessInstance processInstance = historyService.createHistoricProcessInstanceQuery().includeProcessVariables().or().variableValueEquals("anothertest", "invalid").deploymentId("invalid").endOr().singleResult();
        assertNull(processInstance);
        // ProcessDefinitionName
        processInstance = historyService.createHistoricProcessInstanceQuery().includeProcessVariables().or().variableValueEquals("anothertest", "invalid").processDefinitionName(PROCESS_DEFINITION_NAME_2).endOr().singleResult();
        variableMap = processInstance.getProcessVariables();
        assertEquals(1, variableMap.size());
        assertEquals(123, variableMap.get("anothertest"));
        assertEquals(PROCESS_DEFINITION_NAME_2, processInstance.getProcessDefinitionName());
        processInstance = historyService.createHistoricProcessInstanceQuery().includeProcessVariables().or().variableValueEquals("anothertest", "invalid").processDefinitionName("invalid").endOr().singleResult();
        assertNull(processInstance);
        // ProcessDefinitionCategory
        processInstance = historyService.createHistoricProcessInstanceQuery().includeProcessVariables().or().variableValueEquals("anothertest", "invalid").processDefinitionCategory(PROCESS_DEFINITION_CATEGORY_2).endOr().singleResult();
        variableMap = processInstance.getProcessVariables();
        assertEquals(1, variableMap.size());
        assertEquals(123, variableMap.get("anothertest"));
        processInstance = historyService.createHistoricProcessInstanceQuery().includeProcessVariables().or().variableValueEquals("anothertest", "invalid").processDefinitionCategory("invalid").endOr().singleResult();
        assertNull(processInstance);
    }
}
Also used : HistoricProcessInstanceQuery(org.activiti.engine.history.HistoricProcessInstanceQuery) HistoricProcessInstance(org.activiti.engine.history.HistoricProcessInstance)

Example 64 with HistoricProcessInstance

use of org.activiti.engine.history.HistoricProcessInstance in project Activiti by Activiti.

the class HistoricProcessInstanceAndVariablesQueryTest method testOrQueryMultipleVariableValues.

public void testOrQueryMultipleVariableValues() {
    if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.ACTIVITY)) {
        HistoricProcessInstanceQuery query0 = historyService.createHistoricProcessInstanceQuery().includeProcessVariables().or();
        for (int i = 0; i < 20; i++) {
            query0 = query0.variableValueEquals("anothertest", i);
        }
        query0 = query0.processDefinitionId("undefined").endOr();
        assertNull(query0.singleResult());
        HistoricProcessInstanceQuery query1 = historyService.createHistoricProcessInstanceQuery().includeProcessVariables().or().variableValueEquals("anothertest", 123);
        for (int i = 0; i < 20; i++) {
            query1 = query1.variableValueEquals("anothertest", i);
        }
        query1 = query1.processDefinitionId("undefined").endOr();
        HistoricProcessInstance processInstance = query1.singleResult();
        Map<String, Object> variableMap = processInstance.getProcessVariables();
        assertEquals(1, variableMap.size());
        assertEquals(123, variableMap.get("anothertest"));
        HistoricProcessInstanceQuery query2 = historyService.createHistoricProcessInstanceQuery().includeProcessVariables().or();
        for (int i = 0; i < 20; i++) {
            query2 = query2.variableValueEquals("anothertest", i);
        }
        query2 = query2.processDefinitionId("undefined").endOr().or().processDefinitionKey(PROCESS_DEFINITION_KEY_2).processDefinitionId("undefined").endOr();
        assertNull(query2.singleResult());
        HistoricProcessInstanceQuery query3 = historyService.createHistoricProcessInstanceQuery().includeProcessVariables().or().variableValueEquals("anothertest", 123);
        for (int i = 0; i < 20; i++) {
            query3 = query3.variableValueEquals("anothertest", i);
        }
        query3 = query3.processDefinitionId("undefined").endOr().or().processDefinitionKey(PROCESS_DEFINITION_KEY_2).processDefinitionId("undefined").endOr();
        variableMap = query3.singleResult().getProcessVariables();
        assertEquals(1, variableMap.size());
        assertEquals(123, variableMap.get("anothertest"));
    }
}
Also used : HistoricProcessInstanceQuery(org.activiti.engine.history.HistoricProcessInstanceQuery) HistoricProcessInstance(org.activiti.engine.history.HistoricProcessInstance)

Example 65 with HistoricProcessInstance

use of org.activiti.engine.history.HistoricProcessInstance in project Activiti by Activiti.

the class HistoricProcessInstanceAndVariablesQueryTest method testOrQuery.

public void testOrQuery() {
    if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.ACTIVITY)) {
        HistoricProcessInstance processInstance = historyService.createHistoricProcessInstanceQuery().includeProcessVariables().or().variableValueEquals("anothertest", 123).processDefinitionId("undefined").endOr().singleResult();
        Map<String, Object> variableMap = processInstance.getProcessVariables();
        assertEquals(1, variableMap.size());
        assertEquals(123, variableMap.get("anothertest"));
        processInstance = historyService.createHistoricProcessInstanceQuery().includeProcessVariables().or().variableValueEquals("anothertest", 123).processDefinitionId("undefined").endOr().or().processDefinitionKey(PROCESS_DEFINITION_KEY_2).processDefinitionId("undefined").endOr().singleResult();
        variableMap = processInstance.getProcessVariables();
        assertEquals(1, variableMap.size());
        assertEquals(123, variableMap.get("anothertest"));
        processInstance = historyService.createHistoricProcessInstanceQuery().includeProcessVariables().or().variableValueEquals("anothertest", 123).processDefinitionId("undefined").endOr().or().processDefinitionKey(PROCESS_DEFINITION_KEY).processDefinitionId("undefined").endOr().singleResult();
        assertNull(processInstance);
        processInstance = historyService.createHistoricProcessInstanceQuery().includeProcessVariables().or().variableValueLikeIgnoreCase("casetest", "mytest").processDefinitionId("undefined").endOr().singleResult();
        assertNotNull(processInstance);
        variableMap = processInstance.getProcessVariables();
        assertEquals(1, variableMap.size());
        assertEquals("MyTest", variableMap.get("casetest"));
        List<HistoricProcessInstance> instanceList = historyService.createHistoricProcessInstanceQuery().includeProcessVariables().or().processDefinitionKey(PROCESS_DEFINITION_KEY).processDefinitionId("undefined").endOr().list();
        assertEquals(4, instanceList.size());
        processInstance = instanceList.get(0);
        variableMap = processInstance.getProcessVariables();
        assertEquals(2, variableMap.size());
        assertEquals("test", variableMap.get("test"));
        assertEquals("test2", variableMap.get("test2"));
        processInstance = historyService.createHistoricProcessInstanceQuery().includeProcessVariables().or().processDefinitionKey(PROCESS_DEFINITION_KEY_2).processDefinitionId("undefined").endOr().singleResult();
        variableMap = processInstance.getProcessVariables();
        assertEquals(1, variableMap.size());
        assertEquals(123, variableMap.get("anothertest"));
        processInstance = historyService.createHistoricProcessInstanceQuery().includeProcessVariables().or().finished().processDefinitionId("undefined").endOr().singleResult();
        variableMap = processInstance.getProcessVariables();
        assertEquals(2, variableMap.size());
        assertEquals("test", variableMap.get("test"));
        assertEquals("test2", variableMap.get("test2"));
        instanceList = historyService.createHistoricProcessInstanceQuery().or().variableValueEquals("test", "test").processDefinitionId("undefined").endOr().includeProcessVariables().listPage(0, 50);
        assertEquals(4, instanceList.size());
        instanceList = historyService.createHistoricProcessInstanceQuery().or().variableValueEquals("test", "test").processDefinitionId("undefined").endOr().includeProcessVariables().listPage(0, 1);
        assertEquals(1, instanceList.size());
        processInstance = instanceList.get(0);
        variableMap = processInstance.getProcessVariables();
        assertEquals(2, variableMap.size());
        assertEquals("test", variableMap.get("test"));
        assertEquals("test2", variableMap.get("test2"));
        instanceList = historyService.createHistoricProcessInstanceQuery().includeProcessVariables().or().processDefinitionKey(PROCESS_DEFINITION_KEY).processDefinitionId("undefined").endOr().listPage(1, 2);
        assertEquals(2, instanceList.size());
        processInstance = instanceList.get(0);
        variableMap = processInstance.getProcessVariables();
        assertEquals(2, variableMap.size());
        assertEquals("test", variableMap.get("test"));
        assertEquals("test2", variableMap.get("test2"));
        instanceList = historyService.createHistoricProcessInstanceQuery().includeProcessVariables().or().processDefinitionKey(PROCESS_DEFINITION_KEY).processDefinitionId("undefined").endOr().listPage(3, 4);
        assertEquals(1, instanceList.size());
        processInstance = instanceList.get(0);
        variableMap = processInstance.getProcessVariables();
        assertEquals(2, variableMap.size());
        assertEquals("test", variableMap.get("test"));
        assertEquals("test2", variableMap.get("test2"));
        instanceList = historyService.createHistoricProcessInstanceQuery().includeProcessVariables().or().processDefinitionKey(PROCESS_DEFINITION_KEY).processDefinitionId("undefined").endOr().listPage(4, 2);
        assertEquals(0, instanceList.size());
        instanceList = historyService.createHistoricProcessInstanceQuery().or().variableValueEquals("test", "test").processDefinitionId("undefined").endOr().includeProcessVariables().orderByProcessInstanceId().asc().listPage(0, 50);
        assertEquals(4, instanceList.size());
        instanceList = historyService.createHistoricProcessInstanceQuery().or().variableValueEquals("test", "test").processDefinitionId("undefined").endOr().or().processDefinitionKey(PROCESS_DEFINITION_KEY).processDefinitionId("undefined").endOr().includeProcessVariables().orderByProcessInstanceId().asc().listPage(0, 50);
        assertEquals(4, instanceList.size());
    }
}
Also used : HistoricProcessInstance(org.activiti.engine.history.HistoricProcessInstance)

Aggregations

HistoricProcessInstance (org.activiti.engine.history.HistoricProcessInstance)74 Deployment (org.activiti.engine.test.Deployment)34 ProcessInstance (org.activiti.engine.runtime.ProcessInstance)29 Task (org.activiti.engine.task.Task)14 HistoricProcessInstanceQuery (org.activiti.engine.history.HistoricProcessInstanceQuery)9 Item (com.vaadin.data.Item)6 ArrayList (java.util.ArrayList)6 HashMap (java.util.HashMap)6 HistoricActivityInstance (org.activiti.engine.history.HistoricActivityInstance)6 HistoricTaskInstance (org.activiti.engine.history.HistoricTaskInstance)6 ProcessDefinition (org.activiti.engine.repository.ProcessDefinition)6 Test (org.junit.Test)6 Property (com.vaadin.data.Property)4 ValueChangeEvent (com.vaadin.data.Property.ValueChangeEvent)4 Table (com.vaadin.ui.Table)4 Calendar (java.util.Calendar)4 Date (java.util.Date)4 HashSet (java.util.HashSet)4 ActivitiObjectNotFoundException (org.activiti.engine.ActivitiObjectNotFoundException)4 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)3