@RequestMapping(value = "/search", method = GET, headers = ACCEPT_JSON) public ResponseEntity<OpenLmisResponse> getByProgram( @RequestParam(value = "page", defaultValue = "1") Integer page, @RequestParam(value = "searchParam", required = true) String searchParam, @RequestParam(value = "column", required = true, defaultValue = "product") String column, @Value("${search.page.size}") String limit) { Pagination pagination = new Pagination(page, parseInt(limit)); pagination.setTotalRecords(service.getTotalSearchResultCount(searchParam, column)); List<ProgramProduct> programProductList = service.search(searchParam, pagination, column); ResponseEntity<OpenLmisResponse> response = OpenLmisResponse.response(PROGRAM_PRODUCT_LIST, programProductList); response.getBody().addData("pagination", pagination); return response; }
@RequestMapping(value = "/programId/{programId}", method = GET, headers = ACCEPT_JSON) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_PROGRAM_PRODUCT')") public ResponseEntity<OpenLmisResponse> getProgramProductsByProgram( @PathVariable Long programId) { List<ProgramProduct> programProductsByProgram = service.getByProgram(new Program(programId)); return response(PROGRAM_PRODUCT_LIST, programProductsByProgram); }
@RequestMapping( value = "/filter/programId/{programId}/facilityTypeId/{facilityTypeId}", method = GET, headers = ACCEPT_JSON) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_FACILITY_APPROVED_PRODUCT')") public List<ProgramProduct> getUnapprovedProgramProducts( @PathVariable(value = "facilityTypeId") Long facilityTypeId, @PathVariable(value = "programId") Long programId) { return service.getUnapprovedProgramProducts(facilityTypeId, programId); }
@RequestMapping(value = "/{programProductId}/isa", method = POST, headers = ACCEPT_JSON) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_PROGRAM_PRODUCT')") public void insertIsa( @PathVariable Long programProductId, @RequestBody ProgramProductISA programProductISA, HttpServletRequest request) { programProductISA.setCreatedBy(loggedInUserId(request)); programProductISA.setModifiedBy(loggedInUserId(request)); programProductISA.setProgramProductId(programProductId); service.insertISA(programProductISA); }