Search in sources :

Example 1 with UserSearchDto

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;
}
Also used : UserSearchDto(org.mifos.dto.domain.UserSearchDto) ModelAndView(org.springframework.web.servlet.ModelAndView) SystemUserSearchResultsDto(org.mifos.dto.screen.SystemUserSearchResultsDto) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 2 with UserSearchDto

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));
}
Also used : UserSearchDto(org.mifos.dto.domain.UserSearchDto) MifosUser(org.mifos.security.MifosUser) SystemUserSearchResultsDto(org.mifos.dto.screen.SystemUserSearchResultsDto) Test(org.junit.Test)

Aggregations

UserSearchDto (org.mifos.dto.domain.UserSearchDto)2 SystemUserSearchResultsDto (org.mifos.dto.screen.SystemUserSearchResultsDto)2 Test (org.junit.Test)1 MifosUser (org.mifos.security.MifosUser)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1 ModelAndView (org.springframework.web.servlet.ModelAndView)1