Search in sources :

Example 1 with QueryResultAccountIdSearch

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

the class LegacyAccountDao method search.

public QueryResult search(String queryString, Short officeId) throws PersistenceException {
    AccountBO accountBO = findBySystemId(queryString);
    if (accountBO == null) {
        return null;
    }
    if (accountBO.getType() == AccountTypes.CUSTOMER_ACCOUNT || accountBO.getType() == AccountTypes.INDIVIDUAL_LOAN_ACCOUNT) {
        return null;
    }
    QueryResult queryResult = QueryFactory.getQueryResult(CustomerSearchConstants.LOANACCOUNTIDSEARCH);
    ((QueryResultAccountIdSearch) queryResult).setSearchString(queryString);
    String[] namedQuery = new String[2];
    List<Param> paramList = new ArrayList<Param>();
    QueryInputs queryInputs = new QueryInputs();
    String[] aliasNames = { "customerId", "centerName", "centerGlobalCustNum", "customerType", "branchGlobalNum", "branchName", "loanOfficerName", "loanOffcerGlobalNum", "customerStatus", "groupName", "groupGlobalCustNum", "clientName", "clientGlobalCustNum", "loanGlobalAccountNumber" };
    queryInputs.setPath("org.mifos.customers.business.CustomerSearchDto");
    queryInputs.setAliasNames(aliasNames);
    if (officeId != null) {
        if (officeId.shortValue() == 0) {
            namedQuery[0] = NamedQueryConstants.ACCOUNT_ID_SEARCH_NOOFFICEID_COUNT;
            namedQuery[1] = NamedQueryConstants.ACCOUNT_ID_SEARCH_NOOFFICEID;
        } else {
            namedQuery[0] = NamedQueryConstants.ACCOUNT_ID_SEARCH_COUNT;
            namedQuery[1] = NamedQueryConstants.ACCOUNT_ID_SEARCH;
            paramList.add(typeNameValue("Short", "OFFICEID", officeId));
        }
        paramList.add(typeNameValue("String", "SEARCH_STRING", queryString));
    }
    queryInputs.setQueryStrings(namedQuery);
    queryInputs.setParamList(paramList);
    try {
        queryResult.setQueryInputs(queryInputs);
    } catch (HibernateSearchException e) {
        throw new PersistenceException(e);
    }
    return queryResult;
}
Also used : AccountBO(org.mifos.accounts.business.AccountBO) QueryResult(org.mifos.framework.hibernate.helper.QueryResult) QueryResultAccountIdSearch(org.mifos.framework.hibernate.helper.QueryResultAccountIdSearch) 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

ArrayList (java.util.ArrayList)1 AccountBO (org.mifos.accounts.business.AccountBO)1 Param (org.mifos.customers.util.helpers.Param)1 HibernateSearchException (org.mifos.framework.exceptions.HibernateSearchException)1 PersistenceException (org.mifos.framework.exceptions.PersistenceException)1 QueryInputs (org.mifos.framework.hibernate.helper.QueryInputs)1 QueryResult (org.mifos.framework.hibernate.helper.QueryResult)1 QueryResultAccountIdSearch (org.mifos.framework.hibernate.helper.QueryResultAccountIdSearch)1