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);
}
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>());
}
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;
}
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);
}
}
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);
}
}
Aggregations