Search in sources :

Example 1 with OfficeDetailsForEdit

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

the class OfficeServiceFacadeWebTier method retrieveOfficeDetailsForEdit.

@Override
public OfficeDetailsForEdit retrieveOfficeDetailsForEdit(String officeLevel) {
    List<OfficeDetailsDto> parents = new ArrayList<OfficeDetailsDto>();
    if (StringUtils.isNotBlank(officeLevel)) {
        parents = retrieveActiveParentOffices(Short.valueOf(officeLevel));
    }
    try {
        List<OfficeDetailsDto> configuredOfficeLevels = new OfficePersistence().getActiveLevels();
        for (OfficeDetailsDto officeDetailsDto : configuredOfficeLevels) {
            String levelName = ApplicationContextProvider.getBean(MessageLookup.class).lookup(officeDetailsDto.getLevelNameKey());
            officeDetailsDto.setLevelName(levelName);
        }
        List<OfficeDetailsDto> statusList = new OfficePersistence().getStatusList();
        for (OfficeDetailsDto officeDetailsDto : statusList) {
            officeDetailsDto.setLevelName(ApplicationContextProvider.getBean(MessageLookup.class).lookup(officeDetailsDto.getLevelNameKey()));
        }
        return new OfficeDetailsForEdit(parents, statusList, configuredOfficeLevels);
    } catch (PersistenceException e) {
        throw new MifosRuntimeException(e);
    }
}
Also used : MessageLookup(org.mifos.application.master.MessageLookup) ArrayList(java.util.ArrayList) PersistenceException(org.mifos.framework.exceptions.PersistenceException) OfficeDetailsForEdit(org.mifos.dto.screen.OfficeDetailsForEdit) OfficePersistence(org.mifos.customers.office.persistence.OfficePersistence) OfficeDetailsDto(org.mifos.dto.domain.OfficeDetailsDto) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Example 2 with OfficeDetailsForEdit

use of org.mifos.dto.screen.OfficeDetailsForEdit 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)

Aggregations

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