You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@olingo.apache.org by ch...@apache.org on 2015/07/23 10:53:05 UTC
olingo-odata4 git commit: [OLINGO-570] JsonMetadataDeserializer part1
Repository: olingo-odata4
Updated Branches:
refs/heads/jsonMetadata 6e8c30a97 -> fa38869ba
[OLINGO-570] JsonMetadataDeserializer part1
Project: http://git-wip-us.apache.org/repos/asf/olingo-odata4/repo
Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata4/commit/fa38869b
Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata4/tree/fa38869b
Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata4/diff/fa38869b
Branch: refs/heads/jsonMetadata
Commit: fa38869ba2e395e899823a966320d053f6de3aab
Parents: 6e8c30a
Author: Christian Amend <ch...@sap.com>
Authored: Thu Jul 23 10:52:12 2015 +0200
Committer: Christian Amend <ch...@sap.com>
Committed: Thu Jul 23 10:52:12 2015 +0200
----------------------------------------------------------------------
.../client/api/edm/json/EdmJsonSchema.java | 32 +++++
.../olingo/client/api/edm/xml/XMLMetadata.java | 3 +-
.../client/api/serialization/ODataReader.java | 2 +-
.../client/core/edm/ClientCsdlJSONMetadata.java | 74 +++++++++++
.../edm/json/ClientCsdlActionDeserializer.java | 130 ++++++++++++++++++
.../json/ClientCsdlDefinitionsDeserializer.java | 86 ++++++++++++
.../json/ClientCsdlEntitySetDeserializer.java | 56 ++++++++
.../json/ClientCsdlEntityTypeDeserializer.java | 67 ++++++++++
.../json/ClientCsdlEnumTypeDeserializer.java | 60 +++++++++
.../json/ClientCsdlFunctionDeserializer.java | 133 +++++++++++++++++++
.../json/ClientCsdlReferencesDeserializer.java | 86 ++++++++++++
.../edm/json/ClientCsdlSchemasDeserializer.java | 96 +++++++++++++
.../core/edm/json/ClientJsonCsdlInclude.java | 46 +++++++
.../json/ClientJsonCsdlIncludeAnnotation.java | 56 ++++++++
.../core/edm/json/ClientJsonCsdlReference.java | 62 +++++++++
.../core/edm/json/ClientJsonSchemaCsdl.java | 73 ++++++++++
.../ClientODataDeserializerImpl.java | 26 +++-
.../core/serialization/ODataReaderImpl.java | 6 +-
.../olingo/client/core/v4/EntityTest.java | 2 +-
.../olingo/client/core/v4/JsonMetadataTest.java | 55 ++++++++
.../olingo/client/core/v4/MetadataTest.java | 14 +-
.../apache/olingo/client/core/v4/metadata.json | 1 +
.../json/MetadataDocumentJsonSerializer.java | 5 +-
.../MetadataDocumentJsonSerializerTest.java | 9 +-
.../json/MetadataDocumentJsonTest.java | 2 +
25 files changed, 1163 insertions(+), 19 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/fa38869b/lib/client-api/src/main/java/org/apache/olingo/client/api/edm/json/EdmJsonSchema.java
----------------------------------------------------------------------
diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/edm/json/EdmJsonSchema.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/edm/json/EdmJsonSchema.java
new file mode 100644
index 0000000..ff18c1e
--- /dev/null
+++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/edm/json/EdmJsonSchema.java
@@ -0,0 +1,32 @@
+/*
+ * 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.client.api.edm.json;
+
+import org.apache.olingo.client.api.edm.xml.Reference;
+import org.apache.olingo.commons.api.edm.provider.CsdlSchema;
+
+import java.util.List;
+
+public interface EdmJsonSchema {
+
+ List<CsdlSchema> getSchemas();
+
+ List<Reference> getReferences();
+
+}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/fa38869b/lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/XMLMetadata.java
----------------------------------------------------------------------
diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/XMLMetadata.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/XMLMetadata.java
index 74191cf..53fbc16 100644
--- a/lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/XMLMetadata.java
+++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/XMLMetadata.java
@@ -20,7 +20,6 @@ package org.apache.olingo.client.api.edm.xml;
import java.util.List;
import java.util.Map;
-
import org.apache.olingo.commons.api.edm.provider.CsdlSchema;
/**
@@ -52,6 +51,6 @@ public interface XMLMetadata {
List<CsdlSchema> getSchemas();
Map<String, CsdlSchema> getSchemaByNsOrAlias();
-
+
List<Reference> getReferences();
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/fa38869b/lib/client-api/src/main/java/org/apache/olingo/client/api/serialization/ODataReader.java
----------------------------------------------------------------------
diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/serialization/ODataReader.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/serialization/ODataReader.java
index 7e4aa96..a9cf19a 100644
--- a/lib/client-api/src/main/java/org/apache/olingo/client/api/serialization/ODataReader.java
+++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/serialization/ODataReader.java
@@ -46,7 +46,7 @@ public interface ODataReader {
* @param input stream to de-serialize.
* @return metadata representation.
*/
- Edm readMetadata(InputStream input);
+ Edm readMetadata(InputStream input, ODataFormat format);
/**
* Parses a stream into metadata representation, including referenced metadata documents.
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/fa38869b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/ClientCsdlJSONMetadata.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/ClientCsdlJSONMetadata.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/ClientCsdlJSONMetadata.java
new file mode 100644
index 0000000..c1c5cfe
--- /dev/null
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/ClientCsdlJSONMetadata.java
@@ -0,0 +1,74 @@
+/*
+ * 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.client.core.edm;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.olingo.client.api.edm.json.EdmJsonSchema;
+import org.apache.olingo.client.api.edm.xml.Reference;
+import org.apache.olingo.client.api.edm.xml.XMLMetadata;
+import org.apache.olingo.commons.api.edm.provider.CsdlSchema;
+
+/**
+ * Entry point for access information about EDM JSON metadata.
+ */
+public class ClientCsdlJSONMetadata implements XMLMetadata {
+
+ protected final EdmJsonSchema edmJsonSchema;
+
+ public ClientCsdlJSONMetadata(final EdmJsonSchema edmJsonSchema) {
+ this.edmJsonSchema= edmJsonSchema;
+ }
+
+ @Override
+ public List<CsdlSchema> getSchemas() {
+ return this.edmJsonSchema.getSchemas();
+ }
+
+ @Override
+ public CsdlSchema getSchema(final int index) {
+ return getSchemas().get(index);
+ }
+
+ @Override
+ public CsdlSchema getSchema(final String key) {
+ return getSchemaByNsOrAlias().get(key);
+ }
+
+ @Override
+ public Map<String, CsdlSchema> getSchemaByNsOrAlias() {
+ final Map<String, CsdlSchema> schemaByNsOrAlias = new HashMap<String, CsdlSchema>();
+ for (CsdlSchema schema : getSchemas()) {
+ schemaByNsOrAlias.put(schema.getNamespace(), schema);
+ if (StringUtils.isNotBlank(schema.getAlias())) {
+ schemaByNsOrAlias.put(schema.getAlias(), schema);
+ }
+ }
+ return schemaByNsOrAlias;
+ }
+
+ @Override
+ public List<Reference> getReferences() {
+ return this.edmJsonSchema.getReferences();
+ }
+}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/fa38869b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/json/ClientCsdlActionDeserializer.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/json/ClientCsdlActionDeserializer.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/json/ClientCsdlActionDeserializer.java
new file mode 100644
index 0000000..49f7e87
--- /dev/null
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/json/ClientCsdlActionDeserializer.java
@@ -0,0 +1,130 @@
+/*
+ * 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.client.core.edm.json;
+
+import com.fasterxml.jackson.core.JsonParser;
+import com.fasterxml.jackson.databind.DeserializationContext;
+import com.fasterxml.jackson.databind.JsonDeserializer;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import org.apache.olingo.commons.api.edm.FullQualifiedName;
+import org.apache.olingo.commons.api.edm.provider.CsdlAction;
+import org.apache.olingo.commons.api.edm.provider.CsdlParameter;
+import org.apache.olingo.commons.api.edm.provider.CsdlReturnType;
+import org.apache.olingo.commons.api.edm.provider.CsdlSchema;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+public class ClientCsdlActionDeserializer extends JsonDeserializer<CsdlAction> {
+
+ private CsdlSchema schema;
+
+ public ClientCsdlActionDeserializer(CsdlSchema schema) {
+ this.schema = schema;
+ }
+
+ @Override
+ public CsdlAction deserialize(final JsonParser parser, final DeserializationContext ctxt)
+ throws IOException {
+ final ObjectNode tree = parser.getCodec().readTree(parser);
+ CsdlAction action = new CsdlAction();
+
+ if (tree.has("name")) {
+ action.setName(tree.get("name").asText());
+ }
+ if (tree.has("entitySetPath")) {
+ action.setEntitySetPath(tree.get("entitySetPath").asText());
+ }
+ if (tree.has("isBound")) {
+ action.setBound(tree.get("isBound").asBoolean());
+ }
+
+ if (tree.has("returnType")) {
+ CsdlReturnType returnType = new CsdlReturnType();
+ if (tree.get("returnType").has("type")) {
+ String fullQualifiedName = tree.get("returnType").get("type").asText();
+ fullQualifiedName = fullQualifiedName.replace(schema.getAlias(), schema.getNamespace());
+ String typeName = "";
+ if (fullQualifiedName.contains("Collection")) {
+ returnType.setCollection(true);
+ typeName = fullQualifiedName.substring("Collection(".length(), fullQualifiedName.length() - 2);
+ } else {
+ typeName = fullQualifiedName;
+ }
+ returnType.setType(new FullQualifiedName(typeName));
+ }
+ if (tree.get("returnType").has("scale")) {
+ returnType.setScale(tree.get("returnType").get("scale").asInt());
+ }
+ if (tree.get("returnType").has("precision")) {
+ returnType.setPrecision(tree.get("returnType").get("precision").asInt());
+ }
+ if (tree.get("returnType").has("nullable")) {
+ returnType.setNullable(tree.get("returnType").get("nullable").asBoolean());
+ }
+ if (tree.get("returnType").has("maxLength")) {
+ returnType.setMaxLength(tree.get("returnType").get("maxLength").asInt());
+ }
+ action.setReturnType(returnType);
+ }
+
+ if (tree.has("parameters")) {
+ List<CsdlParameter> parameterList = new ArrayList<CsdlParameter>();
+ Iterator<Map.Entry<String, JsonNode>> iterator = tree.get("parameters").fields();
+ while (iterator.hasNext()) {
+ Map.Entry<String, JsonNode> entry = iterator.next();
+ CsdlParameter parameter = new CsdlParameter();
+ parameter.setName(entry.getKey());
+ if (entry.getValue().has("type")) {
+ String fullQualifiedName = entry.getValue().get("type").asText();
+ fullQualifiedName = fullQualifiedName.replace(schema.getAlias(), schema.getNamespace());
+ String typeName = "";
+ if (fullQualifiedName.contains("Collection")) {
+ parameter.setCollection(true);
+ typeName = fullQualifiedName.substring("Collection(".length(), fullQualifiedName.length() - 2);
+ } else {
+ typeName = fullQualifiedName;
+ }
+ parameter.setType(new FullQualifiedName(typeName));
+ }
+ if (entry.getValue().has("scale")) {
+ parameter.setScale(entry.getValue().get("scale").asInt());
+ }
+ if (entry.getValue().has("precision")) {
+ parameter.setPrecision(entry.getValue().get("precision").asInt());
+ }
+ if (entry.getValue().has("nullable")) {
+ parameter.setNullable(entry.getValue().get("nullable").asBoolean());
+ }
+ if (entry.getValue().has("maxLength")) {
+ parameter.setMaxLength(entry.getValue().get("maxLength").asInt());
+ }
+ parameterList.add(parameter);
+ }
+ action.setParameters(parameterList);
+ }
+
+ return action;
+ }
+}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/fa38869b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/json/ClientCsdlDefinitionsDeserializer.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/json/ClientCsdlDefinitionsDeserializer.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/json/ClientCsdlDefinitionsDeserializer.java
new file mode 100644
index 0000000..b72d66e
--- /dev/null
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/json/ClientCsdlDefinitionsDeserializer.java
@@ -0,0 +1,86 @@
+/*
+ * 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.client.core.edm.json;
+
+import com.fasterxml.jackson.core.JsonParser;
+import com.fasterxml.jackson.databind.DeserializationContext;
+import com.fasterxml.jackson.databind.JsonDeserializer;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.olingo.commons.api.edm.FullQualifiedName;
+import org.apache.olingo.commons.api.edm.provider.*;
+
+import java.io.IOException;
+import java.util.*;
+
+public class ClientCsdlDefinitionsDeserializer extends JsonDeserializer<ClientJsonSchemaCsdl> {
+
+ private ClientJsonSchemaCsdl jsonCsdl;
+
+ public ClientCsdlDefinitionsDeserializer(ClientJsonSchemaCsdl jsonCsdl){
+ this.jsonCsdl=jsonCsdl;
+ }
+
+ @Override
+ public ClientJsonSchemaCsdl deserialize(final JsonParser parser, final DeserializationContext ctxt)
+ throws IOException {
+ final ObjectNode tree = parser.getCodec().readTree(parser);
+ Iterator<Map.Entry<String, JsonNode>> iterator = tree.fields();
+ while (iterator.hasNext()) {
+ Map.Entry<String, JsonNode> typeObject;
+ typeObject = iterator.next();
+ String combinedNamespaceType = typeObject.getKey();
+ FullQualifiedName fullQualifiedTypeName = new FullQualifiedName(combinedNamespaceType);
+ String typeName = fullQualifiedTypeName.getName();
+ String nameSpace = fullQualifiedTypeName.getNamespace();
+ if(typeObject.getValue().has("enum")){
+ final CsdlEnumType enumType = new ClientCsdlEnumTypeDeserializer(nameSpace,typeName).deserialize(
+ tree.get(typeObject.getKey()).traverse(parser.getCodec()), ctxt);
+ if (getSchemaByNsOrAlias().get(nameSpace)!=null){
+ getSchemaByNsOrAlias().get(nameSpace).getEnumTypes().add(enumType);
+ }
+ }else if(typeObject.getValue().has("type")&&"object".equals(typeObject.getValue().get("type").asText())){
+ for(CsdlEntitySet entitySet : getSchemaByNsOrAlias().get(nameSpace)
+ .getEntityContainer().getEntitySets()){
+ if(entitySet.getType().equals(combinedNamespaceType)){
+ final CsdlEntityType type = new ClientCsdlEntityTypeDeserializer(nameSpace,typeName)
+ .deserialize(tree.get(typeObject.getKey()).traverse(parser.getCodec()), ctxt);
+ getSchemaByNsOrAlias().get(nameSpace).getEntityTypes().add(type);
+ }
+ }
+ }else{
+ //toDo Complex Type and other type definitions
+ }
+ }
+ return jsonCsdl;
+ }
+
+ public Map<String, CsdlSchema> getSchemaByNsOrAlias() {
+ final Map<String, CsdlSchema> schemaByNsOrAlias = new HashMap<String, CsdlSchema>();
+ for (CsdlSchema schema : jsonCsdl.getSchemas()) {
+ schemaByNsOrAlias.put(schema.getNamespace(), schema);
+ if (StringUtils.isNotBlank(schema.getAlias())) {
+ schemaByNsOrAlias.put(schema.getAlias(), schema);
+ }
+ }
+ return schemaByNsOrAlias;
+ }
+}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/fa38869b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/json/ClientCsdlEntitySetDeserializer.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/json/ClientCsdlEntitySetDeserializer.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/json/ClientCsdlEntitySetDeserializer.java
new file mode 100644
index 0000000..4aa4247
--- /dev/null
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/json/ClientCsdlEntitySetDeserializer.java
@@ -0,0 +1,56 @@
+/*
+ * 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.client.core.edm.json;
+
+import com.fasterxml.jackson.core.JsonParser;
+import com.fasterxml.jackson.databind.DeserializationContext;
+import com.fasterxml.jackson.databind.JsonDeserializer;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import org.apache.olingo.commons.api.edm.FullQualifiedName;
+import org.apache.olingo.commons.api.edm.provider.CsdlEntitySet;
+import org.apache.olingo.commons.api.edm.provider.CsdlSchema;
+
+import java.io.IOException;
+
+public class ClientCsdlEntitySetDeserializer extends JsonDeserializer<CsdlEntitySet> {
+
+ private String name;
+ private CsdlSchema schema;
+
+ public ClientCsdlEntitySetDeserializer(CsdlSchema schema,String name){
+ this.schema =schema;
+ this.name = name;
+ }
+
+
+ @Override
+ public CsdlEntitySet deserialize(final JsonParser parser, final DeserializationContext ctxt)
+ throws IOException {
+ final ObjectNode tree = parser.getCodec().readTree(parser);
+ CsdlEntitySet entitySet = new CsdlEntitySet();
+ entitySet.setName(name);
+ String entityTypeName=tree.get("entityType").asText();
+ String aliasReplaced = entityTypeName.replace(schema.getAlias(), schema.getNamespace());
+ FullQualifiedName typeName = new FullQualifiedName(aliasReplaced);
+ entitySet.setType(typeName);
+ //toDo navigational property bindings
+ return entitySet;
+ }
+}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/fa38869b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/json/ClientCsdlEntityTypeDeserializer.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/json/ClientCsdlEntityTypeDeserializer.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/json/ClientCsdlEntityTypeDeserializer.java
new file mode 100644
index 0000000..aeebf0c
--- /dev/null
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/json/ClientCsdlEntityTypeDeserializer.java
@@ -0,0 +1,67 @@
+/*
+ * 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.client.core.edm.json;
+
+import com.fasterxml.jackson.core.JsonParser;
+import com.fasterxml.jackson.databind.DeserializationContext;
+import com.fasterxml.jackson.databind.JsonDeserializer;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import org.apache.olingo.commons.api.edm.provider.CsdlEntityType;
+import org.apache.olingo.commons.api.edm.provider.CsdlPropertyRef;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+public class ClientCsdlEntityTypeDeserializer extends JsonDeserializer<CsdlEntityType> {
+
+ private String typeName;
+ private String nameSpace;
+
+ public ClientCsdlEntityTypeDeserializer(String nameSpace,String typeName){
+ this.nameSpace = nameSpace;
+ this.typeName = typeName;
+ }
+
+ @Override
+ public CsdlEntityType deserialize(final JsonParser parser, final DeserializationContext ctxt)
+ throws IOException {
+ final ObjectNode tree = parser.getCodec().readTree(parser);
+ CsdlEntityType type = new CsdlEntityType();
+ type.setName(typeName);
+ if(tree.has("keys")){
+ Iterator<JsonNode> itr=tree.get("keys").elements();
+ while (itr.hasNext()){
+ JsonNode key = itr.next();
+ CsdlPropertyRef propRef=new CsdlPropertyRef();
+ propRef.setName(key.get("name").asText());
+ List<CsdlPropertyRef> keys = new ArrayList<CsdlPropertyRef>();
+ keys.add(propRef);
+ type.setKey(keys);
+ }
+ }
+ if(tree.has("properties")){
+ //toDo add properties deserialization here
+ }
+ return type;
+ }
+}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/fa38869b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/json/ClientCsdlEnumTypeDeserializer.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/json/ClientCsdlEnumTypeDeserializer.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/json/ClientCsdlEnumTypeDeserializer.java
new file mode 100644
index 0000000..7fc706d
--- /dev/null
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/json/ClientCsdlEnumTypeDeserializer.java
@@ -0,0 +1,60 @@
+/*
+ * 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.client.core.edm.json;
+
+import com.fasterxml.jackson.core.JsonParser;
+import com.fasterxml.jackson.databind.DeserializationContext;
+import com.fasterxml.jackson.databind.JsonDeserializer;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import org.apache.olingo.commons.api.edm.provider.CsdlEnumMember;
+import org.apache.olingo.commons.api.edm.provider.CsdlEnumType;
+
+import java.io.IOException;
+import java.util.Iterator;
+
+public class ClientCsdlEnumTypeDeserializer extends JsonDeserializer<CsdlEnumType> {
+
+ private String typeName;
+ private String nameSpace;
+
+ public ClientCsdlEnumTypeDeserializer(String nameSpace,String typeName){
+ this.nameSpace = nameSpace;
+ this.typeName = typeName;
+ }
+
+ @Override
+ public CsdlEnumType deserialize(final JsonParser parser, final DeserializationContext ctxt)
+ throws IOException {
+ final ObjectNode tree = parser.getCodec().readTree(parser);
+ final CsdlEnumType enumType = new CsdlEnumType();
+ enumType.setName(typeName);
+ Iterator<JsonNode> itr=tree.get("enum").elements();
+ while(itr.hasNext()){
+ JsonNode node = itr.next();
+ CsdlEnumMember member=new CsdlEnumMember();
+ member.setName(node.asText());
+ member.setValue(tree.get(node.asText() + "@odata.value").asText());
+ enumType.getMembers().add(member);
+ }
+ return enumType;
+
+ }
+}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/fa38869b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/json/ClientCsdlFunctionDeserializer.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/json/ClientCsdlFunctionDeserializer.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/json/ClientCsdlFunctionDeserializer.java
new file mode 100644
index 0000000..5a94637
--- /dev/null
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/json/ClientCsdlFunctionDeserializer.java
@@ -0,0 +1,133 @@
+/*
+ * 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.client.core.edm.json;
+
+import com.fasterxml.jackson.core.JsonParser;
+import com.fasterxml.jackson.databind.DeserializationContext;
+import com.fasterxml.jackson.databind.JsonDeserializer;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import org.apache.olingo.commons.api.edm.FullQualifiedName;
+import org.apache.olingo.commons.api.edm.provider.CsdlFunction;
+import org.apache.olingo.commons.api.edm.provider.CsdlParameter;
+import org.apache.olingo.commons.api.edm.provider.CsdlReturnType;
+import org.apache.olingo.commons.api.edm.provider.CsdlSchema;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+public class ClientCsdlFunctionDeserializer extends JsonDeserializer<CsdlFunction> {
+
+ private CsdlSchema schema;
+
+ public ClientCsdlFunctionDeserializer(CsdlSchema schema) {
+ this.schema = schema;
+ }
+
+ @Override
+ public CsdlFunction deserialize(final JsonParser parser, final DeserializationContext ctxt)
+ throws IOException {
+ final ObjectNode tree = parser.getCodec().readTree(parser);
+ CsdlFunction function = new CsdlFunction();
+
+ if (tree.has("name")) {
+ function.setName(tree.get("name").asText());
+ }
+ if (tree.has("entitySetPath")) {
+ function.setEntitySetPath(tree.get("entitySetPath").asText());
+ }
+ if (tree.has("isBound")) {
+ function.setBound(tree.get("isBound").asBoolean());
+ }
+ if (tree.has("isComposable")) {
+ function.setComposable(tree.get("isComposable").asBoolean());
+ }
+
+ if (tree.has("returnType")) {
+ CsdlReturnType returnType = new CsdlReturnType();
+ if (tree.get("returnType").has("type")) {
+ String fullQualifiedName = tree.get("returnType").get("type").asText();
+ fullQualifiedName = fullQualifiedName.replace(schema.getAlias(), schema.getNamespace());
+ String typeName = "";
+ if (fullQualifiedName.contains("Collection")) {
+ returnType.setCollection(true);
+ typeName = fullQualifiedName.substring("Collection(".length(), fullQualifiedName.length() - 2);
+ } else {
+ typeName = fullQualifiedName;
+ }
+ returnType.setType(new FullQualifiedName(typeName));
+ }
+ if (tree.get("returnType").has("scale")) {
+ returnType.setScale(tree.get("returnType").get("scale").asInt());
+ }
+ if (tree.get("returnType").has("precision")) {
+ returnType.setPrecision(tree.get("returnType").get("precision").asInt());
+ }
+ if (tree.get("returnType").has("nullable")) {
+ returnType.setNullable(tree.get("returnType").get("nullable").asBoolean());
+ }
+ if (tree.get("returnType").has("maxLength")) {
+ returnType.setMaxLength(tree.get("returnType").get("maxLength").asInt());
+ }
+ function.setReturnType(returnType);
+ }
+
+ if (tree.has("parameters")) {
+ List<CsdlParameter> parameterList = new ArrayList<CsdlParameter>();
+ Iterator<Map.Entry<String, JsonNode>> iterator = tree.get("parameters").fields();
+ while (iterator.hasNext()) {
+ Map.Entry<String, JsonNode> entry = iterator.next();
+ CsdlParameter parameter = new CsdlParameter();
+ parameter.setName(entry.getKey());
+ if (entry.getValue().has("type")) {
+ String fullQualifiedName = entry.getValue().get("type").asText();
+ fullQualifiedName = fullQualifiedName.replace(schema.getAlias(), schema.getNamespace());
+ String typeName = "";
+ if (fullQualifiedName.contains("Collection")) {
+ parameter.setCollection(true);
+ typeName = fullQualifiedName.substring("Collection(".length(), fullQualifiedName.length() - 2);
+ } else {
+ typeName = fullQualifiedName;
+ }
+ parameter.setType(new FullQualifiedName(typeName));
+ }
+ if (entry.getValue().has("scale")) {
+ parameter.setScale(entry.getValue().get("scale").asInt());
+ }
+ if (entry.getValue().has("precision")) {
+ parameter.setPrecision(entry.getValue().get("precision").asInt());
+ }
+ if (entry.getValue().has("nullable")) {
+ parameter.setNullable(entry.getValue().get("nullable").asBoolean());
+ }
+ if (entry.getValue().has("maxLength")) {
+ parameter.setMaxLength(entry.getValue().get("maxLength").asInt());
+ }
+ parameterList.add(parameter);
+ }
+ function.setParameters(parameterList);
+ }
+
+ return function;
+ }
+}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/fa38869b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/json/ClientCsdlReferencesDeserializer.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/json/ClientCsdlReferencesDeserializer.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/json/ClientCsdlReferencesDeserializer.java
new file mode 100644
index 0000000..fc4dd08
--- /dev/null
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/json/ClientCsdlReferencesDeserializer.java
@@ -0,0 +1,86 @@
+/*
+ * 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.client.core.edm.json;
+
+import com.fasterxml.jackson.core.JsonParser;
+import com.fasterxml.jackson.databind.DeserializationContext;
+import com.fasterxml.jackson.databind.JsonDeserializer;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+
+import java.io.IOException;
+import java.net.URI;
+import java.util.*;
+
+public class ClientCsdlReferencesDeserializer extends JsonDeserializer<ClientJsonSchemaCsdl> {
+
+ private ClientJsonSchemaCsdl jsonCsdl;
+
+ public ClientCsdlReferencesDeserializer(ClientJsonSchemaCsdl jsonCsdl){
+ this.jsonCsdl=jsonCsdl;
+ }
+
+ @Override
+ public ClientJsonSchemaCsdl deserialize(final JsonParser parser, final DeserializationContext ctxt)
+ throws IOException {
+ final ObjectNode tree = parser.getCodec().readTree(parser);
+ Iterator<Map.Entry<String,JsonNode>> iterator = tree.fields();
+ while(iterator.hasNext()){
+ Map.Entry<String,JsonNode> referenceEntry = iterator.next();
+ ClientJsonCsdlReference reference = new ClientJsonCsdlReference();
+ jsonCsdl.getReferences().add(reference);
+ reference.setUri(URI.create(referenceEntry.getKey()));
+
+ if(referenceEntry.getValue().has("includes")){
+ JsonNode includes = referenceEntry.getValue().get("includes");
+ Iterator<Map.Entry<String,JsonNode>> includeElements = includes.fields();
+ while(includeElements.hasNext()){
+ Map.Entry<String,JsonNode> includeNode = includeElements.next();
+ ClientJsonCsdlInclude csdlInclude = new ClientJsonCsdlInclude();
+ csdlInclude.setNamespace(includeNode.getKey());
+ if(includeNode.getValue().has("alias")){
+ csdlInclude.setAlias(includeNode.getValue().get("alias").asText());
+ }
+ reference.getIncludes().add(csdlInclude);
+ }
+ }
+
+ if(referenceEntry.getValue().has("includeAnnotations")){
+ JsonNode includesAnnotations = referenceEntry.getValue().get("includeAnnotations");
+ Iterator<JsonNode> annotationEntry = includesAnnotations.elements();
+ while(annotationEntry.hasNext()){
+ JsonNode annotationNode = annotationEntry.next();
+ ClientJsonCsdlIncludeAnnotation csdlIncludeAnnotation = new ClientJsonCsdlIncludeAnnotation();
+ if(annotationNode.has("targetNamespace")){
+ csdlIncludeAnnotation.setTargetNamespace(annotationNode.get("targetNamespace").asText());
+ }
+ if(annotationNode.has("termNamespace")){
+ csdlIncludeAnnotation.setTermNamespace(annotationNode.get("termNamespace").asText());
+ }
+ if(annotationNode.has("qualifier")){
+ csdlIncludeAnnotation.setQualifier(annotationNode.get("qualifier").asText());
+ }
+ reference.getIncludeAnnotations().add(csdlIncludeAnnotation);
+ }
+ }
+ }
+ return jsonCsdl;
+ }
+}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/fa38869b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/json/ClientCsdlSchemasDeserializer.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/json/ClientCsdlSchemasDeserializer.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/json/ClientCsdlSchemasDeserializer.java
new file mode 100644
index 0000000..63abb59
--- /dev/null
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/json/ClientCsdlSchemasDeserializer.java
@@ -0,0 +1,96 @@
+/*
+ * 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.client.core.edm.json;
+
+import com.fasterxml.jackson.core.JsonParser;
+import com.fasterxml.jackson.databind.DeserializationContext;
+import com.fasterxml.jackson.databind.JsonDeserializer;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import org.apache.olingo.commons.api.edm.provider.*;
+
+import java.io.IOException;
+import java.util.Iterator;
+import java.util.Map;
+
+
+public class ClientCsdlSchemasDeserializer extends JsonDeserializer<ClientJsonSchemaCsdl> {
+ private ClientJsonSchemaCsdl jsonCsdl;
+
+ public ClientCsdlSchemasDeserializer(ClientJsonSchemaCsdl jsonCsdl){
+ this.jsonCsdl=jsonCsdl;
+ }
+
+ @Override
+ public ClientJsonSchemaCsdl deserialize(final JsonParser parser, final DeserializationContext ctxt)
+ throws IOException {
+
+ final ObjectNode tree = parser.getCodec().readTree(parser);
+ Iterator<Map.Entry<String, JsonNode>> iterator = tree.fields();
+ while (iterator.hasNext()) {
+ CsdlSchema schema = new CsdlSchema();
+ jsonCsdl.getSchemas().add(schema);
+ Map.Entry<String, JsonNode> schemaNode = iterator.next();
+ String nameSpace= schemaNode.getKey();
+ schema.setNamespace(nameSpace);
+ schema.setAlias(schemaNode.getValue().get("alias").asText());
+
+ JsonNode entityContainer = schemaNode.getValue().get("entityContainer");
+ if(entityContainer!=null){
+ CsdlEntityContainer container= new CsdlEntityContainer();
+ schema.setEntityContainer(container);
+ container.setName(entityContainer.get("name").asText());
+ Iterator<Map.Entry<String, JsonNode>> itr = entityContainer.get("entitySets").fields();
+ while(itr.hasNext()){
+ Map.Entry<String, JsonNode> entitySetEntry = itr.next();
+ JsonNode entitySetNode= entitySetEntry.getValue();
+ CsdlEntitySet entitySet = new ClientCsdlEntitySetDeserializer(schema,entitySetEntry.getKey())
+ .deserialize(entitySetNode.traverse(parser.getCodec()),ctxt);
+ container.getEntitySets().add(entitySet);
+ }
+ }
+
+ JsonNode actions = schemaNode.getValue().get("actions");
+ if (actions != null) {
+ Iterator<JsonNode> itr = actions.elements();
+ while (itr.hasNext()) {
+ JsonNode actionNode = itr.next();
+ CsdlAction action = new ClientCsdlActionDeserializer(schema)
+ .deserialize(actionNode.traverse(parser.getCodec()), ctxt);
+ schema.getActions().add(action);
+ }
+ }
+
+ JsonNode functions = schemaNode.getValue().get("functions");
+ if (actions != null) {
+ Iterator<JsonNode> itr = functions.elements();
+ while (itr.hasNext()) {
+ JsonNode functionNode = itr.next();
+ CsdlFunction function = new ClientCsdlFunctionDeserializer(schema)
+ .deserialize(functionNode.traverse(parser.getCodec()), ctxt);
+ schema.getFunctions().add(function);
+ }
+ }
+
+ }
+ return jsonCsdl;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/fa38869b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/json/ClientJsonCsdlInclude.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/json/ClientJsonCsdlInclude.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/json/ClientJsonCsdlInclude.java
new file mode 100644
index 0000000..8f0dbc4
--- /dev/null
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/json/ClientJsonCsdlInclude.java
@@ -0,0 +1,46 @@
+/*
+ * 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.client.core.edm.json;
+
+import org.apache.olingo.client.api.edm.xml.Include;
+
+public class ClientJsonCsdlInclude implements Include {
+
+ private String namespace;
+ private String alias;
+
+ @Override
+ public String getNamespace() {
+ return namespace;
+ }
+
+ public void setNamespace(final String namespace) {
+ this.namespace = namespace;
+ }
+
+ @Override
+ public String getAlias() {
+ return alias;
+ }
+
+ public void setAlias(final String alias) {
+ this.alias = alias;
+ }
+}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/fa38869b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/json/ClientJsonCsdlIncludeAnnotation.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/json/ClientJsonCsdlIncludeAnnotation.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/json/ClientJsonCsdlIncludeAnnotation.java
new file mode 100644
index 0000000..a915243
--- /dev/null
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/json/ClientJsonCsdlIncludeAnnotation.java
@@ -0,0 +1,56 @@
+/*
+ * 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.client.core.edm.json;
+
+import org.apache.olingo.client.api.edm.xml.IncludeAnnotations;
+
+public class ClientJsonCsdlIncludeAnnotation implements IncludeAnnotations {
+
+ private String termNamespace;
+ private String qualifier;
+ private String targetNamespace;
+
+ @Override
+ public String getTermNamespace() {
+ return termNamespace;
+ }
+
+ public void setTermNamespace(final String termNamespace) {
+ this.termNamespace = termNamespace;
+ }
+
+ @Override
+ public String getQualifier() {
+ return qualifier;
+ }
+
+ public void setQualifier(final String qualifier) {
+ this.qualifier = qualifier;
+ }
+
+ @Override
+ public String getTargetNamespace() {
+ return targetNamespace;
+ }
+
+ public void setTargetNamespace(final String targetNamespace) {
+ this.targetNamespace = targetNamespace;
+ }
+}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/fa38869b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/json/ClientJsonCsdlReference.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/json/ClientJsonCsdlReference.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/json/ClientJsonCsdlReference.java
new file mode 100644
index 0000000..ae1c353
--- /dev/null
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/json/ClientJsonCsdlReference.java
@@ -0,0 +1,62 @@
+/*
+ * 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.client.core.edm.json;
+
+import org.apache.olingo.client.api.edm.xml.Include;
+import org.apache.olingo.client.api.edm.xml.IncludeAnnotations;
+import org.apache.olingo.client.api.edm.xml.Reference;
+import org.apache.olingo.commons.api.edm.provider.CsdlAnnotation;
+
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.List;
+
+public class ClientJsonCsdlReference implements Reference {
+
+ private URI uri;
+ private final List<Include> includes = new ArrayList<Include>();
+ private final List<IncludeAnnotations> includeAnnotations = new ArrayList<IncludeAnnotations>();
+ private final List<CsdlAnnotation> annotations = new ArrayList<CsdlAnnotation>();
+
+ @Override
+ public List<CsdlAnnotation> getAnnotations() {
+ return annotations;
+ }
+
+ @Override
+ public URI getUri() {
+ return uri;
+ }
+
+ public void setUri(final URI uri) {
+ this.uri = uri;
+ }
+
+ @Override
+ public List<Include> getIncludes() {
+ return includes;
+ }
+
+ @Override
+ public List<IncludeAnnotations> getIncludeAnnotations() {
+ return includeAnnotations;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/fa38869b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/json/ClientJsonSchemaCsdl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/json/ClientJsonSchemaCsdl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/json/ClientJsonSchemaCsdl.java
new file mode 100644
index 0000000..2dce17a
--- /dev/null
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/json/ClientJsonSchemaCsdl.java
@@ -0,0 +1,73 @@
+/*
+ * 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.client.core.edm.json;
+
+import com.fasterxml.jackson.core.JsonParser;
+import com.fasterxml.jackson.databind.DeserializationContext;
+import com.fasterxml.jackson.databind.JsonDeserializer;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import org.apache.olingo.client.api.edm.json.EdmJsonSchema;
+import org.apache.olingo.client.api.edm.xml.Reference;
+
+import org.apache.olingo.commons.api.edm.provider.CsdlSchema;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+@JsonDeserialize(using = ClientJsonSchemaCsdl.JsonCsdlDeserializer.class)
+public class ClientJsonSchemaCsdl implements EdmJsonSchema {
+
+ private final List<Reference> references = new ArrayList<Reference>();
+
+ private final List<CsdlSchema> schemas = new ArrayList<CsdlSchema>();
+
+ @Override
+ public List<CsdlSchema> getSchemas() {
+ return schemas;
+ }
+
+ @Override
+ public List<Reference> getReferences() {
+ return references;
+ }
+
+ static class JsonCsdlDeserializer extends JsonDeserializer<ClientJsonSchemaCsdl> {
+
+ @Override
+ public ClientJsonSchemaCsdl deserialize(final JsonParser parser, final DeserializationContext ctxt)
+ throws IOException {
+ final ClientJsonSchemaCsdl jsonSchemaCsdl = new ClientJsonSchemaCsdl();
+ final ObjectNode tree = parser.getCodec().readTree(parser);
+ JsonNode definitionsNode=tree.get("definitions");
+ //Dependency exists schemas should be de serialized first
+ JsonNode schemasNode=tree.get("schemas");
+ new ClientCsdlSchemasDeserializer(jsonSchemaCsdl)
+ .deserialize(schemasNode.traverse(parser.getCodec()),ctxt);
+ JsonNode referencesNode=tree.get("references");
+ new ClientCsdlReferencesDeserializer(jsonSchemaCsdl)
+ .deserialize(referencesNode.traverse(parser.getCodec()), ctxt);
+ return new ClientCsdlDefinitionsDeserializer(jsonSchemaCsdl)
+ .deserialize(definitionsNode.traverse(parser.getCodec()), ctxt);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/fa38869b/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ClientODataDeserializerImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ClientODataDeserializerImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ClientODataDeserializerImpl.java
index 92bd57b..da11820 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ClientODataDeserializerImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ClientODataDeserializerImpl.java
@@ -23,11 +23,14 @@ import java.io.InputStream;
import javax.xml.stream.XMLStreamException;
+import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.olingo.client.api.data.ServiceDocument;
import org.apache.olingo.client.api.edm.xml.XMLMetadata;
import org.apache.olingo.client.api.serialization.ClientODataDeserializer;
import org.apache.olingo.client.core.data.JSONServiceDocumentDeserializer;
import org.apache.olingo.client.core.data.XMLServiceDocumentDeserializer;
+import org.apache.olingo.client.core.edm.ClientCsdlJSONMetadata;
+import org.apache.olingo.client.core.edm.json.ClientJsonSchemaCsdl;
import org.apache.olingo.client.core.edm.xml.ClientCsdlEdmx;
import org.apache.olingo.client.core.edm.ClientCsdlXMLMetadata;
import org.apache.olingo.commons.api.data.Delta;
@@ -111,10 +114,31 @@ public class ClientODataDeserializerImpl implements ClientODataDeserializer {
return xmlMapper;
}
+ protected ObjectMapper getObjectMapper() {
+ final ObjectMapper jsonMapper = new ObjectMapper();
+
+ jsonMapper.setInjectableValues(new InjectableValues.Std().addValue(Boolean.class, Boolean.FALSE));
+
+ jsonMapper.addHandler(new DeserializationProblemHandler() {
+ @Override
+ public boolean handleUnknownProperty(final DeserializationContext ctxt, final JsonParser jp,
+ final com.fasterxml.jackson.databind.JsonDeserializer<?> deserializer,
+ final Object beanOrClass, final String propertyName)
+ throws IOException, JsonProcessingException {
+
+ ctxt.getParser().skipChildren();
+ return true;
+ }
+ });
+ return jsonMapper;
+ }
+
@Override
public XMLMetadata toMetadata(final InputStream input) {
try {
- return new ClientCsdlXMLMetadata(getXmlMapper().readValue(input, ClientCsdlEdmx.class));
+ return format == ODataFormat.XML ?
+ new ClientCsdlXMLMetadata(getXmlMapper().readValue(input,ClientCsdlEdmx.class)):
+ new ClientCsdlJSONMetadata(getObjectMapper().readValue(input, ClientJsonSchemaCsdl.class));
} catch (Exception e) {
throw new IllegalArgumentException("Could not parse as Edmx document", e);
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/fa38869b/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ODataReaderImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ODataReaderImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ODataReaderImpl.java
index 6c97cdb..40634f8 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ODataReaderImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ODataReaderImpl.java
@@ -62,8 +62,8 @@ public class ODataReaderImpl implements ODataReader {
}
@Override
- public Edm readMetadata(final InputStream input) {
- return readMetadata(client.getDeserializer(ODataFormat.XML).toMetadata(input).getSchemaByNsOrAlias());
+ public Edm readMetadata(final InputStream input, final ODataFormat format) {
+ return readMetadata(client.getDeserializer(format).toMetadata(input).getSchemaByNsOrAlias());
}
@Override
@@ -129,7 +129,7 @@ public class ODataReaderImpl implements ODataReader {
res = new ResWrap<T>(
(URI) null,
null,
- reference.cast(readMetadata(src)));
+ reference.cast(readMetadata(src,ODataFormat.fromString(format))));
} else if (ClientServiceDocument.class.isAssignableFrom(reference)) {
final ResWrap<ServiceDocument> resource =
client.getDeserializer(ODataFormat.fromString(format)).toServiceDocument(src);
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/fa38869b/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/EntityTest.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/EntityTest.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/EntityTest.java
index 7373da6..f7109c0 100644
--- a/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/EntityTest.java
+++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/EntityTest.java
@@ -70,7 +70,7 @@ public class EntityTest extends AbstractTest {
@Override
public Edm getCachedEdm() {
if (edm == null) {
- edm = getReader().readMetadata(getClass().getResourceAsStream("staticservice-metadata.xml"));
+ edm = getReader().readMetadata(getClass().getResourceAsStream("staticservice-metadata.xml"),ODataFormat.XML);
}
return edm;
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/fa38869b/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/JsonMetadataTest.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/JsonMetadataTest.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/JsonMetadataTest.java
new file mode 100644
index 0000000..879b5fd
--- /dev/null
+++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/JsonMetadataTest.java
@@ -0,0 +1,55 @@
+/*
+ * 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.client.core.v4;
+
+import org.apache.olingo.client.api.ODataClient;
+import org.apache.olingo.client.core.AbstractTest;
+import org.apache.olingo.commons.api.edm.Edm;
+import org.apache.olingo.commons.api.edm.FullQualifiedName;
+import org.apache.olingo.commons.api.format.ODataFormat;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+public class JsonMetadataTest extends AbstractTest {
+
+
+ @Override
+ protected ODataClient getClient() {
+ return v4Client;
+ }
+
+ @Test
+ public void parse() {
+ final Edm edm = getClient().getReader().
+ readMetadata(getClass().getResourceAsStream("metadata.json"), ODataFormat.JSON);
+ assertNotNull(edm);
+
+ assertNotNull(edm.getEnumType(new FullQualifiedName("namespace", "ENString")));
+ assertNotNull(edm.getEntityType(new FullQualifiedName("namespace", "ETAbstractBase")));
+ assertNotNull(edm.getEntityContainer(new FullQualifiedName("namespace","container"))
+ .getEntitySet("ESAllPrim"));
+ assertEquals(edm.getEntityType(new FullQualifiedName("namespace", "ETAbstractBase")),
+ edm.getEntityContainer(new FullQualifiedName("namespace","container"))
+ .getEntitySet("ESAllPrim").getEntityType());
+
+ }
+}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/fa38869b/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/MetadataTest.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/MetadataTest.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/MetadataTest.java
index 562a255..4aafa67 100644
--- a/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/MetadataTest.java
+++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/MetadataTest.java
@@ -79,7 +79,8 @@ public class MetadataTest extends AbstractTest {
@Test
public void parse() {
- final Edm edm = getClient().getReader().readMetadata(getClass().getResourceAsStream("metadata.xml"));
+ final Edm edm = getClient().getReader().
+ readMetadata(getClass().getResourceAsStream("metadata.xml"),ODataFormat.XML);
assertNotNull(edm);
// 1. Enum
@@ -155,7 +156,7 @@ public class MetadataTest extends AbstractTest {
// Now let's test some edm:Annotations
final Edm edm = getClient().getReader().
- readMetadata(getClass().getResourceAsStream("demo-metadata.xml"));
+ readMetadata(getClass().getResourceAsStream("demo-metadata.xml"),ODataFormat.XML);
assertNotNull(edm);
final EdmSchema schema = edm.getSchema("ODataDemo");
@@ -239,7 +240,8 @@ public class MetadataTest extends AbstractTest {
functionImport.getFunction());
// Now let's go high-level
- final Edm edm = getClient().getReader().readMetadata(getClass().getResourceAsStream("fromdoc1-metadata.xml"));
+ final Edm edm = getClient().getReader().readMetadata(getClass().getResourceAsStream("fromdoc1-metadata.xml")
+ ,ODataFormat.XML);
assertNotNull(edm);
List<EdmSchema> schemaList = edm.getSchemas();
@@ -325,7 +327,8 @@ public class MetadataTest extends AbstractTest {
*/
@Test
public void fromdoc3() {
- final Edm edm = getClient().getReader().readMetadata(getClass().getResourceAsStream("fromdoc3-metadata.xml"));
+ final Edm edm = getClient().getReader().readMetadata(getClass().getResourceAsStream("fromdoc3-metadata.xml")
+ ,ODataFormat.XML);
assertNotNull(edm);
final EdmAnnotations group = edm.getSchema("Annotations").getAnnotationGroups().get(0);
@@ -371,7 +374,8 @@ public class MetadataTest extends AbstractTest {
assertTrue(urlRef.getValue().asDynamic().isApply());
// Now let's go high-level
- final Edm edm = getClient().getReader().readMetadata(getClass().getResourceAsStream("fromdoc4-metadata.xml"));
+ final Edm edm = getClient().getReader().readMetadata(getClass().getResourceAsStream("fromdoc4-metadata.xml")
+ ,ODataFormat.XML);
assertNotNull(edm);
final EdmAnnotations edmGroup = edm.getSchemas().get(0).getAnnotationGroups().get(0);
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/fa38869b/lib/client-core/src/test/resources/org/apache/olingo/client/core/v4/metadata.json
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/resources/org/apache/olingo/client/core/v4/metadata.json b/lib/client-core/src/test/resources/org/apache/olingo/client/core/v4/metadata.json
new file mode 100644
index 0000000..299c75c
--- /dev/null
+++ b/lib/client-core/src/test/resources/org/apache/olingo/client/core/v4/metadata.json
@@ -0,0 +1 @@
+{"$schema":"http://docs.oasis-open.org/odata/odata-json-csdl/v4.0/edm.json#","definitions":{"namespace.ENString":{"enum":["String1"],"String1@odata.value":"1"},"namespace.ETAbstractBase":{"type":"object","allOf":[{"$ref":"http://docs.oasis-open.org/odata/odata-json-csdl/v4.0/edm.json#/definitions/namespace.ETAbstract"}],"keys":[{"name":"PropertyInt16"}],"properties":{"PropertyInt16":{"$ref":"http://docs.oasis-open.org/odata/odata-json-csdl/v4.0/edm.json#/definitions/Edm.Int16"}}}},"schemas":{"namespace":{"alias":"Alias","entityContainer":{"name":"container","entitySets":{"ESAllPrim":{"entityType":"Alias.ETAbstractBase"}}}}},"references":{"http://docs.oasis-open.org/odata/odata/v4.0/cs02/vocabularies/Org.OData.Core.V1.xml":{"includes":{"Org.OData.Core.V1":{"alias":"Core"}}}}}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/fa38869b/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/json/MetadataDocumentJsonSerializer.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/json/MetadataDocumentJsonSerializer.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/json/MetadataDocumentJsonSerializer.java
index 6d6875c..e67ac01 100644
--- a/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/json/MetadataDocumentJsonSerializer.java
+++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/json/MetadataDocumentJsonSerializer.java
@@ -39,6 +39,8 @@ public class MetadataDocumentJsonSerializer {
private final Map<String, String> namespaceToAlias = new HashMap<String, String>();
private static final String CONSTANT_SCHEMA = "$schema";
private static final String DEFAULT_SCHEMA="http://docs.oasis-open.org/odata/odata-json-csdl/v4.0/edm.json#";
+ private static final String CONSTANT_VERSION = "odata-version";
+ private static final String CONSTANT_VERSION_VALUE = "4.0";
private static final String CONSTANT_DEFINITION_REFERENCE=DEFAULT_SCHEMA+"/definitions/";
private static final String CONSTANT_REFERENCE_IDENTIFIER="$ref";
private static final String CONSTANT_REFERENCES = "references";
@@ -113,8 +115,9 @@ public class MetadataDocumentJsonSerializer {
public void writeMetadataDocument(final JsonGenerator gen) throws IOException {
gen.writeStartObject();
gen.writeObjectField(CONSTANT_SCHEMA, DEFAULT_SCHEMA);
+ gen.writeObjectField(CONSTANT_VERSION, CONSTANT_VERSION_VALUE);
appendDefinitions(gen);
- appendSchemas(gen);
+ appendSchemas(gen);
appendReference(gen);
gen.writeEndObject();
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/fa38869b/lib/server-core/src/test/java/org/apache/olingo/server/core/serializer/json/MetadataDocumentJsonSerializerTest.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/test/java/org/apache/olingo/server/core/serializer/json/MetadataDocumentJsonSerializerTest.java b/lib/server-core/src/test/java/org/apache/olingo/server/core/serializer/json/MetadataDocumentJsonSerializerTest.java
index bd72810..566868b 100644
--- a/lib/server-core/src/test/java/org/apache/olingo/server/core/serializer/json/MetadataDocumentJsonSerializerTest.java
+++ b/lib/server-core/src/test/java/org/apache/olingo/server/core/serializer/json/MetadataDocumentJsonSerializerTest.java
@@ -63,8 +63,8 @@ public class MetadataDocumentJsonSerializerTest {
ServiceMetadata metadata = mock(ServiceMetadata.class);
when(metadata.getEdm()).thenReturn(edm);
String resultString = IOUtils.toString(serializer.metadataDocument(metadata).getContent());
- String expectedString = "{\"$schema\":\"http://docs.oasis-open.org/odata/odata-json-csdl/" +
- "v4.0/edm.json#\"}";
+ String expectedString = "{\"$schema\":\"http://docs.oasis-open.org/odata/odata-json-csdl/v4.0/edm.json#\",\"" +
+ "odata-version\":\"4.0\"}";
assertEquals(expectedString, resultString);
}
@@ -78,9 +78,8 @@ public class MetadataDocumentJsonSerializerTest {
when(serviceMetadata.getEdm()).thenReturn(edm);
InputStream metadata = serializer.metadataDocument(serviceMetadata).getContent();
String resultString = IOUtils.toString(metadata);
- String expectedString = "{\"$schema\":\"http://docs.oasis-open.org/odata/odata-json-csdl/" +
- "v4.0/edm.json#\",\"definitions\":{},\"schemas\":{\"MyNamespace\":" +
- "{\"alias\":null}}}";
+ String expectedString = "{\"$schema\":\"http://docs.oasis-open.org/odata/odata-json-csdl/v4.0/edm.json#\",\"" +
+ "odata-version\":\"4.0\",\"definitions\":{},\"schemas\":{\"MyNamespace\":{\"alias\":null}}}";
assertNotNull(metadata);
assertEquals(expectedString, resultString);
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/fa38869b/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/json/MetadataDocumentJsonTest.java
----------------------------------------------------------------------
diff --git a/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/json/MetadataDocumentJsonTest.java b/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/json/MetadataDocumentJsonTest.java
index 8ef17fe..7e2e908 100644
--- a/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/json/MetadataDocumentJsonTest.java
+++ b/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/json/MetadataDocumentJsonTest.java
@@ -56,6 +56,8 @@ public class MetadataDocumentJsonTest {
expectedString="\"$schema\":\"http://docs.oasis-open.org/odata/odata-json-csdl/v4.0/edm.json#\"";
assertThat(metadata, containsString(expectedString));
+ expectedString="\"odata-version\":\"4.0\"";
+ assertThat(metadata, containsString(expectedString));
expectedString="\"olingo.odata.test1.ENString\":{\"enum\":[\"String1\",\"String2\",\"String3\"]," +
"\"String1@odata.value\":\"1\",\"String2@odata.value\":\"2\",\"String3@odata.value\":\"4\"}";