You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@olingo.apache.org by mi...@apache.org on 2015/04/02 11:04:46 UTC

[08/18] olingo-odata4 git commit: OLINGO-573: New processing framework on server side with single interface with TripPin as example

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/2b73abcc/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/DataCreator.java
----------------------------------------------------------------------
diff --git a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/DataCreator.java b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/DataCreator.java
index e6193df..1f28900 100644
--- a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/DataCreator.java
+++ b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/DataCreator.java
@@ -6,9 +6,9 @@
  * 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
@@ -41,11 +41,14 @@ import org.apache.olingo.commons.core.data.EntityImpl;
 import org.apache.olingo.commons.core.data.EntitySetImpl;
 import org.apache.olingo.commons.core.data.LinkImpl;
 import org.apache.olingo.commons.core.data.PropertyImpl;
+import org.apache.olingo.server.tecsvc.provider.ComplexTypeProvider;
+import org.apache.olingo.server.tecsvc.provider.EntityTypeProvider;
+
 
 public class DataCreator {
 
   private static final UUID GUID = UUID.fromString("01234567-89ab-cdef-0123-456789abcdef");
-
+  private static final String ctPropComp = ComplexTypeProvider.nameCTTwoPrim.getFullQualifiedNameAsString();
   private final Map<String, EntitySet> data;
 
   public DataCreator() {
@@ -96,7 +99,9 @@ public class DataCreator {
           .addProperty(createPrimitive("PropertyInt16", i))
           .addProperty(createPrimitive("PropertyString", "Number:" + i)));
     }
-
+    for (Entity en:entitySet.getEntities()) {
+      en.setType(EntityTypeProvider.nameETServerSidePaging.getFullQualifiedNameAsString());
+    }
     return entitySet;
   }
 
@@ -106,7 +111,9 @@ public class DataCreator {
     entitySet.getEntities().add(createETKeyNavEntity(1, "I am String Property 1"));
     entitySet.getEntities().add(createETKeyNavEntity(2, "I am String Property 2"));
     entitySet.getEntities().add(createETKeyNavEntity(3, "I am String Property 3"));
-
+    for (Entity en:entitySet.getEntities()) {
+      en.setType(EntityTypeProvider.nameETKeyNav.getFullQualifiedNameAsString());
+    }
     return entitySet;
   }
 
@@ -115,10 +122,12 @@ public class DataCreator {
     return new EntityImpl()
         .addProperty(createPrimitive("PropertyInt16", propertyInt16))
         .addProperty(createPrimitive("PropertyString", propertyString))
-        .addProperty(createComplex("PropertyCompNav",
+        .addProperty(createComplex("PropertyCompNav", ctPropComp,
             createPrimitive("PropertyInt16", 1)))
         .addProperty(createKeyNavAllPrimComplexValue("PropertyCompAllPrim"))
-        .addProperty(createComplex("PropertyCompTwoPrim",
+        .addProperty(
+            createComplex("PropertyCompTwoPrim",
+                ComplexTypeProvider.nameCTTwoPrim.getFullQualifiedNameAsString(),
             createPrimitive("PropertyInt16", 16),
             createPrimitive("PropertyString", "Test123")))
         .addProperty(createPrimitiveCollection("CollPropertyString",
@@ -126,7 +135,9 @@ public class DataCreator {
             "Employee2@company.example",
             "Employee3@company.example"))
         .addProperty(createPrimitiveCollection("CollPropertyInt16", 1000, 2000, 30112))
-        .addProperty(createComplexCollection("CollPropertyComp",
+        .addProperty(
+            createComplexCollection("CollPropertyComp", ComplexTypeProvider.nameCTPrimComp
+                .getFullQualifiedNameAsString(),
             Arrays.asList(
                 createPrimitive("PropertyInt16", 1),
                 createKeyNavAllPrimComplexValue("PropertyComp")),
@@ -136,9 +147,11 @@ public class DataCreator {
             Arrays.asList(
                 createPrimitive("PropertyInt16", 3),
                 createKeyNavAllPrimComplexValue("PropertyComp"))))
-        .addProperty(createComplex("PropertyCompCompNav",
+        .addProperty(
+            createComplex("PropertyCompCompNav",
+                ComplexTypeProvider.nameCTCompComp.getFullQualifiedNameAsString(),
             createPrimitive("PropertyString", "1"),
-            createComplex("PropertyComp", createPrimitive("PropertyInt16", 1))));
+            createComplex("PropertyComp", ctPropComp, createPrimitive("PropertyInt16", 1))));
   }
 
   private EntitySet createESTwoKeyNav() {
@@ -148,7 +161,9 @@ public class DataCreator {
     entitySet.getEntities().add(createESTwoKeyNavEntity(1, "2"));
     entitySet.getEntities().add(createESTwoKeyNavEntity(2, "1"));
     entitySet.getEntities().add(createESTwoKeyNavEntity(3, "1"));
-
+    for (Entity en:entitySet.getEntities()) {
+      en.setType(EntityTypeProvider.nameETTwoKeyNav.getFullQualifiedNameAsString());
+    }
     return entitySet;
   }
 
@@ -157,9 +172,9 @@ public class DataCreator {
     return new EntityImpl()
         .addProperty(createPrimitive("PropertyInt16", propertyInt16))
         .addProperty(createPrimitive("PropertyString", propertyString))
-        .addProperty(createComplex("PropertyComp",
+        .addProperty(createComplex("PropertyComp",ctPropComp,
             createPrimitive("PropertyInt16", 11),
-            createComplex("PropertyComp",
+            createComplex("PropertyComp", ctPropComp,
                 createPrimitive("PropertyString", "StringValue"),
                 createPrimitive("PropertyBinary", new byte[] { 1, 35, 69, 103, -119, -85, -51, -17 }),
                 createPrimitive("PropertyBoolean", true),
@@ -175,20 +190,26 @@ public class DataCreator {
                 createPrimitive("PropertyInt64", Long.MAX_VALUE),
                 createPrimitive("PropertySByte", Byte.MAX_VALUE),
                 createPrimitive("PropertyTimeOfDay", getTime(21, 5, 59)))))
-        .addProperty(createComplex("PropertyCompNav",
+        .addProperty(
+            createComplex("PropertyCompNav",
+                ComplexTypeProvider.nameCTCompNav.getFullQualifiedNameAsString(),
             createPrimitive("PropertyInt16", 1),
             createKeyNavAllPrimComplexValue("PropertyComp")))
-        .addProperty(createComplexCollection("CollPropertyComp"))
-        .addProperty(createComplexCollection("CollPropertyCompNav",
+        .addProperty(createComplexCollection("CollPropertyComp", null))
+        .addProperty(
+            createComplexCollection("CollPropertyCompNav",
+                ComplexTypeProvider.nameCTCompNav.getFullQualifiedNameAsString(),
             Arrays.asList(createPrimitive("PropertyInt16", 1))))
         .addProperty(createPrimitiveCollection("CollPropertyString", 1, 2))
-        .addProperty(createComplex("PropertyCompTwoPrim",
+        .addProperty(
+            createComplex("PropertyCompTwoPrim",
+                ComplexTypeProvider.nameCTTwoPrim.getFullQualifiedNameAsString(),
             createPrimitive("PropertyInt16", 11),
             createPrimitive("PropertyString", "11")));
   }
 
   private Property createKeyNavAllPrimComplexValue(final String name) {
-    return createComplex(name,
+    return createComplex(name, ComplexTypeProvider.nameCTAllPrim.getFullQualifiedNameAsString(),
         createPrimitive("PropertyString", "First Resource - positive values"),
         createPrimitive("PropertyBinary", new byte[] { 1, 35, 69, 103, -119, -85, -51, -17 }),
         createPrimitive("PropertyBoolean", true),
@@ -213,8 +234,9 @@ public class DataCreator {
 
     entitySet.getEntities().add(new EntityImpl()
         .addProperty(createPrimitive("PropertyInt16", Short.MAX_VALUE))
-        .addProperty(createComplex("PropertyComp",
-            createComplexCollection("CollPropertyComp",
+        .addProperty(createComplex("PropertyComp", null,
+                    createComplexCollection("CollPropertyComp", ComplexTypeProvider.nameCTTwoPrim
+                        .getFullQualifiedNameAsString(),
                 Arrays.asList(
                     createPrimitive("PropertyInt16", 555),
                     createPrimitive("PropertyString", "1 Test Complex in Complex Property")),
@@ -227,8 +249,9 @@ public class DataCreator {
 
     entitySet.getEntities().add(new EntityImpl()
         .addProperty(createPrimitive("PropertyInt16", 12345))
-        .addProperty(createComplex("PropertyComp",
-            createComplexCollection("CollPropertyComp",
+        .addProperty(createComplex("PropertyComp",null,
+                    createComplexCollection("CollPropertyComp", ComplexTypeProvider.nameCTTwoPrim
+                        .getFullQualifiedNameAsString(),
                 Arrays.asList(
                     createPrimitive("PropertyInt16", 888),
                     createPrimitive("PropertyString", "11 Test Complex in Complex Property")),
@@ -238,7 +261,9 @@ public class DataCreator {
                 Arrays.asList(
                     createPrimitive("PropertyInt16", 0),
                     createPrimitive("PropertyString", "13 Test Complex in Complex Property"))))));
-
+    for (Entity en:entitySet.getEntities()) {
+      en.setType(EntityTypeProvider.nameETCompCollComp.getFullQualifiedNameAsString());
+    }
     return entitySet;
   }
 
@@ -260,7 +285,9 @@ public class DataCreator {
     entitySet.getEntities().add(new EntityImpl()
         .addProperty(createPrimitive("PropertyInt16", Short.MAX_VALUE))
         .addProperty(createPrimitive("PropertyString", "Test String4")));
-
+    for (Entity en:entitySet.getEntities()) {
+      en.setType(EntityTypeProvider.nameETTwoPrim.getFullQualifiedNameAsString());
+    }
     return entitySet;
   }
 
@@ -322,7 +349,9 @@ public class DataCreator {
         .addProperty(createPrimitive("PropertyDuration", 0))
         .addProperty(createPrimitive("PropertyGuid", UUID.fromString("76543201-23ab-cdef-0123-456789cccddd")))
         .addProperty(createPrimitive("PropertyTimeOfDay", getTime(0, 1, 1))));
-
+    for (Entity en:entitySet.getEntities()) {
+      en.setType(EntityTypeProvider.nameETAllPrim.getFullQualifiedNameAsString());
+    }
     return entitySet;
   }
 
@@ -331,7 +360,7 @@ public class DataCreator {
 
     Entity entity = new EntityImpl();
     entity.addProperty(createPrimitive("PropertyInt16", Short.MAX_VALUE));
-    entity.addProperty(createComplex("PropertyComp",
+    entity.addProperty(createComplex("PropertyComp",ctPropComp,
         createPrimitive("PropertyString", "First Resource - first"),
         createPrimitive("PropertyBinary",
             new byte[] { 0x01, 0x23, 0x45, 0x67, (byte) 0x89, (byte) 0xAB, (byte) 0xCD, (byte) 0xEF }),
@@ -353,7 +382,7 @@ public class DataCreator {
 
     entity = new EntityImpl();
     entity.addProperty(createPrimitive("PropertyInt16", 7));
-    entity.addProperty(createComplex("PropertyComp",
+    entity.addProperty(createComplex("PropertyComp",ctPropComp,
         createPrimitive("PropertyString", "Second Resource - second"),
         createPrimitive("PropertyBinary",
             new byte[] { 0x01, 0x23, 0x45, 0x67, (byte) 0x89, (byte) 0xAB, (byte) 0xCD, (byte) 0xEF }),
@@ -375,7 +404,7 @@ public class DataCreator {
 
     entity = new EntityImpl();
     entity.addProperty(createPrimitive("PropertyInt16", 0));
-    entity.addProperty(createComplex("PropertyComp",
+    entity.addProperty(createComplex("PropertyComp",ctPropComp,
         createPrimitive("PropertyString", "Third Resource - third"),
         createPrimitive("PropertyBinary",
             new byte[] { 0x01, 0x23, 0x45, 0x67, (byte) 0x89, (byte) 0xAB, (byte) 0xCD, (byte) 0xEF }),
@@ -394,7 +423,9 @@ public class DataCreator {
         createPrimitive("PropertySByte", Byte.MAX_VALUE),
         createPrimitive("PropertyTimeOfDay", getTime(13, 27, 45))));
     entitySet.getEntities().add(entity);
-
+    for (Entity en:entitySet.getEntities()) {
+      en.setType(EntityTypeProvider.nameETCompAllPrim.getFullQualifiedNameAsString());
+    }
     return entitySet;
   }
 
@@ -444,13 +475,15 @@ public class DataCreator {
     entity.getProperties().addAll(entitySet.getEntities().get(0).getProperties());
     entity.getProperties().set(0, createPrimitive("PropertyInt16", 3));
     entitySet.getEntities().add(entity);
-
+    for (Entity en:entitySet.getEntities()) {
+      en.setType(EntityTypeProvider.nameETCollAllPrim.getFullQualifiedNameAsString());
+    }
     return entitySet;
   }
 
   private EntitySet createESMixPrimCollComp() {
     @SuppressWarnings("unchecked")
-    final Property complexCollection = createComplexCollection("CollPropertyComp",
+    final Property complexCollection = createComplexCollection("CollPropertyComp", ctPropComp,
         Arrays.asList(createPrimitive("PropertyInt16", 123), createPrimitive("PropertyString", "TEST 1")),
         Arrays.asList(createPrimitive("PropertyInt16", 456), createPrimitive("PropertyString", "TEST 2")),
         Arrays.asList(createPrimitive("PropertyInt16", 789), createPrimitive("PropertyString", "TEST 3")));
@@ -461,7 +494,7 @@ public class DataCreator {
         .addProperty(createPrimitive("PropertyInt16", Short.MAX_VALUE))
         .addProperty(createPrimitiveCollection("CollPropertyString",
             "Employee1@company.example", "Employee2@company.example", "Employee3@company.example"))
-        .addProperty(createComplex("PropertyComp",
+        .addProperty(createComplex("PropertyComp",ctPropComp,
             createPrimitive("PropertyInt16", 111),
             createPrimitive("PropertyString", "TEST A")))
         .addProperty(complexCollection));
@@ -470,7 +503,7 @@ public class DataCreator {
         .addProperty(createPrimitive("PropertyInt16", 7))
         .addProperty(createPrimitiveCollection("CollPropertyString",
             "Employee1@company.example", "Employee2@company.example", "Employee3@company.example"))
-        .addProperty(createComplex("PropertyComp",
+        .addProperty(createComplex("PropertyComp",ctPropComp,
             createPrimitive("PropertyInt16", 222),
             createPrimitive("PropertyString", "TEST B")))
         .addProperty(complexCollection));
@@ -479,11 +512,13 @@ public class DataCreator {
         .addProperty(createPrimitive("PropertyInt16", 0))
         .addProperty(createPrimitiveCollection("CollPropertyString",
             "Employee1@company.example", "Employee2@company.example", "Employee3@company.example"))
-        .addProperty(createComplex("PropertyComp",
+        .addProperty(createComplex("PropertyComp",ctPropComp,
             createPrimitive("PropertyInt16", 333),
             createPrimitive("PropertyString", "TEST C")))
         .addProperty(complexCollection));
-
+    for (Entity en:entitySet.getEntities()) {
+      en.setType(EntityTypeProvider.nameETMixPrimCollComp.getFullQualifiedNameAsString());
+    }
     return entitySet;
   }
 
@@ -519,7 +554,9 @@ public class DataCreator {
         .addProperty(createPrimitive("PropertyDuration", 6))
         .addProperty(createPrimitive("PropertyGuid", GUID))
         .addProperty(createPrimitive("PropertyTimeOfDay", getTime(2, 48, 21))));
-
+    for (Entity en:entitySet.getEntities()) {
+      en.setType(EntityTypeProvider.nameETAllKey.getFullQualifiedNameAsString());
+    }
     return entitySet;
   }
 
@@ -528,20 +565,22 @@ public class DataCreator {
 
     Entity entity = new EntityImpl();
     entity.addProperty(createPrimitive("PropertyInt16", 1));
-    entity.addProperty(createComplex("PropertyComp",
-        createComplex("PropertyComp",
+    entity.addProperty(createComplex("PropertyComp", null,
+        createComplex("PropertyComp",ctPropComp,
             createPrimitive("PropertyInt16", 123),
             createPrimitive("PropertyString", "String 1"))));
     entitySet.getEntities().add(entity);
 
     entity = new EntityImpl();
     entity.addProperty(createPrimitive("PropertyInt16", 2));
-    entity.addProperty(createComplex("PropertyComp",
-        createComplex("PropertyComp",
+    entity.addProperty(createComplex("PropertyComp", null,
+        createComplex("PropertyComp",ctPropComp,
             createPrimitive("PropertyInt16", 987),
             createPrimitive("PropertyString", "String 2"))));
     entitySet.getEntities().add(entity);
-
+    for (Entity en:entitySet.getEntities()) {
+      en.setType(EntityTypeProvider.nameETCompComp.getFullQualifiedNameAsString());
+    }
     return entitySet;
   }
 
@@ -571,7 +610,9 @@ public class DataCreator {
         .addProperty(createPrimitive(DataProvider.MEDIA_PROPERTY_NAME, createImage("black")));
     entity.setMediaContentType("image/svg+xml");
     entitySet.getEntities().add(entity);
-
+    for (Entity en:entitySet.getEntities()) {
+      en.setType(EntityTypeProvider.nameETMedia.getFullQualifiedNameAsString());
+    }
     return entitySet;
   }
 
@@ -677,22 +718,23 @@ public class DataCreator {
     return new PropertyImpl(null, name, ValueType.COLLECTION_PRIMITIVE, Arrays.asList(values));
   }
 
-  protected static Property createComplex(final String name, final Property... properties) {
+  protected static Property createComplex(final String name, String type, final Property... properties) {
     ComplexValue complexValue = new ComplexValueImpl();
     for (final Property property : properties) {
       complexValue.getValue().add(property);
     }
-    return new PropertyImpl(null, name, ValueType.COMPLEX, complexValue);
+    return new PropertyImpl(type, name, ValueType.COMPLEX, complexValue);
   }
 
-  protected static Property createComplexCollection(final String name, final List<Property>... propertiesList) {
+  protected static Property createComplexCollection(final String name, String type,
+      final List<Property>... propertiesList) {
     List<ComplexValue> complexCollection = new ArrayList<ComplexValue>();
     for (final List<Property> properties : propertiesList) {
       ComplexValue complexValue = new ComplexValueImpl();
       complexValue.getValue().addAll(properties);
       complexCollection.add(complexValue);
     }
-    return new PropertyImpl(null, name, ValueType.COLLECTION_COMPLEX, complexCollection);
+    return new PropertyImpl(type, name, ValueType.COLLECTION_COMPLEX, complexCollection);
   }
 
   private Calendar getDateTime(final int year, final int month, final int day,

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/2b73abcc/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/DataProvider.java
----------------------------------------------------------------------
diff --git a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/DataProvider.java b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/DataProvider.java
index fed499f..4fc9300 100644
--- a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/DataProvider.java
+++ b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/DataProvider.java
@@ -6,9 +6,9 @@
  * 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
@@ -138,7 +138,7 @@ public class DataProvider {
     final List<Entity> entities = entitySet.getEntities();
     final Map<String, Object> newKey = findFreeComposedKey(entities, edmEntitySet.getEntityType());
     final Entity newEntity = new EntityImpl();
-
+    newEntity.setType(edmEntityType.getFullQualifiedName().getFullQualifiedNameAsString());
     for (final String keyName : edmEntityType.getKeyPredicateNames()) {
       newEntity.addProperty(DataCreator.createPrimitive(keyName, newKey.get(keyName)));
     }
@@ -194,7 +194,8 @@ public class DataProvider {
     return true;
   }
 
-  private void createProperties(final EdmStructuredType type, List<Property> properties) throws DataProviderException {
+  private void createProperties(final EdmStructuredType type, List<Property> properties)
+      throws DataProviderException {
     final List<String> keyNames = type instanceof EdmEntityType ?
         ((EdmEntityType) type).getKeyPredicateNames() : Collections.<String> emptyList();
     for (final String propertyName : type.getPropertyNames()) {
@@ -204,11 +205,11 @@ public class DataProvider {
       }
     }
   }
-  
-  private Property createProperty(final EdmProperty edmProperty, final String propertyName) 
+
+  private Property createProperty(final EdmProperty edmProperty, final String propertyName)
       throws DataProviderException {
     Property newProperty;
-    
+
     if (edmProperty.isPrimitive()) {
       newProperty = edmProperty.isCollection() ?
           DataCreator.createPrimitiveCollection(propertyName) :
@@ -216,17 +217,19 @@ public class DataProvider {
     } else {
       if (edmProperty.isCollection()) {
         @SuppressWarnings("unchecked")
-        Property newProperty2 = DataCreator.createComplexCollection(propertyName);
+        Property newProperty2 = DataCreator.createComplexCollection(propertyName, edmProperty
+            .getType().getFullQualifiedName().getFullQualifiedNameAsString());
         newProperty = newProperty2;
       } else {
-        newProperty = DataCreator.createComplex(propertyName);
+        newProperty = DataCreator.createComplex(propertyName, edmProperty.getType()
+            .getFullQualifiedName().getFullQualifiedNameAsString());
         createProperties((EdmComplexType) edmProperty.getType(), newProperty.asComplex().getValue());
       }
     }
-    
+
     return newProperty;
   }
-  
+
   public void update(final String rawBaseUri, final EdmEntitySet edmEntitySet, Entity entity,
       final Entity changedEntity, final boolean patch, final boolean isInsert) throws DataProviderException {
 
@@ -433,7 +436,7 @@ public class DataProvider {
     }
   }
 
-  private ComplexValue createComplexValue(final EdmProperty edmProperty, final ComplexValue complexValue, 
+  private ComplexValue createComplexValue(final EdmProperty edmProperty, final ComplexValue complexValue,
       final boolean patch) throws DataProviderException {
     final ComplexValueImpl result = new ComplexValueImpl();
     final EdmComplexType edmType =  (EdmComplexType) edmProperty.getType();
@@ -445,7 +448,7 @@ public class DataProvider {
       final Property currentProperty = findProperty(propertyName, givenProperties);
       final Property newProperty = createProperty(innerEdmProperty, propertyName);
       result.getValue().add(newProperty);
-      
+
       if (currentProperty != null) {
         updateProperty(innerEdmProperty, newProperty, currentProperty, patch);
       } else {
@@ -459,7 +462,7 @@ public class DataProvider {
         }
       }
     }
-    
+
     return result;
   }
 

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/2b73abcc/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/FunctionData.java
----------------------------------------------------------------------
diff --git a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/FunctionData.java b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/FunctionData.java
index 5451d5d..316a7b0 100644
--- a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/FunctionData.java
+++ b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/data/FunctionData.java
@@ -31,6 +31,7 @@ import org.apache.olingo.commons.core.data.EntitySetImpl;
 import org.apache.olingo.commons.core.edm.primitivetype.EdmPrimitiveTypeFactory;
 import org.apache.olingo.server.api.uri.UriParameter;
 import org.apache.olingo.server.tecsvc.data.DataProvider.DataProviderException;
+import org.apache.olingo.server.tecsvc.provider.ComplexTypeProvider;
 
 public class FunctionData {
 
@@ -80,12 +81,12 @@ public class FunctionData {
     } else if (name.equals("UFCRTCollString")) {
       return data.get("ESCollAllPrim").getEntities().get(0).getProperty("CollPropertyString");
     } else if (name.equals("UFCRTCTTwoPrim")) {
-      return DataCreator.createComplex(name,
+      return DataCreator.createComplex(name, ComplexTypeProvider.nameCTTwoPrim.getFullQualifiedNameAsString(),
           DataCreator.createPrimitive("PropertyInt16", 16),
           DataCreator.createPrimitive("PropertyString", "UFCRTCTTwoPrim string value"));
     } else if (name.equals("UFCRTCTTwoPrimParam")) {
       try {
-        return DataCreator.createComplex(name,
+        return DataCreator.createComplex(name,ComplexTypeProvider.nameCTTwoPrim.getFullQualifiedNameAsString(),
             DataCreator.createPrimitive("PropertyInt16",
                 EdmPrimitiveTypeFactory.getInstance(EdmPrimitiveTypeKind.Int16).valueOfString(
                     getParameterText("ParameterInt16", parameters),
@@ -99,7 +100,7 @@ public class FunctionData {
         throw new DataProviderException("Error in function " + name + ".", e);
       }
     } else if (name.equals("UFCRTCollCTTwoPrim")) {
-      return DataCreator.createComplexCollection(name,
+      return DataCreator.createComplexCollection(name,ComplexTypeProvider.nameCTTwoPrim.getFullQualifiedNameAsString(),
           Arrays.asList(DataCreator.createPrimitive("PropertyInt16", 16),
               DataCreator.createPrimitive("PropertyString", "Test123")),
           Arrays.asList(DataCreator.createPrimitive("PropertyInt16", 17),

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/2b73abcc/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalEntityProcessor.java
----------------------------------------------------------------------
diff --git a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalEntityProcessor.java b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalEntityProcessor.java
index f610fc2b..841eabe 100644
--- a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalEntityProcessor.java
+++ b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalEntityProcessor.java
@@ -6,9 +6,9 @@
  * 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
@@ -38,6 +38,7 @@ import org.apache.olingo.commons.core.data.EntitySetImpl;
 import org.apache.olingo.server.api.ODataApplicationException;
 import org.apache.olingo.server.api.ODataRequest;
 import org.apache.olingo.server.api.ODataResponse;
+import org.apache.olingo.server.api.ServiceMetadata;
 import org.apache.olingo.server.api.deserializer.DeserializerException;
 import org.apache.olingo.server.api.deserializer.ODataDeserializer;
 import org.apache.olingo.server.api.processor.ActionEntityCollectionProcessor;
@@ -74,8 +75,11 @@ public class TechnicalEntityProcessor extends TechnicalProcessor
     EntityProcessor, ActionEntityProcessor, MediaEntityProcessor,
     ActionVoidProcessor {
 
-  public TechnicalEntityProcessor(final DataProvider dataProvider) {
+  private final ServiceMetadata serviceMetadata;
+
+  public TechnicalEntityProcessor(final DataProvider dataProvider, ServiceMetadata serviceMetadata) {
     super(dataProvider);
+    this.serviceMetadata = serviceMetadata;
   }
 
   @Override
@@ -109,21 +113,24 @@ public class TechnicalEntityProcessor extends TechnicalProcessor
           entitySet,
           edmEntitySet,
           request.getRawRequestUri());
-      
+
       // Apply expand system query option
       final ODataFormat format = ODataFormat.fromContentType(requestedContentType);
       ODataSerializer serializer = odata.createSerializer(format);
       final ExpandOption expand = uriInfo.getExpandOption();
       final SelectOption select = uriInfo.getSelectOption();
-      
+
       // Create a shallow copy of each entity. So the expanded navigation properties can be modified for serialization,
       // without affecting the data stored in the database.
       final ExpandSystemQueryOptionHandler expandHandler = new ExpandSystemQueryOptionHandler();
       final EntitySet entitySetSerialization = expandHandler.copyEntitySetShallowRekursive(entitySet);
       expandHandler.applyExpandQueryOptions(entitySetSerialization, edmEntitySet, expand);
-      
+
       // Serialize
-      response.setContent(serializer.entityCollection(edmEntityType, entitySetSerialization,
+      response.setContent(serializer.entityCollection(
+          this.serviceMetadata,
+          edmEntityType,
+          entitySetSerialization,
           EntityCollectionSerializerOptions.with()
               .contextURL(format == ODataFormat.JSON_NO_METADATA ? null :
                   getContextUrl(edmEntitySet, edmEntityType, false, expand, select))
@@ -170,17 +177,20 @@ public class TechnicalEntityProcessor extends TechnicalProcessor
         edmEntitySet.getEntityType();
 
     final Entity entity = readEntity(uriInfo);
-    
+
     final ODataFormat format = ODataFormat.fromContentType(requestedContentType);
     ODataSerializer serializer = odata.createSerializer(format);
     final ExpandOption expand = uriInfo.getExpandOption();
     final SelectOption select = uriInfo.getSelectOption();
-    
+
     final ExpandSystemQueryOptionHandler expandHandler = new ExpandSystemQueryOptionHandler();
     final Entity entitySerialization = expandHandler.copyEntityShallowRekursive(entity);
     expandHandler.applyExpandQueryOptions(entitySerialization, edmEntitySet, expand);
-    
-    response.setContent(serializer.entity(edmEntitySet.getEntityType(), entitySerialization,
+
+    response.setContent(serializer.entity(
+        this.serviceMetadata,
+        edmEntitySet.getEntityType(),
+        entitySerialization,
         EntitySerializerOptions.with()
             .contextURL(format == ODataFormat.JSON_NO_METADATA ? null :
                 getContextUrl(edmEntitySet, edmEntityType, true, expand, select))
@@ -233,7 +243,7 @@ public class TechnicalEntityProcessor extends TechnicalProcessor
 
     final ODataFormat format = ODataFormat.fromContentType(responseFormat);
     ODataSerializer serializer = odata.createSerializer(format);
-    response.setContent(serializer.entity(edmEntityType, entity,
+    response.setContent(serializer.entity(this.serviceMetadata, edmEntityType, entity,
         EntitySerializerOptions.with()
             .contextURL(format == ODataFormat.JSON_NO_METADATA ? null :
                 getContextUrl(edmEntitySet, edmEntityType, true, null, null))

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/2b73abcc/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalPrimitiveComplexProcessor.java
----------------------------------------------------------------------
diff --git a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalPrimitiveComplexProcessor.java b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalPrimitiveComplexProcessor.java
index e36dc6b..b853e48 100644
--- a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalPrimitiveComplexProcessor.java
+++ b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalPrimitiveComplexProcessor.java
@@ -6,9 +6,9 @@
  * 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
@@ -44,6 +44,7 @@ import org.apache.olingo.commons.core.edm.primitivetype.EdmPrimitiveTypeFactory;
 import org.apache.olingo.server.api.ODataApplicationException;
 import org.apache.olingo.server.api.ODataRequest;
 import org.apache.olingo.server.api.ODataResponse;
+import org.apache.olingo.server.api.ServiceMetadata;
 import org.apache.olingo.server.api.deserializer.DeserializerException;
 import org.apache.olingo.server.api.processor.ActionComplexCollectionProcessor;
 import org.apache.olingo.server.api.processor.ActionComplexProcessor;
@@ -81,8 +82,12 @@ public class TechnicalPrimitiveComplexProcessor extends TechnicalProcessor
     ComplexProcessor, ActionComplexProcessor,
     ComplexCollectionProcessor, ActionComplexCollectionProcessor {
 
-  public TechnicalPrimitiveComplexProcessor(final DataProvider dataProvider) {
+  private final ServiceMetadata serviceMetadata;
+
+  public TechnicalPrimitiveComplexProcessor(final DataProvider dataProvider,
+      ServiceMetadata serviceMetadata) {
     super(dataProvider);
+    this.serviceMetadata = serviceMetadata;
   }
 
   @Override
@@ -246,7 +251,7 @@ public class TechnicalPrimitiveComplexProcessor extends TechnicalProcessor
                   .build()));
           break;
         case COMPLEX:
-          response.setContent(serializer.complex((EdmComplexType) type, property,
+          response.setContent(serializer.complex(this.serviceMetadata,(EdmComplexType) type, property,
               ComplexSerializerOptions.with().contextURL(contextURL)
                   .expand(expand).select(select)
                   .build()));
@@ -262,7 +267,7 @@ public class TechnicalPrimitiveComplexProcessor extends TechnicalProcessor
                   .build()));
           break;
         case COLLECTION_COMPLEX:
-          response.setContent(serializer.complexCollection((EdmComplexType) type, property,
+          response.setContent(serializer.complexCollection(this.serviceMetadata, (EdmComplexType) type, property,
               ComplexSerializerOptions.with().contextURL(contextURL)
                   .expand(expand).select(select)
                   .build()));

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/2b73abcc/lib/server-tecsvc/src/test/java/org/apache/olingo/server/tecsvc/data/DataProviderTest.java
----------------------------------------------------------------------
diff --git a/lib/server-tecsvc/src/test/java/org/apache/olingo/server/tecsvc/data/DataProviderTest.java b/lib/server-tecsvc/src/test/java/org/apache/olingo/server/tecsvc/data/DataProviderTest.java
index 76edb33..4549a03 100644
--- a/lib/server-tecsvc/src/test/java/org/apache/olingo/server/tecsvc/data/DataProviderTest.java
+++ b/lib/server-tecsvc/src/test/java/org/apache/olingo/server/tecsvc/data/DataProviderTest.java
@@ -22,9 +22,9 @@ import java.util.Arrays;
 import java.util.Collections;
 import java.util.List;
 
+import org.apache.olingo.commons.api.data.ComplexValue;
 import org.apache.olingo.commons.api.data.Entity;
 import org.apache.olingo.commons.api.data.EntitySet;
-import org.apache.olingo.commons.api.data.ComplexValue;
 import org.apache.olingo.commons.api.data.Property;
 import org.apache.olingo.commons.api.edm.Edm;
 import org.apache.olingo.commons.api.edm.EdmEntityContainer;

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/2b73abcc/lib/server-test/src/test/java/org/apache/olingo/server/core/deserializer/json/ODataJsonDeserializerEntityTest.java
----------------------------------------------------------------------
diff --git a/lib/server-test/src/test/java/org/apache/olingo/server/core/deserializer/json/ODataJsonDeserializerEntityTest.java b/lib/server-test/src/test/java/org/apache/olingo/server/core/deserializer/json/ODataJsonDeserializerEntityTest.java
index cd421f4..870f7c3 100644
--- a/lib/server-test/src/test/java/org/apache/olingo/server/core/deserializer/json/ODataJsonDeserializerEntityTest.java
+++ b/lib/server-test/src/test/java/org/apache/olingo/server/core/deserializer/json/ODataJsonDeserializerEntityTest.java
@@ -6,9 +6,9 @@
  * 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

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/2b73abcc/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/json/ODataJsonSerializerTest.java
----------------------------------------------------------------------
diff --git a/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/json/ODataJsonSerializerTest.java b/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/json/ODataJsonSerializerTest.java
index 038c668..ee38684 100644
--- a/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/json/ODataJsonSerializerTest.java
+++ b/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/json/ODataJsonSerializerTest.java
@@ -41,11 +41,12 @@ import org.apache.olingo.commons.api.edm.FullQualifiedName;
 import org.apache.olingo.commons.api.format.ODataFormat;
 import org.apache.olingo.commons.core.data.PropertyImpl;
 import org.apache.olingo.server.api.OData;
+import org.apache.olingo.server.api.ServiceMetadata;
 import org.apache.olingo.server.api.edmx.EdmxReference;
 import org.apache.olingo.server.api.serializer.ComplexSerializerOptions;
 import org.apache.olingo.server.api.serializer.EntityCollectionSerializerOptions;
-import org.apache.olingo.server.api.serializer.ODataSerializer;
 import org.apache.olingo.server.api.serializer.EntitySerializerOptions;
+import org.apache.olingo.server.api.serializer.ODataSerializer;
 import org.apache.olingo.server.api.serializer.PrimitiveSerializerOptions;
 import org.apache.olingo.server.api.serializer.SerializerException;
 import org.apache.olingo.server.api.uri.UriHelper;
@@ -64,9 +65,9 @@ import org.junit.Test;
 import org.mockito.Mockito;
 
 public class ODataJsonSerializerTest {
-
-  private static final Edm edm = OData.newInstance().createServiceMetadata(
-      new EdmTechProvider(), Collections.<EdmxReference> emptyList()).getEdm();
+  private static final ServiceMetadata metadata = OData.newInstance().createServiceMetadata(
+      new EdmTechProvider(), Collections.<EdmxReference> emptyList());
+  private static final Edm edm = metadata.getEdm();
   private static final EdmEntityContainer entityContainer = edm.getEntityContainer(
       new FullQualifiedName("olingo.odata.test1", "Container"));
   private final DataProvider data = new DataProvider();
@@ -77,7 +78,7 @@ public class ODataJsonSerializerTest {
   public void entitySimple() throws Exception {
     final EdmEntitySet edmEntitySet = entityContainer.getEntitySet("ESAllPrim");
     final Entity entity = data.readAll(edmEntitySet).getEntities().get(0);
-    InputStream result = serializer.entity(edmEntitySet.getEntityType(), entity,
+    InputStream result = serializer.entity(metadata, edmEntitySet.getEntityType(), entity,
         EntitySerializerOptions.with()
             .contextURL(ContextURL.with().entitySet(edmEntitySet).suffix(Suffix.ENTITY).build())
             .build());
@@ -109,7 +110,8 @@ public class ODataJsonSerializerTest {
     final EdmEntitySet edmEntitySet = entityContainer.getEntitySet("ESAllPrim");
     Entity entity = data.readAll(edmEntitySet).getEntities().get(0);
     entity.getProperties().retainAll(Arrays.asList(entity.getProperties().get(0)));
-    final String resultString = IOUtils.toString(serializer.entity(edmEntitySet.getEntityType(), entity,
+    final String resultString = IOUtils.toString(serializer.entity(metadata, edmEntitySet.getEntityType(),
+        entity,
         EntitySerializerOptions.with()
             .contextURL(ContextURL.with().entitySet(edmEntitySet).suffix(Suffix.ENTITY).build())
             .build()));
@@ -130,7 +132,7 @@ public class ODataJsonSerializerTest {
     final EdmEntitySet edmEntitySet = entityContainer.getEntitySet("ESAllPrim");
     Entity entity = data.readAll(edmEntitySet).getEntities().get(0);
     entity.getProperties().clear();
-    serializer.entity(edmEntitySet.getEntityType(), entity,
+    serializer.entity(metadata, edmEntitySet.getEntityType(), entity,
         EntitySerializerOptions.with()
             .contextURL(ContextURL.with().entitySet(edmEntitySet).suffix(Suffix.ENTITY).build())
             .build());
@@ -142,7 +144,7 @@ public class ODataJsonSerializerTest {
     Entity entity = data.readAll(edmEntitySet).getEntities().get(0);
     entity.getProperties().get(0).setValue(ValueType.PRIMITIVE, false);
     try {
-      serializer.entity(edmEntitySet.getEntityType(), entity,
+      serializer.entity(metadata, edmEntitySet.getEntityType(), entity,
           EntitySerializerOptions.with()
               .contextURL(ContextURL.with().entitySet(edmEntitySet).suffix(Suffix.ENTITY).build())
               .build());
@@ -163,7 +165,7 @@ public class ODataJsonSerializerTest {
     entitySet.setNext(URI.create("/next"));
     CountOption countOption = Mockito.mock(CountOption.class);
     Mockito.when(countOption.getValue()).thenReturn(true);
-    InputStream result = serializer.entityCollection(edmEntitySet.getEntityType(), entitySet,
+    InputStream result = serializer.entityCollection(metadata, edmEntitySet.getEntityType(), entitySet,
         EntityCollectionSerializerOptions.with()
             .contextURL(ContextURL.with().entitySet(edmEntitySet).build())
             .count(countOption)
@@ -188,7 +190,7 @@ public class ODataJsonSerializerTest {
   public void entityCollAllPrim() throws Exception {
     final EdmEntitySet edmEntitySet = entityContainer.getEntitySet("ESCollAllPrim");
     final Entity entity = data.readAll(edmEntitySet).getEntities().get(0);
-    InputStream result = serializer.entity(edmEntitySet.getEntityType(), entity,
+    InputStream result = serializer.entity(metadata, edmEntitySet.getEntityType(), entity,
         EntitySerializerOptions.with()
             .contextURL(ContextURL.with().serviceRoot(URI.create("http://host/service/"))
                 .entitySet(edmEntitySet).suffix(Suffix.ENTITY).build())
@@ -224,7 +226,7 @@ public class ODataJsonSerializerTest {
   public void entityCompAllPrim() throws Exception {
     final EdmEntitySet edmEntitySet = entityContainer.getEntitySet("ESCompAllPrim");
     final Entity entity = data.readAll(edmEntitySet).getEntities().get(0);
-    InputStream result = serializer.entity(edmEntitySet.getEntityType(), entity,
+    InputStream result = serializer.entity(metadata, edmEntitySet.getEntityType(), entity,
         EntitySerializerOptions.with()
             .contextURL(ContextURL.with().entitySet(edmEntitySet).suffix(Suffix.ENTITY).build())
             .build());
@@ -257,7 +259,7 @@ public class ODataJsonSerializerTest {
   public void entityMixPrimCollComp() throws Exception {
     final EdmEntitySet edmEntitySet = entityContainer.getEntitySet("ESMixPrimCollComp");
     final Entity entity = data.readAll(edmEntitySet).getEntities().get(0);
-    InputStream result = serializer.entity(edmEntitySet.getEntityType(), entity,
+    InputStream result = serializer.entity(metadata, edmEntitySet.getEntityType(), entity,
         EntitySerializerOptions.with()
             .contextURL(ContextURL.with().entitySet(edmEntitySet).suffix(Suffix.ENTITY).build())
             .build());
@@ -280,7 +282,7 @@ public class ODataJsonSerializerTest {
     final EdmEntitySet edmEntitySet = entityContainer.getEntitySet("ESMixPrimCollComp");
     Entity entity = data.readAll(edmEntitySet).getEntities().get(0);
     entity.getProperties().retainAll(Arrays.asList(entity.getProperties().get(0)));
-    final String resultString = IOUtils.toString(serializer.entity(edmEntitySet.getEntityType(), entity,
+    final String resultString = IOUtils.toString(serializer.entity(metadata, edmEntitySet.getEntityType(), entity,
         EntitySerializerOptions.with()
             .contextURL(ContextURL.with().entitySet(edmEntitySet).suffix(Suffix.ENTITY).build())
             .build()));
@@ -295,7 +297,7 @@ public class ODataJsonSerializerTest {
     final EdmEntitySet edmEntitySet = entityContainer.getEntitySet("ESTwoPrim");
     final Entity entity = data.readAll(edmEntitySet).getEntities().get(0);
     InputStream result = new ODataJsonSerializer(ODataFormat.JSON_NO_METADATA)
-        .entity(edmEntitySet.getEntityType(), entity, null);
+        .entity(metadata, edmEntitySet.getEntityType(), entity, null);
     final String resultString = IOUtils.toString(result);
     final String expectedResult = "{\"PropertyInt16\":32766,\"PropertyString\":\"Test String1\"}";
     Assert.assertEquals(expectedResult, resultString);
@@ -306,7 +308,7 @@ public class ODataJsonSerializerTest {
     final EdmEntitySet edmEntitySet = entityContainer.getEntitySet("ESTwoPrim");
     final EntitySet entitySet = data.readAll(edmEntitySet);
     InputStream result = new ODataJsonSerializer(ODataFormat.JSON_NO_METADATA)
-        .entityCollection(edmEntitySet.getEntityType(), entitySet,
+        .entityCollection(metadata, edmEntitySet.getEntityType(), entitySet,
             EntityCollectionSerializerOptions.with()
                 .contextURL(ContextURL.with().entitySet(edmEntitySet).build()).build());
     final String resultString = IOUtils.toString(result);
@@ -323,7 +325,8 @@ public class ODataJsonSerializerTest {
     final EdmEntitySet edmEntitySet = entityContainer.getEntitySet("ESMedia");
     Entity entity = data.readAll(edmEntitySet).getEntities().get(0);
     entity.setMediaETag("theMediaETag");
-    final String resultString = IOUtils.toString(serializer.entity(edmEntitySet.getEntityType(), entity,
+    final String resultString = IOUtils.toString(serializer.entity(metadata, edmEntitySet.getEntityType(),
+        entity,
         EntitySerializerOptions.with()
             .contextURL(ContextURL.with().entitySet(edmEntitySet).suffix(Suffix.ENTITY).build())
             .build()));
@@ -337,7 +340,8 @@ public class ODataJsonSerializerTest {
   public void entitySetMedia() throws Exception {
     final EdmEntitySet edmEntitySet = entityContainer.getEntitySet("ESMedia");
     final EntitySet entitySet = data.readAll(edmEntitySet);
-    final String resultString = IOUtils.toString(serializer.entityCollection(edmEntitySet.getEntityType(), entitySet,
+    final String resultString = IOUtils.toString(serializer.entityCollection(metadata,
+        edmEntitySet.getEntityType(), entitySet,
         EntityCollectionSerializerOptions.with()
             .contextURL(ContextURL.with().entitySet(edmEntitySet).build()).build()));
     final String expectedResult = "{\"@odata.context\":\"$metadata#ESMedia\",\"value\":["
@@ -358,7 +362,7 @@ public class ODataJsonSerializerTest {
     final SelectOption select = ExpandSelectMock.mockSelectOption(Arrays.asList(
         selectItem1, selectItem2, selectItem2));
     InputStream result = serializer
-        .entity(entityType, entity,
+        .entity(metadata, entityType, entity,
             EntitySerializerOptions.with()
                 .contextURL(ContextURL.with().entitySet(edmEntitySet)
                     .selectList(helper.buildContextURLSelectList(entityType, null, select))
@@ -380,7 +384,7 @@ public class ODataJsonSerializerTest {
     SelectItem selectItem2 = Mockito.mock(SelectItem.class);
     Mockito.when(selectItem2.isStar()).thenReturn(true);
     final SelectOption select = ExpandSelectMock.mockSelectOption(Arrays.asList(selectItem1, selectItem2));
-    InputStream result = serializer.entity(edmEntitySet.getEntityType(), entity,
+    InputStream result = serializer.entity(metadata, edmEntitySet.getEntityType(), entity,
         EntitySerializerOptions.with()
             .contextURL(ContextURL.with().entitySet(edmEntitySet).suffix(Suffix.ENTITY).build())
             .select(select)
@@ -399,7 +403,7 @@ public class ODataJsonSerializerTest {
     final SelectOption select = ExpandSelectMock.mockSelectOption(Arrays.asList(
         ExpandSelectMock.mockSelectItem(edmEntitySet, "PropertyComp", "PropertyComp", "PropertyString")));
     InputStream result = serializer
-        .entityCollection(entityType, entitySet,
+        .entityCollection(metadata, entityType, entitySet,
             EntityCollectionSerializerOptions.with()
                 .contextURL(ContextURL.with().entitySet(edmEntitySet)
                     .selectList(helper.buildContextURLSelectList(entityType, null, select))
@@ -424,7 +428,7 @@ public class ODataJsonSerializerTest {
         ExpandSelectMock.mockSelectItem(edmEntitySet, "PropertyComp", "PropertyComp", "PropertyString"),
         ExpandSelectMock.mockSelectItem(edmEntitySet, "PropertyComp", "PropertyComp")));
     final String resultString = IOUtils.toString(serializer
-        .entityCollection(entityType, entitySet,
+        .entityCollection(metadata, entityType, entitySet,
             EntityCollectionSerializerOptions.with()
                 .contextURL(ContextURL.with().entitySet(edmEntitySet)
                     .selectList(helper.buildContextURLSelectList(entityType, null, select))
@@ -445,7 +449,7 @@ public class ODataJsonSerializerTest {
     final Entity entity = data.readAll(edmEntitySet).getEntities().get(3);
     final ExpandOption expand = ExpandSelectMock.mockExpandOption(Arrays.asList(
         ExpandSelectMock.mockExpandItem(edmEntitySet, "NavPropertyETAllPrimOne")));
-    InputStream result = serializer.entity(edmEntitySet.getEntityType(), entity,
+    InputStream result = serializer.entity(metadata, edmEntitySet.getEntityType(), entity,
         EntitySerializerOptions.with()
             .contextURL(ContextURL.with().entitySet(edmEntitySet).suffix(Suffix.ENTITY).build())
             .expand(expand)
@@ -484,7 +488,7 @@ public class ODataJsonSerializerTest {
     Mockito.when(expandItem.getSelectOption()).thenReturn(select);
     final ExpandOption expand = ExpandSelectMock.mockExpandOption(Arrays.asList(expandItem));
     final String resultString = IOUtils.toString(serializer
-        .entity(entityType, entity,
+        .entity(metadata, entityType, entity,
             EntitySerializerOptions.with()
                 .contextURL(ContextURL.with().entitySet(edmEntitySet)
                     .selectList(helper.buildContextURLSelectList(entityType, expand, select))
@@ -511,7 +515,7 @@ public class ODataJsonSerializerTest {
     final SelectOption select = ExpandSelectMock.mockSelectOption(Arrays.asList(
         ExpandSelectMock.mockSelectItem(edmEntitySet, "PropertySByte")));
     final String resultString = IOUtils.toString(serializer
-        .entity(entityType, entity,
+        .entity(metadata, entityType, entity,
             EntitySerializerOptions.with()
                 .contextURL(ContextURL.with().entitySet(edmEntitySet)
                     .selectList(helper.buildContextURLSelectList(entityType, expand, select))
@@ -538,7 +542,7 @@ public class ODataJsonSerializerTest {
     final SelectOption select = ExpandSelectMock.mockSelectOption(Arrays.asList(
         ExpandSelectMock.mockSelectItem(edmEntitySet, "PropertyTimeOfDay")));
     final String resultString = IOUtils.toString(serializer
-        .entity(entityType, entity,
+        .entity(metadata, entityType, entity,
             EntitySerializerOptions.with()
                 .contextURL(ContextURL.with().entitySet(edmEntitySet)
                     .selectList(helper.buildContextURLSelectList(entityType, expand, select))
@@ -569,7 +573,7 @@ public class ODataJsonSerializerTest {
     Mockito.when(expandItemFirst.getSelectOption()).thenReturn(select);
     final ExpandOption expand = ExpandSelectMock.mockExpandOption(Arrays.asList(expandItemFirst));
     final String resultString = IOUtils.toString(serializer
-        .entity(entityType, entity,
+        .entity(metadata, entityType, entity,
             EntitySerializerOptions.with()
                 .contextURL(ContextURL.with().entitySet(edmEntitySet)
                     .selectList(helper.buildContextURLSelectList(entityType, expand, select))
@@ -646,7 +650,7 @@ public class ODataJsonSerializerTest {
     final Property property = data.readAll(edmEntitySet).getEntities().get(0).getProperty("PropertyComp");
 
     final String resultString = IOUtils.toString(serializer
-        .complex((EdmComplexType) edmProperty.getType(), property,
+        .complex(metadata, (EdmComplexType) edmProperty.getType(), property,
             ComplexSerializerOptions.with()
                 .contextURL(ContextURL.with()
                     .entitySet(edmEntitySet).keyPath("32767").navOrPropertyPath(edmProperty.getName())
@@ -665,7 +669,7 @@ public class ODataJsonSerializerTest {
     final Property property = data.readAll(edmEntitySet).getEntities().get(0).getProperty(edmProperty.getName());
 
     final String resultString = IOUtils.toString(serializer
-        .complexCollection((EdmComplexType) edmProperty.getType(), property,
+        .complexCollection(metadata, (EdmComplexType) edmProperty.getType(), property,
             ComplexSerializerOptions.with()
                 .contextURL(ContextURL.with()
                     .entitySet(edmEntitySet).keyPath("32767").navOrPropertyPath(edmProperty.getName())

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/2b73abcc/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/antlr/TestUriParserImpl.java
----------------------------------------------------------------------
diff --git a/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/antlr/TestUriParserImpl.java b/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/antlr/TestUriParserImpl.java
index 798c5c0..86cbf0e 100644
--- a/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/antlr/TestUriParserImpl.java
+++ b/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/antlr/TestUriParserImpl.java
@@ -6,9 +6,9 @@
  * 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
@@ -1064,13 +1064,16 @@ public class TestUriParserImpl {
   public void testAlias() throws Exception {
     testUri.run("ESAllPrim", "$filter=PropertyInt16 eq @p1&@p1=1)")
         .goFilter().is("<<PropertyInt16> eq <@p1>>");
-  }  
-  
+  }
+
   @Test
   public void testLambda() throws Exception {
     testUri.run("ESTwoKeyNav", "$filter=CollPropertyComp/all( l : true )")
         .goFilter().is("<CollPropertyComp/<ALL;<true>>>");
 
+    testUri.run("ESTwoKeyNav", "$filter=CollPropertyComp/all( x : x/PropertyInt16 eq 2)")
+    .goFilter().is("<CollPropertyComp/<ALL;<<x/PropertyInt16> eq <2>>>>");
+
     testUri.run("ESTwoKeyNav", "$filter=CollPropertyComp/any( l : true )")
         .goFilter().is("<CollPropertyComp/<ANY;<true>>>");
     testUri.run("ESTwoKeyNav", "$filter=CollPropertyComp/any( )")

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/2b73abcc/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/validator/UriValidatorTest.java
----------------------------------------------------------------------
diff --git a/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/validator/UriValidatorTest.java b/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/validator/UriValidatorTest.java
index 1835bef..db3930e 100644
--- a/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/validator/UriValidatorTest.java
+++ b/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/validator/UriValidatorTest.java
@@ -6,9 +6,9 @@
  * 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
@@ -18,6 +18,9 @@
  */
 package org.apache.olingo.server.core.uri.validator;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
 import org.apache.olingo.commons.api.edm.Edm;
 import org.apache.olingo.commons.api.http.HttpMethod;
 import org.apache.olingo.commons.core.edm.provider.EdmProviderImpl;
@@ -31,9 +34,6 @@ import org.apache.olingo.server.tecsvc.provider.ContainerProvider;
 import org.apache.olingo.server.tecsvc.provider.EdmTechProvider;
 import org.junit.Test;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
-
 public class UriValidatorTest {
 
   private static final String URI_ALL = "$all";
@@ -77,7 +77,7 @@ public class UriValidatorTest {
   private static final String QO_SKIPTOKEN = "$skiptoken=123";
   private static final String QO_TOP = "$top=1";
 
-  private String[][] urisWithValidSystemQueryOptions = {
+  private final String[][] urisWithValidSystemQueryOptions = {
       { URI_ALL, QO_FILTER }, { URI_ALL, QO_FORMAT }, { URI_ALL, QO_EXPAND }, { URI_ALL, QO_COUNT },
       { URI_ALL, QO_ORDERBY }, /* { URI_ALL, QO_SEARCH }, */{ URI_ALL, QO_SELECT }, { URI_ALL, QO_SKIP },
       { URI_ALL, QO_SKIPTOKEN }, { URI_ALL, QO_TOP },
@@ -105,7 +105,7 @@ public class UriValidatorTest {
 
       { URI_REFERENCES, QO_FILTER }, { URI_REFERENCES, QO_FORMAT }, { URI_REFERENCES, QO_ORDERBY },
       /* { URI_REFERENCES, QO_SEARCH }, */{ URI_REFERENCES, QO_SKIP }, { URI_REFERENCES, QO_SKIPTOKEN },
-      { URI_REFERENCES, QO_TOP },
+      { URI_REFERENCES, QO_TOP }, { URI_REFERENCES, QO_ID },
 
       { URI_REFERENCE, QO_FORMAT },
 
@@ -160,7 +160,7 @@ public class UriValidatorTest {
       { ContainerProvider.AIRT_STRING }
   };
 
-  private String[][] urisWithNonValidSystemQueryOptions = {
+  private final String[][] urisWithNonValidSystemQueryOptions = {
       { URI_ALL, QO_ID },
 
       { URI_BATCH, QO_FILTER }, { URI_BATCH, QO_FORMAT }, { URI_BATCH, QO_ID }, { URI_BATCH, QO_EXPAND },
@@ -199,7 +199,7 @@ public class UriValidatorTest {
       /* { URI_MEDIA_STREAM, QO_SEARCH }, */ { URI_MEDIA_STREAM, QO_SELECT }, { URI_MEDIA_STREAM, QO_SKIP },
       { URI_MEDIA_STREAM, QO_SKIPTOKEN }, { URI_MEDIA_STREAM, QO_TOP },
 
-      { URI_REFERENCES, QO_ID }, { URI_REFERENCES, QO_EXPAND }, { URI_REFERENCES, QO_COUNT },
+      { URI_REFERENCES, QO_EXPAND }, { URI_REFERENCES, QO_COUNT },
       { URI_REFERENCES, QO_SELECT },
 
       { URI_REFERENCE, QO_FILTER }, { URI_REFERENCE, QO_ID }, { URI_REFERENCE, QO_EXPAND },

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/2b73abcc/samples/server/src/main/java/org/apache/olingo/server/sample/data/DataProvider.java
----------------------------------------------------------------------
diff --git a/samples/server/src/main/java/org/apache/olingo/server/sample/data/DataProvider.java b/samples/server/src/main/java/org/apache/olingo/server/sample/data/DataProvider.java
index d59d251..2e44e35 100644
--- a/samples/server/src/main/java/org/apache/olingo/server/sample/data/DataProvider.java
+++ b/samples/server/src/main/java/org/apache/olingo/server/sample/data/DataProvider.java
@@ -6,9 +6,9 @@
  * 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
@@ -37,10 +37,11 @@ import org.apache.olingo.commons.core.data.EntityImpl;
 import org.apache.olingo.commons.core.data.EntitySetImpl;
 import org.apache.olingo.commons.core.data.PropertyImpl;
 import org.apache.olingo.server.api.uri.UriParameter;
+import org.apache.olingo.server.sample.edmprovider.CarsEdmProvider;
 
 public class DataProvider {
 
-  private Map<String, EntitySet> data;
+  private final Map<String, EntitySet> data;
 
   public DataProvider() {
     data = new HashMap<String, EntitySet>();
@@ -133,6 +134,9 @@ public class DataProvider {
         .addProperty(createPrimitive("Price", 167189.00))
         .addProperty(createPrimitive("Currency", "EUR")));
 
+    for (Entity entity:entitySet.getEntities()) {
+      entity.setType(CarsEdmProvider.ET_CAR.getFullQualifiedNameAsString());
+    }
     return entitySet;
   }
 
@@ -149,6 +153,9 @@ public class DataProvider {
         .addProperty(createPrimitive("Name", "Horse Powered Racing"))
         .addProperty(createAddress("Horse Street 1", "Maranello", "41053", "Italy")));
 
+    for (Entity entity:entitySet.getEntities()) {
+      entity.setType(CarsEdmProvider.ET_MANUFACTURER.getFullQualifiedNameAsString());
+    }
     return entitySet;
   }
 

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/2b73abcc/samples/server/src/main/java/org/apache/olingo/server/sample/processor/CarsProcessor.java
----------------------------------------------------------------------
diff --git a/samples/server/src/main/java/org/apache/olingo/server/sample/processor/CarsProcessor.java b/samples/server/src/main/java/org/apache/olingo/server/sample/processor/CarsProcessor.java
index 891acbb..71b827d 100644
--- a/samples/server/src/main/java/org/apache/olingo/server/sample/processor/CarsProcessor.java
+++ b/samples/server/src/main/java/org/apache/olingo/server/sample/processor/CarsProcessor.java
@@ -6,9 +6,9 @@
  * 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
@@ -74,7 +74,8 @@ public class CarsProcessor implements EntityCollectionProcessor, EntityProcessor
     PrimitiveProcessor, PrimitiveValueProcessor, ComplexProcessor {
 
   private OData odata;
-  private DataProvider dataProvider;
+  private final DataProvider dataProvider;
+  private ServiceMetadata edm;
 
   // This constructor is application specific and not mandatory for the Olingo library. We use it here to simulate the
   // database access
@@ -85,6 +86,7 @@ public class CarsProcessor implements EntityCollectionProcessor, EntityProcessor
   @Override
   public void init(OData odata, ServiceMetadata edm) {
     this.odata = odata;
+    this.edm = edm;
   }
 
   @Override
@@ -105,7 +107,7 @@ public class CarsProcessor implements EntityCollectionProcessor, EntityProcessor
     // Now the content is serialized using the serializer.
     final ExpandOption expand = uriInfo.getExpandOption();
     final SelectOption select = uriInfo.getSelectOption();
-    InputStream serializedContent = serializer.entityCollection(edmEntitySet.getEntityType(), entitySet,
+    InputStream serializedContent = serializer.entityCollection(edm, edmEntitySet.getEntityType(), entitySet,
         EntityCollectionSerializerOptions.with()
             .contextURL(format == ODataFormat.JSON_NO_METADATA ? null :
                 getContextUrl(edmEntitySet, false, expand, select, null))
@@ -143,7 +145,7 @@ public class CarsProcessor implements EntityCollectionProcessor, EntityProcessor
       ODataSerializer serializer = odata.createSerializer(format);
       final ExpandOption expand = uriInfo.getExpandOption();
       final SelectOption select = uriInfo.getSelectOption();
-      InputStream serializedContent = serializer.entity(edmEntitySet.getEntityType(), entity,
+      InputStream serializedContent = serializer.entity(edm, edmEntitySet.getEntityType(), entity,
           EntitySerializerOptions.with()
               .contextURL(format == ODataFormat.JSON_NO_METADATA ? null :
                   getContextUrl(edmEntitySet, true, expand, select, null))
@@ -256,7 +258,7 @@ public class CarsProcessor implements EntityCollectionProcessor, EntityProcessor
           final ContextURL contextURL = format == ODataFormat.JSON_NO_METADATA ? null :
               getContextUrl(edmEntitySet, true, null, null, edmProperty.getName());
           InputStream serializerContent = complex ?
-              serializer.complex((EdmComplexType) edmProperty.getType(), property,
+              serializer.complex(edm, (EdmComplexType) edmProperty.getType(), property,
                   ComplexSerializerOptions.with().contextURL(contextURL).build()) :
               serializer.primitive((EdmPrimitiveType) edmProperty.getType(), property,
                                     PrimitiveSerializerOptions.with()
@@ -273,7 +275,7 @@ public class CarsProcessor implements EntityCollectionProcessor, EntityProcessor
       }
     }
   }
-  
+
   private Entity readEntityInternal(final UriInfoResource uriInfo, final EdmEntitySet entitySet)
       throws DataProvider.DataProviderException {
     // This method will extract the key values and pass them to the data provider