Search in sources :

Example 6 with CustSearchActionForm

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);
}
Also used : CustomerStatusDetailDto(org.mifos.dto.screen.CustomerStatusDetailDto) CustSearchActionForm(org.mifos.customers.struts.actionforms.CustSearchActionForm) HashMap(java.util.HashMap) UserContext(org.mifos.security.util.UserContext) ArrayList(java.util.ArrayList) ValueListElement(org.mifos.dto.domain.ValueListElement) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 7 with CustSearchActionForm

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;
}
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) CustomerPersistence(org.mifos.customers.persistence.CustomerPersistence) ActionForward(org.apache.struts.action.ActionForward) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 8 with CustSearchActionForm

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());
}
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)

Aggregations

CustSearchActionForm (org.mifos.customers.struts.actionforms.CustSearchActionForm)8 TransactionDemarcate (org.mifos.framework.util.helpers.TransactionDemarcate)8 UserContext (org.mifos.security.util.UserContext)7 ArrayList (java.util.ArrayList)4 HashMap (java.util.HashMap)4 ValueListElement (org.mifos.dto.domain.ValueListElement)4 CustomerStatusDetailDto (org.mifos.dto.screen.CustomerStatusDetailDto)4 CustomerException (org.mifos.customers.exceptions.CustomerException)2 CustomerPersistence (org.mifos.customers.persistence.CustomerPersistence)2 PersonnelBO (org.mifos.customers.personnel.business.PersonnelBO)2 QueryResult (org.mifos.framework.hibernate.helper.QueryResult)2 ActionErrors (org.apache.struts.action.ActionErrors)1 ActionForward (org.apache.struts.action.ActionForward)1 ActionMessage (org.apache.struts.action.ActionMessage)1 OfficePersistence (org.mifos.customers.office.persistence.OfficePersistence)1 CustomerDetailDto (org.mifos.dto.domain.CustomerDetailDto)1 DashboardDto (org.mifos.dto.domain.DashboardDto)1 UserDetailDto (org.mifos.dto.domain.UserDetailDto)1 SearchFiltersDto (org.mifos.dto.screen.SearchFiltersDto)1