Search in sources :

Example 66 with LiteralType

use of org.geotoolkit.ogc.xml.v110.LiteralType in project geotoolkit by Geomatys.

the class OGC100Test method testFilterLogicalOr.

@Test
public void testFilterLogicalOr() throws JAXBException {
    final Unmarshaller UNMARSHALLER = POOL.acquireUnmarshaller();
    final Marshaller MARSHALLER = POOL.acquireMarshaller();
    // Read test
    Object obj = UNMARSHALLER.unmarshal(FILE_FIL_LOG_OR);
    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_OR);
    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_OR);
    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)

Example 67 with LiteralType

use of org.geotoolkit.ogc.xml.v110.LiteralType in project geotoolkit by Geomatys.

the class OGC100Test method testFilterComparisonPropertyIsLike.

@Test
public void testFilterComparisonPropertyIsLike() throws JAXBException {
    final Unmarshaller UNMARSHALLER = POOL.acquireUnmarshaller();
    final Marshaller MARSHALLER = POOL.acquireMarshaller();
    // Read test
    Object obj = UNMARSHALLER.unmarshal(FILE_FIL_COMP_ISLIKE);
    assertNotNull(obj);
    JAXBElement<? extends FilterType> jaxfilter = (JAXBElement<? extends FilterType>) obj;
    assertNotNull(jaxfilter);
    Filter filter = TRANSFORMER_GT.visitFilter(jaxfilter.getValue());
    assertNotNull(filter);
    LikeOperator prop = (LikeOperator) filter;
    ValueReference exp = (ValueReference) prop.getExpressions().get(0);
    char escape = prop.getEscapeChar();
    String literal = (String) ((Literal) prop.getExpressions().get(1)).getValue();
    char single = prop.getSingleChar();
    char wild = prop.getWildCard();
    assertEquals(exp.getXPath(), "LAST_NAME");
    assertEquals(literal, "JOHN*");
    assertEquals(escape, '!');
    assertEquals(single, '#');
    assertEquals(wild, '*');
    // write test
    FilterType ft = TRANSFORMER_OGC.apply(filter);
    assertNotNull(ft.getComparisonOps());
    ComparisonOpsType cot = ft.getComparisonOps().getValue();
    PropertyIsLikeType pibt = (PropertyIsLikeType) cot;
    PropertyNameType lf = pibt.getPropertyName();
    LiteralType lt = pibt.getLiteralType();
    char esc = pibt.getEscapeChar();
    char sin = pibt.getSingleChar();
    char wi = pibt.getWildCard();
    assertEquals(lf.getContent(), "LAST_NAME");
    assertEquals(lt.getContent().get(0).toString().trim(), "JOHN*");
    assertEquals(esc, '!');
    assertEquals(sin, '#');
    assertEquals(wi, '*');
    MARSHALLER.marshal(ft.getComparisonOps(), TEST_FILE_FIL_COMP_ISLIKE);
    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) LikeOperator(org.opengis.filter.LikeOperator) Unmarshaller(javax.xml.bind.Unmarshaller) PropertyIsLikeType(org.geotoolkit.ogc.xml.v100.PropertyIsLikeType) ValueReference(org.opengis.filter.ValueReference) PropertyNameType(org.geotoolkit.ogc.xml.v100.PropertyNameType) Test(org.junit.Test)

Example 68 with LiteralType

use of org.geotoolkit.ogc.xml.v110.LiteralType 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)

Example 69 with LiteralType

use of org.geotoolkit.ogc.xml.v110.LiteralType in project geotoolkit by Geomatys.

the class OGC100Test method testExpDiv.

@Test
public void testExpDiv() throws JAXBException {
    final Unmarshaller UNMARSHALLER = POOL.acquireUnmarshaller();
    final Marshaller MARSHALLER = POOL.acquireMarshaller();
    // Read test
    Object obj = UNMARSHALLER.unmarshal(FILE_EXP_DIV);
    assertNotNull(obj);
    JAXBElement<BinaryOperatorType> jax = (JAXBElement<BinaryOperatorType>) obj;
    Expression exp = (Expression) TRANSFORMER_GT.visitExpression(jax);
    assertNotNull(exp);
    ValueReference left = (ValueReference) exp.getParameters().get(0);
    Literal right = (Literal) exp.getParameters().get(1);
    assertNotNull(left);
    assertNotNull(right);
    assertEquals(left.getXPath(), valueStr);
    assertEquals(((Number) right.apply(null)).floatValue(), valueF, DELTA);
    // Write test
    jax = (JAXBElement<BinaryOperatorType>) TRANSFORMER_OGC.extract(exp);
    assertNotNull(jax);
    assertEquals(jax.getName().getLocalPart(), OGCJAXBStatics.EXPRESSION_DIV);
    JAXBElement<PropertyNameType> ele1 = (JAXBElement<PropertyNameType>) jax.getValue().getExpression().get(0);
    JAXBElement<LiteralType> ele2 = (JAXBElement<LiteralType>) jax.getValue().getExpression().get(1);
    MARSHALLER.marshal(jax, TEST_FILE_EXP_DIV);
    POOL.recycle(MARSHALLER);
    POOL.recycle(UNMARSHALLER);
}
Also used : Marshaller(javax.xml.bind.Marshaller) BinaryOperatorType(org.geotoolkit.ogc.xml.v100.BinaryOperatorType) LiteralType(org.geotoolkit.ogc.xml.v100.LiteralType) JAXBElement(javax.xml.bind.JAXBElement) Expression(org.opengis.filter.Expression) Literal(org.opengis.filter.Literal) Unmarshaller(javax.xml.bind.Unmarshaller) ValueReference(org.opengis.filter.ValueReference) PropertyNameType(org.geotoolkit.ogc.xml.v100.PropertyNameType) Test(org.junit.Test)

Example 70 with LiteralType

use of org.geotoolkit.ogc.xml.v110.LiteralType in project geotoolkit by Geomatys.

the class OGC100Test method testExpLiteral.

@Test
public void testExpLiteral() throws JAXBException {
    final Unmarshaller UNMARSHALLER = POOL.acquireUnmarshaller();
    final Marshaller MARSHALLER = POOL.acquireMarshaller();
    // Read test
    Object obj = UNMARSHALLER.unmarshal(FILE_EXP_LITERAL);
    assertNotNull(obj);
    JAXBElement<LiteralType> jax = (JAXBElement<LiteralType>) obj;
    Literal exp = (Literal) TRANSFORMER_GT.visitExpression(jax);
    assertNotNull(exp);
    float val = ((Number) exp.apply(null)).floatValue();
    assertEquals(val, valueF, DELTA);
    // Write test
    jax = (JAXBElement<LiteralType>) TRANSFORMER_OGC.extract(exp);
    assertNotNull(jax);
    String str = jax.getValue().getContent().get(0).toString().trim();
    assertEquals(Float.valueOf(str), valueF, DELTA);
    MARSHALLER.marshal(jax, TEST_FILE_EXP_LITERAL);
    POOL.recycle(MARSHALLER);
    POOL.recycle(UNMARSHALLER);
}
Also used : Marshaller(javax.xml.bind.Marshaller) Literal(org.opengis.filter.Literal) LiteralType(org.geotoolkit.ogc.xml.v100.LiteralType) JAXBElement(javax.xml.bind.JAXBElement) Unmarshaller(javax.xml.bind.Unmarshaller) Test(org.junit.Test)

Aggregations

JAXBElement (javax.xml.bind.JAXBElement)40 LiteralType (org.geotoolkit.ogc.xml.v110.LiteralType)40 PropertyNameType (org.geotoolkit.ogc.xml.v110.PropertyNameType)40 Literal (org.opengis.filter.Literal)35 Marshaller (javax.xml.bind.Marshaller)34 Unmarshaller (javax.xml.bind.Unmarshaller)34 Test (org.junit.Test)34 ValueReference (org.opengis.filter.ValueReference)34 Filter (org.opengis.filter.Filter)26 BinaryComparisonOperator (org.opengis.filter.BinaryComparisonOperator)21 LiteralType (org.geotoolkit.ogc.xml.v100.LiteralType)17 PropertyNameType (org.geotoolkit.ogc.xml.v100.PropertyNameType)16 FilterType (org.geotoolkit.ogc.xml.v110.FilterType)14 FilterType (org.geotoolkit.ogc.xml.v100.FilterType)11 Expression (org.opengis.filter.Expression)11 LiteralType (org.flyte.api.v1.LiteralType)10 BinaryComparisonOpType (org.geotoolkit.ogc.xml.v100.BinaryComparisonOpType)9 ComparisonOpsType (org.geotoolkit.ogc.xml.v100.ComparisonOpsType)9 BinaryComparisonOpType (org.geotoolkit.ogc.xml.v110.BinaryComparisonOpType)9 LogicalOperator (org.opengis.filter.LogicalOperator)9