Search in sources :

Example 6 with ComparisonFilter

use of org.n52.shetland.ogc.filter.ComparisonFilter in project arctic-sea by 52North.

the class GetObservationRequest method setResultFilter.

public GetObservationRequest setResultFilter(ComparisonFilter filter) {
    this.resultFilter = filter;
    addExtension(new ResultFilter(filter));
    return this;
}
Also used : ResultFilter(org.n52.shetland.ogc.sos.ResultFilter)

Example 7 with ComparisonFilter

use of org.n52.shetland.ogc.filter.ComparisonFilter in project arctic-sea by 52North.

the class ODataFesParserTest method testContains.

@Test
public void testContains() throws DecodingException {
    Filter<?> filter = parser.decode("contains(textValue,'as%df')");
    assertThat(filter, is(instanceOf(ComparisonFilter.class)));
    ComparisonFilter cf = (ComparisonFilter) filter;
    errors.checkThat(cf.getOperator(), is(ComparisonOperator.PropertyIsLike));
    errors.checkThat(cf.getValue(), is("%as%df%"));
    errors.checkThat(cf.getValueReference(), is("om:result"));
}
Also used : ComparisonFilter(org.n52.shetland.ogc.filter.ComparisonFilter) Test(org.junit.Test)

Example 8 with ComparisonFilter

use of org.n52.shetland.ogc.filter.ComparisonFilter in project arctic-sea by 52North.

the class FesDecoderv20 method parsePropertyIsLikeFilter.

/**
 * Parse XML propertyIsLike element
 *
 * @param comparisonOpsType
 *            XML propertyIsLike element
 * @return SOS comparison filter
 * @throws DecodingException
 *             If an error occurs of the filter is not supported!
 */
private ComparisonFilter parsePropertyIsLikeFilter(PropertyIsLikeType comparisonOpsType) throws DecodingException {
    ComparisonFilter comparisonFilter = new ComparisonFilter();
    comparisonFilter.setOperator(ComparisonOperator.PropertyIsLike);
    comparisonFilter.setEscapeString(comparisonOpsType.getEscapeChar());
    comparisonFilter.setSingleChar(comparisonOpsType.getSingleChar());
    comparisonFilter.setWildCard(comparisonOpsType.getWildCard());
    parseExpressions(comparisonOpsType.getExpressionArray(), comparisonFilter);
    return comparisonFilter;
}
Also used : ComparisonFilter(org.n52.shetland.ogc.filter.ComparisonFilter)

Example 9 with ComparisonFilter

use of org.n52.shetland.ogc.filter.ComparisonFilter in project arctic-sea by 52North.

the class FesDecoderV20Test method should_parse_PropertyIsEqualTo_Filter.

/**
 * Test PropertyIsEqualTo filter decoding
 *
 * @throws OwsExceptionReport
 */
@Test
public void should_parse_PropertyIsEqualTo_Filter() throws DecodingException {
    PropertyIsEqualToDocument propertyIsEqualToDoc = PropertyIsEqualToDocument.Factory.newInstance();
    BinaryComparisonOpType propertyIsEqualToType = propertyIsEqualToDoc.addNewPropertyIsEqualTo();
    // valueReference
    XmlString valueReference = (XmlString) propertyIsEqualToType.addNewExpression().substitute(FilterConstants.QN_VALUE_REFERENCE, XmlString.type);
    valueReference.setStringValue(TEST_VALUE_REFERENCE);
    // literal
    LiteralType literalType = (LiteralType) propertyIsEqualToType.addNewExpression().substitute(FilterConstants.QN_LITERAL, LiteralType.type);
    XmlString newInstance = XmlString.Factory.newInstance();
    newInstance.setStringValue(TEST_LITERAL);
    literalType.set(newInstance);
    // create document
    FilterDocument filterDoc = FilterDocument.Factory.newInstance();
    FilterType filterType = filterDoc.addNewFilter();
    filterType.setComparisonOps(propertyIsEqualToType);
    filterType.getComparisonOps().substitute(FilterConstants.QN_PROPERTY_IS_EQUAL_TO, BinaryComparisonOpType.type);
    ComparisonFilter comparisonFilter = (ComparisonFilter) decoder.decode(filterDoc);
    // test
    assertThat(comparisonFilter.getOperator(), is(FilterConstants.ComparisonOperator.PropertyIsEqualTo));
    assertThat(comparisonFilter.getValueReference(), is(TEST_VALUE_REFERENCE));
    assertThat(comparisonFilter.getValue(), is(TEST_LITERAL));
}
Also used : PropertyIsEqualToDocument(net.opengis.fes.x20.PropertyIsEqualToDocument) FilterType(net.opengis.fes.x20.FilterType) ComparisonFilter(org.n52.shetland.ogc.filter.ComparisonFilter) XmlString(org.apache.xmlbeans.XmlString) LiteralType(net.opengis.fes.x20.LiteralType) FilterDocument(net.opengis.fes.x20.FilterDocument) BinaryComparisonOpType(net.opengis.fes.x20.BinaryComparisonOpType) Test(org.junit.Test)

Aggregations

ComparisonFilter (org.n52.shetland.ogc.filter.ComparisonFilter)8 Test (org.junit.Test)5 LiteralType (net.opengis.fes.x20.LiteralType)2 BinaryComparisonOpType (net.opengis.fes.x20.BinaryComparisonOpType)1 FilterDocument (net.opengis.fes.x20.FilterDocument)1 FilterType (net.opengis.fes.x20.FilterType)1 PropertyIsEqualToDocument (net.opengis.fes.x20.PropertyIsEqualToDocument)1 XmlException (org.apache.xmlbeans.XmlException)1 XmlString (org.apache.xmlbeans.XmlString)1 ResultFilter (org.n52.shetland.ogc.sos.ResultFilter)1 UnsupportedDecoderXmlInputException (org.n52.svalbard.decode.exception.UnsupportedDecoderXmlInputException)1