use of org.activiti.engine.runtime.Execution in project Activiti by Activiti.
the class JavaServiceTaskTest method testJavaServiceDelegation.
@Deployment
public void testJavaServiceDelegation() {
ProcessInstance pi = runtimeService.startProcessInstanceByKey("javaServiceDelegation", CollectionUtil.singletonMap("input", "Activiti BPM Engine"));
Execution execution = runtimeService.createExecutionQuery().processInstanceId(pi.getId()).activityId("waitState").singleResult();
assertEquals("ACTIVITI BPM ENGINE", runtimeService.getVariable(execution.getId(), "input"));
}
use of org.activiti.engine.runtime.Execution in project Activiti by Activiti.
the class JavaServiceTaskTest method testExpressionFieldInjection.
@Deployment
public void testExpressionFieldInjection() {
Map<String, Object> vars = new HashMap<String, Object>();
vars.put("name", "kermit");
vars.put("gender", "male");
vars.put("genderBean", new GenderBean());
ProcessInstance pi = runtimeService.startProcessInstanceByKey("expressionFieldInjection", vars);
Execution execution = runtimeService.createExecutionQuery().processInstanceId(pi.getId()).activityId("waitState").singleResult();
assertEquals("timrek .rM olleH", runtimeService.getVariable(execution.getId(), "var2"));
assertEquals("elam :si redneg ruoY", runtimeService.getVariable(execution.getId(), "var1"));
}
use of org.activiti.engine.runtime.Execution in project Activiti by Activiti.
the class JavaServiceTaskTest method testExpressionFieldInjectionWithSkipExpression.
@Deployment
public void testExpressionFieldInjectionWithSkipExpression() {
Map<String, Object> vars = new HashMap<String, Object>();
vars.put("name", "kermit");
vars.put("gender", "male");
vars.put("genderBean", new GenderBean());
vars.put("_ACTIVITI_SKIP_EXPRESSION_ENABLED", true);
vars.put("skip", false);
ProcessInstance pi = runtimeService.startProcessInstanceByKey("expressionFieldInjectionWithSkipExpression", vars);
Execution execution = runtimeService.createExecutionQuery().processInstanceId(pi.getId()).activityId("waitState").singleResult();
assertEquals("timrek .rM olleH", runtimeService.getVariable(execution.getId(), "var2"));
assertEquals("elam :si redneg ruoY", runtimeService.getVariable(execution.getId(), "var1"));
Map<String, Object> vars2 = new HashMap<String, Object>();
vars2.put("name", "kermit");
vars2.put("gender", "male");
vars2.put("genderBean", new GenderBean());
vars2.put("_ACTIVITI_SKIP_EXPRESSION_ENABLED", true);
vars2.put("skip", true);
ProcessInstance pi2 = runtimeService.startProcessInstanceByKey("expressionFieldInjectionWithSkipExpression", vars2);
Execution execution2 = runtimeService.createExecutionQuery().processInstanceId(pi2.getId()).activityId("waitState").singleResult();
assertEquals(null, execution2);
}
use of org.activiti.engine.runtime.Execution in project Activiti by Activiti.
the class ExecutionVariableDataResource method getVariableData.
@RequestMapping(value = "/runtime/executions/{executionId}/variables/{variableName}/data", method = RequestMethod.GET)
@ResponseBody
public byte[] getVariableData(@PathVariable("executionId") String executionId, @PathVariable("variableName") String variableName, @RequestParam(value = "scope", required = false) String scope, HttpServletRequest request, HttpServletResponse response) {
try {
byte[] result = null;
Execution execution = getExecutionFromRequest(executionId);
RestVariable variable = getVariableFromRequest(execution, variableName, scope, true);
if (RestResponseFactory.BYTE_ARRAY_VARIABLE_TYPE.equals(variable.getType())) {
result = (byte[]) variable.getValue();
response.setContentType("application/octet-stream");
} else if (RestResponseFactory.SERIALIZABLE_VARIABLE_TYPE.equals(variable.getType())) {
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
ObjectOutputStream outputStream = new ObjectOutputStream(buffer);
outputStream.writeObject(variable.getValue());
outputStream.close();
result = buffer.toByteArray();
response.setContentType("application/x-java-serialized-object");
} else {
throw new ActivitiObjectNotFoundException("The variable does not have a binary data stream.", null);
}
return result;
} catch (IOException ioe) {
throw new ActivitiException("Error getting variable " + variableName, ioe);
}
}
use of org.activiti.engine.runtime.Execution in project Activiti by Activiti.
the class ProcessInstanceVariableCollectionResource method deleteLocalVariables.
@RequestMapping(value = "/runtime/process-instances/{processInstanceId}/variables", method = RequestMethod.DELETE)
public void deleteLocalVariables(@PathVariable String processInstanceId, HttpServletResponse response) {
Execution execution = getProcessInstanceFromRequest(processInstanceId);
deleteAllLocalVariables(execution, response);
}
Aggregations