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/08/18 14:00:05 UTC

olingo-odata4 git commit: [OLINGO-570] JsonMetadataDeserializer part3

Repository: olingo-odata4
Updated Branches:
  refs/heads/jsonMetadata e4e3c187d -> 1e6d06e2c


[OLINGO-570] JsonMetadataDeserializer part3


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

Branch: refs/heads/jsonMetadata
Commit: 1e6d06e2c17ccdb5951d716a5a98ac4bb4ed31c4
Parents: e4e3c18
Author: Christian Amend <ch...@sap.com>
Authored: Tue Aug 18 13:59:28 2015 +0200
Committer: Christian Amend <ch...@sap.com>
Committed: Tue Aug 18 13:59:28 2015 +0200

----------------------------------------------------------------------
 .../json/ClientCsdlComplexTypeDeserializer.java |  96 +++++++++++
 .../json/ClientCsdlDefinitionsDeserializer.java |  12 +-
 .../json/ClientCsdlEntityTypeDeserializer.java  |  66 ++++++-
 ...lientCsdlNavigationPropertyDeserializer.java | 138 +++++++++++++++
 .../json/ClientCsdlPropertyDeserializer.java    | 170 +++++++++++++++++++
 5 files changed, 473 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/1e6d06e2/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/json/ClientCsdlComplexTypeDeserializer.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/json/ClientCsdlComplexTypeDeserializer.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/json/ClientCsdlComplexTypeDeserializer.java
new file mode 100644
index 0000000..ed7be37
--- /dev/null
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/json/ClientCsdlComplexTypeDeserializer.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.FullQualifiedName;
+import org.apache.olingo.commons.api.edm.provider.CsdlComplexType;
+import org.apache.olingo.commons.api.edm.provider.CsdlNavigationProperty;
+import org.apache.olingo.commons.api.edm.provider.CsdlProperty;
+import org.apache.olingo.commons.api.edm.provider.CsdlReferentialConstraint;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.Map;
+
+public class ClientCsdlComplexTypeDeserializer extends JsonDeserializer<CsdlComplexType> {
+
+    private static final String DEFAULT_SCHEMA = "http://docs.oasis-open.org/odata/odata-json-csdl/v4.0/edm.json#";
+    private static final String CONSTANT_DEFINITION_REFERENCE = DEFAULT_SCHEMA + "/definitions/";
+
+    private String typeName;
+    private String nameSpace;
+
+    public ClientCsdlComplexTypeDeserializer(String nameSpace, String typeName) {
+        this.nameSpace = nameSpace;
+        this.typeName = typeName;
+    }
+
+    @Override
+    public CsdlComplexType deserialize(final JsonParser parser, final DeserializationContext ctxt)
+            throws IOException {
+        final ObjectNode tree = parser.getCodec().readTree(parser);
+        CsdlComplexType type = new CsdlComplexType();
+        type.setName(typeName);
+
+        if (tree.has("allOf")) {
+            Iterator<JsonNode> itr = tree.get("allOf").elements();
+            JsonNode baseTypeNode = itr.next();
+            if (baseTypeNode != null) {
+                if (baseTypeNode.has("$ref")) {
+                    String fqnAsString = baseTypeNode.get("$ref").asText().replace(CONSTANT_DEFINITION_REFERENCE, "");
+                    fqnAsString = fqnAsString.trim();
+                    type.setBaseType(new FullQualifiedName(fqnAsString));
+                }
+            }
+        }
+
+        if (tree.has("abstract")) {
+            type.setAbstract(tree.get("abstract").asBoolean());
+        }
+
+        if (tree.has("properties")) {
+            Iterator<Map.Entry<String, JsonNode>> iterator = tree.get("properties").fields();
+            ArrayList<CsdlNavigationProperty> navigationProperties = new ArrayList<CsdlNavigationProperty>();
+            ArrayList<CsdlProperty> properties = new ArrayList<CsdlProperty>();
+            while (iterator.hasNext()) {
+                Map.Entry<String, JsonNode> entry = iterator.next();
+                if (entry.getValue().has("relationship")) {
+                    final CsdlNavigationProperty property = new ClientCsdlNavigationPropertyDeserializer(entry.getKey())
+                            .deserialize(tree.get("properties").get(entry.getKey()).traverse(parser.getCodec()), ctxt);
+                    navigationProperties.add(property);
+                } else {
+                    final CsdlProperty property = new ClientCsdlPropertyDeserializer(entry.getKey())
+                            .deserialize(tree.get("properties").get(entry.getKey()).traverse(parser.getCodec()), ctxt);
+                    properties.add(property);
+
+                }
+            }
+            type.setNavigationProperties(navigationProperties);
+            type.setProperties(properties);
+        }
+        return type;
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/1e6d06e2/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
index d26feda..c3bf05b 100644
--- 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
@@ -58,15 +58,25 @@ public class ClientCsdlDefinitionsDeserializer extends JsonDeserializer<ClientJs
                     getSchemaByNsOrAlias().get(nameSpace).getEnumTypes().add(enumType);
                 }
             }else if(typeObject.getValue().has("type")&&"object".equals(typeObject.getValue().get("type").asText())){
+
+                boolean isEntityType = false;
                 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);
+                        isEntityType=true;
+                        break;
                     }
                 }
-                //toDo Complex Type
+
+                if(!isEntityType) {
+                    final CsdlComplexType type = new ClientCsdlComplexTypeDeserializer(nameSpace, typeName)
+                            .deserialize(tree.get(typeObject.getKey()).traverse(parser.getCodec()), ctxt);
+                    getSchemaByNsOrAlias().get(nameSpace).getComplexTypes().add(type);
+                }
+
             } else if (typeObject.getValue().has("type") &&
                     !("object".equals(typeObject.getValue().get("type").asText()))) {
                 final CsdlTypeDefinition typeDefinition = new ClientCsdlTypeDefinitionDeserializer(nameSpace, typeName)

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/1e6d06e2/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
index aeebf0c..5aa50e7 100644
--- 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
@@ -24,16 +24,23 @@ 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.CsdlEntityType;
+import org.apache.olingo.commons.api.edm.provider.CsdlNavigationProperty;
+import org.apache.olingo.commons.api.edm.provider.CsdlProperty;
 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;
+import java.util.Map;
 
 public class ClientCsdlEntityTypeDeserializer extends JsonDeserializer<CsdlEntityType> {
 
+    private static final String DEFAULT_SCHEMA="http://docs.oasis-open.org/odata/odata-json-csdl/v4.0/edm.json#";
+    private static final String CONSTANT_DEFINITION_REFERENCE=DEFAULT_SCHEMA+"/definitions/";
+
     private String typeName;
     private String nameSpace;
 
@@ -48,19 +55,62 @@ public class ClientCsdlEntityTypeDeserializer extends JsonDeserializer<CsdlEntit
         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()){
+        if (tree.has("keys")) {
+            Iterator<JsonNode> itr = tree.get("keys").elements();
+            List<CsdlPropertyRef> keys = new ArrayList<CsdlPropertyRef>();
+            while (itr.hasNext()) {
                 JsonNode key = itr.next();
-                CsdlPropertyRef propRef=new CsdlPropertyRef();
+                CsdlPropertyRef propRef = new CsdlPropertyRef();
                 propRef.setName(key.get("name").asText());
-                List<CsdlPropertyRef> keys = new ArrayList<CsdlPropertyRef>();
+                if (key.has("alias")) {
+                    propRef.setAlias(key.get("alias").asText());
+                }
                 keys.add(propRef);
-                type.setKey(keys);
             }
+            type.setKey(keys);
+        }
+
+        if (tree.has("allOf")) {
+            Iterator<JsonNode> itr = tree.get("allOf").elements();
+            JsonNode baseTypeNode = itr.next();
+            if (baseTypeNode != null) {
+                if (baseTypeNode.has("$ref")) {
+                    String fqnAsString = baseTypeNode.get("$ref").asText().replace(CONSTANT_DEFINITION_REFERENCE, "");
+                    fqnAsString = fqnAsString.trim();
+                    type.setBaseType(new FullQualifiedName(fqnAsString));
+                }
+            }
+        }
+
+        if (tree.has("abstract")) {
+            type.setAbstract(tree.get("abstract").asBoolean());
         }
-        if(tree.has("properties")){
-            //toDo add properties deserialization here
+        if (tree.has("hasStream")) {
+            type.setHasStream(tree.get("hasStream").asBoolean());
+        }
+        if (tree.has("openType")) {
+            type.setOpenType(tree.get("openType").asBoolean());
+        }
+
+        if (tree.has("properties")) {
+            Iterator<Map.Entry<String, JsonNode>> iterator = tree.get("properties").fields();
+            ArrayList<CsdlNavigationProperty> navigationProperties = new ArrayList<CsdlNavigationProperty>();
+            ArrayList<CsdlProperty> properties = new ArrayList<CsdlProperty>();
+            while (iterator.hasNext()) {
+                Map.Entry<String, JsonNode> entry = iterator.next();
+                if (entry.getValue().has("relationship")) {
+                    final CsdlNavigationProperty property = new ClientCsdlNavigationPropertyDeserializer(entry.getKey())
+                            .deserialize(tree.get("properties").get(entry.getKey()).traverse(parser.getCodec()), ctxt);
+                    navigationProperties.add(property);
+                } else {
+                    final CsdlProperty property = new ClientCsdlPropertyDeserializer(entry.getKey())
+                            .deserialize(tree.get("properties").get(entry.getKey()).traverse(parser.getCodec()), ctxt);
+                    properties.add(property);
+
+                }
+            }
+            type.setNavigationProperties(navigationProperties);
+            type.setProperties(properties);
         }
         return type;
     }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/1e6d06e2/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/json/ClientCsdlNavigationPropertyDeserializer.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/json/ClientCsdlNavigationPropertyDeserializer.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/json/ClientCsdlNavigationPropertyDeserializer.java
new file mode 100644
index 0000000..c9cad74
--- /dev/null
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/json/ClientCsdlNavigationPropertyDeserializer.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.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.CsdlNavigationProperty;
+import org.apache.olingo.commons.api.edm.provider.CsdlReferentialConstraint;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.Map;
+
+public class ClientCsdlNavigationPropertyDeserializer extends JsonDeserializer<CsdlNavigationProperty> {
+
+    private static final String DEFAULT_SCHEMA = "http://docs.oasis-open.org/odata/odata-json-csdl/v4.0/edm.json#";
+    private static final String CONSTANT_DEFINITION_REFERENCE = DEFAULT_SCHEMA + "/definitions/";
+
+    private String propertyName;
+
+
+    public ClientCsdlNavigationPropertyDeserializer(String propertyName) {
+        this.propertyName = propertyName;
+    }
+
+    @Override
+    public CsdlNavigationProperty deserialize(final JsonParser parser, final DeserializationContext ctxt)
+            throws IOException {
+        final ObjectNode tree = parser.getCodec().readTree(parser);
+        CsdlNavigationProperty property = new CsdlNavigationProperty();
+        property.setName(propertyName);
+
+        if (tree.has("$ref")) {
+            String fqnAsString = tree.get("$ref").asText().replace(CONSTANT_DEFINITION_REFERENCE, "");
+            fqnAsString = fqnAsString.trim();
+            property.setType(new FullQualifiedName(fqnAsString));
+            property.setNullable(false);
+            property.setCollection(false);
+        }
+
+        if (tree.has("anyOf")) {
+            Iterator<JsonNode> iterator = tree.get("anyOf").elements();
+            while (iterator.hasNext()) {
+                JsonNode node = iterator.next();
+                if (node.has("$ref")) {
+                    String fqnAsString = node.get("$ref").asText().replace(CONSTANT_DEFINITION_REFERENCE, "");
+                    fqnAsString = fqnAsString.trim();
+                    property.setType(new FullQualifiedName(fqnAsString));
+                    property.setCollection(false);
+                } else if (node.has("type")) {
+                    if (node.get("type").asText().equals(null)) {
+                        property.setNullable(true);
+                    }
+                }
+            }
+        }
+
+
+        if (tree.has("type")) {
+            if (tree.get("type").asText().equals("array")) {
+                if (tree.has("items")) {
+                    if (tree.get("items").has("$ref")) {
+                        String fqnAsString = tree.get("items").get("$ref").asText()
+                                .replace(CONSTANT_DEFINITION_REFERENCE, "");
+                        fqnAsString = fqnAsString.trim();
+                        property.setType(new FullQualifiedName(fqnAsString));
+                        property.setNullable(false);
+                        property.setCollection(true);
+                    } else if (tree.get("items").has("anyOf")) {
+                        Iterator<JsonNode> iterator = tree.get("items").get("anyOf").elements();
+                        while (iterator.hasNext()) {
+                            JsonNode node = iterator.next();
+                            if (node.has("$ref")) {
+                                String fqnAsString = node.get("$ref").asText()
+                                        .replace(CONSTANT_DEFINITION_REFERENCE, "");
+                                fqnAsString = fqnAsString.trim();
+                                property.setType(new FullQualifiedName(fqnAsString));
+                                property.setCollection(true);
+                            } else if (node.has("type")) {
+                                if (node.get("type").asText().equals(null)) {
+                                    property.setNullable(true);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+        }
+
+        if (tree.has("relationship")) {
+            JsonNode relationship = tree.get("relationship");
+            if (relationship.has("partner")) {
+                property.setPartner(relationship.get("partner").asText());
+            }
+            if (relationship.has("containsTarget")) {
+                property.setContainsTarget(relationship.get("containsTarget").asBoolean());
+            }
+            if (relationship.has("referentialConstraints")) {
+                Iterator<Map.Entry<String, JsonNode>> iterator = relationship.get("referentialConstraints").fields();
+                ArrayList<CsdlReferentialConstraint> constraintsList = new ArrayList<CsdlReferentialConstraint>();
+
+                while (iterator.hasNext()) {
+                    Map.Entry<String, JsonNode> entry = iterator.next();
+                    CsdlReferentialConstraint constraint = new CsdlReferentialConstraint();
+                    constraint.setProperty(entry.getKey());
+                    if (entry.getValue().has("referencedProperty")) {
+                        constraint.setReferencedProperty(entry.getValue().get("referencedProperty").asText());
+                    }
+                    constraintsList.add(constraint);
+                }
+                property.setReferentialConstraints(constraintsList);
+            }
+        }
+        return property;
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/1e6d06e2/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/json/ClientCsdlPropertyDeserializer.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/json/ClientCsdlPropertyDeserializer.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/json/ClientCsdlPropertyDeserializer.java
new file mode 100644
index 0000000..c0528da
--- /dev/null
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/json/ClientCsdlPropertyDeserializer.java
@@ -0,0 +1,170 @@
+/*
+ * 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.EdmPrimitiveTypeKind;
+import org.apache.olingo.commons.api.edm.FullQualifiedName;
+import org.apache.olingo.commons.api.edm.provider.CsdlProperty;
+import org.apache.olingo.commons.core.edm.primitivetype.EdmPrimitiveTypeFactory;
+
+import java.io.IOException;
+import java.util.Iterator;
+
+public class ClientCsdlPropertyDeserializer extends JsonDeserializer<CsdlProperty> {
+
+    private static final String DEFAULT_SCHEMA = "http://docs.oasis-open.org/odata/odata-json-csdl/v4.0/edm.json#";
+    private static final String CONSTANT_DEFINITION_REFERENCE = DEFAULT_SCHEMA + "/definitions/";
+
+    private String propertyName;
+
+
+    public ClientCsdlPropertyDeserializer(String propertyName) {
+        this.propertyName = propertyName;
+    }
+
+    @Override
+    public CsdlProperty deserialize(final JsonParser parser, final DeserializationContext ctxt)
+            throws IOException {
+        final ObjectNode tree = parser.getCodec().readTree(parser);
+        CsdlProperty property = new CsdlProperty();
+        property.setName(propertyName);
+
+        if (tree.has("type") && !tree.get("type").asText().equals("array")) {
+            property.setCollection(false);
+            if (!tree.get("type").isArray()) {
+                if (tree.get("type").asText().equals("string")) {
+                    property.setType(EdmPrimitiveTypeFactory
+                            .getInstance(EdmPrimitiveTypeKind.String).getFullQualifiedName());
+
+                } else if (tree.get("type").asText().equals("number")) {
+                    property.setType(EdmPrimitiveTypeFactory
+                            .getInstance(EdmPrimitiveTypeKind.Decimal).getFullQualifiedName());
+
+                } else if (tree.get("type").asText().equals("boolean")) {
+                    property.setType(EdmPrimitiveTypeFactory
+                            .getInstance(EdmPrimitiveTypeKind.Boolean).getFullQualifiedName());
+                }
+            } else {
+                Iterator<JsonNode> iterator = tree.get("type").elements();
+                while (iterator.hasNext()) {
+                    JsonNode booleanOrString = iterator.next();
+                    if (booleanOrString.asText().equals("string")) {
+                        property.setType(EdmPrimitiveTypeFactory
+                                .getInstance(EdmPrimitiveTypeKind.String).getFullQualifiedName());
+
+                    } else if (booleanOrString.asText().equals("boolean")) {
+                        property.setType(EdmPrimitiveTypeFactory
+                                .getInstance(EdmPrimitiveTypeKind.Boolean).getFullQualifiedName());
+                    } else if (booleanOrString.asText().equals(null)) {
+                        property.setNullable(true);
+                    }
+                }
+            }
+        }
+
+        if (tree.has("$ref") && tree.has("type") && !tree.get("type").asText().equals("array")) {
+            String fqnAsString = tree.get("$ref").asText().replace(CONSTANT_DEFINITION_REFERENCE, "");
+            fqnAsString = fqnAsString.trim();
+            property.setType(new FullQualifiedName(fqnAsString));
+            property.setCollection(false);
+        }
+
+        this.deserializePropertyFacets(tree, property);
+
+        if (tree.has("items") && tree.has("type") && tree.get("type").asText().equals("array")) {
+            property.setCollection(true);
+            JsonNode collectionProperty = tree.get("items");
+            if (collectionProperty.has("type")) {
+                if (collectionProperty.get("type").asText().equals("string")) {
+                    property.setType(EdmPrimitiveTypeFactory
+                            .getInstance(EdmPrimitiveTypeKind.String).getFullQualifiedName());
+
+                } else if (collectionProperty.get("type").asText().equals("number")) {
+                    property.setType(EdmPrimitiveTypeFactory
+                            .getInstance(EdmPrimitiveTypeKind.Decimal).getFullQualifiedName());
+
+                } else if (collectionProperty.get("type").asText().equals("boolean")) {
+                    property.setType(EdmPrimitiveTypeFactory
+                            .getInstance(EdmPrimitiveTypeKind.Boolean).getFullQualifiedName());
+                }
+                this.deserializePropertyFacets(collectionProperty, property);
+            }
+        }
+
+        return property;
+    }
+
+    private void deserializePropertyFacets(JsonNode tree, CsdlProperty property) {
+
+        if (tree.has("unicode")) {
+            property.setUnicode(tree.get("unicode").asBoolean());
+        }
+
+        if (tree.has("defaultValue")) {
+            property.setDefaultValue(tree.get("defaultValue").asText());
+        }
+
+        if (tree.has("maxLength")) {
+            property.setMaxLength(tree.get("maxLength").asInt());
+        }
+
+        if (tree.has("multipleOf")) {
+            int unstructured = tree.get("maxLength").asInt();
+            String temp = String.valueOf(unstructured);
+            if (temp.equals("1")) {
+                property.setScale(0);
+            } else {
+                temp = temp.replace("1e-", "");
+                property.setScale(Integer.valueOf(temp));
+            }
+        }
+
+        if (tree.has("minimum") && tree.has("maximum")) {
+            int maximum = tree.get("maximum").asInt();
+            int scale;
+            if (tree.has("multipleOf")) {
+                int unstructured = tree.get("maxLength").asInt();
+                String temp = String.valueOf(unstructured);
+                if (temp.equals("1")) {
+                    scale = 0;
+                } else {
+                    temp = temp.replace("1e-", "");
+                    scale = Integer.valueOf(temp);
+                }
+            } else {
+                scale = 0;
+            }
+
+            String strMax = String.valueOf(maximum);
+            String[] arrayStr = strMax.split("\\.");
+
+            char[] charArray = arrayStr[0].toCharArray();
+            int precision;
+            precision = scale + charArray.length;
+            property.setPrecision(precision);
+        }
+    }
+}
\ No newline at end of file