aboutsummaryrefslogtreecommitdiffstats
path: root/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/core/plugins/CallActivityBusinessKeyParseListener.java
blob: 80d86ad00901f0b79f3722493606445e2fe6bebf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package org.onap.so.bpmn.core.plugins;

import org.camunda.bpm.engine.impl.bpmn.behavior.CallableElementActivityBehavior;
import org.camunda.bpm.engine.impl.bpmn.parser.AbstractBpmnParseListener;
import org.camunda.bpm.engine.impl.context.Context;
import org.camunda.bpm.engine.impl.core.model.CallableElement;
import org.camunda.bpm.engine.impl.el.ElValueProvider;
import org.camunda.bpm.engine.impl.el.Expression;
import org.camunda.bpm.engine.impl.el.ExpressionManager;
import org.camunda.bpm.engine.impl.pvm.process.ActivityImpl;
import org.camunda.bpm.engine.impl.pvm.process.ScopeImpl;
import org.camunda.bpm.engine.impl.util.xml.Element;
import org.springframework.stereotype.Component;


@Component
public class CallActivityBusinessKeyParseListener extends AbstractBpmnParseListener {

    @Override
    public void parseCallActivity(Element callActivityElement, ScopeImpl scope, ActivityImpl activity) {
        ExpressionManager expressionManager = Context.getProcessEngineConfiguration().getExpressionManager();
        Expression expression = expressionManager.createExpression("#{execution.processBusinessKey}");
        ElValueProvider p = new ElValueProvider(expression);
        CallableElementActivityBehavior callableElementActivityBehavior =
                (CallableElementActivityBehavior) activity.getActivityBehavior();
        CallableElement callableElement = (CallableElement) callableElementActivityBehavior.getCallableElement();
        callableElement.setBusinessKeyValueProvider(p);
        callableElementActivityBehavior.setCallableElement(callableElement);
    }
}