Search in sources :

Example 51 with EntitySearchFilter

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

the class BaseFilterUtils method getFilters.

public EntitySearchFilter[] getFilters(IApsEntity entityPrototype, String filtersString, String langCode) {
    if (null == entityPrototype) {
        return null;
    }
    List<Properties> properties = getFiltersProperties(filtersString);
    EntitySearchFilter[] filters = new EntitySearchFilter[properties.size()];
    for (int i = 0; i < properties.size(); i++) {
        Properties props = properties.get(i);
        EntitySearchFilter filter = EntitySearchFilter.getInstance(entityPrototype, props);
        this.attachLangFilter(entityPrototype, filter, props, langCode);
        filters[i] = filter;
    }
    return filters;
}
Also used : Properties(java.util.Properties) EntitySearchFilter(com.agiletec.aps.system.common.entity.model.EntitySearchFilter)

Example 52 with EntitySearchFilter

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

the class DataObjectActionHelper method getOrderFilter.

@Override
public EntitySearchFilter getOrderFilter(String groupBy, String order) {
    String key = null;
    if (null == groupBy || groupBy.trim().length() == 0 || groupBy.equals("lastModified")) {
        key = IDataObjectManager.DATA_OBJECT_MODIFY_DATE_FILTER_KEY;
    } else if (groupBy.equals("code")) {
        key = IDataObjectManager.ENTITY_ID_FILTER_KEY;
    } else if (groupBy.equals("descr")) {
        key = IDataObjectManager.DATA_OBJECT_DESCR_FILTER_KEY;
    } else if (groupBy.equals("created")) {
        key = IDataObjectManager.DATA_OBJECT_CREATION_DATE_FILTER_KEY;
    } else {
        throw new RuntimeException("Invalid Filter '" + groupBy + "'");
    }
    EntitySearchFilter filter = new EntitySearchFilter(key, false);
    if (null == order || order.trim().length() == 0) {
        filter.setOrder(EntitySearchFilter.DESC_ORDER);
    } else {
        filter.setOrder(order);
    }
    return filter;
}
Also used : EntitySearchFilter(com.agiletec.aps.system.common.entity.model.EntitySearchFilter)

Example 53 with EntitySearchFilter

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

the class ContentFinderAction method getLastUpdateContentResponse.

@SuppressWarnings("rawtypes")
public List<ContentJO> getLastUpdateContentResponse() {
    List<ContentJO> response = null;
    try {
        EntitySearchFilter modifyOrder = new EntitySearchFilter(IContentManager.CONTENT_MODIFY_DATE_FILTER_KEY, false);
        modifyOrder.setOrder(EntitySearchFilter.DESC_ORDER);
        List<String> ids = this.getContentManager().searchId(new EntitySearchFilter[] { modifyOrder });
        if (null != ids && !ids.isEmpty()) {
            if (this.getLastUpdateResponseSize() > ids.size() - 1)
                this.setLastUpdateResponseSize(ids.size() - 1);
            List<String> subList = ids.subList(0, this.getLastUpdateResponseSize());
            response = new ArrayList<ContentJO>();
            Iterator<String> sublist = subList.iterator();
            while (sublist.hasNext()) {
                String contentId = sublist.next();
                Content content = this.getContentManager().loadContent(contentId, false);
                ContentRecordVO vo = this.getContentManager().loadContentVO(contentId);
                ContentJO contentJO = new ContentJO(content, vo);
                response.add(contentJO);
            }
        }
    } catch (Throwable t) {
        _logger.error("Error loading last updated content response", t);
        throw new RuntimeException("Error loading last updated content response", t);
    }
    return response;
}
Also used : ContentJO(org.entando.entando.plugins.jacms.apsadmin.content.rs.model.ContentJO) Content(com.agiletec.plugins.jacms.aps.system.services.content.model.Content) ContentRecordVO(com.agiletec.plugins.jacms.aps.system.services.content.model.ContentRecordVO) EntitySearchFilter(com.agiletec.aps.system.common.entity.model.EntitySearchFilter)

Example 54 with EntitySearchFilter

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

the class ContentFinderAction method createFilters.

/**
 * Restitusce i filtri per la selezione e l'ordinamento dei contenuti
 * erogati nell'interfaccia.
 *
 * @return Il filtri di selezione ed ordinamento dei contenuti.
 */
@SuppressWarnings("rawtypes")
protected EntitySearchFilter[] createFilters() {
    ContentFinderSearchInfo searchInfo = getContentSearchInfo();
    this.createBaseFilters();
    if (null != this.getState() && this.getState().trim().length() > 0) {
        EntitySearchFilter filterToAdd = new EntitySearchFilter(IContentManager.CONTENT_STATUS_FILTER_KEY, false, this.getState(), false);
        this.addFilter(filterToAdd);
        searchInfo.addFilter(IContentManager.CONTENT_STATUS_FILTER_KEY, filterToAdd);
    } else {
        searchInfo.removeFilter(IContentManager.CONTENT_STATUS_FILTER_KEY);
    }
    if (null != this.getText() && this.getText().trim().length() > 0) {
        EntitySearchFilter filterToAdd = new EntitySearchFilter(IContentManager.CONTENT_DESCR_FILTER_KEY, false, this.getText(), true);
        this.addFilter(filterToAdd);
        searchInfo.addFilter(IContentManager.CONTENT_DESCR_FILTER_KEY, filterToAdd);
    } else {
        searchInfo.removeFilter(IContentManager.CONTENT_DESCR_FILTER_KEY);
    }
    if (null != this.getOwnerGroupName() && this.getOwnerGroupName().trim().length() > 0) {
        EntitySearchFilter filterToAdd = new EntitySearchFilter(IContentManager.CONTENT_MAIN_GROUP_FILTER_KEY, false, this.getOwnerGroupName(), false);
        this.addFilter(filterToAdd);
        searchInfo.addFilter(IContentManager.CONTENT_MAIN_GROUP_FILTER_KEY, filterToAdd);
    } else {
        searchInfo.removeFilter(IContentManager.CONTENT_MAIN_GROUP_FILTER_KEY);
    }
    if (null != this.getOnLineState() && this.getOnLineState().trim().length() > 0) {
        EntitySearchFilter filterToAdd = new EntitySearchFilter(IContentManager.CONTENT_ONLINE_FILTER_KEY, false);
        filterToAdd.setNullOption(this.getOnLineState().trim().equals("no"));
        this.addFilter(filterToAdd);
        searchInfo.addFilter(IContentManager.CONTENT_ONLINE_FILTER_KEY, filterToAdd);
    } else {
        searchInfo.removeFilter(IContentManager.CONTENT_ONLINE_FILTER_KEY);
    }
    if (null != this.getContentIdToken() && this.getContentIdToken().trim().length() > 0) {
        EntitySearchFilter filterToAdd = new EntitySearchFilter(IContentManager.ENTITY_ID_FILTER_KEY, false, this.getContentIdToken(), true);
        this.addFilter(filterToAdd);
        searchInfo.addFilter(IContentManager.ENTITY_ID_FILTER_KEY, filterToAdd);
    } else {
        searchInfo.removeFilter(IContentManager.ENTITY_ID_FILTER_KEY);
    }
    this.savePagerSearchState(searchInfo);
    EntitySearchFilter orderFilter = this.getContentActionHelper().getOrderFilter(this.getLastGroupBy(), this.getLastOrder());
    super.addFilter(orderFilter);
    searchInfo.addFilter(ContentFinderSearchInfo.ORDER_FILTER, orderFilter);
    return this.getFilters();
}
Also used : EntitySearchFilter(com.agiletec.aps.system.common.entity.model.EntitySearchFilter)

Example 55 with EntitySearchFilter

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

the class ContentFinderAction method createBaseFilters.

@SuppressWarnings("rawtypes")
protected void createBaseFilters() {
    try {
        int initSize = this.getFilters().length;
        ContentFinderSearchInfo searchInfo = getContentSearchInfo();
        EntitySearchFilter[] roleFilters = this.getEntityActionHelper().getRoleFilters(this);
        this.addFilters(roleFilters);
        IApsEntity prototype = this.getEntityPrototype();
        searchInfo.removeFilter(IEntityManager.ENTITY_TYPE_CODE_FILTER_KEY);
        searchInfo.removeFilterByPrefix(ContentFinderSearchInfo.ATTRIBUTE_FILTER);
        if (null != prototype) {
            EntitySearchFilter filterToAdd = new EntitySearchFilter(IEntityManager.ENTITY_TYPE_CODE_FILTER_KEY, false, prototype.getTypeCode(), false);
            this.addFilter(filterToAdd);
            searchInfo.addFilter(IEntityManager.ENTITY_TYPE_CODE_FILTER_KEY, filterToAdd);
            EntitySearchFilter[] filters = this.getEntityActionHelper().getAttributeFilters(this, prototype);
            this.addFilters(filters);
            searchInfo.addAttributeFilters(filters);
        }
        this.setAddedAttributeFilter(this.getFilters().length > initSize);
    } catch (Throwable t) {
        _logger.error("Error while creating entity filters", t);
        throw new RuntimeException("Error while creating entity filters", t);
    }
}
Also used : IApsEntity(com.agiletec.aps.system.common.entity.model.IApsEntity) 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