Search in sources :

Example 21 with HistoricDetail

use of org.camunda.bpm.engine.history.HistoricDetail in project camunda-bpm-platform by camunda.

the class HistoricDetailQueryImpl method executeList.

public List<HistoricDetail> executeList(CommandContext commandContext, Page page) {
    checkQueryOk();
    List<HistoricDetail> historicDetails = commandContext.getHistoricDetailManager().findHistoricDetailsByQueryCriteria(this, page);
    if (historicDetails != null) {
        for (HistoricDetail historicDetail : historicDetails) {
            if (historicDetail instanceof HistoricDetailVariableInstanceUpdateEntity) {
                HistoricDetailVariableInstanceUpdateEntity entity = (HistoricDetailVariableInstanceUpdateEntity) historicDetail;
                if (shouldFetchValue(entity)) {
                    try {
                        entity.getTypedValue(isCustomObjectDeserializationEnabled);
                    } catch (Exception t) {
                        // do not fail if one of the variables fails to load
                        LOG.exceptionWhileGettingValueForVariable(t);
                    }
                }
            }
        }
    }
    return historicDetails;
}
Also used : HistoricDetail(org.camunda.bpm.engine.history.HistoricDetail) HistoricDetailVariableInstanceUpdateEntity(org.camunda.bpm.engine.impl.persistence.entity.HistoricDetailVariableInstanceUpdateEntity)

Example 22 with HistoricDetail

use of org.camunda.bpm.engine.history.HistoricDetail in project camunda-bpm-platform by camunda.

the class RestartProcessInstancesCmd method collectInitialVariables.

protected VariableMap collectInitialVariables(CommandContext commandContext, HistoricProcessInstance processInstance) {
    HistoryService historyService = commandContext.getProcessEngineConfiguration().getHistoryService();
    HistoricActivityInstance startActivityInstance = resolveStartActivityInstance(processInstance);
    HistoricDetailQueryImpl query = (HistoricDetailQueryImpl) historyService.createHistoricDetailQuery().variableUpdates().executionId(processInstance.getId()).activityInstanceId(startActivityInstance.getId());
    List<HistoricDetail> historicDetails = query.sequenceCounter(1).list();
    VariableMap variables = new VariableMapImpl();
    for (HistoricDetail detail : historicDetails) {
        HistoricVariableUpdate variableUpdate = (HistoricVariableUpdate) detail;
        variables.putValueTyped(variableUpdate.getVariableName(), variableUpdate.getTypedValue());
    }
    return variables;
}
Also used : HistoricVariableUpdate(org.camunda.bpm.engine.history.HistoricVariableUpdate) HistoricDetail(org.camunda.bpm.engine.history.HistoricDetail) VariableMapImpl(org.camunda.bpm.engine.variable.impl.VariableMapImpl) VariableMap(org.camunda.bpm.engine.variable.VariableMap) HistoricDetailQueryImpl(org.camunda.bpm.engine.impl.HistoricDetailQueryImpl) HistoryService(org.camunda.bpm.engine.HistoryService) HistoricActivityInstance(org.camunda.bpm.engine.history.HistoricActivityInstance)

Example 23 with HistoricDetail

use of org.camunda.bpm.engine.history.HistoricDetail in project camunda-bpm-platform by camunda.

the class FullHistoryTest method testBinaryFetchingDisabled.

@Test
public void testBinaryFetchingDisabled() {
    Task newTask = taskService.newTask();
    taskService.saveTask(newTask);
    String variableName = "binaryVariableName";
    taskService.setVariable(newTask.getId(), variableName, "some bytes".getBytes());
    HistoricDetail result = historyService.createHistoricDetailQuery().disableBinaryFetching().variableUpdates().singleResult();
    assertNull(((HistoricVariableUpdate) result).getValue());
    taskService.deleteTask(newTask.getId(), true);
}
Also used : HistoricDetail(org.camunda.bpm.engine.history.HistoricDetail) Task(org.camunda.bpm.engine.task.Task) Test(org.junit.Test)

Example 24 with HistoricDetail

use of org.camunda.bpm.engine.history.HistoricDetail in project camunda-bpm-platform by camunda.

the class FullHistoryTest method testHistoricFormProperties.

@Test
@Deployment
public void testHistoricFormProperties() throws Exception {
    Date startedDate = new SimpleDateFormat("dd/MM/yyyy hh:mm:ss SSS").parse("01/01/2001 01:23:46 000");
    ClockUtil.setCurrentTime(startedDate);
    Map<String, String> formProperties = new HashMap<String, String>();
    formProperties.put("formProp1", "Activiti rocks");
    formProperties.put("formProp2", "12345");
    ProcessDefinition procDef = repositoryService.createProcessDefinitionQuery().processDefinitionKey("historicFormPropertiesProcess").singleResult();
    ProcessInstance processInstance = formService.submitStartFormData(procDef.getId(), formProperties);
    // Submit form-properties on the created task
    Task task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult();
    assertNotNull(task);
    // Out execution only has a single activity waiting, the task
    List<String> activityIds = runtimeService.getActiveActivityIds(task.getExecutionId());
    assertNotNull(activityIds);
    assertEquals(1, activityIds.size());
    String taskActivityId = activityIds.get(0);
    // Submit form properties
    formProperties = new HashMap<String, String>();
    formProperties.put("formProp3", "Activiti still rocks!!!");
    formProperties.put("formProp4", "54321");
    formService.submitTaskFormData(task.getId(), formProperties);
    // 4 historic form properties should be created. 2 when process started, 2 when task completed
    List<HistoricDetail> props = historyService.createHistoricDetailQuery().formProperties().processInstanceId(processInstance.getId()).orderByFormPropertyId().asc().list();
    HistoricFormProperty historicProperty1 = (HistoricFormProperty) props.get(0);
    assertEquals("formProp1", historicProperty1.getPropertyId());
    assertEquals("Activiti rocks", historicProperty1.getPropertyValue());
    assertEquals(startedDate, historicProperty1.getTime());
    assertEquals(processInstance.getId(), historicProperty1.getProcessInstanceId());
    assertNull(historicProperty1.getTaskId());
    assertNotNull(historicProperty1.getActivityInstanceId());
    HistoricActivityInstance historicActivityInstance = historyService.createHistoricActivityInstanceQuery().activityInstanceId(historicProperty1.getActivityInstanceId()).singleResult();
    assertNotNull(historicActivityInstance);
    assertEquals("start", historicActivityInstance.getActivityId());
    HistoricFormProperty historicProperty2 = (HistoricFormProperty) props.get(1);
    assertEquals("formProp2", historicProperty2.getPropertyId());
    assertEquals("12345", historicProperty2.getPropertyValue());
    assertEquals(startedDate, historicProperty2.getTime());
    assertEquals(processInstance.getId(), historicProperty2.getProcessInstanceId());
    assertNull(historicProperty2.getTaskId());
    assertNotNull(historicProperty2.getActivityInstanceId());
    historicActivityInstance = historyService.createHistoricActivityInstanceQuery().activityInstanceId(historicProperty2.getActivityInstanceId()).singleResult();
    assertNotNull(historicActivityInstance);
    assertEquals("start", historicActivityInstance.getActivityId());
    HistoricFormProperty historicProperty3 = (HistoricFormProperty) props.get(2);
    assertEquals("formProp3", historicProperty3.getPropertyId());
    assertEquals("Activiti still rocks!!!", historicProperty3.getPropertyValue());
    assertEquals(startedDate, historicProperty3.getTime());
    assertEquals(processInstance.getId(), historicProperty3.getProcessInstanceId());
    String activityInstanceId = historicProperty3.getActivityInstanceId();
    historicActivityInstance = historyService.createHistoricActivityInstanceQuery().activityInstanceId(activityInstanceId).singleResult();
    assertNotNull(historicActivityInstance);
    assertEquals(taskActivityId, historicActivityInstance.getActivityId());
    assertNotNull(historicProperty3.getTaskId());
    HistoricFormProperty historicProperty4 = (HistoricFormProperty) props.get(3);
    assertEquals("formProp4", historicProperty4.getPropertyId());
    assertEquals("54321", historicProperty4.getPropertyValue());
    assertEquals(startedDate, historicProperty4.getTime());
    assertEquals(processInstance.getId(), historicProperty4.getProcessInstanceId());
    activityInstanceId = historicProperty4.getActivityInstanceId();
    historicActivityInstance = historyService.createHistoricActivityInstanceQuery().activityInstanceId(activityInstanceId).singleResult();
    assertNotNull(historicActivityInstance);
    assertEquals(taskActivityId, historicActivityInstance.getActivityId());
    assertNotNull(historicProperty4.getTaskId());
    assertEquals(4, props.size());
}
Also used : HistoricDetail(org.camunda.bpm.engine.history.HistoricDetail) Task(org.camunda.bpm.engine.task.Task) HistoricFormProperty(org.camunda.bpm.engine.history.HistoricFormProperty) HashMap(java.util.HashMap) ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition) Date(java.util.Date) HistoricProcessInstance(org.camunda.bpm.engine.history.HistoricProcessInstance) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) SimpleDateFormat(java.text.SimpleDateFormat) HistoricActivityInstance(org.camunda.bpm.engine.history.HistoricActivityInstance) Test(org.junit.Test) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 25 with HistoricDetail

use of org.camunda.bpm.engine.history.HistoricDetail in project camunda-bpm-platform by camunda.

the class FullHistoryTest method testHistoricDetailActivityInstanceIdForInactiveScopeExecution.

@Test
@Deployment
public void testHistoricDetailActivityInstanceIdForInactiveScopeExecution() {
    ProcessInstance pi = runtimeService.startProcessInstanceByKey("testProcess");
    runtimeService.setVariable(pi.getId(), "foo", "bar");
    HistoricDetail historicDetail = historyService.createHistoricDetailQuery().singleResult();
    assertNotNull(historicDetail.getActivityInstanceId());
}
Also used : HistoricDetail(org.camunda.bpm.engine.history.HistoricDetail) HistoricProcessInstance(org.camunda.bpm.engine.history.HistoricProcessInstance) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) Test(org.junit.Test) Deployment(org.camunda.bpm.engine.test.Deployment)

Aggregations

HistoricDetail (org.camunda.bpm.engine.history.HistoricDetail)40 Deployment (org.camunda.bpm.engine.test.Deployment)23 Test (org.junit.Test)20 HistoricProcessInstance (org.camunda.bpm.engine.history.HistoricProcessInstance)14 HistoricVariableInstance (org.camunda.bpm.engine.history.HistoricVariableInstance)14 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)14 Task (org.camunda.bpm.engine.task.Task)13 HistoricActivityInstance (org.camunda.bpm.engine.history.HistoricActivityInstance)12 HistoricVariableUpdate (org.camunda.bpm.engine.history.HistoricVariableUpdate)10 HashMap (java.util.HashMap)7 ActivityInstance (org.camunda.bpm.engine.runtime.ActivityInstance)7 CaseInstance (org.camunda.bpm.engine.runtime.CaseInstance)6 ArrayList (java.util.ArrayList)3 HistoricCaseInstance (org.camunda.bpm.engine.history.HistoricCaseInstance)3 HistoricDetailVariableInstanceUpdateEntity (org.camunda.bpm.engine.impl.persistence.entity.HistoricDetailVariableInstanceUpdateEntity)3 SimpleDateFormat (java.text.SimpleDateFormat)2 Date (java.util.Date)2 HistoricDetailQuery (org.camunda.bpm.engine.history.HistoricDetailQuery)2 HistoricFormProperty (org.camunda.bpm.engine.history.HistoricFormProperty)2 HistoricVariableInstanceQuery (org.camunda.bpm.engine.history.HistoricVariableInstanceQuery)2