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