public PartitionTrendData GetPartitionTrendData(int profileId, string areaCode, int indicatorId, int ageId, int sexId, int categoryTypeId, int areaTypeId) { InitGrouping(profileId, areaTypeId, indicatorId, sexId, ageId); InitMetadata(_grouping); var categories = _areasReader.GetCategories(categoryTypeId); var dictionaryBuilder = new PartitionTrendDataDictionaryBuilder( categories.Cast<INamedEntity>().ToList(), PartitionDataType.Category); // Add data for each time period var timePeriods = _grouping.GetTimePeriodIterator(_indicatorMetadata.YearType).TimePeriods; foreach (var timePeriod in timePeriods) { IList<CoreDataSet> dataList = _groupDataReader.GetAllCategoryDataWithinParentArea(areaCode, indicatorId, sexId, ageId, timePeriod).Where(x => x.CategoryTypeId == categoryTypeId).ToList(); dictionaryBuilder.AddDataForNextTimePeriod(dataList); } // Remove entities without data from dictionary var allData = dictionaryBuilder.AllDataAsList; // Return trend data timePeriods = RemoveEarlyEmptyTimePeriods(dictionaryBuilder, timePeriods); FormatData(allData); var limits = new LimitsBuilder().GetLimits(allData); return new PartitionTrendData { Limits = limits, Labels = categories.Cast<INamedEntity>().ToList(), TrendData = dictionaryBuilder.Dictionary, Periods = GetTimePeriodStrings(timePeriods) }; }
public PartitionTrendData GetPartitionTrendData(int profileId, string areaCode, int indicatorId, int ageId, int areaTypeId) { InitGrouping(profileId, areaTypeId, indicatorId, ageId); InitMetadata(_grouping); var sexes = _pholioReader.GetAllSexes(); var dictionaryBuilder = new PartitionTrendDataDictionaryBuilder( sexes.Cast<INamedEntity>().ToList(), PartitionDataType.Sex); // Add data for each time period var timePeriods = _grouping.GetTimePeriodIterator(_indicatorMetadata.YearType).TimePeriods; foreach (var timePeriod in timePeriods) { IList<CoreDataSet> dataList = _groupDataReader.GetCoreDataForAllSexes( indicatorId, timePeriod, areaCode, ageId); dictionaryBuilder.AddDataForNextTimePeriod(dataList); } // Remove entities without data from dictionary var allData = dictionaryBuilder.AllDataAsList; var sexesWithData = GetSexesFromDataList(allData); foreach (var sex in sexes) { if (sexesWithData.Contains(sex) == false) { dictionaryBuilder.RemoveEntity(sex.Id); } } // Return trend data timePeriods = RemoveEarlyEmptyTimePeriods(dictionaryBuilder, timePeriods); FormatData(allData); var limits = new LimitsBuilder().GetLimits(allData); return new PartitionTrendData { Limits = limits, Labels = sexesWithData.Cast<INamedEntity>().ToList(), TrendData = dictionaryBuilder.Dictionary, Periods = GetTimePeriodStrings(timePeriods) }; }
private static void AddValidData(PartitionTrendDataDictionaryBuilder builder) { builder.AddDataForNextTimePeriod(new List<CoreDataSet> { new CoreDataSet {SexId = Sex1,Value = 1}, new CoreDataSet {SexId = Sex2,Value = 1}, }); }
private static void AddNullData(PartitionTrendDataDictionaryBuilder builder) { builder.AddDataForNextTimePeriod(new List<CoreDataSet> { new CoreDataSet {SexId = SexIds.NotApplicable,Value = 1}, new CoreDataSet {SexId = Sex2,Value = ValueData.NullValue}, }); }