Search in sources :

Example 1 with LabelKey

use of org.mifos.config.util.helpers.LabelKey in project head by mifos.

the class MessageLookup method updateLookupValueInCache.

public void updateLookupValueInCache(String lookupKey, String newValue) {
    synchronized (labelCache) {
        LabelKey key = new LabelKey(lookupKey, getLocaleId());
        if (labelCache.containsKey(key)) {
            labelCache.remove(key);
            labelCache.put(key, newValue);
        } else {
            labelCache.put(key, newValue);
        }
    }
}
Also used : LabelKey(org.mifos.config.util.helpers.LabelKey)

Example 2 with LabelKey

use of org.mifos.config.util.helpers.LabelKey in project head by mifos.

the class MessageLookup method updateLabelKey.

public void updateLabelKey(String keyString, String newLabelValue, Short localeId) {
    synchronized (labelCache) {
        LabelKey key = new LabelKey(keyString, localeId);
        if (labelCache.containsKey(key)) {
            labelCache.remove(key);
            labelCache.put(key, newLabelValue);
        } else {
            labelCache.put(key, newLabelValue);
        }
    }
}
Also used : LabelKey(org.mifos.config.util.helpers.LabelKey)

Example 3 with LabelKey

use of org.mifos.config.util.helpers.LabelKey in project head by mifos.

the class MessageLookup method updateLabelCache.

public void updateLabelCache() {
    List<LookUpValueEntity> lookupValueEntities = applicationConfigurationDao.findLookupValues();
    for (LookUpValueEntity lookupValueEntity : lookupValueEntities) {
        String keyString = lookupValueEntity.getPropertiesKey();
        if (keyString == null) {
            throw new IllegalStateException("Key is empty");
        }
        String messageText = lookupValueEntity.getMessageText();
        if (StringUtils.isBlank(messageText)) {
            messageText = lookup(keyString);
        }
        labelCache.put(new LabelKey(keyString, getLocaleId()), messageText);
    }
}
Also used : LabelKey(org.mifos.config.util.helpers.LabelKey) LookUpValueEntity(org.mifos.application.master.business.LookUpValueEntity)

Example 4 with LabelKey

use of org.mifos.config.util.helpers.LabelKey in project head by mifos.

the class ConfigurationIntegrationTest method testLabelKey.

/*
     * Will be uncommented when spanish values will be entered in master data.
     * @Test
    public void testGetLabelValueSpanish(){Assert.assertEquals("Entrada agranel
     * ",MifosConfiguration.getInstance().getLabelValue(ConfigurationConstants.BULKENTRY,(short)2))
     * ; }
     */
@Test
public void testLabelKey() {
    LabelKey labelKey = new LabelKey("key", (short) 1);
    Assert.assertEquals("[localeId=1][key=key]", labelKey.toString());
    Assert.assertEquals(false, labelKey.equals(null));
    LabelKey labelKeyToCompare = new LabelKey("key", (short) 2);
    Assert.assertEquals(false, labelKey.equals(labelKeyToCompare));
}
Also used : LabelKey(org.mifos.config.util.helpers.LabelKey) Test(org.junit.Test)

Aggregations

LabelKey (org.mifos.config.util.helpers.LabelKey)4 Test (org.junit.Test)1 LookUpValueEntity (org.mifos.application.master.business.LookUpValueEntity)1