Index: trunk/autoquest-plugin-uml/src/main/java/de/ugoe/cs/autoquest/plugin/uml/UMLUtils.java
===================================================================
--- trunk/autoquest-plugin-uml/src/main/java/de/ugoe/cs/autoquest/plugin/uml/UMLUtils.java	(revision 1633)
+++ trunk/autoquest-plugin-uml/src/main/java/de/ugoe/cs/autoquest/plugin/uml/UMLUtils.java	(revision 1643)
@@ -29,4 +29,5 @@
 import org.eclipse.uml2.uml.Element;
 import org.eclipse.uml2.uml.Interaction;
+import org.eclipse.uml2.uml.InteractionFragment;
 import org.eclipse.uml2.uml.Lifeline;
 import org.eclipse.uml2.uml.Message;
@@ -42,5 +43,7 @@
 import de.ugoe.cs.autoquest.eventcore.Event;
 import de.ugoe.cs.autoquest.plugin.http.eventcore.SOAPEventType;
+import de.ugoe.cs.autoquest.plugin.http.eventcore.SimpleSOAPEventType;
 import de.ugoe.cs.autoquest.plugin.uml.eventcore.UMLTransitionType;
+import de.ugoe.cs.autoquest.usageprofiles.TrieBasedModel;
 
 /**
@@ -273,53 +276,133 @@
         for (Event event : sequence) {
             if (!(event.equals(Event.STARTEVENT) || event.equals(Event.ENDEVENT))) {
-                if (event.getType() instanceof SOAPEventType) {
-                    SOAPEventType eventType = (SOAPEventType) event.getType();
-                    String serviceName = eventType.getServiceName();
-                    String methodName = eventType.getCalledMethod();
-                    Class targetClass = classMap.get(serviceName);
-                    if (targetClass == null) {
-                        throw new RuntimeException(
-                                                   "Could not find class in the UML model that belong to the service: " +
-                                                       serviceName);
-                    }
-
-                    Lifeline targetLifeline = interaction.getLifeline(serviceName);
-                    if (targetLifeline == null) {
-                        targetLifeline = interaction.createLifeline(serviceName);
-                        Association association =
-                            (Association) model.getPackagedElement("user_" + serviceName, true,
-                                                                   UMLPackage.Literals.ASSOCIATION,
-                                                                   true);
-                        targetLifeline.setRepresents(association.getMemberEnd(serviceName, classMap
-                            .get(serviceName)));
-                    }
-                    MessageOccurrenceSpecification sendFragment =
-                        (MessageOccurrenceSpecification) interaction
-                            .createFragment(i + ":" + methodName + "_sendFragment",
-                                            UMLPackage.Literals.MESSAGE_OCCURRENCE_SPECIFICATION);
-                    MessageOccurrenceSpecification recvFragment =
-                        (MessageOccurrenceSpecification) interaction
-                            .createFragment(i + ":" + methodName + "_recvFragment",
-                                            UMLPackage.Literals.MESSAGE_OCCURRENCE_SPECIFICATION);
-
-                    sendFragment.setCovered(userLifeline);
-                    recvFragment.setCovered(targetLifeline);
-
-                    Message message = interaction.createMessage(methodName);
-                    message.setSignature(getOperationFromName(targetClass.getOperations(),
-                                                              methodName));
-                    message.setSendEvent(sendFragment);
-                    message.setReceiveEvent(recvFragment);
-
-                    sendFragment.setMessage(message);
-                    recvFragment.setMessage(message);
-                }
-                else {
+                String serviceName = getServiceNameFromEvent(event);
+                String methodName = getCalledMethodFromEvent(event);
+
+                Class targetClass = classMap.get(serviceName);
+                if (targetClass == null) {
                     throw new RuntimeException(
-                                               "Wrong event type. Only SOAPEventType supported but was: " +
-                                                   event.getType().getClass().getName());
-                }
+                                               "Could not find class in the UML model that belong to the service: " +
+                                                   serviceName);
+                }
+
+                Lifeline targetLifeline = interaction.getLifeline(serviceName);
+                if (targetLifeline == null) {
+                    targetLifeline = interaction.createLifeline(serviceName);
+                    Association association =
+                        (Association) model.getPackagedElement("user_" + serviceName, true,
+                                                               UMLPackage.Literals.ASSOCIATION,
+                                                               true);
+                    targetLifeline
+                        .setRepresents(association.getMemberEnd(serviceName,
+                                                                classMap.get(serviceName)));
+                }
+                MessageOccurrenceSpecification sendFragment =
+                    (MessageOccurrenceSpecification) interaction
+                        .createFragment(i + ":" + methodName + "_sendFragment",
+                                        UMLPackage.Literals.MESSAGE_OCCURRENCE_SPECIFICATION);
+                MessageOccurrenceSpecification recvFragment =
+                    (MessageOccurrenceSpecification) interaction
+                        .createFragment(i + ":" + methodName + "_recvFragment",
+                                        UMLPackage.Literals.MESSAGE_OCCURRENCE_SPECIFICATION);
+
+                sendFragment.setCovered(userLifeline);
+                recvFragment.setCovered(targetLifeline);
+
+                Message message = interaction.createMessage(methodName);
+                message.setSignature(getOperationFromName(targetClass.getOperations(), methodName));
+                message.setSendEvent(sendFragment);
+                message.setReceiveEvent(recvFragment);
+
+                sendFragment.setMessage(message);
+                recvFragment.setMessage(message);
+
                 i++;
             }
+        }
+    }
+
+    /**
+     * <p>
+     * Calculates the usage score of an interaction as the logsum of the event probabilities
+     * multiplied with the length of the interaction.
+     * </p>
+     * 
+     * @param interaction
+     *            interaction for which the score is calculated
+     * @param usageProfile
+     *            usage profile used for the calculation
+     * @return calculated usage score
+     */
+    public static double calculateUsageScore(Interaction interaction, TrieBasedModel usageProfile) {
+        double usageScore = 0.0d;
+
+        EList<InteractionFragment> interactionFragments = interaction.getFragments();
+        List<Event> eventSequence = new LinkedList<>();
+        eventSequence.add(Event.STARTEVENT);
+        for (InteractionFragment interactionFragment : interactionFragments) {
+            if (interactionFragment.getName() != null &&
+                interactionFragment.getName().endsWith("_recvFragment"))
+            {
+                String serviceName =
+                    interactionFragment.getCovereds().get(0).getRepresents().getName();
+                String methodName = "UNKNOWN";
+                if (interactionFragment instanceof MessageOccurrenceSpecification) {
+                    methodName =
+                        ((MessageOccurrenceSpecification) interactionFragment).getMessage()
+                            .getName();
+                }
+                eventSequence.add(new Event(new SimpleSOAPEventType(methodName, serviceName)));
+            }
+        }
+        double prob = usageProfile.getLogSum(eventSequence);
+        usageScore = prob * eventSequence.size();
+
+        return usageScore;
+    }
+
+    /**
+     * <p>
+     * Helper function to get the name of a service from a SOAP event.
+     * </p>
+     * 
+     * @param event
+     *            event for which the service name is retrieved
+     * @return service name
+     */
+    private static String getServiceNameFromEvent(Event event) {
+        if (event.getType() instanceof SOAPEventType) {
+            return ((SOAPEventType) event.getType()).getServiceName();
+        }
+        else if (event.getType() instanceof SimpleSOAPEventType) {
+            return ((SimpleSOAPEventType) event.getType()).getServiceName();
+        }
+        else {
+            throw new RuntimeException(
+                                       "Wrong event type. Only SOAPEventType and SimpleSOAPEventType supported but was: " +
+                                           event.getType().getClass().getName());
+        }
+    }
+
+    /**
+     * 
+     * <p>
+     * Helper function to get the called method from a SOAP event
+     * </p>
+     * 
+     * @param event
+     *            event for which the called method is retrieved
+     * @return called method
+     */
+    private static String getCalledMethodFromEvent(Event event) {
+        if (event.getType() instanceof SOAPEventType) {
+            return ((SOAPEventType) event.getType()).getCalledMethod();
+        }
+        else if (event.getType() instanceof SimpleSOAPEventType) {
+            return ((SimpleSOAPEventType) event.getType()).getCalledMethod();
+        }
+        else {
+            throw new RuntimeException(
+                                       "Wrong event type. Only SOAPEventType and SimpleSOAPEventType supported but was: " +
+                                           event.getType().getClass().getName());
         }
     }
