use of org.apache.sis.metadata.iso.citation.DefaultCitation in project sis by apache.
the class MetadataBuilder method addTitle.
/**
* Adds a title or alternate title of the resource.
* Storage location is:
*
* <ul>
* <li>{@code metadata/identificationInfo/citation/title} if not yet used</li>
* <li>{@code metadata/identificationInfo/citation/alternateTitle} otherwise</li>
* </ul>
*
* @param title the resource title or alternate title, or {@code null} for no-operation.
*
* @see #addAbstract(CharSequence)
*/
public final void addTitle(final CharSequence title) {
final InternationalString i18n = trim(title);
if (i18n != null) {
final DefaultCitation citation = citation();
final InternationalString current = citation.getTitle();
if (current == null) {
citation.setTitle(i18n);
} else if (!equals(current, i18n)) {
addIfNotPresent(citation.getAlternateTitles(), i18n);
}
}
}
use of org.apache.sis.metadata.iso.citation.DefaultCitation in project sis by apache.
the class MetadataBuilderTest method verifyCopyrightParsing.
/**
* Verifies the metadata that contains the result of parsing a copyright statement.
* Should contains the "John Smith" name and 1992 year.
*
* @param notice the copyright statement to parse.
*/
private static void verifyCopyrightParsing(final String notice) {
final MetadataBuilder builder = new MetadataBuilder();
builder.parseLegalNotice(notice);
final DefaultLegalConstraints constraints = (DefaultLegalConstraints) getSingleton(getSingleton(builder.build(false).getIdentificationInfo()).getResourceConstraints());
assertEquals("useConstraints", Restriction.COPYRIGHT, getSingleton(constraints.getUseConstraints()));
final Citation ref = getSingleton(constraints.getReferences());
assertTitleEquals("reference.title", notice, ref);
assertPartyNameEquals("reference.citedResponsibleParty", "John Smith", (DefaultCitation) ref);
assertEquals("date", date("1992-01-01 00:00:00"), getSingleton(ref.getDates()).getDate());
}
use of org.apache.sis.metadata.iso.citation.DefaultCitation in project sis by apache.
the class Store method getFormat.
/**
* Returns a more complete description of the GPX format.
* The format will be part of the metadata returned by {@link #getMetadata()}.
*
* @see StoreProvider#getFormat()
* @see org.apache.sis.internal.storage.gpx.Metadata#getResourceFormats()
*/
final Format getFormat() {
assert Thread.holdsLock(this);
Format format = ((StoreProvider) provider).getFormat(listeners);
if (version != null) {
final DefaultFormat df = new DefaultFormat(format);
final DefaultCitation citation = new DefaultCitation(df.getFormatSpecificationCitation());
citation.setEdition(new SimpleInternationalString(version.toString()));
df.setFormatSpecificationCitation(citation);
format = df;
}
return format;
}
use of org.apache.sis.metadata.iso.citation.DefaultCitation 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.apache.sis.metadata.iso.citation.DefaultCitation 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;
}
Aggregations