Search in sources :

Example 6 with BriefRecordType

use of org.geotoolkit.csw.xml.v202.BriefRecordType in project geotoolkit by Geomatys.

the class CswXMLBindingTest method briefRecordUnmarshalingTest.

/**
 * Test brief Record Unmarshalling.
 */
@Test
public void briefRecordUnmarshalingTest() throws JAXBException {
    Unmarshaller unmarshaller = pool.acquireUnmarshaller();
    /*
         * Test marshalling BRIEF csw Record v2.0.2
         */
    String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n" + "<csw:BriefRecord xmlns:ows=\"http://www.opengis.net/ows\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:csw=\"http://www.opengis.net/cat/csw/2.0.2\">\n" + "  <dc:identifier>{8C71082D-5B3B-5F9D-FC40-F7807C8AB645}</dc:identifier>\n" + "  <dc:title>(JASON-1)</dc:title>\n" + "  <dc:type>clearinghouse</dc:type>\n" + "  <ows:WGS84BoundingBox dimensions=\"2\">\n" + "    <ows:LowerCorner>180.0 -66.0000000558794</ows:LowerCorner>\n" + "    <ows:UpperCorner>-180.0 65.9999999720603</ows:UpperCorner>\n" + "  </ows:WGS84BoundingBox>\n" + "</csw:BriefRecord>\n";
    StringReader sr = new StringReader(xml);
    BriefRecordType result = (BriefRecordType) unmarshaller.unmarshal(sr);
    SimpleLiteral id = new SimpleLiteral("{8C71082D-5B3B-5F9D-FC40-F7807C8AB645}");
    SimpleLiteral title = new SimpleLiteral("(JASON-1)");
    SimpleLiteral type = new SimpleLiteral("clearinghouse");
    List<BoundingBoxType> bbox = new ArrayList<>();
    bbox.add(new WGS84BoundingBoxType(180, -66.0000000558794, -180, 65.9999999720603));
    BriefRecordType expResult = new BriefRecordType(id, title, type, bbox);
    assertEquals(expResult, result);
    /*
         * Test marshalling csw Record v2.0.2
         */
    xml = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n" + "<csw:BriefRecord xmlns:ows=\"http://www.opengis.net/ows\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:csw=\"http://www.opengis.net/cat/csw/2.0.2\">\n" + "  <dc:identifier>{8C71082D-5B3B-5F9D-FC40-F7807C8AB645}</dc:identifier>\n" + "  <dc:identifier>urn:ogc:x-def:F7807C8AB645</dc:identifier>\n" + "  <dc:title>(JASON-1)</dc:title>\n" + "  <dc:title>(JASON-2)</dc:title>\n" + "  <dc:type>clearinghouse</dc:type>\n" + "  <ows:WGS84BoundingBox dimensions=\"2\">\n" + "    <ows:LowerCorner>180.0 -66.0000000558794</ows:LowerCorner>\n" + "    <ows:UpperCorner>-180.0 65.9999999720603</ows:UpperCorner>\n" + "  </ows:WGS84BoundingBox>\n" + "  <ows:WGS84BoundingBox dimensions=\"2\">\n" + "    <ows:LowerCorner>176.0 -16.4</ows:LowerCorner>\n" + "    <ows:UpperCorner>-178.0 6.1</ows:UpperCorner>\n" + "  </ows:WGS84BoundingBox>\n" + "</csw:BriefRecord>\n";
    sr = new StringReader(xml);
    result = (BriefRecordType) unmarshaller.unmarshal(sr);
    List<SimpleLiteral> identifiers = new ArrayList<>();
    identifiers.add(new SimpleLiteral("{8C71082D-5B3B-5F9D-FC40-F7807C8AB645}"));
    identifiers.add(new SimpleLiteral("urn:ogc:x-def:F7807C8AB645"));
    List<SimpleLiteral> titles = new ArrayList<>();
    titles.add(new SimpleLiteral("(JASON-1)"));
    titles.add(new SimpleLiteral("(JASON-2)"));
    type = new SimpleLiteral("clearinghouse");
    bbox = new ArrayList<>();
    bbox.add(new WGS84BoundingBoxType(180, -66.0000000558794, -180, 65.9999999720603));
    bbox.add(new WGS84BoundingBoxType(176, -16.4, -178, 6.1));
    expResult = new BriefRecordType(identifiers, titles, type, bbox);
    assertEquals(expResult, result);
    pool.recycle(unmarshaller);
}
Also used : BoundingBoxType(org.geotoolkit.ows.xml.v100.BoundingBoxType) WGS84BoundingBoxType(org.geotoolkit.ows.xml.v100.WGS84BoundingBoxType) WGS84BoundingBoxType(org.geotoolkit.ows.xml.v100.WGS84BoundingBoxType) StringReader(java.io.StringReader) ArrayList(java.util.ArrayList) SimpleLiteral(org.geotoolkit.dublincore.xml.v2.elements.SimpleLiteral) Unmarshaller(javax.xml.bind.Unmarshaller) BriefRecordType(org.geotoolkit.csw.xml.v202.BriefRecordType) Test(org.junit.Test)

Example 7 with BriefRecordType

use of org.geotoolkit.csw.xml.v202.BriefRecordType in project geotoolkit by Geomatys.

the class CswXMLBindingTest method transactionResponseUnmarshalingTest.

/**
 * Test simple Record Marshalling.
 */
@Test
public void transactionResponseUnmarshalingTest() throws JAXBException {
    Unmarshaller unmarshaller = pool.acquireUnmarshaller();
    String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<csw:TransactionResponse version=\"2.0.2\" xmlns:csw=\"http://www.opengis.net/cat/csw/2.0.2\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:ows=\"http://www.opengis.net/ows\">\n" + "  <csw:TransactionSummary requestId=\"rid\">\n" + "    <csw:totalInserted>2</csw:totalInserted>\n" + "    <csw:totalUpdated>0</csw:totalUpdated>\n" + "    <csw:totalDeleted>1</csw:totalDeleted>\n" + "  </csw:TransactionSummary>\n" + "  <csw:InsertResult>\n" + "    <csw:BriefRecord>\n" + "      <dc:identifier>{8C71082D-5B3B-5F9D-FC40-F7807C8AB645}</dc:identifier>\n" + "      <dc:title>(JASON-1)</dc:title>\n" + "      <dc:type>clearinghouse</dc:type>\n" + "      <ows:WGS84BoundingBox dimensions=\"2\">\n" + "        <ows:LowerCorner>180.0 -66.0000000558794</ows:LowerCorner>\n" + "        <ows:UpperCorner>-180.0 65.9999999720603</ows:UpperCorner>\n" + "      </ows:WGS84BoundingBox>\n" + "    </csw:BriefRecord>\n" + "  </csw:InsertResult>\n" + "</csw:TransactionResponse>\n";
    TransactionResponseType result = ((JAXBElement<TransactionResponseType>) unmarshaller.unmarshal(new StringReader(xml))).getValue();
    SimpleLiteral id = new SimpleLiteral("{8C71082D-5B3B-5F9D-FC40-F7807C8AB645}");
    SimpleLiteral title = new SimpleLiteral("(JASON-1)");
    SimpleLiteral type = new SimpleLiteral("clearinghouse");
    List<BoundingBoxType> bbox = new ArrayList<>();
    bbox.add(new WGS84BoundingBoxType(180, -66.0000000558794, -180, 65.9999999720603));
    Object record = new BriefRecordType(id, title, type, bbox);
    final List<InsertResultType> inserteds = new ArrayList<>();
    inserteds.add(new InsertResultType(Arrays.asList(record), null));
    TransactionSummaryType summ = new TransactionSummaryType(2, 0, 1, "rid");
    TransactionResponseType expResult = new TransactionResponseType(summ, inserteds, "2.0.2");
    assertEquals(expResult.getTransactionSummary(), result.getTransactionSummary());
    assertEquals(expResult.getInsertResult(), result.getInsertResult());
    assertEquals(expResult, result);
    pool.recycle(unmarshaller);
}
Also used : WGS84BoundingBoxType(org.geotoolkit.ows.xml.v100.WGS84BoundingBoxType) ArrayList(java.util.ArrayList) JAXBElement(javax.xml.bind.JAXBElement) TransactionSummaryType(org.geotoolkit.csw.xml.v202.TransactionSummaryType) BriefRecordType(org.geotoolkit.csw.xml.v202.BriefRecordType) TransactionResponseType(org.geotoolkit.csw.xml.v202.TransactionResponseType) BoundingBoxType(org.geotoolkit.ows.xml.v100.BoundingBoxType) WGS84BoundingBoxType(org.geotoolkit.ows.xml.v100.WGS84BoundingBoxType) StringReader(java.io.StringReader) SimpleLiteral(org.geotoolkit.dublincore.xml.v2.elements.SimpleLiteral) Unmarshaller(javax.xml.bind.Unmarshaller) InsertResultType(org.geotoolkit.csw.xml.v202.InsertResultType) Test(org.junit.Test)

Example 8 with BriefRecordType

use of org.geotoolkit.csw.xml.v202.BriefRecordType in project geotoolkit by Geomatys.

the class CswXMLBindingTest method getRecordsResponseMarshalingTest.

/**
 * Test getRecordById request Marshalling.
 */
@Test
public void getRecordsResponseMarshalingTest() throws JAXBException {
    Marshaller marshaller = pool.acquireMarshaller();
    /*
         * Test marshalling csw getRecordByIdResponse v2.0.2
         */
    SimpleLiteral id = new SimpleLiteral("{8C71082D-5B3B-5F9D-FC40-F7807C8AB645}");
    SimpleLiteral title = new SimpleLiteral("(JASON-1)");
    SimpleLiteral type = new SimpleLiteral("clearinghouse");
    List<SimpleLiteral> subject = new ArrayList<>();
    subject.add(new SimpleLiteral("oceans elevation NASA/JPL/JASON-1"));
    subject.add(new SimpleLiteral("oceans elevation 2"));
    SimpleLiteral modified = new SimpleLiteral("2007-11-15 21:26:49");
    SimpleLiteral Abstract = new SimpleLiteral("Jason-1 is the first follow-on to the highly successful TOPEX/Poseidonmission that measured ocean surface topography to an accuracy of 4.2cm.");
    SimpleLiteral references = new SimpleLiteral("http://keel.esri.com/output/TOOLKIT_Browse_Metadata_P7540_T8020_D1098.xml");
    SimpleLiteral spatial = new SimpleLiteral("northlimit=65.9999999720603; eastlimit=180; southlimit=-66.0000000558794; westlimit=-180;");
    List<BoundingBoxType> bbox = new ArrayList<>();
    bbox.add(new WGS84BoundingBoxType(180, -66.0000000558794, -180, 65.9999999720603));
    RecordType record = new RecordType(id, title, type, subject, null, modified, null, Abstract, bbox, null, null, null, spatial, references);
    BriefRecordType briefRecord = new BriefRecordType(id, title, type, bbox);
    SummaryRecordType sumRecord = new SummaryRecordType(id, title, type, bbox, subject, null, modified, Abstract);
    List<Object> records = new ArrayList<>();
    records.add(record);
    records.add(briefRecord);
    records.add(sumRecord);
    final SearchResultsType sr = new SearchResultsType("set", ElementSetType.BRIEF, 1, records, 1, 0);
    GetRecordsResponse response = new GetRecordsResponseType("rid", 100000, "v1.2", sr);
    StringWriter sw = new StringWriter();
    marshaller.marshal(response, sw);
    String result = sw.toString();
    String expResult = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n" + "<csw:GetRecordsResponse version=\"v1.2\" xmlns:ows=\"http://www.opengis.net/ows\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:csw=\"http://www.opengis.net/cat/csw/2.0.2\" xmlns:dct=\"http://purl.org/dc/terms/\">\n" + "  <csw:RequestId>rid</csw:RequestId>\n" + "  <csw:SearchStatus timestamp=\"1970-01-01T01:01:40.000+01:00\"/>\n" + "  <csw:SearchResults resultSetId=\"set\" elementSet=\"brief\" numberOfRecordsMatched=\"1\" numberOfRecordsReturned=\"1\" nextRecord=\"0\">\n" + "    <csw:Record>\n" + "      <dc:identifier>{8C71082D-5B3B-5F9D-FC40-F7807C8AB645}</dc:identifier>\n" + "      <dc:title>(JASON-1)</dc:title>\n" + "      <dc:type>clearinghouse</dc:type>\n" + "      <dc:subject>oceans elevation NASA/JPL/JASON-1</dc:subject>\n" + "      <dc:subject>oceans elevation 2</dc:subject>\n" + "      <dct:modified>2007-11-15 21:26:49</dct:modified>\n" + "      <dct:abstract>Jason-1 is the first follow-on to the highly successful TOPEX/Poseidonmission that measured ocean surface topography to an accuracy of 4.2cm.</dct:abstract>\n" + "      <dct:references>http://keel.esri.com/output/TOOLKIT_Browse_Metadata_P7540_T8020_D1098.xml</dct:references>\n" + "      <dct:spatial>northlimit=65.9999999720603; eastlimit=180; southlimit=-66.0000000558794; westlimit=-180;</dct:spatial>\n" + "      <ows:WGS84BoundingBox dimensions=\"2\">\n" + "        <ows:LowerCorner>180.0 -66.0000000558794</ows:LowerCorner>\n" + "        <ows:UpperCorner>-180.0 65.9999999720603</ows:UpperCorner>\n" + "      </ows:WGS84BoundingBox>\n" + "    </csw:Record>\n" + "    <csw:BriefRecord>\n" + "      <dc:identifier>{8C71082D-5B3B-5F9D-FC40-F7807C8AB645}</dc:identifier>\n" + "      <dc:title>(JASON-1)</dc:title>\n" + "      <dc:type>clearinghouse</dc:type>\n" + "      <ows:WGS84BoundingBox dimensions=\"2\">\n" + "        <ows:LowerCorner>180.0 -66.0000000558794</ows:LowerCorner>\n" + "        <ows:UpperCorner>-180.0 65.9999999720603</ows:UpperCorner>\n" + "      </ows:WGS84BoundingBox>\n" + "    </csw:BriefRecord>\n" + "    <csw:SummaryRecord>\n" + "      <dc:identifier>{8C71082D-5B3B-5F9D-FC40-F7807C8AB645}</dc:identifier>\n" + "      <dc:title>(JASON-1)</dc:title>\n" + "      <dc:type>clearinghouse</dc:type>\n" + "      <dc:subject>oceans elevation NASA/JPL/JASON-1</dc:subject>\n" + "      <dc:subject>oceans elevation 2</dc:subject>\n" + "      <dct:modified>2007-11-15 21:26:49</dct:modified>\n" + "      <dct:abstract>Jason-1 is the first follow-on to the highly successful TOPEX/Poseidonmission that measured ocean surface topography to an accuracy of 4.2cm.</dct:abstract>\n" + "      <ows:WGS84BoundingBox dimensions=\"2\">\n" + "        <ows:LowerCorner>180.0 -66.0000000558794</ows:LowerCorner>\n" + "        <ows:UpperCorner>-180.0 65.9999999720603</ows:UpperCorner>\n" + "      </ows:WGS84BoundingBox>\n" + "    </csw:SummaryRecord>\n" + "  </csw:SearchResults>\n" + "</csw:GetRecordsResponse>\n";
    LOGGER.log(Level.FINER, "RESULT:\n{0}", result);
    LOGGER.log(Level.FINER, "EXPRESULT:\n{0}", expResult);
    assertXmlEquals(expResult, result, "xmlns:*");
    pool.recycle(marshaller);
}
Also used : SummaryRecordType(org.geotoolkit.csw.xml.v202.SummaryRecordType) Marshaller(javax.xml.bind.Marshaller) WGS84BoundingBoxType(org.geotoolkit.ows.xml.v100.WGS84BoundingBoxType) SearchResultsType(org.geotoolkit.csw.xml.v202.SearchResultsType) ArrayList(java.util.ArrayList) BriefRecordType(org.geotoolkit.csw.xml.v202.BriefRecordType) BoundingBoxType(org.geotoolkit.ows.xml.v100.BoundingBoxType) WGS84BoundingBoxType(org.geotoolkit.ows.xml.v100.WGS84BoundingBoxType) AbstractRecordType(org.geotoolkit.csw.xml.v202.AbstractRecordType) BriefRecordType(org.geotoolkit.csw.xml.v202.BriefRecordType) SummaryRecordType(org.geotoolkit.csw.xml.v202.SummaryRecordType) RecordType(org.geotoolkit.csw.xml.v202.RecordType) StringWriter(java.io.StringWriter) GetRecordsResponseType(org.geotoolkit.csw.xml.v202.GetRecordsResponseType) SimpleLiteral(org.geotoolkit.dublincore.xml.v2.elements.SimpleLiteral) Test(org.junit.Test)

Example 9 with BriefRecordType

use of org.geotoolkit.csw.xml.v202.BriefRecordType in project geotoolkit by Geomatys.

the class CswXMLBindingTest method getRecordByIdResponseMarshalingTest.

/**
 * Test getRecordById request Marshalling.
 */
@Test
public void getRecordByIdResponseMarshalingTest() throws JAXBException {
    Marshaller marshaller = pool.acquireMarshaller();
    /*
         * Test marshalling csw getRecordByIdResponse v2.0.2
         */
    SimpleLiteral id = new SimpleLiteral("{8C71082D-5B3B-5F9D-FC40-F7807C8AB645}");
    SimpleLiteral title = new SimpleLiteral("(JASON-1)");
    SimpleLiteral type = new SimpleLiteral("clearinghouse");
    List<SimpleLiteral> subject = new ArrayList<>();
    subject.add(new SimpleLiteral("oceans elevation NASA/JPL/JASON-1"));
    subject.add(new SimpleLiteral("oceans elevation 2"));
    SimpleLiteral modified = new SimpleLiteral("2007-11-15 21:26:49");
    SimpleLiteral Abstract = new SimpleLiteral("Jason-1 is the first follow-on to the highly successful TOPEX/Poseidonmission that measured ocean surface topography to an accuracy of 4.2cm.");
    SimpleLiteral references = new SimpleLiteral("http://keel.esri.com/output/TOOLKIT_Browse_Metadata_P7540_T8020_D1098.xml");
    SimpleLiteral spatial = new SimpleLiteral("northlimit=65.9999999720603; eastlimit=180; southlimit=-66.0000000558794; westlimit=-180;");
    List<BoundingBoxType> bbox = new ArrayList<>();
    bbox.add(new WGS84BoundingBoxType(180, -66.0000000558794, -180, 65.9999999720603));
    RecordType record = new RecordType(id, title, type, subject, null, modified, null, Abstract, bbox, null, null, null, spatial, references);
    BriefRecordType briefRecord = new BriefRecordType(id, title, type, bbox);
    SummaryRecordType sumRecord = new SummaryRecordType(id, title, type, bbox, subject, null, modified, Abstract);
    List<Object> records = new ArrayList<>();
    records.add(record);
    records.add(briefRecord);
    records.add(sumRecord);
    GetRecordByIdResponse response = new GetRecordByIdResponseType(records);
    StringWriter sw = new StringWriter();
    marshaller.marshal(response, sw);
    String result = sw.toString();
    String expResult = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n" + "<csw:GetRecordByIdResponse xmlns:ows=\"http://www.opengis.net/ows\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:csw=\"http://www.opengis.net/cat/csw/2.0.2\" xmlns:dct=\"http://purl.org/dc/terms/\">\n" + "  <csw:Record>\n" + "    <dc:identifier>{8C71082D-5B3B-5F9D-FC40-F7807C8AB645}</dc:identifier>\n" + "    <dc:title>(JASON-1)</dc:title>\n" + "    <dc:type>clearinghouse</dc:type>\n" + "    <dc:subject>oceans elevation NASA/JPL/JASON-1</dc:subject>\n" + "    <dc:subject>oceans elevation 2</dc:subject>\n" + "    <dct:modified>2007-11-15 21:26:49</dct:modified>\n" + "    <dct:abstract>Jason-1 is the first follow-on to the highly successful TOPEX/Poseidonmission that measured ocean surface topography to an accuracy of 4.2cm.</dct:abstract>\n" + "    <dct:references>http://keel.esri.com/output/TOOLKIT_Browse_Metadata_P7540_T8020_D1098.xml</dct:references>\n" + "    <dct:spatial>northlimit=65.9999999720603; eastlimit=180; southlimit=-66.0000000558794; westlimit=-180;</dct:spatial>\n" + "    <ows:WGS84BoundingBox dimensions=\"2\">\n" + "      <ows:LowerCorner>180.0 -66.0000000558794</ows:LowerCorner>\n" + "      <ows:UpperCorner>-180.0 65.9999999720603</ows:UpperCorner>\n" + "    </ows:WGS84BoundingBox>\n" + "  </csw:Record>\n" + "  <csw:BriefRecord>\n" + "    <dc:identifier>{8C71082D-5B3B-5F9D-FC40-F7807C8AB645}</dc:identifier>\n" + "    <dc:title>(JASON-1)</dc:title>\n" + "    <dc:type>clearinghouse</dc:type>\n" + "    <ows:WGS84BoundingBox dimensions=\"2\">\n" + "      <ows:LowerCorner>180.0 -66.0000000558794</ows:LowerCorner>\n" + "      <ows:UpperCorner>-180.0 65.9999999720603</ows:UpperCorner>\n" + "    </ows:WGS84BoundingBox>\n" + "  </csw:BriefRecord>\n" + "  <csw:SummaryRecord>\n" + "    <dc:identifier>{8C71082D-5B3B-5F9D-FC40-F7807C8AB645}</dc:identifier>\n" + "    <dc:title>(JASON-1)</dc:title>\n" + "    <dc:type>clearinghouse</dc:type>\n" + "    <dc:subject>oceans elevation NASA/JPL/JASON-1</dc:subject>\n" + "    <dc:subject>oceans elevation 2</dc:subject>\n" + "    <dct:modified>2007-11-15 21:26:49</dct:modified>\n" + "    <dct:abstract>Jason-1 is the first follow-on to the highly successful TOPEX/Poseidonmission that measured ocean surface topography to an accuracy of 4.2cm.</dct:abstract>\n" + "    <ows:WGS84BoundingBox dimensions=\"2\">\n" + "      <ows:LowerCorner>180.0 -66.0000000558794</ows:LowerCorner>\n" + "      <ows:UpperCorner>-180.0 65.9999999720603</ows:UpperCorner>\n" + "    </ows:WGS84BoundingBox>\n" + "  </csw:SummaryRecord>\n" + "</csw:GetRecordByIdResponse>\n";
    LOGGER.log(Level.FINER, "RESULT:\n{0}", result);
    LOGGER.log(Level.FINER, "EXPRESULT:\n{0}", expResult);
    assertXmlEquals(expResult, result, "xmlns:*");
    pool.recycle(marshaller);
}
Also used : SummaryRecordType(org.geotoolkit.csw.xml.v202.SummaryRecordType) Marshaller(javax.xml.bind.Marshaller) WGS84BoundingBoxType(org.geotoolkit.ows.xml.v100.WGS84BoundingBoxType) ArrayList(java.util.ArrayList) BriefRecordType(org.geotoolkit.csw.xml.v202.BriefRecordType) BoundingBoxType(org.geotoolkit.ows.xml.v100.BoundingBoxType) WGS84BoundingBoxType(org.geotoolkit.ows.xml.v100.WGS84BoundingBoxType) GetRecordByIdResponseType(org.geotoolkit.csw.xml.v202.GetRecordByIdResponseType) AbstractRecordType(org.geotoolkit.csw.xml.v202.AbstractRecordType) BriefRecordType(org.geotoolkit.csw.xml.v202.BriefRecordType) SummaryRecordType(org.geotoolkit.csw.xml.v202.SummaryRecordType) RecordType(org.geotoolkit.csw.xml.v202.RecordType) StringWriter(java.io.StringWriter) SimpleLiteral(org.geotoolkit.dublincore.xml.v2.elements.SimpleLiteral) Test(org.junit.Test)

Example 10 with BriefRecordType

use of org.geotoolkit.csw.xml.v202.BriefRecordType 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)

Aggregations

Test (org.junit.Test)9 ArrayList (java.util.ArrayList)8 BriefRecordType (org.geotoolkit.csw.xml.v202.BriefRecordType)8 SimpleLiteral (org.geotoolkit.dublincore.xml.v2.elements.SimpleLiteral)8 BoundingBoxType (org.geotoolkit.ows.xml.v100.BoundingBoxType)8 WGS84BoundingBoxType (org.geotoolkit.ows.xml.v100.WGS84BoundingBoxType)8 StringReader (java.io.StringReader)4 StringWriter (java.io.StringWriter)4 JAXBElement (javax.xml.bind.JAXBElement)4 Marshaller (javax.xml.bind.Marshaller)4 Unmarshaller (javax.xml.bind.Unmarshaller)4 AbstractRecordType (org.geotoolkit.csw.xml.v202.AbstractRecordType)4 RecordType (org.geotoolkit.csw.xml.v202.RecordType)4 SummaryRecordType (org.geotoolkit.csw.xml.v202.SummaryRecordType)4 Metacard (ddf.catalog.data.Metacard)3 BriefRecordType (net.opengis.cat.csw.v_2_0_2.BriefRecordType)3 SimpleLiteral (net.opengis.cat.csw.v_2_0_2.dc.elements.SimpleLiteral)3 List (java.util.List)2 BriefRecordType (net.opengis.cat.csw._3.BriefRecordType)2 InsertResultType (net.opengis.cat.csw.v_2_0_2.InsertResultType)2