Package org.motechproject.mots.service
Class LocationService
- java.lang.Object
-
- org.motechproject.mots.service.LocationService
-
@Service public class LocationService extends java.lang.Object
-
-
Constructor Summary
Constructors Constructor Description LocationService()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description DistrictcreateDistrict(District district)Creates IVR group and sets this group toDistrictthen saves the district into the db.FacilitycreateFacility(Facility facility)FacilitycreateImportedFacility(Facility facility)VillagecreateImportedVillage(Village village)SectorcreateSector(Sector sector)VillagecreateVillage(Village village)DistrictgetDistrict(java.util.UUID id)java.util.List<District>getDistricts()java.util.List<Facility>getFacilites()FacilitygetFacility(java.util.UUID id)SectorgetSector(java.util.UUID id)java.util.List<Sector>getSectors()VillagegetVillage(java.util.UUID id)java.util.List<Village>getVillages()java.util.Map<java.lang.Integer,java.lang.String>importFacilitiesFromCsv(org.springframework.web.multipart.MultipartFile facilitiesCsvFile)Import and save Facility list from CSV file and return list of errors in the file.java.util.Map<java.lang.Integer,java.lang.String>importSectorsFromCsv(org.springframework.web.multipart.MultipartFile sectorsCsvFile)Import and save Sector list from CSV file and return list of errors in the file.java.util.Map<java.lang.Integer,java.lang.String>importVillagesFromCsv(org.springframework.web.multipart.MultipartFile villagesCsvFile)Import and save Village list from CSV file and return list of errors in the file.DistrictsaveDistrict(District district)Update District.FacilitysaveFacility(Facility facility)Update Facility.SectorsaveSector(Sector sector)Update Sector.VillagesaveVillage(Village village)Update Village.org.springframework.data.domain.Page<District>searchDistricts(java.lang.String districtName, org.springframework.data.domain.Pageable pageable)FindsDistricts matching all of the provided parameters.org.springframework.data.domain.Page<Facility>searchFacilities(java.lang.String facilityName, java.lang.String inchargeFullName, java.lang.String inchargePhone, java.lang.String inchargeEmail, java.lang.String parentSector, java.lang.String districtName, org.springframework.data.domain.Pageable pageable)FindsFacilitys matching all of the provided parameters.org.springframework.data.domain.Page<Sector>searchSectors(java.lang.String sectorName, java.lang.String parentDistrict, org.springframework.data.domain.Pageable pageable)Finds sectors matching all of the provided parameters.org.springframework.data.domain.Page<Village>searchVillages(java.lang.String villageName, java.lang.String parentFacility, java.lang.String sectorName, java.lang.String districtName, org.springframework.data.domain.Pageable pageable)FindsVillages matching all of the provided parameters.
-
-
-
Method Detail
-
getDistricts
public java.util.List<District> getDistricts()
-
getSectors
public java.util.List<Sector> getSectors()
-
getFacilites
public java.util.List<Facility> getFacilites()
-
getVillages
public java.util.List<Village> getVillages()
-
createDistrict
public District createDistrict(District district)
Creates IVR group and sets this group toDistrictthen saves the district into the db.- Parameters:
district- district to save- Returns:
- saves District
- Throws:
ChwException- if creating IVR group fails
-
searchDistricts
@PreAuthorize("hasAnyRole(\'ROLE_DISPLAY_FACILITIES\',\'ROLE_MANAGE_FACILITIES\',\'ROLE_MANAGE_OWN_FACILITIES\')") public org.springframework.data.domain.Page<District> searchDistricts(java.lang.String districtName, org.springframework.data.domain.Pageable pageable)FindsDistricts matching all of the provided parameters. If there are no parameters, return all districts.- Parameters:
districtName- name of aDistrictpageable- pagination parameters (page size, page number, sort order)- Returns:
- page with found districts
-
searchSectors
@PreAuthorize("hasAnyRole(\'ROLE_DISPLAY_FACILITIES\',\'ROLE_MANAGE_FACILITIES\',\'ROLE_MANAGE_OWN_FACILITIES\')") public org.springframework.data.domain.Page<Sector> searchSectors(java.lang.String sectorName, java.lang.String parentDistrict, org.springframework.data.domain.Pageable pageable)Finds sectors matching all of the provided parameters. If there are no parameters, return all sectors.- Parameters:
pageable- pagination parameters (page size, page number, sort order)sectorName- name of sectorparentDistrict- name ofDistrictthat may belong to sector- Returns:
- page with found sectors.
-
searchVillages
@PreAuthorize("hasAnyRole(\'ROLE_DISPLAY_FACILITIES\',\'ROLE_MANAGE_FACILITIES\',\'ROLE_MANAGE_OWN_FACILITIES\')") public org.springframework.data.domain.Page<Village> searchVillages(java.lang.String villageName, java.lang.String parentFacility, java.lang.String sectorName, java.lang.String districtName, org.springframework.data.domain.Pageable pageable)FindsVillages matching all of the provided parameters. If there are no parameters, return all Villages.- Parameters:
parentFacility- name ofFacilityto which a village may belongvillageName- name of a villagedistrictName- name ofDistrictto which a village may belongsectorName- name ofSectorto which a village may belongpageable- pagination parameters (page size, page number, sort order)- Returns:
- page with found villages
-
searchFacilities
@PreAuthorize("hasAnyRole(\'ROLE_DISPLAY_FACILITIES\',\'ROLE_MANAGE_FACILITIES\',\'ROLE_MANAGE_OWN_FACILITIES\')") public org.springframework.data.domain.Page<Facility> searchFacilities(java.lang.String facilityName, java.lang.String inchargeFullName, java.lang.String inchargePhone, java.lang.String inchargeEmail, java.lang.String parentSector, java.lang.String districtName, org.springframework.data.domain.Pageable pageable)FindsFacilitys matching all of the provided parameters. If there are no parameters, return all facilities.- Parameters:
pageable- pagination parameters (page size, page number, sort order)districtName- name ofDistrictthat may belong to a facilityinchargeEmail- email of person in chargeinchargeFullName- full name of person in chargeinchargePhone- phone of person in chargeparentSector- name ofSectorthat may belong to a facilityfacilityName- name of facility- Returns:
- page with found facilities
-
createFacility
@PreAuthorize("hasRole(\'ROLE_CREATE_FACILITIES\')") public Facility createFacility(Facility facility)
-
createVillage
@PreAuthorize("hasRole(\'ROLE_CREATE_FACILITIES\')") public Village createVillage(Village village)
-
saveDistrict
@PreAuthorize("hasAnyRole(\'ROLE_MANAGE_FACILITIES\',\'ROLE_MANAGE_OWN_FACILITIES\')") public District saveDistrict(District district)Update District.- Parameters:
district- District to update- Returns:
- updated District
-
saveSector
@PreAuthorize("hasAnyRole(\'ROLE_MANAGE_FACILITIES\',\'ROLE_MANAGE_OWN_FACILITIES\')") public Sector saveSector(Sector sector)Update Sector.- Parameters:
sector- Sector to update- Returns:
- updated Sector
-
saveFacility
@PreAuthorize("hasAnyRole(\'ROLE_MANAGE_FACILITIES\',\'ROLE_MANAGE_OWN_FACILITIES\')") public Facility saveFacility(Facility facility)Update Facility.- Parameters:
facility- facility to update- Returns:
- updated Facility
-
saveVillage
@PreAuthorize("hasAnyRole(\'ROLE_MANAGE_FACILITIES\',\'ROLE_MANAGE_OWN_FACILITIES\')") public Village saveVillage(Village village)Update Village.- Parameters:
village- Village to update- Returns:
- updated Village
-
importSectorsFromCsv
@PreAuthorize("hasRole(\'ROLE_UPLOAD_LOCATION_CSV\')") public java.util.Map<java.lang.Integer,java.lang.String> importSectorsFromCsv(org.springframework.web.multipart.MultipartFile sectorsCsvFile) throws java.io.IOExceptionImport and save Sector list from CSV file and return list of errors in the file.- Parameters:
sectorsCsvFile- CSV file with Sector list- Returns:
- map with row numbers as keys and errors as values.
- Throws:
java.io.IOException- in case of file issues
-
importVillagesFromCsv
@PreAuthorize("hasRole(\'ROLE_UPLOAD_LOCATION_CSV\')") public java.util.Map<java.lang.Integer,java.lang.String> importVillagesFromCsv(org.springframework.web.multipart.MultipartFile villagesCsvFile) throws java.io.IOExceptionImport and save Village list from CSV file and return list of errors in the file.- Parameters:
villagesCsvFile- CSV file with Village list- Returns:
- map with row numbers as keys and errors as values.
- Throws:
java.io.IOException- in case of file issues
-
importFacilitiesFromCsv
@PreAuthorize("hasRole(\'ROLE_UPLOAD_LOCATION_CSV\')") public java.util.Map<java.lang.Integer,java.lang.String> importFacilitiesFromCsv(org.springframework.web.multipart.MultipartFile facilitiesCsvFile) throws java.io.IOExceptionImport and save Facility list from CSV file and return list of errors in the file.- Parameters:
facilitiesCsvFile- CSV file with Facility list- Returns:
- map with row numbers as keys and errors as values.
- Throws:
java.io.IOException- in case of file issues
-
getVillage
@PreAuthorize("hasAnyRole(\'ROLE_DISPLAY_FACILITIES\',\'ROLE_MANAGE_FACILITIES\',\'ROLE_MANAGE_OWN_FACILITIES\')") public Village getVillage(java.util.UUID id)
-
getFacility
@PreAuthorize("hasAnyRole(\'ROLE_DISPLAY_FACILITIES\',\'ROLE_MANAGE_FACILITIES\',\'ROLE_MANAGE_OWN_FACILITIES\')") public Facility getFacility(java.util.UUID id)
-
getSector
@PreAuthorize("hasAnyRole(\'ROLE_DISPLAY_FACILITIES\',\'ROLE_MANAGE_FACILITIES\',\'ROLE_MANAGE_OWN_FACILITIES\')") public Sector getSector(java.util.UUID id)
-
getDistrict
@PreAuthorize("hasAnyRole(\'ROLE_DISPLAY_FACILITIES\',\'ROLE_MANAGE_FACILITIES\',\'ROLE_MANAGE_OWN_FACILITIES\')") public District getDistrict(java.util.UUID id)
-
-