private Dictionary <long, ExtractRITCharInfo> AggregateRITChars(Dictionary <long, ExtractRITCharInfo> CoverageIdAttrMap) { Dictionary <long, ExtractRITCharInfo> AggregatedRITCharsOutput = new Dictionary <long, ExtractRITCharInfo>(); var AggreagateRITCharGroups = EDSDataExtract.CoverageIdAttrMap.GroupBy(pair => pair.Value.OriginalRITECharacteristicId); foreach (var AggRITCharGroup in AggreagateRITCharGroups) { ExtractRITCharInfo SampleDisAggCharInfo = AggRITCharGroup.First().Value; ExtractRITCharInfo AggRITCharInfo = new ExtractRITCharInfo(SampleDisAggCharInfo); if (AggRITCharGroup.Key != AggRITCharGroup.First().Key) { AggRITCharInfo.IsAggregateLowRes = true; } AggRITCharInfo.NumBuildings = 0; AggRITCharInfo.Value = 0; //AggRITCharInfo.NumSamples = 0; //AggRITCharInfo.Factor = 1; AggRITCharInfo.RITExposureId = AggRITCharInfo.OriginalRITExposureId; AggRITCharInfo.OriginalRITECharacteristicId = AggRITCharGroup.Key; AggregateIDtoDisaggIDs.Add(AggRITCharInfo.OriginalRITECharacteristicId, new HashSet <long>()); foreach (KeyValuePair <long, ExtractRITCharInfo> pair in AggRITCharGroup) { AggRITCharInfo.NumBuildings += pair.Value.NumBuildings; AggRITCharInfo.Value += pair.Value.Value; RiskCharIDtoAggregateID.Add(pair.Key, AggRITCharInfo.OriginalRITECharacteristicId); AggregateIDtoDisaggIDs[AggRITCharInfo.OriginalRITECharacteristicId].Add(pair.Key); DisaggRitCharToDisAggRIT.Add(pair.Key, pair.Value.RITExposureId); } AggregatedRITCharsOutput.Add(AggRITCharGroup.Key, AggRITCharInfo); } return(AggregatedRITCharsOutput); }
//public ExposureDataAdaptor(ContractExposure contractExposure, NGFMPrototype _ParsingAPI) //{ // //ParsingAPI = _ParsingAPI; // UseJSContext = false; // _contractExposure = contractExposure; // _contractJSON = GetJSONForContract(); // EDSDataExtract = new ExposureDataExtractor(_contractExposure); // _characteristics = new HashSet<RITCharacteristic>(); // _rites = new HashSet<RITE>(); // _schedules = new HashSet<ScheduleOfRITEs>(); // _characteristicsDict = new Dictionary<long, RITCharacteristic>(); // _ritesDict = new Dictionary<long, RITE>(); // _schedulesDict = new Dictionary<string, ScheduleOfRITEs>(); // if (_contractExposure.ContractType.IsReinsuranceContract()) // TreatyExposure = true; // else // TreatyExposure = false; //} public void GetPrimaryData() { if (TreatyExposure) { throw new InvalidOperationException("Cannot use this method to get exposure data for reinsurance contract"); } EDSDataExtract.ExtractRiteMap(); Dictionary <long, ExtractRITCharInfo> CoverageIdAttrMap = EDSDataExtract.CoverageIdAttrMap; if (UseAggregatedRITEs) { CoverageIdAttrMap = AggregateRITChars(CoverageIdAttrMap); } else { foreach (KeyValuePair <long, ExtractRITCharInfo> pair in CoverageIdAttrMap) { RiskCharIDtoAggregateID.Add(pair.Key, pair.Key); AggregateIDtoDisaggIDs.Add(pair.Key, new HashSet <long> { pair.Key }); } } #region old RITE aggreagation code //foreach (var LocGroup in LocationGroups) //{ // if (UseAggregatedRITEs) // { // long RiteID = LocGroup.First().Value.RITExposureId; // long OriginalRiteID = (long)LocGroup.First().Value.OriginalRITExposureId; // if (RiteID == OriginalRiteID) // { // RITE newRITE = BuildRITE(LocGroup.First()); // _rites.Add(newRITE); // _ritesDict.Add(LocGroup.Key, newRITE); // foreach (KeyValuePair<long, ExtractRITCharInfo> pair in LocGroup) // { // RITCharacteristic newRITChar = BuildRITCharacteristic(pair); // _characteristics.Add(newRITChar); // _characteristicsDict.Add(pair.Key, newRITChar); // newRITE.AddCharacteristic(newRITChar); // } // } // else // { // foreach (KeyValuePair<long, ExtractRITCharInfo> pair in LocGroup) // { // RiskCharIDtoAggregateID.Add(pair.Key, (long)pair.Value.OriginalRITECharacteristicId); // } // } // } // else // { // RITE newRITE = BuildRITE(LocGroup.First()); // _rites.Add(newRITE); // _ritesDict.Add(LocGroup.Key, newRITE); // foreach (KeyValuePair<long, ExtractRITCharInfo> pair in LocGroup) // { // RITCharacteristic newRITChar = BuildRITCharacteristic(pair); // _characteristics.Add(newRITChar); // _characteristicsDict.Add(pair.Key, newRITChar); // newRITE.AddCharacteristic(newRITChar); // } // } //} #endregion var LocationGroups = CoverageIdAttrMap.GroupBy(pair => pair.Value.RITExposureId); foreach (var LocGroup in LocationGroups) { RITE newRITE = BuildRITE(LocGroup.First()); _rites.Add(newRITE); _ritesDict.Add(LocGroup.Key, newRITE); foreach (KeyValuePair <long, ExtractRITCharInfo> pair in LocGroup) { RITCharacteristic newRITChar = BuildRITCharacteristic(pair); _characteristics.Add(newRITChar); _characteristicsDict.Add(pair.Key, newRITChar); newRITE.AddCharacteristic(newRITChar); } } foreach (KeyValuePair <string, Subschedule> EDSschedule in EDSDataExtract.SubSchedule) { ScheduleOfRITEs newSchedule; HashSet <long> Ids = (EDSschedule.Value.Ids != null) ? EDSschedule.Value.Ids : new HashSet <long>(EDSschedule.Value.CompressedIds.Enumerable()); if (EDSschedule.Value.Type == SubscheduleType.RITCHARACTERISTICS) //|| EDSschedule.Value.Name == "Blanket_FL" || EDSschedule.Value.Name == "Blanket_EQ" || EDSschedule.Value.Name == "Blanket_WS") //Sunny Hack { newSchedule = BuildScheduleFromRITChars2(EDSschedule.Key, Ids); } else if (EDSschedule.Value.Type == SubscheduleType.RITEXPOSURES) { try { newSchedule = BuildScheduleFromRITs2(EDSschedule.Key, Ids); } catch (IndexOutOfRangeException exp) { newSchedule = BuildScheduleFromRITChars2(EDSschedule.Key, Ids); } } else { throw new InvalidOperationException("Cannot support building schedules of type: " + EDSschedule.Value.Type.ToString()); } _schedules.Add(newSchedule); _schedulesDict.Add(newSchedule.Name, newSchedule); } }
public bool RITEInContract(long newRITEID) { return(RiskCharIDtoAggregateID.ContainsKey(newRITEID)); }