private EMOF.IClass ConstructClass(EnAr.Element classElement) { // We create a EMOF.Class EMOF.IClass clazz = new EMOF.Class() { IsAbstract = classElement.Abstract.ToLower() == "true", Name = classElement.Name }; elementToType.Add(classElement, clazz); // We browse the attributes of the EMOF.Class element (~= ecore attributes) foreach (EnAr.Attribute attribute in explorer.GetAttributes(classElement)) { EMOF.IProperty property = ConstructProperty(attribute); property.Class = clazz; clazz.OwnedAttribute.Add(property); } // We browse the connectors (~= ecore references + inheritance links) foreach (EnAr.Connector connector in explorer.GetConnectorsWithSource(classElement)) { EnAr.Element targetElement = explorer.GetTargetElement(connector); if (targetElement.Type.ToLower() == "class") { EMOF.IClass targetType = ConstructType(targetElement) as EMOF.Class; if (targetType != null) { // Case super type if (connector.Type.ToLower() == "generalization") { clazz.SuperClass.Add(targetType); } // Case reference(s) else { EMOF.IProperty prop1 = ConstructProperty(clazz, targetType, connector.ClientEnd, connector.SupplierEnd); EMOF.IProperty prop2 = ConstructProperty(targetType, clazz, connector.SupplierEnd, connector.ClientEnd); if (prop1 != null && prop2 != null) { prop1.Opposite = prop2; prop2.Opposite = prop1; } } } } } // And finally the methods foreach (EnAr.Method method in explorer.GetMethods(classElement)) { EMOF.IOperation operation = ConstructOperation(method); clazz.OwnedOperation.Add(operation); operation.Class = clazz; } return(clazz); }
private void ConstructRelationDomain(QVTRelations.IRelationalTransformation relationTransformation, QVTRelations.IRelation relation, EnAr.Connector qvtTransformationLinkConnector) { // We look in the EA "domain" Element pointed by the qvtTransformationLinkConnector EnAr.Element domainObjectElement = explorer.GetTargetElement(qvtTransformationLinkConnector); // We construct (or get) the typed model, if any QVTBase.ITypedModel candidateTypedModel = ConstructTypedModel(relationTransformation, qvtTransformationLinkConnector); // If no typed model, it must be a primitive type // TODO maybe check for a tag? if (candidateTypedModel == null) { ConstructPrimitiveRelationDomain(relation, qvtTransformationLinkConnector, domainObjectElement); return; } // Else, we construct a regular domain ConstructNonPrimitiveRelationDomain(relation, candidateTypedModel, qvtTransformationLinkConnector, domainObjectElement); }