Search in sources :

Example 1 with ParameterValueProvider

use of org.camunda.bpm.engine.impl.core.variable.mapping.value.ParameterValueProvider in project camunda-bpm-platform by camunda.

the class BpmnParseUtil method parseInputParameterElement.

/**
 * Parses a input parameter and adds it to the {@link IoMapping}.
 *
 * @param inputParameterElement the input parameter element
 * @param ioMapping the mapping to add the element
 * @throws BpmnParseException if the input parameter element is malformed
 */
public static void parseInputParameterElement(Element inputParameterElement, IoMapping ioMapping) {
    String nameAttribute = inputParameterElement.attribute("name");
    if (nameAttribute == null || nameAttribute.isEmpty()) {
        throw new BpmnParseException("Missing attribute 'name' for inputParameter", inputParameterElement);
    }
    ParameterValueProvider valueProvider = parseNestedParamValueProvider(inputParameterElement);
    // add parameter
    ioMapping.addInputParameter(new InputParameter(nameAttribute, valueProvider));
}
Also used : BpmnParseException(org.camunda.bpm.engine.BpmnParseException) ParameterValueProvider(org.camunda.bpm.engine.impl.core.variable.mapping.value.ParameterValueProvider) InputParameter(org.camunda.bpm.engine.impl.core.variable.mapping.InputParameter)

Example 2 with ParameterValueProvider

use of org.camunda.bpm.engine.impl.core.variable.mapping.value.ParameterValueProvider in project camunda-bpm-platform by camunda.

the class BpmnParseUtil method parseOutputParameterElement.

/**
 * Parses a output parameter and adds it to the {@link IoMapping}.
 *
 * @param outputParameterElement the output parameter element
 * @param ioMapping the mapping to add the element
 * @throws BpmnParseException if the output parameter element is malformed
 */
public static void parseOutputParameterElement(Element outputParameterElement, IoMapping ioMapping) {
    String nameAttribute = outputParameterElement.attribute("name");
    if (nameAttribute == null || nameAttribute.isEmpty()) {
        throw new BpmnParseException("Missing attribute 'name' for outputParameter", outputParameterElement);
    }
    ParameterValueProvider valueProvider = parseNestedParamValueProvider(outputParameterElement);
    // add parameter
    ioMapping.addOutputParameter(new OutputParameter(nameAttribute, valueProvider));
}
Also used : OutputParameter(org.camunda.bpm.engine.impl.core.variable.mapping.OutputParameter) BpmnParseException(org.camunda.bpm.engine.BpmnParseException) ParameterValueProvider(org.camunda.bpm.engine.impl.core.variable.mapping.value.ParameterValueProvider)

Example 3 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 parseDmnBusinessRuleTask.

/**
 * Parse a Business Rule Task which references a decision.
 */
protected ActivityImpl parseDmnBusinessRuleTask(Element businessRuleTaskElement, ScopeImpl scope) {
    ActivityImpl activity = createActivityOnScope(businessRuleTaskElement, scope);
    // the activity is a scope since the result variable is stored as local variable
    activity.setScope(true);
    parseAsynchronousContinuationForActivity(businessRuleTaskElement, activity);
    String decisionRef = businessRuleTaskElement.attributeNS(CAMUNDA_BPMN_EXTENSIONS_NS, "decisionRef");
    BaseCallableElement callableElement = new BaseCallableElement();
    callableElement.setDeploymentId(deployment.getId());
    ParameterValueProvider definitionKeyProvider = createParameterValueProvider(decisionRef, expressionManager);
    callableElement.setDefinitionKeyValueProvider(definitionKeyProvider);
    parseBinding(businessRuleTaskElement, activity, callableElement, "decisionRefBinding");
    parseVersion(businessRuleTaskElement, activity, callableElement, "decisionRefBinding", "decisionRefVersion");
    parseTenantId(businessRuleTaskElement, activity, callableElement, "decisionRefTenantId");
    String resultVariable = parseResultVariable(businessRuleTaskElement);
    DecisionResultMapper decisionResultMapper = parseDecisionResultMapper(businessRuleTaskElement);
    DmnBusinessRuleTaskActivityBehavior behavior = new DmnBusinessRuleTaskActivityBehavior(callableElement, resultVariable, decisionResultMapper);
    activity.setActivityBehavior(behavior);
    parseExecutionListenersOnScope(businessRuleTaskElement, activity);
    for (BpmnParseListener parseListener : parseListeners) {
        parseListener.parseBusinessRuleTask(businessRuleTaskElement, scope, activity);
    }
    return activity;
}
Also used : ParameterValueProvider(org.camunda.bpm.engine.impl.core.variable.mapping.value.ParameterValueProvider) DecisionResultMapper(org.camunda.bpm.engine.impl.dmn.result.DecisionResultMapper)

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

Example 5 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 parseInputParameter.

protected void parseInputParameter(Element elementWithParameters, CallableElement callableElement) {
    Element extensionsElement = elementWithParameters.element("extensionElements");
    if (extensionsElement != null) {
        // input data elements
        for (Element inElement : extensionsElement.elementsNS(CAMUNDA_BPMN_EXTENSIONS_NS, "in")) {
            String businessKey = inElement.attribute("businessKey");
            if (businessKey != null && !businessKey.isEmpty()) {
                ParameterValueProvider businessKeyValueProvider = createParameterValueProvider(businessKey, expressionManager);
                callableElement.setBusinessKeyValueProvider(businessKeyValueProvider);
            } else {
                CallableElementParameter parameter = parseCallableElementProvider(inElement);
                if (attributeValueEquals(inElement, "local", TRUE)) {
                    parameter.setReadLocal(true);
                }
                callableElement.addInput(parameter);
            }
        }
    }
}
Also used : ParameterValueProvider(org.camunda.bpm.engine.impl.core.variable.mapping.value.ParameterValueProvider) Element(org.camunda.bpm.engine.impl.util.xml.Element)

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