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);
}
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));
}
}
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));
}
}
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));
}
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));
}
Aggregations