private static ISet <EMOF.IClass> FindAllClassesUsedInTransformation(QVTRelations.RelationalTransformation transformation) { ISet <EMOF.IClass> result = new HashSet <EMOF.IClass>(); foreach (QVTRelations.IRelation relation in transformation.Rule.OfType <QVTRelations.IRelation>()) { result.AddRange(FindAllClassesUsedInRelation(relation)); } return(result); }
private void FinishRelation(QVTRelations.RelationalTransformation transformation, EnAr.Element relationElement) { // We use the existing Relation object QVTRelations.IRelation relation = FindRelation(transformation, relationElement.Name); // We look for the tag "where" string whereCode = explorer.GetTaggedValue(relationElement, "Where"); if (!string.IsNullOrWhiteSpace(whereCode)) { relation.Where = ConstructWhenOrWherePattern(relation, whereCode); } // We look for the tag "when" string whenCode = explorer.GetTaggedValue(relationElement, "When"); if (!string.IsNullOrWhiteSpace(whenCode)) { relation.When = ConstructWhenOrWherePattern(relation, whenCode); } // We look for the tag 'qvtKey' string qvtKeyString = explorer.GetTaggedValue(relationElement, "qvtKey"); if (!string.IsNullOrWhiteSpace(qvtKeyString)) { relationsWithKeys.Add(relation); ISet <EMOF.IClass> classes = FindAllClassesUsedInRelation(relation); IList <QvtKeyParserResult> parsed = QvtKeyParser.Parse(qvtKeyString); foreach (QvtKeyParserResult keyParserResult in parsed) { QVTRelations.IKey key = ConstructKey(classes, keyParserResult); QVTRelations.IKey existingKey = relation.Keys().FirstOrDefault(k => k.Identifies == key.Identifies); if (existingKey == null) { relation.Keys().Add(key); } else { MergeKeyInto(existingKey, key); } } } }
private QVTBase.Function ConstructFunction(QVTRelations.RelationalTransformation transformation, EnAr.Method method) { QVTBase.Function result = new QVTBase.Function() { Type = emofImporter.ConstructTypeOfMethod(method), Name = method.Name, Class = transformation, IsOrdered = false, IsUnique = false, Lower = 1, Upper = 1, OwnedComment = { }, QueryExpression = null, RaisedException = { }, ReferencedElements = { }, // TODO ??? }; foreach (EnAr.Parameter parameter in method.Parameters) { ConstructParameter(result, parameter); } return(result); }
/// <summary> /// Creates a new instance /// </summary> public RelationalTransformationReferencedElementsCollection(RelationalTransformation parent) { this._parent = parent; }
/// <summary> /// Creates a new instance /// </summary> public RelationalTransformationChildrenCollection(RelationalTransformation parent) { this._parent = parent; }
private QVTRelations.IRelationalTransformation ConstructRelationalTransformation(EnAr.Element transformationElement) { // We create a Transformation object QVTRelations.RelationalTransformation transformation = new QVTRelations.RelationalTransformation { Name = transformationElement.Name, }; // We first find the "Functions" class that contains the functions of the transformation EnAr.Element functionsClass = explorer.GetChildrenElementsWithType(transformationElement, "class").FirstOrDefault(e => e.Stereotype.IsNullOrEmpty()); if (functionsClass != null) { // For each method, we create a Function in the QVT transforamtion foreach (EnAr.Method method in functionsClass.Methods.OfType <EnAr.Method>()) { ConstructFunction(transformation, method); } } // We browse the children EA elements with the stereotype "qvtRelation" IList <EnAr.Element> relationsElements = explorer.GetChildrenElementsWithTypeAndStereotype(transformationElement, "class", "qvtRelation"); // First pass: we create the basic relations (to manage relation calls later) foreach (EnAr.Element relationElement in relationsElements) { ConstructBasicRelation(transformation, relationElement); } // Second pass, we finish the relations (with relation calls) foreach (EnAr.Element relationElement in relationsElements) { FinishRelation(transformation, relationElement); } // We look for the tag 'qvtKey' string qvtKeyString = explorer.GetTaggedValue(transformationElement, "qvtKey"); if (!string.IsNullOrWhiteSpace(qvtKeyString)) { ISet <EMOF.IClass> classes = FindAllClassesUsedInTransformation(transformation); IList <QvtKeyParserResult> parsed = QvtKeyParser.Parse(qvtKeyString); foreach (QvtKeyParserResult keyParserResult in parsed) { QVTRelations.IKey key = ConstructKey(classes, keyParserResult); QVTRelations.IKey existingKey = transformation.OwnedKey.FirstOrDefault(k => k.Identifies == key.Identifies); if (existingKey == null) { transformation.OwnedKey.Add(key); } else { MergeKeyInto(existingKey, key); } } } // We check if some relation-level keys should not be removed because subsumed by global keys foreach (QVTRelations.IRelation relationWithKeys in relationsWithKeys) { foreach (QVTRelations.IKey key in relationWithKeys.Keys().ToList()) { QVTRelations.IKey superKey = transformation.OwnedKey.FirstOrDefault(k => Subsumes(k, key)); if (superKey != null) { relationWithKeys.Keys().Remove(key); } } } //TODO QVT Query Functions owned by the transformation? return(transformation); }