private void savePackageChangesToEATaggedValue(SQLRepository sqlRepository, String GUID) { SQLPackage sqlPackage = sqlRepository.GetPackageByGuid(GUID); EPackage epackage = new EPackage(sqlPackage, sqlRepository); String packages = addPackageName(epackage, "", sqlRepository); String previousName = sqlPackage.Name; SQLTaggedValue changesTreeTag = EAEcoreAddin.Util.EAUtil.findTaggedValue(sqlPackage, Main.MoflonChangesTreeTaggedValueName); if (changesTreeTag != null) { MocaNode eClassMocaNode = MocaTreeUtil.mocaNodeFromXmlString(changesTreeTag.Notes); previousName = eClassMocaNode.getAttribute("previousName").Value; } CachedPackage temp = new CachedPackage(); temp.getPackage(GUID, sqlRepository); temp.name = sqlPackage.Name; temp.previousName = previousName; temp.packageName = packages; temp.projectName = getTopLevelPackageName(sqlPackage, sqlRepository); temp.savePackageToEATaggedValue(true); }
public MocaNode processEClass(SQLElement eaClass) { SQLTaggedValue changesTreeTag = EAEcoreAddin.Util.EAUtil.findTaggedValue(eaClass, Main.MoflonChangesTreeTaggedValueName); if (changesTreeTag != null) { EClass eClass = new EClass(eaClass, repository); eClass.loadTreeFromTaggedValue(); MocaNode eClassMocaNode = MocaTreeUtil.mocaNodeFromXmlString(changesTreeTag.Notes); eClass.addMocaAttributesDuringExport(eClassMocaNode); this.currentNode.appendChildNode(eClassMocaNode); if (eClassMocaNode.hasAllAttributes(new List <string>( new string[] { ChangesTreeConstants.ATTRIBUTE_KEY_PACKAGE_NAME, ChangesTreeConstants.ATTRIBUTE_KEY_PROJECT_NAME }))) { String packageName = eClassMocaNode.getAttribute(ChangesTreeConstants.ATTRIBUTE_KEY_PACKAGE_NAME).Value; String projectName = eClassMocaNode.getAttribute(ChangesTreeConstants.ATTRIBUTE_KEY_PROJECT_NAME).Value; CachedClass temp = new CachedClass(); temp.getElement(eaClass.ElementGUID, repository); temp.name = eClass.Name; temp.previousName = eClass.Name; temp.packageName = packageName; temp.projectName = projectName; temp.saveElementToEATaggedValue(true); return(eClassMocaNode); } } return(null); }
private void saveElementChangesToEATaggedValue(SQLElement eaElement, String GUID, SQLRepository sqlRepository) { SQLPackage package = sqlRepository.GetPackageByID(eaElement.PackageID); EPackage epackage = new EPackage(package, sqlRepository); // String packages = addPackageName(epackage, "", sqlRepository); String previousName = eaElement.Name; SQLTaggedValue exportTreeTag = EAEcoreAddin.Util.EAUtil.findTaggedValue(eaElement, Main.MoflonExportTreeTaggedValueName); /*if (exportTreeTag != null) * { * MocaNode eClassMocaNode = MocaTreeUtil.mocaNodeFromXmlString(exportTreeTag.Notes); * MocaNode eClassAttributes = eClassMocaNode.Children[1]; * eClassAttributes.getAttribute() * * previousName = eClassMocaNode.getAttribute("previousName").Value; * }*/ SQLTaggedValue changesTreeTag = EAEcoreAddin.Util.EAUtil.findTaggedValue(eaElement, Main.MoflonChangesTreeTaggedValueName); if (changesTreeTag != null) { MocaNode eClassMocaNode = MocaTreeUtil.mocaNodeFromXmlString(changesTreeTag.Notes); previousName = eClassMocaNode.getAttribute("previousName").Value; } CachedClass temp = new CachedClass(); temp.getElement(GUID, sqlRepository); temp.name = eaElement.Name; temp.previousName = previousName; temp.packageName = addPackageName(epackage, "", sqlRepository); temp.projectName = getTopLevelPackageName(package, sqlRepository); temp.saveElementToEATaggedValue(true); }
public MocaNode processEClass(SQLElement eaClass) { SQLTaggedValue refactorTreeTag = EAEcoreAddin.Util.EAUtil.findTaggedValue(eaClass, Main.MoflonRefactorTreeTaggedValueName); if (refactorTreeTag != null) { EClass eClass = new EClass(eaClass, repository); eClass.loadTreeFromTaggedValue(); MocaNode eClassMocaNode = MocaTreeUtil.mocaNodeFromXmlString(refactorTreeTag.Notes); eClass.addMocaAttributesDuringExport(eClassMocaNode); //add baseclass dependencies /*foreach (var baseClass in eClassMocaNode.getAttributeOrCreate("baseClasses").Value.Split(" ".ToArray())) * { * if (baseClass != "") * { * SQLElement baseclass = repository.GetElementByGuid(baseClass); * Export.computeAndAddToDependencies(repository, baseclass); * } * }*/ this.currentNode.appendChildNode(eClassMocaNode); return(eClassMocaNode); } return(null); }
private MocaNode processEPackage(SQLPackage eaPackage) { //backgroundWorker.ReportProgress(0, PersistencyUtil.computePackageUri(eaPackage, repository)); //SQLTaggedValue mocaTreeTag = EAEcoreAddin.Util.EAUtil.findTaggedValue(eaPackage, Main.MoflonRefactorTreeTaggedValueName); //if (mocaTreeTag == null) 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); 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); }
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); }
public void addChangesAttributesDuringExport(MocaNode pkgNode, SQLTaggedValue changesTreeTag) { MocaNode ePackageMocaNode = MocaTreeUtil.mocaNodeFromXmlString(changesTreeTag.Notes); string[] expectedAttributes = { ChangesTreeConstants.ATTRIBUTE_KEY_NAME, ChangesTreeConstants.ATTRIBUTE_KEY_PREVIOUS_NAME, ChangesTreeConstants.ATTRIBUTE_KEY_PACKAGE_NAME, ChangesTreeConstants.ATTRIBUTE_KEY_PROJECT_NAME }; if (ePackageMocaNode.hasAllAttributes(new List <string>(expectedAttributes))) { pkgNode.appendChildAttribute("Changes::Name", ePackageMocaNode.getAttribute(ChangesTreeConstants.ATTRIBUTE_KEY_NAME).Value); pkgNode.appendChildAttribute("Changes::PreviousName", ePackageMocaNode.getAttribute(ChangesTreeConstants.ATTRIBUTE_KEY_PREVIOUS_NAME).Value); pkgNode.appendChildAttribute("Changes::PackageName", ePackageMocaNode.getAttribute(ChangesTreeConstants.ATTRIBUTE_KEY_PACKAGE_NAME).Value); pkgNode.appendChildAttribute("Changes::ProjectName", ePackageMocaNode.getAttribute(ChangesTreeConstants.ATTRIBUTE_KEY_PROJECT_NAME).Value); //pkgNode.appendChildAttribute("Changes::IsTLP", ePackageMocaNode.getAttribute("isTLP").Value); } }
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); }
private void buttonImportCSP_Click(object sender, EventArgs e) { checkForFunctions(); if (activateExportImportCSPButton) { String pathToWrite = Path.GetDirectoryName(repository.ConnectionString); OpenFileDialog dialog = new OpenFileDialog(); dialog.AddExtension = true; dialog.DefaultExt = "txt"; dialog.InitialDirectory = pathToWrite; dialog.Filter = "Text files (*.txt)|*.txt|All files (*.*)|*.*"; dialog.FileName = "csptemp.txt"; if (dialog.ShowDialog() == DialogResult.OK) { TGG tggPackage = new TGG(repository, repository.GetTreeSelectedPackage()); tggPackage.loadTreeFromTaggedValue(); String fileContent = File.ReadAllText(dialog.FileName); MocaNode dummyParent = MocaTreeUtil.mocaNodeFromXmlString(fileContent); foreach (MocaNode cspNode in dummyParent.Children) { CSPConstraint constraint = new CSPConstraint(); constraint.deserializeFromMocaTree(cspNode); Boolean alreadyIn = false; foreach (CSPConstraint existingCSP in tggPackage.Constraints) { if (existingCSP.Name == constraint.Name) { alreadyIn = true; break; } } if (!alreadyIn) { tggPackage.Constraints.Add(constraint); } } tggPackage.saveTreeToEATaggedValue(false); } } }
public MocaNode processEClass(SQLElement eaClass) { //this.exportProgressBar.invokePerformNext("Exporting EClass: " + eaClass.Name); SQLTaggedValue changesTreeTag = EAEcoreAddin.Util.EAUtil.findTaggedValue(eaClass, Main.MoflonChangesTreeTaggedValueName); SQLTaggedValue mocaTreeTag = EAEcoreAddin.Util.EAUtil.findTaggedValue(eaClass, Main.MoflonExportTreeTaggedValueName); if (mocaTreeTag != null) { EClass eClass = new EClass(eaClass, repository); eClass.loadTreeFromTaggedValue(); MocaNode eClassMocaNode = MocaTreeUtil.mocaNodeFromXmlString(mocaTreeTag.Notes); eClass.addMocaAttributesDuringExport(eClassMocaNode); if (changesTreeTag != null) { MocaNode eClassChangesNode = MocaTreeUtil.mocaNodeFromXmlString(changesTreeTag.Notes); eClass.addMocaAttributesDuringExport(eClassChangesNode); } //add baseclass dependencies foreach (var baseClass in eClassMocaNode.getAttributeOrCreate("baseClasses").Value.Split(" ".ToArray())) { if (baseClass != "") { SQLElement baseclass = repository.GetElementByGuid(baseClass); Export.computeAndAddToDependencies(repository, baseclass); } } this.currentNode.appendChildNode(eClassMocaNode); //process SDM Container Objects int counter = 0; foreach (SQLElement possibleSDMContainer in eaClass.Elements) { if (possibleSDMContainer.Stereotype == SDMModelingMain.SdmContainerStereotype || possibleSDMContainer.Stereotype == "SDM_Container") { String associatedMethodguid = EAEcoreAddin.Util.EAUtil.findTaggedValue(possibleSDMContainer, SDMModelingMain.SDMContainerAssociatedMethodTaggedValueName).Value; MocaNode operationsNode = eClassMocaNode.getChildNodeWithName(EClass.OperationsChildNodeName); MocaNode owningOperationNode = null; if (!Export.showStatusBar) { Console.Out.WriteLine("SCALE:Export SDM '" + possibleSDMContainer.Name + "' %" + counter + "/" + eaClass.Elements.Count + "#"); } counter++; foreach (MocaNode EOperationNode in operationsNode.Children) { MocaAttribute guidAttribute = EOperationNode.getAttributeOrCreate(Main.GuidStringName); if (guidAttribute != null && guidAttribute.Value == associatedMethodguid) { owningOperationNode = EOperationNode; } } if (owningOperationNode != null) { MocaNode sdmActivityNode = this.sdmExport.processActivity(possibleSDMContainer); owningOperationNode.appendChildNode(sdmActivityNode); } } } foreach (SQLAttribute element in eaClass.Attributes) { string t = element.Type; int cid = element.ClassifierID; SQLElement typeElement = repository.GetElementByIDNullable(cid); Export.computeAndAddToDependencies(repository, typeElement); } counter = 0; foreach (SQLConnector ereference in eaClass.Connectors) { if (ereference.Type == Main.EAAssociationType) { if (!Export.showStatusBar) { Console.Out.WriteLine("SCALE:Export EReference '" + ereference.Name + "' %" + counter + "/" + eaClass.Connectors.Count + "#"); } counter++; MocaNode referencesNode = eClassMocaNode.getChildNodeWithName(EClass.ReferencesChildNodeName); if (ereference.ClientID != eaClass.ElementID && ereference.ClientEnd.IsNavigable) { this.currentNode = referencesNode; processEReference(ereference, ereference.ClientEnd.End); } else if (ereference.SupplierID != eaClass.ElementID && ereference.SupplierEnd.IsNavigable) { this.currentNode = referencesNode; processEReference(ereference, ereference.SupplierEnd.End); } if (ereference.SupplierID == eaClass.ElementID && ereference.ClientID == eaClass.ElementID && ereference.SupplierEnd.IsNavigable) { this.currentNode = referencesNode; processEReference(ereference, ereference.SupplierEnd.End); } if (ereference.SupplierID == eaClass.ElementID && ereference.ClientID == eaClass.ElementID && ereference.ClientEnd.IsNavigable) { this.currentNode = referencesNode; processEReference(ereference, ereference.ClientEnd.End); } } } return(eClassMocaNode); } return(null); }