You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@olingo.apache.org by il...@apache.org on 2014/03/20 11:26:58 UTC

[04/21] git commit: WIP commits before merge

WIP commits before merge


Project: http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/commit/aa80231b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/tree/aa80231b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/diff/aa80231b

Branch: refs/heads/olingo200
Commit: aa80231bcaf9275c747c35df0a301d7bfc888fc8
Parents: cb07ded
Author: Francesco Chicchiriccò <il...@apache.org>
Authored: Sat Mar 15 15:22:48 2014 +0100
Committer: Francesco Chicchiriccò <il...@apache.org>
Committed: Sat Mar 15 15:22:48 2014 +0100

----------------------------------------------------------------------
 .../org/apache/olingo/client/api/Constants.java |  67 +++---
 .../api/domain/geospatial/Geospatial.java       | 224 ++++++++++---------
 .../olingo/client/core/edm/EdmTypeInfo.java     |  16 +-
 .../core/op/impl/AbstractODataBinder.java       |   4 +-
 4 files changed, 177 insertions(+), 134 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/aa80231b/lib/client-api/src/main/java/org/apache/olingo/client/api/Constants.java
----------------------------------------------------------------------
diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/Constants.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/Constants.java
index 091f000..f7d75e5 100644
--- a/lib/client-api/src/main/java/org/apache/olingo/client/api/Constants.java
+++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/Constants.java
@@ -19,6 +19,7 @@
 package org.apache.olingo.client.api;
 
 import javax.xml.XMLConstants;
+import javax.xml.namespace.QName;
 
 /**
  * Constant values related to the OData protocol.
@@ -41,19 +42,21 @@ public class Constants {
 
   public static final String XMLNS_DATASERVICES = XMLConstants.XMLNS_ATTRIBUTE + ":d";
 
-  public static final String PREFIX_DATASERVICES = "d:";
+  public static final String PREFIX_DATASERVICES = "d";
 
   public static final String XMLNS_METADATA = XMLConstants.XMLNS_ATTRIBUTE + ":m";
 
-  public static final String PREFIX_METADATA = "m:";
+  public static final String PREFIX_METADATA = "m";
 
   public static final String XMLNS_GEORSS = XMLConstants.XMLNS_ATTRIBUTE + ":georss";
 
-  public static final String PREFIX_GEORSS = "georss:";
+  public static final String PREFIX_GEORSS = "georss";
 
   public static final String XMLNS_GML = XMLConstants.XMLNS_ATTRIBUTE + ":gml";
 
-  public static final String PREFIX_GML = "gml:";
+  public static final String PREFIX_GML = "gml";
+
+  public final static String SRS_URLPREFIX = "http://www.opengis.net/def/crs/EPSG/0/";
 
   /**
    * Edit link rel value.
@@ -74,9 +77,11 @@ public class Constants {
 
   public final static String ATTR_TYPE = "type";
 
-  public static final String ATTR_M_TYPE = PREFIX_METADATA + ATTR_TYPE;
+  public static final String ATTR_M_TYPE = PREFIX_METADATA + ":" + ATTR_TYPE;
+
+  public final static String ATTR_NULL = "null";
 
-  public static final String ATTR_NULL = PREFIX_METADATA + "null";
+  public static final String ATTR_M_NULL = PREFIX_METADATA + ":" + ATTR_NULL;
 
   public static final String ATTR_XMLBASE = "xml:base";
 
@@ -92,39 +97,51 @@ public class Constants {
 
   public static final String ELEM_COLLECTION = "collection";
 
-  public static final String ATTR_SRSNAME = PREFIX_GML + "srsName";
+  public static final String ATTR_SRSNAME = "srsName";
+
+  public static final String ELEM_POINT = "Point";
+
+  public static final String ELEM_MULTIPOINT = "MultiPoint";
+
+  public static final String ELEM_POINTMEMBERS = "pointMembers";
 
-  public static final String ELEM_POINT = PREFIX_GML + "Point";
+  public static final QName QNAME_POINTMEMBERS = new QName(Constants.NS_GML, ELEM_POINTMEMBERS);
 
-  public static final String ELEM_MULTIPOINT = PREFIX_GML + "MultiPoint";
+  public static final String ELEM_LINESTRING = "LineString";
 
-  public static final String ELEM_POINTMEMBERS = PREFIX_GML + "pointMembers";
+  public static final QName QNAME_LINESTRING = new QName(Constants.NS_GML, ELEM_LINESTRING);
 
-  public static final String ELEM_LINESTRING = PREFIX_GML + "LineString";
+  public static final String ELEM_MULTILINESTRING = "MultiCurve";
 
-  public static final String ELEM_MULTILINESTRING = PREFIX_GML + "MultiCurve";
+  public static final String ELEM_LINESTRINGMEMBERS = "curveMembers";
 
-  public static final String ELEM_LINESTRINGMEMBERS = PREFIX_GML + "curveMembers";
+  public static final String ELEM_POLYGON = "Polygon";
 
-  public static final String ELEM_POLYGON = PREFIX_GML + "Polygon";
+  public static final QName QNAME_POLYGON = new QName(Constants.NS_GML, ELEM_POLYGON);
 
-  public static final String ELEM_POLYGON_EXTERIOR = PREFIX_GML + "exterior";
+  public static final String ELEM_POLYGON_EXTERIOR = "exterior";
 
-  public static final String ELEM_POLYGON_INTERIOR = PREFIX_GML + "interior";
+  public static final QName QNAME_POLYGON_EXTERIOR = new QName(Constants.NS_GML, ELEM_POLYGON_EXTERIOR);
 
-  public static final String ELEM_POLYGON_LINEARRING = PREFIX_GML + "LinearRing";
+  public static final String ELEM_POLYGON_INTERIOR = "interior";
 
-  public static final String ELEM_MULTIPOLYGON = PREFIX_GML + "MultiSurface";
+  public static final QName QNAME_POLYGON_INTERIOR = new QName(Constants.NS_GML, ELEM_POLYGON_INTERIOR);
 
-  public static final String ELEM_SURFACEMEMBERS = PREFIX_GML + "surfaceMembers";
+  public static final String ELEM_POLYGON_LINEARRING = "LinearRing";
 
-  public static final String ELEM_GEOCOLLECTION = PREFIX_GML + "MultiGeometry";
+  public static final String ELEM_MULTIPOLYGON = "MultiSurface";
 
-  public static final String ELEM_GEOMEMBERS = PREFIX_GML + "geometryMembers";
+  public static final String ELEM_SURFACEMEMBERS = "surfaceMembers";
 
-  public static final String ELEM_POS = PREFIX_GML + "pos";
+  public static final String ELEM_GEOCOLLECTION = "MultiGeometry";
 
-  public static final String ELEM_POSLIST = PREFIX_GML + "posList";
+  public static final String ELEM_GEOMEMBERS = "geometryMembers";
+
+  public static final QName QNAME_GEOMEMBERS = new QName(Constants.NS_GML, ELEM_GEOMEMBERS);
+
+  public static final String ELEM_POS = "pos";
+
+  public static final String ELEM_POSLIST = "posList";
 
   public static final String ELEM_PROPERTY = "property";
 
@@ -161,6 +178,8 @@ public class Constants {
 
   public final static String JSON_MEDIAEDIT_LINK_SUFFIX = "@odata.mediaEditLink";
 
+  public final static String JSON_NULL = "odata.null";
+
   public final static String JSON_VALUE = "value";
 
   public final static String JSON_URL = "url";
@@ -171,8 +190,6 @@ public class Constants {
 
   public final static String JSON_CRS = "crs";
 
-  public final static String JSON_GIS_URLPREFIX = "http://www.opengis.net/def/crs/EPSG/0/";
-
   // Atom stuff
   public final static String ATOM_ELEM_ENTRY = "entry";
 

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/aa80231b/lib/client-api/src/main/java/org/apache/olingo/client/api/domain/geospatial/Geospatial.java
----------------------------------------------------------------------
diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/domain/geospatial/Geospatial.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/domain/geospatial/Geospatial.java
index f9d0535..44e9558 100644
--- a/lib/client-api/src/main/java/org/apache/olingo/client/api/domain/geospatial/Geospatial.java
+++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/domain/geospatial/Geospatial.java
@@ -31,127 +31,139 @@ import org.apache.olingo.client.api.domain.ODataJClientEdmPrimitiveType;
  */
 public abstract class Geospatial implements Serializable {
 
-    public enum Dimension {
-
-        GEOMETRY,
-        GEOGRAPHY;
-
-    }
-
-    public enum Type {
-
-        /**
-         * The OGIS geometry type number for points.
-         */
-        POINT,
-        /**
-         * The OGIS geometry type number for lines.
-         */
-        LINESTRING,
-        /**
-         * The OGIS geometry type number for polygons.
-         */
-        POLYGON,
-        /**
-         * The OGIS geometry type number for aggregate points.
-         */
-        MULTIPOINT,
-        /**
-         * The OGIS geometry type number for aggregate lines.
-         */
-        MULTILINESTRING,
-        /**
-         * The OGIS geometry type number for aggregate polygons.
-         */
-        MULTIPOLYGON,
-        /**
-         * The OGIS geometry type number for feature collections.
-         */
-        GEOSPATIALCOLLECTION;
-
-    }
-
-    protected final Dimension dimension;
-
-    protected final Type type;
+  public enum Dimension {
 
-    /**
-     * Null value means it is expected to vary per instance.
-     */
-    protected Integer srid;
+    GEOMETRY,
+    GEOGRAPHY;
 
-    /**
-     * Constructor.
-     *
-     * @param dimension dimension.
-     * @param type type.
-     */
-    protected Geospatial(final Dimension dimension, final Type type) {
-        this.dimension = dimension;
-        this.type = type;
-    }
+  }
+
+  public enum Type {
 
     /**
-     * Gets dimension.
-     *
-     * @return dimension.
-     * @see Dimension
+     * The OGIS geometry type number for points.
      */
-    public Dimension getDimension() {
-        return dimension;
-    }
-
+    POINT,
     /**
-     * Gets type.
-     *
-     * @return type.
-     * @see Type
+     * The OGIS geometry type number for lines.
      */
-    public Type getType() {
-        return type;
-    }
-
+    LINESTRING,
     /**
-     * Gets s-rid.
-     *
-     * @return s-rid.
+     * The OGIS geometry type number for polygons.
      */
-    public Integer getSrid() {
-        return srid;
-    }
-
+    POLYGON,
     /**
-     * Sets s-rid.
-     *
-     * @param srid s-rid.
+     * The OGIS geometry type number for aggregate points.
      */
-    public void setSrid(final Integer srid) {
-        this.srid = srid;
-    }
-
-    public abstract ODataJClientEdmPrimitiveType getEdmSimpleType();
-
+    MULTIPOINT,
     /**
-     * {@inheritDoc }
+     * The OGIS geometry type number for aggregate lines.
      */
-    @Override
-    public boolean equals(final Object obj) {
-        return EqualsBuilder.reflectionEquals(this, obj);
-    }
-
+    MULTILINESTRING,
     /**
-     * {@inheritDoc }
+     * The OGIS geometry type number for aggregate polygons.
      */
-    @Override
-    public int hashCode() {
-        return HashCodeBuilder.reflectionHashCode(this);
-    }
-
+    MULTIPOLYGON,
     /**
-     * {@inheritDoc }
+     * The OGIS geometry type number for feature collections.
      */
-    @Override
-    public String toString() {
-        return ReflectionToStringBuilder.toString(this, ToStringStyle.MULTI_LINE_STYLE);
-    }
+    GEOSPATIALCOLLECTION;
+
+  }
+
+  protected final Dimension dimension;
+
+  protected final Type type;
+
+  protected String crs;
+
+  /**
+   * Null value means it is expected to vary per instance.
+   */
+  protected Integer srid;
+
+  /**
+   * Constructor.
+   *
+   * @param dimension dimension.
+   * @param type type.
+   */
+  protected Geospatial(final Dimension dimension, final Type type, final String crs) {
+    this.dimension = dimension;
+    this.type = type;
+    this.crs = crs;
+  }
+
+  /**
+   * Gets dimension.
+   *
+   * @return dimension.
+   * @see Dimension
+   */
+  public Dimension getDimension() {
+    return dimension;
+  }
+
+  /**
+   * Gets type.
+   *
+   * @return type.
+   * @see Type
+   */
+  public Type getType() {
+    return type;
+  }
+
+  /**
+   * Gets CRS.
+   *
+   * @return CRS
+   */
+  public String getCrs() {
+    return crs;
+  }
+
+  /**
+   * Gets s-rid.
+   *
+   * @return s-rid.
+   */
+  public Integer getSrid() {
+    return srid;
+  }
+
+  /**
+   * Sets s-rid.
+   *
+   * @param srid s-rid.
+   */
+  public void setSrid(final Integer srid) {
+    this.srid = srid;
+  }
+
+  public abstract ODataJClientEdmPrimitiveType getEdmSimpleType();
+
+  /**
+   * {@inheritDoc }
+   */
+  @Override
+  public boolean equals(final Object obj) {
+    return EqualsBuilder.reflectionEquals(this, obj);
+  }
+
+  /**
+   * {@inheritDoc }
+   */
+  @Override
+  public int hashCode() {
+    return HashCodeBuilder.reflectionHashCode(this);
+  }
+
+  /**
+   * {@inheritDoc }
+   */
+  @Override
+  public String toString() {
+    return ReflectionToStringBuilder.toString(this, ToStringStyle.MULTI_LINE_STYLE);
+  }
 }

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/aa80231b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmTypeInfo.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmTypeInfo.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmTypeInfo.java
index b8e930f..2cfb2cb 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmTypeInfo.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmTypeInfo.java
@@ -18,6 +18,7 @@
  */
 package org.apache.olingo.client.core.edm;
 
+import org.apache.commons.lang3.NotImplementedException;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.olingo.commons.api.edm.Edm;
 import org.apache.olingo.commons.api.edm.EdmComplexType;
@@ -73,6 +74,8 @@ public class EdmTypeInfo {
 
   private EdmPrimitiveType primitiveType;
 
+  private final boolean geospatialType;
+
   private EdmEnumType enumType;
 
   private EdmComplexType complexType;
@@ -116,6 +119,9 @@ public class EdmTypeInfo {
     } catch (IllegalArgumentException e) {
       LOG.debug("{} does not appear to refer to an Edm primitive type", this.fullQualifiedName);
     }
+    // TODO: implement Geospatial types!
+    this.geospatialType = this.fullQualifiedName.getNamespace().equals(EdmPrimitiveType.EDM_NAMESPACE)
+            && this.fullQualifiedName.getName().startsWith("Geo");
     if (this.primitiveType == null && this.edm != null) {
       this.enumType = this.edm.getEnumType(this.fullQualifiedName);
       if (this.enumType == null) {
@@ -140,13 +146,21 @@ public class EdmTypeInfo {
   }
 
   public boolean isPrimitiveType() {
-    return this.primitiveType != null;
+    return this.primitiveType != null || isGeospatialType();
   }
 
   public EdmPrimitiveType getPrimitiveType() {
     return primitiveType;
   }
 
+  public boolean isGeospatialType() {
+    return geospatialType;
+  }
+
+  public Object getGeospatialType() {
+    throw new NotImplementedException("Geospatial types missing");
+  }
+
   public boolean isEnumType() {
     return this.enumType != null;
   }

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/aa80231b/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/AbstractODataBinder.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/AbstractODataBinder.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/AbstractODataBinder.java
index edead41..bdb968c 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/AbstractODataBinder.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/AbstractODataBinder.java
@@ -367,7 +367,7 @@ public abstract class AbstractODataBinder implements ODataBinder {
   public ODataProperty getODataProperty(final Element property) {
     final ODataProperty res;
 
-    final Node nullNode = property.getAttributes().getNamedItem(Constants.ATTR_NULL);
+    final Node nullNode = property.getAttributes().getNamedItem(Constants.ATTR_M_NULL);
 
     if (nullNode == null) {
       final ODataJClientEdmType edmType = StringUtils.isBlank(property.getAttribute(Constants.ATTR_M_TYPE))
@@ -463,7 +463,7 @@ public abstract class AbstractODataBinder implements ODataBinder {
 
   protected Element toNullPropertyElement(final ODataProperty prop, final Document doc) {
     final Element element = doc.createElement(Constants.PREFIX_DATASERVICES + prop.getName());
-    element.setAttribute(Constants.ATTR_NULL, Boolean.toString(true));
+    element.setAttribute(Constants.ATTR_M_NULL, Boolean.toString(true));
     return element;
   }