Example #1
0
        protected void RecalculateTargetingType(
            TargetingType targetingType,
            ICollection <BgaPortfolioSecurityTargetInfo> result,
            IDataManager manager
            )
        {
            var issues = new List <IValidationIssue>();

            foreach (var portfolio in targetingType.BroadGlobalActivePortfolios)
            {
                try
                {
                    this.RecalculatePortfolio(
                        targetingType,
                        portfolio,
                        result,
                        manager
                        );
                }
                catch (ValidationException exception)
                {
                    issues.Add(exception.Issue);
                }

                if (issues.Any(x => x is ErrorIssue))
                {
                    var issue = new CompoundValidationIssue(
                        "Unable to recalculate the \"" + targetingType.Name + "\" targeting type (ID: " + targetingType.Id + ").",
                        issues
                        );
                    throw new ValidationException(issue);
                }
            }
        }
Example #2
0
        protected void RecalculateTargetingTypes(
            IEnumerable <TargetingType> targetingTypes,
            List <BgaPortfolioSecurityTargetInfo> result,
            IDataManager manager
            )
        {
            var issues = new List <IValidationIssue>();

            foreach (var targetingType in targetingTypes)
            {
                try
                {
                    this.RecalculateTargetingType(targetingType, result, manager);
                }
                catch (ValidationException exception)
                {
                    issues.Add(exception.Issue);
                }
            }
            if (issues.Any(x => x is ErrorIssue))
            {
                var issue = new CompoundValidationIssue("Unable to do recalculation.", issues);
                throw new ValidationException(issue);
            }
        }
Example #3
0
        protected void RecalculatePortfolio(
            TargetingType targetingType,
            BroadGlobalActivePortfolio portfolio,
            ICollection <BgaPortfolioSecurityTargetInfo> result,
            IDataManager manager
            )
        {
            var portfolioRepository = this.repositoryManager.ClaimPortfolioRepository(manager);

            var root = this.bptManager.GetRootModel(
                targetingType.Id,
                portfolio.Id,
                false /* we coundn't care less about benchmarks at this point */,
                manager,
                "" /* we don't care about username here */
                );

            var ticket = new CalculationTicket();

            // let's see if computations are valid
            var issues = this.bptManager.Validate(root, ticket).ToList();

            if (issues.Any(x => x is ErrorIssue))
            {
                var issue = new CompoundValidationIssue("Unable to recalculate the \"" + portfolio.Name + "\" portfolio (ID: " + portfolio.Id + ").", issues);
                throw new ValidationException(issue);
            }

            var models = this.bptManager.Traverser.TraverseGlobe(root.Globe);

            foreach (var model in models)
            {
                try
                {
                    this.RecalculateModelOnceResolved(
                        model,
                        targetingType,
                        portfolio,
                        result,
                        manager,
                        ticket
                        );
                }
                catch (ValidationException exception)
                {
                    issues.Add(exception.Issue);
                }
            }

            if (issues.Any(x => x is ErrorIssue))
            {
                var issue = new CompoundValidationIssue("Unable to recalculate the \"" + portfolio.Name + "\" portfolio (ID: " + portfolio.Id + ").", issues);
                throw new ValidationException(issue);
            }
        }
Example #4
0
 public void SerializeCompoundValidationIssue(CompoundValidationIssue issue, IJsonWriter writer)
 {
     this.Serialize(issue.Message, issue.Issues, writer);
 }
Example #5
0
 public void Resolve(CompoundValidationIssue issue)
 {
     this.serializer.SerializeCompoundValidationIssue(issue, writer);
 }