Search in sources :

Example 16 with FieldSearchFilter

use of com.agiletec.aps.system.common.FieldSearchFilter in project entando-core by entando.

the class RestListRequest method buildFieldSearchFilters.

@SuppressWarnings("rawtypes")
public List<FieldSearchFilter> buildFieldSearchFilters() {
    List<FieldSearchFilter> fieldSearchFilters = new ArrayList<>();
    if (null != filters && filters.length > 0) {
        Arrays.stream(filters).forEach(i -> fieldSearchFilters.add(i.getFieldSearchFilter()));
    }
    FieldSearchFilter pageFilter = this.buildPaginationFilter();
    if (null != pageFilter) {
        fieldSearchFilters.add(pageFilter);
    }
    FieldSearchFilter sortFilter = this.buildSortFilter();
    if (null != sortFilter) {
        fieldSearchFilters.add(sortFilter);
    }
    return fieldSearchFilters;
}
Also used : ArrayList(java.util.ArrayList) FieldSearchFilter(com.agiletec.aps.system.common.FieldSearchFilter)

Example 17 with FieldSearchFilter

use of com.agiletec.aps.system.common.FieldSearchFilter in project entando-core by entando.

the class DataObjectModelManager method getDataObjectModels.

@Override
public SearcherDaoPaginatedResult<DataObjectModel> getDataObjectModels(List<FieldSearchFilter> filters) throws ApsSystemException {
    SearcherDaoPaginatedResult<DataObjectModel> pagedResult = null;
    try {
        List<DataObjectModel> dataObjectModels = new ArrayList<>();
        FieldSearchFilter[] filtersArray = filters.toArray(new FieldSearchFilter[filters.size()]);
        int count = this.getDataModelDAO().countDataObjectModels(filtersArray);
        List<Long> codes = this.searchDataObjectModels(filtersArray);
        for (Long code : codes) {
            dataObjectModels.add(this.getDataObjectModel(code));
        }
        pagedResult = new SearcherDaoPaginatedResult<>(count, dataObjectModels);
    } catch (Throwable t) {
        logger.error("Error searching models", t);
        throw new ApsSystemException("Error searching models", t);
    }
    return pagedResult;
}
Also used : ArrayList(java.util.ArrayList) ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException) FieldSearchFilter(com.agiletec.aps.system.common.FieldSearchFilter)

Example 18 with FieldSearchFilter

use of com.agiletec.aps.system.common.FieldSearchFilter in project entando-core by entando.

the class GuiFragmentManager method searchGuiFragments.

@Override
public List<String> searchGuiFragments(FieldSearchFilter[] filters) throws ApsSystemException {
    List<String> guiFragments = null;
    try {
        FieldSearchFilter filter = new FieldSearchFilter("code");
        filter.setOrder(FieldSearchFilter.Order.ASC);
        filters = this.addFilter(filters, filter);
        guiFragments = this.getGuiFragmentDAO().searchGuiFragments(filters);
    } catch (Throwable t) {
        logger.error("Error searching GuiFragments", t);
        throw new ApsSystemException("Error searching GuiFragments", t);
    }
    return guiFragments;
}
Also used : ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException) FieldSearchFilter(com.agiletec.aps.system.common.FieldSearchFilter)

Example 19 with FieldSearchFilter

use of com.agiletec.aps.system.common.FieldSearchFilter in project entando-core by entando.

the class GuiFragmentManager method searchFragments.

protected Set<String> searchFragments(String strToSearch, String column) throws ApsSystemException {
    FieldSearchFilter filterTag = new FieldSearchFilter(column, "<@wp.fragment", true);
    FieldSearchFilter[] filters1 = new FieldSearchFilter[] { filterTag };
    List<String> result1 = this.searchGuiFragments(filters1);
    FieldSearchFilter filterCode = new FieldSearchFilter(column, strToSearch, true);
    FieldSearchFilter[] filters2 = new FieldSearchFilter[] { filterCode };
    List<String> result2 = this.searchGuiFragments(filters2);
    Set<String> result = new HashSet<>();
    result.addAll(result1);
    result.addAll(result2);
    return result;
}
Also used : FieldSearchFilter(com.agiletec.aps.system.common.FieldSearchFilter) HashSet(java.util.HashSet)

Example 20 with FieldSearchFilter

use of com.agiletec.aps.system.common.FieldSearchFilter in project entando-core by entando.

the class GuiFragmentManager method getGuiFragmentCodesByWidgetType.

@Override
@CachePut(value = ICacheInfoManager.DEFAULT_CACHE_NAME, key = "'GuiFragment_codesByWidgetType_'.concat(#widgetTypeCode)")
// TODO improve group handling
@CacheableInfo(groups = "'GuiFragment_codesByWidgetTypeGroup'")
public List<String> getGuiFragmentCodesByWidgetType(String widgetTypeCode) throws ApsSystemException {
    List<String> codes = null;
    try {
        FieldSearchFilter filter = new FieldSearchFilter("widgettypecode", widgetTypeCode, false);
        filter.setOrder(FieldSearchFilter.Order.ASC);
        FieldSearchFilter[] filters = { filter };
        codes = this.searchGuiFragments(filters);
    } catch (Throwable t) {
        logger.error("Error loading fragments code by widget '{}'", widgetTypeCode, t);
        throw new ApsSystemException("Error loading fragment codes by widget " + widgetTypeCode, t);
    }
    return codes;
}
Also used : ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException) FieldSearchFilter(com.agiletec.aps.system.common.FieldSearchFilter) CacheableInfo(org.entando.entando.aps.system.services.cache.CacheableInfo) CachePut(org.springframework.cache.annotation.CachePut)

Aggregations

FieldSearchFilter (com.agiletec.aps.system.common.FieldSearchFilter)32 ArrayList (java.util.ArrayList)15 ApsSystemException (com.agiletec.aps.system.exception.ApsSystemException)13 RestListRequest (org.entando.entando.web.common.model.RestListRequest)10 SearcherDaoPaginatedResult (com.agiletec.aps.system.common.model.dao.SearcherDaoPaginatedResult)5 List (java.util.List)5 RestRourceNotFoundException (org.entando.entando.aps.system.exception.RestRourceNotFoundException)5 RestServerError (org.entando.entando.aps.system.exception.RestServerError)5 IDtoBuilder (org.entando.entando.aps.system.services.IDtoBuilder)5 PagedMetadata (org.entando.entando.web.common.model.PagedMetadata)5 Logger (org.slf4j.Logger)5 LoggerFactory (org.slf4j.LoggerFactory)5 BeanPropertyBindingResult (org.springframework.validation.BeanPropertyBindingResult)4 Map (java.util.Map)3 GuiFragment (org.entando.entando.aps.system.services.guifragment.GuiFragment)3 ValidationConflictException (org.entando.entando.web.common.exceptions.ValidationConflictException)3 Filter (org.entando.entando.web.common.model.Filter)3 Test (org.junit.Test)3 Autowired (org.springframework.beans.factory.annotation.Autowired)3 GroupUtilizer (com.agiletec.aps.system.services.group.GroupUtilizer)2