use of org.opengis.metadata.citation.OnlineResource 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));
}
use of org.opengis.metadata.citation.OnlineResource in project sis by apache.
the class DefaultMetadata method setDataSetUri.
/**
* Sets the URI of the dataset to which the metadata applies.
* This method sets the linkage of the first online resource in the citation of the first identification info.
*
* @param newValue the new data set URI.
* @throws URISyntaxException if the given value can not be parsed as a URI.
*
* @deprecated As of ISO 19115:2014, replaced by {@link #getIdentificationInfo()}
* followed by {@link DefaultDataIdentification#getCitation()}
* followed by {@link DefaultCitation#setOnlineResources(Collection)}.
*/
@Deprecated
public void setDataSetUri(final String newValue) throws URISyntaxException {
final URI uri = new URI(newValue);
checkWritePermission();
// See "Note about deprecated methods implementation"
Collection<Identification> info = identificationInfo;
AbstractIdentification firstId = AbstractIdentification.castOrCopy(CollectionsExt.first(info));
if (firstId == null) {
firstId = new DefaultDataIdentification();
}
DefaultCitation citation = DefaultCitation.castOrCopy(firstId.getCitation());
if (citation == null) {
citation = new DefaultCitation();
}
Collection<OnlineResource> onlineResources = citation.getOnlineResources();
DefaultOnlineResource firstOnline = DefaultOnlineResource.castOrCopy(CollectionsExt.first(onlineResources));
if (firstOnline == null) {
firstOnline = new DefaultOnlineResource();
}
firstOnline.setLinkage(uri);
onlineResources = OtherLocales.setFirst(onlineResources, firstOnline);
citation.setOnlineResources(onlineResources);
firstId.setCitation(citation);
info = OtherLocales.setFirst(info, firstId);
setIdentificationInfo(info);
}
use of org.opengis.metadata.citation.OnlineResource in project sis by apache.
the class DefaultMetadata method getDataSetUri.
/**
* Provides the URI of the dataset to which the metadata applies.
*
* @return Uniform Resource Identifier of the dataset, or {@code null}.
*
* @deprecated As of ISO 19115:2014, replaced by {@link #getIdentificationInfo()} followed by
* {@link DefaultDataIdentification#getCitation()} followed by {@link DefaultCitation#getOnlineResources()}.
*/
@Override
@Deprecated
@Dependencies("getIdentificationInfo")
@XmlElement(name = "dataSetURI", namespace = LegacyNamespaces.GMD)
public String getDataSetUri() {
String linkage = null;
final Collection<Identification> info;
if (FilterByVersion.LEGACY_METADATA.accept() && (info = getIdentificationInfo()) != null) {
for (final Identification identification : info) {
final Citation citation = identification.getCitation();
if (citation instanceof DefaultCitation) {
final Collection<? extends OnlineResource> onlineResources = ((DefaultCitation) citation).getOnlineResources();
if (onlineResources != null) {
for (final OnlineResource link : onlineResources) {
final URI uri = link.getLinkage();
if (uri != null) {
if (linkage == null) {
linkage = uri.toString();
} else {
LegacyPropertyAdapter.warnIgnoredExtraneous(OnlineResource.class, DefaultMetadata.class, "getDataSetUri");
break;
}
}
}
}
}
}
}
return linkage;
}
use of org.opengis.metadata.citation.OnlineResource in project tika by apache.
the class GeographicInformationParser method getMetaDataDistributionInfo.
private void getMetaDataDistributionInfo(Metadata metadata, DefaultMetadata defaultMetaData) {
Distribution distribution = defaultMetaData.getDistributionInfo();
ArrayList<Format> distributionFormat = (ArrayList<Format>) distribution.getDistributionFormats();
for (Format f : distributionFormat) {
if (f.getName() != null)
metadata.add("DistributionFormatSpecificationAlternativeTitle ", f.getName().toString());
}
ArrayList<Distributor> distributorList = (ArrayList<Distributor>) distribution.getDistributors();
for (Distributor d : distributorList) {
if (d != null && d.getDistributorContact() != null && d.getDistributorContact().getRole() != null)
metadata.add("Distributor Contact ", d.getDistributorContact().getRole().name());
if (d != null && d.getDistributorContact() != null && d.getDistributorContact().getOrganisationName() != null)
metadata.add("Distributor Organization Name ", d.getDistributorContact().getOrganisationName().toString());
}
ArrayList<DigitalTransferOptions> transferOptionsList = (ArrayList<DigitalTransferOptions>) distribution.getTransferOptions();
for (DigitalTransferOptions d : transferOptionsList) {
ArrayList<OnlineResource> onlineResourceList = (ArrayList<OnlineResource>) d.getOnLines();
for (OnlineResource or : onlineResourceList) {
if (or.getLinkage() != null)
metadata.add("TransferOptionsOnlineLinkage ", or.getLinkage().toString());
if (or.getProtocol() != null)
metadata.add("TransferOptionsOnlineProtocol ", or.getProtocol());
if (or.getApplicationProfile() != null)
metadata.add("TransferOptionsOnlineProfile ", or.getApplicationProfile());
if (or.getName() != null)
metadata.add("TransferOptionsOnlineName ", or.getName());
if (or.getDescription() != null)
metadata.add("TransferOptionsOnlineDescription ", or.getDescription().toString());
if (or.getFunction() != null)
metadata.add("TransferOptionsOnlineFunction ", or.getFunction().name());
}
}
}
use of org.opengis.metadata.citation.OnlineResource in project sis by apache.
the class DefaultCitationTest method testUnmarshalling.
/**
* Tests XML unmarshalling for a metadata version.
* The version is not specified since it should be detected automatically.
*
* @param file file containing the metadata to unmarshal.
*/
private void testUnmarshalling(final String file) throws JAXBException {
final DefaultCitation c = unmarshalFile(DefaultCitation.class, file);
assertTitleEquals("title", "Fight against poverty", c);
final CitationDate date = getSingleton(c.getDates());
assertEquals("date", date.getDate(), TestUtilities.date("2015-10-17 00:00:00"));
assertEquals("dateType", DateType.valueOf("adopted"), date.getDateType());
assertEquals("presentationForm", PresentationForm.valueOf("physicalObject"), getSingleton(c.getPresentationForms()));
final Iterator<ResponsibleParty> it = c.getCitedResponsibleParties().iterator();
final Contact contact = assertResponsibilityEquals(Role.ORIGINATOR, "Maid Marian", it.next());
assertEquals("Contact instruction", "Send carrier pigeon.", String.valueOf(contact.getContactInstructions()));
final OnlineResource resource = contact.getOnlineResource();
assertEquals("Resource name", "IP over Avian Carriers", String.valueOf(resource.getName()));
assertEquals("Resource description", "High delay, low throughput, and low altitude service.", String.valueOf(resource.getDescription()));
assertEquals("Resource linkage", "https://tools.ietf.org/html/rfc1149", String.valueOf(resource.getLinkage()));
assertEquals("Resource function", OnLineFunction.OFFLINE_ACCESS, resource.getFunction());
// Thanks to xlink:href, the Contact shall be the same instance as above.
assertSame("contact", contact, assertResponsibilityEquals(Role.valueOf("funder"), "Robin Hood", it.next()));
assertFalse(it.hasNext());
}
Aggregations