Search in sources :

Example 1 with AccountSearchResultsDto

use of org.mifos.accounts.util.helpers.AccountSearchResultsDto in project head by mifos.

the class SavingsServiceFacadeWebTier method retrieveCustomerThatQualifyForSavings.

@Override
public List<CustomerSearchResultDto> retrieveCustomerThatQualifyForSavings(CustomerSearchDto customerSearchDto) {
    MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
    UserContext userContext = toUserContext(user);
    try {
        List<CustomerSearchResultDto> pagedDetails = new ArrayList<CustomerSearchResultDto>();
        QueryResult customerForSavings = new CustomerPersistence().searchCustForSavings(customerSearchDto.getSearchTerm(), userContext.getId());
        int position = this.resultsetOffset(customerSearchDto.getPage(), customerSearchDto.getPageSize());
        List<AccountSearchResultsDto> pagedResults = customerForSavings.get(position, customerSearchDto.getPageSize());
        int i = 1;
        for (AccountSearchResultsDto customerBO : pagedResults) {
            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);
    }
}
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) PersistenceException(org.mifos.framework.exceptions.PersistenceException) CustomerSearchResultDto(org.mifos.dto.domain.CustomerSearchResultDto) CustomerPersistence(org.mifos.customers.persistence.CustomerPersistence) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Example 2 with AccountSearchResultsDto

use of org.mifos.accounts.util.helpers.AccountSearchResultsDto in project head by mifos.

the class LoanAccountServiceFacadeWebTier method retrieveCustomersThatQualifyForLoans.

@Override
public List<CustomerSearchResultDto> retrieveCustomersThatQualifyForLoans(CustomerSearchDto customerSearchDto, boolean isNewGLIMCreation) {
    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) {
            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 3 with AccountSearchResultsDto

use of org.mifos.accounts.util.helpers.AccountSearchResultsDto 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)

Aggregations

ArrayList (java.util.ArrayList)3 AccountSearchResultsDto (org.mifos.accounts.util.helpers.AccountSearchResultsDto)3 MifosRuntimeException (org.mifos.core.MifosRuntimeException)3 CustomerSearchResultDto (org.mifos.dto.domain.CustomerSearchResultDto)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