Index: trunk/autoquest-plugin-uml/src/main/java/de/ugoe/cs/autoquest/plugin/uml/UMLInteractionCreator.java
===================================================================
--- trunk/autoquest-plugin-uml/src/main/java/de/ugoe/cs/autoquest/plugin/uml/UMLInteractionCreator.java	(revision 2011)
+++ trunk/autoquest-plugin-uml/src/main/java/de/ugoe/cs/autoquest/plugin/uml/UMLInteractionCreator.java	(revision 2038)
@@ -52,4 +52,5 @@
 import org.eclipse.uml2.uml.Slot;
 import org.eclipse.uml2.uml.Type;
+import org.eclipse.uml2.uml.UMLFactory;
 import org.eclipse.uml2.uml.UMLPackage;
 
@@ -85,5 +86,6 @@
 
     /**
-     * a cache of the already created instance specification; used to create the overall number of generated specifications
+     * a cache of the already created instance specification; used to create the overall number of
+     * generated specifications
      */
     private final Map<String, InstanceSpecification> instanceSpecificationCache;
@@ -380,5 +382,7 @@
                         int multiplicityChosen = paramNodes.size();
 
-                        if (multiplicityChosen == 0 && internalParameter.getLower() > 0) {
+                        if (multiplicityChosen == 0 && internalParameter.getLower() > 0 &&
+                            requestBody != null)
+                        {
                             Console
                                 .traceln(Level.WARNING,
@@ -391,28 +395,30 @@
                             multiplicityChosen = internalParameter.getLower();
                         }
-                        for (int i = 0; i < multiplicityChosen; i++) {
-                            org.w3c.dom.Element paramNode = null;
-                            if (!paramNodes.isEmpty()) {
-                                paramNode = paramNodes.get(i);
-                            }
-
+                        if (multiplicityChosen > 0) {
                             Slot slot = instSpecParameters.createSlot();
                             slot.setDefiningFeature(internalParameter);
-
-                            InstanceValue value =
-                                (InstanceValue) slot
-                                    .createValue(internalParameter.getName() + "_" + i,
-                                                 internalParameter.getType(),
-                                                 UMLPackage.Literals.INSTANCE_VALUE);
-                            InstanceSpecification instSpec =
-                                createInstanceSpecification((DataType) internalParameter.getType(),
-                                                            instSpecPkg, prefix, instSpecNumber,
-                                                            paramNode, path);
-                            value.setInstance(instSpec);
-                            /*
-                             * InstanceValue value = (InstanceValue) argument .createOperand(null,
-                             * internalParameter.getType(), UMLPackage.Literals.INSTANCE_VALUE);
-                             * value.setInstance(instSpec);
-                             */
+                            for (int i = 0; i < multiplicityChosen; i++) {
+                                org.w3c.dom.Element paramNode = null;
+                                if (!paramNodes.isEmpty()) {
+                                    paramNode = paramNodes.get(i);
+                                }
+
+                                InstanceValue value =
+                                    (InstanceValue) slot
+                                        .createValue(internalParameter.getName() + "_" + i,
+                                                     internalParameter.getType(),
+                                                     UMLPackage.Literals.INSTANCE_VALUE);
+                                InstanceSpecification instSpec =
+                                    createInstanceSpecification((DataType) internalParameter
+                                                                    .getType(),
+                                                                instSpecPkg, prefix,
+                                                                instSpecNumber, paramNode, path);
+                                value.setInstance(instSpec);
+                                /*
+                                 * InstanceValue value = (InstanceValue) argument
+                                 * .createOperand(null, internalParameter.getType(),
+                                 * UMLPackage.Literals.INSTANCE_VALUE); value.setInstance(instSpec);
+                                 */
+                            }
                         }
                     }
@@ -477,119 +483,213 @@
                 createSlotPrimitiveType(instSpec, prop, currentNode, path);
             }
-            else if (prop.getType() instanceof Enumeration ) {
+            else if (prop.getType() instanceof Enumeration) {
                 createSlotEnumeration(instSpec, prop, currentNode, path);
             }
             else if (prop.getType() instanceof DataType) {
-                if( isXSDSequence(prop.getType()) ) { // XSD sequence, no real type
+                if (isXSDSequence(prop.getType())) { // XSD sequence, no real type
                     List<String> childNames = SOAPUtils.getChildNodeNames(currentNode);
                     List<org.w3c.dom.Element> childNodes = SOAPUtils.getChildElements(currentNode);
-                    EList<Property> sequenceProperties = ((DataType) prop.getType()).getAllAttributes();
+                    EList<Property> sequenceProperties =
+                        ((DataType) prop.getType()).getAllAttributes();
                     boolean sequenceIsMatch = true;
-                    if( sequenceProperties.size()==childNames.size()) {
-                        for(int i=0; sequenceIsMatch && i<sequenceProperties.size() ; i++) {
+                    // can currently only work with exactly one sequence and no optional elements
+                    if (sequenceProperties.size() == childNames.size()) {
+                        for (int i = 0; sequenceIsMatch && i < sequenceProperties.size(); i++) {
                             Property propSeq = sequenceProperties.get(i);
                             String currentChildName = childNames.get(i);
-                            if( isXSDChoice(propSeq.getType() ) ) {
+                            if (isXSDChoice(propSeq.getType())) {
                                 boolean choiceMatchFound = false;
-                                for( Property propChoice : ((DataType) propSeq.getType()).getAllAttributes() ) {
-                                    if( currentChildName.equals(propChoice.getName()) ) {
+                                for (Property propChoice : ((DataType) propSeq.getType())
+                                    .getAllAttributes())
+                                {
+                                    if (currentChildName.equals(propChoice.getName())) {
                                         choiceMatchFound = true;
                                     }
                                 }
                                 sequenceIsMatch &= choiceMatchFound;
-                            } else {
+                            }
+                            else {
                                 sequenceIsMatch &= currentChildName.equals(propSeq.getName());
                             }
                         }
-                        if( sequenceIsMatch ) {
-                            // this is the correct sequence, it matches; now appropriate data must be created
-                            
+                        if (sequenceIsMatch) {
+                            // this is the correct sequence, it matches; now appropriate data must
+                            // be created
+
                             // first we create the slot and instance specification for the sequence
                             Slot slot = instSpec.createSlot();
                             slot.setDefiningFeature(prop);
                             InstanceValue value =
-                                (InstanceValue) slot.createValue(prop.getName(), prop.getType(), UMLPackage.Literals.INSTANCE_VALUE);
+                                (InstanceValue) slot
+                                    .createValue(prop.getName(), prop.getType(),
+                                                 UMLPackage.Literals.INSTANCE_VALUE);
                             InstanceSpecification instSpecSequence =
-                                    (InstanceSpecification) pkg
-                                        .createPackagedElement(prefix + prop.getName() + "_instspec" + instSpecNumber.intValue() + "_" +
-                                                                   type.getName(),
-                                                               UMLPackage.Literals.INSTANCE_SPECIFICATION);
+                                (InstanceSpecification) pkg
+                                    .createPackagedElement(prefix + prop.getName() + "_instspec" +
+                                                               instSpecNumber.intValue() + "_" +
+                                                               type.getName(),
+                                                           UMLPackage.Literals.INSTANCE_SPECIFICATION);
                             instSpecSequence.getClassifiers().add((DataType) prop.getType());
                             instSpecNumber.setValue(instSpecNumber.intValue() + 1);
                             value.setInstance(instSpecSequence);
-                            
-                            // now we create the slots and instance specifications for the elements of the sequence
-                            for(int i=0; i<sequenceProperties.size() ; i++) {
+
+                            // now we create the slots and instance specifications for the elements
+                            // of the sequence
+                            for (int i = 0; i < sequenceProperties.size(); i++) {
                                 Property propSeq = sequenceProperties.get(i);
                                 String currentChildName = childNames.get(i);
                                 slot = instSpecSequence.createSlot();
                                 slot.setDefiningFeature(propSeq);
-                                value = (InstanceValue) slot.createValue(propSeq.getName(), propSeq.getType(), UMLPackage.Literals.INSTANCE_VALUE);
-                                if( isXSDChoice(propSeq.getType() ) ) {
+                                value =
+                                    (InstanceValue) slot
+                                        .createValue(propSeq.getName(), propSeq.getType(),
+                                                     UMLPackage.Literals.INSTANCE_VALUE);
+                                if (isXSDChoice(propSeq.getType())) {
                                     // create the inner choice instance spec
-                                    InstanceSpecification instSpecSequenceChoice = (InstanceSpecification) pkg
-                                            .createPackagedElement(prefix + propSeq.getName() + "_instspec" + instSpecNumber.intValue() + "_" +
-                                                    propSeq.getType().getName(),
-                                                UMLPackage.Literals.INSTANCE_SPECIFICATION);
-                                    instSpecSequenceChoice.getClassifiers().add((DataType) propSeq.getType());
-                                    instSpecNumber.setValue(instSpecNumber.intValue()+1);
+                                    InstanceSpecification instSpecSequenceChoice =
+                                        (InstanceSpecification) pkg
+                                            .createPackagedElement(prefix + propSeq.getName() +
+                                                                       "_instspec" +
+                                                                       instSpecNumber.intValue() +
+                                                                       "_" +
+                                                                       propSeq.getType().getName(),
+                                                                   UMLPackage.Literals.INSTANCE_SPECIFICATION);
+                                    instSpecSequenceChoice.getClassifiers().add((DataType) propSeq
+                                                                                    .getType());
+                                    instSpecNumber.setValue(instSpecNumber.intValue() + 1);
                                     value.setInstance(instSpecSequenceChoice);
-                                    for( Property propChoice : ((DataType) propSeq.getType()).getAllAttributes() ) {
-                                        if( currentChildName.equals(propChoice.getName()) ) {
+                                    for (Property propChoice : ((DataType) propSeq.getType())
+                                        .getAllAttributes())
+                                    {
+                                        if (currentChildName.equals(propChoice.getName())) {
                                             slot = instSpecSequenceChoice.createSlot();
                                             slot.setDefiningFeature(propChoice);
-                                            value = (InstanceValue) slot.createValue(propChoice.getName(), propChoice.getType(), UMLPackage.Literals.INSTANCE_VALUE);
-                                            value.setInstance(createInstanceSpecification((DataType) propChoice.getType(), pkg, prefix, instSpecNumber, childNodes.get(i), path+"."+propChoice.getName()));
+                                            value =
+                                                (InstanceValue) slot
+                                                    .createValue(propChoice.getName(),
+                                                                 propChoice.getType(),
+                                                                 UMLPackage.Literals.INSTANCE_VALUE);
+                                            value
+                                                .setInstance(createInstanceSpecification((DataType) propChoice
+                                                                                             .getType(),
+                                                                                         pkg,
+                                                                                         prefix,
+                                                                                         instSpecNumber,
+                                                                                         childNodes
+                                                                                             .get(i),
+                                                                                         path +
+                                                                                             "." +
+                                                                                             propChoice
+                                                                                                 .getName()));
                                             break;
                                         }
                                     }
-                                } else {
-                                    value.setInstance(createInstanceSpecification((DataType) propSeq.getType(), pkg, prefix, instSpecNumber, childNodes.get(i), path+"."+propSeq.getName()));
                                 }
-                            } 
+                                else {
+                                    value
+                                        .setInstance(createInstanceSpecification((DataType) propSeq
+                                            .getType(), pkg, prefix, instSpecNumber, childNodes
+                                            .get(i), path + "." + propSeq.getName()));
+                                }
+                            }
                         }
                     }
                 }
-                else if( isXSDChoice(prop.getType()) ) { 
-                    // TODO implement handling of choices, if required for the MIDAS pilots
-                    Console.traceln(Level.SEVERE, "cannot handle choices that are the child elements of normal data types yet!");
-                    Console.traceln(Level.SEVERE, "choice is ignored and no data is created.");
-                } else {
+                else if (isXSDChoice(prop.getType())) {
+                    for (Property propChoice : ((DataType) prop.getType()).getAllAttributes()) {
+                        List<org.w3c.dom.Element> matchingChildren =
+                            SOAPUtils.getMatchingChildNode(propChoice.getName(), currentNode);
+                        if (!matchingChildren.isEmpty()) {
+                            // create instance specification for the choice
+                            Slot slot = instSpec.createSlot();
+                            slot.setDefiningFeature(prop);
+                            InstanceValue value =
+                                (InstanceValue) slot
+                                    .createValue(prop.getName(), prop.getType(),
+                                                 UMLPackage.Literals.INSTANCE_VALUE);
+                            InstanceSpecification instSpecSequence =
+                                (InstanceSpecification) pkg
+                                    .createPackagedElement(prefix + prop.getName() + "_instspec" +
+                                                               instSpecNumber.intValue() + "_" +
+                                                               type.getName(),
+                                                           UMLPackage.Literals.INSTANCE_SPECIFICATION);
+                            instSpecSequence.getClassifiers().add((DataType) prop.getType());
+                            instSpecNumber.setValue(instSpecNumber.intValue() + 1);
+                            value.setInstance(instSpecSequence);
+
+                            // now the slot and instance specification for the matching choice
+                            slot = instSpecSequence.createSlot();
+                            slot.setDefiningFeature(propChoice);
+                            value =
+                                (InstanceValue) slot
+                                    .createValue(propChoice.getName(), propChoice.getType(),
+                                                 UMLPackage.Literals.INSTANCE_VALUE);
+                            value
+                                .setInstance(createInstanceSpecification((DataType) propChoice
+                                    .getType(), pkg, prefix, instSpecNumber, matchingChildren
+                                    .get(0), path + "." + propChoice.getName()));
+                        }
+                    }
+                }
+                else {
+                    // normal child, neither choice nor sequence
                     List<org.w3c.dom.Element> attributeNodes = null;
                     int multiplicityChosen = 0;
                     if (currentNode != null) {
-                        attributeNodes = SOAPUtils.getMatchingChildNode(prop.getName(), currentNode);
+                        attributeNodes =
+                            SOAPUtils.getMatchingChildNode(prop.getName(), currentNode);
                         multiplicityChosen = attributeNodes.size();
                     }
-    
+
                     if (multiplicityChosen == 0 && prop.getLower() > 0) {
                         if (currentNode != null) {
                             Console.traceln(Level.WARNING,
-                                            "required attribute not found in SOAP message: " + path +
-                                                "." + prop.getName());
+                                            "required attribute not found in SOAP message: " +
+                                                path + "." + prop.getName());
                             Console
                                 .traceln(Level.WARNING,
                                          "setting default values for this attribute and all its children");
-                            Console.traceln(Level.FINE, "XML structure of path:" + StringTools.ENDLINE +
-                                SOAPUtils.getSerialization(currentNode));
+                            Console.traceln(Level.FINE, "XML structure of path:" +
+                                StringTools.ENDLINE + SOAPUtils.getSerialization(currentNode));
                         }
                         multiplicityChosen = prop.getLower();
                     }
-                    for (int i = 0; i < multiplicityChosen; i++) {
+                    if (multiplicityChosen == 1) {
                         org.w3c.dom.Element attributeNode = null;
                         if (attributeNodes != null && !attributeNodes.isEmpty()) {
-                            attributeNode = attributeNodes.get(i);
+                            attributeNode = attributeNodes.get(0);
                         }
-    
+
                         Slot slot = instSpec.createSlot();
                         slot.setDefiningFeature(prop);
-    
+
                         InstanceValue value =
-                            (InstanceValue) slot.createValue(prop.getName() + "_" + i, prop.getType(),
+                            (InstanceValue) slot.createValue(prop.getName() + "_" + 1,
+                                                             prop.getType(),
                                                              UMLPackage.Literals.INSTANCE_VALUE);
-                        value.setInstance(createInstanceSpecification((DataType) prop.getType(), pkg,
-                                                                      prefix, instSpecNumber,
-                                                                      attributeNode,
-                                                                      path + "." + prop.getName()));
+                        value.setInstance(createInstanceSpecification((DataType) prop.getType(),
+                                                                      pkg, prefix, instSpecNumber,
+                                                                      attributeNode, path + "." +
+                                                                          prop.getName()));
+                    }
+                    else if (multiplicityChosen > 1) {
+                        Slot slot = instSpec.createSlot();
+                        slot.setDefiningFeature(prop);
+                        for (int i = 0; i < multiplicityChosen; i++) {
+                            // TODO maybe not yet correct
+                            org.w3c.dom.Element attributeNode = null;
+                            if (attributeNodes != null && !attributeNodes.isEmpty()) {
+                                attributeNode = attributeNodes.get(i);
+                            }
+
+                            InstanceValue value = UMLFactory.eINSTANCE.createInstanceValue();
+                            value
+                                .setInstance(createInstanceSpecification((DataType) prop.getType(),
+                                                                         pkg, prefix,
+                                                                         instSpecNumber,
+                                                                         attributeNode, path + "." +
+                                                                             prop.getName()));
+                            slot.getValues().add(value);
+                        }
                     }
                 }
@@ -686,4 +786,5 @@
                                                    UMLPackage.Literals.LITERAL_REAL);
                 if (attributeValue != null) {
+                    System.out.println(attributeValue);
                     value.setValue(Double.parseDouble(attributeValue));
                 }
@@ -697,9 +798,10 @@
                 Console.traceln(Level.SEVERE, "attribute is ignored!");
                 // TODO
-                //throw new RuntimeException("unknown primitive type: " + prop.getType().getName());
-            }
-        }
-    }
-    
+                // throw new RuntimeException("unknown primitive type: " +
+                // prop.getType().getName());
+            }
+        }
+    }
+
     /**
      * <p>
@@ -717,7 +819,7 @@
      */
     private void createSlotEnumeration(InstanceSpecification instSpec,
-                                         Property prop,
-                                         org.w3c.dom.Element currentNode,
-                                         String path)
+                                       Property prop,
+                                       org.w3c.dom.Element currentNode,
+                                       String path)
     {
         List<String> attributeValues = SOAPUtils.getValuesFromElement(prop.getName(), currentNode);
@@ -743,9 +845,12 @@
             Slot slot = instSpec.createSlot();
             slot.setDefiningFeature(prop);
-            
-            InstanceValue value = (InstanceValue) slot.createValue(prop.getName(), null, UMLPackage.Literals.INSTANCE_VALUE);
-            if( attributeValue!=null ) {
+
+            InstanceValue value =
+                (InstanceValue) slot.createValue(prop.getName(), null,
+                                                 UMLPackage.Literals.INSTANCE_VALUE);
+            if (attributeValue != null) {
                 value.setInstance(((Enumeration) prop.getType()).getOwnedLiteral(attributeValue));
-            } else {
+            }
+            else {
                 throw new RuntimeException("cannot create enumeration literal with dummy value");
             }
@@ -807,5 +912,7 @@
                 Element target = ((Generalization) relationship).getTargets().get(0);
                 if (target instanceof PrimitiveType) {
-                    return typeName.equals(((PrimitiveType) target).getName());
+                    if (typeName.equals(((PrimitiveType) target).getName())) {
+                        return true;
+                    }
                 }
             }
@@ -813,30 +920,32 @@
         return false;
     }
-    
+
     /**
      * <p>
      * Checks if a type is an anonymous inner type that represents an XSD sequence
      * </p>
-     *
-     * @param type type that is checked
+     * 
+     * @param type
+     *            type that is checked
      * @return true if XSD sequence; false otherwise
      */
     private boolean isXSDSequence(Type type) {
-        if( type==null || type.getName()==null ) {
+        if (type == null || type.getName() == null) {
             return false;
         }
         return type.getName().matches("sequence\\d*");
     }
-    
+
     /**
      * <p>
      * Checks if a type is an anonymous inner type that represents an XSD choice
      * </p>
-     *
-     * @param type type that is checked
+     * 
+     * @param type
+     *            type that is checked
      * @return true if XSD choice; false otherwise
      */
     private boolean isXSDChoice(Type type) {
-        if( type==null || type.getName()==null ) {
+        if (type == null || type.getName() == null) {
             return false;
         }
