Search in sources :

Example 21 with BinaryLogicOpType

use of org.geotoolkit.ogc.xml.v100.BinaryLogicOpType in project geotoolkit by Geomatys.

the class OGC100Test method testFilterLogicalAnd.

// //////////////////////////////////////////////////////////////////////////
// JAXB TEST MARSHELLING AND UNMARSHELLING FOR LOGIC FILTERS ///////////////
// //////////////////////////////////////////////////////////////////////////
@Test
public void testFilterLogicalAnd() throws JAXBException {
    final Unmarshaller UNMARSHALLER = POOL.acquireUnmarshaller();
    final Marshaller MARSHALLER = POOL.acquireMarshaller();
    // Read test
    Object obj = UNMARSHALLER.unmarshal(FILE_FIL_LOG_AND);
    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 leftop = (BinaryComparisonOperator) prop.getOperands().get(0);
    BinaryComparisonOperator rightop = (BinaryComparisonOperator) prop.getOperands().get(1);
    ValueReference left = (ValueReference) leftop.getOperand1();
    Literal right = (Literal) leftop.getOperand2();
    assertEquals(left.getXPath(), valueStr);
    assertEquals(((Number) right.apply(null)).floatValue(), 455f, DELTA);
    left = (ValueReference) rightop.getOperand1();
    right = (Literal) rightop.getOperand2();
    assertEquals(left.getXPath(), valueStr);
    assertEquals(((Number) right.apply(null)).floatValue(), 457f, 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_AND);
    BinaryLogicOpType pibt = (BinaryLogicOpType) cot;
    BinaryComparisonOpType leftoptype = (BinaryComparisonOpType) pibt.getComparisonOpsOrSpatialOpsOrLogicOps().get(0).getValue();
    BinaryComparisonOpType rightoptype = (BinaryComparisonOpType) pibt.getComparisonOpsOrSpatialOpsOrLogicOps().get(1).getValue();
    PropertyNameType lf = (PropertyNameType) leftoptype.getExpression().get(0).getValue();
    LiteralType rg = (LiteralType) leftoptype.getExpression().get(1).getValue();
    assertEquals(valueStr, lf.getContent());
    numberEquals(455, rg.getContent().get(0));
    lf = (PropertyNameType) rightoptype.getExpression().get(0).getValue();
    rg = (LiteralType) rightoptype.getExpression().get(1).getValue();
    assertEquals(valueStr, lf.getContent());
    numberEquals(457, rg.getContent().get(0));
    MARSHALLER.marshal(ft.getLogicOps(), TEST_FILE_FIL_LOG_AND);
    POOL.recycle(MARSHALLER);
    POOL.recycle(UNMARSHALLER);
}
Also used : Marshaller(javax.xml.bind.Marshaller) LogicalOperator(org.opengis.filter.LogicalOperator) LiteralType(org.geotoolkit.ogc.xml.v100.LiteralType) JAXBElement(javax.xml.bind.JAXBElement) LogicOpsType(org.geotoolkit.ogc.xml.v100.LogicOpsType) FilterType(org.geotoolkit.ogc.xml.v100.FilterType) BinaryLogicOpType(org.geotoolkit.ogc.xml.v100.BinaryLogicOpType) Filter(org.opengis.filter.Filter) Literal(org.opengis.filter.Literal) Unmarshaller(javax.xml.bind.Unmarshaller) BinaryComparisonOperator(org.opengis.filter.BinaryComparisonOperator) BinaryComparisonOpType(org.geotoolkit.ogc.xml.v100.BinaryComparisonOpType) ValueReference(org.opengis.filter.ValueReference) PropertyNameType(org.geotoolkit.ogc.xml.v100.PropertyNameType) Test(org.junit.Test)

Aggregations

ArrayList (java.util.ArrayList)12 BinaryLogicOpType (net.opengis.filter.v_2_0_0.BinaryLogicOpType)11 FilterType (net.opengis.filter.v_2_0_0.FilterType)11 Test (org.junit.Test)10 JAXBElement (javax.xml.bind.JAXBElement)8 Method (java.lang.reflect.Method)6 DistanceBufferType (net.opengis.filter.v_2_0_0.DistanceBufferType)6 PropertyIsLikeType (net.opengis.filter.v_2_0_0.PropertyIsLikeType)6 Filter (org.opengis.filter.Filter)5 Marshaller (javax.xml.bind.Marshaller)4 Unmarshaller (javax.xml.bind.Unmarshaller)4 BinaryLogicOpType (org.geosdi.geoplatform.xml.filter.v110.BinaryLogicOpType)4 BinaryComparisonOperator (org.opengis.filter.BinaryComparisonOperator)4 Literal (org.opengis.filter.Literal)4 LogicalOperator (org.opengis.filter.LogicalOperator)4 ValueReference (org.opengis.filter.ValueReference)4 BinaryTemporalOpType (net.opengis.filter.v_2_0_0.BinaryTemporalOpType)3 QueryImpl (ddf.catalog.operation.impl.QueryImpl)2 QueryRequestImpl (ddf.catalog.operation.impl.QueryRequestImpl)2 UnaryLogicOpType (net.opengis.filter.v_2_0_0.UnaryLogicOpType)2