Search in sources :

Example 1 with LookUpValueLocaleEntity

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;
            }
        }
    }
}
Also used : LookUpValueLocaleEntity(org.mifos.application.master.business.LookUpValueLocaleEntity) PersistenceException(org.mifos.framework.exceptions.PersistenceException) ConfigurationException(org.mifos.config.exceptions.ConfigurationException)

Example 2 with LookUpValueLocaleEntity

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());
}
Also used : LookUpEntity(org.mifos.application.master.business.LookUpEntity) LookUpValueLocaleEntity(org.mifos.application.master.business.LookUpValueLocaleEntity) LookUpValueEntity(org.mifos.application.master.business.LookUpValueEntity) Test(org.junit.Test)

Example 3 with LookUpValueLocaleEntity

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());
        }
    }
}
Also used : MasterDataEntity(org.mifos.application.master.business.MasterDataEntity) AccountStateEntity(org.mifos.accounts.business.AccountStateEntity) LookUpValueLocaleEntity(org.mifos.application.master.business.LookUpValueLocaleEntity) Test(org.junit.Test)

Example 4 with LookUpValueLocaleEntity

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);
}
Also used : ActivityEntity(org.mifos.security.rolesandpermission.business.ActivityEntity) LookUpValueLocaleEntity(org.mifos.application.master.business.LookUpValueLocaleEntity) Test(org.junit.Test)

Example 5 with LookUpValueLocaleEntity

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;
}
Also used : LookUpEntity(org.mifos.application.master.business.LookUpEntity) MessageLookup(org.mifos.application.master.MessageLookup) LookUpValueLocaleEntity(org.mifos.application.master.business.LookUpValueLocaleEntity) LookUpValueEntity(org.mifos.application.master.business.LookUpValueEntity)

Aggregations

LookUpValueLocaleEntity (org.mifos.application.master.business.LookUpValueLocaleEntity)9 LookUpValueEntity (org.mifos.application.master.business.LookUpValueEntity)4 Test (org.junit.Test)3 MessageLookup (org.mifos.application.master.MessageLookup)2 LookUpEntity (org.mifos.application.master.business.LookUpEntity)2 ActivityEntity (org.mifos.security.rolesandpermission.business.ActivityEntity)2 Session (org.hibernate.Session)1 AccountStateEntity (org.mifos.accounts.business.AccountStateEntity)1 MasterDataEntity (org.mifos.application.master.business.MasterDataEntity)1 ConfigurationException (org.mifos.config.exceptions.ConfigurationException)1 PersistenceException (org.mifos.framework.exceptions.PersistenceException)1