Search in sources :

Example 16 with WGS84BoundingBoxType

use of org.geotoolkit.ows.xml.v100.WGS84BoundingBoxType in project geotoolkit by Geomatys.

the class WfsXMLBindingTest method marshallingTest.

@Test
public void marshallingTest() throws JAXBException {
    WFSCapabilitiesType capa = new WFSCapabilitiesType();
    List<FeatureTypeType> featList = new ArrayList<>();
    List<String> otherSRS = Arrays.asList("urn:ogc:def:crs", "crs:EPSG::32615", "crs:EPSG::5773");
    WGS84BoundingBoxType bbox = new WGS84BoundingBoxType(29.8, -90.1, 30, -89.9);
    FeatureTypeType ft1 = new FeatureTypeType(new QName("http://www.opengis.net/ows-6/utds/0.3", "Building", "utds"), "", "urn:ogc:def:crs:EPSG::4979", otherSRS, Arrays.asList(bbox));
    featList.add(ft1);
    FeatureTypeListType featureList = new FeatureTypeListType(null, featList);
    capa.setFeatureTypeList(featureList);
    StringWriter sw = new StringWriter();
    marshaller.marshal(capa, sw);
    DeleteElementType del = null;
    TransactionType transac = new TransactionType("WFS", "1.1.0", null, AllSomeType.ALL, del);
    PropertyIsLikeType pis = new PropertyIsLikeType("NAME", "Ashton", "*", "?", "\\");
    FilterType filter = new FilterType(pis);
    DirectPositionType dp = new DirectPositionType(21400.0, 2001368.0);
    PointType pt = new PointType(null, dp);
    pt.setSrsName("urn:ogc:def:crs:epsg:7.4:27582");
    PropertyType property = new PropertyType(new QName("the_geom"), new ValueType(pt));
    UpdateElementType update = new UpdateElementType(null, Arrays.asList(property), filter, new QName("http://www.opengis.net/gml", "NamedPlaces"), null);
    transac.getInsertOrUpdateOrDelete().add(update);
// marshaller.marshal(transac, System.out);
}
Also used : DirectPositionType(org.geotoolkit.gml.xml.v311.DirectPositionType) WGS84BoundingBoxType(org.geotoolkit.ows.xml.v100.WGS84BoundingBoxType) QName(javax.xml.namespace.QName) ArrayList(java.util.ArrayList) FilterType(org.geotoolkit.ogc.xml.v110.FilterType) StringWriter(java.io.StringWriter) PointType(org.geotoolkit.gml.xml.v311.PointType) PropertyIsLikeType(org.geotoolkit.ogc.xml.v110.PropertyIsLikeType)

Example 17 with WGS84BoundingBoxType

use of org.geotoolkit.ows.xml.v100.WGS84BoundingBoxType in project geotoolkit by Geomatys.

the class WfsXMLBindingTest method marshallingTest.

@Test
public void marshallingTest() throws JAXBException {
    WFSCapabilitiesType capa = new WFSCapabilitiesType();
    List<FeatureTypeType> featList = new ArrayList<>();
    List<String> otherSRS = Arrays.asList("urn:ogc:def:crs", "crs:EPSG::32615", "crs:EPSG::5773");
    WGS84BoundingBoxType bbox = new WGS84BoundingBoxType(29.8, -90.1, 30, -89.9);
    FeatureTypeType ft1 = new FeatureTypeType(new QName("http://www.opengis.net/ows-6/utds/0.3", "Building", "utds"), "", "urn:ogc:def:crs:EPSG::4979", otherSRS, Arrays.asList(bbox));
    featList.add(ft1);
    FeatureTypeListType featureList = new FeatureTypeListType(null, featList);
    capa.setFeatureTypeList(featureList);
    StringWriter sw = new StringWriter();
    marshaller.marshal(capa, sw);
    DeleteType del = null;
    TransactionType transac = new TransactionType("WFS", "1.1.0", null, AllSomeType.ALL, del);
    PropertyIsLikeType pis = new PropertyIsLikeType("NAME", "Ashton", "*", "?", "\\");
    FilterType filter = new FilterType(pis);
    DirectPositionType dp = new DirectPositionType(21400.0, 2001368.0);
    PointType pt = new PointType(null, dp);
    pt.setSrsName("urn:ogc:def:crs:epsg:7.4:27582");
    PropertyType property = new PropertyType(new ValueReference(), pt);
    UpdateType update = new UpdateType(null, Arrays.asList(property), filter, new QName("http://www.opengis.net/gml", "NamedPlaces"), null);
    final ObjectFactory factory = new ObjectFactory();
    transac.getAbstractTransactionAction().add(factory.createUpdate(update));
    sw = new StringWriter();
    marshaller.marshal(transac, sw);
    final List<StoredQueryDescription> descriptions = new ArrayList<>();
    final ParameterExpressionType param = new ParameterExpressionType("param1", "parameter 1", "a test parameter", new QName("http://www.w3.org/2001/XMLSchema", "string", "xs"));
    final List<QName> types = Arrays.asList(new QName("http://test.com", "someType"));
    final QueryType query = new QueryType(filter, types, "2.0.0");
    final QueryExpressionTextType queryEx = new QueryExpressionTextType("urn:ogc:def:queryLanguage:OGC-WFS::WFS_QueryExpression", query, types);
    final StoredQueryDescriptionType des1 = new StoredQueryDescriptionType("query1", "title1", "abstract1", param, queryEx);
    descriptions.add(des1);
    final StoredQueries storesQueries = new StoredQueries(descriptions);
    sw = new StringWriter();
    marshaller.marshal(storesQueries, sw);
    // System.out.println(sw.toString());
    StoredQueryListItemType item = new StoredQueryListItemType("someid", Arrays.asList(new Title("some title")), null);
    ListStoredQueriesResponseType lsqr = new ListStoredQueriesResponseType(Arrays.asList(item));
    sw = new StringWriter();
    marshaller.marshal(lsqr, sw);
    System.out.println(sw.toString());
    item = new StoredQueryListItemType("someid", Arrays.asList(new Title("some title")), Arrays.asList(new QName("")));
    lsqr = new ListStoredQueriesResponseType(Arrays.asList(item));
    sw = new StringWriter();
    marshaller.marshal(lsqr, sw);
    System.out.println(sw.toString());
}
Also used : DirectPositionType(org.geotoolkit.gml.xml.v321.DirectPositionType) ArrayList(java.util.ArrayList) StringWriter(java.io.StringWriter) WGS84BoundingBoxType(org.geotoolkit.ows.xml.v110.WGS84BoundingBoxType) QName(javax.xml.namespace.QName) FilterType(org.geotoolkit.ogc.xml.v200.FilterType) PointType(org.geotoolkit.gml.xml.v321.PointType) PropertyIsLikeType(org.geotoolkit.ogc.xml.v200.PropertyIsLikeType)

Example 18 with WGS84BoundingBoxType

use of org.geotoolkit.ows.xml.v100.WGS84BoundingBoxType in project geotoolkit by Geomatys.

the class WfsXMLBindingTest method unmarshallingTest.

@Test
public void unmarshallingTest() throws JAXBException, FileNotFoundException {
    InputStream is = WfsXMLBindingTest.class.getResourceAsStream("/org/geotoolkit/wfs/v200/capabilities.xml");
    Object unmarshalled = unmarshaller.unmarshal(is);
    if (unmarshalled instanceof JAXBElement) {
        unmarshalled = ((JAXBElement) unmarshalled).getValue();
    }
    assertTrue(unmarshalled instanceof WFSCapabilitiesType);
    WFSCapabilitiesType result = (WFSCapabilitiesType) unmarshalled;
    assertTrue(result.getFeatureTypeList() != null);
    WFSCapabilitiesType expResult = new WFSCapabilitiesType();
    List<FeatureTypeType> featList = new ArrayList<>();
    List<String> otherSRS = Arrays.asList("urn:ogc:def:crs", "crs:EPSG::32615", "crs:EPSG::5773");
    WGS84BoundingBoxType bbox = new WGS84BoundingBoxType(29.8, -90.1, 30, -89.9);
    FeatureTypeType ft1 = new FeatureTypeType(new QName("http://www.opengis.net/ows-6/utds/0.3", "Building", "utds"), "", "urn:ogc:def:crs:EPSG::4979", otherSRS, Arrays.asList(bbox));
    featList.add(ft1);
    FeatureTypeType ft2 = new FeatureTypeType(new QName("http://www.opengis.net/ows-6/utds/0.3", "AircraftTransportationComplex", "utds"), "", "urn:ogc:def:crs:EPSG::4979", otherSRS, Arrays.asList(bbox));
    featList.add(ft2);
    FeatureTypeType ft3 = new FeatureTypeType(new QName("http://www.opengis.net/ows-6/utds/0.3", "Fence", "utds"), "", "urn:ogc:def:crs:EPSG::4979", otherSRS, Arrays.asList(bbox));
    featList.add(ft3);
    FeatureTypeListType featureList = new FeatureTypeListType(null, featList);
    expResult.setFeatureTypeList(featureList);
    assertEquals(expResult.getFeatureTypeList().getFeatureType(), result.getFeatureTypeList().getFeatureType());
    assertEquals(expResult.getFeatureTypeList(), result.getFeatureTypeList());
    /*assertEquals(expResult.getOperationsMetadata(), result.getOperationsMetadata());
        assertEquals(expResult.getFilterCapabilities(), result.getFilterCapabilities());
        assertEquals(expResult, result);*/
    // TEST with WFSBindingUtilities
    is = WfsXMLBindingTest.class.getResourceAsStream("/org/geotoolkit/wfs/v200/capabilities.xml");
    Object obj = WFSBindingUtilities.unmarshall(is, WFSVersion.v200);
    assertTrue("was " + obj.getClass().getName(), obj instanceof WFSCapabilitiesType);
    result = (WFSCapabilitiesType) obj;
    assertEquals(expResult.getFeatureTypeList().getFeatureType(), result.getFeatureTypeList().getFeatureType());
    assertEquals(expResult.getFeatureTypeList(), result.getFeatureTypeList());
    String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + '\n' + "<wfs:Transaction version=\"2.0.0\" service=\"WFS\" xmlns:gml=\"http://www.opengis.net/gml/3.2\" xmlns:ogc=\"http://www.opengis.net/fes/2.0\" " + '\n' + "          xmlns:wfs=\"http://www.opengis.net/wfs/2.0\" xmlns:sampling=\"http://www.opengis.net/sampling/1.0\">" + '\n' + "    <wfs:Insert idgen=\"UseExisting\">" + '\n' + "    </wfs:Insert>" + '\n' + "</wfs:Transaction>";
    unmarshalled = unmarshaller.unmarshal(new StringReader(xml));
    if (unmarshalled instanceof JAXBElement) {
        unmarshalled = ((JAXBElement) unmarshalled).getValue();
    }
    assertTrue("was " + unmarshalled.getClass().getName(), unmarshalled instanceof TransactionType);
    TransactionType resultT = (TransactionType) unmarshalled;
    InsertType ins = new InsertType();
    // ins.setIdgen(IdentifierGenerationOptionType.USE_EXISTING);
    TransactionType expResultT = new TransactionType("WFS", "2.0.0", null, null, ins);
    assertEquals(expResultT, resultT);
    xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + '\n' + "<wfs:Transaction version=\"2.0.0\" service=\"WFS\" xmlns:gml=\"http://www.opengis.net/gml/3.2\" xmlns:fes=\"http://www.opengis.net/fes/2.0\" " + '\n' + "          xmlns:wfs=\"http://www.opengis.net/wfs/2.0\" xmlns:sampling=\"http://www.opengis.net/sampling/1.0\">" + '\n' + "    <wfs:Delete typeName=\"gml:test\">" + '\n' + "    </wfs:Delete>" + '\n' + "</wfs:Transaction>";
    unmarshalled = unmarshaller.unmarshal(new StringReader(xml));
    if (unmarshalled instanceof JAXBElement) {
        unmarshalled = ((JAXBElement) unmarshalled).getValue();
    }
    assertTrue(unmarshalled instanceof TransactionType);
    resultT = (TransactionType) unmarshalled;
    DeleteType del = new DeleteType();
    del.setTypeName(new QName("http://www.opengis.net/gml/3.2", "test"));
    expResultT = new TransactionType("WFS", "2.0.0", null, null, del);
    assertEquals(expResultT, resultT);
}
Also used : WGS84BoundingBoxType(org.geotoolkit.ows.xml.v110.WGS84BoundingBoxType) InputStream(java.io.InputStream) QName(javax.xml.namespace.QName) ArrayList(java.util.ArrayList) JAXBElement(javax.xml.bind.JAXBElement) StringReader(java.io.StringReader)

Aggregations

ArrayList (java.util.ArrayList)17 WGS84BoundingBoxType (org.geotoolkit.ows.xml.v100.WGS84BoundingBoxType)15 SimpleLiteral (org.geotoolkit.dublincore.xml.v2.elements.SimpleLiteral)13 BoundingBoxType (org.geotoolkit.ows.xml.v100.BoundingBoxType)13 Test (org.junit.Test)13 BriefRecordType (org.geotoolkit.csw.xml.v202.BriefRecordType)11 StringWriter (java.io.StringWriter)9 SummaryRecordType (org.geotoolkit.csw.xml.v202.SummaryRecordType)9 StringReader (java.io.StringReader)8 Marshaller (javax.xml.bind.Marshaller)7 AbstractRecordType (org.geotoolkit.csw.xml.v202.AbstractRecordType)7 RecordType (org.geotoolkit.csw.xml.v202.RecordType)7 Unmarshaller (javax.xml.bind.Unmarshaller)6 JAXBElement (javax.xml.bind.JAXBElement)5 QName (javax.xml.namespace.QName)4 InputStream (java.io.InputStream)2 List (java.util.List)2 GetRecordByIdResponseType (org.geotoolkit.csw.xml.v202.GetRecordByIdResponseType)2 GetRecordsResponseType (org.geotoolkit.csw.xml.v202.GetRecordsResponseType)2 InsertResultType (org.geotoolkit.csw.xml.v202.InsertResultType)2