Search in sources :

Example 31 with QueryResult

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

the class LegacyPersonnelDao method getQueryResults.

private QueryResult getQueryResults(List<Param> paramList, String[] namedQuery) throws PersistenceException {
    QueryResult queryResult = QueryFactory.getQueryResult(PersonnelConstants.USER_LIST);
    QueryInputs queryInputs = new QueryInputs();
    queryInputs.setQueryStrings(namedQuery);
    queryInputs.setParamList(paramList);
    queryInputs.setPath("org.mifos.customers.personnel.util.helpers.UserSearchResultsDto");
    queryInputs.setAliasNames(getAliasNames());
    try {
        queryResult.setQueryInputs(queryInputs);
    } catch (HibernateSearchException e) {
        throw new PersistenceException(e);
    }
    return queryResult;
}
Also used : QueryResult(org.mifos.framework.hibernate.helper.QueryResult) HibernateSearchException(org.mifos.framework.exceptions.HibernateSearchException) QueryInputs(org.mifos.framework.hibernate.helper.QueryInputs) PersistenceException(org.mifos.framework.exceptions.PersistenceException)

Example 32 with QueryResult

use of org.mifos.framework.hibernate.helper.QueryResult 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)

Example 33 with QueryResult

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

the class CustSearchAction method mainSearch.

@TransactionDemarcate(joinToken = true)
public ActionForward mainSearch(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
    CustSearchActionForm actionForm = (CustSearchActionForm) form;
    Short officeId = getShortValue(actionForm.getOfficeId());
    String searchString = actionForm.getSearchString();
    UserContext userContext = (UserContext) SessionUtils.getAttribute(Constants.USERCONTEXT, request.getSession());
    super.search(mapping, form, request, response);
    if (searchString == null || searchString.equals("")) {
        ActionErrors errors = new ActionErrors();
        errors.add(CustomerSearchConstants.NAMEMANDATORYEXCEPTION, new ActionMessage(CustomerSearchConstants.NAMEMANDATORYEXCEPTION));
        request.setAttribute(Globals.ERROR_KEY, errors);
        return mapping.findForward(ActionForwards.mainSearch_success.toString());
    }
    if (officeId != null && officeId != 0) {
        addSeachValues(searchString, officeId.toString(), new OfficePersistence().getOffice(officeId).getOfficeName(), request);
    } else {
        addSeachValues(searchString, officeId.toString(), new OfficePersistence().getOffice(userContext.getBranchId()).getOfficeName(), request);
    }
    searchString = SearchUtils.normalizeSearchString(searchString);
    if (searchString.equals("")) {
        throw new CustomerException(CustomerSearchConstants.NAMEMANDATORYEXCEPTION);
    }
    if (actionForm.getFilters() == null) {
        actionForm.setFilters(new SearchFiltersDto());
    }
    QueryResult customerSearchResult = new CustomerPersistence().search(searchString, officeId, userContext.getId(), userContext.getBranchId(), actionForm.getFilters());
    SessionUtils.setQueryResultAttribute(Constants.SEARCH_RESULTS, customerSearchResult, request);
    return mapping.findForward(ActionForwards.mainSearch_success.toString());
}
Also used : CustomerException(org.mifos.customers.exceptions.CustomerException) QueryResult(org.mifos.framework.hibernate.helper.QueryResult) CustSearchActionForm(org.mifos.customers.struts.actionforms.CustSearchActionForm) UserContext(org.mifos.security.util.UserContext) ActionMessage(org.apache.struts.action.ActionMessage) SearchFiltersDto(org.mifos.dto.screen.SearchFiltersDto) CustomerPersistence(org.mifos.customers.persistence.CustomerPersistence) OfficePersistence(org.mifos.customers.office.persistence.OfficePersistence) ActionErrors(org.apache.struts.action.ActionErrors) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 34 with QueryResult

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

the class LegacyAccountDaoIntegrationTest method testSearchCustomerAccount.

@Test
public void testSearchCustomerAccount() throws Exception {
    QueryResult queryResult = null;
    queryResult = legacyAccountDao.search(center.getCustomerAccount().getGlobalAccountNum(), (short) 3);
    Assert.assertNull(queryResult);
}
Also used : QueryResult(org.mifos.framework.hibernate.helper.QueryResult) Test(org.junit.Test)

Example 35 with QueryResult

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

the class LegacyAccountDaoIntegrationTest method testSearchAccount.

@Test
public void testSearchAccount() throws Exception {
    savingsBO = createSavingsAccount();
    QueryResult queryResult = null;
    queryResult = legacyAccountDao.search(savingsBO.getGlobalAccountNum(), (short) 3);
    Assert.assertNotNull(queryResult);
    Assert.assertEquals(1, queryResult.getSize());
    Assert.assertEquals(1, queryResult.get(0, 10).size());
}
Also used : QueryResult(org.mifos.framework.hibernate.helper.QueryResult) Test(org.junit.Test)

Aggregations

QueryResult (org.mifos.framework.hibernate.helper.QueryResult)53 Test (org.junit.Test)30 HibernateSearchException (org.mifos.framework.exceptions.HibernateSearchException)16 PersistenceException (org.mifos.framework.exceptions.PersistenceException)14 ArrayList (java.util.ArrayList)13 PersonnelBO (org.mifos.customers.personnel.business.PersonnelBO)10 QueryInputs (org.mifos.framework.hibernate.helper.QueryInputs)10 Param (org.mifos.customers.util.helpers.Param)9 MifosRuntimeException (org.mifos.core.MifosRuntimeException)7 UserContext (org.mifos.security.util.UserContext)7 MifosUser (org.mifos.security.MifosUser)5 CustomerPersistence (org.mifos.customers.persistence.CustomerPersistence)4 List (java.util.List)3 Query (org.hibernate.Query)3 Session (org.hibernate.Session)3 AccountSearchResultsDto (org.mifos.accounts.util.helpers.AccountSearchResultsDto)3 CustomerSearchDto (org.mifos.customers.business.CustomerSearchDto)3 CustomerException (org.mifos.customers.exceptions.CustomerException)3 CustomerSearchResultDto (org.mifos.dto.domain.CustomerSearchResultDto)3 Date (java.sql.Date)2