コード例 #1
1
        public CategoryAreaDataWriter(IAreasReader areasReader, IGroupDataReader groupDataReader, WorksheetInfo worksheet,
            ProfileDataWriter profileDataWriter, CategoryAreaType categoryAreaType)
            : base(areasReader, groupDataReader, worksheet, profileDataWriter)
        {
            _categoryAreaTypeId = categoryAreaType.CategoryTypeId;

            categories = areasReader.GetCategories(_categoryAreaTypeId);

                subnationalCategoryIdToCategoryAreaMap = categories
                    .ToDictionary<Category, int, IArea>(
                    category => category.Id,
                    category => CategoryArea.New(category)
                    );
        }
コード例 #2
0
        public static IArea NewArea(IAreasReader areasReader, string areaCode)
        {
            if (areaCode == null)
            {
                throw new FingertipsException("Area code was null");
            }

            // Category areas
            if (CategoryArea.IsCategoryAreaCode(areaCode))
            {
                var categoryArea = new CategoryArea(areaCode);
                var category = areasReader.GetCategory(categoryArea.CategoryTypeId, categoryArea.CategoryId);
                categoryArea.SetNames(category);
                return categoryArea;
            }

            // Nearest neighbour
            if (NearestNeighbourArea.IsNearestNeighbourAreaCode(areaCode))
            {
                var nearestNeighboursArea = new NearestNeighbourArea(areaCode);
                nearestNeighboursArea.Neighbours = areasReader.GetNearestNeighbours(
                    nearestNeighboursArea.AreaCodeOfAreaWithNeighbours, nearestNeighboursArea.NeighbourTypeId);
                return nearestNeighboursArea;
            }

            // Standard area
            return areasReader.GetAreaFromCode(areaCode);
        }
コード例 #3
0
 protected ParentDataWriter(IAreasReader areasReader, IGroupDataReader groupDataReader, WorksheetInfo worksheetInfo, ProfileDataWriter profileDataWriter)
 {
     AreasReader = areasReader;
     GroupDataReader = groupDataReader;
     Worksheet = worksheetInfo;
     ProfileDataWriter = profileDataWriter;
 }
コード例 #4
0
 public AreaTypeListProvider(IGroupIdProvider groupdIdProvider,
     IAreasReader areasReader, IGroupDataReader groupDataReader)
 {
     this.groupdIdProvider = groupdIdProvider;
     this.areasReader = areasReader;
     this.groupDataReader = groupDataReader;
 }
コード例 #5
0
        public ChildAreaListBuilder(IAreasReader areasReader, string parentAreaCode, int childAreaTypeId)
        {
            IArea area = AreaFactory.NewArea(areasReader, parentAreaCode);

            var categoryArea = area as CategoryArea;
            if (categoryArea != null)
            {
                ChildAreas =
                    new ChildAreaListForCategoryAreaBuilder(areasReader, categoryArea, childAreaTypeId)
                    .ChildAreas
                    .ToList();
            }
            else if (Area.IsNearestNeighbour(parentAreaCode))
            {
                // TODO: this should be replaced by CreateAreaListFromNearestNeighbourAreaCode

                var nearestNeighbourArea = new NearestNeighbourArea(parentAreaCode);
                var nearestNeighbours = areasReader.GetNearestNeighbours(nearestNeighbourArea.AreaCodeOfAreaWithNeighbours, nearestNeighbourArea.NeighbourTypeId);
                var nearestNeighboursAreas = nearestNeighbours.Select(x => x.NeighbourAreaCode).ToList();
                var areas = areasReader.GetAreasFromCodes(nearestNeighboursAreas);
                ChildAreas = areas.Cast<IArea>().ToList();
            }
            else
            {
                var areas = area.IsCountry
                    ? areasReader.GetAreasByAreaTypeId(childAreaTypeId)
                    : areasReader.GetChildAreas(parentAreaCode, childAreaTypeId);

                ChildAreas = areas.Cast<IArea>().ToList();
            }
        }
コード例 #6
0
 public ExcelFileGenerator(ILogger logger, IAreaTypeListProvider areaTypeListProvider,
     IAreasReader areasReader, IProfileReader profileReader)
 {
     _logger = logger;
     _areaTypeListProvider = areaTypeListProvider;
     _areasReader = areasReader;
     _profileReader = profileReader;
 }
コード例 #7
0
 public ChildAreaValuesBuilder(IndicatorComparerFactory indicatorComparerFactory,
     IGroupDataReader groupDataReader, IAreasReader areasReader, IProfileReader profileReader)
     : base(groupDataReader)
 {
     this.indicatorComparerFactory = indicatorComparerFactory;
     this.areasReader = areasReader;
     this.profileReader = profileReader;
 }
コード例 #8
0
 public IndicatorDataBodyContainer(IndicatorMetadataProvider indicatorMetadataProvider, ExportAreaHelper areaHelper,
                                   IAreasReader areasReader, CsvBuilderAttributesForBodyContainer attributesForBodyContainer)
 {
     _indicatorMetadataProvider = indicatorMetadataProvider;
     _areaHelper  = areaHelper;
     _areasReader = areasReader;
     _attributesForBodyContainer = attributesForBodyContainer;
 }
コード例 #9
0
 public static ParentDataWriter New(IAreasReader areasReader, IGroupDataReader groupDataReader, WorksheetInfo worksheetInfo, 
     ProfileDataWriter profileDataWriter, IAreaType parentAreaType)
 {
     var categoryAreaType = parentAreaType as CategoryAreaType;
     return categoryAreaType != null
         ? (ParentDataWriter)new CategoryAreaDataWriter(areasReader, groupDataReader, worksheetInfo, profileDataWriter, categoryAreaType)
         : (ParentDataWriter)new SubnationalAreaDataWriter(areasReader, groupDataReader, worksheetInfo, profileDataWriter, parentAreaType);
 }
 public ChildAreaListForCategoryAreaBuilder(IAreasReader reader, CategoryArea parentArea, int childAreaType)
 {
     var areaCodes = reader
         .GetCategorisedAreasForOneCategory(AreaTypeIds.Country, childAreaType, parentArea.CategoryTypeId, parentArea.CategoryId)
         .Select(x => x.AreaCode);
     var areaListBuilder = new AreaListProvider(reader);
     areaListBuilder.CreateAreaListFromAreaCodes(areaCodes);
     ChildAreas = areaListBuilder.Areas.OrderBy(x=> x.Name).ToList();
 }
コード例 #11
0
        public static IAreaType New(IAreasReader areasReader, int parentAreaTypeId)
        {

            if (CategoryAreaType.IsCategoryAreaTypeId(parentAreaTypeId))
            {
                var categoryTypeId = CategoryAreaType.GetCategoryTypeIdFromAreaTypeId(parentAreaTypeId);
                var categoryType = areasReader.GetCategoryType(categoryTypeId);
                return CategoryAreaType.New(categoryType);
            }

            return areasReader.GetAreaType(parentAreaTypeId);
        }
コード例 #12
0
        public LookUpManager(PholioReader pholioReader, IAreasReader areasReader,
            IList<int> areaTypeIds, IList<int> categoryTypeIds)
        {
            ageIdToName = pholioReader.GetAllAges().ToDictionary(x => x.Id, x => x.Name);
            sexIdToName = pholioReader.GetAllSexes().ToDictionary(x => x.Id, x => x.Name);
            InitAreaCodeToNameLookUp(areasReader, areaTypeIds);

            var categoryTypes = areasReader.GetCategoryTypes(categoryTypeIds);
            categoryTypeIdToName = categoryTypes.ToDictionary(x => x.Id, x => x.Name);
            categoryTypeIdToCategoryIdToName = GetCategoryTypeIdToCategoryIdToNameLookUp(categoryTypes);

            valueNoteIdToText = pholioReader.GetAllValueNotes().ToDictionary(x => x.Id, x => x.Text);
        }
コード例 #13
0
        public static IAreaType New(IAreasReader areasReader, ParentAreaGroup parentAreaGroup)
        {
            if (parentAreaGroup.ParentAreaTypeId.HasValue)
            {
                return areasReader.GetAreaType(parentAreaGroup.ParentAreaTypeId.Value);
            }

            if (parentAreaGroup.CategoryTypeId.HasValue)
            {
                var categoryType = areasReader.GetCategoryType(parentAreaGroup.CategoryTypeId.Value);
                return CategoryAreaType.New(categoryType);
            }

            throw new FingertipsException("Could not create an area type for Id=" + parentAreaGroup.Id);
        }
コード例 #14
0
        public void TestAreaMappingsGorToUpperTierLAs()
        {
            areaTypeId = AreaTypeIds.CountyAndUnitaryAuthority;

            reader = ReaderFactory.GetAreasReader();
            ExpectChildren(AreaCodes.Gor_EastMidlands, 9);
            ExpectChildren(AreaCodes.Gor_EastOfEngland, 11);
            ExpectChildren(AreaCodes.Gor_London, 33);
            ExpectChildren(AreaCodes.Gor_NorthEast, 12);
            ExpectChildren(AreaCodes.Gor_NorthWest, 23);
            ExpectChildren(AreaCodes.Gor_SouthEast, 19);
            ExpectChildren(AreaCodes.Gor_SouthWest, 16);
            ExpectChildren(AreaCodes.Gor_WestMidlands, 14);
            ExpectChildren(AreaCodes.Gor_YorkshireHumber, 15);

        }
        public NearestNeighbourAreaListBuilder(IAreasReader areasReader, NearestNeighbourArea nearestNeighbourArea)
        {
            var areaCodes = nearestNeighbourArea.NeighbourAreaCodes;

            IList<string> newAreaCodes = new List<string>();

            // add the selected area to the list of neighbours 
            // it should always be on zeroth index
            newAreaCodes.Add(nearestNeighbourArea.AreaCodeOfAreaWithNeighbours);

            foreach (var areaCode in areaCodes)
            {
                newAreaCodes.Add(areaCode);
            }

            var areas = areasReader.GetAreasFromCodes(newAreaCodes);
            Areas = areas.Cast<IArea>().ToList();
        }
コード例 #16
0
 private void InitAreaCodeToNameLookUp(IAreasReader areasReader, 
     IList<int> areaTypeIds)
 {
     areaCodeToName = new Dictionary<string, string>();
     areaCodeToTypeName = new Dictionary<string, string>();
     foreach (var areaTypeId in areaTypeIds)
     {
         var areaType = areasReader.GetAreaType(areaTypeId);
         var areas = areasReader.GetAreasByAreaTypeId(areaTypeId);
         foreach (var area in areas)
         {
             var areaCode = area.Code;
             if (areaCodeToName.ContainsKey(areaCode) == false)
             {
                 areaCodeToTypeName.Add(areaCode, areaType.ShortName);
                 areaCodeToName.Add(areaCode, area.Name);
             }
         }
     }
 }
コード例 #17
0
 public ChildAreaCounter(IAreasReader areasReader)
 {
     _areasReader = areasReader;
 }
コード例 #18
0
 public PostcodeProvider(IAreasReader areasReader)
 {
     this.areasReader = areasReader;
 }
コード例 #19
0
 public CsvBuilderIndicatorDataHeaderWriter(IAreasReader areasReader, IndicatorExportParameters generalParameters)
 {
     _areasReader       = areasReader;
     _generalParameters = generalParameters;
 }
 public FilteredChildAreaListProvider(IAreasReader areasReader)
 {
     _areasReader = areasReader;
 }
コード例 #21
0
 public AreaListProvider(IAreasReader areasReader)
 {
     this.areasReader = areasReader;
 }
        private static CategorisedArea GetDecileArea(int childAreaTypeId, string areaCode, IAreasReader areasReader)
        {
            CategorisedArea decileArea = null;

            if (childAreaTypeId == AreaTypeIds.DistrictAndUnitaryAuthority)
            {
                decileArea = areasReader.GetCategorisedArea(areaCode, AreaTypeIds.Country,
                    AreaTypeIds.DistrictAndUnitaryAuthority,
                    CategoryTypeIds.DeprivationDecileDistrictAndUA2010);
            }
            else if (childAreaTypeId == AreaTypeIds.CountyAndUnitaryAuthority)
            {
                decileArea = areasReader.GetCategorisedArea(areaCode, AreaTypeIds.Country,
                    AreaTypeIds.CountyAndUnitaryAuthority,
                    CategoryTypeIds.DeprivationDecileCountyAndUA2010);
            }

            return decileArea;
        }
コード例 #23
0
 public Calculator()
 {
     _groupReader = ReaderFactory.GetGroupDataReader();
     _areasReader = ReaderFactory.GetAreasReader();
 }
 public AreaTypesWithParentAreaTypesBuilder(IList<ParentAreaGroup> parentAreaGroups, IAreasReader areasReader)
 {
     this.parentAreaGroups = parentAreaGroups;
     this.areasReader = areasReader;
 }