Author: desruisseaux
Date: Fri May 11 16:10:59 2018
New Revision: 1831430
URL: http://svn.apache.org/viewvc?rev=1831430&view=rev
Log:
Merge from JDK8 branch.
Added:
sis/trunk/core/sis-feature/src/main/java/org/apache/sis/internal/feature/FeatureExpression.java
- copied, changed from r1831428,
sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/internal/feature/FeatureExpression.java
sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/MemoryFeatureSet.java
- copied, changed from r1831428,
sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/MemoryFeatureSet.java
sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/query/
- copied from r1831428,
sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/query/
sis/trunk/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/query/
- copied from r1831428,
sis/branches/JDK8/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/query/
Removed:
sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/query/SortByComparator.java
Modified:
sis/trunk/ (props changed)
sis/trunk/core/sis-feature/src/main/java/org/apache/sis/feature/DefaultAssociationRole.java
sis/trunk/core/sis-feature/src/main/java/org/apache/sis/feature/FeatureOperations.java
sis/trunk/core/sis-feature/src/main/java/org/apache/sis/feature/StringJoinOperation.java
sis/trunk/core/sis-feature/src/main/java/org/apache/sis/feature/builder/FeatureTypeBuilder.java
sis/trunk/core/sis-feature/src/main/java/org/apache/sis/feature/builder/TypeBuilder.java
sis/trunk/core/sis-feature/src/main/java/org/apache/sis/feature/package-info.java
sis/trunk/core/sis-feature/src/main/java/org/apache/sis/internal/feature/AttributeConvention.java
sis/trunk/core/sis-feature/src/main/java/org/apache/sis/internal/feature/FeatureUtilities.java
sis/trunk/core/sis-feature/src/main/java/org/apache/sis/internal/feature/package-info.java
sis/trunk/core/sis-feature/src/test/java/org/apache/sis/feature/StringJoinOperationTest.java
sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/sql/TypeMapper.java
sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/simple/SimpleIdentifier.java
sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/PropertyInformation.java
sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/TreeNode.java
sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/TreeNodeChildren.java
sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/internal/metadata/sql/TestDatabase.java
sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/metadata/sql/MetadataWriterTest.java
sis/trunk/core/sis-metadata/src/test/resources/org/apache/sis/metadata/xml/2007/Metadata.xml
sis/trunk/core/sis-metadata/src/test/resources/org/apache/sis/metadata/xml/2016/Metadata.xml
sis/trunk/core/sis-referencing/pom.xml
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/ConcurrentAuthorityFactory.java
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/GeodeticAuthorityFactory.java
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGDataAccess.java
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/package-info.java
sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/sql/EPSGInstallerTest.java
sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/util/DefinitionURI.java
sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/Classes.java
sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/collection/Containers.java
sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/collection/package-info.java
sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/logging/MonolineFormatter.java
sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/logging/WarningListeners.java
sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/package-info.java
sis/trunk/core/sis-utility/src/test/java/org/apache/sis/util/ClassesTest.java
sis/trunk/ide-project/NetBeans/nbproject/project.properties
sis/trunk/pom.xml
sis/trunk/storage/pom.xml
sis/trunk/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/DiscreteSampling.java
sis/trunk/storage/sis-sql/src/main/java/org/apache/sis/sql/SQLQuery.java
sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/AbstractFeatureSet.java
sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/AbstractResource.java
sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/package-info.java
sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/query/FeatureSubset.java
sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/query/SimpleQuery.java
sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/storage/DataSet.java
sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/storage/FeatureSet.java
sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/storage/Query.java
sis/trunk/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/query/SimpleQueryTest.java
sis/trunk/storage/sis-storage/src/test/java/org/apache/sis/test/suite/StorageTestSuite.java
sis/trunk/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/gpx/GroupAsPolylineOperation.java
sis/trunk/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/gpx/Reader.java
sis/trunk/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/gpx/Writer.java
Propchange: sis/trunk/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri May 11 16:10:59 2018
@@ -2,5 +2,5 @@
/sis/branches/ISO-19115-3:1804459-1825252
/sis/branches/JDK6:1394364-1758914
/sis/branches/JDK7:1394913-1822221
-/sis/branches/JDK8:1584960-1829667
+/sis/branches/JDK8:1584960-1831428
/sis/branches/JDK9:1773327-1803064
Modified:
sis/trunk/core/sis-feature/src/main/java/org/apache/sis/feature/DefaultAssociationRole.java
URL:
http://svn.apache.org/viewvc/sis/trunk/core/sis-feature/src/main/java/org/apache/sis/feature/DefaultAssociationRole.java?rev=1831430&r1=1831429&r2=1831430&view=diff
==============================================================================
---
sis/trunk/core/sis-feature/src/main/java/org/apache/sis/feature/DefaultAssociationRole.java
[UTF-8] (original)
+++
sis/trunk/core/sis-feature/src/main/java/org/apache/sis/feature/DefaultAssociationRole.java
[UTF-8] Fri May 11 16:10:59 2018
@@ -25,6 +25,7 @@ import org.opengis.util.GenericName;
import org.opengis.util.InternationalString;
import org.opengis.metadata.Identifier;
import org.apache.sis.internal.feature.Resources;
+import org.apache.sis.internal.feature.AttributeConvention;
import org.apache.sis.util.Debug;
import static org.apache.sis.util.ArgumentChecks.*;
@@ -48,7 +49,7 @@ import static org.apache.sis.util.Argume
* Such immutable instances can be shared by many objects and passed between
threads without synchronization.
*
* @author Martin Desruisseaux (Geomatys)
- * @version 0.8
+ * @version 1.0
*
* @see DefaultFeatureType
* @see AbstractAssociation
@@ -414,7 +415,7 @@ public class DefaultAssociationRole exte
private static String searchTitleProperty(final DefaultFeatureType ft) {
String fallback = null;
try {
- return ft.getProperty("sis:identifier").getName().toString();
+ return
ft.getProperty(AttributeConvention.IDENTIFIER).getName().toString();
} catch (IllegalArgumentException e) {
// Ignore.
}
Modified:
sis/trunk/core/sis-feature/src/main/java/org/apache/sis/feature/FeatureOperations.java
URL:
http://svn.apache.org/viewvc/sis/trunk/core/sis-feature/src/main/java/org/apache/sis/feature/FeatureOperations.java?rev=1831430&r1=1831429&r2=1831430&view=diff
==============================================================================
---
sis/trunk/core/sis-feature/src/main/java/org/apache/sis/feature/FeatureOperations.java
[UTF-8] (original)
+++
sis/trunk/core/sis-feature/src/main/java/org/apache/sis/feature/FeatureOperations.java
[UTF-8] Fri May 11 16:10:59 2018
@@ -102,7 +102,7 @@ import org.apache.sis.util.resources.Err
*
* @author Johann Sorel (Geomatys)
* @author Martin Desruisseaux (Geomatys)
- * @version 0.7
+ * @version 1.0
* @since 0.7
* @module
*/
@@ -176,7 +176,7 @@ public final class FeatureOperations ext
* <p><b>Restrictions:</b></p>
* <ul>
* <li>The single properties can be either attributes or operations that
produce attributes;
- * feature associations are not allowed.</li>
+ * feature associations are not allowed, unless they have an {@code
"sis:identifier"} property.</li>
* <li>Each attribute shall contain at most one value; multi-valued
attributes are not allowed.</li>
* <li>The delimiter can not contain the {@code '\'} escape
character.</li>
* </ul>
@@ -221,7 +221,10 @@ public final class FeatureOperations ext
}
case 1: {
if ((prefix == null || prefix.isEmpty()) && (suffix == null ||
suffix.isEmpty())) {
- return link(identification, singleAttributes[0]);
+ final AbstractIdentifiedType at = singleAttributes[0];
+ if (!(at instanceof DefaultAssociationRole)) {
+ return link(identification, at);
+ }
}
break;
}
Modified:
sis/trunk/core/sis-feature/src/main/java/org/apache/sis/feature/StringJoinOperation.java
URL:
http://svn.apache.org/viewvc/sis/trunk/core/sis-feature/src/main/java/org/apache/sis/feature/StringJoinOperation.java?rev=1831430&r1=1831429&r2=1831430&view=diff
==============================================================================
---
sis/trunk/core/sis-feature/src/main/java/org/apache/sis/feature/StringJoinOperation.java
[UTF-8] (original)
+++
sis/trunk/core/sis-feature/src/main/java/org/apache/sis/feature/StringJoinOperation.java
[UTF-8] Fri May 11 16:10:59 2018
@@ -21,10 +21,13 @@ import java.util.Map;
import java.util.Set;
import java.util.Objects;
import java.io.IOException;
+import java.io.Serializable;
import org.opengis.parameter.ParameterDescriptorGroup;
import org.opengis.parameter.ParameterValueGroup;
import org.opengis.util.GenericName;
import org.apache.sis.internal.util.CollectionsExt;
+import org.apache.sis.internal.converter.SurjectiveConverter;
+import org.apache.sis.internal.feature.AttributeConvention;
import org.apache.sis.internal.feature.FeatureUtilities;
import org.apache.sis.internal.feature.Resources;
import org.apache.sis.util.ArgumentChecks;
@@ -35,8 +38,6 @@ import org.apache.sis.util.resources.Err
import org.apache.sis.util.CharSequences;
import org.apache.sis.util.Classes;
-// Branch-dependent imports
-
/**
* An operation concatenating the string representations of the values of
multiple properties.
@@ -48,7 +49,7 @@ import org.apache.sis.util.Classes;
*
* @author Johann Sorel (Geomatys)
* @author Martin Desruisseaux (Geomatys)
- * @version 0.7
+ * @version 1.0
*
* @see <a href="https://en.wikipedia.org/wiki/Compound_key">Compound key on
Wikipedia</a>
*
@@ -72,6 +73,52 @@ final class StringJoinOperation extends
private static final ParameterDescriptorGroup EMPTY_PARAMS =
FeatureUtilities.parameters("StringJoin");
/**
+ * A pseudo-converter returning the identifier of a feature. This
pseudo-converter is used in place
+ * of "real" converters in the {@link StringJoinOperation#converters}
array when the property is an
+ * association to a feature instead than an attribute. This
pseudo-converters is used as below:
+ *
+ * <ul>
+ * <li>{@link Result#getValue()} gets this converter by a call to {@code
converters[i].inverse()}.
+ * This works provided that {@link #inverse()} returns {@code this}
(see comment below).</li>
+ * <li>{@link Result#setValue(String)} needs to perform a special case
for this class.</li>
+ * </ul>
+ *
+ * This is not a well-formed converter since its {@link #inverse()} method
does not fulfill the required
+ * semantic of {@link ObjectConverter#inverse()}, but this is okay for
{@link StringJoinOperation} needs.
+ * This converter should never be accessible to users however.
+ */
+ private static final class ForFeature extends
SurjectiveConverter<Object,Object> implements Serializable {
+ /** For cross-version compatibility. */
+ private static final long serialVersionUID = 2208230611402221572L;
+
+ /**
+ * The "real" converter which would have been stored in the {@link
StringJoinOperation#converters}
+ * array if the property was an attribute instead than an association.
For formatting the feature
+ * identifier, we need to use the inverse of that converter.
+ */
+ final ObjectConverter<? super String, ?> converter;
+
+ /** Creates a new wrapper over the given converter. */
+ ForFeature(final ObjectConverter<? super String, ?> converter) {
+ this.converter = converter;
+ }
+
+ /**
+ * Returns {@code this} for allowing {@link Result#getValue()} to get
this pseudo-converter.
+ * This is a violation of {@link ObjectConverter} contract since this
pseudo-converter is not
+ * an identity converter. Direct uses of this pseudo-converter will
need a {@code instanceof}
+ * check instead.
+ */
+ @Override public ObjectConverter<Object,Object> inverse()
{return this;}
+ @Override public Class<Object> getSourceClass()
{return Object.class;}
+ @Override public Class<Object> getTargetClass()
{return Object.class;}
+ @Override public Object apply(final Object f) {
+ return (f != null) ? format(converter.inverse(),
+ ((AbstractFeature)
f).getPropertyValue(AttributeConvention.IDENTIFIER)) : null;
+ }
+ }
+
+ /**
* The name of the properties (attributes of operations producing
attributes)
* from which to get the values to concatenate.
*/
@@ -117,6 +164,8 @@ final class StringJoinOperation extends
* Creates a new operation for string concatenations using the given
prefix, suffix and delimeter.
* It is caller's responsibility to ensure that {@code delimiter} and
{@code singleAttributes} are not null.
* This private constructor does not verify that condition on the
assumption that the public API did.
+ *
+ * @see FeatureOperations#compound(Map, String, String, String,
AbstractIdentifiedType...)
*/
@SuppressWarnings({"rawtypes", "unchecked"})
// Generic array creation.
StringJoinOperation(final Map<String,?> identification, final String
delimiter,
@@ -130,21 +179,42 @@ final class StringJoinOperation extends
/*
* Verify the following conditions:
* - property types are non-null.
- * - properties are either attributes, or operations producing
attributes.
+ * - properties are either attributes, or operations producing
attributes,
+ * or association to features having an "sis:identifier"
property.
* - attributes contain at most one value (no collections).
+ *
+ * We test FeatureAssociationRole, Operation and AttributeType in
that order
+ * because the "sis:identifier" property of FeatureType may be an
Operation,
+ * which may in turn produce an AttributeType. We do not accept
more complex
+ * combinations (e.g. operation producing an association).
*/
- AbstractIdentifiedType attributeType = singleAttributes[i];
- ArgumentChecks.ensureNonNullElement("singleAttributes", i,
attributeType);
- final GenericName name = attributeType.getName();
- if (attributeType instanceof AbstractOperation) {
- attributeType = ((AbstractOperation)
attributeType).getResult();
+ AbstractIdentifiedType propertyType = singleAttributes[i];
+ ArgumentChecks.ensureNonNullElement("singleAttributes", i,
propertyType);
+ final GenericName name = propertyType.getName();
+ int maximumOccurs = 0; // May be a
bitwise combination; need only to know if > 1.
+ IllegalArgumentException cause = null; // In case of
failure to find "sis:identifier" property.
+ final boolean isAssociation = (propertyType instanceof
DefaultAssociationRole);
+ if (isAssociation) {
+ final DefaultAssociationRole role = (DefaultAssociationRole)
propertyType;
+ final DefaultFeatureType ft = role.getValueType();
+ maximumOccurs = role.getMaximumOccurs();
+ try {
+ propertyType =
ft.getProperty(AttributeConvention.IDENTIFIER);
+ } catch (IllegalArgumentException e) {
+ cause = e;
+ }
}
- if (!(attributeType instanceof DefaultAttributeType)) {
- final Class<?>[] inf =
Classes.getLeafInterfaces(Classes.getClass(attributeType),
AbstractIdentifiedType.class);
+ if (propertyType instanceof AbstractOperation) {
+ propertyType = ((AbstractOperation) propertyType).getResult();
+ }
+ if (propertyType instanceof DefaultAttributeType) {
+ maximumOccurs |= ((DefaultAttributeType<?>)
propertyType).getMaximumOccurs();
+ } else {
+ final Class<?>[] inf =
Classes.getLeafInterfaces(Classes.getClass(propertyType),
AbstractIdentifiedType.class);
throw new
IllegalArgumentException(Resources.forProperties(identification)
- .getString(Resources.Keys.IllegalPropertyType_2, name,
(inf.length != 0) ? inf[0] : null));
+ .getString(Resources.Keys.IllegalPropertyType_2, name,
(inf.length != 0) ? inf[0] : null), cause);
}
- if (((DefaultAttributeType<?>) attributeType).getMaximumOccurs() >
1) {
+ if (maximumOccurs > 1) {
throw new
IllegalArgumentException(Resources.forProperties(identification)
.getString(Resources.Keys.NotASingleton_1, name));
}
@@ -153,7 +223,12 @@ final class StringJoinOperation extends
* We need only their names and how to convert from String to
their values.
*/
attributeNames[i] = name.toString();
- converters[i] = ObjectConverters.find(String.class,
((DefaultAttributeType<?>) attributeType).getValueClass());
+ ObjectConverter<? super String, ?> converter =
ObjectConverters.find(
+ String.class, ((DefaultAttributeType<?>)
propertyType).getValueClass());
+ if (isAssociation) {
+ converter = new ForFeature(converter);
+ }
+ converters[i] = converter;
}
resultType = FeatureOperations.POOL.unique(new DefaultAttributeType<>(
resultIdentification(identification), String.class, 1, 1,
null));
@@ -199,7 +274,7 @@ final class StringJoinOperation extends
/**
* Formats the given value using the given converter. This method is a
workaround for the presence
* of the first {@code ?} in {@code ObjectConverter<?,?>}: defining a
separated method allows us
- * to replace that {@code <?>} by {@code <V>}, thus allowing the compiler
to verify consistency.
+ * to replace that {@code <?>} by {@code <S>}, thus allowing the compiler
to verify consistency.
*
* @param converter the converter to use for formatting the given value.
* @param value the value to format, or {@code null}.
@@ -235,7 +310,7 @@ final class StringJoinOperation extends
private static final long serialVersionUID = -8435975199763452547L;
/**
- * The feature specified to the {@code
StringJoinOperation.apply(Feature, ParameterValueGroup)} method.
+ * The feature specified to the {@link
StringJoinOperation#apply(AbstractFeature, ParameterValueGroup)} method.
*/
private final AbstractFeature feature;
@@ -368,11 +443,17 @@ final class StringJoinOperation extends
* If we have more values than expected, continue the parsing
but without storing the values.
* The intent is to get the correct count of values for error
reporting.
*/
- if (!element.isEmpty() && count < values.length) try {
- values[count] = converters[count].apply(element);
- } catch (UnconvertibleObjectException e) {
- throw new IllegalArgumentException(Errors.format(
- Errors.Keys.CanNotAssign_2, attributeNames[count],
element), e);
+ if (!element.isEmpty() && count < values.length) {
+ ObjectConverter<? super String, ?> converter =
converters[count];
+ if (converter instanceof ForFeature) {
+ converter = ((ForFeature) converter).converter;
+ }
+ try {
+ values[count] = converter.apply(element);
+ } catch (UnconvertibleObjectException e) {
+ throw new IllegalArgumentException(Errors.format(
+ Errors.Keys.CanNotAssign_2,
attributeNames[count], element), e);
+ }
}
count++;
upper += delimiter.length();
@@ -380,14 +461,21 @@ final class StringJoinOperation extends
} while (!done);
/*
* Store the values in the properties only after we successfully
converted all of them,
- * in order to have a "all or nothing" behavior.
+ * in order to have a "all or nothing" behavior (assuming that
calls to Feature methods
+ * below do not fail).
*/
if (values.length != count) {
throw new IllegalArgumentException(Resources.format(
Resources.Keys.UnexpectedNumberOfComponents_4,
getName(), value, values.length, count));
}
for (int i=0; i < values.length; i++) {
- feature.setPropertyValue(attributeNames[i], values[i]);
+ AbstractFeature f = feature;
+ String name = attributeNames[i];
+ if (converters[i] instanceof ForFeature) {
+ f = (AbstractFeature) f.getPropertyValue(name);
+ name = AttributeConvention.IDENTIFIER;
+ }
+ f.setPropertyValue(name, values[i]);
}
}
}
Modified:
sis/trunk/core/sis-feature/src/main/java/org/apache/sis/feature/builder/FeatureTypeBuilder.java
URL:
http://svn.apache.org/viewvc/sis/trunk/core/sis-feature/src/main/java/org/apache/sis/feature/builder/FeatureTypeBuilder.java?rev=1831430&r1=1831429&r2=1831430&view=diff
==============================================================================
---
sis/trunk/core/sis-feature/src/main/java/org/apache/sis/feature/builder/FeatureTypeBuilder.java
[UTF-8] (original)
+++
sis/trunk/core/sis-feature/src/main/java/org/apache/sis/feature/builder/FeatureTypeBuilder.java
[UTF-8] Fri May 11 16:10:59 2018
@@ -1039,7 +1039,7 @@ public class FeatureTypeBuilder extends
buffer.append(" {");
separator = System.lineSeparator();
for (final PropertyTypeBuilder p : properties) {
- p.toString(buffer.append(separator).append("
").append(p.getClass().getSimpleName()));
+ p.appendStringTo(buffer.append(separator).append("
").append(p.getClass().getSimpleName()));
}
buffer.append(separator).append('}');
}
Modified:
sis/trunk/core/sis-feature/src/main/java/org/apache/sis/feature/builder/TypeBuilder.java
URL:
http://svn.apache.org/viewvc/sis/trunk/core/sis-feature/src/main/java/org/apache/sis/feature/builder/TypeBuilder.java?rev=1831430&r1=1831429&r2=1831430&view=diff
==============================================================================
---
sis/trunk/core/sis-feature/src/main/java/org/apache/sis/feature/builder/TypeBuilder.java
[UTF-8] (original)
+++
sis/trunk/core/sis-feature/src/main/java/org/apache/sis/feature/builder/TypeBuilder.java
[UTF-8] Fri May 11 16:10:59 2018
@@ -538,14 +538,14 @@ public abstract class TypeBuilder implem
@Debug
@Override
public String toString() {
- return toString(new
StringBuilder(Classes.getShortClassName(this))).toString();
+ return appendStringTo(new
StringBuilder(Classes.getShortClassName(this))).toString();
}
/**
* Partial implementation of {@link #toString()}. This method assumes that
the class name
* has already be written in the buffer.
*/
- final StringBuilder toString(final StringBuilder buffer) {
+ final StringBuilder appendStringTo(final StringBuilder buffer) {
toStringInternal(buffer.append("[“").append(getDisplayName()).append('”'));
return buffer.append(']');
}
Modified:
sis/trunk/core/sis-feature/src/main/java/org/apache/sis/feature/package-info.java
URL:
http://svn.apache.org/viewvc/sis/trunk/core/sis-feature/src/main/java/org/apache/sis/feature/package-info.java?rev=1831430&r1=1831429&r2=1831430&view=diff
==============================================================================
---
sis/trunk/core/sis-feature/src/main/java/org/apache/sis/feature/package-info.java
[UTF-8] (original)
+++
sis/trunk/core/sis-feature/src/main/java/org/apache/sis/feature/package-info.java
[UTF-8] Fri May 11 16:10:59 2018
@@ -93,7 +93,7 @@
* @author Travis L. Pinney
* @author Johann Sorel (Geomatys)
* @author Martin Desruisseaux (Geomatys)
- * @version 0.8
+ * @version 1.0
* @since 0.5
* @module
*/
Modified:
sis/trunk/core/sis-feature/src/main/java/org/apache/sis/internal/feature/AttributeConvention.java
URL:
http://svn.apache.org/viewvc/sis/trunk/core/sis-feature/src/main/java/org/apache/sis/internal/feature/AttributeConvention.java?rev=1831430&r1=1831429&r2=1831430&view=diff
==============================================================================
---
sis/trunk/core/sis-feature/src/main/java/org/apache/sis/internal/feature/AttributeConvention.java
[UTF-8] (original)
+++
sis/trunk/core/sis-feature/src/main/java/org/apache/sis/internal/feature/AttributeConvention.java
[UTF-8] Fri May 11 16:10:59 2018
@@ -24,6 +24,7 @@ import org.apache.sis.util.iso.Names;
import org.apache.sis.util.Static;
// Branch-dependent imports
+import org.apache.sis.feature.AbstractFeature;
import org.apache.sis.feature.AbstractAttribute;
import org.apache.sis.feature.AbstractIdentifiedType;
import org.apache.sis.feature.AbstractOperation;
@@ -63,7 +64,7 @@ import org.apache.sis.feature.DefaultFea
*
* @author Johann Sorel (Geomatys)
* @author Martin Desruisseaux (Geomatys)
- * @version 0.8
+ * @version 1.0
* @since 0.7
* @module
*/
@@ -171,6 +172,18 @@ public final class AttributeConvention e
}
/**
+ * String representation of the {@link #IDENTIFIER_PROPERTY} name.
+ * This can be used in calls to {@link
AbstractFeature#getPropertyValue(String)}.
+ */
+ public static final String IDENTIFIER = "sis:identifier";
+
+ /**
+ * String representation of the {@link #GEOMETRY_PROPERTY} name.
+ * This can be used in calls to {@link
AbstractFeature#getPropertyValue(String)}.
+ */
+ public static final String GEOMETRY = "sis:geometry";
+
+ /**
* Do not allow instantiation of this class.
*/
private AttributeConvention() {
@@ -198,6 +211,21 @@ public final class AttributeConvention e
}
return false;
}
+
+ /**
+ * Returns {@code true} if the given feature type is non-null and has a
{@value #IDENTIFIER} property.
+ *
+ * @param feature the feature type to test, or {@code null}.
+ * @return whether the given feature type is non-null and has a {@value
#IDENTIFIER} property.
+ */
+ public static boolean hasIdentifier(final DefaultFeatureType feature) {
+ if (feature != null) try {
+ return feature.getProperty(IDENTIFIER) != null;
+ } catch (IllegalArgumentException e) {
+ // Ignore
+ }
+ return false;
+ }
/**
* Returns {@code true} if the given type is an {@code AttributeType} or
an {@code Operation} computing
Copied:
sis/trunk/core/sis-feature/src/main/java/org/apache/sis/internal/feature/FeatureExpression.java
(from r1831428,
sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/internal/feature/FeatureExpression.java)
URL:
http://svn.apache.org/viewvc/sis/trunk/core/sis-feature/src/main/java/org/apache/sis/internal/feature/FeatureExpression.java?p2=sis/trunk/core/sis-feature/src/main/java/org/apache/sis/internal/feature/FeatureExpression.java&p1=sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/internal/feature/FeatureExpression.java&r1=1831428&r2=1831430&rev=1831430&view=diff
==============================================================================
---
sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/internal/feature/FeatureExpression.java
[UTF-8] (original)
+++
sis/trunk/core/sis-feature/src/main/java/org/apache/sis/internal/feature/FeatureExpression.java
[UTF-8] Fri May 11 16:10:59 2018
@@ -17,13 +17,13 @@
package org.apache.sis.internal.feature;
// Branch-dependent imports
-import org.opengis.feature.FeatureType;
-import org.opengis.feature.PropertyType;
+import org.apache.sis.feature.AbstractIdentifiedType;
+import org.apache.sis.feature.DefaultFeatureType;
/**
* OGC expressions or other functions operating on feature instances.
- * This interface adds an additional method, {@link
#expectedType(FeatureType)},
+ * This interface adds an additional method, {@link
#expectedType(DefaultFeatureType)},
* for fetching in advance the expected type of expression results.
*
* @author Johann Sorel (Geomatys)
@@ -35,12 +35,12 @@ public interface FeatureExpression {
/**
* Returns the expected type of values produced by this expression when a
feature of the given
* type is evaluated. The resulting type shall describe a "static"
property, i.e. it can be an
- * {@link org.opengis.feature.AttributeType} or a {@link
org.opengis.feature.FeatureAssociationRole}
- * but not an {@link org.opengis.feature.Operation}.
+ * {@code org.opengis.feature.AttributeType} or a {@code
org.opengis.feature.FeatureAssociationRole}
+ * but not an {@code org.opengis.feature.Operation}.
*
* @param type the type of features on which to apply this expression.
* @return expected expression result type.
* @throws IllegalArgumentException if this method can not determine the
property type for the given feature type.
*/
- PropertyType expectedType(FeatureType type);
+ AbstractIdentifiedType expectedType(DefaultFeatureType type);
}
Modified:
sis/trunk/core/sis-feature/src/main/java/org/apache/sis/internal/feature/FeatureUtilities.java
URL:
http://svn.apache.org/viewvc/sis/trunk/core/sis-feature/src/main/java/org/apache/sis/internal/feature/FeatureUtilities.java?rev=1831430&r1=1831429&r2=1831430&view=diff
==============================================================================
---
sis/trunk/core/sis-feature/src/main/java/org/apache/sis/internal/feature/FeatureUtilities.java
[UTF-8] (original)
+++
sis/trunk/core/sis-feature/src/main/java/org/apache/sis/internal/feature/FeatureUtilities.java
[UTF-8] Fri May 11 16:10:59 2018
@@ -18,6 +18,10 @@ package org.apache.sis.internal.feature;
import java.util.Map;
import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Collection;
+import java.util.ConcurrentModificationException;
+import org.opengis.util.GenericName;
import org.opengis.metadata.Identifier;
import org.opengis.parameter.ParameterDescriptor;
import org.opengis.parameter.ParameterDescriptorGroup;
@@ -36,7 +40,7 @@ import org.apache.sis.feature.AbstractId
*
* @author Johann Sorel (Geomatys)
* @author Martin Desruisseaux (Geomatys)
- * @version 0.8
+ * @version 1.0
* @since 0.8
* @module
*/
@@ -90,4 +94,33 @@ public final class FeatureUtilities exte
}
return null;
}
+
+ /**
+ * Gets the name of all given properties. If any property is null or has a
null name,
+ * then the corresponding entry in the returned array will be null.
+ *
+ * @param properties the properties for which to get the names, or
{@code null}.
+ * @return the name of all given properties, or {@code null} if the given
list was null.
+ */
+ public static String[] getNames(final Collection<? extends
AbstractIdentifiedType> properties) {
+ if (properties == null) {
+ return null;
+ }
+ final String[] names = new String[properties.size()];
+ final Iterator<? extends AbstractIdentifiedType> it =
properties.iterator();
+ for (int i=0; i < names.length; i++) {
+ final AbstractIdentifiedType property = it.next();
+ if (property != null) {
+ final GenericName name = property.getName();
+ if (name != null) {
+ names[i] = name.toString();
+ }
+ }
+ }
+ // Should not have any element left, unless collection size changed
during iteration.
+ if (it.hasNext()) {
+ throw new ConcurrentModificationException();
+ }
+ return names;
+ }
}
Modified:
sis/trunk/core/sis-feature/src/main/java/org/apache/sis/internal/feature/package-info.java
URL:
http://svn.apache.org/viewvc/sis/trunk/core/sis-feature/src/main/java/org/apache/sis/internal/feature/package-info.java?rev=1831430&r1=1831429&r2=1831430&view=diff
==============================================================================
---
sis/trunk/core/sis-feature/src/main/java/org/apache/sis/internal/feature/package-info.java
[UTF-8] (original)
+++
sis/trunk/core/sis-feature/src/main/java/org/apache/sis/internal/feature/package-info.java
[UTF-8] Fri May 11 16:10:59 2018
@@ -26,7 +26,8 @@
* may change in incompatible ways in any future version without notice.
*
* @author Johann Sorel (Geomatys)
- * @version 0.7
+ * @author Martin Desruisseaux (Geomatys)
+ * @version 1.0
* @since 0.7
* @module
*/
Modified:
sis/trunk/core/sis-feature/src/test/java/org/apache/sis/feature/StringJoinOperationTest.java
URL:
http://svn.apache.org/viewvc/sis/trunk/core/sis-feature/src/test/java/org/apache/sis/feature/StringJoinOperationTest.java?rev=1831430&r1=1831429&r2=1831430&view=diff
==============================================================================
---
sis/trunk/core/sis-feature/src/test/java/org/apache/sis/feature/StringJoinOperationTest.java
[UTF-8] (original)
+++
sis/trunk/core/sis-feature/src/test/java/org/apache/sis/feature/StringJoinOperationTest.java
[UTF-8] Fri May 11 16:10:59 2018
@@ -19,6 +19,7 @@ package org.apache.sis.feature;
import java.util.Collections;
import java.util.Map;
import org.junit.Test;
+import org.apache.sis.internal.feature.AttributeConvention;
import org.apache.sis.test.DependsOnMethod;
import org.apache.sis.test.DependsOn;
import org.apache.sis.test.TestCase;
@@ -31,7 +32,7 @@ import static org.junit.Assert.*;
*
* @author Johann Sorel (Geomatys)
* @author Martin Desruisseaux (Geomatys)
- * @version 0.7
+ * @version 1.0
* @since 0.7
* @module
*/
@@ -63,7 +64,7 @@ public final strictfp class StringJoinOp
/**
* Creates the identification map to be given to attribute, operation and
feature constructors.
*/
- private static Map<String,?> name(final String name) {
+ private static Map<String,?> name(final Object name) {
return Collections.singletonMap(AbstractIdentifiedType.NAME_KEY, name);
}
@@ -168,4 +169,41 @@ public final strictfp class StringJoinOp
assertTrue(message, message.contains("age"));
}
}
+
+ /**
+ * Tests the creation of an identifier when one property is a feature.
+ * This method tests both {@code getValue(…)} and {@code setValue(…)}.
+ */
+ @Test
+ public void testFeatureAssociation() {
+ final AbstractIdentifiedType id1 = new
DefaultAttributeType<>(name(AttributeConvention.IDENTIFIER_PROPERTY),
String.class, 1, 1, null);
+ final DefaultFeatureType ft1 = new DefaultFeatureType(name("Child
feature"), false, null, id1);
+ final AbstractIdentifiedType p1 = new
DefaultAssociationRole(name("first"), ft1, 1, 1);
+ final AbstractIdentifiedType p2 = new
DefaultAttributeType<>(name("second"), Integer.class, 1, 1, null);
+ final AbstractIdentifiedType idc =
FeatureOperations.compound(name("concat"), "/", "<<:", ":>>", p1, p2);
+ final AbstractFeature feature = new DefaultFeatureType(name("Parent
feature"), false, null, p1, p2, idc).newInstance();
+ /*
+ * For empty feature, should have only the prefix, delimiter and
suffix.
+ */
+ assertEquals("<<:/:>>", feature.getPropertyValue("concat"));
+ /*
+ * Test with a value for the property (nothing in the association yet).
+ */
+ feature.setPropertyValue("second", 21);
+ assertEquals("<<:/21:>>", feature.getPropertyValue("concat"));
+ /*
+ * Create the associated feature and set its identifier.
+ * The compound identifier shall be updated accordingly.
+ */
+ final AbstractFeature f1 = ft1.newInstance();
+ feature.setPropertyValue("first", f1);
+ f1.setPropertyValue("sis:identifier", "SomeKey");
+ assertEquals("<<:SomeKey/21:>>", feature.getPropertyValue("concat"));
+ /*
+ * Setting a value should cascade to the child feature.
+ */
+ feature.setPropertyValue("concat", "<<:NewKey/38:>>");
+ assertEquals(38, feature.getPropertyValue("second"));
+ assertEquals("NewKey", f1.getPropertyValue("sis:identifier"));
+ }
}
Modified:
sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/sql/TypeMapper.java
URL:
http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/sql/TypeMapper.java?rev=1831430&r1=1831429&r2=1831430&view=diff
==============================================================================
---
sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/sql/TypeMapper.java
[UTF-8] (original)
+++
sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/sql/TypeMapper.java
[UTF-8] Fri May 11 16:10:59 2018
@@ -34,7 +34,7 @@ public final class TypeMapper {
* but only the ones which are of interest for the Apache SIS metadata
implementation.
* The types will be tested in the order they are declared, so the last
declarations are fallbacks.
*
- * <p>The types declared here matches both the JavaDB and PostgreSQL
mapping.</p>
+ * <p>The types declared here matches both the Derby and PostgreSQL
mapping.</p>
*/
private static final TypeMapper[] TYPES = {
new TypeMapper(Boolean.class, Types.BOOLEAN, "BOOLEAN"),
@@ -44,7 +44,7 @@ public final class TypeMapper {
new TypeMapper(Long .class, Types.BIGINT, "BIGINT"),
new TypeMapper(Integer.class, Types.INTEGER, "INTEGER"),
new TypeMapper(Short .class, Types.SMALLINT, "SMALLINT"),
- new TypeMapper(Byte .class, Types.TINYINT, "SMALLINT"), //
JavaDB does not support TINYINT.
+ new TypeMapper(Byte .class, Types.TINYINT, "SMALLINT"), //
Derby does not support TINYINT.
new TypeMapper(Number .class, Types.DECIMAL, "DECIMAL") //
Implemented by BigDecimal.
};
Modified:
sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/simple/SimpleIdentifier.java
URL:
http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/simple/SimpleIdentifier.java?rev=1831430&r1=1831429&r2=1831430&view=diff
==============================================================================
---
sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/simple/SimpleIdentifier.java
[UTF-8] (original)
+++
sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/simple/SimpleIdentifier.java
[UTF-8] Fri May 11 16:10:59 2018
@@ -221,7 +221,7 @@ public class SimpleIdentifier implements
if (open) {
buffer.append('”');
}
- appendToString(buffer);
+ appendStringTo(buffer);
return buffer.append(']').toString();
}
@@ -231,7 +231,7 @@ public class SimpleIdentifier implements
*
* @param buffer a buffer filled with the {@link #toString()}
characters, that subclasses can update.
*/
- protected void appendToString(final StringBuilder buffer) {
+ protected void appendStringTo(final StringBuilder buffer) {
}
/**
Modified:
sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/PropertyInformation.java
URL:
http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/PropertyInformation.java?rev=1831430&r1=1831429&r2=1831430&view=diff
==============================================================================
---
sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/PropertyInformation.java
[UTF-8] (original)
+++
sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/PropertyInformation.java
[UTF-8] Fri May 11 16:10:59 2018
@@ -382,7 +382,7 @@ final class PropertyInformation<E> exten
* Invoked by {@link #toString()} in order to append additional
information after the identifier.
*/
@Override
- protected void appendToString(final StringBuilder buffer) {
+ protected void appendStringTo(final StringBuilder buffer) {
buffer.append(" : ").append(Types.getCodeLabel(getDataType()))
.append(",
").append(getObligation().name().toLowerCase(Locale.US))
.append(", maxOccurs=");
Modified:
sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/TreeNode.java
URL:
http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/TreeNode.java?rev=1831430&r1=1831429&r2=1831430&view=diff
==============================================================================
---
sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/TreeNode.java
[UTF-8] (original)
+++
sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/TreeNode.java
[UTF-8] Fri May 11 16:10:59 2018
@@ -897,14 +897,14 @@ class TreeNode implements Node {
@Override
public final String toString() {
final StringBuilder buffer = new StringBuilder(60);
- toString(buffer);
+ appendStringTo(buffer);
return buffer.toString();
}
/**
* Implementation of {@link #toString()} appending the string
representation in the given buffer.
*/
- final void toString(final StringBuilder buffer) {
+ final void appendStringTo(final StringBuilder buffer) {
appendIdentifier(buffer.append("Node["));
buffer.append(" :
").append(Classes.getShortName(baseType)).append(']');
}
Modified:
sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/TreeNodeChildren.java
URL:
http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/TreeNodeChildren.java?rev=1831430&r1=1831429&r2=1831430&view=diff
==============================================================================
---
sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/TreeNodeChildren.java
[UTF-8] (original)
+++
sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/TreeNodeChildren.java
[UTF-8] Fri May 11 16:10:59 2018
@@ -614,11 +614,11 @@ final class TreeNodeChildren extends Abs
public String toString() {
final String lineSeparator = System.lineSeparator();
final StringBuilder buffer = new StringBuilder(512);
- parent.toString(buffer);
+ parent.appendStringTo(buffer);
buffer.append(lineSeparator);
for (final TreeTable.Node node : this) {
buffer.append(" ");
- ((TreeNode) node).toString(buffer);
+ ((TreeNode) node).appendStringTo(buffer);
buffer.append(lineSeparator);
}
return buffer.toString();
Modified:
sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/internal/metadata/sql/TestDatabase.java
URL:
http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/internal/metadata/sql/TestDatabase.java?rev=1831430&r1=1831429&r2=1831430&view=diff
==============================================================================
---
sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/internal/metadata/sql/TestDatabase.java
[UTF-8] (original)
+++
sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/internal/metadata/sql/TestDatabase.java
[UTF-8] Fri May 11 16:10:59 2018
@@ -58,7 +58,7 @@ import static org.junit.Assume.*;
public final strictfp class TestDatabase {
/**
* Data source to an alternative database to use for testing purpose.
- * If {@code null}, an in-memory Derby or JavaDB database will be used.
+ * If {@code null}, an in-memory Derby database will be used.
*
* This field is occasionally set to a non-null value (e.g. a connection
to a PostgreSQL database) only for
* debugging purpose. In such case, it is developer responsibility to
ensure that the appropriate driver is
@@ -74,7 +74,7 @@ public final strictfp class TestDatabase
}
/**
- * Creates a Derby database in memory. If no Derby or JavaDB driver is not
found,
+ * Creates a Derby database in memory. If no Derby driver is not found,
* then the test will be interrupted by an {@code org.junit.Assume}
statement.
*
* @param name the database name (without {@code "memory:"} prefix).
Modified:
sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/metadata/sql/MetadataWriterTest.java
URL:
http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/metadata/sql/MetadataWriterTest.java?rev=1831430&r1=1831429&r2=1831430&view=diff
==============================================================================
---
sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/metadata/sql/MetadataWriterTest.java
[UTF-8] (original)
+++
sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/metadata/sql/MetadataWriterTest.java
[UTF-8] Fri May 11 16:10:59 2018
@@ -60,7 +60,7 @@ public final strictfp class MetadataWrit
private MetadataWriter source;
/**
- * Runs all tests on JavaDB in the required order.
+ * Runs all tests on Derby in the required order.
*
* @throws Exception if an error occurred while writing or reading the
database.
*/
Modified:
sis/trunk/core/sis-metadata/src/test/resources/org/apache/sis/metadata/xml/2007/Metadata.xml
URL:
http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/test/resources/org/apache/sis/metadata/xml/2007/Metadata.xml?rev=1831430&r1=1831429&r2=1831430&view=diff
==============================================================================
---
sis/trunk/core/sis-metadata/src/test/resources/org/apache/sis/metadata/xml/2007/Metadata.xml
(original)
+++
sis/trunk/core/sis-metadata/src/test/resources/org/apache/sis/metadata/xml/2007/Metadata.xml
Fri May 11 16:10:59 2018
@@ -486,10 +486,10 @@
<gco:Boolean>true</gco:Boolean>
</gmd:extentTypeCode>
<gmd:westBoundLongitude>
- <gco:Decimal>-24.5</gco:Decimal>
+ <gco:Decimal>-32.0</gco:Decimal>
</gmd:westBoundLongitude>
<gmd:eastBoundLongitude>
- <gco:Decimal>-32.0</gco:Decimal>
+ <gco:Decimal>-24.5</gco:Decimal>
</gmd:eastBoundLongitude>
<gmd:southBoundLatitude>
<gco:Decimal>36.75</gco:Decimal>
Modified:
sis/trunk/core/sis-metadata/src/test/resources/org/apache/sis/metadata/xml/2016/Metadata.xml
URL:
http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/test/resources/org/apache/sis/metadata/xml/2016/Metadata.xml?rev=1831430&r1=1831429&r2=1831430&view=diff
==============================================================================
---
sis/trunk/core/sis-metadata/src/test/resources/org/apache/sis/metadata/xml/2016/Metadata.xml
(original)
+++
sis/trunk/core/sis-metadata/src/test/resources/org/apache/sis/metadata/xml/2016/Metadata.xml
Fri May 11 16:10:59 2018
@@ -461,10 +461,10 @@
<gco:Boolean>true</gco:Boolean>
</gex:extentTypeCode>
<gex:westBoundLongitude>
- <gco:Decimal>-24.5</gco:Decimal>
+ <gco:Decimal>-32.0</gco:Decimal>
</gex:westBoundLongitude>
<gex:eastBoundLongitude>
- <gco:Decimal>-32.0</gco:Decimal>
+ <gco:Decimal>-24.5</gco:Decimal>
</gex:eastBoundLongitude>
<gex:southBoundLatitude>
<gco:Decimal>36.75</gco:Decimal>
Modified: sis/trunk/core/sis-referencing/pom.xml
URL:
http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/pom.xml?rev=1831430&r1=1831429&r2=1831430&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/pom.xml (original)
+++ sis/trunk/core/sis-referencing/pom.xml Fri May 11 16:10:59 2018
@@ -140,6 +140,11 @@
<scope>test</scope>
</dependency>
<dependency>
+ <groupId>org.apache.derby</groupId>
+ <artifactId>derby</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
<groupId>org.hsqldb</groupId>
<artifactId>hsqldb</artifactId>
<scope>test</scope>
Modified:
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/ConcurrentAuthorityFactory.java
URL:
http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/ConcurrentAuthorityFactory.java?rev=1831430&r1=1831429&r2=1831430&view=diff
==============================================================================
---
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/ConcurrentAuthorityFactory.java
[UTF-8] (original)
+++
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/ConcurrentAuthorityFactory.java
[UTF-8] Fri May 11 16:10:59 2018
@@ -2157,7 +2157,7 @@ public abstract class ConcurrentAuthorit
*/
@Debug
@Override
- final void toString(final StringBuilder buffer) {
+ final void appendStringTo(final StringBuilder buffer) {
buffer.append(", cache=").append(cache.size()).append(", DAO=");
synchronized (availableDAOs) {
buffer.append(availableDAOs.size());
Modified:
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/GeodeticAuthorityFactory.java
URL:
http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/GeodeticAuthorityFactory.java?rev=1831430&r1=1831429&r2=1831430&view=diff
==============================================================================
---
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/GeodeticAuthorityFactory.java
[UTF-8] (original)
+++
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/GeodeticAuthorityFactory.java
[UTF-8] Fri May 11 16:10:59 2018
@@ -97,7 +97,7 @@ public abstract class GeodeticAuthorityF
* │ └─ Function ……………………………………… Browse
* └─ Online resource (2 of 2)
* ├─ Linkage …………………………………………
jdbc:derby:/my/path/to/SIS_DATA/Databases/SpatialMetadata
- * ├─ Description ……………………………… EPSG dataset version 8.9 on “Apache
Derby Embedded JDBC Driver” version 10.12.
+ * ├─ Description ……………………………… EPSG dataset version 9.1 on “Apache
Derby Embedded JDBC Driver” version 10.14.
* └─ Function ……………………………………… Connection
* }
*
@@ -1326,13 +1326,13 @@ public abstract class GeodeticAuthorityF
public String toString() {
final StringBuilder buffer = new
StringBuilder(Classes.getShortClassName(this))
.append("[“").append(Citations.getIdentifier(getAuthority(),
false)).append('”');
- toString(buffer);
+ appendStringTo(buffer);
return buffer.append(']').toString();
}
/**
* Hook for subclasses.
*/
- void toString(final StringBuilder buffer) {
+ void appendStringTo(final StringBuilder buffer) {
}
}
Modified:
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGDataAccess.java
URL:
http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGDataAccess.java?rev=1831430&r1=1831429&r2=1831430&view=diff
==============================================================================
---
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGDataAccess.java
[UTF-8] (original)
+++
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGDataAccess.java
[UTF-8] Fri May 11 16:10:59 2018
@@ -413,7 +413,7 @@ public class EPSGDataAccess extends Geod
* │ └─ Function ……………………………………… Browse
* └─ Online resource (2 of 2)
* ├─ Linkage …………………………………………
jdbc:derby:/my/path/to/SIS_DATA/Databases/SpatialMetadata
- * ├─ Description ……………………………… EPSG dataset version 8.9 on “Apache
Derby Embedded JDBC Driver” version 10.12.
+ * ├─ Description ……………………………… EPSG dataset version 9.1 on “Apache
Derby Embedded JDBC Driver” version 10.14.
* └─ Function ……………………………………… Connection
* }
*/
@@ -452,7 +452,7 @@ public class EPSGDataAccess extends Geod
*
* Linkage:
jdbc:derby:/my/path/to/SIS_DATA/Databases/SpatialMetadata
* Function: Connection
- * Description: EPSG dataset version 8.9 on “Apache Derby
Embedded JDBC Driver” version 10.12.
+ * Description: EPSG dataset version 9.1 on “Apache Derby
Embedded JDBC Driver” version 10.14.
*
* TODO: A future version should use Citations.EPSG as a template.
* See the "EPSG" case in
ServiceForUtility.createCitation(String).
Modified:
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/package-info.java
URL:
http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/package-info.java?rev=1831430&r1=1831429&r2=1831430&view=diff
==============================================================================
---
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/package-info.java
[UTF-8] (original)
+++
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/package-info.java
[UTF-8] Fri May 11 16:10:59 2018
@@ -24,7 +24,7 @@
*
*
* <div class="section">Connection to the database</div>
- * By default Apache SIS uses Apache Derby (a.k.a. JavaDB in Oracle JDK),
+ * By default Apache SIS uses Apache Derby,
* but the database can also be PostgreSQL or MS-Access.
* The database connection is obtained by the first of the following data
sources which is found:
*
@@ -40,8 +40,7 @@
* </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.
+ * With other choices, an Apache Derby driver should be available on the
classpath.
*
*
* <div class="section">The EPSG dataset</div>
Modified:
sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/sql/EPSGInstallerTest.java
URL:
http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/sql/EPSGInstallerTest.java?rev=1831430&r1=1831429&r2=1831430&view=diff
==============================================================================
---
sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/sql/EPSGInstallerTest.java
[UTF-8] (original)
+++
sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/sql/EPSGInstallerTest.java
[UTF-8] Fri May 11 16:10:59 2018
@@ -123,7 +123,7 @@ public final strictfp class EPSGInstalle
/**
* Tests the creation of an EPSG database on Derby.
- * This test is skipped if Derby/JavaDB is not found, or if the SQL
scripts are not found.
+ * This test is skipped if Derby is not found, or if the SQL scripts are
not found.
*
* @throws Exception if an error occurred while creating the database.
*/
Modified:
sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/util/DefinitionURI.java
URL:
http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/util/DefinitionURI.java?rev=1831430&r1=1831429&r2=1831430&view=diff
==============================================================================
---
sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/util/DefinitionURI.java
[UTF-8] (original)
+++
sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/util/DefinitionURI.java
[UTF-8] Fri May 11 16:10:59 2018
@@ -702,7 +702,7 @@ public final class DefinitionURI {
if (!isHTTP) {
buffer.append(PREFIX);
}
- toString(buffer, SEPARATOR);
+ appendStringTo(buffer, SEPARATOR);
return buffer.toString();
}
@@ -713,7 +713,7 @@ public final class DefinitionURI {
* @param buffer where to format the string representation.
* @param separator first separator to append. Ignored if the URI is
actually a URL.
*/
- private void toString(final StringBuilder buffer, char separator) {
+ private void appendStringTo(final StringBuilder buffer, char separator) {
if (isHTTP) {
buffer.append("http://").append(DOMAIN).append("/def");
separator = '/';
@@ -768,7 +768,7 @@ public final class DefinitionURI {
: COMPONENT_SEPARATOR_2)
.append(i).append(KEY_VALUE_SEPARATOR);
}
- c.toString(buffer, COMPONENT_SEPARATOR);
+ c.appendStringTo(buffer, COMPONENT_SEPARATOR);
}
}
}
Modified:
sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/Classes.java
URL:
http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/Classes.java?rev=1831430&r1=1831429&r2=1831430&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/Classes.java
[UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/Classes.java
[UTF-8] Fri May 11 16:10:59 2018
@@ -28,8 +28,11 @@ import java.lang.reflect.Method;
import java.lang.reflect.WildcardType;
import java.lang.reflect.GenericArrayType;
import java.lang.reflect.ParameterizedType;
+import java.lang.reflect.Modifier;
+import org.opengis.annotation.UML;
import static org.apache.sis.util.collection.Containers.hashMapCapacity;
+import static org.apache.sis.internal.system.Modules.INTERNAL_CLASSNAME_PREFIX;
/**
@@ -50,7 +53,7 @@ import static org.apache.sis.util.collec
* </ul>
*
* @author Martin Desruisseaux (IRD, Geomatys)
- * @version 0.5
+ * @version 1.0
* @since 0.3
* @module
*/
@@ -274,6 +277,39 @@ public final class Classes extends Stati
}
/**
+ * Returns the first type or super-type (including interface) considered
"standard" in Apache SIS sense.
+ * This method applies the following heuristic rules, in that order:
+ *
+ * <ul>
+ * <li>If the given type implements at least one interface having the
{@link UML} annotation,
+ * then the first annotated interface is returned.</li>
+ * <li>Otherwise the first public class or parent class is returned.</li>
+ * </ul>
+ *
+ * Those heuristic rules may be adjusted in any future Apache SIS version.
+ *
+ * @param <T> the compile-time type argument.
+ * @param type the type for which to get the standard interface or
class. May be {@code null}.
+ * @return a standard interface implemented by {@code type}, or otherwise
the most specific public class.
+ * Is {@code null} if the given {@code type} argument was null.
+ *
+ * @since 1.0
+ */
+ public static <T> Class<? super T> getStandardType(final Class<T> type) {
+ for (final Class<? super T> candidate : getAllInterfaces(type)) {
+ if (candidate.isAnnotationPresent(UML.class)) {
+ return candidate;
+ }
+ }
+ for (Class<? super T> candidate = type; candidate != null; candidate =
candidate.getSuperclass()) {
+ if (Modifier.isPublic(candidate.getModifiers()) &&
!candidate.getName().startsWith(INTERNAL_CLASSNAME_PREFIX)) {
+ return candidate;
+ }
+ }
+ return type;
+ }
+
+ /**
* Returns every interfaces implemented, directly or indirectly, by the
given class or interface.
* This is similar to {@link Class#getInterfaces()} except that this
method searches recursively
* in the super-interfaces. For example if the given type is {@link
java.util.ArrayList}, then
Modified:
sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/collection/Containers.java
URL:
http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/collection/Containers.java?rev=1831430&r1=1831429&r2=1831430&view=diff
==============================================================================
---
sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/collection/Containers.java
[UTF-8] (original)
+++
sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/collection/Containers.java
[UTF-8] Fri May 11 16:10:59 2018
@@ -19,6 +19,7 @@ package org.apache.sis.util.collection;
import java.util.Map;
import java.util.Set;
import java.util.List;
+import java.util.Iterator;
import java.util.Collection;
import org.apache.sis.util.Static;
import org.apache.sis.util.ArgumentChecks;
@@ -33,7 +34,7 @@ import org.apache.sis.internal.util.Unmo
* in this class implement the {@code CheckedContainer} interface.
*
* @author Martin Desruisseaux (IRD, Geomatys)
- * @version 0.4
+ * @version 1.0
* @since 0.3
* @module
*/
@@ -268,4 +269,37 @@ public final class Containers extends St
}
return count + r;
}
+
+ /**
+ * Compares element-by-element the values provided by two iterators, in
iteration order. Let {@code o1} be an
+ * element from the first iterator and {@code o2} the element at the same
position from the second iterator.
+ * This method returns the result of the first {@code o1.compareTo(o2)}
call which returned a value different
+ * than zero. If all {@code o1.compareTo(o2)} calls returned zero, then
this method returns -1 if {@code it1}
+ * iteration finished before {@code it2}, +1 if {@code it2} iteration
finished before {@code it1}, or 0 if both
+ * iterators finished in same time.
+ *
+ * <p>Iterators may return null elements. Null elements are considered
"after" any non-null element.</p>
+ *
+ * @param <E> the type of elements returned by the iterators.
+ * @param it1 the first iterator (can not be null).
+ * @param it2 the second iterator (can not be null).
+ * @return -1 if the content given by the first iterator is considered
"before" the content given by the second
+ * iterator, +1 if considered "after", or 0 if considered equal.
+ *
+ * @since 1.0
+ */
+ public static <E extends Comparable<E>> int compare(final Iterator<E> it1,
final Iterator<? extends E> it2) {
+ while (it1.hasNext()) {
+ if (!it2.hasNext()) return +1; // it1 longer than it2.
+ final E o1 = it1.next();
+ final E o2 = it2.next();
+ if (o1 != o2) {
+ if (o1 == null) return +1;
+ if (o2 == null) return -1;
+ final int c = o1.compareTo(o2);
+ if (c != 0) return c;
+ }
+ }
+ return it2.hasNext() ? -1 : 0;
+ }
}
Modified:
sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/collection/package-info.java
URL:
http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/collection/package-info.java?rev=1831430&r1=1831429&r2=1831430&view=diff
==============================================================================
---
sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/collection/package-info.java
[UTF-8] (original)
+++
sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/collection/package-info.java
[UTF-8] Fri May 11 16:10:59 2018
@@ -51,7 +51,7 @@
* </ul>
*
* @author Martin Desruisseaux (IRD, Geomatys)
- * @version 0.3
+ * @version 1.0
* @since 0.3
* @module
*/
Modified:
sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/logging/MonolineFormatter.java
URL:
http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/logging/MonolineFormatter.java?rev=1831430&r1=1831429&r2=1831430&view=diff
==============================================================================
---
sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/logging/MonolineFormatter.java
[UTF-8] (original)
+++
sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/logging/MonolineFormatter.java
[UTF-8] Fri May 11 16:10:59 2018
@@ -53,7 +53,7 @@ import static org.apache.sis.internal.ut
* <tr><td><code>00:01</code></td><td
style="background:blue"><code>CONFIG</code></td>
* <td><code><b>[MyApplication]</b> Read configuration from
“my-application/setup.xml”.</code></td></tr>
* <tr><td><code>00:03</code></td><td
style="background:green"><code>INFO</code></td>
- * <td><code><b>[EPSGFactory]</b> Connected to the EPSG database version
6.9 on JavaDB 10.8.</code></td></tr>
+ * <td><code><b>[EPSGFactory]</b> Connected to the EPSG database version
9.1 on Derby 10.14.</code></td></tr>
* <tr><td><code>00:12</code></td><td
style="background:goldenrod"><code>WARNING</code></td>
* <td><code><b>[DefaultTemporalExtent]</b> This operation requires the
“sis-temporal” module.</code></td></tr>
* </table></blockquote>
Modified:
sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/logging/WarningListeners.java
URL:
http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/logging/WarningListeners.java?rev=1831430&r1=1831429&r2=1831430&view=diff
==============================================================================
---
sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/logging/WarningListeners.java
[UTF-8] (original)
+++
sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/logging/WarningListeners.java
[UTF-8] Fri May 11 16:10:59 2018
@@ -58,7 +58,7 @@ import org.apache.sis.internal.util.Unmo
* from multiple threads.
*
* @author Martin Desruisseaux (Geomatys)
- * @version 0.8
+ * @version 1.0
*
* @param <S> the type of the source of warnings.
*
@@ -278,7 +278,7 @@ public class WarningListeners<S> impleme
*/
static boolean isPublic(final StackTraceElement e) {
final String classname = e.getClassName();
- if (classname.startsWith("java") || classname.contains(".internal.") ||
+ if (classname.startsWith("java") ||
classname.startsWith(Modules.INTERNAL_CLASSNAME_PREFIX) ||
classname.indexOf('$') >= 0 || e.getMethodName().indexOf('$') >= 0)
{
return false;
Modified:
sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/package-info.java
URL:
http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/package-info.java?rev=1831430&r1=1831429&r2=1831430&view=diff
==============================================================================
---
sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/package-info.java
[UTF-8] (original)
+++
sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/package-info.java
[UTF-8] Fri May 11 16:10:59 2018
@@ -38,7 +38,7 @@
* </ul>
*
* @author Martin Desruisseaux (Geomatys)
- * @version 0.3
+ * @version 1.0
* @since 0.3
* @module
*/
Modified:
sis/trunk/core/sis-utility/src/test/java/org/apache/sis/util/ClassesTest.java
URL:
http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/test/java/org/apache/sis/util/ClassesTest.java?rev=1831430&r1=1831429&r2=1831430&view=diff
==============================================================================
---
sis/trunk/core/sis-utility/src/test/java/org/apache/sis/util/ClassesTest.java
[UTF-8] (original)
+++
sis/trunk/core/sis-utility/src/test/java/org/apache/sis/util/ClassesTest.java
[UTF-8] Fri May 11 16:10:59 2018
@@ -56,7 +56,7 @@ import org.opengis.referencing.operation
* Tests the {@link Classes} static methods.
*
* @author Martin Desruisseaux (Geomatys)
- * @version 0.5
+ * @version 1.0
* @since 0.3
* @module
*/
@@ -124,6 +124,18 @@ public final strictfp class ClassesTest
private abstract static class T3 extends T2 implements Transformation {}
/**
+ * Tests {@link Classes#getStandardType(Class)}.
+ */
+ @Test
+ public void testGetStandardType() {
+ assertEquals(GeographicCRS.class, Classes.getStandardType(T1.class));
+ assertEquals(SingleCRS.class, Classes.getStandardType(T2.class));
+ assertEquals(Transformation.class, Classes.getStandardType(T3.class));
+ assertEquals(String.class,
Classes.getStandardType(String.class));
+ assertEquals(CharSequence.class,
Classes.getStandardType(CharSequence.class));
+ }
+
+ /**
* Tests {@link Classes#findCommonClass(Iterable)}
* and {@link Classes#findSpecializedClass(Iterable)}.
*/
Modified: sis/trunk/ide-project/NetBeans/nbproject/project.properties
URL:
http://svn.apache.org/viewvc/sis/trunk/ide-project/NetBeans/nbproject/project.properties?rev=1831430&r1=1831429&r2=1831430&view=diff
==============================================================================
--- sis/trunk/ide-project/NetBeans/nbproject/project.properties [ISO-8859-1]
(original)
+++ sis/trunk/ide-project/NetBeans/nbproject/project.properties [ISO-8859-1]
Fri May 11 16:10:59 2018
@@ -113,8 +113,9 @@ slf4j.version = 1.7.22
junit.version = 4.12
hamcrest.version = 1.3
jaxb-ns-mapper = 2.2.4
+derby.version = 10.14.2.0
hsqldb.version = 2.4.0
-postgresql.version = 42.2.1
+postgresql.version = 42.2.2
icons.version = 3.0.1
#
@@ -142,6 +143,7 @@ javac.test.classpath=\
${maven.repository}/junit/junit/${junit.version}/junit-${junit.version}.jar:\
${maven.repository}/org/hamcrest/hamcrest-core/${hamcrest.version}/hamcrest-core-${hamcrest.version}.jar:\
${maven.repository}/org/opengis/geoapi-conformance/${geoapi.version}/geoapi-conformance-${geoapi.version}.jar:\
+
${maven.repository}/org/apache/derby/derby/${derby.version}/derby-${derby.version}.jar:\
${maven.repository}/org/postgresql/postgresql/${postgresql.version}/postgresql-${postgresql.version}.jar:\
${maven.repository}/org/hsqldb/hsqldb/${hsqldb.version}/hsqldb-${hsqldb.version}.jar:\
${maven.repository}/gov/nist/math/jama/${jama.version}/jama-${jama.version}.jar:\
Modified: sis/trunk/pom.xml
URL:
http://svn.apache.org/viewvc/sis/trunk/pom.xml?rev=1831430&r1=1831429&r2=1831430&view=diff
==============================================================================
--- sis/trunk/pom.xml (original)
+++ sis/trunk/pom.xml Fri May 11 16:10:59 2018
@@ -446,7 +446,8 @@
<dependency>
<groupId>org.apache.derby</groupId>
<artifactId>derby</artifactId>
- <version>10.14.1.0</version>
+ <version>10.14.2.0</version>
+ <scope>test</scope>
</dependency>
<dependency>
<groupId>org.hsqldb</groupId>
@@ -457,7 +458,7 @@
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
- <version>42.2.1</version>
+ <version>42.2.2</version>
<scope>test</scope>
</dependency>
Modified: sis/trunk/storage/pom.xml
URL:
http://svn.apache.org/viewvc/sis/trunk/storage/pom.xml?rev=1831430&r1=1831429&r2=1831430&view=diff
==============================================================================
--- sis/trunk/storage/pom.xml (original)
+++ sis/trunk/storage/pom.xml Fri May 11 16:10:59 2018
@@ -145,6 +145,10 @@
<artifactId>geoapi-conformance</artifactId>
</dependency>
<dependency>
+ <groupId>org.apache.derby</groupId>
+ <artifactId>derby</artifactId>
+ </dependency>
+ <dependency>
<groupId>org.apache.sis.core</groupId>
<artifactId>sis-utility</artifactId>
<version>${project.version}</version>
Modified:
sis/trunk/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/DiscreteSampling.java
URL:
http://svn.apache.org/viewvc/sis/trunk/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/DiscreteSampling.java?rev=1831430&r1=1831429&r2=1831430&view=diff
==============================================================================
---
sis/trunk/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/DiscreteSampling.java
[UTF-8] (original)
+++
sis/trunk/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/DiscreteSampling.java
[UTF-8] Fri May 11 16:10:59 2018
@@ -16,7 +16,6 @@
*/
package org.apache.sis.internal.netcdf;
-import org.opengis.metadata.Metadata;
import org.apache.sis.storage.DataStore;
import org.apache.sis.setup.GeometryLibrary;
import org.apache.sis.internal.feature.Geometries;
@@ -55,18 +54,6 @@ public abstract class DiscreteSampling e
}
/**
- * Returns information about this resource.
- *
- * @return information about this resource, or {@code null} if none.
- *
- * @todo Not yet implemented.
- */
- @Override
- public Metadata getMetadata() {
- return null;
- }
-
- /**
* Returns the error message for a file that can not be read.
*
* @return default error message to use in exceptions.
Modified:
sis/trunk/storage/sis-sql/src/main/java/org/apache/sis/sql/SQLQuery.java
URL:
http://svn.apache.org/viewvc/sis/trunk/storage/sis-sql/src/main/java/org/apache/sis/sql/SQLQuery.java?rev=1831430&r1=1831429&r2=1831430&view=diff
==============================================================================
--- sis/trunk/storage/sis-sql/src/main/java/org/apache/sis/sql/SQLQuery.java
[UTF-8] (original)
+++ sis/trunk/storage/sis-sql/src/main/java/org/apache/sis/sql/SQLQuery.java
[UTF-8] Fri May 11 16:10:59 2018
@@ -19,6 +19,7 @@ package org.apache.sis.sql;
import org.apache.sis.storage.Query;
import org.apache.sis.util.ArgumentChecks;
+
/**
* An SQL query executed directly on the database.
* Such query should be transfered to the JDBC without or with minimum
modifications.
@@ -28,7 +29,7 @@ import org.apache.sis.util.ArgumentCheck
* @since 1.0
* @module
*/
-public class SQLQuery implements Query {
+public class SQLQuery extends Query {
private final String statement;
private final String name;
Modified:
sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/AbstractFeatureSet.java
URL:
http://svn.apache.org/viewvc/sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/AbstractFeatureSet.java?rev=1831430&r1=1831429&r2=1831430&view=diff
==============================================================================
---
sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/AbstractFeatureSet.java
[UTF-8] (original)
+++
sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/AbstractFeatureSet.java
[UTF-8] Fri May 11 16:10:59 2018
@@ -17,25 +17,104 @@
package org.apache.sis.internal.storage;
import org.apache.sis.storage.DataStore;
+import org.apache.sis.storage.DataStoreException;
import org.apache.sis.storage.FeatureSet;
+import org.apache.sis.storage.Query;
+import org.apache.sis.storage.UnsupportedQueryException;
+import org.apache.sis.internal.storage.query.SimpleQuery;
+import org.apache.sis.metadata.iso.DefaultMetadata;
+import org.apache.sis.metadata.iso.citation.DefaultCitation;
+import org.apache.sis.metadata.iso.identification.DefaultDataIdentification;
import org.apache.sis.util.logging.WarningListeners;
+import org.opengis.metadata.Metadata;
+import org.opengis.util.GenericName;
+
+// Branch-dependent imports
+import org.apache.sis.feature.DefaultFeatureType;
/**
* Base implementation of feature sets contained in data stores.
*
+ * @author Johann Sorel (Geomatys)
* @author Martin Desruisseaux (Geomatys)
- * @version 0.8
+ * @version 1.0
* @since 0.8
* @module
*/
public abstract class AbstractFeatureSet extends AbstractResource implements
FeatureSet {
/**
+ * A description of this set of features, or {@code null} if not yet
computed.
+ * Those metadata are created by {@link #getMetadata()} when first needed.
+ * Subclasses can set a value to this field directly.
+ */
+ protected Metadata metadata;
+
+ /**
* Creates a new resource.
*
- * @param listeners the set of registered warning listeners for the data
store.
+ * @param listeners the set of registered warning listeners for the data
store, or {@code null} if none.
*/
protected AbstractFeatureSet(final WarningListeners<DataStore> listeners) {
super(listeners);
}
+
+ /**
+ * Creates a new feature set with the same warning listeners than the
given resource,
+ * or {@code null} if the listeners are unknown.
+ *
+ * @param resource the resources from which to get the listeners, or
{@code null} if none.
+ */
+ protected AbstractFeatureSet(final FeatureSet resource) {
+ super(resource);
+ }
+
+ /**
+ * Returns a description of this set of features.
+ * Current implementation sets only the resource name; this may change in
any future Apache SIS version.
+ *
+ * <div class="note"><b>Note:</b>
+ * we currently do not set the geographic extent from the envelope because
default {@link #getEnvelope()}
+ * implementation itself invokes {@code getMetadata()}. Consequently
requesting the envelope from this
+ * method could create a never-ending loop.</div>
+ */
+ @Override
+ public synchronized Metadata getMetadata() throws DataStoreException {
+ if (metadata == null) {
+ final DefaultMetadata metadata = new DefaultMetadata();
+ final DefaultFeatureType type = getType();
+ if (type != null) {
+ final GenericName name = type.getName();
+ if (name != null) { // Paranoiac check
(should never be null).
+ final DefaultCitation citation = new
DefaultCitation(name.toInternationalString());
+ final DefaultDataIdentification identification = new
DefaultDataIdentification();
+ identification.setCitation(citation);
+ }
+ }
+ // No geographic extent - see above javadoc.
+ metadata.freeze();
+ this.metadata = metadata;
+ }
+ return metadata;
+ }
+
+ /**
+ * Requests a subset of features and/or feature properties from this
resource.
+ * The default implementation try to execute the queries by filtering the
+ * {@linkplain #features(boolean) stream of features}, which may be
inefficient.
+ * Subclasses are encouraged to override.
+ *
+ * @param query definition of feature and feature properties filtering
applied at reading time.
+ * @return resulting subset of features (never {@code null}).
+ * @throws UnsupportedQueryException if this {@code FeatureSet} can not
execute the given query.
+ * @throws DataStoreException if another error occurred while processing
the query.
+ */
+ @Override
+ public FeatureSet subset(final Query query) throws DataStoreException {
+ if (query instanceof SimpleQuery) {
+ return ((SimpleQuery) query).execute(this);
+ } else {
+ return FeatureSet.super.subset(query);
+ }
+ }
}
Modified:
sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/AbstractResource.java
URL:
http://svn.apache.org/viewvc/sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/AbstractResource.java?rev=1831430&r1=1831429&r2=1831430&view=diff
==============================================================================
---
sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/AbstractResource.java
[UTF-8] (original)
+++
sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/AbstractResource.java
[UTF-8] Fri May 11 16:10:59 2018
@@ -46,20 +46,30 @@ import org.opengis.metadata.identificati
*/
public abstract class AbstractResource implements Resource, Localized {
/**
- * The set of registered warning listeners for the data store.
+ * The set of registered warning listeners for the data store, or {@code
null} if none.
*/
protected final WarningListeners<DataStore> listeners;
/**
* Creates a new resource.
*
- * @param listeners the set of registered warning listeners for the data
store.
+ * @param listeners the set of registered warning listeners for the data
store, or {@code null} if none.
*/
protected AbstractResource(final WarningListeners<DataStore> listeners) {
this.listeners = listeners;
}
/**
+ * Creates a new resource with the same warning listeners than the given
resource,
+ * or {@code null} if the listeners are unknown.
+ *
+ * @param resource the resources from which to get the listeners, or
{@code null} if none.
+ */
+ protected AbstractResource(final Resource resource) {
+ listeners = (resource instanceof AbstractResource) ?
((AbstractResource) resource).listeners : null;
+ }
+
+ /**
* Returns the locale for error messages or warnings.
* Returns {@code null} if no locale is explicitly defined.
*
Copied:
sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/MemoryFeatureSet.java
(from r1831428,
sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/MemoryFeatureSet.java)
URL:
http://svn.apache.org/viewvc/sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/MemoryFeatureSet.java?p2=sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/MemoryFeatureSet.java&p1=sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/MemoryFeatureSet.java&r1=1831428&r2=1831430&rev=1831430&view=diff
==============================================================================
---
sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/MemoryFeatureSet.java
[UTF-8] (original)
+++
sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/MemoryFeatureSet.java
[UTF-8] Fri May 11 16:10:59 2018
@@ -21,10 +21,12 @@ import java.util.stream.Stream;
import org.apache.sis.storage.DataStore;
import org.apache.sis.util.ArgumentChecks;
import org.apache.sis.util.logging.WarningListeners;
-import org.opengis.feature.Feature;
-import org.opengis.feature.FeatureType;
import org.opengis.metadata.Metadata;
+// Branch-dependent imports
+import org.apache.sis.feature.AbstractFeature;
+import org.apache.sis.feature.DefaultFeatureType;
+
/**
* Set of features stored in memory.
@@ -40,17 +42,17 @@ public final class MemoryFeatureSet exte
/**
* The type specified at construction time and returned by {@link
#getType()}.
*/
- private final FeatureType type;
+ private final DefaultFeatureType type;
/**
* The features specified at construction time, potentially as a
modifiable collection.
- * For all features in this collection, {@link Feature#getType()} shall be
{@link #type}.
+ * For all features in this collection, {@link AbstractFeature#getType()}
shall be {@link #type}.
*/
- private final Collection<Feature> features;
+ private final Collection<AbstractFeature> features;
/**
* Creates a new set of features stored in memory. It is caller
responsibility to ensure that
- * <code>{@linkplain Feature#getType()} == type</code> for all elements in
the given collection
+ * <code>{@linkplain AbstractFeature#getType()} == type</code> for all
elements in the given collection
* (this is not verified).
*
* @param listeners the set of registered warning listeners for the data
store, or {@code null} if none.
@@ -59,7 +61,7 @@ public final class MemoryFeatureSet exte
* @param features collection of stored features. This collection will
not be copied.
*/
public MemoryFeatureSet(final WarningListeners<DataStore> listeners,
Metadata metadata,
- final FeatureType type, final Collection<Feature>
features)
+ final DefaultFeatureType type, final
Collection<AbstractFeature> features)
{
super(listeners);
ArgumentChecks.ensureNonNull("type", type);
@@ -75,7 +77,7 @@ public final class MemoryFeatureSet exte
* @return a description of properties that are common to all features in
this dataset.
*/
@Override
- public FeatureType getType() {
+ public DefaultFeatureType getType() {
return type;
}
@@ -86,7 +88,7 @@ public final class MemoryFeatureSet exte
* @return all features contained in this dataset.
*/
@Override
- public Stream<Feature> features(final boolean parallel) {
+ public Stream<AbstractFeature> features(final boolean parallel) {
return parallel ? features.parallelStream() : features.stream();
}
}
Modified:
sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/package-info.java
URL:
http://svn.apache.org/viewvc/sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/package-info.java?rev=1831430&r1=1831429&r2=1831430&view=diff
==============================================================================
---
sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/package-info.java
[UTF-8] (original)
+++
sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/package-info.java
[UTF-8] Fri May 11 16:10:59 2018
@@ -24,8 +24,9 @@
* may change in incompatible ways in any future version without notice.
*
* @author Martin Desruisseaux (Geomatys)
+ * @author Johann Sorel (Geomatys)
* @version 1.0
- * @since 0.3
+ * @since 0.4
* @module
*/
package org.apache.sis.internal.storage;