Search in sources :

Example 1 with CamundaCaseExecutionListener

use of org.camunda.bpm.model.cmmn.instance.camunda.CamundaCaseExecutionListener in project camunda-cmmn-model by camunda.

the class CamundaCaseExecutionListenerImpl method registerType.

public static void registerType(ModelBuilder modelBuilder) {
    ModelElementTypeBuilder typeBuilder = modelBuilder.defineType(CamundaCaseExecutionListener.class, CAMUNDA_ELEMENT_CASE_EXECUTION_LISTENER).namespaceUri(CAMUNDA_NS).instanceProvider(new ModelTypeInstanceProvider<CamundaCaseExecutionListener>() {

        public CamundaCaseExecutionListener newInstance(ModelTypeInstanceContext instanceContext) {
            return new CamundaCaseExecutionListenerImpl(instanceContext);
        }
    });
    camundaEventAttribute = typeBuilder.stringAttribute(CAMUNDA_ATTRIBUTE_EVENT).namespace(CAMUNDA_NS).build();
    camundaClassAttribute = typeBuilder.stringAttribute(CAMUNDA_ATTRIBUTE_CLASS).namespace(CAMUNDA_NS).build();
    camundaExpressionAttribute = typeBuilder.stringAttribute(CAMUNDA_ATTRIBUTE_EXPRESSION).namespace(CAMUNDA_NS).build();
    camundaDelegateExpressionAttribute = typeBuilder.stringAttribute(CAMUNDA_ATTRIBUTE_DELEGATE_EXPRESSION).namespace(CAMUNDA_NS).build();
    SequenceBuilder sequenceBuilder = typeBuilder.sequence();
    camundaFieldCollection = sequenceBuilder.elementCollection(CamundaField.class).build();
    camundaScriptChild = sequenceBuilder.element(CamundaScript.class).build();
    typeBuilder.build();
}
Also used : CamundaCaseExecutionListener(org.camunda.bpm.model.cmmn.instance.camunda.CamundaCaseExecutionListener) SequenceBuilder(org.camunda.bpm.model.xml.type.child.SequenceBuilder) ModelElementTypeBuilder(org.camunda.bpm.model.xml.type.ModelElementTypeBuilder) ModelTypeInstanceContext(org.camunda.bpm.model.xml.impl.instance.ModelTypeInstanceContext)

Example 2 with CamundaCaseExecutionListener

use of org.camunda.bpm.model.cmmn.instance.camunda.CamundaCaseExecutionListener in project camunda-bpm-platform by camunda.

the class ItemHandler method initializeCaseExecutionListeners.

protected void initializeCaseExecutionListeners(CmmnElement element, CmmnActivity activity, CmmnHandlerContext context) {
    PlanItemDefinition definition = getDefinition(element);
    List<CamundaCaseExecutionListener> listeners = queryExtensionElementsByClass(definition, CamundaCaseExecutionListener.class);
    for (CamundaCaseExecutionListener listener : listeners) {
        CaseExecutionListener caseExecutionListener = initializeCaseExecutionListener(element, activity, context, listener);
        String eventName = listener.getCamundaEvent();
        if (eventName != null) {
            activity.addListener(eventName, caseExecutionListener);
        } else {
            for (String event : getStandardEvents(element)) {
                activity.addListener(event, caseExecutionListener);
            }
        }
    }
}
Also used : CamundaCaseExecutionListener(org.camunda.bpm.model.cmmn.instance.camunda.CamundaCaseExecutionListener) PlanItemDefinition(org.camunda.bpm.model.cmmn.instance.PlanItemDefinition) ExpressionCaseExecutionListener(org.camunda.bpm.engine.impl.cmmn.listener.ExpressionCaseExecutionListener) DelegateExpressionCaseExecutionListener(org.camunda.bpm.engine.impl.cmmn.listener.DelegateExpressionCaseExecutionListener) ScriptCaseExecutionListener(org.camunda.bpm.engine.impl.cmmn.listener.ScriptCaseExecutionListener) ClassDelegateCaseExecutionListener(org.camunda.bpm.engine.impl.cmmn.listener.ClassDelegateCaseExecutionListener) CamundaCaseExecutionListener(org.camunda.bpm.model.cmmn.instance.camunda.CamundaCaseExecutionListener) CaseExecutionListener(org.camunda.bpm.engine.delegate.CaseExecutionListener) CamundaString(org.camunda.bpm.model.cmmn.instance.camunda.CamundaString)

Example 3 with CamundaCaseExecutionListener

use of org.camunda.bpm.model.cmmn.instance.camunda.CamundaCaseExecutionListener in project camunda-bpm-platform by camunda.

the class AbstractExecutionListenerSpec method addListenerToElement.

public void addListenerToElement(CmmnModelInstance modelInstance, CmmnModelElementInstance modelElement) {
    ExtensionElements extensionElements = SpecUtil.createElement(modelInstance, modelElement, null, ExtensionElements.class);
    CamundaCaseExecutionListener caseExecutionListener = SpecUtil.createElement(modelInstance, extensionElements, null, CamundaCaseExecutionListener.class);
    if (!ANY_EVENT.equals(eventNameToRegisterOn)) {
        caseExecutionListener.setCamundaEvent(eventNameToRegisterOn);
    }
    configureCaseExecutionListener(modelInstance, caseExecutionListener);
    for (FieldSpec fieldSpec : fieldSpecs) {
        fieldSpec.addFieldToListenerElement(modelInstance, caseExecutionListener);
    }
}
Also used : ExtensionElements(org.camunda.bpm.model.cmmn.instance.ExtensionElements) CamundaCaseExecutionListener(org.camunda.bpm.model.cmmn.instance.camunda.CamundaCaseExecutionListener)

Example 4 with CamundaCaseExecutionListener

use of org.camunda.bpm.model.cmmn.instance.camunda.CamundaCaseExecutionListener in project camunda-bpm-platform by camunda.

the class ItemHandler method initializeCaseExecutionListener.

protected CaseExecutionListener initializeCaseExecutionListener(CmmnElement element, CmmnActivity activity, CmmnHandlerContext context, CamundaCaseExecutionListener listener) {
    Collection<CamundaField> fields = listener.getCamundaFields();
    List<FieldDeclaration> fieldDeclarations = initializeFieldDeclarations(element, activity, context, fields);
    ExpressionManager expressionManager = context.getExpressionManager();
    CaseExecutionListener caseExecutionListener = null;
    String className = listener.getCamundaClass();
    String expression = listener.getCamundaExpression();
    String delegateExpression = listener.getCamundaDelegateExpression();
    CamundaScript scriptElement = listener.getCamundaScript();
    if (className != null) {
        caseExecutionListener = new ClassDelegateCaseExecutionListener(className, fieldDeclarations);
    } else if (expression != null) {
        Expression expressionExp = expressionManager.createExpression(expression);
        caseExecutionListener = new ExpressionCaseExecutionListener(expressionExp);
    } else if (delegateExpression != null) {
        Expression delegateExp = expressionManager.createExpression(delegateExpression);
        caseExecutionListener = new DelegateExpressionCaseExecutionListener(delegateExp, fieldDeclarations);
    } else if (scriptElement != null) {
        ExecutableScript executableScript = initializeScript(element, activity, context, scriptElement);
        if (executableScript != null) {
            caseExecutionListener = new ScriptCaseExecutionListener(executableScript);
        }
    }
    return caseExecutionListener;
}
Also used : CamundaField(org.camunda.bpm.model.cmmn.instance.camunda.CamundaField) ExpressionManager(org.camunda.bpm.engine.impl.el.ExpressionManager) ClassDelegateCaseExecutionListener(org.camunda.bpm.engine.impl.cmmn.listener.ClassDelegateCaseExecutionListener) DelegateExpressionCaseExecutionListener(org.camunda.bpm.engine.impl.cmmn.listener.DelegateExpressionCaseExecutionListener) ExpressionCaseExecutionListener(org.camunda.bpm.engine.impl.cmmn.listener.ExpressionCaseExecutionListener) DelegateExpressionCaseExecutionListener(org.camunda.bpm.engine.impl.cmmn.listener.DelegateExpressionCaseExecutionListener) ScriptCaseExecutionListener(org.camunda.bpm.engine.impl.cmmn.listener.ScriptCaseExecutionListener) ClassDelegateCaseExecutionListener(org.camunda.bpm.engine.impl.cmmn.listener.ClassDelegateCaseExecutionListener) CamundaCaseExecutionListener(org.camunda.bpm.model.cmmn.instance.camunda.CamundaCaseExecutionListener) CaseExecutionListener(org.camunda.bpm.engine.delegate.CaseExecutionListener) ScriptCaseExecutionListener(org.camunda.bpm.engine.impl.cmmn.listener.ScriptCaseExecutionListener) CamundaString(org.camunda.bpm.model.cmmn.instance.camunda.CamundaString) FieldDeclaration(org.camunda.bpm.engine.impl.bpmn.parser.FieldDeclaration) ExpressionCaseExecutionListener(org.camunda.bpm.engine.impl.cmmn.listener.ExpressionCaseExecutionListener) DelegateExpressionCaseExecutionListener(org.camunda.bpm.engine.impl.cmmn.listener.DelegateExpressionCaseExecutionListener) CamundaExpression(org.camunda.bpm.model.cmmn.instance.camunda.CamundaExpression) Expression(org.camunda.bpm.engine.delegate.Expression) ConditionExpression(org.camunda.bpm.model.cmmn.instance.ConditionExpression) ExecutableScript(org.camunda.bpm.engine.impl.scripting.ExecutableScript) CamundaScript(org.camunda.bpm.model.cmmn.instance.camunda.CamundaScript)

Aggregations

CamundaCaseExecutionListener (org.camunda.bpm.model.cmmn.instance.camunda.CamundaCaseExecutionListener)4 CaseExecutionListener (org.camunda.bpm.engine.delegate.CaseExecutionListener)2 ClassDelegateCaseExecutionListener (org.camunda.bpm.engine.impl.cmmn.listener.ClassDelegateCaseExecutionListener)2 DelegateExpressionCaseExecutionListener (org.camunda.bpm.engine.impl.cmmn.listener.DelegateExpressionCaseExecutionListener)2 ExpressionCaseExecutionListener (org.camunda.bpm.engine.impl.cmmn.listener.ExpressionCaseExecutionListener)2 ScriptCaseExecutionListener (org.camunda.bpm.engine.impl.cmmn.listener.ScriptCaseExecutionListener)2 CamundaString (org.camunda.bpm.model.cmmn.instance.camunda.CamundaString)2 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 ExecutableScript (org.camunda.bpm.engine.impl.scripting.ExecutableScript)1 ConditionExpression (org.camunda.bpm.model.cmmn.instance.ConditionExpression)1 ExtensionElements (org.camunda.bpm.model.cmmn.instance.ExtensionElements)1 PlanItemDefinition (org.camunda.bpm.model.cmmn.instance.PlanItemDefinition)1 CamundaExpression (org.camunda.bpm.model.cmmn.instance.camunda.CamundaExpression)1 CamundaField (org.camunda.bpm.model.cmmn.instance.camunda.CamundaField)1 CamundaScript (org.camunda.bpm.model.cmmn.instance.camunda.CamundaScript)1 ModelTypeInstanceContext (org.camunda.bpm.model.xml.impl.instance.ModelTypeInstanceContext)1 ModelElementTypeBuilder (org.camunda.bpm.model.xml.type.ModelElementTypeBuilder)1 SequenceBuilder (org.camunda.bpm.model.xml.type.child.SequenceBuilder)1