Search in sources :

Example 6 with GroupCustActionForm

use of org.mifos.customers.group.struts.actionforms.GroupCustActionForm in project head by mifos.

the class GroupCustAction method preview.

@TransactionDemarcate(joinToken = true)
public ActionForward preview(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    GroupCustActionForm actionForm = (GroupCustActionForm) form;
    boolean isPendingApprovalDefined = ProcessFlowRules.isGroupPendingApprovalStateEnabled();
    SessionUtils.setAttribute(CustomerConstants.PENDING_APPROVAL_DEFINED, isPendingApprovalDefined, request);
    return createGroupQuestionnaire.fetchAppliedQuestions(mapping, actionForm, request, ActionForwards.preview_success);
}
Also used : GroupCustActionForm(org.mifos.customers.group.struts.actionforms.GroupCustActionForm) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 7 with GroupCustActionForm

use of org.mifos.customers.group.struts.actionforms.GroupCustActionForm in project head by mifos.

the class GroupCustAction method manage.

@TransactionDemarcate(joinToken = true)
public ActionForward manage(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    GroupCustActionForm actionForm = (GroupCustActionForm) form;
    actionForm.cleanForm();
    // FIXME - store group identifier (id, globalCustNum) instead of entire business object
    GroupBO group = (GroupBO) SessionUtils.getAttribute(Constants.BUSINESS_KEY, request);
    group = this.customerDao.findGroupBySystemId(group.getGlobalCustNum());
    logger.debug("Entering GroupCustAction manage method and customer id: " + group.getGlobalCustNum());
    CenterDto groupDto = this.groupServiceFacade.retrieveGroupDetailsForUpdate(group.getGlobalCustNum());
    SessionUtils.setAttribute(Constants.BUSINESS_KEY, group, request);
    SessionUtils.setCollectionAttribute(CustomerConstants.LOAN_OFFICER_LIST, groupDto.getActiveLoanOfficersForBranch(), request);
    SessionUtils.setAttribute(GroupConstants.CENTER_HIERARCHY_EXIST, groupDto.isCenterHierarchyExists(), request);
    SessionUtils.setCollectionAttribute(CustomerConstants.CUSTOM_FIELDS_LIST, new ArrayList<CustomFieldDto>(), request);
    SessionUtils.setCollectionAttribute(CustomerConstants.POSITIONS, groupDto.getCustomerPositionViews(), request);
    SessionUtils.setCollectionAttribute(CustomerConstants.CLIENT_LIST, groupDto.getClientList(), request);
    actionForm.setLoanOfficerId(String.valueOf(group.getLoanOfficerId()));
    actionForm.setDisplayName(group.getDisplayName());
    actionForm.setCustomerId(group.getCustomerId().toString());
    actionForm.setGlobalCustNum(group.getGlobalCustNum());
    actionForm.setExternalId(group.getExternalId());
    actionForm.setAddress(group.getAddress());
    actionForm.setCustomerPositions(groupDto.getCustomerPositionViews());
    actionForm.setCustomFields(new ArrayList<CustomFieldDto>());
    if (group.isTrained()) {
        actionForm.setTrained(GroupConstants.TRAINED);
    } else {
        actionForm.setTrained(GroupConstants.NOT_TRAINED);
    }
    if (group.getTrainedDate() != null) {
        actionForm.setTrainedDate(DateUtils.getUserLocaleDate(getUserContext(request).getPreferredLocale(), group.getTrainedDate().toString()));
    }
    logger.debug("Exiting GroupCustAction manage method ");
    return mapping.findForward(ActionForwards.manage_success.toString());
}
Also used : CustomFieldDto(org.mifos.dto.domain.CustomFieldDto) GroupBO(org.mifos.customers.group.business.GroupBO) CenterDto(org.mifos.dto.domain.CenterDto) GroupCustActionForm(org.mifos.customers.group.struts.actionforms.GroupCustActionForm) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 8 with GroupCustActionForm

use of org.mifos.customers.group.struts.actionforms.GroupCustActionForm in project head by mifos.

the class GroupCustAction method get.

@TransactionDemarcate(saveToken = true)
public ActionForward get(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    logger.debug("In GroupCustAction get method ");
    // John W - UserContext object passed because some status' need to be looked up for internationalisation based
    // on UserContext info
    String groupSystemId = ((GroupCustActionForm) form).getGlobalCustNum();
    GroupInformationDto groupInformationDto;
    try {
        groupInformationDto = this.groupServiceFacade.getGroupInformationDto(groupSystemId);
    } catch (MifosRuntimeException e) {
        if (e.getCause() instanceof ApplicationException) {
            throw (ApplicationException) e.getCause();
        }
        throw e;
    }
    SessionUtils.removeThenSetAttribute("groupInformationDto", groupInformationDto, request);
    // John W - - not sure whether to leave these rules as is or do something else like bake the logic into the main
    // dto and out of the jsp
    SessionUtils.setAttribute(GroupConstants.IS_GROUP_LOAN_ALLOWED, ClientRules.getGroupCanApplyLoans(), request);
    SessionUtils.setAttribute(GroupConstants.CENTER_HIERARCHY_EXIST, ClientRules.getCenterHierarchyExists(), request);
    // John W - 'BusinessKey' attribute linked to GroupBo is still used by other actions (e.g. meeting related)
    // further on and also breadcrumb.
    GroupBO groupBO = (GroupBO) this.customerDao.findCustomerById(groupInformationDto.getGroupDisplay().getCustomerId());
    SessionUtils.removeThenSetAttribute(Constants.BUSINESS_KEY, groupBO, request);
    setCurrentPageUrl(request, groupBO);
    setQuestionGroupInstances(request, groupBO);
    logger.debug("Exiting GroupCustAction get method ");
    return mapping.findForward(ActionForwards.get_success.toString());
}
Also used : ApplicationException(org.mifos.framework.exceptions.ApplicationException) GroupBO(org.mifos.customers.group.business.GroupBO) GroupCustActionForm(org.mifos.customers.group.struts.actionforms.GroupCustActionForm) GroupInformationDto(org.mifos.dto.screen.GroupInformationDto) MifosRuntimeException(org.mifos.core.MifosRuntimeException) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 9 with GroupCustActionForm

use of org.mifos.customers.group.struts.actionforms.GroupCustActionForm in project head by mifos.

the class GroupCustAction method cancel.

@TransactionDemarcate(validateAndResetToken = true)
public ActionForward cancel(ActionMapping mapping, ActionForm form, @SuppressWarnings("unused") HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    ActionForwards forward = null;
    GroupCustActionForm actionForm = (GroupCustActionForm) form;
    String fromPage = actionForm.getInput();
    if (fromPage.equals(GroupConstants.MANAGE_GROUP) || fromPage.equals(GroupConstants.PREVIEW_MANAGE_GROUP)) {
        forward = ActionForwards.cancelEdit_success;
    } else if (fromPage.equals(GroupConstants.CREATE_GROUP)) {
        forward = ActionForwards.cancelCreate_success;
    }
    return mapping.findForward(forward.toString());
}
Also used : ActionForwards(org.mifos.application.util.helpers.ActionForwards) GroupCustActionForm(org.mifos.customers.group.struts.actionforms.GroupCustActionForm) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 10 with GroupCustActionForm

use of org.mifos.customers.group.struts.actionforms.GroupCustActionForm in project head by mifos.

the class GroupCustAction method search.

@Override
@TransactionDemarcate(joinToken = true)
public ActionForward search(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
    GroupCustActionForm actionForm = (GroupCustActionForm) form;
    UserContext userContext = getUserContext(request);
    ActionForward actionForward = super.search(mapping, form, request, response);
    String searchString = actionForm.getSearchString();
    if (searchString == null) {
        if (actionForm.getInput() != null && actionForm.getInput().equals(GroupConstants.GROUP_SEARCH_CLIENT_TRANSFER)) {
            request.setAttribute(Constants.INPUT, CenterConstants.INPUT_SEARCH_TRANSFERGROUP);
        } else {
            request.setAttribute(Constants.INPUT, null);
        }
        throw new CustomerException(CenterConstants.NO_SEARCH_STRING);
    }
    addSeachValues(searchString, userContext.getBranchId().toString(), new OfficeBusinessService().getOffice(userContext.getBranchId()).getOfficeName(), request);
    final String normalizedSearchString = SearchUtils.normalizeSearchString(searchString);
    if (normalizedSearchString.equals("")) {
        if (actionForm.getInput() != null && actionForm.getInput().equals(GroupConstants.GROUP_SEARCH_CLIENT_TRANSFER)) {
            request.setAttribute(Constants.INPUT, CenterConstants.INPUT_SEARCH_TRANSFERGROUP);
        } else {
            request.setAttribute(Constants.INPUT, null);
        }
        throw new CustomerException(CenterConstants.NO_SEARCH_STRING);
    }
    boolean searchForAddingClientsToGroup = (actionForm.getInput() != null && actionForm.getInput().equals(GroupConstants.GROUP_SEARCH_ADD_CLIENTS_TO_GROUPS));
    GroupSearchResultsDto searchResult = this.customerServiceFacade.searchGroups(searchForAddingClientsToGroup, normalizedSearchString, userContext.getId());
    SessionUtils.setQueryResultAttribute(Constants.SEARCH_RESULTS, searchResult.getSearchResults(), request);
    if (actionForm.getInput() != null && actionForm.getInput().equals(GroupConstants.GROUP_SEARCH_CLIENT_TRANSFER)) {
        return mapping.findForward(ActionForwards.transferSearch_success.toString());
    } else if (searchForAddingClientsToGroup) {
        SessionUtils.setQueryResultAttribute(Constants.SEARCH_RESULTS, searchResult.getSearchForAddingClientToGroupResults(), request);
        return mapping.findForward(ActionForwards.addGroupSearch_success.toString());
    } else {
        return actionForward;
    }
}
Also used : CustomerException(org.mifos.customers.exceptions.CustomerException) OfficeBusinessService(org.mifos.customers.office.business.service.OfficeBusinessService) UserContext(org.mifos.security.util.UserContext) GroupCustActionForm(org.mifos.customers.group.struts.actionforms.GroupCustActionForm) ActionForward(org.apache.struts.action.ActionForward) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Aggregations

GroupCustActionForm (org.mifos.customers.group.struts.actionforms.GroupCustActionForm)13 TransactionDemarcate (org.mifos.framework.util.helpers.TransactionDemarcate)9 CustomFieldDto (org.mifos.dto.domain.CustomFieldDto)6 Test (org.junit.Test)4 GroupBO (org.mifos.customers.group.business.GroupBO)3 ApplicationException (org.mifos.framework.exceptions.ApplicationException)3 AddressDto (org.mifos.dto.domain.AddressDto)2 UserContext (org.mifos.security.util.UserContext)2 BusinessRuleException (org.mifos.service.BusinessRuleException)2 Calendar (java.util.Calendar)1 GregorianCalendar (java.util.GregorianCalendar)1 ActionForward (org.apache.struts.action.ActionForward)1 DateTime (org.joda.time.DateTime)1 MeetingBO (org.mifos.application.meeting.business.MeetingBO)1 ActionForwards (org.mifos.application.util.helpers.ActionForwards)1 MifosRuntimeException (org.mifos.core.MifosRuntimeException)1 CenterBO (org.mifos.customers.center.business.CenterBO)1 CustomerException (org.mifos.customers.exceptions.CustomerException)1 OfficeBusinessService (org.mifos.customers.office.business.service.OfficeBusinessService)1 CenterDto (org.mifos.dto.domain.CenterDto)1