use of com.agiletec.aps.system.services.lang.Lang in project entando-core by entando.
the class SearcherTagHelper method executeSearch.
/**
* Carica una lista di identificativi di contenuto in base ad una ricerca
* effettuata in funzione ad una parila chiave specificata.
* @param word La parola con cui effettuare la ricerca.
* @param reqCtx Il contesto della richiesta.
* @return La lista di identificativi di contenuto.
* @throws ApsSystemException
*/
public List<String> executeSearch(String word, RequestContext reqCtx) throws ApsSystemException {
List<String> result = new ArrayList<String>();
if (null != word && word.trim().length() > 0) {
UserDetails currentUser = (UserDetails) reqCtx.getRequest().getSession().getAttribute(SystemConstants.SESSIONPARAM_CURRENT_USER);
ICmsSearchEngineManager searchEngine = (ICmsSearchEngineManager) ApsWebApplicationUtils.getBean(JacmsSystemConstants.SEARCH_ENGINE_MANAGER, reqCtx.getRequest());
IAuthorizationManager authManager = (IAuthorizationManager) ApsWebApplicationUtils.getBean(SystemConstants.AUTHORIZATION_SERVICE, reqCtx.getRequest());
List<Group> groups = authManager.getUserGroups(currentUser);
Set<String> userGroups = new HashSet<String>();
Iterator<Group> iter = groups.iterator();
while (iter.hasNext()) {
Group group = iter.next();
userGroups.add(group.getName());
}
Lang currentLang = (Lang) reqCtx.getExtraParam(SystemConstants.EXTRAPAR_CURRENT_LANG);
result = searchEngine.searchEntityId(currentLang.getCode(), word, userGroups);
}
return result;
}
use of com.agiletec.aps.system.services.lang.Lang in project entando-core by entando.
the class DataObjectListHelper method getConfiguredUserFilters.
@Override
public List<UserFilterOptionBean> getConfiguredUserFilters(IDataObjectListTagBean bean, RequestContext reqCtx) throws ApsSystemException {
List<UserFilterOptionBean> userEntityFilters = null;
try {
Widget widget = (Widget) reqCtx.getExtraParam(SystemConstants.EXTRAPAR_CURRENT_WIDGET);
ApsProperties config = (null != widget) ? widget.getConfig() : null;
if (null == config || null == config.getProperty(WIDGET_PARAM_CONTENT_TYPE)) {
return null;
}
String dataObjectTypeCode = config.getProperty(WIDGET_PARAM_CONTENT_TYPE);
IApsEntity prototype = this.getDataObjectManager().getEntityPrototype(dataObjectTypeCode);
if (null == prototype) {
_logger.error("Null dataObject type by code '{}'", dataObjectTypeCode);
return null;
}
Integer currentFrame = (Integer) reqCtx.getExtraParam(SystemConstants.EXTRAPAR_CURRENT_FRAME);
Lang currentLang = (Lang) reqCtx.getExtraParam(SystemConstants.EXTRAPAR_CURRENT_LANG);
String userFilters = config.getProperty(WIDGET_PARAM_USER_FILTERS);
if (null != userFilters && userFilters.length() > 0) {
userEntityFilters = FilterUtils.getUserFilters(userFilters, currentFrame, currentLang, prototype, this.getUserFilterDateFormat(), reqCtx.getRequest());
}
} catch (Throwable t) {
_logger.error("Error extracting user filters", t);
throw new ApsSystemException("Error extracting user filters", t);
}
return userEntityFilters;
}
use of com.agiletec.aps.system.services.lang.Lang in project entando-core by entando.
the class DataObjectListHelper method executeFullTextSearch.
protected List<String> executeFullTextSearch(IDataObjectListTagBean bean, List<String> masterContentsId, RequestContext reqCtx) throws ApsSystemException {
UserFilterOptionBean fullTextUserFilter = null;
List<UserFilterOptionBean> userFilterOptions = bean.getUserFilterOptions();
if (null != userFilterOptions) {
for (int i = 0; i < userFilterOptions.size(); i++) {
UserFilterOptionBean userFilter = userFilterOptions.get(i);
if (null != userFilter.getFormFieldValues() && userFilter.getFormFieldValues().size() > 0) {
if (!userFilter.isAttributeFilter() && userFilter.getKey().equals(UserFilterOptionBean.KEY_FULLTEXT)) {
fullTextUserFilter = userFilter;
}
}
}
}
if (fullTextUserFilter != null && null != fullTextUserFilter.getFormFieldValues()) {
String word = fullTextUserFilter.getFormFieldValues().get(fullTextUserFilter.getFormFieldNames()[0]);
/*
String optionString = fullTextUserFilter.getFormFieldValues().get(fullTextUserFilter.getFormFieldNames()[1]);
SearchEngineFilter.TextSearchOption option = SearchEngineFilter.TextSearchOption.AT_LEAST_ONE_WORD;
if (null != optionString) {
if (optionString.equals(UserFilterOptionBean.FULLTEXT_OPTION_ALL_WORDS)) {
option = SearchEngineFilter.TextSearchOption.ALL_WORDS;
} else if (optionString.equals(UserFilterOptionBean.FULLTEXT_OPTION_EXACT)) {
option = SearchEngineFilter.TextSearchOption.EXACT;
}
}
*/
Lang currentLang = (Lang) reqCtx.getExtraParam(SystemConstants.EXTRAPAR_CURRENT_LANG);
/*
SearchEngineFilter filter = new SearchEngineFilter(currentLang.getCode(), word, option);
SearchEngineFilter[] filters = {filter};
List<String> fullTextResult = this.getSearchEngineManager().searchEntityId(filters, null, this.getAllowedGroups(reqCtx));
*/
List<String> fullTextResult = this.getSearchEngineManager().searchEntityId(currentLang.getCode(), word, this.getAllowedGroups(reqCtx));
if (null != fullTextResult) {
return ListUtils.intersection(fullTextResult, masterContentsId);
} else {
return new ArrayList<String>();
}
} else {
return masterContentsId;
}
}
use of com.agiletec.aps.system.services.lang.Lang in project entando-core by entando.
the class DataObjectViewerHelper method getRenderizationInfo.
@Override
public DataObjectRenderizationInfo getRenderizationInfo(String dataobjectId, String modelId, boolean publishExtraTitle, RequestContext reqCtx) throws ApsSystemException {
DataObjectRenderizationInfo renderizationInfo = null;
try {
Lang currentLang = (Lang) reqCtx.getExtraParam(SystemConstants.EXTRAPAR_CURRENT_LANG);
String langCode = currentLang.getCode();
Widget widget = (Widget) reqCtx.getExtraParam(SystemConstants.EXTRAPAR_CURRENT_WIDGET);
ApsProperties widgetConfig = widget.getConfig();
dataobjectId = this.extractDataId(dataobjectId, widgetConfig, reqCtx);
modelId = this.extractModelId(dataobjectId, modelId, widgetConfig, reqCtx);
if (dataobjectId != null && modelId != null) {
long longModelId = new Long(modelId).longValue();
this.setStylesheet(longModelId, reqCtx);
renderizationInfo = this.getDataObjectDispenser().getRenderizationInfo(dataobjectId, longModelId, langCode, reqCtx, true);
if (null == renderizationInfo) {
_logger.info("Null Renderization informations: dataobject={}", dataobjectId);
return null;
}
this.manageAttributeValues(renderizationInfo, publishExtraTitle, reqCtx);
} else {
_logger.warn("Parametri visualizzazione dataobject incompleti: dataobject={} modello={}", dataobjectId, modelId);
}
} catch (Throwable t) {
_logger.error("Error extracting renderization info", t);
throw new ApsSystemException("Error extracting renderization info", t);
}
return renderizationInfo;
}
use of com.agiletec.aps.system.services.lang.Lang in project entando-core by entando.
the class TestContentViewerHelper method init.
private void init() throws Exception {
try {
_requestContext = this.getRequestContext();
Lang lang = new Lang();
lang.setCode("it");
lang.setDescr("italiano");
_requestContext.addExtraParam(SystemConstants.EXTRAPAR_CURRENT_LANG, lang);
Widget widget = new Widget();
IWidgetTypeManager showletTypeMan = (IWidgetTypeManager) this.getService(SystemConstants.WIDGET_TYPE_MANAGER);
WidgetType showletType = showletTypeMan.getWidgetType("content_viewer");
widget.setType(showletType);
widget.setConfig(new ApsProperties());
_requestContext.addExtraParam(SystemConstants.EXTRAPAR_CURRENT_WIDGET, widget);
this._helper = (IContentViewerHelper) this.getApplicationContext().getBean("jacmsContentViewerHelper");
} catch (Throwable t) {
throw new Exception(t);
}
}
Aggregations