use of com.agiletec.aps.system.services.lang.Lang in project entando-core by entando.
the class IndexerDAO method createDocument.
/**
* Crea un oggetto Document pronto per l'indicizzazione da un oggetto Content.
* @param entity Il contenuto dal quale ricavare il Document.
* @return L'oggetto Document ricavato dal contenuto.
* @throws ApsSystemException In caso di errore
*/
protected Document createDocument(IApsEntity entity) throws ApsSystemException {
Document document = new Document();
document.add(new StringField(CONTENT_ID_FIELD_NAME, entity.getId(), Field.Store.YES));
document.add(new TextField(CONTENT_TYPE_FIELD_NAME, entity.getTypeCode(), Field.Store.YES));
document.add(new StringField(CONTENT_GROUP_FIELD_NAME, entity.getMainGroup(), Field.Store.YES));
Iterator<String> iterGroups = entity.getGroups().iterator();
while (iterGroups.hasNext()) {
String groupName = (String) iterGroups.next();
document.add(new StringField(CONTENT_GROUP_FIELD_NAME, groupName, Field.Store.YES));
}
try {
EntityAttributeIterator attributesIter = new EntityAttributeIterator(entity);
while (attributesIter.hasNext()) {
AttributeInterface currentAttribute = (AttributeInterface) attributesIter.next();
List<Lang> langs = this.getLangManager().getLangs();
for (int i = 0; i < langs.size(); i++) {
Lang currentLang = (Lang) langs.get(i);
this.indexAttribute(document, currentAttribute, currentLang);
}
}
List<Category> categories = entity.getCategories();
if (null != categories && !categories.isEmpty()) {
for (int i = 0; i < categories.size(); i++) {
Category category = categories.get(i);
this.indexCategory(document, category);
}
}
} catch (Throwable t) {
_logger.error("Error creating document", t);
throw new ApsSystemException("Error creating document", t);
}
return document;
}
use of com.agiletec.aps.system.services.lang.Lang in project entando-core by entando.
the class IndexerDAO method indexAttribute.
private void indexAttribute(Document document, AttributeInterface attribute, Lang lang) throws ApsSystemException {
attribute.setRenderingLang(lang.getCode());
if (attribute instanceof IndexableAttributeInterface) {
String valueToIndex = ((IndexableAttributeInterface) attribute).getIndexeableFieldValue();
String indexingType = attribute.getIndexingType();
String fieldName = lang.getCode();
if (attribute instanceof ResourceAttributeInterface) {
fieldName += IIndexerDAO.ATTACHMENT_FIELD_SUFFIX;
}
if (null != indexingType && IndexableAttributeInterface.INDEXING_TYPE_UNSTORED.equalsIgnoreCase(indexingType)) {
document.add(new TextField(fieldName, valueToIndex, Field.Store.NO));
}
if (null != indexingType && IndexableAttributeInterface.INDEXING_TYPE_TEXT.equalsIgnoreCase(indexingType)) {
document.add(new TextField(fieldName, valueToIndex, Field.Store.YES));
}
}
if (attribute.isSearchable()) {
List<Lang> langs = new ArrayList<Lang>();
langs.add(lang);
AttributeTracer tracer = new AttributeTracer();
tracer.setLang(lang);
String name = tracer.getFormFieldName(attribute);
List<AttributeSearchInfo> searchInfos = attribute.getSearchInfos(langs);
if (null != searchInfos) {
for (int i = 0; i < searchInfos.size(); i++) {
AttributeSearchInfo info = searchInfos.get(i);
Field field = null;
if (null != info.getDate()) {
field = new TextField(name, DateTools.timeToString(info.getDate().getTime(), DateTools.Resolution.MINUTE), Field.Store.YES);
} else if (null != info.getBigDecimal()) {
field = new IntField(name, info.getBigDecimal().intValue(), Field.Store.YES);
} else {
field = new TextField(name, info.getString(), Field.Store.YES);
}
document.add(field);
}
}
}
}
use of com.agiletec.aps.system.services.lang.Lang in project entando-core by entando.
the class ContentListTag method addMultilanguageWidgetParameter.
protected void addMultilanguageWidgetParameter(ApsProperties config, String widgetParamPrefix, Lang currentLang, String var) {
if (null == var || null == config)
return;
String paramValue = config.getProperty(widgetParamPrefix + "_" + currentLang.getCode());
if (null == paramValue) {
ILangManager langManager = (ILangManager) ApsWebApplicationUtils.getBean(SystemConstants.LANGUAGE_MANAGER, this.pageContext);
Lang defaultLang = langManager.getDefaultLang();
paramValue = config.getProperty(widgetParamPrefix + "_" + defaultLang.getCode());
}
if (null != paramValue) {
this.pageContext.setAttribute(var, paramValue);
}
}
use of com.agiletec.aps.system.services.lang.Lang in project entando-core by entando.
the class ContentListTag method extractExtraWidgetParameters.
protected void extractExtraWidgetParameters(RequestContext reqCtx) {
try {
Widget currentWidget = (Widget) reqCtx.getExtraParam((SystemConstants.EXTRAPAR_CURRENT_WIDGET));
ApsProperties config = (null != currentWidget) ? currentWidget.getConfig() : null;
if (null != config) {
Lang currentLang = (Lang) reqCtx.getExtraParam((SystemConstants.EXTRAPAR_CURRENT_LANG));
this.addMultilanguageWidgetParameter(config, IContentListWidgetHelper.WIDGET_PARAM_TITLE, currentLang, this.getTitleVar());
this.addMultilanguageWidgetParameter(config, IContentListWidgetHelper.WIDGET_PARAM_PAGE_LINK_DESCR, currentLang, this.getPageLinkDescriptionVar());
if (null != this.getPageLinkVar()) {
String pageLink = config.getProperty(IContentListWidgetHelper.WIDGET_PARAM_PAGE_LINK);
if (null != pageLink) {
this.pageContext.setAttribute(this.getPageLinkVar(), pageLink);
}
}
}
} catch (Throwable t) {
_logger.error("Error extracting extra parameters", t);
}
}
use of com.agiletec.aps.system.services.lang.Lang in project entando-core by entando.
the class AbstractResourceAttribute method getReferences.
@Override
public List<CmsAttributeReference> getReferences(List<Lang> systemLangs) {
List<CmsAttributeReference> refs = new ArrayList<>();
for (int i = 0; i < systemLangs.size(); i++) {
Lang lang = systemLangs.get(i);
ResourceInterface res = this.getResource(lang.getCode());
if (null != res) {
CmsAttributeReference ref = new CmsAttributeReference(null, null, res.getId());
refs.add(ref);
}
}
return refs;
}
Aggregations