use of com.agiletec.aps.system.services.lang.Lang in project entando-core by entando.
the class ListAttribute method getStatus.
@Override
public Status getStatus() {
Lang defaultLang = super.getLangManager().getDefaultLang();
List<AttributeInterface> attributeList = this.getAttributeList(defaultLang.getCode());
boolean valued = (null != attributeList && !attributeList.isEmpty());
if (valued) {
return Status.VALUED;
} else {
return Status.EMPTY;
}
}
use of com.agiletec.aps.system.services.lang.Lang in project entando-core by entando.
the class TextAttribute method getSearchInfos.
@Override
public List<AttributeSearchInfo> getSearchInfos(List<Lang> systemLangs) {
List<AttributeSearchInfo> infos = null;
if (null != this.getTextMap() && this.getTextMap().size() > 0) {
infos = new ArrayList<>();
for (int i = 0; i < systemLangs.size(); i++) {
Lang lang = systemLangs.get(i);
String text = this.getTextMap().get(lang.getCode());
if (null == text) {
text = this.getTextMap().get(this.getDefaultLangCode());
}
if (null != text) {
AttributeSearchInfo info = null;
if (text.length() >= 255) {
info = new AttributeSearchInfo(text.substring(0, 254), null, null, lang.getCode());
} else {
info = new AttributeSearchInfo(text, null, null, lang.getCode());
}
infos.add(info);
}
}
}
return infos;
}
use of com.agiletec.aps.system.services.lang.Lang in project entando-core by entando.
the class OgnlValidationRule method createContextForExpressionValidation.
protected OgnlContext createContextForExpressionValidation(AttributeInterface attribute, AttributeTracer tracer, ILangManager langManager) {
OgnlContext context = new OgnlContext();
Map<String, Lang> langs = new HashMap<>();
List<Lang> langList = langManager.getLangs();
for (int i = 0; i < langList.size(); i++) {
Lang lang = langList.get(i);
langs.put(lang.getCode(), lang);
}
context.put("langs", langs);
context.put("attribute", attribute);
context.put("entity", attribute.getParentEntity());
if (tracer.isCompositeElement()) {
context.put("parent", tracer.getParentAttribute());
} else {
if (tracer.isListElement() || tracer.isMonoListElement()) {
context.put("parent", attribute.getParentEntity().getAttribute(attribute.getName()));
context.put("index", tracer.getListIndex());
}
if (tracer.isListElement()) {
context.put("listLang", tracer.getListLang());
}
}
return context;
}
use of com.agiletec.aps.system.services.lang.Lang in project entando-core by entando.
the class TextAttributeValidationRules method validate.
@Override
public List<AttributeFieldError> validate(AttributeInterface attribute, AttributeTracer tracer, ILangManager langManager) {
List<AttributeFieldError> errors = super.validate(attribute, tracer, langManager);
if (this.isEmpty()) {
return errors;
}
try {
List<Lang> langs = langManager.getLangs();
for (int i = 0; i < langs.size(); i++) {
Lang lang = langs.get(i);
if (!attribute.isMultilingual() && !lang.isDefault())
continue;
AttributeTracer textTracer = (AttributeTracer) tracer.clone();
textTracer.setLang(lang);
this.checkTextLengths(attribute, textTracer, lang, errors);
this.checkRegExp(attribute, textTracer, lang, errors);
}
} catch (Throwable t) {
// ApsSystemUtils.logThrowable(t, this, "validate");
_logger.error("Error validating text attribute", t);
throw new RuntimeException("Error validating text attribute", t);
}
return errors;
}
use of com.agiletec.aps.system.services.lang.Lang in project entando-core by entando.
the class BaseEntityRenderer method convertSpecialCharacters.
protected List<TextAttributeCharReplaceInfo> convertSpecialCharacters(IApsEntity entity, String langCode) {
List<TextAttributeCharReplaceInfo> conversions = new ArrayList<TextAttributeCharReplaceInfo>();
Lang defaultLang = this.getLangManager().getDefaultLang();
EntityAttributeIterator attributeIter = new EntityAttributeIterator(entity);
while (attributeIter.hasNext()) {
AttributeInterface currAttribute = (AttributeInterface) attributeIter.next();
if (currAttribute instanceof ITextAttribute) {
String attributeLangCode = langCode;
ITextAttribute renderizable = (ITextAttribute) currAttribute;
if (renderizable.needToConvertSpecialCharacter()) {
String textToConvert = renderizable.getTextForLang(attributeLangCode);
if (null == textToConvert || textToConvert.trim().length() == 0) {
attributeLangCode = defaultLang.getCode();
textToConvert = renderizable.getTextForLang(attributeLangCode);
}
if (null != textToConvert && textToConvert.trim().length() > 0) {
conversions.add(new TextAttributeCharReplaceInfo(renderizable, textToConvert, attributeLangCode));
String convertedText = StringEscapeUtils.escapeHtml(textToConvert);
renderizable.setText(convertedText, attributeLangCode);
}
}
}
}
return conversions;
}
Aggregations