Search in sources :

Example 1 with OfficeDto

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

the class OfficeServiceFacadeWebTier method divisionalOffices.

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

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

Example 2 with OfficeDto

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

the class OfficeServiceFacadeWebTier method retrieveAllNonBranchOfficesApplicableToLoggedInUser.

@Override
public List<OfficeDto> retrieveAllNonBranchOfficesApplicableToLoggedInUser() {
    MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
    OfficeDto office = officeDao.findOfficeDtoById(user.getBranchId());
    return officeDao.findNonBranchesOnlyWithParentsMatching(office.getSearchId());
}
Also used : OfficeDto(org.mifos.dto.domain.OfficeDto) MifosUser(org.mifos.security.MifosUser)

Example 3 with OfficeDto

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

the class OfficeServiceFacadeWebTier method retrieveActiveBranchesUnderUser.

@Override
public List<OfficeDto> retrieveActiveBranchesUnderUser(Short userId) {
    PersonnelBO personnel = personnelDao.findPersonnelById(userId);
    try {
        List<OfficeBO> officesListBO = new OfficePersistence().getActiveBranchesUnderUser(personnel.getOfficeSearchId());
        List<OfficeDto> officesList = new ArrayList<OfficeDto>();
        for (OfficeBO officeBO : officesListBO) {
            OfficeDto officeDto = new OfficeDto(officeBO.getOfficeId(), officeBO.getOfficeName(), officeBO.getSearchId(), officeBO.getShortName(), officeBO.getGlobalOfficeNum(), officeBO.getParentOffice().getOfficeId(), officeBO.getStatus().getId(), officeBO.getLevel().getId());
            officesList.add(officeDto);
        }
        return officesList;
    } catch (PersistenceException e) {
        throw new MifosRuntimeException(e);
    }
}
Also used : OfficeDto(org.mifos.dto.domain.OfficeDto) PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) OfficeBO(org.mifos.customers.office.business.OfficeBO) ArrayList(java.util.ArrayList) PersistenceException(org.mifos.framework.exceptions.PersistenceException) OfficePersistence(org.mifos.customers.office.persistence.OfficePersistence) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Example 4 with OfficeDto

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

the class OfficeServiceFacadeWebTier method regionalOfficeSpecification.

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

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

Example 5 with OfficeDto

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

the class OfficeServiceFacadeWebTier method areaOffices.

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

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

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