use of org.mifos.customers.office.struts.actionforms.OffActionForm in project head by mifos.
the class OffAction method create.
@TransactionDemarcate(validateAndResetToken = true)
public ActionForward create(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
OffActionForm offActionForm = (OffActionForm) form;
OfficeDto officeDto = new OfficeDto(getShortValue(offActionForm.getOfficeLevel()), getShortValue(offActionForm.getParentOfficeId()), offActionForm.getCustomFields(), offActionForm.getOfficeName(), offActionForm.getShortName(), Address.toDto(offActionForm.getAddress()));
ListElement element = officeServiceFacade.createOffice(OperationMode.REMOTE_SERVER.getValue(), officeDto);
offActionForm.setOfficeId(element.getId().toString());
offActionForm.setGlobalOfficeNum(element.getName());
createGroupQuestionnaire.saveResponses(request, offActionForm, element.getId());
return mapping.findForward(ActionForwards.create_success.toString());
}
use of org.mifos.customers.office.struts.actionforms.OffActionForm in project head by mifos.
the class OffAction method load.
@TransactionDemarcate(saveToken = true)
public ActionForward load(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
OffActionForm actionForm = (OffActionForm) form;
actionForm.clear();
String officeLevel = request.getParameter("officeLevel");
Short officeLevelId = null;
if (StringUtils.isNotBlank(officeLevel)) {
officeLevelId = Short.valueOf(officeLevel);
}
OfficeFormDto officeFormDto = this.officeServiceFacade.retrieveOfficeFormInformation(officeLevelId);
if (StringUtils.isNotBlank(officeLevel)) {
actionForm.setOfficeLevel(officeLevel);
OfficeDto office = (OfficeDto) SessionUtils.getAttribute(OfficeConstants.OFFICE_DTO, request);
List<OfficeDto> validParentOffices = new ArrayList<OfficeDto>();
if (actionForm.getInput() != null && actionForm.getInput().equals("edit") && office != null) {
for (OfficeDto view : officeFormDto.getParents()) {
if (!view.getId().equals(office.getOfficeId())) {
validParentOffices.add(view);
}
}
} else {
validParentOffices.addAll(officeFormDto.getParents());
}
SessionUtils.setCollectionAttribute(OfficeConstants.PARENTS, validParentOffices, request);
}
actionForm.setCustomFields(officeFormDto.getCustomFields());
SessionUtils.setCollectionAttribute(CustomerConstants.CUSTOM_FIELDS_LIST, officeFormDto.getCustomFields(), request);
SessionUtils.setCollectionAttribute(OfficeConstants.OFFICELEVELLIST, officeFormDto.getOfficeLevels(), request);
SessionUtils.setAttribute(CustomerConstants.URL_MAP, null, request.getSession(false));
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 update.
@TransactionDemarcate(validateAndResetToken = true)
@CloseSession
public ActionForward update(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
OffActionForm offActionForm = (OffActionForm) form;
ActionForward forward = null;
OfficeDto sessionOffice = (OfficeDto) SessionUtils.getAttribute(OfficeConstants.OFFICE_DTO, request);
Short officeId = sessionOffice.getOfficeId();
Integer versionNum = sessionOffice.getVersionNum();
OfficeUpdateRequest officeUpdateRequest = officeUpdateRequestFrom(offActionForm);
boolean isParentOfficeChanged = this.officeServiceFacade.updateOffice(officeId, versionNum, officeUpdateRequest);
if (isParentOfficeChanged) {
forward = mapping.findForward(ActionForwards.update_cache_success.toString());
} else {
forward = mapping.findForward(ActionForwards.update_success.toString());
}
return forward;
}
use of org.mifos.customers.office.struts.actionforms.OffActionForm in project head by mifos.
the class OfficeActionStrutsTest method testCreate.
@Test
public void testCreate() throws Exception {
setRequestPathInfo("/offAction.do");
addRequestParameter("method", Methods.create.toString());
addRequestParameter("officeName", "abcd");
addRequestParameter("shortName", "abcd");
addRequestParameter("officeLevel", "5");
addRequestParameter("parentOfficeId", "1");
addRequestParameter("address.line1", "123");
addRequestParameter(Constants.CURRENTFLOWKEY, flowKey);
actionPerform();
verifyForward(ActionForwards.create_success.toString());
OffActionForm offActionForm = (OffActionForm) request.getSession().getAttribute("offActionForm");
Assert.assertEquals("abcd", offActionForm.getOfficeName());
Assert.assertEquals("abcd", offActionForm.getShortName());
Assert.assertEquals("123", offActionForm.getAddress().getLine1());
}
use of org.mifos.customers.office.struts.actionforms.OffActionForm in project head by mifos.
the class OffAction method get.
@TransactionDemarcate(saveToken = true)
public ActionForward get(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
OffActionForm actionForm = (OffActionForm) form;
if (StringUtils.isBlank(actionForm.getOfficeId())) {
throw new OfficeException(OfficeConstants.KEYGETFAILED);
}
OfficeDto officeDto = this.officeServiceFacade.retrieveOfficeById(Short.valueOf(actionForm.getOfficeId()));
actionForm.clear();
List<CustomFieldDefinitionEntity> customFieldDefs = new ArrayList<CustomFieldDefinitionEntity>();
SessionUtils.setCollectionAttribute(CustomerConstants.CUSTOM_FIELDS_LIST, customFieldDefs, request);
actionForm.populate(officeDto);
SessionUtils.setAttribute(OfficeConstants.OFFICE_DTO, officeDto, request);
setCurrentPageUrl(request, officeDto);
return mapping.findForward(ActionForwards.get_success.toString());
}
Aggregations