Search in sources :

Example 1 with OfficeFormDto

use of org.mifos.dto.screen.OfficeFormDto 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());
}
Also used : OfficeDto(org.mifos.dto.domain.OfficeDto) OfficeFormDto(org.mifos.dto.screen.OfficeFormDto) ArrayList(java.util.ArrayList) OffActionForm(org.mifos.customers.office.struts.actionforms.OffActionForm) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 2 with OfficeFormDto

use of org.mifos.dto.screen.OfficeFormDto in project head by mifos.

the class OfficeServiceFacadeWebTier method retrieveOfficeFormInformation.

@Override
public OfficeFormDto retrieveOfficeFormInformation(Short officeLevelId) {
    try {
        List<CustomFieldDto> customFields = new ArrayList<CustomFieldDto>();
        OfficeLevel officeLevel = OfficeLevel.HEADOFFICE;
        if (officeLevelId != null) {
            officeLevel = OfficeLevel.getOfficeLevel(officeLevelId);
        }
        List<OfficeDto> parents = this.officeDao.findActiveParents(officeLevel);
        for (OfficeDto office : parents) {
            String levelName = ApplicationContextProvider.getBean(MessageLookup.class).lookup(office.getLookupNameKey());
            office.setLevelName(levelName);
        }
        List<OfficeDetailsDto> officeLevels = new OfficePersistence().getActiveLevels();
        for (OfficeDetailsDto officeDetailsDto : officeLevels) {
            String levelName = ApplicationContextProvider.getBean(MessageLookup.class).lookup(officeDetailsDto.getLevelNameKey());
            officeDetailsDto.setLevelName(levelName);
        }
        return new OfficeFormDto(customFields, parents, officeLevels);
    } catch (PersistenceException e) {
        throw new MifosRuntimeException(e);
    }
}
Also used : OfficeDto(org.mifos.dto.domain.OfficeDto) OfficeFormDto(org.mifos.dto.screen.OfficeFormDto) CustomFieldDto(org.mifos.dto.domain.CustomFieldDto) ArrayList(java.util.ArrayList) OfficeDetailsDto(org.mifos.dto.domain.OfficeDetailsDto) MessageLookup(org.mifos.application.master.MessageLookup) PersistenceException(org.mifos.framework.exceptions.PersistenceException) OfficePersistence(org.mifos.customers.office.persistence.OfficePersistence) OfficeLevel(org.mifos.customers.office.util.helpers.OfficeLevel) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Aggregations

ArrayList (java.util.ArrayList)2 OfficeDto (org.mifos.dto.domain.OfficeDto)2 OfficeFormDto (org.mifos.dto.screen.OfficeFormDto)2 MessageLookup (org.mifos.application.master.MessageLookup)1 MifosRuntimeException (org.mifos.core.MifosRuntimeException)1 OfficePersistence (org.mifos.customers.office.persistence.OfficePersistence)1 OffActionForm (org.mifos.customers.office.struts.actionforms.OffActionForm)1 OfficeLevel (org.mifos.customers.office.util.helpers.OfficeLevel)1 CustomFieldDto (org.mifos.dto.domain.CustomFieldDto)1 OfficeDetailsDto (org.mifos.dto.domain.OfficeDetailsDto)1 PersistenceException (org.mifos.framework.exceptions.PersistenceException)1 TransactionDemarcate (org.mifos.framework.util.helpers.TransactionDemarcate)1