Search in sources :

Example 11 with PropertyName

use of org.opengis.filter.expression.PropertyName in project ddf by codice.

the class TestCswRecordMapperFilterVisitor method testVisitWithUnmappedName.

@Test
public void testVisitWithUnmappedName() {
    CswRecordMapperFilterVisitor visitor = new CswRecordMapperFilterVisitor(metacardType, mockMetacardTypeList);
    PropertyName propertyName = (PropertyName) visitor.visit(attrExpr, null);
    assertThat(propertyName.getPropertyName(), is(UNMAPPED_PROPERTY));
}
Also used : PropertyName(org.opengis.filter.expression.PropertyName) CswQueryFactoryTest(org.codice.ddf.spatial.ogc.csw.catalog.endpoint.CswQueryFactoryTest) Test(org.junit.Test)

Example 12 with PropertyName

use of org.opengis.filter.expression.PropertyName in project ddf by codice.

the class TestCswRecordMapperFilterVisitor method testVisitWithBoundingBoxProperty.

@Test
public void testVisitWithBoundingBoxProperty() {
    AttributeExpressionImpl propName = new AttributeExpressionImpl(new NameImpl(new QName(CswConstants.DUBLIN_CORE_SCHEMA, CswConstants.OWS_BOUNDING_BOX, CswConstants.DUBLIN_CORE_NAMESPACE_PREFIX)));
    CswRecordMapperFilterVisitor visitor = new CswRecordMapperFilterVisitor(metacardType, mockMetacardTypeList);
    PropertyName propertyName = (PropertyName) visitor.visit(propName, null);
    assertThat(propertyName.getPropertyName(), is(Metacard.ANY_GEO));
}
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 13 with PropertyName

use of org.opengis.filter.expression.PropertyName in project ddf by codice.

the class RefreshRegistryEntries method getBasicRegistryQuery.

private Query getBasicRegistryQuery() {
    List<Filter> filters = new ArrayList<>();
    filters.add(filterBuilder.attribute(Metacard.TAGS).is().equalTo().text(RegistryConstants.REGISTRY_TAG));
    PropertyName propertyName = new PropertyNameImpl(Metacard.MODIFIED);
    SortBy sortBy = new SortByImpl(propertyName, SortOrder.ASCENDING);
    QueryImpl query = new QueryImpl(filterBuilder.allOf(filters));
    query.setSortBy(sortBy);
    query.setPageSize(PAGE_SIZE);
    return query;
}
Also used : PropertyName(org.opengis.filter.expression.PropertyName) QueryImpl(ddf.catalog.operation.impl.QueryImpl) Filter(org.opengis.filter.Filter) SortByImpl(org.geotools.filter.SortByImpl) SortBy(org.opengis.filter.sort.SortBy) ArrayList(java.util.ArrayList) PropertyNameImpl(ddf.catalog.filter.impl.PropertyNameImpl)

Example 14 with PropertyName

use of org.opengis.filter.expression.PropertyName in project ddf by codice.

the class SubscriptionFilterVisitor method visit.

/**
     * PropertyIsLike filter maps to a Contextual search criteria.
     */
@Override
public Object visit(PropertyIsLike filter, Object data) {
    LOGGER.debug("ENTERING: PropertyIsLike filter");
    String wildcard = filter.getWildCard();
    String escape = filter.getEscape();
    String single = filter.getSingleChar();
    boolean isFuzzy = false;
    List<String> textPathList = null;
    LikeFilterImpl likeFilter = (LikeFilterImpl) filter;
    Expression expression = likeFilter.getExpression();
    // ContentTypePredicate
    if (expression instanceof PropertyName) {
        PropertyName propertyName = (PropertyName) expression;
        if (Metacard.CONTENT_TYPE.equals(propertyName.getPropertyName())) {
            LOGGER.debug("Expression is ContentType.");
            String typeValue = likeFilter.getLiteral();
            ContentTypePredicate predicate = new ContentTypePredicate(typeValue, null);
            return predicate;
        } else if (Metacard.CONTENT_TYPE_VERSION.equals(propertyName.getPropertyName())) {
            LOGGER.debug("Expression is ContentTypeVersion.");
            String versionValue = likeFilter.getLiteral();
            ContentTypePredicate predicate = new ContentTypePredicate(null, versionValue);
            return predicate;
        }
    }
    if (expression instanceof AttributeExpressionImpl) {
        AttributeExpressionImpl textPathExpression = (AttributeExpressionImpl) expression;
        textPathList = extractXpathSelectors(textPathExpression);
    } else if (expression instanceof FuzzyFunction) {
        FuzzyFunction fuzzyFunction = (FuzzyFunction) expression;
        LOGGER.debug("fuzzy search");
        isFuzzy = true;
        List<Expression> expressions = fuzzyFunction.getParameters();
        AttributeExpressionImpl firstExpression = (AttributeExpressionImpl) expressions.get(0);
        if (!Metacard.ANY_TEXT.equals(firstExpression.getPropertyName())) {
            LOGGER.debug("fuzzy search has a text path section");
            textPathList = extractXpathSelectors(firstExpression);
        }
    }
    String searchPhrase = likeFilter.getLiteral();
    LOGGER.debug("raw searchPhrase = [{}]", searchPhrase);
    String sterilizedSearchPhrase = sterilize(searchPhrase, wildcard, escape, single);
    LOGGER.debug("sterilizedSearchPhrase = [{}]", sterilizedSearchPhrase);
    ContextualPredicate contextPred = new ContextualPredicate(sterilizedSearchPhrase, isFuzzy, likeFilter.isMatchingCase(), textPathList);
    LOGGER.debug("EXITING: PropertyIsLike filter");
    return contextPred;
}
Also used : PropertyName(org.opengis.filter.expression.PropertyName) FuzzyFunction(ddf.catalog.impl.filter.FuzzyFunction) LikeFilterImpl(org.geotools.filter.LikeFilterImpl) Expression(org.opengis.filter.expression.Expression) AttributeExpressionImpl(org.geotools.filter.AttributeExpressionImpl) ContextualPredicate(ddf.catalog.pubsub.predicate.ContextualPredicate) ContentTypePredicate(ddf.catalog.pubsub.predicate.ContentTypePredicate) ArrayList(java.util.ArrayList) List(java.util.List)

Aggregations

PropertyName (org.opengis.filter.expression.PropertyName)14 Test (org.junit.Test)5 SortBy (org.opengis.filter.sort.SortBy)5 AttributeExpressionImpl (org.geotools.filter.AttributeExpressionImpl)4 Result (ddf.catalog.data.Result)3 ArrayList (java.util.ArrayList)3 CswQueryFactoryTest (org.codice.ddf.spatial.ogc.csw.catalog.endpoint.CswQueryFactoryTest)3 NameImpl (org.geotools.feature.NameImpl)3 Filter (org.opengis.filter.Filter)3 FilterBuilder (ddf.catalog.filter.FilterBuilder)2 PropertyNameImpl (ddf.catalog.filter.impl.PropertyNameImpl)2 GeotoolsFilterBuilder (ddf.catalog.filter.proxy.builder.GeotoolsFilterBuilder)2 FuzzyFunction (ddf.catalog.impl.filter.FuzzyFunction)2 QueryRequest (ddf.catalog.operation.QueryRequest)2 QueryResponse (ddf.catalog.operation.QueryResponse)2 QueryImpl (ddf.catalog.operation.impl.QueryImpl)2 DistanceResultComparator (ddf.catalog.util.impl.DistanceResultComparator)2 RelevanceResultComparator (ddf.catalog.util.impl.RelevanceResultComparator)2 TemporalResultComparator (ddf.catalog.util.impl.TemporalResultComparator)2 Serializable (java.io.Serializable)2