@RequestMapping(method = GET, value = "id")
 @PreAuthorize(
     "@permissionEvaluator.hasPermission(principal,'MANAGE_EQUIPMENT_SETTINGS')"
         + " or @permissionEvaluator.hasPermission(principal,'MANAGE_EQUIPMENT_INVENTORY')")
 public ResponseEntity<OpenLmisResponse> getById(@RequestParam("id") Long id) {
   return OpenLmisResponse.response(EQUIPMENT_TYPE, service.getTypeById(id));
 }
 @RequestMapping(value = PROGRAMS, method = RequestMethod.GET)
 public ResponseEntity<OpenLmisResponse> getPrograms(HttpServletRequest request) {
   Long userId = loggedInUserId(request);
   return OpenLmisResponse.response(
       PROGRAMS,
       programService.getProgramForSupervisedFacilities(userId, MANAGE_EQUIPMENT_INVENTORY));
 }
 @RequestMapping(value = "facility/programs", method = RequestMethod.GET)
 public ResponseEntity<OpenLmisResponse> getProgramsForFacility(
     @RequestParam("facilityId") Long facilityId, HttpServletRequest request) {
   Long userId = loggedInUserId(request);
   return OpenLmisResponse.response(
       PROGRAMS,
       programService.getProgramsForUserByFacilityAndRights(
           facilityId, userId, MANAGE_EQUIPMENT_INVENTORY));
 }
 @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 = "save", method = POST, headers = ACCEPT_JSON)
 @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_EQUIPMENT_SETTINGS')")
 public ResponseEntity<OpenLmisResponse> save(
     @RequestBody EquipmentType type, HttpServletRequest request) {
   try {
     Long userId = loggedInUserId(request);
     type.setCreatedBy(userId);
     type.setModifiedBy(userId);
     service.save(type);
   } catch (DuplicateKeyException exp) {
     return OpenLmisResponse.error("Duplicate Code Exists in DB.", HttpStatus.BAD_REQUEST);
   }
   return OpenLmisResponse.response(STATUS, "success");
 }
Пример #6
0
  @Test
  public void shouldGetSettingByKey() throws Exception {
    ConfigurationSetting setting = new ConfigurationSetting();

    when(configurationService.getByKey("123")).thenReturn(setting);

    ResponseEntity<OpenLmisResponse> expectResponse =
        new ResponseEntity<>(new OpenLmisResponse(), HttpStatus.OK);
    when(OpenLmisResponse.response("settings", setting)).thenReturn(expectResponse);

    ResponseEntity<OpenLmisResponse> response = controller.getByKey("123");

    verify(configurationService).getByKey("123");
    assertThat(response, is(expectResponse));
  }
 @RequestMapping(value = "list", method = RequestMethod.GET)
 public ResponseEntity<OpenLmisResponse> getInventory(
     @RequestParam("typeId") Long typeId,
     @RequestParam("programId") Long programId,
     @RequestParam("equipmentTypeId") Long equipmentTypeId,
     @RequestParam(value = "page", defaultValue = "1") Integer page,
     @Value("${search.page.size}") String limit,
     HttpServletRequest request) {
   Long userId = loggedInUserId(request);
   Pagination pagination = new Pagination(page, parseInt(limit));
   pagination.setTotalRecords(
       service.getInventoryCount(userId, typeId, programId, equipmentTypeId));
   List<EquipmentInventory> inventory =
       service.getInventory(userId, typeId, programId, equipmentTypeId, pagination);
   ResponseEntity<OpenLmisResponse> response = OpenLmisResponse.response(INVENTORY, inventory);
   response.getBody().addData(PAGINATION, pagination);
   return response;
 }
 @RequestMapping(value = "by-id", method = RequestMethod.GET)
 @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_EQUIPMENT_INVENTORY')")
 public ResponseEntity<OpenLmisResponse> getInventory(@RequestParam("id") Long id) {
   return OpenLmisResponse.response(INVENTORY, service.getInventoryById(id));
 }
 @RequestMapping(method = GET, value = "operational-status")
 public ResponseEntity<OpenLmisResponse> getAllStatuses() {
   return OpenLmisResponse.response(STATUS, statusRepository.getAll());
 }
 @RequestMapping(method = GET, value = "list")
 public ResponseEntity<OpenLmisResponse> getAll() {
   return OpenLmisResponse.response(EQUIPMENT_TYPES, service.getAll());
 }