Search in sources :

Example 1 with AbstractIdentification

use of org.apache.sis.metadata.iso.identification.AbstractIdentification 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)

Aggregations

URI (java.net.URI)1 DefaultCitation (org.apache.sis.metadata.iso.citation.DefaultCitation)1 DefaultOnlineResource (org.apache.sis.metadata.iso.citation.DefaultOnlineResource)1 AbstractIdentification (org.apache.sis.metadata.iso.identification.AbstractIdentification)1 DefaultDataIdentification (org.apache.sis.metadata.iso.identification.DefaultDataIdentification)1 OnlineResource (org.opengis.metadata.citation.OnlineResource)1 Identification (org.opengis.metadata.identification.Identification)1