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)));
}
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)));
}
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;
}
Aggregations