Exemplo n.º 1
0
        private List <GraphNode> GetTermNodes(PrimaryContractExtractor contract, List <PrimarySubject> graphSubs)
        {
            List <GraphNode> termNodes = new List <GraphNode>();

            foreach (PrimarySubject sub in graphSubs)
            {
                TermNode node = new TermNode(sub);

                DeductibleCollection Deds;
                if (contract.GetDeductiblesForSubject(sub, out Deds))
                {
                    node.Deductibles = Deds;
                }

                LimitCollection Lims;
                if (contract.GetLimitsForSubject(sub, out Lims))
                {
                    node.Limits = Lims;
                }

                termNodes.Add(node);
            }

            return(termNodes);
        }
Exemplo n.º 2
0
        private AutoGraphStyle GetGraphStyle(ContractExtractor contract)
        {
            if (contract.IsTreaty)
            {
                return(AutoGraphStyle.Node);
            }
            else
            {
                PrimaryContractExtractor primaryContract = contract as PrimaryContractExtractor;

                List <PrimarySubject> primarysubjects = primaryContract.GetAllTermSubjects();

                foreach (PrimarySubject priSub in primarysubjects)
                {
                    DeductibleCollection dedCol;
                    if (primaryContract.GetDeductiblesForSubject(priSub, out dedCol))
                    {
                        foreach (Deductible ded in dedCol)
                        {
                            if (ded.DedInterType == DedInteractionType.SingleLargest)
                            {
                                return(AutoGraphStyle.Node);
                            }

                            if (ded.DedType == TermValueType.PercentAffected || ded.DedType == TermValueType.PercentLoss)
                            {
                                return(AutoGraphStyle.Node);
                            }
                        }
                    }
                }

                return(AutoGraphStyle.Matrix);
            }
        }
Exemplo n.º 3
0
        private ContractExtractor GetContract(ExposureDataAdaptor expData, GraphBuildCache graphCache)
        {
            //Make all graph nodes for Graph
            List <GraphNode>  IntitialGraphNodes = new List <GraphNode>();
            ContractExtractor contract;

            if (expData.TreatyExposure)
            {
                contract = new TreatyContractExtractor(expData, graphCache);
            }
            else
            {
                contract = new PrimaryContractExtractor(expData);
            }

            return(contract);
        }
Exemplo n.º 4
0
        public Graph Build()
        {
            //Make all graph nodes for Graph
            List <GraphNode>  IntitialGraphNodes = new List <GraphNode>();
            ContractExtractor contract;

            if (expData.TreatyExposure)
            {
                contract = new TreatyContractExtractor(expData, graphChache);
            }
            else
            {
                contract = new PrimaryContractExtractor(expData);
            }

            //Get All Cover Nodes
            contract.Extract();
            List <Subject> graphSubs = contract.GetAllCoverSubjects();

            IntitialGraphNodes.AddRange(GetCoverNodes(contract, graphSubs));

            //Get All Term Nodes
            if (!expData.TreatyExposure)
            {
                PrimaryContractExtractor primaryContract = (PrimaryContractExtractor)contract;
                List <PrimarySubject>    termgraphSubs   = primaryContract.GetAllTermSubjects();
                IntitialGraphNodes.AddRange(GetTermNodes(primaryContract, termgraphSubs));
            }

            //Build Hasse Diagram from Graph Nodes
            HasseDiagramGenerator HasseBuilder = new HasseDiagramGenerator();
            HasseDiagram          HasseDiagram = HasseBuilder.Generate(IntitialGraphNodes);

            //Convert Hasse Diagram to Reference.Graph object
            List <GraphNode> TopGraphNodes   = new List <GraphNode>();
            List <GraphNode> FinalGraphNodes = HasseDiagram.HasseDiagramNodes.Where(pair => pair.Key != "{}")
                                               .Select(pair => pair.Value)
                                               .Cast <GraphNode>()
                                               .ToList();
            Dictionary <GraphNode, List <GraphNode> > ParentToChildrenMap = new Dictionary <GraphNode, List <GraphNode> >();

            foreach (GraphNode graphnode in FinalGraphNodes)
            {
                List <GraphNode> childrenList = graphnode.EdgesToCovered.Select(edge => edge.LowerNode)
                                                .Where(node => node.KeyString != "")
                                                .Cast <GraphNode>().ToList();
                if (childrenList.Count > 0)
                {
                    ParentToChildrenMap.Add(graphnode, childrenList);
                }

                if (graphnode.EdgesToCovering.Count == 0)
                {
                    TopGraphNodes.Add(graphnode);
                }
            }

            Graph graph;

            if (expData.TreatyExposure)
            {
                graph = new TreatyGraph(expData.ContractID, TopGraphNodes, FinalGraphNodes, ParentToChildrenMap, contract.Declarations);
            }
            else
            {
                graph = new PrimaryGraph(expData.ContractID, TopGraphNodes, FinalGraphNodes, ParentToChildrenMap, contract.Declarations);
            }

            //graph.BuildAtomicRITEs();
            //graph.AssignLevelToNode();
            //graph.GraphReady = true;
            return(graph);
        }
Exemplo n.º 5
0
 public PrimaryContractNodeBuilder(PrimaryContractExtractor _contract)
 {
     Contract = _contract;
 }