Search in sources :

Example 11 with PropertyIsLike

use of org.opengis.filter.PropertyIsLike in project sldeditor by robward-scisys.

the class ExtractAttributes method copy.

/**
 * (non-Javadoc)
 *
 * @see org.geotools.styling.visitor.DuplicatingStyleVisitor#copy(org.opengis.filter.Filter)
 */
protected Filter copy(Filter filter) {
    if (filter instanceof NotImpl) {
        copy(((NotImpl) filter).getFilter());
    } else if (filter instanceof LogicFilterImpl) {
        LogicFilterImpl logicFilter = (LogicFilterImpl) filter;
        for (Filter childFilter : logicFilter.getChildren()) {
            copy(childFilter);
        }
    } else if (filter instanceof MultiCompareFilterImpl) {
        MultiCompareFilterImpl multiCompareFilter = (MultiCompareFilterImpl) filter;
        List<String> foundList1 = new ArrayList<String>();
        Class<?> returnType1 = extractAttribute(String.class, multiCompareFilter.getExpression1(), foundList1);
        List<String> foundList2 = new ArrayList<String>();
        Class<?> returnType2 = extractAttribute(String.class, multiCompareFilter.getExpression2(), foundList2);
        determineTypeFromExpressions(foundList1, returnType1, foundList2, returnType2);
    } else if (filter instanceof BinaryTemporalOperator) {
        BinaryTemporalOperator binaryTemporalOperator = (BinaryTemporalOperator) filter;
        List<String> foundList1 = new ArrayList<String>();
        Class<?> returnType1 = extractAttribute(String.class, binaryTemporalOperator.getExpression1(), foundList1);
        List<String> foundList2 = new ArrayList<String>();
        Class<?> returnType2 = extractAttribute(String.class, binaryTemporalOperator.getExpression2(), foundList2);
        determineTypeFromExpressions(foundList1, returnType1, foundList2, returnType2);
    } else if (filter instanceof BinarySpatialOperator) {
        BinarySpatialOperator binarySpatialOperator = (BinarySpatialOperator) filter;
        List<String> foundList1 = new ArrayList<String>();
        Class<?> returnType1 = extractAttribute(String.class, binarySpatialOperator.getExpression1(), foundList1);
        List<String> foundList2 = new ArrayList<String>();
        Class<?> returnType2 = extractAttribute(String.class, binarySpatialOperator.getExpression2(), foundList2);
        determineTypeFromExpressions(foundList1, returnType1, foundList2, returnType2);
    } else if (filter instanceof PropertyIsBetween) {
        PropertyIsBetween isBetween = (PropertyIsBetween) filter;
        List<String> foundList1 = new ArrayList<String>();
        Class<?> returnType1 = extractAttribute(String.class, isBetween.getLowerBoundary(), foundList1);
        List<String> foundList2 = new ArrayList<String>();
        Class<?> returnType2 = extractAttribute(String.class, isBetween.getExpression(), foundList2);
        List<String> foundList3 = new ArrayList<String>();
        Class<?> returnType3 = extractAttribute(String.class, isBetween.getUpperBoundary(), foundList3);
        determineTypeFromExpressions(foundList1, returnType1, foundList2, returnType2, foundList3, returnType3);
    } else if (filter instanceof PropertyIsNull) {
        PropertyIsNull isNull = (PropertyIsNull) filter;
        List<String> foundList1 = new ArrayList<String>();
        extractAttribute(String.class, isNull.getExpression(), foundList1);
    } else if (filter instanceof PropertyIsLike) {
        PropertyIsLike isLike = (PropertyIsLike) filter;
        List<String> foundList1 = new ArrayList<String>();
        extractAttribute(String.class, isLike.getExpression(), foundList1);
    }
    return super.copy(filter);
}
Also used : PropertyIsLike(org.opengis.filter.PropertyIsLike) NotImpl(org.geotools.filter.NotImpl) ArrayList(java.util.ArrayList) LineString(com.vividsolutions.jts.geom.LineString) BinaryTemporalOperator(org.opengis.filter.temporal.BinaryTemporalOperator) PropertyIsNull(org.opengis.filter.PropertyIsNull) Filter(org.opengis.filter.Filter) MultiCompareFilterImpl(org.geotools.filter.MultiCompareFilterImpl) LogicFilterImpl(org.geotools.filter.LogicFilterImpl) ArrayList(java.util.ArrayList) List(java.util.List) PropertyIsBetween(org.opengis.filter.PropertyIsBetween) BinarySpatialOperator(org.opengis.filter.spatial.BinarySpatialOperator)

Example 12 with PropertyIsLike

use of org.opengis.filter.PropertyIsLike in project ddf by codice.

the class OpenSearchFilterVisitorTest method testPropertyIsLike.

@Test
public void testPropertyIsLike() {
    PropertyIsLike textLikeFilter = (PropertyIsLike) geotoolsFilterBuilder.attribute(SOME_ATTRIBUTE_NAME).is().like().text(TEST_STRING);
    OpenSearchFilterVisitorObject openSearchFilterVisitorObject = new OpenSearchFilterVisitorObject();
    OpenSearchFilterVisitorObject result = (OpenSearchFilterVisitorObject) openSearchFilterVisitor.visit(textLikeFilter, openSearchFilterVisitorObject);
    assertThat(result.getContextualSearch(), allOf(is(notNullValue()), hasProperty("searchPhraseMap", hasEntry(OpenSearchConstants.SEARCH_TERMS, TEST_STRING))));
}
Also used : PropertyIsLike(org.opengis.filter.PropertyIsLike) Test(org.junit.Test)

Example 13 with PropertyIsLike

use of org.opengis.filter.PropertyIsLike in project ddf by codice.

the class CswQueryFactoryTest method testPostGetRecordsContextualCQLQuery.

@Test
public void testPostGetRecordsContextualCQLQuery() throws CswException, UnsupportedQueryException, SourceUnavailableException, FederationException {
    GetRecordsType grr = createDefaultPostRecordsRequest();
    QueryType query = new QueryType();
    List<QName> typeNames = new ArrayList<>();
    typeNames.add(new QName(CswConstants.CSW_OUTPUT_SCHEMA, VALID_TYPE, VALID_PREFIX));
    query.setTypeNames(typeNames);
    QueryConstraintType constraint = new QueryConstraintType();
    constraint.setCqlText(CQL_CONTEXTUAL_LIKE_QUERY);
    query.setConstraint(constraint);
    JAXBElement<QueryType> jaxbQuery = new JAXBElement<>(cswQnameOutPutSchema, QueryType.class, query);
    grr.setAbstractQuery(jaxbQuery);
    QueryRequest queryRequest = queryFactory.getQuery(grr);
    QueryImpl frameworkQuery = (QueryImpl) queryRequest.getQuery();
    Filter queryFilter = ((QueryImpl) frameworkQuery.getFilter()).getFilter();
    assertThat(queryFilter, instanceOf(PropertyIsLike.class));
    PropertyIsLike like = (PropertyIsLike) queryFilter;
    assertThat(like.getLiteral(), is(CQL_CONTEXTUAL_PATTERN));
    assertThat(((AttributeExpressionImpl) like.getExpression()).getPropertyName(), is(CQL_FRAMEWORK_TEST_ATTRIBUTE));
}
Also used : QueryImpl(ddf.catalog.operation.impl.QueryImpl) PropertyIsLike(org.opengis.filter.PropertyIsLike) QueryRequest(ddf.catalog.operation.QueryRequest) Filter(org.opengis.filter.Filter) QName(javax.xml.namespace.QName) ArrayList(java.util.ArrayList) GetRecordsType(net.opengis.cat.csw.v_2_0_2.GetRecordsType) JAXBElement(javax.xml.bind.JAXBElement) QueryType(net.opengis.cat.csw.v_2_0_2.QueryType) QueryConstraintType(net.opengis.cat.csw.v_2_0_2.QueryConstraintType) Test(org.junit.Test)

Aggregations

PropertyIsLike (org.opengis.filter.PropertyIsLike)13 Test (org.junit.Test)8 Filter (org.opengis.filter.Filter)7 Expression (org.opengis.filter.expression.Expression)6 ArrayList (java.util.ArrayList)5 LogicFilterImpl (org.geotools.filter.LogicFilterImpl)4 PropertyIsBetween (org.opengis.filter.PropertyIsBetween)4 PropertyIsNull (org.opengis.filter.PropertyIsNull)4 BinarySpatialOperator (org.opengis.filter.spatial.BinarySpatialOperator)4 BinaryTemporalOperator (org.opengis.filter.temporal.BinaryTemporalOperator)4 CswQueryFactoryTest (org.codice.ddf.spatial.ogc.csw.catalog.endpoint.CswQueryFactoryTest)3 BinaryComparisonAbstract (org.geotools.filter.BinaryComparisonAbstract)3 Not (org.opengis.filter.Not)3 FilterConfigInterface (com.sldeditor.filter.v2.function.FilterConfigInterface)2 GeotoolsFilterBuilder (ddf.catalog.filter.proxy.builder.GeotoolsFilterBuilder)2 List (java.util.List)2 FidFilterImpl (org.geotools.filter.FidFilterImpl)2 PropertyIsGreaterThan (org.opengis.filter.PropertyIsGreaterThan)2 FilterName (com.sldeditor.filter.v2.function.FilterName)1 LineString (com.vividsolutions.jts.geom.LineString)1