コード例 #1
0
        public static AllowedError FindAllowedErrorInSortedList(
            [NotNull] List <AllowedError> allowedErrors,
            [NotNull] QaError qaError,
            [NotNull] QualityCondition qualityCondition,
            [NotNull] ISpatialReference spatialReference,
            [NotNull] IQualityConditionObjectDatasetResolver datasetResolver,
            [NotNull] ICollection <esriGeometryType> storedGeometryTypes,
            bool forPre10Geodatabase)
        {
            Assert.ArgumentNotNull(allowedErrors, nameof(allowedErrors));
            Assert.ArgumentNotNull(qaError, nameof(qaError));
            Assert.ArgumentNotNull(qualityCondition, nameof(qualityCondition));
            Assert.ArgumentNotNull(spatialReference, nameof(spatialReference));
            Assert.ArgumentNotNull(storedGeometryTypes, nameof(storedGeometryTypes));

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

            QaError asStoredError = GetForAllowedErrorComparison(
                qaError, spatialReference, storedGeometryTypes, forPre10Geodatabase);

            int index = FindAllowedErrorIndex(asStoredError,
                                              qualityCondition,
                                              allowedErrors,
                                              datasetResolver);

            return(index < 0
                                       ? null
                                       : allowedErrors[index]);
        }
コード例 #2
0
        public void WriteIssue(QaError qaError, QualitySpecificationElement element)
        {
            var errorRequiresIdLookup = false;

            foreach (InvolvedRow involvedRow in qaError.InvolvedRows)
            {
                TableKeyLookup tableKeyLookup =
                    GetTableRequiringIdLookup(involvedRow, element);

                if (tableKeyLookup != null)
                {
                    tableKeyLookup.AddObjectId(involvedRow.OID);
                    errorRequiresIdLookup = true;
                }
            }

            if (errorRequiresIdLookup)
            {
                AddToBuffer(qaError, element);

                if (IsBufferCapacityExceeded())
                {
                    Flush();
                }
            }
            else
            {
                var issue = new Issue(element, qaError);

                WriteIssueCore(issue, qaError.Geometry);
            }
        }
コード例 #3
0
        public static string GetInvolvedObjectsString(
            [NotNull] QualityCondition qualityCondition,
            [NotNull] QaError qaError,
            [NotNull] ICollection <ITest> tests,
            int maxLength,
            [NotNull] IQualityConditionObjectDatasetResolver datasetResolver)
        {
            IEnumerable <InvolvedRow> involvedRowsWithDatasetNames =
                GetInvolvedRows(qaError,
                                qualityCondition,
                                datasetResolver);

            if (tests.Count == 1)
            {
                return(RowParser.Format(involvedRowsWithDatasetNames, maxLength));
            }

            var testIndex = 0;

            foreach (ITest test in tests)
            {
                if (test == qaError.Test)
                {
                    return(RowParser.Format(test, testIndex, involvedRowsWithDatasetNames,
                                            maxLength));
                }

                testIndex++;
            }

            throw new InvalidProgramException(
                      string.Format("Test {0} not found in QualityCondition {1}",
                                    qaError.Test.GetType(), qualityCondition.Name));
        }
コード例 #4
0
        private void ReportErrorForFailedTest([NotNull] ITest test,
                                              [CanBeNull] IDataReference dataReference,
                                              [NotNull] string message)
        {
            var       involvedRows  = new List <InvolvedRow>();
            IGeometry errorGeometry = null;

            IRow row          = null;
            var  rowReference = dataReference as RowReference;

            if (rowReference != null)
            {
                row = rowReference.Row;
            }

            if (row != null)
            {
                involvedRows.Add(new InvolvedRow(row));
                errorGeometry = TestUtils.GetShapeCopy(row);
            }

            const bool assertionFailed = true;
            var        qaError         = new QaError(test, message, involvedRows, errorGeometry,
                                                     null, null, assertionFailed);

            OnQaError(new QaErrorEventArgs(qaError));
        }
コード例 #5
0
        private static void AssertErrorPartCount(int errorPartCount, [NotNull] QaError error)
        {
            IGeometry errorGeometry = error.Geometry;

            Assert.NotNull(errorGeometry);
            Assert.AreEqual(errorPartCount, GeometryUtils.GetPartCount(errorGeometry));
        }
コード例 #6
0
        protected override bool MatchesCore(ExceptionObject exceptionObject,
                                            QaError qaError)
        {
            string searchIssueCodeId = qaError.IssueCode?.ID.Trim();

            return(Matches(exceptionObject.IssueCode, searchIssueCodeId));
        }
コード例 #7
0
        private IssueDatasetWriter PrepareIssueWriter(
            [NotNull] QaError qaError,
            [NotNull] QualityCondition qualityCondition,
            bool isAllowable,
            bool forceSimplify = false)
        {
            // create valid Error geometry (geometry type, min dimensions) if possible
            IGeometry geometry = ErrorRepositoryUtils.GetGeometryToStore(
                qaError.Geometry,
                IssueDatasets.SpatialReference,
                IssueDatasets.GetIssueWritersByGeometryType().Keys,
                _isPre10Geodatabase,
                forceSimplify);

            IssueDatasetWriter issueWriter = IssueDatasets.GetIssueWriter(geometry);

            IRowBuffer rowBuffer = issueWriter.GetRowBuffer();

            // write geometry to the buffer
            if (geometry != null)
            {
                // update the geometry directly if needed (it is already a copy)
                GeometryUtils.EnsureSchemaZM(geometry, issueWriter.HasZ, issueWriter.HasM);

                WriteGeometry(geometry, (IFeatureBuffer)rowBuffer);
            }

            IList <ITest> tests = _testsByQualityCondition[qualityCondition];

            WriteAttributes(issueWriter, rowBuffer, qualityCondition, isAllowable,
                            qaError, tests);

            return(issueWriter);
        }
コード例 #8
0
        public void CaDetectDistinct()
        {
            var involvedRows = new List <InvolvedRow>
            {
                new InvolvedRow("Table2", 100),
                new InvolvedRow("Table1", 1000),
                new InvolvedRow("Table2", 200)
            };

            var involvedTables =
                new List <InvolvedTable>
            {
                new InvolvedTable("Table2", new RowReference[] { new OIDRowReference(100) }),
                new InvolvedTable("Table1", new RowReference[] { new OIDRowReference(1000) })
            };

            ITable tableMock = ExceptionObjectTestUtils.GetMockTable();

            ExceptionObject exceptionObject = ExceptionObjectTestUtils.CreateExceptionObject(
                1, involvedTables);
            QaError qaError = ExceptionObjectTestUtils.CreateQaError(tableMock, involvedRows);

            var predicate = new ExceptionObjectInvolvedRowsPredicate(null);

            Assert.False(predicate.Matches(exceptionObject, qaError));
        }
コード例 #9
0
        private static bool HasLength([NotNull] QaError e, double expectedLength)
        {
            var    polycurve = e.Geometry as IPolycurve;
            double length    = polycurve?.Length ?? 0;

            return(AreEqualWithinTolerance(expectedLength, length));
        }
コード例 #10
0
        /// <summary>
        /// Adds an error to the error repository. Call <see cref="SavePendingErrors"/> to
        /// save all the pending errors added to the repository.
        /// </summary>
        /// <param name="qaError"></param>
        /// <param name="qualityCondition"></param>
        /// <param name="isAllowable"></param>
        public void AddError([NotNull] QaError qaError,
                             [NotNull] QualityCondition qualityCondition,
                             bool isAllowable)
        {
            Assert.ArgumentNotNull(qaError, nameof(qaError));
            Assert.ArgumentNotNull(qualityCondition, nameof(qualityCondition));

            IssueDatasetWriter issueWriter = PrepareIssueWriter(qaError, qualityCondition,
                                                                isAllowable);

            try
            {
                issueWriter.InsertRow();
            }
            catch (IssueFeatureInsertionFailedException)
            {
                _msg.Warn(
                    "Unable to write issue feature (see log for details); trying again with simplified issue geometry");

                // the geometry was probably non-simple enough for the insert to fail
                // -> try again with forced simplification of issue geometry
                issueWriter = PrepareIssueWriter(qaError, qualityCondition, isAllowable,
                                                 forceSimplify: true);

                // give up if this fails also
                issueWriter.InsertRow();
            }
        }
コード例 #11
0
        void IExceptionEvaluationStatistics.AddUsedException(
            ExceptionObject exceptionObject, QualitySpecificationElement element,
            QaError qaError)
        {
            ExceptionCount++;

            var issueGroupKey = new IssueGroupKey(new Issue(element, qaError));

            List <ExceptionObject> usedExceptionObjects;

            if (!_usedExceptions.TryGetValue(issueGroupKey, out usedExceptionObjects))
            {
                usedExceptionObjects           = new List <ExceptionObject>();
                _usedExceptions[issueGroupKey] = usedExceptionObjects;
            }

            usedExceptionObjects.Add(exceptionObject);

            string key = exceptionObject.ExceptionCategory?.Trim() ?? string.Empty;

            int count;

            count = _usedExceptionsByExceptionCategory.TryGetValue(key, out count)
                                        ? count + 1
                                        : 1;
            _usedExceptionsByExceptionCategory[key] = count;

            GetStatistics(element.QualityCondition).AddUsedException(exceptionObject);
        }
コード例 #12
0
 private void AddToBuffer([NotNull] QaError qaError,
                          [NotNull] QualitySpecificationElement element)
 {
     _pendingQaErrors.Add(new PendingQaError(qaError, element, qaError.Geometry));
     _errorGeometryVertexCount = _errorGeometryVertexCount +
                                 GeometryUtils.GetPointCount(qaError.Geometry);
 }
コード例 #13
0
        private static bool HasCode([NotNull] QaError e,
                                    [NotNull] string expectedIssueCodeId)
        {
            string code = e.IssueCode?.ID;

            return(StripPrefix(code) == expectedIssueCodeId);
        }
コード例 #14
0
        public bool ExistsExceptionFor(QaError qaError,
                                       QualitySpecificationElement element,
                                       out ExceptionObject exceptionObject)
        {
            var uuid = new Guid(element.QualityCondition.Uuid);

            // TODO if the error exceeds the verification extent, compare with envelope by "contained envelope" criterion instead of "equal envelope"
            // Reason: some tests cut off the error geometry at the verification extent

            QualityConditionExceptions qualityConditionExceptions;

            if (_qualityConditionExceptions.TryGetValue(uuid, out qualityConditionExceptions))
            {
                if (qualityConditionExceptions.ExistsExceptionFor(qaError, out exceptionObject))
                {
                    _exceptionEvaluationStatistics.AddUsedException(
                        exceptionObject, element, qaError);
                    return(true);
                }

                return(false);
            }

            // no exceptions exist for this quality condition
            exceptionObject = null;
            return(false);
        }
コード例 #15
0
 public PendingQaError(
     [NotNull] QaError error,
     [NotNull] QualitySpecificationElement qualitySpecificationElement,
     [CanBeNull] IGeometry errorGeometry)
 {
     Error         = error;
     ErrorGeometry = errorGeometry;
     QualitySpecificationElement = qualitySpecificationElement;
 }
コード例 #16
0
        public bool Matches([NotNull] ExceptionObject exceptionObject,
                            [NotNull] QaError qaError)
        {
            Assert.ArgumentNotNull(exceptionObject, nameof(exceptionObject));
            Assert.ArgumentNotNull(qaError, nameof(qaError));

            // TODO record match statistics etc.
            return(MatchesCore(exceptionObject, qaError));
        }
コード例 #17
0
 private bool Matches([NotNull] QaError qaError,
                      [NotNull] ExceptionObject exceptionObject,
                      bool applyInvolvedRowsPredicate)
 {
     return((!applyInvolvedRowsPredicate ||
             _involvedRowsPredicate.Matches(exceptionObject, qaError)) &&
            _issueCodePredicate.Matches(exceptionObject, qaError) &&
            _affectedComponentPredicate.Matches(exceptionObject, qaError) &&
            _valuesPredicate.Matches(exceptionObject, qaError));
 }
コード例 #18
0
        public static QaError GetForAllowedErrorComparison(
            [NotNull] QaError qaError,
            [NotNull] ISpatialReference spatialReference,
            [NotNull] ICollection <esriGeometryType> storedGeometryTypes)
        {
            const bool forPre10Geodatabase = false;

            return(GetForAllowedErrorComparison(qaError, spatialReference, storedGeometryTypes,
                                                forPre10Geodatabase));
        }
コード例 #19
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Issue"/> class.
 /// </summary>
 /// <param name="qualitySpecificationElement">The quality condition.</param>
 /// <param name="qaError">The QA error.</param>
 public Issue([NotNull] QualitySpecificationElement qualitySpecificationElement,
              [NotNull] QaError qaError)
     : this(qualitySpecificationElement,
            qaError.Description,
            IssueUtils.GetInvolvedTables(qaError.InvolvedRows),
            qaError.IssueCode,
            qaError.AffectedComponent,
            qaError.Values)
 {
 }
コード例 #20
0
        private bool ProcessQaError([NotNull] QaError qaError)
        {
            Assert.ArgumentNotNull(qaError, nameof(qaError));

            if (_msg.IsVerboseDebugEnabled)
            {
                _msg.DebugFormat("Issue found: {0}", qaError);
            }

            // TODO: Consider checking basic relevance (inside test perimeter?) here

            var eventArgs = new QaErrorEventArgs(qaError);

            QaError?.Invoke(this, eventArgs);

            if (eventArgs.Cancel)
            {
                return(false);
            }

            ITest test = qaError.Test;
            QualityConditionVerification conditionVerification =
                GetQualityConditionVerification(test);
            QualityCondition qualityCondition = conditionVerification.QualityCondition;

            Assert.NotNull(qualityCondition, "no quality condition for verification");

            StopInfo stopInfo = null;

            if (conditionVerification.StopOnError)
            {
                stopInfo = new StopInfo(qualityCondition, qaError.Description);

                foreach (InvolvedRow involvedRow in qaError.InvolvedRows)
                {
                    RowsWithStopConditions.Add(involvedRow.TableName,
                                               involvedRow.OID, stopInfo);
                }
            }

            if (!conditionVerification.AllowErrors)
            {
                conditionVerification.Fulfilled = false;

                if (stopInfo != null)
                {
                    // it's a stop condition, and it is a 'hard' condition, and the error is
                    // relevant --> consider the stop situation as sufficiently reported
                    // (no reporting in case of stopped tests required)
                    stopInfo.Reported = true;
                }
            }

            return(true);
        }
コード例 #21
0
        public IEnumerable <ExceptionObject> Search([NotNull] QaError qaError)
        {
            string key = ExceptionObjectUtils.GetKey(qaError.InvolvedRows,
                                                     _excludeTableFromKey);

            List <ExceptionObject> exceptionObjects;

            return(_index.TryGetValue(key, out exceptionObjects)
                                       ? exceptionObjects
                                       : _emptyList);
        }
コード例 #22
0
        public static void OneError([NotNull] QaTestRunnerBase runner,
                                    [NotNull] string issueCodeId,
                                    [NotNull] out QaError error)
        {
            Assert.AreEqual(1, runner.Errors.Count);
            error = runner.Errors[0];
            IssueCode issueCode = error.IssueCode;

            Assert.IsNotNull(issueCode);
            Assert.AreEqual(issueCodeId, issueCode.ID);
        }
コード例 #23
0
        private static bool Matches([CanBeNull] string exceptionObjectIssueCode,
                                    [CanBeNull] string qaErrorIssueCode)
        {
            ExceptionObject exceptionObject = CreateExceptionObject(1, exceptionObjectIssueCode);
            ITable          table           = ExceptionObjectTestUtils.GetMockTable();
            QaError         qaError         = ExceptionObjectTestUtils.CreateQaError(table, qaErrorIssueCode,
                                                                                     null);

            var predicate = new ExceptionObjectIssueCodePredicate();

            return(predicate.Matches(exceptionObject, qaError));
        }
コード例 #24
0
        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));
        }
コード例 #25
0
        private bool ExistsExceptionFor([NotNull] QaError qaError,
                                        [NotNull] QualitySpecificationElement element)
        {
            if (_exceptionObjectEvaluator == null)
            {
                return(false);
            }

            ExceptionObject exceptionObject;

            return(_exceptionObjectEvaluator.ExistsExceptionFor(qaError, element,
                                                                out exceptionObject));
        }
コード例 #26
0
        public static bool IsAllowedError(
            [NotNull] QaError comparableError,
            [NotNull] QualityCondition qualityCondition,
            [NotNull] List <AllowedError> allowedErrors,
            [NotNull] IQualityConditionObjectDatasetResolver datasetResolver)
        {
            int index = FindAllowedErrorIndex(comparableError,
                                              qualityCondition,
                                              allowedErrors,
                                              datasetResolver);

            return(index >= 0);
        }
        private static bool Matches([CanBeNull] string exceptionAffectedComponent,
                                    [CanBeNull] string qaErrorAffectedComponent)
        {
            ExceptionObject exceptionObject = CreateExceptionObject(1,
                                                                    exceptionAffectedComponent);
            ITable  table   = ExceptionObjectTestUtils.GetMockTable();
            QaError qaError = ExceptionObjectTestUtils.CreateQaError(table, null,
                                                                     qaErrorAffectedComponent);

            var predicate = new ExceptionObjectAffectedComponentPredicate();

            return(predicate.Matches(exceptionObject, qaError));
        }
コード例 #28
0
        private Issue CreateIssue([NotNull] PendingQaError pendingQaError)
        {
            QualitySpecificationElement element = pendingQaError.QualitySpecificationElement;

            QaError error = pendingQaError.Error;

            return(new Issue(element,
                             error.Description,
                             GetInvolvedTables(pendingQaError.Error.InvolvedRows, element),
                             error.IssueCode,
                             error.AffectedComponent,
                             error.Values));
        }
コード例 #29
0
        public static AllowedError FindAllowedErrorInSortedList(
            [NotNull] List <AllowedError> allowedErrors,
            [NotNull] QaError qaError,
            [NotNull] QualityCondition qualityCondition,
            [NotNull] ISpatialReference spatialReference,
            [NotNull] IQualityConditionObjectDatasetResolver datasetResolver,
            [NotNull] ICollection <esriGeometryType> storedGeometryTypes)
        {
            const bool forPre10Geodatabase = false;

            return(FindAllowedErrorInSortedList(allowedErrors, qaError, qualityCondition,
                                                spatialReference, datasetResolver,
                                                storedGeometryTypes, forPre10Geodatabase));
        }
コード例 #30
0
        internal static QaError CreateReferenceGeometryError(
            [NotNull] QaError qaError,
            [NotNull] IGeometry referenceGeometry)
        {
            string description = string.Format(
                "{0}; {1}", qaError.Description,
                _referencedGeometryInfo);

            return(new QaError(qaError.Test,
                               description,
                               qaError.InvolvedRows,
                               referenceGeometry,
                               qaError.IssueCode,
                               qaError.AffectedComponent));
        }