use of com.developmentontheedge.be5.metadata.model.EntityLocalizations in project be5 by DevelopmentOnTheEdge.
the class MetaImpl method getLocalization.
private String getLocalization(Project project, String language, String entity, Predicate<LocalizationElement> accept) {
for (Module module : project.getModulesAndApplication()) {
Localizations localizations = module.getLocalizations();
LanguageLocalizations languageLocalizations = localizations.get(language);
if (languageLocalizations == null)
continue;
EntityLocalizations entityLocalizations = languageLocalizations.get(entity);
if (entityLocalizations == null)
continue;
for (LocalizationElement element : entityLocalizations.elements()) if (accept.test(element))
return element.getValue();
}
return "";
}
use of com.developmentontheedge.be5.metadata.model.EntityLocalizations in project be5 by DevelopmentOnTheEdge.
the class EntityLocalizationsTest method testLocalizations.
@Test
public void testLocalizations() {
Project proj = new Project("test");
proj.getApplication().getLocalizations().addLocalization("de", "entity", Arrays.asList("@AllQueries", "topic"), "Hello", "Guten Tag");
Entity entity = new Entity("entity", proj.getApplication(), EntityType.TABLE);
DataElementUtils.save(entity);
DataElementUtils.save(new Query("testQuery", entity));
DataElementUtils.save(new Query("testQuery2", entity));
EntityLocalizations el = proj.getApplication().getLocalizations().get("de").get("entity");
Set<LocalizationRow> expected = StreamEx.of("testQuery", "testQuery2", "topic").map(topic -> new EntityLocalizations.LocalizationRow(topic, "Hello", "Guten Tag")).toSet();
assertEquals(expected, el.getRawRows());
assertEquals(expected, el.getRows());
el.remove("Hello", Collections.singleton("topic"));
expected = StreamEx.of("testQuery", "testQuery2").map(topic -> new EntityLocalizations.LocalizationRow(topic, "Hello", "Guten Tag")).toSet();
assertEquals(expected, el.getRawRows());
assertEquals(expected, el.getRows());
}
Aggregations