Search in sources :

Example 1 with ScriptCondition

use of org.camunda.bpm.engine.impl.scripting.ScriptCondition 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

ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)1 Condition (org.camunda.bpm.engine.impl.Condition)1 ExecutableScript (org.camunda.bpm.engine.impl.scripting.ExecutableScript)1 ScriptCondition (org.camunda.bpm.engine.impl.scripting.ScriptCondition)1