Search in sources :

Example 6 with ParameterValueProvider

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;
}
Also used : ParameterValueProvider(org.camunda.bpm.engine.impl.core.variable.mapping.value.ParameterValueProvider)

Example 7 with ParameterValueProvider

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);
    }
}
Also used : ExpressionManager(org.camunda.bpm.engine.impl.el.ExpressionManager) ParameterValueProvider(org.camunda.bpm.engine.impl.core.variable.mapping.value.ParameterValueProvider) CallableElementParameter(org.camunda.bpm.engine.impl.core.model.CallableElementParameter) CamundaOut(org.camunda.bpm.model.cmmn.instance.camunda.CamundaOut)

Example 8 with ParameterValueProvider

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;
}
Also used : JobDefinitionEntity(org.camunda.bpm.engine.impl.persistence.entity.JobDefinitionEntity) ParameterValueProvider(org.camunda.bpm.engine.impl.core.variable.mapping.value.ParameterValueProvider)

Example 9 with ParameterValueProvider

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);
}
Also used : ExpressionManager(org.camunda.bpm.engine.impl.el.ExpressionManager) ParameterValueProvider(org.camunda.bpm.engine.impl.core.variable.mapping.value.ParameterValueProvider)

Example 10 with ParameterValueProvider

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());
}
Also used : CallableElement(org.camunda.bpm.engine.impl.core.model.CallableElement) ExtensionElements(org.camunda.bpm.model.cmmn.instance.ExtensionElements) ParameterValueProvider(org.camunda.bpm.engine.impl.core.variable.mapping.value.ParameterValueProvider) CallableElementParameter(org.camunda.bpm.engine.impl.core.model.CallableElementParameter) ProcessTaskActivityBehavior(org.camunda.bpm.engine.impl.cmmn.behavior.ProcessTaskActivityBehavior) ElValueProvider(org.camunda.bpm.engine.impl.el.ElValueProvider) CamundaOut(org.camunda.bpm.model.cmmn.instance.camunda.CamundaOut) CmmnActivity(org.camunda.bpm.engine.impl.cmmn.model.CmmnActivity) Test(org.junit.Test)

Aggregations

ParameterValueProvider (org.camunda.bpm.engine.impl.core.variable.mapping.value.ParameterValueProvider)42 CmmnActivity (org.camunda.bpm.engine.impl.cmmn.model.CmmnActivity)26 Test (org.junit.Test)26 CallableElement (org.camunda.bpm.engine.impl.core.model.CallableElement)20 ConstantValueProvider (org.camunda.bpm.engine.impl.core.variable.mapping.value.ConstantValueProvider)14 ElValueProvider (org.camunda.bpm.engine.impl.el.ElValueProvider)14 ExtensionElements (org.camunda.bpm.model.cmmn.instance.ExtensionElements)12 CaseTaskActivityBehavior (org.camunda.bpm.engine.impl.cmmn.behavior.CaseTaskActivityBehavior)10 ProcessTaskActivityBehavior (org.camunda.bpm.engine.impl.cmmn.behavior.ProcessTaskActivityBehavior)10 CallableElementParameter (org.camunda.bpm.engine.impl.core.model.CallableElementParameter)10 CamundaIn (org.camunda.bpm.model.cmmn.instance.camunda.CamundaIn)9 DecisionTaskActivityBehavior (org.camunda.bpm.engine.impl.cmmn.behavior.DecisionTaskActivityBehavior)6 DmnDecisionTaskActivityBehavior (org.camunda.bpm.engine.impl.cmmn.behavior.DmnDecisionTaskActivityBehavior)6 BaseCallableElement (org.camunda.bpm.engine.impl.core.model.BaseCallableElement)6 ExpressionManager (org.camunda.bpm.engine.impl.el.ExpressionManager)5 CamundaOut (org.camunda.bpm.model.cmmn.instance.camunda.CamundaOut)5 BpmnParseException (org.camunda.bpm.engine.BpmnParseException)3 NullValueProvider (org.camunda.bpm.engine.impl.core.variable.mapping.value.NullValueProvider)2 Element (org.camunda.bpm.engine.impl.util.xml.Element)2 DecisionRefExpression (org.camunda.bpm.model.cmmn.instance.DecisionRefExpression)2