use of org.mifos.application.master.business.LookUpValueLocaleEntity in project head by mifos.
the class MessageLookup method updateLookupValue.
/**
* @deprecated - don't use from pojo domain model for updating entities lookup values
*
* @see OfficeLevelEntity#update(String)
*/
@Deprecated
public void updateLookupValue(LookUpValueEntity lookupValueEntity, String newValue) {
Set<LookUpValueLocaleEntity> lookUpValueLocales = lookupValueEntity.getLookUpValueLocales();
if ((lookUpValueLocales != null) && StringUtils.isNotBlank(newValue)) {
for (LookUpValueLocaleEntity entity : lookUpValueLocales) {
if (entity.getLookUpId().equals(lookupValueEntity.getLookUpId()) && (entity.getLookUpValue() == null || !entity.getLookUpValue().equals(newValue))) {
entity.setLookUpValue(newValue);
try {
legacyMasterDao.createOrUpdate(entity);
} catch (Exception ex) {
throw new RuntimeException(ex.getMessage());
}
updateLookupValueInCache(lookupValueEntity.getLookUpName(), newValue);
break;
}
}
}
}
use of org.mifos.application.master.business.LookUpValueLocaleEntity in project head by mifos.
the class AccountActionEntityIntegrationTest method testBasics.
@Test
public void testBasics() throws Exception {
AccountActionEntity action = (AccountActionEntity) session.get(AccountActionEntity.class, AccountActionTypes.PAYMENT.getValue());
LookUpValueEntity lookUpValue = action.getLookUpValue();
Assert.assertEquals("AccountAction-Payment", lookUpValue.getLookUpName());
Assert.assertEquals(new Integer(191), lookUpValue.getLookUpId());
LookUpEntity lookUpEntity = lookUpValue.getLookUpEntity();
Assert.assertEquals(LookUpEntity.ACCOUNT_ACTION, lookUpEntity.getEntityId().shortValue());
Assert.assertEquals("AccountAction", lookUpEntity.getEntityType());
Set<LookUpValueLocaleEntity> valueLocales = lookUpValue.getLookUpValueLocales();
Assert.assertEquals(1, valueLocales.size());
LookUpValueLocaleEntity valueLocale = valueLocales.iterator().next();
Assert.assertEquals(1, (int) valueLocale.getLocaleId());
Assert.assertEquals("Payment", ApplicationContextProvider.getBean(MessageLookup.class).lookup(lookUpValue));
Assert.assertEquals("Payment", action.getName());
}
use of org.mifos.application.master.business.LookUpValueLocaleEntity in project head by mifos.
the class LegacyMasterDaoIntegrationTest method testRetrieveMasterDataEntity.
@Test
public void testRetrieveMasterDataEntity() throws Exception {
List<AccountStateEntity> masterDataList = legacyMasterDao.findMasterDataEntities(AccountStateEntity.class);
Assert.assertEquals(18, masterDataList.size());
for (MasterDataEntity masterDataEntity : masterDataList) {
for (LookUpValueLocaleEntity lookUpValueLocaleEntity : masterDataEntity.getLookUpValue().getLookUpValueLocales()) {
Assert.assertEquals(Short.valueOf("1"), lookUpValueLocaleEntity.getLocaleId());
}
}
}
use of org.mifos.application.master.business.LookUpValueLocaleEntity in project head by mifos.
the class LegacyRolesPermissionsDaoIntegrationTest method testShouldSuccessWhenChangeActivityMessage.
@Test
public void testShouldSuccessWhenChangeActivityMessage() throws Exception {
ActivityEntity activityEntity = legacyRolesPermissionsDao.getPersistentObject(ActivityEntity.class, Short.valueOf((short) 3));
Integer lookUpId = activityEntity.getActivityNameLookupValues().getLookUpId();
Assert.assertEquals(373, lookUpId.intValue());
short localeId = Localization.ENGLISH_LOCALE_ID;
LookUpValueLocaleEntity lookUpValueLocaleEntity = legacyMasterDao.retrieveOneLookUpValueLocaleEntity(localeId, lookUpId.intValue());
Assert.assertNull(lookUpValueLocaleEntity.getLookUpValue());
legacyRolesPermissionsDao.changeActivityMessage((short) 3, localeId, "wahaha");
lookUpValueLocaleEntity = legacyMasterDao.retrieveOneLookUpValueLocaleEntity(localeId, lookUpId.intValue());
Assert.assertEquals("wahaha", lookUpValueLocaleEntity.getLookUpValue());
legacyRolesPermissionsDao.changeActivityMessage((short) 3, localeId, null);
}
use of org.mifos.application.master.business.LookUpValueLocaleEntity in project head by mifos.
the class LegacyMasterDao method addValueListElementForLocale.
/**
* Create a new list element for a single locale.
*
* It would be nicer for this to operate on objects rather than ids, but it
* is a first step that works.
*/
public LookUpValueEntity addValueListElementForLocale(final Short lookupEnityId, final String newElementText, final String lookUpName) throws PersistenceException {
LookUpEntity lookUpEntity = getPersistentObject(LookUpEntity.class, lookupEnityId);
LookUpValueEntity lookUpValueEntity = new LookUpValueEntity();
lookUpValueEntity.setLookUpEntity(lookUpEntity);
lookUpValueEntity.setLookUpName(lookUpName);
createOrUpdate(lookUpValueEntity);
LookUpValueLocaleEntity lookUpValueLocaleEntity = new LookUpValueLocaleEntity();
lookUpValueLocaleEntity.setLocaleId(Localization.ENGLISH_LOCALE_ID);
lookUpValueLocaleEntity.setLookUpValue(newElementText);
lookUpValueLocaleEntity.setLookUpId(lookUpValueEntity.getLookUpId());
createOrUpdate(lookUpValueLocaleEntity);
// MifosConfiguration.getInstance().updateKey(lookUpValueEntity,
// newElementText);
ApplicationContextProvider.getBean(MessageLookup.class).updateLookupValueInCache(lookUpValueEntity, newElementText);
return lookUpValueEntity;
}
Aggregations