Search in sources :

Example 6 with InsertResultType

use of org.geotoolkit.csw.xml.v202.InsertResultType in project ddf by codice.

the class CswEndpoint method getInsertResultFromResponse.

private InsertResultType getInsertResultFromResponse(CreateResponse createResponse) throws CswException {
    InsertResultType result = new InsertResultType();
    WKTReader reader = new WKTReader();
    for (Metacard metacard : createResponse.getCreatedMetacards()) {
        BoundingBoxType boundingBox = new BoundingBoxType();
        Geometry geometry = null;
        String bbox = null;
        try {
            if (metacard.getAttribute(CswConstants.BBOX_PROP) != null) {
                bbox = metacard.getAttribute(CswConstants.BBOX_PROP).getValue().toString();
                geometry = reader.read(bbox);
            } else if (StringUtils.isNotBlank(metacard.getLocation())) {
                bbox = metacard.getLocation();
                geometry = reader.read(bbox);
            }
        } catch (ParseException e) {
            LOGGER.debug("Unable to parse BoundingBox : {}", bbox, e);
        }
        BriefRecordType briefRecordType = new BriefRecordType();
        if (geometry != null) {
            Envelope bounds = geometry.getEnvelopeInternal();
            if (bounds != null) {
                boundingBox.setCrs(CswConstants.SRS_NAME);
                boundingBox.setLowerCorner(Arrays.asList(bounds.getMinX(), bounds.getMinY()));
                boundingBox.setUpperCorner(Arrays.asList(bounds.getMaxX(), bounds.getMaxY()));
                briefRecordType.getBoundingBox().add(new net.opengis.ows.v_1_0_0.ObjectFactory().createBoundingBox(boundingBox));
            }
        }
        SimpleLiteral identifier = new SimpleLiteral();
        identifier.getContent().add(metacard.getId());
        briefRecordType.getIdentifier().add(new JAXBElement<>(CswConstants.DC_IDENTIFIER_QNAME, SimpleLiteral.class, identifier));
        SimpleLiteral title = new SimpleLiteral();
        title.getContent().add(metacard.getTitle());
        briefRecordType.getTitle().add(new JAXBElement<>(CswConstants.DC_TITLE_QNAME, SimpleLiteral.class, title));
        SimpleLiteral type = new SimpleLiteral();
        type.getContent().add(metacard.getContentTypeName());
        briefRecordType.setType(type);
        result.getBriefRecord().add(briefRecordType);
    }
    return result;
}
Also used : WKTReader(org.locationtech.jts.io.WKTReader) Envelope(org.locationtech.jts.geom.Envelope) BriefRecordType(net.opengis.cat.csw.v_2_0_2.BriefRecordType) BoundingBoxType(net.opengis.ows.v_1_0_0.BoundingBoxType) Geometry(org.locationtech.jts.geom.Geometry) Metacard(ddf.catalog.data.Metacard) ObjectFactory(net.opengis.cat.csw.v_2_0_2.ObjectFactory) SimpleLiteral(net.opengis.cat.csw.v_2_0_2.dc.elements.SimpleLiteral) MimeTypeParseException(javax.activation.MimeTypeParseException) ParseException(org.locationtech.jts.io.ParseException) InsertResultType(net.opengis.cat.csw.v_2_0_2.InsertResultType)

Example 7 with InsertResultType

use of org.geotoolkit.csw.xml.v202.InsertResultType in project arctic-sea by 52North.

the class SosDecoderv20 method parseInsertResult.

private OwsServiceRequest parseInsertResult(final InsertResultDocument insertResultDoc) throws DecodingException {
    final InsertResultType insertResult = insertResultDoc.getInsertResult();
    final InsertResultRequest sosInsertResultRequest = new InsertResultRequest();
    sosInsertResultRequest.setService(insertResult.getService());
    sosInsertResultRequest.setVersion(insertResult.getVersion());
    sosInsertResultRequest.setTemplateIdentifier(insertResult.getTemplate());
    sosInsertResultRequest.setResultValues(parseResultValues(insertResult.getResultValues()));
    sosInsertResultRequest.setExtensions(parseExtensibleRequest(insertResult));
    return sosInsertResultRequest;
}
Also used : InsertResultRequest(org.n52.shetland.ogc.sos.request.InsertResultRequest) InsertResultType(net.opengis.sos.x20.InsertResultType)

Aggregations

InsertResultType (net.opengis.sos.x20.InsertResultType)3 Test (org.junit.Test)3 Metacard (ddf.catalog.data.Metacard)2 ArrayList (java.util.ArrayList)2 JAXBElement (javax.xml.bind.JAXBElement)2 BriefRecordType (net.opengis.cat.csw.v_2_0_2.BriefRecordType)2 InsertResultType (net.opengis.cat.csw.v_2_0_2.InsertResultType)2 SimpleLiteral (net.opengis.cat.csw.v_2_0_2.dc.elements.SimpleLiteral)2 InsertResultDocument (net.opengis.sos.x20.InsertResultDocument)2 BriefRecordType (org.geotoolkit.csw.xml.v202.BriefRecordType)2 InsertResultType (org.geotoolkit.csw.xml.v202.InsertResultType)2 TransactionResponseType (org.geotoolkit.csw.xml.v202.TransactionResponseType)2 TransactionSummaryType (org.geotoolkit.csw.xml.v202.TransactionSummaryType)2 SimpleLiteral (org.geotoolkit.dublincore.xml.v2.elements.SimpleLiteral)2 BoundingBoxType (org.geotoolkit.ows.xml.v100.BoundingBoxType)2 WGS84BoundingBoxType (org.geotoolkit.ows.xml.v100.WGS84BoundingBoxType)2 InsertResultRequest (org.n52.shetland.ogc.sos.request.InsertResultRequest)2 ResultImpl (ddf.catalog.data.impl.ResultImpl)1 CreateRequest (ddf.catalog.operation.CreateRequest)1 CreateResponse (ddf.catalog.operation.CreateResponse)1