本文整理汇总了Java中org.camunda.bpm.engine.variable.VariableMap.put方法的典型用法代码示例。如果您正苦于以下问题:Java VariableMap.put方法的具体用法?Java VariableMap.put怎么用?Java VariableMap.put使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.camunda.bpm.engine.variable.VariableMap
的用法示例。
在下文中一共展示了VariableMap.put方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
}
}
示例2: execute
import org.camunda.bpm.engine.variable.VariableMap; //导入方法依赖的package包/类
public VariableMap execute(final CommandContext commandContext) {
StartFormData startFormData = commandContext.runWithoutAuthorization(new Callable<StartFormData>() {
public StartFormData call() throws Exception {
return new GetStartFormCmd(resourceId).execute(commandContext);
}
});
ProcessDefinition definition = startFormData.getProcessDefinition();
checkGetStartFormVariables((ProcessDefinitionEntity) definition, commandContext);
VariableMap result = new VariableMapImpl();
for (FormField formField : startFormData.getFormFields()) {
if(formVariableNames == null || formVariableNames.contains(formField.getId())) {
result.put(formField.getId(), createVariable(formField, null));
}
}
return result;
}
示例3: createVariablesUsingVariableMap
import org.camunda.bpm.engine.variable.VariableMap; //导入方法依赖的package包/类
@Test
public void createVariablesUsingVariableMap() {
// given
BpmnModelInstance simpleInstanceWithListener = Bpmn.createExecutableProcess("Process")
.startEvent()
.camundaExecutionListenerClass(ExecutionListener.EVENTNAME_END, ReadTransientVariableExecutionListener.class)
.userTask()
.endEvent()
.done();
testRule.deploy(simpleInstanceWithListener);
// when
VariableMap variables = Variables.createVariables();
variables.put(VARIABLE_NAME, Variables.untypedValue(true, true));
runtimeService.startProcessInstanceByKey("Process",
variables
);
// then
List<VariableInstance> variableInstances = runtimeService.createVariableInstanceQuery().list();
List<HistoricVariableInstance> historicVariableInstances = historyService.createHistoricVariableInstanceQuery().list();
assertEquals(0, variableInstances.size());
assertEquals(0, historicVariableInstances.size());
}
示例4: testSerializeFileVariable
import org.camunda.bpm.engine.variable.VariableMap; //导入方法依赖的package包/类
@Test
public void testSerializeFileVariable() {
BpmnModelInstance modelInstance = Bpmn.createExecutableProcess("process").startEvent().userTask().endEvent().done();
org.camunda.bpm.engine.repository.Deployment deployment = repositoryService.createDeployment().addModelInstance("process.bpmn", modelInstance).deploy();
VariableMap variables = Variables.createVariables();
String filename = "test.txt";
String type = "text/plain";
FileValue fileValue = Variables.fileValue(filename).file("ABC".getBytes()).encoding("UTF-8").mimeType(type).create();
variables.put("file", fileValue);
runtimeService.startProcessInstanceByKey("process", variables);
Task task = taskService.createTaskQuery().singleResult();
VariableInstance result = runtimeService.createVariableInstanceQuery().processInstanceIdIn(task.getProcessInstanceId()).singleResult();
FileValue value = (FileValue) result.getTypedValue();
assertThat(value.getFilename(), is(filename));
assertThat(value.getMimeType(), is(type));
assertThat(value.getEncoding(), is("UTF-8"));
assertThat(value.getEncodingAsCharset(), is(Charset.forName("UTF-8")));
Scanner scanner = new Scanner(value.getValue());
assertThat(scanner.nextLine(), is("ABC"));
// clean up
repositoryService.deleteDeployment(deployment.getId(), true);
}
示例5: testPurgeWithExistingProcessInstance
import org.camunda.bpm.engine.variable.VariableMap; //导入方法依赖的package包/类
@Test
public void testPurgeWithExistingProcessInstance() {
//given process with variable and staying process instance in second user task
BpmnModelInstance test = Bpmn.createExecutableProcess(PROCESS_DEF_KEY)
.startEvent()
.userTask()
.userTask()
.endEvent()
.done();
engineRule.getRepositoryService().createDeployment().addModelInstance(PROCESS_MODEL_NAME, test).deploy();
VariableMap variables = Variables.createVariables();
variables.put("key", "value");
engineRule.getRuntimeService().startProcessInstanceByKey(PROCESS_DEF_KEY, variables);
Task task = engineRule.getTaskService().createTaskQuery().singleResult();
engineRule.getTaskService().complete(task.getId());
// when purge is executed
ManagementServiceImpl managementService = (ManagementServiceImpl) engineRule.getManagementService();
managementService.purge();
// then no more data exist
assertAndEnsureCleanDbAndCache(engineRule.getProcessEngine(), true);
}
示例6: executeComplexBpmnProcess
import org.camunda.bpm.engine.variable.VariableMap; //导入方法依赖的package包/类
private void executeComplexBpmnProcess(boolean complete) {
VariableMap variables = Variables.createVariables();
variables.put("key", "value");
engineRule.getRuntimeService().startProcessInstanceByKey(PROCESS_DEF_KEY, variables);
//execute start event
Job job = engineRule.getManagementService().createJobQuery().singleResult();
engineRule.getManagementService().executeJob(job.getId());
//fetch tasks and jobs
List<LockedExternalTask> externalTasks = engineRule.getExternalTaskService().fetchAndLock(1, "worker").topic("external", 1500).execute();
job = engineRule.getManagementService().createJobQuery().singleResult();
Task task = engineRule.getTaskService().createTaskQuery().singleResult();
//complete
if (complete) {
engineRule.getManagementService().setJobRetries(job.getId(), 0);
engineRule.getManagementService().executeJob(job.getId());
engineRule.getExternalTaskService().complete(externalTasks.get(0).getId(), "worker");
engineRule.getTaskService().complete(task.getId());
}
}
示例7: testNonInterruptingSetMultipleVariables
import org.camunda.bpm.engine.variable.VariableMap; //导入方法依赖的package包/类
@Test
public void testNonInterruptingSetMultipleVariables() {
BpmnModelInstance modelInstance = Bpmn.createExecutableProcess(CONDITIONAL_EVENT_PROCESS_KEY)
.startEvent()
.userTask(TASK_WITH_CONDITION_ID).name(TASK_WITH_CONDITION)
.endEvent().done();
deployConditionalEventSubProcess(modelInstance, CONDITIONAL_EVENT_PROCESS_KEY, false);
//given
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey(CONDITIONAL_EVENT_PROCESS_KEY);
TaskQuery taskQuery = taskService.createTaskQuery().processInstanceId(processInstance.getId());
Task task = taskQuery.singleResult();
//when multiple variable are set on task execution
VariableMap variables = Variables.createVariables();
variables.put("variable", 1);
variables.put("variable1", 1);
runtimeService.setVariables(task.getExecutionId(), variables);
//then event sub process should be triggered more than once
tasksAfterVariableIsSet = taskQuery.list();
assertEquals(3, tasksAfterVariableIsSet.size());
}
示例8: getCorrelationKeys
import org.camunda.bpm.engine.variable.VariableMap; //导入方法依赖的package包/类
private VariableMap getCorrelationKeys(JsonObject event) {
VariableMap correlationKeys = Variables.createVariables();
if (event.get("orderId") != null) {
correlationKeys.put("orderId", event.getString("orderId"));
} else if (event.get("refId") != null) {
correlationKeys.put("orderId", event.getString("refId"));
} else if (event.get("pickId") != null) {
correlationKeys.put("pickId", event.getString("pickId"));
} else if (event.get("shipmentId") != null) {
correlationKeys.put("shipmentId", event.getString("shipmentId"));
}
return correlationKeys;
}
示例9: buildVariableMapFromVariableContext
import org.camunda.bpm.engine.variable.VariableMap; //导入方法依赖的package包/类
protected VariableMap buildVariableMapFromVariableContext(VariableContext variableContext) {
VariableMap variableMap = Variables.createVariables();
Set<String> variables = variableContext.keySet();
for(String variable: variables) {
variableMap.put(variable, variableContext.resolve(variable));
}
return variableMap;
}
示例10: assertExample
import org.camunda.bpm.engine.variable.VariableMap; //导入方法依赖的package包/类
public static void assertExample(DmnEngine engine, DmnDecision decision) {
VariableMap variables = Variables.createVariables();
variables.put("status", "bronze");
variables.put("sum", 200);
DmnDecisionTableResult results = engine.evaluateDecisionTable(decision, variables);
assertThat(results)
.hasSingleResult()
.containsKeys("result", "reason")
.containsEntry("result", "notok")
.containsEntry("reason", "work on your status first, as bronze you're not going to get anything");
variables.put("status", "silver");
results = engine.evaluateDecisionTable(decision, variables);
assertThat(results)
.hasSingleResult()
.containsKeys("result", "reason")
.containsEntry("result", "ok")
.containsEntry("reason", "you little fish will get what you want");
variables.put("sum", 1200);
results = engine.evaluateDecisionTable(decision, variables);
assertThat(results)
.hasSingleResult()
.containsKeys("result", "reason")
.containsEntry("result", "notok")
.containsEntry("reason", "you took too much man, you took too much!");
variables.put("status", "gold");
variables.put("sum", 200);
results = engine.evaluateDecisionTable(decision, variables);
assertThat(results)
.hasSingleResult()
.containsKeys("result", "reason")
.containsEntry("result", "ok")
.containsEntry("reason", "you get anything you want");
}
示例11: testPurgeWithAsyncProcessInstance
import org.camunda.bpm.engine.variable.VariableMap; //导入方法依赖的package包/类
@Test
public void testPurgeWithAsyncProcessInstance() {
// given process with variable and async process instance
BpmnModelInstance test = Bpmn.createExecutableProcess(PROCESS_DEF_KEY)
.startEvent()
.camundaAsyncBefore()
.userTask()
.userTask()
.endEvent()
.done();
engineRule.getRepositoryService().createDeployment().addModelInstance(PROCESS_MODEL_NAME, test).deploy();
VariableMap variables = Variables.createVariables();
variables.put("key", "value");
engineRule.getRuntimeService().startProcessInstanceByKey(PROCESS_DEF_KEY, variables);
Job job = engineRule.getManagementService().createJobQuery().singleResult();
engineRule.getManagementService().executeJob(job.getId());
Task task = engineRule.getTaskService().createTaskQuery().singleResult();
engineRule.getTaskService().complete(task.getId());
// when purge is executed
ManagementServiceImpl managementService = (ManagementServiceImpl) engineRule.getManagementService();
managementService.purge();
// then no more data exist
assertAndEnsureCleanDbAndCache(engineRule.getProcessEngine(), true);
}
示例12: toMap
import org.camunda.bpm.engine.variable.VariableMap; //导入方法依赖的package包/类
public static VariableMap toMap(Map<String, VariableValueDto> variables, ProcessEngine processEngine, ObjectMapper objectMapper) {
if(variables == null) {
return null;
}
VariableMap result = Variables.createVariables();
for (Entry<String, VariableValueDto> variableEntry : variables.entrySet()) {
result.put(variableEntry.getKey(), variableEntry.getValue().toTypedValue(processEngine, objectMapper));
}
return result;
}
示例13: handleEvent
import org.camunda.bpm.engine.variable.VariableMap; //导入方法依赖的package包/类
@Override
public boolean handleEvent(String type, String eventName, String transactionId, JsonObject event) {
if ("Event".equals(type) && "OrderPlaced".equals(eventName)) {
// Currently special handling to also persist the order
Order order = parseOrder(event.getJsonObject("order"));
// "Persist" order
orderRepository.persistOrder(order);
VariableMap variables = Variables.createVariables();
variables.put("orderId", order.getId());
variables.put("transactionId", transactionId);
engine.getRuntimeService().startProcessInstanceByKey("order", transactionId, variables);
return true;
} else {
// Currently the transaction is NOT used for correlation, as we can assume
// to hit some legacy system some time which is not able to handle it
// That's why we only use it for tracking / monitoring purposes
// Correlate by possible ids in this priority
VariableMap correlationKeys = getCorrelationKeys(event);
MessageCorrelationBuilder correlation = engine.getRuntimeService().createMessageCorrelation(eventName);
ExecutionQuery query = engine.getRuntimeService().createExecutionQuery().messageEventSubscriptionName(eventName);
for (String key : correlationKeys.keySet()) {
correlation.processInstanceVariableEquals(key, correlationKeys.get(key));
query.processVariableValueEquals(key, correlationKeys.get(key));
}
// if nobody waits for this event we consider it not to be for us
if (query.count()==0) {
return false;
}
// otherwise correlate it
// add all possible additional correlation keys as variables to the flow
VariableMap newVariables = getNewVariables(event);
correlation.setVariables(newVariables);
correlation.correlateWithResult();
return true;
}
}
示例14: testProcessVariableMap
import org.camunda.bpm.engine.variable.VariableMap; //导入方法依赖的package包/类
@Test
public void testProcessVariableMap() {
BusinessProcess businessProcess = getBeanInstance(BusinessProcess.class);
VariableMap variables = (VariableMap) getBeanInstance("processVariableMap");
assertNotNull(variables);
///////////////////////////////////////////////////////////////////
// Put a variable via BusinessProcess and get it via VariableMap //
///////////////////////////////////////////////////////////////////
String aValue = "aValue";
businessProcess.setVariable(VARNAME_1, Variables.stringValue(aValue));
// Legacy API
assertEquals(aValue, variables.get(VARNAME_1));
// Typed variable API
TypedValue aTypedValue = variables.getValueTyped(VARNAME_1);
assertEquals(ValueType.STRING, aTypedValue.getType());
assertEquals(aValue, aTypedValue.getValue());
assertEquals(aValue, variables.getValue(VARNAME_1, String.class));
// Type API with wrong type
try {
variables.getValue(VARNAME_1, Integer.class);
fail("ClassCastException expected!");
} catch(ClassCastException ex) {
assertEquals("Cannot cast variable named 'aVariable' with value 'aValue' to type 'class java.lang.Integer'.", ex.getMessage());
}
///////////////////////////////////////////////////////////////////
// Put a variable via VariableMap and get it via BusinessProcess //
///////////////////////////////////////////////////////////////////
String anotherValue = "anotherValue";
variables.put(VARNAME_2, Variables.stringValue(anotherValue));
// Legacy API
assertEquals(anotherValue, businessProcess.getVariable(VARNAME_2));
// Typed variable API
TypedValue anotherTypedValue = businessProcess.getVariableTyped(VARNAME_2);
assertEquals(ValueType.STRING, anotherTypedValue.getType());
assertEquals(anotherValue, anotherTypedValue.getValue());
}
示例15: testProcessVariableMapLocal
import org.camunda.bpm.engine.variable.VariableMap; //导入方法依赖的package包/类
@Test
@Deployment(resources = "org/camunda/bpm/engine/cdi/test/api/BusinessProcessBeanTest.test.bpmn20.xml")
public void testProcessVariableMapLocal() {
BusinessProcess businessProcess = getBeanInstance(BusinessProcess.class);
businessProcess.startProcessByKey("businessProcessBeanTest");
VariableMap variables = (VariableMap) getBeanInstance("processVariableMapLocal");
assertNotNull(variables);
///////////////////////////////////////////////////////////////////
// Put a variable via BusinessProcess and get it via VariableMap //
///////////////////////////////////////////////////////////////////
String aValue = "aValue";
businessProcess.setVariableLocal(VARNAME_1, Variables.stringValue(aValue));
// Legacy API
assertEquals(aValue, variables.get(VARNAME_1));
// Typed variable API
TypedValue aTypedValue = variables.getValueTyped(VARNAME_1);
assertEquals(ValueType.STRING, aTypedValue.getType());
assertEquals(aValue, aTypedValue.getValue());
assertEquals(aValue, variables.getValue(VARNAME_1, String.class));
// Type API with wrong type
try {
variables.getValue(VARNAME_1, Integer.class);
fail("ClassCastException expected!");
} catch(ClassCastException ex) {
assertEquals("Cannot cast variable named 'aVariable' with value 'aValue' to type 'class java.lang.Integer'.", ex.getMessage());
}
///////////////////////////////////////////////////////////////////
// Put a variable via VariableMap and get it via BusinessProcess //
///////////////////////////////////////////////////////////////////
String anotherValue = "anotherValue";
variables.put(VARNAME_2, Variables.stringValue(anotherValue));
// Legacy API
assertEquals(anotherValue, businessProcess.getVariableLocal(VARNAME_2));
// Typed variable API
TypedValue anotherTypedValue = businessProcess.getVariableLocalTyped(VARNAME_2);
assertEquals(ValueType.STRING, anotherTypedValue.getType());
assertEquals(anotherValue, anotherTypedValue.getValue());
}