use of com.agiletec.aps.util.ApsProperties in project entando-core by entando.
the class TestNavigatorWidgetConfigAction method testFailureAddExpression_2.
public void testFailureAddExpression_2() throws Throwable {
Map<String, String> params = new HashMap<String, String>();
params.put("pageCode", "pagina_2");
params.put("frame", "3");
params.put("widgetTypeCode", "leftmenu");
params.put("navSpec", "parent.subtree(2)+abs(1).subtree(2)+current");
params.put("specId", "3");
params.put("specSuperLevel", "-2");
String result = this.executeAddExpression("admin", params);
assertEquals(Action.INPUT, result);
ActionSupport action = this.getAction();
assertEquals(1, action.getActionErrors().size());
NavigatorWidgetConfigAction navAction = (NavigatorWidgetConfigAction) action;
Widget widget = navAction.getWidget();
assertNotNull(widget);
ApsProperties props = widget.getConfig();
assertEquals(0, props.size());
assertEquals("parent.subtree(2)+abs(1).subtree(2)+current", navAction.getNavSpec());
assertEquals(3, navAction.getExpressions().size());
}
use of com.agiletec.aps.util.ApsProperties in project entando-core by entando.
the class I18nDAO method loadLabelGroups.
/**
* Carica la mappa che contiene tutte le label in tutte le lingue.
* @return La mappa contenente tutte le label.
*/
public Map<String, ApsProperties> loadLabelGroups() {
Connection conn = null;
Statement stat = null;
ResultSet res = null;
Map<String, ApsProperties> labels = null;
try {
conn = this.getConnection();
stat = conn.createStatement();
res = stat.executeQuery(LOAD_ALL_LABELS);
labels = this.createLabels(res);
} catch (Throwable t) {
_logger.error("Error loading labels", t);
throw new RuntimeException("Error loading labels", t);
// processDaoException(t, "Error loading label", "loadLabelMap");
} finally {
closeDaoResources(res, stat, conn);
}
return labels;
}
use of com.agiletec.aps.util.ApsProperties in project entando-core by entando.
the class I18nManager method renderLabel.
@Override
public String renderLabel(String key, String renderingLang, boolean keyIfEmpty) throws ApsSystemException {
String label = null;
ApsProperties labelsProp = this.getLabelGroup(key);
if (labelsProp != null) {
label = labelsProp.getProperty(renderingLang);
if (StringUtils.isEmpty(label)) {
label = labelsProp.getProperty(this.getDefaultLang());
}
}
if (keyIfEmpty && StringUtils.isEmpty(label)) {
label = key;
}
return label;
}
use of com.agiletec.aps.util.ApsProperties in project entando-core by entando.
the class I18nManager method getLabel.
/**
* Restituisce una label in base alla chiave ed alla lingua specificata.
* @param key La chiave
* @param langCode Il codice della lingua.
* @return La label richiesta.
* @throws ApsSystemException
*/
@Override
public String getLabel(String key, String langCode) throws ApsSystemException {
String label = null;
ApsProperties labelsProp = (ApsProperties) this.getCacheWrapper().getLabelGroups().get(key);
if (labelsProp != null) {
label = labelsProp.getProperty(langCode);
}
return label;
}
use of com.agiletec.aps.util.ApsProperties in project entando-core by entando.
the class I18nManager method searchLabelsKey.
/**
* Restituisce la lista di chiavi di gruppi di labels
* in base ai parametri segbalati.
* @param insertedText Il testo tramite il quale effettuare la ricerca.
* @param doSearchByKey Specifica se effettuare la ricerca sulle chiavi,
* in base al testo inserito.
* @param doSearchByLang Specifica se effettuare la ricerca
* sul testo di una lingua, in base al testo inserito.
* @param langCode Specifica la lingua della label sulla quale effettuare
* la ricerca, in base al testo inserito.
* @return La lista di chiavi di gruppi di labels
* in base ai parametri segbalati.
*/
@Override
public List<String> searchLabelsKey(String insertedText, boolean doSearchByKey, boolean doSearchByLang, String langCode) {
List<String> keys = new ArrayList<String>();
Pattern pattern = Pattern.compile(insertedText, Pattern.CASE_INSENSITIVE + Pattern.LITERAL);
Matcher matcher = pattern.matcher("");
List<String> allKeys = new ArrayList<String>(this.getLabelGroups().keySet());
for (int i = 0; i < allKeys.size(); i++) {
String key = allKeys.get(i);
ApsProperties properies = (ApsProperties) this.getLabelGroups().get(key);
if (!doSearchByKey && !doSearchByLang) {
matcher = matcher.reset(key);
if (matcher.find()) {
keys.add(key);
} else {
Enumeration<Object> langKeys = properies.keys();
while (langKeys.hasMoreElements()) {
String lang = (String) langKeys.nextElement();
String target = properies.getProperty(lang);
if (this.labelMatch(target, matcher)) {
keys.add(key);
break;
}
}
}
} else if (doSearchByKey && !doSearchByLang) {
matcher = matcher.reset(key);
if (matcher.find()) {
keys.add(key);
}
} else if (!doSearchByKey && doSearchByLang) {
String target = properies.getProperty(langCode);
if (this.labelMatch(target, matcher)) {
keys.add(key);
}
}
}
return keys;
}
Aggregations