Search in sources :

Example 1 with SummaryRecordType

use of net.opengis.cat.csw._3.SummaryRecordType in project ddf by codice.

the class TestCswSourceBase method generateCswCollection.

protected CswRecordCollection generateCswCollection(String file) {
    InputStream stream = getClass().getResourceAsStream(file);
    GetRecordsResponseType recordsResponse = parseXml(stream);
    GetRecordsResponseType records = new GetRecordsResponseType();
    recordsResponse.copyTo(records);
    List<Metacard> cswRecords = new LinkedList<>();
    for (JAXBElement<? extends AbstractRecordType> rec : records.getSearchResults().getAbstractRecord()) {
        MetacardImpl metacard = new MetacardImpl();
        cswRecords.add(metacard);
        if (rec.getValue() instanceof BriefRecordType) {
            BriefRecordType record = (BriefRecordType) rec.getValue();
            metacard.setId(record.getIdentifier().get(0).getValue().getContent().get(0));
            if (!CollectionUtils.isEmpty(record.getType().getContent())) {
                metacard.setContentTypeName(record.getType().getContent().get(0));
            }
        } else if (rec.getValue() instanceof SummaryRecordType) {
            SummaryRecordType record = (SummaryRecordType) rec.getValue();
            metacard.setId(record.getIdentifier().get(0).getValue().getContent().get(0));
            if (!CollectionUtils.isEmpty(record.getType().getContent())) {
                metacard.setContentTypeName(record.getType().getContent().get(0));
            }
        } else if (rec.getValue() instanceof RecordType) {
            RecordType record = (RecordType) rec.getValue();
            for (JAXBElement<SimpleLiteral> jb : record.getDCElement()) {
                if ("identifier".equals(jb.getName().getLocalPart())) {
                    metacard.setId(jb.getValue().getContent().get(0));
                }
                if ("type".equals(jb.getName().getLocalPart()) && !CollectionUtils.isEmpty(jb.getValue().getContent())) {
                    metacard.setContentTypeName(jb.getValue().getContent().get(0));
                }
            }
        }
    }
    CswRecordCollection collection = new CswRecordCollection();
    collection.setCswRecords(cswRecords);
    collection.setNumberOfRecordsMatched(records.getSearchResults().getNumberOfRecordsMatched().intValue());
    collection.setNumberOfRecordsReturned(records.getSearchResults().getNumberOfRecordsReturned().intValue());
    return collection;
}
Also used : SummaryRecordType(net.opengis.cat.csw.v_2_0_2.SummaryRecordType) InputStream(java.io.InputStream) BriefRecordType(net.opengis.cat.csw.v_2_0_2.BriefRecordType) LinkedList(java.util.LinkedList) MetacardImpl(ddf.catalog.data.impl.MetacardImpl) Metacard(ddf.catalog.data.Metacard) AbstractRecordType(net.opengis.cat.csw.v_2_0_2.AbstractRecordType) RecordType(net.opengis.cat.csw.v_2_0_2.RecordType) SummaryRecordType(net.opengis.cat.csw.v_2_0_2.SummaryRecordType) BriefRecordType(net.opengis.cat.csw.v_2_0_2.BriefRecordType) CswRecordCollection(org.codice.ddf.spatial.ogc.csw.catalog.common.CswRecordCollection) GetRecordsResponseType(net.opengis.cat.csw.v_2_0_2.GetRecordsResponseType) SimpleLiteral(net.opengis.cat.csw.v_2_0_2.dc.elements.SimpleLiteral)

Example 2 with SummaryRecordType

use of net.opengis.cat.csw._3.SummaryRecordType in project geotoolkit by Geomatys.

the class CswXMLBindingTest method getRecordsResponseUnMarshalingTest.

/**
 * Test getRecordById request Marshalling.
 */
@Test
public void getRecordsResponseUnMarshalingTest() throws JAXBException {
    Unmarshaller unmarshaller = pool.acquireUnmarshaller();
    /*
         * 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 expResult = new GetRecordsResponseType("rid", 100000, "v1.2", sr);
    String xml = "<?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";
    GetRecordsResponse result = ((JAXBElement<GetRecordsResponse>) unmarshaller.unmarshal(new StringReader(xml))).getValue();
    assertTrue(result.getSearchResults().getAny() instanceof List);
    List<Object> resultList = result.getSearchResults().getAny();
    List<Object> expResultList = expResult.getSearchResults().getAny();
    assertEquals(expResultList.get(0), resultList.get(0));
    assertEquals(expResultList.get(1), resultList.get(1));
    assertEquals(expResultList.get(2), resultList.get(2));
    assertEquals(expResultList, resultList);
    assertEquals(expResult.getSearchResults().getAny(), result.getSearchResults().getAny());
    assertEquals(expResult.getSearchStatus(), result.getSearchStatus());
    assertEquals(expResult, result);
    pool.recycle(unmarshaller);
}
Also used : SummaryRecordType(org.geotoolkit.csw.xml.v202.SummaryRecordType) WGS84BoundingBoxType(org.geotoolkit.ows.xml.v100.WGS84BoundingBoxType) SearchResultsType(org.geotoolkit.csw.xml.v202.SearchResultsType) ArrayList(java.util.ArrayList) JAXBElement(javax.xml.bind.JAXBElement) 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) StringReader(java.io.StringReader) GetRecordsResponseType(org.geotoolkit.csw.xml.v202.GetRecordsResponseType) SimpleLiteral(org.geotoolkit.dublincore.xml.v2.elements.SimpleLiteral) List(java.util.List) ArrayList(java.util.ArrayList) Unmarshaller(javax.xml.bind.Unmarshaller) Test(org.junit.Test)

Example 3 with SummaryRecordType

use of net.opengis.cat.csw._3.SummaryRecordType 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 4 with SummaryRecordType

use of net.opengis.cat.csw._3.SummaryRecordType in project geotoolkit by Geomatys.

the class CswXMLBindingTest method summmaryRecordMarshalingTest.

/**
 * Test summary Record Marshalling.
 */
@Test
public void summmaryRecordMarshalingTest() throws JAXBException {
    Marshaller marshaller = pool.acquireMarshaller();
    /*
         * Test marshalling csw summmary Record 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"));
    List<SimpleLiteral> formats = new ArrayList<>();
    formats.add(new SimpleLiteral("format 11-11"));
    formats.add(new SimpleLiteral("format 22-22"));
    SimpleLiteral modified = new SimpleLiteral("2007-11-15 21:26:49");
    List<SimpleLiteral> Abstract = new ArrayList<>();
    Abstract.add(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."));
    List<BoundingBoxType> bbox = new ArrayList<>();
    bbox.add(new WGS84BoundingBoxType(180, -66.0000000558794, -180, 65.9999999720603));
    SummaryRecordType record = new SummaryRecordType(id, title, type, bbox, subject, formats, modified, Abstract);
    StringWriter sw = new StringWriter();
    marshaller.marshal(record, sw);
    String result = sw.toString();
    String expResult = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n" + "<csw:SummaryRecord 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" + "  <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" + "  <dc:format>format 11-11</dc:format>\n" + "  <dc:format>format 22-22</dc:format>\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";
    assertXmlEquals(expResult, result, "xmlns:*");
    /*
         * Test marshalling csw summmary Record v2.0.2
         */
    List<SimpleLiteral> ids = new ArrayList<>();
    ids.add(new SimpleLiteral("{8C71082D-5B3B-5F9D-FC40-F7807C8AB645}"));
    ids.add(new SimpleLiteral("urn:ogc-x:df:F7807C8AB645"));
    List<SimpleLiteral> titles = new ArrayList<>();
    titles.add(new SimpleLiteral("(JASON-1)"));
    titles.add(new SimpleLiteral("(JASON-2)"));
    type = new SimpleLiteral("clearinghouse");
    subject = new ArrayList<>();
    subject.add(new SimpleLiteral("oceans elevation NASA/JPL/JASON-1"));
    subject.add(new SimpleLiteral("oceans elevation 2"));
    formats = new ArrayList<>();
    formats.add(new SimpleLiteral("format 11-11"));
    formats.add(new SimpleLiteral("format 22-22"));
    List<SimpleLiteral> modifieds = new ArrayList<>();
    modifieds.add(new SimpleLiteral("2007-11-15 21:26:49"));
    modifieds.add(new SimpleLiteral("2007-11-15 21:26:48"));
    Abstract = new ArrayList<>();
    Abstract.add(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."));
    Abstract.add(new SimpleLiteral("Jason-2 blablablablabla."));
    bbox = new ArrayList<>();
    bbox.add(new WGS84BoundingBoxType(180, -66.0000000558794, -180, 65.9999999720603));
    bbox.add(new WGS84BoundingBoxType(100, -6.04, -144, 5.9));
    record = new SummaryRecordType(ids, titles, type, bbox, subject, formats, modifieds, Abstract);
    sw = new StringWriter();
    marshaller.marshal(record, sw);
    result = sw.toString();
    expResult = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n" + "<csw:SummaryRecord 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" + "  <dc:identifier>{8C71082D-5B3B-5F9D-FC40-F7807C8AB645}</dc:identifier>\n" + "  <dc:identifier>urn:ogc-x:df:F7807C8AB645</dc:identifier>\n" + "  <dc:title>(JASON-1)</dc:title>\n" + "  <dc:title>(JASON-2)</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" + "  <dc:format>format 11-11</dc:format>\n" + "  <dc:format>format 22-22</dc:format>\n" + "  <dct:modified>2007-11-15 21:26:49</dct:modified>\n" + "  <dct:modified>2007-11-15 21:26:48</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:abstract>Jason-2 blablablablabla.</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" + "  <ows:WGS84BoundingBox dimensions=\"2\">\n" + "    <ows:LowerCorner>100.0 -6.04</ows:LowerCorner>\n" + "    <ows:UpperCorner>-144.0 5.9</ows:UpperCorner>\n" + "  </ows:WGS84BoundingBox>\n" + "</csw:SummaryRecord>\n";
    assertXmlEquals(expResult, result, "xmlns:*");
    pool.recycle(marshaller);
}
Also used : BoundingBoxType(org.geotoolkit.ows.xml.v100.BoundingBoxType) WGS84BoundingBoxType(org.geotoolkit.ows.xml.v100.WGS84BoundingBoxType) SummaryRecordType(org.geotoolkit.csw.xml.v202.SummaryRecordType) Marshaller(javax.xml.bind.Marshaller) StringWriter(java.io.StringWriter) WGS84BoundingBoxType(org.geotoolkit.ows.xml.v100.WGS84BoundingBoxType) ArrayList(java.util.ArrayList) SimpleLiteral(org.geotoolkit.dublincore.xml.v2.elements.SimpleLiteral) Test(org.junit.Test)

Example 5 with SummaryRecordType

use of net.opengis.cat.csw._3.SummaryRecordType 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)

Aggregations

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