use of org.mifos.dto.domain.UserSearchDto in project head by mifos.
the class SystemUserSearchController method processSearch.
@RequestMapping(method = RequestMethod.POST)
public ModelAndView processSearch(@RequestParam(required = false, value = "next") String next, @RequestParam(required = false, value = "previous") String previous, @RequestParam(required = false, value = "searchbutton") String newSearch, @RequestParam(required = false, value = "lastSearch") String lastSearchTerm, @RequestParam(required = true, value = "lastPage") Integer lastPage, @ModelAttribute("searchResults") SystemUserSearchFormBean searchResultsFormBean) {
int startingPage = lastPage;
if (StringUtils.isNotBlank(next)) {
startingPage++;
searchResultsFormBean.setSearch(lastSearchTerm);
} else if (StringUtils.isNotBlank(previous)) {
startingPage--;
searchResultsFormBean.setSearch(lastSearchTerm);
} else if (StringUtils.isNotBlank(newSearch)) {
startingPage = 1;
}
if (startingPage <= 0) {
startingPage = 1;
}
UserSearchDto searchDto = new UserSearchDto(searchResultsFormBean.getSearch(), startingPage, 10);
SystemUserSearchResultsDto dto = this.personnelServiceFacade.searchUser(searchDto);
ModelAndView mav = new ModelAndView("redirect:/viewSystemUsers.ftl");
mav.addObject("searchResults", searchResultsFormBean);
mav.addObject("pagedResults", dto);
return mav;
}
use of org.mifos.dto.domain.UserSearchDto in project head by mifos.
the class PersonnelDaoHibernateIntegrationTest method shouldFindUsersByNameWhenSearching.
@Test
public void shouldFindUsersByNameWhenSearching() {
// setup
MifosUser user = personnelDao.findAuthenticatedUserByUsername("mifos");
// exercise test
String searchString = "mifos";
Integer page = 1;
Integer pageSize = 10;
UserSearchDto searchDto = new UserSearchDto(searchString, page, pageSize);
SystemUserSearchResultsDto searchResults = personnelDao.search(searchDto, user);
// verification
assertNotNull(searchResults);
// assertThat(searchResults.size(), is(1));
}
Aggregations