Search in sources :

Example 1 with Format

use of org.opengis.metadata.distribution.Format in project sis by apache.

the class CustomMetadataTest method testSubtypeAttributes.

/**
 * Tests that the attributes defined in subtypes are also marshalled.
 *
 * @throws JAXBException if an error occurred during (un)marshalling.
 *
 * @see <a href="http://jira.geotoolkit.org/browse/GEOTK-108">GEOTK-108</a>
 */
@Test
public void testSubtypeAttributes() throws JAXBException {
    final NameFactory factory = DefaultFactories.forBuildin(NameFactory.class);
    final DataIdentification identification = new DataIdentification() {

        @Override
        public InternationalString getAbstract() {
            Map<Locale, String> names = new HashMap<>();
            names.put(Locale.ENGLISH, "Description");
            return factory.createInternationalString(names);
        }

        @Override
        public InternationalString getEnvironmentDescription() {
            Map<Locale, String> names = new HashMap<>();
            names.put(Locale.ENGLISH, "Environment");
            return factory.createInternationalString(names);
        }

        @Override
        public InternationalString getSupplementalInformation() {
            return null;
        }

        @Override
        public Citation getCitation() {
            return null;
        }

        @Override
        public InternationalString getPurpose() {
            return null;
        }

        @Override
        public Collection<SpatialRepresentationType> getSpatialRepresentationTypes() {
            return null;
        }

        @Override
        public Collection<Resolution> getSpatialResolutions() {
            return null;
        }

        @Override
        public Collection<Locale> getLanguages() {
            return null;
        }

        @Override
        public Collection<CharacterSet> getCharacterSets() {
            return null;
        }

        @Override
        public Collection<TopicCategory> getTopicCategories() {
            return null;
        }

        @Override
        public Collection<Extent> getExtents() {
            return null;
        }

        @Override
        public Collection<String> getCredits() {
            return null;
        }

        @Override
        public Collection<Progress> getStatus() {
            return null;
        }

        @Override
        public Collection<ResponsibleParty> getPointOfContacts() {
            return null;
        }

        @Override
        public Collection<MaintenanceInformation> getResourceMaintenances() {
            return null;
        }

        @Override
        public Collection<BrowseGraphic> getGraphicOverviews() {
            return null;
        }

        @Override
        public Collection<Format> getResourceFormats() {
            return null;
        }

        @Override
        public Collection<Keywords> getDescriptiveKeywords() {
            return null;
        }

        @Override
        public Collection<Usage> getResourceSpecificUsages() {
            return null;
        }

        @Override
        public Collection<Constraints> getResourceConstraints() {
            return null;
        }

        @Deprecated
        @Override
        public Collection<AggregateInformation> getAggregationInfo() {
            return null;
        }
    };
    final DefaultMetadata data = new DefaultMetadata();
    data.setIdentificationInfo(singleton(identification));
    final String xml = XML.marshal(data);
    /*
         * A few simple checks.
         */
    assertTrue("Missing Identification attribute.", xml.contains("Description"));
    assertTrue("Missing DataIdentification attribute.", xml.contains("Environment"));
}
Also used : Locale(java.util.Locale) HashMap(java.util.HashMap) Extent(org.opengis.metadata.extent.Extent) InternationalString(org.opengis.util.InternationalString) SimpleInternationalString(org.apache.sis.util.iso.SimpleInternationalString) ResponsibleParty(org.opengis.metadata.citation.ResponsibleParty) Format(org.opengis.metadata.distribution.Format) Constraints(org.opengis.metadata.constraint.Constraints) MaintenanceInformation(org.opengis.metadata.maintenance.MaintenanceInformation) NameFactory(org.opengis.util.NameFactory) SpatialRepresentationType(org.opengis.metadata.spatial.SpatialRepresentationType) Test(org.junit.Test)

Example 2 with Format

use of org.opengis.metadata.distribution.Format 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 3 with Format

use of org.opengis.metadata.distribution.Format in project tika by apache.

the class GeographicInformationParser method getMetaDataDistributionInfo.

private void getMetaDataDistributionInfo(Metadata metadata, DefaultMetadata defaultMetaData) {
    Distribution distribution = defaultMetaData.getDistributionInfo();
    ArrayList<Format> distributionFormat = (ArrayList<Format>) distribution.getDistributionFormats();
    for (Format f : distributionFormat) {
        if (f.getName() != null)
            metadata.add("DistributionFormatSpecificationAlternativeTitle ", f.getName().toString());
    }
    ArrayList<Distributor> distributorList = (ArrayList<Distributor>) distribution.getDistributors();
    for (Distributor d : distributorList) {
        if (d != null && d.getDistributorContact() != null && d.getDistributorContact().getRole() != null)
            metadata.add("Distributor Contact ", d.getDistributorContact().getRole().name());
        if (d != null && d.getDistributorContact() != null && d.getDistributorContact().getOrganisationName() != null)
            metadata.add("Distributor Organization Name ", d.getDistributorContact().getOrganisationName().toString());
    }
    ArrayList<DigitalTransferOptions> transferOptionsList = (ArrayList<DigitalTransferOptions>) distribution.getTransferOptions();
    for (DigitalTransferOptions d : transferOptionsList) {
        ArrayList<OnlineResource> onlineResourceList = (ArrayList<OnlineResource>) d.getOnLines();
        for (OnlineResource or : onlineResourceList) {
            if (or.getLinkage() != null)
                metadata.add("TransferOptionsOnlineLinkage ", or.getLinkage().toString());
            if (or.getProtocol() != null)
                metadata.add("TransferOptionsOnlineProtocol ", or.getProtocol());
            if (or.getApplicationProfile() != null)
                metadata.add("TransferOptionsOnlineProfile ", or.getApplicationProfile());
            if (or.getName() != null)
                metadata.add("TransferOptionsOnlineName ", or.getName());
            if (or.getDescription() != null)
                metadata.add("TransferOptionsOnlineDescription ", or.getDescription().toString());
            if (or.getFunction() != null)
                metadata.add("TransferOptionsOnlineFunction ", or.getFunction().name());
        }
    }
}
Also used : OnlineResource(org.opengis.metadata.citation.OnlineResource) Format(org.opengis.metadata.distribution.Format) Distributor(org.opengis.metadata.distribution.Distributor) Distribution(org.opengis.metadata.distribution.Distribution) CheckedArrayList(org.apache.sis.internal.util.CheckedArrayList) ArrayList(java.util.ArrayList) DigitalTransferOptions(org.opengis.metadata.distribution.DigitalTransferOptions)

Example 4 with Format

use of org.opengis.metadata.distribution.Format 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)

Example 5 with Format

use of org.opengis.metadata.distribution.Format in project sis by apache.

the class DocumentedStoreProvider method getFormat.

/**
 * Returns a more complete description of the format, sending warnings to the given listeners if non-null.
 *
 * @param  listeners  where to report the warning in case of error, or {@code null} if none.
 * @return a description of the data format.
 */
public final Format getFormat(final WarningListeners<DataStore> listeners) {
    /*
         * Note: this method does not cache the format because such caching is already done by MetadataSource.
         */
    if (name != null)
        try {
            return MetadataSource.getProvided().lookup(Format.class, name);
        } catch (MetadataStoreException e) {
            if (listeners != null) {
                listeners.warning(null, e);
            } else {
                final Level level;
                if (!logged) {
                    // Not atomic - not a big deal if we use warning level twice.
                    logged = true;
                    level = Level.WARNING;
                } else {
                    level = Level.FINE;
                }
                final LogRecord record = Resources.forLocale(null).getLogRecord(level, Resources.Keys.CanNotGetCommonMetadata_2, getShortName(), e.getLocalizedMessage());
                record.setLoggerName(Modules.STORAGE);
                Logging.log(getClass(), "getFormat", record);
            }
        }
    return super.getFormat();
}
Also used : MetadataStoreException(org.apache.sis.metadata.sql.MetadataStoreException) Format(org.opengis.metadata.distribution.Format) LogRecord(java.util.logging.LogRecord) Level(java.util.logging.Level)

Aggregations

Format (org.opengis.metadata.distribution.Format)5 ArrayList (java.util.ArrayList)2 Locale (java.util.Locale)2 CheckedArrayList (org.apache.sis.internal.util.CheckedArrayList)2 SimpleInternationalString (org.apache.sis.util.iso.SimpleInternationalString)2 ResponsibleParty (org.opengis.metadata.citation.ResponsibleParty)2 Extent (org.opengis.metadata.extent.Extent)2 InternationalString (org.opengis.util.InternationalString)2 HashMap (java.util.HashMap)1 Level (java.util.logging.Level)1 LogRecord (java.util.logging.LogRecord)1 CheckedHashSet (org.apache.sis.internal.util.CheckedHashSet)1 DefaultCitation (org.apache.sis.metadata.iso.citation.DefaultCitation)1 DefaultLegalConstraints (org.apache.sis.metadata.iso.constraint.DefaultLegalConstraints)1 DefaultFormat (org.apache.sis.metadata.iso.distribution.DefaultFormat)1 DefaultGeographicDescription (org.apache.sis.metadata.iso.extent.DefaultGeographicDescription)1 DefaultDataIdentification (org.apache.sis.metadata.iso.identification.DefaultDataIdentification)1 MetadataStoreException (org.apache.sis.metadata.sql.MetadataStoreException)1 CodeListSet (org.apache.sis.util.collection.CodeListSet)1 Test (org.junit.Test)1