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 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(SQLMethod eaMethod, SQLWrapperClasses.SQLRepository repository) { List <String> results = new List <string>(); SQLElement parentClass = repository.GetElementByID(eaMethod.ParentID); if (parentClass.Stereotype == ECOREModelingMain.EClassStereotype) { foreach (SQLParameter param in eaMethod.Parameters) { Boolean isClassifier = false; Boolean validDatatype = false; if (EcoreUtil.ecoreEDataTypes.Contains(param.Type)) { validDatatype = true; } if (param.ClassifierID != "0" && param.ClassifierID != "") { try { SQLElement classifier = repository.GetElementByID(int.Parse(param.ClassifierID)); isClassifier = true; } catch { } } if (!validDatatype && !isClassifier) { String type = HttpUtility.HtmlDecode(param.Type); if (type == "EEList<E>" || type == "EMap<K,V>") { results.Add(@"Unsupported EDatatype, This EDatatype is not currently supported, please choose another EDatatype or create a new EDatatype with an appropriate alias (mapping to Java type) - " + param.Name + ":" + param.Type); } else { results.Add(@"Type is invalid - Please choose a model element or use a known Ecore datatype - " + param.Name + ":" + param.Type); } } } } return(results); }
public override List <String> doRule(SQLConnector eaConnector, SQLWrapperClasses.SQLRepository repository) { List <String> results = new List <string>(); if (eaConnector.Type == ECOREModelingMain.EReferenceConnectorType && eaConnector.Stereotype == "") { 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) { if (eaConnector.ClientEnd.Navigable == "Navigable") { if (eaConnector.ClientEnd.getAggregation() == 2 && (eaConnector.ClientEnd.Cardinality != "1" && eaConnector.ClientEnd.Cardinality != "0..1")) { results.Add("Containment end must have multiplicity 1 or 0..1"); } if (eaConnector.ClientEnd.Cardinality == "") { results.Add("Multiplicities must be defined for navigable ends"); } } else if (eaConnector.SupplierEnd.Navigable == "Navigable") { if (eaConnector.SupplierEnd.getAggregation() == 2 && (eaConnector.SupplierEnd.Cardinality != "1" && eaConnector.SupplierEnd.Cardinality != "0..1")) { results.Add("Containment end must have multiplicity 1 or 0..1"); } if (eaConnector.SupplierEnd.Cardinality == "") { results.Add("Multiplicities must be defined for navigable ends"); } } } } return(results); }
public override List <String> doRule(SQLConnector eaConnector, SQLWrapperClasses.SQLRepository repository) { List <String> results = new List <string>(); SQLElement clientClass = repository.GetElementByID(eaConnector.ClientID); if (clientClass.Stereotype == ECOREModelingMain.EClassStereotype && eaConnector.Type == ECOREModelingMain.EReferenceConnectorType) { SQLConnector con = eaConnector; SQLElement supplierClass = repository.GetElementByID(con.SupplierID); EReference eReference = new EReference(con, repository); eReference.loadTreeFromTaggedValue(); if ((con.ClientEnd.Navigable == "Navigable" && eReference.ClientEnd.typeGUID != clientClass.ElementGUID) || (con.SupplierEnd.Navigable == "Navigable" && eReference.SupplierEnd.typeGUID != supplierClass.ElementGUID)) { results.Add("Moca fragment of EReference is invalid and must be refreshed"); } } return(results); }
public override List <String> doRule(SQLElement eaElement, SQLWrapperClasses.SQLRepository repository) { List <String> results = new List <string>(); if (eaElement.Stereotype == SDMModelingMain.ObjectVariableStereotype) { SQLElement containingElement = repository.GetElementByID(eaElement.ParentID); if (containingElement.Stereotype != SDMModelingMain.StoryNodeStereotype) { results.Add("Every ObjectVariable must be contained in a story pattern"); } } return(results); }
public override List <string> doRule(SQLConnector eaConnector, SQLWrapperClasses.SQLRepository repository) { List <String> results = new List <string>(); try { repository.GetElementByID(eaConnector.ClientID); } catch { results.Add("Connector client is not existing anymore. Connector should be deleted"); } try { repository.GetElementByID(eaConnector.SupplierID); } catch { results.Add("Connector supplier is not existing anymore. Connector should be deleted"); } return(results); }
public override List <String> doRule(SQLElement eaElement, SQLWrapperClasses.SQLRepository repository) { List <String> results = new List <string>(); if (SDMUtil.isActivityNodeMetatype(eaElement.Stereotype)) { SQLElement aNodeParent = repository.GetElementByID(eaElement.ParentID); if (aNodeParent.Stereotype != SDMModelingMain.SdmContainerStereotype) { results.Add("ActivityNode must be child of SDM Activity element"); } } return(results); }
public override List <String> doRule(SQLConnector eaConnector, SQLWrapperClasses.SQLRepository repository) { List <String> results = new List <string>(); SQLElement clientClass = repository.GetElementByID(eaConnector.ClientID); SQLElement suppClass = repository.GetElementByID(eaConnector.SupplierID); if (clientClass.Stereotype == ECOREModelingMain.EClassStereotype && eaConnector.Type == ECOREModelingMain.EReferenceConnectorType) { if (eaConnector.SupplierEnd.Role != "") { Char first = eaConnector.SupplierEnd.Role[0]; if (Char.IsUpper(first)) { results.Add("Supplier Rolename should not start with uppercase"); } } if (eaConnector.ClientEnd.Role != "") { Char first = eaConnector.ClientEnd.Role[0]; if (Char.IsUpper(first)) { results.Add("Client Rolename should not start with uppercase"); } } if (eaConnector.SupplierEnd.Role == clientClass.Name) { results.Add("Rolename must not be equal to EClass name [" + clientClass.Name + "]"); } if (eaConnector.ClientEnd.Role == suppClass.Name) { results.Add("Rolename must not be equal to EClass name [" + suppClass.Name + "]"); } } return(results); }
public override void doRuleQuickFix(SQLElement eaElement, SQLWrapperClasses.SQLRepository repository, int i, String errorMessage) { if (i == 0) { EA.Element realElement = eaElement.getRealElement(); SQLElement classifier = repository.GetElementByID(eaElement.ClassifierID); realElement.Name = classifier.Name.Substring(0, 1).ToLower() + classifier.Name.Substring(1, classifier.Name.Length - 1); realElement.Update(); } else if (i == 1) { ObjectVariable ov = ObjectVariable.createCorrectOvType(eaElement, repository); OvDialog ovDialog = new OvDialog(repository, ov); ovDialog.ShowDialog(); } }
public override List <String> doRule(SQLConnector eaConnector, SQLWrapperClasses.SQLRepository repository) { List <String> results = new List <string>(); SQLElement sourceElement = repository.GetElementByID(eaConnector.ClientID); if (sourceElement.Stereotype == ECOREModelingMain.EClassStereotype && eaConnector.Type == ECOREModelingMain.EReferenceConnectorType) { if (eaConnector.ClientEnd.Role != "" && eaConnector.ClientEnd.Navigable != "Navigable") { results.Add("Every named end must be set to navigable"); } if (eaConnector.SupplierEnd.Role != "" && eaConnector.SupplierEnd.Navigable != "Navigable") { results.Add("Every named end must be set to navigable"); } } return(results); }
public override List <String> doRule(SQLAttribute eaAttribute, SQLWrapperClasses.SQLRepository repository) { List <String> results = new List <string>(); SQLElement parentClass = repository.GetElementByID(eaAttribute.ParentID); if (parentClass.Stereotype == ECOREModelingMain.EClassStereotype) { List <String> attRefNames = new List <String>(); foreach (SQLAttribute attribute in parentClass.Attributes) { attRefNames.Add(attribute.Name); } foreach (SQLConnector reference in parentClass.Connectors) { if (reference.Type == ECOREModelingMain.EReferenceConnectorType) { if (reference.ClientID == parentClass.ElementID) { if (reference.SupplierEnd.Navigable == "Navigable") { attRefNames.Add(reference.SupplierEnd.Role); } } if (reference.SupplierID == parentClass.ElementID) { if (reference.ClientEnd.Navigable == "Navigable") { attRefNames.Add(reference.ClientEnd.Role); } } } } if (attRefNames.LastIndexOf(eaAttribute.Name) != attRefNames.IndexOf(eaAttribute.Name)) { results.Add("All attribute and reference names must be explicit"); } } return(results); }
public override List <String> doRule(SQLAttribute eaAttribute, SQLWrapperClasses.SQLRepository repository) { List <String> results = new List <string>(); SQLElement parentClass = repository.GetElementByID(eaAttribute.ParentID); if (parentClass.Stereotype == ECOREModelingMain.EEnumStereotype) { if (ConsistencyUtil.isValidConstantName(eaAttribute.Name)) { try { Int32.Parse(eaAttribute.Default); } catch (FormatException) { results.Add("EEnums constants must provide 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.CSPConstraintStereotype || eaElement.Stereotype == "TGGCsp") { SQLElement parentElement = repository.GetElementByID(eaElement.ParentID); if (parentElement.Stereotype != SDMModelingMain.StoryNodeStereotype) { CSPInstance csp = new CSPInstance(repository, eaElement); if (csp.loadTreeFromTaggedValue()) { foreach (CSPInstanceEntry instance in csp.createdEntries) { foreach (Expression exp in instance.typedInExpressions) { if (!ConsistencyUtil.checkExpression(eaElement, exp, repository)) { results.Add("Tgg CSP expression is invalid: " + exp); } } } } else { results.Add("Tgg CSP is outdated and maybe erroneous - updating it manually is recommended"); } } } else if (eaElement.Type == "Constraint") { results.Add("Tgg CSP is outdated and cant be modified - quickfix is recommended"); } return(results); }
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); }