Java Code Examples for org.camunda.bpm.engine.variable.VariableMap#putAll()

The following examples show how to use org.camunda.bpm.engine.variable.VariableMap#putAll() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DefaultDmnDecisionContext.java    From camunda-engine-dmn with Apache License 2.0 6 votes vote down vote up
protected void addResultToVariableContext(DmnDecisionResult evaluatedResult, VariableMap variableMap, DmnDecision evaluatedDecision) {
  List<Map<String, Object>> resultList = evaluatedResult.getResultList();

  if (resultList.isEmpty()) {
    return;
  } else if (resultList.size() == 1 && !isDecisionTableWithCollectOrRuleOrderHitPolicy(evaluatedDecision)) {
    variableMap.putAll(evaluatedResult.getSingleResult());
  } else {
    Set<String> outputs = new HashSet<String>();

    for (Map<String, Object> resultMap : resultList) {
      outputs.addAll(resultMap.keySet());
    }

    for (String output : outputs) {
      List<Object> values = evaluatedResult.collectEntries(output);
      variableMap.put(output, values);
    }
  }
}
 
Example 2
Source File: ErrorEventSubProcessTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Deployment(resources = {
  "org/camunda/bpm/engine/test/bpmn/event/error/ErrorEventSubProcessTest.testCatchErrorThrownByDelegateExpression.bpmn20.xml"
})
public void testCatchErrorThrownByExecuteOfDelegateExpression() {
  VariableMap variables = Variables.createVariables().putValue("myDelegate", new ThrowErrorDelegate());
  variables.putAll(throwError());
  String pi = runtimeService.startProcessInstanceByKey("testProcess", variables).getId();

  assertTrue((Boolean) runtimeService.getVariable(pi, "executed"));
  assertNull(runtimeService.getVariable(pi, "signaled"));

  Task userTask = taskService.createTaskQuery().processInstanceId(pi).singleResult();
  assertNotNull(userTask);
  assertEquals("userTaskError", userTask.getTaskDefinitionKey());

  taskService.complete(userTask.getId());
}
 
Example 3
Source File: ErrorEventSubProcessTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Deployment(resources = {
  "org/camunda/bpm/engine/test/bpmn/event/error/ErrorEventSubProcessTest.testCatchErrorThrownByDelegateExpression.bpmn20.xml"
})
public void testCatchExceptionThrownByExecuteOfDelegateExpression() {
  VariableMap variables = Variables.createVariables().putValue("myDelegate", new ThrowErrorDelegate());
  variables.putAll(throwException());
  String pi = runtimeService.startProcessInstanceByKey("testProcess", variables).getId();

  assertTrue((Boolean) runtimeService.getVariable(pi, "executed"));
  assertNull(runtimeService.getVariable(pi, "signaled"));

  Task userTask = taskService.createTaskQuery().processInstanceId(pi).singleResult();
  assertNotNull(userTask);
  assertEquals("userTaskException", userTask.getTaskDefinitionKey());

  taskService.complete(userTask.getId());
}
 
Example 4
Source File: BoundaryErrorEventTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Deployment( resources = {
  "org/camunda/bpm/engine/test/bpmn/event/error/BoundaryErrorEventTest.testCatchErrorThrownByDelegateExpression.bpmn20.xml"
})
public void testCatchErrorThrownByExecuteOfDelegateExpression() {
  VariableMap variables = Variables.createVariables().putValue("myDelegate", new ThrowErrorDelegate());
  variables.putAll(throwError());
  String pi = runtimeService.startProcessInstanceByKey("testProcess", variables).getId();

  assertTrue((Boolean) runtimeService.getVariable(pi, "executed"));
  assertNull(runtimeService.getVariable(pi, "signaled"));

  Task userTask = taskService.createTaskQuery().processInstanceId(pi).singleResult();
  assertNotNull(userTask);
  assertEquals("userTaskError", userTask.getTaskDefinitionKey());

  taskService.complete(userTask.getId());
}
 
Example 5
Source File: BoundaryErrorEventTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Deployment( resources = {
  "org/camunda/bpm/engine/test/bpmn/event/error/BoundaryErrorEventTest.testCatchErrorThrownByDelegateExpression.bpmn20.xml"
})
public void testCatchExceptionThrownByExecuteOfDelegateExpression() {
  VariableMap variables = Variables.createVariables().putValue("myDelegate", new ThrowErrorDelegate());
  variables.putAll(throwException());
  String pi = runtimeService.startProcessInstanceByKey("testProcess", variables).getId();

  assertTrue((Boolean) runtimeService.getVariable(pi, "executed"));
  assertNull(runtimeService.getVariable(pi, "signaled"));

  Task userTask = taskService.createTaskQuery().processInstanceId(pi).singleResult();
  assertNotNull(userTask);
  assertEquals("userTaskException", userTask.getTaskDefinitionKey());

  taskService.complete(userTask.getId());
}
 
Example 6
Source File: MultiInstanceTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Deployment( resources = {
  "org/camunda/bpm/engine/test/bpmn/multiinstance/MultiInstanceTest.testCatchErrorThrownByParallelDelegateExpression.bpmn20.xml"
})
public void testCatchErrorThrownByExecuteOfParallelDelegateExpression() {
  VariableMap variables = Variables.createVariables().putValue("myDelegate", new ThrowErrorDelegate());
  variables.putAll(throwError());
  String pi = runtimeService.startProcessInstanceByKey("testProcess", variables).getId();

  assertTrue((Boolean) runtimeService.getVariable(pi, "executed"));
  assertNull(runtimeService.getVariable(pi, "signaled"));

  Task userTask = taskService.createTaskQuery().processInstanceId(pi).singleResult();
  assertNotNull(userTask);
  assertEquals("userTaskError", userTask.getTaskDefinitionKey());

  taskService.complete(userTask.getId());
}
 
Example 7
Source File: DefaultDmnDecisionContext.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
protected void addResultToVariableContext(DmnDecisionResult evaluatedResult, VariableMap variableMap, DmnDecision evaluatedDecision) {
  List<Map<String, Object>> resultList = evaluatedResult.getResultList();

  if (resultList.isEmpty()) {
    return;
  } else if (resultList.size() == 1 && !isDecisionTableWithCollectOrRuleOrderHitPolicy(evaluatedDecision)) {
    variableMap.putAll(evaluatedResult.getSingleResult());
  } else {
    Set<String> outputs = new HashSet<String>();

    for (Map<String, Object> resultMap : resultList) {
      outputs.addAll(resultMap.keySet());
    }

    for (String output : outputs) {
      List<Object> values = evaluatedResult.collectEntries(output);
      variableMap.put(output, values);
    }
  }
}
 
Example 8
Source File: MultiInstanceTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Deployment( resources = {
  "org/camunda/bpm/engine/test/bpmn/multiinstance/MultiInstanceTest.testCatchErrorThrownByParallelDelegateExpression.bpmn20.xml"
})
public void testCatchExceptionThrownByExecuteOfParallelDelegateExpression() {
  VariableMap variables = Variables.createVariables().putValue("myDelegate", new ThrowErrorDelegate());
  variables.putAll(throwException());
  String pi = runtimeService.startProcessInstanceByKey("testProcess", variables).getId();

  assertTrue((Boolean) runtimeService.getVariable(pi, "executed"));
  assertNull(runtimeService.getVariable(pi, "signaled"));

  Task userTask = taskService.createTaskQuery().processInstanceId(pi).singleResult();
  assertNotNull(userTask);
  assertEquals("userTaskException", userTask.getTaskDefinitionKey());

  taskService.complete(userTask.getId());
}
 
Example 9
Source File: MultiInstanceTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Deployment( resources = {
  "org/camunda/bpm/engine/test/bpmn/multiinstance/MultiInstanceTest.testCatchErrorThrownBySequentialDelegateExpression.bpmn20.xml"
})
public void testCatchExceptionThrownByExecuteOfSequentialDelegateExpression() {
  VariableMap variables = Variables.createVariables().putValue("myDelegate", new ThrowErrorDelegate());
  variables.putAll(throwException());
  String pi = runtimeService.startProcessInstanceByKey("testProcess", variables).getId();

  assertTrue((Boolean) runtimeService.getVariable(pi, "executed"));
  assertNull(runtimeService.getVariable(pi, "signaled"));

  Task userTask = taskService.createTaskQuery().processInstanceId(pi).singleResult();
  assertNotNull(userTask);
  assertEquals("userTaskException", userTask.getTaskDefinitionKey());

  taskService.complete(userTask.getId());
}
 
Example 10
Source File: MultiInstanceTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Deployment( resources = {
  "org/camunda/bpm/engine/test/bpmn/multiinstance/MultiInstanceTest.testCatchErrorThrownBySequentialDelegateExpression.bpmn20.xml"
})
public void testCatchErrorThrownByExecuteOfSequentialDelegateExpression() {
  VariableMap variables = Variables.createVariables().putValue("myDelegate", new ThrowErrorDelegate());
  variables.putAll(throwError());
  String pi = runtimeService.startProcessInstanceByKey("testProcess", variables).getId();

  assertTrue((Boolean) runtimeService.getVariable(pi, "executed"));
  assertNull(runtimeService.getVariable(pi, "signaled"));

  Task userTask = taskService.createTaskQuery().processInstanceId(pi).singleResult();
  assertNotNull(userTask);
  assertEquals("userTaskError", userTask.getTaskDefinitionKey());

  taskService.complete(userTask.getId());
}
 
Example 11
Source File: BusinessProcess.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public ProcessInstance startProcessById(String processDefinitionId, Map<String, Object> variables) {
  assertCommandContextNotActive();

  VariableMap cachedVariables = getAndClearCachedVariableMap();
  cachedVariables.putAll(variables);
  ProcessInstance instance = processEngine.getRuntimeService().startProcessInstanceById(processDefinitionId, cachedVariables);
  if (!instance.isEnded()) {
    setExecution(instance);
  }
  return instance;
}
 
Example 12
Source File: BusinessProcess.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public ProcessInstance startProcessByMessage(String messageName, String businessKey, Map<String, Object> processVariables) {
  assertCommandContextNotActive();

  VariableMap cachedVariables = getAndClearCachedVariableMap();
  cachedVariables.putAll(processVariables);
  ProcessInstance instance =  processEngine.getRuntimeService().startProcessInstanceByMessage(messageName, businessKey, cachedVariables);
  if (!instance.isEnded()) {
    setExecution(instance);
  }
  return instance;
}
 
Example 13
Source File: BusinessProcess.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public ProcessInstance startProcessByMessage(String messageName, Map<String, Object> processVariables) {
  assertCommandContextNotActive();

  VariableMap cachedVariables = getAndClearCachedVariableMap();
  cachedVariables.putAll(processVariables);
  ProcessInstance instance =  processEngine.getRuntimeService().startProcessInstanceByMessage(messageName, cachedVariables);
  if (!instance.isEnded()) {
    setExecution(instance);
  }
  return instance;
}
 
Example 14
Source File: BusinessProcess.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public ProcessInstance startProcessByKey(String key, String businessKey, Map<String, Object> variables) {
  assertCommandContextNotActive();

  VariableMap cachedVariables = getAndClearCachedVariableMap();
  cachedVariables.putAll(variables);
  ProcessInstance instance = processEngine.getRuntimeService().startProcessInstanceByKey(key, businessKey, cachedVariables);
  if (!instance.isEnded()) {
    setExecution(instance);
  }
  return instance;
}
 
Example 15
Source File: BusinessProcess.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public ProcessInstance startProcessByKey(String key, Map<String, Object> variables) {
  assertCommandContextNotActive();

  VariableMap cachedVariables = getAndClearCachedVariableMap();
  cachedVariables.putAll(variables);
  ProcessInstance instance = processEngine.getRuntimeService().startProcessInstanceByKey(key, cachedVariables);
  if (!instance.isEnded()) {
    setExecution(instance);
  }
  return instance;
}
 
Example 16
Source File: BusinessProcess.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public ProcessInstance startProcessById(String processDefinitionId, String businessKey, Map<String, Object> variables) {
  assertCommandContextNotActive();

  VariableMap cachedVariables = getAndClearCachedVariableMap();
  cachedVariables.putAll(variables);
  ProcessInstance instance = processEngine.getRuntimeService().startProcessInstanceById(processDefinitionId, businessKey, cachedVariables);
  if (!instance.isEnded()) {
    setExecution(instance);
  }
  return instance;
}
 
Example 17
Source File: AbstractCorrelateMessageCmd.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
protected VariableMap resolveStartVariables() {
  VariableMap mergedVariables = Variables.createVariables();
  mergedVariables.putAll(builder.getPayloadProcessInstanceVariables());
  mergedVariables.putAll(builder.getPayloadProcessInstanceVariablesLocal());
  return mergedVariables;
}