Search in sources :

Example 1 with BinaryLogicFilter

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

the class ODataFesParserTest method testDisjunction.

@Test
@SuppressWarnings("unchecked")
public void testDisjunction() throws Exception {
    Filter<?> filter = parser.decode("countValue lt 10 or textValue eq 'thetext'");
    assertThat(filter, is(instanceOf(BinaryLogicFilter.class)));
    BinaryLogicFilter blf = (BinaryLogicFilter) filter;
    errors.checkThat(blf.getOperator(), is(BinaryLogicOperator.Or));
    Set<Filter<?>> filterPredicates = blf.getFilterPredicates();
    errors.checkThat(filterPredicates, Matchers.containsInAnyOrder(Matchers.instanceOf(ComparisonFilter.class), Matchers.instanceOf(ComparisonFilter.class)));
}
Also used : SpatialFilter(org.n52.shetland.ogc.filter.SpatialFilter) BinaryLogicFilter(org.n52.shetland.ogc.filter.BinaryLogicFilter) ComparisonFilter(org.n52.shetland.ogc.filter.ComparisonFilter) Filter(org.n52.shetland.ogc.filter.Filter) BinaryLogicFilter(org.n52.shetland.ogc.filter.BinaryLogicFilter) Test(org.junit.Test)

Example 2 with BinaryLogicFilter

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

the class ODataFesParserTest method testConjunction.

@Test
@SuppressWarnings("unchecked")
public void testConjunction() throws Exception {
    Filter<?> filter = parser.decode("countValue lt 10 and textValue eq 'thetext'");
    assertThat(filter, is(instanceOf(BinaryLogicFilter.class)));
    BinaryLogicFilter blf = (BinaryLogicFilter) filter;
    errors.checkThat(blf.getOperator(), is(BinaryLogicOperator.And));
    Set<Filter<?>> filterPredicates = blf.getFilterPredicates();
    errors.checkThat(filterPredicates, Matchers.containsInAnyOrder(Matchers.instanceOf(ComparisonFilter.class), Matchers.instanceOf(ComparisonFilter.class)));
}
Also used : SpatialFilter(org.n52.shetland.ogc.filter.SpatialFilter) BinaryLogicFilter(org.n52.shetland.ogc.filter.BinaryLogicFilter) ComparisonFilter(org.n52.shetland.ogc.filter.ComparisonFilter) Filter(org.n52.shetland.ogc.filter.Filter) BinaryLogicFilter(org.n52.shetland.ogc.filter.BinaryLogicFilter) Test(org.junit.Test)

Example 3 with BinaryLogicFilter

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

the class FesDecoderv20 method parseBinaryLogicalFilter.

/**
 * parses a single binary logic filter of the requests and returns service
 * binary logic filter
 *
 * @param binaryLogicOpType
 *            XmlObject representing the binary logic filter
 * @return Service representation of binary logic filter
 * @throws DecodingException
 *             if creation of the BinaryLogicFilter failed or filter size is
 *             less than two
 */
private BinaryLogicFilter parseBinaryLogicalFilter(BinaryLogicOpType binaryLogicOpType) throws DecodingException {
    BinaryLogicFilter binaryLogicFilter = null;
    String localName = XmlHelper.getLocalName(binaryLogicOpType);
    if (localName.equals(BinaryLogicOperator.And.name())) {
        binaryLogicFilter = new BinaryLogicFilter(BinaryLogicOperator.And);
    } else if (localName.equals(BinaryLogicOperator.Or.name())) {
        binaryLogicFilter = new BinaryLogicFilter(BinaryLogicOperator.Or);
    } else {
        throw new UnsupportedDecoderXmlInputException(this, binaryLogicOpType);
    }
    Set<Filter<?>> filters = getFilterPredicates(binaryLogicOpType);
    if (filters.size() < 2) {
        throw new DecodingException("The binary logic filter requires minimla two filter predicates!");
    }
    binaryLogicFilter.addFilterPredicates(filters);
    return binaryLogicFilter;
}
Also used : Filter(org.n52.shetland.ogc.filter.Filter) TemporalFilter(org.n52.shetland.ogc.filter.TemporalFilter) SpatialFilter(org.n52.shetland.ogc.filter.SpatialFilter) BinaryLogicFilter(org.n52.shetland.ogc.filter.BinaryLogicFilter) UnaryLogicFilter(org.n52.shetland.ogc.filter.UnaryLogicFilter) ComparisonFilter(org.n52.shetland.ogc.filter.ComparisonFilter) UnsupportedDecoderXmlInputException(org.n52.svalbard.decode.exception.UnsupportedDecoderXmlInputException) DecodingException(org.n52.svalbard.decode.exception.DecodingException) BinaryLogicFilter(org.n52.shetland.ogc.filter.BinaryLogicFilter)

Aggregations

BinaryLogicFilter (org.n52.shetland.ogc.filter.BinaryLogicFilter)3 ComparisonFilter (org.n52.shetland.ogc.filter.ComparisonFilter)3 Filter (org.n52.shetland.ogc.filter.Filter)3 SpatialFilter (org.n52.shetland.ogc.filter.SpatialFilter)3 Test (org.junit.Test)2 TemporalFilter (org.n52.shetland.ogc.filter.TemporalFilter)1 UnaryLogicFilter (org.n52.shetland.ogc.filter.UnaryLogicFilter)1 DecodingException (org.n52.svalbard.decode.exception.DecodingException)1 UnsupportedDecoderXmlInputException (org.n52.svalbard.decode.exception.UnsupportedDecoderXmlInputException)1