Search in sources :

Example 66 with HistoricProcessInstance

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

the class HistoricProcessInstanceQueryTest method testLocalization.

@Deployment
public void testLocalization() throws Exception {
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("historicProcessLocalization");
    String processInstanceId = processInstance.getId();
    Task task = taskService.createTaskQuery().processInstanceId(processInstanceId).singleResult();
    taskService.complete(task.getId());
    if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.ACTIVITY)) {
        List<HistoricProcessInstance> processes = historyService.createHistoricProcessInstanceQuery().processInstanceId(processInstanceId).list();
        assertEquals(1, processes.size());
        assertNull(processes.get(0).getName());
        assertNull(processes.get(0).getDescription());
        ObjectNode infoNode = dynamicBpmnService.changeLocalizationName("en-GB", "historicProcessLocalization", "Historic Process Name 'en-GB'");
        dynamicBpmnService.changeLocalizationDescription("en-GB", "historicProcessLocalization", "Historic Process Description 'en-GB'", infoNode);
        dynamicBpmnService.saveProcessDefinitionInfo(processInstance.getProcessDefinitionId(), infoNode);
        dynamicBpmnService.changeLocalizationName("en", "historicProcessLocalization", "Historic Process Name 'en'", infoNode);
        dynamicBpmnService.changeLocalizationDescription("en", "historicProcessLocalization", "Historic Process Description 'en'", infoNode);
        dynamicBpmnService.saveProcessDefinitionInfo(processInstance.getProcessDefinitionId(), infoNode);
        processes = historyService.createHistoricProcessInstanceQuery().processInstanceId(processInstanceId).list();
        assertEquals(1, processes.size());
        assertNull(processes.get(0).getName());
        assertNull(processes.get(0).getDescription());
        processes = historyService.createHistoricProcessInstanceQuery().processInstanceId(processInstanceId).locale("en-GB").list();
        assertEquals(1, processes.size());
        assertEquals("Historic Process Name 'en-GB'", processes.get(0).getName());
        assertEquals("Historic Process Description 'en-GB'", processes.get(0).getDescription());
        processes = historyService.createHistoricProcessInstanceQuery().processInstanceId(processInstanceId).listPage(0, 10);
        assertEquals(1, processes.size());
        assertNull(processes.get(0).getName());
        assertNull(processes.get(0).getDescription());
        processes = historyService.createHistoricProcessInstanceQuery().processInstanceId(processInstanceId).locale("en-GB").listPage(0, 10);
        assertEquals(1, processes.size());
        assertEquals("Historic Process Name 'en-GB'", processes.get(0).getName());
        assertEquals("Historic Process Description 'en-GB'", processes.get(0).getDescription());
        HistoricProcessInstance process = historyService.createHistoricProcessInstanceQuery().processInstanceId(processInstanceId).singleResult();
        assertNull(process.getName());
        assertNull(process.getDescription());
        process = historyService.createHistoricProcessInstanceQuery().processInstanceId(processInstanceId).locale("en-GB").singleResult();
        assertEquals("Historic Process Name 'en-GB'", process.getName());
        assertEquals("Historic Process Description 'en-GB'", process.getDescription());
        process = historyService.createHistoricProcessInstanceQuery().processInstanceId(processInstanceId).locale("en").singleResult();
        assertEquals("Historic Process Name 'en'", process.getName());
        assertEquals("Historic Process Description 'en'", process.getDescription());
        process = historyService.createHistoricProcessInstanceQuery().processInstanceId(processInstanceId).locale("en-AU").withLocalizationFallback().singleResult();
        assertEquals("Historic Process Name 'en'", process.getName());
        assertEquals("Historic Process Description 'en'", process.getDescription());
    }
}
Also used : Task(org.activiti.engine.task.Task) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) 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 67 with HistoricProcessInstance

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

the class HistoryServiceTest method testQueryEqualsIgnoreCase.

@Deployment(resources = { "org/activiti/engine/test/api/oneTaskProcess.bpmn20.xml" })
public void testQueryEqualsIgnoreCase() {
    Map<String, Object> vars = new HashMap<String, Object>();
    vars.put("mixed", "AbCdEfG");
    vars.put("lower", "ABCDEFG");
    vars.put("upper", "abcdefg");
    ProcessInstance processInstance1 = runtimeService.startProcessInstanceByKey("oneTaskProcess", vars);
    HistoricProcessInstance instance = historyService.createHistoricProcessInstanceQuery().variableValueEqualsIgnoreCase("mixed", "abcdefg").singleResult();
    assertNotNull(instance);
    assertEquals(processInstance1.getId(), instance.getId());
    instance = historyService.createHistoricProcessInstanceQuery().variableValueEqualsIgnoreCase("lower", "abcdefg").singleResult();
    assertNotNull(instance);
    assertEquals(processInstance1.getId(), instance.getId());
    instance = historyService.createHistoricProcessInstanceQuery().variableValueEqualsIgnoreCase("upper", "abcdefg").singleResult();
    assertNotNull(instance);
    assertEquals(processInstance1.getId(), instance.getId());
    // Pass in non-lower-case string
    instance = historyService.createHistoricProcessInstanceQuery().variableValueEqualsIgnoreCase("upper", "ABCdefg").singleResult();
    assertNotNull(instance);
    assertEquals(processInstance1.getId(), instance.getId());
    // Pass in null-value, should cause exception
    try {
        historyService.createHistoricProcessInstanceQuery().variableValueEqualsIgnoreCase("upper", null).singleResult();
        fail("Exception expected");
    } catch (ActivitiIllegalArgumentException ae) {
        assertEquals("value is null", ae.getMessage());
    }
    // Pass in null name, should cause exception
    try {
        historyService.createHistoricProcessInstanceQuery().variableValueEqualsIgnoreCase(null, "abcdefg").singleResult();
        fail("Exception expected");
    } catch (ActivitiIllegalArgumentException ae) {
        assertEquals("name is null", ae.getMessage());
    }
}
Also used : HashMap(java.util.HashMap) ActivitiIllegalArgumentException(org.activiti.engine.ActivitiIllegalArgumentException) 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 68 with HistoricProcessInstance

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

the class HistoricProcessInstanceQueryEscapeClauseTest method testQueryByProcessInstanceNameLikeIgnoreCase.

@Test
public void testQueryByProcessInstanceNameLikeIgnoreCase() {
    if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.ACTIVITY)) {
        // processInstanceNameLike
        HistoricProcessInstance historicProcessInstance = historyService.createHistoricProcessInstanceQuery().processInstanceNameLikeIgnoreCase("%\\%%").singleResult();
        assertNotNull(historicProcessInstance);
        assertEquals(processInstance1.getId(), historicProcessInstance.getId());
        historicProcessInstance = historyService.createHistoricProcessInstanceQuery().processInstanceNameLikeIgnoreCase("%\\_%").singleResult();
        assertNotNull(historicProcessInstance);
        assertEquals(processInstance2.getId(), historicProcessInstance.getId());
        // orQuery
        historicProcessInstance = historyService.createHistoricProcessInstanceQuery().or().processInstanceNameLikeIgnoreCase("%\\%%").processDefinitionId("undefined").singleResult();
        assertNotNull(historicProcessInstance);
        assertEquals(processInstance1.getId(), historicProcessInstance.getId());
        historicProcessInstance = historyService.createHistoricProcessInstanceQuery().or().processInstanceNameLikeIgnoreCase("%\\_%").processDefinitionId("undefined").singleResult();
        assertNotNull(historicProcessInstance);
        assertEquals(processInstance2.getId(), historicProcessInstance.getId());
    }
}
Also used : HistoricProcessInstance(org.activiti.engine.history.HistoricProcessInstance) Test(org.junit.Test)

Example 69 with HistoricProcessInstance

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

the class HistoricProcessInstanceQueryEscapeClauseTest method testQueryLikeIgnoreCaseByQueryVariableValue.

@Test
public void testQueryLikeIgnoreCaseByQueryVariableValue() {
    if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.ACTIVITY)) {
        // queryVariableValueIgnoreCase
        HistoricProcessInstance historicProcessInstance = historyService.createHistoricProcessInstanceQuery().variableValueLikeIgnoreCase("var1", "%\\%%").singleResult();
        assertNotNull(historicProcessInstance);
        assertEquals(processInstance1.getId(), historicProcessInstance.getId());
        historicProcessInstance = historyService.createHistoricProcessInstanceQuery().variableValueLikeIgnoreCase("var1", "%\\_%").singleResult();
        assertNotNull(historicProcessInstance);
        assertEquals(processInstance2.getId(), historicProcessInstance.getId());
        // orQuery
        historicProcessInstance = historyService.createHistoricProcessInstanceQuery().or().variableValueLikeIgnoreCase("var1", "%\\%%").processDefinitionId("undefined").singleResult();
        assertNotNull(historicProcessInstance);
        assertEquals(processInstance1.getId(), historicProcessInstance.getId());
        historicProcessInstance = historyService.createHistoricProcessInstanceQuery().or().variableValueLikeIgnoreCase("var1", "%\\_%").processDefinitionId("undefined").singleResult();
        assertNotNull(historicProcessInstance);
        assertEquals(processInstance2.getId(), historicProcessInstance.getId());
    }
}
Also used : HistoricProcessInstance(org.activiti.engine.history.HistoricProcessInstance) Test(org.junit.Test)

Example 70 with HistoricProcessInstance

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

the class HistoricProcessInstanceQueryEscapeClauseTest method testQueryLikeByQueryVariableValue.

@Test
public void testQueryLikeByQueryVariableValue() {
    if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.ACTIVITY)) {
        // queryVariableValue
        HistoricProcessInstance historicProcessInstance = historyService.createHistoricProcessInstanceQuery().variableValueLike("var1", "%\\%%").singleResult();
        assertNotNull(historicProcessInstance);
        assertEquals(processInstance1.getId(), historicProcessInstance.getId());
        historicProcessInstance = historyService.createHistoricProcessInstanceQuery().variableValueLike("var1", "%\\_%").singleResult();
        assertNotNull(historicProcessInstance);
        assertEquals(processInstance2.getId(), historicProcessInstance.getId());
        // orQuery
        historicProcessInstance = historyService.createHistoricProcessInstanceQuery().or().variableValueLike("var1", "%\\%%").processDefinitionId("undefined").singleResult();
        assertNotNull(historicProcessInstance);
        assertEquals(processInstance1.getId(), historicProcessInstance.getId());
        historicProcessInstance = historyService.createHistoricProcessInstanceQuery().or().variableValueLike("var1", "%\\_%").processDefinitionId("undefined").singleResult();
        assertNotNull(historicProcessInstance);
        assertEquals(processInstance2.getId(), historicProcessInstance.getId());
    }
}
Also used : HistoricProcessInstance(org.activiti.engine.history.HistoricProcessInstance) Test(org.junit.Test)

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