Search in sources :

Example 1 with AttributeExpressionImpl

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);
}
Also used : NameImpl(org.geotools.feature.NameImpl) AttributeExpressionImpl(org.geotools.filter.AttributeExpressionImpl) QName(javax.xml.namespace.QName) FilterFactoryImpl(org.geotools.filter.FilterFactoryImpl) BeforeClass(org.junit.BeforeClass)

Example 2 with AttributeExpressionImpl

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));
}
Also used : NameImpl(org.geotools.feature.NameImpl) Expression(org.opengis.filter.expression.Expression) AttributeExpressionImpl(org.geotools.filter.AttributeExpressionImpl) QName(javax.xml.namespace.QName) Date(java.util.Date) During(org.opengis.filter.temporal.During) PropertyIsGreaterThan(org.opengis.filter.PropertyIsGreaterThan) CswQueryFactoryTest(org.codice.ddf.spatial.ogc.csw.catalog.endpoint.CswQueryFactoryTest) Test(org.junit.Test)

Example 3 with AttributeExpressionImpl

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)));
}
Also used : NameImpl(org.geotools.feature.NameImpl) PropertyName(org.opengis.filter.expression.PropertyName) AttributeExpressionImpl(org.geotools.filter.AttributeExpressionImpl) QName(javax.xml.namespace.QName) CswQueryFactoryTest(org.codice.ddf.spatial.ogc.csw.catalog.endpoint.CswQueryFactoryTest) Test(org.junit.Test)

Example 4 with AttributeExpressionImpl

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);
}
Also used : LikeFilterImpl(org.geotools.filter.LikeFilterImpl) AttributeExpressionImpl(org.geotools.filter.AttributeExpressionImpl)

Example 5 with AttributeExpressionImpl

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;
}
Also used : SortedSimpleFeatureCollection(org.geotools.feature.collection.SortedSimpleFeatureCollection) SortByImpl(org.geotools.filter.SortByImpl) AttributeExpressionImpl(org.geotools.filter.AttributeExpressionImpl) SortBy(org.opengis.filter.sort.SortBy) AttributeDescriptor(org.opengis.feature.type.AttributeDescriptor) SortedSimpleFeatureCollection(org.geotools.feature.collection.SortedSimpleFeatureCollection) SimpleFeatureCollection(org.geotools.data.simple.SimpleFeatureCollection)

Aggregations

AttributeExpressionImpl (org.geotools.filter.AttributeExpressionImpl)50 LiteralExpressionImpl (org.geotools.filter.LiteralExpressionImpl)20 Expression (org.opengis.filter.expression.Expression)19 NameImpl (org.geotools.feature.NameImpl)13 Test (org.junit.Test)10 PropertyName (org.opengis.filter.expression.PropertyName)10 LikeFilterImpl (org.geotools.filter.LikeFilterImpl)9 ArrayList (java.util.ArrayList)8 QName (javax.xml.namespace.QName)8 FunctionExpressionImpl (org.geotools.filter.FunctionExpressionImpl)7 MathExpressionImpl (org.geotools.filter.MathExpressionImpl)7 CswQueryFactoryTest (org.codice.ddf.spatial.ogc.csw.catalog.endpoint.CswQueryFactoryTest)6 FilterFactoryImpl (org.geotools.filter.FilterFactoryImpl)5 HashMap (java.util.HashMap)4 FieldIdEnum (com.sldeditor.common.xml.ui.FieldIdEnum)3 FieldConfigCommonData (com.sldeditor.ui.detail.config.FieldConfigCommonData)3 ContentTypePredicate (ddf.catalog.pubsub.predicate.ContentTypePredicate)3 ContextualPredicate (ddf.catalog.pubsub.predicate.ContextualPredicate)3 Date (java.util.Date)3 FunctionExpression (org.geotools.filter.FunctionExpression)3