You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@olingo.apache.org by fm...@apache.org on 2013/07/26 13:22:24 UTC

[19/51] [partial] initial commit

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/ff2b0a0e/odata-core/src/main/java/org/apache/olingo/odata2/core/edm/provider/EdmComplexTypeImplProv.java
----------------------------------------------------------------------
diff --git a/odata-core/src/main/java/org/apache/olingo/odata2/core/edm/provider/EdmComplexTypeImplProv.java b/odata-core/src/main/java/org/apache/olingo/odata2/core/edm/provider/EdmComplexTypeImplProv.java
new file mode 100644
index 0000000..72f294f
--- /dev/null
+++ b/odata-core/src/main/java/org/apache/olingo/odata2/core/edm/provider/EdmComplexTypeImplProv.java
@@ -0,0 +1,43 @@
+/*******************************************************************************
+ * 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.odata2.core.edm.provider;
+
+import org.apache.olingo.odata2.api.edm.EdmAnnotations;
+import org.apache.olingo.odata2.api.edm.EdmComplexType;
+import org.apache.olingo.odata2.api.edm.EdmException;
+import org.apache.olingo.odata2.api.edm.EdmTypeKind;
+import org.apache.olingo.odata2.api.edm.provider.ComplexType;
+
+public class EdmComplexTypeImplProv extends EdmStructuralTypeImplProv implements EdmComplexType {
+
+  public EdmComplexTypeImplProv(final EdmImplProv edm, final ComplexType complexType, final String namespace) throws EdmException {
+    super(edm, complexType, EdmTypeKind.COMPLEX, namespace);
+  }
+
+  @Override
+  public EdmComplexType getBaseType() throws EdmException {
+    return (EdmComplexType) edmBaseType;
+  }
+
+  @Override
+  public EdmAnnotations getAnnotations() throws EdmException {
+    return new EdmAnnotationsImplProv(structuralType.getAnnotationAttributes(), structuralType.getAnnotationElements());
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/ff2b0a0e/odata-core/src/main/java/org/apache/olingo/odata2/core/edm/provider/EdmElementImplProv.java
----------------------------------------------------------------------
diff --git a/odata-core/src/main/java/org/apache/olingo/odata2/core/edm/provider/EdmElementImplProv.java b/odata-core/src/main/java/org/apache/olingo/odata2/core/edm/provider/EdmElementImplProv.java
new file mode 100644
index 0000000..599abde
--- /dev/null
+++ b/odata-core/src/main/java/org/apache/olingo/odata2/core/edm/provider/EdmElementImplProv.java
@@ -0,0 +1,51 @@
+/*******************************************************************************
+ * 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.odata2.core.edm.provider;
+
+import org.apache.olingo.odata2.api.edm.EdmElement;
+import org.apache.olingo.odata2.api.edm.EdmException;
+import org.apache.olingo.odata2.api.edm.EdmFacets;
+import org.apache.olingo.odata2.api.edm.EdmMapping;
+import org.apache.olingo.odata2.api.edm.EdmMultiplicity;
+import org.apache.olingo.odata2.api.edm.FullQualifiedName;
+
+/**
+ * @author SAP AG
+ */
+public abstract class EdmElementImplProv extends EdmTypedImplProv implements EdmElement {
+
+  private EdmFacets edmFacets;
+  private EdmMapping edmMapping;
+
+  public EdmElementImplProv(final EdmImplProv edm, final String name, final FullQualifiedName typeName, final EdmFacets edmFacets, final EdmMapping edmMapping) throws EdmException {
+    super(edm, name, typeName, (edmFacets == null || edmFacets.isNullable() == null) || edmFacets.isNullable() ? EdmMultiplicity.ZERO_TO_ONE : EdmMultiplicity.ONE);
+    this.edmFacets = edmFacets;
+    this.edmMapping = edmMapping;
+  }
+
+  @Override
+  public EdmMapping getMapping() throws EdmException {
+    return edmMapping;
+  }
+
+  @Override
+  public EdmFacets getFacets() throws EdmException {
+    return edmFacets;
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/ff2b0a0e/odata-core/src/main/java/org/apache/olingo/odata2/core/edm/provider/EdmEntityContainerImplProv.java
----------------------------------------------------------------------
diff --git a/odata-core/src/main/java/org/apache/olingo/odata2/core/edm/provider/EdmEntityContainerImplProv.java b/odata-core/src/main/java/org/apache/olingo/odata2/core/edm/provider/EdmEntityContainerImplProv.java
new file mode 100644
index 0000000..016f1d8
--- /dev/null
+++ b/odata-core/src/main/java/org/apache/olingo/odata2/core/edm/provider/EdmEntityContainerImplProv.java
@@ -0,0 +1,184 @@
+/*******************************************************************************
+ * 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.odata2.core.edm.provider;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.olingo.odata2.api.edm.EdmAnnotatable;
+import org.apache.olingo.odata2.api.edm.EdmAnnotations;
+import org.apache.olingo.odata2.api.edm.EdmAssociation;
+import org.apache.olingo.odata2.api.edm.EdmAssociationSet;
+import org.apache.olingo.odata2.api.edm.EdmEntityContainer;
+import org.apache.olingo.odata2.api.edm.EdmEntitySet;
+import org.apache.olingo.odata2.api.edm.EdmException;
+import org.apache.olingo.odata2.api.edm.EdmFunctionImport;
+import org.apache.olingo.odata2.api.edm.EdmNavigationProperty;
+import org.apache.olingo.odata2.api.edm.FullQualifiedName;
+import org.apache.olingo.odata2.api.edm.provider.AssociationSet;
+import org.apache.olingo.odata2.api.edm.provider.EntityContainerInfo;
+import org.apache.olingo.odata2.api.edm.provider.EntitySet;
+import org.apache.olingo.odata2.api.edm.provider.FunctionImport;
+import org.apache.olingo.odata2.api.exception.ODataException;
+
+/**
+ * @author SAP AG
+ */
+public class EdmEntityContainerImplProv implements EdmEntityContainer, EdmAnnotatable {
+
+  private EdmImplProv edm;
+  private EntityContainerInfo entityContainer;
+  private Map<String, EdmEntitySet> edmEntitySets;
+  private Map<String, EdmAssociationSet> edmAssociationSets;
+  private Map<String, EdmFunctionImport> edmFunctionImports;
+  private EdmEntityContainer edmExtendedEntityContainer;
+  private boolean isDefaultContainer;
+
+  public EdmEntityContainerImplProv(final EdmImplProv edm, final EntityContainerInfo entityContainer) throws EdmException {
+    this.edm = edm;
+    this.entityContainer = entityContainer;
+    edmEntitySets = new HashMap<String, EdmEntitySet>();
+    edmAssociationSets = new HashMap<String, EdmAssociationSet>();
+    edmFunctionImports = new HashMap<String, EdmFunctionImport>();
+    isDefaultContainer = entityContainer.isDefaultEntityContainer();
+
+    if (entityContainer.getExtendz() != null) {
+      edmExtendedEntityContainer = edm.getEntityContainer(entityContainer.getExtendz());
+      if (edmExtendedEntityContainer == null) {
+        throw new EdmException(EdmException.COMMON);
+      }
+    }
+  }
+
+  @Override
+  public String getName() throws EdmException {
+    return entityContainer.getName();
+  }
+
+  @Override
+  public EdmEntitySet getEntitySet(final String name) throws EdmException {
+    EdmEntitySet edmEntitySet = edmEntitySets.get(name);
+    if (edmEntitySet != null) {
+      return edmEntitySet;
+    }
+
+    EntitySet entitySet;
+    try {
+      entitySet = edm.edmProvider.getEntitySet(entityContainer.getName(), name);
+    } catch (ODataException e) {
+      throw new EdmException(EdmException.PROVIDERPROBLEM, e);
+    }
+
+    if (entitySet != null) {
+      edmEntitySet = createEntitySet(entitySet);
+      edmEntitySets.put(name, edmEntitySet);
+    } else if (edmExtendedEntityContainer != null) {
+      edmEntitySet = edmExtendedEntityContainer.getEntitySet(name);
+      if (edmEntitySet != null) {
+        edmEntitySets.put(name, edmEntitySet);
+      }
+    }
+
+    return edmEntitySet;
+  }
+
+  @Override
+  public EdmFunctionImport getFunctionImport(final String name) throws EdmException {
+    EdmFunctionImport edmFunctionImport = edmFunctionImports.get(name);
+    if (edmFunctionImport != null) {
+      return edmFunctionImport;
+    }
+
+    FunctionImport functionImport;
+    try {
+      functionImport = edm.edmProvider.getFunctionImport(entityContainer.getName(), name);
+    } catch (ODataException e) {
+      throw new EdmException(EdmException.PROVIDERPROBLEM, e);
+    }
+
+    if (functionImport != null) {
+      edmFunctionImport = createFunctionImport(functionImport);
+      edmFunctionImports.put(name, edmFunctionImport);
+    } else if (edmExtendedEntityContainer != null) {
+      edmFunctionImport = edmExtendedEntityContainer.getFunctionImport(name);
+      if (edmFunctionImport != null) {
+        edmFunctionImports.put(name, edmFunctionImport);
+      }
+    }
+
+    return edmFunctionImport;
+  }
+
+  @Override
+  public EdmAssociationSet getAssociationSet(final EdmEntitySet sourceEntitySet, final EdmNavigationProperty navigationProperty) throws EdmException {
+    EdmAssociation edmAssociation = navigationProperty.getRelationship();
+    String association = edmAssociation.getNamespace() + "." + edmAssociation.getName();
+    String entitySetName = sourceEntitySet.getName();
+    String entitySetFromRole = navigationProperty.getFromRole();
+
+    String key = entitySetName + ">>" + association + ">>" + entitySetFromRole;
+
+    EdmAssociationSet edmAssociationSet = edmAssociationSets.get(key);
+    if (edmAssociationSet != null) {
+      return edmAssociationSet;
+    }
+
+    AssociationSet associationSet;
+    FullQualifiedName associationFQName = new FullQualifiedName(edmAssociation.getNamespace(), edmAssociation.getName());
+    try {
+      associationSet = edm.edmProvider.getAssociationSet(entityContainer.getName(), associationFQName, entitySetName, entitySetFromRole);
+    } catch (ODataException e) {
+      throw new EdmException(EdmException.PROVIDERPROBLEM, e);
+    }
+
+    if (associationSet != null) {
+      edmAssociationSet = createAssociationSet(associationSet);
+      edmAssociationSets.put(key, edmAssociationSet);
+      return edmAssociationSet;
+    } else if (edmExtendedEntityContainer != null) {
+      edmAssociationSet = edmExtendedEntityContainer.getAssociationSet(sourceEntitySet, navigationProperty);
+      edmAssociationSets.put(key, edmAssociationSet);
+      return edmAssociationSet;
+    } else {
+      throw new EdmException(EdmException.COMMON);
+    }
+  }
+
+  private EdmEntitySet createEntitySet(final EntitySet entitySet) throws EdmException {
+    return new EdmEntitySetImplProv(edm, entitySet, this);
+  }
+
+  private EdmFunctionImport createFunctionImport(final FunctionImport functionImport) throws EdmException {
+    return new EdmFunctionImportImplProv(edm, functionImport, this);
+  }
+
+  private EdmAssociationSet createAssociationSet(final AssociationSet associationSet) throws EdmException {
+    return new EdmAssociationSetImplProv(edm, associationSet, this);
+  }
+
+  @Override
+  public boolean isDefaultEntityContainer() {
+    return isDefaultContainer;
+  }
+
+  @Override
+  public EdmAnnotations getAnnotations() throws EdmException {
+    return new EdmAnnotationsImplProv(entityContainer.getAnnotationAttributes(), entityContainer.getAnnotationElements());
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/ff2b0a0e/odata-core/src/main/java/org/apache/olingo/odata2/core/edm/provider/EdmEntitySetImplProv.java
----------------------------------------------------------------------
diff --git a/odata-core/src/main/java/org/apache/olingo/odata2/core/edm/provider/EdmEntitySetImplProv.java b/odata-core/src/main/java/org/apache/olingo/odata2/core/edm/provider/EdmEntitySetImplProv.java
new file mode 100644
index 0000000..d864b5c
--- /dev/null
+++ b/odata-core/src/main/java/org/apache/olingo/odata2/core/edm/provider/EdmEntitySetImplProv.java
@@ -0,0 +1,86 @@
+/*******************************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one
+ *        or more contributor license agreements.  See the NOTICE file
+ *        distributed with this work for additional information
+ *        regarding copyright ownership.  The ASF licenses this file
+ *        to you under the Apache License, Version 2.0 (the
+ *        "License"); you may not use this file except in compliance
+ *        with the License.  You may obtain a copy of the License at
+ * 
+ *          http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ *        Unless required by applicable law or agreed to in writing,
+ *        software distributed under the License is distributed on an
+ *        "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *        KIND, either express or implied.  See the License for the
+ *        specific language governing permissions and limitations
+ *        under the License.
+ ******************************************************************************/
+package org.apache.olingo.odata2.core.edm.provider;
+
+import org.apache.olingo.odata2.api.edm.EdmAnnotatable;
+import org.apache.olingo.odata2.api.edm.EdmAnnotations;
+import org.apache.olingo.odata2.api.edm.EdmAssociationSet;
+import org.apache.olingo.odata2.api.edm.EdmAssociationSetEnd;
+import org.apache.olingo.odata2.api.edm.EdmEntityContainer;
+import org.apache.olingo.odata2.api.edm.EdmEntitySet;
+import org.apache.olingo.odata2.api.edm.EdmEntityType;
+import org.apache.olingo.odata2.api.edm.EdmException;
+import org.apache.olingo.odata2.api.edm.EdmMapping;
+import org.apache.olingo.odata2.api.edm.EdmNavigationProperty;
+import org.apache.olingo.odata2.api.edm.FullQualifiedName;
+import org.apache.olingo.odata2.api.edm.provider.EntitySet;
+
+public class EdmEntitySetImplProv extends EdmNamedImplProv implements EdmEntitySet, EdmAnnotatable {
+
+  private EntitySet entitySet;
+  private EdmEntityContainer edmEntityContainer;
+  private EdmEntityType edmEntityType;
+
+  public EdmEntitySetImplProv(final EdmImplProv edm, final EntitySet entitySet, final EdmEntityContainer edmEntityContainer) throws EdmException {
+    super(edm, entitySet.getName());
+    this.entitySet = entitySet;
+    this.edmEntityContainer = edmEntityContainer;
+  }
+
+  @Override
+  public EdmEntityType getEntityType() throws EdmException {
+    if (edmEntityType == null) {
+      FullQualifiedName fqName = entitySet.getEntityType();
+      edmEntityType = edm.getEntityType(fqName.getNamespace(), fqName.getName());
+      if (edmEntityType == null) {
+        throw new EdmException(EdmException.COMMON);
+      }
+    }
+    return edmEntityType;
+  }
+
+  @Override
+  public EdmEntitySet getRelatedEntitySet(final EdmNavigationProperty navigationProperty) throws EdmException {
+    EdmAssociationSet associationSet = edmEntityContainer.getAssociationSet(edmEntityContainer.getEntitySet(entitySet.getName()), navigationProperty);
+    EdmAssociationSetEnd toEnd = associationSet.getEnd(navigationProperty.getToRole());
+    if (toEnd == null) {
+      throw new EdmException(EdmException.COMMON);
+    }
+    EdmEntitySet targetEntitySet = toEnd.getEntitySet();
+    if (targetEntitySet == null) {
+      throw new EdmException(EdmException.COMMON);
+    }
+    return targetEntitySet;
+  }
+
+  @Override
+  public EdmEntityContainer getEntityContainer() throws EdmException {
+    return edmEntityContainer;
+  }
+
+  @Override
+  public EdmAnnotations getAnnotations() throws EdmException {
+    return new EdmAnnotationsImplProv(entitySet.getAnnotationAttributes(), entitySet.getAnnotationElements());
+  }
+
+  @Override
+  public EdmMapping getMapping() throws EdmException {
+    return entitySet.getMapping();
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/ff2b0a0e/odata-core/src/main/java/org/apache/olingo/odata2/core/edm/provider/EdmEntitySetInfoImplProv.java
----------------------------------------------------------------------
diff --git a/odata-core/src/main/java/org/apache/olingo/odata2/core/edm/provider/EdmEntitySetInfoImplProv.java b/odata-core/src/main/java/org/apache/olingo/odata2/core/edm/provider/EdmEntitySetInfoImplProv.java
new file mode 100644
index 0000000..85a6177
--- /dev/null
+++ b/odata-core/src/main/java/org/apache/olingo/odata2/core/edm/provider/EdmEntitySetInfoImplProv.java
@@ -0,0 +1,78 @@
+/*******************************************************************************
+ * 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.odata2.core.edm.provider;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+
+import org.apache.olingo.odata2.api.edm.EdmEntitySetInfo;
+import org.apache.olingo.odata2.api.edm.EdmException;
+import org.apache.olingo.odata2.api.edm.provider.EntityContainerInfo;
+import org.apache.olingo.odata2.api.edm.provider.EntitySet;
+
+public class EdmEntitySetInfoImplProv implements EdmEntitySetInfo {
+
+  private final String entitySetName;
+  private final URI entitySetUri;
+  private final String entityContainerName;
+  private final boolean isDefaultEntityContainer;
+
+  public EdmEntitySetInfoImplProv(final EntitySet entitySet, final EntityContainerInfo entityContainerInfo) throws EdmException {
+    entityContainerName = entityContainerInfo.getName();
+    isDefaultEntityContainer = entityContainerInfo.isDefaultEntityContainer();
+
+    entitySetName = entitySet.getName();
+
+    try {
+      if (isDefaultEntityContainer) {
+        entitySetUri = new URI(entitySetName);
+      } else {
+        entitySetUri = new URI(entityContainerName + "." + entitySetName);
+      }
+    } catch (URISyntaxException e) {
+      throw new EdmException(EdmException.COMMON, e);
+    }
+
+  }
+
+  @Override
+  public String getEntityContainerName() {
+    return entityContainerName;
+
+  }
+
+  @Override
+  public String getEntitySetName() {
+    return entitySetName;
+
+  }
+
+  @Override
+  public boolean isDefaultEntityContainer() {
+    return isDefaultEntityContainer;
+
+  }
+
+  @Override
+  public URI getEntitySetUri() {
+    return entitySetUri;
+
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/ff2b0a0e/odata-core/src/main/java/org/apache/olingo/odata2/core/edm/provider/EdmEntityTypeImplProv.java
----------------------------------------------------------------------
diff --git a/odata-core/src/main/java/org/apache/olingo/odata2/core/edm/provider/EdmEntityTypeImplProv.java b/odata-core/src/main/java/org/apache/olingo/odata2/core/edm/provider/EdmEntityTypeImplProv.java
new file mode 100644
index 0000000..de82bb0
--- /dev/null
+++ b/odata-core/src/main/java/org/apache/olingo/odata2/core/edm/provider/EdmEntityTypeImplProv.java
@@ -0,0 +1,173 @@
+/*******************************************************************************
+ * 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.odata2.core.edm.provider;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.olingo.odata2.api.edm.EdmAnnotations;
+import org.apache.olingo.odata2.api.edm.EdmCustomizableFeedMappings;
+import org.apache.olingo.odata2.api.edm.EdmEntityType;
+import org.apache.olingo.odata2.api.edm.EdmException;
+import org.apache.olingo.odata2.api.edm.EdmProperty;
+import org.apache.olingo.odata2.api.edm.EdmTypeKind;
+import org.apache.olingo.odata2.api.edm.EdmTyped;
+import org.apache.olingo.odata2.api.edm.provider.EntityType;
+import org.apache.olingo.odata2.api.edm.provider.NavigationProperty;
+import org.apache.olingo.odata2.api.edm.provider.PropertyRef;
+
+public class EdmEntityTypeImplProv extends EdmStructuralTypeImplProv implements EdmEntityType {
+
+  private EntityType entityType;
+
+  private Map<String, EdmProperty> keyProperties;
+  private List<EdmProperty> edmKeyProperties;
+  private List<String> edmKeyPropertyNames;
+
+  private Map<String, NavigationProperty> navigationProperties;
+  private List<String> edmNavigationPropertyNames;
+
+  public EdmEntityTypeImplProv(final EdmImplProv edm, final EntityType entityType, final String namespace) throws EdmException {
+    super(edm, entityType, EdmTypeKind.ENTITY, namespace);
+    this.entityType = entityType;
+
+    buildNavigationPropertiesInternal();
+  }
+
+  private void buildNavigationPropertiesInternal() throws EdmException {
+    navigationProperties = new HashMap<String, NavigationProperty>();
+
+    if (entityType.getNavigationProperties() != null) {
+      for (final NavigationProperty navigationProperty : entityType.getNavigationProperties()) {
+        navigationProperties.put(navigationProperty.getName(), navigationProperty);
+      }
+    }
+  }
+
+  @Override
+  public List<String> getKeyPropertyNames() throws EdmException {
+    if (edmKeyPropertyNames == null) {
+      if (edmBaseType != null) {
+        return ((EdmEntityType) edmBaseType).getKeyPropertyNames();
+      }
+
+      edmKeyPropertyNames = new ArrayList<String>();
+
+      if (entityType.getKey() != null) {
+        for (final PropertyRef keyProperty : entityType.getKey().getKeys()) {
+          edmKeyPropertyNames.add(keyProperty.getName());
+        }
+      } else {
+        //Entity Type does not define a key
+        throw new EdmException(EdmException.COMMON);
+      }
+    }
+
+    return edmKeyPropertyNames;
+  }
+
+  @Override
+  public List<EdmProperty> getKeyProperties() throws EdmException {
+    if (edmKeyProperties == null) {
+      if (edmBaseType != null) {
+        return ((EdmEntityType) edmBaseType).getKeyProperties();
+      }
+
+      if (keyProperties == null) {
+        keyProperties = new HashMap<String, EdmProperty>();
+        edmKeyProperties = new ArrayList<EdmProperty>();
+
+        for (String keyPropertyName : getKeyPropertyNames()) {
+          final EdmTyped edmProperty = getProperty(keyPropertyName);
+          if (edmProperty != null && edmProperty instanceof EdmProperty) {
+            keyProperties.put(keyPropertyName, (EdmProperty) edmProperty);
+            edmKeyProperties.add((EdmProperty) edmProperty);
+          } else {
+            throw new EdmException(EdmException.COMMON);
+          }
+        }
+      }
+    }
+
+    return edmKeyProperties;
+  }
+
+  @Override
+  public boolean hasStream() throws EdmException {
+    return entityType.isHasStream();
+  }
+
+  @Override
+  public EdmCustomizableFeedMappings getCustomizableFeedMappings() throws EdmException {
+    return entityType.getCustomizableFeedMappings();
+  }
+
+  @Override
+  public List<String> getNavigationPropertyNames() throws EdmException {
+    if (edmNavigationPropertyNames == null) {
+      edmNavigationPropertyNames = new ArrayList<String>();
+      if (edmBaseType != null) {
+        edmNavigationPropertyNames.addAll(((EdmEntityType) edmBaseType).getNavigationPropertyNames());
+      }
+      if (entityType.getNavigationProperties() != null) {
+        for (final NavigationProperty navigationProperty : entityType.getNavigationProperties()) {
+          edmNavigationPropertyNames.add(navigationProperty.getName());
+        }
+      }
+    }
+    return edmNavigationPropertyNames;
+  }
+
+  @Override
+  public EdmEntityType getBaseType() throws EdmException {
+    return (EdmEntityType) edmBaseType;
+  }
+
+  @Override
+  protected EdmTyped getPropertyInternal(final String name) throws EdmException {
+    EdmTyped edmProperty = super.getPropertyInternal(name);
+
+    if (edmProperty != null) {
+      return edmProperty;
+    }
+
+    if (navigationProperties.containsKey(name)) {
+      edmProperty = createNavigationProperty(navigationProperties.get(name));
+      edmProperties.put(name, edmProperty);
+    } else if (edmBaseType != null) {
+      edmProperty = edmBaseType.getProperty(name);
+      if (edmProperty != null) {
+        edmProperties.put(name, edmProperty);
+      }
+    }
+
+    return edmProperty;
+  }
+
+  protected EdmTyped createNavigationProperty(final NavigationProperty property) throws EdmException {
+    return new EdmNavigationPropertyImplProv(edm, property);
+  }
+
+  @Override
+  public EdmAnnotations getAnnotations() throws EdmException {
+    return new EdmAnnotationsImplProv(entityType.getAnnotationAttributes(), entityType.getAnnotationElements());
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/ff2b0a0e/odata-core/src/main/java/org/apache/olingo/odata2/core/edm/provider/EdmFunctionImportImplProv.java
----------------------------------------------------------------------
diff --git a/odata-core/src/main/java/org/apache/olingo/odata2/core/edm/provider/EdmFunctionImportImplProv.java b/odata-core/src/main/java/org/apache/olingo/odata2/core/edm/provider/EdmFunctionImportImplProv.java
new file mode 100644
index 0000000..9e0e555
--- /dev/null
+++ b/odata-core/src/main/java/org/apache/olingo/odata2/core/edm/provider/EdmFunctionImportImplProv.java
@@ -0,0 +1,142 @@
+/*******************************************************************************
+ * 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.odata2.core.edm.provider;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.olingo.odata2.api.edm.EdmAnnotatable;
+import org.apache.olingo.odata2.api.edm.EdmAnnotations;
+import org.apache.olingo.odata2.api.edm.EdmEntityContainer;
+import org.apache.olingo.odata2.api.edm.EdmEntitySet;
+import org.apache.olingo.odata2.api.edm.EdmException;
+import org.apache.olingo.odata2.api.edm.EdmFunctionImport;
+import org.apache.olingo.odata2.api.edm.EdmMapping;
+import org.apache.olingo.odata2.api.edm.EdmParameter;
+import org.apache.olingo.odata2.api.edm.EdmTyped;
+import org.apache.olingo.odata2.api.edm.provider.FunctionImport;
+import org.apache.olingo.odata2.api.edm.provider.FunctionImportParameter;
+import org.apache.olingo.odata2.api.edm.provider.ReturnType;
+
+/**
+ * @author SAP AG
+ */
+public class EdmFunctionImportImplProv extends EdmNamedImplProv implements EdmFunctionImport, EdmAnnotatable {
+
+  private FunctionImport functionImport;
+  private EdmEntityContainer edmEntityContainer;
+  private Map<String, EdmParameter> edmParameters;
+  private Map<String, FunctionImportParameter> parameters;
+  private List<String> parametersList;
+
+  public EdmFunctionImportImplProv(final EdmImplProv edm, final FunctionImport functionImport, final EdmEntityContainer edmEntityContainer) throws EdmException {
+    super(edm, functionImport.getName());
+    this.functionImport = functionImport;
+    this.edmEntityContainer = edmEntityContainer;
+
+    buildFunctionImportParametersInternal();
+
+    edmParameters = new HashMap<String, EdmParameter>();
+  }
+
+  private void buildFunctionImportParametersInternal() {
+    parameters = new HashMap<String, FunctionImportParameter>();
+
+    List<FunctionImportParameter> parameters = functionImport.getParameters();
+    if (parameters != null) {
+      FunctionImportParameter functionImportParameter;
+      for (Iterator<FunctionImportParameter> iterator = parameters.iterator(); iterator.hasNext();) {
+        functionImportParameter = iterator.next();
+        this.parameters.put(functionImportParameter.getName(), functionImportParameter);
+      }
+    }
+  }
+
+  @Override
+  public EdmParameter getParameter(final String name) throws EdmException {
+    EdmParameter parameter = null;
+    if (edmParameters.containsKey(name)) {
+      parameter = edmParameters.get(name);
+    } else {
+      parameter = createParameter(name);
+    }
+
+    return parameter;
+  }
+
+  private EdmParameter createParameter(final String name) throws EdmException {
+    EdmParameter edmParameter = null;
+    if (parameters.containsKey(name)) {
+      FunctionImportParameter parameter = parameters.get(name);
+      edmParameter = new EdmParameterImplProv(edm, parameter);
+      edmParameters.put(name, edmParameter);
+    }
+    return edmParameter;
+  }
+
+  @Override
+  public List<String> getParameterNames() throws EdmException {
+    if (parametersList == null) {
+      parametersList = new ArrayList<String>();
+
+      Set<String> keySet = parameters.keySet();
+      Iterator<String> iterator = keySet.iterator();
+      while (iterator.hasNext()) {
+        parametersList.add(iterator.next());
+      }
+    }
+
+    return parametersList;
+  }
+
+  @Override
+  public EdmEntitySet getEntitySet() throws EdmException {
+    return edmEntityContainer.getEntitySet(functionImport.getEntitySet());
+  }
+
+  @Override
+  public String getHttpMethod() throws EdmException {
+    return functionImport.getHttpMethod();
+  }
+
+  @Override
+  public EdmTyped getReturnType() throws EdmException {
+    final ReturnType returnType = functionImport.getReturnType();
+    return new EdmTypedImplProv(edm, functionImport.getName(), returnType.getTypeName(), returnType.getMultiplicity());
+  }
+
+  @Override
+  public EdmEntityContainer getEntityContainer() throws EdmException {
+    return edmEntityContainer;
+  }
+
+  @Override
+  public EdmAnnotations getAnnotations() throws EdmException {
+    return new EdmAnnotationsImplProv(functionImport.getAnnotationAttributes(), functionImport.getAnnotationElements());
+  }
+
+  @Override
+  public EdmMapping getMapping() throws EdmException {
+    return functionImport.getMapping();
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/ff2b0a0e/odata-core/src/main/java/org/apache/olingo/odata2/core/edm/provider/EdmImplProv.java
----------------------------------------------------------------------
diff --git a/odata-core/src/main/java/org/apache/olingo/odata2/core/edm/provider/EdmImplProv.java b/odata-core/src/main/java/org/apache/olingo/odata2/core/edm/provider/EdmImplProv.java
new file mode 100644
index 0000000..126c08c
--- /dev/null
+++ b/odata-core/src/main/java/org/apache/olingo/odata2/core/edm/provider/EdmImplProv.java
@@ -0,0 +1,85 @@
+/*******************************************************************************
+ * 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.odata2.core.edm.provider;
+
+import org.apache.olingo.odata2.api.edm.EdmAssociation;
+import org.apache.olingo.odata2.api.edm.EdmComplexType;
+import org.apache.olingo.odata2.api.edm.EdmEntityContainer;
+import org.apache.olingo.odata2.api.edm.EdmEntityType;
+import org.apache.olingo.odata2.api.edm.FullQualifiedName;
+import org.apache.olingo.odata2.api.edm.provider.Association;
+import org.apache.olingo.odata2.api.edm.provider.ComplexType;
+import org.apache.olingo.odata2.api.edm.provider.EdmProvider;
+import org.apache.olingo.odata2.api.edm.provider.EdmProviderAccessor;
+import org.apache.olingo.odata2.api.edm.provider.EntityContainerInfo;
+import org.apache.olingo.odata2.api.edm.provider.EntityType;
+import org.apache.olingo.odata2.api.exception.ODataException;
+import org.apache.olingo.odata2.core.edm.EdmImpl;
+
+public class EdmImplProv extends EdmImpl implements EdmProviderAccessor {
+
+  protected EdmProvider edmProvider;
+
+  public EdmImplProv(final EdmProvider edmProvider) {
+    super(new EdmServiceMetadataImplProv(edmProvider));
+    this.edmProvider = edmProvider;
+  }
+
+  @Override
+  protected EdmEntityContainer createEntityContainer(final String name) throws ODataException {
+    EntityContainerInfo enitityContainerInfo = edmProvider.getEntityContainerInfo(name);
+    if (enitityContainerInfo == null) {
+      return null;
+    }
+    return new EdmEntityContainerImplProv(this, enitityContainerInfo);
+  }
+
+  @Override
+  protected EdmEntityType createEntityType(final FullQualifiedName fqName) throws ODataException {
+    EntityType entityType = edmProvider.getEntityType(fqName);
+    if (entityType == null) {
+      return null;
+    }
+
+    return new EdmEntityTypeImplProv(this, entityType, fqName.getNamespace());
+  }
+
+  @Override
+  protected EdmComplexType createComplexType(final FullQualifiedName fqName) throws ODataException {
+    ComplexType complexType = edmProvider.getComplexType(fqName);
+    if (complexType == null) {
+      return null;
+    }
+    return new EdmComplexTypeImplProv(this, complexType, fqName.getNamespace());
+  }
+
+  @Override
+  protected EdmAssociation createAssociation(final FullQualifiedName fqName) throws ODataException {
+    Association association = edmProvider.getAssociation(fqName);
+    if (association == null) {
+      return null;
+    }
+    return new EdmAssociationImplProv(this, association, fqName.getNamespace());
+  }
+
+  @Override
+  public EdmProvider getEdmProvider() {
+    return edmProvider;
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/ff2b0a0e/odata-core/src/main/java/org/apache/olingo/odata2/core/edm/provider/EdmNamedImplProv.java
----------------------------------------------------------------------
diff --git a/odata-core/src/main/java/org/apache/olingo/odata2/core/edm/provider/EdmNamedImplProv.java b/odata-core/src/main/java/org/apache/olingo/odata2/core/edm/provider/EdmNamedImplProv.java
new file mode 100644
index 0000000..0d29c1b
--- /dev/null
+++ b/odata-core/src/main/java/org/apache/olingo/odata2/core/edm/provider/EdmNamedImplProv.java
@@ -0,0 +1,57 @@
+/*******************************************************************************
+ * 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.odata2.core.edm.provider;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.apache.olingo.odata2.api.edm.EdmException;
+import org.apache.olingo.odata2.api.edm.EdmNamed;
+
+public abstract class EdmNamedImplProv implements EdmNamed {
+
+  private static final Pattern PATTERN_VALID_NAME = Pattern
+      .compile("^[:A-Z_a-z\\u00C0\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02ff\\u0370-\\u037d"
+          + "\\u037f-\\u1fff\\u200c\\u200d\\u2070-\\u218f\\u2c00-\\u2fef\\u3001-\\ud7ff"
+          + "\\uf900-\\ufdcf\\ufdf0-\\ufffd\\x10000-\\xEFFFF]"
+          + "[:A-Z_a-z\\u00C0\\u00D6\\u00D8-\\u00F6"
+          + "\\u00F8-\\u02ff\\u0370-\\u037d\\u037f-\\u1fff\\u200c\\u200d\\u2070-\\u218f"
+          + "\\u2c00-\\u2fef\\u3001-\\udfff\\uf900-\\ufdcf\\ufdf0-\\ufffd\\-\\.0-9"
+          + "\\u00b7\\u0300-\\u036f\\u203f-\\u2040]*\\Z");
+  protected EdmImplProv edm;
+  private String name;
+
+  public EdmNamedImplProv(final EdmImplProv edm, final String name) throws EdmException {
+    this.edm = edm;
+    this.name = getValidatedName(name);
+  }
+
+  @Override
+  public String getName() throws EdmException {
+    return name;
+  }
+
+  private String getValidatedName(final String name) throws EdmException {
+    Matcher matcher = PATTERN_VALID_NAME.matcher(name);
+    if (matcher.matches()) {
+      return name;
+    }
+    throw new EdmException(EdmException.COMMON);
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/ff2b0a0e/odata-core/src/main/java/org/apache/olingo/odata2/core/edm/provider/EdmNavigationPropertyImplProv.java
----------------------------------------------------------------------
diff --git a/odata-core/src/main/java/org/apache/olingo/odata2/core/edm/provider/EdmNavigationPropertyImplProv.java b/odata-core/src/main/java/org/apache/olingo/odata2/core/edm/provider/EdmNavigationPropertyImplProv.java
new file mode 100644
index 0000000..7d603e7
--- /dev/null
+++ b/odata-core/src/main/java/org/apache/olingo/odata2/core/edm/provider/EdmNavigationPropertyImplProv.java
@@ -0,0 +1,77 @@
+/*******************************************************************************
+ * 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.odata2.core.edm.provider;
+
+import org.apache.olingo.odata2.api.edm.EdmAnnotatable;
+import org.apache.olingo.odata2.api.edm.EdmAnnotations;
+import org.apache.olingo.odata2.api.edm.EdmAssociation;
+import org.apache.olingo.odata2.api.edm.EdmException;
+import org.apache.olingo.odata2.api.edm.EdmMapping;
+import org.apache.olingo.odata2.api.edm.EdmMultiplicity;
+import org.apache.olingo.odata2.api.edm.EdmNavigationProperty;
+import org.apache.olingo.odata2.api.edm.EdmType;
+import org.apache.olingo.odata2.api.edm.FullQualifiedName;
+import org.apache.olingo.odata2.api.edm.provider.NavigationProperty;
+
+public class EdmNavigationPropertyImplProv extends EdmTypedImplProv implements EdmNavigationProperty, EdmAnnotatable {
+
+  private NavigationProperty navigationProperty;
+
+  public EdmNavigationPropertyImplProv(final EdmImplProv edm, final NavigationProperty property) throws EdmException {
+    super(edm, property.getName(), null, null);
+    navigationProperty = property;
+  }
+
+  @Override
+  public EdmType getType() throws EdmException {
+    return getRelationship().getEnd(navigationProperty.getToRole()).getEntityType();
+  }
+
+  @Override
+  public EdmMultiplicity getMultiplicity() throws EdmException {
+    return ((EdmAssociationImplProv) getRelationship()).getEndMultiplicity(navigationProperty.getToRole());
+  }
+
+  @Override
+  public EdmAssociation getRelationship() throws EdmException {
+    final FullQualifiedName relationship = navigationProperty.getRelationship();
+    return edm.getAssociation(relationship.getNamespace(), relationship.getName());
+  }
+
+  @Override
+  public String getFromRole() throws EdmException {
+    return navigationProperty.getFromRole();
+  }
+
+  @Override
+  public String getToRole() throws EdmException {
+    return navigationProperty.getToRole();
+  }
+
+  @Override
+  public EdmAnnotations getAnnotations() throws EdmException {
+    return new EdmAnnotationsImplProv(navigationProperty.getAnnotationAttributes(), navigationProperty.getAnnotationElements());
+  }
+
+  @Override
+  public EdmMapping getMapping() throws EdmException {
+    return navigationProperty.getMapping();
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/ff2b0a0e/odata-core/src/main/java/org/apache/olingo/odata2/core/edm/provider/EdmParameterImplProv.java
----------------------------------------------------------------------
diff --git a/odata-core/src/main/java/org/apache/olingo/odata2/core/edm/provider/EdmParameterImplProv.java b/odata-core/src/main/java/org/apache/olingo/odata2/core/edm/provider/EdmParameterImplProv.java
new file mode 100644
index 0000000..79a6423
--- /dev/null
+++ b/odata-core/src/main/java/org/apache/olingo/odata2/core/edm/provider/EdmParameterImplProv.java
@@ -0,0 +1,56 @@
+/*******************************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one
+ *        or more contributor license agreements.  See the NOTICE file
+ *        distributed with this work for additional information
+ *        regarding copyright ownership.  The ASF licenses this file
+ *        to you under the Apache License, Version 2.0 (the
+ *        "License"); you may not use this file except in compliance
+ *        with the License.  You may obtain a copy of the License at
+ * 
+ *          http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ *        Unless required by applicable law or agreed to in writing,
+ *        software distributed under the License is distributed on an
+ *        "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *        KIND, either express or implied.  See the License for the
+ *        specific language governing permissions and limitations
+ *        under the License.
+ ******************************************************************************/
+package org.apache.olingo.odata2.core.edm.provider;
+
+import org.apache.olingo.odata2.api.edm.EdmAnnotatable;
+import org.apache.olingo.odata2.api.edm.EdmAnnotations;
+import org.apache.olingo.odata2.api.edm.EdmException;
+import org.apache.olingo.odata2.api.edm.EdmParameter;
+import org.apache.olingo.odata2.api.edm.EdmType;
+import org.apache.olingo.odata2.api.edm.provider.FunctionImportParameter;
+import org.apache.olingo.odata2.core.edm.EdmSimpleTypeFacadeImpl;
+
+/**
+ * @author SAP AG
+ */
+public class EdmParameterImplProv extends EdmElementImplProv implements EdmParameter, EdmAnnotatable {
+
+  FunctionImportParameter parameter;
+
+  public EdmParameterImplProv(final EdmImplProv edm, final FunctionImportParameter parameter) throws EdmException {
+    super(edm, parameter.getName(), parameter.getType().getFullQualifiedName(), parameter.getFacets(), parameter.getMapping());
+    this.parameter = parameter;
+  }
+
+  @Override
+  public EdmType getType() throws EdmException {
+    if (edmType == null) {
+      edmType = EdmSimpleTypeFacadeImpl.getEdmSimpleType(parameter.getType());
+      if (edmType == null) {
+        throw new EdmException(EdmException.COMMON);
+      }
+    }
+    return edmType;
+  }
+
+  @Override
+  public EdmAnnotations getAnnotations() throws EdmException {
+    return new EdmAnnotationsImplProv(parameter.getAnnotationAttributes(), parameter.getAnnotationElements());
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/ff2b0a0e/odata-core/src/main/java/org/apache/olingo/odata2/core/edm/provider/EdmPropertyImplProv.java
----------------------------------------------------------------------
diff --git a/odata-core/src/main/java/org/apache/olingo/odata2/core/edm/provider/EdmPropertyImplProv.java b/odata-core/src/main/java/org/apache/olingo/odata2/core/edm/provider/EdmPropertyImplProv.java
new file mode 100644
index 0000000..b2545be
--- /dev/null
+++ b/odata-core/src/main/java/org/apache/olingo/odata2/core/edm/provider/EdmPropertyImplProv.java
@@ -0,0 +1,52 @@
+/*******************************************************************************
+ * 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.odata2.core.edm.provider;
+
+import org.apache.olingo.odata2.api.edm.EdmAnnotatable;
+import org.apache.olingo.odata2.api.edm.EdmAnnotations;
+import org.apache.olingo.odata2.api.edm.EdmCustomizableFeedMappings;
+import org.apache.olingo.odata2.api.edm.EdmException;
+import org.apache.olingo.odata2.api.edm.EdmProperty;
+import org.apache.olingo.odata2.api.edm.FullQualifiedName;
+import org.apache.olingo.odata2.api.edm.provider.Property;
+
+public abstract class EdmPropertyImplProv extends EdmElementImplProv implements EdmProperty, EdmAnnotatable {
+
+  private Property property;
+
+  public EdmPropertyImplProv(final EdmImplProv edm, final FullQualifiedName propertyName, final Property property) throws EdmException {
+    super(edm, property.getName(), propertyName, property.getFacets(), property.getMapping());
+    this.property = property;
+  }
+
+  @Override
+  public EdmCustomizableFeedMappings getCustomizableFeedMappings() throws EdmException {
+    return property.getCustomizableFeedMappings();
+  }
+
+  @Override
+  public String getMimeType() throws EdmException {
+    return property.getMimeType();
+  }
+
+  @Override
+  public EdmAnnotations getAnnotations() throws EdmException {
+    return new EdmAnnotationsImplProv(property.getAnnotationAttributes(), property.getAnnotationElements());
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/ff2b0a0e/odata-core/src/main/java/org/apache/olingo/odata2/core/edm/provider/EdmServiceMetadataImplProv.java
----------------------------------------------------------------------
diff --git a/odata-core/src/main/java/org/apache/olingo/odata2/core/edm/provider/EdmServiceMetadataImplProv.java b/odata-core/src/main/java/org/apache/olingo/odata2/core/edm/provider/EdmServiceMetadataImplProv.java
new file mode 100644
index 0000000..259422a
--- /dev/null
+++ b/odata-core/src/main/java/org/apache/olingo/odata2/core/edm/provider/EdmServiceMetadataImplProv.java
@@ -0,0 +1,163 @@
+/*******************************************************************************
+ * 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.odata2.core.edm.provider;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStreamWriter;
+import java.io.UnsupportedEncodingException;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamWriter;
+
+import org.apache.olingo.odata2.api.ODataServiceVersion;
+import org.apache.olingo.odata2.api.edm.EdmEntitySetInfo;
+import org.apache.olingo.odata2.api.edm.EdmServiceMetadata;
+import org.apache.olingo.odata2.api.edm.provider.DataServices;
+import org.apache.olingo.odata2.api.edm.provider.EdmProvider;
+import org.apache.olingo.odata2.api.edm.provider.EntityContainer;
+import org.apache.olingo.odata2.api.edm.provider.EntitySet;
+import org.apache.olingo.odata2.api.edm.provider.EntityType;
+import org.apache.olingo.odata2.api.edm.provider.Property;
+import org.apache.olingo.odata2.api.edm.provider.Schema;
+import org.apache.olingo.odata2.api.ep.EntityProviderException;
+import org.apache.olingo.odata2.api.exception.ODataException;
+import org.apache.olingo.odata2.core.ep.producer.XmlMetadataProducer;
+import org.apache.olingo.odata2.core.ep.util.CircleStreamBuffer;
+
+/**
+ * @author SAP AG
+ */
+public class EdmServiceMetadataImplProv implements EdmServiceMetadata {
+
+  private EdmProvider edmProvider;
+  private String dataServiceVersion;
+  private List<Schema> schemas;
+  private List<EdmEntitySetInfo> entitySetInfos;
+
+  public EdmServiceMetadataImplProv(final EdmProvider edmProvider) {
+    this.edmProvider = edmProvider;
+  }
+
+  @Override
+  public InputStream getMetadata() throws ODataException {
+    if (schemas == null) {
+      schemas = edmProvider.getSchemas();
+    }
+
+    OutputStreamWriter writer = null;
+    CircleStreamBuffer csb = new CircleStreamBuffer();
+    EntityProviderException cachedException = null;
+    DataServices metadata = new DataServices().setSchemas(schemas).setDataServiceVersion(getDataServiceVersion());
+
+    try {
+      writer = new OutputStreamWriter(csb.getOutputStream(), "UTF-8");
+      XMLStreamWriter xmlStreamWriter = XMLOutputFactory.newInstance().createXMLStreamWriter(writer);
+      XmlMetadataProducer.writeMetadata(metadata, xmlStreamWriter, null);
+      return csb.getInputStream();
+    } catch (XMLStreamException e) {
+      cachedException = new EntityProviderException(EntityProviderException.COMMON, e);
+      throw cachedException;
+    } catch (UnsupportedEncodingException e) {
+      cachedException = new EntityProviderException(EntityProviderException.COMMON, e);
+      throw cachedException;
+    } finally {// NOPMD (suppress DoNotThrowExceptionInFinally)
+      if (writer != null) {
+        try {
+          writer.close();
+        } catch (IOException e) {
+          if (cachedException != null) {
+            throw cachedException;
+          } else {
+            throw new EntityProviderException(EntityProviderException.COMMON, e);
+          }
+        }
+      }
+    }
+  }
+
+  @Override
+  public String getDataServiceVersion() throws ODataException {
+    if (schemas == null) {
+      schemas = edmProvider.getSchemas();
+    }
+
+    if (dataServiceVersion == null) {
+      dataServiceVersion = ODataServiceVersion.V10;
+
+      if (schemas != null) {
+        for (Schema schema : schemas) {
+          List<EntityType> entityTypes = schema.getEntityTypes();
+          if (entityTypes != null) {
+            for (EntityType entityType : entityTypes) {
+              List<Property> properties = entityType.getProperties();
+              if (properties != null) {
+                for (Property property : properties) {
+                  if (property.getCustomizableFeedMappings() != null) {
+                    if (property.getCustomizableFeedMappings().getFcKeepInContent() != null) {
+                      if (!property.getCustomizableFeedMappings().getFcKeepInContent()) {
+                        dataServiceVersion = ODataServiceVersion.V20;
+                        return dataServiceVersion;
+                      }
+                    }
+                  }
+                }
+                if (entityType.getCustomizableFeedMappings() != null) {
+                  if (entityType.getCustomizableFeedMappings().getFcKeepInContent() != null) {
+                    if (entityType.getCustomizableFeedMappings().getFcKeepInContent()) {
+                      dataServiceVersion = ODataServiceVersion.V20;
+                      return dataServiceVersion;
+                    }
+                  }
+                }
+              }
+            }
+          }
+        }
+      }
+    }
+    return dataServiceVersion;
+  }
+
+  @Override
+  public List<EdmEntitySetInfo> getEntitySetInfos() throws ODataException {
+    if (entitySetInfos == null) {
+      entitySetInfos = new ArrayList<EdmEntitySetInfo>();
+
+      if (schemas == null) {
+        schemas = edmProvider.getSchemas();
+      }
+
+      for (Schema schema : schemas) {
+        for (EntityContainer entityContainer : schema.getEntityContainers()) {
+          for (EntitySet entitySet : entityContainer.getEntitySets()) {
+            EdmEntitySetInfo entitySetInfo = new EdmEntitySetInfoImplProv(entitySet, entityContainer);
+            entitySetInfos.add(entitySetInfo);
+          }
+        }
+      }
+
+    }
+
+    return entitySetInfos;
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/ff2b0a0e/odata-core/src/main/java/org/apache/olingo/odata2/core/edm/provider/EdmSimplePropertyImplProv.java
----------------------------------------------------------------------
diff --git a/odata-core/src/main/java/org/apache/olingo/odata2/core/edm/provider/EdmSimplePropertyImplProv.java b/odata-core/src/main/java/org/apache/olingo/odata2/core/edm/provider/EdmSimplePropertyImplProv.java
new file mode 100644
index 0000000..47d4841
--- /dev/null
+++ b/odata-core/src/main/java/org/apache/olingo/odata2/core/edm/provider/EdmSimplePropertyImplProv.java
@@ -0,0 +1,50 @@
+/*******************************************************************************
+ * 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.odata2.core.edm.provider;
+
+import org.apache.olingo.odata2.api.edm.EdmException;
+import org.apache.olingo.odata2.api.edm.EdmType;
+import org.apache.olingo.odata2.api.edm.provider.SimpleProperty;
+import org.apache.olingo.odata2.core.edm.EdmSimpleTypeFacadeImpl;
+
+public class EdmSimplePropertyImplProv extends EdmPropertyImplProv {
+
+  private SimpleProperty property;
+
+  public EdmSimplePropertyImplProv(final EdmImplProv edm, final SimpleProperty property) throws EdmException {
+    super(edm, property.getType().getFullQualifiedName(), property);
+    this.property = property;
+  }
+
+  @Override
+  public EdmType getType() throws EdmException {
+    if (edmType == null) {
+      edmType = EdmSimpleTypeFacadeImpl.getEdmSimpleType(property.getType());
+      if (edmType == null) {
+        throw new EdmException(EdmException.COMMON);
+      }
+    }
+    return edmType;
+  }
+
+  @Override
+  public boolean isSimple() {
+    return true;
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/ff2b0a0e/odata-core/src/main/java/org/apache/olingo/odata2/core/edm/provider/EdmStructuralTypeImplProv.java
----------------------------------------------------------------------
diff --git a/odata-core/src/main/java/org/apache/olingo/odata2/core/edm/provider/EdmStructuralTypeImplProv.java b/odata-core/src/main/java/org/apache/olingo/odata2/core/edm/provider/EdmStructuralTypeImplProv.java
new file mode 100644
index 0000000..38619a2
--- /dev/null
+++ b/odata-core/src/main/java/org/apache/olingo/odata2/core/edm/provider/EdmStructuralTypeImplProv.java
@@ -0,0 +1,172 @@
+/*******************************************************************************
+ * 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.odata2.core.edm.provider;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.olingo.odata2.api.edm.Edm;
+import org.apache.olingo.odata2.api.edm.EdmAnnotatable;
+import org.apache.olingo.odata2.api.edm.EdmException;
+import org.apache.olingo.odata2.api.edm.EdmMapping;
+import org.apache.olingo.odata2.api.edm.EdmStructuralType;
+import org.apache.olingo.odata2.api.edm.EdmTypeKind;
+import org.apache.olingo.odata2.api.edm.EdmTyped;
+import org.apache.olingo.odata2.api.edm.FullQualifiedName;
+import org.apache.olingo.odata2.api.edm.provider.ComplexProperty;
+import org.apache.olingo.odata2.api.edm.provider.ComplexType;
+import org.apache.olingo.odata2.api.edm.provider.Property;
+import org.apache.olingo.odata2.api.edm.provider.SimpleProperty;
+
+/**
+ * @author SAP AG
+ */
+public abstract class EdmStructuralTypeImplProv extends EdmNamedImplProv implements EdmStructuralType, EdmAnnotatable {
+
+  protected EdmStructuralType edmBaseType;
+  protected ComplexType structuralType;
+  private EdmTypeKind edmTypeKind;
+  protected String namespace;
+  protected Map<String, EdmTyped> edmProperties;
+  private Map<String, Property> properties;
+  private List<String> edmPropertyNames;
+
+  public EdmStructuralTypeImplProv(final EdmImplProv edm, final ComplexType structuralType, final EdmTypeKind edmTypeKind, final String namespace) throws EdmException {
+    super(edm, structuralType.getName());
+    this.structuralType = structuralType;
+    this.namespace = namespace;
+    this.edmTypeKind = edmTypeKind;
+
+    resolveBaseType();
+
+    buildPropertiesInternal();
+
+    edmProperties = new HashMap<String, EdmTyped>();
+  }
+
+  private void resolveBaseType() throws EdmException {
+    FullQualifiedName fqName = structuralType.getBaseType();
+    if (fqName != null) {
+      if (EdmTypeKind.COMPLEX.equals(edmTypeKind)) {
+        edmBaseType = edm.getComplexType(fqName.getNamespace(), fqName.getName());
+      } else if (EdmTypeKind.ENTITY.equals(edmTypeKind)) {
+        edmBaseType = edm.getEntityType(fqName.getNamespace(), fqName.getName());
+      }
+      if (edmBaseType == null) {
+        throw new EdmException(EdmException.COMMON);
+      }
+    }
+  }
+
+  private void buildPropertiesInternal() throws EdmException {
+    properties = new HashMap<String, Property>();
+
+    if (structuralType.getProperties() != null) {
+      for (final Property property : structuralType.getProperties()) {
+        properties.put(property.getName(), property);
+      }
+    }
+  }
+
+  @Override
+  public String getNamespace() throws EdmException {
+    return namespace;
+  }
+
+  @Override
+  public EdmTyped getProperty(final String name) throws EdmException {
+    EdmTyped property = edmProperties.get(name);
+    if (property == null) {
+      property = getPropertyInternal(name);
+      if (property == null && edmBaseType != null) {
+        property = edmBaseType.getProperty(name);
+      }
+    }
+    return property;
+  }
+
+  @Override
+  public List<String> getPropertyNames() throws EdmException {
+    if (edmPropertyNames == null) {
+      edmPropertyNames = new ArrayList<String>();
+      if (edmBaseType != null) {
+        edmPropertyNames.addAll(edmBaseType.getPropertyNames());
+      }
+      if (structuralType.getProperties() != null) {
+        for (final Property property : structuralType.getProperties()) {
+          edmPropertyNames.add(property.getName());
+        }
+      }
+    }
+
+    return edmPropertyNames;
+  }
+
+  @Override
+  public EdmStructuralType getBaseType() throws EdmException {
+    return edmBaseType;
+  }
+
+  @Override
+  public EdmTypeKind getKind() {
+    return edmTypeKind;
+  }
+
+  @Override
+  public EdmMapping getMapping() throws EdmException {
+    return structuralType.getMapping();
+  }
+
+  protected EdmTyped getPropertyInternal(final String name) throws EdmException {
+    EdmTyped edmProperty = null;
+
+    if (properties.containsKey(name)) {
+      edmProperty = createProperty(properties.get(name));
+      edmProperties.put(name, edmProperty);
+    } else if (edmBaseType != null) {
+      edmProperty = edmBaseType.getProperty(name);
+      if (edmProperty != null) {
+        edmProperties.put(name, edmProperty);
+      }
+    }
+
+    return edmProperty;
+  }
+
+  protected EdmTyped createProperty(final Property property) throws EdmException {
+    if (property instanceof SimpleProperty) {
+      return new EdmSimplePropertyImplProv(edm, (SimpleProperty) property);
+    } else if (property instanceof ComplexProperty) {
+      return new EdmComplexPropertyImplProv(edm, (ComplexProperty) property);
+    } else {
+      throw new EdmException(EdmException.COMMON);
+    }
+  }
+
+  @Override
+  public String toString() {
+    try {
+      return namespace + Edm.DELIMITER + getName();
+    } catch (final EdmException e) {
+      return null;
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/ff2b0a0e/odata-core/src/main/java/org/apache/olingo/odata2/core/edm/provider/EdmTypedImplProv.java
----------------------------------------------------------------------
diff --git a/odata-core/src/main/java/org/apache/olingo/odata2/core/edm/provider/EdmTypedImplProv.java b/odata-core/src/main/java/org/apache/olingo/odata2/core/edm/provider/EdmTypedImplProv.java
new file mode 100644
index 0000000..d763b0b
--- /dev/null
+++ b/odata-core/src/main/java/org/apache/olingo/odata2/core/edm/provider/EdmTypedImplProv.java
@@ -0,0 +1,70 @@
+/*******************************************************************************
+ * 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.odata2.core.edm.provider;
+
+import org.apache.olingo.odata2.api.edm.EdmException;
+import org.apache.olingo.odata2.api.edm.EdmMultiplicity;
+import org.apache.olingo.odata2.api.edm.EdmSimpleType;
+import org.apache.olingo.odata2.api.edm.EdmSimpleTypeKind;
+import org.apache.olingo.odata2.api.edm.EdmType;
+import org.apache.olingo.odata2.api.edm.EdmTyped;
+import org.apache.olingo.odata2.api.edm.FullQualifiedName;
+import org.apache.olingo.odata2.core.edm.EdmSimpleTypeFacadeImpl;
+
+/**
+ * @author SAP AG
+ */
+public class EdmTypedImplProv extends EdmNamedImplProv implements EdmTyped {
+
+  protected EdmType edmType;
+  private FullQualifiedName typeName;
+  private EdmMultiplicity multiplicity;
+
+  public EdmTypedImplProv(final EdmImplProv edm, final String name, final FullQualifiedName typeName, final EdmMultiplicity multiplicity) throws EdmException {
+    super(edm, name);
+    this.typeName = typeName;
+    this.multiplicity = multiplicity;
+  }
+
+  @Override
+  public EdmType getType() throws EdmException {
+    if (edmType == null) {
+      final String namespace = typeName.getNamespace();
+      if (EdmSimpleType.EDM_NAMESPACE.equals(typeName.getNamespace())) {
+        edmType = EdmSimpleTypeFacadeImpl.getEdmSimpleType(EdmSimpleTypeKind.valueOf(typeName.getName()));
+      } else {
+        edmType = edm.getComplexType(namespace, typeName.getName());
+      }
+      if (edmType == null) {
+        edmType = edm.getEntityType(namespace, typeName.getName());
+      }
+
+      if (edmType == null) {
+        throw new EdmException(EdmException.COMMON);
+      }
+
+    }
+    return edmType;
+  }
+
+  @Override
+  public EdmMultiplicity getMultiplicity() throws EdmException {
+    return multiplicity;
+  }
+}