Search in sources :

Example 1 with ComparisonOpsType

use of org.geotoolkit.ogc.xml.v100.ComparisonOpsType in project geo-platform by geosdi.

the class AndOperatorHandler method processQueryRestrictions.

/**
 * @param filter
 * @param queryRestrictionDTOs
 */
@Override
protected void processQueryRestrictions(FilterType filter, List<QueryRestrictionDTO> queryRestrictionDTOs) {
    logger.debug("################### {} Processing............\n", getFilterName());
    List<JAXBElement<?>> elements = super.buildJAXBElementList(queryRestrictionDTOs);
    logger.debug("##################{} builds : {} " + (elements.size() > 1 ? "elements" : "element") + "\n", getFilterName(), elements.size());
    if (elements.size() == 1) {
        if (filter.isSetSpatialOps()) {
            elements.add(filter.getSpatialOps());
            filter.setSpatialOps(null);
            BinaryLogicOpType and = new BinaryLogicOpType();
            and.setComparisonOpsOrSpatialOpsOrLogicOps(elements);
            filter.setLogicOps(filterFactory.createAnd(and));
        } else {
            JAXBElement<ComparisonOpsType> opsTypeJAXBElement = (JAXBElement<ComparisonOpsType>) elements.get(0);
            filter.setComparisonOps(opsTypeJAXBElement);
        }
    } else if (elements.size() > 1) {
        if (filter.isSetSpatialOps()) {
            elements.add(filter.getSpatialOps());
            filter.setSpatialOps(null);
        }
        BinaryLogicOpType and = new BinaryLogicOpType();
        and.setComparisonOpsOrSpatialOpsOrLogicOps(elements);
        filter.setLogicOps(filterFactory.createAnd(and));
    }
}
Also used : BinaryLogicOpType(org.geosdi.geoplatform.xml.filter.v110.BinaryLogicOpType) ComparisonOpsType(org.geosdi.geoplatform.xml.filter.v110.ComparisonOpsType) JAXBElement(javax.xml.bind.JAXBElement)

Example 2 with ComparisonOpsType

use of org.geotoolkit.ogc.xml.v100.ComparisonOpsType in project geo-platform by geosdi.

the class OrOperatorHandler method processQueryRestrictions.

/**
 * @param filter
 * @param queryRestrictionDTOs
 */
@Override
protected void processQueryRestrictions(FilterType filter, List<QueryRestrictionDTO> queryRestrictionDTOs) {
    logger.debug("################### {} Processing............\n", getFilterName());
    List<JAXBElement<?>> elements = super.buildJAXBElementList(queryRestrictionDTOs);
    logger.debug("##################{} builds : {} " + (elements.size() > 1 ? "elements" : "element") + "\n", getFilterName(), elements.size());
    if (elements.size() == 1) {
        if (filter.isSetSpatialOps()) {
            elements.add(filter.getSpatialOps());
            filter.setSpatialOps(null);
            BinaryLogicOpType or = new BinaryLogicOpType();
            or.setComparisonOpsOrSpatialOpsOrLogicOps(elements);
            filter.setLogicOps(filterFactory.createOr(or));
        } else {
            JAXBElement<ComparisonOpsType> element = (JAXBElement<ComparisonOpsType>) elements.get(0);
            filter.setComparisonOps(element);
        }
    } else if (elements.size() > 1) {
        if (filter.isSetSpatialOps()) {
            elements.add(filter.getSpatialOps());
            filter.setSpatialOps(null);
        }
        BinaryLogicOpType or = new BinaryLogicOpType();
        or.setComparisonOpsOrSpatialOpsOrLogicOps(elements);
        filter.setLogicOps(filterFactory.createOr(or));
    }
}
Also used : BinaryLogicOpType(org.geosdi.geoplatform.xml.filter.v110.BinaryLogicOpType) ComparisonOpsType(org.geosdi.geoplatform.xml.filter.v110.ComparisonOpsType) JAXBElement(javax.xml.bind.JAXBElement)

Example 3 with ComparisonOpsType

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

the class OGC100Test method testFilterComparisonPropertyIsLessThanOrEqual.

@Test
public void testFilterComparisonPropertyIsLessThanOrEqual() throws JAXBException {
    final Unmarshaller UNMARSHALLER = POOL.acquireUnmarshaller();
    final Marshaller MARSHALLER = POOL.acquireMarshaller();
    // Read test
    Object obj = UNMARSHALLER.unmarshal(FILE_FIL_COMP_ISLESSOREQUAL);
    assertNotNull(obj);
    JAXBElement<? extends FilterType> jaxfilter = (JAXBElement<? extends FilterType>) obj;
    assertNotNull(jaxfilter);
    Filter filter = TRANSFORMER_GT.visitFilter(jaxfilter.getValue());
    assertNotNull(filter);
    BinaryComparisonOperator prop = (BinaryComparisonOperator) filter;
    ValueReference left = (ValueReference) prop.getOperand1();
    Literal right = (Literal) prop.getOperand2();
    assertEquals(left.getXPath(), valueStr);
    assertEquals(((Number) right.apply(null)).floatValue(), valueF, DELTA);
    // write test
    FilterType ft = TRANSFORMER_OGC.apply(filter);
    assertNotNull(ft.getComparisonOps());
    ComparisonOpsType cot = ft.getComparisonOps().getValue();
    BinaryComparisonOpType pibt = (BinaryComparisonOpType) cot;
    PropertyNameType lf = (PropertyNameType) pibt.getExpression().get(0).getValue();
    LiteralType rg = (LiteralType) pibt.getExpression().get(1).getValue();
    assertEquals(valueStr, lf.getContent());
    numberEquals(valueF, rg.getContent().get(0).toString().trim());
    MARSHALLER.marshal(ft.getComparisonOps(), TEST_FILE_FIL_COMP_ISLESSOREQUAL);
    POOL.recycle(MARSHALLER);
    POOL.recycle(UNMARSHALLER);
}
Also used : Marshaller(javax.xml.bind.Marshaller) ComparisonOpsType(org.geotoolkit.ogc.xml.v100.ComparisonOpsType) LiteralType(org.geotoolkit.ogc.xml.v100.LiteralType) JAXBElement(javax.xml.bind.JAXBElement) FilterType(org.geotoolkit.ogc.xml.v100.FilterType) 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)

Example 4 with ComparisonOpsType

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

the class OGC100Test method testFilterComparisonPropertyIsNotEqualTo.

@Test
public void testFilterComparisonPropertyIsNotEqualTo() throws JAXBException {
    final Unmarshaller UNMARSHALLER = POOL.acquireUnmarshaller();
    final Marshaller MARSHALLER = POOL.acquireMarshaller();
    // Read test
    Object obj = UNMARSHALLER.unmarshal(FILE_FIL_COMP_ISNOTEQUAL);
    assertNotNull(obj);
    JAXBElement<? extends FilterType> jaxfilter = (JAXBElement<? extends FilterType>) obj;
    assertNotNull(jaxfilter);
    Filter filter = TRANSFORMER_GT.visitFilter(jaxfilter.getValue());
    assertNotNull(filter);
    BinaryComparisonOperator prop = (BinaryComparisonOperator) filter;
    ValueReference left = (ValueReference) prop.getOperand1();
    Literal right = (Literal) prop.getOperand2();
    assertEquals(left.getXPath(), valueStr);
    assertEquals(((Number) right.apply(null)).floatValue(), valueF, DELTA);
    // write test
    FilterType ft = TRANSFORMER_OGC.apply(filter);
    assertNotNull(ft.getComparisonOps());
    ComparisonOpsType cot = ft.getComparisonOps().getValue();
    BinaryComparisonOpType pibt = (BinaryComparisonOpType) cot;
    PropertyNameType lf = (PropertyNameType) pibt.getExpression().get(0).getValue();
    LiteralType rg = (LiteralType) pibt.getExpression().get(1).getValue();
    assertEquals(valueStr, lf.getContent());
    numberEquals(valueF, rg.getContent().get(0).toString().trim());
    MARSHALLER.marshal(ft.getComparisonOps(), TEST_FILE_FIL_COMP_ISNOTEQUAL);
    POOL.recycle(MARSHALLER);
    POOL.recycle(UNMARSHALLER);
}
Also used : Marshaller(javax.xml.bind.Marshaller) ComparisonOpsType(org.geotoolkit.ogc.xml.v100.ComparisonOpsType) LiteralType(org.geotoolkit.ogc.xml.v100.LiteralType) JAXBElement(javax.xml.bind.JAXBElement) FilterType(org.geotoolkit.ogc.xml.v100.FilterType) 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)

Example 5 with ComparisonOpsType

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

the class OGC100Test method testFilterComparisonPropertyIsEqualTo.

@Test
public void testFilterComparisonPropertyIsEqualTo() throws JAXBException {
    final Unmarshaller UNMARSHALLER = POOL.acquireUnmarshaller();
    final Marshaller MARSHALLER = POOL.acquireMarshaller();
    // Read test
    Object obj = UNMARSHALLER.unmarshal(FILE_FIL_COMP_ISEQUAL);
    assertNotNull(obj);
    JAXBElement<? extends FilterType> jaxfilter = (JAXBElement<? extends FilterType>) obj;
    assertNotNull(jaxfilter);
    Filter filter = TRANSFORMER_GT.visitFilter(jaxfilter.getValue());
    assertNotNull(filter);
    BinaryComparisonOperator prop = (BinaryComparisonOperator) filter;
    ValueReference left = (ValueReference) prop.getOperand1();
    Literal right = (Literal) prop.getOperand2();
    assertEquals(left.getXPath(), valueStr);
    assertEquals(((Number) right.apply(null)).floatValue(), valueF, DELTA);
    // write test
    FilterType ft = TRANSFORMER_OGC.apply(filter);
    assertNotNull(ft.getComparisonOps());
    ComparisonOpsType cot = ft.getComparisonOps().getValue();
    BinaryComparisonOpType pibt = (BinaryComparisonOpType) cot;
    PropertyNameType lf = (PropertyNameType) pibt.getExpression().get(0).getValue();
    LiteralType rg = (LiteralType) pibt.getExpression().get(1).getValue();
    assertEquals(valueStr, lf.getContent());
    numberEquals(valueF, rg.getContent().get(0).toString().trim());
    MARSHALLER.marshal(ft.getComparisonOps(), TEST_FILE_FIL_COMP_ISEQUAL);
    POOL.recycle(MARSHALLER);
    POOL.recycle(UNMARSHALLER);
}
Also used : Marshaller(javax.xml.bind.Marshaller) ComparisonOpsType(org.geotoolkit.ogc.xml.v100.ComparisonOpsType) LiteralType(org.geotoolkit.ogc.xml.v100.LiteralType) JAXBElement(javax.xml.bind.JAXBElement) FilterType(org.geotoolkit.ogc.xml.v100.FilterType) 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

JAXBElement (javax.xml.bind.JAXBElement)23 Filter (org.opengis.filter.Filter)20 ValueReference (org.opengis.filter.ValueReference)19 Marshaller (javax.xml.bind.Marshaller)18 Unmarshaller (javax.xml.bind.Unmarshaller)18 Test (org.junit.Test)18 Literal (org.opengis.filter.Literal)15 BinaryComparisonOperator (org.opengis.filter.BinaryComparisonOperator)13 ComparisonOpsType (org.geotoolkit.ogc.xml.v100.ComparisonOpsType)11 FilterType (org.geotoolkit.ogc.xml.v100.FilterType)11 ComparisonOpsType (org.geotoolkit.ogc.xml.v110.ComparisonOpsType)11 PropertyNameType (org.geotoolkit.ogc.xml.v100.PropertyNameType)10 LiteralType (org.geotoolkit.ogc.xml.v100.LiteralType)9 FilterType (org.geotoolkit.ogc.xml.v110.FilterType)9 PropertyNameType (org.geotoolkit.ogc.xml.v110.PropertyNameType)9 LiteralType (org.geotoolkit.ogc.xml.v110.LiteralType)8 BinaryComparisonOpType (org.geotoolkit.ogc.xml.v100.BinaryComparisonOpType)6 BinaryComparisonOpType (org.geotoolkit.ogc.xml.v110.BinaryComparisonOpType)6 PropertyIsLikeType (org.geotoolkit.ogc.xml.v100.PropertyIsLikeType)3 LikeOperator (org.opengis.filter.LikeOperator)3