Search in sources :

Example 1 with DefaultDataIdentification

use of org.apache.sis.metadata.iso.identification.DefaultDataIdentification in project tika by apache.

the class GeographicInformationParser method extractContent.

private void extractContent(XHTMLContentHandler xhtmlContentHandler, DefaultMetadata defaultMetadata) throws SAXException {
    xhtmlContentHandler.startDocument();
    xhtmlContentHandler.newline();
    xhtmlContentHandler.newline();
    ArrayList<Identification> identifications = (ArrayList<Identification>) defaultMetadata.getIdentificationInfo();
    for (Identification i : identifications) {
        xhtmlContentHandler.startElement("h1");
        xhtmlContentHandler.characters(i.getCitation().getTitle().toString());
        xhtmlContentHandler.endElement("h1");
        xhtmlContentHandler.newline();
        ArrayList<ResponsibleParty> responsiblePartyArrayList = (ArrayList<ResponsibleParty>) i.getCitation().getCitedResponsibleParties();
        for (ResponsibleParty r : responsiblePartyArrayList) {
            xhtmlContentHandler.startElement("h3");
            xhtmlContentHandler.newline();
            xhtmlContentHandler.characters("CitedResponsiblePartyRole " + r.getRole().toString());
            xhtmlContentHandler.characters("CitedResponsiblePartyName " + r.getIndividualName().toString());
            xhtmlContentHandler.endElement("h3");
            xhtmlContentHandler.newline();
        }
        xhtmlContentHandler.startElement("p");
        xhtmlContentHandler.newline();
        xhtmlContentHandler.characters("IdentificationInfoAbstract " + i.getAbstract().toString());
        xhtmlContentHandler.endElement("p");
        xhtmlContentHandler.newline();
        Collection<Extent> extentList = ((DefaultDataIdentification) i).getExtents();
        for (Extent e : extentList) {
            ArrayList<GeographicExtent> geoElements = (ArrayList<GeographicExtent>) e.getGeographicElements();
            for (GeographicExtent g : geoElements) {
                if (g instanceof DefaultGeographicBoundingBox) {
                    xhtmlContentHandler.startElement("tr");
                    xhtmlContentHandler.startElement("td");
                    xhtmlContentHandler.characters("GeographicElementWestBoundLatitude");
                    xhtmlContentHandler.endElement("td");
                    xhtmlContentHandler.startElement("td");
                    xhtmlContentHandler.characters(String.valueOf(((DefaultGeographicBoundingBox) g).getWestBoundLongitude()));
                    xhtmlContentHandler.endElement("td");
                    xhtmlContentHandler.endElement("tr");
                    xhtmlContentHandler.startElement("tr");
                    xhtmlContentHandler.startElement("td");
                    xhtmlContentHandler.characters("GeographicElementEastBoundLatitude");
                    xhtmlContentHandler.endElement("td");
                    xhtmlContentHandler.startElement("td");
                    xhtmlContentHandler.characters(String.valueOf(((DefaultGeographicBoundingBox) g).getEastBoundLongitude()));
                    xhtmlContentHandler.endElement("td");
                    xhtmlContentHandler.endElement("tr");
                    xhtmlContentHandler.startElement("tr");
                    xhtmlContentHandler.startElement("td");
                    xhtmlContentHandler.characters("GeographicElementNorthBoundLatitude");
                    xhtmlContentHandler.endElement("td");
                    xhtmlContentHandler.startElement("td");
                    xhtmlContentHandler.characters(String.valueOf(((DefaultGeographicBoundingBox) g).getNorthBoundLatitude()));
                    xhtmlContentHandler.endElement("td");
                    xhtmlContentHandler.endElement("tr");
                    xhtmlContentHandler.startElement("tr");
                    xhtmlContentHandler.startElement("td");
                    xhtmlContentHandler.characters("GeographicElementSouthBoundLatitude");
                    xhtmlContentHandler.endElement("td");
                    xhtmlContentHandler.startElement("td");
                    xhtmlContentHandler.characters(String.valueOf(((DefaultGeographicBoundingBox) g).getSouthBoundLatitude()));
                    xhtmlContentHandler.endElement("td");
                    xhtmlContentHandler.endElement("tr");
                }
            }
        }
    }
    xhtmlContentHandler.newline();
    xhtmlContentHandler.endDocument();
}
Also used : DefaultGeographicBoundingBox(org.apache.sis.metadata.iso.extent.DefaultGeographicBoundingBox) GeographicExtent(org.opengis.metadata.extent.GeographicExtent) Extent(org.opengis.metadata.extent.Extent) CheckedArrayList(org.apache.sis.internal.util.CheckedArrayList) ArrayList(java.util.ArrayList) DefaultDataIdentification(org.apache.sis.metadata.iso.identification.DefaultDataIdentification) DefaultDataIdentification(org.apache.sis.metadata.iso.identification.DefaultDataIdentification) Identification(org.opengis.metadata.identification.Identification) ResponsibleParty(org.opengis.metadata.citation.ResponsibleParty) GeographicExtent(org.opengis.metadata.extent.GeographicExtent)

Example 2 with DefaultDataIdentification

use of org.apache.sis.metadata.iso.identification.DefaultDataIdentification in project sis by apache.

the class MetadataBuilder method addSupplementalInformation.

/**
 * Adds any other descriptive information about the resource.
 * If information already exists, the new one will be appended after a new line.
 * Storage location is:
 *
 * <ul>
 *   <li>{@code metadata/identificationInfo/supplementalInformation}</li>
 * </ul>
 *
 * @param info  any other descriptive information about the resource, or {@code null} for no-operation.
 */
public final void addSupplementalInformation(final CharSequence info) {
    final InternationalString i18n = trim(info);
    if (i18n != null) {
        final DefaultDataIdentification identification = identification();
        identification.setSupplementalInformation(append(identification.getSupplementalInformation(), i18n));
    }
}
Also used : InternationalString(org.opengis.util.InternationalString) DefaultDataIdentification(org.apache.sis.metadata.iso.identification.DefaultDataIdentification)

Example 3 with DefaultDataIdentification

use of org.apache.sis.metadata.iso.identification.DefaultDataIdentification 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 4 with DefaultDataIdentification

use of org.apache.sis.metadata.iso.identification.DefaultDataIdentification 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)

Example 5 with DefaultDataIdentification

use of org.apache.sis.metadata.iso.identification.DefaultDataIdentification in project tika by apache.

the class GeographicInformationParser method getMetaDataIdentificationInfo.

private void getMetaDataIdentificationInfo(Metadata metadata, DefaultMetadata defaultMetaData) {
    ArrayList<Identification> identifications = (ArrayList<Identification>) defaultMetaData.getIdentificationInfo();
    for (Identification i : identifications) {
        DefaultDataIdentification defaultDataIdentification = (DefaultDataIdentification) i;
        if (i.getCitation() != null && i.getCitation().getTitle() != null)
            metadata.add("IdentificationInfoCitationTitle ", i.getCitation().getTitle().toString());
        ArrayList<CitationDate> dateArrayList = (ArrayList<CitationDate>) i.getCitation().getDates();
        for (CitationDate d : dateArrayList) {
            if (d.getDateType() != null)
                metadata.add("CitationDate ", d.getDateType().name() + "-->" + d.getDate());
        }
        ArrayList<ResponsibleParty> responsiblePartyArrayList = (ArrayList<ResponsibleParty>) i.getCitation().getCitedResponsibleParties();
        for (ResponsibleParty r : responsiblePartyArrayList) {
            if (r.getRole() != null)
                metadata.add("CitedResponsiblePartyRole ", r.getRole().toString());
            if (r.getIndividualName() != null)
                metadata.add("CitedResponsiblePartyName ", r.getIndividualName().toString());
            if (r.getOrganisationName() != null)
                metadata.add("CitedResponsiblePartyOrganizationName ", r.getOrganisationName().toString());
            if (r.getPositionName() != null)
                metadata.add("CitedResponsiblePartyPositionName ", r.getPositionName().toString());
            if (r.getContactInfo() != null) {
                for (String s : r.getContactInfo().getAddress().getElectronicMailAddresses()) {
                    metadata.add("CitedResponsiblePartyEMail ", s.toString());
                }
            }
        }
        if (i.getAbstract() != null)
            metadata.add("IdentificationInfoAbstract ", i.getAbstract().toString());
        for (Progress p : i.getStatus()) {
            metadata.add("IdentificationInfoStatus ", p.name());
        }
        ArrayList<Format> formatArrayList = (ArrayList<Format>) i.getResourceFormats();
        for (Format f : formatArrayList) {
            if (f.getName() != null)
                metadata.add("ResourceFormatSpecificationAlternativeTitle ", f.getName().toString());
        }
        CheckedHashSet<Locale> localeCheckedHashSet = (CheckedHashSet<Locale>) defaultDataIdentification.getLanguages();
        for (Locale l : localeCheckedHashSet) {
            metadata.add("IdentificationInfoLanguage-->", l.getDisplayLanguage(Locale.ENGLISH));
        }
        CodeListSet<TopicCategory> categoryList = (CodeListSet<TopicCategory>) defaultDataIdentification.getTopicCategories();
        for (TopicCategory t : categoryList) {
            metadata.add("IdentificationInfoTopicCategory-->", t.name());
        }
        ArrayList<Keywords> keywordList = (ArrayList<Keywords>) i.getDescriptiveKeywords();
        int j = 1;
        for (Keywords k : keywordList) {
            j++;
            ArrayList<InternationalString> stringList = (ArrayList<InternationalString>) k.getKeywords();
            for (InternationalString s : stringList) {
                metadata.add("Keywords " + j, s.toString());
            }
            if (k.getType() != null)
                metadata.add("KeywordsType " + j, k.getType().name());
            if (k.getThesaurusName() != null && k.getThesaurusName().getTitle() != null)
                metadata.add("ThesaurusNameTitle " + j, k.getThesaurusName().getTitle().toString());
            if (k.getThesaurusName() != null && k.getThesaurusName().getAlternateTitles() != null)
                metadata.add("ThesaurusNameAlternativeTitle " + j, k.getThesaurusName().getAlternateTitles().toString());
            ArrayList<CitationDate> citationDates = (ArrayList<CitationDate>) k.getThesaurusName().getDates();
            for (CitationDate cd : citationDates) {
                if (cd.getDateType() != null)
                    metadata.add("ThesaurusNameDate ", cd.getDateType().name() + "-->" + cd.getDate());
            }
        }
        ArrayList<DefaultLegalConstraints> constraintList = (ArrayList<DefaultLegalConstraints>) i.getResourceConstraints();
        for (DefaultLegalConstraints c : constraintList) {
            for (Restriction r : c.getAccessConstraints()) {
                metadata.add("AccessContraints ", r.name());
            }
            for (InternationalString s : c.getOtherConstraints()) {
                metadata.add("OtherConstraints ", s.toString());
            }
            for (Restriction r : c.getUseConstraints()) {
                metadata.add("UserConstraints ", r.name());
            }
        }
        Collection<Extent> extentList = ((DefaultDataIdentification) i).getExtents();
        for (Extent e : extentList) {
            ArrayList<GeographicExtent> geoElements = (ArrayList<GeographicExtent>) e.getGeographicElements();
            for (GeographicExtent g : geoElements) {
                if (g instanceof DefaultGeographicDescription) {
                    if (((DefaultGeographicDescription) g).getGeographicIdentifier() != null && ((DefaultGeographicDescription) g).getGeographicIdentifier().getCode() != null)
                        metadata.add("GeographicIdentifierCode ", ((DefaultGeographicDescription) g).getGeographicIdentifier().getCode().toString());
                    if (((DefaultGeographicDescription) g).getGeographicIdentifier() != null && ((DefaultGeographicDescription) g).getGeographicIdentifier().getAuthority() != null && ((DefaultGeographicDescription) g).getGeographicIdentifier().getAuthority().getTitle() != null)
                        metadata.add("GeographicIdentifierAuthorityTitle ", ((DefaultGeographicDescription) g).getGeographicIdentifier().getAuthority().getTitle().toString());
                    for (InternationalString s : ((DefaultGeographicDescription) g).getGeographicIdentifier().getAuthority().getAlternateTitles()) {
                        metadata.add("GeographicIdentifierAuthorityAlternativeTitle ", s.toString());
                    }
                    for (CitationDate cd : ((DefaultGeographicDescription) g).getGeographicIdentifier().getAuthority().getDates()) {
                        if (cd.getDateType() != null && cd.getDate() != null)
                            metadata.add("GeographicIdentifierAuthorityDate ", cd.getDateType().name() + " " + cd.getDate().toString());
                    }
                }
            }
        }
    }
}
Also used : Locale(java.util.Locale) CodeListSet(org.apache.sis.util.collection.CodeListSet) Keywords(org.opengis.metadata.identification.Keywords) GeographicExtent(org.opengis.metadata.extent.GeographicExtent) Extent(org.opengis.metadata.extent.Extent) CheckedArrayList(org.apache.sis.internal.util.CheckedArrayList) ArrayList(java.util.ArrayList) DefaultDataIdentification(org.apache.sis.metadata.iso.identification.DefaultDataIdentification) Identification(org.opengis.metadata.identification.Identification) InternationalString(org.opengis.util.InternationalString) Format(org.opengis.metadata.distribution.Format) DefaultLegalConstraints(org.apache.sis.metadata.iso.constraint.DefaultLegalConstraints) DefaultDataIdentification(org.apache.sis.metadata.iso.identification.DefaultDataIdentification) CitationDate(org.opengis.metadata.citation.CitationDate) Progress(org.opengis.metadata.identification.Progress) TopicCategory(org.opengis.metadata.identification.TopicCategory) ResponsibleParty(org.opengis.metadata.citation.ResponsibleParty) CheckedHashSet(org.apache.sis.internal.util.CheckedHashSet) GeographicExtent(org.opengis.metadata.extent.GeographicExtent) DefaultGeographicDescription(org.apache.sis.metadata.iso.extent.DefaultGeographicDescription) Restriction(org.opengis.metadata.constraint.Restriction) InternationalString(org.opengis.util.InternationalString)

Aggregations

DefaultDataIdentification (org.apache.sis.metadata.iso.identification.DefaultDataIdentification)10 InternationalString (org.opengis.util.InternationalString)5 URI (java.net.URI)4 Identification (org.opengis.metadata.identification.Identification)4 Test (org.junit.Test)3 ArrayList (java.util.ArrayList)2 CheckedArrayList (org.apache.sis.internal.util.CheckedArrayList)2 DefaultMetadata (org.apache.sis.metadata.iso.DefaultMetadata)2 DefaultCitation (org.apache.sis.metadata.iso.citation.DefaultCitation)2 DefaultOnlineResource (org.apache.sis.metadata.iso.citation.DefaultOnlineResource)2 AbstractIdentification (org.apache.sis.metadata.iso.identification.AbstractIdentification)2 SimpleInternationalString (org.apache.sis.util.iso.SimpleInternationalString)2 OnlineResource (org.opengis.metadata.citation.OnlineResource)2 ResponsibleParty (org.opengis.metadata.citation.ResponsibleParty)2 Extent (org.opengis.metadata.extent.Extent)2 GeographicExtent (org.opengis.metadata.extent.GeographicExtent)2 TopicCategory (org.opengis.metadata.identification.TopicCategory)2 Locale (java.util.Locale)1 XmlElement (javax.xml.bind.annotation.XmlElement)1 CI_Citation (org.apache.sis.internal.jaxb.metadata.CI_Citation)1