Search in sources :

Example 16 with TransactionSummaryType

use of org.geotoolkit.csw.xml.v202.TransactionSummaryType in project geo-platform by geosdi.

the class WFSTransactionInsertTest method tasmaniaRoads.

@Test
@Ignore(value = "To Enable this test there will be a Geoserver local to run.")
public void tasmaniaRoads() throws Exception {
    WFSTransactionRequest<TransactionResponseType> request = serverConnector.createTransactionRequest();
    request.setOperation(INSERT);
    request.setTypeName(TASMANIA_ROADS);
    AttributeDTO att = new AttributeDTO();
    att.setName("TYPE");
    att.setValue("ecco");
    GeometryAttributeDTO geometry = new GeometryAttributeDTO();
    geometry.setName("the_geom");
    geometry.setSrid(valueOf(4326));
    geometry.setValue("MULTILINESTRING ((10 10, 20 20, 10 40), (40 40, 30 30, 40 20, 30 10))");
    request.setAttributes(Arrays.asList(att, geometry));
    logger.info("***************** Request TRANSACTION INSERT ******\n{}\n\n", request.showRequestAsString());
    TransactionResponseType response = request.getResponse();
    logger.info("\n*** {}", response.getTransactionResults());
    TransactionSummaryType transactionSummary = response.getTransactionSummary();
    assertEquals(0, transactionSummary.getTotalDeleted().intValue());
    assertEquals(0, transactionSummary.getTotalUpdated().intValue());
    assertEquals(1, transactionSummary.getTotalInserted().intValue());
    assertEquals("1.1.0", response.getVersion());
    logger.info("@@@@@@@@@@@@@@@@@@@@@@InsertResults {}", response.getInsertResults());
    List<LayerSchemaDTO> schemas = featureReaderXSD.read(new URL(wfsURL + "?service=wfs" + "&version=1.1.0" + "&request=DescribeFeatureType" + "&typeName=topp:tasmania_roads").openStream());
    assertNotNull(schemas);
    assertEquals(1, schemas.size());
    LayerSchemaDTO layerSchema = schemas.get(0);
    logger.info("###############################Layer Schema : {}", layerSchema);
    QName name = new QName("topp:tasmania_roads");
    WFSGetFeatureRequest getRequest = serverConnector.createGetFeatureRequest();
    getRequest.setTypeName(name);
    getRequest.setResultType(ResultTypeType.RESULTS.value());
    InputStream is = getRequest.getResponseAsStream();
    WFSGetFeatureStaxReader featureReaderStAX = new WFSGetFeatureStaxReader(layerSchema);
    FeatureCollectionDTO featureCollection = featureReaderStAX.read(is);
    logger.info("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ {}", featureCollection);
}
Also used : QName(javax.xml.namespace.QName) InputStream(java.io.InputStream) TransactionSummaryType(org.geosdi.geoplatform.xml.wfs.v110.TransactionSummaryType) WFSGetFeatureRequest(org.geosdi.geoplatform.connector.server.request.WFSGetFeatureRequest) URL(java.net.URL) TransactionResponseType(org.geosdi.geoplatform.xml.wfs.v110.TransactionResponseType) FeatureCollectionDTO(org.geosdi.geoplatform.connector.wfs.response.FeatureCollectionDTO) GeometryAttributeDTO(org.geosdi.geoplatform.connector.wfs.response.GeometryAttributeDTO) AttributeDTO(org.geosdi.geoplatform.connector.wfs.response.AttributeDTO) WFSGetFeatureStaxReader(org.geosdi.geoplatform.support.wfs.feature.reader.WFSGetFeatureStaxReader) GeometryAttributeDTO(org.geosdi.geoplatform.connector.wfs.response.GeometryAttributeDTO) LayerSchemaDTO(org.geosdi.geoplatform.connector.wfs.response.LayerSchemaDTO) Ignore(org.junit.Ignore) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)15 TransactionResponseType (net.opengis.cat.csw.v_2_0_2.TransactionResponseType)13 TransactionSummaryType (net.opengis.cat.csw.v_2_0_2.TransactionSummaryType)13 MetacardImpl (ddf.catalog.data.impl.MetacardImpl)11 CswTransactionRequest (org.codice.ddf.spatial.ogc.csw.catalog.common.transaction.CswTransactionRequest)11 ArrayList (java.util.ArrayList)8 Metacard (ddf.catalog.data.Metacard)5 ResultImpl (ddf.catalog.data.impl.ResultImpl)5 Update (ddf.catalog.operation.Update)5 UpdateRequest (ddf.catalog.operation.UpdateRequest)5 UpdateResponse (ddf.catalog.operation.UpdateResponse)5 UpdateImpl (ddf.catalog.operation.impl.UpdateImpl)5 UpdateResponseImpl (ddf.catalog.operation.impl.UpdateResponseImpl)5 Result (ddf.catalog.data.Result)4 QueryResponse (ddf.catalog.operation.QueryResponse)4 QueryResponseImpl (ddf.catalog.operation.impl.QueryResponseImpl)4 QName (javax.xml.namespace.QName)4 UpdateAction (org.codice.ddf.spatial.ogc.csw.catalog.actions.UpdateAction)4 QueryRequest (ddf.catalog.operation.QueryRequest)3 Serializable (java.io.Serializable)3