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/07 10:09:03 UTC
[14/57] [abbrv] [OLINGO-169] Introducing V3 and V4 metadata parsing
tests - still using dummy Edm interfaces
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/e7135610/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/edm/v4/PropertyImpl.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/edm/v4/PropertyImpl.java b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/edm/v4/PropertyImpl.java
index 00c4567..05d1b50 100644
--- a/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/edm/v4/PropertyImpl.java
+++ b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/edm/v4/PropertyImpl.java
@@ -18,6 +18,7 @@
*/
package org.apache.olingo.odata4.client.core.edm.v4;
+import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import org.apache.olingo.odata4.client.api.edm.v4.Annotation;
import org.apache.olingo.odata4.client.core.edm.AbstractProperty;
@@ -27,15 +28,16 @@ public class PropertyImpl extends AbstractProperty implements AnnotatedEdmItem {
private static final long serialVersionUID = -5541908235094985412L;
@JsonProperty("Annotation")
- private Annotation annotation;
+ private AnnotationImpl annotation;
@Override
- public Annotation getAnnotation() {
+ public AnnotationImpl getAnnotation() {
return annotation;
}
+ @JsonIgnore
@Override
public void setAnnotation(final Annotation annotation) {
- this.annotation = annotation;
+ this.annotation = (AnnotationImpl) annotation;
}
}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/e7135610/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/edm/v4/ReferenceDeserializer.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/edm/v4/ReferenceDeserializer.java b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/edm/v4/ReferenceDeserializer.java
index 2fd0ef9..5cceb75 100644
--- a/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/edm/v4/ReferenceDeserializer.java
+++ b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/edm/v4/ReferenceDeserializer.java
@@ -24,7 +24,7 @@ import com.fasterxml.jackson.core.JsonToken;
import com.fasterxml.jackson.databind.DeserializationContext;
import java.io.IOException;
import java.net.URI;
-import org.apache.olingo.odata4.client.core.data.impl.AbstractEdmDeserializer;
+import org.apache.olingo.odata4.client.core.op.impl.AbstractEdmDeserializer;
public class ReferenceDeserializer extends AbstractEdmDeserializer<ReferenceImpl> {
@@ -41,13 +41,13 @@ public class ReferenceDeserializer extends AbstractEdmDeserializer<ReferenceImpl
reference.setUri(URI.create(jp.nextTextValue()));
} else if ("Include".equals(jp.getCurrentName())) {
jp.nextToken();
- reference.getIncludes().add(jp.getCodec().readValue(jp, IncludeImpl.class));
+ reference.getIncludes().add(jp.readValueAs( IncludeImpl.class));
} else if ("IncludeAnnotations".equals(jp.getCurrentName())) {
jp.nextToken();
- reference.getIncludeAnnotations().add(jp.getCodec().readValue(jp, IncludeAnnotationsImpl.class));
+ reference.getIncludeAnnotations().add(jp.readValueAs( IncludeAnnotationsImpl.class));
} else if ("Annotation".equals(jp.getCurrentName())) {
jp.nextToken();
- reference.getAnnotations().add(jp.getCodec().readValue(jp, AnnotationImpl.class));
+ reference.getAnnotations().add(jp.readValueAs( AnnotationImpl.class));
}
}
}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/e7135610/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/edm/v4/SingletonDeserializer.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/edm/v4/SingletonDeserializer.java b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/edm/v4/SingletonDeserializer.java
index 306aabb..e5520ca 100644
--- a/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/edm/v4/SingletonDeserializer.java
+++ b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/edm/v4/SingletonDeserializer.java
@@ -23,7 +23,7 @@ import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.JsonToken;
import com.fasterxml.jackson.databind.DeserializationContext;
import java.io.IOException;
-import org.apache.olingo.odata4.client.core.data.impl.AbstractEdmDeserializer;
+import org.apache.olingo.odata4.client.core.op.impl.AbstractEdmDeserializer;
public class SingletonDeserializer extends AbstractEdmDeserializer<SingletonImpl> {
@@ -43,10 +43,10 @@ public class SingletonDeserializer extends AbstractEdmDeserializer<SingletonImpl
} else if ("NavigationPropertyBinding".equals(jp.getCurrentName())) {
jp.nextToken();
singleton.getNavigationPropertyBindings().add(
- jp.getCodec().readValue(jp, NavigationPropertyBindingImpl.class));
+ jp.readValueAs( NavigationPropertyBindingImpl.class));
} else if ("Annotation".equals(jp.getCurrentName())) {
jp.nextToken();
- singleton.setAnnotation(jp.getCodec().readValue(jp, AnnotationImpl.class));
+ singleton.setAnnotation(jp.readValueAs( AnnotationImpl.class));
}
}
}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/e7135610/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/edm/v4/SingletonImpl.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/edm/v4/SingletonImpl.java b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/edm/v4/SingletonImpl.java
index 6c62467..a904668 100644
--- a/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/edm/v4/SingletonImpl.java
+++ b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/edm/v4/SingletonImpl.java
@@ -21,7 +21,6 @@ package org.apache.olingo.odata4.client.core.edm.v4;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import java.util.ArrayList;
import java.util.List;
-import org.apache.olingo.odata4.client.api.edm.NavigationPropertyBinding;
import org.apache.olingo.odata4.client.api.edm.v4.Singleton;
@JsonDeserialize(using = SingletonDeserializer.class)
@@ -33,8 +32,8 @@ public class SingletonImpl extends AbstractAnnotatedEdmItem implements Singleton
private String type;
- private final List<NavigationPropertyBinding> navigationPropertyBindings
- = new ArrayList<NavigationPropertyBinding>();
+ private final List<NavigationPropertyBindingImpl> navigationPropertyBindings
+ = new ArrayList<NavigationPropertyBindingImpl>();
public String getName() {
return name;
@@ -52,7 +51,7 @@ public class SingletonImpl extends AbstractAnnotatedEdmItem implements Singleton
this.type = type;
}
- public List<NavigationPropertyBinding> getNavigationPropertyBindings() {
+ public List<NavigationPropertyBindingImpl> getNavigationPropertyBindings() {
return navigationPropertyBindings;
}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/e7135610/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/edm/v4/TermDeserializer.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/edm/v4/TermDeserializer.java b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/edm/v4/TermDeserializer.java
index af18cf4..38a267e 100644
--- a/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/edm/v4/TermDeserializer.java
+++ b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/edm/v4/TermDeserializer.java
@@ -27,7 +27,7 @@ import java.math.BigInteger;
import org.apache.commons.lang3.BooleanUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.olingo.odata4.client.api.edm.v4.CSDLElement;
-import org.apache.olingo.odata4.client.core.data.impl.AbstractEdmDeserializer;
+import org.apache.olingo.odata4.client.core.op.impl.AbstractEdmDeserializer;
public class TermDeserializer extends AbstractEdmDeserializer<TermImpl> {
@@ -64,7 +64,7 @@ public class TermDeserializer extends AbstractEdmDeserializer<TermImpl> {
}
} else if ("Annotation".equals(jp.getCurrentName())) {
jp.nextToken();
- term.setAnnotation(jp.getCodec().readValue(jp, AnnotationImpl.class));
+ term.setAnnotation(jp.readValueAs( AnnotationImpl.class));
}
}
}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/e7135610/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/edm/v4/TypeDefinitionDeserializer.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/edm/v4/TypeDefinitionDeserializer.java b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/edm/v4/TypeDefinitionDeserializer.java
index df340f1..ff71d77 100644
--- a/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/edm/v4/TypeDefinitionDeserializer.java
+++ b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/edm/v4/TypeDefinitionDeserializer.java
@@ -25,7 +25,7 @@ import com.fasterxml.jackson.databind.DeserializationContext;
import java.io.IOException;
import java.math.BigInteger;
import org.apache.commons.lang3.BooleanUtils;
-import org.apache.olingo.odata4.client.core.data.impl.AbstractEdmDeserializer;
+import org.apache.olingo.odata4.client.core.op.impl.AbstractEdmDeserializer;
public class TypeDefinitionDeserializer extends AbstractEdmDeserializer<TypeDefinitionImpl> {
@@ -54,7 +54,7 @@ public class TypeDefinitionDeserializer extends AbstractEdmDeserializer<TypeDefi
typeDefinition.setSrid(jp.nextTextValue());
} else if ("Annotation".equals(jp.getCurrentName())) {
jp.nextToken();
- typeDefinition.getAnnotations().add(jp.getCodec().readValue(jp, AnnotationImpl.class));
+ typeDefinition.getAnnotations().add(jp.readValueAs( AnnotationImpl.class));
}
}
}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/e7135610/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/edm/v4/annotation/ApplyDeserializer.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/edm/v4/annotation/ApplyDeserializer.java b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/edm/v4/annotation/ApplyDeserializer.java
index 2c427ea..9d03068 100644
--- a/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/edm/v4/annotation/ApplyDeserializer.java
+++ b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/edm/v4/annotation/ApplyDeserializer.java
@@ -23,7 +23,7 @@ import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.JsonToken;
import com.fasterxml.jackson.databind.DeserializationContext;
import java.io.IOException;
-import org.apache.olingo.odata4.client.core.data.impl.AbstractEdmDeserializer;
+import org.apache.olingo.odata4.client.core.op.impl.AbstractEdmDeserializer;
import org.apache.olingo.odata4.client.core.edm.v4.AnnotationImpl;
public class ApplyDeserializer extends AbstractEdmDeserializer<Apply> {
@@ -40,11 +40,11 @@ public class ApplyDeserializer extends AbstractEdmDeserializer<Apply> {
if ("Function".equals(jp.getCurrentName())) {
apply.setFunction(jp.nextTextValue());
} else if ("Annotation".equals(jp.getCurrentName())) {
- apply.setAnnotation(jp.getCodec().readValue(jp, AnnotationImpl.class));
+ apply.setAnnotation(jp.readValueAs( AnnotationImpl.class));
} else if (isAnnotationConstExprConstruct(jp)) {
apply.getParameters().add(parseAnnotationConstExprConstruct(jp));
} else {
- apply.getParameters().add(jp.getCodec().readValue(jp, DynExprConstruct.class));
+ apply.getParameters().add(jp.readValueAs( DynExprConstruct.class));
}
}
}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/e7135610/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/edm/v4/annotation/CastDeserializer.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/edm/v4/annotation/CastDeserializer.java b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/edm/v4/annotation/CastDeserializer.java
index 7721171..3219776 100644
--- a/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/edm/v4/annotation/CastDeserializer.java
+++ b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/edm/v4/annotation/CastDeserializer.java
@@ -24,7 +24,7 @@ import com.fasterxml.jackson.core.JsonToken;
import com.fasterxml.jackson.databind.DeserializationContext;
import java.io.IOException;
import java.math.BigInteger;
-import org.apache.olingo.odata4.client.core.data.impl.AbstractEdmDeserializer;
+import org.apache.olingo.odata4.client.core.op.impl.AbstractEdmDeserializer;
import org.apache.olingo.odata4.client.core.edm.v4.AnnotationImpl;
public class CastDeserializer extends AbstractEdmDeserializer<Cast> {
@@ -41,7 +41,7 @@ public class CastDeserializer extends AbstractEdmDeserializer<Cast> {
if ("Type".equals(jp.getCurrentName())) {
cast.setType(jp.nextTextValue());
} else if ("Annotation".equals(jp.getCurrentName())) {
- cast.setAnnotation(jp.getCodec().readValue(jp, AnnotationImpl.class));
+ cast.setAnnotation(jp.readValueAs( AnnotationImpl.class));
} else if ("MaxLength".equals(jp.getCurrentName())) {
cast.setMaxLength(jp.nextTextValue());
} else if ("Precision".equals(jp.getCurrentName())) {
@@ -51,7 +51,7 @@ public class CastDeserializer extends AbstractEdmDeserializer<Cast> {
} else if ("SRID".equals(jp.getCurrentName())) {
cast.setSrid(jp.nextTextValue());
} else {
- cast.setValue(jp.getCodec().readValue(jp, DynExprConstruct.class));
+ cast.setValue(jp.readValueAs( DynExprConstruct.class));
}
}
}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/e7135610/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/edm/v4/annotation/CollectionDeserializer.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/edm/v4/annotation/CollectionDeserializer.java b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/edm/v4/annotation/CollectionDeserializer.java
index e117536..986a22a 100644
--- a/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/edm/v4/annotation/CollectionDeserializer.java
+++ b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/edm/v4/annotation/CollectionDeserializer.java
@@ -23,7 +23,7 @@ import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.JsonToken;
import com.fasterxml.jackson.databind.DeserializationContext;
import java.io.IOException;
-import org.apache.olingo.odata4.client.core.data.impl.AbstractEdmDeserializer;
+import org.apache.olingo.odata4.client.core.op.impl.AbstractEdmDeserializer;
public class CollectionDeserializer extends AbstractEdmDeserializer<Collection> {
@@ -39,7 +39,7 @@ public class CollectionDeserializer extends AbstractEdmDeserializer<Collection>
if (isAnnotationConstExprConstruct(jp)) {
collection.getItems().add(parseAnnotationConstExprConstruct(jp));
} else {
- collection.getItems().add(jp.getCodec().readValue(jp, DynExprConstruct.class));
+ collection.getItems().add(jp.readValueAs( DynExprConstruct.class));
}
}
}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/e7135610/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/edm/v4/annotation/DynExprConstructDeserializer.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/edm/v4/annotation/DynExprConstructDeserializer.java b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/edm/v4/annotation/DynExprConstructDeserializer.java
index 01ea538..3f80881 100644
--- a/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/edm/v4/annotation/DynExprConstructDeserializer.java
+++ b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/edm/v4/annotation/DynExprConstructDeserializer.java
@@ -26,7 +26,7 @@ import com.fasterxml.jackson.databind.DeserializationContext;
import java.io.IOException;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.ClassUtils;
-import org.apache.olingo.odata4.client.core.data.impl.AbstractEdmDeserializer;
+import org.apache.olingo.odata4.client.core.op.impl.AbstractEdmDeserializer;
public class DynExprConstructDeserializer extends AbstractEdmDeserializer<DynExprConstruct> {
@@ -67,7 +67,7 @@ public class DynExprConstructDeserializer extends AbstractEdmDeserializer<DynExp
if (isAnnotationConstExprConstruct(jp)) {
result = parseAnnotationConstExprConstruct(jp);
} else {
- result = jp.getCodec().readValue(jp, DynExprConstruct.class);
+ result = jp.readValueAs( DynExprConstruct.class);
}
jp.nextToken();
@@ -86,7 +86,7 @@ public class DynExprConstructDeserializer extends AbstractEdmDeserializer<DynExp
jp.nextToken();
jp.nextToken();
- dynExprSingleParamOp.setExpression(jp.getCodec().readValue(jp, DynExprConstruct.class));
+ dynExprSingleParamOp.setExpression(jp.readValueAs( DynExprConstruct.class));
construct = dynExprSingleParamOp;
} else if (DynExprDoubleParamOp.Type.fromString(jp.getCurrentName()) != null) {
@@ -95,8 +95,8 @@ public class DynExprConstructDeserializer extends AbstractEdmDeserializer<DynExp
jp.nextToken();
jp.nextToken();
- dynExprDoubleParamOp.setLeft(jp.getCodec().readValue(jp, DynExprConstruct.class));
- dynExprDoubleParamOp.setRight(jp.getCodec().readValue(jp, DynExprConstruct.class));
+ dynExprDoubleParamOp.setLeft(jp.readValueAs( DynExprConstruct.class));
+ dynExprDoubleParamOp.setRight(jp.readValueAs( DynExprConstruct.class));
construct = dynExprDoubleParamOp;
} else if (ArrayUtils.contains(EL_OR_ATTR, jp.getCurrentName())) {
@@ -106,13 +106,13 @@ public class DynExprConstructDeserializer extends AbstractEdmDeserializer<DynExp
construct = elOrAttr;
} else if (APPLY.equals(jp.getCurrentName())) {
jp.nextToken();
- construct = jp.getCodec().readValue(jp, Apply.class);
+ construct = jp.readValueAs( Apply.class);
} else if (CAST.equals(jp.getCurrentName())) {
jp.nextToken();
- construct = jp.getCodec().readValue(jp, Cast.class);
+ construct = jp.readValueAs( Cast.class);
} else if (COLLECTION.equals(jp.getCurrentName())) {
jp.nextToken();
- construct = jp.getCodec().readValue(jp, Collection.class);
+ construct = jp.readValueAs( Collection.class);
} else if (IF.equals(jp.getCurrentName())) {
jp.nextToken();
jp.nextToken();
@@ -125,19 +125,19 @@ public class DynExprConstructDeserializer extends AbstractEdmDeserializer<DynExp
construct = _if;
} else if (IS_OF.equals(jp.getCurrentName())) {
jp.nextToken();
- construct = jp.getCodec().readValue(jp, IsOf.class);
+ construct = jp.readValueAs( IsOf.class);
} else if (LABELED_ELEMENT.equals(jp.getCurrentName())) {
jp.nextToken();
- construct = jp.getCodec().readValue(jp, LabeledElement.class);
+ construct = jp.readValueAs( LabeledElement.class);
} else if (NULL.equals(jp.getCurrentName())) {
jp.nextToken();
- construct = jp.getCodec().readValue(jp, Null.class);
+ construct = jp.readValueAs( Null.class);
} else if (RECORD.equals(jp.getCurrentName())) {
jp.nextToken();
- construct = jp.getCodec().readValue(jp, Record.class);
+ construct = jp.readValueAs( Record.class);
} else if (URL_REF.equals(jp.getCurrentName())) {
jp.nextToken();
- construct = jp.getCodec().readValue(jp, UrlRef.class);
+ construct = jp.readValueAs( UrlRef.class);
}
return construct;
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/e7135610/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/edm/v4/annotation/IsOfDeserializer.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/edm/v4/annotation/IsOfDeserializer.java b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/edm/v4/annotation/IsOfDeserializer.java
index 52187f4..071a1c6 100644
--- a/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/edm/v4/annotation/IsOfDeserializer.java
+++ b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/edm/v4/annotation/IsOfDeserializer.java
@@ -24,7 +24,7 @@ import com.fasterxml.jackson.core.JsonToken;
import com.fasterxml.jackson.databind.DeserializationContext;
import java.io.IOException;
import java.math.BigInteger;
-import org.apache.olingo.odata4.client.core.data.impl.AbstractEdmDeserializer;
+import org.apache.olingo.odata4.client.core.op.impl.AbstractEdmDeserializer;
import org.apache.olingo.odata4.client.core.edm.v4.AnnotationImpl;
public class IsOfDeserializer extends AbstractEdmDeserializer<IsOf> {
@@ -41,7 +41,7 @@ public class IsOfDeserializer extends AbstractEdmDeserializer<IsOf> {
if ("Type".equals(jp.getCurrentName())) {
isof.setType(jp.nextTextValue());
} else if ("Annotation".equals(jp.getCurrentName())) {
- isof.setAnnotation(jp.getCodec().readValue(jp, AnnotationImpl.class));
+ isof.setAnnotation(jp.readValueAs( AnnotationImpl.class));
} else if ("MaxLength".equals(jp.getCurrentName())) {
isof.setMaxLength(jp.nextTextValue());
} else if ("Precision".equals(jp.getCurrentName())) {
@@ -51,7 +51,7 @@ public class IsOfDeserializer extends AbstractEdmDeserializer<IsOf> {
} else if ("SRID".equals(jp.getCurrentName())) {
isof.setSrid(jp.nextTextValue());
} else {
- isof.setValue(jp.getCodec().readValue(jp, DynExprConstruct.class));
+ isof.setValue(jp.readValueAs( DynExprConstruct.class));
}
}
}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/e7135610/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/edm/v4/annotation/LabeledElementDeserializer.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/edm/v4/annotation/LabeledElementDeserializer.java b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/edm/v4/annotation/LabeledElementDeserializer.java
index ae70f55..1f238b7 100644
--- a/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/edm/v4/annotation/LabeledElementDeserializer.java
+++ b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/edm/v4/annotation/LabeledElementDeserializer.java
@@ -23,7 +23,7 @@ import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.JsonToken;
import com.fasterxml.jackson.databind.DeserializationContext;
import java.io.IOException;
-import org.apache.olingo.odata4.client.core.data.impl.AbstractEdmDeserializer;
+import org.apache.olingo.odata4.client.core.op.impl.AbstractEdmDeserializer;
import org.apache.olingo.odata4.client.core.edm.v4.AnnotationImpl;
public class LabeledElementDeserializer extends AbstractEdmDeserializer<LabeledElement> {
@@ -40,9 +40,9 @@ public class LabeledElementDeserializer extends AbstractEdmDeserializer<LabeledE
if ("Name".equals(jp.getCurrentName())) {
element.setName(jp.nextTextValue());
} else if ("Annotation".equals(jp.getCurrentName())) {
- element.setAnnotation(jp.getCodec().readValue(jp, AnnotationImpl.class));
+ element.setAnnotation(jp.readValueAs( AnnotationImpl.class));
} else {
- element.setValue(jp.getCodec().readValue(jp, DynExprConstruct.class));
+ element.setValue(jp.readValueAs( DynExprConstruct.class));
}
}
}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/e7135610/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/edm/v4/annotation/NullDeserializer.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/edm/v4/annotation/NullDeserializer.java b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/edm/v4/annotation/NullDeserializer.java
index f61ce50..3aa7db7 100644
--- a/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/edm/v4/annotation/NullDeserializer.java
+++ b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/edm/v4/annotation/NullDeserializer.java
@@ -23,7 +23,7 @@ import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.JsonToken;
import com.fasterxml.jackson.databind.DeserializationContext;
import java.io.IOException;
-import org.apache.olingo.odata4.client.core.data.impl.AbstractEdmDeserializer;
+import org.apache.olingo.odata4.client.core.op.impl.AbstractEdmDeserializer;
import org.apache.olingo.odata4.client.core.edm.v4.AnnotationImpl;
public class NullDeserializer extends AbstractEdmDeserializer<Null> {
@@ -38,7 +38,7 @@ public class NullDeserializer extends AbstractEdmDeserializer<Null> {
final JsonToken token = jp.getCurrentToken();
if (token == JsonToken.FIELD_NAME) {
if ("Annotation".equals(jp.getCurrentName())) {
- _null.setAnnotation(jp.getCodec().readValue(jp, AnnotationImpl.class));
+ _null.setAnnotation(jp.readValueAs( AnnotationImpl.class));
}
}
}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/e7135610/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/edm/v4/annotation/PropertyValueDeserializer.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/edm/v4/annotation/PropertyValueDeserializer.java b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/edm/v4/annotation/PropertyValueDeserializer.java
index 66793ab..0e48dfc 100644
--- a/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/edm/v4/annotation/PropertyValueDeserializer.java
+++ b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/edm/v4/annotation/PropertyValueDeserializer.java
@@ -23,7 +23,7 @@ import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.JsonToken;
import com.fasterxml.jackson.databind.DeserializationContext;
import java.io.IOException;
-import org.apache.olingo.odata4.client.core.data.impl.AbstractEdmDeserializer;
+import org.apache.olingo.odata4.client.core.op.impl.AbstractEdmDeserializer;
import org.apache.olingo.odata4.client.core.edm.v4.AnnotationImpl;
public class PropertyValueDeserializer extends AbstractEdmDeserializer<PropertyValue> {
@@ -40,11 +40,11 @@ public class PropertyValueDeserializer extends AbstractEdmDeserializer<PropertyV
if ("Property".equals(jp.getCurrentName())) {
propValue.setProperty(jp.nextTextValue());
} else if ("Annotation".equals(jp.getCurrentName())) {
- propValue.setAnnotation(jp.getCodec().readValue(jp, AnnotationImpl.class));
+ propValue.setAnnotation(jp.readValueAs( AnnotationImpl.class));
} else if (isAnnotationConstExprConstruct(jp)) {
propValue.setValue(parseAnnotationConstExprConstruct(jp));
} else {
- propValue.setValue(jp.getCodec().readValue(jp, DynExprConstruct.class));
+ propValue.setValue(jp.readValueAs( DynExprConstruct.class));
}
}
}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/e7135610/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/edm/v4/annotation/RecordDeserializer.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/edm/v4/annotation/RecordDeserializer.java b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/edm/v4/annotation/RecordDeserializer.java
index 5d9c4ab..d14f007 100644
--- a/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/edm/v4/annotation/RecordDeserializer.java
+++ b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/edm/v4/annotation/RecordDeserializer.java
@@ -23,7 +23,7 @@ import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.JsonToken;
import com.fasterxml.jackson.databind.DeserializationContext;
import java.io.IOException;
-import org.apache.olingo.odata4.client.core.data.impl.AbstractEdmDeserializer;
+import org.apache.olingo.odata4.client.core.op.impl.AbstractEdmDeserializer;
import org.apache.olingo.odata4.client.core.edm.v4.AnnotationImpl;
public class RecordDeserializer extends AbstractEdmDeserializer<Record> {
@@ -40,9 +40,9 @@ public class RecordDeserializer extends AbstractEdmDeserializer<Record> {
if ("Tyoe".equals(jp.getCurrentName())) {
record.setType(jp.nextTextValue());
} else if ("Annotation".equals(jp.getCurrentName())) {
- record.setAnnotation(jp.getCodec().readValue(jp, AnnotationImpl.class));
+ record.setAnnotation(jp.readValueAs( AnnotationImpl.class));
} else {
- record.getPropertyValues().add(jp.getCodec().readValue(jp, PropertyValue.class));
+ record.getPropertyValues().add(jp.readValueAs( PropertyValue.class));
}
}
}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/e7135610/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/edm/v4/annotation/UrlRefDeserializer.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/edm/v4/annotation/UrlRefDeserializer.java b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/edm/v4/annotation/UrlRefDeserializer.java
index 57a9f5c..b37c3e8 100644
--- a/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/edm/v4/annotation/UrlRefDeserializer.java
+++ b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/edm/v4/annotation/UrlRefDeserializer.java
@@ -23,7 +23,7 @@ import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.JsonToken;
import com.fasterxml.jackson.databind.DeserializationContext;
import java.io.IOException;
-import org.apache.olingo.odata4.client.core.data.impl.AbstractEdmDeserializer;
+import org.apache.olingo.odata4.client.core.op.impl.AbstractEdmDeserializer;
public class UrlRefDeserializer extends AbstractEdmDeserializer<UrlRef> {
@@ -39,7 +39,7 @@ public class UrlRefDeserializer extends AbstractEdmDeserializer<UrlRef> {
if (isAnnotationConstExprConstruct(jp)) {
urlref.setValue(parseAnnotationConstExprConstruct(jp));
} else {
- urlref.setValue(jp.getCodec().readValue(jp, DynExprConstruct.class));
+ urlref.setValue(jp.readValueAs( DynExprConstruct.class));
}
}
}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/e7135610/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/op/impl/AbstractEdmDeserializer.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/op/impl/AbstractEdmDeserializer.java b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/op/impl/AbstractEdmDeserializer.java
new file mode 100644
index 0000000..6e6e103
--- /dev/null
+++ b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/op/impl/AbstractEdmDeserializer.java
@@ -0,0 +1,69 @@
+/*
+ * 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.olingo.odata4.client.core.op.impl;
+
+import com.fasterxml.jackson.core.JsonParser;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.DeserializationContext;
+import com.fasterxml.jackson.databind.JsonDeserializer;
+import com.fasterxml.jackson.dataformat.xml.deser.FromXmlParser;
+import java.io.IOException;
+import org.apache.olingo.odata4.client.api.ODataClient;
+import org.apache.olingo.odata4.client.core.edm.v4.ReturnTypeImpl;
+import org.apache.olingo.odata4.client.core.edm.v4.annotation.ConstExprConstruct;
+
+public abstract class AbstractEdmDeserializer<T> extends JsonDeserializer<T> {
+
+ protected ODataClient client;
+
+ protected boolean isAnnotationConstExprConstruct(final JsonParser jp) throws IOException {
+ return ConstExprConstruct.Type.fromString(jp.getCurrentName()) != null;
+ }
+
+ protected ConstExprConstruct parseAnnotationConstExprConstruct(final JsonParser jp) throws IOException {
+ final ConstExprConstruct constExpr = new ConstExprConstruct();
+ constExpr.setType(ConstExprConstruct.Type.fromString(jp.getCurrentName()));
+ constExpr.setValue(jp.nextTextValue());
+ return constExpr;
+ }
+
+ protected ReturnTypeImpl parseReturnType(final JsonParser jp, final String elementName) throws IOException {
+ ReturnTypeImpl returnType;
+ if (elementName.equals(((FromXmlParser) jp).getStaxReader().getLocalName())) {
+ returnType = new ReturnTypeImpl();
+ returnType.setType(jp.nextTextValue());
+ } else {
+ jp.nextToken();
+ returnType = jp.readValueAs( ReturnTypeImpl.class);
+ }
+ return returnType;
+ }
+
+ protected abstract T doDeserialize(JsonParser jp, DeserializationContext ctxt)
+ throws IOException, JsonProcessingException;
+
+ @Override
+ public T deserialize(final JsonParser jp, final DeserializationContext ctxt)
+ throws IOException, JsonProcessingException {
+
+ client = (ODataClient) ctxt.findInjectableValue(ODataClient.class.getName(), null, null);
+ return doDeserialize(jp, ctxt);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/e7135610/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/op/impl/AbstractJacksonTool.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/op/impl/AbstractJacksonTool.java b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/op/impl/AbstractJacksonTool.java
new file mode 100644
index 0000000..8536849
--- /dev/null
+++ b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/op/impl/AbstractJacksonTool.java
@@ -0,0 +1,83 @@
+/*
+ * 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.olingo.odata4.client.core.op.impl;
+
+import com.fasterxml.aalto.stax.InputFactoryImpl;
+import com.fasterxml.aalto.stax.OutputFactoryImpl;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.core.JsonParser;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.DeserializationContext;
+import com.fasterxml.jackson.databind.InjectableValues;
+import com.fasterxml.jackson.databind.JsonDeserializer;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.deser.DeserializationProblemHandler;
+import com.fasterxml.jackson.dataformat.xml.JacksonXmlModule;
+import com.fasterxml.jackson.dataformat.xml.XmlFactory;
+import com.fasterxml.jackson.dataformat.xml.XmlMapper;
+import java.io.IOException;
+import org.apache.olingo.odata4.client.api.ODataClient;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+abstract class AbstractJacksonTool {
+
+ protected static final Logger LOG = LoggerFactory.getLogger(AbstractJacksonTool.class);
+
+ protected final ODataClient client;
+
+ protected AbstractJacksonTool(final ODataClient client) {
+ this.client = client;
+ }
+
+ protected ObjectMapper getObjectMapper() {
+ final ObjectMapper mapper = new ObjectMapper().setSerializationInclusion(JsonInclude.Include.NON_NULL);
+
+ mapper.setInjectableValues(new InjectableValues.Std().addValue(ODataClient.class, client));
+
+ mapper.setSerializerProvider(new InjectableSerializerProvider(mapper.getSerializerProvider(),
+ mapper.getSerializationConfig().withAttribute(ODataClient.class, client),
+ mapper.getSerializerFactory()));
+
+ return mapper;
+ }
+
+ protected XmlMapper getXmlMapper() {
+ final XmlMapper xmlMapper = new XmlMapper(
+ new XmlFactory(new InputFactoryImpl(), new OutputFactoryImpl()), new JacksonXmlModule());
+
+ xmlMapper.setInjectableValues(new InjectableValues.Std().addValue(ODataClient.class, client));
+
+ xmlMapper.addHandler(new DeserializationProblemHandler() {
+
+ @Override
+ public boolean handleUnknownProperty(final DeserializationContext ctxt, final JsonParser jp,
+ final JsonDeserializer<?> deserializer, final Object beanOrClass, final String propertyName)
+ throws IOException, JsonProcessingException {
+
+ // skip any unknown property
+ LOG.warn("Skipping unknown property {}", propertyName);
+ ctxt.getParser().skipChildren();
+ return true;
+ }
+ });
+ return xmlMapper;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/e7135610/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/op/impl/AbstractODataDeserializer.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/op/impl/AbstractODataDeserializer.java b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/op/impl/AbstractODataDeserializer.java
new file mode 100644
index 0000000..ed4ebd0
--- /dev/null
+++ b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/op/impl/AbstractODataDeserializer.java
@@ -0,0 +1,177 @@
+/*
+ * 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.olingo.odata4.client.core.op.impl;
+
+import java.io.InputStream;
+import org.apache.olingo.odata4.client.api.ODataClient;
+import org.apache.olingo.odata4.client.api.op.ODataDeserializer;
+import org.apache.olingo.odata4.client.core.xml.XMLParser;
+import org.w3c.dom.Element;
+
+public abstract class AbstractODataDeserializer extends AbstractJacksonTool implements ODataDeserializer {
+
+ private static final long serialVersionUID = -4244158979195609909L;
+
+// private final AtomDeserializer atomDeserializer;
+ public AbstractODataDeserializer(final ODataClient client) {
+ super(client);
+// this.atomDeserializer = new AtomDeserializer(client);
+ }
+
+// @Override
+// @SuppressWarnings("unchecked")
+// public <T extends Feed> T toFeed(final InputStream input, final Class<T> reference) {
+// T entry;
+//
+// if (AtomFeed.class.equals(reference)) {
+// entry = (T) toAtomFeed(input);
+// } else {
+// entry = (T) toJSONFeed(input);
+// }
+//
+// return entry;
+// }
+//
+// @Override
+// @SuppressWarnings("unchecked")
+// public <T extends Entry> T toEntry(final InputStream input, final Class<T> reference) {
+// T entry;
+//
+// if (AtomEntry.class.equals(reference)) {
+// entry = (T) toAtomEntry(input);
+//
+// } else {
+// entry = (T) toJSONEntry(input);
+// }
+//
+// return entry;
+// }
+//
+// @Override
+// public Element toPropertyDOM(final InputStream input, final ODataFormat format) {
+// return format == ODataFormat.XML
+// ? toPropertyDOMFromXML(input)
+// : toPropertyDOMFromJSON(input);
+// }
+//
+// @Override
+// public LinkCollection toLinkCollection(final InputStream input, final ODataFormat format) {
+// return format == ODataFormat.XML
+// ? toLinkCollectionFromXML(input)
+// : toLinkCollectionFromJSON(input);
+// }
+//
+// @Override
+// public ODataError toODataError(final InputStream input, final boolean isXML) {
+// return isXML
+// ? toODataErrorFromXML(input)
+// : toODataErrorFromJSON(input);
+// }
+//
+ @Override
+ public Element toDOM(final InputStream input) {
+ return XMLParser.PARSER.deserialize(input);
+ }
+//
+// /*
+// * ------------------ Protected methods ------------------
+// */
+// protected AtomFeed toAtomFeed(final InputStream input) {
+// try {
+// return atomDeserializer.feed(toDOM(input));
+// } catch (Exception e) {
+// throw new IllegalArgumentException("While deserializing Atom feed", e);
+// }
+// }
+//
+// protected AtomEntry toAtomEntry(final InputStream input) {
+// try {
+// return atomDeserializer.entry(toDOM(input));
+// } catch (Exception e) {
+// throw new IllegalArgumentException("While deserializing Atom entry", e);
+// }
+// }
+//
+// protected JSONFeed toJSONFeed(final InputStream input) {
+// try {
+// return getObjectMapper().readValue(input, JSONFeed.class);
+// } catch (IOException e) {
+// throw new IllegalArgumentException("While deserializing JSON feed", e);
+// }
+// }
+//
+// protected abstract AbstractJSONEntry toJSONEntry(final InputStream input);
+//
+// protected Element toPropertyDOMFromXML(final InputStream input) {
+// return toDOM(input);
+// }
+//
+// protected Element toPropertyDOMFromJSON(final InputStream input) {
+// try {
+// return getObjectMapper().readValue(input, JSONProperty.class).getContent();
+// } catch (IOException e) {
+// throw new IllegalArgumentException("While deserializing JSON property", e);
+// }
+// }
+//
+// protected XMLLinkCollection toLinkCollectionFromXML(final InputStream input) {
+// final Element root = toDOM(input);
+//
+// final NodeList uris = root.getOwnerDocument().getElementsByTagName(ODataConstants.ELEM_URI);
+//
+// final List<URI> links = new ArrayList<URI>();
+// for (int i = 0; i < uris.getLength(); i++) {
+// links.add(URI.create(uris.item(i).getTextContent()));
+// }
+//
+// final NodeList next = root.getElementsByTagName(ODataConstants.NEXT_LINK_REL);
+// final XMLLinkCollection linkCollection = next.getLength() > 0
+// ? new XMLLinkCollection(URI.create(next.item(0).getTextContent()))
+// : new XMLLinkCollection();
+// linkCollection.setLinks(links);
+//
+// return linkCollection;
+// }
+//
+// protected JSONLinkCollection toLinkCollectionFromJSON(final InputStream input) {
+// try {
+// return getObjectMapper().readValue(input, JSONLinkCollection.class);
+// } catch (IOException e) {
+// throw new IllegalArgumentException("While deserializing JSON $links", e);
+// }
+// }
+//
+// protected XMLODataError toODataErrorFromXML(final InputStream input) {
+// try {
+// final XmlMapper xmlMapper = new XmlMapper(
+// new XmlFactory(new InputFactoryImpl(), new OutputFactoryImpl()), new JacksonXmlModule());
+// return xmlMapper.readValue(input, XMLODataError.class);
+// } catch (Exception e) {
+// throw new IllegalArgumentException("While deserializing XML error", e);
+// }
+// }
+//
+// protected JSONODataError toODataErrorFromJSON(final InputStream input) {
+// try {
+// return getObjectMapper().readValue(input, JSONODataErrorBundle.class).getError();
+// } catch (IOException e) {
+// throw new IllegalArgumentException("While deserializing JSON error", e);
+// }
+// }
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/e7135610/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/op/impl/AbstractODataReader.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/op/impl/AbstractODataReader.java b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/op/impl/AbstractODataReader.java
new file mode 100644
index 0000000..3704db7
--- /dev/null
+++ b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/op/impl/AbstractODataReader.java
@@ -0,0 +1,138 @@
+/*
+ * 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.olingo.odata4.client.core.op.impl;
+
+import org.apache.olingo.odata4.client.api.ODataClient;
+import org.apache.olingo.odata4.client.api.op.ODataReader;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public abstract class AbstractODataReader implements ODataReader {
+
+ private static final long serialVersionUID = -1988865870981207079L;
+
+ /**
+ * Logger.
+ */
+ protected static final Logger LOG = LoggerFactory.getLogger(AbstractODataReader.class);
+
+ protected final ODataClient client;
+
+ protected AbstractODataReader(final ODataClient client) {
+ this.client = client;
+ }
+
+// @Override
+// public ODataEntitySet readEntitySet(final InputStream input, final ODataPubFormat format) {
+// return client.getBinder().getODataEntitySet(
+// client.getDeserializer().toFeed(input, ResourceFactory.feedClassForFormat(format)));
+// }
+//
+// @Override
+// public ODataEntity readEntity(final InputStream input, final ODataPubFormat format) {
+// return client.getBinder().getODataEntity(
+// client.getDeserializer().toEntry(input, ResourceFactory.entryClassForFormat(format)));
+// }
+//
+// @Override
+// public ODataProperty readProperty(final InputStream input, final ODataFormat format) {
+// final Element property = client.getDeserializer().toPropertyDOM(input, format);
+//
+// // The ODataProperty object is used either for actual entity properties and for invoke result
+// // (when return type is neither an entity nor a collection of entities).
+// // Such formats are mostly the same except for collections: an entity property looks like
+// // <aproperty m:type="Collection(AType)">
+// // <element>....</element>
+// // </aproperty>
+// //
+// // while an invoke result with returnType="Collection(AnotherType)" looks like
+// // <functionImportName>
+// // <element m:type="AnotherType">...</element>
+// // <functionImportName>
+// //
+// // The code below is meant for "normalizing" the latter into
+// // <functionImportName m:type="Collection(AnotherType)">
+// // <element m:type="AnotherType">...</element>
+// // <functionImportName>
+// final String type = property.getAttribute(ODataConstants.ATTR_M_TYPE);
+// final NodeList elements = property.getElementsByTagName(ODataConstants.ELEM_ELEMENT);
+// if (StringUtils.isBlank(type) && elements != null && elements.getLength() > 0) {
+// final Node elementType = elements.item(0).getAttributes().getNamedItem(ODataConstants.ATTR_M_TYPE);
+// if (elementType != null) {
+// property.setAttribute(ODataConstants.ATTR_M_TYPE, "Collection(" + elementType.getTextContent() + ")");
+// }
+// }
+//
+// return client.getBinder().getProperty(property);
+// }
+//
+// @Override
+// public ODataLinkCollection readLinks(final InputStream input, final ODataFormat format) {
+// return client.getBinder().getLinkCollection(
+// client.getDeserializer().toLinkCollection(input, format));
+// }
+//
+// @Override
+// public ODataError readError(final InputStream inputStream, final boolean isXML) {
+// return client.getDeserializer().toODataError(inputStream, isXML);
+// }
+//
+// @Override
+// @SuppressWarnings("unchecked")
+// public <T> T read(final InputStream src, final String format, final Class<T> reference) {
+// Object res;
+//
+// try {
+// if (ODataEntitySetIterator.class.isAssignableFrom(reference)) {
+// res = new ODataEntitySetIterator(client, src, ODataPubFormat.fromString(format));
+// } else if (ODataEntitySet.class.isAssignableFrom(reference)) {
+// res = readEntitySet(src, ODataPubFormat.fromString(format));
+// } else if (ODataEntity.class.isAssignableFrom(reference)) {
+// res = readEntity(src, ODataPubFormat.fromString(format));
+// } else if (ODataProperty.class.isAssignableFrom(reference)) {
+// res = readProperty(src, ODataFormat.fromString(format));
+// } else if (ODataLinkCollection.class.isAssignableFrom(reference)) {
+// res = readLinks(src, ODataFormat.fromString(format));
+// } else if (ODataValue.class.isAssignableFrom(reference)) {
+// res = client.getPrimitiveValueBuilder().
+// setType(ODataValueFormat.fromString(format) == ODataValueFormat.TEXT
+// ? EdmSimpleType.String : EdmSimpleType.Stream).
+// setText(IOUtils.toString(src)).
+// build();
+// } else if (AbstractEdmMetadata.class.isAssignableFrom(reference)) {
+// res = readMetadata(src);
+// } else if (ODataServiceDocument.class.isAssignableFrom(reference)) {
+// res = readServiceDocument(src, ODataFormat.fromString(format));
+// } else if (ODataError.class.isAssignableFrom(reference)) {
+// res = readError(src, !format.toString().contains("json"));
+// } else {
+// throw new IllegalArgumentException("Invalid reference type " + reference);
+// }
+// } catch (Exception e) {
+// LOG.warn("Cast error", e);
+// res = null;
+// } finally {
+// if (!ODataEntitySetIterator.class.isAssignableFrom(reference)) {
+// IOUtils.closeQuietly(src);
+// }
+// }
+//
+// return (T) res;
+// }
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/e7135610/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/op/impl/AbstractODataSerializer.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/op/impl/AbstractODataSerializer.java b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/op/impl/AbstractODataSerializer.java
new file mode 100644
index 0000000..523d8b4
--- /dev/null
+++ b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/op/impl/AbstractODataSerializer.java
@@ -0,0 +1,160 @@
+/*
+ * 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.olingo.odata4.client.core.op.impl;
+
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.io.Writer;
+import org.apache.olingo.odata4.client.api.ODataClient;
+import org.apache.olingo.odata4.client.api.op.ODataSerializer;
+import org.apache.olingo.odata4.client.core.xml.XMLParser;
+import org.w3c.dom.Node;
+
+public abstract class AbstractODataSerializer extends AbstractJacksonTool implements ODataSerializer {
+
+ private static final long serialVersionUID = -357777648541325363L;
+
+// private final AtomSerializer atomSerializer;
+ public AbstractODataSerializer(final ODataClient client) {
+ super(client);
+// this.atomSerializer = new AtomSerializer(client);
+ }
+
+// @Override
+// public <T extends Feed> void feed(final T obj, final OutputStream out) {
+// feed(obj, new OutputStreamWriter(out));
+// }
+//
+// @Override
+// public <T extends Feed> void feed(final T obj, final Writer writer) {
+// if (obj instanceof AtomFeed) {
+// atom((AtomFeed) obj, writer);
+// } else {
+// json((JSONFeed) obj, writer);
+// }
+// }
+//
+// @Override
+// public <T extends Entry> void entry(final T obj, final OutputStream out) {
+// entry(obj, new OutputStreamWriter(out));
+// }
+//
+// @Override
+// public <T extends Entry> void entry(final T obj, final Writer writer) {
+// if (obj instanceof AtomEntry) {
+// atom((AtomEntry) obj, writer);
+// } else {
+// json((JSONEntry) obj, writer);
+// }
+// }
+//
+// @Override
+// public void property(final Element element, final ODataFormat format, final OutputStream out) {
+// property(element, format, new OutputStreamWriter(out));
+// }
+//
+// @Override
+// public void property(final Element element, final ODataFormat format, final Writer writer) {
+// if (format == ODataFormat.XML) {
+// dom(element, writer);
+// } else {
+// json(element, writer);
+// }
+// }
+//
+// @Override
+// public void link(final ODataLink link, final ODataFormat format, final OutputStream out) {
+// link(link, format, new OutputStreamWriter(out));
+// }
+//
+// @Override
+// public void link(final ODataLink link, final ODataFormat format, final Writer writer) {
+// if (format == ODataFormat.XML) {
+// xmlLink(link, writer);
+// } else {
+// jsonLink(link, writer);
+// }
+// }
+//
+ @Override
+ public void dom(final Node content, final OutputStream out) {
+ dom(content, new OutputStreamWriter(out));
+ }
+
+ @Override
+ public void dom(final Node content, final Writer writer) {
+ XMLParser.PARSER.serialize(content, writer);
+ }
+//
+// /*
+// * ------------------ Protected methods ------------------
+// */
+// protected <T extends AbstractPayloadObject> void atom(final T obj, final Writer writer) {
+// try {
+// dom(atomSerializer.serialize(obj), writer);
+// } catch (Exception e) {
+// throw new IllegalArgumentException("While serializing Atom object", e);
+// }
+// }
+//
+// protected <T extends AbstractPayloadObject> void json(final T obj, final Writer writer) {
+// try {
+// getObjectMapper().writeValue(writer, obj);
+// } catch (IOException e) {
+// throw new IllegalArgumentException("While serializing JSON object", e);
+// }
+// }
+//
+// protected void json(final Element element, final Writer writer) {
+// try {
+// final JSONProperty property = new JSONProperty();
+// property.setContent(element);
+// getObjectMapper().writeValue(writer, property);
+// } catch (IOException e) {
+// throw new IllegalArgumentException("While serializing JSON property", e);
+// }
+// }
+//
+// protected void xmlLink(final ODataLink link, final Writer writer) {
+// try {
+// final DocumentBuilder builder = XMLUtils.DOC_BUILDER_FACTORY.newDocumentBuilder();
+// final Document doc = builder.newDocument();
+// final Element uri = doc.createElementNS(
+// client.getWorkingVersion().getNamespaceMap().get(ODataVersion.NS_DATASERVICES),
+// ODataConstants.ELEM_URI);
+// uri.appendChild(doc.createTextNode(link.getLink().toASCIIString()));
+//
+// dom(uri, writer);
+// } catch (Exception e) {
+// throw new IllegalArgumentException("While serializing XML link", e);
+// }
+// }
+//
+// protected void jsonLink(final ODataLink link, final Writer writer) {
+// final ObjectMapper mapper = getObjectMapper();
+// final ObjectNode uri = mapper.createObjectNode();
+// uri.put(ODataConstants.JSON_URL, link.getLink().toASCIIString());
+//
+// try {
+// mapper.writeValue(writer, uri);
+// } catch (Exception e) {
+// throw new IllegalArgumentException("While serializing JSON link", e);
+// }
+// }
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/e7135610/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/op/impl/ComplexTypeDeserializer.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/op/impl/ComplexTypeDeserializer.java b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/op/impl/ComplexTypeDeserializer.java
new file mode 100644
index 0000000..511bdb1
--- /dev/null
+++ b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/op/impl/ComplexTypeDeserializer.java
@@ -0,0 +1,81 @@
+/*
+ * 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.olingo.odata4.client.core.op.impl;
+
+import com.fasterxml.jackson.core.JsonParser;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.core.JsonToken;
+import com.fasterxml.jackson.databind.DeserializationContext;
+import java.io.IOException;
+import org.apache.commons.lang3.BooleanUtils;
+import org.apache.olingo.odata4.client.core.edm.AbstractComplexType;
+import org.apache.olingo.odata4.client.core.edm.v4.AnnotationImpl;
+import org.apache.olingo.odata4.commons.api.edm.constants.ODataServiceVersion;
+
+public class ComplexTypeDeserializer extends AbstractEdmDeserializer<AbstractComplexType> {
+
+ @Override
+ protected AbstractComplexType doDeserialize(final JsonParser jp, final DeserializationContext ctxt)
+ throws IOException, JsonProcessingException {
+
+ final AbstractComplexType complexType = ODataServiceVersion.V30 == client.getServiceVersion()
+ ? new org.apache.olingo.odata4.client.core.edm.v3.ComplexTypeImpl()
+ : new org.apache.olingo.odata4.client.core.edm.v4.ComplexTypeImpl();
+
+ for (; jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) {
+ final JsonToken token = jp.getCurrentToken();
+ if (token == JsonToken.FIELD_NAME) {
+ if ("Name".equals(jp.getCurrentName())) {
+ complexType.setName(jp.nextTextValue());
+ } else if ("Abstract".equals(jp.getCurrentName())) {
+ ((org.apache.olingo.odata4.client.core.edm.v4.ComplexTypeImpl) complexType).
+ setAbstractEntityType(BooleanUtils.toBoolean(jp.nextTextValue()));
+ } else if ("BaseType".equals(jp.getCurrentName())) {
+ ((org.apache.olingo.odata4.client.core.edm.v4.ComplexTypeImpl) complexType).
+ setBaseType(jp.nextTextValue());
+ } else if ("OpenType".equals(jp.getCurrentName())) {
+ ((org.apache.olingo.odata4.client.core.edm.v4.ComplexTypeImpl) complexType).
+ setOpenType(BooleanUtils.toBoolean(jp.nextTextValue()));
+ } else if ("Property".equals(jp.getCurrentName())) {
+ jp.nextToken();
+ if (complexType instanceof org.apache.olingo.odata4.client.core.edm.v3.ComplexTypeImpl) {
+ ((org.apache.olingo.odata4.client.core.edm.v3.ComplexTypeImpl) complexType).
+ getProperties().add(jp.readValueAs(
+ org.apache.olingo.odata4.client.core.edm.v3.PropertyImpl.class));
+ } else {
+ ((org.apache.olingo.odata4.client.core.edm.v4.ComplexTypeImpl) complexType).
+ getProperties().add(jp.readValueAs(
+ org.apache.olingo.odata4.client.core.edm.v4.PropertyImpl.class));
+ }
+ } else if ("NavigationProperty".equals(jp.getCurrentName())) {
+ jp.nextToken();
+ ((org.apache.olingo.odata4.client.core.edm.v4.ComplexTypeImpl) complexType).
+ getNavigationProperties().add(jp.readValueAs(
+ org.apache.olingo.odata4.client.core.edm.v4.NavigationPropertyImpl.class));
+ } else if ("Annotation".equals(jp.getCurrentName())) {
+ jp.nextToken();
+ ((org.apache.olingo.odata4.client.core.edm.v4.ComplexTypeImpl) complexType).
+ setAnnotation(jp.readValueAs( AnnotationImpl.class));
+ }
+ }
+ }
+
+ return complexType;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/e7135610/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/op/impl/EntityContainerDeserializer.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/op/impl/EntityContainerDeserializer.java b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/op/impl/EntityContainerDeserializer.java
new file mode 100644
index 0000000..2f11064
--- /dev/null
+++ b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/op/impl/EntityContainerDeserializer.java
@@ -0,0 +1,100 @@
+/*
+ * 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.olingo.odata4.client.core.op.impl;
+
+import com.fasterxml.jackson.core.JsonParser;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.core.JsonToken;
+import com.fasterxml.jackson.databind.DeserializationContext;
+import java.io.IOException;
+import org.apache.commons.lang3.BooleanUtils;
+import org.apache.olingo.odata4.client.core.edm.AbstractEntityContainer;
+import org.apache.olingo.odata4.client.core.edm.v3.AssociationSetImpl;
+import org.apache.olingo.odata4.client.core.edm.v4.ActionImportImpl;
+import org.apache.olingo.odata4.client.core.edm.v4.AnnotationImpl;
+import org.apache.olingo.odata4.client.core.edm.v4.SingletonImpl;
+import org.apache.olingo.odata4.commons.api.edm.constants.ODataServiceVersion;
+
+@SuppressWarnings("rawtypes")
+public class EntityContainerDeserializer extends AbstractEdmDeserializer<AbstractEntityContainer> {
+
+ @Override
+ protected AbstractEntityContainer doDeserialize(final JsonParser jp, final DeserializationContext ctxt)
+ throws IOException, JsonProcessingException {
+
+ final AbstractEntityContainer entityContainer = ODataServiceVersion.V30 == client.getServiceVersion()
+ ? new org.apache.olingo.odata4.client.core.edm.v3.EntityContainerImpl()
+ : new org.apache.olingo.odata4.client.core.edm.v4.EntityContainerImpl();
+
+ for (; jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) {
+ final JsonToken token = jp.getCurrentToken();
+ if (token == JsonToken.FIELD_NAME) {
+ if ("Name".equals(jp.getCurrentName())) {
+ entityContainer.setName(jp.nextTextValue());
+ } else if ("Extends".equals(jp.getCurrentName())) {
+ entityContainer.setExtends(jp.nextTextValue());
+ } else if ("LazyLoadingEnabled".equals(jp.getCurrentName())) {
+ entityContainer.setLazyLoadingEnabled(BooleanUtils.toBoolean(jp.nextTextValue()));
+ } else if ("IsDefaultEntityContainer".equals(jp.getCurrentName())) {
+ entityContainer.setDefaultEntityContainer(BooleanUtils.toBoolean(jp.nextTextValue()));
+ } else if ("EntitySet".equals(jp.getCurrentName())) {
+ jp.nextToken();
+ if (entityContainer instanceof org.apache.olingo.odata4.client.core.edm.v3.EntityContainerImpl) {
+ ((org.apache.olingo.odata4.client.core.edm.v3.EntityContainerImpl) entityContainer).
+ getEntitySets().add(jp.readValueAs(
+ org.apache.olingo.odata4.client.core.edm.v3.EntitySetImpl.class));
+ } else {
+ ((org.apache.olingo.odata4.client.core.edm.v4.EntityContainerImpl) entityContainer).
+ getEntitySets().add(jp.readValueAs(
+ org.apache.olingo.odata4.client.core.edm.v4.EntitySetImpl.class));
+ }
+ } else if ("AssociationSet".equals(jp.getCurrentName())) {
+ jp.nextToken();
+ ((org.apache.olingo.odata4.client.core.edm.v3.EntityContainerImpl) entityContainer).
+ getAssociationSets().add(jp.readValueAs( AssociationSetImpl.class));
+ } else if ("Singleton".equals(jp.getCurrentName())) {
+ jp.nextToken();
+ ((org.apache.olingo.odata4.client.core.edm.v4.EntityContainerImpl) entityContainer).
+ getSingletons().add(jp.readValueAs( SingletonImpl.class));
+ } else if ("ActionImport".equals(jp.getCurrentName())) {
+ jp.nextToken();
+ ((org.apache.olingo.odata4.client.core.edm.v4.EntityContainerImpl) entityContainer).
+ getActionImports().add(jp.readValueAs( ActionImportImpl.class));
+ } else if ("FunctionImport".equals(jp.getCurrentName())) {
+ jp.nextToken();
+ if (entityContainer instanceof org.apache.olingo.odata4.client.core.edm.v3.EntityContainerImpl) {
+ ((org.apache.olingo.odata4.client.core.edm.v3.EntityContainerImpl) entityContainer).
+ getFunctionImports().add(jp.readValueAs(
+ org.apache.olingo.odata4.client.core.edm.v3.FunctionImportImpl.class));
+ } else {
+ ((org.apache.olingo.odata4.client.core.edm.v4.EntityContainerImpl) entityContainer).
+ getFunctionImports().add(jp.readValueAs(
+ org.apache.olingo.odata4.client.core.edm.v4.FunctionImportImpl.class));
+ }
+ } else if ("Annotation".equals(jp.getCurrentName())) {
+ jp.nextToken();
+ ((org.apache.olingo.odata4.client.core.edm.v4.EntityContainerImpl) entityContainer).
+ setAnnotation(jp.readValueAs( AnnotationImpl.class));
+ }
+ }
+ }
+
+ return entityContainer;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/e7135610/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/op/impl/EntityKeyDeserializer.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/op/impl/EntityKeyDeserializer.java b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/op/impl/EntityKeyDeserializer.java
new file mode 100644
index 0000000..7569c7b
--- /dev/null
+++ b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/op/impl/EntityKeyDeserializer.java
@@ -0,0 +1,48 @@
+/*
+ * 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.olingo.odata4.client.core.op.impl;
+
+import com.fasterxml.jackson.core.JsonParser;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.core.JsonToken;
+import com.fasterxml.jackson.databind.DeserializationContext;
+import java.io.IOException;
+import org.apache.olingo.odata4.client.core.edm.EntityKeyImpl;
+import org.apache.olingo.odata4.client.core.edm.PropertyRefImpl;
+
+public class EntityKeyDeserializer extends AbstractEdmDeserializer<EntityKeyImpl> {
+
+ @Override
+ protected EntityKeyImpl doDeserialize(final JsonParser jp, final DeserializationContext ctxt)
+ throws IOException, JsonProcessingException {
+
+ final EntityKeyImpl entityKey = new EntityKeyImpl();
+
+ for (; jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) {
+ final JsonToken token = jp.getCurrentToken();
+
+ if (token == JsonToken.FIELD_NAME && "PropertyRef".equals(jp.getCurrentName())) {
+ jp.nextToken();
+ entityKey.getPropertyRefs().add(jp.readValueAs( PropertyRefImpl.class));
+ }
+ }
+
+ return entityKey;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/e7135610/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/op/impl/EntitySetDeserializer.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/op/impl/EntitySetDeserializer.java b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/op/impl/EntitySetDeserializer.java
new file mode 100644
index 0000000..8240645
--- /dev/null
+++ b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/op/impl/EntitySetDeserializer.java
@@ -0,0 +1,68 @@
+/*
+ * 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.olingo.odata4.client.core.op.impl;
+
+import com.fasterxml.jackson.core.JsonParser;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.core.JsonToken;
+import com.fasterxml.jackson.databind.DeserializationContext;
+import java.io.IOException;
+import org.apache.commons.lang3.BooleanUtils;
+import org.apache.olingo.odata4.client.core.edm.AbstractEntitySet;
+import org.apache.olingo.odata4.client.core.edm.v4.AnnotationImpl;
+import org.apache.olingo.odata4.client.core.edm.v4.NavigationPropertyBindingImpl;
+import org.apache.olingo.odata4.commons.api.edm.constants.ODataServiceVersion;
+
+public class EntitySetDeserializer extends AbstractEdmDeserializer<AbstractEntitySet> {
+
+ @Override
+ protected AbstractEntitySet doDeserialize(final JsonParser jp, final DeserializationContext ctxt)
+ throws IOException, JsonProcessingException {
+
+ final AbstractEntitySet entitySet = ODataServiceVersion.V30 == client.getServiceVersion()
+ ? new org.apache.olingo.odata4.client.core.edm.v3.EntitySetImpl()
+ : new org.apache.olingo.odata4.client.core.edm.v4.EntitySetImpl();
+
+ for (; jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) {
+ final JsonToken token = jp.getCurrentToken();
+ if (token == JsonToken.FIELD_NAME) {
+ if ("Name".equals(jp.getCurrentName())) {
+ entitySet.setName(jp.nextTextValue());
+ } else if ("EntityType".equals(jp.getCurrentName())) {
+ entitySet.setEntityType(jp.nextTextValue());
+ } else if ("IncludeInServiceDocument".equals(jp.getCurrentName())) {
+ ((org.apache.olingo.odata4.client.core.edm.v4.EntitySetImpl) entitySet).
+ setIncludeInServiceDocument(BooleanUtils.toBoolean(jp.nextTextValue()));
+ } else if ("NavigationPropertyBinding".equals(jp.getCurrentName())) {
+ jp.nextToken();
+ ((org.apache.olingo.odata4.client.core.edm.v4.EntitySetImpl) entitySet).
+ getNavigationPropertyBindings().add(
+ jp.readValueAs( NavigationPropertyBindingImpl.class));
+ } else if ("Annotation".equals(jp.getCurrentName())) {
+ jp.nextToken();
+ ((org.apache.olingo.odata4.client.core.edm.v4.EntitySetImpl) entitySet).
+ setAnnotation(jp.readValueAs( AnnotationImpl.class));
+ }
+ }
+ }
+
+ return entitySet;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/e7135610/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/op/impl/EntityTypeDeserializer.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/op/impl/EntityTypeDeserializer.java b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/op/impl/EntityTypeDeserializer.java
new file mode 100644
index 0000000..f8af8b2
--- /dev/null
+++ b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/op/impl/EntityTypeDeserializer.java
@@ -0,0 +1,90 @@
+/*
+ * 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.olingo.odata4.client.core.op.impl;
+
+import com.fasterxml.jackson.core.JsonParser;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.core.JsonToken;
+import com.fasterxml.jackson.databind.DeserializationContext;
+import java.io.IOException;
+import org.apache.commons.lang3.BooleanUtils;
+import org.apache.olingo.odata4.client.core.edm.AbstractEntityType;
+import org.apache.olingo.odata4.client.core.edm.EntityKeyImpl;
+import org.apache.olingo.odata4.client.core.edm.v4.AnnotationImpl;
+import org.apache.olingo.odata4.commons.api.edm.constants.ODataServiceVersion;
+
+public class EntityTypeDeserializer extends AbstractEdmDeserializer<AbstractEntityType> {
+
+ @Override
+ protected AbstractEntityType doDeserialize(final JsonParser jp, final DeserializationContext ctxt)
+ throws IOException, JsonProcessingException {
+
+ final AbstractEntityType entityType = ODataServiceVersion.V30 == client.getServiceVersion()
+ ? new org.apache.olingo.odata4.client.core.edm.v3.EntityTypeImpl()
+ : new org.apache.olingo.odata4.client.core.edm.v4.EntityTypeImpl();
+
+ for (; jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) {
+ final JsonToken token = jp.getCurrentToken();
+ if (token == JsonToken.FIELD_NAME) {
+ if ("Name".equals(jp.getCurrentName())) {
+ entityType.setName(jp.nextTextValue());
+ } else if ("Abstract".equals(jp.getCurrentName())) {
+ entityType.setAbstractEntityType(BooleanUtils.toBoolean(jp.nextTextValue()));
+ } else if ("BaseType".equals(jp.getCurrentName())) {
+ entityType.setBaseType(jp.nextTextValue());
+ } else if ("OpenType".equals(jp.getCurrentName())) {
+ entityType.setOpenType(BooleanUtils.toBoolean(jp.nextTextValue()));
+ } else if ("HasStream".equals(jp.getCurrentName())) {
+ entityType.setHasStream(BooleanUtils.toBoolean(jp.nextTextValue()));
+ } else if ("Key".equals(jp.getCurrentName())) {
+ jp.nextToken();
+ entityType.setKey(jp.readValueAs(EntityKeyImpl.class));
+ } else if ("Property".equals(jp.getCurrentName())) {
+ jp.nextToken();
+ if (entityType instanceof org.apache.olingo.odata4.client.core.edm.v3.EntityTypeImpl) {
+ ((org.apache.olingo.odata4.client.core.edm.v3.EntityTypeImpl) entityType).
+ getProperties().add(jp.readValueAs(
+ org.apache.olingo.odata4.client.core.edm.v3.PropertyImpl.class));
+ } else {
+ ((org.apache.olingo.odata4.client.core.edm.v4.EntityTypeImpl) entityType).
+ getProperties().add(jp.readValueAs(
+ org.apache.olingo.odata4.client.core.edm.v4.PropertyImpl.class));
+ }
+ } else if ("NavigationProperty".equals(jp.getCurrentName())) {
+ jp.nextToken();
+ if (entityType instanceof org.apache.olingo.odata4.client.core.edm.v3.EntityTypeImpl) {
+ ((org.apache.olingo.odata4.client.core.edm.v3.EntityTypeImpl) entityType).
+ getNavigationProperties().add(jp.readValueAs(
+ org.apache.olingo.odata4.client.core.edm.v3.NavigationPropertyImpl.class));
+ } else {
+ ((org.apache.olingo.odata4.client.core.edm.v4.EntityTypeImpl) entityType).
+ getNavigationProperties().add(jp.readValueAs(
+ org.apache.olingo.odata4.client.core.edm.v4.NavigationPropertyImpl.class));
+ }
+ } else if ("Annotation".equals(jp.getCurrentName())) {
+ jp.nextToken();
+ ((org.apache.olingo.odata4.client.core.edm.v4.EntityTypeImpl) entityType).
+ setAnnotation(jp.readValueAs(AnnotationImpl.class));
+ }
+ }
+ }
+
+ return entityType;
+ }
+}