Search in sources :

Example 56 with DefaultCitation

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));
    }
}
Also used : InternationalString(org.opengis.util.InternationalString) DefaultCitation(org.apache.sis.metadata.iso.citation.DefaultCitation)

Example 57 with DefaultCitation

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);
}
Also used : InternationalString(org.opengis.util.InternationalString) SimpleInternationalString(org.apache.sis.util.iso.SimpleInternationalString) SimpleInternationalString(org.apache.sis.util.iso.SimpleInternationalString) DefaultCitation(org.apache.sis.metadata.iso.citation.DefaultCitation) Citation(org.opengis.metadata.citation.Citation) DefaultCitation(org.apache.sis.metadata.iso.citation.DefaultCitation) CI_Citation(org.apache.sis.internal.jaxb.metadata.CI_Citation)

Example 58 with DefaultCitation

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);
}
Also used : DefaultCitation(org.apache.sis.metadata.iso.citation.DefaultCitation) SimpleInternationalString(org.apache.sis.util.iso.SimpleInternationalString)

Example 59 with DefaultCitation

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;
}
Also used : DefaultCitation(org.apache.sis.metadata.iso.citation.DefaultCitation)

Example 60 with DefaultCitation

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;
}
Also used : DefaultCitation(org.apache.sis.metadata.iso.citation.DefaultCitation) SQLException(java.sql.SQLException) PreparedStatement(java.sql.PreparedStatement) Statement(java.sql.Statement) InternationalString(org.opengis.util.InternationalString) SimpleInternationalString(org.apache.sis.util.iso.SimpleInternationalString) OnLineFunction(org.opengis.metadata.citation.OnLineFunction) URISyntaxException(java.net.URISyntaxException) DatabaseMetaData(java.sql.DatabaseMetaData) DefaultOnlineResource(org.apache.sis.metadata.iso.citation.DefaultOnlineResource) URI(java.net.URI) Date(java.util.Date) SimpleInternationalString(org.apache.sis.util.iso.SimpleInternationalString) InternationalString(org.opengis.util.InternationalString) SimpleInternationalString(org.apache.sis.util.iso.SimpleInternationalString) ResultSet(java.sql.ResultSet) ImmutableIdentifier(org.apache.sis.metadata.iso.ImmutableIdentifier)

Aggregations

DefaultCitation (org.apache.sis.metadata.iso.citation.DefaultCitation)65 Test (org.junit.Test)35 SimpleInternationalString (org.apache.sis.util.iso.SimpleInternationalString)32 DependsOnMethod (org.apache.sis.test.DependsOnMethod)21 InternationalString (org.opengis.util.InternationalString)14 Citation (org.opengis.metadata.citation.Citation)10 IdentifiedObject (org.opengis.referencing.IdentifiedObject)9 ImmutableIdentifier (org.apache.sis.metadata.iso.ImmutableIdentifier)5 DefaultResponsibleParty (org.apache.sis.metadata.iso.citation.DefaultResponsibleParty)5 URI (java.net.URI)3 DefaultIdentifier (org.apache.sis.metadata.iso.DefaultIdentifier)3 DefaultMetadata (org.apache.sis.metadata.iso.DefaultMetadata)3 DefaultCitationTest (org.apache.sis.metadata.iso.citation.DefaultCitationTest)3 DefaultOnlineResource (org.apache.sis.metadata.iso.citation.DefaultOnlineResource)3 ArrayList (java.util.ArrayList)2 CI_Citation (org.apache.sis.internal.jaxb.metadata.CI_Citation)2 SimpleIdentifiedObject (org.apache.sis.internal.simple.SimpleIdentifiedObject)2 SimpleIdentifier (org.apache.sis.internal.simple.SimpleIdentifier)2 DefaultCitationDate (org.apache.sis.metadata.iso.citation.DefaultCitationDate)2 DefaultIndividual (org.apache.sis.metadata.iso.citation.DefaultIndividual)2