/// <summary>
        /// Deletes those allowed errors whose context have changed. In the base implementation this means
        /// where any involved row has changed since the error creation. Additional context change situations
        /// such as a change in the quality condition can be detected by the sub-repository.
        /// </summary>
        /// <param name="qualityConditions">The quality conditions.</param>
        /// <param name="invalidateAllowedErrorsIfAnyInvolvedObjectChanged">
        /// if set to <c>true</c> allowed errors are invalidated if any involved object changed.</param>
        /// <param name="invalidateAllowedErrorsIfQualityConditionWasUpdated">
        /// if set to <c>true</c> allowed errors are invalidated if the quality condition was updated.</param>
        public void DeleteInvalidAllowedErrors(
            [NotNull] IEnumerable <QualityCondition> qualityConditions,
            bool invalidateAllowedErrorsIfAnyInvolvedObjectChanged,
            bool invalidateAllowedErrorsIfQualityConditionWasUpdated)
        {
            // TODO: consider using AllowedErrorList property, remove qualityConditions parameter
            Assert.ArgumentNotNull(qualityConditions, nameof(qualityConditions));

            ICollection <QualityCondition> qualityConditionCollection =
                CollectionUtils.GetCollection(qualityConditions);

            var allowedErrors =
                new List <AllowedError>(GetAllowedErrors(qualityConditionCollection));

            AllowedErrorUtils.InvalidateAllowedErrors(
                allowedErrors,
                qualityConditionCollection,
                _verificationContext,
                invalidateAllowedErrorsIfAnyInvolvedObjectChanged,
                invalidateAllowedErrorsIfQualityConditionWasUpdated);

            List <AllowedError> invalidErrors =
                allowedErrors.Where(error => error.Invalidated).ToList();

            AllowedErrorUtils.DeleteAllowedErrors(invalidErrors);
        }
 /// <summary>
 /// Ensures that the relevant allowed errors are cached in <see cref="AllowedErrorList"/>
 /// and invalidates those allowed errors that should be deleted, such as where involved
 /// objects do not exist any more.
 /// </summary>
 /// <param name="qualityConditions"></param>
 /// <param name="invalidateAllowedErrorsIfAnyInvolvedObjectChanged"></param>
 /// <param name="invalidateAllowedErrorsIfQualityConditionWasUpdated"></param>
 public void InvalidateAllowedErrors(
     [NotNull] IEnumerable <QualityCondition> qualityConditions,
     bool invalidateAllowedErrorsIfAnyInvolvedObjectChanged,
     bool invalidateAllowedErrorsIfQualityConditionWasUpdated)
 {
     AllowedErrorUtils.InvalidateAllowedErrors(
         AllowedErrorList, qualityConditions, _verificationContext,
         invalidateAllowedErrorsIfAnyInvolvedObjectChanged,
         invalidateAllowedErrorsIfQualityConditionWasUpdated);
 }
        public AllowedError FindAllowedError([NotNull] QaError qaError,
                                             [NotNull] QualityCondition qualityCondition)
        {
            Assert.ArgumentNotNull(qaError, nameof(qaError));
            Assert.ArgumentNotNull(qualityCondition, nameof(qualityCondition));

            return(AllowedErrorUtils.FindAllowedErrorInSortedList(
                       AllowedErrorList, qaError, qualityCondition,
                       IssueDatasets.SpatialReference, _datasetResolver,
                       IssueDatasets.GetIssueWritersByGeometryType().Keys,
                       _isPre10Geodatabase));
        }
        private IEnumerable <AllowedError> GetAllowedErrors(
            [CanBeNull] IGeometry areaOfInterest,
            [NotNull] ISpatialFilter spatialFilter,
            [NotNull] IDictionary <int, QualityCondition> qualityConditionsById)
        {
            // can be made static if error tables and conditions are passed in --> "repository"?
            var factory = new AllowedErrorFactory(qualityConditionsById, _datasetResolver);

            foreach (IssueDatasetWriter issueDatasetWriter in IssueDatasets.GetIssueWriters())
            {
                foreach (AllowedError allowedError in AllowedErrorUtils.GetAllowedErrors(
                             issueDatasetWriter, areaOfInterest, spatialFilter, factory))
                {
                    yield return(allowedError);
                }
            }
        }
        public bool IsAllowedError([NotNull] QaError qaError,
                                   [NotNull] QualityCondition qualityCondition)
        {
            Assert.ArgumentNotNull(qaError, nameof(qaError));
            Assert.ArgumentNotNull(qualityCondition, nameof(qualityCondition));

            QaError comparableError = AllowedErrorUtils.GetForAllowedErrorComparison(
                qaError, IssueDatasets.SpatialReference,
                IssueDatasets.GetIssueWritersByGeometryType().Keys,
                _isPre10Geodatabase);

            var spatialFilter =
                new SpatialFilterClass
            {
                WhereClause = string.Format("{0} = {1} AND {2} = {3}",
                                            FieldNameQualityConditionId,
                                            qualityCondition.Id,
                                            FieldNameErrorType,
                                            (int)ErrorType.Allowed)
            };

            var qualityConditionsById = new Dictionary <int, QualityCondition>
            {
                { qualityCondition.Id, qualityCondition }
            };

            var allowedErrors =
                new List <AllowedError>(GetAllowedErrors(comparableError.Geometry,
                                                         spatialFilter,
                                                         qualityConditionsById));

            if (allowedErrors.Count == 0)
            {
                return(false);
            }

            allowedErrors.Sort();

            return(AllowedErrorUtils.IsAllowedError(comparableError,
                                                    qualityCondition,
                                                    allowedErrors,
                                                    _datasetResolver));
        }
 /// <summary>
 /// Deletes all allowed errors where the Used property is false. The used property is set to true
 /// in a verification if the error was found and the allowed error was used as an exception.
 /// If the error was corrected in the mean while the allowed error is not needed any more.
 /// </summary>
 public void DeleteUnusedAllowedErrors()
 {
     AllowedErrorUtils.DeleteAllowedErrors(GetUnusedAllowedErrors());
 }