Search in sources :

Example 11 with SimpleLiteral

use of org.geotoolkit.dublincore.xml.v2.elements.SimpleLiteral in project geotoolkit by Geomatys.

the class CswXMLBindingTest method updateMarshalingTest.

/**
 * Test simple Record Marshalling.
 */
@Test
public void updateMarshalingTest() throws JAXBException, IOException, ParserConfigurationException, SAXException {
    Marshaller marshaller = pool.acquireMarshaller();
    // <TODO
    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);
    QueryConstraintType query = new QueryConstraintType("identifier='{8C71082D-5B3B-5F9D-FC40-F7807C8AB645}'", "1.1.0");
    UpdateType update = new UpdateType(record, query);
    TransactionType request = new TransactionType("CSW", "2.0.2", update);
    // marshaller.marshal(request, System.out);
    // TODO/>
    /*
         * Test 2 : Simple recordProperty (String)
         */
    RecordPropertyType recordProperty = new RecordPropertyType("/csw:Record/dc:contributor", "Jane");
    query = new QueryConstraintType("identifier='{8C71082D-5B3B-5F9D-FC40-F7807C8AB645}'", "1.1.0");
    update = new UpdateType(Arrays.asList(recordProperty), query);
    request = new TransactionType("CSW", "2.0.2", update);
    String expResult = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n" + "<csw:Transaction verboseResponse=\"false\" version=\"2.0.2\" service=\"CSW\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:csw=\"http://www.opengis.net/cat/csw/2.0.2\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\n" + "  <csw:Update>\n" + "    <csw:RecordProperty>\n" + "      <csw:Name>/csw:Record/dc:contributor</csw:Name>\n" + "      <csw:Value>Jane</csw:Value>\n" + "    </csw:RecordProperty>\n" + "    <csw:Constraint version=\"1.1.0\">\n" + "      <csw:CqlText>identifier='{8C71082D-5B3B-5F9D-FC40-F7807C8AB645}'</csw:CqlText>\n" + "    </csw:Constraint>\n" + "  </csw:Update>\n" + "</csw:Transaction>\n";
    StringWriter sw = new StringWriter();
    marshaller.marshal(request, sw);
    String result = sw.toString();
    assertXmlEquals(expResult, result, "xmlns:*");
    /*
         * Test 3 : Complex recordProperty (GeographicBoundingBox)
         */
    DefaultGeographicBoundingBox geographicElement = new DefaultGeographicBoundingBox(1.1, 1.1, 1.1, 1.1);
    recordProperty = new RecordPropertyType("/gmd:MD_Metadata/identificationInfo/extent/geographicElement", geographicElement);
    query = new QueryConstraintType("identifier='{8C71082D-5B3B-5F9D-FC40-F7807C8AB645}'", "1.1.0");
    update = new UpdateType(Arrays.asList(recordProperty), query);
    request = new TransactionType("CSW", "2.0.2", update);
    expResult = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n" + "<csw:Transaction verboseResponse=\"false\" version=\"2.0.2\" service=\"CSW\" xmlns:csw=\"http://www.opengis.net/cat/csw/2.0.2\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:gmd=\"http://www.isotc211.org/2005/gmd\" xmlns:gco=\"http://www.isotc211.org/2005/gco\">\n" + "  <csw:Update>\n" + "    <csw:RecordProperty>\n" + "      <csw:Name>/gmd:MD_Metadata/identificationInfo/extent/geographicElement</csw:Name>\n" + "      <csw:Value>\n" + "       <gmd:EX_GeographicBoundingBox>" + '\n' + "        <gmd:extentTypeCode>\n" + "          <gco:Boolean>true</gco:Boolean>\n" + "        </gmd:extentTypeCode>\n" + "        <gmd:westBoundLongitude>\n" + "          <gco:Decimal>1.1</gco:Decimal>\n" + "        </gmd:westBoundLongitude>\n" + "        <gmd:eastBoundLongitude>\n" + "          <gco:Decimal>1.1</gco:Decimal>\n" + "        </gmd:eastBoundLongitude>\n" + "        <gmd:southBoundLatitude>\n" + "          <gco:Decimal>1.1</gco:Decimal>\n" + "        </gmd:southBoundLatitude>\n" + "        <gmd:northBoundLatitude>\n" + "          <gco:Decimal>1.1</gco:Decimal>\n" + "        </gmd:northBoundLatitude>\n" + "       </gmd:EX_GeographicBoundingBox>" + '\n' + "      </csw:Value>\n" + "    </csw:RecordProperty>\n" + "    <csw:Constraint version=\"1.1.0\">\n" + "      <csw:CqlText>identifier='{8C71082D-5B3B-5F9D-FC40-F7807C8AB645}'</csw:CqlText>\n" + "    </csw:Constraint>\n" + "  </csw:Update>\n" + "</csw:Transaction>\n";
    sw = new StringWriter();
    marshaller.marshal(request, sw);
    result = sw.toString();
    assertXmlEquals(expResult, result, "xmlns:*");
    pool.recycle(marshaller);
}
Also used : RecordPropertyType(org.geotoolkit.csw.xml.v202.RecordPropertyType) Marshaller(javax.xml.bind.Marshaller) TransactionType(org.geotoolkit.csw.xml.v202.TransactionType) WGS84BoundingBoxType(org.geotoolkit.ows.xml.v100.WGS84BoundingBoxType) ArrayList(java.util.ArrayList) UpdateType(org.geotoolkit.csw.xml.v202.UpdateType) QueryConstraintType(org.geotoolkit.csw.xml.v202.QueryConstraintType) BoundingBoxType(org.geotoolkit.ows.xml.v100.BoundingBoxType) WGS84BoundingBoxType(org.geotoolkit.ows.xml.v100.WGS84BoundingBoxType) DefaultGeographicBoundingBox(org.apache.sis.metadata.iso.extent.DefaultGeographicBoundingBox) 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 12 with SimpleLiteral

use of org.geotoolkit.dublincore.xml.v2.elements.SimpleLiteral in project geotoolkit by Geomatys.

the class CswXMLBindingTest method recordMarshalingTest.

/**
 * Test simple Record Marshalling.
 */
@Test
public void recordMarshalingTest() throws JAXBException {
    Marshaller marshaller = pool.acquireMarshaller();
    /*
         * Test marshalling csw 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"));
    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);
    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:Record 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" + "  <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";
    assertXmlEquals(expResult, result, "xmlns:*");
    pool.recycle(marshaller);
}
Also used : BoundingBoxType(org.geotoolkit.ows.xml.v100.BoundingBoxType) WGS84BoundingBoxType(org.geotoolkit.ows.xml.v100.WGS84BoundingBoxType) Marshaller(javax.xml.bind.Marshaller) 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) WGS84BoundingBoxType(org.geotoolkit.ows.xml.v100.WGS84BoundingBoxType) ArrayList(java.util.ArrayList) SimpleLiteral(org.geotoolkit.dublincore.xml.v2.elements.SimpleLiteral) Test(org.junit.Test)

Example 13 with SimpleLiteral

use of org.geotoolkit.dublincore.xml.v2.elements.SimpleLiteral in project geotoolkit by Geomatys.

the class CswXMLBindingTest method summmaryRecordUnmarshalingTest.

/**
 * Test summary Record Marshalling.
 */
@Test
public void summmaryRecordUnmarshalingTest() throws JAXBException {
    Unmarshaller unmarshaller = pool.acquireUnmarshaller();
    /*
         * Test marshalling csw summmary Record v2.0.2
         */
    String xml = "<?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";
    StringReader sr = new StringReader(xml);
    SummaryRecordType result = (SummaryRecordType) unmarshaller.unmarshal(sr);
    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 expResult = new SummaryRecordType(id, title, type, bbox, subject, formats, modified, Abstract);
    assertEquals(expResult, result);
    /*
         * Test marshalling csw summmary Record v2.0.2
         */
    xml = "<?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";
    sr = new StringReader(xml);
    result = (SummaryRecordType) unmarshaller.unmarshal(sr);
    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));
    expResult = new SummaryRecordType(ids, titles, type, bbox, subject, formats, modifieds, Abstract);
    assertEquals(expResult, result);
    pool.recycle(unmarshaller);
}
Also used : SummaryRecordType(org.geotoolkit.csw.xml.v202.SummaryRecordType) 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) Test(org.junit.Test)

Aggregations

ArrayList (java.util.ArrayList)13 SimpleLiteral (org.geotoolkit.dublincore.xml.v2.elements.SimpleLiteral)13 BoundingBoxType (org.geotoolkit.ows.xml.v100.BoundingBoxType)13 WGS84BoundingBoxType (org.geotoolkit.ows.xml.v100.WGS84BoundingBoxType)13 Test (org.junit.Test)13 BriefRecordType (org.geotoolkit.csw.xml.v202.BriefRecordType)11 SummaryRecordType (org.geotoolkit.csw.xml.v202.SummaryRecordType)9 StringWriter (java.io.StringWriter)7 Marshaller (javax.xml.bind.Marshaller)7 AbstractRecordType (org.geotoolkit.csw.xml.v202.AbstractRecordType)7 RecordType (org.geotoolkit.csw.xml.v202.RecordType)7 StringReader (java.io.StringReader)6 Unmarshaller (javax.xml.bind.Unmarshaller)6 JAXBElement (javax.xml.bind.JAXBElement)3 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 SearchResultsType (org.geotoolkit.csw.xml.v202.SearchResultsType)2 TransactionResponseType (org.geotoolkit.csw.xml.v202.TransactionResponseType)2