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.StringDISTRICT_NAME_PARAMstatic java.lang.StringINCHARGE_EMAIL_PARAMstatic java.lang.StringINCHARGE_FULL_NAME_PARAMstatic java.lang.StringINCHARGE_PHONE_PARAMstatic java.lang.StringNAME_PARAMstatic java.lang.StringPARENT_PARAMstatic java.lang.StringSECTOR_NAME_PARAM
-
Constructor Summary
Constructors Constructor Description LocationController()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description DistrictCreationDtocreateDistrict(@Valid DistrictCreationDto districtCreationDto, org.springframework.validation.BindingResult bindingResult)CreatesDistrictfrom given dto.FacilityCreationDtocreateFacility(@Valid FacilityCreationDto facilityCreationDto, org.springframework.validation.BindingResult bindingResult)CreatesFacilityfrom given dto.SectorCreationDtocreateSector(@Valid SectorCreationDto sectorCreationDto, org.springframework.validation.BindingResult bindingResult)CreatesSectorfrom given dto.VillageCreationDtocreateVillage(@Valid VillageCreationDto villageCreationDto, org.springframework.validation.BindingResult bindingResult)CreatesVillagefrom it's dto.DistrictCreationDtogetDistrict(java.util.UUID id)GetDistrictwith given id.java.util.List<DistrictDto>getDistricts()Get list ofDistricts.java.util.Set<LocationPreviewDto>getDistrictsOnly()Get list ofDistricts for preview.java.util.Set<LocationPreviewDto>getFacilitiesOnly()Get list ofFacilitys for preview.FacilityExtendedInfoDtogetFacility(java.util.UUID id)GetFacilitywith given id.SectorCreationDtogetSector(java.util.UUID id)GetSectorwith given id.java.util.Set<LocationPreviewDto>getSectorsOnly()Get list ofSectors for preview.VillageExtendedInfoDtogetVillage(java.util.UUID id)GetVillagewith given id.java.util.Set<LocationPreviewDto>getVillagesOnly()Get list ofVillages 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.DistrictCreationDtosaveDistrict(java.util.UUID id, @Valid DistrictCreationDto districtCreationDto, org.springframework.validation.BindingResult bindingResult)UpdateDistrictfrom given dto.FacilityCreationDtosaveFacility(java.util.UUID id, @Valid FacilityCreationDto facilityCreationDto, org.springframework.validation.BindingResult bindingResult)UpdateFacilityfrom it's dto.SectorCreationDtosaveSector(java.util.UUID id, @Valid SectorCreationDto sectorCreationDto, org.springframework.validation.BindingResult bindingResult)UpdateSectorfrom it's dto.VillageCreationDtosaveVillage(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)FindsDistricts 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)CreatesDistrictfrom 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)CreatesSectorfrom 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)CreatesFacilityfrom 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)CreatesVillagefrom 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)UpdateDistrictfrom 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)UpdateSectorfrom 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)UpdateFacilityfrom 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)GetDistrictwith 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)GetSectorwith 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)GetFacilitywith 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)GetVillagewith 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 ofDistricts.- Returns:
- list of all districts
-
getDistrictsOnly
@RequestMapping(value="/districtsOnly", method=GET) @ResponseStatus(OK) @ResponseBody public java.util.Set<LocationPreviewDto> getDistrictsOnly()Get list ofDistricts for preview.- Returns:
- list of all districts
-
getSectorsOnly
@RequestMapping(value="/sectorsOnly", method=GET) @ResponseStatus(OK) @ResponseBody public java.util.Set<LocationPreviewDto> getSectorsOnly()Get list ofSectors for preview.- Returns:
- list of all Sectors
-
getFacilitiesOnly
@RequestMapping(value="/facilitiesOnly", method=GET) @ResponseStatus(OK) @ResponseBody public java.util.Set<LocationPreviewDto> getFacilitiesOnly()Get list ofFacilitys for preview.- Returns:
- list of all facilities
-
getVillagesOnly
@RequestMapping(value="/villagesOnly", method=GET) @ResponseStatus(OK) @ResponseBody public java.util.Set<LocationPreviewDto> getVillagesOnly()Get list ofVillages 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)FindsDistricts 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 theDistrictto 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- nameSectorto 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.IOExceptionImport 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.IOExceptionImport 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.IOExceptionImport 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
-
-