Search in sources :

Example 1 with EntryPredicate

use of ddf.catalog.pubsub.predicate.EntryPredicate in project ddf by codice.

the class SubscriptionFilterVisitor method visit.

/**
     * PropertyIsEqualTo filter maps to a Type/Version(s) and Entry search criteria.
     */
@Override
public Object visit(PropertyIsEqualTo filter, Object data) {
    LOGGER.debug("ENTERING: PropertyIsEqualTo filter");
    // TODO: consider if the contentType parameters are invalid (i.e. anything where type is
    // null)
    AttributeExpressionImpl exp1 = (AttributeExpressionImpl) filter.getExpression1();
    String propertyName = exp1.getPropertyName();
    LiteralExpressionImpl exp2 = (LiteralExpressionImpl) filter.getExpression2();
    Predicate predicate = null;
    if (Metacard.ID.equals(propertyName)) {
        String entryId = (String) exp2.getValue();
        LOGGER.debug("entry id for new entry predicate: {}", entryId);
        predicate = new EntryPredicate(entryId);
    } else if (Metacard.CONTENT_TYPE.equals(propertyName)) {
        String typeValue = (String) exp2.getValue();
        predicate = new ContentTypePredicate(typeValue, null);
    } else if (Metacard.CONTENT_TYPE_VERSION.equals(propertyName)) {
        String versionValue = (String) exp2.getValue();
        predicate = new ContentTypePredicate(null, versionValue);
    } else if (Metacard.RESOURCE_URI.equals(propertyName)) {
        URI productUri = null;
        if (exp2.getValue() instanceof URI) {
            productUri = (URI) exp2.getValue();
            predicate = new EntryPredicate(productUri);
        } else {
            try {
                productUri = new URI((String) exp2.getValue());
                predicate = new EntryPredicate(productUri);
            } catch (URISyntaxException e) {
                LOGGER.debug("URI Syntax exception creating EntryPredicate", e);
                throw new UnsupportedOperationException("Could not create a URI object from the given ResourceURI.", e);
            }
        }
    }
    LOGGER.debug("EXITING: PropertyIsEqualTo filter");
    return predicate;
}
Also used : AttributeExpressionImpl(org.geotools.filter.AttributeExpressionImpl) LiteralExpressionImpl(org.geotools.filter.LiteralExpressionImpl) ContentTypePredicate(ddf.catalog.pubsub.predicate.ContentTypePredicate) URISyntaxException(java.net.URISyntaxException) EntryPredicate(ddf.catalog.pubsub.predicate.EntryPredicate) URI(java.net.URI) GeospatialPredicate(ddf.catalog.pubsub.predicate.GeospatialPredicate) ContentTypePredicate(ddf.catalog.pubsub.predicate.ContentTypePredicate) EntryPredicate(ddf.catalog.pubsub.predicate.EntryPredicate) TemporalPredicate(ddf.catalog.pubsub.predicate.TemporalPredicate) ContextualPredicate(ddf.catalog.pubsub.predicate.ContextualPredicate) Predicate(ddf.catalog.pubsub.predicate.Predicate)

Aggregations

ContentTypePredicate (ddf.catalog.pubsub.predicate.ContentTypePredicate)1 ContextualPredicate (ddf.catalog.pubsub.predicate.ContextualPredicate)1 EntryPredicate (ddf.catalog.pubsub.predicate.EntryPredicate)1 GeospatialPredicate (ddf.catalog.pubsub.predicate.GeospatialPredicate)1 Predicate (ddf.catalog.pubsub.predicate.Predicate)1 TemporalPredicate (ddf.catalog.pubsub.predicate.TemporalPredicate)1 URI (java.net.URI)1 URISyntaxException (java.net.URISyntaxException)1 AttributeExpressionImpl (org.geotools.filter.AttributeExpressionImpl)1 LiteralExpressionImpl (org.geotools.filter.LiteralExpressionImpl)1