use of org.camunda.bpm.engine.variable.value.TypedValue in project camunda-engine-dmn by camunda.
the class DecisionTableEvaluationHandler method evaluateOutputEntries.
protected Map<String, DmnEvaluatedOutput> evaluateOutputEntries(List<DmnDecisionTableOutputImpl> decisionTableOutputs, DmnDecisionTableRuleImpl matchingRule, VariableContext variableContext) {
Map<String, DmnEvaluatedOutput> outputEntries = new LinkedHashMap<String, DmnEvaluatedOutput>();
for (int outputIdx = 0; outputIdx < decisionTableOutputs.size(); outputIdx++) {
// evaluate output entry, skip empty expressions
DmnExpressionImpl conclusion = matchingRule.getConclusions().get(outputIdx);
if (isNonEmptyExpression(conclusion)) {
Object value = evaluateOutputEntry(conclusion, variableContext);
// transform to output type
DmnDecisionTableOutputImpl decisionTableOutput = decisionTableOutputs.get(outputIdx);
TypedValue typedValue = decisionTableOutput.getTypeDefinition().transform(value);
// set on result
DmnEvaluatedOutputImpl evaluatedOutput = new DmnEvaluatedOutputImpl(decisionTableOutput, typedValue);
outputEntries.put(decisionTableOutput.getOutputName(), evaluatedOutput);
}
}
return outputEntries;
}
use of org.camunda.bpm.engine.variable.value.TypedValue in project camunda-engine-dmn by camunda.
the class AbstractCollectNumberHitPolicyHandler method apply.
public DmnDecisionTableEvaluationEvent apply(DmnDecisionTableEvaluationEvent decisionTableEvaluationEvent) {
String resultName = getResultName(decisionTableEvaluationEvent);
TypedValue resultValue = getResultValue(decisionTableEvaluationEvent);
DmnDecisionTableEvaluationEventImpl evaluationEvent = (DmnDecisionTableEvaluationEventImpl) decisionTableEvaluationEvent;
evaluationEvent.setCollectResultName(resultName);
evaluationEvent.setCollectResultValue(resultValue);
return evaluationEvent;
}
use of org.camunda.bpm.engine.variable.value.TypedValue in project camunda-bpm-platform by camunda.
the class ProcessVariableMapTest method testProcessVariableMapLocal.
@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());
}
use of org.camunda.bpm.engine.variable.value.TypedValue in project camunda-bpm-platform by camunda.
the class ProcessVariableTypedTest method testProcessVariableTypeAnnotation.
@Test
@Deployment(resources = "org/camunda/bpm/engine/cdi/test/api/annotation/CompleteTaskTest.bpmn20.xml")
public void testProcessVariableTypeAnnotation() {
BusinessProcess businessProcess = getBeanInstance(BusinessProcess.class);
VariableMap variables = Variables.createVariables().putValue("injectedValue", "camunda");
businessProcess.startProcessByKey("keyOfTheProcess", variables);
TypedValue value = getBeanInstance(DeclarativeProcessController.class).getInjectedValue();
assertNotNull(value);
assertTrue(value instanceof StringValue);
assertEquals(ValueType.STRING, value.getType());
assertEquals("camunda", value.getValue());
}
use of org.camunda.bpm.engine.variable.value.TypedValue in project camunda-bpm-platform by camunda.
the class ProcessVariableLocalTypedTest method testProcessVariableLocalTypeAnnotation.
@Test
@Deployment(resources = "org/camunda/bpm/engine/cdi/test/api/annotation/CompleteTaskTest.bpmn20.xml")
public void testProcessVariableLocalTypeAnnotation() {
BusinessProcess businessProcess = getBeanInstance(BusinessProcess.class);
VariableMap variables = Variables.createVariables().putValue("injectedLocalValue", "camunda");
businessProcess.startProcessByKey("keyOfTheProcess", variables);
TypedValue value = getBeanInstance(DeclarativeProcessController.class).getInjectedLocalValue();
assertNotNull(value);
assertTrue(value instanceof StringValue);
assertEquals(ValueType.STRING, value.getType());
assertEquals("camunda", value.getValue());
}
Aggregations