Exemplo n.º 1
0
        public EnArImporterQVT(EnArExplorer explorer)
        {
            this.explorer     = explorer;
            this.emofImporter = new EnArImporterEMOF(explorer);
            Tuple <List <EMOF.IPackage>, Dictionary <string, EMOF.IPackage> > res = this.emofImporter.ConstructMetamodels();

            metamodels.AddRange(res.Item1);
            foreach (KeyValuePair <string, EMOF.IPackage> keyValuePair in res.Item2)
            {
                aliases[keyValuePair.Key] = keyValuePair.Value;
            }
        }
        /// <summary>
        /// Generates the code for a transformation element of a given EnAr instance.
        /// This method can be called from EnAr UI directly.
        /// </summary>
        /// <param name="eaRepository">The EnAr instance.</param>
        /// <param name="transformationGuid">The identifier of the transformation for code generation.</param>
        /// <param name="absoluteOutputFolder">The output folder to put the code into.</param>
        /// <param name="useMetamodelInterface">If true, the generated code will rely on an IMetamodelInterface object. Otherwise, it will rely on standard C# getters/setters.</param>
        public static void GenerateTransformationCode(Repository eaRepository, string transformationGuid, string absoluteOutputFolder, bool useMetamodelInterface = true)
        {
            // Create hybrid repository of an EA instance
            RepositoryImpl hybridrepo = new RepositoryImpl(eaRepository);

            // Import the transformation as real qvt model
            EnArExplorer              explorer = new EnArExplorer(hybridrepo, eaRepository);
            EnArImporterQVT           importer = new EnArImporterQVT(explorer);
            IRelationalTransformation relationalTransformation = importer.ConstructRelationalTransformationFromGuid(transformationGuid);

            // Generate code from qvt model
            QVTCodeGeneratorHelper.GenerateAllCode(relationalTransformation, absoluteOutputFolder, useMetamodelInterface);
        }
Exemplo n.º 3
0
        private QVTTemplate.IObjectTemplateExp ConstructObjectTemplateExp(QVTRelations.IRelation relation, QVTRelations.IDomainPattern domainPattern, EnAr.Element objectElement, ISet <EnAr.Connector> visitedConnectors = null)
        {
            EssentialOCL.IVariable variable = null;
            EMOF.IType             type     = emofImporter.ConstructTypeOfTyped(objectElement);

            // TODO manage the not ?
            if (objectElement.Name != "{not}")
            {
                variable = ConstructVariable(relation, objectElement);
                domainPattern?.BindsTo.Add(variable);
            }

            QVTTemplate.IObjectTemplateExp objectTemplateExp = new QVTTemplate.ObjectTemplateExp()
            {
                BindsTo       = variable,
                ReferredClass = type as EMOF.IClass,
                Where         = null // TODO
            };
            objectTemplateExp.SetAntiTemplate(variable == null);
            objectElementToObjectTemplate.Add(objectElement, objectTemplateExp);

            foreach (RunStateField runStateField in EnArExplorer.GetRunState(objectElement))
            {
                ConstructPropertyTemplateItem(relation, domainPattern, objectTemplateExp, runStateField);
            }

            foreach (EnAr.Connector connector in explorer.GetConnectorsLinkedTo(objectElement).FindAll(c => c.Stereotype != "qvtTransformationLink"))
            {
                Tuple <EnAr.ConnectorEnd, EnAr.Element> linked = explorer.GetElementOppositeTo(objectElement, connector);
                EnAr.ConnectorEnd connectorEnd  = linked.Item1;
                EnAr.Element      linkedElement = linked.Item2;
                //if (!string.IsNullOrWhiteSpace(connectorEnd.Role))
                //{
                ConstructPropertyTemplateItem(relation, domainPattern, objectTemplateExp, connector, connectorEnd, linkedElement, visitedConnectors);
                //}
            }

            return(objectTemplateExp);
        }
Exemplo n.º 4
0
 public EnArImporterEMOF(EnArExplorer explorer)
 {
     this.explorer = explorer;
 }
Exemplo n.º 5
0
 public Ecore2EnAr(EnAr.Package rootContainerPackage, EnArExplorer explorer)
 {
     this.rootContainerPackage = rootContainerPackage;
     this.explorer             = explorer;
 }