use of org.mifos.customers.office.business.OfficeLevelEntity 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.business.OfficeLevelEntity in project head by mifos.
the class AuditConfiguration method fetchMasterData.
private void fetchMasterData(String entityName, Short localeId, String classPath) throws SystemException {
Class clazz = null;
try {
clazz = Thread.currentThread().getContextClassLoader().loadClass(classPath);
} catch (ClassNotFoundException e) {
throw new SystemException(e);
}
List<MasterDataEntity> masterDataList = legacyMasterDao.findMasterDataEntities(clazz);
for (MasterDataEntity masterDataEntity : masterDataList) {
if (masterDataEntity instanceof PersonnelStatusEntity) {
String name = ApplicationContextProvider.getBean(MessageLookup.class).lookup(masterDataEntity.getLookUpValue());
((PersonnelStatusEntity) masterDataEntity).setName(name);
}
if (masterDataEntity instanceof PersonnelLevelEntity) {
String name = ApplicationContextProvider.getBean(MessageLookup.class).lookup(masterDataEntity.getLookUpValue());
((PersonnelLevelEntity) masterDataEntity).setName(name);
}
if (masterDataEntity instanceof OfficeLevelEntity) {
String name = ApplicationContextProvider.getBean(MessageLookup.class).lookup(masterDataEntity.getLookUpValue());
((OfficeLevelEntity) masterDataEntity).setName(name);
}
if (masterDataEntity instanceof OfficeStatusEntity) {
String name = ApplicationContextProvider.getBean(MessageLookup.class).lookup(masterDataEntity.getLookUpValue());
((OfficeStatusEntity) masterDataEntity).setName(name);
}
valueMap.put(masterDataEntity.getId().toString(), masterDataEntity.getName());
}
}
use of org.mifos.customers.office.business.OfficeLevelEntity in project head by mifos.
the class OfficeHierarchyServiceImpl method updateApplicationLabels.
@Override
public void updateApplicationLabels(List<OfficeLevelEntity> changedOfficeLabels, List<LookUpEntity> lookupEntities, List<GracePeriodTypeEntity> gracePeriods, List<LookUpValueEntity> accountStatuses) {
try {
transactionHelper.startTransaction();
for (OfficeLevelEntity entity : changedOfficeLabels) {
officeDao.save(entity);
LookUpValueEntity lookupValue = entity.getLookUpValue();
String messageText = lookupValue.getMessageText();
if (StringUtils.isBlank(messageText)) {
messageText = ApplicationContextProvider.getBean(MessageLookup.class).lookup(lookupValue.getPropertiesKey());
}
ApplicationContextProvider.getBean(MessageLookup.class).updateLookupValueInCache(entity.getLookUpValue().getLookUpName(), messageText);
}
for (GracePeriodTypeEntity entity : gracePeriods) {
applicationConfigurationDao.save(entity);
LookUpValueEntity lookupValue = entity.getLookUpValue();
String messageText = lookupValue.getMessageText();
if (StringUtils.isBlank(messageText)) {
messageText = ApplicationContextProvider.getBean(MessageLookup.class).lookup(lookupValue.getPropertiesKey());
}
ApplicationContextProvider.getBean(MessageLookup.class).updateLookupValueInCache(entity.getLookUpValue().getLookUpName(), messageText);
}
for (LookUpEntity entity : lookupEntities) {
applicationConfigurationDao.save(entity);
ApplicationContextProvider.getBean(MessageLookup.class).updateLookupValueInCache(entity.getEntityType(), entity.findLabel());
}
for (LookUpValueEntity entity : accountStatuses) {
applicationConfigurationDao.save(entity);
}
transactionHelper.commitTransaction();
if (!accountStatuses.isEmpty()) {
MenuRepository.getInstance().removeMenuForAllLocale();
}
} catch (BusinessRuleException e) {
transactionHelper.rollbackTransaction();
throw e;
} catch (Exception e) {
transactionHelper.rollbackTransaction();
throw new MifosRuntimeException(e);
} finally {
transactionHelper.closeSession();
}
}
use of org.mifos.customers.office.business.OfficeLevelEntity in project head by mifos.
the class OfficeHierarchyServiceImpl method updateOfficeHierarchyConfiguration.
@Override
public void updateOfficeHierarchyConfiguration(UpdateConfiguredOfficeLevelRequest updateRequest) {
try {
transactionHelper.startTransaction();
OfficeLevelDto existingOfficeLevels = officeDao.findOfficeLevelsWithConfiguration();
if (updateRequest.isRegionalOfficeEnabled() != existingOfficeLevels.isRegionalOfficeEnabled()) {
OfficeLevelEntity entity = officeDao.retrieveOfficeLevel(OfficeLevel.REGIONALOFFICE);
entity.updateTo(updateRequest.isRegionalOfficeEnabled());
if (existingOfficeLevels.isRegionalOfficeEnabled()) {
officeDao.validateNoOfficesExistGivenOfficeLevel(OfficeLevel.REGIONALOFFICE);
}
this.officeDao.save(entity);
transactionHelper.flushAndClearSession();
}
if (updateRequest.isSubRegionalOfficeEnabled() != existingOfficeLevels.isSubRegionalOfficeEnabled()) {
OfficeLevelEntity entity = officeDao.retrieveOfficeLevel(OfficeLevel.SUBREGIONALOFFICE);
entity.updateTo(updateRequest.isSubRegionalOfficeEnabled());
if (existingOfficeLevels.isSubRegionalOfficeEnabled()) {
officeDao.validateNoOfficesExistGivenOfficeLevel(OfficeLevel.SUBREGIONALOFFICE);
}
this.officeDao.save(entity);
transactionHelper.flushAndClearSession();
}
if (updateRequest.isAreaOfficeEnabled() != existingOfficeLevels.isAreaOfficeEnabled()) {
OfficeLevelEntity entity = officeDao.retrieveOfficeLevel(OfficeLevel.AREAOFFICE);
entity.updateTo(updateRequest.isAreaOfficeEnabled());
if (existingOfficeLevels.isSubRegionalOfficeEnabled()) {
officeDao.validateNoOfficesExistGivenOfficeLevel(OfficeLevel.AREAOFFICE);
}
this.officeDao.save(entity);
transactionHelper.flushAndClearSession();
}
transactionHelper.commitTransaction();
} catch (BusinessRuleException e) {
transactionHelper.rollbackTransaction();
throw e;
} catch (Exception e) {
transactionHelper.rollbackTransaction();
throw new MifosRuntimeException(e);
} finally {
transactionHelper.closeSession();
}
}
use of org.mifos.customers.office.business.OfficeLevelEntity in project head by mifos.
the class OfficeDaoHibernateIntegrationTest method shouldRetrieveOfficeLevelById.
@Test
public void shouldRetrieveOfficeLevelById() throws Exception {
OfficeLevelEntity officeLevel = officeDao.retrieveOfficeLevel(OfficeLevel.AREAOFFICE);
// verification
assertThat(officeLevel.isConfigured(), is(true));
}
Aggregations