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, ""); } } }
private bool tryOldDeserialize(Serialization.MocaTree.MocaNode actNode) { MocaNode adornmentsNode = actNode.getChildNodeWithName("allowedAddornments"); MocaNode modelgenAdornmentsNode = actNode.getChildNodeWithName("modelgenAdornments"); MocaNode parameterInformationNode = actNode.getChildNodeWithName("parameterInformation"); MocaNode parameterTypesNode = actNode.getChildNodeWithName("parameterTypes"); addNodeChildrenToList(adornmentsNode, adornments); addNodeChildrenToList(modelgenAdornmentsNode, modelgenAdornments); addNodeChildrenToList(parameterInformationNode, SignatureInformation); addNodeChildrenToList(parameterTypesNode, Signature); this.informationText = actNode.getAttributeOrCreate("constraintInformation").Value; if (this.informationText.Contains("\r\n")) { String[] splitted = this.informationText.Split("\r\n".ToCharArray()); this.informationText = splitted[splitted.Length - 1]; } this.UserDefined = actNode.getAttributeOrCreate("userDefined").Value == "true"; this.Name = actNode.getAttributeOrCreate("name").Value; MocaAttribute indexAttr = actNode.getAttributeOrCreate("index"); if (indexAttr.Value != "") { this.Index = int.Parse(indexAttr.Value); } return(true); }
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 override void deserializeFromMocaTree(Serialization.MocaTree.MocaNode actNode) { MocaAttribute guidAttr = actNode.getAttributeOrCreate(Main.GuidStringName); MocaAttribute typeGuidAttr = actNode.getAttributeOrCreate("typeGuid"); this.typeGuid = typeGuidAttr.Value; this.guid = actNode.getAttributeOrCreate(Main.GuidStringName).Value; this.returnType = actNode.getAttributeOrCreate("returnType").Value; this.Name = actNode.getAttributeOrCreate("name").Value; MocaNode parametersNode = actNode.getChildNodeWithName(EOperation.ParametersChildNodeName); foreach (MocaNode eParamNode in parametersNode.Children) { if (eParamNode.Name == "EParameter") { foreach (SQLParameter neededParam in this.EaMethod.Parameters) { if (neededParam.Name == eParamNode.getAttributeOrCreate("name").Value) { EParameter eParam = new EParameter(neededParam, Repository); eParam.deserializeFromMocaTree(eParamNode); this.EParameters.Add(eParam); } } } } //only for import purposes }
public override void deserializeFromMocaTree(Serialization.MocaTree.MocaNode actNode) { MocaAttribute valueAttribute = actNode.getAttributeOrCreate("value"); MocaAttribute datatypeAttribute = actNode.getAttributeOrCreate("datatype"); this.Value = valueAttribute.Value; this.Datatype = datatypeAttribute.Value; }
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 actNode) { base.deserializeFromMocaTree(actNode); MocaNode statement = actNode.getChildNodeWithName("statementExpression"); if (statement != null) { MocaAttribute typeAttribute = statement.getAttributeOrCreate("type"); if (typeAttribute != null) { this.StatementExpression = Expression.createExpression(typeAttribute.Value, this.Repository); this.StatementExpression.deserializeFromMocaTree(statement); } } }
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))); }
public override void deserializeFromMocaTree(MocaNode actNode) { this.attributeType = actNode.getAttributeOrCreate("type").Value; this.typeGuid = actNode.getAttributeOrCreate("typeGuid").Value; this.Name = actNode.getAttributeOrCreate("name").Value; this.guid = actNode.getAttributeOrCreate(Main.GuidStringName).Value; this.lowerBound = actNode.getAttributeOrCreate("lowerBound").Value; this.upperBound = actNode.getAttributeOrCreate("upperBound").Value; this.ordered = actNode.getAttributeOrCreate("ordered").Value; this.isId = actNode.getAttributeOrCreate("isId").Value != "" ? actNode.getAttributeOrCreate("isId").Value : "false"; this.isDerived = actNode.getAttributeOrCreate("isDerived").Value != "" ? actNode.getAttributeOrCreate("isDerived").Value : "false"; MocaAttribute defAttr = actNode.getAttributeOrCreate("defaultLiteralValue"); if (defAttr != null) { this.defaultString = defAttr.Value; } }
public override void deserializeFromMocaTree(Serialization.MocaTree.MocaNode actNode) { base.deserializeFromMocaTree(actNode); MocaNode returnValueNode = actNode.getChildNodeWithName("returnValue"); if (returnValueNode != null) { MocaAttribute typeAttribute = returnValueNode.getAttributeOrCreate("type"); Expression returnValueExpression = Expression.createExpression(typeAttribute.Value, this.Repository); if (returnValueExpression != null) { returnValueExpression.deserializeFromMocaTree(returnValueNode); } else { } this.ReturnValue = returnValueExpression; } }
private void setOvGuid(MocaNode actNode) { MocaNode tempNode = actNode.Parent; if (tempNode != null) { while (tempNode != null && tempNode.Name != typeof(ObjectVariable).Name && tempNode.Name != typeof(TGGObjectVariable).Name && tempNode.Name != typeof(TGGCorrespondence).Name) { tempNode = tempNode.Parent; } if (tempNode != null) { MocaAttribute guidAttr = tempNode.getAttributeOrCreate(Main.GuidStringName); if (guidAttr != null) { this.OvGuid = guidAttr.Value; } } } }
protected virtual void setOvName(MocaNode actNode) { MocaNode tempNode = actNode.Parent; if (tempNode != null) { while (tempNode != null && tempNode.Name != typeof(ObjectVariable).Name && tempNode.Name != typeof(TGGObjectVariable).Name && tempNode.Name != typeof(TGGCorrespondence).Name) { tempNode = tempNode.Parent; } if (tempNode != null) { MocaAttribute nameAttr = tempNode.getAttributeOrCreate("name"); if (nameAttr != null) { this.OvName = nameAttr.Value; } } } }
public override void deserializeFromMocaTree(Serialization.MocaTree.MocaNode actNode) { //for old moca trees tryOldDeserialize(actNode); MocaNode adornmentsNode = actNode.getChildNodeWithName(allowedAdornmentsNodeName); MocaNode modelgenAdornmentsNode = actNode.getChildNodeWithName(modelgenAdornmentsNodeName); MocaNode signatureNode = actNode.getChildNodeWithName(signatureNodeName); MocaNode signatureInformationNode = actNode.getChildNodeWithName(signatureInformationNodeName); addNodeChildrenToList(adornmentsNode, adornments); addNodeChildrenToList(modelgenAdornmentsNode, modelgenAdornments); addNodeChildrenToList(signatureNode, Signature); addNodeChildrenToList(signatureInformationNode, SignatureInformation); String infoValue = actNode.getAttributeOrCreate(informationTextNodeName).Value; if (infoValue != "") { this.informationText = infoValue; } String userDefinedValue = actNode.getAttributeOrCreate(userDefinedNodeName).Value; if (userDefinedValue != "") { this.UserDefined = userDefinedValue == "true"; } if (actNode.Name != "CSPConstraint") { this.Name = actNode.Name; } MocaAttribute indexAttr = actNode.getAttributeOrCreate(indexNodeName); if (indexAttr.Value != "") { this.Index = int.Parse(indexAttr.Value); } }
public override void deserializeFromMocaTree(Serialization.MocaTree.MocaNode actNode) { MocaNode operationsNode = actNode.getChildNodeWithName(EClass.OperationsChildNodeName); MocaNode attributesNode = actNode.getChildNodeWithName(EClass.AttributesChildNodeName); MocaAttribute guidAttr = actNode.getAttributeOrCreate(Main.GuidStringName); MocaAttribute nameAttr = actNode.getAttributeOrCreate("name"); MocaAttribute aliasAttr = actNode.getAttributeOrCreate("alias"); MocaAttribute isAbstractAttr = actNode.getAttributeOrCreate("isAbstract"); MocaAttribute isInterfaceAttr = actNode.getAttributeOrCreate("isInterface"); if (nameAttr != null) { this.Name = nameAttr.Value; } if (guidAttr != null) { this.Guid = guidAttr.Value; } if (aliasAttr != null) { this.Alias = aliasAttr.Value; } if (isAbstractAttr.Value != "") { if (bool.TryParse(isAbstractAttr.Value, out this.isAbstract)) { } else { int value = 0; if (int.TryParse(isAbstractAttr.Value, out value)) { this.isAbstract = value == 1; } } } if (isInterfaceAttr.Value != "") { this.isInterface = Boolean.Parse(isInterfaceAttr.Value); } foreach (MocaNode eOpNode in operationsNode.Children) { SQLMethod method = findMethodFromMocaNode(this.EaElement, eOpNode); if (method != null) { EOperation actEOperation = new EOperation(method, Repository); actEOperation.deserializeFromMocaTree(eOpNode); this.EOperations.Add(actEOperation); } } foreach (MocaNode eAttrNode in attributesNode.Children) { foreach (SQLAttribute attr in this.EaElement.Attributes) { if (attr.Name == eAttrNode.getAttributeOrCreate("name").Value) { EAttribute eAttr = new EAttribute(attr, Repository); eAttr.deserializeFromMocaTree(eAttrNode); this.EAttributes.Add(eAttr); } } } isInitialized = true; }
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); }
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; } } }