use of org.mifos.customers.struts.actionforms.CustSearchActionForm in project head by mifos.
the class CustSearchAction method loadMainSearch.
@TransactionDemarcate(saveToken = true)
public ActionForward loadMainSearch(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
String forward = null;
CustSearchActionForm actionForm = (CustSearchActionForm) form;
actionForm.setSearchString(null);
actionForm.setOfficeId("0");
cleanUpSearch(request);
UserContext userContext = getUserContext(request);
SessionUtils.setAttribute("isCenterHierarchyExists", ClientRules.getCenterHierarchyExists(), request);
forward = loadMasterData(userContext.getId(), request, actionForm);
HashMap<String, ArrayList<CustomerStatusDetailDto>> customerStates = new HashMap<String, ArrayList<CustomerStatusDetailDto>>();
customerStates.putAll(customerSearchServiceFacade.getAvailibleCustomerStates());
SessionUtils.setMapAttribute("availibleCustomerStates", customerStates, request);
List<ValueListElement> availibleClientGenders = clientServiceFacade.getClientGenders();
SessionUtils.setCollectionAttribute("availibleClientGenders", availibleClientGenders, request);
return mapping.findForward(forward);
}
use of org.mifos.customers.struts.actionforms.CustSearchActionForm 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.customers.struts.actionforms.CustSearchActionForm 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());
}
Aggregations