Search in sources :

Example 31 with PropertyIsLikeType

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

the class OGC110Test method testFilterComparisonPropertyIsLike.

@Test
public void testFilterComparisonPropertyIsLike() throws JAXBException, NoSuchAuthorityCodeException, FactoryException {
    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.v110.ComparisonOpsType) LiteralType(org.geotoolkit.ogc.xml.v110.LiteralType) JAXBElement(javax.xml.bind.JAXBElement) FilterType(org.geotoolkit.ogc.xml.v110.FilterType) Filter(org.opengis.filter.Filter) LikeOperator(org.opengis.filter.LikeOperator) Unmarshaller(javax.xml.bind.Unmarshaller) PropertyIsLikeType(org.geotoolkit.ogc.xml.v110.PropertyIsLikeType) ValueReference(org.opengis.filter.ValueReference) PropertyNameType(org.geotoolkit.ogc.xml.v110.PropertyNameType) Test(org.junit.Test)

Aggregations

ArrayList (java.util.ArrayList)15 Test (org.junit.Test)15 PropertyIsLikeType (net.opengis.filter.v_2_0_0.PropertyIsLikeType)11 FilterType (net.opengis.filter.v_2_0_0.FilterType)10 Filter (org.opengis.filter.Filter)10 QueryImpl (ddf.catalog.operation.impl.QueryImpl)7 QueryRequestImpl (ddf.catalog.operation.impl.QueryRequestImpl)7 Method (java.lang.reflect.Method)6 JAXBElement (javax.xml.bind.JAXBElement)6 BinaryLogicOpType (net.opengis.filter.v_2_0_0.BinaryLogicOpType)6 PropertyIsLikeType (ogc.schema.opengis.filter.v_1_0_0.PropertyIsLikeType)6 QName (javax.xml.namespace.QName)5 GetFeatureType (ogc.schema.opengis.wfs.v_1_0_0.GetFeatureType)5 QueryType (ogc.schema.opengis.wfs.v_1_0_0.QueryType)5 PropertyIsLikeType (org.geotoolkit.ogc.xml.v110.PropertyIsLikeType)5 StringWriter (java.io.StringWriter)4 PropertyIsLikeType (net.opengis.filter.v_1_1_0.PropertyIsLikeType)4 PropertyNameType (org.geotoolkit.ogc.xml.v110.PropertyNameType)4 LikeOperator (org.opengis.filter.LikeOperator)4 ValueReference (org.opengis.filter.ValueReference)4