Search in sources :

Example 1 with ScriptTaskListener

use of org.camunda.bpm.engine.impl.task.listener.ScriptTaskListener in project camunda-bpm-platform by camunda.

the class HumanTaskItemHandler method initializeTaskListener.

protected TaskListener initializeTaskListener(CmmnElement element, CmmnActivity activity, CmmnHandlerContext context, CamundaTaskListener listener) {
    Collection<CamundaField> fields = listener.getCamundaFields();
    List<FieldDeclaration> fieldDeclarations = initializeFieldDeclarations(element, activity, context, fields);
    ExpressionManager expressionManager = context.getExpressionManager();
    TaskListener taskListener = null;
    String className = listener.getCamundaClass();
    String expression = listener.getCamundaExpression();
    String delegateExpression = listener.getCamundaDelegateExpression();
    CamundaScript scriptElement = listener.getCamundaScript();
    if (className != null) {
        taskListener = new ClassDelegateTaskListener(className, fieldDeclarations);
    } else if (expression != null) {
        Expression expressionExp = expressionManager.createExpression(expression);
        taskListener = new ExpressionTaskListener(expressionExp);
    } else if (delegateExpression != null) {
        Expression delegateExp = expressionManager.createExpression(delegateExpression);
        taskListener = new DelegateExpressionTaskListener(delegateExp, fieldDeclarations);
    } else if (scriptElement != null) {
        ExecutableScript executableScript = initializeScript(element, activity, context, scriptElement);
        if (executableScript != null) {
            taskListener = new ScriptTaskListener(executableScript);
        }
    }
    return taskListener;
}
Also used : CamundaField(org.camunda.bpm.model.cmmn.instance.camunda.CamundaField) ExpressionManager(org.camunda.bpm.engine.impl.el.ExpressionManager) DelegateExpressionTaskListener(org.camunda.bpm.engine.impl.task.listener.DelegateExpressionTaskListener) FieldDeclaration(org.camunda.bpm.engine.impl.bpmn.parser.FieldDeclaration) Expression(org.camunda.bpm.engine.delegate.Expression) ExpressionTaskListener(org.camunda.bpm.engine.impl.task.listener.ExpressionTaskListener) DelegateExpressionTaskListener(org.camunda.bpm.engine.impl.task.listener.DelegateExpressionTaskListener) CamundaTaskListener(org.camunda.bpm.model.cmmn.instance.camunda.CamundaTaskListener) ExpressionTaskListener(org.camunda.bpm.engine.impl.task.listener.ExpressionTaskListener) ClassDelegateTaskListener(org.camunda.bpm.engine.impl.task.listener.ClassDelegateTaskListener) TaskListener(org.camunda.bpm.engine.delegate.TaskListener) DelegateExpressionTaskListener(org.camunda.bpm.engine.impl.task.listener.DelegateExpressionTaskListener) ScriptTaskListener(org.camunda.bpm.engine.impl.task.listener.ScriptTaskListener) ExecutableScript(org.camunda.bpm.engine.impl.scripting.ExecutableScript) ClassDelegateTaskListener(org.camunda.bpm.engine.impl.task.listener.ClassDelegateTaskListener) ScriptTaskListener(org.camunda.bpm.engine.impl.task.listener.ScriptTaskListener) CamundaScript(org.camunda.bpm.model.cmmn.instance.camunda.CamundaScript)

Example 2 with ScriptTaskListener

use of org.camunda.bpm.engine.impl.task.listener.ScriptTaskListener in project camunda-bpm-platform by camunda.

the class BpmnParse method parseTaskListener.

protected TaskListener parseTaskListener(Element taskListenerElement) {
    TaskListener taskListener = null;
    String className = taskListenerElement.attribute(PROPERTYNAME_CLASS);
    String expression = taskListenerElement.attribute(PROPERTYNAME_EXPRESSION);
    String delegateExpression = taskListenerElement.attribute(PROPERTYNAME_DELEGATE_EXPRESSION);
    Element scriptElement = taskListenerElement.elementNS(CAMUNDA_BPMN_EXTENSIONS_NS, "script");
    if (className != null) {
        taskListener = new ClassDelegateTaskListener(className, parseFieldDeclarations(taskListenerElement));
    } else if (expression != null) {
        taskListener = new ExpressionTaskListener(expressionManager.createExpression(expression));
    } else if (delegateExpression != null) {
        taskListener = new DelegateExpressionTaskListener(expressionManager.createExpression(delegateExpression), parseFieldDeclarations(taskListenerElement));
    } else if (scriptElement != null) {
        try {
            ExecutableScript executableScript = parseCamundaScript(scriptElement);
            if (executableScript != null) {
                taskListener = new ScriptTaskListener(executableScript);
            }
        } catch (BpmnParseException e) {
            addError(e);
        }
    } else {
        addError("Element 'class', 'expression', 'delegateExpression' or 'script' is mandatory on taskListener", taskListenerElement);
    }
    return taskListener;
}
Also used : DelegateExpressionTaskListener(org.camunda.bpm.engine.impl.task.listener.DelegateExpressionTaskListener) BpmnParseException(org.camunda.bpm.engine.BpmnParseException) Element(org.camunda.bpm.engine.impl.util.xml.Element) ExpressionTaskListener(org.camunda.bpm.engine.impl.task.listener.ExpressionTaskListener) DelegateExpressionTaskListener(org.camunda.bpm.engine.impl.task.listener.DelegateExpressionTaskListener) ScriptTaskListener(org.camunda.bpm.engine.impl.task.listener.ScriptTaskListener) ExpressionTaskListener(org.camunda.bpm.engine.impl.task.listener.ExpressionTaskListener) ClassDelegateTaskListener(org.camunda.bpm.engine.impl.task.listener.ClassDelegateTaskListener) TaskListener(org.camunda.bpm.engine.delegate.TaskListener) DelegateExpressionTaskListener(org.camunda.bpm.engine.impl.task.listener.DelegateExpressionTaskListener) ExecutableScript(org.camunda.bpm.engine.impl.scripting.ExecutableScript) ClassDelegateTaskListener(org.camunda.bpm.engine.impl.task.listener.ClassDelegateTaskListener) ScriptTaskListener(org.camunda.bpm.engine.impl.task.listener.ScriptTaskListener)

Aggregations

TaskListener (org.camunda.bpm.engine.delegate.TaskListener)2 ExecutableScript (org.camunda.bpm.engine.impl.scripting.ExecutableScript)2 ClassDelegateTaskListener (org.camunda.bpm.engine.impl.task.listener.ClassDelegateTaskListener)2 DelegateExpressionTaskListener (org.camunda.bpm.engine.impl.task.listener.DelegateExpressionTaskListener)2 ExpressionTaskListener (org.camunda.bpm.engine.impl.task.listener.ExpressionTaskListener)2 ScriptTaskListener (org.camunda.bpm.engine.impl.task.listener.ScriptTaskListener)2 BpmnParseException (org.camunda.bpm.engine.BpmnParseException)1 Expression (org.camunda.bpm.engine.delegate.Expression)1 FieldDeclaration (org.camunda.bpm.engine.impl.bpmn.parser.FieldDeclaration)1 ExpressionManager (org.camunda.bpm.engine.impl.el.ExpressionManager)1 Element (org.camunda.bpm.engine.impl.util.xml.Element)1 CamundaField (org.camunda.bpm.model.cmmn.instance.camunda.CamundaField)1 CamundaScript (org.camunda.bpm.model.cmmn.instance.camunda.CamundaScript)1 CamundaTaskListener (org.camunda.bpm.model.cmmn.instance.camunda.CamundaTaskListener)1