Search in sources :

Example 11 with HistoricData

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

the class HistoricJPAVariableTest method testGetJPAEntityAsHistoricLog.

@Deployment
public void testGetJPAEntityAsHistoricLog() {
    setupJPAEntities();
    // -----------------------------------------------------------------------------
    // Simple test, Start process with JPA entities as variables
    // -----------------------------------------------------------------------------
    Map<String, Object> variables = new HashMap<String, Object>();
    variables.put("simpleEntityFieldAccess", simpleEntityFieldAccess);
    // Start the process with the JPA-entities as variables. They will be stored in the DB.
    this.processInstanceId = runtimeService.startProcessInstanceByKey("JPAVariableProcess", variables).getId();
    // Finish tasks
    for (Task task : taskService.createTaskQuery().includeTaskLocalVariables().list()) {
        taskService.complete(task.getId());
    }
    // Get JPAEntity Variable by ProcessInstanceHistoryLogQuery
    ProcessInstanceHistoryLog log = historyService.createProcessInstanceHistoryLogQuery(processInstanceId).includeVariables().singleResult();
    List<HistoricData> events = log.getHistoricData();
    for (HistoricData event : events) {
        Object value = ((HistoricVariableInstanceEntity) event).getValue();
        assertTrue(value instanceof FieldAccessJPAEntity);
        assertEquals(((FieldAccessJPAEntity) value).getValue(), simpleEntityFieldAccess.getValue());
    }
}
Also used : Task(org.activiti.engine.task.Task) HistoricData(org.activiti.engine.history.HistoricData) HashMap(java.util.HashMap) ProcessInstanceHistoryLog(org.activiti.engine.history.ProcessInstanceHistoryLog) HistoricVariableInstanceEntity(org.activiti.engine.impl.persistence.entity.HistoricVariableInstanceEntity) Deployment(org.activiti.engine.test.Deployment)

Example 12 with HistoricData

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

the class HistoricJPAVariableTest method testGetJPAUpdateEntityAsHistoricLog.

@Deployment(resources = { "org/activiti/standalone/jpa/HistoricJPAVariableTest.testGetJPAEntityAsHistoricLog.bpmn20.xml" })
public void testGetJPAUpdateEntityAsHistoricLog() {
    setupJPAEntities();
    // -----------------------------------------------------------------------------
    // Simple test, Start process with JPA entities as variables
    // -----------------------------------------------------------------------------
    Map<String, Object> variables = new HashMap<String, Object>();
    variables.put("simpleEntityFieldAccess", simpleEntityFieldAccess);
    // Start the process with the JPA-entities as variables. They will be stored in the DB.
    this.processInstanceId = runtimeService.startProcessInstanceByKey("JPAVariableProcess", variables).getId();
    // Finish tasks
    for (Task task : taskService.createTaskQuery().includeProcessVariables().list()) {
        taskService.setVariable(task.getId(), "simpleEntityFieldAccess", simpleEntityFieldAccess);
        taskService.complete(task.getId());
    }
    // Get JPAEntity Variable by ProcessInstanceHistoryLogQuery
    ProcessInstanceHistoryLog log = historyService.createProcessInstanceHistoryLogQuery(processInstanceId).includeVariableUpdates().singleResult();
    List<HistoricData> events = log.getHistoricData();
    for (HistoricData event : events) {
        Object value = ((HistoricDetailVariableInstanceUpdateEntity) event).getValue();
        assertTrue(value instanceof FieldAccessJPAEntity);
        assertEquals(((FieldAccessJPAEntity) value).getValue(), simpleEntityFieldAccess.getValue());
    }
}
Also used : Task(org.activiti.engine.task.Task) HistoricData(org.activiti.engine.history.HistoricData) HashMap(java.util.HashMap) ProcessInstanceHistoryLog(org.activiti.engine.history.ProcessInstanceHistoryLog) HistoricDetailVariableInstanceUpdateEntity(org.activiti.engine.impl.persistence.entity.HistoricDetailVariableInstanceUpdateEntity) Deployment(org.activiti.engine.test.Deployment)

Aggregations

HistoricData (org.activiti.engine.history.HistoricData)12 ProcessInstanceHistoryLog (org.activiti.engine.history.ProcessInstanceHistoryLog)11 HistoricVariableInstance (org.activiti.engine.history.HistoricVariableInstance)4 HistoricVariableUpdate (org.activiti.engine.history.HistoricVariableUpdate)3 HashMap (java.util.HashMap)2 HistoricActivityInstance (org.activiti.engine.history.HistoricActivityInstance)2 HistoricTaskInstance (org.activiti.engine.history.HistoricTaskInstance)2 HistoricVariableInstanceEntity (org.activiti.engine.impl.persistence.entity.HistoricVariableInstanceEntity)2 Comment (org.activiti.engine.task.Comment)2 Task (org.activiti.engine.task.Task)2 Deployment (org.activiti.engine.test.Deployment)2 HistoricDetailVariableInstanceUpdateEntity (org.activiti.engine.impl.persistence.entity.HistoricDetailVariableInstanceUpdateEntity)1 HistoricProcessInstanceEntity (org.activiti.engine.impl.persistence.entity.HistoricProcessInstanceEntity)1 CacheableVariable (org.activiti.engine.impl.variable.CacheableVariable)1