@Test public void shouldSave() throws Exception { MaintenanceRequest maintenanceRequest = new MaintenanceRequest(); ResponseEntity<OpenLmisResponse> response = controller.save(maintenanceRequest, request); assertThat(maintenanceRequest, is(response.getBody().getData().get("log"))); }
@RequestMapping(value = "save", method = RequestMethod.POST, headers = ACCEPT_JSON) public ResponseEntity<OpenLmisResponse> save(@RequestBody MaintenanceRequest maintenanceRequest, HttpServletRequest request){ if(maintenanceRequest.getId() == null) { maintenanceRequest.setCreatedBy(loggedInUserId(request)); maintenanceRequest.setUserId(loggedInUserId(request)); maintenanceRequest.setResolved(false); maintenanceRequest.setRequestDate(new Date()); } maintenanceRequest.setModifiedBy(loggedInUserId(request)); maintenanceRequest.setModifiedDate(new Date()); service.save(maintenanceRequest); ResponseEntity<OpenLmisResponse> response = OpenLmisResponse.success(messageService.message("message.maintenance.request.saved")); response.getBody().addData(LOG, maintenanceRequest); return response; }
MaintenanceRequestController extends BaseController { @RequestMapping(value = "save", method = RequestMethod.POST, headers = ACCEPT_JSON) public ResponseEntity<OpenLmisResponse> save(@RequestBody MaintenanceRequest maintenanceRequest, HttpServletRequest request){ if(maintenanceRequest.getId() == null) { maintenanceRequest.setCreatedBy(loggedInUserId(request)); maintenanceRequest.setUserId(loggedInUserId(request)); maintenanceRequest.setResolved(false); maintenanceRequest.setRequestDate(new Date()); } maintenanceRequest.setModifiedBy(loggedInUserId(request)); maintenanceRequest.setModifiedDate(new Date()); service.save(maintenanceRequest); ResponseEntity<OpenLmisResponse> response = OpenLmisResponse.success(messageService.message("message.maintenance.request.saved")); response.getBody().addData(LOG, maintenanceRequest); return response; } }
MaintenanceRequestController extends BaseController { @RequestMapping(value = "save", method = RequestMethod.POST, headers = ACCEPT_JSON) public ResponseEntity<OpenLmisResponse> save(@RequestBody MaintenanceRequest maintenanceRequest, HttpServletRequest request){ if(maintenanceRequest.getId() == null) { maintenanceRequest.setCreatedBy(loggedInUserId(request)); maintenanceRequest.setUserId(loggedInUserId(request)); maintenanceRequest.setResolved(false); maintenanceRequest.setRequestDate(new Date()); } maintenanceRequest.setModifiedBy(loggedInUserId(request)); maintenanceRequest.setModifiedDate(new Date()); service.save(maintenanceRequest); ResponseEntity<OpenLmisResponse> response = OpenLmisResponse.success(messageService.message("message.maintenance.request.saved")); response.getBody().addData(LOG, maintenanceRequest); return response; }  }
MaintenanceRequestController extends BaseController { @RequestMapping(value = "save", method = RequestMethod.POST, headers = ACCEPT_JSON) public ResponseEntity<OpenLmisResponse> save(@RequestBody MaintenanceRequest maintenanceRequest, HttpServletRequest request){ if(maintenanceRequest.getId() == null) { maintenanceRequest.setCreatedBy(loggedInUserId(request)); maintenanceRequest.setUserId(loggedInUserId(request)); maintenanceRequest.setResolved(false); maintenanceRequest.setRequestDate(new Date()); } maintenanceRequest.setModifiedBy(loggedInUserId(request)); maintenanceRequest.setModifiedDate(new Date()); service.save(maintenanceRequest); ResponseEntity<OpenLmisResponse> response = OpenLmisResponse.success(messageService.message("message.maintenance.request.saved")); response.getBody().addData(LOG, maintenanceRequest); return response; }  @RequestMapping(method = RequestMethod.GET, value = "list") ResponseEntity<OpenLmisResponse> getAll(); @RequestMapping(method = RequestMethod.GET, value = "id") ResponseEntity<OpenLmisResponse> getById( @RequestParam("id") Long id); @RequestMapping(method = RequestMethod.GET, value = "for-facility") ResponseEntity<OpenLmisResponse> getByFacilityId( @RequestParam("id") Long id); @RequestMapping(method = RequestMethod.GET, value = "for-vendor") ResponseEntity<OpenLmisResponse> getByVendorId( @RequestParam("id") Long id); @RequestMapping(method = RequestMethod.GET, value = "outstanding-for-vendor") ResponseEntity<OpenLmisResponse> getOutstandingByVendorId( @RequestParam("id") Long id); @RequestMapping(method = RequestMethod.GET, value = "outstanding-for-user") ResponseEntity<OpenLmisResponse> getOutstandingByUserId( HttpServletRequest request); @RequestMapping(method = RequestMethod.GET, value = "full-history") ResponseEntity<OpenLmisResponse> getFullHistoryId( @RequestParam("id") Long inventoryId); @RequestMapping(value = "save", method = RequestMethod.POST, headers = ACCEPT_JSON) ResponseEntity<OpenLmisResponse> save(@RequestBody MaintenanceRequest maintenanceRequest, HttpServletRequest request); }
MaintenanceRequestController extends BaseController { @RequestMapping(value = "save", method = RequestMethod.POST, headers = ACCEPT_JSON) public ResponseEntity<OpenLmisResponse> save(@RequestBody MaintenanceRequest maintenanceRequest, HttpServletRequest request){ if(maintenanceRequest.getId() == null) { maintenanceRequest.setCreatedBy(loggedInUserId(request)); maintenanceRequest.setUserId(loggedInUserId(request)); maintenanceRequest.setResolved(false); maintenanceRequest.setRequestDate(new Date()); } maintenanceRequest.setModifiedBy(loggedInUserId(request)); maintenanceRequest.setModifiedDate(new Date()); service.save(maintenanceRequest); ResponseEntity<OpenLmisResponse> response = OpenLmisResponse.success(messageService.message("message.maintenance.request.saved")); response.getBody().addData(LOG, maintenanceRequest); return response; }  @RequestMapping(method = RequestMethod.GET, value = "list") ResponseEntity<OpenLmisResponse> getAll(); @RequestMapping(method = RequestMethod.GET, value = "id") ResponseEntity<OpenLmisResponse> getById( @RequestParam("id") Long id); @RequestMapping(method = RequestMethod.GET, value = "for-facility") ResponseEntity<OpenLmisResponse> getByFacilityId( @RequestParam("id") Long id); @RequestMapping(method = RequestMethod.GET, value = "for-vendor") ResponseEntity<OpenLmisResponse> getByVendorId( @RequestParam("id") Long id); @RequestMapping(method = RequestMethod.GET, value = "outstanding-for-vendor") ResponseEntity<OpenLmisResponse> getOutstandingByVendorId( @RequestParam("id") Long id); @RequestMapping(method = RequestMethod.GET, value = "outstanding-for-user") ResponseEntity<OpenLmisResponse> getOutstandingByUserId( HttpServletRequest request); @RequestMapping(method = RequestMethod.GET, value = "full-history") ResponseEntity<OpenLmisResponse> getFullHistoryId( @RequestParam("id") Long inventoryId); @RequestMapping(value = "save", method = RequestMethod.POST, headers = ACCEPT_JSON) ResponseEntity<OpenLmisResponse> save(@RequestBody MaintenanceRequest maintenanceRequest, HttpServletRequest request); static final String LOG; static final String LOGS; }