public IDictionary<int, List<int>> GetAreaTypeIdToIndicatorIdsWithData()
        {
            var indicatorIds = new IndicatorSearch().SearchIndicators(_parameters.SearchText);
            var profileIds = _parameters.RestrictResultsToProfileIdList;

            var areaTypes = new AreaTypeListProvider(new GroupIdProvider(profileReader), areasReader, groupDataReader)
                .GetChildAreaTypesUsedInProfiles(profileIds);

            IDictionary<int, List<int>> areaTypeIdToIndicatorIdsWithData = new Dictionary<int, List<int>>();
            foreach (var areaType in areaTypes)
            {
                List<int> indicatorIdsWithData = new List<int>();
                int areaTypeId = areaType.Id;

                var groupings = new GroupingListProvider(groupDataReader, profileReader)
                    .GetGroupings(profileIds, indicatorIds, areaTypeId);

                var groupRoots = new GroupRootBuilder().BuildGroupRoots(groupings);

                foreach (var groupRoot in groupRoots)
                {
                    var grouping = groupRoot.FirstGrouping;
                    var count = groupDataReader.GetCoreDataCountAtDataPoint(grouping);
                    if (count > 0)
                    {
                        indicatorIdsWithData.Add(grouping.IndicatorId);
                    }
                }

                areaTypeIdToIndicatorIdsWithData.Add(areaTypeId, indicatorIdsWithData);
            }

            return areaTypeIdToIndicatorIdsWithData;
        }
コード例 #2
0
        public void TestSearchIndicators()
        {
            // Standard search
            List<int> ids = new IndicatorSearch().SearchIndicators("drug");
            Assert.IsTrue(ids.Count > 10);

            // Nonsense search string
            ids = new IndicatorSearch().SearchIndicators("xhoawecapqfhasfdg");
            Assert.AreEqual(0, ids.Count);
        }
コード例 #3
0
 public void TestIndicatorSearchIsCaseInsensitive()
 {
     var search = new IndicatorSearch();
     Assert.AreEqual(search.SearchIndicators("TUBERCULOSIS").Count, search.SearchIndicators("tuberculosis").Count);
     Assert.IsTrue(search.SearchIndicators("tuberculosis").Count > 0);
 }