Ignore:
Timestamp:
03/11/15 16:59:16 (10 years ago)
Author:
sherbold
Message:
  • extended SimpleSOAPEventType with clientName
  • modified UMLUtils.createInteraction... to use the client name to determine the source lifeline
  • updated UMLUtilsTest to work with new service name definitions
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/autoquest-plugin-uml/src/main/java/de/ugoe/cs/autoquest/plugin/uml/UMLUtils.java

    r1908 r1913  
    486486                String serviceName = getServiceNameFromEvent(event); 
    487487                String methodName = getCalledMethodFromEvent(event); 
     488                String clientName = getClientNameFromEvent(event); 
    488489                // determine lifelines 
    489490                Lifeline msgTargetLifeline; 
    490491                Lifeline msgSourceLifeline; 
    491  
    492                 if (serviceName.equals(userLifeline.getName())) { 
    493                     // message being send to user 
    494                     // currently we just select the first lifeline that is not the user 
    495                     // this, obviously, has to be replaced with the real service. 
    496                     // however, identification of the source of a message is still an open issue 
    497                     msgSourceLifeline = null; 
    498                     for (Lifeline lifeline : interaction.getLifelines()) { 
    499                         if (!lifeline.equals(userLifeline)) { 
    500                             msgSourceLifeline = lifeline; 
    501                             break; 
    502                         } 
    503                     } 
    504                     msgTargetLifeline = userLifeline; 
    505                 } 
    506                 else { 
    507                     msgSourceLifeline = userLifeline; 
    508                     msgTargetLifeline = interaction.getLifeline(serviceName); 
    509                 } 
     492                 
     493                msgSourceLifeline = interaction.getLifeline(clientName); 
     494                msgTargetLifeline = interaction.getLifeline(serviceName); 
     495                 
    510496                if (msgSourceLifeline == null) { 
    511497                    throw new RuntimeException( 
    512                                                "Error creating message: could not determine source lifeline."); 
     498                                               "Error creating message: could not determine source lifeline for component: " + clientName); 
    513499                } 
    514500                if (msgTargetLifeline == null) { 
    515501                    throw new RuntimeException( 
    516                                                "Error creating message: could not determine target lifeline."); 
     502                                               "Error creating message: could not determine target lifeline for component: " + serviceName); 
    517503                } 
    518504                // determine correct target interface 
     
    666652                            .getName(); 
    667653                } 
    668                 eventSequence.add(new Event(new SimpleSOAPEventType(methodName, serviceName))); 
     654                eventSequence.add(new Event(new SimpleSOAPEventType(methodName, serviceName,""))); // TODO add client name 
    669655            } 
    670656        } 
     
    809795        else if (event.getType() instanceof SimpleSOAPEventType) { 
    810796            return ((SimpleSOAPEventType) event.getType()).getCalledMethod(); 
     797        } 
     798        else { 
     799            throw new RuntimeException( 
     800                                       "Wrong event type. Only SOAPEventType and SimpleSOAPEventType supported but was: " + 
     801                                           event.getType().getClass().getName()); 
     802        } 
     803    } 
     804     
     805    /** 
     806     * <p> 
     807     * Helper function to get the name of a client from a SOAP event. 
     808     * </p> 
     809     *  
     810     * @param event 
     811     *            event for which the client name is retrieved 
     812     * @return service name 
     813     */ 
     814    protected static String getClientNameFromEvent(Event event) { 
     815        if (event.getType() instanceof SOAPEventType) { 
     816            return ((SOAPEventType) event.getType()).getClientName(); 
     817        } 
     818        else if (event.getType() instanceof SimpleSOAPEventType) { 
     819            return ((SimpleSOAPEventType) event.getType()).getClientName(); 
    811820        } 
    812821        else { 
     
    10131022        InstanceSpecification instSpec = (InstanceSpecification) serviceInstSpecPkg.createPackagedElement("instspec_"+type.getName(), UMLPackage.Literals.INSTANCE_SPECIFICATION); 
    10141023        instSpec.getClassifiers().add(type); 
    1015         System.out.println(type.getName()); 
    10161024        for( Property prop : type.getAllAttributes() ) { 
    10171025            // TODO handle multiplicity 
Note: See TracChangeset for help on using the changeset viewer.