private void processTggRule(SQLElement ruleClass) { //this.exportProgressBar.invokePerformNext("exporting EClass: " + eaClass.Name); SQLTaggedValue mocaTreeTag = EAEcoreAddin.Util.EAUtil.findTaggedValue(ruleClass, Main.MoflonExportTreeTaggedValueName); TGGRule tggRule = new TGGRule(repository, ruleClass); tggRule.loadTreeFromTaggedValue(); MocaNode tggRuleMocaNode = new MocaNode(); tggRuleMocaNode.deserializeFromXmlTree(MocaTreeUtil.stringToXmlDocument(mocaTreeTag.Notes).DocumentElement.FirstChild as XmlElement); this.currentNode.appendChildNode(tggRuleMocaNode); tggRule.additionalAttributesDuringExport(tggRuleMocaNode); foreach (SQLElement element in ruleClass.Elements) { //handle tgg rule pattern if (element.Stereotype == TGGModelingMain.TggObjectVariableStereotype || element.Stereotype == TGGModelingMain.TggCorrespondenceStereotype) { this.currentNode = tggRuleMocaNode.getChildNodeWithName(StoryPattern.ObjectVariablesChildNodeName); processTggObjectVariable(element); } //handle sdms of tgg rule class else if (element.Stereotype == SDMModelingMain.SdmContainerStereotype) { String associatedMethodguid = EAEcoreAddin.Util.EAUtil.findTaggedValue(element, SDMModelingMain.SDMContainerAssociatedMethodTaggedValueName).Value; MocaNode operationsNode = tggRuleMocaNode.getChildNodeWithName(EClass.OperationsChildNodeName); MocaNode owningOperationNode = null; 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.ExportMain.ecoreExport.sdmExport.processActivity(element); owningOperationNode.appendChildNode(sdmActivityNode); } } else if (element.Stereotype == TGGModelingMain.CSPConstraintStereotype || element.Stereotype == "TGGCsp") { MocaNode cspsNode = tggRuleMocaNode.getChildNodeWithName(TGGRule.CspsChildNodeName); if (cspsNode == null) { cspsNode = tggRuleMocaNode.appendChildNode(TGGRule.CspsChildNodeName); } this.currentNode = cspsNode; processTGGCSP(element); tggRuleMocaNode.getAttributeOrCreate(TGGRule.CspSpecAttributeName).Value += element.Notes.Replace(Environment.NewLine, ""); } } }
public void processTggEReference(SQLConnector eaReference, String clientOrSupplier) { SQLConnectorTag mocaTreeTag = EAEcoreAddin.Util.EAUtil.findTaggedValue(eaReference, Main.MoflonExportTreeTaggedValueName); MocaNode referenceEndNode = new MocaNode(); referenceEndNode.deserializeFromXmlTree(MocaTreeUtil.stringToXmlDocument(mocaTreeTag.Notes).DocumentElement.FirstChild as XmlElement); SQLElement eTypeElement = null; if (clientOrSupplier == "Client") { referenceEndNode = referenceEndNode.getChildNodeWithName(EReference.ClientReferenceChildNodeName).Children[0]; eTypeElement = repository.GetElementByID(eaReference.ClientID); } else if (clientOrSupplier == "Supplier") { referenceEndNode = referenceEndNode.getChildNodeWithName(EReference.SupplierReferenceChildNodeName).Children[0]; eTypeElement = repository.GetElementByID(eaReference.SupplierID); } ExportMain.computeAndAddToDependencies(repository, eTypeElement); this.currentNode.appendChildNode(referenceEndNode); }
public void processObjectVariable(SQLElement objectVariable) { SQLTaggedValue mocaTreeTag = EAEcoreAddin.Util.EAUtil.findTaggedValue(objectVariable, Main.MoflonExportTreeTaggedValueName); ObjectVariable ov = new ObjectVariable(objectVariable, repository); ov.loadTreeFromTaggedValue(); SQLElement classifier = EAUtil.getClassifierElement(repository, objectVariable.ClassifierID); if (classifier != null) { Export.computeAndAddToDependencies(repository, classifier); } MocaNode ovMocaNode = new MocaNode(); ovMocaNode.deserializeFromXmlTree(MocaTreeUtil.stringToXmlDocument(mocaTreeTag.Notes).DocumentElement.FirstChild as XmlElement); ov.addAttributesDuringExport(ovMocaNode); this.currentNode.appendChildNode(ovMocaNode); foreach (SQLConnector linkVariable in objectVariable.Connectors) { if ((linkVariable.Stereotype == SDMModelingMain.LinkVariableStereotype || linkVariable.Stereotype == "SDM_Association") && linkVariable.ClientID == objectVariable.ElementID) { this.currentNode = ovMocaNode.getChildNodeWithName(ObjectVariable.OutgoingLinksNodeName); processLinkVariable(linkVariable); } } }
public static MocaNode mocaNodeFromXmlString(String xmlString) { XmlDocument xmlDoc = MocaTreeUtil.stringToXmlDocument(xmlString); MocaNode mocaNode = new MocaNode(); mocaNode.deserializeFromXmlTree(xmlDoc.DocumentElement.FirstChild as XmlElement); return(mocaNode); }
/// <summary> /// Deserializes the TaggedValue from the tagged Object /// </summary> /// <returns></returns> public Boolean loadTreeFromTaggedValue() { String tagNotes = ""; Object mocaTag = null; Object objectToBeTagged = getObjectToBeTagged(); if (objectToBeTagged is SQLElement) { mocaTag = EAUtil.findTaggedValue(objectToBeTagged as SQLElement, Main.MoflonExportTreeTaggedValueName); } else if (objectToBeTagged is SQLConnector) { mocaTag = EAUtil.findTaggedValue(objectToBeTagged as SQLConnector, Main.MoflonExportTreeTaggedValueName); } else if (objectToBeTagged is SQLPackage) { mocaTag = EAUtil.findTaggedValue(objectToBeTagged as SQLPackage, Main.MoflonExportTreeTaggedValueName); } else if (objectToBeTagged is SQLMethod) { mocaTag = EAUtil.findTaggedValue(Repository.GetOriginalRepository().GetMethodByID((objectToBeTagged as SQLMethod).MethodID), Main.MoflonExportTreeTaggedValueName); } if (mocaTag is SQLTaggedValue) { tagNotes = (mocaTag as SQLTaggedValue).Notes; } else if (mocaTag is SQLConnectorTag) { tagNotes = (mocaTag as SQLConnectorTag).Notes; } else if (mocaTag is EA.MethodTag) { tagNotes = (mocaTag as EA.MethodTag).Notes; } if (tagNotes != "") { XmlDocument xmlDocument = MocaTreeUtil.stringToXmlDocument(tagNotes); MocaNode emptyMocaNode = new MocaNode(); //fill mocanode from xmlElement emptyMocaNode.deserializeFromXmlTree(xmlDocument.FirstChild.FirstChild as XmlElement); //fill this from mocanode try { deserializeFromMocaTree(emptyMocaNode); } catch { return(false); } return(true); } return(false); }
public void doImport() { if (import.Value && eapFile.Values.Count == 1) { EA.Repository repository = null; try { foreach (String eapFilename in eapFile.Values) { Console.Out.WriteLine("DEBUG:Start import#"); String xmiFilename = xmiFile.Value; EAEcoreAddin.Main main = new EAEcoreAddin.Main(); repository = new EA.Repository(); repository.OpenFile(eapFilename); Console.Out.WriteLine("DEBUG:Initialize Importer#"); SQLRepository sqlRepository = new SQLRepository(repository, false); MainImport importer = MainImport.getInstance(sqlRepository, new BackgroundWorker()); Console.Out.WriteLine("DEBUG:Get MocaTree Node#"); MocaNode exportedTree = new MocaNode(); String readText = File.ReadAllText(xmiFilename); XmlDocument mocaXmlDocument = XmlUtil.stringToXmlDocument(readText); exportedTree.deserializeFromXmlTree(mocaXmlDocument.DocumentElement.FirstChild as XmlElement); Console.Out.WriteLine("DEBUG:Do Import#"); checkedMetamodelsToImport = new List <string>(); MocaNode mocaTree = new MocaNode(); mocaTree.appendChildNode(exportedTree); importer.startImport(exportedTree, checkedMetamodelsToImport, false); ////open the empty eap Console.Out.WriteLine("INFO:Import was Successfull#"); } } catch (Exception e) { Console.Out.Write("ERROR:Import was not successfull. Reason: " + e.Message); } finally { try { repository.Exit(); } catch { } } } }
private void processTGGCSP(SQLElement element) { SQLTaggedValue mocaTreeTag = EAEcoreAddin.Util.EAUtil.findTaggedValue(element, Main.MoflonExportTreeTaggedValueName); if (mocaTreeTag != null) { MocaNode tggRuleMocaNode = new MocaNode(); tggRuleMocaNode.deserializeFromXmlTree(MocaTreeUtil.stringToXmlDocument(mocaTreeTag.Notes).DocumentElement.FirstChild as XmlElement); this.currentNode.appendChildNode(tggRuleMocaNode); } }
public void processEEnum(SQLElement eaEnum) { SQLTaggedValue mocaTreeTag = EAEcoreAddin.Util.EAUtil.findTaggedValue(eaEnum, Main.MoflonExportTreeTaggedValueName); if (mocaTreeTag != null) { MocaNode eEnumMocaNode = new MocaNode(); eEnumMocaNode.deserializeFromXmlTree(MocaTreeUtil.stringToXmlDocument(mocaTreeTag.Notes).DocumentElement.FirstChild as XmlElement); this.currentNode.appendChildNode(eEnumMocaNode); } }
public void processActivityEdge(SQLConnector activityEdgeEAElement) { SQLConnectorTag mocaTreeTag = EAEcoreAddin.Util.EAUtil.findTaggedValue(activityEdgeEAElement, Main.MoflonExportTreeTaggedValueName); ActivityEdge aEdge = new ActivityEdge(repository, activityEdgeEAElement); Boolean valid = aEdge.loadTreeFromTaggedValue(); MocaNode activityEdgeMocaNode = new MocaNode(); activityEdgeMocaNode.deserializeFromXmlTree(MocaTreeUtil.stringToXmlDocument(mocaTreeTag.Notes).DocumentElement.FirstChild as XmlElement); aEdge.addAttributesDuringExport(activityEdgeMocaNode); this.currentNode.appendChildNode(activityEdgeMocaNode); }
public void processTggLinkVariable(SQLConnector linkVariable) { SQLConnectorTag mocaTreeTag = EAEcoreAddin.Util.EAUtil.findTaggedValue(linkVariable, Main.MoflonExportTreeTaggedValueName); TGGLinkVariable lv = new TGGLinkVariable(linkVariable, repository); Boolean valid = lv.loadTreeFromTaggedValue(); MocaNode linkVariableMocaNode = new MocaNode(); linkVariableMocaNode.deserializeFromXmlTree(MocaTreeUtil.stringToXmlDocument(mocaTreeTag.Notes).DocumentElement.FirstChild as XmlElement); lv.addAttributesDuringExport(linkVariableMocaNode); this.currentNode.appendChildNode(linkVariableMocaNode); }
private void textBoxFile_TextChanged(object sender, EventArgs e) { groupBoxCheckboxes.Controls.Clear(); checkedMetamodelsToImport.Clear(); String fileName = textBoxFile.Text; if (File.Exists(fileName)) { buttonImport.Enabled = true; MocaNode mocaTree = new MocaNode(); String readText = File.ReadAllText(fileName); XmlDocument mocaXmlDocument = XmlUtil.stringToXmlDocument(readText); mocaTree.deserializeFromXmlTree(mocaXmlDocument.DocumentElement.FirstChild as XmlElement); this.mocaTree = mocaTree; foreach (MocaNode modelPackageNode in mocaTree.Children) { if (modelPackageNode.Name == ECOREModelingMain.EPackageStereotype) { addCheckbox(modelPackageNode); } else if (modelPackageNode.Name == "TGG") { addCheckbox(modelPackageNode); } } } else { buttonImport.Enabled = false; } int newHeight = 310 + groupBoxCheckboxes.Controls.Count * 23; if (newHeight < 352) { Height = 352; } else { Height = newHeight; } MinimumSize = new Size(492, Height); }
public MocaNode processTggObjectVariable(SQLElement objectVariable) { SQLTaggedValue mocaTreeTag = EAEcoreAddin.Util.EAUtil.findTaggedValue(objectVariable, Main.MoflonExportTreeTaggedValueName); ObjectVariable ov = null; if (objectVariable.Stereotype == TGGModelingMain.TggObjectVariableStereotype) { ov = new TGGObjectVariable(objectVariable, repository); } else if (objectVariable.Stereotype == TGGModelingMain.TggCorrespondenceStereotype) { ov = new TGGCorrespondence(objectVariable, repository); } SQLElement classifier = repository.GetElementByID(objectVariable.ClassifierID); ExportMain.computeAndAddToDependencies(repository, classifier); MocaNode ovMocaNode = new MocaNode(); ovMocaNode.deserializeFromXmlTree(MocaTreeUtil.stringToXmlDocument(mocaTreeTag.Notes).DocumentElement.FirstChild as XmlElement); ov.addAttributesDuringExport(ovMocaNode); this.currentNode.appendChildNode(ovMocaNode); foreach (SQLConnector linkVariable in objectVariable.Connectors) { try { SQLElement source = repository.GetElementByID(linkVariable.ClientID); SQLElement target = repository.GetElementByID(linkVariable.SupplierID); if ((linkVariable.Stereotype == TGGModelingMain.TggLinkVariableStereotype || linkVariable.Type == Main.EAAssociationType) && linkVariable.ClientID == objectVariable.ElementID) { this.currentNode = ovMocaNode.getChildNodeWithName(ObjectVariable.OutgoingLinksNodeName); processTggLinkVariable(linkVariable); } } catch { } } return(ovMocaNode); }
public void processTGGCorrespondenceType(SQLElement eaClass) { SQLTaggedValue mocaTreeTag = EAEcoreAddin.Util.EAUtil.findTaggedValue(eaClass, Main.MoflonExportTreeTaggedValueName); TGGCorrespondenceType tggCorrType = new TGGCorrespondenceType(eaClass, repository); tggCorrType.loadTreeFromTaggedValue(); MocaNode eClassMocaNode = new MocaNode(); eClassMocaNode.deserializeFromXmlTree(MocaTreeUtil.stringToXmlDocument(mocaTreeTag.Notes).DocumentElement.FirstChild as XmlElement); tggCorrType.addMocaAttributesDuringExport(eClassMocaNode); this.currentNode.appendChildNode(eClassMocaNode); foreach (SQLConnector ereference in eaClass.Connectors) { if (ereference.Type == Main.EAAssociationType) { MocaNode referencesNode = eClassMocaNode.getChildNodeWithName(EClass.ReferencesChildNodeName); if (ereference.ClientID != eaClass.ElementID && ereference.ClientEnd.IsNavigable) { this.currentNode = referencesNode; processTggEReference(ereference, ereference.ClientEnd.End); } else if (ereference.SupplierID != eaClass.ElementID && ereference.SupplierEnd.IsNavigable) { this.currentNode = referencesNode; processTggEReference(ereference, ereference.SupplierEnd.End); } if (ereference.SupplierID == eaClass.ElementID && ereference.ClientID == eaClass.ElementID && ereference.SupplierEnd.IsNavigable) { this.currentNode = referencesNode; processTggEReference(ereference, ereference.SupplierEnd.End); } if (ereference.SupplierID == eaClass.ElementID && ereference.ClientID == eaClass.ElementID && ereference.ClientEnd.IsNavigable) { this.currentNode = referencesNode; processTggEReference(ereference, ereference.ClientEnd.End); } } } }
public MocaNode processTggOutermostPackage(SQLPackage tggOutermostPackage) { backgroundWorker.ReportProgress(0, PersistencyUtil.computePackageUri(tggOutermostPackage, repository)); this.currentNode = new MocaNode(); SQLTaggedValue mocaTreeTag = EAEcoreAddin.Util.EAUtil.findTaggedValue(tggOutermostPackage, Main.MoflonExportTreeTaggedValueName); TGG tgg = new TGG(repository, tggOutermostPackage); tgg.loadTreeFromTaggedValue(); XmlDocument xmlDoc = MocaTreeUtil.stringToXmlDocument(mocaTreeTag.Notes); MocaNode ePackageMocaNode = new MocaNode(); ePackageMocaNode.deserializeFromXmlTree(xmlDoc.DocumentElement.FirstChild as XmlElement); tgg.addAttributesDuringExport(ePackageMocaNode); this.currentNode.appendChildNode(ePackageMocaNode); foreach (SQLPackage childPackage in tggOutermostPackage.Packages) { this.currentNode = ePackageMocaNode.getChildNodeWithName(EPackageHelper.PackagesChildNodeName); processTggPackage(childPackage); } foreach (SQLElement childClass in tggOutermostPackage.Elements) { processTGGPackageFeatures(ePackageMocaNode, childClass); } SQLTaggedValue moflonExportTag = EAEcoreAddin.Util.EAUtil.findTaggedValue(tggOutermostPackage, MetamodelHelper.MoflonExportTaggedValueName); if (moflonExportTag != null) { ePackageMocaNode.appendChildAttribute(MetamodelHelper.MoflonExportTaggedValueName, moflonExportTag.Value); } else { ePackageMocaNode.appendChildAttribute(MetamodelHelper.MoflonExportTaggedValueName, "false"); } return(ePackageMocaNode); }
public MocaNode processActivity(SQLElement sdmContainerClass) { SQLTaggedValue mocaTreeTag = EAEcoreAddin.Util.EAUtil.findTaggedValue(sdmContainerClass, Main.MoflonExportTreeTaggedValueName); Activity activity = new Activity(sdmContainerClass, repository); Boolean valid = activity.loadTreeFromTaggedValue(); MocaNode activityMocaNode = new MocaNode(); activityMocaNode.deserializeFromXmlTree(MocaTreeUtil.stringToXmlDocument(mocaTreeTag.Notes).DocumentElement.FirstChild as XmlElement); this.currentNode = activityMocaNode; foreach (SQLElement activityNode in sdmContainerClass.Elements) { if (activityNode.Type == Main.EAActivityType || activityNode.Type == Main.EAStateNodeType) { this.currentNode = activityMocaNode; processActivityNode(activityNode); } } return(activityMocaNode); }
private MocaNode processTggPackage(SQLPackage eaPackage) { backgroundWorker.ReportProgress(0, PersistencyUtil.computePackageUri(eaPackage, repository)); EPackage ePackage = new EPackage(eaPackage, repository); if (eaPackage.Element.Stereotype == TGGModelingMain.TggRulePackageStereotype || eaPackage.Name == "Rules") { ePackage = new TGGRulePackage(eaPackage, repository); } ePackage.loadTreeFromTaggedValue(); SQLTaggedValue mocaTreeTag = EAEcoreAddin.Util.EAUtil.findTaggedValue(eaPackage, Main.MoflonExportTreeTaggedValueName); XmlDocument xmlDoc = MocaTreeUtil.stringToXmlDocument(mocaTreeTag.Notes); MocaNode ePackageMocaNode = new MocaNode(); ePackageMocaNode.deserializeFromXmlTree(xmlDoc.DocumentElement.FirstChild as XmlElement); ePackage.addAttributesDuringExport(ePackageMocaNode); this.currentNode.appendChildNode(ePackageMocaNode); foreach (SQLPackage childPackage in eaPackage.Packages) { this.currentNode = ePackageMocaNode.getChildNodeWithName(EPackageHelper.PackagesChildNodeName); processTggPackage(childPackage); } foreach (SQLElement childClass in eaPackage.Elements) { processTGGPackageFeatures(ePackageMocaNode, childClass); } return(ePackageMocaNode); }
public void processActivityNode(SQLElement activityNodeEAElement) { if (Serialization.MocaTaggableElement.isIgnored(activityNodeEAElement)) { return; } ActivityNode actNode = null; if (activityNodeEAElement.Stereotype == "StoryNode" || activityNodeEAElement.Elements.Count > 0 || (activityNodeEAElement.Elements.Count == 0 && activityNodeEAElement.Notes == "" && activityNodeEAElement.Subtype != 100 && activityNodeEAElement.Subtype != 101)) { actNode = new StoryNode(repository, activityNodeEAElement); } else if (activityNodeEAElement.Stereotype == "StopNode" || activityNodeEAElement.Subtype == 101) { actNode = new StopNode(repository, activityNodeEAElement); } else if (activityNodeEAElement.Stereotype == "StartNode" || activityNodeEAElement.Subtype == 100) { actNode = new StartNode(repository, activityNodeEAElement); } else if (activityNodeEAElement.Stereotype == "StatementNode" || (activityNodeEAElement.Elements.Count == 0 && activityNodeEAElement.Notes != "")) { actNode = new StatementNode(repository, activityNodeEAElement); } Boolean valid = actNode.loadTreeFromTaggedValue(); SQLTaggedValue mocaTreeTag = EAEcoreAddin.Util.EAUtil.findTaggedValue(activityNodeEAElement, Main.MoflonExportTreeTaggedValueName); MocaNode activityNodeMocaNode = new MocaNode(); activityNodeMocaNode.deserializeFromXmlTree(MocaTreeUtil.stringToXmlDocument(mocaTreeTag.Notes).DocumentElement.FirstChild as XmlElement); this.currentNode.appendChildNode(activityNodeMocaNode); foreach (SQLConnector activityEdge in activityNodeEAElement.Connectors) { if ((activityEdge.Stereotype == SDMModelingMain.ActivityEdgeStereotype || activityEdge.Stereotype == "") && activityEdge.Type == "ControlFlow" && activityEdge.ClientID == activityNodeEAElement.ElementID) { this.currentNode = activityNodeMocaNode.getChildNodeWithName(ActivityNode.OutgoingTransitionsNodeName); processActivityEdge(activityEdge); } } foreach (SQLElement storyNodeChild in activityNodeEAElement.Elements) { if (storyNodeChild.Stereotype == SDMModelingMain.ObjectVariableStereotype || storyNodeChild.Stereotype == "SDM_Object") { this.currentNode = activityNodeMocaNode.getChildNodeWithName(StoryPattern.ObjectVariablesChildNodeName); processObjectVariable(storyNodeChild); } else if (storyNodeChild.Stereotype == SDMModelingMain.CSPInstanceStereotype) { this.currentNode = activityNodeMocaNode.getChildNodeWithName("AttributeConstraints"); if (currentNode == null) { this.currentNode = activityNodeMocaNode.appendChildNode("AttributeConstraints"); } MocaNode cspNode = currentNode.appendChildNode("AttributeConstraint"); cspNode.appendChildAttribute("constraintSpec", storyNodeChild.Notes); SQLTaggedValue nacIndexTag = EAUtil.findTaggedValue(storyNodeChild, "nacIndex"); if (nacIndexTag != null) { String nacIndex = nacIndexTag.Value; cspNode.appendChildAttribute("nacIndex", nacIndex != "" ? nacIndex : "-1"); } } } }