private void loadCSPConstraints(MocaNode actNode) { MocaNode constraintsNode = actNode.getChildNodeWithName(ConstraintsChildNodeName); if (constraintsNode != null) { Constraints.Clear(); foreach (MocaNode constraintNode in actNode.getChildNodeWithName(ConstraintsChildNodeName).Children) { if (constraintNode.Name == DeclarationsChildNodeName) { foreach (MocaNode constraintNodeReal in constraintNode.Children) { CSPConstraint newConstr = new CSPConstraint(); newConstr.deserializeFromMocaTree(constraintNodeReal); this.Constraints.Add(newConstr); } } else if (constraintNode.Name == ConstraintInstancesChildNodeName) { } else { CSPConstraint newConstr = new CSPConstraint(); newConstr.deserializeFromMocaTree(constraintNode); this.Constraints.Add(newConstr); } } } CSPUtil.addDefaultConstraints(Constraints); this.Constraints.Sort(new CSPConstraintComparer()); CSPUtil.recomputeConstraintIndizes(Constraints); }
public SQLMethod findMethodFromMocaNode(SQLElement parent, MocaNode methodNode) { SQLMethod found = null; foreach (SQLMethod method in parent.Methods) { int validCount = 0; if (method.Name == methodNode.getAttributeOrCreate("name").Value) { foreach (SQLParameter param in method.Parameters) { foreach (MocaNode paramNode in methodNode.getChildNodeWithName(EOperation.ParametersChildNodeName).Children) { if (paramNode.getAttributeOrCreate("name").Value == param.Name) { validCount++; } } } if (validCount == method.Parameters.Count && validCount == methodNode.getChildNodeWithName(EOperation.ParametersChildNodeName).Children.Count) { found = method; } } } return(found); }
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 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 importEPackageFeatures(MocaNode ePackageNode, SQLPackage modelPackage) { foreach (MocaNode eclassNode in ePackageNode.getChildNodeWithName(EPackageHelper.ClassesChildNodeName).Children) { if (eclassNode.Name == ECOREModelingMain.EClassStereotype) { importEClass(modelPackage, eclassNode); } else if (eclassNode.Name == ECOREModelingMain.EDatatypeStereotype) { importEDatatype(modelPackage, eclassNode); } else if (eclassNode.Name == ECOREModelingMain.EEnumStereotype) { importEEnum(modelPackage, eclassNode); } } foreach (MocaNode packageNode in ePackageNode.getChildNodeWithName(EPackageHelper.PackagesChildNodeName).Children) { if (packageNode.Name == ECOREModelingMain.EPackageStereotype) { importEPackage(packageNode, modelPackage); } } }
private void processTGGPackageFeatures(MocaNode ePackageMocaNode, SQLElement childClass) { if (childClass.Stereotype == TGGModelingMain.TggCorrespondenceTypeStereotype) { this.currentNode = ePackageMocaNode.getChildNodeWithName(EPackageHelper.ClassesChildNodeName); processTGGCorrespondenceType(childClass); } else if (childClass.Stereotype == TGGModelingMain.TggRuleSetStereotype) { foreach (SQLElement childElement in childClass.Elements) { processTGGPackageFeatures(ePackageMocaNode, childElement); } } else if (childClass.Stereotype == TGGModelingMain.TggRuleStereotype) { MocaNode rulesNode = ePackageMocaNode.getChildNodeWithName(TGGRulePackage.RulesChildNodeName); if (rulesNode == null) { rulesNode = ePackageMocaNode.appendChildNode(TGGRulePackage.RulesChildNodeName); } this.currentNode = rulesNode; processTggRule(childClass); } else if (childClass.Stereotype == ECOREModelingMain.EClassStereotype) { ExportMain.ecoreExport.currentNode = new MocaNode(); this.currentNode = ePackageMocaNode.getChildNodeWithName(EPackageHelper.ClassesChildNodeName); currentNode.appendChildNode(ExportMain.ecoreExport.processEClass(childClass)); } }
private void importActivityNode(SQLElement sdmContainer, MocaNode activityNodeNode) { EA.Element activityNodeElement = null; ActivityNode aNode = null; if (activityNodeNode.getAttributeOrCreate("type").Value == "start") { activityNodeElement = MainImport.getInstance().EcoreImport.getOrCreateElement(sdmContainer, activityNodeNode, Main.EAStateNodeType, Main.EAStartNodeSubtype); aNode = new StartNode(sqlRep, sqlRep.GetElementByID(activityNodeElement.ElementID)); } else if (activityNodeNode.getAttributeOrCreate("type").Value == "stop") { activityNodeElement = MainImport.getInstance().EcoreImport.getOrCreateElement(sdmContainer, activityNodeNode, Main.EAStateNodeType, Main.EAStopNodeSubtype); aNode = new StopNode(sqlRep, sqlRep.GetElementByID(activityNodeElement.ElementID)); } else if (activityNodeNode.getAttributeOrCreate("type").Value == "statement") { activityNodeElement = MainImport.getInstance().EcoreImport.getOrCreateElement(sdmContainer, activityNodeNode, Main.EAActivityType); aNode = new StatementNode(sqlRep, sqlRep.GetElementByID(activityNodeElement.ElementID)); } else if (activityNodeNode.getAttributeOrCreate("type").Value == "story") { activityNodeElement = MainImport.getInstance().EcoreImport.getOrCreateElement(sdmContainer, activityNodeNode, Main.EAActivityType); appendSdmDiagram(activityNodeElement.Name, activityNodeElement); aNode = new StoryNode(sqlRep, sqlRep.GetElementByID(activityNodeElement.ElementID)); } MocaNode outgoingEdgesNode = activityNodeNode.getChildNodeWithName(ActivityNode.OutgoingTransitionsNodeName); if (outgoingEdgesNode != null) { foreach (MocaNode outgoingEdgeNode in outgoingEdgesNode.Children) { MainImport.getInstance().ConnectorNodeToParent.Add(outgoingEdgeNode, activityNodeElement); } } MocaNode objectVariablesNode = activityNodeNode.getChildNodeWithName(StoryPattern.ObjectVariablesChildNodeName); if (objectVariablesNode != null) { foreach (MocaNode ovNode in objectVariablesNode.Children) { importObjectVariable(sqlRep.GetElementByID(activityNodeElement.ElementID), ovNode); } } aNode.deserializeFromMocaTree(activityNodeNode); MainImport.getInstance().ElementGuidToElement.Add(activityNodeElement.ElementGUID, activityNodeElement); MainImport.getInstance().OldGuidToNewGuid.Add(aNode.EaGuid, activityNodeElement.ElementGUID); MainImport.getInstance().MocaTaggableElements.Add(aNode); }
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); }
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 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 override MocaNode serializeToMocaTree() { EClass dummyEClass = new EClass(this.rule, Repository); dummyEClass.computeFeatures(); MocaNode ruleNode = dummyEClass.serializeToMocaTree(); ruleNode.Name = "Rule"; MocaNode operationsNode = ruleNode.getChildNodeWithName(EClass.OperationsChildNodeName); MocaNode toDelete = null; if (operationsNode != null) { foreach (MocaNode node in operationsNode.Children) { MocaAttribute nameAttr = node.getAttributeOrCreate("name"); if (nameAttr != null && nameAttr.Value == this.Name) { toDelete = node; } } } if (toDelete != null) { operationsNode.Children.Remove(toDelete); } ruleNode.appendChildAttribute(TGGRule.CspSpecAttributeName, ""); ruleNode.appendChildAttribute("refines", ""); ruleNode.appendChildAttribute("baseClasses", ""); ruleNode.appendChildNode(StoryPattern.ObjectVariablesChildNodeName); return(ruleNode); }
public ObjectVariable importObjectVariable(SQLElement storyNode, MocaNode ovNode) { EA.Element ovElement = MainImport.getInstance().EcoreImport.getOrCreateElement(storyNode, ovNode, Main.EAObjectType); MocaNode outgoingLinksNode = ovNode.getChildNodeWithName(ObjectVariable.OutgoingLinksNodeName); if (outgoingLinksNode != null) { foreach (MocaNode outgoingLinkNode in outgoingLinksNode.Children) { MainImport.getInstance().ConnectorNodeToParent.Add(outgoingLinkNode, ovElement); } } ObjectVariable ov = new ObjectVariable(sqlRep.GetElementByID(ovElement.ElementID), sqlRep); ov.deserializeFromMocaTree(ovNode); MainImport.getInstance().MocaTaggableElements.Add(ov); MainImport.getInstance().ElementGuidToElement.Add(ovElement.ElementGUID, ovElement); MainImport.getInstance().OldGuidToNewGuid.Add(ov.Guid, ovElement.ElementGUID); MainImport.getInstance().ObjectToTypeGuid.Add(ovElement, ov.TypeGuid); return(ov); }
public void importTGGFeatures(MocaNode ePackageNode, SQLPackage modelPackage) { foreach (MocaNode eclassNode in ePackageNode.getChildNodeWithName(EPackageHelper.ClassesChildNodeName).Children) { if (eclassNode.Name == TGGModelingMain.TggCorrespondenceTypeStereotype) { importCorrespondenceType(modelPackage, eclassNode); } } foreach (MocaNode packageNode in ePackageNode.getChildNodeWithName(EPackageHelper.PackagesChildNodeName).Children) { if (packageNode.Name == TGGModelingMain.TggRulePackageStereotype) { importRulePackage(modelPackage, packageNode); } } }
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 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); }
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); }
private void importEEnum(SQLPackage parentPackage, MocaNode eEnumNode) { EA.Element eenumElement = getOrCreateElement(parentPackage, eEnumNode, "Enumeration"); foreach (MocaNode literalNode in eEnumNode.getChildNodeWithName("literals").Children) { String literalName = literalNode.getAttributeOrCreate("name").Value; if (literalName != "" && !literalExist(eenumElement, literalName)) { EA.Attribute literalAtt = eenumElement.Attributes.AddNew(literalName, "") as EA.Attribute; literalAtt.Update(); } } eenumElement.Attributes.Refresh(); EEnum eenum = new EEnum(sqlRep.GetElementByID(eenumElement.ElementID), sqlRep); eenum.deserializeFromMocaTree(eEnumNode); MainImport.getInstance().ElementGuidToElement.Add(eenumElement.ElementGUID, eenumElement); MainImport.getInstance().MocaTaggableElements.Add(eenum); MainImport.getInstance().OldGuidToNewGuid.Add(eenum.Guid, eenumElement.ElementGUID); }
public override void addAttributesDuringExport(MocaNode pkgNode) { base.addAttributesDuringExport(pkgNode); List <CSPConstraint> tempList = new List <CSPConstraint>(); CSPUtil.addDefaultConstraints(tempList); MocaNode constraintRootNode = pkgNode.getChildNodeWithName(ConstraintsChildNodeName); if (constraintRootNode != null) { MocaNode declarationsRootNode = constraintRootNode.getChildNodeWithName(DeclarationsChildNodeName); if (declarationsRootNode != null) { foreach (CSPConstraint constr in tempList) { MocaNode constraintNode = declarationsRootNode.appendChildNode(""); constr.serializeToMocaTree(constraintNode); } } } }
public EClass importEClassFeatures(MocaNode eClassNode, SQLElement eclassElem) { MocaNode operationsNode = eClassNode.getChildNodeWithName(EClass.OperationsChildNodeName); MocaNode attributesNode = eClassNode.getChildNodeWithName(EClass.AttributesChildNodeName); MocaNode refsNode = eClassNode.getChildNodeWithName(EClass.ReferencesChildNodeName); foreach (MocaNode eOpNode in operationsNode.Children) { EA.Method eaMethod = getOrCreateMethod(eclassElem, eOpNode); foreach (MocaNode eParamNode in eOpNode.getChildNodeWithName(EOperation.ParametersChildNodeName).Children) { if (eParamNode.Name == "EParameter") { EA.Parameter eaParam = getOrCreateParameter(eaMethod, eParamNode); } } eaMethod.Parameters.Refresh(); MocaNode sdmActivityNode = eOpNode.getChildNodeWithName("Activity"); if (sdmActivityNode != null) { MainImport.getInstance().SdmImport.importSDMActivity(eclassElem, sqlRep.GetMethodByID(eaMethod.MethodID), sdmActivityNode); } } foreach (MocaNode eAttrNode in attributesNode.Children) { EA.Attribute eAttribute = getOrCreateAttribute(eclassElem, eAttrNode);; eAttribute.Update(); } if (refsNode.Children.Count != 0) { MainImport.getInstance().ConnectorNodeToParent.Add(refsNode, eclassElem.getRealElement()); } eclassElem.Attributes.Refresh(); eclassElem.Methods.Refresh(); EClass eclass = new EClass(sqlRep.GetElementByID(eclassElem.ElementID), sqlRep); eclass.deserializeFromMocaTree(eClassNode); foreach (EAttribute eattr in eclass.EAttributes) { if (eattr.typeGuid != "") { MainImport.getInstance().ObjectToTypeGuid.Add(eattr.EaAttribute.getRealAttribute(), eattr.typeGuid); } MainImport.getInstance().OldGuidToNewGuid.Add(eattr.guid, eattr.EaAttribute.AttributeGUID); } foreach (EOperation eOp in eclass.EOperations) { if (eOp.typeGuid != "") { MainImport.getInstance().ObjectToTypeGuid.Add(eOp.EaMethod.getRealMethod(), eOp.typeGuid); } MainImport.getInstance().OldGuidToNewGuid.Add(eOp.guid, eOp.EaMethod.MethodGUID); foreach (EParameter eParam in eOp.EParameters) { if (eParam.typeGuid != "") { MainImport.getInstance().ObjectToTypeGuid.Add(eParam.EaParameter.getRealParameter(), eParam.typeGuid); } MainImport.getInstance().OldGuidToNewGuid.Add(eParam.Guid, eParam.EaParameter.ParameterGUID); } } if (eClassNode.getAttributeOrCreate("baseClasses").Value != "") { MainImport.getInstance().ElementToBaseClassGuids.Add(eclassElem.getRealElement(), eClassNode.getAttributeOrCreate("baseClasses").Value); } MainImport.getInstance().ElementGuidToElement.Add(eclassElem.ElementGUID, eclassElem.getRealElement()); MainImport.getInstance().MocaTaggableElements.Add(eclass); MainImport.getInstance().OldGuidToNewGuid.Add(eclass.Guid, eclassElem.ElementGUID); return(eclass); }
private void importRule(SQLPackage modelPackage, MocaNode ruleNode) { EA.Element ruleElement = MainImport.getInstance().EcoreImport.getOrCreateElement(modelPackage, ruleNode, Main.EAClassType); if (ruleElement.Diagrams.Count == 0) { EA.Diagram ruleDiagram = ruleElement.Diagrams.AddNew(ruleElement.Name, TGGModelingMain.TggRuleDiagramMetatype[0]) as EA.Diagram; ruleDiagram.Update(); MainImport.getInstance().DiagramsToBeFilled.Add(ruleDiagram); } EA.Method mainMethod = MainImport.getInstance().EcoreImport.getOrCreateMethod(sqlRep.GetElementByID(ruleElement.ElementID), ruleNode.getAttributeOrCreate("mainMethodGuid").Value, ruleElement.Name, ""); MocaNode parametersNode = ruleNode.getChildNodeWithName(EOperation.ParametersChildNodeName); if (parametersNode != null) { foreach (MocaNode paramNode in parametersNode.Children) { EA.Parameter parameter = MainImport.getInstance().EcoreImport.getOrCreateParameter(mainMethod, paramNode); MainImport.getInstance().OldGuidToNewGuid.Add(paramNode.getAttributeOrCreate(Main.GuidStringName).Value, parameter.ParameterGUID); } } EClass eClass = MainImport.getInstance().EcoreImport.importEClassFeatures(ruleNode, sqlRep.GetElementByID(ruleElement.ElementID)); MainImport.getInstance().MocaTaggableElements.Remove(eClass); TGGRule rule = new TGGRule(sqlRep, sqlRep.GetElementByID(ruleElement.ElementID)); rule.deserializeFromMocaTree(ruleNode); MainImport.getInstance().MocaTaggableElements.Add(rule); foreach (MocaNode ovNode in ruleNode.getChildNodeWithName(StoryPattern.ObjectVariablesChildNodeName).Children) { if (ovNode.Name == TGGModelingMain.TggObjectVariableStereotype) { ObjectVariable ov = MainImport.getInstance().SdmImport.importObjectVariable(sqlRep.GetElementByID(ruleElement.ElementID), ovNode); MainImport.getInstance().MocaTaggableElements.Remove(ov); ov = new TGGObjectVariable(ov.sqlElement, sqlRep); ov.deserializeFromMocaTree(ovNode); MainImport.getInstance().MocaTaggableElements.Add(ov); } else if (ovNode.Name == TGGCorrespondence.CorrespondenceNodeName) { ObjectVariable ov = MainImport.getInstance().SdmImport.importObjectVariable(sqlRep.GetElementByID(ruleElement.ElementID), ovNode); MainImport.getInstance().MocaTaggableElements.Remove(ov); ov = new TGGCorrespondence(ov.sqlElement, sqlRep); ov.deserializeFromMocaTree(ovNode); MainImport.getInstance().MocaTaggableElements.Add(ov); } } MocaNode cspsNode = ruleNode.getChildNodeWithName(TGGRule.CspsChildNodeName); if (cspsNode != null) { foreach (MocaNode cspInstanceNode in cspsNode.Children) { importTGGCSP(sqlRep.GetElementByID(ruleElement.ElementID), cspInstanceNode); } } else { if (ruleNode.getAttributeOrCreate(TGGRule.CspSpecAttributeName).Value != "") { EA.Element constraintElement = ruleElement.Elements.AddNew("", Main.EAClassType) as EA.Element; constraintElement.Stereotype = TGGModelingMain.CSPConstraintStereotype; constraintElement.Notes = ruleNode.getAttributeOrCreate(TGGRule.CspSpecAttributeName).Value; constraintElement.Update(); CSPInstance cspInstance = new CSPInstance(sqlRep, sqlRep.GetElementByID(constraintElement.ElementID)); cspInstance.CspStringValueFromImport = ruleNode.getAttributeOrCreate(TGGRule.CspSpecAttributeName).Value; MainImport.getInstance().MocaTaggableElements.Add(cspInstance); } } }
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; } } }
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"); } } } }
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); }