use of org.apache.sis.metadata.iso.citation.DefaultCitation in project sis by apache.
the class MetadataBuilder method addEdition.
/**
* Adds a version of the resource.
* If a version already exists, the new one will be appended after a new line.
* Storage location is:
*
* <ul>
* <li>{@code metadata/identificationInfo/citation/edition}</li>
* </ul>
*
* @param version the version of resource(s), or {@code null} for no-operation.
*/
public final void addEdition(final CharSequence version) {
final InternationalString i18n = trim(version);
if (i18n != null) {
final DefaultCitation citation = citation();
citation.setEdition(append(citation.getEdition(), i18n));
}
}
use of org.apache.sis.metadata.iso.citation.DefaultCitation in project sis by apache.
the class DefaultMetadata method setMetadataStandard.
/**
* Implementation of legacy {@link #setMetadataStandardName(String)} and
* {@link #setMetadataStandardVersion(String)} methods.
*/
private void setMetadataStandard(final boolean version, final String newValue) {
checkWritePermission();
final InternationalString i18n = (newValue != null) ? new SimpleInternationalString(newValue) : null;
final List<Citation> newValues = (metadataStandards != null) ? new ArrayList<>(metadataStandards) : new ArrayList<>(1);
DefaultCitation citation = newValues.isEmpty() ? null : DefaultCitation.castOrCopy(newValues.get(0));
if (citation == null) {
citation = new DefaultCitation();
}
if (version) {
citation.setEdition(i18n);
} else {
citation.setTitle(i18n);
}
if (newValues.isEmpty()) {
newValues.add(citation);
} else {
newValues.set(0, citation);
}
setMetadataStandards(newValues);
}
use of org.apache.sis.metadata.iso.citation.DefaultCitation in project sis by apache.
the class DefaultMetadata method setParentIdentifier.
/**
* Sets the file identifier of the metadata to which this metadata is a subset (child).
*
* @param newValue the new parent identifier.
*
* @deprecated As of ISO 19115:2014, replaced by {@link #getParentMetadata()}.
*/
@Deprecated
public void setParentIdentifier(final String newValue) {
checkWritePermission();
// See "Note about deprecated methods implementation"
DefaultCitation parent = DefaultCitation.castOrCopy(parentMetadata);
if (parent == null) {
parent = new DefaultCitation();
}
parent.setTitle(new SimpleInternationalString(newValue));
setParentMetadata(parent);
}
use of org.apache.sis.metadata.iso.citation.DefaultCitation in project sis by apache.
the class EPSGFactoryFallback method getAuthority.
/**
* Returns the EPSG authority with only a modification in the title
* for emphasing that this is a subset of EPSG dataset.
*/
@Override
public synchronized Citation getAuthority() {
if (authority == null) {
final DefaultCitation c = new DefaultCitation(Citations.EPSG);
c.setTitle(Vocabulary.formatInternational(Vocabulary.Keys.SubsetOf_1, c.getTitle()));
authority = c;
}
return authority;
}
use of org.apache.sis.metadata.iso.citation.DefaultCitation in project sis by apache.
the class EPSGDataAccess method getAuthority.
/**
* Returns the authority for this EPSG dataset. The returned citation contains the database version
* in the {@linkplain Citation#getEdition() edition} attribute, together with date of last update in
* the {@linkplain Citation#getEditionDate() edition date}.
* Example (the exact content will vary with Apache SIS versions, JDBC driver and EPSG dataset versions):
*
* {@preformat text
* Citation
* ├─ Title ……………………………………………………… EPSG Geodetic Parameter Dataset
* ├─ Identifier ………………………………………… EPSG
* ├─ Online resource (1 of 2)
* │ ├─ Linkage ………………………………………… http://epsg-registry.org/
* │ └─ Function ……………………………………… Browse
* └─ Online resource (2 of 2)
* ├─ Linkage ………………………………………… jdbc:derby:/my/path/to/SIS_DATA/Databases/SpatialMetadata
* ├─ Description ……………………………… EPSG dataset version 8.9 on “Apache Derby Embedded JDBC Driver” version 10.12.
* └─ Function ……………………………………… Connection
* }
*/
@Override
public synchronized Citation getAuthority() {
/*
* We do not cache this citation because the caching service is already provided by ConcurrentAuthorityFactory.
*/
final DefaultCitation c = new DefaultCitation("EPSG Geodetic Parameter Dataset");
c.setIdentifiers(Collections.singleton(new ImmutableIdentifier(null, null, Constants.EPSG)));
try {
/*
* Get the most recent version number from the history table. We get the date in local timezone
* instead then UTC because the date is for information purpose only, and the local timezone is
* more likely to be shown nicely (without artificial hours) to the user.
*/
final String query = translator.apply("SELECT VERSION_NUMBER, VERSION_DATE FROM [Version History]" + " ORDER BY VERSION_DATE DESC, VERSION_HISTORY_CODE DESC");
String version = null;
try (Statement statement = connection.createStatement();
ResultSet result = statement.executeQuery(query)) {
while (result.next()) {
version = getOptionalString(result, 1);
// Local timezone.
final Date date = result.getDate(2);
if (version != null && date != null) {
// Paranoiac check.
c.setEdition(new SimpleInternationalString(version));
c.setEditionDate(date);
break;
}
}
}
/*
* Add some hard-coded links to EPSG resources, and finally add the JDBC driver name and version number.
* The list last OnlineResource looks like:
*
* Linkage: jdbc:derby:/my/path/to/SIS_DATA/Databases/SpatialMetadata
* Function: Connection
* Description: EPSG dataset version 8.9 on “Apache Derby Embedded JDBC Driver” version 10.12.
*
* TODO: A future version should use Citations.EPSG as a template.
* See the "EPSG" case in ServiceForUtility.createCitation(String).
*/
final DatabaseMetaData metadata = connection.getMetaData();
addURIs: for (int i = 0; ; i++) {
String url;
OnLineFunction function;
InternationalString description = null;
switch(i) {
case 0:
url = "http://epsg-registry.org/";
function = OnLineFunction.SEARCH;
break;
case 1:
url = "http://www.epsg.org/";
function = OnLineFunction.DOWNLOAD;
break;
case 2:
{
url = SQLUtilities.getSimplifiedURL(metadata);
function = OnLineFunction.valueOf(CONNECTION);
description = Resources.formatInternational(Resources.Keys.GeodeticDataBase_4, Constants.EPSG, version, metadata.getDatabaseProductName(), Version.valueOf(metadata.getDatabaseMajorVersion(), metadata.getDatabaseMinorVersion()));
break;
}
// Finished adding all URIs.
default:
break addURIs;
}
final DefaultOnlineResource r = new DefaultOnlineResource();
try {
r.setLinkage(new URI(url));
} catch (URISyntaxException exception) {
unexpectedException("getAuthority", exception);
}
r.setFunction(function);
r.setDescription(description);
c.getOnlineResources().add(r);
}
} catch (SQLException exception) {
unexpectedException("getAuthority", exception);
} finally {
c.freeze();
}
return c;
}
Aggregations