Esempio n. 1
0
            private esriFieldType?DetermineFieldType([NotNull] string tableName,
                                                     [NotNull] string fieldName)
            {
                IObjectDataset objectDataset = _datasetResolver.GetDatasetByInvolvedRowTableName(
                    tableName, _qualityCondition);

                if (objectDataset == null)
                {
                    return(null);
                }

                ITable table = _datasetContext.OpenTable(objectDataset);

                if (table == null)
                {
                    return(null);
                }

                int fieldIndex = table.FindField(fieldName);

                if (fieldIndex < 0)
                {
                    return(null);
                }

                IField field = table.Fields.Field[fieldIndex];

                return(field.Type);
            }
Esempio n. 2
0
        private static IObject GetInvolvedObject(
            [NotNull] InvolvedRow involvedRow,
            [NotNull] QualityCondition qualityCondition,
            [NotNull] IDatasetContext datasetContext,
            [NotNull] IQualityConditionObjectDatasetResolver datasetResolver,
            [NotNull] out IObjectDataset objectDataset)
        {
            Assert.ArgumentNotNull(involvedRow, nameof(involvedRow));
            Assert.ArgumentNotNull(qualityCondition, nameof(qualityCondition));
            Assert.ArgumentCondition(!involvedRow.RepresentsEntireTable,
                                     "involved row represents entire table");
            Assert.ArgumentNotNull(datasetContext, nameof(datasetContext));

            //string gdbTableName = involvedRow.TableName;
            //objectDataset = Assert.NotNull(
            //    QualityVerificationUtils.GetInvolvedObjectDataset(gdbTableName,
            //                                                      qualityCondition,
            //                                                      datasetResolver),
            //    "object dataset not found for {0}", involvedRow.TableName);
            string gdbTableName = involvedRow.TableName;

            objectDataset = Assert.NotNull(
                datasetResolver.GetDatasetByGdbTableName(gdbTableName, qualityCondition),
                "object dataset not found for {0}", involvedRow.TableName);

            ITable table = datasetContext.OpenTable(objectDataset);

            // TODO REFACTORMODEL revise null handling
            Assert.NotNull(table, "Dataset not found in workspace: {0}", objectDataset.Name);

            // TODO batch!
            return((IObject)table.GetRow(involvedRow.OID));
        }
Esempio n. 3
0
        private object OpenKnownDatasetType(IDdxDataset dataset, Type knownType)
        {
            Assert.ArgumentNotNull(knownType, nameof(knownType));

            if (typeof(IFeatureClass) == knownType)
            {
                return(_datasetContext.OpenFeatureClass((IVectorDataset)dataset));
            }

            if (typeof(ITable) == knownType)
            {
                return(_datasetContext.OpenTable((IObjectDataset)dataset));
            }

            if (typeof(IMosaicDataset) == knownType)
            {
                return((IMosaicDataset)_datasetContext.OpenRasterDataset(
                           (IDdxRasterDataset)dataset));
            }

            if (typeof(IRasterDataset) == knownType)
            {
                return(_datasetContext.OpenRasterDataset((IDdxRasterDataset)dataset));
            }

            if (typeof(IRasterDataset2) == knownType)
            {
                return((IRasterDataset2)_datasetContext.OpenRasterDataset(
                           (IDdxRasterDataset)dataset));
            }

            throw new ArgumentException($"Unsupported data type {knownType}");
        }
Esempio n. 4
0
        private static IssueDatasetWriter CreateIssueWriter(
            [NotNull] IErrorDataset objectDataset,
            [NotNull] IDatasetContext datasetContext,
            [NotNull] IFieldIndexCache fieldIndexCache)
        {
            Assert.ArgumentNotNull(objectDataset, nameof(objectDataset));
            Assert.ArgumentNotNull(datasetContext, nameof(datasetContext));
            Assert.ArgumentNotNull(fieldIndexCache, nameof(fieldIndexCache));

            ITable table = datasetContext.OpenTable(objectDataset);

            return(table == null
                                       ? null
                                       : new IssueDatasetWriter(table, objectDataset, fieldIndexCache));
        }
Esempio n. 5
0
        private static IEnumerable <IRow> GetInvolvedRows(
            [NotNull] IErrorObject errorObject,
            [NotNull] IDatasetContext datasetContext,
            [NotNull] IQualityConditionRepository qualityConditionRepository,
            [NotNull] IQualityConditionObjectDatasetResolver datasetResolver)
        {
            IList <InvolvedRow> involved = RowParser.Parse(errorObject.RawInvolvedObjects);

            QualityCondition qualityCondition = GetQualityCondition(errorObject,
                                                                    qualityConditionRepository);

            if (qualityCondition == null)
            {
                yield break;
            }

            foreach (KeyValuePair <string, IList <int> > pair in
                     GetInvolvedObjectIDsByTableName(involved))
            {
                string      tableName = pair.Key;
                IList <int> objectIDs = pair.Value;

                IObjectDataset dataset =
                    datasetResolver.GetDatasetByInvolvedRowTableName(tableName, qualityCondition);
                if (dataset == null)
                {
                    continue;
                }

                ITable table;
                try
                {
                    table = datasetContext.OpenTable(dataset);
                }
                catch (Exception e)
                {
                    _msg.WarnFormat("Error getting involved rows for table {0}: {1}", tableName,
                                    e.Message);
                    continue;
                }

                if (table == null)
                {
                    continue;
                }

                IEnumerable <IRow> rows = TryGetRows(table, objectIDs);

                if (rows == null)
                {
                    // error already logged in TryGetRows()
                    continue;
                }

                foreach (IRow row in rows)
                {
                    if (GdbObjectUtils.IsDeleted(row))
                    {
                        // don't return deleted rows
                        continue;
                    }

                    yield return(row);
                }
            }
        }
Esempio n. 6
0
        private static ITable GetInvolvedTableAndQueryFilter(
            [NotNull] IObjectDataset involvedObjectDataset,
            [NotNull] IDatasetContext datasetContext,
            bool includeDateOfChangeField,
            [NotNull] out IQueryFilter queryFilter,
            out int dateOfChangeFieldIndex)
        {
            ITable result;

            try
            {
                result = datasetContext.OpenTable(involvedObjectDataset);
                Assert.NotNull(result, "Dataset not found in current context: {0}",
                               involvedObjectDataset.Name);
            }
            catch (Exception e)
            {
                string message;
                if (involvedObjectDataset.Deleted)
                {
                    message = string.Format(
                        "The dataset '{0}' referenced in allowed errors is registered as deleted, unable to open",
                        involvedObjectDataset.Name);
                }
                else
                {
                    message = string.Format(
                        "Error opening dataset '{0}' referenced in allowed errors: {1}",
                        involvedObjectDataset.Name,
                        e.Message);
                }

                throw new InvolvedTableOpenException(message, e);
            }

            queryFilter = new QueryFilterClass();

            var subfields = new List <string> {
                result.OIDFieldName
            };

            if (includeDateOfChangeField)
            {
                ObjectAttribute dateOfChangeAttribute =
                    involvedObjectDataset.GetAttribute(AttributeRole.DateOfChange);

                dateOfChangeFieldIndex =
                    dateOfChangeAttribute != null
                                                ? AttributeUtils.GetFieldIndex(result, dateOfChangeAttribute)
                                                : -1;

                if (dateOfChangeAttribute != null && dateOfChangeFieldIndex >= 0)
                {
                    subfields.Add(dateOfChangeAttribute.Name);
                }
            }
            else
            {
                dateOfChangeFieldIndex = -1;
            }

            GdbQueryUtils.SetSubFields(queryFilter, subfields);

            return(result);
        }