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); } } }
private bool validateFirstObject(String selectedExpressionString, int firtObjectClassifierId) { bool valid = false; if (methodParameterClassifierIdFilter != -1 && methodParameterClassifierIdFilter != 0) { if (selectedExpressionString == "ObjectVariableExpression" || selectedExpressionString == "ParameterExpression") { try { //is object classifier == method parameter classifier, we can skip the base class detection if (firtObjectClassifierId == methodParameterClassifierIdFilter) { valid = true; } //is the object classifier contained in the method parameter classifier type hierarchy? else { SQLElement methodClassifier = EAUtil.getClassifierElement(repository, methodParameterClassifierIdFilter); if (methodClassifier != null) { //all targets are valid for EObject parameters if (methodClassifier.Name == "EObject") { valid = true; } } if (!valid) { SQLElement classifierFilter = repository.GetElementByID(firtObjectClassifierId); List <SQLElement> baseClasses = EAUtil.getBaseClasses(classifierFilter); foreach (SQLElement baseClass in baseClasses) { if (baseClass.ElementID == methodParameterClassifierIdFilter) { valid = true; } } } } } catch (COMException) { } } //other expression is used. do not filter it else { valid = true; } } else { valid = true; } return(valid); }
public override List <String> doRule(SQLElement eaElement, SQLRepository repository) { List <String> results = new List <string>(); if (eaElement.Stereotype == SDMModelingMain.ObjectVariableStereotype || eaElement.Stereotype == "SDM_Object" || eaElement.Stereotype == TGGModelingMain.TggObjectVariableStereotype || eaElement.Stereotype == TGGModelingMain.TggCorrespondenceStereotype) { SQLElement classifier = EAUtil.getClassifierElement(repository, eaElement.ClassifierID); if (classifier == null) { results.Add("must have a valid classifier"); } } return(results); }
public override List <String> doRule(SQLElement eaElement, SQLWrapperClasses.SQLRepository repository) { List <String> results = new List <string>(); if (eaElement.Stereotype == TGGModelingMain.TggCorrespondenceStereotype) { SQLPackage containingPackage = EAUtil.getOutermostPackage(eaElement, repository); SQLElement correspondenceTypeElement = EAUtil.getClassifierElement(repository, eaElement.ClassifierID); SQLPackage corrTypeContainingPackage = EAUtil.getOutermostPackage(correspondenceTypeElement, repository); if (correspondenceTypeElement != null && containingPackage.PackageGUID != corrTypeContainingPackage.PackageGUID) { results.Add("the correspondence classifier is not located in the current tgg package"); } } return(results); }
public override List <SecondObject> getSecondObjects(Object targetObject, SQLRepository repository) { Object targetElement = targetObject; List <SecondObject> sourceMethods = new List <SecondObject>(); SQLElement realClassifier = null; List <SQLElement> allClasses = new List <SQLElement>(); if (targetObject is SQLElement) { realClassifier = EAUtil.getClassifierElement(repository, (targetObject as SQLElement).ClassifierID); } else if (targetElement is SQLParameter) { if ((targetObject as SQLParameter).ClassifierID != "0" && (targetObject as SQLParameter).ClassifierID != "") { try { realClassifier = repository.GetElementByID(int.Parse((targetObject as SQLParameter).ClassifierID)); } catch { realClassifier = null; } } } if (realClassifier != null) { allClasses = EAUtil.getBaseClasses(realClassifier); foreach (SQLElement actClass in allClasses) { foreach (SQLMethod method in actClass.Methods) { SecondObject sObject = new SecondObject(method); sourceMethods.Add(sObject); } } sourceMethods.Sort(new EAObjectIComparer()); } return(sourceMethods); }
public void computeAttributes() { SQLElement classifier = EAUtil.getClassifierElement(Repository, this.EaAttribute.ClassifierID); if (classifier != null) { this.typeGuid = classifier.ElementGUID; } else { String ecoreAdress = PersistencyUtil.getReferenceToBuiltInEcoreType(this.Type); } lowerBound = this.EaAttribute.LowerBound == "*" ? "-1" : this.EaAttribute.LowerBound; if (lowerBound == "") { lowerBound = "0"; } upperBound = this.EaAttribute.UpperBound == "*" ? "-1" : this.EaAttribute.UpperBound; if (upperBound == "") { upperBound = "1"; } if (this.EaAttribute.IsOrdered) { this.ordered = "true"; } if (this.EaAttribute.IsDerived) { this.isDerived = "true"; } if (this.EaAttribute.getRealAttribute().IsID) { this.isId = "true"; } }
public AddPostProcessForm(SQLRepository repository) { InitializeComponent(); this.parameterNames = new List <string>(); this.selectedObjects = new List <SQLElement>(); this.checkBoxToElement = new Dictionary <CheckBox, SQLElement>(); this.elementToClassifier = new Dictionary <SQLElement, SQLElement>(); this.repository = repository; initialSettings(); EA.Diagram currentDiagram = repository.GetCurrentDiagram(); if (currentDiagram.ParentID != 0) { this.tggRuleElement = repository.GetOriginalRepository().GetElementByID(currentDiagram.ParentID); foreach (EA.DiagramObject diagObject in currentDiagram.SelectedObjects) { SQLElement selectedElement = repository.GetElementByID(diagObject.ElementID); if (selectedElement.MetaType == SDMModelingMain.ObjectVariableStereotype) { this.selectedObjects.Add(selectedElement); SQLElement classifier = EAUtil.getClassifierElement(repository, selectedElement.ClassifierID); if (classifier != null) { this.elementToClassifier.Add(selectedElement, classifier); addEntry(classifier, selectedElement); } } } updateThisSize(); this.ShowDialog(); } }
public override List <SecondObject> getSecondObjects(Object targetObject, SQLRepository repository) { Object targetElement = targetObject; List <SecondObject> sourceAttributes = new List <SecondObject>(); SQLElement realClassifier = null; List <SQLElement> allClasses = new List <SQLElement>(); if (targetObject is SQLElement) { SQLElement tempElement = targetObject as SQLElement; realClassifier = EAUtil.getClassifierElement(repository, tempElement.ClassifierID); } else if (targetElement is SQLParameter) { SQLParameter targetParameter = targetObject as SQLParameter; if (targetParameter.ClassifierID != "0" && targetParameter.ClassifierID != "") { realClassifier = repository.GetElementByID(int.Parse((targetObject as EA.Parameter).ClassifierID)); } } if (realClassifier != null) { allClasses = EAUtil.getBaseClasses(realClassifier); foreach (SQLElement actClass in allClasses) { foreach (SQLAttribute attribute in actClass.Attributes) { SecondObject sObject = new SecondObject(attribute); sourceAttributes.Add(sObject); } } sourceAttributes.Sort(new EAObjectIComparer()); } return(sourceAttributes); }
public override List <String> doRule(SQLConnector eaConnector, SQLWrapperClasses.SQLRepository repository) { List <String> results = new List <string>(); if (eaConnector.Stereotype == SDMModelingMain.LinkVariableStereotype || eaConnector.Stereotype == TGGModelingMain.TggLinkVariableStereotype) { LinkVariable lv = new LinkVariable(eaConnector, repository); lv.loadTreeFromTaggedValue(); SQLConnector referencedReference = SDMUtil.getRelatedEReference(lv); //try to get the related EReference //related EReference cant be found if (referencedReference == null) { results.Add("There is no related EReference"); } //rolename of linkVariable not existing in the referenced EReference if (eaConnector.SupplierEnd.Role != "" && referencedReference != null) { if (!((eaConnector.SupplierEnd.Role == referencedReference.ClientEnd.Role || eaConnector.SupplierEnd.Role == referencedReference.SupplierEnd.Role) && (eaConnector.ClientEnd.Role == referencedReference.ClientEnd.Role || eaConnector.ClientEnd.Role == referencedReference.SupplierEnd.Role))) { results.Add("The rolename(s) of the LinkVariable differs from the related EReference"); } } //for unidirectional EReferences the supplierEnd.Role of the linkvariable must be the "value" rolename if (eaConnector.ClientEnd.Role != "" && eaConnector.SupplierEnd.Role == "") { results.Add("The rolename(s) of the LinkVariable differs from the related EReference"); } //checks if the related reference is connecting the correct EClasses if (referencedReference != null) { try { SQLElement lvSource = repository.GetElementByID(eaConnector.ClientID); SQLElement lvTarget = repository.GetElementByID(eaConnector.SupplierID); SQLElement sourceClassifier = EAUtil.getClassifierElement(repository, lvSource.ClassifierID); SQLElement targetClassifier = EAUtil.getClassifierElement(repository, lvTarget.ClassifierID); SQLElement refRefClient = repository.GetElementByID(referencedReference.ClientID); SQLElement refRefSupplier = repository.GetElementByID(referencedReference.SupplierID); if (sourceClassifier != null && targetClassifier != null) { List <SQLElement> sourceBases = EAUtil.getBaseClasses(sourceClassifier); List <SQLElement> targetBases = EAUtil.getBaseClasses(targetClassifier); Boolean valid = false; foreach (SQLElement sourceBase in sourceBases) { foreach (SQLElement targetBase in targetBases) { if (((referencedReference.ClientID == sourceBase.ElementID || referencedReference.ClientID == targetBase.ElementID) && (referencedReference.SupplierID == sourceBase.ElementID || referencedReference.SupplierID == targetBase.ElementID))) { valid = true; } } } //maybe there is a direct connectio to EObject if (!valid) { if (refRefClient.Name == "EObject" && (eaConnector.SupplierEnd.Role == referencedReference.SupplierEnd.Role || eaConnector.SupplierEnd.Role == referencedReference.ClientEnd.Role) || refRefSupplier.Name == "EObject" && (eaConnector.SupplierEnd.Role == referencedReference.SupplierEnd.Role || eaConnector.SupplierEnd.Role == referencedReference.ClientEnd.Role)) { valid = true; } } if (!valid) { results.Add("The related EReference doesn't connect EClasses from the same type hiearchy as the LinkVariable"); } } } catch { results.Add("Error during computing of related EReference. Please update your LinkVariable manually"); } } } return(results); }
private void addPossibleLinks() { SQLElement clientClassifier = EAUtil.getClassifierElement(repository, lvClient.ClassifierID); SQLElement supplierClassifier = EAUtil.getClassifierElement(repository, lvSupplier.ClassifierID); if (clientClassifier != null && supplierClassifier != null) { List <SQLConnector> clientToSupplierAssociations = new List <SQLConnector>(); List <SQLConnector> supplierToClientAssociations = new List <SQLConnector>(); collectPossibleAssociations(ref clientClassifier, ref supplierClassifier, ref clientToSupplierAssociations, ref supplierToClientAssociations, ref this.repository); foreach (SQLConnector possibleAssociation in clientToSupplierAssociations) { LinkDialogueEntry linkDialogueEntry = new LinkDialogueEntry(); linkDialogueEntry.CorrespondingConnectorGuid = possibleAssociation.ConnectorGUID; EA.Element associationClient = repository.GetOriginalRepository().GetElementByID(possibleAssociation.ClientID); EA.Element associationSupplier = repository.GetOriginalRepository().GetElementByID(possibleAssociation.SupplierID); if (possibleAssociation.Direction == "Bi-Directional") { linkDialogueEntry.output = (lvClient.Name + ":" + associationClient.Name + " <--(" + possibleAssociation.ClientEnd.Role + ") - (" + possibleAssociation.SupplierEnd.Role + ")--> " + lvSupplier.Name + ":" + associationSupplier.Name); linkDialogueEntry.direction = LinkDialogueEntryDirection.BI; linkDialogueEntry.clientRoleName = possibleAssociation.ClientEnd.Role; linkDialogueEntry.supplierRoleName = possibleAssociation.SupplierEnd.Role; } else if (possibleAssociation.Direction == Main.EASourceTargetDirection) { linkDialogueEntry.output = (lvClient.Name + ":" + associationClient.Name + " --(" + possibleAssociation.SupplierEnd.Role + ")--> " + lvSupplier.Name + ":" + associationSupplier.Name); linkDialogueEntry.direction = LinkDialogueEntryDirection.RIGHT; linkDialogueEntry.supplierRoleName = possibleAssociation.SupplierEnd.Role; } else if (possibleAssociation.Direction == Main.EATargetSourceDirection) { linkDialogueEntry.output = (lvClient.Name + ":" + associationClient.Name + " <--(" + possibleAssociation.ClientEnd.Role + ")-- " + lvSupplier.Name + ":" + associationSupplier.Name); linkDialogueEntry.OutputOpposite = (lvSupplier.Name + ":" + associationSupplier.Name + " --(" + possibleAssociation.ClientEnd.Role + ")--> " + lvClient.Name + ":" + associationClient.Name); linkDialogueEntry.direction = LinkDialogueEntryDirection.LEFT; linkDialogueEntry.supplierRoleName = possibleAssociation.ClientEnd.Role; } if (linkDialogueEntry.output != null) { linkDialogueEntries.Add(linkDialogueEntry); listboxLinks.Items.Add(linkDialogueEntry.output); } } foreach (SQLConnector possibleAssociation in supplierToClientAssociations) { LinkDialogueEntry linkDialogueEntry = new LinkDialogueEntry(); linkDialogueEntry.CorrespondingConnectorGuid = possibleAssociation.ConnectorGUID; EA.Element associationClient = repository.GetOriginalRepository().GetElementByID(possibleAssociation.ClientID); EA.Element associationSupplier = repository.GetOriginalRepository().GetElementByID(possibleAssociation.SupplierID); if (possibleAssociation.Direction == "Bi-Directional") { linkDialogueEntry.output = (lvClient.Name + ":" + associationSupplier.Name + " <--(" + possibleAssociation.SupplierEnd.Role + ") - (" + possibleAssociation.ClientEnd.Role + ")--> " + lvSupplier.Name + ":" + associationClient.Name); linkDialogueEntry.direction = LinkDialogueEntryDirection.BI; linkDialogueEntry.clientRoleName = possibleAssociation.SupplierEnd.Role; linkDialogueEntry.supplierRoleName = possibleAssociation.ClientEnd.Role; } else if (possibleAssociation.Direction == Main.EASourceTargetDirection) { linkDialogueEntry.output = (lvClient.Name + ":" + associationSupplier.Name + " <--(" + possibleAssociation.SupplierEnd.Role + ")-- " + lvSupplier.Name + ":" + associationClient.Name); linkDialogueEntry.OutputOpposite = (lvSupplier.Name + ":" + associationClient.Name + " --(" + possibleAssociation.SupplierEnd.Role + ")--> " + lvClient.Name + ":" + associationSupplier.Name); linkDialogueEntry.direction = LinkDialogueEntryDirection.LEFT; linkDialogueEntry.supplierRoleName = possibleAssociation.SupplierEnd.Role; } else if (possibleAssociation.Direction == Main.EATargetSourceDirection) { linkDialogueEntry.output = (lvClient.Name + ":" + associationSupplier.Name + " --(" + possibleAssociation.ClientEnd.Role + ")--> " + lvSupplier.Name + ":" + associationClient.Name); linkDialogueEntry.direction = LinkDialogueEntryDirection.RIGHT; linkDialogueEntry.supplierRoleName = possibleAssociation.ClientEnd.Role; } if (linkDialogueEntry.output != null) { linkDialogueEntries.Add(linkDialogueEntry); listboxLinks.Items.Add(linkDialogueEntry.output); } } setListBoxSize(); } }