Search in sources :

Example 6 with OffActionForm

use of org.mifos.customers.office.struts.actionforms.OffActionForm in project head by mifos.

the class OffAction method loadParent.

@TransactionDemarcate(joinToken = true)
public ActionForward loadParent(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    OffActionForm offActionForm = (OffActionForm) form;
    String officeLevel = request.getParameter("officeLevel");
    if (StringUtils.isNotBlank(officeLevel)) {
        offActionForm.setOfficeLevel(officeLevel);
        List<OfficeDetailsDto> parents = this.officeServiceFacade.retrieveActiveParentOffices(Short.valueOf(officeLevel));
        OfficeDto office = (OfficeDto) SessionUtils.getAttribute(OfficeConstants.OFFICE_DTO, request);
        if (offActionForm.getInput() != null && offActionForm.getInput().equals("edit") && office != null) {
            for (int i = 0; i < parents.size(); i++) {
                OfficeDetailsDto view = parents.get(i);
                if (view.getOfficeId().equals(office.getOfficeId())) {
                    parents.remove(view);
                }
            }
        }
        SessionUtils.setCollectionAttribute(OfficeConstants.PARENTS, parents, request);
    }
    if (offActionForm.getInput() != null && offActionForm.getInput().equals("edit")) {
        return mapping.findForward(ActionForwards.edit_success.toString());
    }
    return mapping.findForward(ActionForwards.load_success.toString());
}
Also used : OfficeDto(org.mifos.dto.domain.OfficeDto) OffActionForm(org.mifos.customers.office.struts.actionforms.OffActionForm) OfficeDetailsDto(org.mifos.dto.domain.OfficeDetailsDto) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 7 with OffActionForm

use of org.mifos.customers.office.struts.actionforms.OffActionForm in project head by mifos.

the class OffAction method edit.

@TransactionDemarcate(joinToken = true)
public ActionForward edit(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    OffActionForm offActionForm = (OffActionForm) form;
    OfficeDto sessionOffice = (OfficeDto) SessionUtils.getAttribute(OfficeConstants.OFFICE_DTO, request);
    OfficeBO office = this.officeDao.findOfficeById(sessionOffice.getOfficeId());
    checkVersionMismatch(sessionOffice.getVersionNum(), office.getVersionNo());
    String officeLevel = request.getParameter("officeLevel");
    OfficeDetailsForEdit officeDetailsForEdit = this.officeServiceFacade.retrieveOfficeDetailsForEdit(officeLevel);
    if (StringUtils.isNotBlank(officeLevel)) {
        offActionForm.setOfficeLevel(officeLevel);
        List<OfficeDetailsDto> parents = this.officeServiceFacade.retrieveActiveParentOffices(Short.valueOf(officeLevel));
        OfficeDto office1 = (OfficeDto) SessionUtils.getAttribute(OfficeConstants.OFFICE_DTO, request);
        if (offActionForm.getInput() != null && offActionForm.getInput().equals("edit") && office1 != null) {
            for (int i = 0; i < parents.size(); i++) {
                OfficeDetailsDto view = parents.get(i);
                if (view.getOfficeId().equals(office1.getOfficeId())) {
                    parents.remove(view);
                }
            }
        }
        SessionUtils.setCollectionAttribute(OfficeConstants.PARENTS, parents, request);
    }
    offActionForm.setCustomFields(new ArrayList<CustomFieldDto>());
    SessionUtils.setCollectionAttribute(OfficeConstants.OFFICELEVELLIST, officeDetailsForEdit.getConfiguredOfficeLevels(), request);
    SessionUtils.setCollectionAttribute(OfficeConstants.OFFICESTATUSLIST, officeDetailsForEdit.getStatusList(), request);
    List<CustomFieldDefinitionEntity> customFieldDefs = new ArrayList<CustomFieldDefinitionEntity>();
    SessionUtils.setCollectionAttribute(CustomerConstants.CUSTOM_FIELDS_LIST, customFieldDefs, request);
    return mapping.findForward(ActionForwards.edit_success.toString());
}
Also used : OfficeDto(org.mifos.dto.domain.OfficeDto) CustomFieldDto(org.mifos.dto.domain.CustomFieldDto) ArrayList(java.util.ArrayList) OffActionForm(org.mifos.customers.office.struts.actionforms.OffActionForm) OfficeDetailsForEdit(org.mifos.dto.screen.OfficeDetailsForEdit) OfficeDetailsDto(org.mifos.dto.domain.OfficeDetailsDto) CustomFieldDefinitionEntity(org.mifos.application.master.business.CustomFieldDefinitionEntity) OfficeBO(org.mifos.customers.office.business.OfficeBO) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 8 with OffActionForm

use of org.mifos.customers.office.struts.actionforms.OffActionForm in project head by mifos.

the class OfficeActionStrutsTest method testLoadLevel.

@Test
public void testLoadLevel() throws Exception {
    setRequestPathInfo("/offAction.do");
    addRequestParameter("method", Methods.load.toString());
    addRequestParameter("officeLevel", "5");
    addRequestParameter(Constants.CURRENTFLOWKEY, flowKey);
    actionPerform();
    verifyForward(ActionForwards.load_success.toString());
    List<OfficeDetailsDto> parents = (List<OfficeDetailsDto>) SessionUtils.getAttribute(OfficeConstants.PARENTS, request);
    Assert.assertEquals(2, parents.size());
    List<OfficeDetailsDto> levels = (List<OfficeDetailsDto>) SessionUtils.getAttribute(OfficeConstants.OFFICELEVELLIST, request);
    Assert.assertEquals(4, levels.size());
    OffActionForm offActionForm = (OffActionForm) request.getSession().getAttribute("offActionForm");
    Assert.assertNotNull(offActionForm);
    Assert.assertEquals("5", offActionForm.getOfficeLevel());
}
Also used : List(java.util.List) OffActionForm(org.mifos.customers.office.struts.actionforms.OffActionForm) OfficeDetailsDto(org.mifos.dto.domain.OfficeDetailsDto) Test(org.junit.Test)

Aggregations

OffActionForm (org.mifos.customers.office.struts.actionforms.OffActionForm)8 OfficeDto (org.mifos.dto.domain.OfficeDto)6 TransactionDemarcate (org.mifos.framework.util.helpers.TransactionDemarcate)6 ArrayList (java.util.ArrayList)3 OfficeDetailsDto (org.mifos.dto.domain.OfficeDetailsDto)3 Test (org.junit.Test)2 CustomFieldDefinitionEntity (org.mifos.application.master.business.CustomFieldDefinitionEntity)2 List (java.util.List)1 ActionForward (org.apache.struts.action.ActionForward)1 OfficeBO (org.mifos.customers.office.business.OfficeBO)1 OfficeException (org.mifos.customers.office.exceptions.OfficeException)1 CustomFieldDto (org.mifos.dto.domain.CustomFieldDto)1 OfficeUpdateRequest (org.mifos.dto.domain.OfficeUpdateRequest)1 ListElement (org.mifos.dto.screen.ListElement)1 OfficeDetailsForEdit (org.mifos.dto.screen.OfficeDetailsForEdit)1 OfficeFormDto (org.mifos.dto.screen.OfficeFormDto)1 CloseSession (org.mifos.framework.util.helpers.CloseSession)1