Source:
public ResponseEntity<StudyInventoryTable> searchStudyTransactions( @PathVariable final String cropName, @PathVariable final String programUUID, @PathVariable final Integer studyId, @RequestBody final StudyTransactionsRequest studyTransactionsRequest ) { Preconditions.checkNotNull(studyTransactionsRequest, "params cannot be null"); final SortedPageRequest sortedRequest = studyTransactionsRequest.getSortedPageRequest(); Preconditions.checkNotNull(sortedRequest, "sortedRequest inside params cannot be null"); final Integer pageNumber = sortedRequest.getPageNumber(); final Integer pageSize = sortedRequest.getPageSize(); PagedResult<StudyTransactionsDto> pagedResult; try { inventoryLock.lockRead(); pagedResult = new PaginatedSearch().execute(pageNumber, pageSize, new SearchSpec<StudyTransactionsDto>() { @Override public long getCount() { return studyTransactionsService.countAllStudyTransactions(studyId, studyTransactionsRequest); } @Override public long getFilteredCount() { return studyTransactionsService.countFilteredStudyTransactions(studyId, studyTransactionsRequest); } @Override public List<StudyTransactionsDto> getResults(final PagedResult<StudyTransactionsDto> pagedResult) { return studyTransactionsService.searchStudyTransactions(studyId, studyTransactionsRequest); } }); } finally { inventoryLock.unlockRead(); } final StudyInventoryTable studyInventoryTable = new StudyInventoryTable(); studyInventoryTable.setData(pagedResult.getPageResults()); studyInventoryTable.setDraw(studyTransactionsRequest.getDraw()); studyInventoryTable.setRecordsTotal((int) pagedResult.getTotalResults()); studyInventoryTable.setRecordsFiltered((int) pagedResult.getFilteredResults()); return new ResponseEntity<>(studyInventoryTable, HttpStatus.OK); }

Target:
public ResponseEntity<StudyInventoryTable> searchStudyTransactions( @PathVariable final String cropName, @PathVariable final String programUUID, @PathVariable final Integer studyId, @RequestBody final StudyTransactionsRequest studyTransactionsRequest ) { BaseValidator.checkNotNull(studyTransactionsRequest, "param.null", new String[] {"studyTransactionsRequest"}); final SortedPageRequest sortedRequest = studyTransactionsRequest.getSortedPageRequest(); BaseValidator.checkNotNull(sortedRequest, "sortedrequest.empty"); final Integer pageNumber = sortedRequest.getPageNumber(); final Integer pageSize = sortedRequest.getPageSize(); PagedResult<StudyTransactionsDto> pagedResult; try { inventoryLock.lockRead(); pagedResult = new PaginatedSearch().execute(pageNumber, pageSize, new SearchSpec<StudyTransactionsDto>() { @Override public long getCount() { return studyTransactionsService.countStudyTransactions(studyId, null); } @Override public long getFilteredCount() { return studyTransactionsService.countStudyTransactions(studyId, studyTransactionsRequest); } @Override public List<StudyTransactionsDto> getResults(final PagedResult<StudyTransactionsDto> pagedResult) { return studyTransactionsService.searchStudyTransactions(studyId, studyTransactionsRequest); } }); } finally { inventoryLock.unlockRead(); } final StudyInventoryTable studyInventoryTable = new StudyInventoryTable(); studyInventoryTable.setData(pagedResult.getPageResults()); studyInventoryTable.setDraw(studyTransactionsRequest.getDraw()); studyInventoryTable.setRecordsTotal((int) pagedResult.getTotalResults()); studyInventoryTable.setRecordsFiltered((int) pagedResult.getFilteredResults()); return new ResponseEntity<>(studyInventoryTable, HttpStatus.OK); }