private void validateEAElement(Object eaObject, SQLRepository repository, Boolean singleRulecheck) { SQLElement element = eaObject as SQLElement; //only do rules for Element, Attributes and Methods if (singleRulecheck) { foreach (SQLAttribute actAttribute in element.Attributes) { RuleControl.deleteRuleResults(EA.ObjectType.otAttribute, actAttribute.AttributeID); RuleControl.doRules(actAttribute, repository); } foreach (SQLMethod actMethod in element.Methods) { RuleControl.deleteRuleResults(EA.ObjectType.otMethod, actMethod.MethodID); RuleControl.doRules(actMethod, repository); } RuleControl.deleteRuleResults(EA.ObjectType.otElement, element.ElementID); RuleControl.doRules(element, repository); } else { List <SQLElement> listOfElements = new List <SQLElement>(); List <SQLConnector> listOfConnectors = new List <SQLConnector>(); List <SQLAttribute> listOfAttributes = new List <SQLAttribute>(); List <SQLMethod> listofMethods = new List <SQLMethod>(); List <SQLParameter> listofParameters = new List <SQLParameter>(); List <SQLPackage> listOfPackages = new List <SQLPackage>(); addElementChildFeatures(listOfElements, listOfConnectors, listOfAttributes, listofMethods, listofParameters, element); doRulesForFeatures(repository, listOfElements, listOfConnectors, listOfAttributes, listofMethods, listofParameters, listOfPackages); } }
private void startValidation(EA.ObjectType ot, Object eaObject, SQLRepository repository, Boolean singleRulecheck, Boolean validateAll) { this.fullValidation = validateAll; this.singleRuleCheck = singleRulecheck; switch (ot) { //do rules for elements and their attributes/methods case EA.ObjectType.otElement: validateEAElement(eaObject, repository, singleRulecheck); break; //do rules for connectors case EA.ObjectType.otConnector: SQLConnector connector = eaObject as SQLConnector; RuleControl.deleteRuleResults(EA.ObjectType.otConnector, connector.ConnectorID); RuleControl.doRules(connector, repository); break; //do rules for attributes case EA.ObjectType.otAttribute: SQLAttribute attribute = eaObject as SQLAttribute; RuleControl.deleteRuleResults(EA.ObjectType.otAttribute, attribute.AttributeID); RuleControl.doRules(attribute, repository); break; //do rules for methods case EA.ObjectType.otMethod: SQLMethod method = eaObject as SQLMethod; RuleControl.deleteRuleResults(EA.ObjectType.otMethod, method.MethodID); RuleControl.doRules(method, repository); break; //do rules for packages case EA.ObjectType.otPackage: validatePackage(eaObject, repository, singleRulecheck, validateAll); break; case EA.ObjectType.otDiagram: SQLDiagram diagram = eaObject as SQLDiagram; RuleControl.deleteRuleResults(EA.ObjectType.otDiagram, diagram.DiagramID); RuleControl.doRules(diagram, repository); break; } if (DoGlobalRules) { RuleControl.doGlobalRules(repository); } endValidation(repository); }
private void doRulesForFeatures(SQLRepository repository, List <SQLElement> listOfElements, List <SQLConnector> listOfConnectors, List <SQLAttribute> listOfAttributes, List <SQLMethod> listofMethods, List <SQLParameter> listofParameters, List <SQLPackage> listOfPackages) { List <SQLElement> toDelete = new List <SQLElement>(); foreach (SQLElement elem in listOfElements) { if (elem.Type == "Constraint") { toDelete.Add(elem); } } foreach (SQLElement del in toDelete) { listOfElements.Remove(del); } String result = repository.SQLQuery("select a.* from t_object a, t_package b, t_diagramobjects c where a.Object_Type = 'Constraint' AND a.Package_ID = b.Package_ID and b.Name = 'Rules' AND c.Object_ID = a.Object_ID"); //String result = repository.SQLQuery("select * from t_object where Object_Type = 'Constraint' AND Diagram_ID <> 0"); foreach (String row in EAUtil.getXMLNodeContentFromSQLQueryString(result, "Row")) { if (row != "") { listOfElements.Add(new SQLElement(repository, row)); } } consistencyProgressbar.invokeProgressBarSetBarSize(6); consistencyProgressbar.invokeProgressBarAndPerformNext(EA.ObjectType.otElement); foreach (SQLElement element in listOfElements) { if (Canceled) { return; } RuleControl.deleteRuleResults(EA.ObjectType.otElement, element.ElementID); RuleControl.doRules(element, repository); } consistencyProgressbar.invokeProgressBarAndPerformNext(EA.ObjectType.otConnector); foreach (SQLConnector connector in listOfConnectors) { if (Canceled) { return; } RuleControl.deleteRuleResults(EA.ObjectType.otConnector, connector.ConnectorID); RuleControl.doRules(connector, repository); } consistencyProgressbar.invokeProgressBarAndPerformNext(EA.ObjectType.otMethod); foreach (SQLMethod method in listofMethods) { if (Canceled) { return; } RuleControl.deleteRuleResults(EA.ObjectType.otMethod, method.MethodID); RuleControl.doRules(method, repository); } consistencyProgressbar.invokeProgressBarAndPerformNext(EA.ObjectType.otParameter); foreach (SQLParameter parameter in listofParameters) { } consistencyProgressbar.invokeProgressBarAndPerformNext(EA.ObjectType.otAttribute); foreach (SQLAttribute attribute in listOfAttributes) { if (Canceled) { return; } RuleControl.deleteRuleResults(EA.ObjectType.otAttribute, attribute.AttributeID); RuleControl.doRules(attribute, repository); } consistencyProgressbar.invokeProgressBarAndPerformNext(EA.ObjectType.otPackage); foreach (SQLPackage actpackage in listOfPackages) { if (Canceled) { return; } RuleControl.deleteRuleResults(EA.ObjectType.otPackage, actpackage.PackageID); RuleControl.doRules(actpackage, repository); } }
private void validatePackage(Object eaObject, SQLRepository repository, Boolean singleRulecheck, Boolean validateAll) { SQLPackage package = eaObject as SQLPackage; //if a full rulecheck should be done if (!singleRulecheck) { List <SQLPackage> packagesToValidate = new List <SQLPackage>(); //if package is a simple package check all elements within the package if (!validateAll) { SQLPackage modelPackage = package; //root node is selected if (modelPackage.ParentID == 0) { foreach (SQLPackage pkg in modelPackage.Packages) { SQLTaggedValue validated = EAEcoreAddin.Util.EAUtil.findTaggedValue(pkg, MetamodelHelper.MoflonValidatedTaggedValueName); if (validated == null || validated.Value != "true") { packagesToValidate.Add(pkg); } } } //simple package is selected else { if (modelPackage.IsModel) { SQLTaggedValue validated = EAEcoreAddin.Util.EAUtil.findTaggedValue(modelPackage, MetamodelHelper.MoflonValidatedTaggedValueName); if (validated == null || validated.Value != "true") { packagesToValidate.Add(modelPackage); } } else { packagesToValidate.Add(modelPackage); } } } else { foreach (SQLPackage root in repository.Models) { foreach (SQLPackage model in root.Packages) { SQLTaggedValue validated = EAEcoreAddin.Util.EAUtil.findTaggedValue(model, MetamodelHelper.MoflonValidatedTaggedValueName); if (validated == null || !validated.Value.ToLower().Contains("true") || validated.Value == EPackageHelper.DEFAULT_VALUE_PLACEHOLDER) { packagesToValidate.Add(model); } } } } doRulesForPackages(packagesToValidate, repository); } //single rulecheck for package else { RuleControl.deleteRuleResults(EA.ObjectType.otPackage, package.PackageID); RuleControl.doRules(package, repository); } }