use of org.mifos.framework.hibernate.helper.QueryResult in project head by mifos.
the class CustomerPersistence method getAllCustomerNotes.
public QueryResult getAllCustomerNotes(final Integer customerId) throws PersistenceException {
QueryResult notesResult = null;
try {
Session session = null;
notesResult = QueryFactory.getQueryResult("NotesSearch");
session = StaticHibernateUtil.getSessionTL();
Query query = session.getNamedQuery(NamedQueryConstants.GETALLCUSTOMERNOTES);
query.setInteger("CUSTOMER_ID", customerId);
notesResult.executeQuery(query);
} catch (HibernateProcessException hpe) {
throw new PersistenceException(hpe);
} catch (HibernateSearchException hse) {
throw new PersistenceException(hse);
}
return notesResult;
}
use of org.mifos.framework.hibernate.helper.QueryResult in project head by mifos.
the class SavingsServiceFacadeWebTier method retrieveCustomerThatQualifyForSavings.
@Override
public List<CustomerSearchResultDto> retrieveCustomerThatQualifyForSavings(CustomerSearchDto customerSearchDto) {
MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
UserContext userContext = toUserContext(user);
try {
List<CustomerSearchResultDto> pagedDetails = new ArrayList<CustomerSearchResultDto>();
QueryResult customerForSavings = new CustomerPersistence().searchCustForSavings(customerSearchDto.getSearchTerm(), userContext.getId());
int position = this.resultsetOffset(customerSearchDto.getPage(), 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);
}
}
use of org.mifos.framework.hibernate.helper.QueryResult in project head by mifos.
the class CustSearchAction method search.
/**
* FIXME: KEITHW - When replacing search functionality for customers with spring/ftl implementation,
* find cleaner way of implementing search that returns a non domain related class (data only object)
*/
@Override
@TransactionDemarcate(joinToken = true)
public ActionForward search(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
if (request.getParameter("perspective") != null) {
request.setAttribute("perspective", request.getParameter("perspective"));
}
ActionForward actionForward = super.search(mapping, form, request, response);
CustSearchActionForm actionForm = (CustSearchActionForm) form;
UserContext userContext = getUserContext(request);
String searchString = actionForm.getSearchString();
if (searchString == null) {
throw new CustomerException(CenterConstants.NO_SEARCH_STRING);
}
String officeName = this.centerServiceFacade.retrieveOfficeName(userContext.getBranchId());
addSeachValues(searchString, userContext.getBranchId().toString(), officeName, request);
searchString = SearchUtils.normalizeSearchString(searchString);
if (StringUtils.isBlank(searchString)) {
throw new CustomerException(CenterConstants.NO_SEARCH_STRING);
}
if (actionForm.getInput() != null && actionForm.getInput().equals("loan")) {
QueryResult groupClients = new CustomerPersistence().searchGroupClient(searchString, userContext.getId(), false);
SessionUtils.setQueryResultAttribute(Constants.SEARCH_RESULTS, groupClients, request);
} else if (actionForm.getInput() != null && actionForm.getInput().equals("savings")) {
QueryResult customerForSavings = new CustomerPersistence().searchCustForSavings(searchString, userContext.getId());
SessionUtils.setQueryResultAttribute(Constants.SEARCH_RESULTS, customerForSavings, request);
}
return actionForward;
}
use of org.mifos.framework.hibernate.helper.QueryResult 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.hibernate.helper.QueryResult in project head by mifos.
the class LegacyAccountDao method getAllAccountNotes.
public QueryResult getAllAccountNotes(Integer accountId) throws PersistenceException {
QueryResult notesResult = null;
try {
Session session = null;
notesResult = QueryFactory.getQueryResult("NotesSearch");
session = StaticHibernateUtil.getSessionTL();
Query query = session.getNamedQuery(NamedQueryConstants.GETALLACCOUNTNOTES);
query.setInteger("accountId", accountId);
notesResult.executeQuery(query);
} catch (Exception e) {
throw new PersistenceException(e);
}
return notesResult;
}
Aggregations