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;
}
Aggregations