* The XML element defining the call activity
* @param scope
* The current scope on which the call activity is defined.
*/
public ActivityImpl parseCallActivity(Element callActivityElement, ScopeImpl scope) {
ActivityImpl activity = createActivityOnScope(callActivityElement, scope);
parseAsynchronousContinuation(callActivityElement, activity);
String calledElement = callActivityElement.attribute("calledElement");
String calledElementBinding = callActivityElement.attributeNS(BpmnParser.ACTIVITI_BPMN_EXTENSIONS_NS, "calledElementBinding");
String calledElementVersion = callActivityElement.attributeNS(BpmnParser.ACTIVITI_BPMN_EXTENSIONS_NS, "calledElementVersion");
if (calledElement == null) {
addError("Missing attribute 'calledElement'", callActivityElement);
}
if (calledElementBinding != null &&
calledElementBinding.equals(CallActivityBehavior.CalledElementBinding.VERSION.getValue()) &&
calledElementVersion == null) {
addError("Missing attribute 'calledElementVersion' when calledElementBinding has value '" + CallActivityBehavior.CalledElementBinding.VERSION.getValue() + "'", callActivityElement);
}
Integer processDefinitionVersion = null;
if (calledElementVersion != null) {
processDefinitionVersion = Integer.parseInt(calledElementVersion);
}
CallActivityBehavior callActivityBehaviour = null;
String expressionRegex = "(\\$|#)(\\{.+\\})";
if (calledElement != null && calledElement.matches(expressionRegex)) {
if (calledElementBinding == null) {
callActivityBehaviour = new CallActivityBehavior(expressionManager.createExpression(calledElement));
} else {
callActivityBehaviour = new CallActivityBehavior(expressionManager.createExpression(calledElement), calledElementBinding, processDefinitionVersion);
}
} else {
if (calledElementBinding == null) {
callActivityBehaviour = new CallActivityBehavior(calledElement);
} else {
callActivityBehaviour = new CallActivityBehavior(calledElement, calledElementBinding, processDefinitionVersion);
}
}
Element extensionsElement = callActivityElement.element("extensionElements");
if (extensionsElement != null) {
// input data elements
for (Element inElement : extensionsElement.elementsNS(BpmnParser.ACTIVITI_BPMN_EXTENSIONS_NS, "in")) {
String source = inElement.attribute("source");
String sourceExpression = inElement.attribute("sourceExpression");
String target = inElement.attribute("target");
String variables = inElement.attribute("variables");
String businessKeyExpression = inElement.attribute("businessKey");
if ((source != null || sourceExpression != null) && target == null) {
addError("Missing attribute 'target' when attribute source or sourceExpression is set", inElement);
}
else if (sourceExpression != null) {
Expression expression = expressionManager.createExpression(sourceExpression.trim());
callActivityBehaviour.addDataInputAssociation(new DataAssociation(expression, target));
} else if (variables != null && ("all").equals(variables)) {
callActivityBehaviour.addDataInputAssociation(new DataAssociation(variables));
} else if (businessKeyExpression != null) {
Expression expression = expressionManager.createExpression(businessKeyExpression.trim());
callActivityBehaviour.addDataInputAssociation(new DataAssociation(expression));
} else {
callActivityBehaviour.addDataInputAssociation(new DataAssociation(source, target));
}
}
// output data elements
for (Element outElement : extensionsElement.elementsNS(BpmnParser.ACTIVITI_BPMN_EXTENSIONS_NS, "out")) {
String source = outElement.attribute("source");
String sourceExpression = outElement.attribute("sourceExpression");
String target = outElement.attribute("target");
String variables = outElement.attribute("variables");
if ((source != null || sourceExpression != null) && target == null) {
addError("Missing attribute 'target' when attribute source or sourceExpression is set", outElement);
}
else if (sourceExpression != null) {
Expression expression = expressionManager.createExpression(sourceExpression.trim());
callActivityBehaviour.addDataOutputAssociation(new DataAssociation(expression, target));
} else if (variables != null && ("all").equals(variables)) {
callActivityBehaviour.addDataOutputAssociation(new DataAssociation(variables));
} else {
callActivityBehaviour.addDataOutputAssociation(new DataAssociation(source, target));
}
}
}
activity.setScope(true);
activity.setActivityBehavior(callActivityBehaviour);
parseExecutionListenersOnScope(callActivityElement, activity);
for (BpmnParseListener parseListener : parseListeners) {
parseListener.parseCallActivity(callActivityElement, scope, activity);