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;
}
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;
}
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);
}
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());
}
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());
}
Aggregations