Beispiel #1
0
        private String computeRootNodeName(EPackage package)
        {
            SQLPackage curPackage = package.EaPackage;

            while (curPackage.ParentID != 0)
            {
                curPackage = package.Repository.GetPackageByID(curPackage.ParentID);
            }
            return(curPackage.Name);
        }
Beispiel #2
0
        public TGG(SQLRepository repository, SQLPackage tggSchemaPackage) : base(tggSchemaPackage, repository)
        {
            this.Name  = tggSchemaPackage.Name;
            TGGRules   = new List <TGGRule>();
            Metamodels = new List <Metamodel>();
            Domains    = new List <Domain>();

            Constraints = new List <CSPConstraint>();
            CSPUtil.addDefaultConstraints(Constraints);
        }
 public void DeleteWithGuid(SQLPackage rootPackage, String guid)
 {
     foreach (SQLPackage sqlPackage in rootPackage.Packages)
     {
         if (rootPackage.PackageGUID == guid)
         {
             rootPackage.Packages.Delete(sqlPackage);
         }
     }
 }
Beispiel #4
0
        public static DomainType getDomainOfEClass(SQLRepository repository, SQLElement eClass)
        {
            //Get the TGG Schema diagram
            EA.Diagram tggSchema = repository.GetCurrentDiagram();

            //Get the TGG Project
            SQLPackage tggProject    = repository.GetPackageByID(tggSchema.PackageID);
            SQLPackage parentPackage = repository.GetPackageByID(tggProject.ParentID);

            while (parentPackage.ParentID != 0)
            {
                tggProject    = parentPackage;
                parentPackage = repository.GetPackageByID(tggProject.ParentID);
            }

            TGG tgg = new TGG(repository, tggProject);

            tgg.loadTreeFromTaggedValue();

            String sourceDomainID = tgg.getDomain(DomainType.SOURCE).MetamodelGuid;
            String targetDomainID = tgg.getDomain(DomainType.TARGET).MetamodelGuid;

            SQLPackage currentPackage         = repository.GetPackageByID(eClass.PackageID);
            SQLPackage parentOfCurrentPackage = repository.GetPackageByID(currentPackage.ParentID);

            while (parentOfCurrentPackage.ParentID != 0)
            {
                currentPackage         = parentOfCurrentPackage;
                parentOfCurrentPackage = repository.GetPackageByID(parentOfCurrentPackage.ParentID);
            }

            SQLPackage modelOfTheEClass = currentPackage;

            Boolean isSource = sourceDomainID == modelOfTheEClass.PackageGUID;
            Boolean isTarget = targetDomainID == modelOfTheEClass.PackageGUID;

            if (isTarget && isSource)
            {
                return(DomainType.UNDEFINED);
            }

            else if (isTarget)
            {
                return(DomainType.TARGET);
            }

            else if (isSource)
            {
                return(DomainType.SOURCE);
            }
            else
            {
                return(DomainType.UNDEFINED);
            }
        }
Beispiel #5
0
        private String getTopLevelPackageName(SQLPackage sqlPackage, SQLRepository repository)
        {
            int        parentID = sqlPackage.ParentID;
            SQLPackage parent   = repository.GetPackageByID(parentID);

            if (parent.IsModel)
            {
                return(getTopLevelPackageName(parent, repository));
            }
            return(sqlPackage.Name);
        }
        public override List <String> doRule(SQLPackage eaPackage, SQLWrapperClasses.SQLRepository repository)
        {
            List <String> results = new List <string>();

            handleObsoleteTaggedValue(eaPackage, results, "Moflon::ValidationFilter");
            handleObsoleteTaggedValue(eaPackage, results, "Moflon::CustomNsUri");
            handleObsoleteTaggedValue(eaPackage, results, "validated");
            handleObsoleteTaggedValue(eaPackage, results, "Moflon::CustomNsPrefix");

            return(results);
        }
Beispiel #7
0
        public MocaNode processOutermostPackage(SQLPackage outermostPackage)
        {
            this.currentNode = new MocaNode();
            MocaNode outerMostPackageMocaNode = processEPackage(outermostPackage);

            if (outerMostPackageMocaNode != null)
            {
                outerMostPackageMocaNode.appendChildAttribute("Changes::IsTLP", "true");
            }

            return(outerMostPackageMocaNode);
        }
        private void importEDatatype(SQLPackage parentPackage, MocaNode eDatatypeNode)
        {
            EA.Element edatatypeElement = getOrCreateElement(parentPackage, eDatatypeNode, "Class");

            EDatatype edatatype = new EDatatype(sqlRep.GetElementByID(edatatypeElement.ElementID), sqlRep);

            edatatype.deserializeFromMocaTree(eDatatypeNode);

            MainImport.getInstance().ElementGuidToElement.Add(edatatypeElement.ElementGUID, edatatypeElement);
            MainImport.getInstance().MocaTaggableElements.Add(edatatype);
            MainImport.getInstance().OldGuidToNewGuid.Add(edatatype.Guid, edatatypeElement.ElementGUID);
        }
        public NewTGGProjectDialog(SQLRepository repository, SQLPackage newTggProject)
        {
            InitializeComponent();
            this.StartPosition = FormStartPosition.CenterScreen;
            this.repository    = repository;
            this.newTGGProject = newTggProject;

            this.tgg = new TGG(repository, newTggProject);
            tgg.loadTreeFromTaggedValue();

            InitializeInformation();
        }
Beispiel #10
0
 public static Boolean packageIsModel(SQLPackage pkg, SQLRepository repository)
 {
     if (pkg != null && pkg.ParentID != 0)
     {
         SQLPackage parent = repository.GetPackageByID(pkg.ParentID);
         if (parent.ParentID == 0)
         {
             return(true);
         }
     }
     return(false);
 }
Beispiel #11
0
 public void computeAndAddToDependencies(SQLRepository repository, SQLElement element)
 {
     if (element != null)
     {
         SQLPackage pkg = repository.GetPackageByID(element.PackageID);
         while (!pkg.IsModel)
         {
             pkg = repository.GetPackageByID(pkg.ParentID);
         }
         addDependency(CurrentMetamodelName, pkg.Name);
     }
 }
Beispiel #12
0
        private void importRulePackage(SQLPackage modelPackage, MocaNode packageNode)
        {
            EPackage ePackage = MainImport.getInstance().EcoreImport.importEPackage(packageNode, modelPackage);

            MainImport.getInstance().MocaTaggableElements.Remove(ePackage);
            ePackage = new TGGRulePackage(ePackage.EaPackage, sqlRep);
            MainImport.getInstance().MocaTaggableElements.Add(ePackage);

            foreach (MocaNode ruleNode in packageNode.getChildNodeWithName(TGGRulePackage.RulesChildNodeName).Children)
            {
                importRule(ePackage.EaPackage, ruleNode);
            }
        }
        public override List <String> doRule(SQLPackage eaPackage, SQLWrapperClasses.SQLRepository repository)
        {
            List <String> results = new List <string>();

            foreach (string segment in eaPackage.Name.Split('.'))
            {
                if (ConsistencyUtil.nameIsKeyword(segment))
                {
                    results.Add("The segment " + segment + " of package " + eaPackage.Name + " is a Java keyword and may not be used.");
                }
            }
            return(results);
        }
 public void doSinglePackageRule(SQLPackage package, SQLRepository repository, Rule rule)
 {
     if (rule is PackageRule && (ruleExecutionPoint == rule.getRuleExecutionPoint() || ruleExecutionPoint == RuleExecutionPoint.OnRequest))
     {
         foreach (RuleResult result in rule.getRuleResult(package, repository))
         {
             if (!result.Passed)
             {
                 handleRuleResult(result, repository);
             }
         }
     }
 }
Beispiel #15
0
 public TGGObjectVariable(SQLElement sdmObject, SQLRepository repository) :
     base(sdmObject, repository)
 {
     if (sdmObject.PackageID != 0)
     {
         SQLPackage mmPkg = repository.GetPackageByID(sdmObject.PackageID);
         while (!mmPkg.IsModel)
         {
             mmPkg = repository.GetPackageByID(mmPkg.ParentID);
         }
         this.metamodelGuid = mmPkg.PackageGUID;
     }
 }
 public override void doRuleQuickFix(SQLElement eaElement, SQLRepository repository, int i, String errorMessage)
 {
     if (i == 0)
     {
         EAUtil.deleteElement(eaElement.getRealElement(), repository);
     }
     else if (i == 1)
     {
         EA.Diagram possibleDiagram = null;
         SQLElement parent          = eaElement;
         SQLPackage parentPackage   = null;
         while (possibleDiagram == null)
         {
             if (parent.ParentID != 0)
             {
                 parent = repository.GetElementByID(parent.ParentID);
                 if (parent.Diagrams.Count > 0)
                 {
                     possibleDiagram = parent.Diagrams.GetAt(0) as EA.Diagram;
                 }
             }
             else
             {
                 if (parentPackage == null)
                 {
                     parentPackage = repository.GetPackageByID(parent.PackageID);
                 }
                 else
                 {
                     parentPackage = repository.GetPackageByID(parentPackage.ParentID);
                 }
                 if (parentPackage.Diagrams.Count > 0)
                 {
                     possibleDiagram = parentPackage.Diagrams.GetAt(0) as EA.Diagram;
                 }
             }
         }
         possibleDiagram = EAUtil.sqlEAObjectToOriginalObject(repository, possibleDiagram) as EA.Diagram;
         EA.DiagramObject diagObject = possibleDiagram.DiagramObjects.AddNew("", eaElement.Type) as EA.DiagramObject;
         diagObject.left      = 20;
         diagObject.right     = 120;
         diagObject.top       = -20;
         diagObject.bottom    = -70;
         diagObject.ElementID = eaElement.ElementID;
         diagObject.Update();
         repository.OpenDiagram(possibleDiagram.DiagramID);
         EAUtil.clearSelectedDiagramObjects(repository);
         possibleDiagram.SelectedObjects.AddNew(diagObject.ElementID.ToString(), "");
         repository.ReloadDiagram(possibleDiagram.DiagramID);
     }
 }
        public EA.Package getOrCreatePackage(SQLPackage rootPackage, MocaNode packageNode)
        {
            String oldGuid = packageNode.getAttributeOrCreate(Main.GuidStringName).Value;

            EA.Package modelPackage = repository.GetPackageByGuid(oldGuid);
            if (modelPackage != null)
            {
                DeleteWithGuid(rootPackage, oldGuid);
                EA.Package parent = repository.GetPackageByID(modelPackage.ParentID);
                DeleteWithGuid(parent, oldGuid);
            }

            EA.Package rootPackageOriginal = rootPackage.getRealPackage();
            String     packageName         = packageNode.getAttributeOrCreate(MetamodelHelper.MoflonCustomNameTaggedValueName).Value;

            if (packageName == "")
            {
                packageName = packageNode.getAttributeOrCreate("name").Value;
            }

            modelPackage = rootPackageOriginal.Packages.AddNew(packageName, "") as EA.Package;
            if (rootPackageOriginal.ParentID == 0)
            {
                modelPackage.Flags = "isModel=1;VICON=3;";
            }
            modelPackage.Update();

            // import nsUri
            setTagValueIfPossibleForPackage(MetamodelHelper.MoflonCustomNsUriTaggedValueName, packageNode, modelPackage);

            // import export
            setTagValueIfPossibleForPackage(MetamodelHelper.MoflonExportTaggedValueName, packageNode, modelPackage);

            // import pluginID
            setTagValueIfPossibleForPackage(MetamodelHelper.MoflonCustomPluginIDTaggedValueName, packageNode, modelPackage);

            // import prefix
            setTagValueIfPossibleForPackage(MetamodelHelper.MoflonCustomNsPrefixTaggedValueName, packageNode, modelPackage);

            // import validated
            setTagValueIfPossibleForPackage(MetamodelHelper.MoflonValidatedTaggedValueName, packageNode, modelPackage);

            // import name
            setTagValueIfPossibleForPackage(MetamodelHelper.MoflonCustomNameTaggedValueName, packageNode, modelPackage);

            repository.Execute("update t_package set ea_guid = '" + oldGuid + "' where ea_guid = '" + modelPackage.PackageGUID + "'");
            repository.Execute("update t_object set ea_guid = '" + oldGuid + "' where ea_guid = '" + modelPackage.PackageGUID + "'");
            modelPackage = repository.GetPackageByGuid(oldGuid);

            return(modelPackage);
        }
Beispiel #18
0
        private MocaNode processEPackage(SQLPackage eaPackage)
        {
            SQLTaggedValue mocaTreeTag = EAEcoreAddin.Util.EAUtil.findTaggedValue(eaPackage, Main.MoflonExportTreeTaggedValueName);

            if (mocaTreeTag != null)
            {
                EPackage ePackage         = new EPackage(eaPackage, repository);
                MocaNode ePackageMocaNode = MocaTreeUtil.mocaNodeFromXmlString(mocaTreeTag.Notes);

                SQLTaggedValue changesTreeTag = EAEcoreAddin.Util.EAUtil.findTaggedValue(eaPackage, Main.MoflonChangesTreeTaggedValueName);
                if (changesTreeTag != null)
                {
                    MocaNode ePackageChangesMocaNode = MocaTreeUtil.mocaNodeFromXmlString(changesTreeTag.Notes);
                    if (ePackageChangesMocaNode.hasAllAttributes(new List <string>(
                                                                     new string[] { ChangesTreeConstants.ATTRIBUTE_KEY_PACKAGE_NAME, ChangesTreeConstants.ATTRIBUTE_KEY_PROJECT_NAME })))
                    {
                        ePackage.addChangesAttributesDuringExport(ePackageMocaNode, changesTreeTag);

                        CachedPackage temp = new CachedPackage();
                        temp.getPackage(eaPackage.PackageGUID, repository);
                        temp.name         = eaPackage.Name;
                        temp.previousName = eaPackage.Name;
                        temp.packageName  = ePackageChangesMocaNode.getAttribute(ChangesTreeConstants.ATTRIBUTE_KEY_PACKAGE_NAME).Value;
                        temp.projectName  = ePackageChangesMocaNode.getAttribute(ChangesTreeConstants.ATTRIBUTE_KEY_PROJECT_NAME).Value;
                        temp.savePackageToEATaggedValue(true);
                    }
                }

                ePackage.addAttributesDuringExport(ePackageMocaNode);
                this.currentNode.appendChildNode(ePackageMocaNode);

                foreach (SQLElement childClass in eaPackage.Elements)
                {
                    this.currentNode = ePackageMocaNode.getChildNodeWithName(EPackageHelper.ClassesChildNodeName);
                    if (childClass.Stereotype.ToLower() == ECOREModelingMain.EClassStereotype.ToLower())
                    {
                        processEClass(childClass);
                    }
                }

                foreach (SQLPackage childPackage in eaPackage.Packages)
                {
                    this.currentNode = ePackageMocaNode.getChildNodeWithName(EPackageHelper.PackagesChildNodeName);
                    processEPackage(childPackage);
                }

                return(ePackageMocaNode);
            }
            return(null);
        }
Beispiel #19
0
        public EPackage(SQLPackage eaPackage, SQLRepository repository)
        {
            this.EaPackage  = eaPackage;
            this.Repository = repository;

            if (EAUtil.packageIsModel(EaPackage, Repository))
            {
                helper = new MetamodelHelper(this);
            }
            else
            {
                helper = new SubPackageHelper(this);
            }
        }
        public override List <String> doRule(SQLPackage eaPackage, SQLWrapperClasses.SQLRepository repository)
        {
            List <String> results = new List <string>();

            //not for root packages
            if (eaPackage.ParentID != 0)
            {
                if (eaPackage.Name.Contains(" "))
                {
                    results.Add("Blanks are not allowed in package names");
                }
            }
            return(results);
        }
Beispiel #21
0
        private MocaNode processEPackage(SQLPackage eaPackage)
        {
            backgroundWorker.ReportProgress(0, PersistencyUtil.computePackageUri(eaPackage, repository));
            SQLTaggedValue mocaTreeTag = EAEcoreAddin.Util.EAUtil.findTaggedValue(eaPackage, Main.MoflonExportTreeTaggedValueName);


            if (mocaTreeTag != null)
            {
                EPackage ePackage = new EPackage(eaPackage, repository);


                MocaNode ePackageMocaNode = MocaTreeUtil.mocaNodeFromXmlString(mocaTreeTag.Notes);

                ePackage.addAttributesDuringExport(ePackageMocaNode);

                this.currentNode.appendChildNode(ePackageMocaNode);
                int counter = 0;
                foreach (SQLElement childClass in eaPackage.Elements)
                {
                    if (!Export.showStatusBar)
                    {
                        Console.Out.WriteLine("SCALE:Export Classifier '" + childClass.Name + "' %" + counter + "/" + eaPackage.Elements.Count + "#");
                    }
                    counter++;
                    this.currentNode = ePackageMocaNode.getChildNodeWithName(EPackageHelper.ClassesChildNodeName);
                    if (childClass.Stereotype.ToLower() == ECOREModelingMain.EClassStereotype.ToLower())
                    {
                        processEClass(childClass);
                    }
                    else if (childClass.Stereotype.ToLower() == ECOREModelingMain.EDatatypeStereotype.ToLower())
                    {
                        processEDatatype(childClass);
                    }
                    else if (childClass.Stereotype.ToLower() == ECOREModelingMain.EEnumStereotype.ToLower())
                    {
                        processEEnum(childClass);
                    }
                }

                foreach (SQLPackage childPackage in eaPackage.Packages)
                {
                    this.currentNode = ePackageMocaNode.getChildNodeWithName(EPackageHelper.PackagesChildNodeName);
                    processEPackage(childPackage);
                }

                return(ePackageMocaNode);
            }
            return(null);
        }
 public override void doRuleQuickFix(SQLPackage eaPackage, SQLWrapperClasses.SQLRepository repository, int i, String errorMessage)
 {
     if (errorMessage == "TGG Package must contain a TGG diagram")
     {
         EA.Package pkg        = EAUtil.sqlEAObjectToOriginalObject(repository, eaPackage) as EA.Package;
         EA.Diagram newDiagram = pkg.Diagrams.AddNew(eaPackage.Name, TGGModelingMain.TggSchemaDiagramMetatype[0]) as EA.Diagram;
         newDiagram.Update();
     }
     else if (errorMessage == "Ecore Package must contain an Ecore diagram")
     {
         EA.Package pkg        = EAUtil.sqlEAObjectToOriginalObject(repository, eaPackage) as EA.Package;
         EA.Diagram newDiagram = pkg.Diagrams.AddNew(eaPackage.Name, ECOREModelingMain.EcoreDiagramMetatype[0]) as EA.Diagram;
         newDiagram.Update();
     }
 }
        public static String computePackageUri(SQLPackage pkg, SQLRepository rep)
        {
            String     val        = pkg.Name;
            SQLPackage currentPkg = pkg;

            while (!currentPkg.IsModel)
            {
                currentPkg = rep.GetPackageByID(currentPkg.ParentID);
                if (!currentPkg.IsModel)
                {
                    val = currentPkg.Name + "/" + val;
                }
            }
            return(val);
        }
        public void doRulesForPackages(List <SQLPackage> packagesToValidate, SQLRepository repository)
        {
            if (packagesToValidate.Count > 0)
            {
                List <SQLElement>   listOfElements   = new List <SQLElement>();
                List <SQLConnector> listOfConnectors = new List <SQLConnector>();
                List <SQLAttribute> listOfAttributes = new List <SQLAttribute>();
                List <SQLMethod>    listofMethods    = new List <SQLMethod>();
                List <SQLParameter> listofParameters = new List <SQLParameter>();
                List <SQLPackage>   listOfPackages   = new List <SQLPackage>();
                listOfPackages.AddRange(packagesToValidate);
                int z = listOfPackages.Count;

                //wait for progressbar to be initialized
                while (consistencyProgressbar == null)
                {
                }
                consistencyProgressbar.invokeProgressBarAndPrepare();
                for (int i = 0; i < z; i++)
                {
                    if (Canceled)
                    {
                        return;
                    }
                    SQLPackage actPackage       = (SQLPackage)listOfPackages[i];
                    SQLPackage currentMetamodel = EAUtil.getOutermostPackage(actPackage, repository);

                    foreach (SQLElement actElement in actPackage.Elements)
                    {
                        if (Canceled)
                        {
                            return;
                        }
                        addElementChildFeatures(listOfElements, listOfConnectors, listOfAttributes, listofMethods, listofParameters, actElement);
                    }
                    foreach (SQLPackage actpackage in actPackage.Packages)
                    {
                        if (Canceled)
                        {
                            return;
                        }
                        listOfPackages.Add(actpackage);
                        z++;
                    }
                }
                doRulesForFeatures(repository, listOfElements, listOfConnectors, listOfAttributes, listofMethods, listofParameters, listOfPackages);
            }
        }
        public override List <string> doRule(SQLElement eaElement, SQLWrapperClasses.SQLRepository repository)
        {
            if (eaElement.Stereotype == ECOREModelingMain.EClassStereotype)
            {
                List <String> results = new List <string>();

                SQLPackage pkg = repository.GetPackageByID(eaElement.PackageID);

                if (eaElement.ParentID != 0 || pkg.Element == null || (pkg.Element.Stereotype != ECOREModelingMain.EPackageStereotype && pkg.Element.Stereotype != TGGModelingMain.TggSchemaPackageStereotype))
                {
                    results.Add("EClasses can only be contained by EPackages");
                }
                return(results);
            }
            return(new List <string>());
        }
        public override List <String> doRule(SQLPackage eaObject, SQLWrapperClasses.SQLRepository repository)
        {
            List <String> results = new List <string>();

            if (eaObject.Element != null)
            {
                if (eaObject.Element.Stereotype == ECOREModelingMain.EPackageStereotype)
                {
                    if (eaObject.Elements.Count == 0)
                    {
                        results.Add("Empty package is not allowed");
                    }
                }
            }
            return(results);
        }
        public EPackage importEPackage(MocaNode ePackageNode, SQLPackage parentPackage)
        {
            EA.Package modelPackage = getOrCreatePackage(parentPackage, ePackageNode);

            EPackage ePkg = new EPackage(sqlRep.GetPackageByID(modelPackage.PackageID), sqlRep);

            ePkg.deserializeFromMocaTree(ePackageNode);

            MainImport.getInstance().MocaTaggableElements.Add(ePkg);
            MainImport.getInstance().OldGuidToNewGuid.Add(ePkg.Guid, modelPackage.PackageGUID);

            appendDiagram(modelPackage, "eMoflon Ecore Diagrams::Ecore Diagram", repository);// ECOREModelingMain.EcoreDiagramMetatype[0]);

            importEPackageFeatures(ePackageNode, sqlRep.GetPackageByID(modelPackage.PackageID));

            return(ePkg);
        }
Beispiel #28
0
        private void updateMocaTreeFragments()
        {
            // For all packages (recursively!) in TGG and Ecore projects
            foreach (EA.Package p in EAUtil.findAllMoflonPackages(repository))
            {
                SQLPackage p2 = sqlRep.GetPackageByID(p.PackageID);
                if (p.Element.Stereotype == TGGModelingMain.TggSchemaPackageStereotype)
                {
                    TGG tgg = new TGG(sqlRep, p2);
                    tgg.loadTreeFromTaggedValue();
                    tgg.saveTreeToEATaggedValue(false);
                }
                else if (p.Element.Stereotype == TGGModelingMain.TggRulePackageStereotype)
                {
                    TGGRulePackage package = new TGGRulePackage(p2, sqlRep);
                    package.loadTreeFromTaggedValue();
                    package.saveTreeToEATaggedValue(false);
                }
                else
                {
                    EPackage package = new EPackage(p2, sqlRep);
                    package.loadTreeFromTaggedValue();
                    package.saveTreeToEATaggedValue(false);
                }
            }

            foreach (EA.Element eClassElement in EAUtil.findAllEClasses(repository))
            {
                EClass eClass = new EClass(sqlRep.GetElementByID(eClassElement.ElementID), sqlRep);
                eClass.saveTreeToEATaggedValue(false);
            }

            foreach (EA.Element ruleElement in EAUtil.findAllStereotypedElements(repository, TGGModelingMain.TggRuleStereotype))
            {
                TGGRule rule = new TGGRule(sqlRep, sqlRep.GetElementByID(ruleElement.ElementID));
                rule.loadTreeFromTaggedValue();
                rule.saveTreeToEATaggedValue(false);
            }

            foreach (EA.Element corrTypeElement in EAUtil.findAllStereotypedElements(repository, TGGModelingMain.TggCorrespondenceTypeStereotype))
            {
                TGGCorrespondenceType corrType = new TGGCorrespondenceType(sqlRep.GetElementByID(corrTypeElement.ElementID), sqlRep);
                corrType.loadTreeFromTaggedValue();
                corrType.saveTreeToEATaggedValue(false);
            }
        }
        public EClass importEClass(SQLPackage parentPackage, MocaNode eClassNode)
        {
            EA.Element    eclassElem = getOrCreateElement(parentPackage, eClassNode, "Class");
            MocaAttribute isAbstract = eClassNode.getAttributeOrCreate("isAbstract");

            if (isAbstract.Value == "true")
            {
                eclassElem.Abstract = "1";
            }
            else
            {
                eclassElem.Abstract = "0";
            }
            eclassElem.Update();

            return(importEClassFeatures(eClassNode, sqlRep.GetElementByID(eclassElem.ElementID)));
        }
Beispiel #30
0
        private static DomainType determineDomainSimple(SQLRepository repository, TGGObjectVariable tggOv)
        {
            if (tggOv.sqlElement.Stereotype == TGGModelingMain.TggCorrespondenceStereotype)
            {
                return(DomainType.CORRESPONDENCE);
            }

            EClass classifierElement = tggOv.Classifier;

            if (classifierElement != null)
            {
                SQLElement eClass          = repository.GetElementByID(classifierElement.EaElement.ElementID);
                SQLPackage wantedDomainPkg = repository.GetPackageByID(eClass.PackageID);
                while (!wantedDomainPkg.IsModel)
                {
                    wantedDomainPkg = repository.GetPackageByID(wantedDomainPkg.ParentID);
                }

                SQLPackage tggPackage = repository.GetPackageByID(tggOv.sqlElement.PackageID);
                while (!tggPackage.IsModel)
                {
                    tggPackage = repository.GetPackageByID(tggPackage.ParentID);
                }

                TGG tgg = new TGG(repository, tggPackage);
                tgg.loadTreeFromTaggedValue();

                // source metamodel == target metamodel
                if (tgg.getDomain(DomainType.SOURCE).MetamodelGuid == tgg.getDomain(DomainType.TARGET).MetamodelGuid)
                {
                    return(determineDomainUsingPrefixConvention(tggOv, repository));
                }

                if (wantedDomainPkg.PackageGUID == tgg.getDomain(DomainType.SOURCE).MetamodelGuid)
                {
                    return(DomainType.SOURCE);
                }
                else if (wantedDomainPkg.PackageGUID == tgg.getDomain(DomainType.TARGET).MetamodelGuid)
                {
                    return(DomainType.TARGET);
                }
            }

            return(determineDomainUsingPrefixConvention(tggOv, repository));
        }