Search in sources :

Example 26 with DefaultCitation

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

Example 27 with DefaultCitation

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

Example 28 with DefaultCitation

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

Example 29 with DefaultCitation

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);
}
Also used : OnlineResource(org.opengis.metadata.citation.OnlineResource) DefaultOnlineResource(org.apache.sis.metadata.iso.citation.DefaultOnlineResource) DefaultCitation(org.apache.sis.metadata.iso.citation.DefaultCitation) AbstractIdentification(org.apache.sis.metadata.iso.identification.AbstractIdentification) DefaultDataIdentification(org.apache.sis.metadata.iso.identification.DefaultDataIdentification) DefaultDataIdentification(org.apache.sis.metadata.iso.identification.DefaultDataIdentification) Identification(org.opengis.metadata.identification.Identification) AbstractIdentification(org.apache.sis.metadata.iso.identification.AbstractIdentification) DefaultOnlineResource(org.apache.sis.metadata.iso.citation.DefaultOnlineResource) URI(java.net.URI)

Example 30 with DefaultCitation

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;
}
Also used : OnlineResource(org.opengis.metadata.citation.OnlineResource) DefaultOnlineResource(org.apache.sis.metadata.iso.citation.DefaultOnlineResource) DefaultCitation(org.apache.sis.metadata.iso.citation.DefaultCitation) DefaultDataIdentification(org.apache.sis.metadata.iso.identification.DefaultDataIdentification) Identification(org.opengis.metadata.identification.Identification) AbstractIdentification(org.apache.sis.metadata.iso.identification.AbstractIdentification) InternationalString(org.opengis.util.InternationalString) SimpleInternationalString(org.apache.sis.util.iso.SimpleInternationalString) Citation(org.opengis.metadata.citation.Citation) DefaultCitation(org.apache.sis.metadata.iso.citation.DefaultCitation) CI_Citation(org.apache.sis.internal.jaxb.metadata.CI_Citation) URI(java.net.URI) XmlElement(javax.xml.bind.annotation.XmlElement) Dependencies(org.apache.sis.internal.metadata.Dependencies)

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