use of org.activiti.engine.history.HistoricVariableInstance in project Activiti by Activiti.
the class RestResponseFactory method createHistoricVariableInstanceResponseList.
public List<HistoricVariableInstanceResponse> createHistoricVariableInstanceResponseList(List<HistoricVariableInstance> variableInstances) {
RestUrlBuilder urlBuilder = createUrlBuilder();
List<HistoricVariableInstanceResponse> responseList = new ArrayList<HistoricVariableInstanceResponse>();
for (HistoricVariableInstance instance : variableInstances) {
responseList.add(createHistoricVariableInstanceResponse(instance, urlBuilder));
}
return responseList;
}
use of org.activiti.engine.history.HistoricVariableInstance in project Activiti by Activiti.
the class BlueprintBasicTest method exportJavaDelegate.
@Test
public void exportJavaDelegate() throws Exception {
// wait for deployment to be done
Thread.sleep(5000);
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("osgiProcess");
assertTrue(processInstance.isEnded());
HistoricVariableInstance variable = historyService.createHistoricVariableInstanceQuery().processInstanceId(processInstance.getId()).variableName("visited").singleResult();
assertTrue((Boolean) variable.getValue());
HistoricVariableInstance activityBehaviourVisited = historyService.createHistoricVariableInstanceQuery().processInstanceId(processInstance.getId()).variableName("visitedActivityBehaviour").singleResult();
assertTrue((Boolean) activityBehaviourVisited.getValue());
}
use of org.activiti.engine.history.HistoricVariableInstance in project Activiti by Activiti.
the class FormDataResourceTest method testSubmitFormData.
@Deployment
public void testSubmitFormData() throws Exception {
Map<String, Object> variableMap = new HashMap<String, Object>();
variableMap.put("SpeakerName", "John Doe");
Address address = new Address();
variableMap.put("address", address);
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("oneTaskProcess", variableMap);
String processInstanceId = processInstance.getId();
String processDefinitionId = processInstance.getProcessDefinitionId();
Task task = taskService.createTaskQuery().processInstanceId(processInstanceId).singleResult();
ObjectNode requestNode = objectMapper.createObjectNode();
requestNode.put("taskId", task.getId());
ArrayNode propertyArray = objectMapper.createArrayNode();
requestNode.put("properties", propertyArray);
ObjectNode propNode = objectMapper.createObjectNode();
propNode.put("id", "room");
propNode.put("value", 123l);
propertyArray.add(propNode);
HttpPost httpPost = new HttpPost(SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(RestUrls.URL_FORM_DATA));
httpPost.setEntity(new StringEntity(requestNode.toString()));
closeResponse(executeRequest(httpPost, HttpStatus.SC_INTERNAL_SERVER_ERROR));
propNode = objectMapper.createObjectNode();
propNode.put("id", "street");
propNode.put("value", "test");
propertyArray.add(propNode);
httpPost.setEntity(new StringEntity(requestNode.toString()));
closeResponse(executeRequest(httpPost, HttpStatus.SC_NO_CONTENT));
task = taskService.createTaskQuery().processInstanceId(processInstanceId).singleResult();
assertNull(task);
processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(processInstanceId).singleResult();
assertNull(processInstance);
List<HistoricVariableInstance> variables = historyService.createHistoricVariableInstanceQuery().processInstanceId(processInstanceId).list();
Map<String, HistoricVariableInstance> historyMap = new HashMap<String, HistoricVariableInstance>();
for (HistoricVariableInstance historicVariableInstance : variables) {
historyMap.put(historicVariableInstance.getVariableName(), historicVariableInstance);
}
assertEquals("123", historyMap.get("room").getValue());
assertEquals(processInstanceId, historyMap.get("room").getProcessInstanceId());
processInstance = runtimeService.startProcessInstanceByKey("oneTaskProcess", variableMap);
processInstanceId = processInstance.getId();
task = taskService.createTaskQuery().processInstanceId(processInstanceId).singleResult();
requestNode.put("taskId", task.getId());
propNode = objectMapper.createObjectNode();
propNode.put("id", "direction");
propNode.put("value", "nowhere");
propertyArray.add(propNode);
httpPost.setEntity(new StringEntity(requestNode.toString()));
closeResponse(executeRequest(httpPost, HttpStatus.SC_BAD_REQUEST));
propNode.put("value", "up");
httpPost.setEntity(new StringEntity(requestNode.toString()));
closeResponse(executeRequest(httpPost, HttpStatus.SC_NO_CONTENT));
task = taskService.createTaskQuery().processInstanceId(processInstanceId).singleResult();
assertNull(task);
processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(processInstanceId).singleResult();
assertNull(processInstance);
variables = historyService.createHistoricVariableInstanceQuery().processInstanceId(processInstanceId).list();
historyMap.clear();
for (HistoricVariableInstance historicVariableInstance : variables) {
historyMap.put(historicVariableInstance.getVariableName(), historicVariableInstance);
}
assertEquals("123", historyMap.get("room").getValue());
assertEquals(processInstanceId, historyMap.get("room").getProcessInstanceId());
assertEquals("up", historyMap.get("direction").getValue());
requestNode = objectMapper.createObjectNode();
requestNode.put("processDefinitionId", processDefinitionId);
propertyArray = objectMapper.createArrayNode();
requestNode.put("properties", propertyArray);
propNode = objectMapper.createObjectNode();
propNode.put("id", "number");
propNode.put("value", 123);
propertyArray.add(propNode);
httpPost.setEntity(new StringEntity(requestNode.toString()));
CloseableHttpResponse response = executeRequest(httpPost, HttpStatus.SC_OK);
JsonNode responseNode = objectMapper.readTree(response.getEntity().getContent());
closeResponse(response);
assertNotNull(responseNode.get("id").asText());
assertEquals(processDefinitionId, responseNode.get("processDefinitionId").asText());
task = taskService.createTaskQuery().processInstanceId(responseNode.get("id").asText()).singleResult();
assertNotNull(task);
}
use of org.activiti.engine.history.HistoricVariableInstance in project Activiti by Activiti.
the class ReplayEventLogTest method testProcessInstanceStartEvents.
@Test
public void testProcessInstanceStartEvents() throws Exception {
ProcessEngineImpl processEngine = initProcessEngine();
TaskService taskService = processEngine.getTaskService();
RuntimeService runtimeService = processEngine.getRuntimeService();
ManagementService managementService = processEngine.getManagementService();
HistoryService historyService = processEngine.getHistoryService();
// record events
Map<String, Object> variables = new HashMap<String, Object>();
variables.put(TEST_VARIABLE, TEST_VALUE);
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey(USERTASK_PROCESS, BUSINESS_KEY, variables);
Task task = taskService.createTaskQuery().taskDefinitionKey("userTask").singleResult();
TimeUnit.MILLISECONDS.sleep(50);
variables = new HashMap<String, Object>();
variables.put(TASK_TEST_VARIABLE, TASK_TEST_VALUE);
taskService.complete(task.getId(), variables);
// transform log events
List<EventLogEntry> eventLogEntries = managementService.getEventLogEntries(null, null);
EventLogTransformer transformer = new EventLogTransformer(getTransformers());
List<SimulationEvent> simulationEvents = transformer.transform(eventLogEntries);
SimpleEventCalendar eventCalendar = new SimpleEventCalendar(processEngine.getProcessEngineConfiguration().getClock(), new SimulationEventComparator());
eventCalendar.addEvents(simulationEvents);
// replay process instance run
final SimulationDebugger simRun = new ReplaySimulationRun(processEngine, eventCalendar, getReplayHandlers(processInstance.getId()));
simRun.init(new NoExecutionVariableScope());
// original process is finished - there should not be any running process instance/task
assertEquals(0, runtimeService.createProcessInstanceQuery().processDefinitionKey(USERTASK_PROCESS).count());
assertEquals(0, taskService.createTaskQuery().taskDefinitionKey("userTask").count());
simRun.step();
// replay process was started
ProcessInstance replayProcessInstance = runtimeService.createProcessInstanceQuery().processDefinitionKey(USERTASK_PROCESS).singleResult();
assertNotNull(replayProcessInstance);
assertTrue(replayProcessInstance.getId().equals(processInstance.getId()) == false);
assertEquals(TEST_VALUE, runtimeService.getVariable(replayProcessInstance.getId(), TEST_VARIABLE));
// there should be one task
assertEquals(1, taskService.createTaskQuery().taskDefinitionKey("userTask").count());
simRun.step();
// userTask was completed - replay process was finished
assertEquals(0, runtimeService.createProcessInstanceQuery().processDefinitionKey(USERTASK_PROCESS).count());
assertEquals(0, taskService.createTaskQuery().taskDefinitionKey("userTask").count());
HistoricVariableInstance variableInstance = historyService.createHistoricVariableInstanceQuery().processInstanceId(replayProcessInstance.getId()).variableName(TASK_TEST_VARIABLE).singleResult();
assertNotNull(variableInstance);
assertEquals(TASK_TEST_VALUE, variableInstance.getValue());
// close simulation
simRun.close();
processEngine.close();
ProcessEngines.destroy();
}
use of org.activiti.engine.history.HistoricVariableInstance in project Activiti by Activiti.
the class SavedReportDetailPanel method initForm.
protected void initForm() {
// Report dataset is stored as historical variable as json
HistoricVariableInstance historicVariableInstance = ProcessEngines.getDefaultProcessEngine().getHistoryService().createHistoricVariableInstanceQuery().processInstanceId(historicProcessInstance.getId()).variableName("reportData").singleResult();
// Generate chart
byte[] reportData = (byte[]) historicVariableInstance.getValue();
ChartComponent chart = ChartGenerator.generateChart(reportData);
chart.setWidth(100, UNITS_PERCENTAGE);
chart.setHeight(100, UNITS_PERCENTAGE);
// Put chart on screen
detailContainer.addComponent(chart);
}
Aggregations