Java Code Examples for org.opengis.metadata.citation.Citation#getEdition()

The following examples show how to use org.opengis.metadata.citation.Citation#getEdition() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DefaultFormat.java    From sis with Apache License 2.0 5 votes vote down vote up
/**
 * Returns the version of the format (date, number, etc.).
 *
 * @return version of the format, or {@code null}.
 *
 * @deprecated As of ISO 19115:2014, replaced by
 * <code>{@linkplain #getFormatSpecificationCitation()}.{@linkplain DefaultCitation#getEdition()
 * getEdition()}</code>.
 */
@Override
@Deprecated
@Dependencies("getFormatSpecificationCitation")
@XmlElement(name = "version", namespace = LegacyNamespaces.GMD)
public InternationalString getVersion() {
    if (FilterByVersion.LEGACY_METADATA.accept()) {
        final Citation citation = getFormatSpecificationCitation();
        if (citation != null) {
            return citation.getEdition();
        }
    }
    return null;
}
 
Example 2
Source File: DefaultMetadata.java    From sis with Apache License 2.0 5 votes vote down vote up
/**
 * Implementation of legacy {@link #getMetadataStandardName()} and {@link #getMetadataStandardVersion()} methods.
 */
private String getMetadataStandard(final boolean version) {
    if (FilterByVersion.LEGACY_METADATA.accept()) {
        final Citation standard = LegacyPropertyAdapter.getSingleton(getMetadataStandards(),
                Citation.class, null, DefaultMetadata.class,
                version ? "getMetadataStandardName" : "getMetadataStandardVersion");
        if (standard != null) {
            final InternationalString title = version ? standard.getEdition() : standard.getTitle();
            if (title != null) {
                return title.toString();
            }
        }
    }
    return null;
}
 
Example 3
Source File: DefaultCitation.java    From sis with Apache License 2.0 5 votes vote down vote up
/**
 * Constructs a new instance initialized with the values from the specified metadata object.
 * This is a <cite>shallow</cite> copy constructor, since the other metadata contained in the
 * given object are not recursively copied.
 *
 * @param  object  the metadata to copy values from, or {@code null} if none.
 *
 * @see #castOrCopy(Citation)
 */
public DefaultCitation(final Citation object) {
    super(object);
    if (object != null) {
        title                   = object.getTitle();
        alternateTitles         = copyCollection(object.getAlternateTitles(), InternationalString.class);
        dates                   = copyCollection(object.getDates(), CitationDate.class);
        edition                 = object.getEdition();
        editionDate             = toMilliseconds(object.getEditionDate());
        identifiers             = copyCollection(object.getIdentifiers(), Identifier.class);
        citedResponsibleParties = copyCollection(object.getCitedResponsibleParties(), ResponsibleParty.class);
        presentationForms       = copyCollection(object.getPresentationForms(), PresentationForm.class);
        series                  = object.getSeries();
        otherCitationDetails    = object.getOtherCitationDetails();
        collectiveTitle         = object.getCollectiveTitle();
        if (object instanceof DefaultCitation) {
            final DefaultCitation c = (DefaultCitation) object;
            onlineResources = copyCollection(c.getOnlineResources(), OnlineResource.class);
            graphics        = copyCollection(c.getGraphics(), BrowseGraphic.class);
        }
        final String id1        = object.getISBN();
        final String id2        = object.getISSN();
        if (id1 != null || id2 != null) {
            final IdentifierMap map = super.getIdentifierMap();
            if (id1 != null) map.putSpecialized(Citations.ISBN, id1);
            if (id2 != null) map.putSpecialized(Citations.ISSN, id2);
        }
    }
}
 
Example 4
Source File: EPSGDataAccess.java    From sis with Apache License 2.0 4 votes vote down vote up
/**
 * Returns the name and aliases for the {@link IdentifiedObject} to construct.
 *
 * @param  table       the table on which a query has been executed.
 * @param  name        the name for the {@link IdentifiedObject} to construct.
 * @param  code        the EPSG code of the object to construct.
 * @param  remarks     remarks as a {@link String} or {@link InternationalString}, or {@code null} if none.
 * @param  deprecated  {@code true} if the object to create is deprecated.
 * @return the name together with a set of properties.
 */
@SuppressWarnings("ReturnOfCollectionOrArrayField")
private Map<String,Object> createProperties(final String table, String name, final Integer code,
        CharSequence remarks, final boolean deprecated) throws SQLException, FactoryDataException
{
    /*
     * Search for aliases. Note that searching for the object code is not sufficient. We also need to check if the
     * record is really from the table we are looking for since different tables may have objects with the same ID.
     *
     * Some aliases are identical to the name except that some letters are replaced by their accented letters.
     * For example "Reseau Geodesique Francais" → "Réseau Géodésique Français". If we find such alias, replace
     * the name by the alias so we have proper display in user interface. Notes:
     *
     *   - WKT formatting will still be compliant with ISO 19162 because the WKT formatter replaces accented
     *     letters by ASCII ones.
     *   - We do not perform this replacement directly in our EPSG database because ASCII letters are more
     *     convenient for implementing accent-insensitive searches.
     */
    final List<GenericName> aliases = new ArrayList<>();
    try (ResultSet result = executeMetadataQuery("Alias",
            "SELECT NAMING_SYSTEM_NAME, ALIAS" +
            " FROM [Alias] INNER JOIN [Naming System]" +
              " ON [Alias].NAMING_SYSTEM_CODE =" +
            " [Naming System].NAMING_SYSTEM_CODE" +
            " WHERE OBJECT_TABLE_NAME=? AND OBJECT_CODE=?", table, code))
            // Note: "OBJECT_TABLE_NAME=?" is handled in a special way by SQLTranslator.
    {
        while (result.next()) {
            final String naming = getOptionalString(result, 1);
            final String alias  = getString(code,   result, 2);
            NameSpace ns = null;
            if (naming != null) {
                ns = namingSystems.get(naming);
                if (ns == null) {
                    ns = owner.nameFactory.createNameSpace(owner.nameFactory.createLocalName(null, naming), null);
                    namingSystems.put(naming, ns);
                }
            }
            if (CharSequences.toASCII(alias).toString().equals(name)) {
                name = alias;
            } else {
                aliases.add(owner.nameFactory.createLocalName(ns, alias));
            }
        }
    }
    /*
     * At this point we can fill the properties map.
     */
    properties.clear();
    GenericName gn = null;
    final Locale locale = getLocale();
    final Citation authority = owner.getAuthority();
    final InternationalString edition = authority.getEdition();
    final String version = (edition != null) ? edition.toString() : null;
    if (name != null) {
        gn = owner.nameFactory.createGenericName(namespace, Constants.EPSG, name);
        properties.put("name", gn);
        properties.put(NamedIdentifier.CODE_KEY,      name);
        properties.put(NamedIdentifier.VERSION_KEY,   version);
        properties.put(NamedIdentifier.AUTHORITY_KEY, authority);
        properties.put(AbstractIdentifiedObject.LOCALE_KEY, locale);
        final NamedIdentifier id = new NamedIdentifier(properties);
        properties.clear();
        properties.put(IdentifiedObject.NAME_KEY, id);
    }
    if (!aliases.isEmpty()) {
        properties.put(IdentifiedObject.ALIAS_KEY, aliases.toArray(new GenericName[aliases.size()]));
    }
    if (code != null) {
        final String codeString = code.toString();
        final ImmutableIdentifier identifier;
        if (deprecated) {
            final String replacedBy = getSupersession(table, code, locale);
            identifier = new DeprecatedCode(authority, Constants.EPSG, codeString, version,
                    Character.isDigit(replacedBy.charAt(0)) ? replacedBy : null,
                    Vocabulary.formatInternational(Vocabulary.Keys.SupersededBy_1, replacedBy));
            properties.put(AbstractIdentifiedObject.DEPRECATED_KEY, Boolean.TRUE);
        } else {
            identifier = new ImmutableIdentifier(authority, Constants.EPSG, codeString, version,
                                (gn != null) ? gn.toInternationalString() : null);
        }
        properties.put(IdentifiedObject.IDENTIFIERS_KEY, identifier);
    }
    properties.put(IdentifiedObject.REMARKS_KEY, remarks);
    properties.put(AbstractIdentifiedObject.LOCALE_KEY, locale);
    properties.put(ReferencingFactoryContainer.MT_FACTORY, owner.mtFactory);
    return properties;
}
 
Example 5
Source File: NameMeaning.java    From sis with Apache License 2.0 3 votes vote down vote up
/**
 * Returns the version of the namespace managed by the given authority.
 * Current Apache SIS implementation searches this information in the {@link Citation#getEdition()} property.
 * This approach is based on the assumption that the authority is some specification document or reference to
 * a database, not an organization. However this policy may be revisited in any future SIS version.
 *
 * @param  authority  the authority from which to get a version, or {@code null}.
 * @return the version, or {@code null} if none.
 *
 * @since 0.7
 */
public static String getVersion(final Citation authority) {
    if (authority != null) {
        final InternationalString i18n = authority.getEdition();
        if (i18n != null) {
            return i18n.toString(Locale.US);
        }
    }
    return null;
}