Search in sources :

Example 1 with OfficeLevel

use of org.mifos.customers.office.util.helpers.OfficeLevel 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)

Example 2 with OfficeLevel

use of org.mifos.customers.office.util.helpers.OfficeLevel in project head by mifos.

the class OfficeBO method update.

public void update(UserContext userContext, OfficeUpdateRequest officeUpdateRequest, OfficeBO newParentOffice) throws OfficeException {
    updateDetails(userContext);
    OfficeStatus officeStatus = OfficeStatus.getOfficeStatus(officeUpdateRequest.getNewStatus());
    OfficeLevel officeLevel = OfficeLevel.getOfficeLevel(officeUpdateRequest.getNewlevel());
    Address address = null;
    AddressDto dto = officeUpdateRequest.getAddress();
    if (dto != null) {
        address = new Address(dto.getLine1(), dto.getLine2(), dto.getLine3(), dto.getCity(), dto.getState(), dto.getCountry(), dto.getZip(), dto.getPhoneNumber());
    }
    update(officeUpdateRequest.getOfficeName(), officeUpdateRequest.getShortName(), officeStatus, officeLevel, newParentOffice, address, new ArrayList<CustomFieldDto>());
}
Also used : Address(org.mifos.framework.business.util.Address) CustomFieldDto(org.mifos.dto.domain.CustomFieldDto) AddressDto(org.mifos.dto.domain.AddressDto) OfficeStatus(org.mifos.customers.office.util.helpers.OfficeStatus) OfficeLevel(org.mifos.customers.office.util.helpers.OfficeLevel)

Example 3 with OfficeLevel

use of org.mifos.customers.office.util.helpers.OfficeLevel in project head by mifos.

the class OfficeDaoHibernate method findOfficeLevelsWithConfiguration.

@SuppressWarnings("unchecked")
@Override
public OfficeLevelDto findOfficeLevelsWithConfiguration() {
    HashMap<String, Object> queryParameters = new HashMap<String, Object>();
    List<OfficeLevelEntity> officeLevelEntities = (List<OfficeLevelEntity>) genericDao.executeNamedQuery("officeLevel.getOfficeLevelsWithConfiguration", queryParameters);
    if (officeLevelEntities == null) {
        officeLevelEntities = new ArrayList<OfficeLevelEntity>();
    }
    OfficeLevelDto officeLevels = new OfficeLevelDto();
    for (OfficeLevelEntity officeLevelEntity : officeLevelEntities) {
        LookUpValueEntity lookupValue = officeLevelEntity.getLookUpValue();
        String messageText = lookupValue.getMessageText();
        if (StringUtils.isBlank(messageText)) {
            messageText = ApplicationContextProvider.getBean(MessageLookup.class).lookup(lookupValue.getPropertiesKey());
        }
        OfficeLevel level = OfficeLevel.getOfficeLevel(officeLevelEntity.getId());
        switch(level) {
            case HEADOFFICE:
                officeLevels.setHeadOfficeEnabled(officeLevelEntity.isConfigured());
                officeLevels.setHeadOfficeNameKey(messageText);
                break;
            case REGIONALOFFICE:
                officeLevels.setRegionalOfficeEnabled(officeLevelEntity.isConfigured());
                officeLevels.setRegionalOfficeNameKey(messageText);
                break;
            case SUBREGIONALOFFICE:
                officeLevels.setSubRegionalOfficeEnabled(officeLevelEntity.isConfigured());
                officeLevels.setSubRegionalOfficeNameKey(messageText);
                break;
            case AREAOFFICE:
                officeLevels.setAreaOfficeEnabled(officeLevelEntity.isConfigured());
                officeLevels.setAreaOfficeNameKey(messageText);
                break;
            case BRANCHOFFICE:
                officeLevels.setBranchOfficeEnabled(officeLevelEntity.isConfigured());
                officeLevels.setBranchOfficeNameKey(messageText);
                break;
            default:
                break;
        }
    }
    return officeLevels;
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) List(java.util.List) OfficeLevelDto(org.mifos.dto.domain.OfficeLevelDto) OfficeLevel(org.mifos.customers.office.util.helpers.OfficeLevel) OfficeLevelEntity(org.mifos.customers.office.business.OfficeLevelEntity) LookUpValueEntity(org.mifos.application.master.business.LookUpValueEntity)

Example 4 with OfficeLevel

use of org.mifos.customers.office.util.helpers.OfficeLevel in project head by mifos.

the class OfficeServiceFacadeWebTier method retrieveActiveParentOffices.

@Override
public List<OfficeDetailsDto> retrieveActiveParentOffices(Short officeLevelId) {
    OfficeLevel Level = OfficeLevel.getOfficeLevel(officeLevelId);
    try {
        List<OfficeDetailsDto> officeParents = new OfficePersistence().getActiveParents(Level);
        for (OfficeDetailsDto officeDetailsDto : officeParents) {
            String levelName = ApplicationContextProvider.getBean(MessageLookup.class).lookup(officeDetailsDto.getLevelNameKey());
            officeDetailsDto.setLevelName(levelName);
        }
        return officeParents;
    } catch (PersistenceException e) {
        throw new MifosRuntimeException(e);
    }
}
Also used : MessageLookup(org.mifos.application.master.MessageLookup) PersistenceException(org.mifos.framework.exceptions.PersistenceException) OfficePersistence(org.mifos.customers.office.persistence.OfficePersistence) OfficeDetailsDto(org.mifos.dto.domain.OfficeDetailsDto) OfficeLevel(org.mifos.customers.office.util.helpers.OfficeLevel) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Example 5 with OfficeLevel

use of org.mifos.customers.office.util.helpers.OfficeLevel 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

OfficeLevel (org.mifos.customers.office.util.helpers.OfficeLevel)6 ArrayList (java.util.ArrayList)3 MifosRuntimeException (org.mifos.core.MifosRuntimeException)3 OfficePersistence (org.mifos.customers.office.persistence.OfficePersistence)3 AddressDto (org.mifos.dto.domain.AddressDto)3 Address (org.mifos.framework.business.util.Address)3 PersistenceException (org.mifos.framework.exceptions.PersistenceException)3 MessageLookup (org.mifos.application.master.MessageLookup)2 OfficeStatus (org.mifos.customers.office.util.helpers.OfficeStatus)2 CustomFieldDto (org.mifos.dto.domain.CustomFieldDto)2 OfficeDetailsDto (org.mifos.dto.domain.OfficeDetailsDto)2 HashMap (java.util.HashMap)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1 UserContextFactory (org.mifos.accounts.servicefacade.UserContextFactory)1 LookUpValueEntity (org.mifos.application.master.business.LookUpValueEntity)1 OfficeBO (org.mifos.customers.office.business.OfficeBO)1 OfficeLevelEntity (org.mifos.customers.office.business.OfficeLevelEntity)1 OfficeException (org.mifos.customers.office.exceptions.OfficeException)1 OfficeValidationException (org.mifos.customers.office.exceptions.OfficeValidationException)1