Search in sources :

Example 1 with CopyFilterDelegate

use of ddf.catalog.filter.delegate.CopyFilterDelegate in project ddf by codice.

the class DummyPreQueryPlugin method process.

@Override
public QueryRequest process(QueryRequest input) throws PluginExecutionException, StopProcessingException {
    String methodName = "process";
    LOGGER.trace(ENTERING, methodName);
    QueryRequest newQueryRequest = input;
    if (input != null) {
        Query query = input.getQuery();
        if (query != null) {
            FilterDelegate<Filter> delegate = new CopyFilterDelegate(filterBuilder);
            try {
                // Make a defensive copy of the original filter (just in case anyone else
                // expects
                // it to remain unmodified)
                Filter copiedFilter = filterAdapter.adapt(query, delegate);
                // Define the extra query clause(s) to add to the copied filter
                // This will create a filter with a search phrase of:
                // ((("schematypesearch") and ("test" and ("ISAF" or "CAN"))))
                Filter contextualFilter = filterBuilder.attribute(Metacard.ANY_TEXT).like().text("test");
                Filter releasableToFilter1 = filterBuilder.attribute(Metacard.ANY_TEXT).like().text("ISAF");
                Filter releasableToFilter2 = filterBuilder.attribute(Metacard.ANY_TEXT).like().text("CAN");
                Filter orFilter = filterBuilder.anyOf(releasableToFilter1, releasableToFilter2);
                Filter extraFilter = filterBuilder.allOf(contextualFilter, orFilter);
                // AND this PreQueryPlugin's extra query clause(s) to the copied filter
                Filter modifiedFilter = filterBuilder.allOf(copiedFilter, extraFilter);
                // Create a new QueryRequest using the modified filter and the attributes from
                // the original query
                QueryImpl newQuery = new QueryImpl(modifiedFilter, query.getStartIndex(), query.getPageSize(), query.getSortBy(), query.requestsTotalResultsCount(), query.getTimeoutMillis());
                newQueryRequest = new QueryRequestImpl(newQuery, input.isEnterprise(), input.getSourceIds(), input.getProperties());
            } catch (UnsupportedQueryException e) {
                throw new PluginExecutionException(e);
            }
        }
    }
    LOGGER.trace(EXITING, methodName);
    return newQueryRequest;
}
Also used : QueryImpl(ddf.catalog.operation.impl.QueryImpl) QueryRequest(ddf.catalog.operation.QueryRequest) Query(ddf.catalog.operation.Query) Filter(org.opengis.filter.Filter) CopyFilterDelegate(ddf.catalog.filter.delegate.CopyFilterDelegate) QueryRequestImpl(ddf.catalog.operation.impl.QueryRequestImpl) UnsupportedQueryException(ddf.catalog.source.UnsupportedQueryException) PluginExecutionException(ddf.catalog.plugin.PluginExecutionException)

Example 2 with CopyFilterDelegate

use of ddf.catalog.filter.delegate.CopyFilterDelegate in project ddf by codice.

the class DummyPreSubscriptionPlugin method process.

public Subscription process(Subscription input) throws PluginExecutionException {
    String methodName = "process";
    LOGGER.trace(ENTERING, methodName);
    Subscription newSubscription = input;
    if (input != null) {
        FilterDelegate<Filter> delegate = new CopyFilterDelegate(filterBuilder);
        try {
            // Make a defensive copy of the original filter (just in case anyone else expects
            // it to remain unmodified)
            Filter copiedFilter = filterAdapter.adapt(input, delegate);
            // Define the extra query clause(s) to add to the copied filter
            Filter extraFilter = filterBuilder.attribute(Metacard.ANY_TEXT).like().text("CAN");
            // AND the extra query clause(s) to the copied filter
            Filter modifiedFilter = filterBuilder.allOf(copiedFilter, extraFilter);
            // Create a new subscription with the modified filter
            newSubscription = new SubscriptionImpl(modifiedFilter, input.getDeliveryMethod(), input.getSourceIds(), input.isEnterprise());
        } catch (UnsupportedQueryException e) {
            throw new PluginExecutionException(e);
        }
    }
    LOGGER.trace(EXITING, methodName);
    return newSubscription;
}
Also used : Filter(org.opengis.filter.Filter) CopyFilterDelegate(ddf.catalog.filter.delegate.CopyFilterDelegate) UnsupportedQueryException(ddf.catalog.source.UnsupportedQueryException) Subscription(ddf.catalog.event.Subscription) SubscriptionImpl(ddf.catalog.event.impl.SubscriptionImpl) PluginExecutionException(ddf.catalog.plugin.PluginExecutionException)

Aggregations

CopyFilterDelegate (ddf.catalog.filter.delegate.CopyFilterDelegate)2 PluginExecutionException (ddf.catalog.plugin.PluginExecutionException)2 UnsupportedQueryException (ddf.catalog.source.UnsupportedQueryException)2 Filter (org.opengis.filter.Filter)2 Subscription (ddf.catalog.event.Subscription)1 SubscriptionImpl (ddf.catalog.event.impl.SubscriptionImpl)1 Query (ddf.catalog.operation.Query)1 QueryRequest (ddf.catalog.operation.QueryRequest)1 QueryImpl (ddf.catalog.operation.impl.QueryImpl)1 QueryRequestImpl (ddf.catalog.operation.impl.QueryRequestImpl)1