Search in sources :

Example 1 with OfficeUpdateRequest

use of org.mifos.dto.domain.OfficeUpdateRequest 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;
}
Also used : OfficeDto(org.mifos.dto.domain.OfficeDto) OffActionForm(org.mifos.customers.office.struts.actionforms.OffActionForm) ActionForward(org.apache.struts.action.ActionForward) OfficeUpdateRequest(org.mifos.dto.domain.OfficeUpdateRequest) CloseSession(org.mifos.framework.util.helpers.CloseSession) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 2 with OfficeUpdateRequest

use of org.mifos.dto.domain.OfficeUpdateRequest in project head by mifos.

the class OffAction method officeUpdateRequestFrom.

private OfficeUpdateRequest officeUpdateRequestFrom(OffActionForm offActionForm) throws OfficeException {
    OfficeStatus newStatus = null;
    if (getShortValue(offActionForm.getOfficeStatus()) != null) {
        newStatus = OfficeStatus.getOfficeStatus(getShortValue(offActionForm.getOfficeStatus()));
    }
    OfficeLevel newlevel = OfficeLevel.getOfficeLevel(getShortValue(offActionForm.getOfficeLevel()));
    Short parentOfficeId = getShortValue(offActionForm.getParentOfficeId());
    Address address = offActionForm.getAddress();
    AddressDto addressDto = null;
    if (address != null) {
        addressDto = Address.toDto(address);
    }
    return new OfficeUpdateRequest(offActionForm.getOfficeName(), offActionForm.getShortName(), newStatus.getValue(), newlevel.getValue(), parentOfficeId, addressDto);
}
Also used : Address(org.mifos.framework.business.util.Address) AddressDto(org.mifos.dto.domain.AddressDto) OfficeStatus(org.mifos.customers.office.util.helpers.OfficeStatus) OfficeLevel(org.mifos.customers.office.util.helpers.OfficeLevel) OfficeUpdateRequest(org.mifos.dto.domain.OfficeUpdateRequest)

Aggregations

OfficeUpdateRequest (org.mifos.dto.domain.OfficeUpdateRequest)2 ActionForward (org.apache.struts.action.ActionForward)1 OffActionForm (org.mifos.customers.office.struts.actionforms.OffActionForm)1 OfficeLevel (org.mifos.customers.office.util.helpers.OfficeLevel)1 OfficeStatus (org.mifos.customers.office.util.helpers.OfficeStatus)1 AddressDto (org.mifos.dto.domain.AddressDto)1 OfficeDto (org.mifos.dto.domain.OfficeDto)1 Address (org.mifos.framework.business.util.Address)1 CloseSession (org.mifos.framework.util.helpers.CloseSession)1 TransactionDemarcate (org.mifos.framework.util.helpers.TransactionDemarcate)1