Search in sources :

Example 6 with Citation

use of org.opengis.metadata.citation.Citation in project sis by apache.

the class MetadataWriterTest method read.

/**
 * Reads known entries in the database.
 * Expected entry is:
 *
 * {@preformat text
 *   Citation
 *     ├─Title………………………………………………………… EPSG Geodetic Parameter Dataset
 *     ├─Identifier
 *     │   └─Code………………………………………………… EPSG
 *     ├─Cited responsible party
 *     │   ├─Party
 *     │   │   ├─Name……………………………………… International Association of Oil & Gas Producers
 *     │   │   └─Contact info
 *     │   │       └─Online resource
 *     │   │           ├─Linkage………… http://www.epsg.org
 *     │   │           └─Function……… Information
 *     │   └─Role………………………………………………… Principal investigator
 *     └─Presentation form………………………… Table digital
 * }
 *
 * @throws MetadataStoreException if an error occurred while reading the database.
 */
private void read() throws MetadataStoreException {
    final Citation c = source.lookup(Citation.class, "EPSG");
    assertEquals("EPSG Geodetic Parameter Dataset", c.getTitle().toString());
    assertEquals(PresentationForm.TABLE_DIGITAL, TestUtilities.getSingleton(c.getPresentationForms()));
    /*
         * Ask for dependencies that are known to exist.
         */
    final ResponsibleParty responsible = TestUtilities.getSingleton(c.getCitedResponsibleParties());
    assertEquals(Role.PRINCIPAL_INVESTIGATOR, responsible.getRole());
    assertEquals("International Association of Oil & Gas Producers", responsible.getOrganisationName().toString());
    OnlineResource resource = responsible.getContactInfo().getOnlineResource();
    assertEquals("http://www.epsg.org", resource.getLinkage().toString());
    assertEquals(OnLineFunction.INFORMATION, resource.getFunction());
    /*
         * Ask columns that are known to not exist.
         */
    assertNull(c.getEditionDate());
    assertTrue(c.getDates().isEmpty());
    assertEquals(0, c.getAlternateTitles().size());
    /*
         * Test the cache.
         */
    assertSame(c, source.lookup(Citation.class, "EPSG"));
    assertNotSame(c, source.lookup(Citation.class, "SIS"));
    /*
         * Should return the identifier with no search. Actually the real test is the call to "proxy",
         * since there is no way to ensure that the call to "search" tooks the short path (except by
         * looking at the debugger). But if "proxy" succeed, then "search" should be okay.
         */
    assertEquals("EPSG", source.proxy(c));
    assertEquals("EPSG", source.search(c));
}
Also used : OnlineResource(org.opengis.metadata.citation.OnlineResource) Citation(org.opengis.metadata.citation.Citation) ResponsibleParty(org.opengis.metadata.citation.ResponsibleParty)

Example 7 with Citation

use of org.opengis.metadata.citation.Citation in project sis by apache.

the class FreeTextMarshallingTest method testLegacy.

/**
 * Tests parsing of a free text in the legacy (pre-Geotk 3.17) format.
 * We continue to support this format for compatibility reason, but
 * also because it is more compact and closer to what we would expect
 * inside a {@code <textGroup>} node.
 *
 * @throws JAXBException if the XML in this test can not be parsed by JAXB.
 */
@Test
public void testLegacy() throws JAXBException {
    final String legacy = "<cit:CI_Citation xmlns:lan=\"" + Namespaces.LAN + '"' + " xmlns:cit=\"" + Namespaces.CIT + '"' + " xmlns:gco=\"" + Namespaces.GCO + '"' + " xmlns:xsi=\"" + Namespaces.XSI + "\">\n" + "  <cit:title xsi:type=\"lan:PT_FreeText_PropertyType\">\n" + "    <gco:CharacterString>OpenSource Project</gco:CharacterString>\n" + "    <lan:PT_FreeText>\n" + "      <lan:textGroup>\n" + "        <lan:LocalisedCharacterString locale=\"#locale-eng\">OpenSource Project</lan:LocalisedCharacterString>\n" + "        <lan:LocalisedCharacterString locale=\"#locale-ita\">Progetto OpenSource</lan:LocalisedCharacterString>\n" + "        <lan:LocalisedCharacterString locale=\"#locale-fra\">Projet OpenSource</lan:LocalisedCharacterString>\n" + "      </lan:textGroup>\n" + "    </lan:PT_FreeText>\n" + "  </cit:title>\n" + "</cit:CI_Citation>\n";
    final Citation citation = unmarshal(Citation.class, legacy);
    assertEquals(getExpectedI18N(), citation.getTitle());
}
Also used : DefaultInternationalString(org.apache.sis.util.iso.DefaultInternationalString) Citation(org.opengis.metadata.citation.Citation) Test(org.junit.Test)

Example 8 with Citation

use of org.opengis.metadata.citation.Citation in project sis by apache.

the class FreeTextMarshallingTest method testStandard.

/**
 * Tests parsing of a free text in an ISO 19139-compliant way.
 * The free text is wrapped inside a citation for marshalling
 * purpose, but only the free text is actually tested.
 *
 * @throws JAXBException if the XML in this test can not be parsed by JAXB.
 */
@Test
public void testStandard() throws JAXBException {
    final String expected = "<cit:CI_Citation xmlns:lan=\"" + Namespaces.LAN + '"' + " xmlns:cit=\"" + Namespaces.CIT + '"' + " xmlns:gco=\"" + Namespaces.GCO + '"' + " xmlns:xsi=\"" + Namespaces.XSI + "\">\n" + "  <cit:title xsi:type=\"lan:PT_FreeText_PropertyType\">\n" + "    <gco:CharacterString>OpenSource Project</gco:CharacterString>\n" + "    <lan:PT_FreeText>\n" + "      <lan:textGroup>\n" + "        <lan:LocalisedCharacterString locale=\"#locale-eng\">OpenSource Project</lan:LocalisedCharacterString>\n" + "      </lan:textGroup>\n" + "      <lan:textGroup>\n" + "        <lan:LocalisedCharacterString locale=\"#locale-ita\">Progetto OpenSource</lan:LocalisedCharacterString>\n" + "      </lan:textGroup>\n" + "      <lan:textGroup>\n" + "        <lan:LocalisedCharacterString locale=\"#locale-fra\">Projet OpenSource</lan:LocalisedCharacterString>\n" + "      </lan:textGroup>\n" + "    </lan:PT_FreeText>\n" + "  </cit:title>\n" + "</cit:CI_Citation>\n";
    final Citation citation = unmarshal(Citation.class, expected);
    assertEquals(getExpectedI18N(), citation.getTitle());
    final String actual = marshal(citation);
    assertXmlEquals(expected, actual, "xmlns:*");
}
Also used : DefaultInternationalString(org.apache.sis.util.iso.DefaultInternationalString) Citation(org.opengis.metadata.citation.Citation) Test(org.junit.Test)

Example 9 with Citation

use of org.opengis.metadata.citation.Citation in project sis by apache.

the class NilReasonMarshallingTest method testURI.

/**
 * Tests a case where the nil reason is specified by a URI.
 *
 * @throws JAXBException if an error occurred during (un)marshalling.
 */
@Test
@DependsOnMethod("testMissing")
public void testURI() throws JAXBException {
    final String expected = "<cit:CI_Citation xmlns:cit=\"" + Namespaces.CIT + '"' + " xmlns:gco=\"" + Namespaces.GCO + "\">\n" + "  <cit:title>\n" + "    <gco:CharacterString>A title</gco:CharacterString>\n" + "  </cit:title>\n" + "  <cit:series gco:nilReason=\"http://www.myreason.org\"/>\n" + "</cit:CI_Citation>";
    final Citation citation = unmarshal(Citation.class, expected);
    assertTitleEquals("citation", "A title", citation);
    final Series series = citation.getSeries();
    assertInstanceOf("Should have instantiated a proxy.", NilObject.class, series);
    final NilReason reason = ((NilObject) series).getNilReason();
    assertNull("NilReason.explanation", reason.getOtherExplanation());
    assertEquals("NilReason.URI", "http://www.myreason.org", String.valueOf(reason.getURI()));
    assertEquals("Series[http://www.myreason.org]", series.toString());
    assertNull("All attributes are expected to be null.", series.getName());
    final String actual = marshal(citation);
    assertXmlEquals(expected, actual, "xmlns:*");
    assertEquals(citation, unmarshal(Citation.class, actual));
}
Also used : Series(org.opengis.metadata.citation.Series) Citation(org.opengis.metadata.citation.Citation) Test(org.junit.Test) DependsOnMethod(org.apache.sis.test.DependsOnMethod)

Example 10 with Citation

use of org.opengis.metadata.citation.Citation in project sis by apache.

the class NilReasonMarshallingTest method testOther.

/**
 * Tests a case where the nil reason is specified by an other reason.
 *
 * @throws JAXBException if an error occurred during (un)marshalling.
 */
@Test
@DependsOnMethod("testMissing")
public void testOther() throws JAXBException {
    final String expected = "<cit:CI_Citation xmlns:cit=\"" + Namespaces.CIT + '"' + " xmlns:gco=\"" + Namespaces.GCO + "\">\n" + "  <cit:title>\n" + "    <gco:CharacterString>A title</gco:CharacterString>\n" + "  </cit:title>\n" + "  <cit:series gco:nilReason=\"other:myReason\"/>\n" + "</cit:CI_Citation>";
    final Citation citation = unmarshal(Citation.class, expected);
    assertTitleEquals("citation", "A title", citation);
    final Series series = citation.getSeries();
    assertInstanceOf("Should have instantiated a proxy.", NilObject.class, series);
    final NilReason reason = ((NilObject) series).getNilReason();
    assertEquals("NilReason.explanation", "myReason", reason.getOtherExplanation());
    assertNull("NilReason.URI", reason.getURI());
    assertEquals("Series[other:myReason]", series.toString());
    assertNull("All attributes are expected to be null.", series.getName());
    final String actual = marshal(citation);
    assertXmlEquals(expected, actual, "xmlns:*");
    assertEquals(citation, unmarshal(Citation.class, actual));
}
Also used : Series(org.opengis.metadata.citation.Series) Citation(org.opengis.metadata.citation.Citation) Test(org.junit.Test) DependsOnMethod(org.apache.sis.test.DependsOnMethod)

Aggregations

Citation (org.opengis.metadata.citation.Citation)43 Test (org.junit.Test)17 DefaultCitation (org.apache.sis.metadata.iso.citation.DefaultCitation)12 InternationalString (org.opengis.util.InternationalString)11 Identifier (org.opengis.metadata.Identifier)10 SimpleInternationalString (org.apache.sis.util.iso.SimpleInternationalString)7 Series (org.opengis.metadata.citation.Series)6 DependsOnMethod (org.apache.sis.test.DependsOnMethod)5 ArrayList (java.util.ArrayList)4 NamedIdentifier (org.apache.sis.referencing.NamedIdentifier)4 ReferenceIdentifier (org.opengis.referencing.ReferenceIdentifier)4 ResponsibleParty (org.opengis.metadata.citation.ResponsibleParty)3 CI_Citation (org.apache.sis.internal.jaxb.metadata.CI_Citation)2 FormattableObject (org.apache.sis.io.wkt.FormattableObject)2 ImmutableIdentifier (org.apache.sis.metadata.iso.ImmutableIdentifier)2 DefaultInternationalString (org.apache.sis.util.iso.DefaultInternationalString)2 OnlineResource (org.opengis.metadata.citation.OnlineResource)2 NoSuchAuthorityCodeException (org.opengis.referencing.NoSuchAuthorityCodeException)2 VendorOptionVersion (com.sldeditor.common.vendoroption.VendorOptionVersion)1 ValueComboBoxData (com.sldeditor.ui.widgets.ValueComboBoxData)1