sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1723870 - in /sis/branches/JDK8/core: sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/ sis-referencing/src/test/java/org/apache/sis/referencing/factory/sql/ sis-utility/src/main/java/org/apache/sis/internal/util/
Date Sat, 09 Jan 2016 18:18:23 GMT
Author: desruisseaux
Date: Sat Jan  9 18:18:22 2016
New Revision: 1723870

URL: http://svn.apache.org/viewvc?rev=1723870&view=rev
Log:
EPSGDataAccess.getAuthorityCodes() should exclude the code of deprecated objects.

Added:
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/package-info.java
  (with props)
Modified:
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/AuthorityCodes.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGDataAccess.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/TableInfo.java
    sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/sql/EPSGFactoryTest.java
    sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/util/AbstractMap.java

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/AuthorityCodes.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/AuthorityCodes.java?rev=1723870&r1=1723869&r2=1723870&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/AuthorityCodes.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/AuthorityCodes.java
[UTF-8] Sat Jan  9 18:18:22 2016
@@ -149,18 +149,19 @@ final class AuthorityCodes extends Abstr
                 final Class<?> candidate = table.subTypes[i];
                 if (candidate.isAssignableFrom(type)) {
                     buffer.append(" WHERE (").append(table.typeColumn)
-                          .append(" LIKE '").append(table.typeNames[i]).append("%'");
+                          .append(" LIKE '").append(table.typeNames[i]).append("%')");
                     hasWhere = true;
                     tableType = candidate;
                     break;
                 }
             }
-            if (hasWhere) {
-                buffer.append(')');
-            }
         }
+        buffer.append(hasWhere ? " AND " : " WHERE ");
         final int conditionStart = buffer.length();
-        buffer.append(" ORDER BY ABS(DEPRECATED), ").append(table.codeColumn);
+        if (table.showColumn != null) {
+            buffer.append(table.showColumn).append("<>0 AND ");
+        }
+        buffer.append("DEPRECATED=0 ORDER BY ").append(table.codeColumn);
         sql[ALL] = factory.translator.apply(buffer.toString());
         /*
          * Build the SQL query for fetching the name of a single object for a given code.
@@ -172,7 +173,7 @@ final class AuthorityCodes extends Abstr
         if (table.nameColumn != null) {
             buffer.replace(columnNameStart, columnNameEnd, table.nameColumn);
         }
-        buffer.append(hasWhere ? " AND " : " WHERE ").append(table.codeColumn).append(" =
?");
+        buffer.append(table.codeColumn).append(" = ?");
         sql[ONE] = factory.translator.apply(buffer.toString());
         /*
          * Other information opportunistically computed from above search.

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGDataAccess.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGDataAccess.java?rev=1723870&r1=1723869&r2=1723870&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGDataAccess.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGDataAccess.java
[UTF-8] Sat Jan  9 18:18:22 2016
@@ -258,6 +258,13 @@ public class EPSGDataAccess extends Geod
     private final Map<Integer,Class<?>> safetyGuard = new HashMap<>();
 
     /**
+     * {@code true} for disabling the logging of warnings when this factory creates deprecated
objects.
+     * This flag should be always {@code false}, except during {@link Finder#find(IdentifiedObject)}
+     * execution since that method may temporarily creates deprecated objects which are later
discarded.
+     */
+    private transient boolean quiet;
+
+    /**
      * The {@code ConcurrentAuthorityFactory} that supply caching for all {@code createFoo(String)}
methods.
      */
     protected final EPSGFactory parent;
@@ -419,6 +426,16 @@ addURIs:    for (int i=0; ; i++) {
      * JDBC resources. If the set of codes is needed for a long time, their values should
be copied in another
      * collection object.
      *
+     * <div class="section">Handling of deprecated objects</div>
+     * The collection returned by this method gives an enumeration of EPSG codes for valid
objects only.
+     * The EPSG codes of deprecated objects are not included in iterations, computation of
{@code Set.size()} value,
+     * {@code Set.toString()} result, <i>etc.</i> with one exception:
+     * a call to {@code Set.contains(…)} will return {@code true} if the given identifier
exists
+     * for a deprecated object, even if that identifier does not show up in iterations.
+     *
+     * <p>An other point of view could be to said that the returned collection behaves
as if the deprecated codes
+     * were included in the set but invisible.</p>
+     *
      * @param  type The spatial reference objects type (may be {@code Object.class}).
      * @return The set of authority codes for spatial reference objects of the given type
(may be an empty set).
      * @throws FactoryException if access to the underlying database failed.
@@ -936,10 +953,12 @@ addURIs:    for (int i=0; ; i++) {
                 break;
             }
         }
-        LogRecord record = Messages.getResources(locale).getLogRecord(Level.WARNING, Messages.Keys.DeprecatedCode_3,
-                Constants.EPSG + DefaultNameSpace.DEFAULT_SEPARATOR + code, replacedBy, reason);
-        record.setLoggerName(Loggers.CRS_FACTORY);
-        Logging.log(EPSGDataAccess.class, method, record);
+        if (!quiet) {
+            LogRecord record = Messages.getResources(locale).getLogRecord(Level.WARNING,
Messages.Keys.DeprecatedCode_3,
+                    Constants.EPSG + DefaultNameSpace.DEFAULT_SEPARATOR + code, replacedBy,
reason);
+            record.setLoggerName(Loggers.CRS_FACTORY);
+            Logging.log(EPSGDataAccess.class, method, record);
+        }
         return Vocabulary.formatInternational(Vocabulary.Keys.SupersededBy_1, replacedBy);
     }
 
@@ -1514,12 +1533,13 @@ addURIs:    for (int i=0; ; i++) {
                       " COORD_OP_METHOD_CODE," +
                       " TARGET_CRS_CODE" +
                 " FROM [Coordinate_Operation]" +
-               " WHERE TARGET_CRS_CODE = "       + BursaWolfInfo.TARGET_CRS +
+               " WHERE DEPRECATED=0" +
+                 " AND TARGET_CRS_CODE = "       + BursaWolfInfo.TARGET_CRS +
                  " AND COORD_OP_METHOD_CODE >= " + BursaWolfInfo.MIN_METHOD_CODE +
                  " AND COORD_OP_METHOD_CODE <= " + BursaWolfInfo.MAX_METHOD_CODE +
                  " AND SOURCE_CRS_CODE IN " +
                "(SELECT COORD_REF_SYS_CODE FROM [Coordinate Reference System] WHERE DATUM_CODE
= ?)" +
-            " ORDER BY TARGET_CRS_CODE, ABS(DEPRECATED), COORD_OP_ACCURACY, COORD_OP_CODE
DESC", code))
+            " ORDER BY TARGET_CRS_CODE, COORD_OP_ACCURACY, COORD_OP_CODE DESC", code))
         {
             while (result.next()) {
                 final BursaWolfInfo info = new BursaWolfInfo(
@@ -2763,6 +2783,20 @@ addURIs:    for (int i=0; ; i++) {
         }
 
         /**
+         * Searches for the given object with warnings for deprecations temporarily disabled.
+         */
+        @Override
+        public Set<IdentifiedObject> find(final IdentifiedObject object) throws FactoryException
{
+            final boolean old = quiet;
+            quiet = true;
+            try {
+                return super.find(object);
+            } finally {
+                quiet = old;
+            }
+        }
+
+        /**
          * Returns a set of authority codes that <strong>may</strong> identify
the same object than the specified one.
          * This implementation tries to get a smaller set than what {@link EPSGDataAccess#getAuthorityCodes()}
would produce.
          * Deprecated objects must be last in iteration order.

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/TableInfo.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/TableInfo.java?rev=1723870&r1=1723869&r2=1723870&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/TableInfo.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/TableInfo.java
[UTF-8] Sat Jan  9 18:18:22 2016
@@ -56,7 +56,8 @@ final class TableInfo {
                 new Class<?>[] { ProjectedCRS.class, GeographicCRS.class, GeocentricCRS.class,
                                  VerticalCRS.class,  CompoundCRS.class,   EngineeringCRS.class},
                 new String[]   {"projected",        "geographic",        "geocentric",
-                                "vertical",         "compound",          "engineering"}),
+                                "vertical",         "compound",          "engineering"},
+                "SHOW_CRS"),
 
         new TableInfo(CoordinateSystem.class,
                 "[Coordinate System]",
@@ -64,13 +65,15 @@ final class TableInfo {
                 "COORD_SYS_NAME",
                 "COORD_SYS_TYPE",
                 new Class<?>[] { CartesianCS.class, EllipsoidalCS.class, SphericalCS.class,
VerticalCS.class},
-                new String[]   {"Cartesian",       "ellipsoidal",       "spherical",    
  "vertical"}),
-                               //Really upper-case C.
+                new String[]   {"Cartesian",       "ellipsoidal",       "spherical",    
  "vertical"},    //Really upper-case C.
+                null),
+
         new TableInfo(CoordinateSystemAxis.class,
                 "[Coordinate Axis] AS CA INNER JOIN [Coordinate Axis Name] AS CAN" +
                                  " ON CA.COORD_AXIS_NAME_CODE=CAN.COORD_AXIS_NAME_CODE",
                 "COORD_AXIS_CODE",
-                "COORD_AXIS_NAME"),
+                "COORD_AXIS_NAME",
+                null, null, null, null),
 
         new TableInfo(Datum.class,
                 "[Datum]",
@@ -78,17 +81,20 @@ final class TableInfo {
                 "DATUM_NAME",
                 "DATUM_TYPE",
                 new Class<?>[] { GeodeticDatum.class, VerticalDatum.class, EngineeringDatum.class},
-                new String[]   {"geodetic",          "vertical",          "engineering"}),
+                new String[]   {"geodetic",          "vertical",          "engineering"},
+                null),
 
         new TableInfo(Ellipsoid.class,
                 "[Ellipsoid]",
                 "ELLIPSOID_CODE",
-                "ELLIPSOID_NAME"),
+                "ELLIPSOID_NAME",
+                null, null, null, null),
 
         new TableInfo(PrimeMeridian.class,
                 "[Prime Meridian]",
                 "PRIME_MERIDIAN_CODE",
-                "PRIME_MERIDIAN_NAME"),
+                "PRIME_MERIDIAN_NAME",
+                null, null, null, null),
 
         new TableInfo(CoordinateOperation.class,
                 "[Coordinate_Operation]",
@@ -96,23 +102,27 @@ final class TableInfo {
                 "COORD_OP_NAME",
                 "COORD_OP_TYPE",
                 new Class<?>[] { Projection.class, Conversion.class, Transformation.class},
-                new String[]   {"conversion",     "conversion",     "transformation"}),
+                new String[]   {"conversion",     "conversion",     "transformation"},
+                "SHOW_OPERATION"),
                 // Note: Projection is handled in a special way.
 
         new TableInfo(OperationMethod.class,
                 "[Coordinate_Operation Method]",
                 "COORD_OP_METHOD_CODE",
-                "COORD_OP_METHOD_NAME"),
+                "COORD_OP_METHOD_NAME",
+                null, null, null, null),
 
         new TableInfo(ParameterDescriptor.class,
                 "[Coordinate_Operation Parameter]",
                 "PARAMETER_CODE",
-                "PARAMETER_NAME"),
+                "PARAMETER_NAME",
+                null, null, null, null),
 
         new TableInfo(Unit.class,
                 "[Unit of Measure]",
                 "UOM_CODE",
-                "UNIT_OF_MEAS_NAME")
+                "UNIT_OF_MEAS_NAME",
+                null, null, null, null),
     };
 
     /**
@@ -151,20 +161,17 @@ final class TableInfo {
     final String[] typeNames;
 
     /**
-     * Stores information about a specific table.
+     * The column that specify if the object should be shown, or {@code null} if none.
      */
-    private TableInfo(final Class<?> type, final String table,
-                      final String codeColumn, final String nameColumn)
-    {
-        this(type, table, codeColumn, nameColumn, null, null, null);
-    }
+    final String showColumn;
 
     /**
      * Stores information about a specific table.
      */
     private TableInfo(final Class<?> type,
                       final String table, final String codeColumn, final String nameColumn,
-                      final String typeColumn, final Class<?>[] subTypes, final String[]
typeNames)
+                      final String typeColumn, final Class<?>[] subTypes, final String[]
typeNames,
+                      final String showColumn)
     {
         this.type       = type;
         this.table      = table;
@@ -173,5 +180,6 @@ final class TableInfo {
         this.typeColumn = typeColumn;
         this.subTypes   = subTypes;
         this.typeNames  = typeNames;
+        this.showColumn = showColumn;
     }
 }

Added: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/package-info.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/package-info.java?rev=1723870&view=auto
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/package-info.java
(added)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/package-info.java
[UTF-8] Sat Jan  9 18:18:22 2016
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * Factories for geodetic objects defined in a SQL database.
+ * Every classes in this package require a connection to a database, which may be on Apache
Derby (a.k.a. JavaDB),
+ * PostgreSQL or MS-Access. The connection is obtained by the first of the following data
sources which is found:
+ *
+ * <ol>
+ *   <li>If a {@linkplain javax.naming.InitialContext JNDI context} exists,
+ *       the {@link javax.sql.DataSource} registered under the {@code "java:comp/env/jdbc/SpatialMetadata"}
name.</li>
+ *   <li>If the {@code SIS_DATA} {@linkplain System#getenv(String) environment variable}
is defined,
+ *       a JDBC connection for the {@code "jdbc:derby:$SIS_DATA/Databases/SpatialMetadata"}
URL.</li>
+ *   <li>If the {@code "derby.system.home"} {@linkplain System#getProperty(String)
property} is defined,
+ *       a JDBC connection for the {@code "jdbc:derby:SpatialMetadata"} URL.</li>
+ * </ol>
+ *
+ * In choice 1, the JDBC driver must be provided by the application container (e.g. Apache
Tomcat).
+ * In choice 2 and 3, Apache SIS tries to use the JavaDB driver in the JDK installation directory
+ * (included in Oracle's distribution of Java) if no Apache Derby driver is found on the
classpath.
+ *
+ *
+ * <div class="section">The EPSG dataset</div>
+ * A widely-used factory is the <a href="http://www.epsg.org">EPSG geodetic dataset</a>.
+ * EPSG codes are numerical identifiers.
+ * For example {@code "EPSG::4326"} is the EPSG identifier for the <cite>"WGS 84"</cite>
geographic CRS.
+ * However, the Apache SIS implementation accepts names as well as numeric identifiers.
+ * For example {@code createProjectedCRS("NTF (Paris) / Lambert zone II")} and {@code createProjectedCRS("27572")}
+ * both fetch the same object. However names may be ambiguous since the same name may be
used for more than one object.
+ * This is the case of <cite>"WGS 84"</cite> for example. If such an ambiguity
is found, an exception will be thrown.
+ *
+ * <p>When an error is discovered in a Coordinate Reference System definition, the
EPSG group does not apply the
+ * correction directly on the erroneous object (unless the correction is very minor).
+ * Instead, the erroneous object is deprecated and a new one is created.
+ * Apache SIS handles deprecated objects as below:</p>
+ *
+ * <ul>
+ *   <li>Deprecated objects are not listed in the collection returned by the
+ *       {@link org.apache.sis.referencing.factory.sql.EPSGDataAccess#getAuthorityCodes getAuthorityCodes(…)}
method.</li>
+ *   <li>However if the code of a deprecated object is given directly to {@code getAuthorityCodes(…).contains(…)},
+ *       {@code getDescriptionText(…)} or any {@code createFoo(…)} method, it will be
recognized.</li>
+ *   <li>If a deprecated object is created by a call to {@code createFoo(…)}, a warning
will be logged
+ *       with a message proposing a replacement.</li>
+ * </ul>
+ *
+ * @author  Martin Desruisseaux (IRD, Geomatys)
+ * @author  Yann Cézard (IRD)
+ * @author  Rueben Schulz (UBC)
+ * @author  Matthias Basler
+ * @author  Andrea Aime (TOPP)
+ * @author  Jody Garnett (Refractions)
+ * @author  Didier Richard (IGN)
+ * @author  John Grange
+ * @version 0.7
+ * @since   0.7
+ * @module
+ */
+package org.apache.sis.referencing.factory.sql;

Propchange: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/package-info.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/package-info.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain;charset=UTF-8

Modified: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/sql/EPSGFactoryTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/sql/EPSGFactoryTest.java?rev=1723870&r1=1723869&r2=1723870&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/sql/EPSGFactoryTest.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/sql/EPSGFactoryTest.java
[UTF-8] Sat Jan  9 18:18:22 2016
@@ -23,14 +23,18 @@ import java.util.Iterator;
 import java.util.Collections;
 import javax.measure.unit.Unit;
 import org.opengis.metadata.extent.GeographicBoundingBox;
+import org.opengis.parameter.ParameterDescriptor;
 import org.opengis.parameter.ParameterValueGroup;
 import org.opengis.referencing.IdentifiedObject;
 import org.opengis.referencing.NoSuchAuthorityCodeException;
 import org.opengis.referencing.crs.*;
 import org.opengis.referencing.cs.AxisDirection;
 import org.opengis.referencing.cs.CoordinateSystem;
+import org.opengis.referencing.cs.CoordinateSystemAxis;
 import org.opengis.referencing.datum.Datum;
+import org.opengis.referencing.datum.Ellipsoid;
 import org.opengis.referencing.datum.GeodeticDatum;
+import org.opengis.referencing.datum.PrimeMeridian;
 import org.opengis.referencing.datum.VerticalDatum;
 import org.opengis.referencing.operation.Conversion;
 import org.opengis.referencing.operation.Transformation;
@@ -558,6 +562,30 @@ public final strictfp class EPSGFactoryT
     public void testAuthorityCodes() throws FactoryException {
         assumeNotNull(factory);
         /*
+         * Most basic objects.
+         * Note: the numbers in 'size() >= x' checks were determined from the content
of EPSG dataset version 7.9.
+         */
+        final Set<String> axes = factory.getAuthorityCodes(CoordinateSystemAxis.class);
+        assertFalse("Axes not found.",              axes.isEmpty());
+        assertTrue ("Shall contain Geocentric X.",  axes.contains("115"));
+
+        final Set<String> coordinateSystems = factory.getAuthorityCodes(CoordinateSystem.class);
+        assertFalse("Coordinate systems not found.",  coordinateSystems.isEmpty());
+        assertTrue ("Shall contain ellipsoidal CS.",  coordinateSystems.contains("6422"));
+
+        final Set<String> primeMeridians = factory.getAuthorityCodes(PrimeMeridian.class);
+        assertFalse("Prime meridian not found.",  primeMeridians.isEmpty());
+        assertTrue ("Check size() consistency.",  primeMeridians.size() >= 14);
+        assertTrue ("Shall contain Greenwich.",   primeMeridians.contains("8901"));
+        assertTrue ("Shall contain Paris.",       primeMeridians.contains("8903"));
+
+        final Set<String> ellipsoids = factory.getAuthorityCodes(Ellipsoid.class);
+        assertFalse("Ellipsoid not found.",       ellipsoids.isEmpty());
+        assertTrue ("Check size() consistency.",  ellipsoids.size() >= 49);
+        assertTrue ("Shall contain WGS84.",       ellipsoids.contains("7030"));
+        assertTrue ("Shall contain GRS 1980.",    ellipsoids.contains("7019"));
+
+        /*
          * DATUM - The amount of datum is not too large (612 in EPSG 7.9), so execution time
should be reasonable
          *         for most tests even if a method call causes scanning of the whole Datum
table. We nevertheless
          *         limit such tests to the VerticalDatum (unless EXTENSIVE is true), which
is a smaller set.
@@ -575,14 +603,14 @@ public final strictfp class EPSGFactoryT
 
         final Set<String> verticalDatum = factory.getAuthorityCodes(VerticalDatum.class);
         assertFalse("Vertical datum not found.",                    verticalDatum.isEmpty());
-        assertTrue ("Check size() consistency.",                    verticalDatum.size()
> 0);          // Cause a scanning of the full table.
+        assertTrue ("Check size() consistency.",                    verticalDatum.size()
>= 124);       // Cause a scanning of the full table.
         assertFalse("Shall not contain WGS84.",                     verticalDatum.contains("6326"));
         assertTrue ("Shall contain Mean Sea Level (MSL).",          verticalDatum.contains("5100"));
         assertFalse("Vertical datum should be a subset of datum.",  verticalDatum.containsAll(datum));
 // Iteration should stop at the first mismatch.
         assertTrue ("Vertical datum should be a subset of datum.",  datum.containsAll(verticalDatum));
 // Iteration should over a small set (vertical datum).
 
         if (RUN_EXTENSIVE_TESTS) {
-            assertTrue ("Check size() consistency.",                    geodeticDatum.size()
> 0);
+            assertTrue ("Check size() consistency.",                    geodeticDatum.size()
>= 445);
             assertTrue ("Geodetic datum should be a subset of datum.",  datum.size() >
geodeticDatum.size());
             assertTrue ("Vertical datum should be a subset of datum.",  datum.size() >
verticalDatum.size());
             assertTrue ("Geodetic datum should be a subset of datum.",  datum.containsAll(geodeticDatum));
@@ -597,7 +625,7 @@ public final strictfp class EPSGFactoryT
         assertTrue  ("Shall contain WGS84.",           crs.contains("4326"));
         assertTrue  ("Shall contain World Mercator.",  crs.contains("3395"));
         if (RUN_EXTENSIVE_TESTS) {
-            assertTrue  ("Check size() consistency.",  crs.size() > 0);         // Cause
a scanning of the full table.
+            assertTrue  ("Check size() consistency.",  crs.size() >= 4175);      // Cause
a scanning of the full table.
             assertEquals("Check size() consistency.",  crs.size(), crs.size());
         }
 
@@ -606,7 +634,7 @@ public final strictfp class EPSGFactoryT
         assertTrue ("Shall contain WGS84.",              geographicCRS.contains("4326"));
         assertFalse("Shall not contain projected CRS.",  geographicCRS.contains("3395"));
         if (RUN_EXTENSIVE_TESTS) {
-            assertTrue ("Check size() consistency.",                  geographicCRS.size()
> 0);
+            assertTrue ("Check size() consistency.",                  geographicCRS.size()
>= 468);
             assertTrue ("Geographic CRS should be a subset of CRS.",  geographicCRS.size()
< crs.size());
             assertFalse("Geographic CRS should be a subset of CRS.",  geographicCRS.containsAll(crs));
             assertTrue ("Geographic CRS should be a subset of CRS.",  crs.containsAll(geographicCRS));
@@ -617,7 +645,7 @@ public final strictfp class EPSGFactoryT
         assertFalse("Shall not contain geographic CRS.",  projectedCRS.contains("4326"));
         assertTrue ("Shall contain World Mercator.",      projectedCRS.contains("3395"));
         if (RUN_EXTENSIVE_TESTS) {
-            assertTrue ("Check size() consistency.",                 projectedCRS.size()
> 0);
+            assertTrue ("Check size() consistency.",                 projectedCRS.size()
>= 3441);
             assertTrue ("Projected CRS should be a subset of CRS.",  projectedCRS.size()
< crs.size());
             assertFalse("Projected CRS should be a subset of CRS.",  projectedCRS.containsAll(crs));
             assertTrue ("Projected CRS should be a subset of CRS.",  crs.containsAll(projectedCRS));
@@ -628,16 +656,22 @@ public final strictfp class EPSGFactoryT
          * COORDINATE OPERATIONS - There is thousands of operations, so we avoid all tests
that may require
          *                         an iteration over the full table unless EXTENSIVE is true.
          */
-        final Set<String> operations      = factory.getAuthorityCodes(SingleOperation.class);
-        final Set<String> conversions     = factory.getAuthorityCodes(Conversion  
  .class);
-        final Set<String> projections     = factory.getAuthorityCodes(Projection  
  .class);
-        final Set<String> transformations = factory.getAuthorityCodes(Transformation
.class);
+        final Set<String> methods         = factory.getAuthorityCodes(OperationMethod
   .class);
+        final Set<String> parameters      = factory.getAuthorityCodes(ParameterDescriptor.class);
+        final Set<String> operations      = factory.getAuthorityCodes(SingleOperation
   .class);
+        final Set<String> conversions     = factory.getAuthorityCodes(Conversion  
      .class);
+        final Set<String> projections     = factory.getAuthorityCodes(Projection  
      .class);
+        final Set<String> transformations = factory.getAuthorityCodes(Transformation
    .class);
 
+        assertFalse("Methods not found.",          methods        .isEmpty());
+        assertFalse("Parameters not found.",       parameters     .isEmpty());
         assertFalse("Operations not found.",       operations     .isEmpty());
         assertFalse("Conversions not found.",      conversions    .isEmpty());
         assertFalse("Projections not found.",      projections    .isEmpty());
         assertFalse("Transformations not found.",  transformations.isEmpty());
 
+        assertTrue ("Shall contain “Mercator 1SP”",                    methods.contains("9804"));
+        assertTrue ("Shall contain “Scale factor”",                 parameters.contains("8805"));
         assertTrue ("Shall contain “ED50 to WGS 84 (1)”",           operations.contains("1133"));
         assertFalse("Shall not contain “ED50 to WGS 84 (1)”",      conversions.contains("1133"));
         assertFalse("Shall not contain “ED50 to WGS 84 (1)”",      projections.contains("1133"));
@@ -898,7 +932,7 @@ public final strictfp class EPSGFactoryT
         /*
          * Scan the database for searching the CRS.
          */
-        finder.setSearchDomain(IdentifiedObjectFinder.Domain.VALID_DATASET);
+        finder.setSearchDomain(IdentifiedObjectFinder.Domain.ALL_DATASET);
         final IdentifiedObject found = finder.findSingleton(crs);
         assertNotNull("With full scan allowed, the CRS should be found.", found);
         assertEpsgNameAndIdentifierEqual("WGS 84", 4326, found);

Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/util/AbstractMap.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/util/AbstractMap.java?rev=1723870&r1=1723869&r2=1723870&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/util/AbstractMap.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/util/AbstractMap.java
[UTF-8] Sat Jan  9 18:18:22 2016
@@ -388,6 +388,29 @@ public abstract class AbstractMap<K,V> i
                 final EntryIterator<K,V> it = entryIterator();
                 return (it != null) ? new Keys<>(it) : Collections.emptyIterator();
             }
+
+            /** Overridden for the same reason than {@link AbstractMap#equals(Object). */
+            @Override public boolean equals(final Object object) {
+                if (object == this) {
+                    return true;
+                }
+                if (!(object instanceof Set<?>)) {
+                    return false;
+                }
+                final Set<?> that = (Set<?>) object;
+                final EntryIterator<K,V> it = entryIterator();
+                if (it == null) {
+                    return that.isEmpty();
+                }
+                int size = 0;
+                while (it.next()) {
+                    if (!that.contains(it.getKey())) {
+                        return false;
+                    }
+                    size++;
+                }
+                return size == that.size();
+            }
         };
     }
 
@@ -447,6 +470,29 @@ public abstract class AbstractMap<K,V> i
                 final EntryIterator<K,V> it = entryIterator();
                 return (it != null) ? new Entries<>(it) : Collections.emptyIterator();
             }
+
+            /** Overridden for the same reason than {@link AbstractMap#equals(Object). */
+            @Override public boolean equals(final Object object) {
+                if (object == this) {
+                    return true;
+                }
+                if (!(object instanceof Set<?>)) {
+                    return false;
+                }
+                final Set<?> that = (Set<?>) object;
+                final EntryIterator<K,V> it = entryIterator();
+                if (it == null) {
+                    return that.isEmpty();
+                }
+                int size = 0;
+                while (it.next()) {
+                    if (!that.contains(it.getEntry())) {
+                        return false;
+                    }
+                    size++;
+                }
+                return size == that.size();
+            }
         };
     }
 
@@ -557,27 +603,27 @@ public abstract class AbstractMap<K,V> i
         if (object == this) {
             return true;
         }
-        if (object instanceof Map) {
-            final Map<?,?> map = (Map<?,?>) object;
-            final EntryIterator<K,V> it = entryIterator();
-            if (it == null) {
-                return map.isEmpty();
-            }
-            /*
-             * We do not check if map.size() == size() because in some Apache SIS implementations,
-             * the size() method have to scan through all map entries. We presume that if
the maps
-             * are not equal, we will find a mismatched entry soon anyway.
-             */
-            int size = 0;
-            while (it.next()) {
-                if (!it.getValue().equals(map.get(it.getKey()))) {
-                    return false;
-                }
-                size++;
+        if (!(object instanceof Map<?,?>)) {
+            return false;
+        }
+        final Map<?,?> that = (Map<?,?>) object;
+        final EntryIterator<K,V> it = entryIterator();
+        if (it == null) {
+            return that.isEmpty();
+        }
+        /*
+         * We do not check if map.size() == size() because in some Apache SIS implementations,
+         * the size() method have to scan through all map entries. We presume that if the
maps
+         * are not equal, we will find a mismatched entry soon anyway.
+         */
+        int size = 0;
+        while (it.next()) {
+            if (!it.getValue().equals(that.get(it.getKey()))) {
+                return false;
             }
-            return size == map.size();
+            size++;
         }
-        return false;
+        return size == that.size();
     }
 
     /**



Mime
View raw message