Search in sources :

Example 6 with DefaultDataIdentification

use of org.apache.sis.metadata.iso.identification.DefaultDataIdentification in project sis by apache.

the class EnumMarshallingTest method testTopicCategories.

/**
 * Tests (un)marshaling of an enumeration.
 *
 * @throws JAXBException if an error occurred while (un)marshaling the XML.
 */
@Test
public void testTopicCategories() throws JAXBException {
    final Collection<TopicCategory> topics = Arrays.asList(TopicCategory.OCEANS, TopicCategory.ENVIRONMENT, // We need to test at least one enum with many words.
    TopicCategory.IMAGERY_BASE_MAPS_EARTH_COVER);
    final DefaultDataIdentification id = new DefaultDataIdentification();
    id.setTopicCategories(topics);
    String expected = "<mri:MD_DataIdentification xmlns:mri=\"" + Namespaces.MRI + "\">\n" + "  <mri:topicCategory>\n" + "    <mri:MD_TopicCategoryCode>environment</mri:MD_TopicCategoryCode>\n" + "  </mri:topicCategory>\n" + "  <mri:topicCategory>\n" + "    <mri:MD_TopicCategoryCode>imageryBaseMapsEarthCover</mri:MD_TopicCategoryCode>\n" + "  </mri:topicCategory>\n" + "  <mri:topicCategory>\n" + "    <mri:MD_TopicCategoryCode>oceans</mri:MD_TopicCategoryCode>\n" + "  </mri:topicCategory>\n" + "</mri:MD_DataIdentification>";
    final String xml = marshal(id, VERSION_2014);
    assertXmlEquals(expected, xml, "xmlns:*");
    /*
         * Unmarshall the above XML and verify that we find all the topic categories.
         */
    final Collection<TopicCategory> unmarshalled = unmarshal(DefaultDataIdentification.class, expected).getTopicCategories();
    assertSetEquals(topics, unmarshalled);
}
Also used : DefaultDataIdentification(org.apache.sis.metadata.iso.identification.DefaultDataIdentification) TopicCategory(org.opengis.metadata.identification.TopicCategory) Test(org.junit.Test)

Example 7 with DefaultDataIdentification

use of org.apache.sis.metadata.iso.identification.DefaultDataIdentification in project sis by apache.

the class MetadataBuilder method addAbstract.

/**
 * Adds a brief narrative summary of the resource(s).
 * If a summary already exists, the new one will be appended after a new line.
 * Storage location is:
 *
 * <ul>
 *   <li>{@code metadata/identificationInfo/abstract}</li>
 * </ul>
 *
 * @param description  the summary of resource(s), or {@code null} for no-operation.
 *
 * @see #addTitle(CharSequence)
 * @see #addPurpose(CharSequence)
 */
public final void addAbstract(final CharSequence description) {
    final InternationalString i18n = trim(description);
    if (i18n != null) {
        final DefaultDataIdentification identification = identification();
        identification.setAbstract(append(identification.getAbstract(), i18n));
    }
}
Also used : InternationalString(org.opengis.util.InternationalString) DefaultDataIdentification(org.apache.sis.metadata.iso.identification.DefaultDataIdentification)

Example 8 with DefaultDataIdentification

use of org.apache.sis.metadata.iso.identification.DefaultDataIdentification in project sis by apache.

the class MetadataBuilder method addPurpose.

/**
 * Adds a summary of the intentions with which the resource(s) was developed.
 * If a purpose already exists, the new one will be appended after a new line.
 * Storage location is:
 *
 * <ul>
 *   <li>{@code metadata/identificationInfo/purpose}</li>
 * </ul>
 *
 * @param intention  the summary of intention(s), or {@code null} for no-operation.
 *
 * @see #addAbstract(CharSequence)
 */
public final void addPurpose(final CharSequence intention) {
    final InternationalString i18n = trim(intention);
    if (i18n != null) {
        final DefaultDataIdentification identification = identification();
        identification.setPurpose(append(identification.getPurpose(), i18n));
    }
}
Also used : InternationalString(org.opengis.util.InternationalString) DefaultDataIdentification(org.apache.sis.metadata.iso.identification.DefaultDataIdentification)

Example 9 with DefaultDataIdentification

use of org.apache.sis.metadata.iso.identification.DefaultDataIdentification in project sis by apache.

the class XLinkMarshallingTest method testLinkOnly.

/**
 * Tests (un)marshalling of an object with a {@code xlink:href} attribute without element definition.
 * The XML fragment is:
 *
 * {@preformat xml
 *   <mdb:MD_Metadata>
 *     <mdb:identificationInfo xlink:href="http://test.net"/>
 *   </mdb:MD_Metadata>
 * }
 *
 * @throws JAXBException if an error occurred during (un)marshalling.
 * @throws URISyntaxException if the URI used in this test is malformed.
 */
@Test
public void testLinkOnly() throws JAXBException, URISyntaxException {
    final XLink xlink = new XLink();
    xlink.setHRef(new URI("http://test.net"));
    final DefaultDataIdentification identification = new DefaultDataIdentification();
    identification.getIdentifierMap().putSpecialized(IdentifierSpace.XLINK, xlink);
    final DefaultMetadata metadata = new DefaultMetadata();
    metadata.setIdentificationInfo(Collections.singleton(identification));
    assertXmlEquals(LINK_ONLY_XML, marshal(metadata), "xmlns:*");
    verify(true, unmarshal(DefaultMetadata.class, LINK_ONLY_XML));
}
Also used : DefaultMetadata(org.apache.sis.metadata.iso.DefaultMetadata) DefaultDataIdentification(org.apache.sis.metadata.iso.identification.DefaultDataIdentification) URI(java.net.URI) Test(org.junit.Test)

Example 10 with DefaultDataIdentification

use of org.apache.sis.metadata.iso.identification.DefaultDataIdentification in project sis by apache.

the class XLinkMarshallingTest method testWithElement.

/**
 * Tests (un)marshalling of an object with a {@code xlink:href} attribute with an element definition.
 * The XML fragment is:
 *
 * {@preformat xml
 *   <mdb:MD_Metadata>
 *     <mdb:identificationInfo xlink:href="http://test.net">
 *       <mdb:MD_DataIdentification>
 *         <mdb:abstract>
 *           <gco:CharacterString>This is a test.</gco:CharacterString>
 *         </mdb:abstract>
 *       </mdb:MD_DataIdentification>
 *     </mdb:identificationInfo>
 *   </mdb:MD_Metadata>
 * }
 *
 * @throws JAXBException if an error occurred during (un)marshalling.
 * @throws URISyntaxException if the URI used in this test is malformed.
 */
@Test
public void testWithElement() throws JAXBException, URISyntaxException {
    final XLink xlink = new XLink();
    xlink.setHRef(new URI("http://test.net"));
    final DefaultDataIdentification identification = new DefaultDataIdentification();
    identification.getIdentifierMap().putSpecialized(IdentifierSpace.XLINK, xlink);
    identification.setAbstract(new SimpleInternationalString("This is a test."));
    final DefaultMetadata metadata = new DefaultMetadata();
    metadata.setIdentificationInfo(Collections.singleton(identification));
    assertXmlEquals(LINK_WITH_ELEMENT_XML, marshal(metadata), "xmlns:*");
    final DefaultMetadata unmarshal = unmarshal(DefaultMetadata.class, LINK_WITH_ELEMENT_XML);
    verify(false, unmarshal);
    assertTrue(metadata.equals(unmarshal, ComparisonMode.DEBUG));
}
Also used : SimpleInternationalString(org.apache.sis.util.iso.SimpleInternationalString) DefaultMetadata(org.apache.sis.metadata.iso.DefaultMetadata) DefaultDataIdentification(org.apache.sis.metadata.iso.identification.DefaultDataIdentification) URI(java.net.URI) Test(org.junit.Test)

Aggregations

DefaultDataIdentification (org.apache.sis.metadata.iso.identification.DefaultDataIdentification)10 InternationalString (org.opengis.util.InternationalString)5 URI (java.net.URI)4 Identification (org.opengis.metadata.identification.Identification)4 Test (org.junit.Test)3 ArrayList (java.util.ArrayList)2 CheckedArrayList (org.apache.sis.internal.util.CheckedArrayList)2 DefaultMetadata (org.apache.sis.metadata.iso.DefaultMetadata)2 DefaultCitation (org.apache.sis.metadata.iso.citation.DefaultCitation)2 DefaultOnlineResource (org.apache.sis.metadata.iso.citation.DefaultOnlineResource)2 AbstractIdentification (org.apache.sis.metadata.iso.identification.AbstractIdentification)2 SimpleInternationalString (org.apache.sis.util.iso.SimpleInternationalString)2 OnlineResource (org.opengis.metadata.citation.OnlineResource)2 ResponsibleParty (org.opengis.metadata.citation.ResponsibleParty)2 Extent (org.opengis.metadata.extent.Extent)2 GeographicExtent (org.opengis.metadata.extent.GeographicExtent)2 TopicCategory (org.opengis.metadata.identification.TopicCategory)2 Locale (java.util.Locale)1 XmlElement (javax.xml.bind.annotation.XmlElement)1 CI_Citation (org.apache.sis.internal.jaxb.metadata.CI_Citation)1