// characteristics
if (!(activity.getActivityBehavior() instanceof AbstractBpmnActivityBehavior)) {
return;
}
Element miLoopCharacteristics = activityElement.element("multiInstanceLoopCharacteristics");
if (miLoopCharacteristics != null) {
MultiInstanceActivityBehavior miActivityBehavior = null;
boolean isSequential = parseBooleanAttribute(miLoopCharacteristics.attribute("isSequential"), false);
if (isSequential) {
miActivityBehavior = new SequentialMultiInstanceBehavior(activity, (AbstractBpmnActivityBehavior) activity.getActivityBehavior());
} else {
miActivityBehavior = new ParallelMultiInstanceBehavior(activity, (AbstractBpmnActivityBehavior) activity.getActivityBehavior());
}
activity.setScope(true);
activity.setProperty("multiInstance", isSequential ? "sequential" : "parallel");
activity.setActivityBehavior(miActivityBehavior);
// loopCardinality
Element loopCardinality = miLoopCharacteristics.element("loopCardinality");
if (loopCardinality != null) {
String loopCardinalityText = loopCardinality.getText();
if (loopCardinalityText == null || "".equals(loopCardinalityText)) {
addError("loopCardinality must be defined for a multiInstanceLoopCharacteristics definition ", miLoopCharacteristics);
}
miActivityBehavior.setLoopCardinalityExpression(expressionManager.createExpression(loopCardinalityText));
}
// completionCondition
Element completionCondition = miLoopCharacteristics.element("completionCondition");
if (completionCondition != null) {
String completionConditionText = completionCondition.getText();
miActivityBehavior.setCompletionConditionExpression(expressionManager.createExpression(completionConditionText));
}
// activiti:collection
String collection = miLoopCharacteristics.attributeNS(BpmnParser.ACTIVITI_BPMN_EXTENSIONS_NS, "collection");
if (collection != null) {
if (collection.contains("{")) {
miActivityBehavior.setCollectionExpression(expressionManager.createExpression(collection));
} else {
miActivityBehavior.setCollectionVariable(collection);
}
}
// loopDataInputRef
Element loopDataInputRef = miLoopCharacteristics.element("loopDataInputRef");
if (loopDataInputRef != null) {
String loopDataInputRefText = loopDataInputRef.getText();
if (loopDataInputRefText != null) {
if (loopDataInputRefText.contains("{")) {
miActivityBehavior.setCollectionExpression(expressionManager.createExpression(loopDataInputRefText));
} else {
miActivityBehavior.setCollectionVariable(loopDataInputRefText);
}
}
}
// activiti:elementVariable
String elementVariable = miLoopCharacteristics.attributeNS(BpmnParser.ACTIVITI_BPMN_EXTENSIONS_NS, "elementVariable");
if (elementVariable != null) {
miActivityBehavior.setCollectionElementVariable(elementVariable);
}
// dataInputItem
Element inputDataItem = miLoopCharacteristics.element("inputDataItem");
if (inputDataItem != null) {
String inputDataItemName = inputDataItem.attribute("name");
miActivityBehavior.setCollectionElementVariable(inputDataItemName);
}
// Validation
if (miActivityBehavior.getLoopCardinalityExpression() == null && miActivityBehavior.getCollectionExpression() == null