Пример #1
0
        public TargetingType DeserializeToTargetingType(
            TargetingTypeInfo targetingTypeInfo,
            TaxonomyRepository taxonomyRepository,
            IEnumerable <TargetingTypePortfolioInfo> whateverPortfolioCompositionInfos,
            PortfolioRepository portfolioRepository
            )
        {
            var taxonomy = taxonomyRepository.GetTaxonomy(targetingTypeInfo.TaxonomyId);

            var owned = whateverPortfolioCompositionInfos
                        .Where(x => x.TargetingTypeId == targetingTypeInfo.Id);

            var broadGlobalActivePortfolios = owned
                                              .Select(x => portfolioRepository.FindBroadGlobalActivePortfolio(x.PortfolioId))
                                              .Where(x => x != null);

            var bottomUpPortfolios = this.GetBottomUpPortfolios(owned, portfolioRepository);

            var result = new TargetingType(
                targetingTypeInfo.Id,
                targetingTypeInfo.Name,
                targetingTypeInfo.TargetingTypeGroupId,
                targetingTypeInfo.BenchmarkIdOpt,
                taxonomy,
                broadGlobalActivePortfolios,
                bottomUpPortfolios
                );

            return(result);
        }
 public TargetingTypeRepository ClaimTargetingTypeRepository(
     IOnDemand <IDataManager> ondemandManager,
     TaxonomyRepository taxonomyRepository,
     PortfolioRepository portfolioRepository
     )
 {
     return(this.targetingTypeRepositoryStorage.Claim(TargetingTypeRepositoryStorageKey, delegate
     {
         return this.CreateTargetingTypeRepository(
             ondemandManager.Claim(),
             taxonomyRepository,
             portfolioRepository
             );
     }));
 }
        protected TargetingTypeRepository CreateTargetingTypeRepository(
            IDataManager manager,
            TaxonomyRepository taxonomyRepository,
            PortfolioRepository portfolioRepository
            )
        {
            var targetingTypeInfos = manager.GetAllTargetingTypes();
            var whateverPortfolioCompositionInfos = manager.GetAllTargetingTypePortfolio();
            var targetingTypes = targetingTypeInfos
                                 .Select(x => this.deserializer.DeserializeToTargetingType(
                                             x, taxonomyRepository,
                                             whateverPortfolioCompositionInfos,
                                             portfolioRepository
                                             ));

            var result = new TargetingTypeRepository(targetingTypes);

            return(result);
        }
Пример #4
0
        public TargetingType DeserializeTargetingType(
            TargetingTypeInfo targetingTypeInfo,
            IEnumerable <TargetingTypePortfolioCompositionInfo> whateverCompositionInfos,
            TaxonomyRepository taxonomyRepository
            )
        {
            var taxonomy = taxonomyRepository.GetTaxonomy(targetingTypeInfo.TaxonomyId);

            var portfolios = whateverCompositionInfos
                             .Where(x => x.TargetingTypeId == targetingTypeInfo.Id)
                             .Select(x => new Portfolio(x.PortfolioId));

            var result = new TargetingType(
                targetingTypeInfo.Id,
                targetingTypeInfo.Name,
                targetingTypeInfo.BenchmarkIdOpt,
                taxonomy,
                portfolios
                );

            return(result);
        }
Пример #5
0
        public TargetingTypeGroup DeserializeTargetingTypeGroup(
            TargetingTypeGroupInfo targetingTypeGroupInfo,
            IEnumerable <TargetingTypeInfo> whateverTargetingTypeInfos,
            IEnumerable <TargetingTypePortfolioCompositionInfo> whateverPortfolioCompositionInfos,
            TaxonomyRepository taxonomyRepository
            )
        {
            // get only targeting types that belong to the given group
            var ownedTargetingTypeInfos = whateverTargetingTypeInfos.Where(x => x.TargetingTypeGroupId == targetingTypeGroupInfo.Id);

            var targetingTypes = ownedTargetingTypeInfos
                                 .Select(x => this.DeserializeTargetingType(x, whateverPortfolioCompositionInfos, taxonomyRepository));

            var result = new TargetingTypeGroup(
                targetingTypeGroupInfo.Id,
                targetingTypeGroupInfo.Name,
                targetingTypeGroupInfo.BenchmarkIdOpt,
                targetingTypes
                );

            return(result);
        }