public override List <String> doRule(SQLConnector eaConnector, SQLRepository repository) { List <String> results = new List <string>(); if (eaConnector.Type == ECOREModelingMain.EReferenceConnectorType) { SQLElement source = repository.GetElementByID(eaConnector.ClientID); SQLElement target = repository.GetElementByID(eaConnector.SupplierID); if (source.Stereotype == ECOREModelingMain.EClassStereotype || source.Stereotype == TGGModelingMain.TggCorrespondenceTypeStereotype || target.Stereotype == ECOREModelingMain.EClassStereotype || target.Stereotype == TGGModelingMain.TggCorrespondenceTypeStereotype) { SQLConnectorEnd targetEnd = eaConnector.SupplierEnd; SQLConnectorEnd sourceEnd = eaConnector.ClientEnd; if (targetEnd.Navigable == "Navigable" && targetEnd.Role == "") { results.Add("EReference: Navigable end must have a role name"); } if (sourceEnd.Navigable == "Navigable" && sourceEnd.Role == "") { results.Add("EReference: Navigable end must have a role name"); } } } return(results); }
public EReferenceEnd(SQLConnectorEnd eaConnectorEnd, SQLConnector connector, SQLRepository repository) { this.Repository = repository; this.EaConnector = connector; this.ConnectorEnd = eaConnectorEnd; this.Navigable = eaConnectorEnd.IsNavigable; }
public override List <string> doRule(SQLElement eaElement, SQLWrapperClasses.SQLRepository repository) { List <String> result = new List <string>(); if (eaElement.Stereotype == TGGModelingMain.TggCorrespondenceTypeStereotype) { List <SQLElement> baseClasses = EAUtil.getBaseClasses(eaElement); if (baseClasses.Count > 1) { foreach (SQLConnector con in eaElement.Connectors) { if (con.Type != Main.EAGeneralizationConType) { result.Add("Only the top level correspondence type in inheritance hierarchy should have connectors besides inheritance "); break; } } } else { int count = 0; bool valid = true; foreach (SQLConnector con in eaElement.Connectors) { if (con.Type == Main.EAAssociationType) { count++; SQLConnectorEnd rightEnd = null; SQLConnectorEnd wrongEnd = null; if (con.ClientID == eaElement.ElementID) { wrongEnd = con.ClientEnd; rightEnd = con.SupplierEnd; } else if (con.SupplierID == eaElement.ElementID) { wrongEnd = con.SupplierEnd; rightEnd = con.ClientEnd; } valid &= wrongEnd.Role == ""; valid &= !wrongEnd.IsNavigable; valid &= (rightEnd.Role == "source" || rightEnd.Role == "target"); valid &= rightEnd.IsNavigable; valid &= rightEnd.Cardinality == "1"; } } if (count != 2 || !valid) { result.Add("Correspondence type should only have source and target EReference with multiplicity 1"); } } } return(result); }
public override void doRuleQuickFix(SQLElement eaElement, SQLWrapperClasses.SQLRepository repository, int i, string errorMessage) { if (i == 0) { List <SQLConnector> toDelte = new List <SQLConnector>(); List <SQLElement> baseClasses = EAUtil.getBaseClasses(eaElement); if (baseClasses.Count > 1) { foreach (SQLConnector con in eaElement.Connectors) { if (con.Type != Main.EAGeneralizationConType) { toDelte.Add(con); } } } else { foreach (SQLConnector con in eaElement.Connectors) { if (con.Type == Main.EAAssociationType) { bool valid = true; SQLConnectorEnd rightEnd = null; SQLConnectorEnd wrongEnd = null; if (con.ClientID == eaElement.ElementID) { wrongEnd = con.ClientEnd; rightEnd = con.SupplierEnd; } else if (con.SupplierID == eaElement.ElementID) { wrongEnd = con.SupplierEnd; rightEnd = con.ClientEnd; } valid &= wrongEnd.Role == ""; valid &= !wrongEnd.IsNavigable; valid &= (rightEnd.Role == "source" || rightEnd.Role == "target"); valid &= rightEnd.IsNavigable; valid &= rightEnd.Cardinality == "1"; if (!valid) { toDelte.Add(con); } } } } foreach (EA.Connector toDeleteCon in toDelte) { EAUtil.deleteConnector(toDeleteCon, repository.GetOriginalRepository()); } } }
public override List <string> doRule(SQLElement eaElement, SQLWrapperClasses.SQLRepository repository) { List <String> results = new List <string>(); if (eaElement.Stereotype == ECOREModelingMain.EClassStereotype) { List <String> referenceNames = new List <string>(); foreach (SQLConnector con in eaElement.Connectors) { if (con.Type == ECOREModelingMain.EReferenceConnectorType) { SQLConnectorEnd otherEnd = null; if (con.ClientID == eaElement.ElementID) { otherEnd = con.SupplierEnd; } else { otherEnd = con.ClientEnd; } if (otherEnd.Role != "") { if (referenceNames.Contains(otherEnd.Role)) { results.Add("Two outgoing EReferences must not have the same"); } else { referenceNames.Add(otherEnd.Role); } } } } } return(results); }