use of org.mifos.application.master.business.LookUpValueEntity in project head by mifos.
the class LegacyMasterDao method deleteValueListElement.
/**
* This method is intended to delete a single LookUpValueEntity and all its
* associated LookUpValueLocaleEntity objects. The primary purpose is for
* test script cleanup, since deletion of LookUpValueEntity elements is not
* allowed in the main app.
*
* It would be nicer for this to operate on objects rather than ids, but it
* is a first step that works.
*/
public void deleteValueListElement(final Integer lookupValueEntityId) throws PersistenceException {
LookUpValueEntity lookUpValueEntity = getPersistentObject(LookUpValueEntity.class, lookupValueEntityId);
delete(lookUpValueEntity);
ApplicationContextProvider.getBean(MessageLookup.class).deleteKey(lookUpValueEntity.getLookUpName());
}
use of org.mifos.application.master.business.LookUpValueEntity in project head by mifos.
the class ApplicationConfigurationDaoHibernate method findLookupValues.
@Override
@SuppressWarnings("unchecked")
public List<LookUpValueEntity> findLookupValues() {
List<LookUpValueEntity> values = null;
Session session = StaticHibernateUtil.getSessionTL();
values = session.getNamedQuery(NamedQueryConstants.GET_LOOKUPVALUES).list();
if (values != null) {
for (LookUpValueEntity value : values) {
Set<LookUpValueLocaleEntity> localeValues = value.getLookUpValueLocales();
value.getLookUpName();
if (localeValues != null) {
for (LookUpValueLocaleEntity locale : localeValues) {
locale.getLookUpValue();
locale.getLocaleId();
}
}
}
}
return values;
}
use of org.mifos.application.master.business.LookUpValueEntity 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.application.master.business.LookUpValueEntity 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.application.master.business.LookUpValueEntity in project head by mifos.
the class FeeActionStrutsTest method testSuccessfulManage_RateFee.
@Test
public void testSuccessfulManage_RateFee() throws Exception {
fee = TestObjectFactory.createOneTimeRateFee("One Time Fee", FeeCategory.ALLCUSTOMERS, 12.34, FeeFormula.AMOUNT, FeePayment.UPFRONT, null);
LookUpValueEntity lookUpValue = new LookUpValueEntity();
fee.getFeeFrequency().getFeeFrequencyType().setLookUpValue(lookUpValue);
fee.getFeeFrequency().getFeePayment().setLookUpValue(lookUpValue);
((RateFeeBO) fee).getFeeFormula().setLookUpValue(lookUpValue);
String feeId = fee.getFeeId().toString();
request.setAttribute("feeModel", TestObjectFactory.getRateBasedFee(feeId, "StatusID", 12.34, "1"));
request.setAttribute(Constants.CURRENTFLOWKEY, flowKey);
SessionUtils.setAttribute(Constants.BUSINESS_KEY, fee, request);
setRequestPathInfo("/feeaction.do");
addRequestParameter("method", "manage");
addRequestParameter(Constants.CURRENTFLOWKEY, flowKey);
addRequestParameter("feeId", feeId);
actionPerform();
verifyNoActionErrors();
verifyNoActionMessages();
verifyForward(ActionForwards.manage_success.toString());
FeeActionForm actionForm = (FeeActionForm) request.getSession().getAttribute("feeactionform");
Assert.assertEquals("12.34", actionForm.getRate());
Assert.assertEquals("1", actionForm.getFeeFormula());
Assert.assertNull(actionForm.getAmount());
Assert.assertEquals("The size of master data for status", 2, ((List<MasterDataEntity>) SessionUtils.getAttribute(FeeConstants.STATUSLIST, request)).size());
}
Aggregations