use of org.camunda.bpm.engine.impl.core.variable.mapping.value.ParameterValueProvider in project camunda-bpm-platform by camunda.
the class BpmnParse method parseCallActivity.
/**
* Parses a call activity (currently only supporting calling subprocesses).
*
* @param callActivityElement
* The XML element defining the call activity
* @param scope
* The current scope on which the call activity is defined.
*/
public ActivityImpl parseCallActivity(Element callActivityElement, ScopeImpl scope, boolean isMultiInstance) {
ActivityImpl activity = createActivityOnScope(callActivityElement, scope);
// parse async
parseAsynchronousContinuationForActivity(callActivityElement, activity);
// parse definition key (and behavior)
String calledElement = callActivityElement.attribute("calledElement");
String caseRef = callActivityElement.attributeNS(CAMUNDA_BPMN_EXTENSIONS_NS, "caseRef");
String className = callActivityElement.attributeNS(CAMUNDA_BPMN_EXTENSIONS_NS, PROPERTYNAME_VARIABLE_MAPPING_CLASS);
String delegateExpression = callActivityElement.attributeNS(CAMUNDA_BPMN_EXTENSIONS_NS, PROPERTYNAME_VARIABLE_MAPPING_DELEGATE_EXPRESSION);
if (calledElement == null && caseRef == null) {
addError("Missing attribute 'calledElement' or 'caseRef'", callActivityElement);
} else if (calledElement != null && caseRef != null) {
addError("The attributes 'calledElement' or 'caseRef' cannot be used together: Use either 'calledElement' or 'caseRef'", callActivityElement);
}
String bindingAttributeName = "calledElementBinding";
String versionAttributeName = "calledElementVersion";
String tenantIdAttributeName = "calledElementTenantId";
String deploymentId = deployment.getId();
CallableElement callableElement = new CallableElement();
callableElement.setDeploymentId(deploymentId);
CallableElementActivityBehavior behavior = null;
if (calledElement != null) {
if (className != null) {
behavior = new CallActivityBehavior(className);
} else if (delegateExpression != null) {
Expression exp = expressionManager.createExpression(delegateExpression);
behavior = new CallActivityBehavior(exp);
} else {
behavior = new CallActivityBehavior();
}
ParameterValueProvider definitionKeyProvider = createParameterValueProvider(calledElement, expressionManager);
callableElement.setDefinitionKeyValueProvider(definitionKeyProvider);
} else {
behavior = new CaseCallActivityBehavior();
ParameterValueProvider definitionKeyProvider = createParameterValueProvider(caseRef, expressionManager);
callableElement.setDefinitionKeyValueProvider(definitionKeyProvider);
bindingAttributeName = "caseBinding";
versionAttributeName = "caseVersion";
tenantIdAttributeName = "caseTenantId";
}
behavior.setCallableElement(callableElement);
// parse binding
parseBinding(callActivityElement, activity, callableElement, bindingAttributeName);
// parse version
parseVersion(callActivityElement, activity, callableElement, bindingAttributeName, versionAttributeName);
// parse tenant id
parseTenantId(callActivityElement, activity, callableElement, tenantIdAttributeName);
// parse input parameter
parseInputParameter(callActivityElement, callableElement);
// parse output parameter
parseOutputParameter(callActivityElement, activity, callableElement);
if (!isMultiInstance) {
// turn activity into a scope unless it is a multi instance activity, in
// that case this
// is not necessary because there is already the multi instance body scope
// and concurrent
// child executions are sufficient
activity.setScope(true);
}
activity.setActivityBehavior(behavior);
parseExecutionListenersOnScope(callActivityElement, activity);
for (BpmnParseListener parseListener : parseListeners) {
parseListener.parseCallActivity(callActivityElement, scope, activity);
}
return activity;
}
use of org.camunda.bpm.engine.impl.core.variable.mapping.value.ParameterValueProvider in project camunda-bpm-platform by camunda.
the class ProcessOrCaseTaskItemHandler method initializeOutputParameter.
protected void initializeOutputParameter(CmmnElement element, CmmnActivity activity, CmmnHandlerContext context, CallableElement callableElement) {
ExpressionManager expressionManager = context.getExpressionManager();
List<CamundaOut> outputs = getOutputs(element);
for (CamundaOut output : outputs) {
// create new parameter
CallableElementParameter parameter = new CallableElementParameter();
callableElement.addOutput(parameter);
// all variables
String variables = output.getCamundaVariables();
if ("all".equals(variables)) {
parameter.setAllVariables(true);
continue;
}
// source/sourceExpression
String source = output.getCamundaSource();
if (source == null || source.isEmpty()) {
source = output.getCamundaSourceExpression();
}
ParameterValueProvider sourceValueProvider = createParameterValueProvider(source, expressionManager);
parameter.setSourceValueProvider(sourceValueProvider);
// target
String target = output.getCamundaTarget();
parameter.setTarget(target);
}
}
use of org.camunda.bpm.engine.impl.core.variable.mapping.value.ParameterValueProvider in project camunda-bpm-platform by camunda.
the class DefaultJobPriorityProvider method getSpecificPriority.
@Override
protected Long getSpecificPriority(ExecutionEntity execution, JobDeclaration<?, ?> param, String jobDefinitionId) {
Long specificPriority = null;
JobDefinitionEntity jobDefinition = getJobDefinitionFor(jobDefinitionId);
if (jobDefinition != null)
specificPriority = jobDefinition.getOverridingJobPriority();
if (specificPriority == null) {
ParameterValueProvider priorityProvider = param.getJobPriorityProvider();
if (priorityProvider != null) {
specificPriority = evaluateValueProvider(priorityProvider, execution, describeContext(param, execution));
}
}
return specificPriority;
}
use of org.camunda.bpm.engine.impl.core.variable.mapping.value.ParameterValueProvider in project camunda-bpm-platform by camunda.
the class CallingTaskItemHandler method initializeDefinitionKey.
protected void initializeDefinitionKey(CmmnElement element, CmmnActivity activity, CmmnHandlerContext context, BaseCallableElement callableElement) {
ExpressionManager expressionManager = context.getExpressionManager();
String definitionKey = getDefinitionKey(element, activity, context);
ParameterValueProvider definitionKeyProvider = createParameterValueProvider(definitionKey, expressionManager);
callableElement.setDefinitionKeyValueProvider(definitionKeyProvider);
}
use of org.camunda.bpm.engine.impl.core.variable.mapping.value.ParameterValueProvider in project camunda-bpm-platform by camunda.
the class ProcessTaskPlanItemHandlerTest method testOutputSourceExpression.
@Test
public void testOutputSourceExpression() {
// given:
String source = "${a}";
ExtensionElements extensionElements = addExtensionElements(processTask);
CamundaOut sourceElement = createElement(extensionElements, null, CamundaOut.class);
sourceElement.setCamundaSourceExpression(source);
// when
CmmnActivity activity = handler.handleElement(planItem, context);
// then
ProcessTaskActivityBehavior behavior = (ProcessTaskActivityBehavior) activity.getActivityBehavior();
CallableElement callableElement = behavior.getCallableElement();
CallableElementParameter parameter = callableElement.getOutputs().get(0);
assertNotNull(parameter);
assertFalse(parameter.isAllVariables());
ParameterValueProvider sourceExpressionValueProvider = parameter.getSourceValueProvider();
assertNotNull(sourceExpressionValueProvider);
assertTrue(sourceExpressionValueProvider instanceof ElValueProvider);
ElValueProvider valueProvider = (ElValueProvider) sourceExpressionValueProvider;
assertEquals(source, valueProvider.getExpression().getExpressionText());
}
Aggregations