sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1547491 - in /sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gml: TM_Primitive.java TimeInstant.java TimeInstant31.java TimePeriod.java TimePeriod31.java TimePeriodBound.java
Date Tue, 03 Dec 2013 17:31:41 GMT
Author: desruisseaux
Date: Tue Dec  3 17:31:41 2013
New Revision: 1547491

URL: http://svn.apache.org/r1547491
Log:
Patch by Guilhem L├ęgal for partial support of temporal objects in GML 3.1 namespace.
This is hopefully a temporary hack, until we find a better way to support the evolutions of
GML schemas.

Added:
    sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gml/TimeInstant31.java
  (with props)
    sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gml/TimePeriod31.java
  (with props)
Modified:
    sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gml/TM_Primitive.java
    sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gml/TimeInstant.java
    sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gml/TimePeriod.java
    sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gml/TimePeriodBound.java

Modified: sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gml/TM_Primitive.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gml/TM_Primitive.java?rev=1547491&r1=1547490&r2=1547491&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gml/TM_Primitive.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gml/TM_Primitive.java
[UTF-8] Tue Dec  3 17:31:41 2013
@@ -23,6 +23,7 @@ import org.opengis.temporal.Instant;
 import org.opengis.temporal.TemporalPrimitive;
 import org.apache.sis.internal.jaxb.Context;
 import org.apache.sis.internal.jaxb.XmlUtilities;
+import org.apache.sis.internal.jaxb.LegacyNamespaces;
 import org.apache.sis.internal.jaxb.gco.PropertyType;
 import org.apache.sis.internal.util.TemporalUtilities;
 import org.apache.sis.util.resources.Errors;
@@ -35,7 +36,7 @@ import org.apache.sis.util.resources.Err
  * @author  Guilhem Legal (Geomatys)
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.3 (derived from geotk-3.00)
- * @version 0.3
+ * @version 0.4
  * @module
  */
 public final class TM_Primitive extends PropertyType<TM_Primitive, TemporalPrimitive>
{
@@ -67,6 +68,8 @@ public final class TM_Primitive extends 
 
     /**
      * Returns the GeoAPI interface which is bound by this adapter.
+     *
+     * @return {@code TemporalPrimitive.class}
      */
     @Override
     protected Class<TemporalPrimitive> getBoundType() {
@@ -74,6 +77,17 @@ public final class TM_Primitive extends 
     }
 
     /**
+     * Returns {@code true} if the user asked to format a GML 3.2 document, or {@code false}
for GML 3.1 or older.
+     * The only difference managed by this class is the namespace.
+     *
+     * <p>This method will be removed in a future SIS version if we find a better way
to support evolution
+     * of GML schemas.</p>
+     */
+    private static boolean isGML32() {
+        return Context.isGMLVersion(Context.current(), GMLAdapter.GML_3_2);
+    }
+
+    /**
      * Returns the {@code TimePeriod} generated from the metadata value.
      * This method is systematically called at marshalling-time by JAXB.
      *
@@ -81,7 +95,7 @@ public final class TM_Primitive extends 
      */
     @XmlElement(name = "TimePeriod")
     public TimePeriod getTimePeriod() {
-        if (!skip()) {
+        if (!skip() && isGML32()) {
             final TemporalPrimitive metadata = this.metadata;
             if (metadata instanceof Period) {
                 return new TimePeriod((Period) metadata);
@@ -91,6 +105,22 @@ public final class TM_Primitive extends 
     }
 
     /**
+     * Same as {@link #getTimePeriod()}, but using the GML 3.1 namespace.
+     *
+     * @return The time period, or {@code null}.
+     */
+    @XmlElement(name = "TimePeriod", namespace = LegacyNamespaces.GML)
+    public TimePeriod31 getTimePeriod31() {
+        if (!skip() && !isGML32()) {
+            final TemporalPrimitive metadata = this.metadata;
+            if (metadata instanceof Period) {
+                return new TimePeriod31((Period) metadata);
+            }
+        }
+        return null;
+    }
+
+    /**
      * Returns the {@link TimeInstant} generated from the metadata value.
      * This method is systematically called at marshalling-time by JAXB.
      *
@@ -98,7 +128,7 @@ public final class TM_Primitive extends 
      */
     @XmlElement(name = "TimeInstant")
     public TimeInstant getTimeInstant() {
-        if (!skip()) {
+        if (!skip() && isGML32()) {
             final TemporalPrimitive metadata = this.metadata;
             if (metadata instanceof Instant) {
                 return new TimeInstant((Instant) metadata);
@@ -108,10 +138,26 @@ public final class TM_Primitive extends 
     }
 
     /**
+     * Same as {@link #getTimeInstant()}, but using the GML 3.1 namespace.
+     *
+     * @return The time instant, or {@code null}.
+     */
+    @XmlElement(name = "TimeInstant", namespace = LegacyNamespaces.GML)
+    public TimeInstant31 getTimeInstant31() {
+        if (!skip() && !isGML32()) {
+            final TemporalPrimitive metadata = this.metadata;
+            if (metadata instanceof Instant) {
+                return new TimeInstant31((Instant) metadata);
+            }
+        }
+        return null;
+    }
+
+    /**
      * Sets the value from the {@link TimePeriod}.
      * This method is called at unmarshalling-time by JAXB.
      *
-     * @param period The adapter to set.
+     * @param period The wrapper to set.
      */
     public void setTimePeriod(final TimePeriod period) {
         metadata = null; // Cleaned first in case of failure.
@@ -139,10 +185,25 @@ public final class TM_Primitive extends 
     }
 
     /**
+     * Same as {@link #setTimePeriod(TimePeriod)}, but using the GML 3.1 namespace.
+     *
+     * @param period The wrapper to set.
+     */
+    public void setTimePeriod31(final TimePeriod31 period) {
+        TimePeriod c = null;
+        if (period != null) {
+            c = new TimePeriod();
+            c.begin = period.begin;
+            c.end   = period.end;
+        }
+        setTimePeriod(c);
+    }
+
+    /**
      * Sets the value from the {@link TimeInstant}.
      * This method is called at unmarshalling-time by JAXB.
      *
-     * @param instant The adapter to set.
+     * @param instant The wrapper to set.
      */
     public void setTimeInstant(final TimeInstant instant) {
         metadata = null; // Cleaned first in case of failure.
@@ -158,6 +219,20 @@ public final class TM_Primitive extends 
     }
 
     /**
+     * Same as {@link #setTimeInstant(TimeInstant)}, but using the GML 3.1 namespace.
+     *
+     * @param instant The wrapper to set.
+     */
+    public void setTimeInstant31(final TimeInstant31 instant) {
+        TimeInstant c = null;
+        if (instant != null) {
+            c = new TimeInstant();
+            c.timePosition = instant.timePosition;
+        }
+        setTimeInstant(c);
+    }
+
+    /**
      * Returns the date of the given bounds, or {@code null} if none.
      */
     private static Date toDate(final TimePeriodBound bound) {

Modified: sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gml/TimeInstant.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gml/TimeInstant.java?rev=1547491&r1=1547490&r2=1547491&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gml/TimeInstant.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gml/TimeInstant.java
[UTF-8] Tue Dec  3 17:31:41 2013
@@ -97,6 +97,8 @@ public final class TimeInstant extends G
 
     /**
      * Returns a string representation for debugging and formatting error message.
+     *
+     * @return A string representation of this time instant.
      */
     @Override
     public String toString() {

Added: sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gml/TimeInstant31.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gml/TimeInstant31.java?rev=1547491&view=auto
==============================================================================
--- sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gml/TimeInstant31.java
(added)
+++ sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gml/TimeInstant31.java
[UTF-8] Tue Dec  3 17:31:41 2013
@@ -0,0 +1,58 @@
+/*
+ * 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.
+ */
+package org.apache.sis.internal.jaxb.gml;
+
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.datatype.XMLGregorianCalendar;
+import org.opengis.temporal.Instant;
+import org.apache.sis.internal.jaxb.LegacyNamespaces;
+
+
+/**
+ * A copy of {@link TimeInstant} using GML 3.1 namespace instead than GML 3.2.
+ * This class will be deleted in a future SIS version if we find a better way
+ * to support evolution of GML schemas.
+ *
+ * @author  Guilhem Legal (Geomatys)
+ * @since   0.4
+ * @version 0.4
+ * @module
+ */
+@XmlRootElement(name="TimeInstant", namespace = LegacyNamespaces.GML)
+public final class TimeInstant31 extends GMLAdapter {
+    /**
+     * Same as {@link TimeInstant#timePosition}, but using GML 3.1 namespace.
+     */
+    @XmlElement(namespace = LegacyNamespaces.GML)
+    public XMLGregorianCalendar timePosition;
+
+    /**
+     * Same as {@link TimeInstant#TimeInstant()} but for GML 3.1 namespace.
+     */
+    public TimeInstant31() {
+    }
+
+    /**
+     * Same as {@link TimeInstant#TimeInstant(Instant)} but for GML 3.1 namespace.
+     *
+     * @param instant The initial instant value.
+     */
+    public TimeInstant31(final Instant instant) {
+        timePosition = TimeInstant.toXML(instant);
+    }
+}

Propchange: sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gml/TimeInstant31.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gml/TimeInstant31.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain;charset=UTF-8

Modified: sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gml/TimePeriod.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gml/TimePeriod.java?rev=1547491&r1=1547490&r2=1547491&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gml/TimePeriod.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gml/TimePeriod.java
[UTF-8] Tue Dec  3 17:31:41 2013
@@ -88,6 +88,8 @@ public final class TimePeriod extends GM
 
     /**
      * Returns a string representation for debugging and formatting error message.
+     *
+     * @return A string representation of this time period.
      */
     @Override
     public String toString() {

Added: sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gml/TimePeriod31.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gml/TimePeriod31.java?rev=1547491&view=auto
==============================================================================
--- sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gml/TimePeriod31.java
(added)
+++ sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gml/TimePeriod31.java
[UTF-8] Tue Dec  3 17:31:41 2013
@@ -0,0 +1,131 @@
+/*
+ * 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.
+ */
+package org.apache.sis.internal.jaxb.gml;
+
+import javax.xml.bind.annotation.XmlType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlElements;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.datatype.XMLGregorianCalendar;
+import org.opengis.temporal.Instant;
+import org.opengis.temporal.Period;
+import org.apache.sis.internal.jaxb.Context;
+import org.apache.sis.internal.jaxb.LegacyNamespaces;
+
+import static org.apache.sis.internal.jaxb.gml.GMLAdapter.GML_3_0;
+
+
+/**
+ * A copy of {@link TimePeriod} using GML 3.1 namespace instead than GML 3.2.
+ * This class will be deleted in a future SIS version if we find a better way
+ * to support evolution of GML schemas.
+ *
+ * @author  Guilhem Legal (Geomatys)
+ * @since   0.4
+ * @version 0.4
+ * @module
+ */
+@XmlRootElement(name="TimePeriod", namespace = LegacyNamespaces.GML)
+@XmlType(propOrder = {
+    "begin",
+    "end"
+})
+public final class TimePeriod31 extends GMLAdapter {
+    /**
+     * Same as {@link TimePeriod#begin}, but using GML 3.1 namespace.
+     */
+    @XmlElements({
+        @XmlElement(type=TimePeriodBound.GML3.class, name="beginPosition", namespace = LegacyNamespaces.GML),
+        @XmlElement(type=Bound.class, name="begin", namespace = LegacyNamespaces.GML)
+    })
+    TimePeriodBound begin;
+
+    /**
+     * Same as {@link TimePeriod#end}, but using GML 3.1 namespace.
+     */
+    @XmlElements({
+        @XmlElement(type=TimePeriodBound.GML3.class, name="endPosition", namespace = LegacyNamespaces.GML),
+        @XmlElement(type=Bound.class, name="end", namespace = LegacyNamespaces.GML)
+    })
+    TimePeriodBound end;
+
+    /**
+     * Same as {@link TimePeriod#TimePeriod()} but for GML 3.1 namespace.
+     */
+    public TimePeriod31() {
+    }
+
+    /**
+     * Same as {@link TimePeriod#TimePeriod(Period)} but for GML 3.1 namespace.
+     *
+     * @param period The period to use for initializing this object.
+     */
+    public TimePeriod31(final Period period) {
+        super(period);
+        if (period != null) {
+            if (Context.isGMLVersion(Context.current(), GML_3_0)) {
+                begin = new TimePeriodBound.GML3(period.getBeginning(), "before");
+                end   = new TimePeriodBound.GML3(period.getEnding(), "after");
+            } else {
+                begin = new Bound(period.getBeginning());
+                end   = new Bound(period.getEnding());
+            }
+        }
+    }
+
+    /**
+     * A copy of {@link TimePeriodBound.GML2} using GML 3.1 namespace instead than GML 3.2.
+     * This class will be deleted in a future SIS version if we find a better way to support
+     * evolution of GML schemas.
+     *
+     * @author  Guilhem Legal (Geomatys)
+     * @since   0.4
+     * @version 0.4
+     * @module
+     */
+    private static final class Bound extends TimePeriodBound {
+        /**
+         * Same as {@link TimePeriodBound.GML2#timeInstant}, but using GML 3.1 namespace.
+         */
+        @XmlElement(name = "TimeInstant", namespace = LegacyNamespaces.GML)
+        public TimeInstant timeInstant;
+
+        /**
+         * Same as {@link TimePeriodBound.GML2#GML2()} but for GML 3.1 namespace.
+         */
+        public Bound() {
+        }
+
+        /**
+         * Same as {@link TimePeriodBound.GML2#GML2(Instant)} but for GML 3.1 namespace.
+         *
+         * @param instant The instant of the new bound, or {@code null}.
+         */
+        Bound(final Instant instant) {
+            timeInstant = new TimeInstant(instant);
+        }
+
+        /**
+         * Same as {@link TimePeriodBound.GML2#calendar()} but for GML 3.1 namespace.
+         */
+        @Override
+        XMLGregorianCalendar calendar() {
+            final TimeInstant timeInstant = this.timeInstant;
+            return (timeInstant != null) ? timeInstant.timePosition : null;
+        }
+    }
+}

Propchange: sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gml/TimePeriod31.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gml/TimePeriod31.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain;charset=UTF-8

Modified: sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gml/TimePeriodBound.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gml/TimePeriodBound.java?rev=1547491&r1=1547490&r2=1547491&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gml/TimePeriodBound.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gml/TimePeriodBound.java
[UTF-8] Tue Dec  3 17:31:41 2013
@@ -52,6 +52,8 @@ public abstract class TimePeriodBound {
 
     /**
      * Returns a string representation of this bound for debugging purpose.
+     *
+     * @return A string representation of the time currently set.
      */
     @Override
     public String toString() {



Mime
View raw message