protected override HashSet <Subject> GetSubjectForTerm(Dictionary <string, object> termDict) { string expTypes = termDict["ExposureTypes"].ToString(); string COLTypes = termDict["CausesOfLoss"].ToString(); ExposureTypeCollection termExp; COLCollection termCOL; if (COLTypes == "") { termCOL = contractSubject.CauseOfLossSet; } else { termCOL = new COLCollection(COLTypes); } if (expTypes == "") { termExp = contractSubject.ExposureTypes; } else { termExp = ExposureTypeCollection.BuildFromString(expTypes); } string termSchedule = termDict["Schedule"].ToString(); ScheduleOfRITEs schedule = ExpData.GetSchedule(termSchedule); bool isPerRisk = false; if (termDict.ContainsKey("PerRisk") & termDict["PerRisk"].ToString() == "True") { isPerRisk = true; } PrimarySubject sub = new PrimarySubject(schedule, termExp, termCOL, isPerRisk); //DO NOT Explode //if (termDict.ContainsKey("PerRisk") // & termDict["PerRisk"].ToString() == "True") // return new HashSet<Subject>(ExplodeSubjectForPerRisk(sub).Cast<Subject>()); //else // return new HashSet<Subject>(){sub}; return(new HashSet <Subject>() { sub }); }
private HashSet <PrimarySubject> ExplodeSubjectForPerRisk(PrimarySubject primarySub) { //Per Risk, expand the schedule to all location subschedules if (primarySub.Schedule.IsLocation) { return new HashSet <PrimarySubject>() { primarySub } } ; HashSet <PrimarySubject> ExplodedSubjects = new HashSet <PrimarySubject>(); foreach (RITE Rite in primarySub.Schedule.ScheduleList) { //Check if schedule already exists in exposure data with RITE ScheduleOfRITEs schedule; if (FindScheduleWithRite(Rite, out schedule)) { ExplodedSubjects.Add(new PrimarySubject(schedule, primarySub.ExposureTypes, primarySub.CauseOfLossSet)); } else { //Create new schedule in exposure data string newScheduleName = primarySub.Schedule.Name + " ." + Rite.ExposureID; ExpData.AddSchedule(newScheduleName, new HashSet <RITE>() { Rite }); ExplodedSubjects.Add(new PrimarySubject(ExpData.GetSchedule(newScheduleName), primarySub.ExposureTypes, primarySub.CauseOfLossSet)); } } return(ExplodedSubjects); }