Package org.motechproject.mots.web
Class LocationController
- java.lang.Object
-
- org.motechproject.mots.web.BaseController
-
- org.motechproject.mots.web.LocationController
-
@Controller public class LocationController extends BaseController
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
DISTRICT_NAME_PARAM
static java.lang.String
INCHARGE_EMAIL_PARAM
static java.lang.String
INCHARGE_FULL_NAME_PARAM
static java.lang.String
INCHARGE_PHONE_PARAM
static java.lang.String
NAME_PARAM
static java.lang.String
PARENT_PARAM
static java.lang.String
SECTOR_NAME_PARAM
-
Constructor Summary
Constructors Constructor Description LocationController()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description DistrictCreationDto
createDistrict(@Valid DistrictCreationDto districtCreationDto, org.springframework.validation.BindingResult bindingResult)
CreatesDistrict
from given dto.FacilityCreationDto
createFacility(@Valid FacilityCreationDto facilityCreationDto, org.springframework.validation.BindingResult bindingResult)
CreatesFacility
from given dto.SectorCreationDto
createSector(@Valid SectorCreationDto sectorCreationDto, org.springframework.validation.BindingResult bindingResult)
CreatesSector
from given dto.VillageCreationDto
createVillage(@Valid VillageCreationDto villageCreationDto, org.springframework.validation.BindingResult bindingResult)
CreatesVillage
from it's dto.DistrictCreationDto
getDistrict(java.util.UUID id)
GetDistrict
with given id.java.util.List<DistrictDto>
getDistricts()
Get list ofDistrict
s.java.util.Set<LocationPreviewDto>
getDistrictsOnly()
Get list ofDistrict
s for preview.java.util.Set<LocationPreviewDto>
getFacilitiesOnly()
Get list ofFacility
s for preview.FacilityExtendedInfoDto
getFacility(java.util.UUID id)
GetFacility
with given id.SectorCreationDto
getSector(java.util.UUID id)
GetSector
with given id.java.util.Set<LocationPreviewDto>
getSectorsOnly()
Get list ofSector
s for preview.VillageExtendedInfoDto
getVillage(java.util.UUID id)
GetVillage
with given id.java.util.Set<LocationPreviewDto>
getVillagesOnly()
Get list ofVillage
s for preview.java.util.Map<java.lang.Integer,java.lang.String>
importFacilityCsv(org.springframework.web.multipart.MultipartFile file)
Import list of Facilities in ".csv" format to mots, parse it and save records in DB.java.util.Map<java.lang.Integer,java.lang.String>
importSectorCsv(org.springframework.web.multipart.MultipartFile file)
Import list of Sectors in ".csv" format to mots, parse it and save records in DB.java.util.Map<java.lang.Integer,java.lang.String>
importVillageCsv(org.springframework.web.multipart.MultipartFile file)
Import list of Villages in ".csv" format to mots, parse it and save records in DB.DistrictCreationDto
saveDistrict(java.util.UUID id, @Valid DistrictCreationDto districtCreationDto, org.springframework.validation.BindingResult bindingResult)
UpdateDistrict
from given dto.FacilityCreationDto
saveFacility(java.util.UUID id, @Valid FacilityCreationDto facilityCreationDto, org.springframework.validation.BindingResult bindingResult)
UpdateFacility
from it's dto.SectorCreationDto
saveSector(java.util.UUID id, @Valid SectorCreationDto sectorCreationDto, org.springframework.validation.BindingResult bindingResult)
UpdateSector
from it's dto.VillageCreationDto
saveVillage(java.util.UUID id, @Valid VillageCreationDto villageCreationDto, org.springframework.validation.BindingResult bindingResult)
UpdateVillage
.org.springframework.data.domain.Page<LocationPreviewDto>
searchDistricts(java.lang.String name, org.springframework.data.domain.Pageable pageable)
FindsDistrict
s matching all of the provided parameters.org.springframework.data.domain.Page<LocationPreviewDto>
searchFacilities(java.lang.String name, java.lang.String inchargeFullName, java.lang.String inchargePhone, java.lang.String inchargeEmail, java.lang.String parentSector, java.lang.String district, org.springframework.data.domain.Pageable pageable)
Finds facilities matching all of the provided parameters.org.springframework.data.domain.Page<LocationPreviewDto>
searchSectors(java.lang.String name, java.lang.String parentDistrict, org.springframework.data.domain.Pageable pageable)
Finds Sectors matching all of the provided parameters.org.springframework.data.domain.Page<LocationPreviewDto>
searchVillages(java.lang.String name, java.lang.String parentFacility, java.lang.String sector, java.lang.String district, org.springframework.data.domain.Pageable pageable)
Finds Villages matching all of the provided parameters.-
Methods inherited from class org.motechproject.mots.web.BaseController
checkBindingResult, getErrors
-
-
-
-
Field Detail
-
NAME_PARAM
public static final java.lang.String NAME_PARAM
- See Also:
- Constant Field Values
-
PARENT_PARAM
public static final java.lang.String PARENT_PARAM
- See Also:
- Constant Field Values
-
INCHARGE_FULL_NAME_PARAM
public static final java.lang.String INCHARGE_FULL_NAME_PARAM
- See Also:
- Constant Field Values
-
INCHARGE_PHONE_PARAM
public static final java.lang.String INCHARGE_PHONE_PARAM
- See Also:
- Constant Field Values
-
INCHARGE_EMAIL_PARAM
public static final java.lang.String INCHARGE_EMAIL_PARAM
- See Also:
- Constant Field Values
-
SECTOR_NAME_PARAM
public static final java.lang.String SECTOR_NAME_PARAM
- See Also:
- Constant Field Values
-
DISTRICT_NAME_PARAM
public static final java.lang.String DISTRICT_NAME_PARAM
- See Also:
- Constant Field Values
-
-
Method Detail
-
createDistrict
@RequestMapping(value="/district", method=POST) @ResponseStatus(CREATED) @ResponseBody public DistrictCreationDto createDistrict(@RequestBody @Valid @Valid DistrictCreationDto districtCreationDto, org.springframework.validation.BindingResult bindingResult)
CreatesDistrict
from given dto.- Parameters:
districtCreationDto
- DTO of District to be createdbindingResult
- spring object used for validation- Returns:
- created District
-
createSector
@RequestMapping(value="/sector", method=POST) @ResponseStatus(CREATED) @ResponseBody public SectorCreationDto createSector(@RequestBody @Valid @Valid SectorCreationDto sectorCreationDto, org.springframework.validation.BindingResult bindingResult)
CreatesSector
from given dto.- Parameters:
sectorCreationDto
- DTO of sector to be createdbindingResult
- spring object used for validation- Returns:
- created Sector
-
createFacility
@RequestMapping(value="/facility", method=POST) @ResponseStatus(CREATED) @ResponseBody public FacilityCreationDto createFacility(@RequestBody @Valid @Valid FacilityCreationDto facilityCreationDto, org.springframework.validation.BindingResult bindingResult)
CreatesFacility
from given dto.- Parameters:
facilityCreationDto
- DTO of facility to be createdbindingResult
- spring object used for validation- Returns:
- created Facility
-
createVillage
@RequestMapping(value="/village", method=POST) @ResponseStatus(CREATED) @ResponseBody public VillageCreationDto createVillage(@RequestBody @Valid @Valid VillageCreationDto villageCreationDto, org.springframework.validation.BindingResult bindingResult)
CreatesVillage
from it's dto.- Parameters:
villageCreationDto
- DTO of village to be createdbindingResult
- spring object used for validation- Returns:
- created Village
-
saveDistrict
@RequestMapping(value="/district/{id}", method=PUT) @ResponseStatus(OK) @ResponseBody public DistrictCreationDto saveDistrict(@PathVariable("id") java.util.UUID id, @RequestBody @Valid @Valid DistrictCreationDto districtCreationDto, org.springframework.validation.BindingResult bindingResult)
UpdateDistrict
from given dto.- Parameters:
id
- id of District to updatedistrictCreationDto
- DTO of District to be updatedbindingResult
- spring object used for validation- Returns:
- updated District
-
saveSector
@RequestMapping(value="/sector/{id}", method=PUT) @ResponseStatus(OK) @ResponseBody public SectorCreationDto saveSector(@PathVariable("id") java.util.UUID id, @RequestBody @Valid @Valid SectorCreationDto sectorCreationDto, org.springframework.validation.BindingResult bindingResult)
UpdateSector
from it's dto.- Parameters:
id
- id of Sector to updatesectorCreationDto
- DTO of Sector to be updatedbindingResult
- spring object used for validation- Returns:
- updated Sector
-
saveVillage
@RequestMapping(value="/village/{id}", method=PUT) @ResponseStatus(OK) @ResponseBody public VillageCreationDto saveVillage(@PathVariable("id") java.util.UUID id, @RequestBody @Valid @Valid VillageCreationDto villageCreationDto, org.springframework.validation.BindingResult bindingResult)
UpdateVillage
. from it's dto- Parameters:
id
- id of Village to updatevillageCreationDto
- DTO of Village to be updatedbindingResult
- spring object used for validation- Returns:
- updated Village
-
saveFacility
@RequestMapping(value="/facility/{id}", method=PUT) @ResponseStatus(OK) @ResponseBody public FacilityCreationDto saveFacility(@PathVariable("id") java.util.UUID id, @RequestBody @Valid @Valid FacilityCreationDto facilityCreationDto, org.springframework.validation.BindingResult bindingResult)
UpdateFacility
from it's dto.- Parameters:
id
- id of Facility to updatefacilityCreationDto
- DTO of Facility to be updatedbindingResult
- spring object used for validation- Returns:
- updated Facility
FacilityCreationDto
-
getDistrict
@RequestMapping(value="/district/{id}", method=GET) @ResponseStatus(OK) @ResponseBody public DistrictCreationDto getDistrict(@PathVariable("id") java.util.UUID id)
GetDistrict
with given id.- Parameters:
id
- id of District to find- Returns:
- DistrictCreationDto with given id
-
getSector
@RequestMapping(value="/sector/{id}", method=GET) @ResponseStatus(OK) @ResponseBody public SectorCreationDto getSector(@PathVariable("id") java.util.UUID id)
GetSector
with given id.- Parameters:
id
- id of Sector to find- Returns:
- SectorCreationDto with given id
-
getFacility
@RequestMapping(value="/facility/{id}", method=GET) @ResponseStatus(OK) @ResponseBody public FacilityExtendedInfoDto getFacility(@PathVariable("id") java.util.UUID id)
GetFacility
with given id.- Parameters:
id
- id of Facility to find- Returns:
- FacilityCreationDto with given id
-
getVillage
@RequestMapping(value="/village/{id}", method=GET) @ResponseStatus(OK) @ResponseBody public VillageExtendedInfoDto getVillage(@PathVariable("id") java.util.UUID id)
GetVillage
with given id.- Parameters:
id
- id of Village to find- Returns:
- VillageCreationDto with given id
-
getDistricts
@RequestMapping(value="/districts", method=GET) @ResponseStatus(OK) @ResponseBody public java.util.List<DistrictDto> getDistricts()
Get list ofDistrict
s.- Returns:
- list of all districts
-
getDistrictsOnly
@RequestMapping(value="/districtsOnly", method=GET) @ResponseStatus(OK) @ResponseBody public java.util.Set<LocationPreviewDto> getDistrictsOnly()
Get list ofDistrict
s for preview.- Returns:
- list of all districts
-
getSectorsOnly
@RequestMapping(value="/sectorsOnly", method=GET) @ResponseStatus(OK) @ResponseBody public java.util.Set<LocationPreviewDto> getSectorsOnly()
Get list ofSector
s for preview.- Returns:
- list of all Sectors
-
getFacilitiesOnly
@RequestMapping(value="/facilitiesOnly", method=GET) @ResponseStatus(OK) @ResponseBody public java.util.Set<LocationPreviewDto> getFacilitiesOnly()
Get list ofFacility
s for preview.- Returns:
- list of all facilities
-
getVillagesOnly
@RequestMapping(value="/villagesOnly", method=GET) @ResponseStatus(OK) @ResponseBody public java.util.Set<LocationPreviewDto> getVillagesOnly()
Get list ofVillage
s for preview.- Returns:
- list of all villages
-
searchDistricts
@RequestMapping(value="district/locations/search", method=GET) @ResponseStatus(OK) @ResponseBody public org.springframework.data.domain.Page<LocationPreviewDto> searchDistricts(@RequestParam(value="name",required=false) java.lang.String name, org.springframework.data.domain.Pageable pageable)
FindsDistrict
s matching all of the provided parameters. If there are no parameters, return all districts.- Parameters:
name
- of the districtpageable
- pagination parameters (page size, page number, sort order)- Returns:
- page with districts
-
searchSectors
@RequestMapping(value="sector/locations/search", method=GET) @ResponseStatus(OK) @ResponseBody public org.springframework.data.domain.Page<LocationPreviewDto> searchSectors(@RequestParam(value="name",required=false) java.lang.String name, @RequestParam(value="parent",required=false) 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)name
- name of the sectorparentDistrict
- district to which sector may belong- Returns:
- page with sectors
-
searchVillages
@RequestMapping(value="village/locations/search", method=GET) @ResponseStatus(OK) @ResponseBody public org.springframework.data.domain.Page<LocationPreviewDto> searchVillages(@RequestParam(value="name",required=false) java.lang.String name, @RequestParam(value="parent",required=false) java.lang.String parentFacility, @RequestParam(value="sectorName",required=false) java.lang.String sector, @RequestParam(value="districtName",required=false) java.lang.String district, org.springframework.data.domain.Pageable pageable)
Finds Villages matching all of the provided parameters. If there are no parameters, return all Villages.
-
searchFacilities
@RequestMapping(value="facility/locations/search", method=GET) @ResponseStatus(OK) @ResponseBody public org.springframework.data.domain.Page<LocationPreviewDto> searchFacilities(@RequestParam(value="name",required=false) java.lang.String name, @RequestParam(value="inchargeFullName",required=false) java.lang.String inchargeFullName, @RequestParam(value="inchargePhone",required=false) java.lang.String inchargePhone, @RequestParam(value="inchargeEmail",required=false) java.lang.String inchargeEmail, @RequestParam(value="parent",required=false) java.lang.String parentSector, @RequestParam(value="districtName",required=false) java.lang.String district, org.springframework.data.domain.Pageable pageable)
Finds facilities matching all of the provided parameters. If there are no parameters, return all facilities.- Parameters:
district
- name of theDistrict
to which facility may belongpageable
- pagination parameters (page size, page number, sort order)name
- name of facilityinchargeEmail
- email of person in chargeinchargeFullName
- full name of person in chargeinchargePhone
- phone of person in chargeparentSector
- nameSector
to which facility may belong- Returns:
- page with facilities
-
importSectorCsv
@RequestMapping(value="/sector/import", method=POST) @ResponseStatus(OK) @ResponseBody public java.util.Map<java.lang.Integer,java.lang.String> importSectorCsv(@RequestPart("file") org.springframework.web.multipart.MultipartFile file) throws java.io.IOException
Import list of Sectors in ".csv" format to mots, parse it and save records in DB.- Parameters:
file
- File in ".csv" format to upload- Returns:
- map with row numbers as keys and errors as values.
- Throws:
java.io.IOException
- if there is an error while reading a file
-
importVillageCsv
@RequestMapping(value="/village/import", method=POST) @ResponseStatus(OK) @ResponseBody public java.util.Map<java.lang.Integer,java.lang.String> importVillageCsv(@RequestPart("file") org.springframework.web.multipart.MultipartFile file) throws java.io.IOException
Import list of Villages in ".csv" format to mots, parse it and save records in DB.- Parameters:
file
- File in ".csv" format to upload- Returns:
- map with row numbers as keys and errors as values.
- Throws:
java.io.IOException
- if there is an error while reading a file
-
importFacilityCsv
@RequestMapping(value="/facility/import", method=POST) @ResponseStatus(OK) @ResponseBody public java.util.Map<java.lang.Integer,java.lang.String> importFacilityCsv(@RequestPart("file") org.springframework.web.multipart.MultipartFile file) throws java.io.IOException
Import list of Facilities in ".csv" format to mots, parse it and save records in DB.- Parameters:
file
- File in ".csv" format to upload- Returns:
- map with row numbers as keys and errors as values.
- Throws:
java.io.IOException
- if there is an error while reading a file
-
-