private District getDistrictById(State state, Long districtId) { if (null == districtId) { return null; } else { for (District district : state.getDistricts()) { if (Objects.equals(district.getCode(), districtId)) { return district; } } throw new CsvImportDataException("District does not exists"); } }
private FrontLineWorker processInstance(Map<String, Object> record, State state) { String mctsFlwId = (String) record.get(ID); Long contactNumber = (Long) record.get(CONTACT_NO); String name = (String) record.get(NAME); Long districtId = (Long) record.get(DISTRICT_ID); District district = getDistrictById(state, districtId); FrontLineWorker instance = new FrontLineWorker(contactNumber); instance.setMctsFlwId(mctsFlwId); instance.setName(name); instance.setDistrict(district); if (null != district) { instance.setLanguage(district.getLanguage()); } return instance; }
private void createLocationData() { // specific locations from the mother and child data files: State state21 = createState(21L, "State 21"); District district2 = createDistrict(state21, 2L, "Jharsuguda", new Language("21", "English")); District district3 = createDistrict(state21, 3L, "Sambalpur"); District district4 = createDistrict(state21, 4L, "Debagarh"); state21.getDistricts().addAll(Arrays.asList(district2, district3, district4)); Taluka taluka24 = createTaluka(district2, "0024", "Laikera P.S.", 24); district2.getTalukas().add(taluka24); Taluka taluka26 = createTaluka(district3, "0026", "Govindpur P.S.", 26); district3.getTalukas().add(taluka26); Taluka taluka46 = createTaluka(district4, "0046", "Debagarh P.S.", 46); district4.getTalukas().add(taluka46); HealthBlock healthBlock259 = createHealthBlock(taluka24, 259L, "Laikera", "hq"); taluka24.getHealthBlocks().add(healthBlock259); HealthBlock healthBlock453 = createHealthBlock(taluka26, 453L, "Bamara", "hq"); taluka26.getHealthBlocks().add(healthBlock453); HealthBlock healthBlock153 = createHealthBlock(taluka46, 153L, "Tileibani", "hq"); taluka46.getHealthBlocks().add(healthBlock153); HealthFacilityType facilityType635 = createHealthFacilityType("Mundrajore CHC", 635L); HealthFacility healthFacility635 = createHealthFacility(healthBlock259, 635L, "Mundrajore CHC", facilityType635); healthBlock259.getHealthFacilities().add(healthFacility635); HealthFacilityType facilityType41 = createHealthFacilityType("Garposh CHC", 41L); HealthFacility healthFacility41 = createHealthFacility(healthBlock453, 41L, "Garposh CHC", facilityType41); healthBlock453.getHealthFacilities().add(healthFacility41); HealthFacilityType facilityType114 = createHealthFacilityType("CHC Tileibani", 114L); HealthFacility healthFacility114 = createHealthFacility(healthBlock153, 114L, "CHC Tileibani", facilityType114); healthBlock153.getHealthFacilities().add(healthFacility114); HealthSubFacility subFacilityType7389 = createHealthSubFacility("Babuniktimal", 7389L, healthFacility41); healthFacility41.getHealthSubFacilities().add(subFacilityType7389); HealthSubFacility subFacilityType7393 = createHealthSubFacility("Jarabaga", 7393L, healthFacility41); healthFacility41.getHealthSubFacilities().add(subFacilityType7393); HealthSubFacility subFacilityType2104 = createHealthSubFacility("Chupacabra", 2104L, healthFacility635); healthFacility635.getHealthSubFacilities().add(subFacilityType2104); HealthSubFacility subFacilityType342 = createHealthSubFacility("El Dorado", 342L, healthFacility114); healthFacility114.getHealthSubFacilities().add(subFacilityType342); Village village10004693 = createVillage(taluka24, 10004693L, 0, "Khairdihi"); Village village10004691 = createVillage(taluka24, 10004691L, 0, "Gambhariguda"); Village village1509 = createVillage(taluka24, 0, 1509L, "Mundrajore"); Village village1505 = createVillage(taluka24, 0, 1505L, "Kulemura"); Village village10004690 = createVillage(taluka24, 10004690L, 0, "Ampada"); Village village10004697 = createVillage(taluka24, 10004697L, 0, "Saletikra"); taluka24 .getVillages() .addAll( Arrays.asList( village10004693, village10004691, village1509, village1505, village10004690, village10004697)); Village village3089 = createVillage(taluka46, 0, 3089L, "Podapara"); taluka46.getVillages().add(village3089); stateDataService.create(state21); }