Search in sources :

Example 11 with HibernateSearchException

use of org.mifos.framework.exceptions.HibernateSearchException 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 12 with HibernateSearchException

use of org.mifos.framework.exceptions.HibernateSearchException in project head by mifos.

the class CustomerPersistence method searchCustForSavings.

public QueryResult searchCustForSavings(final String searchString, final Short userId) throws PersistenceException {
    String[] namedQuery = new String[2];
    List<Param> paramList = new ArrayList<Param>();
    QueryInputs queryInputs = new QueryInputs();
    QueryResult queryResult = QueryFactory.getQueryResult(CustomerSearchConstants.CUSTOMERSFORSAVINGSACCOUNT);
    PersonnelBO personnel = getLegacyPersonnelDao().getPersonnel(userId);
    if (personnel.getLevelEnum() == PersonnelLevel.LOAN_OFFICER) {
        namedQuery[0] = NamedQueryConstants.SEARCH_CUSTOMER_FOR_SAVINGS_COUNT;
        namedQuery[1] = NamedQueryConstants.SEARCH_CUSTOMER_FOR_SAVINGS;
        paramList.add(typeNameValue("Short", "PERSONNEL_ID", userId));
    } else {
        namedQuery[0] = NamedQueryConstants.SEARCH_CUSTOMER_FOR_SAVINGS_COUNT_NOLO;
        namedQuery[1] = NamedQueryConstants.SEARCH_CUSTOMER_FOR_SAVINGS_NOLO;
    }
    paramList.add(typeNameValue("String", "SEARCH_ID", personnel.getOffice().getSearchId() + "%"));
    paramList.add(typeNameValue("String", "SEARCH_STRING", "%" + searchString + "%"));
    String[] aliasNames = { "clientName", "clientId", "groupName", "centerName", "officeName", "globelNo" };
    queryInputs.setQueryStrings(namedQuery);
    queryInputs.setPath("org.mifos.accounts.util.helpers.AccountSearchResultsDto");
    queryInputs.setAliasNames(aliasNames);
    queryInputs.setParamList(paramList);
    try {
        queryResult.setQueryInputs(queryInputs);
    } catch (HibernateSearchException e) {
        throw new PersistenceException(e);
    }
    return queryResult;
}
Also used : QueryResult(org.mifos.framework.hibernate.helper.QueryResult) PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) HibernateSearchException(org.mifos.framework.exceptions.HibernateSearchException) ArrayList(java.util.ArrayList) Param(org.mifos.customers.util.helpers.Param) QueryInputs(org.mifos.framework.hibernate.helper.QueryInputs) PersistenceException(org.mifos.framework.exceptions.PersistenceException)

Example 13 with HibernateSearchException

use of org.mifos.framework.exceptions.HibernateSearchException in project head by mifos.

the class GroupPersistence method searchForAddingClientToGroup.

public QueryResult searchForAddingClientToGroup(String searchString, Short userId) throws PersistenceException {
    String[] namedQuery = new String[2];
    List<Param> paramList = new ArrayList<Param>();
    QueryInputs queryInputs = new QueryInputs();
    QueryResult queryResult = QueryFactory.getQueryResult(CustomerSearchConstants.GROUPLIST);
    PersonnelBO personnel = legacyPersonnelDao.getPersonnel(userId);
    String officeSearchId = personnel.getOffice().getSearchId();
    if (ClientRules.getCenterHierarchyExists()) {
        namedQuery[0] = NamedQueryConstants.GROUP_SEARCH_COUNT_WITH_CENTER_FOR_ADDING_GROUPMEMBER;
        namedQuery[1] = NamedQueryConstants.GROUP_SEARCHWITH_CENTER_FOR_ADDING_GROUPMEMBER;
        String[] aliasNames = { "officeName", "groupName", "centerName", "groupId" };
        queryInputs.setAliasNames(aliasNames);
    } else {
        namedQuery[0] = NamedQueryConstants.GROUP_SEARCH_COUNT_WITHOUT_CENTER_FOR_ADDING_GROUPMEMBER;
        namedQuery[1] = NamedQueryConstants.GROUP_SEARCH_WITHOUT_CENTER_FOR_ADDING_GROUPMEMBER;
        String[] aliasNames = { "officeName", "groupName", "groupId" };
        queryInputs.setAliasNames(aliasNames);
    }
    paramList.add(typeNameValue("String", "SEARCH_ID", officeSearchId + "%"));
    paramList.add(typeNameValue("String", "SEARCH_STRING", searchString + "%"));
    paramList.add(typeNameValue("Short", "LEVEL_ID", CustomerLevel.GROUP.getValue()));
    paramList.add(typeNameValue("Short", "USER_ID", userId));
    paramList.add(typeNameValue("Short", "USER_LEVEL_ID", personnel.getLevelEnum().getValue()));
    paramList.add(typeNameValue("Short", "LO_LEVEL_ID", PersonnelLevel.LOAN_OFFICER.getValue()));
    queryInputs.setQueryStrings(namedQuery);
    queryInputs.setPath("org.mifos.customers.group.util.helpers.GroupSearchResults");
    queryInputs.setParamList(paramList);
    try {
        queryResult.setQueryInputs(queryInputs);
    } catch (HibernateSearchException e) {
        throw new PersistenceException(e);
    }
    return queryResult;
}
Also used : QueryResult(org.mifos.framework.hibernate.helper.QueryResult) PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) HibernateSearchException(org.mifos.framework.exceptions.HibernateSearchException) ArrayList(java.util.ArrayList) Param(org.mifos.customers.util.helpers.Param) QueryInputs(org.mifos.framework.hibernate.helper.QueryInputs) PersistenceException(org.mifos.framework.exceptions.PersistenceException)

Example 14 with HibernateSearchException

use of org.mifos.framework.exceptions.HibernateSearchException in project head by mifos.

the class GroupPersistence method search.

public QueryResult search(String searchString, Short userId) throws PersistenceException {
    String[] namedQuery = new String[2];
    List<Param> paramList = new ArrayList<Param>();
    QueryInputs queryInputs = new QueryInputs();
    QueryResult queryResult = QueryFactory.getQueryResult(CustomerSearchConstants.GROUPLIST);
    PersonnelBO personnel = legacyPersonnelDao.getPersonnel(userId);
    String officeSearchId = personnel.getOffice().getSearchId();
    if (ClientRules.getCenterHierarchyExists()) {
        namedQuery[0] = NamedQueryConstants.GROUP_SEARCH_COUNT_WITH_CENTER;
        namedQuery[1] = NamedQueryConstants.GROUP_SEARCHWITH_CENTER;
        String[] aliasNames = { "officeName", "groupName", "centerName", "groupId" };
        queryInputs.setAliasNames(aliasNames);
    } else {
        namedQuery[0] = NamedQueryConstants.GROUP_SEARCH_COUNT_WITHOUT_CENTER;
        namedQuery[1] = NamedQueryConstants.GROUP_SEARCH_WITHOUT_CENTER;
        String[] aliasNames = { "officeName", "groupName", "groupId" };
        queryInputs.setAliasNames(aliasNames);
    }
    paramList.add(typeNameValue("String", "SEARCH_ID", officeSearchId + "%"));
    paramList.add(typeNameValue("String", "SEARCH_STRING", "%" + searchString + "%"));
    paramList.add(typeNameValue("Short", "LEVEL_ID", CustomerLevel.GROUP.getValue()));
    paramList.add(typeNameValue("Short", "USER_ID", userId));
    paramList.add(typeNameValue("Short", "USER_LEVEL_ID", personnel.getLevelEnum().getValue()));
    paramList.add(typeNameValue("Short", "LO_LEVEL_ID", PersonnelLevel.LOAN_OFFICER.getValue()));
    queryInputs.setQueryStrings(namedQuery);
    queryInputs.setPath("org.mifos.customers.group.util.helpers.GroupSearchResults");
    queryInputs.setParamList(paramList);
    try {
        queryResult.setQueryInputs(queryInputs);
    } catch (HibernateSearchException e) {
        throw new PersistenceException(e);
    }
    return queryResult;
}
Also used : QueryResult(org.mifos.framework.hibernate.helper.QueryResult) PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) HibernateSearchException(org.mifos.framework.exceptions.HibernateSearchException) ArrayList(java.util.ArrayList) Param(org.mifos.customers.util.helpers.Param) QueryInputs(org.mifos.framework.hibernate.helper.QueryInputs) PersistenceException(org.mifos.framework.exceptions.PersistenceException)

Example 15 with HibernateSearchException

use of org.mifos.framework.exceptions.HibernateSearchException in project head by mifos.

the class CenterPersistence method search.

/**
     * @deprecated - use {@link CustomerDao#search(String, PersonnelBO)}.
     */
@Deprecated
public QueryResult search(String searchString, Short userId) throws PersistenceException {
    String[] namedQuery = new String[2];
    List<Param> paramList = new ArrayList<Param>();
    QueryInputs queryInputs = new QueryInputs();
    QueryResult queryResult = QueryFactory.getQueryResult(PersonnelConstants.USER_LIST);
    PersonnelBO user = legacyPersonnelDao.getPersonnel(userId);
    String officeSearchId = user.getOffice().getSearchId();
    namedQuery[0] = NamedQueryConstants.CENTER_SEARCH_COUNT;
    namedQuery[1] = NamedQueryConstants.CENTER_SEARCH;
    paramList.add(typeNameValue("String", "SEARCH_ID", officeSearchId + "%"));
    paramList.add(typeNameValue("String", "CENTER_NAME", searchString + "%"));
    paramList.add(typeNameValue("Short", "LEVEL_ID", CustomerLevel.CENTER.getValue()));
    paramList.add(typeNameValue("Short", "STATUS_ID", CustomerStatus.CENTER_ACTIVE.getValue()));
    paramList.add(typeNameValue("Short", "USER_ID", userId));
    paramList.add(typeNameValue("Short", "USER_LEVEL_ID", user.getLevelEnum().getValue()));
    paramList.add(typeNameValue("Short", "LO_LEVEL_ID", PersonnelConstants.LOAN_OFFICER));
    String[] aliasNames = { "parentOfficeId", "parentOfficeName", "centerSystemId", "centerName" };
    queryInputs.setQueryStrings(namedQuery);
    queryInputs.setPath("org.mifos.customers.center.util.helpers.CenterSearchResultsDto");
    queryInputs.setAliasNames(aliasNames);
    queryInputs.setParamList(paramList);
    try {
        queryResult.setQueryInputs(queryInputs);
    } catch (HibernateSearchException e) {
        throw new PersistenceException(e);
    }
    return queryResult;
}
Also used : QueryResult(org.mifos.framework.hibernate.helper.QueryResult) PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) HibernateSearchException(org.mifos.framework.exceptions.HibernateSearchException) ArrayList(java.util.ArrayList) Param(org.mifos.customers.util.helpers.Param) QueryInputs(org.mifos.framework.hibernate.helper.QueryInputs) PersistenceException(org.mifos.framework.exceptions.PersistenceException)

Aggregations

HibernateSearchException (org.mifos.framework.exceptions.HibernateSearchException)25 ArrayList (java.util.ArrayList)16 QueryResult (org.mifos.framework.hibernate.helper.QueryResult)15 PersistenceException (org.mifos.framework.exceptions.PersistenceException)13 Query (org.hibernate.Query)8 Param (org.mifos.customers.util.helpers.Param)8 QueryInputs (org.mifos.framework.hibernate.helper.QueryInputs)8 Session (org.hibernate.Session)7 MifosRuntimeException (org.mifos.core.MifosRuntimeException)5 PersonnelBO (org.mifos.customers.personnel.business.PersonnelBO)5 MifosUser (org.mifos.security.MifosUser)4 UserContext (org.mifos.security.util.UserContext)4 List (java.util.List)3 AccountSearchResultsDto (org.mifos.accounts.util.helpers.AccountSearchResultsDto)3 CustomerSearchDto (org.mifos.customers.business.CustomerSearchDto)3 CustomerSearchResultDto (org.mifos.dto.domain.CustomerSearchResultDto)3 HttpServletRequest (javax.servlet.http.HttpServletRequest)2 HibernateException (org.hibernate.HibernateException)2 ConfigurationException (org.mifos.config.exceptions.ConfigurationException)2 CustomerPersistence (org.mifos.customers.persistence.CustomerPersistence)2