use of org.activiti.engine.history.HistoricVariableInstance in project Activiti by Activiti.
the class EmptyProcessTest method testRunProcessWithHeader.
@Deployment(resources = { "process/empty.bpmn20.xml" })
public void testRunProcessWithHeader() throws Exception {
CamelContext ctx = applicationContext.getBean(CamelContext.class);
ProducerTemplate tpl = camelContext.createProducerTemplate();
String body = "body text";
Exchange exchange = ctx.getEndpoint("direct:startEmptyWithHeader").createExchange();
exchange.getIn().setBody(body);
tpl.send("direct:startEmptyWithHeader", exchange);
String instanceId = (String) exchange.getProperty("PROCESS_ID_PROPERTY");
assertProcessEnded(instanceId);
HistoricVariableInstance var = processEngine.getHistoryService().createHistoricVariableInstanceQuery().variableName("camelBody").singleResult();
assertNotNull(var);
assertEquals(body, var.getValue());
var = processEngine.getHistoryService().createHistoricVariableInstanceQuery().variableName("MyVar").singleResult();
assertNotNull(var);
assertEquals("Foo", var.getValue());
}
use of org.activiti.engine.history.HistoricVariableInstance in project Activiti by Activiti.
the class EmptyProcessTest method testObjectAsVariable.
@Deployment(resources = { "process/empty.bpmn20.xml" })
public void testObjectAsVariable() throws Exception {
CamelContext ctx = applicationContext.getBean(CamelContext.class);
ProducerTemplate tpl = ctx.createProducerTemplate();
Object expectedObj = new Long(99);
Exchange exchange = ctx.getEndpoint("direct:startEmpty").createExchange();
exchange.getIn().setBody(expectedObj);
tpl.send("direct:startEmpty", exchange);
String instanceId = (String) exchange.getProperty("PROCESS_ID_PROPERTY");
assertProcessEnded(instanceId);
HistoricVariableInstance var = processEngine.getHistoryService().createHistoricVariableInstanceQuery().variableName("camelBody").singleResult();
assertNotNull(var);
assertEquals(expectedObj, var.getValue());
}
use of org.activiti.engine.history.HistoricVariableInstance in project Activiti by Activiti.
the class ProcessInstanceLogQueryAndByteArrayTypeVariableTest method testIncludeVariableUpdates.
public void testIncludeVariableUpdates() {
if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.FULL)) {
HistoricVariableInstance historicVariableInstance = historyService.createHistoricVariableInstanceQuery().processInstanceId(processInstanceId).variableName("var").singleResult();
assertEquals(historicVariableInstance.getValue(), LARGE_STRING_VALUE);
ProcessInstanceHistoryLog log = historyService.createProcessInstanceHistoryLogQuery(processInstanceId).includeVariableUpdates().singleResult();
List<HistoricData> events = log.getHistoricData();
assertEquals(1, events.size());
for (HistoricData event : events) {
assertTrue(event instanceof HistoricVariableUpdate);
assertEquals(((HistoricDetailVariableInstanceUpdateEntity) event).getValue(), LARGE_STRING_VALUE);
}
}
}
use of org.activiti.engine.history.HistoricVariableInstance in project Activiti by Activiti.
the class ProcessInstanceLogQueryAndByteArrayTypeVariableTest method testIncludeVariables.
public void testIncludeVariables() {
if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.FULL)) {
HistoricVariableInstance historicVariableInstance = historyService.createHistoricVariableInstanceQuery().processInstanceId(processInstanceId).variableName("var").singleResult();
assertEquals(historicVariableInstance.getValue(), LARGE_STRING_VALUE);
ProcessInstanceHistoryLog log = historyService.createProcessInstanceHistoryLogQuery(processInstanceId).includeVariables().singleResult();
List<HistoricData> events = log.getHistoricData();
assertEquals(1, events.size());
for (HistoricData event : events) {
assertTrue(event instanceof HistoricVariableInstance);
assertEquals(((HistoricVariableInstanceEntity) event).getValue(), LARGE_STRING_VALUE);
}
}
}
use of org.activiti.engine.history.HistoricVariableInstance in project Activiti by Activiti.
the class RestResponseFactory method createProcessInstanceResponse.
public ProcessInstanceResponse createProcessInstanceResponse(ProcessInstance processInstance, boolean returnVariables, Map<String, Object> runtimeVariableMap, List<HistoricVariableInstance> historicVariableList) {
RestUrlBuilder urlBuilder = createUrlBuilder();
ProcessInstanceResponse result = new ProcessInstanceResponse();
result.setActivityId(processInstance.getActivityId());
result.setBusinessKey(processInstance.getBusinessKey());
result.setId(processInstance.getId());
result.setName(processInstance.getName());
result.setProcessDefinitionId(processInstance.getProcessDefinitionId());
result.setProcessDefinitionUrl(urlBuilder.buildUrl(RestUrls.URL_PROCESS_DEFINITION, processInstance.getProcessDefinitionId()));
result.setProcessDefinitionKey(processInstance.getProcessDefinitionKey());
result.setEnded(processInstance.isEnded());
result.setSuspended(processInstance.isSuspended());
result.setUrl(urlBuilder.buildUrl(RestUrls.URL_PROCESS_INSTANCE, processInstance.getId()));
result.setTenantId(processInstance.getTenantId());
//Added by Ryan Johnston
if (processInstance.isEnded()) {
//Process complete. Note the same in the result.
result.setCompleted(true);
} else {
//Process not complete. Note the same in the result.
result.setCompleted(false);
}
if (returnVariables) {
if (processInstance.isEnded()) {
if (historicVariableList != null) {
for (HistoricVariableInstance historicVariable : historicVariableList) {
result.addVariable(createRestVariable(historicVariable.getVariableName(), historicVariable.getValue(), RestVariableScope.LOCAL, processInstance.getId(), VARIABLE_PROCESS, false, urlBuilder));
}
}
} else {
if (runtimeVariableMap != null) {
for (String name : runtimeVariableMap.keySet()) {
result.addVariable(createRestVariable(name, runtimeVariableMap.get(name), RestVariableScope.LOCAL, processInstance.getId(), VARIABLE_PROCESS, false, urlBuilder));
}
}
}
}
return result;
}
Aggregations