Search in sources :

Example 1 with GroupCustActionForm

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

the class GroupCustAction method update.

@TransactionDemarcate(validateAndResetToken = true)
@CloseSession
public ActionForward update(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    GroupBO group = (GroupBO) SessionUtils.getAttribute(Constants.BUSINESS_KEY, request);
    GroupCustActionForm actionForm = (GroupCustActionForm) form;
    boolean trained = false;
    if (actionForm.getTrainedValue() != null && actionForm.getTrainedValue().equals(Short.valueOf("1"))) {
        trained = true;
    }
    AddressDto address = null;
    if (actionForm.getAddress() != null) {
        address = Address.toDto(actionForm.getAddress());
    }
    GroupUpdate groupUpdate = new GroupUpdate(group.getCustomerId(), group.getGlobalCustNum(), group.getVersionNo(), actionForm.getDisplayName(), actionForm.getLoanOfficerIdValue(), actionForm.getExternalId(), trained, actionForm.getTrainedDate(), address, actionForm.getCustomFields(), actionForm.getCustomerPositions());
    try {
        this.groupServiceFacade.updateGroup(groupUpdate);
    } catch (BusinessRuleException e) {
        throw new ApplicationException(e.getMessageKey(), e);
    }
    return mapping.findForward(ActionForwards.update_success.toString());
}
Also used : BusinessRuleException(org.mifos.service.BusinessRuleException) ApplicationException(org.mifos.framework.exceptions.ApplicationException) GroupBO(org.mifos.customers.group.business.GroupBO) AddressDto(org.mifos.dto.domain.AddressDto) GroupCustActionForm(org.mifos.customers.group.struts.actionforms.GroupCustActionForm) GroupUpdate(org.mifos.dto.domain.GroupUpdate) CloseSession(org.mifos.framework.util.helpers.CloseSession) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 2 with GroupCustActionForm

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

the class GroupCustAction method loadSearch.

@TransactionDemarcate(conditionToken = true)
public ActionForward loadSearch(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    GroupCustActionForm actionForm = (GroupCustActionForm) form;
    actionForm.setSearchString(null);
    cleanUpSearch(request);
    boolean groupHierarchyRequired = this.customerServiceFacade.isGroupHierarchyRequired();
    if (groupHierarchyRequired) {
        SessionUtils.setAttribute(CustomerConstants.GROUP_HIERARCHY_REQUIRED, CustomerConstants.NO, request);
    } else {
        SessionUtils.setAttribute(CustomerConstants.GROUP_HIERARCHY_REQUIRED, CustomerConstants.YES, request);
    }
    if (actionForm.getInput() != null && actionForm.getInput().equals(GroupConstants.GROUP_SEARCH_CLIENT_TRANSFER)) {
        return mapping.findForward(ActionForwards.loadTransferSearch_success.toString());
    }
    SessionUtils.setAttribute(CustomerConstants.URL_MAP, null, request.getSession(false));
    return mapping.findForward(ActionForwards.loadSearch_success.toString());
}
Also used : GroupCustActionForm(org.mifos.customers.group.struts.actionforms.GroupCustActionForm) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 3 with GroupCustActionForm

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

the class GroupCustAction method load.

@TransactionDemarcate(saveToken = true)
public ActionForward load(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    GroupCustActionForm actionForm = (GroupCustActionForm) form;
    actionForm.cleanForm();
    SessionUtils.removeAttribute(CustomerConstants.CUSTOMER_MEETING, request.getSession());
    GroupCreation groupCreation = null;
    boolean isCenterHierarchyExists = ClientRules.getCenterHierarchyExists();
    if (isCenterHierarchyExists) {
        String centerSystemId = actionForm.getCenterSystemId();
        CenterBO center = this.customerDao.findCenterBySystemId(centerSystemId);
        groupCreation = new GroupCreation(actionForm.getOfficeIdValue(), centerSystemId);
        // inherit these settings from center/parent if center hierarchy is configured
        actionForm.setParentCustomer(center);
        actionForm.setOfficeId(center.getOfficeId().toString());
        actionForm.setFormedByPersonnel(center.getLoanOfficerId().toString());
    } else {
        groupCreation = new GroupCreation(actionForm.getOfficeIdValue(), "");
    }
    GroupFormCreationDto groupFormCreationDto = this.groupServiceFacade.retrieveGroupFormCreationData(groupCreation);
    actionForm.setCustomFields(new ArrayList<CustomFieldDto>());
    actionForm.setDefaultFees(groupFormCreationDto.getDefaultFees());
    SessionUtils.setCollectionAttribute(CustomerConstants.ADDITIONAL_FEES_LIST, groupFormCreationDto.getAdditionalFees(), request);
    SessionUtils.setCollectionAttribute(CustomerConstants.LOAN_OFFICER_LIST, groupFormCreationDto.getPersonnelList(), request);
    SessionUtils.setCollectionAttribute(CustomerConstants.CUSTOM_FIELDS_LIST, new ArrayList<CustomFieldDto>(), request);
    SessionUtils.setCollectionAttribute(CustomerConstants.FORMEDBY_LOAN_OFFICER_LIST, groupFormCreationDto.getFormedByPersonnel(), request);
    SessionUtils.setAttribute(GroupConstants.CENTER_HIERARCHY_EXIST, groupFormCreationDto.isCenterHierarchyExists(), request);
    return mapping.findForward(ActionForwards.load_success.toString());
}
Also used : GroupFormCreationDto(org.mifos.dto.domain.GroupFormCreationDto) GroupCreation(org.mifos.dto.domain.GroupCreation) CustomFieldDto(org.mifos.dto.domain.CustomFieldDto) CenterBO(org.mifos.customers.center.business.CenterBO) GroupCustActionForm(org.mifos.customers.group.struts.actionforms.GroupCustActionForm) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 4 with GroupCustActionForm

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

the class GroupActionStrutsTest method testPreviewManageSuccessForNameChange_AfterTrainedSet.

/**
     * This test asserts that when a group name for a trained group is edited, there are no errors and the trained date
     * is present in the action form.
     */
@Test
public void testPreviewManageSuccessForNameChange_AfterTrainedSet() throws Exception {
    Calendar cal = new GregorianCalendar();
    cal.set(Calendar.DAY_OF_MONTH, 2);
    cal.set(Calendar.MONTH, 5);
    cal.set(Calendar.YEAR, 2008);
    request.setAttribute(Constants.CURRENTFLOWKEY, flowKey);
    createTrainedGroupAndSetInSession(cal.getTime());
    setRequestPathInfo("/groupCustAction.do");
    addRequestParameter("method", "manage");
    addRequestParameter("officeId", "3");
    addRequestParameter(Constants.CURRENTFLOWKEY, (String) request.getAttribute(Constants.CURRENTFLOWKEY));
    actionPerform();
    List<CustomFieldDto> customFieldDefs = getCustomFieldsFromSession();
    setRequestPathInfo("/groupCustAction.do");
    addRequestParameter("method", "previewManage");
    addRequestParameter("officeId", "3");
    // editing group name
    addRequestParameter("displayName", "group123");
    int i = 0;
    for (CustomFieldDto customFieldDef : customFieldDefs) {
        addRequestParameter("customField[" + i + "].fieldId", customFieldDef.getFieldId().toString());
        addRequestParameter("customField[" + i + "].fieldValue", "Req");
        i++;
    }
    addRequestParameter("trained", "1");
    addRequestParameter("trainedDate", "2/6/2008");
    addRequestParameter(Constants.CURRENTFLOWKEY, (String) request.getAttribute(Constants.CURRENTFLOWKEY));
    actionPerform();
    GroupCustActionForm actionForm = (GroupCustActionForm) getActionForm();
    Assert.assertEquals("2/6/2008", actionForm.getTrainedDate());
    Assert.assertEquals(0, getErrorSize());
}
Also used : GregorianCalendar(java.util.GregorianCalendar) Calendar(java.util.Calendar) CustomFieldDto(org.mifos.dto.domain.CustomFieldDto) GregorianCalendar(java.util.GregorianCalendar) GroupCustActionForm(org.mifos.customers.group.struts.actionforms.GroupCustActionForm) Test(org.junit.Test)

Example 5 with GroupCustActionForm

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

the class GroupActionStrutsTest method testFailureCreate_DuplicateName.

@Test
public void testFailureCreate_DuplicateName() throws Exception {
    createGroupWithCenter();
    setRequestPathInfo("/groupCustAction.do");
    addRequestParameter("method", "load");
    addRequestParameter("centerSystemId", center.getGlobalCustNum());
    actionPerform();
    List<CustomFieldDto> customFieldDefs = getCustomFieldsFromSession();
    setRequestPathInfo("/groupCustAction.do");
    addRequestParameter("method", "preview");
    addRequestParameter(Constants.CURRENTFLOWKEY, (String) request.getAttribute(Constants.CURRENTFLOWKEY));
    addRequestParameter("displayName", "group");
    addRequestParameter("status", CustomerStatus.GROUP_PENDING.getValue().toString());
    addRequestParameter("formedByPersonnel", center.getPersonnel().getPersonnelId().toString());
    int i = 0;
    for (CustomFieldDto customFieldDef : customFieldDefs) {
        addRequestParameter("customField[" + i + "].fieldId", customFieldDef.getFieldId().toString());
        addRequestParameter("customField[" + i + "].fieldValue", "11");
        i++;
    }
    actionPerform();
    setRequestPathInfo("/groupCustAction.do");
    addRequestParameter("method", "create");
    addRequestParameter(Constants.CURRENTFLOWKEY, (String) request.getAttribute(Constants.CURRENTFLOWKEY));
    actionPerform();
    verifyActionErrors(new String[] { CustomerConstants.ERRORS_DUPLICATE_CUSTOMER });
    verifyForward(ActionForwards.create_failure.toString());
    group = TestObjectFactory.getGroup(group.getCustomerId());
    center = TestObjectFactory.getCenter(center.getCustomerId());
    GroupCustActionForm actionForm = (GroupCustActionForm) request.getSession().getAttribute("groupCustActionForm");
    actionForm.setParentCustomer(null);
}
Also used : CustomFieldDto(org.mifos.dto.domain.CustomFieldDto) GroupCustActionForm(org.mifos.customers.group.struts.actionforms.GroupCustActionForm) Test(org.junit.Test)

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