Search in sources :

Example 6 with Condition

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

the class BpmnParse method parseSequenceFlowConditionExpression.

/**
 * Parses a condition expression on a sequence flow.
 *
 * @param seqFlowElement
 *          The 'sequenceFlow' element that can contain a condition.
 * @param seqFlow
 *          The sequenceFlow object representation to which the condition must
 *          be added.
 */
public void parseSequenceFlowConditionExpression(Element seqFlowElement, TransitionImpl seqFlow) {
    Element conditionExprElement = seqFlowElement.element(CONDITION_EXPRESSION);
    if (conditionExprElement != null) {
        Condition condition = parseConditionExpression(conditionExprElement);
        seqFlow.setProperty(PROPERTYNAME_CONDITION_TEXT, conditionExprElement.getText().trim());
        seqFlow.setProperty(PROPERTYNAME_CONDITION, condition);
    }
}
Also used : ScriptCondition(org.camunda.bpm.engine.impl.scripting.ScriptCondition) Condition(org.camunda.bpm.engine.impl.Condition) Element(org.camunda.bpm.engine.impl.util.xml.Element)

Example 7 with Condition

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

the class BpmnParse method parseConditionExpression.

protected Condition parseConditionExpression(Element conditionExprElement) {
    String expression = conditionExprElement.getText().trim();
    String type = conditionExprElement.attributeNS(XSI_NS, TYPE);
    String language = conditionExprElement.attribute(PROPERTYNAME_LANGUAGE);
    String resource = conditionExprElement.attributeNS(CAMUNDA_BPMN_EXTENSIONS_NS, PROPERTYNAME_RESOURCE);
    if (type != null) {
        String value = type.contains(":") ? resolveName(type) : BpmnParser.BPMN20_NS + ":" + type;
        if (!value.equals(ATTRIBUTEVALUE_T_FORMAL_EXPRESSION)) {
            addError("Invalid type, only tFormalExpression is currently supported", conditionExprElement);
        }
    }
    Condition condition = null;
    if (language == null) {
        condition = new UelExpressionCondition(expressionManager.createExpression(expression));
    } else {
        try {
            ExecutableScript script = ScriptUtil.getScript(language, expression, resource, expressionManager);
            condition = new ScriptCondition(script);
        } catch (ProcessEngineException e) {
            addError("Unable to process condition expression:" + e.getMessage(), conditionExprElement);
        }
    }
    return condition;
}
Also used : ScriptCondition(org.camunda.bpm.engine.impl.scripting.ScriptCondition) Condition(org.camunda.bpm.engine.impl.Condition) ExecutableScript(org.camunda.bpm.engine.impl.scripting.ExecutableScript) ProcessEngineException(org.camunda.bpm.engine.ProcessEngineException) ScriptCondition(org.camunda.bpm.engine.impl.scripting.ScriptCondition)

Aggregations

Condition (org.camunda.bpm.engine.impl.Condition)7 PvmTransition (org.camunda.bpm.engine.impl.pvm.PvmTransition)4 ScriptCondition (org.camunda.bpm.engine.impl.scripting.ScriptCondition)4 ArrayList (java.util.ArrayList)2 Element (org.camunda.bpm.engine.impl.util.xml.Element)2 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)1 PvmActivity (org.camunda.bpm.engine.impl.pvm.PvmActivity)1 ActivityExecution (org.camunda.bpm.engine.impl.pvm.delegate.ActivityExecution)1 ExecutableScript (org.camunda.bpm.engine.impl.scripting.ExecutableScript)1