use of org.camunda.bpm.engine.impl.core.variable.mapping.value.ConstantValueProvider in project camunda-bpm-platform by camunda.
the class BpmnParse method parseCallableElementProvider.
protected CallableElementParameter parseCallableElementProvider(Element parameterElement) {
CallableElementParameter parameter = new CallableElementParameter();
String variables = parameterElement.attribute("variables");
if (ALL.equals(variables)) {
parameter.setAllVariables(true);
} else {
boolean strictValidation = !Context.getProcessEngineConfiguration().getDisableStrictCallActivityValidation();
ParameterValueProvider sourceValueProvider = new NullValueProvider();
String source = parameterElement.attribute("source");
if (source != null) {
if (!source.isEmpty()) {
sourceValueProvider = new ConstantValueProvider(source);
} else {
if (strictValidation) {
addError("Empty attribute 'source' when passing variables", parameterElement);
} else {
source = null;
}
}
}
if (source == null) {
source = parameterElement.attribute("sourceExpression");
if (source != null) {
if (!source.isEmpty()) {
Expression expression = expressionManager.createExpression(source);
sourceValueProvider = new ElValueProvider(expression);
} else if (strictValidation) {
addError("Empty attribute 'sourceExpression' when passing variables", parameterElement);
}
}
}
if (strictValidation && source == null) {
addError("Missing parameter 'source' or 'sourceExpression' when passing variables", parameterElement);
}
parameter.setSourceValueProvider(sourceValueProvider);
String target = parameterElement.attribute("target");
if ((strictValidation || source != null && !source.isEmpty()) && target == null) {
addError("Missing attribute 'target' when attribute 'source' or 'sourceExpression' is set", parameterElement);
} else if (strictValidation && target != null && target.isEmpty()) {
addError("Empty attribute 'target' when attribute 'source' or 'sourceExpression' is set", parameterElement);
}
parameter.setTarget(target);
}
return parameter;
}
use of org.camunda.bpm.engine.impl.core.variable.mapping.value.ConstantValueProvider in project camunda-bpm-platform by camunda.
the class CaseTaskPlanItemHandlerTest method testOutputSource.
@Test
public void testOutputSource() {
// given:
String source = "a";
ExtensionElements extensionElements = addExtensionElements(caseTask);
CamundaOut sourceElement = createElement(extensionElements, null, CamundaOut.class);
sourceElement.setCamundaSource(source);
// when
CmmnActivity activity = handler.handleElement(planItem, context);
// then
CaseTaskActivityBehavior behavior = (CaseTaskActivityBehavior) activity.getActivityBehavior();
CallableElement callableElement = behavior.getCallableElement();
CallableElementParameter parameter = callableElement.getOutputs().get(0);
assertNotNull(parameter);
assertFalse(parameter.isAllVariables());
ParameterValueProvider sourceValueProvider = parameter.getSourceValueProvider();
assertNotNull(sourceValueProvider);
assertTrue(sourceValueProvider instanceof ConstantValueProvider);
assertEquals(source, sourceValueProvider.getValue(null));
}
use of org.camunda.bpm.engine.impl.core.variable.mapping.value.ConstantValueProvider in project camunda-bpm-platform by camunda.
the class CaseTaskPlanItemHandlerTest method testCaseRefConstant.
@Test
public void testCaseRefConstant() {
// given:
String caseRef = "aCaseToCall";
caseTask.setCase(caseRef);
// when
CmmnActivity activity = handler.handleElement(planItem, context);
// then
CaseTaskActivityBehavior behavior = (CaseTaskActivityBehavior) activity.getActivityBehavior();
CallableElement callableElement = behavior.getCallableElement();
ParameterValueProvider caseRefValueProvider = callableElement.getDefinitionKeyValueProvider();
assertNotNull(caseRefValueProvider);
assertTrue(caseRefValueProvider instanceof ConstantValueProvider);
ConstantValueProvider valueProvider = (ConstantValueProvider) caseRefValueProvider;
assertEquals(caseRef, valueProvider.getValue(null));
}
use of org.camunda.bpm.engine.impl.core.variable.mapping.value.ConstantValueProvider in project camunda-bpm-platform by camunda.
the class CaseTaskPlanItemHandlerTest method testInputSource.
@Test
public void testInputSource() {
// given:
String source = "a";
ExtensionElements extensionElements = addExtensionElements(caseTask);
CamundaIn sourceElement = createElement(extensionElements, null, CamundaIn.class);
sourceElement.setCamundaSource(source);
// when
CmmnActivity activity = handler.handleElement(planItem, context);
// then
CaseTaskActivityBehavior behavior = (CaseTaskActivityBehavior) activity.getActivityBehavior();
CallableElement callableElement = behavior.getCallableElement();
CallableElementParameter parameter = callableElement.getInputs().get(0);
assertNotNull(parameter);
assertFalse(parameter.isAllVariables());
ParameterValueProvider sourceValueProvider = parameter.getSourceValueProvider();
assertNotNull(sourceValueProvider);
assertTrue(sourceValueProvider instanceof ConstantValueProvider);
assertEquals(source, sourceValueProvider.getValue(null));
}
use of org.camunda.bpm.engine.impl.core.variable.mapping.value.ConstantValueProvider in project camunda-bpm-platform by camunda.
the class CaseTaskPlanItemHandlerTest method testBusinessKeyConstant.
@Test
public void testBusinessKeyConstant() {
// given:
String businessKey = "myBusinessKey";
ExtensionElements extensionElements = addExtensionElements(caseTask);
CamundaIn businessKeyElement = createElement(extensionElements, null, CamundaIn.class);
businessKeyElement.setCamundaBusinessKey(businessKey);
// when
CmmnActivity activity = handler.handleElement(planItem, context);
// then
CaseTaskActivityBehavior behavior = (CaseTaskActivityBehavior) activity.getActivityBehavior();
CallableElement callableElement = behavior.getCallableElement();
ParameterValueProvider businessKeyValueProvider = callableElement.getBusinessKeyValueProvider();
assertNotNull(businessKeyValueProvider);
assertTrue(businessKeyValueProvider instanceof ConstantValueProvider);
assertEquals(businessKey, businessKeyValueProvider.getValue(null));
}
Aggregations