use of org.geotools.filter.AttributeExpressionImpl in project ddf by codice.
the class TestCswRecordMapperFilterVisitor method testVisitPropertyIsGreaterThanTemporal.
@Test
public void testVisitPropertyIsGreaterThanTemporal() {
Expression val = factory.literal(new Date(System.currentTimeMillis() - 1000));
Expression test = new AttributeExpressionImpl(new NameImpl(new QName(CswConstants.DUBLIN_CORE_SCHEMA, "TestDate", CswConstants.DUBLIN_CORE_NAMESPACE_PREFIX)));
PropertyIsGreaterThan filter = factory.greater(test, val);
Object obj = visitor.visit(filter, null);
assertThat(obj, instanceOf(During.class));
During duplicate = (During) obj;
assertThat(duplicate.getExpression1(), is(test));
assertThat(duplicate.getExpression2(), is(val));
}
use of org.geotools.filter.AttributeExpressionImpl in project ddf by codice.
the class TestCswRecordMapperFilterVisitor method testVisitWithMappedName.
@Test
public void testVisitWithMappedName() {
AttributeExpressionImpl propName = new AttributeExpressionImpl(new NameImpl(new QName(CswConstants.DUBLIN_CORE_SCHEMA, CswConstants.CSW_ALTERNATIVE, CswConstants.DUBLIN_CORE_NAMESPACE_PREFIX)));
CswRecordMapperFilterVisitor visitor = new CswRecordMapperFilterVisitor(metacardType, mockMetacardTypeList);
PropertyName propertyName = (PropertyName) visitor.visit(propName, null);
assertThat(propertyName.getPropertyName(), is(Core.TITLE));
assertThat(propertyName.getPropertyName(), not(is(CswConstants.CSW_ALTERNATIVE)));
}
use of org.geotools.filter.AttributeExpressionImpl in project ddf by codice.
the class MockQuery method addContextualFilter.
public void addContextualFilter(String searchTerm, String selector) {
Filter filter = null;
if (selector != null) {
List<Filter> xpathFilters = new ArrayList<Filter>();
String[] selectors = selector.split(",");
for (int i = 0; i < selectors.length; i++) {
Expression xpathRef = new AttributeExpressionImpl(selectors[i]);
filter = FILTER_FACTORY.like(xpathRef, searchTerm);
xpathFilters.add(filter);
}
filter = FILTER_FACTORY.or(xpathFilters);
} else {
filter = FILTER_FACTORY.like(FILTER_FACTORY.property(Metacard.ANY_TEXT), searchTerm);
}
if (filter != null) {
filters.add(filter);
this.filter = getFilter();
}
}
use of org.geotools.filter.AttributeExpressionImpl in project ddf by codice.
the class CswQueryFactory method buildSort.
private SortBy buildSort(SortByType sort) throws CswException {
if (sort == null || sort.getSortProperty() == null) {
return null;
}
SortBy[] sortByArr = parseSortBy(sort);
if (sortByArr.length > 1) {
LOGGER.debug("Query request has multiple sort criteria, only primary will be used");
}
SortBy sortBy = sortByArr[0];
if (sortBy.getPropertyName() == null) {
LOGGER.debug("No property name in primary sort criteria");
return null;
}
if (!attributeRegistry.lookup(sortBy.getPropertyName().getPropertyName()).isPresent() && !DefaultCswRecordMap.hasDefaultMetacardFieldForPrefixedString(sortBy.getPropertyName().getPropertyName(), sortBy.getPropertyName().getNamespaceContext())) {
throw new CswException("Property " + sortBy.getPropertyName().getPropertyName() + " is not a valid SortBy Field", CswConstants.INVALID_PARAMETER_VALUE, "SortProperty");
}
String name = DefaultCswRecordMap.getDefaultMetacardFieldForPrefixedString(sortBy.getPropertyName().getPropertyName(), sortBy.getPropertyName().getNamespaceContext());
PropertyName propName = new AttributeExpressionImpl(new NameImpl(name));
return new SortByImpl(propName, sortBy.getSortOrder());
}
use of org.geotools.filter.AttributeExpressionImpl in project ddf by codice.
the class OpenSearchQueryTest method verifyContextualFilter.
// private Document getDocument( String xml ) throws Exception
// {
// DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
// factory.setNamespaceAware( true );
// DocumentBuilder builder = factory.newDocumentBuilder();
// StringReader reader = new StringReader( xml );
// InputSource inputSource = new InputSource( reader );
// Document doc = builder.parse( inputSource );
// reader.close();
//
// return doc;
// }
// private String getFilterAsXml( Filter filter ) throws Exception
// {
// FilterTransformer transform = new FilterTransformer();
// transform.setIndentation( 2 );
// String filterXml = transform.transform( filter );
// LOGGER.debug( filterXml );
//
// return filterXml;
// }
private void verifyContextualFilter(Filter filter, String expectedPropertyName, String expectedSearchTerm) throws Exception {
LikeFilterImpl likeFilter = (LikeFilterImpl) filter;
AttributeExpressionImpl expression = (AttributeExpressionImpl) likeFilter.getExpression();
LOGGER.debug("propertyName = {}", expression.getPropertyName());
assertEquals(expectedPropertyName, expression.getPropertyName());
String extractedSearchTerm = likeFilter.getLiteral();
LOGGER.debug("extractedSearchTerm = [{}]", extractedSearchTerm);
assertEquals(expectedSearchTerm, extractedSearchTerm);
}
Aggregations