public virtual int analyze(IRule rule) { int result = Analysis_Fields.VALIDATION_PASSED; error = new ErrorSummary(); warning = new WarningSummary(); checkForModule(rule); ICondition[] cnds = rule.Conditions; for (int idx = 0; idx < cnds.Length; idx++) { ICondition cnd = cnds[idx]; if (cnd is ObjectCondition) { ObjectCondition oc = (ObjectCondition)cnd; Deftemplate dft = oc.Deftemplate; if (dft != null) { IConstraint[] cntrs = oc.Constraints; for (int idy = 0; idy < cntrs.Length; idy++) { IConstraint cons = cntrs[idy]; if (cons is LiteralConstraint) { Slot sl = dft.getSlot(cons.Name); if (sl == null) { error.addMessage(INVALID_SLOT + " " + cons.Name + " slot does not exist."); result = Analysis_Fields.VALIDATION_FAILED; } } else if (cons is BoundConstraint) { BoundConstraint bc = (BoundConstraint)cons; if (!bc.isObjectBinding) { Slot sl = dft.getSlot(bc.Name); if (sl == null) { error.addMessage(INVALID_SLOT + " " + cons.Name + " slot does not exist."); result = Analysis_Fields.VALIDATION_FAILED; } } } else if (cons is PredicateConstraint) { PredicateConstraint pc = (PredicateConstraint)cons; IFunction f = engine.findFunction(pc.FunctionName); if (f == null) { addInvalidFunctionError(pc.FunctionName); } } } } else { error.addMessage(INVALID_TEMPLATE + " " + oc.TemplateName + " template does not exist."); result = Analysis_Fields.VALIDATION_FAILED; } } else if (cnd is TestCondition) { TestCondition tc = (TestCondition)cnd; if (tc.Function == null) { error.addMessage(NO_FUNCTION); result = Analysis_Fields.VALIDATION_FAILED; } else { IFunction f = tc.Function; if (engine.findFunction(f.Name) == null) { addInvalidFunctionError(f.Name); result = Analysis_Fields.VALIDATION_FAILED; } } } else if (cnd is ExistCondition) { } } // now we check the Right-hand side IAction[] acts = rule.Actions; for (int idx = 0; idx < acts.Length; idx++) { IAction act = acts[idx]; if (act is FunctionAction) { FunctionAction fa = (FunctionAction)act; if (engine.findFunction(fa.FunctionName) == null) { addInvalidFunctionError(fa.FunctionName); result = Analysis_Fields.VALIDATION_FAILED; } } } return(result); }
public virtual int analyze(IRule rule) { int result = Analysis_Fields.VALIDATION_PASSED; error = new ErrorSummary(); warning = new WarningSummary(); checkForModule(rule); ICondition[] cnds = rule.Conditions; for (int idx = 0; idx < cnds.Length; idx++) { ICondition cnd = cnds[idx]; if (cnd is ObjectCondition) { ObjectCondition oc = (ObjectCondition) cnd; Deftemplate dft = oc.Deftemplate; if (dft != null) { IConstraint[] cntrs = oc.Constraints; for (int idy = 0; idy < cntrs.Length; idy++) { IConstraint cons = cntrs[idy]; if (cons is LiteralConstraint) { Slot sl = dft.getSlot(cons.Name); if (sl == null) { error.addMessage(INVALID_SLOT + " " + cons.Name + " slot does not exist."); result = Analysis_Fields.VALIDATION_FAILED; } } else if (cons is BoundConstraint) { BoundConstraint bc = (BoundConstraint) cons; if (!bc.isObjectBinding) { Slot sl = dft.getSlot(bc.Name); if (sl == null) { error.addMessage(INVALID_SLOT + " " + cons.Name + " slot does not exist."); result = Analysis_Fields.VALIDATION_FAILED; } } } else if (cons is PredicateConstraint) { PredicateConstraint pc = (PredicateConstraint) cons; IFunction f = engine.findFunction(pc.FunctionName); if (f == null) { addInvalidFunctionError(pc.FunctionName); } } } } else { error.addMessage(INVALID_TEMPLATE + " " + oc.TemplateName + " template does not exist."); result = Analysis_Fields.VALIDATION_FAILED; } } else if (cnd is TestCondition) { TestCondition tc = (TestCondition) cnd; if (tc.Function == null) { error.addMessage(NO_FUNCTION); result = Analysis_Fields.VALIDATION_FAILED; } else { IFunction f = tc.Function; if (engine.findFunction(f.Name) == null) { addInvalidFunctionError(f.Name); result = Analysis_Fields.VALIDATION_FAILED; } } } else if (cnd is ExistCondition) { } } // now we check the Right-hand side IAction[] acts = rule.Actions; for (int idx = 0; idx < acts.Length; idx++) { IAction act = acts[idx]; if (act is FunctionAction) { FunctionAction fa = (FunctionAction) act; if (engine.findFunction(fa.FunctionName) == null) { addInvalidFunctionError(fa.FunctionName); result = Analysis_Fields.VALIDATION_FAILED; } } } return result; }
public virtual void reset() { error = null; warning = null; }