Beispiel #1
0
        /// <summary>
        /// Constructor for the sub grid retriever helper
        /// </summary>
        /// <param name="siteModel">The project this sub gris is being retrieved from</param>
        /// <param name="gridDataType">The type of client grid data sub grids to be returned by this retriever</param>
        /// <param name="storageProxy">The Ignite storage proxy to be used when requesting data from the persistent store</param>
        /// <param name="filter">The TRex spatial and attribute filtering description for the request</param>
        /// <param name="filterAnnex">An annex of data related to cell by cell filtering where the attributes related to that cell may change from cell to cell</param>
        /// <param name="hasOverrideSpatialCellRestriction">The spatially selected cells are masked by a rectangular restriction boundary</param>
        /// <param name="overrideSpatialCellRestriction"></param>
        /// <param name="prepareGridForCacheStorageIfNoSieving">The cell coordinate bounding box restricting cells involved in the request</param>
        /// <param name="maxNumberOfPassesToReturn">The maximum number of passes in a cell in a sub grid that will be considered when processing the request</param>
        /// <param name="areaControlSet">The skip/step area control set for selection of cells with sub grids for processing. Cells not identified by the control set will return null values.</param>
        /// <param name="populationControl">The delegate responsible for populating events depended on for processing the request.</param>
        /// <param name="pDExistenceMap">The production data existence map for the project the request relates to</param>
        /// <param name="overrides">The set of overriding machine event values to use</param>
        /// <param name="liftParams">The set of layer/lift analysis parameters to use</param>
        public ProgressiveVolumesSubGridRetriever(ISiteModel siteModel,
                                                  GridDataType gridDataType,
                                                  IStorageProxy storageProxy,
                                                  ICombinedFilter filter,
                                                  ICellPassAttributeFilterProcessingAnnex filterAnnex,
                                                  bool hasOverrideSpatialCellRestriction,
                                                  BoundingIntegerExtent2D overrideSpatialCellRestriction,
                                                  bool prepareGridForCacheStorageIfNoSieving,
                                                  int maxNumberOfPassesToReturn,
                                                  AreaControlSet areaControlSet,
                                                  IFilteredValuePopulationControl populationControl,
                                                  ISubGridTreeBitMask pDExistenceMap,
                                                  IOverrideParameters overrides,
                                                  ILiftParameters liftParams)
            : base(siteModel, gridDataType, filter, filterAnnex,
                   hasOverrideSpatialCellRestriction, overrideSpatialCellRestriction, prepareGridForCacheStorageIfNoSieving, maxNumberOfPassesToReturn,
                   storageProxy, areaControlSet, populationControl, pDExistenceMap, overrides, liftParams)
        {
            // Clear any time element from the supplied filter. Time constraints ar derived from the startDate and endDate parameters
            filter.AttributeFilter.HasTimeFilter = false;

            // Clear any instruction in the filter to extract the earliest value - this has no meaning in progressive calculations
            filter.AttributeFilter.ReturnEarliestFilteredCellPass = false;

            // Remove any first/last/highest/lowest aspect from the filter - this has no meaning in progressive calculations
            filter.AttributeFilter.HasElevationTypeFilter = false;

            // Remove any machine filtering - the intent here is to examine volume progression over time, machine breakdowns don't make sense at this point
            filter.AttributeFilter.HasMachineFilter = false;
        }
Beispiel #2
0
 /// <summary>
 /// Removes all the event elements for all machines within the site model
 /// </summary>
 private void RemovalAllMachineEvents(IStorageProxy storageProxy, bool exceptOverrideEvents)
 {
     foreach (var machine in _siteModel.Machines)
     {
         _siteModel.MachinesTargetValues[machine.InternalSiteModelMachineIndex]?.RemoveMachineEventsFromPersistentStore(storageProxy, exceptOverrideEvents);
     }
 }
Beispiel #3
0
        /// <summary>
        /// Remove the design list for a site model from the persistent store
        /// </summary>
        public bool Remove(Guid siteModelId, IStorageProxy storageProxy)
        {
            // First remove all the existence maps associated with the designs
            var designs = Load(siteModelId);

            designs.ForEach(x =>
            {
                FileSystemErrorStatus result;
                var filename = BaseExistenceMapRequest.CacheKeyString(ExistenceMaps.Interfaces.Consts.EXISTENCE_MAP_DESIGN_DESCRIPTOR, x.ID);
                if ((result = storageProxy.RemoveStreamFromPersistentStore(siteModelId, FileSystemStreamType.DesignTopologyExistenceMap, filename)) != FileSystemErrorStatus.OK)
                {
                    _log.LogWarning($"Unable to remove existence map for design {x.ID}, filename = {filename}, with result: {result}");
                }
            });

            // Then remove the designs list stream itself
            var result = storageProxy.RemoveStreamFromPersistentStore(siteModelId, FileSystemStreamType.Designs, DESIGNS_STREAM_NAME);

            if (result != FileSystemErrorStatus.OK)
            {
                _log.LogInformation($"Removing designs list from project {siteModelId} failed with error {result}");
            }

            return(result == FileSystemErrorStatus.OK);
        }
Beispiel #4
0
        /// <summary>
        /// Removes all sub grid directory and segment information in the site model
        /// </summary>
        private bool RemoveAllSpatialCellPassData(IStorageProxy storageProxy)
        {
            var subGridRemovalSuccessful = true;

            _siteModel.ExistenceMap.ScanAllSetBitsAsSubGridAddresses(address =>
            {
                var filename = ServerSubGridTree.GetLeafSubGridFullFileName(address);
                var leaf     = new ServerSubGridTreeLeaf(_siteModel.Grid, null, SubGridTreeConsts.SubGridTreeLevels, StorageMutability.Mutable)
                {
                    OriginX = address.X,
                    OriginY = address.Y
                };
                leaf.LoadDirectoryFromFile(storageProxy, filename);

                leaf.Directory.SegmentDirectory.ForEach(segmentInfo =>
                {
                    var segmentFilename = ServerSubGridTree.GetLeafSubGridSegmentFullFileName(leaf.OriginAsCellAddress(), segmentInfo);
                    if (!leaf.RemoveSegmentFromStorage(storageProxy, segmentFilename, segmentInfo))
                    {
                        _log.LogError($"Failed to remove segment {segmentFilename} sub grid: {leaf.Moniker()}");
                        subGridRemovalSuccessful = false;
                    }
                });

                if (!leaf.RemoveDirectoryFromStorage(storageProxy, filename))
                {
                    _log.LogError($"Failed to remove directory for server sub grid leaf: {leaf.Moniker()}");
                    subGridRemovalSuccessful = false;
                }
            });

            return(subGridRemovalSuccessful);
        }
Beispiel #5
0
        public void TestThatCreateUpdateCommandReturnsSqlCommandForUpdate(bool hasDescription)
        {
            Guid         identifier            = Guid.NewGuid();
            Guid         householdIdentifier   = Guid.NewGuid();
            IHousehold   householdMock         = DomainObjectMockBuilder.BuildHouseholdMock(householdIdentifier);
            int          sortOrder             = GetLegalSortOrder();
            Guid         storageTypeIdentifier = Guid.NewGuid();
            IStorageType storageTypeMock       = DomainObjectMockBuilder.BuildStorageTypeMock(storageTypeIdentifier);
            int          temperature           = GetLegalTemperature(storageTypeMock.TemperatureRange);
            DateTime     creationTime          = DateTime.Now;
            string       description           = hasDescription ? _fixture.Create <string>() : null;

            IStorageProxy sut = CreateSut(identifier, householdMock, sortOrder, storageTypeMock, temperature, creationTime, description);

            Assert.That(sut, Is.Not.Null);

            // ReSharper disable StringLiteralTypo
            new DbCommandTestBuilder("UPDATE Storages SET HouseholdIdentifier=@householdIdentifier,SortOrder=@sortOrder,StorageTypeIdentifier=@storageTypeIdentifier,Descr=@descr,Temperature=@temperature,CreationTime=@creationTime WHERE StorageIdentifier=@storageIdentifier")
            // ReSharper restore StringLiteralTypo
            .AddCharDataParameter("@storageIdentifier", identifier)
            .AddCharDataParameter("@householdIdentifier", householdIdentifier)
            .AddTinyIntDataParameter("@sortOrder", sortOrder, 4)
            .AddCharDataParameter("@storageTypeIdentifier", storageTypeIdentifier)
            // ReSharper disable StringLiteralTypo
            .AddVarCharDataParameter("@descr", description, 2048, true)
            // ReSharper restore StringLiteralTypo
            .AddTinyIntDataParameter("@temperature", temperature, 4)
            .AddDateTimeDataParameter("@creationTime", creationTime.ToUniversalTime())
            .Build()
            .Run(sut.CreateUpdateCommand());
        }
Beispiel #6
0
        public SubGridTreeIterator(IStorageProxy storageProxy,
                                   bool subGridsInServerDiskStore)
        {
            // FDataStoreCache = ADataStoreCache;

            _subGridsInServerDiskStore = subGridsInServerDiskStore;
            _storageProxy = storageProxy;
        }
Beispiel #7
0
        /// <summary>
        /// Cleaves all dirty segments requiring cleaving within the given sub grid
        /// </summary>
        public void PerformSegmentCleaving(IStorageProxy storageProxyForSubGridSegments, IServerLeafSubGrid subGrid, int subGridSegmentPassCountLimit = 0)
        {
            var iterator = new SubGridSegmentIterator(subGrid, storageProxyForSubGridSegments)
            {
                IterationDirection = IterationDirection.Forwards,
                ReturnDirtyOnly    = true,
                RetrieveAllPasses  = true
            };

            var origin = new SubGridCellAddress(subGrid.OriginX, subGrid.OriginY);

            if (!iterator.MoveToFirstSubGridSegment())
            {
                return;
            }

            do
            {
                var segment = iterator.CurrentSubGridSegment;

                var cleavedTimeRangeStart = segment.SegmentInfo.StartTime;
                var cleavedTimeRangeEnd   = segment.SegmentInfo.EndTime;

                if (!segment.RequiresCleaving(out var totalPassCount, out var maximumPassCount))
                {
                    continue;
                }

                if (subGrid.Cells.CleaveSegment(segment, NewSegmentsFromCleaving, PersistedClovenSegments, subGridSegmentPassCountLimit))
                {
                    iterator.SegmentListExtended();

                    if (_segmentCleavingOperationsToLog)
                    {
                        _log.LogInformation(
                            $"Info: Performed cleave on segment ({cleavedTimeRangeStart}-{cleavedTimeRangeEnd}) of sub grid {ServerSubGridTree.GetLeafSubGridFullFileName(origin)}. TotalPassCount = {totalPassCount} MaximumPassCount = {maximumPassCount}");
                    }
                }
                else
                {
                    // The segment cleave failed. While this is not a serious problem (as the sub grid will be
                    // cleaved at some point in the future when it is modified again via tag file processing etc)
                    // it will be noted in the log.

                    _log.LogWarning(
                        $"Cleave on segment ({cleavedTimeRangeStart}-{cleavedTimeRangeEnd}) of sub grid {ServerSubGridTree.GetLeafSubGridFullFileName(origin)} failed. TotalPassCount = {totalPassCount} MaximumPassCount = {maximumPassCount}");
                }

                if (_segmentCleavingOperationsToLog)
                {
                    if (segment.RequiresCleaving(out totalPassCount, out maximumPassCount))
                    {
                        _log.LogWarning(
                            $"Cleave on segment ({cleavedTimeRangeStart}-{cleavedTimeRangeEnd}) of sub grid {subGrid.Moniker()} failed to reduce cell pass count below maximums (max passes = {totalPassCount}/{subGridSegmentPassCountLimit}, per cell = {maximumPassCount}/{_subGridMaxSegmentCellPassesLimit})");
                    }
                }
            } while (iterator.MoveToNextSubGridSegment());
        }
Beispiel #8
0
        /*
         * /// <summary>
         * /// The version number to stamp spatial data elements with generated by this worker.
         * /// Commented out pending requirement for request based consistency requiring a sub grid version map
         * /// </summary>
         * //private long EpochVersion { get; } = DateTime.UtcNow.Ticks;
         */

        /// <summary>
        /// Constructor the initializes state ready for integration. Not that two storage proxies are provided - one to store sub grid dictionary/headers, and one to store segments
        /// so that they can be committed to the persistent store safely (ie: segments first, then headers).
        /// </summary>
        /// <param name="source">The sub grid tree from which information is being integrated</param>
        /// <param name="siteModel">The site model representing the target sub grid tree</param>
        /// <param name="target">The sub grid tree into which the data from the source sub grid tree is integrated</param>
        /// <param name="storageProxySubGrids">The storage proxy providing storage semantics for persisting integration results relating to sub grids (specifically the header/dictionary representation)</param>
        /// <param name="storageProxySubGridSegments">The storage proxy providing storage semantics for persisting integration results relating to sub grid segments</param>
        public SubGridIntegrator(IServerSubGridTree source, ISiteModel siteModel, IServerSubGridTree target,
                                 IStorageProxy storageProxySubGrids, IStorageProxy storageProxySubGridSegments)
        {
            _source                      = source;
            _siteModel                   = siteModel;
            _target                      = target;
            _storageProxySubGrids        = storageProxySubGrids;
            _storageProxySubGridSegments = storageProxySubGridSegments;
        }
Beispiel #9
0
        public void TestThatDeleteRelationsThrowsArgumentNullExceptionIfDataProviderIsNull()
        {
            IStorageProxy sut = CreateSut();

            Assert.That(sut, Is.Not.Null);

            ArgumentNullException result = Assert.Throws <ArgumentNullException>(() => sut.DeleteRelations(null));

            TestHelper.AssertArgumentNullExceptionIsValid(result, "dataProvider");
        }
Beispiel #10
0
        public void TestThatMapDataThrowsArgumentNullExceptionIfDataReaderIsNull()
        {
            IStorageProxy sut = CreateSut();

            Assert.That(sut, Is.Not.Null);

            ArgumentNullException result = Assert.Throws <ArgumentNullException>(() => sut.MapData(null, CreateFoodWasteDataProvider()));

            TestHelper.AssertArgumentNullExceptionIsValid(result, "dataReader");
        }
Beispiel #11
0
        public void TestThatCreateThrowsArgumentNullExceptionIfColumnNameCollectionIsNull()
        {
            IStorageProxy sut = CreateSut();

            Assert.That(sut, Is.Not.Null);

            ArgumentNullException result = Assert.Throws <ArgumentNullException>(() => sut.Create(CreateMySqlDataReader(), CreateFoodWasteDataProvider(), null));

            TestHelper.AssertArgumentNullExceptionIsValid(result, "columnNameCollection");
        }
Beispiel #12
0
        public void TestThatCreateThrowsArgumentNullExceptionIfDataProviderIsNull()
        {
            IStorageProxy sut = CreateSut();

            Assert.That(sut, Is.Not.Null);

            ArgumentNullException result = Assert.Throws <ArgumentNullException>(() => sut.Create(CreateMySqlDataReader(), null, _fixture.Create <string>(), _fixture.Create <string>(), _fixture.Create <string>()));

            TestHelper.AssertArgumentNullExceptionIsValid(result, "dataProvider");
        }
Beispiel #13
0
        /// <summary>
        /// Remove the alignments list for a site model from the persistent store
        /// </summary>
        public bool Remove(Guid siteModelId, IStorageProxy storageProxy)
        {
            var result = storageProxy.RemoveStreamFromPersistentStore(siteModelId, FileSystemStreamType.Designs, ALIGNMENTS_STREAM_NAME);

            if (result != FileSystemErrorStatus.OK)
            {
                _log.LogInformation($"Removing alignments list from project {siteModelId} failed with error {result}");
            }

            return(result == FileSystemErrorStatus.OK);
        }
Beispiel #14
0
        public bool SaveToFile(IStorageProxy storage,
                               string FileName,
                               out FileSystemErrorStatus FSError)
        {
            bool Result;

            FSError = FileSystemErrorStatus.OK;

            CalculateElevationRangeOfPasses();

            if (_segmentCleavingOperationsToLog || _itemsPersistedViaDataPersistorToLog)
            {
                PassesData.CalculateTotalPasses(out int TotalPasses, out _, out int MaxPasses);

                if (_segmentCleavingOperationsToLog && TotalPasses > _subGridSegmentPassCountLimit)
                {
                    Log.LogDebug($"Saving segment {FileName} with {TotalPasses} cell passes (max:{MaxPasses}) which violates the maximum number of cell passes within a segment ({_subGridSegmentPassCountLimit})");
                }

                if (_itemsPersistedViaDataPersistorToLog)
                {
                    Log.LogDebug($"Saving segment {FileName} with {TotalPasses} cell passes (max:{MaxPasses})");
                }
            }

            using (var stream = RecyclableMemoryStreamManagerHelper.Manager.GetStream())
            {
                using (var writer = new BinaryWriter(stream, Encoding.UTF8, true))
                {
                    Result = Write(writer);
                }

                // Log.LogInformation($"Segment persistence stream (uncompressed) for segment {FileName} containing {PassesData.SegmentPassCount} cell passes using storage proxy {storage.Mutability} is {MStream.Length} bytes (average = {MStream.Length / (1.0 * PassesData.SegmentPassCount)})");

                if (Result)
                {
                    FSError = storage.WriteSpatialStreamToPersistentStore(
                        Owner.Owner.ID,
                        FileName,
                        Owner.OriginX, Owner.OriginY,
                        SegmentInfo.StartTime.Ticks,
                        SegmentInfo.EndTime.Ticks,
                        SegmentInfo.Version,
                        FileSystemStreamType.SubGridSegment,
                        stream,
                        this);

                    Result = FSError == FileSystemErrorStatus.OK;
                }
            }

            return(Result);
        }
Beispiel #15
0
        public void TestThatMapRelationsDoesNotCloneDataProvider()
        {
            IStorageProxy sut = CreateSut();

            Assert.That(sut, Is.Not.Null);

            IFoodWasteDataProvider dataProvider = CreateFoodWasteDataProvider();

            sut.MapRelations(dataProvider);

            dataProvider.AssertWasNotCalled(m => m.Clone());
        }
Beispiel #16
0
        public void TestThatDeleteRelationsThrowsIntranetRepositoryExceptionWhenIdentifierIsNull()
        {
            IStorageProxy sut = CreateSut();

            Assert.That(sut, Is.Not.Null);
            Assert.That(sut.Identifier, Is.Null);
            Assert.That(sut.Identifier.HasValue, Is.False);

            IntranetRepositoryException result = Assert.Throws <IntranetRepositoryException>(() => sut.DeleteRelations(CreateFoodWasteDataProvider()));

            TestHelper.AssertIntranetRepositoryExceptionIsValid(result, ExceptionMessage.IllegalValue, sut.Identifier, "Identifier");
        }
Beispiel #17
0
        /// <summary>
        /// Loads the content of the machines list from the persistent store. If there is no item in the persistent store containing
        /// machines for this site model them return an empty list.
        /// </summary>
        public void LoadFromPersistentStore(IStorageProxy storageProxy)
        {
            storageProxy.ReadStreamFromPersistentStore(DataModelID, MACHINES_LIST_STREAM_NAME, FileSystemStreamType.Machines, out MemoryStream MS);
            if (MS == null)
            {
                return;
            }

            using (MS)
            {
                this.FromStream(MS);
            }
        }
Beispiel #18
0
        /// <summary>
        /// Loads the content of the proofing run list from the persistent store. If there is no item in the persistent store containing
        /// proofing runs for this site model them return an empty list.
        /// </summary>
        public void LoadFromPersistentStore(Guid projectUid, IStorageProxy storageProxy)
        {
            storageProxy.ReadStreamFromPersistentStore(projectUid, LIST_STREAM_NAME, FileSystemStreamType.MachineDesigns, out var ms);
            if (ms == null)
            {
                return;
            }

            using (ms)
            {
                this.FromStream(ms);
            }
        }
Beispiel #19
0
        /// <summary>
        /// Loads the content of the proofing run list from the persistent store. If there is no item in the persistent store containing
        /// proofing runs for this site model them return an empty list.
        /// </summary>
        public void LoadFromPersistentStore(IStorageProxy storageProxy)
        {
            storageProxy.ReadStreamFromPersistentStore(DataModelID, PROOFING_RUN_LIST_STREAM_NAME, FileSystemStreamType.ProofingRuns, out MemoryStream ms);
            if (ms == null)
            {
                return;
            }

            using (ms)
            {
                this.FromStream(ms);
            }
        }
Beispiel #20
0
        public void TestThatConstructorInitializeStorageProxy()
        {
            IStorageProxy sut = CreateSut();

            Assert.That(sut, Is.Not.Null);
            Assert.That(sut.Identifier, Is.Null);
            Assert.That(sut.Identifier.HasValue, Is.False);
            Assert.That(sut.Household, Is.Null);
            Assert.That(sut.SortOrder, Is.EqualTo(default(int)));
            Assert.That(sut.StorageType, Is.Null);
            Assert.That(sut.Description, Is.Null);
            Assert.That(sut.Temperature, Is.EqualTo(default(int)));
            Assert.That(sut.CreationTime, Is.EqualTo(default(DateTime)));
        }
Beispiel #21
0
        public void TestThatCreateGetCommandReturnsSqlQueryForId()
        {
            Guid identifier = Guid.NewGuid();

            IStorageProxy sut = CreateSut(identifier);

            Assert.That(sut, Is.Not.Null);

            // ReSharper disable StringLiteralTypo
            new DbCommandTestBuilder("SELECT s.StorageIdentifier,s.HouseholdIdentifier,s.SortOrder,s.StorageTypeIdentifier,s.Descr,s.Temperature,s.CreationTime,h.Name AS HouseholdName,h.Descr AS HouseholdDescr,h.CreationTime AS HouseholdCreationTime,st.SortOrder AS StorageTypeSortOrder,st.Temperature AS StorageTypeTemperature,st.TemperatureRangeStartValue AS StorageTypeTemperatureRangeStartValue,st.TemperatureRangeEndValue AS StorageTypeTemperatureRangeEndValue,st.Creatable AS StorageTypeCreatable,st.Editable AS StorageTypeEditable,st.Deletable AS StorageTypeDeletable FROM Storages AS s INNER JOIN Households AS h ON h.HouseholdIdentifier=s.HouseholdIdentifier INNER JOIN StorageTypes AS st ON st.StorageTypeIdentifier=s.StorageTypeIdentifier WHERE s.StorageIdentifier=@storageIdentifier")
            // ReSharper restore StringLiteralTypo
            .AddCharDataParameter("@storageIdentifier", identifier)
            .Build()
            .Run(sut.CreateGetCommand());
        }
Beispiel #22
0
        public void TestThatUniqueIdGetterThrowsIntranetRepositoryExceptionWhenStorageHasNoIdentifier()
        {
            IStorageProxy sut = CreateSut();

            Assert.That(sut, Is.Not.Null);
            Assert.That(sut.Identifier, Is.Null);
            Assert.That(sut.Identifier.HasValue, Is.False);

            // ReSharper disable ReturnValueOfPureMethodIsNotUsed
            IntranetRepositoryException result = Assert.Throws <IntranetRepositoryException>(() => sut.UniqueId.ToUpper());

            // ReSharper restore ReturnValueOfPureMethodIsNotUsed

            TestHelper.AssertIntranetRepositoryExceptionIsValid(result, ExceptionMessage.IllegalValue, sut.Identifier, "Identifier");
        }
Beispiel #23
0
        public void TestThatUniqueIdGetterGetsUniqueIdentificationForStorageProxy()
        {
            Guid identifier = Guid.NewGuid();

            IStorageProxy sut = CreateSut(identifier);

            Assert.That(sut, Is.Not.Null);
            Assert.That(sut.Identifier, Is.Not.Null);

            string uniqueId = sut.UniqueId;

            Assert.That(uniqueId, Is.Not.Null);
            Assert.That(uniqueId, Is.Not.Empty);
            Assert.That(uniqueId, Is.EqualTo(identifier.ToString("D").ToUpper()));
        }
Beispiel #24
0
        public void TestThatCreateDeleteCommandReturnsSqlCommandForDelete()
        {
            Guid identifier = Guid.NewGuid();

            IStorageProxy sut = CreateSut(identifier);

            Assert.That(sut, Is.Not.Null);

            // ReSharper disable StringLiteralTypo
            new DbCommandTestBuilder("DELETE FROM Storages WHERE StorageIdentifier=@storageIdentifier")
            // ReSharper restore StringLiteralTypo
            .AddCharDataParameter("@storageIdentifier", identifier)
            .Build()
            .Run(sut.CreateDeleteCommand());
        }
Beispiel #25
0
 /// <summary>
 /// Constructor for the sub grid retriever helper
 /// </summary>
 /// <param name="siteModel">The project this sub gris is being retrieved from</param>
 /// <param name="gridDataType">The type of client grid data sub grids to be returned by this retriever</param>
 /// <param name="storageProxy">The Ignite storage proxy to be used when requesting data from the persistent store</param>
 /// <param name="filter">The TRex spatial and attribute filtering description for the request</param>
 /// <param name="filterAnnex">An annex of data related to cell by cell filtering where the attributes related to that cell may change from cell to cell</param>
 /// <param name="hasOverrideSpatialCellRestriction">The spatially selected cells are masked by a rectangular restriction boundary</param>
 /// <param name="overrideSpatialCellRestriction"></param>
 /// <param name="prepareGridForCacheStorageIfNoSieving">The cell coordinate bounding box restricting cells involved in the request</param>
 /// <param name="maxNumberOfPassesToReturn">The maximum number of passes in a cell in a sub grid that will be considered when processing the request</param>
 /// <param name="areaControlSet">The skip/step area control set for selection of cells with sub grids for processing. Cells not identified by the control set will return null values.</param>
 /// <param name="populationControl">The delegate responsible for populating events depended on for processing the request.</param>
 /// <param name="pDExistenceMap">The production data existence map for the project the request relates to</param>
 /// <param name="overrides">The set of overriding machine event values to use</param>
 /// <param name="liftParams">The set of layer/lift analysis parameters to use</param>
 public SubGridRetriever(ISiteModel siteModel,
                         GridDataType gridDataType,
                         IStorageProxy storageProxy,
                         ICombinedFilter filter,
                         ICellPassAttributeFilterProcessingAnnex filterAnnex,
                         bool hasOverrideSpatialCellRestriction,
                         BoundingIntegerExtent2D overrideSpatialCellRestriction,
                         bool prepareGridForCacheStorageIfNoSieving,
                         int maxNumberOfPassesToReturn,
                         AreaControlSet areaControlSet,
                         IFilteredValuePopulationControl populationControl,
                         ISubGridTreeBitMask pDExistenceMap,
                         IOverrideParameters overrides,
                         ILiftParameters liftParams)
     : base(siteModel, gridDataType, filter, filterAnnex,
            hasOverrideSpatialCellRestriction, overrideSpatialCellRestriction, prepareGridForCacheStorageIfNoSieving, maxNumberOfPassesToReturn,
            storageProxy, areaControlSet, populationControl, pDExistenceMap, overrides, liftParams)
 {
 }
Beispiel #26
0
        protected SubGridRetrieverBase(ISiteModel siteModel,
                                       GridDataType gridDataType,
                                       ICombinedFilter filter,
                                       ICellPassAttributeFilterProcessingAnnex filterAnnex,
                                       bool hasOverrideSpatialCellRestriction,
                                       BoundingIntegerExtent2D overrideSpatialCellRestriction,
                                       bool prepareGridForCacheStorageIfNoSieving,
                                       int maxNumberOfPassesToReturn,
                                       IStorageProxy storageProxy,
                                       AreaControlSet areaControlSet,
                                       IFilteredValuePopulationControl populationControl,
                                       ISubGridTreeBitMask pDExistenceMap,
                                       IOverrideParameters overrides,
                                       ILiftParameters liftParams)
        {
            _segmentIterator  = null;
            _cellPassIterator = null;

            _siteModel    = siteModel;
            _gridDataType = gridDataType;
            _filter       = filter;
            _filterAnnex  = filterAnnex;
            _hasOverrideSpatialCellRestriction     = hasOverrideSpatialCellRestriction;
            _overrideSpatialCellRestriction        = overrideSpatialCellRestriction;
            _prepareGridForCacheStorageIfNoSieving = prepareGridForCacheStorageIfNoSieving;
            _maxNumberOfPassesToReturn             = maxNumberOfPassesToReturn;
            _storageProxy      = storageProxy;
            _populationControl = populationControl;
            _areaControlSet    = areaControlSet;
            _pdExistenceMap    = pDExistenceMap;
            _overrides         = overrides;
            _liftParams        = liftParams;

            // Create and configure the assignment context which is used to contain a filtered pass and
            // its attendant machine events and target values prior to assignment to the client sub grid.
            _assignmentContext = new FilteredValueAssignmentContext {
                Overrides = overrides, LiftParams = liftParams
            };

            _filter.AttributeFilter.SiteModel = siteModel;

            _canUseGlobalLatestCells = _filter.AttributeFilter.LastRecordedCellPassSatisfiesFilter;
        }
Beispiel #27
0
        /// <summary>
        /// Sets a reference to a storage proxy that proxies the immutable data store for this mutable data store
        /// </summary>
        /// <param name="immutableProxy"></param>
        public void SetImmutableStorageProxy(IStorageProxy immutableProxy)
        {
            if (Mutability != StorageMutability.Mutable)
            {
                throw new ArgumentException("Non-mutable storage proxy may not accept an immutable storage proxy reference");
            }

            if (immutableProxy == null)
            {
                throw new ArgumentException("Null immutable storage proxy reference supplied to SetImmutableStorageProxy()");
            }

            if (immutableProxy.Mutability != StorageMutability.Immutable)
            {
                throw new ArgumentException("Immutable storage proxy reference is not marked with Immutable mutability");
            }

            ImmutableProxy = immutableProxy;
        }
Beispiel #28
0
        /// <summary>
        /// Remove the surveyed surface list for a site model from the persistent store
        /// </summary>
        public bool Remove(Guid siteModelUid, IStorageProxy storageProxy)
        {
            // First remove all the existence maps associated with the surveyed surfaces
            foreach (var surveyedSurface in Load(siteModelUid))
            {
                FileSystemErrorStatus fsResult;
                var filename = BaseExistenceMapRequest.CacheKeyString(ExistenceMaps.Interfaces.Consts.EXISTENCE_SURVEYED_SURFACE_DESCRIPTOR, surveyedSurface.ID);
                if ((fsResult = storageProxy.RemoveStreamFromPersistentStore(siteModelUid, FileSystemStreamType.DesignTopologyExistenceMap, filename)) != FileSystemErrorStatus.OK)
                {
                    _log.LogWarning($"Unable to remove existence map for surveyed surface {surveyedSurface.ID}, filename = {filename}, in project {siteModelUid} with result: {fsResult}");
                }
            }

            // Then remove the surveyed surface list stream itself
            var result = storageProxy.RemoveStreamFromPersistentStore(siteModelUid, FileSystemStreamType.Designs, SURVEYED_SURFACE_STREAM_NAME);

            if (result != FileSystemErrorStatus.OK)
            {
                _log.LogInformation($"Removing surveyed surfaces list from project {siteModelUid} failed with error {result}");
            }

            return(result == FileSystemErrorStatus.OK);
        }
Beispiel #29
0
 public BestPerformerUpdater(IStorageProxy proxy)
 {
     _proxy = proxy;
 }
Beispiel #30
0
        public ISubGridRetriever Instance(ISubGridsRequestArgument subGridsRequestArgument,
                                          ISiteModel siteModel,
                                          GridDataType gridDataType,
                                          IStorageProxy storageProxy,
                                          ICombinedFilter filter,
                                          ICellPassAttributeFilterProcessingAnnex filterAnnex,
                                          bool hasOverrideSpatialCellRestriction,
                                          BoundingIntegerExtent2D overrideSpatialCellRestriction,
                                          int maxNumberOfPassesToReturn,
                                          AreaControlSet areaControlSet,
                                          IFilteredValuePopulationControl populationControl,
                                          ISubGridTreeBitMask pdExistenceMap,
                                          ITRexSpatialMemoryCacheContext[] subGridCacheContexts,
                                          IOverrideParameters overrides,
                                          ILiftParameters liftParams)
        {
            if (gridDataType == GridDataType.ProgressiveVolumes)
            {
                var retriever = new ProgressiveVolumesSubGridRetriever(siteModel,
                                                                       gridDataType,
                                                                       storageProxy,
                                                                       filter,
                                                                       filterAnnex,
                                                                       hasOverrideSpatialCellRestriction,
                                                                       overrideSpatialCellRestriction,
                                                                       subGridCacheContexts != null,
                                                                       maxNumberOfPassesToReturn,
                                                                       areaControlSet,
                                                                       populationControl,
                                                                       pdExistenceMap,
                                                                       overrides,
                                                                       liftParams);

                if (subGridsRequestArgument is IProgressiveVolumesSubGridsRequestArgument argument)
                {
                    retriever.StartDate = argument.StartDate;
                    retriever.EndDate   = argument.EndDate;
                    retriever.Interval  = argument.Interval;
                }
                else
                {
                    throw new ArgumentException($"Argument passed to sub grid retriever factory for progressive volumes retriever construction is not an expected type: {subGridsRequestArgument.GetType()}");
                }

                return(retriever);
            }
            else
            {
                var retriever = new SubGridRetriever(siteModel,
                                                     gridDataType,
                                                     storageProxy,
                                                     filter,
                                                     filterAnnex,
                                                     hasOverrideSpatialCellRestriction,
                                                     overrideSpatialCellRestriction,
                                                     subGridCacheContexts != null,
                                                     maxNumberOfPassesToReturn,
                                                     areaControlSet,
                                                     populationControl,
                                                     pdExistenceMap,
                                                     overrides,
                                                     liftParams);

                return(retriever);
            }
        }
 public BestPerformerUpdater(IStorageProxy proxy)
 {
     _proxy = proxy;
 }