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 District
createDistrict(District district)
Creates IVR group and sets this group toDistrict
then saves the district into the db.Facility
createFacility(Facility facility)
Facility
createImportedFacility(Facility facility)
Village
createImportedVillage(Village village)
Sector
createSector(Sector sector)
Village
createVillage(Village village)
District
getDistrict(java.util.UUID id)
java.util.List<District>
getDistricts()
java.util.List<Facility>
getFacilites()
Facility
getFacility(java.util.UUID id)
Sector
getSector(java.util.UUID id)
java.util.List<Sector>
getSectors()
Village
getVillage(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.District
saveDistrict(District district)
Update District.Facility
saveFacility(Facility facility)
Update Facility.Sector
saveSector(Sector sector)
Update Sector.Village
saveVillage(Village village)
Update Village.org.springframework.data.domain.Page<District>
searchDistricts(java.lang.String districtName, org.springframework.data.domain.Pageable pageable)
FindsDistrict
s 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)
FindsFacility
s 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)
FindsVillage
s 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 toDistrict
then 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)
FindsDistrict
s matching all of the provided parameters. If there are no parameters, return all districts.- Parameters:
districtName
- name of aDistrict
pageable
- 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 ofDistrict
that 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)
FindsVillage
s matching all of the provided parameters. If there are no parameters, return all Villages.- Parameters:
parentFacility
- name ofFacility
to which a village may belongvillageName
- name of a villagedistrictName
- name ofDistrict
to which a village may belongsectorName
- name ofSector
to 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)
FindsFacility
s 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 ofDistrict
that may belong to a facilityinchargeEmail
- email of person in chargeinchargeFullName
- full name of person in chargeinchargePhone
- phone of person in chargeparentSector
- name ofSector
that 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.IOException
Import 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.IOException
Import 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.IOException
Import 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)
-
-