Search in sources :

Example 6 with CustomerSearchResultDto

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

the class LoanAccountServiceFacadeWebTier method retrievePossibleGuarantors.

public List<CustomerSearchResultDto> retrievePossibleGuarantors(CustomerSearchDto customerSearchDto, boolean isNewGLIMCreation, Integer clientId, Integer loanId) {
    MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
    UserContext userContext = toUserContext(user);
    try {
        List<CustomerSearchResultDto> pagedDetails = new ArrayList<CustomerSearchResultDto>();
        QueryResult customerForSavings = customerPersistence.searchGroupClient(customerSearchDto.getSearchTerm(), userContext.getId(), isNewGLIMCreation);
        int position = (customerSearchDto.getPage() - 1) * customerSearchDto.getPageSize();
        List<AccountSearchResultsDto> pagedResults = customerForSavings.get(position, customerSearchDto.getPageSize());
        int i = 1;
        for (AccountSearchResultsDto customerBO : pagedResults) {
            if (CustomerLevel.getLevel(customerBO.getLevelId()) == CustomerLevel.CLIENT && customerBO.getClientId() != clientId && isApplicableForGuaranty(customerBO, loanId)) {
                CustomerSearchResultDto customer = new CustomerSearchResultDto();
                customer.setCustomerId(customerBO.getClientId());
                customer.setBranchName(customerBO.getOfficeName());
                customer.setGlobalId(customerBO.getGlobelNo());
                customer.setSearchIndex(i);
                customer.setCenterName(StringUtils.defaultIfEmpty(customerBO.getCenterName(), "--"));
                customer.setGroupName(StringUtils.defaultIfEmpty(customerBO.getGroupName(), "--"));
                customer.setClientName(customerBO.getClientName());
                pagedDetails.add(customer);
            }
            i++;
        }
        return pagedDetails;
    } catch (PersistenceException e) {
        throw new MifosRuntimeException(e);
    } catch (HibernateSearchException e) {
        throw new MifosRuntimeException(e);
    } catch (ConfigurationException e) {
        throw new MifosRuntimeException(e);
    }
}
Also used : UserContext(org.mifos.security.util.UserContext) HibernateSearchException(org.mifos.framework.exceptions.HibernateSearchException) ArrayList(java.util.ArrayList) MifosUser(org.mifos.security.MifosUser) QueryResult(org.mifos.framework.hibernate.helper.QueryResult) AccountSearchResultsDto(org.mifos.accounts.util.helpers.AccountSearchResultsDto) ConfigurationException(org.mifos.config.exceptions.ConfigurationException) PersistenceException(org.mifos.framework.exceptions.PersistenceException) CustomerSearchResultDto(org.mifos.dto.domain.CustomerSearchResultDto) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Example 7 with CustomerSearchResultDto

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

the class FundTransferController method searchCustomers.

// All methods are called by Spring Webflow
public CustomerSearchResultsDto searchCustomers(CustomerSearchFormBean formBean) {
    Integer searchCap = 1000;
    CustomerSearchDto customerSearchDto = new CustomerSearchDto(formBean.getSearchString(), Integer.valueOf(1), searchCap);
    List<CustomerSearchResultDto> pagedDetails = this.savingsServiceFacade.retrieveCustomersThatQualifyForTransfer(customerSearchDto);
    SearchDetailsDto searchDetails = new SearchDetailsDto(pagedDetails.size(), 1, 1, searchCap);
    return new CustomerSearchResultsDto(searchDetails, pagedDetails);
}
Also used : SearchDetailsDto(org.mifos.dto.screen.SearchDetailsDto) CustomerSearchDto(org.mifos.dto.domain.CustomerSearchDto) CustomerSearchResultDto(org.mifos.dto.domain.CustomerSearchResultDto) CustomerSearchResultsDto(org.mifos.dto.screen.CustomerSearchResultsDto)

Aggregations

CustomerSearchResultDto (org.mifos.dto.domain.CustomerSearchResultDto)7 CustomerSearchDto (org.mifos.dto.domain.CustomerSearchDto)4 CustomerSearchResultsDto (org.mifos.dto.screen.CustomerSearchResultsDto)4 SearchDetailsDto (org.mifos.dto.screen.SearchDetailsDto)4 ArrayList (java.util.ArrayList)3 AccountSearchResultsDto (org.mifos.accounts.util.helpers.AccountSearchResultsDto)3 MifosRuntimeException (org.mifos.core.MifosRuntimeException)3 HibernateSearchException (org.mifos.framework.exceptions.HibernateSearchException)3 PersistenceException (org.mifos.framework.exceptions.PersistenceException)3 QueryResult (org.mifos.framework.hibernate.helper.QueryResult)3 MifosUser (org.mifos.security.MifosUser)3 UserContext (org.mifos.security.util.UserContext)3 ConfigurationException (org.mifos.config.exceptions.ConfigurationException)2 CustomerPersistence (org.mifos.customers.persistence.CustomerPersistence)1