Search in sources :

Example 6 with Filter

use of org.hippoecm.hst.content.beans.query.filter.Filter in project hippo by NHS-digital-website.

the class ProjectUpdateFeedComponent method addUpdateTypeFilter.

private void addUpdateTypeFilter(List<BaseFilter> filters, String updateType, HstQuery query) {
    if (StringUtils.isNotBlank(updateType)) {
        Filter filter = query.createFilter();
        try {
            filter.addEqualTo("website:typeofupdate", updateType);
            filters.add(filter);
        } catch (final FilterException exception) {
            log.error("Error trying to add type of update filter", exception);
        }
    }
}
Also used : BaseFilter(org.hippoecm.hst.content.beans.query.filter.BaseFilter) Filter(org.hippoecm.hst.content.beans.query.filter.Filter) FilterException(org.hippoecm.hst.content.beans.query.exceptions.FilterException)

Example 7 with Filter

use of org.hippoecm.hst.content.beans.query.filter.Filter in project hippo by NHS-digital-website.

the class SupplementaryInformationHubComponent method contributeAndFilters.

@Override
protected void contributeAndFilters(List<BaseFilter> filters, HstRequest request, HstQuery query) throws FilterException {
    super.contributeAndFilters(filters, request, query);
    // Add year filter
    final String selectedYear = DocumentUtils.findYearOrDefault(getSelectedYear(request), Calendar.getInstance().get(Calendar.YEAR));
    final Calendar calendar = Calendar.getInstance();
    calendar.set(Calendar.YEAR, Integer.parseInt(selectedYear));
    Filter yearFilter = query.createFilter();
    try {
        yearFilter.addEqualTo("publicationsystem:NominalDate", calendar, DateTools.Resolution.YEAR);
        filters.add(yearFilter);
    } catch (final FilterException exception) {
        log.error("Error trying to add year filter", exception);
    }
    // Add month filter
    final Month selectedMonth = findMonthOrNull(getSelectedMonth(request));
    if (Objects.nonNull(selectedMonth)) {
        calendar.set(Calendar.MONTH, calenderMonthOrdinate(selectedMonth));
        Filter monthFilter = query.createFilter();
        try {
            monthFilter.addEqualTo("publicationsystem:NominalDate", calendar, DateTools.Resolution.MONTH);
            filters.add(monthFilter);
        } catch (final FilterException exception) {
            log.error("Error trying to add year filter", exception);
        }
    }
}
Also used : Month(java.time.Month) Filter(org.hippoecm.hst.content.beans.query.filter.Filter) BaseFilter(org.hippoecm.hst.content.beans.query.filter.BaseFilter) FilterException(org.hippoecm.hst.content.beans.query.exceptions.FilterException)

Example 8 with Filter

use of org.hippoecm.hst.content.beans.query.filter.Filter in project hippo by NHS-digital-website.

the class ProjectUpdateFeedComponent method createQueryFilter.

@Override
protected Filter createQueryFilter(final HstRequest request, final HstQuery query) throws FilterException {
    final String queryParam = getSearchQuery(request);
    if (queryParam == null) {
        return null;
    }
    Filter queryFilter = query.createFilter();
    queryFilter.addContains(".", ComponentUtils.parseAndApplyWildcards(queryParam));
    return queryFilter;
}
Also used : BaseFilter(org.hippoecm.hst.content.beans.query.filter.BaseFilter) Filter(org.hippoecm.hst.content.beans.query.filter.Filter)

Example 9 with Filter

use of org.hippoecm.hst.content.beans.query.filter.Filter in project hippo by NHS-digital-website.

the class SupplementaryInformationHubComponent method createQueryFilter.

@Override
protected Filter createQueryFilter(final HstRequest request, final HstQuery query) throws FilterException {
    Filter queryFilter = null;
    final String queryParam = getSearchQuery(request);
    if (queryParam != null) {
        final String querystring = ComponentUtils.parseAndApplyWildcards(queryParam);
        queryFilter = query.createFilter();
        queryFilter.addContains(".", querystring);
    }
    return queryFilter;
}
Also used : Filter(org.hippoecm.hst.content.beans.query.filter.Filter) BaseFilter(org.hippoecm.hst.content.beans.query.filter.BaseFilter)

Example 10 with Filter

use of org.hippoecm.hst.content.beans.query.filter.Filter in project hippo by NHS-digital-website.

the class ProjectUpdateFeedComponent method addYearFilter.

private void addYearFilter(List<BaseFilter> filters, String year, HstQuery query) {
    final Calendar calendar = Calendar.getInstance();
    calendar.set(Calendar.YEAR, Integer.parseInt(year));
    Filter filter = query.createFilter();
    try {
        filter.addEqualTo("website:updatetimestamp", calendar, DateTools.Resolution.YEAR);
        filters.add(filter);
    } catch (final FilterException exception) {
        log.error("Error trying to add year filter", exception);
    }
}
Also used : BaseFilter(org.hippoecm.hst.content.beans.query.filter.BaseFilter) Filter(org.hippoecm.hst.content.beans.query.filter.Filter) FilterException(org.hippoecm.hst.content.beans.query.exceptions.FilterException)

Aggregations

Filter (org.hippoecm.hst.content.beans.query.filter.Filter)17 BaseFilter (org.hippoecm.hst.content.beans.query.filter.BaseFilter)15 FilterException (org.hippoecm.hst.content.beans.query.exceptions.FilterException)8 HstQuery (org.hippoecm.hst.content.beans.query.HstQuery)4 QueryException (org.hippoecm.hst.content.beans.query.exceptions.QueryException)4 ArrayList (java.util.ArrayList)2 Calendar (java.util.Calendar)2 HstQueryBuilder (org.hippoecm.hst.content.beans.query.builder.HstQueryBuilder)2 HippoBeanIterator (org.hippoecm.hst.content.beans.standard.HippoBeanIterator)2 HstRequestContext (org.hippoecm.hst.core.request.HstRequestContext)2 FeedListComponentInfo (uk.nhs.digital.common.components.info.FeedListComponentInfo)2 Month (java.time.Month)1 Node (javax.jcr.Node)1 GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1 HstQueryManager (org.hippoecm.hst.content.beans.query.HstQueryManager)1 HstQueryResult (org.hippoecm.hst.content.beans.query.HstQueryResult)1 HippoDocument (org.hippoecm.hst.content.beans.standard.HippoDocument)1 JSONObject (org.json.simple.JSONObject)1 EssentialsEventsComponentInfo (org.onehippo.cms7.essentials.components.info.EssentialsEventsComponentInfo)1