use of org.camunda.bpm.engine.impl.RuntimeServiceImpl in project camunda-bpm-platform by camunda.
the class LocalExecutionVariablesResource method updateVariableEntities.
protected void updateVariableEntities(VariableMap modifications, List<String> deletions) {
RuntimeServiceImpl runtimeService = (RuntimeServiceImpl) engine.getRuntimeService();
runtimeService.updateVariablesLocal(resourceId, modifications, deletions);
}
use of org.camunda.bpm.engine.impl.RuntimeServiceImpl in project camunda-bpm-platform by camunda.
the class RuntimeServiceTest method testUpdateVariablesLocal.
@Deployment(resources = { "org/camunda/bpm/engine/test/api/oneSubProcess.bpmn20.xml" })
@Test
public void testUpdateVariablesLocal() {
Map<String, Object> globalVars = new HashMap<String, Object>();
globalVars.put("variable4", "value4");
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("startSimpleSubProcess", globalVars);
Task currentTask = taskService.createTaskQuery().singleResult();
Map<String, Object> localVars = new HashMap<String, Object>();
localVars.put("variable1", "value1");
localVars.put("variable2", "value2");
localVars.put("variable3", "value3");
runtimeService.setVariablesLocal(currentTask.getExecutionId(), localVars);
Map<String, Object> modifications = new HashMap<String, Object>();
modifications.put("variable1", "anotherValue1");
modifications.put("variable2", "anotherValue2");
List<String> deletions = new ArrayList<String>();
deletions.add("variable2");
deletions.add("variable3");
deletions.add("variable4");
((RuntimeServiceImpl) runtimeService).updateVariablesLocal(currentTask.getExecutionId(), modifications, deletions);
assertEquals("anotherValue1", runtimeService.getVariable(currentTask.getExecutionId(), "variable1"));
assertNull(runtimeService.getVariable(currentTask.getExecutionId(), "variable2"));
assertNull(runtimeService.getVariable(currentTask.getExecutionId(), "variable3"));
assertEquals("value4", runtimeService.getVariable(processInstance.getId(), "variable4"));
}
use of org.camunda.bpm.engine.impl.RuntimeServiceImpl in project camunda-bpm-platform by camunda.
the class ProcessInstanceAuthorizationTest method testUpdateVariablesLocalWithReadPermissionOnAnyProcessInstance.
public void testUpdateVariablesLocalWithReadPermissionOnAnyProcessInstance() {
// given
String processInstanceId = startProcessInstanceByKey(PROCESS_KEY).getId();
createGrantAuthorization(PROCESS_INSTANCE, ANY, userId, UPDATE);
VariableInstanceQuery query = runtimeService.createVariableInstanceQuery();
// when (1)
((RuntimeServiceImpl) runtimeService).updateVariablesLocal(processInstanceId, getVariables(), null);
// then (1)
disableAuthorization();
verifyQueryResults(query, 1);
enableAuthorization();
// when (2)
((RuntimeServiceImpl) runtimeService).updateVariablesLocal(processInstanceId, null, Arrays.asList(VARIABLE_NAME));
// then (2)
disableAuthorization();
verifyQueryResults(query, 0);
enableAuthorization();
// when (3)
((RuntimeServiceImpl) runtimeService).updateVariablesLocal(processInstanceId, getVariables(), Arrays.asList(VARIABLE_NAME));
// then (3)
disableAuthorization();
verifyQueryResults(query, 0);
enableAuthorization();
}
use of org.camunda.bpm.engine.impl.RuntimeServiceImpl in project camunda-bpm-platform by camunda.
the class ProcessInstanceAuthorizationTest method testUpdateVariablesWithReadInstancePermissionOnAnyProcessDefinition.
public void testUpdateVariablesWithReadInstancePermissionOnAnyProcessDefinition() {
// given
String processInstanceId = startProcessInstanceByKey(PROCESS_KEY).getId();
createGrantAuthorization(PROCESS_DEFINITION, ANY, userId, UPDATE_INSTANCE);
VariableInstanceQuery query = runtimeService.createVariableInstanceQuery();
// when (1)
((RuntimeServiceImpl) runtimeService).updateVariables(processInstanceId, getVariables(), null);
// then (1)
disableAuthorization();
verifyQueryResults(query, 1);
enableAuthorization();
// when (2)
((RuntimeServiceImpl) runtimeService).updateVariables(processInstanceId, null, Arrays.asList(VARIABLE_NAME));
// then (2)
disableAuthorization();
verifyQueryResults(query, 0);
enableAuthorization();
// when (3)
((RuntimeServiceImpl) runtimeService).updateVariables(processInstanceId, getVariables(), Arrays.asList(VARIABLE_NAME));
// then (3)
disableAuthorization();
verifyQueryResults(query, 0);
enableAuthorization();
}
use of org.camunda.bpm.engine.impl.RuntimeServiceImpl in project camunda-bpm-platform by camunda.
the class ProcessInstanceAuthorizationTest method testUpdateVariablesLocalWithReadInstancePermissionOnProcessDefinition.
public void testUpdateVariablesLocalWithReadInstancePermissionOnProcessDefinition() {
// given
String processInstanceId = startProcessInstanceByKey(PROCESS_KEY).getId();
createGrantAuthorization(PROCESS_DEFINITION, PROCESS_KEY, userId, UPDATE_INSTANCE);
VariableInstanceQuery query = runtimeService.createVariableInstanceQuery();
// when (1)
((RuntimeServiceImpl) runtimeService).updateVariablesLocal(processInstanceId, getVariables(), null);
// then (1)
disableAuthorization();
verifyQueryResults(query, 1);
enableAuthorization();
// when (2)
((RuntimeServiceImpl) runtimeService).updateVariablesLocal(processInstanceId, null, Arrays.asList(VARIABLE_NAME));
// then (2)
disableAuthorization();
verifyQueryResults(query, 0);
enableAuthorization();
// when (3)
((RuntimeServiceImpl) runtimeService).updateVariablesLocal(processInstanceId, getVariables(), Arrays.asList(VARIABLE_NAME));
// then (3)
disableAuthorization();
verifyQueryResults(query, 0);
enableAuthorization();
}
Aggregations