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