sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1794136 [4/4] - in /sis/branches/JDK7: ./ core/sis-build-helper/src/main/java/org/apache/sis/internal/taglet/ core/sis-metadata/src/main/java/org/apache/sis/io/wkt/ core/sis-metadata/src/main/java/org/apache/sis/metadata/ core/sis-metadata...
Date Sat, 06 May 2017 12:09:41 GMT
Modified: sis/branches/JDK7/storage/sis-netcdf/src/test/java/org/apache/sis/storage/netcdf/MetadataReaderTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/storage/sis-netcdf/src/test/java/org/apache/sis/storage/netcdf/MetadataReaderTest.java?rev=1794136&r1=1794135&r2=1794136&view=diff
==============================================================================
--- sis/branches/JDK7/storage/sis-netcdf/src/test/java/org/apache/sis/storage/netcdf/MetadataReaderTest.java
[UTF-8] (original)
+++ sis/branches/JDK7/storage/sis-netcdf/src/test/java/org/apache/sis/storage/netcdf/MetadataReaderTest.java
[UTF-8] Sat May  6 12:09:41 2017
@@ -87,46 +87,35 @@ public final strictfp class MetadataRead
         assertMultilinesEquals(
             "Metadata\n" +
             "  ├─Contact\n" +
-            "  │   ├─Party\n" +
-            "  │   │   └─Name…………………………………………………………………………………
NOAA/NWS/NCEP\n" +
+            "  │   ├─Individual……………………………………………………………………………
NOAA/NWS/NCEP\n" +     // TODO: actually we can not distinguish individual from organization.
             "  │   └─Role……………………………………………………………………………………………
Point of contact\n" +
             "  ├─Spatial representation info\n" +
             "  │   ├─Number of dimensions…………………………………………………
3\n" +
-            "  │   ├─Axis dimension properties (1 of 3)\n" +
-            "  │   │   ├─Dimension name………………………………………………………
Column\n" +
+            "  │   ├─Axis dimension properties (1 of 3)…………… Column\n"
+
             "  │   │   └─Dimension size………………………………………………………
73\n" +
-            "  │   ├─Axis dimension properties (2 of 3)\n" +
-            "  │   │   ├─Dimension name………………………………………………………
Row\n" +
+            "  │   ├─Axis dimension properties (2 of 3)…………… Row\n"
+
             "  │   │   └─Dimension size………………………………………………………
73\n" +
-            "  │   ├─Axis dimension properties (3 of 3)\n" +
-            "  │   │   ├─Dimension name………………………………………………………
Time\n" +
+            "  │   ├─Axis dimension properties (3 of 3)…………… Time\n"
+
             "  │   │   └─Dimension size………………………………………………………
1\n" +
             "  │   ├─Cell geometry……………………………………………………………………
Area\n" +
             "  │   └─Transformation parameter availability…… false\n" +
             "  ├─Identification info\n" +
-            "  │   ├─Citation\n" +
-            "  │   │   ├─Title………………………………………………………………………………
Sea Surface Temperature Analysis Model\n" +
-            "  │   │   ├─Date\n" +
-            "  │   │   │   ├─Date………………………………………………………………………
2005-09-22 00:00:00\n" +
+            "  │   ├─Citation…………………………………………………………………………………
Sea Surface Temperature Analysis Model\n" +
+            "  │   │   ├─Date…………………………………………………………………………………
2005-09-22 00:00:00\n" +
             "  │   │   │   └─Date type…………………………………………………………
Creation\n" +
-            "  │   │   ├─Identifier\n" +
-            "  │   │   │   ├─Authority\n" +
-            "  │   │   │   │   └─Title…………………………………………………………
edu.ucar.unidata\n" +
-            "  │   │   │   └─Code………………………………………………………………………
NCEP/SST/Global_5x2p5deg/SST_Global_5x2p5deg_20050922_0000.nc\n" +
+            "  │   │   ├─Identifier…………………………………………………………………
NCEP/SST/Global_5x2p5deg/SST_Global_5x2p5deg_20050922_0000.nc\n" +
+            "  │   │   │   └─Authority…………………………………………………………
edu.ucar.unidata\n" +
             "  │   │   └─Cited responsible party\n" +
-            "  │   │       ├─Party\n" +
-            "  │   │       │   └─Name……………………………………………………………
NOAA/NWS/NCEP\n" +
+            "  │   │       ├─Individual………………………………………………………
NOAA/NWS/NCEP\n" +  // TODO: actually we can not distinguish individual from organization.
             "  │   │       └─Role………………………………………………………………………
Originator\n" +
             "  │   ├─Abstract…………………………………………………………………………………
NCEP SST Global 5.0 x 2.5 degree model data\n" +
             "  │   ├─Point of contact\n" +
-            "  │   │   ├─Party\n" +
-            "  │   │   │   └─Name………………………………………………………………………
NOAA/NWS/NCEP\n" +
+            "  │   │   ├─Individual…………………………………………………………………
NOAA/NWS/NCEP\n" +
             "  │   │   └─Role…………………………………………………………………………………
Point of contact\n" +
             "  │   ├─Descriptive keywords\n" +
             "  │   │   ├─Keyword…………………………………………………………………………
EARTH SCIENCE > Oceans > Ocean Temperature > Sea Surface Temperature\n" +
             "  │   │   ├─Type…………………………………………………………………………………
Theme\n" +
-            "  │   │   └─Thesaurus name\n" +
-            "  │   │       └─Title……………………………………………………………………
GCMD Science Keywords\n" +
+            "  │   │   └─Thesaurus name………………………………………………………
GCMD Science Keywords\n" +
             "  │   ├─Resource constraints\n" +
             "  │   │   └─Use limitation………………………………………………………
Freely available\n" +
             "  │   ├─Spatial representation type………………………………
Grid\n" +
@@ -142,8 +131,7 @@ public final strictfp class MetadataRead
             "  │           └─Maximum value………………………………………………
0.0\n" +
             "  ├─Content info\n" +
             "  │   └─Attribute group\n" +
-            "  │       └─Attribute\n" +
-            "  │           ├─Sequence identifier………………………………
SST\n" +
+            "  │       └─Attribute……………………………………………………………………
SST\n" +
             "  │           ├─Units……………………………………………………………………
K\n" +
             "  │           └─Description……………………………………………………
Sea temperature\n" +
             "  ├─Data quality info\n" +
@@ -152,32 +140,24 @@ public final strictfp class MetadataRead
             "              2005-09-26T21:50:00 - edavis - add attributes for dataset discovery\n"
+
             "  ├─Metadata scope\n" +
             "  │   └─Resource scope…………………………………………………………………
Dataset\n" +
-            "  ├─Metadata identifier\n" +
-            "  │   ├─Authority\n" +
-            "  │   │   └─Title………………………………………………………………………………
edu.ucar.unidata\n" +
-            "  │   └─Code……………………………………………………………………………………………
NCEP/SST/Global_5x2p5deg/SST_Global_5x2p5deg_20050922_0000.nc\n" +
-            "  ├─Metadata standard (1 of 2)\n" +
-            "  │   ├─Title…………………………………………………………………………………………
Geographic Information — Metadata Part 1: Fundamentals\n" +
+            "  ├─Metadata identifier………………………………………………………………
NCEP/SST/Global_5x2p5deg/SST_Global_5x2p5deg_20050922_0000.nc\n" +
+            "  │   └─Authority………………………………………………………………………………
edu.ucar.unidata\n" +
+            "  ├─Metadata standard (1 of 2)……………………………………………
Geographic Information — Metadata Part 1: Fundamentals\n" +
             "  │   ├─Edition……………………………………………………………………………………
ISO 19115-1:2014(E)\n" +
-            "  │   ├─Identifier\n" +
-            "  │   │   ├─Code…………………………………………………………………………………
19115-1\n" +
+            "  │   ├─Identifier……………………………………………………………………………
19115-1\n" +
             "  │   │   ├─Code space…………………………………………………………………
ISO\n" +
             "  │   │   └─Version…………………………………………………………………………
2014(E)\n" +
             "  │   ├─Cited responsible party\n" +
-            "  │   │   ├─Party\n" +
-            "  │   │   │   └─Name………………………………………………………………………
International Organization for Standardization\n" +
+            "  │   │   ├─Organisation……………………………………………………………
International Organization for Standardization\n" +
             "  │   │   └─Role…………………………………………………………………………………
Principal investigator\n" +
             "  │   └─Presentation form…………………………………………………………
Document digital\n" +
-            "  └─Metadata standard (2 of 2)\n" +
-            "      ├─Title…………………………………………………………………………………………
Geographic Information — Metadata Part 2: Extensions for imagery and gridded data\n" +
+            "  └─Metadata standard (2 of 2)……………………………………………
Geographic Information — Metadata Part 2: Extensions for imagery and gridded data\n" +
             "      ├─Edition……………………………………………………………………………………
ISO 19115-2:2009(E)\n" +
-            "      ├─Identifier\n" +
-            "      │   ├─Code…………………………………………………………………………………
19115-2\n" +
+            "      ├─Identifier……………………………………………………………………………
19115-2\n" +
             "      │   ├─Code space…………………………………………………………………
ISO\n" +
             "      │   └─Version…………………………………………………………………………
2009(E)\n" +
             "      ├─Cited responsible party\n" +
-            "      │   ├─Party\n" +
-            "      │   │   └─Name………………………………………………………………………
International Organization for Standardization\n" +
+            "      │   ├─Organisation……………………………………………………………
International Organization for Standardization\n" +
             "      │   └─Role…………………………………………………………………………………
Principal investigator\n" +
             "      └─Presentation form…………………………………………………………
Document digital\n", text);
     }

Modified: sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/wkt/Store.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/wkt/Store.java?rev=1794136&r1=1794135&r2=1794136&view=diff
==============================================================================
--- sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/wkt/Store.java
[UTF-8] (original)
+++ sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/wkt/Store.java
[UTF-8] Sat May  6 12:09:41 2017
@@ -26,23 +26,25 @@ import java.io.IOException;
 import java.text.ParsePosition;
 import java.text.ParseException;
 import org.opengis.metadata.Metadata;
+import org.opengis.util.FactoryException;
 import org.opengis.referencing.ReferenceSystem;
+import org.opengis.referencing.crs.CoordinateReferenceSystem;
 import org.apache.sis.internal.storage.Resources;
+import org.apache.sis.internal.system.Loggers;
 import org.apache.sis.io.wkt.WKTFormat;
 import org.apache.sis.io.wkt.Warnings;
 import org.apache.sis.storage.DataStore;
 import org.apache.sis.storage.StorageConnector;
 import org.apache.sis.storage.DataStoreException;
 import org.apache.sis.storage.DataStoreContentException;
+import org.apache.sis.internal.referencing.DefinitionVerifier;
 import org.apache.sis.metadata.iso.DefaultMetadata;
 import org.apache.sis.util.resources.Errors;
 import org.apache.sis.util.CharSequences;
-import org.apache.sis.referencing.CRS;
 
 
 /**
  * A data store which creates data objects from a WKT definition.
- * This {@code DataStore} implementation is basically a facade for the {@link CRS#fromWKT(String)}
method.
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @version 0.8
@@ -118,17 +120,35 @@ final class Store extends DataStore {
             } finally {
                 in.close();
             }
+            /*
+             * At this point we copied all the file content into a String. This string usually
contain exactly
+             * one WKT definitions, but this DataStore nevertheless allows an arbitrary number
of consecutive
+             * definitions.
+             */
             final ParsePosition pos = new ParsePosition(0);
             final WKTFormat parser = new WKTFormat(null, null);
             do {
-                objects.add(parser.parse(wkt, pos));
+                final Object obj = parser.parse(wkt, pos);
+                objects.add(obj);
                 pos.setIndex(CharSequences.skipLeadingWhitespaces(wkt, pos.getIndex(), wkt.length()));
                 final Warnings warnings = parser.getWarnings();
                 if (warnings != null) {
-                    final LogRecord record = new LogRecord(Level.WARNING, warnings.toString());
-                    record.setSourceClassName(Store.class.getName());
-                    record.setSourceMethodName("getMetadata");          // Public facade
for this method.
-                    listeners.warning(record);
+                    log(new LogRecord(Level.WARNING, warnings.toString()));
+                }
+                /*
+                 * The WKT has been parsed. Below is a verification of whether the parsed
WKT is conform with
+                 * the authority definition (if an authority code has been specified). This
verification is not
+                 * really necessary since we will use the WKT definition anyway even if we
find discrepancies.
+                 * But non-conform WKT definitions happen so often in practice that we are
better to check.
+                 */
+                if (obj instanceof CoordinateReferenceSystem) try {
+                    final DefinitionVerifier v = DefinitionVerifier.withAuthority((CoordinateReferenceSystem)
obj, null, false);
+                    if (v != null) {
+                        final LogRecord warning = v.warning(false);
+                        if (warning != null) log(warning);
+                    }
+                } catch (FactoryException e) {
+                    listeners.warning(null, e);
                 }
             } while (pos.getIndex() < wkt.length());
         } catch (ParseException e) {
@@ -139,6 +159,16 @@ final class Store extends DataStore {
     }
 
     /**
+     * Reports a warning.
+     */
+    private void log(final LogRecord record) {
+        record.setSourceClassName(Store.class.getName());
+        record.setSourceMethodName("getMetadata");          // Public facade for the parse()
method.
+        record.setLoggerName(Loggers.WKT);
+        listeners.warning(record);
+    }
+
+    /**
      * Returns the metadata associated to the parsed objects, or {@code null} if none.
      * The current implementation retains only instances of {@link ReferenceSystem}
      * and ignore other cases.

Modified: sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/xml/Store.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/xml/Store.java?rev=1794136&r1=1794135&r2=1794136&view=diff
==============================================================================
--- sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/xml/Store.java
[UTF-8] (original)
+++ sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/xml/Store.java
[UTF-8] Sat May  6 12:09:41 2017
@@ -26,7 +26,9 @@ import java.io.IOException;
 import javax.xml.bind.JAXBException;
 import javax.xml.transform.stream.StreamSource;
 import org.opengis.metadata.Metadata;
+import org.opengis.util.FactoryException;
 import org.opengis.referencing.ReferenceSystem;
+import org.opengis.referencing.crs.CoordinateReferenceSystem;
 import org.apache.sis.xml.XML;
 import org.apache.sis.storage.DataStore;
 import org.apache.sis.storage.StorageConnector;
@@ -34,6 +36,8 @@ import org.apache.sis.storage.DataStoreE
 import org.apache.sis.metadata.iso.DefaultMetadata;
 import org.apache.sis.util.logging.WarningListener;
 import org.apache.sis.util.resources.Errors;
+import org.apache.sis.internal.system.Loggers;
+import org.apache.sis.internal.referencing.DefinitionVerifier;
 
 import static java.util.Collections.singleton;
 
@@ -124,6 +128,7 @@ final class Store extends DataStore {
 
                 /** Reports the occurrence of a non-fatal error during XML unmarshalling.
*/
                 @Override public void warningOccured(final Object source, final LogRecord
warning) {
+                    warning.setLoggerName(Loggers.XML);
                     listeners.warning(warning);
                 }
             });
@@ -150,6 +155,26 @@ final class Store extends DataStore {
         } catch (JAXBException | IOException e) {
             throw new DataStoreException(Errors.format(Errors.Keys.CanNotRead_1, getDisplayName()),
e);
         }
+        if (object instanceof CoordinateReferenceSystem) try {
+            final DefinitionVerifier v = DefinitionVerifier.withAuthority((CoordinateReferenceSystem)
object, null, false);
+            if (v != null) {
+                log(v.warning(false));
+            }
+        } catch (FactoryException e) {
+            listeners.warning(null, e);
+        }
+    }
+
+    /**
+     * Reports a warning, if non-null.
+     */
+    private void log(final LogRecord record) {
+        if (record != null) {
+            record.setSourceClassName(Store.class.getName());
+            record.setSourceMethodName("getMetadata");          // Public facade for the
parse() method.
+            record.setLoggerName(Loggers.XML);
+            listeners.warning(record);
+        }
     }
 
     /**

Modified: sis/branches/JDK7/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/xml/stream/StaxDataStore.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/xml/stream/StaxDataStore.java?rev=1794136&r1=1794135&r2=1794136&view=diff
==============================================================================
--- sis/branches/JDK7/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/xml/stream/StaxDataStore.java
[UTF-8] (original)
+++ sis/branches/JDK7/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/xml/stream/StaxDataStore.java
[UTF-8] Sat May  6 12:09:41 2017
@@ -335,7 +335,8 @@ public abstract class StaxDataStore exte
         @Override
         public void report(String message, String errorType, Object info, Location location)
{
             final LogRecord record = new LogRecord(Level.WARNING, message);
-            record.setSourceClassName(getClass().getCanonicalName());
+            record.setSourceClassName(StaxDataStore.this.getClass().getCanonicalName());
+            // record.setLoggerName(…) will be invoked by 'listeners' with inferred name.
             listeners.warning(record);
         }
 
@@ -347,6 +348,7 @@ public abstract class StaxDataStore exte
          */
         @Override
         public void warningOccured(final Object source, final LogRecord warning) {
+            warning.setLoggerName(null);        // For allowing 'listeners' to select a logger
name.
             listeners.warning(warning);
         }
 



Mime
View raw message