public IList<GroupRoot> GetGroupRoots() { int profileId = _parameters.ProfileId; var parentArea = new ParentArea(_parameters.ParentAreaCode, _parameters.AreaTypeId); // Do not repository as do not want results cached like this (need to be // cached by ID and areatype, i.e. repository by roots) GroupData data = new GroupDataBuilderByIndicatorIds { IndicatorIds = _parameters.IndicatorIds, ProfileId = profileId, RestrictSearchProfileIds = _parameters.RestrictResultsToProfileIdList, ComparatorMap = new ComparatorMapBuilder(parentArea).ComparatorMap, AreaTypeId = _parameters.AreaTypeId }.Build(); new GroupDataProcessor().Process(data); if (data.IsDataOk) { var groupDataReader = ReaderFactory.GetGroupDataReader(); data.GroupRoots = new GroupRootFilter(groupDataReader).RemoveRootsWithoutChildAreaData(data.GroupRoots); } return data.GroupRoots ?? new List<GroupRoot>(); }
public IList<TrendRoot> GetTrendData() { int profileId = _parameters.ProfileId; var parentArea = new ParentArea(_parameters.ParentAreaCode, _parameters.AreaTypeId); ComparatorMap comparatorMap = new ComparatorMapBuilder(parentArea).ComparatorMap; // Do not repository as do not want results cached like this (need to be // cached by ID and areatype, i.e. repository by roots) GroupData data = new GroupDataBuilderByIndicatorIds { IndicatorIds = _parameters.IndicatorIds, ComparatorMap = comparatorMap, AreaTypeId = _parameters.AreaTypeId, RestrictSearchProfileIds = _parameters.RestrictResultsToProfileIdList, ProfileId = profileId }.Build(); if (data.IsDataOk) { var groupDataReader = ReaderFactory.GetGroupDataReader(); data.GroupRoots = new GroupRootFilter(groupDataReader).RemoveRootsWithoutChildAreaData(data.GroupRoots); } bool isParentAreaCodeNearestNeighbour = Area.IsNearestNeighbour(_parameters.ParentAreaCode); IList<TrendRoot> trendRoots = new TrendRootBuilder().Build(data.GroupRoots, comparatorMap, _parameters.AreaTypeId, profileId, data.IndicatorMetadata, isParentAreaCodeNearestNeighbour); return trendRoots; }
public void TestOneIndicatorCountyAndUnitaryAuthority() { GroupData data = new GroupDataBuilderByIndicatorIds { IndicatorIds = new List<int> { IndicatorIds.DeathsFromLungCancer }, ProfileId = ProfileIds.Search, RestrictSearchProfileIds = new List<int> { ProfileIds.Tobacco }, ComparatorMap = new ComparatorMapBuilder(GetGorEastOfEngland()).ComparatorMap, ParentAreaCode = AreaCodes.Gor_EastOfEngland, AreaTypeId = AreaTypeIds.CountyAndUnitaryAuthority }.Build(); Assert.IsTrue(data.IsDataOk); Assert.IsTrue(data.GroupRoots.Count > 0); Assert.AreEqual(1, data.IndicatorMetadata.Count); }
public void TestAreaTypeIdsWhereNoGroupingsForRequestedAreaTypeIds() { GroupData data = new GroupDataBuilderByIndicatorIds { IndicatorIds = new List<int> { IndicatorIds.DeathsFromLungCancer }, ProfileId = ProfileIds.Search, RestrictSearchProfileIds = new List<int> { ProfileIds.Tobacco }, ComparatorMap = new ComparatorMapBuilder(ComparatorMapBuilderTest.GetRegion102()).ComparatorMap, ParentAreaCode = AreaCodes.Sha_EastOfEngland, AreaTypeId = AreaTypeIds.County }.Build(); Assert.IsFalse(data.IsDataOk); Assert.IsTrue(data.GroupRoots.Count == 0); Assert.AreEqual(0, data.IndicatorMetadata.Count); Assert.AreEqual(0, data.Areas.Count); }
private void CreateFileByIndicatorIds() { foreach (var parentArea in _parentAreas) { InitParentArea(parentArea); GroupData data = new GroupDataBuilderByIndicatorIds { IndicatorIds = _indicatorIds, ProfileId = _profile.Id, RestrictSearchProfileIds = _restrictSearchProfileIds, ComparatorMap = _comparatorMap, ParentAreaCode = parentArea.AreaCode, AreaTypeId = parentArea.ChildAreaTypeId }.Build(); if (data.IsDataOk) { data.GroupRoots = new GroupRootFilter(_groupDataReader).RemoveRootsWithoutChildAreaData(data.GroupRoots); } WriteCoreData(data, parentArea); } WriteIndicatorMetadata(); }