use of org.mifos.framework.exceptions.HibernateSearchException in project head by mifos.
the class QueryResultAccountIdSearch method getSize.
//---Watch out for closeSession block as the cne commendted out here is no longer in codebase
/*
* public List accountIdSearch(String searchString,Short officeId) throws
* SystemException { this.searchString = searchString;
*
* try{ Session session=null; session= QuerySession.getSession(); Query
* query=null; if( officeId.shortValue()==0) {
* query=session.getNamedQuery(NamedQueryConstants
* .ACCOUNT_ID_SEARCH_NOOFFICEID);
* query.setString("SEARCH_STRING",searchString); } else {
*
* query=session.getNamedQuery(NamedQueryConstants.ACCOUNT_ID_SEARCH);
* query.setString("SEARCH_STRING",searchString);
* query.setShort("OFFICEID",officeId); }
*
*
* list=query.list(); this.queryInputs.setTypes(query.getReturnTypes());
* dtoBuilder.setInputs(queryInputs); QuerySession.closeSession(session); }
* catch(HibernateProcessException hpe) { throw new SystemException(); }
* return list; }
*/
@Override
public int getSize() throws HibernateSearchException {
try {
Session session = StaticHibernateUtil.getSessionTL();
if (this.queryInputs == null) {
throw new HibernateSearchException(HibernateConstants.SEARCH_INPUTNULL);
}
Query query = prepareQuery(session, queryInputs.getQueryStrings()[0]);
Integer resultSetCount = ((Number) query.uniqueResult()).intValue();
this.queryInputs.setTypes(query.getReturnTypes());
dtoBuilder.setInputs(queryInputs);
if (resultSetCount != null && resultSetCount > 0) {
size = resultSetCount;
}
StaticHibernateUtil.closeSession();
} catch (Exception e) {
throw new HibernateSearchException(HibernateConstants.SEARCH_FAILED, e);
}
return size;
}
use of org.mifos.framework.exceptions.HibernateSearchException in project head by mifos.
the class QueryResultSearchDTOImpl method get.
/**
* Returns the requested set of search result objects based on the pagination at the front end.
*/
@Override
public List<Object> get(int position, int noOfObjects) throws HibernateSearchException {
Session session = null;
List<Object> returnList = new ArrayList<Object>();
List<?> list = new ArrayList<Object>();
try {
session = StaticHibernateUtil.getSessionTL();
Query query = prepareQuery(session, queryInputs.getQueryStrings()[1]);
query.setFirstResult(position);
query.setMaxResults(noOfObjects);
list = query.list();
logger.debug("\n\nInside get of QueryResultSearchDTOImpl.java . size of main query=" + list.size());
this.queryInputs.setTypes(query.getReturnTypes());
dtoBuilder.setInputs(queryInputs);
returnList = new ArrayList<Object>();
for (int i = 0; i < list.size(); i++) {
if (buildDTO) {
returnList.add(buildDTO((Object[]) list.get(i)));
} else {
if (i < noOfObjects) {
returnList.add(list.get(i));
}
}
}
StaticHibernateUtil.closeSession();
} catch (Exception e) {
throw new HibernateSearchException(HibernateConstants.SEARCH_FAILED, e);
}
return returnList;
}
use of org.mifos.framework.exceptions.HibernateSearchException 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;
}
use of org.mifos.framework.exceptions.HibernateSearchException in project head by mifos.
the class LoanAccountServiceFacadeWebTier method retrieveCustomersThatQualifyForLoans.
@Override
public List<CustomerSearchResultDto> retrieveCustomersThatQualifyForLoans(CustomerSearchDto customerSearchDto, boolean isNewGLIMCreation) {
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) {
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);
}
}
use of org.mifos.framework.exceptions.HibernateSearchException 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;
}
Aggregations