use of org.mifos.framework.hibernate.helper.QueryResult in project head by mifos.
the class CustomerPersistenceIntegrationTest method testSearchWithEthnicityNotExists.
@Test
public void testSearchWithEthnicityNotExists() throws Exception {
createCustomers(CustomerStatus.GROUP_ACTIVE, CustomerStatus.CLIENT_ACTIVE);
StaticHibernateUtil.flushSession();
filters.setEthnicity("wrongEthnicity");
QueryResult queryResult = new CustomerPersistence().search("%", Short.valueOf("0"), Short.valueOf("1"), Short.valueOf("1"), filters);
Assert.assertNotNull(queryResult);
Assert.assertEquals(2, queryResult.getSize());
Assert.assertEquals(2, queryResult.get(0, 10).size());
}
use of org.mifos.framework.hibernate.helper.QueryResult in project head by mifos.
the class CustomerPersistenceIntegrationTest method testSearchClosedClients.
@Test
public void testSearchClosedClients() throws Exception {
createCustomers(CustomerStatus.GROUP_ACTIVE, CustomerStatus.CLIENT_CLOSED);
StaticHibernateUtil.flushSession();
Integer activeStatus = CustomerStatus.CLIENT_CLOSED.getValue().intValue();
filters.getCustomerStates().put(CustomerLevel.CLIENT.toString(), activeStatus);
QueryResult queryResult = new CustomerPersistence().search("Client", Short.valueOf("0"), Short.valueOf("1"), Short.valueOf("1"), filters);
Assert.assertNotNull(queryResult);
Assert.assertEquals(1, queryResult.getSize());
Assert.assertEquals(1, queryResult.get(0, 10).size());
}
use of org.mifos.framework.hibernate.helper.QueryResult in project head by mifos.
the class CustomerPersistenceIntegrationTest method testSearchWithoutCenters.
@Test
public void testSearchWithoutCenters() throws Exception {
createCustomers(CustomerStatus.GROUP_ACTIVE, CustomerStatus.CLIENT_ACTIVE);
StaticHibernateUtil.flushSession();
setCustomerSearch(CustomerLevel.CENTER, false);
QueryResult queryResult = new CustomerPersistence().search("C", Short.valueOf("0"), Short.valueOf("1"), Short.valueOf("1"), filters);
Assert.assertNotNull(queryResult);
Assert.assertEquals(1, queryResult.getSize());
Assert.assertEquals(1, queryResult.get(0, 10).size());
}
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;
}
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;
}
Aggregations