private static int markAttributeOnDiagram(SQLAttribute attribute, SQLRepository repository) { SQLElement parentElement = repository.GetElementByID(attribute.ParentID); int count = markElementOnDiagram(parentElement, repository); return(count); }
public static RuleResult computeRuleResult(Rule rule, SQLAttribute att, String ruleOutput) { Boolean passed = ruleOutput == ""; RuleResult ruleResult = new RuleResult(); ruleResult.Passed = passed; ruleResult.Rule = rule; ruleResult.RuleID = rule.getRuleID(); ruleResult.EaObject = att; ruleResult.ObjectType = EA.ObjectType.otAttribute; ruleResult.ObjectID = att.AttributeID; ruleResult.NameOfObject = att.Name; ruleResult.ErrorOutput = ruleOutput; ruleResult.ErrorLevel = rule.getErrorLevel(att, ruleOutput); if (att.Stereotype == "enum") { ruleResult.TypeOfObject = "EEnumLiteral"; } else { ruleResult.TypeOfObject = "EAttribute"; } return(ruleResult); }
public String getGuidOfAttributeByURIString(String uriString) { List<String> values = new List<String>(); String[] splitted = uriString.Split('/'); foreach (String entry in splitted) { if (entry != "") values.Add(entry.Replace("#", "")); } String result = Repository.SQLQuery("select * from t_attribute where name = '" + this.AttributeName + "'"); foreach (String row in EAEcoreAddin.Util.EAUtil.getXMLNodeContentFromSQLQueryString(result, "Row")) { if (row != "") { SQLAttribute attribute = new SQLAttribute(row, Repository); SQLElement parentElement = Repository.GetElementByID(attribute.ParentID); SQLPackage parentPackage = Repository.GetPackageByID(parentElement.PackageID); if (parentElement.Name == values[values.Count - 2] && parentPackage.Name == values[values.Count - 3]) { return attribute.AttributeGUID; } } } return ""; }
public EAttribute(SQLAttribute eaAttribute, SQLRepository repository) { this.EaAttribute = eaAttribute; this.Repository = repository; this.attributeType = eaAttribute.Type; this.Name = eaAttribute.Name; }
public override void doRuleQuickFix(SQLAttribute eaAttribute, SQLRepository repository, int i, String errorMessage) { if (i == 0) { eaAttribute.getRealAttribute().Name = Regex.Replace(eaAttribute.Name, " ", ""); eaAttribute.getRealAttribute().Update(); } }
public AttributeAssignment(SQLRepository repository, ObjectVariable ov, SQLAttribute attribute) { this.Attribute = attribute; this.AttributeGUID = attribute.AttributeGUID; this.AttributeName = attribute.Name; this.Repository = repository; this.OvName = ov.Name; }
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(SQLAttribute eaAttribute, SQLWrapperClasses.SQLRepository repository) { List <String> results = new List <string>(); if (Consistency.Util.ConsistencyUtil.nameIsKeyword(eaAttribute.Name)) { results.Add("No keywords should be used for attribute names"); } return(results); }
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); }
public AttributeValueExpression(SQLRepository repository, SQLAttribute attribute, SQLElement objectVariable) { this.Attribute = attribute; this.AttributeGUID = attribute.AttributeGUID; this.AttributeName = attribute.Name; this.Type = DESCRIPTION; this.Repository = repository; this.ObjectVariableGUID = objectVariable.ElementGUID; this.ObjectVariable = objectVariable; this.ObjectVariableName = objectVariable.Name; }
public EEnumLiteral(SQLAttribute attribute, SQLRepository sqlRep) { this.Repository = sqlRep; this.enumLiteral = attribute; this.Name = attribute.Name; this.Value = attribute.Default; this.Literal = attribute.getRealAttribute().Alias; if (Literal == "") { Literal = Name; } }
private Expression computeExpression() { Expression expression = null; try { //output will be computed as the name of the stopNode //AttributeValueExpression with target(cmbTarget) and attribute(cmbSources) if (selectedExpressionString == "AttributeValueExpression" && secondObjects.Count > selectedSecondObjectIndex && firstObjects.Count > selectedFirstObjectIndex && selectedSecondObjectIndex != -1 && selectedFirstObjectIndex != -1) { //get OV and Attribute SQLAttribute attribute = this.secondObjects[selectedSecondObjectIndex].EaObject as SQLAttribute; SQLElement targetObjectVariable = this.firstObjects[selectedFirstObjectIndex].EaObject as SQLElement; AttributeValueExpression avExp = new AttributeValueExpression(repository, attribute, targetObjectVariable); expression = avExp; } //MethodCallExpression with target(cmbTarget) and Method(cmbSources) else if (selectedExpressionString == "MethodCallExpression" && secondObjects.Count > selectedSecondObjectIndex && firstObjects.Count > selectedFirstObjectIndex && selectedSecondObjectIndex != -1 && selectedFirstObjectIndex != -1) { SQLMethod method = this.secondObjects[selectedSecondObjectIndex].EaObject as SQLMethod; String name = method.Name; Object target = this.firstObjects[selectedFirstObjectIndex].EaObject; MethodCallExpression methodCallExpression = EditorMethodCallExpression.generateMethodCallExpression(repository, target, method); expression = methodCallExpression; } //parameterExpression else if (selectedExpressionString == "ParameterExpression" && firstObjects.Count > selectedFirstObjectIndex && selectedFirstObjectIndex != -1) { SQLParameter parameter = this.firstObjects[selectedFirstObjectIndex].EaObject as SQLParameter; ParameterExpression pExp = new ParameterExpression(repository, parameter); expression = pExp; } //literalExpression else if (selectedExpressionString == "LiteralExpression") { LiteralExpression literalExpression = new LiteralExpression("null"); expression = literalExpression; } //objectVariableExpression else if (selectedExpressionString == "ObjectVariableExpression" && firstObjects.Count > selectedFirstObjectIndex) { SQLElement sdmObject = this.firstObjects[selectedFirstObjectIndex].EaObject as SQLElement; ObjectVariableExpression ovExp = new ObjectVariableExpression(sdmObject, repository); expression = ovExp; } } catch (Exception) { } return(expression); }
public void doSingleAttributeRule(SQLAttribute attribute, SQLRepository repository, Rule rule) { if (rule is AttributeRule && (ruleExecutionPoint == rule.getRuleExecutionPoint() || ruleExecutionPoint == RuleExecutionPoint.OnRequest)) { foreach (RuleResult result in rule.getRuleResult(attribute, repository)) { if (!result.Passed) { handleRuleResult(result, repository); } } } }
public override void deserializeFromMocaTree(Serialization.MocaTree.MocaNode actNode) { this.AttributeGUID = actNode.getAttributeOrCreate("attributeGuid").Value; this.AttributeNameOld = actNode.getAttributeOrCreate("attributeName").Value; this.AttributeName = this.AttributeNameOld; this.ObjectVariableNameOld = actNode.getAttributeOrCreate("objectVariableName").Value; this.ObjectVariableName = this.ObjectVariableNameOld; this.ObjectVariableGUID = actNode.getAttributeOrCreate("objectVariableGuid").Value; SQLAttribute at = Repository.GetAttributeByGuid(this.AttributeGUID); SQLElement ob = Repository.GetElementByGuid(this.ObjectVariableGUID); if(at != null) this.AttributeName = at.Name; if (ob != null) this.ObjectVariableName = ob.Name; }
public override void deserializeFromMocaTree(Serialization.MocaTree.MocaNode actNode) { setOvName(actNode); setOvGuid(actNode); this.AttributeGUID = actNode.getAttributeOrCreate("attributeGuid").Value; this.AttributeNameOld = actNode.getAttributeOrCreate("attributeName").Value; this.AttributeName = this.AttributeNameOld; MocaNode valueExpressionNode = actNode.getChildNodeWithName("valueExpression"); this.ValueExpression = Expression.createExpression(valueExpressionNode.getAttributeOrCreate("type").Value, Repository); this.ValueExpression.deserializeFromMocaTree(valueExpressionNode); SQLAttribute attribute = Repository.GetAttributeByGuid(this.AttributeGUID); if (attribute != null) { this.AttributeName = attribute.Name; } }
public override List <String> doRule(SQLAttribute eaAttribute, SQLRepository repository) { List <String> results = new List <string>(); SQLElement parentClass = repository.GetElementByID(eaAttribute.ParentID); if (parentClass.Stereotype == ECOREModelingMain.EClassStereotype) { //if return type of method is a ecore built in type if (EcoreUtil.ecoreEDataTypes.Contains(eaAttribute.Type)) { return(new List <string>()); } //if the attribute is a part of an enumeration there is no type needed if (eaAttribute.Stereotype == "enum") { return(new List <string>()); } foreach (SQLTemplate tmpl in (parentClass as SQLElement).Templates) { if (tmpl.Name == eaAttribute.Type) { return(new List <string>()); } } if (eaAttribute.ClassifierID == 0) { String type = HttpUtility.HtmlDecode(eaAttribute.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)"); } else { results.Add("Attribute type is invalid - Please choose a model element or use a known Ecore datatype"); } } } 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 static Boolean checkAttributeAssignment(SQLElement ovElement, AttributeAssignment attrAssignment, SQLRepository repository) { SQLAttribute attribute = repository.GetAttributeByGuid(attrAssignment.AttributeGUID); //attribute not existing if (attribute == null) { return(false); } Boolean attributeParentValid = checkIfClassifierContainsAttribute(repository.GetElementByGuid(attrAssignment.OvGuid), repository, attribute); if (!attributeParentValid) { return(attributeParentValid); } return(checkExpression(ovElement, attrAssignment.ValueExpression, repository)); }
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); }
private static bool checkAttributeValueExpression(SQLElement containingElement, SQLRepository sqlRepository, AttributeValueExpression aVe) { SQLAttribute referencedAttribute = sqlRepository.GetAttributeByGuid(aVe.AttributeGUID); SQLElement referencedObject = sqlRepository.GetElementByGuid(aVe.ObjectVariableGUID); if (referencedAttribute == null || referencedObject == null) { return(false); } if (aVe.ObjectVariableName != aVe.ObjectVariableNameOld || aVe.AttributeName != aVe.AttributeNameOld) { return(false); } if (!checkIfClassifierContainsAttribute(sqlRepository.GetElementByGuid(aVe.ObjectVariableGUID), sqlRepository, referencedAttribute)) { return(false); } return(compareSDMContainerOfSDMElements(containingElement, referencedObject, sqlRepository)); }
public override void doRuleQuickFix(SQLAttribute eaAttribute, SQLRepository repository, int i, String errorMessage) { return; }
public async Task Put([FromBody] SQLAttribute attribute, int id) { await _sqlAttributeService.UpdateAttributes(attribute, id); }
public async Task <SQLAttribute> UpdateAttributes(SQLAttribute attribute, int id) { return(await _sqlunitOfWork.SQLAttributeRepository.Update(attribute, id)); //await Complete(); }
public abstract List <String> doRule(SQLAttribute eaAttribute, SQLRepository repository);
public abstract void doRuleQuickFix(SQLAttribute eaAttribute, SQLRepository repository, int i, String errorMessage);
public override void doRuleQuickFix(SQLAttribute eaAttribute, SQLRepository repository, int i, String errorMessage) { throw new NotImplementedException(); }
private static bool checkIfClassifierContainsAttribute(SQLElement ovElement, SQLRepository repository, SQLAttribute attribute) { SQLElement ovClassifier = repository.GetElementByID(ovElement.ClassifierID); //assignment was created while ov had an other classifier Boolean attributeParentValid = false; foreach (SQLElement actBaseClass in EAUtil.getBaseClasses(ovClassifier)) { if (attribute.ParentID == actBaseClass.ElementID) { attributeParentValid = true; } } return(attributeParentValid); }
public async Task Post([FromBody] SQLAttribute attribute) { await _sqlAttributeService.AddAttributes(attribute); }
private static Boolean markAttributeInProjectBrowser(SQLAttribute attribute, SQLRepository rep) { EA.Attribute realAttribute = rep.GetOriginalRepository().GetAttributeByID(attribute.AttributeID); rep.ShowInProjectView(realAttribute); return(true); }
public async Task <SQLAttribute> AddAttributes(SQLAttribute attribute) { return(await _sqlunitOfWork.SQLAttributeRepository.Add(attribute)); }