Search in sources :

Example 21 with OfficeDto

use of org.mifos.dto.domain.OfficeDto in project head by mifos.

the class OfficeDaoHibernateIntegrationTest method givenAnOfficeExistsShouldReturnItAsOfficeDto.

@Test
public void givenAnOfficeExistsShouldReturnItAsOfficeDto() {
    OfficeDto office = officeDao.findOfficeDtoById(headOffice.getOfficeId());
    assertThat(office.getName(), is("Mifos HO"));
}
Also used : OfficeDto(org.mifos.dto.domain.OfficeDto) Test(org.junit.Test)

Example 22 with OfficeDto

use of org.mifos.dto.domain.OfficeDto in project head by mifos.

the class ViewOfficeDetailsController method showDetails.

@RequestMapping(method = RequestMethod.GET)
public ModelAndView showDetails(HttpServletRequest request) {
    ModelAndView modelAndView = new ModelAndView("viewOfficeDetails");
    OfficeFormBean officeFormBean = new OfficeFormBean();
    OfficeDto officeDto = officeServiceFacade.retrieveOfficeById(Short.parseShort(request.getParameter("id")));
    officeFormBean.setCustomFields(officeDto.getCustomFields());
    officeFormBean.setName(officeDto.getName());
    officeFormBean.setStatusId(officeDto.getStatusId().toString());
    officeFormBean.setOfficeShortName(officeDto.getOfficeShortName());
    officeFormBean.setOfficeLevelName(officeDto.getOfficeLevelName());
    officeFormBean.setId(officeDto.getId());
    if (officeDto.getAddress() != null) {
        officeFormBean.setCity(officeDto.getAddress().getCity());
        officeFormBean.setCountry(officeDto.getAddress().getCountry());
        officeFormBean.setLine1(officeDto.getAddress().getLine1());
        officeFormBean.setLine2(officeDto.getAddress().getLine2());
        officeFormBean.setLine3(officeDto.getAddress().getLine3());
        officeFormBean.setState(officeDto.getAddress().getState());
        officeFormBean.setZip(officeDto.getAddress().getZip());
        officeFormBean.setPhoneNumber(officeDto.getAddress().getPhoneNumber());
    }
    if (!(officeDto.getOfficeLevelName().equalsIgnoreCase("Head Office"))) {
        officeFormBean.setParentId(officeDto.getParentId().toString());
        officeFormBean.setParentOfficeName(officeDto.getParentOfficeName());
    }
    officeFormBean.setGlobalNum(officeDto.getGlobalNum());
    officeFormBean.setId(officeDto.getId());
    officeFormBean.setLevelId(officeDto.getLevelId().toString());
    if (!officeDto.getLookupNameKey().isEmpty()) {
        officeFormBean.setLookupNameKey(officeDto.getLookupNameKey());
    }
    officeFormBean.setName(officeDto.getName());
    officeFormBean.setOfficeLevelName(officeDto.getOfficeLevelName());
    officeFormBean.setOfficeShortName(officeDto.getOfficeShortName());
    officeFormBean.setOfficeStatusName(officeDto.getOfficeStatusName());
    if (!(officeDto.getOfficeLevelName().equalsIgnoreCase("Head Office"))) {
        officeFormBean.setParentId(officeDto.getParentId().toString());
        officeFormBean.setParentOfficeName(officeDto.getParentOfficeName());
    }
    officeFormBean.setSearchId(officeDto.getSearchId());
    officeFormBean.setStatusId(officeDto.getStatusId().toString());
    officeFormBean.setVersionNum(officeDto.getVersionNum());
    modelAndView.addObject("officeFormBean", officeFormBean);
    modelAndView.addObject("officeAddress", officeDto.getAddress());
    return modelAndView;
}
Also used : OfficeDto(org.mifos.dto.domain.OfficeDto) ModelAndView(org.springframework.web.servlet.ModelAndView) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 23 with OfficeDto

use of org.mifos.dto.domain.OfficeDto in project head by mifos.

the class ClientsAndAccountsPageController method showClientsAndAccountsMainSearch.

@SuppressWarnings("PMD.AvoidUsingShortType")
public ModelAndView showClientsAndAccountsMainSearch(HttpServletRequest request, CustomerSearchFormBean customerSearchFormBean, ModelAndView modelAndView) {
    sitePreferenceHelper.resolveSiteType(modelAndView, "clientsAndAccounts", request);
    MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
    Short userId = (short) user.getUserId();
    UserDetailDto userDetails = this.centerServiceFacade.retrieveUsersDetails(userId);
    List<OfficeDto> officeDtoList = officeServiceFacade.retrieveActiveBranchesUnderUser(userId);
    Map<String, String> officesMap = new HashMap<String, String>();
    for (OfficeDto officeDto : officeDtoList) {
        officesMap.put(officeDto.getId().toString(), officeDto.getName());
    }
    customerSearchFormBean.setOffices(officesMap);
    customerSearchFormBean.setOfficeName(userDetails.getOfficeName());
    return modelAndView;
}
Also used : OfficeDto(org.mifos.dto.domain.OfficeDto) HashMap(java.util.HashMap) UserDetailDto(org.mifos.dto.domain.UserDetailDto) MifosUser(org.mifos.security.MifosUser)

Example 24 with OfficeDto

use of org.mifos.dto.domain.OfficeDto in project head by mifos.

the class SearchResultController method legacyShowSearchResults.

@RequestMapping(value = "/legacySearchResult", method = { RequestMethod.POST, RequestMethod.GET })
public ModelAndView legacyShowSearchResults(HttpServletRequest request, @ModelAttribute("customerSearch") @Valid CustomerSearchFormBean customerSearchFormBean, BindingResult result) throws PersistenceException {
    ModelAndView modelAndView = new ModelAndView();
    sitePreferenceHelper.resolveSiteType(modelAndView, "legacySearchResult", request);
    MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
    CustomerHierarchyDto customerHierarchyDto = null;
    List<OfficeDto> officeDtoList = officeServiceFacade.retrieveActiveBranchesUnderUser((short) user.getUserId());
    Map<String, String> officesMap = new HashMap<String, String>();
    for (OfficeDto officeDto : officeDtoList) {
        officesMap.put(officeDto.getId().toString(), officeDto.getName());
    }
    customerSearchFormBean.setOffices(officesMap);
    boolean isCenterHierarchyExists = configurationServiceFacade.getBooleanConfig("ClientRules.CenterHierarchyExists");
    modelAndView.addObject("isCenterHierarchyExists", isCenterHierarchyExists);
    HashMap<String, ArrayList<CustomerStatusDetailDto>> customerStates = new HashMap<String, ArrayList<CustomerStatusDetailDto>>();
    customerStates.putAll(customerSearchServiceFacade.getAvailibleCustomerStates());
    modelAndView.addObject("availibleCustomerStates", customerStates);
    List<ValueListElement> availibleClientGenders = clientServiceFacade.getClientGenders();
    modelAndView.addObject("availibleClientGenders", availibleClientGenders);
    if (result.hasErrors()) {
        return modelAndView;
    }
    int currentPage = 0;
    if (request.getParameter("currentPage") != null) {
        currentPage = new Integer(request.getParameter("currentPage")).intValue();
    }
    modelAndView.addObject("customerSearch", customerSearchFormBean);
    if (customerSearchFormBean.getFilters() == null) {
        customerSearchFormBean.setFilters(new SearchFiltersDto());
    }
    customerHierarchyDto = customerSearchServiceFacade.search(customerSearchFormBean.getSearchString(), customerSearchFormBean.getOfficeId(), currentPage * PAGE_SIZE, PAGE_SIZE, customerSearchFormBean.getFilters());
    boolean prevPageAvailable = false;
    if (currentPage > 0) {
        prevPageAvailable = true;
    }
    boolean nextPageAvailable = false;
    if (customerHierarchyDto.getSize() / PAGE_SIZE > 0 && customerHierarchyDto.getSize() / PAGE_SIZE >= currentPage + 1) {
        nextPageAvailable = true;
    }
    modelAndView.addObject("isPrevPageAvailable", prevPageAvailable);
    modelAndView.addObject("isNextPageAvailable", nextPageAvailable);
    modelAndView.addObject("currentPage", currentPage);
    modelAndView.addObject("pageSize", PAGE_SIZE);
    modelAndView.addObject("customerHierarchy", customerHierarchyDto);
    return modelAndView;
}
Also used : OfficeDto(org.mifos.dto.domain.OfficeDto) CustomerStatusDetailDto(org.mifos.dto.screen.CustomerStatusDetailDto) HashMap(java.util.HashMap) ModelAndView(org.springframework.web.servlet.ModelAndView) ArrayList(java.util.ArrayList) MifosUser(org.mifos.security.MifosUser) SearchFiltersDto(org.mifos.dto.screen.SearchFiltersDto) CustomerHierarchyDto(org.mifos.dto.screen.CustomerHierarchyDto) ValueListElement(org.mifos.dto.domain.ValueListElement) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 25 with OfficeDto

use of org.mifos.dto.domain.OfficeDto in project head by mifos.

the class SearchResultController method showSearchResults.

@RequestMapping(value = "/searchResult", method = { RequestMethod.POST, RequestMethod.GET })
public ModelAndView showSearchResults(HttpServletRequest request, @ModelAttribute("customerSearch") @Valid CustomerSearchFormBean customerSearchFormBean, BindingResult result) throws PersistenceException {
    ModelAndView modelAndView = new ModelAndView();
    sitePreferenceHelper.resolveSiteType(modelAndView, "searchResult", request);
    // mobile search result view doesn't use ajax search
    if (sitePreferenceHelper.isMobile(request)) {
        return legacyShowSearchResults(request, customerSearchFormBean, result);
    }
    MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
    List<OfficeDto> officeDtoList = officeServiceFacade.retrieveActiveBranchesUnderUser((short) user.getUserId());
    Map<String, String> officesMap = new HashMap<String, String>();
    for (OfficeDto officeDto : officeDtoList) {
        officesMap.put(officeDto.getId().toString(), officeDto.getName());
    }
    customerSearchFormBean.setOffices(officesMap);
    modelAndView.addObject("customerSearch", customerSearchFormBean);
    boolean isCenterHierarchyExists = configurationServiceFacade.getBooleanConfig("ClientRules.CenterHierarchyExists");
    modelAndView.addObject("isCenterHierarchyExists", isCenterHierarchyExists);
    HashMap<String, ArrayList<CustomerStatusDetailDto>> customerStates = new HashMap<String, ArrayList<CustomerStatusDetailDto>>();
    customerStates.putAll(customerSearchServiceFacade.getAvailibleCustomerStates());
    modelAndView.addObject("availibleCustomerStates", customerStates);
    List<ValueListElement> availibleClientGenders = clientServiceFacade.getClientGenders();
    modelAndView.addObject("availibleClientGenders", availibleClientGenders);
    if (result.hasErrors()) {
        return modelAndView;
    }
    CustomerHierarchyDto customerHierarchyDto = new CustomerHierarchyDto();
    if (customerSearchFormBean.getFilters() == null) {
        customerSearchFormBean.setFilters(new SearchFiltersDto());
    }
    if (customerSearchFormBean.getSearchString() != null && !customerSearchFormBean.getSearchString().isEmpty()) {
        customerHierarchyDto = customerSearchServiceFacade.search(customerSearchFormBean.getSearchString(), customerSearchFormBean.getOfficeId(), 0, 10, customerSearchFormBean.getFilters());
    }
    modelAndView.addObject("customerHierarchy", customerHierarchyDto);
    modelAndView.addObject("startIndex", 0);
    return modelAndView;
}
Also used : OfficeDto(org.mifos.dto.domain.OfficeDto) CustomerStatusDetailDto(org.mifos.dto.screen.CustomerStatusDetailDto) HashMap(java.util.HashMap) ModelAndView(org.springframework.web.servlet.ModelAndView) ArrayList(java.util.ArrayList) MifosUser(org.mifos.security.MifosUser) SearchFiltersDto(org.mifos.dto.screen.SearchFiltersDto) CustomerHierarchyDto(org.mifos.dto.screen.CustomerHierarchyDto) ValueListElement(org.mifos.dto.domain.ValueListElement) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

OfficeDto (org.mifos.dto.domain.OfficeDto)27 ArrayList (java.util.ArrayList)14 OffActionForm (org.mifos.customers.office.struts.actionforms.OffActionForm)6 TransactionDemarcate (org.mifos.framework.util.helpers.TransactionDemarcate)6 MifosUser (org.mifos.security.MifosUser)6 OfficeBO (org.mifos.customers.office.business.OfficeBO)5 OfficeDetailsDto (org.mifos.dto.domain.OfficeDetailsDto)5 HashMap (java.util.HashMap)3 CustomFieldDto (org.mifos.dto.domain.CustomFieldDto)3 OfficeHierarchyDto (org.mifos.dto.domain.OfficeHierarchyDto)3 ValueListElement (org.mifos.dto.domain.ValueListElement)3 ListElement (org.mifos.dto.screen.ListElement)3 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)3 ModelAndView (org.springframework.web.servlet.ModelAndView)3 LinkedHashMap (java.util.LinkedHashMap)2 Test (org.junit.Test)2 MessageLookup (org.mifos.application.master.MessageLookup)2 CustomFieldDefinitionEntity (org.mifos.application.master.business.CustomFieldDefinitionEntity)2 MifosRuntimeException (org.mifos.core.MifosRuntimeException)2 OfficePersistence (org.mifos.customers.office.persistence.OfficePersistence)2