public FactMetadataBuilder <T> HasMatchedAggregate <TAggregate>()
            where TAggregate : class, IIdentifiable
        {
            // FIXME {all, 03.09.2015}: TAggregate заменить на идентификатор типа
            // FIXME {all, 04.09.2015}: Слабое место - внутри спецификации идентификаторы, затем идём в базу за идентификаторами. Если достать их из спецификации в бузу хдить не потребуется.
            MapToObjectsSpecProvider <T, IOperation> mapSpecificationProviderOnCreate =
                specification => new MapSpecification <IQuery, IEnumerable <IOperation> >(
                    q => q.For(specification)
                    .Select(x => x.Id)
                    .Select(id => new InitializeAggregate(typeof(TAggregate), id)));

            MapToObjectsSpecProvider <T, IOperation> mapSpecificationProviderOnUpdate =
                specification => new MapSpecification <IQuery, IEnumerable <IOperation> >(
                    q => q.For(specification)
                    .Select(x => x.Id)
                    .Select(id => new RecalculateAggregate(typeof(TAggregate), id)));
            MapToObjectsSpecProvider <T, IOperation> mapSpecificationProviderOnDelete =
                specification => new MapSpecification <IQuery, IEnumerable <IOperation> >(
                    q => q.For(specification)
                    .Select(x => x.Id)
                    .Select(id => new DestroyAggregate(typeof(TAggregate), id)));

            AddFeatures(new DirectlyDependentAggregateFeature <T>(mapSpecificationProviderOnCreate, mapSpecificationProviderOnUpdate, mapSpecificationProviderOnDelete));
            return(this);
        }
Ejemplo n.º 2
0
 public AggregateMetadata(
     MapToObjectsSpecProvider <TEntity, TEntity> mapSpecificationProviderForSource,
     MapToObjectsSpecProvider <TEntity, TEntity> mapSpecificationProviderForTarget,
     IEnumerable <IMetadataFeature> features) : base(features)
 {
     MapSpecificationProviderForSource = mapSpecificationProviderForSource;
     MapSpecificationProviderForTarget = mapSpecificationProviderForTarget;
 }
        public IndirectlyDependentAggregateFeature(MapToObjectsSpecProvider <T, IOperation> mapSpecificationProvider)
        {
            FindSpecificationProvider = Specs.Find.ByIds <T>;

            MapSpecificationProviderOnCreate
                    = MapSpecificationProviderOnUpdate
                    = MapSpecificationProviderOnDelete
                    = mapSpecificationProvider;
        }
Ejemplo n.º 4
0
 public FactMetadata(
     MapToObjectsSpecProvider <T, T> mapSpecificationProviderForSource,
     MapToObjectsSpecProvider <T, T> mapSpecificationProviderForTarget,
     IEnumerable <IMetadataFeature> features)
     : base(features)
 {
     MapSpecificationProviderForSource = mapSpecificationProviderForSource;
     MapSpecificationProviderForTarget = mapSpecificationProviderForTarget;
 }
Ejemplo n.º 5
0
 public DataChangesDetector(
     MapToObjectsSpecProvider <T, T> sourceProvider,
     MapToObjectsSpecProvider <T, T> targetProvider,
     IEqualityComparer <T> comparer)
 {
     _sourceProvider = sourceProvider;
     _targetProvider = targetProvider;
     _comparer       = comparer;
 }
 public DataChangesDetector(
     MapToObjectsSpecProvider <TFilter, TOutput> sourceProvider,
     MapToObjectsSpecProvider <TFilter, TOutput> targetProvider,
     IQuery query)
 {
     _sourceProvider = sourceProvider;
     _targetProvider = targetProvider;
     _query          = query;
 }
        public DependentStatisticsFeature(MapToObjectsSpecProvider <T, IOperation> mapSpecificationProvider)
        {
            FindSpecificationProvider = Specs.Find.ByIds <T>;

            MapSpecificationProviderOnCreate
                    = MapSpecificationProviderOnUpdate
                    = MapSpecificationProviderOnDelete
                    = mapSpecificationProvider;
        }
 public TwoPhaseDataChangesDetector(
     MapToObjectsSpecProvider <T, T> sourceProvider,
     MapToObjectsSpecProvider <T, T> targetProvider,
     IEqualityComparer <T> identityComparer,
     IEqualityComparer <T> completeComparer)
 {
     _dataChangesDetector = new DataChangesDetector <T>(sourceProvider, targetProvider, completeComparer);
     _identityComparer    = identityComparer;
 }
 public AggregateMetadata(
     MapToObjectsSpecProvider <T, T> mapSpecificationProviderForSource,
     MapToObjectsSpecProvider <T, T> mapSpecificationProviderForTarget,
     Func <IReadOnlyCollection <long>, FindSpecification <T> > findSpecificationProvider,
     IEnumerable <IMetadataFeature> features) : base(features)
 {
     MapSpecificationProviderForSource = mapSpecificationProviderForSource;
     MapSpecificationProviderForTarget = mapSpecificationProviderForTarget;
     FindSpecificationProvider         = findSpecificationProvider;
 }
Ejemplo n.º 10
0
 public StatisticsRecalculationMetadata(
     MapToObjectsSpecProvider <T, T> mapSpecificationProviderForSource,
     MapToObjectsSpecProvider <T, T> mapSpecificationProviderForTarget,
     Func <long, IReadOnlyCollection <long?>, FindSpecification <T> > findSpecificationProvider,
     IEnumerable <IMetadataFeature> features) : base(features)
 {
     MapSpecificationProviderForSource = mapSpecificationProviderForSource;
     MapSpecificationProviderForTarget = mapSpecificationProviderForTarget;
     FindSpecificationProvider         = findSpecificationProvider;
 }
Ejemplo n.º 11
0
 public ValueObjectMetadata(
     MapToObjectsSpecProvider <TValueObject, TValueObject> mapSpecificationProviderForSource,
     MapToObjectsSpecProvider <TValueObject, TValueObject> mapSpecificationProviderForTarget,
     Func <IReadOnlyCollection <TEntityKey>, FindSpecification <TValueObject> > findSpecificationProvider)
     : base(Enumerable.Empty <IMetadataFeature>())
 {
     MapSpecificationProviderForSource = mapSpecificationProviderForSource;
     MapSpecificationProviderForTarget = mapSpecificationProviderForTarget;
     FindSpecificationProvider         = findSpecificationProvider;
 }
Ejemplo n.º 12
0
 public ValueObjectMetadataElement(
     MapToObjectsSpecProvider <T, T> mapSpecificationProviderForSource,
     MapToObjectsSpecProvider <T, T> mapSpecificationProviderForTarget,
     Func <IReadOnlyCollection <long>, FindSpecification <T> > findSpecificationProvider)
     : base(Enumerable.Empty <IMetadataFeature>())
 {
     MapSpecificationProviderForSource = mapSpecificationProviderForSource;
     MapSpecificationProviderForTarget = mapSpecificationProviderForTarget;
     FindSpecificationProvider         = findSpecificationProvider;
 }
        protected override FactMetadata <T> Create()
        {
            MapToObjectsSpecProvider <T, T> mapSpecificationProviderForSource =
                specification => new MapSpecification <IQuery, IEnumerable <T> >(q => _sourceMappingSpecification.Map(q).Where(specification));

            var targetMappingSpecification = new MapSpecification <IQuery, IQueryable <T> >(q => q.For <T>());
            MapToObjectsSpecProvider <T, T> mapSpecificationProviderForTarget =
                specification => new MapSpecification <IQuery, IEnumerable <T> >(q => targetMappingSpecification.Map(q).Where(specification));

            return(new FactMetadata <T>(mapSpecificationProviderForSource, mapSpecificationProviderForTarget, Specs.Find.ByIds <T>, Features));
        }
Ejemplo n.º 14
0
        protected override AggregateMetadata <T, TKey> Create()
        {
            MapToObjectsSpecProvider <T, T> mapSpecificationProviderForSource =
                specification => new MapSpecification <IQuery, IEnumerable <T> >(q => _mapToSourceSpec.Map(q).Where(specification));

            var targetMappingSpecification = new MapSpecification <IQuery, IQueryable <T> >(q => q.For <T>());
            MapToObjectsSpecProvider <T, T> mapSpecificationProviderForTarget =
                specification => new MapSpecification <IQuery, IEnumerable <T> >(q => targetMappingSpecification.Map(q).Where(specification));

            return(new AggregateMetadata <T, TKey>(mapSpecificationProviderForSource, mapSpecificationProviderForTarget, Features));
        }
        public static FactMetadataBuilder <T> LeadsToStatisticsCalculation <T>(this FactMetadataBuilder <T> builder, Func <FindSpecification <T>, MapSpecification <IQuery, IEnumerable <Tuple <long, long?> > > > provider)
            where T : class, IIdentifiable
        {
            MapToObjectsSpecProvider <T, IOperation> mapSpecificationProvider =
                specification => new MapSpecification <IQuery, IEnumerable <IOperation> >(
                    q => provider.Invoke(specification)
                    .Map(q)
                    .Select(tuple => new RecalculateStatisticsOperation
            {
                ProjectId  = tuple.Item1,
                CategoryId = tuple.Item2
            }));

            return(builder.WithFeatures(new DependentStatisticsFeature <T>(mapSpecificationProvider)));
        }
Ejemplo n.º 16
0
        public AggregateMetadataBuilder <T> HasValueObject <TValueObject>(
            MapSpecification <IQuery, IQueryable <TValueObject> > sourceMappingSpecification,
            Func <IReadOnlyCollection <long>, FindSpecification <TValueObject> > findSpecificationProvider)
            where TValueObject : class
        {
            MapToObjectsSpecProvider <TValueObject, TValueObject> mapSpecificationProviderForSource =
                specification => new MapSpecification <IQuery, IEnumerable <TValueObject> >(q => sourceMappingSpecification.Map(q).Where(specification));

            var targetMappingSpecification = new MapSpecification <IQuery, IQueryable <TValueObject> >(q => q.For <TValueObject>());
            MapToObjectsSpecProvider <TValueObject, TValueObject> mapSpecificationProviderForTarget =
                specification => new MapSpecification <IQuery, IEnumerable <TValueObject> >(q => targetMappingSpecification.Map(q).Where(specification));

            Childs(new ValueObjectMetadataElement <TValueObject>(mapSpecificationProviderForSource, mapSpecificationProviderForTarget, findSpecificationProvider));
            return(this);
        }
        public FactMetadataBuilder <T> HasDependentAggregate <TAggregate>(
            Func <FindSpecification <T>, MapSpecification <IQuery, IEnumerable <long> > > dependentAggregateSpecProvider)

            where TAggregate : class, IIdentifiable
        {
            // FIXME {all, 03.09.2015}: TAggregate заменить на идентификатор типа
            MapToObjectsSpecProvider <T, IOperation> mapSpecificationProvider =
                specification => new MapSpecification <IQuery, IEnumerable <IOperation> >(q => dependentAggregateSpecProvider
                                                                                          .Invoke(specification)
                                                                                          .Map(q)
                                                                                          .Select(id => new RecalculateAggregate(typeof(TAggregate), id)));

            AddFeatures(new IndirectlyDependentAggregateFeature <T>(mapSpecificationProvider));
            return(this);
        }
Ejemplo n.º 18
0
 // FIXME {all, 03.09.2015}: TEntity заменить на идентификатор типа
 public FactMetadataBuilder <TFact> HasDependentEntity <TEntity, TKey>(MapToObjectsSpecProvider <TFact, TKey> dependentEntitySpecProvider)
     where TEntity : class, IIdentifiable <TKey>
 {
     AddFeatures(new IndirectlyDependentEntityFeature <TFact, TKey>(typeof(TEntity), dependentEntitySpecProvider));
     return(this);
 }
 private IEnumerable <IOperation> ProcessDependencies(IReadOnlyCollection <long> factIds, MapToObjectsSpecProvider <TFact, IOperation> operationFactory)
 {
     using (Probe.Create("Querying dependent aggregates"))
     {
         var filter = _metadata.FindSpecificationProvider.Invoke(factIds);
         return(operationFactory.Invoke(filter).Map(_query).ToArray());
     }
 }
 public StatisticsRecalculationMetadataBuilder <T> HasSource(MapSpecification <IQuery, IQueryable <T> > sourceMappingSpecification)
 {
     _mapSpecificationProviderForSource = specification => new MapSpecification <IQuery, IEnumerable <T> >(q => sourceMappingSpecification.Map(q).Where(specification));
     return(this);
 }
Ejemplo n.º 21
0
 public StatisticsRecalculationMetadataBuilder <TStatisticsObject, TEntityKey> HasTarget(MapSpecification <IQuery, IQueryable <TStatisticsObject> > targetMappingSpecification)
 {
     _mapSpecificationProviderForTarget = specification => new MapSpecification <IQuery, IEnumerable <TStatisticsObject> >(q => targetMappingSpecification.Map(q).Where(specification));;
     return(this);
 }
Ejemplo n.º 22
0
 public IndirectlyDependentEntityFeature(Type entityType, MapToObjectsSpecProvider <TFact, TEntityKey> dependentEntitySpecProvider)
 {
     EntityType = entityType;
     FactType   = typeof(TFact);
     DependentEntitySpecProvider = dependentEntitySpecProvider;
 }