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]); }
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); } }
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)); }
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)); }
private static void AssertErrorPartCount(int errorPartCount, [NotNull] QaError error) { IGeometry errorGeometry = error.Geometry; Assert.NotNull(errorGeometry); Assert.AreEqual(errorPartCount, GeometryUtils.GetPartCount(errorGeometry)); }
protected override bool MatchesCore(ExceptionObject exceptionObject, QaError qaError) { string searchIssueCodeId = qaError.IssueCode?.ID.Trim(); return(Matches(exceptionObject.IssueCode, searchIssueCodeId)); }
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); }
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)); }
private static bool HasLength([NotNull] QaError e, double expectedLength) { var polycurve = e.Geometry as IPolycurve; double length = polycurve?.Length ?? 0; return(AreEqualWithinTolerance(expectedLength, length)); }
/// <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(); } }
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); }
private void AddToBuffer([NotNull] QaError qaError, [NotNull] QualitySpecificationElement element) { _pendingQaErrors.Add(new PendingQaError(qaError, element, qaError.Geometry)); _errorGeometryVertexCount = _errorGeometryVertexCount + GeometryUtils.GetPointCount(qaError.Geometry); }
private static bool HasCode([NotNull] QaError e, [NotNull] string expectedIssueCodeId) { string code = e.IssueCode?.ID; return(StripPrefix(code) == expectedIssueCodeId); }
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); }
public PendingQaError( [NotNull] QaError error, [NotNull] QualitySpecificationElement qualitySpecificationElement, [CanBeNull] IGeometry errorGeometry) { Error = error; ErrorGeometry = errorGeometry; QualitySpecificationElement = qualitySpecificationElement; }
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)); }
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)); }
public static QaError GetForAllowedErrorComparison( [NotNull] QaError qaError, [NotNull] ISpatialReference spatialReference, [NotNull] ICollection <esriGeometryType> storedGeometryTypes) { const bool forPre10Geodatabase = false; return(GetForAllowedErrorComparison(qaError, spatialReference, storedGeometryTypes, forPre10Geodatabase)); }
/// <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) { }
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); }
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); }
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); }
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)); }
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 bool ExistsExceptionFor([NotNull] QaError qaError, [NotNull] QualitySpecificationElement element) { if (_exceptionObjectEvaluator == null) { return(false); } ExceptionObject exceptionObject; return(_exceptionObjectEvaluator.ExistsExceptionFor(qaError, element, out exceptionObject)); }
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)); }
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)); }
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)); }
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)); }