use of org.geotools.filter.AttributeExpressionImpl in project ddf by codice.
the class TestCswRecordMapperFilterVisitor method setUpBeforeClass.
@BeforeClass
public static void setUpBeforeClass() throws Exception {
factory = new FilterFactoryImpl();
attrExpr = factory.property(new NameImpl(new QName(CswConstants.DUBLIN_CORE_SCHEMA, UNMAPPED_PROPERTY, CswConstants.DUBLIN_CORE_NAMESPACE_PREFIX)));
created = new AttributeExpressionImpl(new NameImpl(new QName(CswConstants.DUBLIN_CORE_SCHEMA, Core.CREATED, CswConstants.DUBLIN_CORE_NAMESPACE_PREFIX)));
metacardType = CswQueryFactoryTest.getCswMetacardType();
mockMetacardTypeList = new ArrayList<>();
mockMetacardTypeList.add(metacardType);
visitor = new CswRecordMapperFilterVisitor(metacardType, mockMetacardTypeList);
}
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 TwitterFilterVisitor method visit.
/**
* PropertyIsLike filter maps to a Contextual search criteria.
*/
@Override
public Object visit(PropertyIsLike filter, Object data) {
LOGGER.trace("ENTERING: PropertyIsLike filter");
if (currentNest != NestedTypes.NOT) {
LikeFilterImpl likeFilter = (LikeFilterImpl) filter;
AttributeExpressionImpl expression = (AttributeExpressionImpl) likeFilter.getExpression();
String selectors = expression.getPropertyName();
LOGGER.debug("selectors = {}", selectors);
String searchPhrase = likeFilter.getLiteral();
LOGGER.debug("searchPhrase = [{}]", searchPhrase);
if (contextualSearch != null) {
contextualSearch.setSearchPhrase(contextualSearch.getSearchPhrase() + " " + currentNest.toString() + " " + searchPhrase);
} else {
contextualSearch = new ContextualSearch(selectors, searchPhrase, likeFilter.isMatchingCase());
}
}
LOGGER.trace("EXITING: PropertyIsLike filter");
return super.visit(filter, data);
}
use of org.geotools.filter.AttributeExpressionImpl in project coastal-hazards by USGS-CIDA.
the class RibboningProcess method sortFeatures.
// if there's an attribute to sort by, sort by it
public SimpleFeatureCollection sortFeatures(String sortAttribute, SimpleFeatureCollection features) {
SimpleFeatureCollection result = features;
AttributeDescriptor sortAttr = features.getSchema().getDescriptor(sortAttribute);
if (null != sortAttr) {
SortBy sort = new SortByImpl(new AttributeExpressionImpl(sortAttr.getName()), SortOrder.ASCENDING);
result = new SortedSimpleFeatureCollection(features, new SortBy[] { sort });
} else {
LOGGER.log(Level.WARNING, "Could not find sort attribute {0}", sortAttribute);
}
return result;
}
Aggregations