use of com.agiletec.aps.system.services.lang.Lang in project entando-core by entando.
the class DataObjectListHelper method buildCacheKey.
protected static String buildCacheKey(String listName, Collection<String> userGroupCodes, RequestContext reqCtx) {
IPage page = (null != reqCtx) ? (IPage) reqCtx.getExtraParam(SystemConstants.EXTRAPAR_CURRENT_PAGE) : null;
StringBuilder cacheKey = (null != page) ? new StringBuilder(page.getCode()) : new StringBuilder("NOTFOUND");
Widget currentWidget = (null != reqCtx) ? (Widget) reqCtx.getExtraParam(SystemConstants.EXTRAPAR_CURRENT_WIDGET) : null;
if (null != currentWidget && null != currentWidget.getType()) {
cacheKey.append("_").append(currentWidget.getType().getCode());
}
if (null != reqCtx) {
Integer frame = (Integer) reqCtx.getExtraParam(SystemConstants.EXTRAPAR_CURRENT_FRAME);
if (null != frame) {
cacheKey.append("_").append(frame.intValue());
}
Lang currentLang = (Lang) reqCtx.getExtraParam(SystemConstants.EXTRAPAR_CURRENT_LANG);
if (null != currentLang) {
cacheKey.append("_LANG").append(currentLang.getCode()).append("_");
}
}
List<String> groupCodes = new ArrayList<String>(userGroupCodes);
if (!groupCodes.contains(Group.FREE_GROUP_NAME)) {
groupCodes.add(Group.FREE_GROUP_NAME);
}
Collections.sort(groupCodes);
for (int i = 0; i < groupCodes.size(); i++) {
String code = (String) groupCodes.get(i);
cacheKey.append("_").append(code);
}
if (null != currentWidget && null != currentWidget.getConfig()) {
List<String> paramKeys = new ArrayList(currentWidget.getConfig().keySet());
Collections.sort(paramKeys);
for (int i = 0; i < paramKeys.size(); i++) {
if (i == 0) {
cacheKey.append("_WIDGETPARAM");
} else {
cacheKey.append(",");
}
String paramkey = (String) paramKeys.get(i);
cacheKey.append(paramkey).append("=").append(currentWidget.getConfig().getProperty(paramkey));
}
}
if (null != listName) {
cacheKey.append("_LISTNAME").append(listName);
}
return cacheKey.toString();
}
use of com.agiletec.aps.system.services.lang.Lang in project entando-core by entando.
the class WidgetTypeDOM method createParameters.
protected void createParameters(List<WidgetTypeParameter> parameters, Element parameterElement) {
String name = parameterElement.getAttributeValue("name");
String description = parameterElement.getText();
if (name.indexOf("{lang}") > 0) {
for (int i = 0; i < this.getLangs().size(); i++) {
Lang lang = this.getLangs().get(i);
String newName = name.replace("{lang}", lang.getCode());
String newDescription = description;
if (null != description && description.indexOf("{lang}") > 0) {
newDescription = description.replace("{lang}", lang.getCode());
}
this.addParameter(parameters, newName, newDescription);
}
} else {
this.addParameter(parameters, name, description);
}
}
use of com.agiletec.aps.system.services.lang.Lang in project entando-core by entando.
the class FilterUtils method getUserFilter.
public UserFilterOptionBean getUserFilter(String dataObjectType, IEntityFilterBean bean, IDataObjectManager dataObjectManager, String dateFormat, RequestContext reqCtx) {
UserFilterOptionBean filter = null;
try {
IApsEntity prototype = dataObjectManager.createDataObject(dataObjectType);
Properties props = new Properties();
props.setProperty(UserFilterOptionBean.PARAM_KEY, bean.getKey());
props.setProperty(UserFilterOptionBean.PARAM_IS_ATTRIBUTE_FILTER, String.valueOf(bean.isAttributeFilter()));
Lang currentLang = (Lang) reqCtx.getExtraParam(SystemConstants.EXTRAPAR_CURRENT_LANG);
Integer currentFrame = (Integer) reqCtx.getExtraParam(SystemConstants.EXTRAPAR_CURRENT_FRAME);
filter = new UserFilterOptionBean(props, prototype, currentFrame, currentLang, dateFormat, reqCtx.getRequest());
} catch (Throwable t) {
_logger.error("Error creating user filter", t);
// ApsSystemUtils.logThrowable(t, FilterUtils.class, "getUserFilter", "Error creating user filter");
}
return filter;
}
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 dataobject dal quale ricavare il Document.
* @return L'oggetto Document ricavato dal dataobject.
* @throws ApsSystemException In caso di errore
*/
protected Document createDocument(IApsEntity entity) throws ApsSystemException {
Document document = new Document();
document.add(new StringField(DATAOBJECT_ID_FIELD_NAME, entity.getId(), Field.Store.YES));
document.add(new TextField(DATAOBJECT_TYPE_FIELD_NAME, entity.getTypeCode(), Field.Store.YES));
document.add(new StringField(DATAOBJECT_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(DATAOBJECT_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 (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);
}
}
}
}
Aggregations