protected void CheckParameter(IParameter parameterToCheck, ResolveErrorBehavior resolveErrorBehavior) { CheckReferences(parameterToCheck, resolveErrorBehavior); if (parameterToCheck.RHSFormula == null) { return; } CheckFormulaIn(parameterToCheck, parameterToCheck.RHSFormula, resolveErrorBehavior); }
protected void CheckFormulaIn(IUsingFormula entity, IFormula formulaToCheck, ResolveErrorBehavior resolveErrorBehavior) { var entityAbsolutePath = _objectPathFactory.CreateAbsoluteObjectPath(entity).ToPathString(); var builder = _buildConfiguration.BuilderFor(entity); var objectWithError = builder ?? entity; var entityType = _objectTypeResolver.TypeFor(entity); if (formulaToCheck.IsBlackBox()) { addNotificationType(NotificationType.Error, objectWithError, Validation.FormulaIsBlackBoxIn(entity.Name, entityAbsolutePath)); return; } foreach (var objectPath in formulaToCheck.ObjectPaths) { CheckPath(entity, objectPath, resolveErrorBehavior); } }
protected void CheckFormulaIn(IUsingFormula entity, IFormula formulaToCheck, ResolveErrorBehavior resolveErrorBehavior) { var entityAbsolutePath = _objectPathFactory.CreateAbsoluteObjectPath(entity).ToPathString(); var builder = _buildConfiguration.BuilderFor(entity); var objectWithError = builder ?? entity; // Dynamic formula may contain object path that will be resolved per instance. It cannot be checked here if (formulaToCheck.IsDynamic()) { return; } if (formulaToCheck.IsBlackBox()) { addNotificationType(NotificationType.Error, objectWithError, Validation.FormulaIsBlackBoxIn(entity.Name, entityAbsolutePath)); return; } foreach (var objectPath in formulaToCheck.ObjectPaths) { CheckPath(entity, objectPath, resolveErrorBehavior); } }
protected void CheckPath(IUsingFormula entity, IObjectPath objectPathToCheck, ResolveErrorBehavior resolveErrorBehavior) { var builder = _buildConfiguration.BuilderFor(entity); var objectWithError = builder ?? entity; var entityAbsolutePath = _objectPathFactory.CreateAbsoluteObjectPath(entity).ToString(); var entityType = _objectTypeResolver.TypeFor(entity); if (containsKeyWords(objectPathToCheck)) { addNotificationType(NotificationType.Error, objectWithError, Validation.PathContainsReservedKeywords(entity.Name, entityType, entityAbsolutePath, objectPathToCheck.ToPathString())); return; } //found, we continue if (objectPathToCheck.Resolve <IFormulaUsable>(entity) != null) { return; } string message = Validation.ErrorUnableToFindReference(entity.Name, entityType, entityAbsolutePath, objectPathToCheck.ToPathString()); if (resolveErrorBehavior == ResolveErrorBehavior.Error) { addNotificationType(NotificationType.Error, objectWithError, message); } else { var parent = entity.ParentContainer; parent?.RemoveChild(entity); if (resolveErrorBehavior == ResolveErrorBehavior.Delete) { return; } addNotificationType(NotificationType.Warning, objectWithError, message); } }
/// <summary> /// try to resolve all the references used in the formula from the usingFormula object. /// if one reference cannot be resolved, a validation message with info on the missing reference. /// </summary> /// <param name="usingFormulaToCheck">The using formula object to check.</param> /// <param name="resolveErrorBehavior">Specifies the behavior of the method when a reference is not found</param> protected void CheckReferences(IUsingFormula usingFormulaToCheck, ResolveErrorBehavior resolveErrorBehavior) { CheckFormulaIn(usingFormulaToCheck, usingFormulaToCheck.Formula, resolveErrorBehavior); }