use of org.geotoolkit.ogc.xml.v100.UnaryLogicOpType in project geo-platform by geosdi.
the class NotOperatorHandler method createComparisonOps.
/**
* @param element
* @return {@link UnaryLogicOpType}
*/
protected UnaryLogicOpType createComparisonOps(@Nonnull(when = NEVER) JAXBElement element, @Nonnull(when = NEVER) FilterType filter) {
checkArgument(element != null, "The Parameter element must not be null.");
checkArgument(filter != null, "The Parameter filter must not be null.");
if (filter.isSetSpatialOps()) {
List<JAXBElement<?>> elements = new ArrayList<>(2);
elements.add(filter.getSpatialOps());
filter.setSpatialOps(null);
elements.add(element);
UnaryLogicOpType unaryLogicOpType = new UnaryLogicOpType();
BinaryLogicOpType and = new BinaryLogicOpType();
and.setComparisonOpsOrSpatialOpsOrLogicOps(elements);
unaryLogicOpType.setLogicOps(filterFactory.createAnd(and));
return unaryLogicOpType;
} else {
UnaryLogicOpType unaryLogicOpType = new UnaryLogicOpType();
unaryLogicOpType.setComparisonOps(element);
return unaryLogicOpType;
}
}
use of org.geotoolkit.ogc.xml.v100.UnaryLogicOpType in project geotoolkit by Geomatys.
the class OGC110Test method testFilterLogicalNot.
@Test
public void testFilterLogicalNot() throws JAXBException, NoSuchAuthorityCodeException, FactoryException {
final Unmarshaller UNMARSHALLER = POOL.acquireUnmarshaller();
final Marshaller MARSHALLER = POOL.acquireMarshaller();
// Read test
Object obj = UNMARSHALLER.unmarshal(FILE_FIL_LOG_NOT);
assertNotNull(obj);
JAXBElement<? extends FilterType> jaxfilter = (JAXBElement<? extends FilterType>) obj;
assertNotNull(jaxfilter);
Filter filter = TRANSFORMER_GT.visitFilter(jaxfilter.getValue());
assertNotNull(filter);
LogicalOperator prop = (LogicalOperator) filter;
BinaryComparisonOperator subfilter = (BinaryComparisonOperator) prop.getOperands().get(0);
ValueReference left = (ValueReference) subfilter.getOperand1();
Literal right = (Literal) subfilter.getOperand2();
assertEquals(left.getXPath(), valueStr);
assertEquals(((Number) right.apply(null)).floatValue(), valueF, DELTA);
// write test
FilterType ft = TRANSFORMER_OGC.apply(filter);
assertNotNull(ft.getLogicOps());
LogicOpsType cot = ft.getLogicOps().getValue();
assertEquals(ft.getLogicOps().getName().getLocalPart(), OGCJAXBStatics.FILTER_LOGIC_NOT);
UnaryLogicOpType pibt = (UnaryLogicOpType) cot;
BinaryComparisonOpType leftoptype = (BinaryComparisonOpType) pibt.getComparisonOps().getValue();
PropertyNameType lf = (PropertyNameType) leftoptype.getExpression().get(0).getValue();
LiteralType rg = (LiteralType) leftoptype.getExpression().get(1).getValue();
assertEquals(valueStr, lf.getContent());
numberEquals(valueF, rg.getContent().get(0));
MARSHALLER.marshal(ft.getLogicOps(), TEST_FILE_FIL_LOG_NOT);
POOL.recycle(MARSHALLER);
POOL.recycle(UNMARSHALLER);
}
Aggregations