Search in sources :

Example 6 with ElValueProvider

use of org.camunda.bpm.engine.impl.el.ElValueProvider in project camunda-bpm-platform by camunda.

the class DecisionTaskPlanItemHandlerTest method testExpressionDecisionRef.

@Test
public void testExpressionDecisionRef() {
    // given:
    String decisionRef = "${aDecisionToCall}";
    decisionTask.setDecision(decisionRef);
    // when
    CmmnActivity activity = handler.handleElement(planItem, context);
    // then
    DecisionTaskActivityBehavior behavior = (DecisionTaskActivityBehavior) activity.getActivityBehavior();
    BaseCallableElement callableElement = behavior.getCallableElement();
    ParameterValueProvider caseRefValueProvider = callableElement.getDefinitionKeyValueProvider();
    assertNotNull(caseRefValueProvider);
    assertTrue(caseRefValueProvider instanceof ElValueProvider);
    ElValueProvider valueProvider = (ElValueProvider) caseRefValueProvider;
    assertEquals(decisionRef, valueProvider.getExpression().getExpressionText());
}
Also used : ParameterValueProvider(org.camunda.bpm.engine.impl.core.variable.mapping.value.ParameterValueProvider) DecisionTaskActivityBehavior(org.camunda.bpm.engine.impl.cmmn.behavior.DecisionTaskActivityBehavior) DmnDecisionTaskActivityBehavior(org.camunda.bpm.engine.impl.cmmn.behavior.DmnDecisionTaskActivityBehavior) BaseCallableElement(org.camunda.bpm.engine.impl.core.model.BaseCallableElement) ElValueProvider(org.camunda.bpm.engine.impl.el.ElValueProvider) CmmnActivity(org.camunda.bpm.engine.impl.cmmn.model.CmmnActivity) Test(org.junit.Test)

Example 7 with ElValueProvider

use of org.camunda.bpm.engine.impl.el.ElValueProvider in project camunda-bpm-platform by camunda.

the class DecisionTaskPlanItemHandlerTest method testExpressionDecisionRefExpression.

@Test
public void testExpressionDecisionRefExpression() {
    // given:
    String decision = "${aDecisionToCall}";
    DecisionRefExpression decisionRefExpression = createElement(decisionTask, DecisionRefExpression.class);
    decisionRefExpression.setText(decision);
    // when
    CmmnActivity activity = handler.handleElement(planItem, context);
    // then
    DecisionTaskActivityBehavior behavior = (DecisionTaskActivityBehavior) activity.getActivityBehavior();
    BaseCallableElement callableElement = behavior.getCallableElement();
    ParameterValueProvider caseRefValueProvider = callableElement.getDefinitionKeyValueProvider();
    assertNotNull(caseRefValueProvider);
    assertTrue(caseRefValueProvider instanceof ElValueProvider);
    ElValueProvider valueProvider = (ElValueProvider) caseRefValueProvider;
    assertEquals(decision, valueProvider.getExpression().getExpressionText());
}
Also used : ParameterValueProvider(org.camunda.bpm.engine.impl.core.variable.mapping.value.ParameterValueProvider) DecisionTaskActivityBehavior(org.camunda.bpm.engine.impl.cmmn.behavior.DecisionTaskActivityBehavior) DmnDecisionTaskActivityBehavior(org.camunda.bpm.engine.impl.cmmn.behavior.DmnDecisionTaskActivityBehavior) BaseCallableElement(org.camunda.bpm.engine.impl.core.model.BaseCallableElement) ElValueProvider(org.camunda.bpm.engine.impl.el.ElValueProvider) CmmnActivity(org.camunda.bpm.engine.impl.cmmn.model.CmmnActivity) DecisionRefExpression(org.camunda.bpm.model.cmmn.instance.DecisionRefExpression) Test(org.junit.Test)

Example 8 with ElValueProvider

use of org.camunda.bpm.engine.impl.el.ElValueProvider in project camunda-bpm-platform by camunda.

the class BpmnParseUtil method parseParamValueProvider.

/**
 * @throws BpmnParseException if the parameter is invalid
 */
protected static ParameterValueProvider parseParamValueProvider(Element parameterElement) {
    // LIST
    if ("list".equals(parameterElement.getTagName())) {
        List<ParameterValueProvider> providerList = new ArrayList<ParameterValueProvider>();
        for (Element element : parameterElement.elements()) {
            // parse nested provider
            providerList.add(parseParamValueProvider(element));
        }
        return new ListValueProvider(providerList);
    }
    // MAP
    if ("map".equals(parameterElement.getTagName())) {
        TreeMap<ParameterValueProvider, ParameterValueProvider> providerMap = new TreeMap<ParameterValueProvider, ParameterValueProvider>();
        for (Element entryElement : parameterElement.elements("entry")) {
            // entry must provide key
            String keyAttribute = entryElement.attribute("key");
            if (keyAttribute == null || keyAttribute.isEmpty()) {
                throw new BpmnParseException("Missing attribute 'key' for 'entry' element", entryElement);
            }
            // parse nested provider
            providerMap.put(new ElValueProvider(getExpressionManager().createExpression(keyAttribute)), parseNestedParamValueProvider(entryElement));
        }
        return new MapValueProvider(providerMap);
    }
    // SCRIPT
    if ("script".equals(parameterElement.getTagName())) {
        ExecutableScript executableScript = parseCamundaScript(parameterElement);
        if (executableScript != null) {
            return new ScriptValueProvider(executableScript);
        } else {
            return new NullValueProvider();
        }
    }
    String textContent = parameterElement.getText().trim();
    if (!textContent.isEmpty()) {
        // EL
        return new ElValueProvider(getExpressionManager().createExpression(textContent));
    } else {
        // NULL value
        return new NullValueProvider();
    }
}
Also used : Element(org.camunda.bpm.engine.impl.util.xml.Element) ArrayList(java.util.ArrayList) ElValueProvider(org.camunda.bpm.engine.impl.el.ElValueProvider) ScriptValueProvider(org.camunda.bpm.engine.impl.scripting.ScriptValueProvider) TreeMap(java.util.TreeMap) MapValueProvider(org.camunda.bpm.engine.impl.core.variable.mapping.value.MapValueProvider) BpmnParseException(org.camunda.bpm.engine.BpmnParseException) ParameterValueProvider(org.camunda.bpm.engine.impl.core.variable.mapping.value.ParameterValueProvider) ListValueProvider(org.camunda.bpm.engine.impl.core.variable.mapping.value.ListValueProvider) NullValueProvider(org.camunda.bpm.engine.impl.core.variable.mapping.value.NullValueProvider) ExecutableScript(org.camunda.bpm.engine.impl.scripting.ExecutableScript)

Example 9 with ElValueProvider

use of org.camunda.bpm.engine.impl.el.ElValueProvider in project camunda-bpm-platform by camunda.

the class ProcessTaskPlanItemHandlerTest method testVersionExpression.

@Test
public void testVersionExpression() {
    // given:
    String processVersion = "${aVersion}";
    processTask.setCamundaProcessVersion(processVersion);
    // when
    CmmnActivity activity = handler.handleElement(planItem, context);
    // then
    ProcessTaskActivityBehavior behavior = (ProcessTaskActivityBehavior) activity.getActivityBehavior();
    CallableElement callableElement = behavior.getCallableElement();
    ParameterValueProvider processVersionValueProvider = callableElement.getVersionValueProvider();
    assertNotNull(processVersionValueProvider);
    assertTrue(processVersionValueProvider instanceof ElValueProvider);
    ElValueProvider valueProvider = (ElValueProvider) processVersionValueProvider;
    assertEquals(processVersion, valueProvider.getExpression().getExpressionText());
}
Also used : CallableElement(org.camunda.bpm.engine.impl.core.model.CallableElement) ParameterValueProvider(org.camunda.bpm.engine.impl.core.variable.mapping.value.ParameterValueProvider) ProcessTaskActivityBehavior(org.camunda.bpm.engine.impl.cmmn.behavior.ProcessTaskActivityBehavior) ElValueProvider(org.camunda.bpm.engine.impl.el.ElValueProvider) CmmnActivity(org.camunda.bpm.engine.impl.cmmn.model.CmmnActivity) Test(org.junit.Test)

Example 10 with ElValueProvider

use of org.camunda.bpm.engine.impl.el.ElValueProvider in project camunda-bpm-platform by camunda.

the class ProcessTaskPlanItemHandlerTest method testBusinessKeyExpression.

@Test
public void testBusinessKeyExpression() {
    // given:
    String businessKey = "${myBusinessKey}";
    ExtensionElements extensionElements = addExtensionElements(processTask);
    CamundaIn businessKeyElement = createElement(extensionElements, null, CamundaIn.class);
    businessKeyElement.setCamundaBusinessKey(businessKey);
    // when
    CmmnActivity activity = handler.handleElement(planItem, context);
    // then
    ProcessTaskActivityBehavior behavior = (ProcessTaskActivityBehavior) activity.getActivityBehavior();
    CallableElement callableElement = behavior.getCallableElement();
    ParameterValueProvider businessKeyValueProvider = callableElement.getBusinessKeyValueProvider();
    assertNotNull(businessKeyValueProvider);
    assertTrue(businessKeyValueProvider instanceof ElValueProvider);
    ElValueProvider valueProvider = (ElValueProvider) businessKeyValueProvider;
    assertEquals(businessKey, 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) ProcessTaskActivityBehavior(org.camunda.bpm.engine.impl.cmmn.behavior.ProcessTaskActivityBehavior) ElValueProvider(org.camunda.bpm.engine.impl.el.ElValueProvider) CmmnActivity(org.camunda.bpm.engine.impl.cmmn.model.CmmnActivity) CamundaIn(org.camunda.bpm.model.cmmn.instance.camunda.CamundaIn) Test(org.junit.Test)

Aggregations

ParameterValueProvider (org.camunda.bpm.engine.impl.core.variable.mapping.value.ParameterValueProvider)14 ElValueProvider (org.camunda.bpm.engine.impl.el.ElValueProvider)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 ArrayList (java.util.ArrayList)1 TreeMap (java.util.TreeMap)1 BpmnParseException (org.camunda.bpm.engine.BpmnParseException)1 ListValueProvider (org.camunda.bpm.engine.impl.core.variable.mapping.value.ListValueProvider)1 MapValueProvider (org.camunda.bpm.engine.impl.core.variable.mapping.value.MapValueProvider)1 NullValueProvider (org.camunda.bpm.engine.impl.core.variable.mapping.value.NullValueProvider)1