Search in sources :

Example 1 with DefaultLineage

use of org.apache.sis.metadata.iso.lineage.DefaultLineage in project sis by apache.

the class MetadataReader method read.

/**
 * Creates an ISO {@code Metadata} object from the information found in the netCDF file.
 *
 * @return the ISO metadata object.
 * @throws IOException if an I/O operation was necessary but failed.
 * @throws DataStoreException if a logical error occurred.
 */
public Metadata read() throws IOException, DataStoreException {
    addResourceScope(ScopeCode.DATASET, null);
    Set<InternationalString> publisher = addCitation();
    addIdentificationInfo(publisher);
    for (final String service : SERVICES) {
        final String name = stringValue(service);
        if (name != null) {
            addResourceScope(ScopeCode.SERVICE, name);
        }
    }
    addAcquisitionInfo();
    addContentInfo();
    /*
         * 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) {
            addSpatialRepresentationInfo(cs);
        }
    }
    addFileIdentifier();
    /*
         * Add history in Metadata.dataQualityInfo.lineage.statement as specified by UnidataDD2MI.xsl.
         * However Metadata.resourceLineage.statement could be a more appropriate place.
         * See https://issues.apache.org/jira/browse/SIS-361
         */
    final DefaultMetadata metadata = build(false);
    for (final String path : searchPath) {
        decoder.setSearchPath(path);
        DefaultLineage lineage = null;
        String value = stringValue(HISTORY);
        if (value != null) {
            lineage = new DefaultLineage();
            lineage.setStatement(new SimpleInternationalString(value));
        }
        value = stringValue(SOURCE);
        if (value != null) {
            if (lineage == null)
                lineage = new DefaultLineage();
            addIfAbsent(lineage.getSources(), new DefaultSource(value));
        }
        if (lineage != null) {
            final DefaultDataQuality quality = new DefaultDataQuality(ScopeCode.DATASET);
            quality.setLineage(lineage);
            addIfAbsent(metadata.getDataQualityInfo(), quality);
        }
    }
    decoder.setSearchPath(searchPath);
    metadata.setMetadataStandards(Citations.ISO_19115);
    addCompleteMetadata(createURI(stringValue(METADATA_LINK)));
    return metadata;
}
Also used : GridGeometry(org.apache.sis.internal.netcdf.GridGeometry) InternationalString(org.opengis.util.InternationalString) SimpleInternationalString(org.apache.sis.util.iso.SimpleInternationalString) SimpleInternationalString(org.apache.sis.util.iso.SimpleInternationalString) DefaultMetadata(org.apache.sis.metadata.iso.DefaultMetadata) DefaultSource(org.apache.sis.metadata.iso.lineage.DefaultSource) InternationalString(org.opengis.util.InternationalString) SimpleInternationalString(org.apache.sis.util.iso.SimpleInternationalString) DefaultLineage(org.apache.sis.metadata.iso.lineage.DefaultLineage) DefaultDataQuality(org.apache.sis.metadata.iso.quality.DefaultDataQuality)

Aggregations

GridGeometry (org.apache.sis.internal.netcdf.GridGeometry)1 DefaultMetadata (org.apache.sis.metadata.iso.DefaultMetadata)1 DefaultLineage (org.apache.sis.metadata.iso.lineage.DefaultLineage)1 DefaultSource (org.apache.sis.metadata.iso.lineage.DefaultSource)1 DefaultDataQuality (org.apache.sis.metadata.iso.quality.DefaultDataQuality)1 SimpleInternationalString (org.apache.sis.util.iso.SimpleInternationalString)1 InternationalString (org.opengis.util.InternationalString)1