Search in sources :

Example 1 with OnlineResource

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));
}
Also used : OnlineResource(org.opengis.metadata.citation.OnlineResource) Citation(org.opengis.metadata.citation.Citation) ResponsibleParty(org.opengis.metadata.citation.ResponsibleParty)

Example 2 with OnlineResource

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);
}
Also used : OnlineResource(org.opengis.metadata.citation.OnlineResource) DefaultOnlineResource(org.apache.sis.metadata.iso.citation.DefaultOnlineResource) DefaultCitation(org.apache.sis.metadata.iso.citation.DefaultCitation) AbstractIdentification(org.apache.sis.metadata.iso.identification.AbstractIdentification) DefaultDataIdentification(org.apache.sis.metadata.iso.identification.DefaultDataIdentification) DefaultDataIdentification(org.apache.sis.metadata.iso.identification.DefaultDataIdentification) Identification(org.opengis.metadata.identification.Identification) AbstractIdentification(org.apache.sis.metadata.iso.identification.AbstractIdentification) DefaultOnlineResource(org.apache.sis.metadata.iso.citation.DefaultOnlineResource) URI(java.net.URI)

Example 3 with OnlineResource

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;
}
Also used : OnlineResource(org.opengis.metadata.citation.OnlineResource) DefaultOnlineResource(org.apache.sis.metadata.iso.citation.DefaultOnlineResource) DefaultCitation(org.apache.sis.metadata.iso.citation.DefaultCitation) DefaultDataIdentification(org.apache.sis.metadata.iso.identification.DefaultDataIdentification) Identification(org.opengis.metadata.identification.Identification) AbstractIdentification(org.apache.sis.metadata.iso.identification.AbstractIdentification) InternationalString(org.opengis.util.InternationalString) SimpleInternationalString(org.apache.sis.util.iso.SimpleInternationalString) Citation(org.opengis.metadata.citation.Citation) DefaultCitation(org.apache.sis.metadata.iso.citation.DefaultCitation) CI_Citation(org.apache.sis.internal.jaxb.metadata.CI_Citation) URI(java.net.URI) XmlElement(javax.xml.bind.annotation.XmlElement) Dependencies(org.apache.sis.internal.metadata.Dependencies)

Example 4 with OnlineResource

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());
        }
    }
}
Also used : OnlineResource(org.opengis.metadata.citation.OnlineResource) Format(org.opengis.metadata.distribution.Format) Distributor(org.opengis.metadata.distribution.Distributor) Distribution(org.opengis.metadata.distribution.Distribution) CheckedArrayList(org.apache.sis.internal.util.CheckedArrayList) ArrayList(java.util.ArrayList) DigitalTransferOptions(org.opengis.metadata.distribution.DigitalTransferOptions)

Example 5 with OnlineResource

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());
}
Also used : OnlineResource(org.opengis.metadata.citation.OnlineResource) CitationDate(org.opengis.metadata.citation.CitationDate) ResponsibleParty(org.opengis.metadata.citation.ResponsibleParty) Contact(org.opengis.metadata.citation.Contact)

Aggregations

OnlineResource (org.opengis.metadata.citation.OnlineResource)5 URI (java.net.URI)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 DefaultDataIdentification (org.apache.sis.metadata.iso.identification.DefaultDataIdentification)2 Citation (org.opengis.metadata.citation.Citation)2 ResponsibleParty (org.opengis.metadata.citation.ResponsibleParty)2 Identification (org.opengis.metadata.identification.Identification)2 ArrayList (java.util.ArrayList)1 XmlElement (javax.xml.bind.annotation.XmlElement)1 CI_Citation (org.apache.sis.internal.jaxb.metadata.CI_Citation)1 Dependencies (org.apache.sis.internal.metadata.Dependencies)1 CheckedArrayList (org.apache.sis.internal.util.CheckedArrayList)1 SimpleInternationalString (org.apache.sis.util.iso.SimpleInternationalString)1 CitationDate (org.opengis.metadata.citation.CitationDate)1 Contact (org.opengis.metadata.citation.Contact)1 DigitalTransferOptions (org.opengis.metadata.distribution.DigitalTransferOptions)1 Distribution (org.opengis.metadata.distribution.Distribution)1 Distributor (org.opengis.metadata.distribution.Distributor)1