Search in sources :

Example 1 with ConstantValueProvider

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;
}
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 2 with ConstantValueProvider

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));
}
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) CamundaOut(org.camunda.bpm.model.cmmn.instance.camunda.CamundaOut) CmmnActivity(org.camunda.bpm.engine.impl.cmmn.model.CmmnActivity) ConstantValueProvider(org.camunda.bpm.engine.impl.core.variable.mapping.value.ConstantValueProvider) CaseTaskActivityBehavior(org.camunda.bpm.engine.impl.cmmn.behavior.CaseTaskActivityBehavior) Test(org.junit.Test)

Example 3 with ConstantValueProvider

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));
}
Also used : CallableElement(org.camunda.bpm.engine.impl.core.model.CallableElement) ParameterValueProvider(org.camunda.bpm.engine.impl.core.variable.mapping.value.ParameterValueProvider) CmmnActivity(org.camunda.bpm.engine.impl.cmmn.model.CmmnActivity) ConstantValueProvider(org.camunda.bpm.engine.impl.core.variable.mapping.value.ConstantValueProvider) CaseTaskActivityBehavior(org.camunda.bpm.engine.impl.cmmn.behavior.CaseTaskActivityBehavior) Test(org.junit.Test)

Example 4 with ConstantValueProvider

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));
}
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) CmmnActivity(org.camunda.bpm.engine.impl.cmmn.model.CmmnActivity) ConstantValueProvider(org.camunda.bpm.engine.impl.core.variable.mapping.value.ConstantValueProvider) CamundaIn(org.camunda.bpm.model.cmmn.instance.camunda.CamundaIn) CaseTaskActivityBehavior(org.camunda.bpm.engine.impl.cmmn.behavior.CaseTaskActivityBehavior) Test(org.junit.Test)

Example 5 with ConstantValueProvider

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));
}
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) CmmnActivity(org.camunda.bpm.engine.impl.cmmn.model.CmmnActivity) ConstantValueProvider(org.camunda.bpm.engine.impl.core.variable.mapping.value.ConstantValueProvider) CamundaIn(org.camunda.bpm.model.cmmn.instance.camunda.CamundaIn) CaseTaskActivityBehavior(org.camunda.bpm.engine.impl.cmmn.behavior.CaseTaskActivityBehavior) Test(org.junit.Test)

Aggregations

ConstantValueProvider (org.camunda.bpm.engine.impl.core.variable.mapping.value.ConstantValueProvider)14 ParameterValueProvider (org.camunda.bpm.engine.impl.core.variable.mapping.value.ParameterValueProvider)14 CmmnActivity (org.camunda.bpm.engine.impl.cmmn.model.CmmnActivity)13 Test (org.junit.Test)13 CallableElement (org.camunda.bpm.engine.impl.core.model.CallableElement)10 ExtensionElements (org.camunda.bpm.model.cmmn.instance.ExtensionElements)6 CaseTaskActivityBehavior (org.camunda.bpm.engine.impl.cmmn.behavior.CaseTaskActivityBehavior)5 ProcessTaskActivityBehavior (org.camunda.bpm.engine.impl.cmmn.behavior.ProcessTaskActivityBehavior)5 CallableElementParameter (org.camunda.bpm.engine.impl.core.model.CallableElementParameter)4 CamundaIn (org.camunda.bpm.model.cmmn.instance.camunda.CamundaIn)4 DecisionTaskActivityBehavior (org.camunda.bpm.engine.impl.cmmn.behavior.DecisionTaskActivityBehavior)3 DmnDecisionTaskActivityBehavior (org.camunda.bpm.engine.impl.cmmn.behavior.DmnDecisionTaskActivityBehavior)3 BaseCallableElement (org.camunda.bpm.engine.impl.core.model.BaseCallableElement)3 CamundaOut (org.camunda.bpm.model.cmmn.instance.camunda.CamundaOut)2 NullValueProvider (org.camunda.bpm.engine.impl.core.variable.mapping.value.NullValueProvider)1 DecisionRefExpression (org.camunda.bpm.model.cmmn.instance.DecisionRefExpression)1