Search in sources :

Example 16 with OfficeDto

use of org.mifos.dto.domain.OfficeDto 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)

Example 17 with OfficeDto

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

the class OfficeServiceFacadeWebTier method retrieveBranchOnlyOfficeHierarchy.

@Override
public OnlyBranchOfficeHierarchyDto retrieveBranchOnlyOfficeHierarchy() {
    MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
    OfficeDto office = officeDao.findOfficeDtoById(user.getBranchId());
    List<OfficeBO> branchParents = officeDao.findBranchsOnlyWithParentsMatching(office.getSearchId());
    List<OfficeDetailsDto> levels = officeDao.findActiveOfficeLevels();
    List<OfficeHierarchyDto> branchOnlyOfficeHierarchy = OfficeBO.convertToBranchOnlyHierarchyWithParentsOfficeHierarchy(branchParents);
    return new OnlyBranchOfficeHierarchyDto(Locale.getDefault(), levels, office.getSearchId(), branchOnlyOfficeHierarchy);
}
Also used : OfficeHierarchyDto(org.mifos.dto.domain.OfficeHierarchyDto) OnlyBranchOfficeHierarchyDto(org.mifos.dto.screen.OnlyBranchOfficeHierarchyDto) OfficeDto(org.mifos.dto.domain.OfficeDto) OfficeBO(org.mifos.customers.office.business.OfficeBO) OnlyBranchOfficeHierarchyDto(org.mifos.dto.screen.OnlyBranchOfficeHierarchyDto) MifosUser(org.mifos.security.MifosUser) OfficeDetailsDto(org.mifos.dto.domain.OfficeDetailsDto)

Example 18 with OfficeDto

use of org.mifos.dto.domain.OfficeDto 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)

Example 19 with OfficeDto

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

the class OfficeServiceFacadeWebTier method branchOffices.

private List<OfficeDto> branchOffices(List<OfficeDto> allOffices) {
    List<OfficeDto> branchOffices = new ArrayList<OfficeDto>();
    for (OfficeDto officeDto : allOffices) {
        if (OfficeLevel.BRANCHOFFICE.getValue().equals(officeDto.getLevelId())) {
            branchOffices.add(officeDto);
        }
    }
    // sort branch offices by parent due to UI dependency on this.
    Collections.sort(branchOffices, new Comparator<OfficeDto>() {

        @Override
        public int compare(OfficeDto first, OfficeDto next) {
            return first.getParentId().compareTo(next.getParentId());
        }
    });
    return branchOffices;
}
Also used : OfficeDto(org.mifos.dto.domain.OfficeDto) ArrayList(java.util.ArrayList)

Example 20 with OfficeDto

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

the class OfficeServiceFacadeWebTier method retrieveOfficeById.

@Override
public OfficeDto retrieveOfficeById(Short id) {
    OfficeBO officeBO = officeDao.findOfficeById(id);
    List<CustomFieldDto> customFields = new ArrayList<CustomFieldDto>();
    Short parentOfficeId = null;
    String parentOffineName = null;
    if (officeBO.getParentOffice() != null) {
        parentOfficeId = officeBO.getParentOffice().getOfficeId();
        parentOffineName = officeBO.getParentOffice().getOfficeName();
    }
    Address address = officeBO.getAddress() != null ? officeBO.getAddress().getAddress() : null;
    AddressDto addressDto = address != null ? Address.toDto(officeBO.getAddress().getAddress()) : null;
    String officeLevelName = ApplicationContextProvider.getBean(MessageLookup.class).lookup(officeBO.getLevel().getLookUpValue());
    String officeStatusName = ApplicationContextProvider.getBean(MessageLookup.class).lookup(officeBO.getStatus().getLookUpValue());
    OfficeDto officeDto = new OfficeDto(officeBO.getOfficeId(), officeBO.getOfficeName(), officeBO.getSearchId(), officeBO.getShortName(), officeBO.getGlobalOfficeNum(), parentOfficeId, officeBO.getStatus().getId(), officeBO.getLevel().getId(), parentOffineName, officeBO.getVersionNo(), officeStatusName, officeLevelName, addressDto, customFields);
    return officeDto;
}
Also used : OfficeDto(org.mifos.dto.domain.OfficeDto) Address(org.mifos.framework.business.util.Address) OfficeBO(org.mifos.customers.office.business.OfficeBO) CustomFieldDto(org.mifos.dto.domain.CustomFieldDto) MessageLookup(org.mifos.application.master.MessageLookup) ArrayList(java.util.ArrayList) AddressDto(org.mifos.dto.domain.AddressDto)

Aggregations

OfficeDto (org.mifos.dto.domain.OfficeDto)27 ArrayList (java.util.ArrayList)14 OffActionForm (org.mifos.customers.office.struts.actionforms.OffActionForm)6 TransactionDemarcate (org.mifos.framework.util.helpers.TransactionDemarcate)6 MifosUser (org.mifos.security.MifosUser)6 OfficeBO (org.mifos.customers.office.business.OfficeBO)5 OfficeDetailsDto (org.mifos.dto.domain.OfficeDetailsDto)5 HashMap (java.util.HashMap)3 CustomFieldDto (org.mifos.dto.domain.CustomFieldDto)3 OfficeHierarchyDto (org.mifos.dto.domain.OfficeHierarchyDto)3 ValueListElement (org.mifos.dto.domain.ValueListElement)3 ListElement (org.mifos.dto.screen.ListElement)3 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)3 ModelAndView (org.springframework.web.servlet.ModelAndView)3 LinkedHashMap (java.util.LinkedHashMap)2 Test (org.junit.Test)2 MessageLookup (org.mifos.application.master.MessageLookup)2 CustomFieldDefinitionEntity (org.mifos.application.master.business.CustomFieldDefinitionEntity)2 MifosRuntimeException (org.mifos.core.MifosRuntimeException)2 OfficePersistence (org.mifos.customers.office.persistence.OfficePersistence)2