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 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 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); }
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); }
private void setTagValueIfPossibleForPackage(String tagNameInNode, MocaNode node, EA.Package eaPack) { MocaAttribute attribute = node.getAttribute(tagNameInNode); if (attribute != null) { EAEcoreAddin.Util.EAUtil.setTaggedValue(sqlRep, eaPack, tagNameInNode, attribute.Value); } else { EAEcoreAddin.Util.EAUtil.deleteTaggedValue(eaPack.Element, tagNameInNode); } eaPack.Update(); }
public override void deserializeFromMocaTree(Serialization.MocaTree.MocaNode referencesNode) { MocaNode ereferenceNode = referencesNode; ereferenceNode = extractFromReferencesNode(ereferenceNode); //alternative way if (ereferenceNode == null || ereferenceNode.Name != "EReference") { if (ConnectorEnd.End == "Client") { ereferenceNode = referencesNode.getChildNodeWithName("ClientReference"); } else if (ConnectorEnd.End == "Supplier") { ereferenceNode = referencesNode.getChildNodeWithName("SupplierReference"); } if (ereferenceNode != null) { ereferenceNode = ereferenceNode.getChildNodeWithName("EReference"); } } if (ereferenceNode != null) { this.Navigable = true; MocaAttribute typeAttr = ereferenceNode.getAttributeOrCreate("typeGuid"); if (typeAttr != null) { this.typeGUID = typeAttr.Value; } MocaAttribute nameAttr = ereferenceNode.getAttributeOrCreate("name"); if (nameAttr != null) { this.Name = nameAttr.Value; } MocaAttribute guidAttr = ereferenceNode.getAttributeOrCreate(Main.GuidStringName); if (guidAttr != null) { this.refGUID = guidAttr.Value; } MocaAttribute lbAttr = ereferenceNode.getAttributeOrCreate("lowerBound"); if (lbAttr != null) { this.lowerBound = lbAttr.Value; } MocaAttribute ubAttr = ereferenceNode.getAttributeOrCreate("upperBound"); if (ubAttr != null) { this.upperBound = ubAttr.Value; } MocaAttribute cont = ereferenceNode.getAttribute("containment"); if (cont != null) { this.containment = cont.Value == "true"; } MocaAttribute oppo = ereferenceNode.getAttributeOrCreate("oppositeGuid"); if (oppo != null) { this.oppositeGUID = oppo.Value; } } }