public void revisitMultiInstanceTasks(Definitions def) {
try {
List<RootElement> rootElements = def.getRootElements();
for(RootElement root : rootElements) {
if(root instanceof Process) {
Process process = (Process) root;
List<FlowElement> flowElements = process.getFlowElements();
for(FlowElement fe : flowElements) {
if(fe instanceof Task) {
Task task = (Task) fe;
Iterator<FeatureMap.Entry> iter = task.getAnyAttribute().iterator();
while(iter.hasNext()) {
FeatureMap.Entry entry = iter.next();
if(entry.getEStructuralFeature().getName().equals("mitask")) {
String multiValue = (String) entry.getValue();
String[] multiValueParts = multiValue.split("@");
if(multiValueParts != null && multiValueParts.length == 4) {
String miCollectionInput = (multiValueParts[0].equals(" ") ? "" : multiValueParts[0]);
String miCollectionOutput = (multiValueParts[1].equals(" ") ? "" : multiValueParts[1]);
String miDataInput = (multiValueParts[2].equals(" ") ? "" : multiValueParts[2]);
String miDataOutput = (multiValueParts[3].equals(" ") ? "" : multiValueParts[3]);
MultiInstanceLoopCharacteristics loopCharacteristics = Bpmn2Factory.eINSTANCE.createMultiInstanceLoopCharacteristics();
if(miCollectionInput != null && miCollectionInput.length() > 0) {
List<Property> properties = process.getProperties();
for(Property prop : properties) {
if(prop.getId() != null && prop.getId().equals(miCollectionInput)) {
DataInput miCollectionInputDI = Bpmn2Factory.eINSTANCE.createDataInput();
miCollectionInputDI.setName("miinputCollection");
ItemDefinition miCollectionInputDIItemDefinition = Bpmn2Factory.eINSTANCE.createItemDefinition();
miCollectionInputDIItemDefinition.setStructureRef("java.util.Collection");
def.getRootElements().add(miCollectionInputDIItemDefinition);
miCollectionInputDI.setItemSubjectRef(miCollectionInputDIItemDefinition);
task.getIoSpecification().getDataInputs().add(miCollectionInputDI);
if(task.getIoSpecification().getInputSets() == null || task.getIoSpecification().getInputSets().size() < 1) {
InputSet inset = Bpmn2Factory.eINSTANCE.createInputSet();
task.getIoSpecification().getInputSets().add(inset);
}
task.getIoSpecification().getInputSets().get(0).getDataInputRefs().add(miCollectionInputDI);
loopCharacteristics.setLoopDataInputRef(miCollectionInputDI);
DataInputAssociation miCollectionInputDataInputAssociation = Bpmn2Factory.eINSTANCE.createDataInputAssociation();
miCollectionInputDataInputAssociation.getSourceRef().add(prop);
miCollectionInputDataInputAssociation.setTargetRef(miCollectionInputDI);
task.getDataInputAssociations().add(miCollectionInputDataInputAssociation);
break;
}
}
}
if(miCollectionOutput != null && miCollectionOutput.length() > 0) {
List<Property> properties = process.getProperties();
for(Property prop : properties) {
if(prop.getId() != null && prop.getId().equals(miCollectionOutput)) {