public object Create()
 {
     return(new DataChangesDetector <T>(
                _metadata.MapSpecificationProviderForSource,
                _metadata.MapSpecificationProviderForTarget,
                _equalityComparerFactory.CreateIdentityComparer <T>(),
                _query));
 }
 public IdentityChangesProvider(IQuery query,
                                IStorageBasedDataObjectAccessor <TDataObject> storageBasedDataObjectAccessor,
                                IEqualityComparerFactory equalityComparerFactory)
 {
     _query = query;
     _storageBasedDataObjectAccessor = storageBasedDataObjectAccessor;
     _identityComparer = equalityComparerFactory.CreateIdentityComparer <TDataObject>();
 }
 public IdentityInMemoryChangesProvider(IQuery query,
                                        IMemoryBasedDataObjectAccessor <TDataObject> memoryBasedDataObjectAccessor,
                                        IEqualityComparerFactory equalityComparerFactory)
 {
     _query = query;
     _memoryBasedDataObjectAccessor = memoryBasedDataObjectAccessor;
     _identityComparer = equalityComparerFactory.CreateIdentityComparer <TDataObject>();
 }
Exemple #4
0
 public SyncEntityNameActor(IQuery query,
                            IBulkRepository <EntityName> bulkRepository,
                            IEqualityComparerFactory equalityComparerFactory)
 {
     _query            = query;
     _bulkRepository   = bulkRepository;
     _identityComparer = equalityComparerFactory.CreateIdentityComparer <EntityName>();
     _completeComparer = equalityComparerFactory.CreateCompleteComparer <EntityName>();
 }
Exemple #5
0
 public IdentityChangesProvider(IQuery query,
                                IStorageBasedDataObjectAccessor <TDataObject> storageBasedDataObjectAccessor,
                                IEqualityComparerFactory equalityComparerFactory)
 {
     _storageBasedDataObjectAccessor = storageBasedDataObjectAccessor;
     _dataChangesDetector            = new DataChangesDetector <TDataObject>(
         specification => storageBasedDataObjectAccessor.GetSource().WhereMatched(specification),
         specification => query.For <TDataObject>().WhereMatched(specification),
         equalityComparerFactory.CreateIdentityComparer <TDataObject>());
 }
        public void ApplyChanges(IReadOnlyCollection <long> ids)
        {
            var mergeResult = _changesDetector.DetectChanges(Specs.Map.ZeroMapping <T>(), _metadata.FindSpecificationProvider.Invoke(ids), _equalityComparerFactory.CreateIdentityComparer <T>());

            _repository.Delete(mergeResult.Complement);
            _repository.Create(mergeResult.Difference);
            _repository.Update(mergeResult.Intersection);
        }
Exemple #7
0
        public void Execute(IReadOnlyCollection <RecalculateStatisticsOperation> commands)
        {
            var filter = _metadata.FindSpecificationProvider.Invoke(commands.Select(c => c.EntityId).ToArray());

            // Сначала сравниением получаем различающиеся записи,
            // затем получаем те из различающихся, которые совпадают по идентификатору.
            var intermediateResult = _changesDetector.DetectChanges(filter);
            var changes            = MergeTool.Merge(intermediateResult.Difference, intermediateResult.Complement, _equalityComparerFactory.CreateIdentityComparer <T>());

            _repository.Delete(changes.Complement);
            _repository.Create(changes.Difference);
            _repository.Update(changes.Intersection);
        }
        public void RecalculateStatistics(long projectId, IReadOnlyCollection <long?> categoryIds)
        {
            var filter = _metadata.FindSpecificationProvider.Invoke(projectId, categoryIds);

            // Сначала сравниением получаем различающиеся записи,
            // затем получаем те из различающихся, которые совпадают по идентификатору.
            var intermediateResult = _changesDetector.DetectChanges(Specs.Map.ZeroMapping <T>(), filter, _equalityComparerFactory.CreateCompleteComparer <T>());
            var changes            = MergeTool.Merge(intermediateResult.Difference, intermediateResult.Complement, _equalityComparerFactory.CreateIdentityComparer <T>());

            // Наличие или отсутствие статистики - не повод создавать или удалять рубрики у фирм.
            // Поэтому только обновление.
            _repository.Update(changes.Intersection);
        }
 public TwoPhaseDataChangesDetector(IEqualityComparerFactory equalityComparerFactory)
 {
     _identityComparer = equalityComparerFactory.CreateIdentityComparer <TDataObject>();
     _completeComparer = equalityComparerFactory.CreateCompleteComparer <TDataObject>();
 }