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);
        }
        /// <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();
            }
        }
Ejemplo n.º 3
0
        public IssueDatasetWriter GetIssueWriterNoGeometry()
        {
            IssueDatasetWriter issueTable = GetIssueWriter(esriGeometryType.esriGeometryNull);

            Assert.NotNull(issueTable, "No table for issues without geometry defined");

            return(issueTable);
        }
            public DeletableErrorRowFilter([NotNull] IssueDatasetWriter issueWriter,
                                           [NotNull] IObjectSelection objectSelection)
            {
                Assert.ArgumentNotNull(issueWriter, nameof(issueWriter));
                Assert.ArgumentNotNull(objectSelection, nameof(objectSelection));

                _issueWriter     = issueWriter;
                _objectSelection = objectSelection;
            }
        private void WriteAttributes([NotNull] IssueDatasetWriter issueWriter,
                                     [NotNull] IRowBuffer rowBuffer,
                                     [NotNull] QualityCondition qualityCondition,
                                     bool isAllowable,
                                     [NotNull] QaError qaError,
                                     [NotNull] ICollection <ITest> tests)
        {
            Assert.ArgumentNotNull(issueWriter, nameof(issueWriter));
            Assert.ArgumentNotNull(rowBuffer, nameof(rowBuffer));
            Assert.ArgumentNotNull(qualityCondition, nameof(qualityCondition));
            Assert.ArgumentNotNull(qaError, nameof(qaError));
            Assert.ArgumentNotNull(tests, nameof(tests));

            issueWriter.WriteValue(rowBuffer, AttributeRole.ErrorDescription,
                                   qaError.Description);

            int involvedObjectsMaxLength =
                issueWriter.GetFieldLength(AttributeRole.ErrorObjects);

            string involvedObjects = ErrorObjectUtils.GetInvolvedObjectsString(
                qualityCondition, qaError, tests, involvedObjectsMaxLength,
                _datasetResolver);

            issueWriter.WriteValue(rowBuffer, AttributeRole.ErrorObjects, involvedObjects);

            issueWriter.WriteValue(rowBuffer, AttributeRole.ErrorErrorType,
                                   isAllowable
                                                       ? ErrorType.Soft
                                                       : ErrorType.Hard);

            issueWriter.WriteValue(rowBuffer, AttributeRole.ErrorConditionId,
                                   qualityCondition.Id);
            issueWriter.WriteValue(rowBuffer, AttributeRole.ErrorConditionName,
                                   qualityCondition.Name);

            issueWriter.WriteValue(rowBuffer, AttributeRole.ErrorConditionParameters,
                                   qualityCondition.GetParameterValuesString());

            if (issueWriter.HasAttribute(AttributeRole.DateOfCreation))
            {
                issueWriter.WriteValue(rowBuffer, AttributeRole.DateOfCreation,
                                       DateTime.Now);
            }

            WriteAttributesCore(issueWriter, rowBuffer, qualityCondition, qaError);
        }
Ejemplo n.º 6
0
        public IssueDatasetWriter GetIssueWriter([CanBeNull] IGeometry forGeometryToBeStored)
        {
            if (forGeometryToBeStored == null)
            {
                return(GetIssueWriterNoGeometry());
            }

            IssueDatasetWriter result = GetIssueWriter(forGeometryToBeStored.GeometryType);

            if (result != null)
            {
                return(result);
            }

            throw new ArgumentOutOfRangeException(
                      nameof(forGeometryToBeStored),
                      string.Format(@"No issue dataset found for geometry type: {0}.",
                                    forGeometryToBeStored.GeometryType));
        }
Ejemplo n.º 7
0
        CreateIssueWritersByGeometryType(
            [NotNull] IVerificationContext verificationContext,
            [NotNull] IFieldIndexCache fieldIndexCache)
        {
            var result = new Dictionary <esriGeometryType, IssueDatasetWriter>();

            foreach (KeyValuePair <esriGeometryType, IErrorDataset> pair in
                     VerificationContextUtils.GetIssueDatasetsByGeometryType(verificationContext))
            {
                IssueDatasetWriter issueWriter = CreateIssueWriter(pair.Value,
                                                                   verificationContext,
                                                                   fieldIndexCache);

                if (issueWriter != null)
                {
                    result.Add(pair.Key, issueWriter);
                }
            }

            return(result);
        }
 /// <summary>
 /// Allows adapting the issue filter to the project-specific context such as narrowing
 /// the search down to specific work unit or release cycle. The filter is currently used
 /// to find errors to be deleted.
 /// </summary>
 /// <param name="issueWriter">The error Table.</param>
 /// <param name="queryFilter">The filter to be adapted. Note that it can already contain a
 /// spatial filter and a where clause. Additional criteria need to be appended.</param>
 protected virtual void AdaptFilterToContext(
     [NotNull] IssueDatasetWriter issueWriter,
     [NotNull] IQueryFilter queryFilter)
 {
 }
 /// <summary>
 /// Allows writing additional project-specific attributes such as
 /// - operator
 /// - correction status
 /// - work unit / release cycle / model id
 /// </summary>
 /// <param name="issueWriter"></param>
 /// <param name="rowBuffer"></param>
 /// <param name="qualityCondition"></param>
 /// <param name="qaError"></param>
 protected abstract void WriteAttributesCore(
     [NotNull] IssueDatasetWriter issueWriter,
     [NotNull] IRowBuffer rowBuffer,
     [NotNull] QualityCondition qualityCondition,
     [NotNull] QaError qaError);
        public ICollection <IObject> ChangeIssueType(
            [NotNull] IGdbTransaction transaction,
            [NotNull] IEnumerable <IObject> issueObjects,
            ErrorType newIssueType)
        {
            Assert.ArgumentNotNull(transaction, nameof(transaction));
            Assert.ArgumentNotNull(issueObjects, nameof(issueObjects));

            List <IObject> issueObjectList = issueObjects.ToList();
            var            modifiedObjects = new List <IObject>();

            if (issueObjectList.Count == 0)
            {
                return(modifiedObjects);
            }

            IDictionary <IObjectClass, IList <IObject> > objectsByClass =
                GdbObjectUtils.GroupObjectsByClass(issueObjectList);

            IWorkspace workspace = DatasetUtils.GetUniqueWorkspace(objectsByClass.Keys);

            if (workspace == null)
            {
                return(modifiedObjects);
            }

            transaction.Execute(
                workspace,
                delegate
            {
                foreach (KeyValuePair <IObjectClass, IList <IObject> > pair in objectsByClass)
                {
                    IObjectClass issueClass = pair.Key;
                    bool isFeatureClass     = issueClass is IFeatureClass;

                    int fieldIndexErrorType = issueClass.Fields.FindField(FieldNameErrorType);

                    foreach (IObject issueObject in pair.Value)
                    {
                        if (!CanChangeTo(newIssueType, issueObject, fieldIndexErrorType))
                        {
                            continue;
                        }

                        if (newIssueType == ErrorType.Allowed &&
                            isFeatureClass &&
                            IsTableIssueStoredWithReferenceGeometry(issueObject))
                        {
                            // move to issue table without geometry
                            IssueDatasetWriter issueWriter =
                                IssueDatasets.GetIssueWriterNoGeometry();
                            ITable issueTable = issueWriter.Table;

                            IRow row = issueTable.CreateRow();
                            GdbObjectUtils.CopyAttributeValues(issueObject, row);

                            RemoveReferenceGeometryFlag(row);

                            int fieldIndexCopiedErrorType =
                                issueTable.FindField(FieldNameErrorType);
                            row.set_Value(fieldIndexCopiedErrorType, (int)newIssueType);
                            row.Store();

                            modifiedObjects.Add((IObject)row);

                            issueObject.Delete();
                        }
                        else
                        {
                            issueObject.set_Value(fieldIndexErrorType, (int)newIssueType);
                            issueObject.Store();

                            modifiedObjects.Add(issueObject);
                        }
                    }
                }
            }, "Changing issue type");

            return(modifiedObjects);
        }