本文整理汇总了Java中org.camunda.bpm.engine.variable.VariableMap类的典型用法代码示例。如果您正苦于以下问题:Java VariableMap类的具体用法?Java VariableMap怎么用?Java VariableMap使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
VariableMap类属于org.camunda.bpm.engine.variable包,在下文中一共展示了VariableMap类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: convert
import org.camunda.bpm.engine.variable.VariableMap; //导入依赖的package包/类
@Override
public Object convert(Object dest, Object src, Class<?> destinationClass, Class<?> sourceClass) {
if (dest == null) {
dest = new HashMap<String, VariableValueDto>();
}
Map<String, VariableValueDto> destVars = (Map<String, VariableValueDto>) dest;
VariableMap srcVars = (VariableMap) src;
srcVars.forEach((varName, value) -> {
VariableValueDto valueDto = new VariableValueDto();
valueDto.setValue(Objects.toString(value));
destVars.put(varName, valueDto);
});
return destVars;
}
示例2: addResultToVariableContext
import org.camunda.bpm.engine.variable.VariableMap; //导入依赖的package包/类
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);
}
}
}
示例3: testExecutedDecisionElementsOfDrg
import org.camunda.bpm.engine.variable.VariableMap; //导入依赖的package包/类
@Test
@DecisionResource(resource = DISH_EXAMPLE_DMN, decisionKey = "Dish")
public void testExecutedDecisionElementsOfDrg() {
assertThat(metricCollector.getExecutedDecisionElements()).isEqualTo(0L);
VariableMap variableMap = createVariables()
.putValue("temperature", 20)
.putValue("dayType", "Weekend");
dmnEngine.evaluateDecisionTable(decision, variableMap);
assertThat(metricCollector.getExecutedDecisionElements()).isEqualTo(30L);
dmnEngine.evaluateDecisionTable(decision, variableMap);
assertThat(metricCollector.getExecutedDecisionElements()).isEqualTo(60L);
dmnEngine.evaluateDecisionTable(decision, variableMap);
dmnEngine.evaluateDecisionTable(decision, variableMap);
assertThat(metricCollector.getExecutedDecisionElements()).isEqualTo(120L);
}
示例4: evaluateDecisionTable
import org.camunda.bpm.engine.variable.VariableMap; //导入依赖的package包/类
@PostDeploy
public void evaluateDecisionTable(ProcessEngine processEngine) {
DecisionService decisionService = processEngine.getDecisionService();
VariableMap variables = Variables.createVariables()
.putValue("season", "Spring")
.putValue("guestCount", 10)
.putValue("guestsWithChildren", false);
DmnDecisionTableResult dishDecisionResult = decisionService.evaluateDecisionTableByKey("dish", variables);
String desiredDish = dishDecisionResult.getSingleEntry();
System.out.println("Desired dish: " + desiredDish);
DmnDecisionTableResult beveragesDecisionResult = decisionService.evaluateDecisionTableByKey("beverages", variables);
List<Object> beverages = beveragesDecisionResult.collectEntries("beverages");
System.out.println("Desired beverages: " + beverages);
}
示例5: testCreatePrimitiveVariableUntyped
import org.camunda.bpm.engine.variable.VariableMap; //导入依赖的package包/类
@Test
public void testCreatePrimitiveVariableUntyped() {
VariableMap variables = createVariables().putValue(variableName, value);
assertEquals(value, variables.get(variableName));
assertEquals(value, variables.getValueTyped(variableName).getValue());
// no type information present
TypedValue typedValue = variables.getValueTyped(variableName);
if (!(typedValue instanceof NullValueImpl)) {
assertNull(typedValue.getType());
assertEquals(variables.get(variableName), typedValue.getValue());
} else {
assertEquals(NULL, typedValue.getType());
}
}
示例6: testCreateObjectVariables
import org.camunda.bpm.engine.variable.VariableMap; //导入依赖的package包/类
@Test
public void testCreateObjectVariables() {
VariableMap variables = createVariables()
.putValue(DESERIALIZED_OBJECT_VAR_NAME, objectValue(DESERIALIZED_OBJECT_VAR_VALUE));
assertEquals(DESERIALIZED_OBJECT_VAR_VALUE, variables.get(DESERIALIZED_OBJECT_VAR_NAME));
assertEquals(DESERIALIZED_OBJECT_VAR_VALUE, variables.getValue(DESERIALIZED_OBJECT_VAR_NAME, ExampleObject.class));
Object untypedValue = variables.getValueTyped(DESERIALIZED_OBJECT_VAR_NAME).getValue();
assertEquals(DESERIALIZED_OBJECT_VAR_VALUE, untypedValue);
ExampleObject typedValue = variables.<ObjectValue>getValueTyped(DESERIALIZED_OBJECT_VAR_NAME).getValue(ExampleObject.class);
assertEquals(DESERIALIZED_OBJECT_VAR_VALUE, typedValue);
// object type name is not yet available
assertNull(variables.<ObjectValue>getValueTyped(DESERIALIZED_OBJECT_VAR_NAME).getObjectTypeName());
// class is available
assertEquals(DESERIALIZED_OBJECT_VAR_VALUE.getClass(), variables.<ObjectValue>getValueTyped(DESERIALIZED_OBJECT_VAR_NAME).getObjectType());
variables = createVariables()
.putValue(DESERIALIZED_OBJECT_VAR_NAME, objectValue(DESERIALIZED_OBJECT_VAR_VALUE).serializationDataFormat(SERIALIZATION_DATA_FORMAT_NAME));
assertEquals(DESERIALIZED_OBJECT_VAR_VALUE, variables.get(DESERIALIZED_OBJECT_VAR_NAME));
}
示例7: testTransientVariables
import org.camunda.bpm.engine.variable.VariableMap; //导入依赖的package包/类
@Test
public void testTransientVariables() throws URISyntaxException {
VariableMap variableMap = createVariables().putValueTyped("foo", doubleValue(10.0, true))
.putValueTyped("bar", integerValue(10, true))
.putValueTyped("aa", booleanValue(true, true))
.putValueTyped("bb", stringValue("bb", true))
.putValueTyped("test", byteArrayValue("test".getBytes(), true))
.putValueTyped("blob", fileValue(new File(this.getClass().getClassLoader().getResource("org/camunda/bpm/engine/test/variables/simpleFile.txt").toURI()), true))
.putValueTyped("val", dateValue(new Date(), true))
.putValueTyped("var", objectValue(new Integer(10), true).create())
.putValueTyped("short", shortValue((short)12, true))
.putValueTyped("long", longValue((long)10, true))
.putValueTyped("file", fileValue("org/camunda/bpm/engine/test/variables/simpleFile.txt").setTransient(true).create())
.putValueTyped("hi", untypedValue("stringUntyped", true))
.putValueTyped("null", untypedValue(null, true))
.putValueTyped("ser", serializedObjectValue("{\"name\" : \"foo\"}", true).create());
for (Entry<String, Object> e : variableMap.entrySet()) {
TypedValue value = (TypedValue) variableMap.getValueTyped(e.getKey());
assertTrue(value.isTransient());
}
}
示例8: testDeleteAndInsertTheSameVariableByteArray
import org.camunda.bpm.engine.variable.VariableMap; //导入依赖的package包/类
@Test
@RequiredHistoryLevel(ProcessEngineConfiguration.HISTORY_AUDIT)
public void testDeleteAndInsertTheSameVariableByteArray() {
BpmnModelInstance bpmnModel =
Bpmn.createExecutableProcess("serviceTaskProcess")
.startEvent()
.userTask("userTask")
.serviceTask("service")
.camundaClass(DeleteAndInsertVariableDelegate.class)
.userTask("userTask1")
.endEvent()
.done();
ProcessDefinition processDefinition = testHelper.deployAndGetDefinition(bpmnModel);
VariableMap variables = Variables.createVariables().putValue("listVar", Arrays.asList(new int[] { 1, 2, 3 }));
ProcessInstance instance = engineRule.getRuntimeService().startProcessInstanceById(processDefinition.getId(), variables);
Task task = engineRule.getTaskService().createTaskQuery().singleResult();
engineRule.getTaskService().complete(task.getId());
VariableInstance variable = engineRule.getRuntimeService().createVariableInstanceQuery().processInstanceIdIn(instance.getId()).variableName("listVar").singleResult();
assertNotNull(variable);
assertEquals("stringValue", variable.getValue());
HistoricVariableInstance historicVariable = engineRule.getHistoryService().createHistoricVariableInstanceQuery().singleResult();
assertEquals(variable.getName(), historicVariable.getName());
assertEquals(HistoricVariableInstance.STATE_CREATED, historicVariable.getState());
}
示例9: checkVariables
import org.camunda.bpm.engine.variable.VariableMap; //导入依赖的package包/类
private void checkVariables(VariableMap map, int expectedSize) {
List<HistoricVariableInstance> variables = engineRule.getHistoryService()
.createHistoricVariableInstanceQuery()
.orderByVariableName()
.asc()
.list();
assertEquals(expectedSize, variables.size());
assertEquals(variables.size(), map.size());
for (HistoricVariableInstance instance : variables) {
assertTrue(map.containsKey(instance.getName()));
Object instanceValue = instance.getTypedValue().getValue();
Object mapValue = map.getValueTyped(instance.getName()).getValue();
if (instanceValue == null) {
assertNull(mapValue);
} else if (instanceValue instanceof byte[]) {
assertTrue(Arrays.equals((byte[]) instanceValue, (byte[]) mapValue));
} else {
assertEquals(instanceValue, mapValue);
}
}
}
开发者ID:camunda,项目名称:camunda-bpm-platform,代码行数:24,代码来源:ProcessInstantiationWithVariablesInReturnTest.java
示例10: execute
import org.camunda.bpm.engine.variable.VariableMap; //导入依赖的package包/类
public VariableMap execute(CommandContext commandContext) {
final TaskManager taskManager = commandContext.getTaskManager();
TaskEntity task = taskManager.findTaskById(resourceId);
ensureNotNull(BadUserRequestException.class, "Cannot find task with id '" + resourceId + "'.", "task", task);
checkGetTaskFormVariables(task, commandContext);
VariableMapImpl result = new VariableMapImpl();
// first, evaluate form fields
TaskDefinition taskDefinition = task.getTaskDefinition();
if (taskDefinition != null) {
TaskFormData taskFormData = taskDefinition.getTaskFormHandler().createTaskForm(task);
for (FormField formField : taskFormData.getFormFields()) {
if(formVariableNames == null || formVariableNames.contains(formField.getId())) {
result.put(formField.getId(), createVariable(formField, task));
}
}
}
// collect remaining variables from task scope and parent scopes
task.collectVariables(result, formVariableNames, false, deserializeObjectValues);
return result;
}
示例11: testFailSerializationForUnknownSerializedValueType
import org.camunda.bpm.engine.variable.VariableMap; //导入依赖的package包/类
@Deployment(resources = ONE_TASK_PROCESS)
public void testFailSerializationForUnknownSerializedValueType() throws IOException {
// given
JavaSerializable pojo = new JavaSerializable("foo");
ByteArrayOutputStream baos = new ByteArrayOutputStream();
new ObjectOutputStream(baos).writeObject(pojo);
String serializedObject = StringUtil.fromBytes(Base64.encodeBase64(baos.toByteArray()), processEngine);
ObjectValue serializedObjectValue = Variables
.serializedObjectValue(serializedObject)
.serializationDataFormat(SerializationDataFormats.JAVA)
.objectTypeName(pojo.getClass().getName())
.create();
VariableMap variables = Variables.createVariables().putValueTyped("var", serializedObjectValue);
// when
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("oneTaskProcess", variables);
// then
JavaSerializable returnedPojo = (JavaSerializable) runtimeService.getVariable(processInstance.getId(), "var");
assertEquals(pojo, returnedPojo);
}
示例12: testCatchExceptionThrownBySignalOfParallelDelegateExpression
import org.camunda.bpm.engine.variable.VariableMap; //导入依赖的package包/类
@Deployment( resources = {
"org/camunda/bpm/engine/test/bpmn/multiinstance/MultiInstanceTest.testCatchErrorThrownByParallelDelegateExpression.bpmn20.xml"
})
public void testCatchExceptionThrownBySignalOfParallelDelegateExpression() {
VariableMap variables = Variables.createVariables().putValue("myDelegate", new ThrowErrorDelegate());
String pi = runtimeService.startProcessInstanceByKey("testProcess", variables).getId();
assertTrue((Boolean) runtimeService.getVariable(pi, "executed"));
assertNull(runtimeService.getVariable(pi, "signaled"));
Execution serviceTask = runtimeService.createExecutionQuery().processInstanceId(pi).activityId("serviceTask").list().get(3);
assertNotNull(serviceTask);
runtimeService.setVariables(pi, throwException());
runtimeService.signal(serviceTask.getId());
assertTrue((Boolean) runtimeService.getVariable(pi, "executed"));
assertTrue((Boolean) runtimeService.getVariable(pi, "signaled"));
Task userTask = taskService.createTaskQuery().processInstanceId(pi).singleResult();
assertNotNull(userTask);
assertEquals("userTaskException", userTask.getTaskDefinitionKey());
taskService.complete(userTask.getId());
}
示例13: testCatchErrorThrownByExecuteOfDelegateExpression
import org.camunda.bpm.engine.variable.VariableMap; //导入依赖的package包/类
@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());
}
示例14: testGetTypedJsonValue
import org.camunda.bpm.engine.variable.VariableMap; //导入依赖的package包/类
@Deployment(resources = ONE_TASK_PROCESS)
public void testGetTypedJsonValue() throws JSONException {
// given
JsonValue jsonValue = jsonValue(jsonString).create();
VariableMap variables = Variables.createVariables().putValueTyped(variableName, jsonValue);
String processInstanceId = runtimeService.startProcessInstanceByKey(ONE_TASK_PROCESS_KEY, variables).getId();
// when
JsonValue typedValue = runtimeService.getVariableTyped(processInstanceId, variableName);
// then
SpinJsonNode value = typedValue.getValue();
JSONAssert.assertEquals(jsonString, value.toString(), true);
assertTrue(typedValue.isDeserialized());
assertEquals(JSON, typedValue.getType());
assertEquals(JSON_FORMAT_NAME, typedValue.getSerializationDataFormat());
JSONAssert.assertEquals(jsonString, typedValue.getValueSerialized(), true);
}
示例15: testGetUntypedXmlValue
import org.camunda.bpm.engine.variable.VariableMap; //导入依赖的package包/类
@Deployment(resources = ONE_TASK_PROCESS)
public void testGetUntypedXmlValue() {
// given
XmlValue xmlValue = xmlValue(xmlString).create();
VariableMap variables = Variables.createVariables().putValueTyped(variableName, xmlValue);
String processInstanceId = runtimeService.startProcessInstanceByKey(ONE_TASK_PROCESS_KEY, variables).getId();
// when
SpinXmlElement value = (SpinXmlElement) runtimeService.getVariable(processInstanceId, variableName);
// then
assertTrue(value.hasAttr("attrName"));
assertEquals("attrValue", value.attr("attrName").value());
assertTrue(value.childElements().isEmpty());
assertEquals(xml().getName(), value.getDataFormatName());
}