Package org.apache.sis.metadata.iso

Examples of org.apache.sis.metadata.iso.DefaultMetadata


                    new Class<?>[] { Metadata.class }, handler);
        /*
         * Wrap the metadata in a DefaultMetadata, and ensure
         * we can marshall it without an exception being throw.
         */
        data = new DefaultMetadata(data);
        final String xml = XML.marshal(data);
        /*
         * A few simple checks.
         */
        assertTrue(xml.contains("getMetadataStandardName"));
View Full Code Here


            @Override public Collection<Keywords>                  getDescriptiveKeywords()        {return null;}
            @Override public Collection<Usage>                     getResourceSpecificUsages()     {return null;}
            @Override public Collection<Constraints>               getResourceConstraints()        {return null;}
            @Override public Collection<AggregateInformation>      getAggregationInfo()            {return null;}
        };
        final DefaultMetadata data = new DefaultMetadata();
        assertTrue(data.getIdentificationInfo().add(identification));
        final String xml = XML.marshal(data);
        /*
         * A few simple checks.
         */
        assertTrue("Missing Identification attribute.",     xml.contains("Description"));
View Full Code Here

     *
     * @return The ISO metadata object.
     * @throws IOException If an I/O operation was necessary but failed.
     */
    public Metadata read() throws IOException {
        final DefaultMetadata metadata = new DefaultMetadata();
        metadata.setMetadataStandardName(MetadataUtilities.STANDARD_NAME_2);
        metadata.setMetadataStandardVersion(MetadataUtilities.STANDARD_VERSION_2);
        final Identifier identifier = getFileIdentifier();
        if (identifier != null) {
            String code = identifier.getCode();
            final Citation authority = identifier.getAuthority();
            if (authority != null) {
                final InternationalString title = authority.getTitle();
                if (title != null) {
                    code = title.toString() + DefaultNameSpace.DEFAULT_SEPARATOR + code;
                }
            }
            metadata.setFileIdentifier(code);
        }
        metadata.setDateStamp(decoder.dateValue(METADATA_CREATION));
        metadata.getHierarchyLevels().add(ScopeCode.DATASET);
        final String wms = decoder.stringValue("wms_service");
        final String wcs = decoder.stringValue("wcs_service");
        if (wms != null || wcs != null) {
            metadata.getHierarchyLevels().add(ScopeCode.SERVICE);
        }
        /*
         * Add the ResponsibleParty which is declared in global attributes, or in
         * the THREDDS attributes if no information was found in global attributes.
         */
        for (final String path : searchPath) {
            decoder.setSearchPath(path);
            final ResponsibleParty party = createResponsibleParty(CREATOR, true);
            if (party != null && party != pointOfContact) {
                addIfAbsent(metadata.getContacts(), party);
                if (pointOfContact == null) {
                    pointOfContact = party;
                }
            }
        }
        /*
         * Add the publisher AFTER the creator, because this method may
         * reuse the 'creator' field (if non-null and if applicable).
         */
        Set<InternationalString> publisher = null;
        DefaultDistribution distribution   = null;
        for (final String path : searchPath) {
            decoder.setSearchPath(path);
            final ResponsibleParty party = createResponsibleParty(PUBLISHER, false);
            if (party != null) {
                if (distribution == null) {
                    distribution = new DefaultDistribution();
                    metadata.setDistributionInfo(distribution);
                }
                final DefaultDistributor distributor = new DefaultDistributor(party);
                // TODO: There is some transfert option, etc. that we could set there.
                // See UnidataDD2MI.xsl for options for OPeNDAP, THREDDS, etc.
                addIfAbsent(distribution.getDistributors(), distributor);
                publisher = addIfNonNull(publisher, toInternationalString(party.getIndividualName()));
            }
            // Also add history.
            final String history = decoder.stringValue(HISTORY);
            if (history != null) {
                final DefaultDataQuality quality = new DefaultDataQuality();
                final DefaultLineage lineage = new DefaultLineage();
                lineage.setStatement(new SimpleInternationalString(history));
                quality.setLineage(lineage);
                addIfAbsent(metadata.getDataQualityInfo(), quality);
            }
        }
        /*
         * Add the identification info AFTER the responsible parties (both creator and publisher),
         * because this method will reuse the 'creator' and 'publisher' information (if non-null).
         */
        final DataIdentification identification = createIdentificationInfo(identifier, publisher);
        if (identification != null) {
            metadata.getIdentificationInfo().add(identification);
        }
        metadata.setContentInfo(createContentInfo());
        /*
         * Add the dimension information, if any. This metadata node
         * is built from the NetCDF CoordinateSystem objects.
         */
        for (final GridGeometry cs : decoder.getGridGeometries()) {
            if (cs.getSourceDimensions() >= Variable.MIN_DIMENSION && cs.getTargetDimensions() >= Variable.MIN_DIMENSION) {
                metadata.getSpatialRepresentationInfo().add(createSpatialRepresentationInfo(cs));
            }
        }
        metadata.freeze();
        return metadata;
    }
View Full Code Here

        unmarshal();
        if (metadata == null) {
            if (object instanceof Metadata) {
                metadata = (Metadata) object;
            } else if (object instanceof ReferenceSystem) {
                final DefaultMetadata d = new DefaultMetadata();
                d.getReferenceSystemInfo().add((ReferenceSystem) object);
                metadata = d;
            }
        }
        return metadata;
    }
View Full Code Here

    /**
     * Creates the metadata object to be tested.
     */
    private static DefaultMetadata createMetadata() {
        final DefaultMetadata metadata = new DefaultMetadata();
        final DirectReferenceSystem refSys = new DirectReferenceSystem(new ImmutableIdentifier(
                new DefaultCitation(getSingleton(HardCodedCitations.EPSG.getCitedResponsibleParties())), null, "4326"));
        metadata.setReferenceSystemInfo(Arrays.asList(refSys));
        return metadata;
    }
View Full Code Here

     *
     * @throws JAXBException if the unmarshalling process fails.
     */
    @Test
    public void unmarshallingTest() throws JAXBException {
        final DefaultMetadata expected = createMetadata();
        final DefaultMetadata result = unmarshalFile(DefaultMetadata.class, XML_FILE);
        /*
         * Compare in debug mode before to perform the real comparison,
         * for making easier to analyze the stack trace in case of failure.
         */
        assertTrue(expected.equals(result, ComparisonMode.DEBUG));
View Full Code Here

     *
     * @return The ISO metadata object.
     * @throws IOException If an I/O operation was necessary but failed.
     */
    public Metadata read() throws IOException {
        final DefaultMetadata metadata = new DefaultMetadata();
        metadata.setMetadataStandardName(MetadataUtilities.STANDARD_NAME_2);
        metadata.setMetadataStandardVersion(MetadataUtilities.STANDARD_VERSION_2);
        final Identifier identifier = getFileIdentifier();
        if (identifier != null) {
            String code = identifier.getCode();
            final Citation authority = identifier.getAuthority();
            if (authority != null) {
                final InternationalString title = authority.getTitle();
                if (title != null) {
                    code = title.toString() + DefaultNameSpace.DEFAULT_SEPARATOR + code;
                }
            }
            metadata.setFileIdentifier(code);
        }
        metadata.setDateStamp(decoder.dateValue(METADATA_CREATION));
        metadata.getHierarchyLevels().add(ScopeCode.DATASET);
        final String wms = decoder.stringValue("wms_service");
        final String wcs = decoder.stringValue("wcs_service");
        if (wms != null || wcs != null) {
            metadata.getHierarchyLevels().add(ScopeCode.SERVICE);
        }
        /*
         * Add the ResponsibleParty which is declared in global attributes, or in
         * the THREDDS attributes if no information was found in global attributes.
         */
        for (final String path : searchPath) {
            decoder.setSearchPath(path);
            final ResponsibleParty party = createResponsibleParty(CREATOR, true);
            if (party != null && party != pointOfContact) {
                addIfAbsent(metadata.getContacts(), party);
                if (pointOfContact == null) {
                    pointOfContact = party;
                }
            }
        }
        /*
         * Add the publisher AFTER the creator, because this method may
         * reuse the 'creator' field (if non-null and if applicable).
         */
        Set<InternationalString> publisher = null;
        DefaultDistribution distribution   = null;
        for (final String path : searchPath) {
            decoder.setSearchPath(path);
            final ResponsibleParty party = createResponsibleParty(PUBLISHER, false);
            if (party != null) {
                if (distribution == null) {
                    distribution = new DefaultDistribution();
                    metadata.setDistributionInfo(distribution);
                }
                final DefaultDistributor distributor = new DefaultDistributor(party);
                // TODO: There is some transfert option, etc. that we could set there.
                // See UnidataDD2MI.xsl for options for OPeNDAP, THREDDS, etc.
                addIfAbsent(distribution.getDistributors(), distributor);
                publisher = addIfNonNull(publisher, toInternationalString(party.getIndividualName()));
            }
            // Also add history.
            final String history = decoder.stringValue(HISTORY);
            if (history != null) {
                final DefaultDataQuality quality = new DefaultDataQuality();
                final DefaultLineage lineage = new DefaultLineage();
                lineage.setStatement(new SimpleInternationalString(history));
                quality.setLineage(lineage);
                addIfAbsent(metadata.getDataQualityInfo(), quality);
            }
        }
        /*
         * Add the identification info AFTER the responsible parties (both creator and publisher),
         * because this method will reuse the 'creator' and 'publisher' information (if non-null).
         */
        final DataIdentification identification = createIdentificationInfo(identifier, publisher);
        if (identification != null) {
            metadata.getIdentificationInfo().add(identification);
        }
        metadata.setContentInfo(createContentInfo());
        /*
         * Add the dimension information, if any. This metadata node
         * is built from the NetCDF CoordinateSystem objects.
         */
        for (final GridGeometry cs : decoder.getGridGeometries()) {
            if (cs.getSourceDimensions() >= Variable.MIN_DIMENSION && cs.getTargetDimensions() >= Variable.MIN_DIMENSION) {
                metadata.getSpatialRepresentationInfo().add(createSpatialRepresentationInfo(cs));
            }
        }
        metadata.freeze();
        return metadata;
    }
View Full Code Here

    public void testLinkOnly() throws JAXBException, URISyntaxException {
        final XLink xlink = new XLink();
        xlink.setHRef(new URI("http://test.net"));
        final DefaultDataIdentification identification = new DefaultDataIdentification();
        identification.getIdentifierMap().putSpecialized(IdentifierSpace.XLINK, xlink);
        final DefaultMetadata metadata = new DefaultMetadata();
        metadata.setIdentificationInfo(Collections.singleton(identification));

        assertXmlEquals(LINK_ONLY_XML, XML.marshal(metadata), "xmlns:*");
        verify(true, unmarshal(DefaultMetadata.class, LINK_ONLY_XML));
    }
View Full Code Here

        final XLink xlink = new XLink();
        xlink.setHRef(new URI("http://test.net"));
        final DefaultDataIdentification identification = new DefaultDataIdentification();
        identification.getIdentifierMap().putSpecialized(IdentifierSpace.XLINK, xlink);
        identification.setAbstract(new SimpleInternationalString("This is a test."));
        final DefaultMetadata metadata = new DefaultMetadata();
        metadata.setIdentificationInfo(Collections.singleton(identification));

        assertXmlEquals(LINK_WITH_ELEMENT_XML, XML.marshal(metadata), "xmlns:*");
        final DefaultMetadata unmarshal = unmarshal(DefaultMetadata.class, LINK_WITH_ELEMENT_XML);
        verify(false, unmarshal);
        assertTrue(metadata.equals(unmarshal, ComparisonMode.DEBUG));
    }
View Full Code Here

    /**
     * Creates the metadata objects to be used for the test.
     */
    public PrunerTest() {
        metadata       = new DefaultMetadata();
        identification = new DefaultDataIdentification();
        extent         = new DefaultExtent();
        bbox           = new DefaultGeographicBoundingBox();
        extent.getGeographicElements().add(bbox);
        identification.getExtents().add(extent);
View Full Code Here

TOP

Related Classes of org.apache.sis.metadata.iso.DefaultMetadata

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.