Search in sources :

Example 6 with Lang

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;
}
Also used : ICmsSearchEngineManager(com.agiletec.plugins.jacms.aps.system.services.searchengine.ICmsSearchEngineManager) IAuthorizationManager(com.agiletec.aps.system.services.authorization.IAuthorizationManager) Group(com.agiletec.aps.system.services.group.Group) UserDetails(com.agiletec.aps.system.services.user.UserDetails) ArrayList(java.util.ArrayList) Lang(com.agiletec.aps.system.services.lang.Lang) HashSet(java.util.HashSet)

Example 7 with Lang

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;
}
Also used : Widget(com.agiletec.aps.system.services.page.Widget) IApsEntity(com.agiletec.aps.system.common.entity.model.IApsEntity) Lang(com.agiletec.aps.system.services.lang.Lang) ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException) ApsProperties(com.agiletec.aps.util.ApsProperties)

Example 8 with Lang

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;
    }
}
Also used : ArrayList(java.util.ArrayList) Lang(com.agiletec.aps.system.services.lang.Lang)

Example 9 with Lang

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;
}
Also used : DataObjectRenderizationInfo(org.entando.entando.aps.system.services.dataobjectdispenser.DataObjectRenderizationInfo) Widget(com.agiletec.aps.system.services.page.Widget) Lang(com.agiletec.aps.system.services.lang.Lang) ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException) ApsProperties(com.agiletec.aps.util.ApsProperties)

Example 10 with Lang

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);
    }
}
Also used : IWidgetTypeManager(org.entando.entando.aps.system.services.widgettype.IWidgetTypeManager) Widget(com.agiletec.aps.system.services.page.Widget) Lang(com.agiletec.aps.system.services.lang.Lang) WidgetType(org.entando.entando.aps.system.services.widgettype.WidgetType) ApsProperties(com.agiletec.aps.util.ApsProperties)

Aggregations

Lang (com.agiletec.aps.system.services.lang.Lang)90 ArrayList (java.util.ArrayList)15 ApsProperties (com.agiletec.aps.util.ApsProperties)14 IPage (com.agiletec.aps.system.services.page.IPage)12 ApsSystemException (com.agiletec.aps.system.exception.ApsSystemException)11 RequestContext (com.agiletec.aps.system.RequestContext)10 Widget (com.agiletec.aps.system.services.page.Widget)10 ILangManager (com.agiletec.aps.system.services.lang.ILangManager)8 AttributeTracer (com.agiletec.aps.system.common.entity.model.AttributeTracer)7 AttributeInterface (com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface)7 HttpServletRequest (javax.servlet.http.HttpServletRequest)7 HashMap (java.util.HashMap)6 ServletRequest (javax.servlet.ServletRequest)6 AttributeFieldError (com.agiletec.aps.system.common.entity.model.AttributeFieldError)4 IApsEntity (com.agiletec.aps.system.common.entity.model.IApsEntity)4 IndexableAttributeInterface (com.agiletec.aps.system.common.searchengine.IndexableAttributeInterface)4 Category (com.agiletec.aps.system.services.category.Category)4 Properties (java.util.Properties)4 JspException (javax.servlet.jsp.JspException)4 StringField (org.apache.lucene.document.StringField)4