Search in sources :

Example 26 with FieldSearchFilter

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

the class ActionLogDAO method extractRecordToDelete.

private void extractRecordToDelete(String groupName, Integer maxActivitySizeByGroup, Set<Integer> recordIds, Connection conn) {
    PreparedStatement stat = null;
    ResultSet result = null;
    try {
        List<Integer> idList = new ArrayList<Integer>();
        FieldSearchFilter filter1 = new FieldSearchFilter("actiondate");
        filter1.setOrder(FieldSearchFilter.Order.DESC);
        FieldSearchFilter filter2 = new FieldSearchFilter("activitystreaminfo");
        FieldSearchFilter[] filters = { filter1, filter2 };
        List<String> groupCodes = new ArrayList<String>();
        groupCodes.add(groupName);
        stat = this.buildStatement(filters, groupCodes, conn);
        result = stat.executeQuery();
        while (result.next()) {
            Integer id = result.getInt(1);
            if (!idList.contains(id)) {
                idList.add(id);
            }
        }
        if (idList.size() > maxActivitySizeByGroup) {
            for (int i = maxActivitySizeByGroup; i < idList.size(); i++) {
                Integer id = idList.get(i);
                recordIds.add(id);
            }
        }
    } catch (Throwable t) {
        _logger.error("Error while loading activity stream records to delete : group {}", groupName, t);
        throw new RuntimeException("Error while loading activity stream records to delete : group '" + groupName + "'", t);
    } finally {
        closeDaoResources(result, stat);
    }
}
Also used : ResultSet(java.sql.ResultSet) ArrayList(java.util.ArrayList) PreparedStatement(java.sql.PreparedStatement) FieldSearchFilter(com.agiletec.aps.system.common.FieldSearchFilter)

Example 27 with FieldSearchFilter

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

the class TestPageModelManager method testSearch_with_page_filter.

public void testSearch_with_page_filter() throws ApsSystemException {
    RestListRequest restListRequest = new RestListRequest();
    restListRequest.setPageSize(2);
    restListRequest.setPage(1);
    List<FieldSearchFilter> filters = restListRequest.buildFieldSearchFilters();
    SearcherDaoPaginatedResult<PageModel> result = this._pageModelManager.searchPageModels(filters);
    assertThat(result.getCount(), is(3));
    assertThat(result.getList().size(), is(2));
    restListRequest.addFilter(new Filter("descr", "modello"));
    result = this._pageModelManager.searchPageModels(restListRequest.buildFieldSearchFilters());
    assertThat(result.getCount(), is(2));
    assertThat(result.getList().size(), is(2));
    restListRequest.setPage(0);
    result = this._pageModelManager.searchPageModels(restListRequest.buildFieldSearchFilters());
    assertThat(result.getCount(), is(2));
    assertThat(result.getList().size(), is(2));
}
Also used : FieldSearchFilter(com.agiletec.aps.system.common.FieldSearchFilter) Filter(org.entando.entando.web.common.model.Filter) RestListRequest(org.entando.entando.web.common.model.RestListRequest) FieldSearchFilter(com.agiletec.aps.system.common.FieldSearchFilter)

Example 28 with FieldSearchFilter

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

the class GuiFragmentFinderAction method getGuiFragmentsCodes.

public List<String> getGuiFragmentsCodes() {
    try {
        FieldSearchFilter[] filters = new FieldSearchFilter[0];
        if (StringUtils.isNotBlank(this.getCode())) {
            FieldSearchFilter filterToAdd = new FieldSearchFilter("code", this.getCode(), true);
            filters = this.addFilter(filters, filterToAdd);
        }
        if (StringUtils.isNotBlank(this.getWidgetTypeCode())) {
            FieldSearchFilter filterToAdd = new FieldSearchFilter("widgettypecode", this.getWidgetTypeCode(), false);
            filters = this.addFilter(filters, filterToAdd);
        }
        if (StringUtils.isNotBlank(this.getPluginCode())) {
            FieldSearchFilter filterToAdd = new FieldSearchFilter("plugincode", this.getPluginCode(), false);
            filters = this.addFilter(filters, filterToAdd);
        }
        List<String> guiFragments = this.getGuiFragmentManager().searchGuiFragments(filters);
        return guiFragments;
    } catch (Throwable t) {
        _logger.error("Error getting guiFragments list", t);
        throw new RuntimeException("Error getting guiFragments list", t);
    }
}
Also used : FieldSearchFilter(com.agiletec.aps.system.common.FieldSearchFilter)

Example 29 with FieldSearchFilter

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

the class ResourceManager method checkFilterKeys.

protected void checkFilterKeys(FieldSearchFilter[] filters) {
    if (null != filters && filters.length > 0) {
        String[] allowedFilterKeys = { RESOURCE_ID_FILTER_KEY, RESOURCE_TYPE_FILTER_KEY, RESOURCE_DESCR_FILTER_KEY, RESOURCE_MAIN_GROUP_FILTER_KEY, RESOURCE_FILENAME_FILTER_KEY, RESOURCE_CREATION_DATE_FILTER_KEY, RESOURCE_MODIFY_DATE_FILTER_KEY };
        List<String> allowedFilterKeysList = Arrays.asList(allowedFilterKeys);
        for (int i = 0; i < filters.length; i++) {
            FieldSearchFilter filter = filters[i];
            if (!allowedFilterKeysList.contains(filter.getKey())) {
                throw new RuntimeException("Invalid filter key - '" + filter.getKey() + "'");
            }
        }
    }
}
Also used : FieldSearchFilter(com.agiletec.aps.system.common.FieldSearchFilter)

Example 30 with FieldSearchFilter

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

the class ResourceDAO method createFilters.

private FieldSearchFilter[] createFilters(String type, String text, String filename, Collection<String> groupCodes) {
    FieldSearchFilter[] filters = new FieldSearchFilter[0];
    if (null != type && type.trim().length() > 0) {
        FieldSearchFilter filterToAdd = new FieldSearchFilter(IResourceManager.RESOURCE_TYPE_FILTER_KEY, type, false);
        filters = super.addFilter(filters, filterToAdd);
    }
    if (null != text && text.trim().length() > 0) {
        FieldSearchFilter filterToAdd = new FieldSearchFilter(IResourceManager.RESOURCE_DESCR_FILTER_KEY, text, true);
        filters = super.addFilter(filters, filterToAdd);
    }
    if (null != filename && filename.trim().length() > 0) {
        FieldSearchFilter filterToAdd = new FieldSearchFilter(IResourceManager.RESOURCE_FILENAME_FILTER_KEY, filename, true);
        filters = super.addFilter(filters, filterToAdd);
    }
    if (groupCodes != null && groupCodes.size() > 0) {
        List<String> allowedValues = new ArrayList<String>();
        allowedValues.addAll(groupCodes);
        FieldSearchFilter filterToAdd = new FieldSearchFilter(IResourceManager.RESOURCE_MAIN_GROUP_FILTER_KEY, allowedValues, false);
        filters = super.addFilter(filters, filterToAdd);
    }
    if (filters.length == 0) {
        return null;
    }
    return filters;
}
Also used : ArrayList(java.util.ArrayList) FieldSearchFilter(com.agiletec.aps.system.common.FieldSearchFilter)

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