Changeset 1752 for trunk/autoquest-plugin-uml/src
- Timestamp:
- 09/18/14 09:58:15 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/autoquest-plugin-uml/src/main/java/de/ugoe/cs/autoquest/plugin/uml/UMLUtils.java
r1643 r1752 24 24 25 25 import org.eclipse.emf.common.util.EList; 26 import org.eclipse.uml2.uml.Association;27 import org.eclipse.uml2.uml.Class;28 26 import org.eclipse.uml2.uml.Comment; 27 import org.eclipse.uml2.uml.Component; 28 import org.eclipse.uml2.uml.Connector; 29 import org.eclipse.uml2.uml.ConnectorEnd; 29 30 import org.eclipse.uml2.uml.Element; 30 31 import org.eclipse.uml2.uml.Interaction; 31 32 import org.eclipse.uml2.uml.InteractionFragment; 33 import org.eclipse.uml2.uml.Interface; 32 34 import org.eclipse.uml2.uml.Lifeline; 33 35 import org.eclipse.uml2.uml.Message; 34 36 import org.eclipse.uml2.uml.MessageOccurrenceSpecification; 37 import org.eclipse.uml2.uml.MessageSort; 35 38 import org.eclipse.uml2.uml.Model; 36 39 import org.eclipse.uml2.uml.Operation; 40 import org.eclipse.uml2.uml.Port; 37 41 import org.eclipse.uml2.uml.Region; 38 42 import org.eclipse.uml2.uml.StateMachine; … … 258 262 String interactionName) 259 263 { 260 Map<String, Class> classMap = new HashMap<>(); 264 Map<String, Interface> interfaceMap = new HashMap<>(); 265 Map<String, Port> portMap = new HashMap<>(); 261 266 262 267 EList<Element> elements = model.getOwnedElements(); 263 268 for (Element element : elements) { 264 if (element instanceof Class) {265 classMap.put(((Class) element).getName(), (Class) element);269 if (element instanceof Interface) { 270 interfaceMap.put(((Interface) element).getName(), (Interface) element); 266 271 } 267 272 } … … 272 277 273 278 Lifeline userLifeline = interaction.createLifeline("user"); 274 279 280 Component testContext = (Component) model.getPackagedElement("TestContext", true, UMLPackage.Literals.COMPONENT, true); 281 userLifeline.setRepresents(testContext.getAttribute("user", null)); 282 283 Component userComponent = (Component) model.getPackagedElement("User", true, UMLPackage.Literals.COMPONENT, true); 284 Port userPort = (Port) userComponent.getAttribute("p_user_rlus", null); 285 275 286 int i = 0; 276 287 for (Event event : sequence) { … … 279 290 String methodName = getCalledMethodFromEvent(event); 280 291 281 Class targetClass = classMap.get(serviceName);282 if (target Class== null) {292 Interface targetInterface = interfaceMap.get(serviceName); 293 if (targetInterface == null) { 283 294 throw new RuntimeException( 284 "Could not find classin the UML model that belong to the service: " +295 "Could not find interface in the UML model that belong to the service: " + 285 296 serviceName); 286 297 } … … 289 300 if (targetLifeline == null) { 290 301 targetLifeline = interaction.createLifeline(serviceName); 291 Association association = 292 (Association) model.getPackagedElement("user_" + serviceName, true, 293 UMLPackage.Literals.ASSOCIATION, 294 true); 295 targetLifeline 296 .setRepresents(association.getMemberEnd(serviceName, 297 classMap.get(serviceName))); 302 303 304 targetLifeline.setRepresents(testContext.getAttribute(serviceName+"_property", null)); 305 306 Component component = (Component) model.getPackagedElement(serviceName, true, UMLPackage.Literals.COMPONENT, true); 307 portMap.put(serviceName, (Port) component.getAttribute("p_" + serviceName, null)); 298 308 } 299 309 MessageOccurrenceSpecification sendFragment = … … 310 320 311 321 Message message = interaction.createMessage(methodName); 312 message.setSignature(getOperationFromName(targetClass.getOperations(), methodName)); 322 if( getOperationFromName(targetInterface.getOperations(), methodName)==null ) { 323 System.out.println("operation not found: " + methodName); 324 } 325 message.setSignature(getOperationFromName(targetInterface.getOperations(), methodName)); 326 message.setMessageSort(MessageSort.ASYNCH_CALL_LITERAL); 313 327 message.setSendEvent(sendFragment); 314 328 message.setReceiveEvent(recvFragment); 315 329 330 EList<ConnectorEnd> sourceEnds = userPort.getEnds(); 331 EList<ConnectorEnd> targetEnds = portMap.get(serviceName).getEnds(); 332 333 for( ConnectorEnd sourceEnd : sourceEnds ) { 334 Connector sourceConnector = (Connector) sourceEnd.eContainer(); 335 for( ConnectorEnd targetEnd : targetEnds ) { 336 Connector targetConnector = (Connector) targetEnd.eContainer(); 337 if( targetConnector==sourceConnector ) { 338 message.setConnector(targetConnector); 339 } 340 } 341 } 342 316 343 sendFragment.setMessage(message); 317 344 recvFragment.setMessage(message);
Note: See TracChangeset
for help on using the changeset viewer.