Search in sources :

Example 11 with QueryInputs

use of org.mifos.framework.hibernate.helper.QueryInputs in project head by mifos.

the class CustomerPersistence method searchGroupClient.

public QueryResult searchGroupClient(final String searchString, final Short userId, boolean isNewGLIMCreation) throws ConfigurationException, PersistenceException {
    String[] namedQuery = new String[2];
    List<Param> paramList = new ArrayList<Param>();
    QueryInputs queryInputs = new QueryInputs();
    QueryResult queryResult = QueryFactory.getQueryResult(CustomerSearchConstants.ACCOUNTSEARCHRESULTS);
    PersonnelBO personnel = getLegacyPersonnelDao().getPersonnel(userId);
    if (personnel.getLevelEnum() == PersonnelLevel.LOAN_OFFICER) {
        namedQuery[0] = NamedQueryConstants.SEARCH_GROUP_CLIENT_COUNT_LO;
        namedQuery[1] = NamedQueryConstants.SEARCH_GROUP_CLIENT_LO;
        paramList.add(typeNameValue("Short", "PERSONNEL_ID", userId));
    } else if (isNewGLIMCreation) {
        namedQuery[0] = NamedQueryConstants.SEARCH_GROUP_FOR_GROUP_LOAN_COUNT;
        namedQuery[1] = NamedQueryConstants.SEARCH_GROUP_FOR_GROUP_LOAN;
    } else {
        namedQuery[0] = NamedQueryConstants.SEARCH_GROUP_CLIENT_COUNT;
        namedQuery[1] = NamedQueryConstants.SEARCH_GROUP_CLIENT;
    }
    paramList.add(typeNameValue("String", "SEARCH_ID", personnel.getOffice().getSearchId() + "%"));
    paramList.add(typeNameValue("String", "SEARCH_STRING", "%" + searchString + "%"));
    paramList.add(typeNameValue("Boolean", "GROUP_LOAN_ALLOWED", ClientRules.getGroupCanApplyLoans() ? Boolean.TRUE : Boolean.FALSE));
    String[] aliasNames = { "clientName", "clientId", "groupName", "centerName", "officeName", "globelNo", "levelId" };
    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)

Aggregations

QueryInputs (org.mifos.framework.hibernate.helper.QueryInputs)11 QueryResult (org.mifos.framework.hibernate.helper.QueryResult)10 ArrayList (java.util.ArrayList)9 Param (org.mifos.customers.util.helpers.Param)9 HibernateSearchException (org.mifos.framework.exceptions.HibernateSearchException)8 PersistenceException (org.mifos.framework.exceptions.PersistenceException)7 PersonnelBO (org.mifos.customers.personnel.business.PersonnelBO)6 AccountBO (org.mifos.accounts.business.AccountBO)1 MifosRuntimeException (org.mifos.core.MifosRuntimeException)1 OfficePersistence (org.mifos.customers.office.persistence.OfficePersistence)1 QueryResultAccountIdSearch (org.mifos.framework.hibernate.helper.QueryResultAccountIdSearch)1