Search in sources :

Example 6 with Expression

use of org.camunda.bpm.engine.delegate.Expression 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 7 with Expression

use of org.camunda.bpm.engine.delegate.Expression in project camunda-bpm-platform by camunda.

the class HumanTaskItemHandler method initializeTaskDefinitionAssignee.

protected void initializeTaskDefinitionAssignee(CmmnElement element, TaskDefinition taskDefinition, CmmnHandlerContext context) {
    HumanTask definition = getDefinition(element);
    Role performer = definition.getPerformer();
    String assignee = null;
    if (performer != null) {
        assignee = performer.getName();
    } else {
        assignee = definition.getCamundaAssignee();
    }
    if (assignee != null) {
        ExpressionManager expressionManager = context.getExpressionManager();
        Expression assigneeExpression = expressionManager.createExpression(assignee);
        taskDefinition.setAssigneeExpression(assigneeExpression);
    }
}
Also used : Role(org.camunda.bpm.model.cmmn.instance.Role) ExpressionManager(org.camunda.bpm.engine.impl.el.ExpressionManager) Expression(org.camunda.bpm.engine.delegate.Expression) HumanTask(org.camunda.bpm.model.cmmn.instance.HumanTask)

Example 8 with Expression

use of org.camunda.bpm.engine.delegate.Expression in project camunda-bpm-platform by camunda.

the class HumanTaskItemHandler method initializeTaskDefinitionFollowUpDate.

protected void initializeTaskDefinitionFollowUpDate(CmmnElement element, TaskDefinition taskDefinition, CmmnHandlerContext context) {
    HumanTask definition = getDefinition(element);
    String followUpDate = definition.getCamundaFollowUpDate();
    if (followUpDate != null) {
        ExpressionManager expressionManager = context.getExpressionManager();
        Expression followUpDateExpression = expressionManager.createExpression(followUpDate);
        taskDefinition.setFollowUpDateExpression(followUpDateExpression);
    }
}
Also used : ExpressionManager(org.camunda.bpm.engine.impl.el.ExpressionManager) Expression(org.camunda.bpm.engine.delegate.Expression) HumanTask(org.camunda.bpm.model.cmmn.instance.HumanTask)

Example 9 with Expression

use of org.camunda.bpm.engine.delegate.Expression in project camunda-bpm-platform by camunda.

the class DefaultFormHandler method parseFormField.

protected void parseFormField(Element formField, BpmnParse bpmnParse, ExpressionManager expressionManager) {
    FormFieldHandler formFieldHandler = new FormFieldHandler();
    // parse Id
    String id = formField.attribute("id");
    if (id == null || id.isEmpty()) {
        bpmnParse.addError("attribute id must be set for FormFieldGroup and must have a non-empty value", formField);
    } else {
        formFieldHandler.setId(id);
    }
    if (id.equals(businessKeyFieldId)) {
        formFieldHandler.setBusinessKey(true);
    }
    // parse name
    String name = formField.attribute("label");
    if (name != null) {
        Expression nameExpression = expressionManager.createExpression(name);
        formFieldHandler.setLabel(nameExpression);
    }
    // parse properties
    parseProperties(formField, formFieldHandler, bpmnParse, expressionManager);
    // parse validation
    parseValidation(formField, formFieldHandler, bpmnParse, expressionManager);
    // parse type
    FormTypes formTypes = getFormTypes();
    AbstractFormFieldType formType = formTypes.parseFormPropertyType(formField, bpmnParse);
    formFieldHandler.setType(formType);
    // parse default value
    String defaultValue = formField.attribute("defaultValue");
    if (defaultValue != null) {
        Expression defaultValueExpression = expressionManager.createExpression(defaultValue);
        formFieldHandler.setDefaultValueExpression(defaultValueExpression);
    }
    formFieldHandlers.add(formFieldHandler);
}
Also used : FormTypes(org.camunda.bpm.engine.impl.form.type.FormTypes) Expression(org.camunda.bpm.engine.delegate.Expression) AbstractFormFieldType(org.camunda.bpm.engine.impl.form.type.AbstractFormFieldType)

Example 10 with Expression

use of org.camunda.bpm.engine.delegate.Expression in project camunda-bpm-platform by camunda.

the class DefaultFormHandler method parseFormProperties.

protected void parseFormProperties(BpmnParse bpmnParse, ExpressionManager expressionManager, Element extensionElement) {
    FormTypes formTypes = getFormTypes();
    List<Element> formPropertyElements = extensionElement.elementsNS(BpmnParse.CAMUNDA_BPMN_EXTENSIONS_NS, FORM_PROPERTY_ELEMENT);
    for (Element formPropertyElement : formPropertyElements) {
        FormPropertyHandler formPropertyHandler = new FormPropertyHandler();
        String id = formPropertyElement.attribute("id");
        if (id == null) {
            bpmnParse.addError("attribute 'id' is required", formPropertyElement);
        }
        formPropertyHandler.setId(id);
        String name = formPropertyElement.attribute("name");
        formPropertyHandler.setName(name);
        AbstractFormFieldType type = formTypes.parseFormPropertyType(formPropertyElement, bpmnParse);
        formPropertyHandler.setType(type);
        String requiredText = formPropertyElement.attribute("required", "false");
        Boolean required = bpmnParse.parseBooleanAttribute(requiredText);
        if (required != null) {
            formPropertyHandler.setRequired(required);
        } else {
            bpmnParse.addError("attribute 'required' must be one of {on|yes|true|enabled|active|off|no|false|disabled|inactive}", formPropertyElement);
        }
        String readableText = formPropertyElement.attribute("readable", "true");
        Boolean readable = bpmnParse.parseBooleanAttribute(readableText);
        if (readable != null) {
            formPropertyHandler.setReadable(readable);
        } else {
            bpmnParse.addError("attribute 'readable' must be one of {on|yes|true|enabled|active|off|no|false|disabled|inactive}", formPropertyElement);
        }
        String writableText = formPropertyElement.attribute("writable", "true");
        Boolean writable = bpmnParse.parseBooleanAttribute(writableText);
        if (writable != null) {
            formPropertyHandler.setWritable(writable);
        } else {
            bpmnParse.addError("attribute 'writable' must be one of {on|yes|true|enabled|active|off|no|false|disabled|inactive}", formPropertyElement);
        }
        String variableName = formPropertyElement.attribute("variable");
        formPropertyHandler.setVariableName(variableName);
        String expressionText = formPropertyElement.attribute("expression");
        if (expressionText != null) {
            Expression expression = expressionManager.createExpression(expressionText);
            formPropertyHandler.setVariableExpression(expression);
        }
        String defaultExpressionText = formPropertyElement.attribute("default");
        if (defaultExpressionText != null) {
            Expression defaultExpression = expressionManager.createExpression(defaultExpressionText);
            formPropertyHandler.setDefaultExpression(defaultExpression);
        }
        formPropertyHandlers.add(formPropertyHandler);
    }
}
Also used : FormTypes(org.camunda.bpm.engine.impl.form.type.FormTypes) Expression(org.camunda.bpm.engine.delegate.Expression) Element(org.camunda.bpm.engine.impl.util.xml.Element) AbstractFormFieldType(org.camunda.bpm.engine.impl.form.type.AbstractFormFieldType)

Aggregations

Expression (org.camunda.bpm.engine.delegate.Expression)62 ConditionExpression (org.camunda.bpm.model.cmmn.instance.ConditionExpression)18 Test (org.junit.Test)15 CmmnActivity (org.camunda.bpm.engine.impl.cmmn.model.CmmnActivity)14 ExpressionManager (org.camunda.bpm.engine.impl.el.ExpressionManager)14 HumanTaskActivityBehavior (org.camunda.bpm.engine.impl.cmmn.behavior.HumanTaskActivityBehavior)12 TaskDefinition (org.camunda.bpm.engine.impl.task.TaskDefinition)12 HumanTask (org.camunda.bpm.model.cmmn.instance.HumanTask)8 ArrayList (java.util.ArrayList)4 Date (java.util.Date)4 CmmnIfPartDeclaration (org.camunda.bpm.engine.impl.cmmn.model.CmmnIfPartDeclaration)4 IdentityLink (org.camunda.bpm.engine.task.IdentityLink)4 CamundaField (org.camunda.bpm.model.cmmn.instance.camunda.CamundaField)4 FieldDeclaration (org.camunda.bpm.engine.impl.bpmn.parser.FieldDeclaration)3 CaseControlRuleImpl (org.camunda.bpm.engine.impl.cmmn.behavior.CaseControlRuleImpl)3 CmmnSentryDeclaration (org.camunda.bpm.engine.impl.cmmn.model.CmmnSentryDeclaration)3 ExecutableScript (org.camunda.bpm.engine.impl.scripting.ExecutableScript)3 CamundaExpression (org.camunda.bpm.model.cmmn.instance.camunda.CamundaExpression)3 CamundaString (org.camunda.bpm.model.cmmn.instance.camunda.CamundaString)3 Collection (java.util.Collection)2