Search in sources :

Example 81 with EntitySearchFilter

use of com.agiletec.aps.system.common.entity.model.EntitySearchFilter in project entando-core by entando.

the class ApiDataObjectInterface method buildSearchBean.

protected ApiDataObjectListBean buildSearchBean(Properties properties) throws ApiException, Throwable {
    ApiDataObjectListBean bean = null;
    try {
        String dataType = properties.getProperty("dataType");
        if (null == this.getDataObjectManager().getSmallDataTypesMap().get(dataType)) {
            throw new ApiException(IApiErrorCodes.API_PARAMETER_VALIDATION_ERROR, "DataObject Type '" + dataType + "' does not exist", Response.Status.CONFLICT);
        }
        String langCode = properties.getProperty(SystemConstants.API_LANG_CODE_PARAMETER);
        String filtersParam = properties.getProperty("filters");
        EntitySearchFilter[] filters = this.getDataObjectListHelper().getFilters(dataType, filtersParam, langCode);
        String[] categoryCodes = null;
        String categoriesParam = properties.getProperty("categories");
        if (null != categoriesParam && categoriesParam.trim().length() > 0) {
            categoryCodes = categoriesParam.split(IDataTypeListHelper.CATEGORIES_SEPARATOR);
        }
        bean = new ApiDataObjectListBean(dataType, filters, categoryCodes);
    } catch (ApiException ae) {
        throw ae;
    } catch (Throwable t) {
        _logger.error("error in buildSearchBean", t);
        throw new ApsSystemException("Error into API method", t);
    }
    return bean;
}
Also used : ApiDataObjectListBean(org.entando.entando.aps.system.services.dataobject.api.model.ApiDataObjectListBean) ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException) EntitySearchFilter(com.agiletec.aps.system.common.entity.model.EntitySearchFilter) ApiException(org.entando.entando.aps.system.services.api.model.ApiException)

Example 82 with EntitySearchFilter

use of com.agiletec.aps.system.common.entity.model.EntitySearchFilter in project entando-core by entando.

the class DataObjectListHelper method extractContentsId.

protected List<String> extractContentsId(IDataObjectListTagBean bean, RequestContext reqCtx) throws ApsSystemException {
    List<String> contentsId = null;
    try {
        List<UserFilterOptionBean> userFilters = bean.getUserFilterOptions();
        Widget widget = (Widget) reqCtx.getExtraParam(SystemConstants.EXTRAPAR_CURRENT_WIDGET);
        ApsProperties config = (null != widget) ? widget.getConfig() : null;
        if (null == bean.getDataType() && null != config) {
            bean.setContentType(config.getProperty(WIDGET_PARAM_CONTENT_TYPE));
        }
        if (null == bean.getDataType()) {
            throw new ApsSystemException("Tipo contenuto non definito");
        }
        if (null == bean.getCategory() && null != config && null != config.getProperty(SHOWLET_PARAM_CATEGORY)) {
            bean.setCategory(config.getProperty(SHOWLET_PARAM_CATEGORY));
        }
        this.addWidgetFilters(bean, config, WIDGET_PARAM_FILTERS, reqCtx);
        if (null != userFilters && userFilters.size() > 0) {
            for (int i = 0; i < userFilters.size(); i++) {
                UserFilterOptionBean userFilter = userFilters.get(i);
                EntitySearchFilter filter = userFilter.getEntityFilter();
                if (null != filter) {
                    bean.addFilter(filter);
                }
            }
        }
        String[] categories = this.getCategories(bean.getCategories(), config, userFilters);
        Collection<String> userGroupCodes = this.getAllowedGroups(reqCtx);
        boolean orCategoryFilterClause = this.extractOrCategoryFilterClause(config);
        contentsId = this.getDataObjectManager().loadDataObjectsId(bean.getDataType(), categories, orCategoryFilterClause, bean.getFilters(), userGroupCodes);
    } catch (Throwable t) {
        _logger.error("Error extracting contents id", t);
        throw new ApsSystemException("Error extracting contents id", t);
    }
    return contentsId;
}
Also used : Widget(com.agiletec.aps.system.services.page.Widget) ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException) ApsProperties(com.agiletec.aps.util.ApsProperties) EntitySearchFilter(com.agiletec.aps.system.common.entity.model.EntitySearchFilter)

Example 83 with EntitySearchFilter

use of com.agiletec.aps.system.common.entity.model.EntitySearchFilter in project entando-core by entando.

the class ApiContentInterface method buildSearchBean.

protected ApiContentListBean buildSearchBean(Properties properties) throws ApiException, Throwable {
    ApiContentListBean bean = null;
    try {
        String contentType = properties.getProperty("contentType");
        if (null == this.getContentManager().getSmallContentTypesMap().get(contentType)) {
            throw new ApiException(IApiErrorCodes.API_PARAMETER_VALIDATION_ERROR, "Content Type '" + contentType + "' does not exist", Response.Status.CONFLICT);
        }
        String langCode = properties.getProperty(SystemConstants.API_LANG_CODE_PARAMETER);
        String filtersParam = properties.getProperty("filters");
        EntitySearchFilter[] filters = this.getContentListHelper().getFilters(contentType, filtersParam, langCode);
        String[] categoryCodes = null;
        String categoriesParam = properties.getProperty("categories");
        if (null != categoriesParam && categoriesParam.trim().length() > 0) {
            categoryCodes = categoriesParam.split(IContentListHelper.CATEGORIES_SEPARATOR);
        }
        bean = new ApiContentListBean(contentType, filters, categoryCodes);
    } catch (ApiException ae) {
        throw ae;
    } catch (Throwable t) {
        _logger.error("error in buildSearchBean", t);
        throw new ApsSystemException("Error into API method", t);
    }
    return bean;
}
Also used : ApiContentListBean(org.entando.entando.plugins.jacms.aps.system.services.api.model.ApiContentListBean) ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException) EntitySearchFilter(com.agiletec.aps.system.common.entity.model.EntitySearchFilter) ApiException(org.entando.entando.aps.system.services.api.model.ApiException)

Example 84 with EntitySearchFilter

use of com.agiletec.aps.system.common.entity.model.EntitySearchFilter in project entando-core by entando.

the class TestDataObjectManager method testLoadEvents_9_a.

protected void testLoadEvents_9_a(boolean useRoleFilter) throws ApsSystemException {
    List<String> groups = new ArrayList<String>();
    groups.add(Group.ADMINS_GROUP_NAME);
    EntitySearchFilter filter = (useRoleFilter) ? EntitySearchFilter.createRoleFilter(SystemConstants.DATA_TYPE_ATTRIBUTE_ROLE_TITLE, "le", true) : new EntitySearchFilter("Titolo", true, "le", true);
    filter.setLangCode("it");
    filter.setOrder(EntitySearchFilter.DESC_ORDER);
    EntitySearchFilter[] filters = { filter };
    List<String> dataObjects = _dataObjectManager.loadDataObjectsId("EVN", null, filters, groups);
    String[] expectedOrderedDataObjectsId2 = { "EVN25", "EVN21", "EVN23" };
    assertEquals(expectedOrderedDataObjectsId2.length, dataObjects.size());
    for (int i = 0; i < expectedOrderedDataObjectsId2.length; i++) {
        assertEquals(expectedOrderedDataObjectsId2[i], dataObjects.get(i));
    }
}
Also used : ArrayList(java.util.ArrayList) EntitySearchFilter(com.agiletec.aps.system.common.entity.model.EntitySearchFilter)

Example 85 with EntitySearchFilter

use of com.agiletec.aps.system.common.entity.model.EntitySearchFilter in project entando-core by entando.

the class TestDataObjectManager method testSearchDataObjects_1_2.

public void testSearchDataObjects_1_2() throws Throwable {
    EntitySearchFilter versionFilter = new EntitySearchFilter(IDataObjectManager.DATA_OBJECT_CURRENT_VERSION_FILTER_KEY, false, "0.", true);
    EntitySearchFilter[] filters3 = { versionFilter };
    List<String> dataObjectIds = this._dataObjectManager.searchId(filters3);
    assertNotNull(dataObjectIds);
    String[] expected2 = { "ART179" };
    assertEquals(expected2.length, dataObjectIds.size());
    this.verifyOrder(dataObjectIds, expected2);
    versionFilter = new EntitySearchFilter(IDataObjectManager.DATA_OBJECT_CURRENT_VERSION_FILTER_KEY, false, ".0", true);
    EntitySearchFilter[] filters4 = { versionFilter };
    dataObjectIds = this._dataObjectManager.searchId(filters4);
    assertNotNull(dataObjectIds);
    assertEquals(22, dataObjectIds.size());
}
Also used : EntitySearchFilter(com.agiletec.aps.system.common.entity.model.EntitySearchFilter)

Aggregations

EntitySearchFilter (com.agiletec.aps.system.common.entity.model.EntitySearchFilter)157 ArrayList (java.util.ArrayList)51 Date (java.util.Date)46 ApsSystemException (com.agiletec.aps.system.exception.ApsSystemException)12 RequestContext (com.agiletec.aps.system.RequestContext)9 Content (com.agiletec.plugins.jacms.aps.system.services.content.model.Content)7 IApsEntity (com.agiletec.aps.system.common.entity.model.IApsEntity)6 DateAttribute (com.agiletec.aps.system.common.entity.model.attribute.DateAttribute)5 ApiException (org.entando.entando.aps.system.services.api.model.ApiException)5 AttributeInterface (com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface)4 BigDecimal (java.math.BigDecimal)4 HashSet (java.util.HashSet)4 ApsEntityRecord (com.agiletec.aps.system.common.entity.model.ApsEntityRecord)3 BooleanAttribute (com.agiletec.aps.system.common.entity.model.attribute.BooleanAttribute)3 ITextAttribute (com.agiletec.aps.system.common.entity.model.attribute.ITextAttribute)3 NumberAttribute (com.agiletec.aps.system.common.entity.model.attribute.NumberAttribute)3 Properties (java.util.Properties)3 DataObject (org.entando.entando.aps.system.services.dataobject.model.DataObject)3 IEntityTypesConfigurer (com.agiletec.aps.system.common.entity.IEntityTypesConfigurer)2 MonoTextAttribute (com.agiletec.aps.system.common.entity.model.attribute.MonoTextAttribute)2