1 28 29 package org.objectweb.openccm.uml.transformation.ast; 30 31 import ispuml.mdaTransformation.RuleContext; 32 import ispuml.mdaTransformation.TransformationException; 33 import ispuml.mdaTransformation.ActionBase; 34 import ispuml.mdaTransformation.rules.xml.CompositeXmlAction; 35 36 import javax.jmi.reflect.RefPackage; 37 38 import org.objectweb.openccm.uml.transformation.modfact.JmiModFactModelCreateUtils; 39 40 import java.util.Collection ; 41 import java.util.Iterator ; 42 43 46 public class TransformAssociations extends CompositeXmlAction { 47 48 51 public TransformAssociations() { 52 isSrcPropertyRequired = false; 55 isDstPropertyRequired = false; 56 action = new TransformAction(); 57 } 58 59 62 class TransformAction extends ActionBase { 63 64 70 private Collection getAssociatedClass(Collection roots, Object clazz) { 71 Collection list = new java.util.ArrayList (); 72 Iterator it = roots.iterator(); 73 while (it.hasNext()) { 74 Object obj = it.next(); 75 if (obj instanceof org.omg.uml.core.Association) { 76 org.omg.uml.core.Association asso = (org.omg.uml.core.Association) obj; 77 java.util.List connections = asso.getConnection(); 78 if (connections.size() == 2) { 79 if (((org.omg.uml.core.AssociationEnd) connections.get(0)).getParticipant().equals(clazz)) { 80 list.add(connections.get(1)); 81 } 82 if (((org.omg.uml.core.AssociationEnd) connections.get(1)).getParticipant().equals(clazz)) { 83 list.add(connections.get(0)); 84 } 85 } 86 } 87 } 88 return list; 89 } 90 91 97 public Object execute(Object bean, RuleContext request) throws TransformationException { 98 Collection roots = JmiModFactModelCreateUtils.getRoots((RefPackage) bean); 99 Iterator iter = getAssociatedClass(roots, bean).iterator(); 100 while (iter.hasNext()) { 101 Object cur = iter.next(); 102 request.engineContext.engine.transform(cur, request); 103 } 104 return null; 105 } 106 } 108 } 109 | Popular Tags |