public override void doRuleQuickFix(SQLConnector eaConnector, SQLWrapperClasses.SQLRepository repository, int i, string errorMessage) { if (i == 0) { EA.Element ownerElement = null; try { ownerElement = repository.GetOriginalRepository().GetElementByID(eaConnector.ClientID); } catch { try { ownerElement = repository.GetOriginalRepository().GetElementByID(eaConnector.SupplierID); } catch { } } if (ownerElement != null) { short z = 0; foreach (EA.Connector con in ownerElement.Connectors) { if (con.ConnectorGUID == eaConnector.ConnectorGUID) { ownerElement.Connectors.DeleteAt(z, true); break; } z++; } } } }
public override List <String> doRule(SQLElement eaElement, SQLWrapperClasses.SQLRepository repository) { List <String> results = new List <string>(); if (MocaTaggableElement.isIgnored(eaElement)) { return(results); } if (eaElement.Stereotype == SDMModelingMain.StatementNodeStereotype || eaElement.Stereotype == SDMModelingMain.StoryNodeStereotype || eaElement.Stereotype == SDMModelingMain.StopNodeStereotype) { int incomingCount = 0; foreach (SQLConnector edge in eaElement.Connectors) { if (edge.SupplierID == eaElement.ElementID) { incomingCount++; } } if (incomingCount == 0) { results.Add("At least one incoming Edge is needed"); } } return(results); }
public override Dictionary <SQLElement, string> doGlobalRule(SQLWrapperClasses.SQLRepository repository) { Dictionary <SQLElement, string> results = new Dictionary <SQLElement, string>(); String sqlString = "select o.* FROM t_object o, t_diagramobjects a, t_diagramobjects b " + "WHERE a.Object_ID = o.Object_ID " + "AND b.Object_ID <> a.Object_ID " + "AND b.RectRight > a.RectRight " + "AND b.RectLeft < a.RectLeft " + "AND b.RectTop > a.RectTop " + "AND b.RectBottom < a.RectBottom " + "AND a.Diagram_ID = b.Diagram_ID " + "AND o.ParentID <> b.Object_ID"; foreach (String row in EAUtil.getXMLNodeContentFromSQLQueryString(repository.SQLQuery(sqlString), "Row")) { if (row != "") { SQLElement element = new SQLElement(repository, row); if (element.Stereotype == SDMModelingMain.ObjectVariableStereotype || element.Stereotype == TGGModelingMain.TggObjectVariableStereotype) { results.Add(element, "Elements diagram bounds are contained by another diagram element which is not its parent"); } } } return(results); }
public override List <String> doRule(SQLConnector eaConnector, SQLWrapperClasses.SQLRepository repository) { List <String> results = new List <string>(); if (eaConnector.Type == ECOREModelingMain.EReferenceConnectorType) { SQLElement sourceElement = repository.GetElementByID(eaConnector.ClientID); SQLElement targetElement = repository.GetElementByID(eaConnector.SupplierID); if (sourceElement.Stereotype == ECOREModelingMain.EClassStereotype) { String clientResult = checkCardinality(eaConnector.ClientEnd.Cardinality); String supplierResult = checkCardinality(eaConnector.SupplierEnd.Cardinality); if (clientResult != "") { results.Add(clientResult); } if (supplierResult != "") { results.Add(supplierResult); } } } return(results); }
public override List <String> doRule(SQLElement eaElement, SQLWrapperClasses.SQLRepository repository) { List <String> results = new List <string>(); if (Serialization.MocaTaggableElement.isIgnored(eaElement)) { return(results); } if (eaElement.Stereotype == SDMModelingMain.StartNodeStereotype) { checkStartNode(eaElement, results); } else if (eaElement.Stereotype == SDMModelingMain.StopNodeStereotype) { checkStopNode(eaElement, results); } else if (eaElement.Stereotype == SDMModelingMain.StatementNodeStereotype) { checkStatementNode(eaElement, results); } else if (eaElement.Stereotype == SDMModelingMain.StoryNodeStereotype) { checkStoryNode(eaElement, repository, results); } return(results); }
public override List <String> doRule(SQLElement eaElement, SQLWrapperClasses.SQLRepository repository) { List <String> results = new List <string>(); if (eaElement.Stereotype == ECOREModelingMain.EEnumStereotype) { bool foundEnumConstant = false; SQLCollection <SQLAttribute> attributes = eaElement.Attributes; foreach (SQLAttribute attribute in attributes) { if (ConsistencyUtil.isValidConstantName(attribute.Name)) { foundEnumConstant = true; } else { try { Int32.Parse(attribute.Default); foundEnumConstant = true; } catch (FormatException) { //ignore } } } if (!foundEnumConstant) { results.Add("EEnum should contain at least one enum constant consisting of uppercase letters, digits, and underscores with an integer default value."); } } return(results); }
public override List <String> doRule(SQLElement eaElement, SQLWrapperClasses.SQLRepository repository) { List <String> results = new List <string>(); if (eaElement.Stereotype == TGGModelingMain.TggRuleStereotype) { SQLPackage rulesPackage = repository.GetPackageByID(eaElement.PackageID); SQLPackage tggSchemaPackage = repository.GetPackageByID(rulesPackage.ParentID); foreach (SQLElement corrType in tggSchemaPackage.Elements) { if (corrType.Stereotype == TGGModelingMain.TggCorrespondenceTypeStereotype) { if (corrType.Name == eaElement.Name) { results.Add("TGG Rule name shouldnt be equal to TGG CorrespondenceType name"); } } } if (!ConsistencyUtil.isValidTGGRuleName(eaElement.Name)) { results.Add("TGG Rule name should consist of the following letters: a-z,A-Z,0-9,_,-"); } } return(results); }
public override void doRuleQuickFix(SQLElement eaObject, SQLWrapperClasses.SQLRepository repository, int i, string errorMessage) { string sqlString = @"SELECT o.Object_ID from t_diagram d, t_diagramobjects a, t_diagramobjects b, t_object o,t_object x WHERE d.Diagram_ID = a.Diagram_ID AND o.Object_ID = a.Object_ID AND b.Diagram_ID = a.Diagram_ID AND b.RectTop <= a.RectTop AND b.RectBottom >= a.RectBottom AND b.RectLeft >= a.RectLeft AND b.RectRight <= a.RectRight AND b.Object_ID <> a.Object_ID AND x.Object_ID = b.Object_ID AND x.ParentID <> o.Object_ID AND o.Stereotype = '" + TGGModelingMain.TggRuleSetStereotype + @"' AND x.Stereotype = '" + TGGModelingMain.TggRuleStereotype + @"' AND x.Object_ID = " + eaObject.ElementID; String result = repository.SQLQuery(sqlString); String id = EAUtil.getXMLNodeContentFromSQLQueryString(result, "Object_ID")[0]; if (id != "") { int parentId = int.Parse(id); eaObject.getRealElement().ParentID = parentId; eaObject.getRealElement().Update(); } }
public override List <String> doRule(SQLElement eaElement, SQLWrapperClasses.SQLRepository repository) { List <String> results = new List <string>(); if (eaElement.Stereotype == TGGModelingMain.TggObjectVariableStereotype || eaElement.Stereotype == TGGModelingMain.TggCorrespondenceStereotype) { foreach (SQLConnector outgoingLink in eaElement.Connectors) { if (outgoingLink.ClientID == eaElement.ElementID) { if (outgoingLink.Stereotype != TGGModelingMain.TggLinkVariableStereotype && outgoingLink.Type == Main.EAAssociationType) { results.Add("At least one outgoing LinkVariable has the wrong stereotype. Delete and recreate it"); } } } } if (eaElement.Stereotype == SDMModelingMain.ObjectVariableStereotype) { foreach (SQLConnector outgoingLink in eaElement.Connectors) { if (outgoingLink.ClientID == eaElement.ElementID) { if (outgoingLink.Stereotype != SDMModelingMain.LinkVariableStereotype && outgoingLink.Type == Main.EAAssociationType) { results.Add("At least one outgoing LinkVariable has the wrong stereotype. Delete and recreate it"); } } } } return(results); }
public override Dictionary <SQLElement, string> doGlobalRule(SQLWrapperClasses.SQLRepository repository) { Dictionary <SQLElement, string> results = new Dictionary <SQLElement, string>(); string sqlString = @"SELECT x.* from t_diagram d, t_diagramobjects a, t_diagramobjects b, t_object o,t_object x WHERE d.Diagram_ID = a.Diagram_ID AND o.Object_ID = a.Object_ID AND b.Diagram_ID = a.Diagram_ID AND b.RectTop <= a.RectTop AND b.RectBottom >= a.RectBottom AND b.RectLeft >= a.RectLeft AND b.RectRight <= a.RectRight AND b.Object_ID <> a.Object_ID AND x.Object_ID = b.Object_ID AND x.ParentID <> o.Object_ID AND o.Stereotype = '" + TGGModelingMain.TggRuleSetStereotype + @"' AND x.Stereotype = '" + TGGModelingMain.TggRuleStereotype + "'"; String result = repository.SQLQuery(sqlString); foreach (String row in EAUtil.getXMLNodeContentFromSQLQueryString(result, "Row")) { if (row != "") { SQLElement element = new SQLElement(repository, row); results.Add(element, "The Rule should be a children of the containing Rule-Set"); } } return(results); }
public override Dictionary <SQLElement, string> doGlobalRule(SQLWrapperClasses.SQLRepository repository) { Dictionary <SQLElement, string> results = new Dictionary <SQLElement, string>(); String ruleElements = repository.SQLQuery("select * from t_object where Stereotype = '" + TGGModelingMain.TggRuleStereotype + "'"); foreach (String row in EAUtil.getXMLNodeContentFromSQLQueryString(ruleElements, "Row")) { if (row != "") { SQLElement ruleElement = new SQLElement(repository, row); SQLDiagram ruleDiagram = ruleElement.Diagrams.GetAt(0) as SQLDiagram; EA.Diagram rruleDiagram = EAUtil.sqlEAObjectToOriginalObject(repository, ruleDiagram) as EA.Diagram; foreach (EA.DiagramObject diagObject in rruleDiagram.DiagramObjects) { SQLElement diagElement = repository.GetElementByID(diagObject.ElementID); if (diagElement.ParentID != ruleElement.ElementID && (diagElement.Stereotype == TGGModelingMain.TggObjectVariableStereotype || diagElement.Stereotype == TGGModelingMain.TggCorrespondenceStereotype)) { results.Add(diagElement, "Element is no child of Rule: " + ruleElement.Name + " but is contained on its Rule Diagram"); } } } } return(results); }
public override List <String> doRule(SQLElement eaElement, SQLWrapperClasses.SQLRepository repository) { List <String> results = new List <string>(); if (eaElement.Stereotype == TGGModelingMain.TggCorrespondenceTypeStereotype) { SQLPackage pkg = repository.GetPackageByID(eaElement.PackageID); foreach (SQLElement elem in pkg.Elements) { if (elem.Name == eaElement.Name && elem.ElementID != eaElement.ElementID) { results.Add("name of CorrespondenceType must be unique"); } } } if (eaElement.MetaType == ECOREModelingMain.EClassStereotype) { SQLPackage pkg = repository.GetPackageByID(eaElement.PackageID); foreach (SQLElement elem in pkg.Elements) { if (elem.Name == eaElement.Name && elem.ElementID != eaElement.ElementID) { results.Add("name of classes in a package must be unique"); } } } return(results); }
public override void doRuleQuickFix(SQLElement sqlElement, SQLWrapperClasses.SQLRepository repository, int i, String errorMessage) { EA.Element realElement = sqlElement.getRealElement(); if (errorMessage == "TGG Rule name shouldnt be equal to TGG CorrespondenceType name") { if (i == 0) { realElement.Name = "Rule" + realElement.Name; realElement.Update(); TGGRule tggRule = new TGGRule(repository, sqlElement); tggRule.saveTreeToEATaggedValue(true); } } else if (errorMessage == "TGG Rule name must not contain spaces") { if (i == 0) { realElement.Name = realElement.Name.Replace(" ", ""); realElement.Update(); TGGRule tggRule = new TGGRule(repository, sqlElement); tggRule.saveTreeToEATaggedValue(true); } } }
public override List <String> doRule(SQLElement eaElement, SQLWrapperClasses.SQLRepository repository) { List <String> results = new List <string>(); if (Serialization.MocaTaggableElement.isIgnored(eaElement)) { return(results); } if (eaElement.Stereotype == SDMModelingMain.StoryNodeStereotype) { StoryNode storyNode = new StoryNode(repository, eaElement); if (!storyNode.loadTreeFromTaggedValue()) { results.Add("StoryNode is invalid and has to be updated manually"); } } else if (eaElement.Stereotype == SDMModelingMain.StatementNodeStereotype) { StatementNode stNode = new StatementNode(repository, eaElement); if (!stNode.loadTreeFromTaggedValue()) { results.Add("StatementNode is invalid and has to be updated manually"); } } else if (eaElement.Stereotype == SDMModelingMain.StopNodeStereotype) { StopNode stopNode = new StopNode(repository, eaElement); if (!stopNode.loadTreeFromTaggedValue()) { results.Add("StopNode is invalid and has to be updated manually"); } } return(results); }
public override void doRuleQuickFix(SQLConnector eaConnector, SQLWrapperClasses.SQLRepository repository, int i, string errorMessage) { if (i == 0) { EReference eref = new EReference(eaConnector, repository); eref.saveTreeToEATaggedValue(true); } }
public override void doRuleQuickFix(SQLPackage eaPackage, SQLWrapperClasses.SQLRepository repository, int i, String errorMessage) { if (i == 0) { eaPackage.getRealPackage().Name = Regex.Replace(eaPackage.Name, " ", ""); eaPackage.getRealPackage().Update(); } }
public override void doRuleQuickFix(SQLPackage eaPackage, SQLWrapperClasses.SQLRepository repository, int i, String errorMessage) { if (i == 0) { NewTGGProjectDialog dialog = new NewTGGProjectDialog(repository, eaPackage); dialog.ShowDialog(); } }
public override void doRuleQuickFix(SQLElement eaElement, SQLWrapperClasses.SQLRepository repository, int i, String errorMessage) { Activity activity = new Activity(eaElement, repository); EA.Element realElement = eaElement.getRealElement(); realElement.ParentID = activity.OwningOperation.EaMethod.ParentID; realElement.Update(); }
public override void doRuleQuickFix(SQLElement eaElement, SQLWrapperClasses.SQLRepository repository, int i, String errorMessage) { if (i == 0) { ObjectVariable ov = ObjectVariable.createCorrectOvType(eaElement, repository); OvDialog ovDialog = new OvDialog(repository, ov); ovDialog.ShowDialog(); } }
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 Dictionary <SQLElement, string> doGlobalRule(SQLWrapperClasses.SQLRepository repository) { NameValueCollection parentIdToName = new NameValueCollection(); Dictionary <SQLElement, String> results = new Dictionary <SQLElement, string>(); //SDM ObjectVariables string result = repository.SQLQuery(@"select a.* from t_object a, t_object b, t_object c WHERE a.Name = b.Name AND a.ea_guid <> b.ea_guid AND a.ParentID = c.Object_ID AND b.parentID = c.Object_ID AND a.Stereotype = '" + SDMModelingMain.ObjectVariableStereotype + @"' AND b.Stereotype = '" + SDMModelingMain.ObjectVariableStereotype + @"' AND c.Stereotype = '" + SDMModelingMain.StoryNodeStereotype + "'"); foreach (String row in EAUtil.getXMLNodeContentFromSQLQueryString(result, "Row")) { if (row != "") { SQLElement element = new SQLElement(repository, row); String[] names = parentIdToName.GetValues(element.ParentID + ""); if (names == null || !names.Contains(element.Name)) { results.Add(element, "ObjectVariable name in a single StoryPattern must be explicit"); parentIdToName.Add(element.ParentID + "", element.Name); } } } //TGGObjectVariables result = repository.SQLQuery(@"select a.* from t_object a, t_object b, t_object c WHERE a.Name = b.Name AND a.ea_guid <> b.ea_guid AND a.ParentID = c.Object_ID AND b.parentID = c.Object_ID AND (a.Stereotype = '" + TGGModelingMain.TggObjectVariableStereotype + @"' OR a.Stereotype = '" + TGGModelingMain.TggCorrespondenceStereotype + @"') AND (b.Stereotype = '" + TGGModelingMain.TggObjectVariableStereotype + @"' OR b.Stereotype = '" + TGGModelingMain.TggCorrespondenceStereotype + @"') AND c.Stereotype = '" + TGGModelingMain.TggRuleStereotype + "'"); foreach (String row in EAUtil.getXMLNodeContentFromSQLQueryString(result, "Row")) { if (row != "") { SQLElement element = new SQLElement(repository, row); String[] names = parentIdToName.GetValues(element.ParentID + ""); if (names == null || !names.Contains(element.Name)) { results.Add(element, "ObjectVariable name in a single Rule must be explicit"); parentIdToName.Add(element.ParentID + "", element.Name); } } } return(results); }
private static void transformConstraintToCSPElement(SQLElement eaElement2, SQLWrapperClasses.SQLRepository sqlRep, EA.Repository repository) { EA.Element eaElement = EAUtil.sqlEAObjectToOriginalObject(sqlRep, eaElement2) as EA.Element; String result = repository.SQLQuery("select Diagram_ID from t_diagramobjects where Object_ID = " + eaElement.ElementID); string diagramId = EAUtil.getXMLNodeContentFromSQLQueryString(result, "Diagram_ID")[0]; if (diagramId != "") { EA.Diagram diagram = repository.GetDiagramByID(int.Parse(diagramId)); EA.DiagramObject oldDiagObject = EAUtil.findDiagramObject(sqlRep, eaElement, diagram); EA.Element ruleElement = repository.GetElementByID(diagram.ParentID); if (ruleElement.Stereotype == TGGModelingMain.TggRuleStereotype) { List <EA.Connector> outgoingCons = new List <EA.Connector>(); foreach (EA.Connector con in eaElement.Connectors) { if (con.Stereotype == "ConstraintLink" && con.ClientID == eaElement.ElementID) { outgoingCons.Add(con); } } EA.Element newCsp = ruleElement.Elements.AddNew("", Main.EAClassType) as EA.Element; newCsp.Notes = eaElement.Notes; newCsp.Stereotype = TGGModelingMain.CSPConstraintStereotype; newCsp.Update(); EA.TaggedValue oldTag = EAUtil.findTaggedValue(eaElement, Main.MoflonExportTreeTaggedValueName); if (oldTag != null) { EAUtil.setTaggedValueNotes(sqlRep, newCsp, oldTag.Name, oldTag.Notes); } EA.DiagramObject newDiagObject = diagram.DiagramObjects.AddNew("", Main.EAClassType) as EA.DiagramObject; newDiagObject.ElementID = newCsp.ElementID; newDiagObject.left = oldDiagObject.left; newDiagObject.right = oldDiagObject.right; newDiagObject.bottom = oldDiagObject.bottom; newDiagObject.top = oldDiagObject.top; newDiagObject.Update(); foreach (EA.Connector con in outgoingCons) { con.ClientID = newCsp.ElementID; con.Update(); } EAUtil.deleteDiagramObject(repository, diagram, eaElement); EAUtil.deleteElement(eaElement, sqlRep); } } }
public override List <String> doRule(SQLElement eaElement, SQLWrapperClasses.SQLRepository repository) { List <String> results = new List <string>(); if (Consistency.Util.ConsistencyUtil.nameIsKeyword(eaElement.Name)) { results.Add("No keywords should be used for element names"); } return(results); }
public override List <String> doRule(SQLMethod eaMethod, SQLWrapperClasses.SQLRepository repository) { List <String> results = new List <string>(); if (eaMethod.Name.Contains(" ")) { results.Add("Blanks are not allowed in method names"); } return(results); }
public override List <String> doRule(SQLAttribute eaAttribute, SQLWrapperClasses.SQLRepository repository) { List <String> results = new List <string>(); if (eaAttribute.Name.Contains(" ")) { results.Add("Blanks are not allowed in attribute names"); } return(results); }
public override List <String> doRule(SQLPackage eaPackage, SQLWrapperClasses.SQLRepository repository) { List <String> results = new List <string>(); handleObsoleteTaggedValue(eaPackage, results, "Moflon::ValidationFilter"); handleObsoleteTaggedValue(eaPackage, results, "Moflon::CustomNsUri"); handleObsoleteTaggedValue(eaPackage, results, "validated"); handleObsoleteTaggedValue(eaPackage, results, "Moflon::CustomNsPrefix"); return(results); }
public override void doRuleQuickFix(SQLElement eaElement, SQLWrapperClasses.SQLRepository sqlRep, int i, string errorMessage) { EA.Repository repository = sqlRep.GetOriginalRepository(); if (errorMessage == "Tgg CSP is outdated and cant be modified - quickfix is recommended") { if (i == 0) { transformConstraintToCSPElement(eaElement, sqlRep, repository); } } }
public LiteralExpressionForm(string textFieldContent, SQLWrapperClasses.SQLRepository repository) { InitializeComponent(); StartPosition = FormStartPosition.CenterScreen; literalExpressionTextBox.Select(); this.repository = repository; this.literalExpressionTextBox.Text = textFieldContent; this.literalExpressionTextBox.AutoCompleteSource = System.Windows.Forms.AutoCompleteSource.CustomSource; this.literalExpressionTextBox.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.SuggestAppend; this.literalExpressionTextBox.AutoCompleteCustomSource = this.source; }
public override void doRuleQuickFix(SQLElement eaElement, SQLWrapperClasses.SQLRepository repository, int i, string errorMessage) { if (i == 0) { if (eaElement.Stereotype == TGGModelingMain.TggRuleStereotype) { TGGRule tggRule = new TGGRule(repository, eaElement); tggRule.saveTreeToEATaggedValue(true); } } }