Search in sources :

Example 1 with UserFilterOptionBean

use of com.agiletec.plugins.jacms.aps.system.services.content.widget.UserFilterOptionBean in project entando-core by entando.

the class FilterUtils method getUserFilters.

public static List<UserFilterOptionBean> getUserFilters(String userFiltersParam, Integer currentFrame, Lang currentLang, IApsEntity prototype, String dateFormat, HttpServletRequest request) {
    if (null == userFiltersParam) {
        return new ArrayList<UserFilterOptionBean>();
    }
    List<UserFilterOptionBean> list = new ArrayList<UserFilterOptionBean>();
    String[] filterStrings = userFiltersParam.split("\\+");
    for (int i = 0; i < filterStrings.length; i++) {
        String fullFilterString = filterStrings[i];
        try {
            String toStringFilter = fullFilterString.substring(1, fullFilterString.length() - 1);
            Properties properties = getProperties(toStringFilter, DEFAULT_FILTER_PARAM_SEPARATOR);
            UserFilterOptionBean filterBean = new UserFilterOptionBean(properties, prototype, currentFrame, currentLang, dateFormat, request);
            list.add(filterBean);
        } catch (Throwable t) {
            _logger.error("Error extracting user filter by string '{}' for type '{}'", fullFilterString, prototype.getTypeCode(), t);
        // ApsSystemUtils.logThrowable(t, FilterUtils.class, "getUserFilters", "Error extracting user filter by string '" + fullFilterString + "' for type '" + prototype.getTypeCode() + "'");
        }
    }
    return list;
}
Also used : ArrayList(java.util.ArrayList) UserFilterOptionBean(com.agiletec.plugins.jacms.aps.system.services.content.widget.UserFilterOptionBean) Properties(java.util.Properties)

Example 2 with UserFilterOptionBean

use of com.agiletec.plugins.jacms.aps.system.services.content.widget.UserFilterOptionBean in project entando-core by entando.

the class ContentListTag method doEndTag.

@Override
public int doEndTag() throws JspException {
    ServletRequest request = this.pageContext.getRequest();
    RequestContext reqCtx = (RequestContext) request.getAttribute(RequestContext.REQCTX);
    try {
        IContentListWidgetHelper helper = (IContentListWidgetHelper) ApsWebApplicationUtils.getBean(JacmsSystemConstants.CONTENT_LIST_HELPER, this.pageContext);
        List<UserFilterOptionBean> defaultUserFilterOptions = helper.getConfiguredUserFilters(this, reqCtx);
        this.addUserFilterOptions(defaultUserFilterOptions);
        this.extractExtraWidgetParameters(reqCtx);
        if (null != this.getUserFilterOptions() && null != this.getUserFilterOptionsVar()) {
            this.pageContext.setAttribute(this.getUserFilterOptionsVar(), this.getUserFilterOptions());
        }
        List<String> contents = this.getContentsId(helper, reqCtx);
        this.pageContext.setAttribute(this.getListName(), contents);
    } catch (Throwable t) {
        _logger.error("error in end tag", t);
        throw new JspException("Error detected while finalising the tag", t);
    }
    this.release();
    return EVAL_PAGE;
}
Also used : ServletRequest(javax.servlet.ServletRequest) JspException(javax.servlet.jsp.JspException) IContentListWidgetHelper(com.agiletec.plugins.jacms.aps.system.services.content.widget.IContentListWidgetHelper) UserFilterOptionBean(com.agiletec.plugins.jacms.aps.system.services.content.widget.UserFilterOptionBean) RequestContext(com.agiletec.aps.system.RequestContext)

Example 3 with UserFilterOptionBean

use of com.agiletec.plugins.jacms.aps.system.services.content.widget.UserFilterOptionBean in project entando-core by entando.

the class ContentListUserFilterOptionTag method doEndTag.

@Override
public int doEndTag() throws JspException {
    ServletRequest request = this.pageContext.getRequest();
    RequestContext reqCtx = (RequestContext) request.getAttribute(RequestContext.REQCTX);
    try {
        if (!this.isRightKey()) {
            StringBuilder message = new StringBuilder();
            for (int i = 0; i < IContentListWidgetHelper.allowedMetadataUserFilterOptionKeys.length; i++) {
                if (i != 0)
                    message.append(",");
                message.append(IContentListWidgetHelper.allowedMetadataUserFilterOptionKeys[i]);
            }
            throw new RuntimeException("The key '" + this.getKey() + "' is unknown; " + "Please use a valid one - " + message);
        }
        IContentListWidgetHelper helper = (IContentListWidgetHelper) ApsWebApplicationUtils.getBean(JacmsSystemConstants.CONTENT_LIST_HELPER, this.pageContext);
        IContentListTagBean parent = (IContentListTagBean) findAncestorWithClass(this, IContentListTagBean.class);
        String contentType = parent.getContentType();
        UserFilterOptionBean filter = helper.getUserFilterOption(contentType, this, reqCtx);
        if (null != filter) {
            parent.addUserFilterOption(filter);
        }
    } catch (Throwable t) {
        _logger.error("error in do end tag", t);
        // ApsSystemUtils.logThrowable(t, this, "doEndTag");
        throw new JspException("Tag error detected ", t);
    }
    return super.doEndTag();
}
Also used : ServletRequest(javax.servlet.ServletRequest) JspException(javax.servlet.jsp.JspException) IContentListWidgetHelper(com.agiletec.plugins.jacms.aps.system.services.content.widget.IContentListWidgetHelper) IContentListTagBean(com.agiletec.plugins.jacms.aps.system.services.content.widget.IContentListTagBean) UserFilterOptionBean(com.agiletec.plugins.jacms.aps.system.services.content.widget.UserFilterOptionBean) RequestContext(com.agiletec.aps.system.RequestContext)

Example 4 with UserFilterOptionBean

use of com.agiletec.plugins.jacms.aps.system.services.content.widget.UserFilterOptionBean in project entando-core by entando.

the class FilterUtils method getUserFilter.

public UserFilterOptionBean getUserFilter(String contentType, IEntityFilterBean bean, IContentManager contentManager, String dateFormat, RequestContext reqCtx) {
    UserFilterOptionBean filter = null;
    try {
        IApsEntity prototype = contentManager.createContentType(contentType);
        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;
}
Also used : UserFilterOptionBean(com.agiletec.plugins.jacms.aps.system.services.content.widget.UserFilterOptionBean) IApsEntity(com.agiletec.aps.system.common.entity.model.IApsEntity) Lang(com.agiletec.aps.system.services.lang.Lang) Properties(java.util.Properties)

Aggregations

UserFilterOptionBean (com.agiletec.plugins.jacms.aps.system.services.content.widget.UserFilterOptionBean)4 RequestContext (com.agiletec.aps.system.RequestContext)2 IContentListWidgetHelper (com.agiletec.plugins.jacms.aps.system.services.content.widget.IContentListWidgetHelper)2 Properties (java.util.Properties)2 ServletRequest (javax.servlet.ServletRequest)2 JspException (javax.servlet.jsp.JspException)2 IApsEntity (com.agiletec.aps.system.common.entity.model.IApsEntity)1 Lang (com.agiletec.aps.system.services.lang.Lang)1 IContentListTagBean (com.agiletec.plugins.jacms.aps.system.services.content.widget.IContentListTagBean)1 ArrayList (java.util.ArrayList)1