use of org.geotools.filter.AttributeExpressionImpl in project ddf by codice.
the class OpenSearchQueryTest method verifyEqualsFilter.
private void verifyEqualsFilter(Filter filter, String expectedPropertyName, String expectedValue) {
assertTrue(filter instanceof IsEqualsToImpl);
IsEqualsToImpl equalsFilter = (IsEqualsToImpl) filter;
AttributeExpressionImpl expression1 = (AttributeExpressionImpl) equalsFilter.getExpression1();
LOGGER.debug("propertyName = {}", expression1.getPropertyName());
assertEquals(expectedPropertyName, expression1.getPropertyName());
LiteralExpressionImpl expression2 = (LiteralExpressionImpl) equalsFilter.getExpression2();
LOGGER.debug("version to search for = {}", expression2.getValue());
assertEquals(expectedValue, expression2.getValue());
}
use of org.geotools.filter.AttributeExpressionImpl in project ddf by codice.
the class SubscriptionFilterVisitor method visit.
/**
* During filter maps to a Temporal (Absolute and Modified) search criteria.
*/
@Override
public Object visit(During filter, Object data) {
LOGGER.debug("ENTERING: During filter");
AttributeExpressionImpl temporalTypeAttribute = (AttributeExpressionImpl) filter.getExpression1();
String temporalType = temporalTypeAttribute.getPropertyName();
LiteralExpressionImpl timePeriodLiteral = (LiteralExpressionImpl) filter.getExpression2();
Object literal = timePeriodLiteral.getValue();
Predicate returnPredicate = null;
if (literal instanceof Period) {
Period timePeriod = (Period) literal;
// Extract the start and end dates from the OGC TOverlaps filter
Date start = timePeriod.getBeginning().getPosition().getDate();
Date end = timePeriod.getEnding().getPosition().getDate();
LOGGER.debug("time period lowerBound = {}", start);
LOGGER.debug("time period upperBound = {}", end);
LOGGER.debug("EXITING: (temporal) filter");
returnPredicate = new TemporalPredicate(start, end, DateType.getDateType(temporalType));
// CREATE RELATIVE
} else if (literal instanceof PeriodDuration) {
DefaultPeriodDuration duration = (DefaultPeriodDuration) literal;
long offset = duration.getTimeInMillis();
LOGGER.debug("EXITING: (temporal) filter");
returnPredicate = new TemporalPredicate(offset, DateType.getDateType(temporalType));
}
LOGGER.debug("temporalType: {}", temporalType);
LOGGER.debug("Temporal Predicate: {}", returnPredicate);
LOGGER.debug("EXITING: During filter");
return returnPredicate;
}
use of org.geotools.filter.AttributeExpressionImpl 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;
}
use of org.geotools.filter.AttributeExpressionImpl in project ddf by codice.
the class MockQuery method addContextualFilter.
public void addContextualFilter(String searchPhrase, String textPathSections, boolean caseSensitive) {
Filter filter = null;
if (searchPhrase != null) {
if (textPathSections != null) {
List<Filter> xpathFilters = new ArrayList<Filter>();
String[] selectors = textPathSections.split(",");
for (int i = 0; i < selectors.length; i++) {
Expression xpathRef = new AttributeExpressionImpl(selectors[i]);
filter = FILTER_FACTORY.like(xpathRef, searchPhrase);
xpathFilters.add(filter);
}
filter = FILTER_FACTORY.or(xpathFilters);
} else {
filter = FILTER_FACTORY.like(FILTER_FACTORY.property(Metacard.ANY_TEXT), searchPhrase, SubscriptionFilterVisitor.LUCENE_WILDCARD_CHAR, SubscriptionFilterVisitor.LUCENE_SINGLE_CHAR, SubscriptionFilterVisitor.LUCENE_ESCAPE_CHAR, caseSensitive);
}
if (filter != null) {
filters.add(filter);
}
}
}
use of org.geotools.filter.AttributeExpressionImpl in project ddf by codice.
the class PropertyMapperVisitorTest method testPropertyMapperVisitPassThrough.
@Test
public void testPropertyMapperVisitPassThrough() {
Map<String, String> map = new HashMap<>();
map.put("prop", "newProp");
PropertyMapperVisitor mapper = new PropertyMapperVisitor(map);
PropertyName propertyName = new PropertyNameImpl("myprop");
AttributeExpressionImpl exp = (AttributeExpressionImpl) mapper.visit(propertyName, new FilterFactoryImpl());
assertThat(exp.getPropertyName(), equalTo("myprop"));
}
Aggregations