// todo daro: rafactor SelectionItemRepository(Dictionary<IWorkspaceContext, GdbTableIdentity>, Dictionary<GdbTableIdentity, List<long>>)
        public SelectionItemRepository(Dictionary <Geodatabase, List <Table> > tablesByGeodatabase,
                                       Dictionary <Table, List <long> > selection,
                                       IRepository stateRepository) : base(tablesByGeodatabase, stateRepository)
        {
            foreach (var pair in selection)
            {
                var          id          = new GdbTableIdentity(pair.Key);
                ISourceClass sourceClass = GeodatabaseBySourceClasses.Keys.FirstOrDefault(s => s.Uses(id));

                if (sourceClass == null)
                {
                    // todo daro: assert?
                    continue;
                }

                if (_oidsBySource.TryGetValue(sourceClass, out List <long> ids))
                {
                    // todo daro: assert?
                    //			  should never be the case because values of SourceClassesByGeodatabase should be distinct
                    ids.AddRange(ids);
                }
                else
                {
                    _oidsBySource.Add(sourceClass, pair.Value);
                }
            }
        }
Example #2
0
        protected override async Task SetStatusCoreAsync(IWorkItem item, ISourceClass source)
        {
            Table table = OpenFeatureClass(source);

            try
            {
                var databaseSourceClass = (DatabaseSourceClass)source;

                string description = GetOperationDescription(item.Status);

                _msg.Info($"{description}, {item.Proxy}");

                var operation = new EditOperation {
                    Name = description
                };

                string fieldName = databaseSourceClass.StatusFieldName;
                object value     = databaseSourceClass.GetValue(item.Status);

                operation.Modify(table, item.ObjectID, fieldName, value);

                await operation.ExecuteAsync();
            }
            catch (Exception e)
            {
                _msg.Error($"Error set status of work item {item.OID}, {item.Proxy}", e);
                throw;
            }
            finally
            {
                table?.Dispose();
            }
        }
Example #3
0
        protected virtual int CreateItemIDCore(Row row, ISourceClass source)
        {
            long oid = row.GetObjectID();

            // oid = 666, tableId = 42 => 42666
            return((int)(Math.Pow(10, Math.Floor(Math.Log10(oid) + 1)) * source.Id + oid));
        }
Example #4
0
 protected override void RefreshCore(IWorkItem item,
                                     ISourceClass sourceClass,
                                     Row row)
 {
     // todo daro: use AttributeReader?
     // todo daro: really needed here? Only geometry is updated but
     //			  the work itmes's state remains the same.
     item.Status = ((DatabaseSourceClass)sourceClass).GetStatus(row);
 }
Example #5
0
        //[CanBeNull]
        //protected Table OpenFeatureClass2([NotNull] ISourceClass sourceClass)
        //{
        //	return GeodatabaseBySourceClasses.TryGetValue(sourceClass, out Geodatabase gdb)
        //		       ? sourceClass.OpenFeatureClass(gdb)
        //		       : null;
        //}

        private ISourceClass CreateSourceClass(GdbTableIdentity identity, FeatureClassDefinition definition)
        {
            IAttributeReader attributeReader = CreateAttributeReaderCore(definition);

            WorkListStatusSchema statusSchema = CreateStatusSchemaCore(definition);

            ISourceClass sourceClass = CreateSourceClassCore(identity, attributeReader, statusSchema);

            return(sourceClass);
        }
Example #6
0
        public async Task SetStatus(IWorkItem item, WorkItemStatus status)
        {
            GdbTableIdentity tableId = item.Proxy.Table;

            ISourceClass source = GeodatabaseBySourceClasses.Keys.FirstOrDefault(s => s.Uses(tableId));

            Assert.NotNull(source);

            // todo daro: read / restore item again from db? restore pattern in case of failure?
            await SetStatusCoreAsync(item, source);
        }
Example #7
0
        private Row GetRow([NotNull] ISourceClass sourceClass, long oid)
        {
            var filter = new QueryFilter {
                ObjectIDs = new List <long> {
                    oid
                }
            };

            // todo daro: log message
            return(GetRowsCore(sourceClass, filter, recycle: true).FirstOrDefault());
        }
Example #8
0
        protected virtual IEnumerable <Row> GetRowsCore([NotNull] ISourceClass sourceClass, [CanBeNull] QueryFilter filter, bool recycle)
        {
            Table table = OpenFeatureClass(sourceClass);

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

            // Todo daro: check recycle
            foreach (Feature feature in GdbQueryUtils.GetRows <Feature>(
                         table, filter, recycle))
            {
                yield return(feature);
            }
        }
        protected override IEnumerable <Row> GetRowsCore(ISourceClass sourceClass, QueryFilter filter, bool recycle)
        {
            Assert.True(_oidsBySource.TryGetValue(sourceClass, out List <long> oids),
                        "unexpected source class");

            if (filter == null)
            {
                filter = new QueryFilter {
                    ObjectIDs = new ReadOnlyCollection <long>(oids)
                };
            }

            if (filter is SpatialQueryFilter spatialFilter)
            {
                spatialFilter.SearchOrder = SearchOrder.Attribute;
            }

            return(base.GetRowsCore(sourceClass, filter, recycle));
        }
Example #10
0
        private void RegisterDatasets(Dictionary <Geodatabase, List <Table> > tablesByGeodatabase)
        {
            foreach (var pair in tablesByGeodatabase)
            {
                Geodatabase geodatabase = pair.Key;
                var         definitions = geodatabase.GetDefinitions <FeatureClassDefinition>().ToLookup(d => d.GetName());

                foreach (Table table in pair.Value)
                {
                    var identity = new GdbTableIdentity(table);

                    FeatureClassDefinition definition = definitions[identity.Name].FirstOrDefault();

                    ISourceClass sourceClass = CreateSourceClass(identity, definition);

                    GeodatabaseBySourceClasses.Add(sourceClass, geodatabase);
                }
            }
        }
Example #11
0
        protected override IWorkItem CreateWorkItemCore(Row row, ISourceClass source)
        {
            int id = CreateItemIDCore(row, source);

            IAttributeReader reader = ((DatabaseSourceClass)source).AttributeReader;

            var item = new IssueItem(id, row)
            {
                Status = ((DatabaseSourceClass)source).GetStatus(row),

                IssueCode            = reader.GetValue <string>(row, Attributes.IssueCode),
                IssueCodeDescription = reader.GetValue <string>(row, Attributes.IssueCodeDescription),
                InvolvedObjects      = reader.GetValue <string>(row, Attributes.InvolvedObjects),
                QualityCondition     = reader.GetValue <string>(row, Attributes.QualityConditionName),
                TestName             = reader.GetValue <string>(row, Attributes.TestName),
                TestDescription      = reader.GetValue <string>(row, Attributes.TestDescription),
                TestType             = reader.GetValue <string>(row, Attributes.TestType),
                IssueSeverity        = reader.GetValue <string>(row, Attributes.IssueSeverity),
                StopCondition        = reader.GetValue <string>(row, Attributes.IsStopCondition),
                Category             = reader.GetValue <string>(row, Attributes.Category),
                AffectedComponent    = reader.GetValue <string>(row, Attributes.AffectedComponent),
                Url                          = reader.GetValue <string>(row, Attributes.Url),
                DoubleValue1                 = reader.GetValue <double?>(row, Attributes.DoubleValue1),
                DoubleValue2                 = reader.GetValue <double?>(row, Attributes.DoubleValue2),
                TextValue                    = reader.GetValue <string>(row, Attributes.TextValue),
                IssueAssignment              = reader.GetValue <string>(row, Attributes.IssueAssignment),
                QualityConditionUuid         = reader.GetValue <string>(row, Attributes.QualityConditionUuid),
                QualityConditionVersionUuid  = reader.GetValue <string>(row, Attributes.QualityConditionVersionUuid),
                ExceptionStatus              = reader.GetValue <string>(row, Attributes.ExceptionStatus),
                ExceptionNotes               = reader.GetValue <string>(row, Attributes.ExceptionNotes),
                ExceptionCategory            = reader.GetValue <string>(row, Attributes.ExceptionCategory),
                ExceptionOrigin              = reader.GetValue <string>(row, Attributes.ExceptionOrigin),
                ExceptionDefinedDate         = reader.GetValue <string>(row, Attributes.ExceptionDefinedDate),
                ExceptionLastRevisionDate    = reader.GetValue <string>(row, Attributes.ExceptionLastRevisionDate),
                ExceptionRetirementDate      = reader.GetValue <string>(row, Attributes.ExceptionRetirementDate),
                ExceptionShapeMatchCriterion = reader.GetValue <string>(row, Attributes.ExceptionShapeMatchCriterion)
            };

            item.InIssueInvolvedTables = IssueUtils.ParseInvolvedTables(item.InvolvedObjects);

            return(RefreshState(item));
        }
Example #12
0
        public void Refresh(IWorkItem item)
        {
            GdbTableIdentity tableId = item.Proxy.Table;

            // todo daro: log message
            ISourceClass source = GeodatabaseBySourceClasses.Keys.FirstOrDefault(sc => sc.Uses(tableId));

            Assert.NotNull(source);

            Row row = GetRow(source, item.Proxy.ObjectId);

            Assert.NotNull(row);

            if (row is Feature feature)
            {
                ((WorkItem)item).SetGeometryFromFeature(feature);
            }

            RefreshCore(item, source, row);
        }
Example #13
0
 protected virtual Task SetStatusCoreAsync([NotNull] IWorkItem item,
                                           [NotNull] ISourceClass source)
 {
     return(Task.FromResult(0));
 }
        protected override IWorkItem CreateWorkItemCore(Row row, ISourceClass source)
        {
            int id = CreateItemIDCore(row, source);

            return(RefreshState(new SelectionItem(id, row)));
        }
Example #15
0
 protected abstract IWorkItem CreateWorkItemCore([NotNull] Row row, ISourceClass source);
Example #16
0
 protected override async Task SetStatusCoreAsync(IWorkItem item, ISourceClass source)
 {
     await Task.Run(() => WorkItemStateRepository.Update(item));
 }
Example #17
0
 protected virtual void RefreshCore([NotNull] IWorkItem item,
                                    [NotNull] ISourceClass sourceClass,
                                    [NotNull] Row row)
 {
 }
Example #18
0
 protected Table OpenFeatureClass([NotNull] ISourceClass sourceClass)
 {
     return(GeodatabaseBySourceClasses.TryGetValue(sourceClass, out Geodatabase gdb)
                                ? gdb.OpenDataset <Table>(sourceClass.Name)
                                : null);
 }