use of org.mifos.application.master.business.LookUpLabelEntity in project head by mifos.
the class MessageLookup method setCustomLabel.
/*
* Set a custom label value that will override resource bundle values.
*
* TODO: we need to add a method for getting and/or setting a label value directly rather than having to iterate.
* Also, we don't necessarily want to reinitialize the MifosConfiguration after each update. Ultimately, it would be
* cleaner to just use a key-value lookup to implement these overrides.
*/
public void setCustomLabel(String labelKey, String value) throws PersistenceException {
// only update the value if there is a change
if (lookupLabel(labelKey).compareTo(value) != 0) {
for (LookUpEntity entity : applicationConfigurationDao.findLookupEntities()) {
if (entity.getEntityType().equals(labelKey)) {
Set<LookUpLabelEntity> labels = entity.getLookUpLabels();
for (LookUpLabelEntity label : labels) {
label.setLabelName(value);
genericDao.createOrUpdate(label);
StaticHibernateUtil.commitTransaction();
updateLookupValueInCache(labelKey, value);
}
}
}
}
}
use of org.mifos.application.master.business.LookUpLabelEntity in project head by mifos.
the class ApplicationConfigurationDaoHibernate method findLookupEntities.
@SuppressWarnings("unchecked")
@Override
public List<LookUpEntity> findLookupEntities() {
Session session = StaticHibernateUtil.getSessionTL();
List<LookUpEntity> entities = session.getNamedQuery(NamedQueryConstants.GET_ENTITIES).list();
for (LookUpEntity entity : entities) {
Set<LookUpLabelEntity> labels = entity.getLookUpLabels();
entity.getEntityType();
for (LookUpLabelEntity label : labels) {
label.getLabelText();
label.getLocaleId();
}
}
return entities;
}
use of org.mifos.application.master.business.LookUpLabelEntity in project head by mifos.
the class ApplicationConfigurationPersistenceIntegrationTest method testGetLookupEntities.
/*
* Check that we can can retrieve LookupEntities and enforce the conventions: LookupEntity names cannot contain
* whitespace LookupEntities should not have more than 1 label
*/
@Test
public void testGetLookupEntities() {
List<LookUpEntity> entities = applicationConfigurationDao.findLookupEntities();
Assert.assertNotNull(entities);
// Enforce that no entity names contain whitespace
for (LookUpEntity entity : entities) {
Assert.assertEquals(StringUtils.deleteWhitespace(entity.getEntityType()), entity.getEntityType());
Set<LookUpLabelEntity> labels = entity.getLookUpLabels();
// Enforce that each entity has 0 or 1 labels and not more
Assert.assertTrue(labels.size() <= 1);
for (LookUpLabelEntity label : labels) {
// if (entity.getEntityType().equals("Client")) {
// Assert.assertEquals("Client", label.getLabelText());
// }
}
}
}
Aggregations