Search in sources :

Example 1 with ComparisonFilter

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

the class ODataFesParserTest method testEndswith.

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

Example 2 with ComparisonFilter

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

the class ODataFesParserTest method testStartswith.

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

Example 3 with ComparisonFilter

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

the class FesDecoderv20 method parsePropertyIsBetweenFilter.

/**
 * Parse XML propertyIsBetween element
 *
 * @param comparisonOpsType
 *            XML propertyIsBetween element
 * @return SOS comparison filter
 * @throws DecodingException
 *             If an error occurs of the filter is not supported
 */
private ComparisonFilter parsePropertyIsBetweenFilter(PropertyIsBetweenType comparisonOpsType) throws DecodingException {
    ComparisonFilter comparisonFilter = new ComparisonFilter();
    comparisonFilter.setOperator(ComparisonOperator.PropertyIsBetween);
    try {
        comparisonFilter.setValueReference(parseValueReference(comparisonOpsType.getExpression()));
    } catch (XmlException xmle) {
        throw valueReferenceParsingException(xmle);
    }
    if (comparisonOpsType.getLowerBoundary().getExpression() instanceof LiteralType) {
        comparisonFilter.setValue(parseLiteralValue((LiteralType) comparisonOpsType.getLowerBoundary().getExpression()));
    }
    if (comparisonOpsType.getUpperBoundary().getExpression() instanceof LiteralType) {
        comparisonFilter.setValueUpper(parseLiteralValue((LiteralType) comparisonOpsType.getUpperBoundary().getExpression()));
    }
    return comparisonFilter;
}
Also used : ComparisonFilter(org.n52.shetland.ogc.filter.ComparisonFilter) XmlException(org.apache.xmlbeans.XmlException) LiteralType(net.opengis.fes.x20.LiteralType)

Example 4 with ComparisonFilter

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

the class FesDecoderv20 method parseBinaryComparisonFilter.

private ComparisonFilter parseBinaryComparisonFilter(BinaryComparisonOpType comparisonOpsType) throws DecodingException {
    ComparisonFilter comparisonFilter = new ComparisonFilter();
    String localName = XmlHelper.getLocalName(comparisonOpsType);
    if (ComparisonOperator.PropertyIsEqualTo.name().equals(localName)) {
        comparisonFilter.setOperator(ComparisonOperator.PropertyIsEqualTo);
    } else if (ComparisonOperator.PropertyIsNotEqualTo.name().equals(localName)) {
        comparisonFilter.setOperator(ComparisonOperator.PropertyIsNotEqualTo);
    } else if (ComparisonOperator.PropertyIsLessThan.name().equals(localName)) {
        comparisonFilter.setOperator(ComparisonOperator.PropertyIsLessThan);
    } else if (ComparisonOperator.PropertyIsGreaterThan.name().equals(localName)) {
        comparisonFilter.setOperator(ComparisonOperator.PropertyIsGreaterThan);
    } else if (ComparisonOperator.PropertyIsLessThanOrEqualTo.name().equals(localName)) {
        comparisonFilter.setOperator(ComparisonOperator.PropertyIsLessThanOrEqualTo);
    } else if (ComparisonOperator.PropertyIsGreaterThanOrEqualTo.name().equals(localName)) {
        comparisonFilter.setOperator(ComparisonOperator.PropertyIsGreaterThanOrEqualTo);
    } else {
        throw new UnsupportedDecoderXmlInputException(this, comparisonOpsType);
    }
    if (comparisonOpsType.isSetMatchCase()) {
        comparisonFilter.setMatchCase(comparisonOpsType.getMatchCase());
    }
    parseExpressions(comparisonOpsType.getExpressionArray(), comparisonFilter);
    return comparisonFilter;
}
Also used : ComparisonFilter(org.n52.shetland.ogc.filter.ComparisonFilter) UnsupportedDecoderXmlInputException(org.n52.svalbard.decode.exception.UnsupportedDecoderXmlInputException)

Example 5 with ComparisonFilter

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

the class ComparisonFilterTest method testCopyOf_like.

@Test
public void testCopyOf_like() throws OwsExceptionReport {
    ComparisonFilter original = new ComparisonFilter(FilterConstants.ComparisonOperator.PropertyIsLike, "vr", "val", "up", "escape");
    original.setMatchCase(false);
    original.setSingleChar("single");
    original.setWildCard("wild");
    ComparisonFilter copy = original.copy();
    Assert.assertThat(copy.getEscapeString(), is(original.getEscapeString()));
    Assert.assertThat(copy.getSingleChar(), is(original.getSingleChar()));
    Assert.assertThat(copy.getValue(), is(original.getValue()));
    Assert.assertThat(copy.getValueReference(), is(original.getValueReference()));
    Assert.assertThat(copy.getValueUpper(), is(original.getValueUpper()));
    Assert.assertThat(copy.getWildCard(), is(original.getWildCard()));
    Assert.assertThat(copy, is(not(original)));
    Assert.assertThat("copy is not equal to original, equal to is not implemented", not(copy.equals(original)));
}
Also used : ComparisonFilter(org.n52.shetland.ogc.filter.ComparisonFilter) 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