Ignore:
Timestamp:
07/10/15 10:23:29 (9 years ago)
Author:
sherbold
Message:
  • updated connector inference; now we do not make the assumption anymore that there is only one connector between lifelines
File:
1 edited

Legend:

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

    r2000 r2001  
    6060import org.eclipse.uml2.uml.MessageSort; 
    6161import org.eclipse.uml2.uml.Model; 
     62import org.eclipse.uml2.uml.NamedElement; 
    6263import org.eclipse.uml2.uml.Operation; 
    6364import org.eclipse.uml2.uml.Package; 
     
    7778 
    7879import de.ugoe.cs.autoquest.eventcore.Event; 
    79 import de.ugoe.cs.autoquest.eventcore.EventUtils; 
    8080import de.ugoe.cs.autoquest.plugin.http.SOAPUtils; 
    8181import de.ugoe.cs.autoquest.plugin.http.eventcore.SOAPEventType; 
     
    536536                    getOperationFromName(targetInterface.getOperations(), methodName); 
    537537                // get connector 
    538                 Connector connector = inferConnector(msgSourceLifeline, msgTargetLifeline); 
     538                System.out.println(event.getType()); 
     539                Connector connector = inferConnector(msgSourceLifeline, msgTargetLifeline, targetInterface); 
     540                if( connector==null ) { 
     541                    throw new RuntimeException("Error creating message: could not find connector between the two life lines that supports the target interface at the target lifeline"); 
     542                } 
    539543 
    540544                boolean asynch = false; 
     
    979983     * Infers connector between two lifelines. 
    980984     * </p> 
    981      * <p> 
    982      * TODO: Currently assumes only one connector between two lifelines possible. This assumption is 
    983      * invalid as soon as there are two ports that connect the same two properties. 
    984      * </p> 
    985985     *  
    986986     * @param msgSourceLifeline 
     
    989989     *            target lifeline of the message 
    990990     */ 
    991     private static Connector inferConnector(Lifeline msgSourceLifeline, Lifeline msgTargetLifeline) 
     991    private static Connector inferConnector(Lifeline msgSourceLifeline, Lifeline msgTargetLifeline, Interface targetInterface) 
    992992    { 
    993993        EList<Property> userAttributes = 
    994             ((Component) msgSourceLifeline.getRepresents().getType()).getAttributes(); 
     994            ((Component) msgSourceLifeline.getRepresents().getType()).getAllAttributes(); 
    995995        EList<Property> targetAttributes = 
    996             ((Component) msgTargetLifeline.getRepresents().getType()).getAttributes(); 
     996            ((Component) msgTargetLifeline.getRepresents().getType()).getAllAttributes(); 
    997997        for (Property userAttribute : userAttributes) { 
    998998            if (userAttribute instanceof Port) { 
     
    10021002                    for (Property targetAttribute : targetAttributes) { 
    10031003                        if (targetAttribute instanceof Port) { 
    1004                             EList<ConnectorEnd> targetEnds = ((Port) targetAttribute).getEnds(); 
    1005                             for (ConnectorEnd targetEnd : targetEnds) { 
    1006                                 Connector targetConnector = (Connector) targetEnd.eContainer(); 
    1007                                 if (targetConnector == userConnector) { 
    1008                                     return targetConnector; 
     1004                            if( ((Port) targetAttribute).getProvideds().contains(targetInterface) ) { 
     1005                                EList<ConnectorEnd> targetEnds = ((Port) targetAttribute).getEnds(); 
     1006                                for (ConnectorEnd targetEnd : targetEnds) { 
     1007                                    Connector targetConnector = (Connector) targetEnd.eContainer(); 
     1008                                    if (targetConnector == userConnector) { 
     1009                                        return targetConnector; 
     1010                                    } 
    10091011                                } 
    10101012                            } 
Note: See TracChangeset for help on using the changeset viewer.