olingo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chri...@apache.org
Subject olingo-odata4 git commit: [OLINGO-575] Finish Edm Refactoring
Date Mon, 30 Mar 2015 13:15:14 GMT
Repository: olingo-odata4
Updated Branches:
  refs/heads/master af1417b3c -> 62f100148


[OLINGO-575] Finish Edm Refactoring


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

Branch: refs/heads/master
Commit: 62f100148a9dd8c7389c0ced8e9dd08e8f687515
Parents: af1417b
Author: Christian Amend <chrisam@apache.org>
Authored: Mon Mar 30 15:14:40 2015 +0200
Committer: Christian Amend <chrisam@apache.org>
Committed: Mon Mar 30 15:14:40 2015 +0200

----------------------------------------------------------------------
 .../olingo/ext/pojogen/AbstractPOJOGenMojo.java |  53 +++---
 .../ext/pojogen/NavPropertyBindingDetails.java  |  51 +++---
 .../org/apache/olingo/commons/api/edm/Edm.java  |   9 +
 .../olingo/commons/api/edm/EdmSchema.java       |  18 --
 .../olingo/commons/core/edm/AbstractEdm.java    | 166 +++++++++----------
 .../core/edm/provider/EdmAnnotationsImpl.java   |  38 +++--
 .../core/edm/provider/EdmProviderImpl.java      |   6 +-
 .../core/edm/provider/EdmSchemaImpl.java        | 126 +++++++-------
 8 files changed, 225 insertions(+), 242 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/62f10014/ext/pojogen-maven-plugin/src/main/java/org/apache/olingo/ext/pojogen/AbstractPOJOGenMojo.java
----------------------------------------------------------------------
diff --git a/ext/pojogen-maven-plugin/src/main/java/org/apache/olingo/ext/pojogen/AbstractPOJOGenMojo.java
b/ext/pojogen-maven-plugin/src/main/java/org/apache/olingo/ext/pojogen/AbstractPOJOGenMojo.java
index 5caeafb..9321c64 100644
--- a/ext/pojogen-maven-plugin/src/main/java/org/apache/olingo/ext/pojogen/AbstractPOJOGenMojo.java
+++ b/ext/pojogen-maven-plugin/src/main/java/org/apache/olingo/ext/pojogen/AbstractPOJOGenMojo.java
@@ -1,18 +1,18 @@
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
+ * or more contributor license agreements. See the NOTICE file
  * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
+ * 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
- *
+ * 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
+ * KIND, either express or implied. See the License for the
  * specific language governing permissions and limitations
  * under the License.
  */
@@ -112,12 +112,12 @@ public abstract class AbstractPOJOGenMojo extends AbstractMojo {
 
   protected File mkPkgDir(final String path) {
     return StringUtils.isBlank(basePackage)
-            ? mkdir(path)
-            : mkdir(basePackage.replace('.', File.separatorChar) + File.separator + path);
+        ? mkdir(path)
+        : mkdir(basePackage.replace('.', File.separatorChar) + File.separator + path);
   }
 
   protected void writeFile(final String name, final File path, final VelocityContext ctx,
final Template template,
-          final boolean append) throws MojoExecutionException {
+      final boolean append) throws MojoExecutionException {
 
     if (!path.exists()) {
       throw new IllegalArgumentException("Invalid base path '" + path.getAbsolutePath() +
"'");
@@ -152,30 +152,30 @@ public abstract class AbstractPOJOGenMojo extends AbstractMojo {
   }
 
   protected void parseObj(final File base, final String pkg, final String name, final String
out)
-          throws MojoExecutionException {
+      throws MojoExecutionException {
 
-    parseObj(base, false, pkg, name, out, Collections.<String, Object>emptyMap());
+    parseObj(base, false, pkg, name, out, Collections.<String, Object> emptyMap());
   }
 
   protected void parseObj(
-          final File base,
-          final String pkg,
-          final String name,
-          final String out,
-          final Map<String, Object> objs)
-          throws MojoExecutionException {
+      final File base,
+      final String pkg,
+      final String name,
+      final String out,
+      final Map<String, Object> objs)
+      throws MojoExecutionException {
 
     parseObj(base, false, pkg, name, out, objs);
   }
 
   protected void parseObj(
-          final File base,
-          final boolean append,
-          final String pkg,
-          final String name,
-          final String out,
-          final Map<String, Object> objs)
-          throws MojoExecutionException {
+      final File base,
+      final boolean append,
+      final String pkg,
+      final String name,
+      final String out,
+      final Map<String, Object> objs)
+      throws MojoExecutionException {
 
     final VelocityContext ctx = newContext();
     ctx.put("package", pkg);
@@ -351,7 +351,8 @@ public abstract class AbstractPOJOGenMojo extends AbstractMojo {
         }
 
         // write container and top entity sets into the base package
-        for (EdmEntityContainer container : schema.getEntityContainers()) {
+        EdmEntityContainer container = schema.getEntityContainer();
+        if(container != null){
           objs.clear();
           objs.put("container", container);
           objs.put("namespace", schema.getNamespace());

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/62f10014/ext/pojogen-maven-plugin/src/main/java/org/apache/olingo/ext/pojogen/NavPropertyBindingDetails.java
----------------------------------------------------------------------
diff --git a/ext/pojogen-maven-plugin/src/main/java/org/apache/olingo/ext/pojogen/NavPropertyBindingDetails.java
b/ext/pojogen-maven-plugin/src/main/java/org/apache/olingo/ext/pojogen/NavPropertyBindingDetails.java
index 48bf288..75f2105 100644
--- a/ext/pojogen-maven-plugin/src/main/java/org/apache/olingo/ext/pojogen/NavPropertyBindingDetails.java
+++ b/ext/pojogen-maven-plugin/src/main/java/org/apache/olingo/ext/pojogen/NavPropertyBindingDetails.java
@@ -60,21 +60,19 @@ public class NavPropertyBindingDetails {
   }
 
   private EdmBindingTarget getNavigationBindingDetails(final EdmStructuredType type) {
-    for (EdmSchema sc : edm.getSchemas()) {
-      for (EdmEntityContainer c : sc.getEntityContainers()) {
-        for (EdmEntitySet es : c.getEntitySets()) {
-          if (es.getEntityType().getFullQualifiedName().equals(type.getFullQualifiedName()))
{
-            return es;
-          }
+    EdmEntityContainer c = edm.getEntityContainer();
+    if (c != null) {
+      for (EdmEntitySet es : c.getEntitySets()) {
+        if (es.getEntityType().getFullQualifiedName().equals(type.getFullQualifiedName()))
{
+          return es;
         }
+      }
 
-        for (EdmSingleton s : c.getSingletons()) {
-          if (s.getEntityType().getFullQualifiedName().equals(type.getFullQualifiedName()))
{
-            return s;
-          }
+      for (EdmSingleton s : c.getSingletons()) {
+        if (s.getEntityType().getFullQualifiedName().equals(type.getFullQualifiedName()))
{
+          return s;
         }
       }
-
     }
 
     throw new IllegalStateException("EntitySet for '" + type.getName() + "' not found");
@@ -83,26 +81,25 @@ public class NavPropertyBindingDetails {
   private EdmBindingTarget getNavigationBindingDetails(
       final EdmStructuredType sourceType, final EdmNavigationProperty property) {
 
-    for (EdmSchema sc : edm.getSchemas()) {
-      for (EdmEntityContainer c : sc.getEntityContainers()) {
-        for (EdmEntitySet es : c.getEntitySets()) {
-          if (es.getEntityType().getFullQualifiedName().equals(sourceType.getFullQualifiedName()))
{
-            for (EdmNavigationPropertyBinding binding : es.getNavigationPropertyBindings())
{
-              if (binding.getPath().equals(property.getName())
-                  || binding.getPath().endsWith("/" + property.getName())) {
-                return es.getRelatedBindingTarget(binding.getPath());
-              }
+    EdmEntityContainer c = edm.getEntityContainer();
+    if (c != null) {
+      for (EdmEntitySet es : c.getEntitySets()) {
+        if (es.getEntityType().getFullQualifiedName().equals(sourceType.getFullQualifiedName()))
{
+          for (EdmNavigationPropertyBinding binding : es.getNavigationPropertyBindings())
{
+            if (binding.getPath().equals(property.getName())
+                || binding.getPath().endsWith("/" + property.getName())) {
+              return es.getRelatedBindingTarget(binding.getPath());
             }
           }
         }
+      }
 
-        for (EdmSingleton s : c.getSingletons()) {
-          if (s.getEntityType().getFullQualifiedName().equals(sourceType.getFullQualifiedName()))
{
-            for (EdmNavigationPropertyBinding binding : s.getNavigationPropertyBindings())
{
-              if (binding.getPath().equals(property.getName())
-                  || binding.getPath().endsWith("/" + property.getName())) {
-                return s.getRelatedBindingTarget(binding.getPath());
-              }
+      for (EdmSingleton s : c.getSingletons()) {
+        if (s.getEntityType().getFullQualifiedName().equals(sourceType.getFullQualifiedName()))
{
+          for (EdmNavigationPropertyBinding binding : s.getNavigationPropertyBindings())
{
+            if (binding.getPath().equals(property.getName())
+                || binding.getPath().endsWith("/" + property.getName())) {
+              return s.getRelatedBindingTarget(binding.getPath());
             }
           }
         }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/62f10014/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/Edm.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/Edm.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/Edm.java
index 8790afb..7b9376a 100644
--- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/Edm.java
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/Edm.java
@@ -43,6 +43,15 @@ public interface Edm {
   EdmSchema getSchema(String namespace);
 
   /**
+   * Get main entity container.
+   * <br/>
+   * See {@link EdmEntityContainer} for more information.
+   * 
+   * @return {@link EdmEntityContainer}
+   */
+  EdmEntityContainer getEntityContainer();
+  
+  /**
    * Get entity container by full qualified name.
    * <br/>
    * See {@link EdmEntityContainer} for more information.

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/62f10014/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmSchema.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmSchema.java
b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmSchema.java
index 1f4667c..837514e 100644
--- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmSchema.java
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmSchema.java
@@ -80,22 +80,4 @@ public interface EdmSchema extends EdmAnnotatable {
    */
   EdmEntityContainer getEntityContainer();
 
-  /**
-   * Returns the list of entity containers for this schema.
-   * <br/>
-   * According to CSDL specifications, this method will always return a singleton list for
OData 4.0, containing the
-   * same container as returned by {@link #getEntityContainer()}.
-   * 
-   * @return the list of entity containers for this schema; singleton list for OData 4.0
-   */
-  List<EdmEntityContainer> getEntityContainers();
-
-  /**
-   * Returns the entity container for the given name, or null if not found.
-   * 
-   * @param name entity container full qualified name
-   * @return the entity container for the given name, or null if not found
-   */
-  EdmEntityContainer getEntityContainer(FullQualifiedName name);
-
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/62f10014/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/AbstractEdm.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/AbstractEdm.java
b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/AbstractEdm.java
index bc0b304..e865aa6 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/AbstractEdm.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/AbstractEdm.java
@@ -79,13 +79,17 @@ public abstract class AbstractEdm implements Edm {
 
   @Override
   public List<EdmSchema> getSchemas() {
-    initSchemas();
+    if (schemaList == null) {
+      initSchemas();
+    }
     return schemaList;
   }
 
   @Override
   public EdmSchema getSchema(final String namespace) {
-    initSchemas();
+    if (schemas == null) {
+      initSchemas();
+    }
 
     EdmSchema schema = schemas.get(namespace);
     if (schema == null) {
@@ -99,94 +103,20 @@ public abstract class AbstractEdm implements Edm {
   }
 
   private void initSchemas() {
+    aliasToNamespaceInfo = new HashMap<String, String>();
+    schemas = createSchemas();
     if (schemas == null) {
-      schemas = createSchemas();
-      if (schemas != null) {
-        schemaList = Collections.unmodifiableList(new ArrayList<EdmSchema>(schemas.values()));
-        aliasToNamespaceInfo = new HashMap<String, String>();
-        for (EdmSchema schema : schemas.values()) {
-          final String namespace = schema.getNamespace();
-
-          if (schema.getAlias() != null) {
-            aliasToNamespaceInfo.put(schema.getAlias(), namespace);
-          }
-
-          final List<EdmEnumType> localEnumTypes = schema.getEnumTypes();
-          if (localEnumTypes != null) {
-            for (EdmEnumType enumType : localEnumTypes) {
-              enumTypes.put(new FullQualifiedName(namespace, enumType.getName()), enumType);
-            }
-          }
-
-          final List<EdmTypeDefinition> localTypeDefinitions = schema.getTypeDefinitions();
-          if (localTypeDefinitions != null) {
-            for (EdmTypeDefinition typeDef : localTypeDefinitions) {
-              typeDefinitions.put(new FullQualifiedName(namespace, typeDef.getName()), typeDef);
-            }
-          }
-
-          final List<EdmComplexType> localComplexTypes = schema.getComplexTypes();
-          if (localComplexTypes != null) {
-            for (EdmComplexType complexType : localComplexTypes) {
-              complexTypes.put(new FullQualifiedName(namespace, complexType.getName()), complexType);
-            }
-          }
-
-          List<EdmEntityType> localEntityTypes = schema.getEntityTypes();
-          if (localEntityTypes != null) {
-            for (EdmEntityType entityType : localEntityTypes) {
-              entityTypes.put(new FullQualifiedName(namespace, entityType.getName()), entityType);
-            }
-          }
-
-          final List<EdmAction> localActions = schema.getActions();
-          if (localActions != null) {
-            for (EdmAction action : localActions) {
-              final FullQualifiedName name = new FullQualifiedName(namespace, action.getName());
-              if (action.isBound()) {
-                final ActionMapKey key = new ActionMapKey(name,
-                    action.getBindingParameterTypeFqn(), action.isBindingParameterTypeCollection());
-                boundActions.put(key, action);
-              } else {
-                unboundActions.put(name, action);
-              }
-            }
-          }
-
-          final List<EdmFunction> localFunctions = schema.getFunctions();
-          if (localFunctions != null) {
-            for (EdmFunction function : localFunctions) {
-              final FullQualifiedName name = new FullQualifiedName(namespace, function.getName());
-              final FunctionMapKey key = new FunctionMapKey(name,
-                  function.getBindingParameterTypeFqn(), function.isBindingParameterTypeCollection(),
-                  function.getParameterNames());
-
-              if (function.isBound()) {
-                boundFunctions.put(key, function);
-              } else {
-                if (!unboundFunctionsByName.containsKey(name)) {
-                  unboundFunctionsByName.put(name, new ArrayList<EdmFunction>());
-                }
-                unboundFunctionsByName.get(name).add(function);
-
-                unboundFunctionsByKey.put(key, function);
-              }
-            }
-          }
-
-          final EdmEntityContainer entityContainer = schema.getEntityContainer();
-          if (entityContainer != null) {
-            entityContainers.put(new FullQualifiedName(namespace, entityContainer.getName()),
entityContainer);
-            if (!entityContainers.containsKey(null)) {
-              entityContainers.put(null, entityContainer);
-            }
-          }
-        }
-      }
+      schemas = Collections.emptyMap();
     }
+    schemaList = Collections.unmodifiableList(new ArrayList<EdmSchema>(schemas.values()));
   }
 
   @Override
+  public EdmEntityContainer getEntityContainer() {
+    return getEntityContainer(null);
+  }
+  
+  @Override
   public EdmEntityContainer getEntityContainer(final FullQualifiedName namespaceOrAliasFQN)
{
     final FullQualifiedName fqn = resolvePossibleAlias(namespaceOrAliasFQN);
     EdmEntityContainer container = entityContainers.get(fqn);
@@ -419,16 +349,43 @@ public abstract class AbstractEdm implements Edm {
 
   protected abstract Map<String, String> createAliasToNamespaceInfo();
 
+  public void cacheAliasNamespaceInfo(String alias, String namespace) {
+    if (aliasToNamespaceInfo == null) {
+      aliasToNamespaceInfo = new HashMap<String, String>();
+    }
+    aliasToNamespaceInfo.put(alias, namespace);
+  }
+
   protected abstract EdmEntityContainer createEntityContainer(FullQualifiedName containerName);
 
+  public void cacheEntityContainer(FullQualifiedName containerFQN, EdmEntityContainer container)
{
+    entityContainers.put(containerFQN, container);
+  }
+
   protected abstract EdmEnumType createEnumType(FullQualifiedName enumName);
 
+  public void cacheEnumType(FullQualifiedName enumName, EdmEnumType enumType) {
+    enumTypes.put(enumName, enumType);
+  }
+
   protected abstract EdmTypeDefinition createTypeDefinition(FullQualifiedName typeDefinitionName);
 
+  public void cacheTypeDefinition(FullQualifiedName typeDefName, EdmTypeDefinition typeDef)
{
+    typeDefinitions.put(typeDefName, typeDef);
+  }
+
   protected abstract EdmEntityType createEntityType(FullQualifiedName entityTypeName);
 
+  public void cacheEntityType(FullQualifiedName entityTypeName, EdmEntityType entityType)
{
+    entityTypes.put(entityTypeName, entityType);
+  }
+
   protected abstract EdmComplexType createComplexType(FullQualifiedName complexTypeName);
 
+  public void cacheComplexType(FullQualifiedName compelxTypeName, EdmComplexType complexType)
{
+    complexTypes.put(compelxTypeName, complexType);
+  }
+
   protected abstract EdmAction createUnboundAction(FullQualifiedName actionName);
 
   protected abstract List<EdmFunction> createUnboundFunctions(FullQualifiedName functionName);
@@ -443,9 +400,48 @@ public abstract class AbstractEdm implements Edm {
       FullQualifiedName bindingParameterTypeName, Boolean isBindingParameterCollection,
       List<String> parameterNames);
 
+  public void cacheFunction(FullQualifiedName functionName, EdmFunction function) {
+    final FunctionMapKey key = new FunctionMapKey(functionName,
+        function.getBindingParameterTypeFqn(), function.isBindingParameterTypeCollection(),
+        function.getParameterNames());
+
+    if (function.isBound()) {
+      boundFunctions.put(key, function);
+    } else {
+      if (!unboundFunctionsByName.containsKey(functionName)) {
+        unboundFunctionsByName.put(functionName, new ArrayList<EdmFunction>());
+      }
+      unboundFunctionsByName.get(functionName).add(function);
+
+      unboundFunctionsByKey.put(key, function);
+    }
+  }
+
+  public void cacheAction(FullQualifiedName actionName, EdmAction action) {
+    if (action.isBound()) {
+      final ActionMapKey key = new ActionMapKey(actionName,
+          action.getBindingParameterTypeFqn(), action.isBindingParameterTypeCollection());
+      boundActions.put(key, action);
+    } else {
+      unboundActions.put(actionName, action);
+    }
+  }
+
   protected abstract EdmTerm createTerm(FullQualifiedName termName);
+  
+  public void cacheTerm(FullQualifiedName termName, EdmTerm term) {
+    terms.put(termName, term);
+  }
 
   protected abstract EdmAnnotations createAnnotationGroup(FullQualifiedName targetName);
+ 
+  public void cacheAnnotationGroup(FullQualifiedName annotationsGroupName, EdmAnnotations
annotationsGroup) {
+    annotationGroups.put(annotationsGroupName, annotationsGroup);
+  }
 
   protected abstract List<EdmAnnotation> createAnnotations(FullQualifiedName annotatedName);
+  
+//  public void cacheAnnotation(FullQualifiedName annotationsGroupName, EdmAnnotations annotationsGroup)
{
+//    annotationGroups.put(annotationsGroupName, annotationsGroup);
+//  }
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/62f10014/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmAnnotationsImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmAnnotationsImpl.java
b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmAnnotationsImpl.java
index a779bf1..4de911c 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmAnnotationsImpl.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmAnnotationsImpl.java
@@ -1,18 +1,18 @@
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
+ * or more contributor license agreements. See the NOTICE file
  * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
+ * 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
- *
+ * 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
+ * KIND, either express or implied. See the License for the
  * specific language governing permissions and limitations
  * under the License.
  */
@@ -54,8 +54,8 @@ public class EdmAnnotationsImpl implements EdmAnnotations {
     EdmAnnotationsTarget _target = null;
     if (structured != null) {
       _target = path == null
-              ? structured
-              : structured.getStructuralProperty(path);
+          ? structured
+          : structured.getStructuralProperty(path);
       if (_target == null) {
         _target = structured.getNavigationProperty(path);
       }
@@ -67,8 +67,8 @@ public class EdmAnnotationsImpl implements EdmAnnotations {
     EdmAnnotationsTarget _target = null;
     if (enumType != null) {
       _target = path == null
-              ? enumType
-              : enumType.getMember(path);
+          ? enumType
+          : enumType.getMember(path);
     }
     return _target;
   }
@@ -80,23 +80,25 @@ public class EdmAnnotationsImpl implements EdmAnnotations {
       final FullQualifiedName base = new FullQualifiedName(splitted[0]);
       final String path = splitted.length > 1 ? splitted[1] : null;
 
-      final EdmEntityContainer baseEntityContainer = schema.getEntityContainer(base);
-      
-      target = baseEntityContainer == null? null: baseEntityContainer.getActionImport(path);
+      final EdmEntityContainer baseEntityContainer = schema.getEntityContainer();
+
+      target = baseEntityContainer == null ? null : baseEntityContainer.getActionImport(path);
       if (target == null) {
         target = getTarget(edm.getComplexType(base), path);
         if (target == null) {
-          target = baseEntityContainer;
+          if(baseEntityContainer != null && baseEntityContainer.getFullQualifiedName().equals(base)){
+            target = baseEntityContainer;
+          }
           if (target == null) {
-            target = baseEntityContainer == null? null: baseEntityContainer.getEntitySet(path);
+            target = baseEntityContainer == null ? null : baseEntityContainer.getEntitySet(path);
             if (target == null) {
               target = getTarget(edm.getEntityType(base), path);
               if (target == null) {
                 target = getTarget(edm.getEnumType(base), path);
                 if (target == null) {
-                  target = baseEntityContainer == null? null: baseEntityContainer.getFunctionImport(path);
+                  target = baseEntityContainer == null ? null : baseEntityContainer.getFunctionImport(path);
                   if (target == null) {
-                    target = baseEntityContainer == null? null: baseEntityContainer.getSingleton(path);
+                    target = baseEntityContainer == null ? null : baseEntityContainer.getSingleton(path);
                     if (target == null) {
                       target = edm.getTerm(base);
                       if (target == null) {

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/62f10014/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmProviderImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmProviderImpl.java
b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmProviderImpl.java
index 3da0536..daa0e87 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmProviderImpl.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmProviderImpl.java
@@ -317,11 +317,11 @@ public class EdmProviderImpl extends AbstractEdm {
   @Override
   protected Map<String, EdmSchema> createSchemas() {
     try {
-      final Map<String, EdmSchema> _schemas = new LinkedHashMap<String, EdmSchema>();
+      final Map<String, EdmSchema> providerSchemas = new LinkedHashMap<String, EdmSchema>();
       for (Schema schema : provider.getSchemas()) {
-        _schemas.put(schema.getNamespace(), new EdmSchemaImpl(this, provider, schema));
+        providerSchemas.put(schema.getNamespace(), new EdmSchemaImpl(this, provider, schema));
       }
-      return _schemas;
+      return providerSchemas;
     } catch (ODataException e) {
       throw new EdmException(e);
     }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/62f10014/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmSchemaImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmSchemaImpl.java
b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmSchemaImpl.java
index 7e09b2d..ea44dc6 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmSchemaImpl.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmSchemaImpl.java
@@ -22,7 +22,6 @@ import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
 
-import org.apache.olingo.commons.api.edm.Edm;
 import org.apache.olingo.commons.api.edm.EdmAction;
 import org.apache.olingo.commons.api.edm.EdmAnnotation;
 import org.apache.olingo.commons.api.edm.EdmAnnotations;
@@ -50,7 +49,7 @@ import org.apache.olingo.commons.api.edm.provider.TypeDefinition;
 public class EdmSchemaImpl implements EdmSchema {
 
   private final Schema schema;
-  private final Edm edm;
+  private final EdmProviderImpl edm;
   private final EdmProvider provider;
 
   protected final String namespace;
@@ -66,115 +65,81 @@ public class EdmSchemaImpl implements EdmSchema {
   private List<EdmAnnotation> annotations;
   private EdmEntityContainer entityContainer;
 
-  public EdmSchemaImpl(final Edm edm, final EdmProvider provider, final Schema schema) {
+  public EdmSchemaImpl(final EdmProviderImpl edm, final EdmProvider provider, final Schema
schema) {
     this.edm = edm;
     this.provider = provider;
     this.schema = schema;
     this.namespace = schema.getNamespace();
     this.alias = schema.getAlias();
+
+    if (alias != null) {
+      edm.cacheAliasNamespaceInfo(alias, namespace);
+    }
+
+    enumTypes = createEnumTypes();
+    typeDefinitions = createTypeDefinitions();
+    entityTypes = createEntityTypes();
+    complexTypes = createComplexTypes();
+    actions = createActions();
+    functions = createFunctions();
+    entityContainer = createEntityContainer();
+    annotationGroups = createAnnotationGroups();
+    annotations = createAnnotations();
+    terms = createTerms();
+
   }
 
   @Override
   public List<EdmEnumType> getEnumTypes() {
-    if (enumTypes == null) {
-      enumTypes = createEnumTypes();
-    }
     return Collections.unmodifiableList(enumTypes);
   }
 
   @Override
   public List<EdmEntityType> getEntityTypes() {
-    if (entityTypes == null) {
-      entityTypes = createEntityTypes();
-    }
     return Collections.unmodifiableList(entityTypes);
   }
 
   @Override
   public List<EdmComplexType> getComplexTypes() {
-    if (complexTypes == null) {
-      complexTypes = createComplexTypes();
-    }
     return Collections.unmodifiableList(complexTypes);
   }
 
   @Override
   public List<EdmAction> getActions() {
-    if (actions == null) {
-      actions = createActions();
-    }
     return Collections.unmodifiableList(actions);
   }
 
   @Override
   public List<EdmFunction> getFunctions() {
-    if (functions == null) {
-      functions = createFunctions();
-    }
     return Collections.unmodifiableList(functions);
   }
 
   @Override
   public List<EdmTypeDefinition> getTypeDefinitions() {
-    if (typeDefinitions == null) {
-      typeDefinitions = createTypeDefinitions();
-    }
     return Collections.unmodifiableList(typeDefinitions);
   }
 
   @Override
   public List<EdmTerm> getTerms() {
-    if (terms == null) {
-      terms = createTerms();
-    }
     return Collections.unmodifiableList(terms);
   }
 
   @Override
   public List<EdmAnnotations> getAnnotationGroups() {
-    if (annotationGroups == null) {
-      annotationGroups = createAnnotationGroups();
-    }
     return Collections.unmodifiableList(annotationGroups);
   }
 
   @Override
   public List<EdmAnnotation> getAnnotations() {
-    if (annotations == null) {
-      annotations = createAnnotations();
-    }
     return Collections.unmodifiableList(annotations);
   }
 
   @Override
   public EdmEntityContainer getEntityContainer() {
-    if (entityContainer == null) {
-      entityContainer = createEntityContainer();
-    }
     return entityContainer;
   }
 
   @Override
-  public List<EdmEntityContainer> getEntityContainers() {
-    if (getEntityContainer() == null) {
-      return Collections.<EdmEntityContainer> emptyList();
-    } else {
-      return Collections.unmodifiableList(Collections.singletonList(getEntityContainer()));
-    }
-  }
-
-  @Override
-  public EdmEntityContainer getEntityContainer(final FullQualifiedName name) {
-    return getEntityContainer() == null
-        ? null
-        : name == null
-            ? getEntityContainer()
-            : name.equals(getEntityContainer().getFullQualifiedName())
-                ? getEntityContainer()
-                : null;
-  }
-
-  @Override
   public String getNamespace() {
     return namespace;
   }
@@ -187,7 +152,10 @@ public class EdmSchemaImpl implements EdmSchema {
   protected EdmEntityContainer createEntityContainer() {
     if (schema.getEntityContainer() != null) {
       FullQualifiedName containerFQN = new FullQualifiedName(namespace, schema.getEntityContainer().getName());
-      return new EdmEntityContainerImpl(edm, provider, containerFQN, schema.getEntityContainer());
+      EdmEntityContainer impl = new EdmEntityContainerImpl(edm, provider, containerFQN, schema.getEntityContainer());
+      edm.cacheEntityContainer(containerFQN, impl);
+      edm.cacheEntityContainer(null, impl);
+      return impl;
     }
     return null;
   }
@@ -197,7 +165,10 @@ public class EdmSchemaImpl implements EdmSchema {
     final List<TypeDefinition> providerTypeDefinitions = schema.getTypeDefinitions();
     if (providerTypeDefinitions != null) {
       for (TypeDefinition def : providerTypeDefinitions) {
-        typeDefinitions.add(new EdmTypeDefinitionImpl(edm, new FullQualifiedName(namespace,
def.getName()), def));
+        FullQualifiedName typeDefName = new FullQualifiedName(namespace, def.getName());
+        EdmTypeDefinitionImpl typeDefImpl = new EdmTypeDefinitionImpl(edm, typeDefName, def);
+        typeDefinitions.add(typeDefImpl);
+        edm.cacheTypeDefinition(typeDefName, typeDefImpl);
       }
     }
     return typeDefinitions;
@@ -208,7 +179,10 @@ public class EdmSchemaImpl implements EdmSchema {
     final List<EnumType> providerEnumTypes = schema.getEnumTypes();
     if (providerEnumTypes != null) {
       for (EnumType enumType : providerEnumTypes) {
-        enumTypes.add(new EdmEnumTypeImpl(edm, new FullQualifiedName(namespace, enumType.getName()),
enumType));
+        FullQualifiedName enumName = new FullQualifiedName(namespace, enumType.getName());
+        EdmEnumType enumTypeImpl = new EdmEnumTypeImpl(edm, enumName, enumType);
+        enumTypes.add(enumTypeImpl);
+        edm.cacheEnumType(enumName, enumTypeImpl);
       }
     }
     return enumTypes;
@@ -219,8 +193,10 @@ public class EdmSchemaImpl implements EdmSchema {
     final List<EntityType> providerEntityTypes = schema.getEntityTypes();
     if (providerEntityTypes != null) {
       for (EntityType entityType : providerEntityTypes) {
-        entityTypes.add(new EdmEntityTypeImpl(edm, new FullQualifiedName(namespace, entityType.getName()),
-            entityType));
+        FullQualifiedName entityTypeName = new FullQualifiedName(namespace, entityType.getName());
+        EdmEntityTypeImpl entityTypeImpl = new EdmEntityTypeImpl(edm, entityTypeName, entityType);
+        entityTypes.add(entityTypeImpl);
+        edm.cacheEntityType(entityTypeName, entityTypeImpl);
       }
     }
     return entityTypes;
@@ -231,8 +207,10 @@ public class EdmSchemaImpl implements EdmSchema {
     final List<ComplexType> providerComplexTypes = schema.getComplexTypes();
     if (providerComplexTypes != null) {
       for (ComplexType complexType : providerComplexTypes) {
-        complexTypes.add(new EdmComplexTypeImpl(edm, new FullQualifiedName(namespace, complexType.getName()),
-            complexType));
+        FullQualifiedName comlexTypeName = new FullQualifiedName(namespace, complexType.getName());
+        EdmComplexTypeImpl complexTypeImpl = new EdmComplexTypeImpl(edm, comlexTypeName,
complexType);
+        complexTypes.add(complexTypeImpl);
+        edm.cacheComplexType(comlexTypeName, complexTypeImpl);
       }
     }
     return complexTypes;
@@ -243,7 +221,10 @@ public class EdmSchemaImpl implements EdmSchema {
     final List<Action> providerActions = schema.getActions();
     if (providerActions != null) {
       for (Action action : providerActions) {
-        actions.add(new EdmActionImpl(edm, new FullQualifiedName(namespace, action.getName()),
action));
+        FullQualifiedName actionName = new FullQualifiedName(namespace, action.getName());
+        EdmActionImpl edmActionImpl = new EdmActionImpl(edm, actionName, action);
+        actions.add(edmActionImpl);
+        edm.cacheAction(actionName, edmActionImpl);
       }
     }
     return actions;
@@ -254,7 +235,10 @@ public class EdmSchemaImpl implements EdmSchema {
     final List<Function> providerFunctions = schema.getFunctions();
     if (providerFunctions != null) {
       for (Function function : providerFunctions) {
-        functions.add(new EdmFunctionImpl(edm, new FullQualifiedName(namespace, function.getName()),
function));
+        FullQualifiedName functionName = new FullQualifiedName(namespace, function.getName());
+        EdmFunctionImpl functionImpl = new EdmFunctionImpl(edm, functionName, function);
+        functions.add(functionImpl);
+        edm.cacheFunction(functionName, functionImpl);
       }
     }
     return functions;
@@ -265,7 +249,10 @@ public class EdmSchemaImpl implements EdmSchema {
     final List<Term> providerTerms = schema.getTerms();
     if (providerTerms != null) {
       for (Term term : providerTerms) {
-        terms.add(new EdmTermImpl(edm, getNamespace(), term));
+        FullQualifiedName termName = new FullQualifiedName(namespace, term.getName());
+        EdmTermImpl termImpl = new EdmTermImpl(edm, getNamespace(), term);
+        terms.add(termImpl);
+        edm.cacheTerm(termName, termImpl);
       }
     }
     return terms;
@@ -277,7 +264,15 @@ public class EdmSchemaImpl implements EdmSchema {
         schema.getAnnotationGroups();
     if (providerAnnotations != null) {
       for (Annotations annotationGroup : providerAnnotations) {
-        annotationGroups.add(new EdmAnnotationsImpl(edm, this, annotationGroup));
+        FullQualifiedName annotationsGroupName;
+        if (annotationGroup.getTarget().contains(".")) {
+          annotationsGroupName = new FullQualifiedName(annotationGroup.getTarget());
+        } else {
+          annotationsGroupName = new FullQualifiedName(namespace, annotationGroup.getTarget());
+        }
+        EdmAnnotationsImpl annotationsImpl = new EdmAnnotationsImpl(edm, this, annotationGroup);
+        annotationGroups.add(annotationsImpl);
+        edm.cacheAnnotationGroup(annotationsGroupName, annotationsImpl);
       }
     }
     return annotationGroups;
@@ -289,7 +284,8 @@ public class EdmSchemaImpl implements EdmSchema {
         schema.getAnnotations();
     if (providerAnnotations != null) {
       for (Annotation annotation : providerAnnotations) {
-        annotations.add(new EdmAnnotationImpl(edm, annotation));
+        EdmAnnotationImpl annotationImpl = new EdmAnnotationImpl(edm, annotation);
+        annotations.add(annotationImpl);
       }
     }
     return annotations;


Mime
View raw message