You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@olingo.apache.org by ch...@apache.org on 2013/12/15 18:11:42 UTC

git commit: [OLINGO-75] Support New Edm Annotations along with Deprecated Annotations for Function Imports

Updated Branches:
  refs/heads/master eaacc2b96 -> 094740171


[OLINGO-75] Support New Edm Annotations along with Deprecated
Annotations for Function Imports

Project: http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/commit/09474017
Tree: http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/tree/09474017
Diff: http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/diff/09474017

Branch: refs/heads/master
Commit: 094740171d0cecc5bfd58fe9f5f7225f3db8131d
Parents: eaacc2b
Author: Chandan V A <ch...@sap.com>
Authored: Sun Dec 15 22:39:50 2013 +0530
Committer: Chandan V A <ch...@sap.com>
Committed: Sun Dec 15 22:39:50 2013 +0530

----------------------------------------------------------------------
 .../core/jpa/access/model/JPATypeConvertor.java |   4 +-
 .../core/jpa/model/JPAEdmFunctionImport.java    |  84 +--
 .../jpa/model/_JPAEdmFunctionImportBuilder.java | 237 ++++++++
 .../jpa/mock/model/JPACustomProcessorMock.java  |  46 +-
 .../model/JPACustomProcessorNegativeMock.java   |  69 ---
 .../jpa/mock/model/_JPACustomProcessorMock.java |  77 +++
 .../model/_JPACustomProcessorNegativeMock.java  |  70 +++
 .../jpa/model/JPAEdmFunctionImportTest.java     |  27 +-
 .../jpa/model/_JPAEdmFunctionImportTest.java    | 570 +++++++++++++++++++
 .../extension/SalesOrderHeaderProcessor.java    | 241 ++++----
 .../extension/_SalesOrderHeaderProcessor.java   | 127 +++++
 11 files changed, 1281 insertions(+), 271 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/09474017/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/access/model/JPATypeConvertor.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/access/model/JPATypeConvertor.java b/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/access/model/JPATypeConvertor.java
index 54d99ad..e7b8a6e 100644
--- a/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/access/model/JPATypeConvertor.java
+++ b/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/access/model/JPATypeConvertor.java
@@ -52,9 +52,9 @@ public class JPATypeConvertor {
    * 
    * @see EdmSimpleTypeKind
    */
-  
+
   private static final String OBJECT_TYPE = "java.lang.Object";
-  
+
   public static EdmSimpleTypeKind
       convertToEdmSimpleType(final Class<?> jpaType, final Attribute<?, ?> currentAttribute)
           throws ODataJPAModelException {

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/09474017/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmFunctionImport.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmFunctionImport.java b/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmFunctionImport.java
index 75b67a6..b64f61c 100644
--- a/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmFunctionImport.java
+++ b/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmFunctionImport.java
@@ -26,9 +26,9 @@ import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 
-import org.apache.olingo.odata2.api.annotation.edm.FunctionImport.Multiplicity;
-import org.apache.olingo.odata2.api.annotation.edm.FunctionImport.ReturnType;
-import org.apache.olingo.odata2.api.annotation.edm.Parameter;
+import org.apache.olingo.odata2.api.annotation.edm.EdmFunctionImport;
+import org.apache.olingo.odata2.api.annotation.edm.EdmFunctionImport.ReturnType;
+import org.apache.olingo.odata2.api.annotation.edm.EdmFunctionImportParameter;
 import org.apache.olingo.odata2.api.edm.EdmMultiplicity;
 import org.apache.olingo.odata2.api.edm.EdmSimpleTypeKind;
 import org.apache.olingo.odata2.api.edm.provider.ComplexType;
@@ -76,7 +76,10 @@ public class JPAEdmFunctionImport extends JPAEdmBaseViewImpl implements JPAEdmFu
 
     private JPAEdmEntityTypeView jpaEdmEntityTypeView = null;
     private JPAEdmComplexTypeView jpaEdmComplexTypeView = null;
+    @SuppressWarnings("deprecation")
+    private _JPAEdmFunctionImportBuilder builderDeprecated = new _JPAEdmFunctionImportBuilder();
 
+    @SuppressWarnings("deprecation")
     @Override
     public void build() throws ODataJPAModelException, ODataJPARuntimeException {
 
@@ -87,6 +90,10 @@ public class JPAEdmFunctionImport extends JPAEdmBaseViewImpl implements JPAEdmFu
       jpaEdmComplexTypeView = schemaView.getJPAEdmComplexTypeView();
 
       if (customOperations != null) {
+        // Initialize deprecated Builder
+        builderDeprecated.setJPAEdmComplexTypeView(jpaEdmComplexTypeView);
+        builderDeprecated.setJPAEdmEntityTypeView(jpaEdmEntityTypeView);
+        builderDeprecated.setSchemaView(schemaView);
 
         for (Class<?> clazz : customOperations.keySet()) {
 
@@ -135,17 +142,35 @@ public class JPAEdmFunctionImport extends JPAEdmBaseViewImpl implements JPAEdmFu
       }
     }
 
+    @SuppressWarnings("deprecation")
     private FunctionImport buildFunctionImport(final Method method) throws ODataJPAModelException {
 
+      EdmFunctionImport edmAnnotationFunctionImport = method.getAnnotation(EdmFunctionImport.class);
+      if (edmAnnotationFunctionImport != null && edmAnnotationFunctionImport.returnType() != null) {
+        return buildEdmFunctionImport(method, edmAnnotationFunctionImport);
+      }
+
       org.apache.olingo.odata2.api.annotation.edm.FunctionImport annotation =
           method.getAnnotation(org.apache.olingo.odata2.api.annotation.edm.FunctionImport.class);
-      if (annotation != null && annotation.returnType() != ReturnType.NONE) {
+
+      if (annotation != null) {
+        FunctionImport functionImport = builderDeprecated.buildFunctionImport(method, annotation);
+
+        return functionImport;
+      }
+      return null;
+    }
+
+    private FunctionImport buildEdmFunctionImport(final Method method,
+        final EdmFunctionImport edmAnnotationFunctionImport)
+        throws ODataJPAModelException {
+      if (edmAnnotationFunctionImport != null && edmAnnotationFunctionImport.returnType() != null) {
         FunctionImport functionImport = new FunctionImport();
 
-        if (annotation.name().equals("")) {
+        if (edmAnnotationFunctionImport.name().equals("")) {
           functionImport.setName(method.getName());
         } else {
-          functionImport.setName(annotation.name());
+          functionImport.setName(edmAnnotationFunctionImport.name());
         }
 
         JPAEdmMapping mapping = new JPAEdmMappingImpl();
@@ -153,19 +178,18 @@ public class JPAEdmFunctionImport extends JPAEdmBaseViewImpl implements JPAEdmFu
         mapping.setJPAType(method.getDeclaringClass());
         functionImport.setMapping((Mapping) mapping);
 
-        functionImport.setHttpMethod(annotation.httpMethod().name().toString());
+        functionImport.setHttpMethod(edmAnnotationFunctionImport.httpMethod().name().toString());
 
-        buildReturnType(functionImport, method, annotation);
-        buildParameter(functionImport, method);
+        buildEdmReturnType(functionImport, method, edmAnnotationFunctionImport);
+        buildEdmParameter(functionImport, method);
 
         return functionImport;
       }
       return null;
     }
 
-    private void buildParameter(final FunctionImport functionImport, final Method method)
+    private void buildEdmParameter(final FunctionImport functionImport, final Method method)
         throws ODataJPAModelException {
-
       Annotation[][] annotations = method.getParameterAnnotations();
       Class<?>[] parameterTypes = method.getParameterTypes();
       List<FunctionImportParameter> funcImpList = new ArrayList<FunctionImportParameter>();
@@ -175,8 +199,8 @@ public class JPAEdmFunctionImport extends JPAEdmBaseViewImpl implements JPAEdmFu
         Class<?> parameterType = parameterTypes[j++];
 
         for (Annotation element : annotationArr) {
-          if (element instanceof Parameter) {
-            Parameter annotation = (Parameter) element;
+          if (element instanceof EdmFunctionImportParameter) {
+            EdmFunctionImportParameter annotation = (EdmFunctionImportParameter) element;
             FunctionImportParameter functionImportParameter = new FunctionImportParameter();
             if (annotation.name().equals("")) {
               throw ODataJPAModelException.throwException(ODataJPAModelException.FUNC_PARAM_NAME_EXP.addContent(method
@@ -186,7 +210,6 @@ public class JPAEdmFunctionImport extends JPAEdmBaseViewImpl implements JPAEdmFu
             }
 
             functionImportParameter.setType(JPATypeConvertor.convertToEdmSimpleType(parameterType, null));
-            functionImportParameter.setMode(annotation.mode().toString());
 
             Facets facets = new Facets();
             if (annotation.facets().maxLength() > 0) {
@@ -218,24 +241,22 @@ public class JPAEdmFunctionImport extends JPAEdmBaseViewImpl implements JPAEdmFu
       }
     }
 
-    private void buildReturnType(final FunctionImport functionImport, final Method method,
-        final org.apache.olingo.odata2.api.annotation.edm.FunctionImport annotation) throws ODataJPAModelException {
-      ReturnType returnType = annotation.returnType();
-      Multiplicity multiplicity = null;
+    private void buildEdmReturnType(final FunctionImport functionImport, final Method method,
+        final EdmFunctionImport edmAnnotationFunctionImport) throws ODataJPAModelException {
+      ReturnType returnType = edmAnnotationFunctionImport.returnType();
 
-      if (returnType != ReturnType.NONE) {
+      if (returnType != null) {
         org.apache.olingo.odata2.api.edm.provider.ReturnType functionReturnType =
             new org.apache.olingo.odata2.api.edm.provider.ReturnType();
-        multiplicity = annotation.multiplicity();
 
-        if (multiplicity == Multiplicity.MANY) {
+        if (returnType.isCollection()) {
           functionReturnType.setMultiplicity(EdmMultiplicity.MANY);
         } else {
           functionReturnType.setMultiplicity(EdmMultiplicity.ONE);
         }
 
-        if (returnType == ReturnType.ENTITY_TYPE) {
-          String entitySet = annotation.entitySet();
+        if (returnType.type() == ReturnType.Type.ENTITY) {
+          String entitySet = edmAnnotationFunctionImport.entitySet();
           if (entitySet.equals("")) {
             throw ODataJPAModelException.throwException(ODataJPAModelException.FUNC_ENTITYSET_EXP, null);
           }
@@ -247,12 +268,12 @@ public class JPAEdmFunctionImport extends JPAEdmBaseViewImpl implements JPAEdmFu
           throw ODataJPAModelException.throwException(ODataJPAModelException.FUNC_RETURN_TYPE_EXP.addContent(method
               .getDeclaringClass(), method.getName()), null);
         }
-        switch (returnType) {
-        case ENTITY_TYPE:
+        switch (returnType.type()) {
+        case ENTITY:
           EntityType edmEntityType = null;
-          if (multiplicity == Multiplicity.ONE) {
+          if (returnType.isCollection() == false) {
             edmEntityType = jpaEdmEntityTypeView.searchEdmEntityType(methodReturnType.getSimpleName());
-          } else if (multiplicity == Multiplicity.MANY) {
+          } else {
             edmEntityType = jpaEdmEntityTypeView.searchEdmEntityType(getReturnTypeSimpleName(method));
           }
 
@@ -262,17 +283,16 @@ public class JPAEdmFunctionImport extends JPAEdmBaseViewImpl implements JPAEdmFu
           }
           functionReturnType.setTypeName(JPAEdmNameBuilder.build(schemaView, edmEntityType.getName()));
           break;
-        case SCALAR:
-
+        case SIMPLE:
           EdmSimpleTypeKind edmSimpleTypeKind = JPATypeConvertor.convertToEdmSimpleType(methodReturnType, null);
           functionReturnType.setTypeName(edmSimpleTypeKind.getFullQualifiedName());
 
           break;
-        case COMPLEX_TYPE:
+        case COMPLEX:
           ComplexType complexType = null;
-          if (multiplicity == Multiplicity.ONE) {
+          if (returnType.isCollection() == false) {
             complexType = jpaEdmComplexTypeView.searchEdmComplexType(methodReturnType.getName());
-          } else if (multiplicity == Multiplicity.MANY) {
+          } else {
             complexType = jpaEdmComplexTypeView.searchEdmComplexType(getReturnTypeName(method));
           }
           if (complexType == null) {

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/09474017/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/_JPAEdmFunctionImportBuilder.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/_JPAEdmFunctionImportBuilder.java b/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/_JPAEdmFunctionImportBuilder.java
new file mode 100644
index 0000000..da8054c
--- /dev/null
+++ b/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/_JPAEdmFunctionImportBuilder.java
@@ -0,0 +1,237 @@
+/*******************************************************************************
+ * 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.processor.core.jpa.model;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Method;
+import java.lang.reflect.ParameterizedType;
+import java.lang.reflect.Type;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.olingo.odata2.api.annotation.edm.FunctionImport.Multiplicity;
+import org.apache.olingo.odata2.api.annotation.edm.FunctionImport.ReturnType;
+import org.apache.olingo.odata2.api.annotation.edm.Parameter;
+import org.apache.olingo.odata2.api.edm.EdmMultiplicity;
+import org.apache.olingo.odata2.api.edm.EdmSimpleTypeKind;
+import org.apache.olingo.odata2.api.edm.provider.ComplexType;
+import org.apache.olingo.odata2.api.edm.provider.EntityType;
+import org.apache.olingo.odata2.api.edm.provider.Facets;
+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.Mapping;
+import org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPAModelException;
+import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmComplexTypeView;
+import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmEntityTypeView;
+import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmMapping;
+import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmSchemaView;
+import org.apache.olingo.odata2.processor.core.jpa.access.model.JPAEdmNameBuilder;
+import org.apache.olingo.odata2.processor.core.jpa.access.model.JPATypeConvertor;
+
+@Deprecated
+public final class _JPAEdmFunctionImportBuilder {
+
+  private JPAEdmEntityTypeView jpaEdmEntityTypeView = null;
+  private JPAEdmComplexTypeView jpaEdmComplexTypeView = null;
+  private JPAEdmSchemaView schemaView;
+
+  public void setJPAEdmEntityTypeView(final JPAEdmEntityTypeView jpaEdmEntityTypeView) {
+    this.jpaEdmEntityTypeView = jpaEdmEntityTypeView;
+  }
+
+  public void setSchemaView(final JPAEdmSchemaView schemaView) {
+    this.schemaView = schemaView;
+  }
+
+  public void setJPAEdmComplexTypeView(final JPAEdmComplexTypeView jpaEdmComplexTypeView) {
+    this.jpaEdmComplexTypeView = jpaEdmComplexTypeView;
+  }
+
+  public FunctionImport buildFunctionImport(final Method method,
+      final org.apache.olingo.odata2.api.annotation.edm.FunctionImport annotation) throws ODataJPAModelException {
+
+    if (method != null && annotation != null && annotation.returnType() != ReturnType.NONE) {
+      FunctionImport functionImport = new FunctionImport();
+
+      if (annotation.name().equals("")) {
+        functionImport.setName(method.getName());
+      } else {
+        functionImport.setName(annotation.name());
+      }
+
+      JPAEdmMapping mapping = new JPAEdmMappingImpl();
+      ((Mapping) mapping).setInternalName(method.getName());
+      mapping.setJPAType(method.getDeclaringClass());
+      functionImport.setMapping((Mapping) mapping);
+
+      functionImport.setHttpMethod(annotation.httpMethod().name().toString());
+
+      buildReturnType(functionImport, method, annotation);
+      buildParameter(functionImport, method);
+      return functionImport;
+    }
+    return null;
+
+  }
+
+  private void buildParameter(final FunctionImport functionImport, final Method method)
+      throws ODataJPAModelException {
+
+    Annotation[][] annotations = method.getParameterAnnotations();
+    Class<?>[] parameterTypes = method.getParameterTypes();
+    List<FunctionImportParameter> funcImpList = new ArrayList<FunctionImportParameter>();
+    JPAEdmMapping mapping = null;
+    int j = 0;
+    for (Annotation[] annotationArr : annotations) {
+      Class<?> parameterType = parameterTypes[j++];
+
+      for (Annotation element : annotationArr) {
+        if (element instanceof Parameter) {
+          Parameter annotation = (Parameter) element;
+          FunctionImportParameter functionImportParameter = new FunctionImportParameter();
+          if (annotation.name().equals("")) {
+            throw ODataJPAModelException.throwException(ODataJPAModelException.FUNC_PARAM_NAME_EXP.addContent(method
+                .getDeclaringClass().getName(), method.getName()), null);
+          } else {
+            functionImportParameter.setName(annotation.name());
+          }
+
+          functionImportParameter.setType(JPATypeConvertor.convertToEdmSimpleType(parameterType, null));
+          functionImportParameter.setMode(annotation.mode().toString());
+
+          Facets facets = new Facets();
+          if (annotation.facets().maxLength() > 0) {
+            facets.setMaxLength(annotation.facets().maxLength());
+          }
+          if (annotation.facets().nullable() == false) {
+            facets.setNullable(false);
+          } else {
+            facets.setNullable(true);
+          }
+
+          if (annotation.facets().precision() > 0) {
+            facets.setPrecision(annotation.facets().precision());
+          }
+          if (annotation.facets().scale() >= 0) {
+            facets.setScale(annotation.facets().scale());
+          }
+
+          functionImportParameter.setFacets(facets);
+          mapping = new JPAEdmMappingImpl();
+          mapping.setJPAType(parameterType);
+          functionImportParameter.setMapping((Mapping) mapping);
+          funcImpList.add(functionImportParameter);
+        }
+      }
+    }
+    if (!funcImpList.isEmpty()) {
+      functionImport.setParameters(funcImpList);
+    }
+  }
+
+  private void buildReturnType(final FunctionImport functionImport, final Method method,
+      final org.apache.olingo.odata2.api.annotation.edm.FunctionImport annotation) throws ODataJPAModelException {
+    org.apache.olingo.odata2.api.annotation.edm.FunctionImport.ReturnType returnType = annotation.returnType();
+    Multiplicity multiplicity = null;
+
+    if (returnType != ReturnType.NONE) {
+      org.apache.olingo.odata2.api.edm.provider.ReturnType functionReturnType =
+          new org.apache.olingo.odata2.api.edm.provider.ReturnType();
+      multiplicity = annotation.multiplicity();
+
+      if (multiplicity == Multiplicity.MANY) {
+        functionReturnType.setMultiplicity(EdmMultiplicity.MANY);
+      } else {
+        functionReturnType.setMultiplicity(EdmMultiplicity.ONE);
+      }
+
+      if (returnType == ReturnType.ENTITY_TYPE) {
+        String entitySet = annotation.entitySet();
+        if (entitySet.equals("")) {
+          throw ODataJPAModelException.throwException(ODataJPAModelException.FUNC_ENTITYSET_EXP, null);
+        }
+        functionImport.setEntitySet(entitySet);
+      }
+
+      Class<?> methodReturnType = method.getReturnType();
+      if (methodReturnType == null || methodReturnType.getName().equals("void")) {
+        throw ODataJPAModelException.throwException(ODataJPAModelException.FUNC_RETURN_TYPE_EXP.addContent(method
+            .getDeclaringClass(), method.getName()), null);
+      }
+      switch (returnType) {
+      case ENTITY_TYPE:
+        EntityType edmEntityType = null;
+        if (multiplicity == Multiplicity.ONE) {
+          edmEntityType = jpaEdmEntityTypeView.searchEdmEntityType(methodReturnType.getSimpleName());
+        } else if (multiplicity == Multiplicity.MANY) {
+          edmEntityType = jpaEdmEntityTypeView.searchEdmEntityType(getReturnTypeSimpleName(method));
+        }
+
+        if (edmEntityType == null) {
+          throw ODataJPAModelException.throwException(ODataJPAModelException.FUNC_RETURN_TYPE_ENTITY_NOT_FOUND
+              .addContent(method.getDeclaringClass(), method.getName(), methodReturnType.getSimpleName()), null);
+        }
+        functionReturnType.setTypeName(JPAEdmNameBuilder.build(schemaView, edmEntityType.getName()));
+        break;
+      case SCALAR:
+
+        EdmSimpleTypeKind edmSimpleTypeKind = JPATypeConvertor.convertToEdmSimpleType(methodReturnType, null);
+        functionReturnType.setTypeName(edmSimpleTypeKind.getFullQualifiedName());
+
+        break;
+      case COMPLEX_TYPE:
+        ComplexType complexType = null;
+        if (multiplicity == Multiplicity.ONE) {
+          complexType = jpaEdmComplexTypeView.searchEdmComplexType(methodReturnType.getName());
+        } else if (multiplicity == Multiplicity.MANY) {
+          complexType = jpaEdmComplexTypeView.searchEdmComplexType(getReturnTypeName(method));
+        }
+        if (complexType == null) {
+          throw ODataJPAModelException.throwException(ODataJPAModelException.FUNC_RETURN_TYPE_ENTITY_NOT_FOUND
+              .addContent(method.getDeclaringClass(), method.getName(), methodReturnType.getSimpleName()), null);
+        }
+        functionReturnType.setTypeName(JPAEdmNameBuilder.build(schemaView, complexType.getName()));
+        break;
+      default:
+        break;
+      }
+      functionImport.setReturnType(functionReturnType);
+    }
+  }
+
+  private String getReturnTypeName(final Method method) {
+    try {
+      ParameterizedType pt = (ParameterizedType) method.getGenericReturnType();
+      Type t = pt.getActualTypeArguments()[0];
+      return ((Class<?>) t).getName();
+    } catch (ClassCastException e) {
+      return method.getReturnType().getName();
+    }
+  }
+
+  private String getReturnTypeSimpleName(final Method method) {
+    try {
+      ParameterizedType pt = (ParameterizedType) method.getGenericReturnType();
+      Type t = pt.getActualTypeArguments()[0];
+      return ((Class<?>) t).getSimpleName();
+    } catch (ClassCastException e) {
+      return method.getReturnType().getSimpleName();
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/09474017/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/JPACustomProcessorMock.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/JPACustomProcessorMock.java b/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/JPACustomProcessorMock.java
index a91442a..54a6871 100644
--- a/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/JPACustomProcessorMock.java
+++ b/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/JPACustomProcessorMock.java
@@ -21,54 +21,52 @@ package org.apache.olingo.odata2.processor.core.jpa.mock.model;
 import java.util.ArrayList;
 import java.util.List;
 
-import org.apache.olingo.odata2.api.annotation.edm.Facets;
-import org.apache.olingo.odata2.api.annotation.edm.FunctionImport;
-import org.apache.olingo.odata2.api.annotation.edm.FunctionImport.Multiplicity;
-import org.apache.olingo.odata2.api.annotation.edm.FunctionImport.ReturnType;
-import org.apache.olingo.odata2.api.annotation.edm.Parameter;
-import org.apache.olingo.odata2.api.annotation.edm.Parameter.Mode;
+import org.apache.olingo.odata2.api.annotation.edm.EdmFacets;
+import org.apache.olingo.odata2.api.annotation.edm.EdmFunctionImport;
+import org.apache.olingo.odata2.api.annotation.edm.EdmFunctionImport.ReturnType;
+import org.apache.olingo.odata2.api.annotation.edm.EdmFunctionImport.ReturnType.Type;
+import org.apache.olingo.odata2.api.annotation.edm.EdmFunctionImportParameter;
 
 public class JPACustomProcessorMock {
 
   public static final String className = "JPACustomProcessorMock";
   public static final String edmName = "JPACustomProcessor";
 
-  @FunctionImport(name = "Method1", entitySet = "MockSet", returnType = ReturnType.ENTITY_TYPE,
-      multiplicity = Multiplicity.MANY)
-  public List<JPACustomProcessorMock> method1(@Parameter(name = "Param1", facets = @Facets(nullable = true,
-      maxLength = 2), mode = Mode.IN) final String param1, final int param2, @Parameter(name = "Param3",
-      facets = @Facets(precision = 10, scale = 2), mode = Mode.IN) final double param3) {
+  @EdmFunctionImport(name = "Method1", entitySet = "MockSet", returnType = @ReturnType(type = Type.ENTITY,
+      isCollection = true))
+  public List<JPACustomProcessorMock> method1(@EdmFunctionImportParameter(name = "Param1", facets = @EdmFacets(
+      nullable = true,
+      maxLength = 2)) final String param1, final int param2, @EdmFunctionImportParameter(name = "Param3",
+      facets = @EdmFacets(precision = 10, scale = 2)) final double param3) {
     return new ArrayList<JPACustomProcessorMock>();
   }
 
-  @FunctionImport(name = "Method2", entitySet = "MockSet", returnType = ReturnType.ENTITY_TYPE,
-      multiplicity = Multiplicity.MANY)
+  @EdmFunctionImport(name = "Method2", entitySet = "MockSet", returnType = @ReturnType(type = Type.ENTITY,
+      isCollection = true))
   public List<JPACustomProcessorMock> method2(
-      @Parameter(facets = @Facets(maxLength = 2), name = "Param2") final String param2) {
+      @EdmFunctionImportParameter(facets = @EdmFacets(maxLength = 2), name = "Param2") final String param2) {
     return new ArrayList<JPACustomProcessorMock>();
   }
 
-  @FunctionImport(returnType = ReturnType.SCALAR)
-  public int method3(@Parameter(name = "Param3") final String param3) {
+  @EdmFunctionImport(returnType = @ReturnType(type = Type.SIMPLE))
+  public int method3(@EdmFunctionImportParameter(name = "Param3") final String param3) {
     return 0;
   }
 
-  @FunctionImport(returnType = ReturnType.NONE)
-  public void method4() {
-    return;
-  }
-
-  @FunctionImport(returnType = ReturnType.ENTITY_TYPE, entitySet = "MockSet", multiplicity = Multiplicity.ONE)
+  @EdmFunctionImport(returnType = @ReturnType(type = Type.ENTITY,
+      isCollection = false), entitySet = "MockSet")
   public JPACustomProcessorMock method7() {
     return null;
   }
 
-  @FunctionImport(returnType = ReturnType.COMPLEX_TYPE, multiplicity = Multiplicity.ONE)
+  @EdmFunctionImport(returnType = @ReturnType(type = Type.COMPLEX,
+      isCollection = false))
   public JPACustomProcessorMock method9() {
     return null;
   }
 
-  @FunctionImport(returnType = ReturnType.COMPLEX_TYPE, multiplicity = Multiplicity.MANY)
+  @EdmFunctionImport(returnType = @ReturnType(type = Type.COMPLEX,
+      isCollection = true))
   public List<JPACustomProcessorMock> method10() {
     return null;
   }

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/09474017/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/JPACustomProcessorNegativeMock.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/JPACustomProcessorNegativeMock.java b/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/JPACustomProcessorNegativeMock.java
deleted file mode 100644
index 2d0ef23..0000000
--- a/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/JPACustomProcessorNegativeMock.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*******************************************************************************
- * 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.processor.core.jpa.mock.model;
-
-import java.util.List;
-
-import org.apache.olingo.odata2.api.annotation.edm.FunctionImport;
-import org.apache.olingo.odata2.api.annotation.edm.FunctionImport.Multiplicity;
-import org.apache.olingo.odata2.api.annotation.edm.FunctionImport.ReturnType;
-import org.apache.olingo.odata2.api.annotation.edm.Parameter;
-
-public class JPACustomProcessorNegativeMock {
-
-  @FunctionImport(returnType = ReturnType.ENTITY_TYPE, multiplicity = Multiplicity.MANY)
-  public List<JPACustomProcessorNegativeMock> method5() {
-    return null;
-  }
-
-  @FunctionImport(returnType = ReturnType.ENTITY_TYPE, entitySet = "MockSet", multiplicity = Multiplicity.MANY)
-  public void method6() {
-    return;
-  }
-
-  @FunctionImport(returnType = ReturnType.ENTITY_TYPE, entitySet = "MockSet", multiplicity = Multiplicity.MANY)
-  public JPACustomProcessorNegativeMock method8() {
-    return null;
-  }
-
-  @FunctionImport(returnType = ReturnType.COMPLEX_TYPE, multiplicity = Multiplicity.ONE)
-  public JPACustomProcessorNegativeMock method11() {
-    return null;
-  }
-
-  @FunctionImport(returnType = ReturnType.SCALAR, multiplicity = Multiplicity.ONE)
-  public JPACustomProcessorMock method12() {
-    return null;
-  }
-
-  @FunctionImport(returnType = ReturnType.SCALAR, multiplicity = Multiplicity.ONE)
-  public int method13(@Parameter(name = "") final int y) {
-    return 0;
-  }
-
-  @FunctionImport(returnType = ReturnType.SCALAR, multiplicity = Multiplicity.ONE)
-  public void method16(@Parameter(name = "") final int y) {
-    return;
-  }
-
-  @FunctionImport(returnType = ReturnType.COMPLEX_TYPE, multiplicity = Multiplicity.ONE)
-  public void method17(@Parameter(name = "") final int y) {
-    return;
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/09474017/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/_JPACustomProcessorMock.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/_JPACustomProcessorMock.java b/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/_JPACustomProcessorMock.java
new file mode 100644
index 0000000..dbc6d7a
--- /dev/null
+++ b/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/_JPACustomProcessorMock.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.processor.core.jpa.mock.model;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.olingo.odata2.api.annotation.edm.Facets;
+import org.apache.olingo.odata2.api.annotation.edm.FunctionImport;
+import org.apache.olingo.odata2.api.annotation.edm.FunctionImport.Multiplicity;
+import org.apache.olingo.odata2.api.annotation.edm.FunctionImport.ReturnType;
+import org.apache.olingo.odata2.api.annotation.edm.Parameter;
+import org.apache.olingo.odata2.api.annotation.edm.Parameter.Mode;
+
+@Deprecated
+public class _JPACustomProcessorMock {
+
+  public static final String className = "_JPACustomProcessorMock";
+  public static final String edmName = "JPACustomProcessor";
+
+  @FunctionImport(name = "Method1", entitySet = "MockSet", returnType = ReturnType.ENTITY_TYPE,
+      multiplicity = Multiplicity.MANY)
+  public List<_JPACustomProcessorMock> method1(@Parameter(name = "Param1", facets = @Facets(nullable = true,
+      maxLength = 2), mode = Mode.IN) final String param1, final int param2, @Parameter(name = "Param3",
+      facets = @Facets(precision = 10, scale = 2), mode = Mode.IN) final double param3) {
+    return new ArrayList<_JPACustomProcessorMock>();
+  }
+
+  @FunctionImport(name = "Method2", entitySet = "MockSet", returnType = ReturnType.ENTITY_TYPE,
+      multiplicity = Multiplicity.MANY)
+  public List<_JPACustomProcessorMock> method2(
+      @Parameter(facets = @Facets(maxLength = 2), name = "Param2") final String param2) {
+    return new ArrayList<_JPACustomProcessorMock>();
+  }
+
+  @FunctionImport(returnType = ReturnType.SCALAR)
+  public int method3(@Parameter(name = "Param3") final String param3) {
+    return 0;
+  }
+
+  @FunctionImport(returnType = ReturnType.NONE)
+  public void method4() {
+    return;
+  }
+
+  @FunctionImport(returnType = ReturnType.ENTITY_TYPE, entitySet = "MockSet", multiplicity = Multiplicity.ONE)
+  public _JPACustomProcessorMock method7() {
+    return null;
+  }
+
+  @FunctionImport(returnType = ReturnType.COMPLEX_TYPE, multiplicity = Multiplicity.ONE)
+  public _JPACustomProcessorMock method9() {
+    return null;
+  }
+
+  @FunctionImport(returnType = ReturnType.COMPLEX_TYPE, multiplicity = Multiplicity.MANY)
+  public List<_JPACustomProcessorMock> method10() {
+    return null;
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/09474017/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/_JPACustomProcessorNegativeMock.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/_JPACustomProcessorNegativeMock.java b/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/_JPACustomProcessorNegativeMock.java
new file mode 100644
index 0000000..6799949
--- /dev/null
+++ b/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/_JPACustomProcessorNegativeMock.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.processor.core.jpa.mock.model;
+
+import java.util.List;
+
+import org.apache.olingo.odata2.api.annotation.edm.FunctionImport;
+import org.apache.olingo.odata2.api.annotation.edm.FunctionImport.Multiplicity;
+import org.apache.olingo.odata2.api.annotation.edm.FunctionImport.ReturnType;
+import org.apache.olingo.odata2.api.annotation.edm.Parameter;
+
+@Deprecated
+public class _JPACustomProcessorNegativeMock {
+
+  @FunctionImport(returnType = ReturnType.ENTITY_TYPE, multiplicity = Multiplicity.MANY)
+  public List<_JPACustomProcessorNegativeMock> method5() {
+    return null;
+  }
+
+  @FunctionImport(returnType = ReturnType.ENTITY_TYPE, entitySet = "MockSet", multiplicity = Multiplicity.MANY)
+  public void method6() {
+    return;
+  }
+
+  @FunctionImport(returnType = ReturnType.ENTITY_TYPE, entitySet = "MockSet", multiplicity = Multiplicity.MANY)
+  public _JPACustomProcessorNegativeMock method8() {
+    return null;
+  }
+
+  @FunctionImport(returnType = ReturnType.COMPLEX_TYPE, multiplicity = Multiplicity.ONE)
+  public _JPACustomProcessorNegativeMock method11() {
+    return null;
+  }
+
+  @FunctionImport(returnType = ReturnType.SCALAR, multiplicity = Multiplicity.ONE)
+  public JPACustomProcessorMock method12() {
+    return null;
+  }
+
+  @FunctionImport(returnType = ReturnType.SCALAR, multiplicity = Multiplicity.ONE)
+  public int method13(@Parameter(name = "") final int y) {
+    return 0;
+  }
+
+  @FunctionImport(returnType = ReturnType.SCALAR, multiplicity = Multiplicity.ONE)
+  public void method16(@Parameter(name = "") final int y) {
+    return;
+  }
+
+  @FunctionImport(returnType = ReturnType.COMPLEX_TYPE, multiplicity = Multiplicity.ONE)
+  public void method17(@Parameter(name = "") final int y) {
+    return;
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/09474017/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmFunctionImportTest.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmFunctionImportTest.java b/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmFunctionImportTest.java
index 2e678cb..94665d7 100644
--- a/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmFunctionImportTest.java
+++ b/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmFunctionImportTest.java
@@ -26,7 +26,6 @@ import static org.junit.Assert.fail;
 import java.util.HashMap;
 import java.util.List;
 
-import org.apache.olingo.odata2.api.annotation.edm.Parameter.Mode;
 import org.apache.olingo.odata2.api.edm.EdmFacets;
 import org.apache.olingo.odata2.api.edm.EdmMultiplicity;
 import org.apache.olingo.odata2.api.edm.EdmSimpleTypeKind;
@@ -47,7 +46,7 @@ import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmMapping;
 import org.apache.olingo.odata2.processor.core.jpa.common.ODataJPATestConstants;
 import org.apache.olingo.odata2.processor.core.jpa.mock.ODataJPAContextMock;
 import org.apache.olingo.odata2.processor.core.jpa.mock.model.JPACustomProcessorMock;
-import org.apache.olingo.odata2.processor.core.jpa.mock.model.JPACustomProcessorNegativeMock;
+import org.apache.olingo.odata2.processor.core.jpa.mock.model._JPACustomProcessorNegativeMock;
 import org.junit.Before;
 import org.junit.Test;
 
@@ -89,11 +88,9 @@ public class JPAEdmFunctionImportTest extends JPAEdmTestModelView {
       assertEquals(2, funcImpList.size());
       assertEquals("Param1", funcImpList.get(0).getName());
       assertEquals(EdmSimpleTypeKind.String, funcImpList.get(0).getType());
-      assertEquals(Mode.IN.toString(), funcImpList.get(0).getMode());
 
       assertEquals("Param3", funcImpList.get(1).getName());
       assertEquals(EdmSimpleTypeKind.Double, funcImpList.get(1).getType());
-      assertEquals(Mode.IN.toString(), funcImpList.get(1).getMode());
 
     }
 
@@ -166,12 +163,6 @@ public class JPAEdmFunctionImportTest extends JPAEdmTestModelView {
 
     assertEquals(functionImportList.size(), 0);
 
-    // FunctionImport functionImport = functionImportList.get(0);
-    // assertEquals(functionImport.getName(), "method4");
-    // assertNotNull(functionImport.getMapping());
-    //
-    // assertNull(functionImport.getReturnType());
-
   }
 
   /**
@@ -488,31 +479,31 @@ public class JPAEdmFunctionImportTest extends JPAEdmTestModelView {
     } else if (VARIANT == 4) {
       customOperations.put(JPACustomProcessorMock.class, new String[] { "method4" });
     } else if (VARIANT == 5) {
-      customOperations.put(JPACustomProcessorNegativeMock.class, new String[] { "method5" });
+      customOperations.put(_JPACustomProcessorNegativeMock.class, new String[] { "method5" });
     } else if (VARIANT == 6) {
-      customOperations.put(JPACustomProcessorNegativeMock.class, new String[] { "method6" });
+      customOperations.put(_JPACustomProcessorNegativeMock.class, new String[] { "method6" });
     } else if (VARIANT == 7) {
       customOperations.put(JPACustomProcessorMock.class, new String[] { "method7" });
     } else if (VARIANT == 8) {
-      customOperations.put(JPACustomProcessorNegativeMock.class, new String[] { "method8" });
+      customOperations.put(_JPACustomProcessorNegativeMock.class, new String[] { "method8" });
     } else if (VARIANT == 9) {
       customOperations.put(JPACustomProcessorMock.class, new String[] { "method9" });
     } else if (VARIANT == 10) {
       customOperations.put(JPACustomProcessorMock.class, new String[] { "method10" });
     } else if (VARIANT == 11) {
-      customOperations.put(JPACustomProcessorNegativeMock.class, new String[] { "method11" });
+      customOperations.put(_JPACustomProcessorNegativeMock.class, new String[] { "method11" });
     } else if (VARIANT == 12) {
-      customOperations.put(JPACustomProcessorNegativeMock.class, new String[] { "method12" });
+      customOperations.put(_JPACustomProcessorNegativeMock.class, new String[] { "method12" });
     } else if (VARIANT == 13) {
-      customOperations.put(JPACustomProcessorNegativeMock.class, new String[] { "method13" });
+      customOperations.put(_JPACustomProcessorNegativeMock.class, new String[] { "method13" });
     } else if (VARIANT == 14) {
       customOperations.put(JPACustomProcessorMock.class, new String[] { "method1" });
     } else if (VARIANT == 15) {
       customOperations.put(JPACustomProcessorMock.class, new String[] { "method3" });
     } else if (VARIANT == 16) {
-      customOperations.put(JPACustomProcessorNegativeMock.class, new String[] { "method16" });
+      customOperations.put(_JPACustomProcessorNegativeMock.class, new String[] { "method16" });
     } else if (VARIANT == 17) {
-      customOperations.put(JPACustomProcessorNegativeMock.class, new String[] { "method17" });
+      customOperations.put(_JPACustomProcessorNegativeMock.class, new String[] { "method17" });
     } else {
       return null;
     }

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/09474017/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/_JPAEdmFunctionImportTest.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/_JPAEdmFunctionImportTest.java b/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/_JPAEdmFunctionImportTest.java
new file mode 100644
index 0000000..d596e77
--- /dev/null
+++ b/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/_JPAEdmFunctionImportTest.java
@@ -0,0 +1,570 @@
+/*******************************************************************************
+ * 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.processor.core.jpa.model;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.fail;
+
+import java.util.HashMap;
+import java.util.List;
+
+import org.apache.olingo.odata2.api.annotation.edm.Parameter.Mode;
+import org.apache.olingo.odata2.api.edm.EdmFacets;
+import org.apache.olingo.odata2.api.edm.EdmMultiplicity;
+import org.apache.olingo.odata2.api.edm.EdmSimpleTypeKind;
+import org.apache.olingo.odata2.api.edm.provider.ComplexType;
+import org.apache.olingo.odata2.api.edm.provider.EntityType;
+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.Mapping;
+import org.apache.olingo.odata2.api.edm.provider.ReturnType;
+import org.apache.olingo.odata2.processor.api.jpa.access.JPAEdmBuilder;
+import org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPAModelException;
+import org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPARuntimeException;
+import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmComplexTypeView;
+import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmEntityContainerView;
+import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmEntitySetView;
+import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmEntityTypeView;
+import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmMapping;
+import org.apache.olingo.odata2.processor.core.jpa.common.ODataJPATestConstants;
+import org.apache.olingo.odata2.processor.core.jpa.mock.ODataJPAContextMock;
+import org.apache.olingo.odata2.processor.core.jpa.mock.model._JPACustomProcessorMock;
+import org.apache.olingo.odata2.processor.core.jpa.mock.model._JPACustomProcessorNegativeMock;
+import org.junit.Before;
+import org.junit.Test;
+
+@Deprecated
+public class _JPAEdmFunctionImportTest extends JPAEdmTestModelView {
+  private static final int METHOD_COUNT = 6;
+  private static int VARIANT = 0;
+  private JPAEdmFunctionImport jpaEdmfunctionImport;
+
+  @Before
+  public void setup() {
+    jpaEdmfunctionImport = new JPAEdmFunctionImport(this);
+  }
+
+  /**
+   * Test Case - Function Import Basic test - Positive Case
+   */
+  @Test
+  public void testFunctionImportBasic() {
+    VARIANT = 0;
+
+    build();
+
+    List<FunctionImport> functionImportList = jpaEdmfunctionImport.getConsistentFunctionImportList();
+
+    assertEquals(functionImportList.size(), 1);
+    for (FunctionImport functionImport : functionImportList) {
+      assertEquals(functionImport.getName(), "Method1");
+      assertNotNull(functionImport.getMapping());
+      Mapping mapping = new Mapping();
+      mapping.setInternalName("method1");
+
+      assertEquals(mapping.getInternalName(), functionImport.getMapping().getInternalName());
+
+      ReturnType returnType = functionImport.getReturnType();
+      assertNotNull(returnType);
+      assertEquals(EdmMultiplicity.MANY, returnType.getMultiplicity());
+
+      List<FunctionImportParameter> funcImpList = functionImport.getParameters();
+      assertEquals(2, funcImpList.size());
+      assertEquals("Param1", funcImpList.get(0).getName());
+      assertEquals(EdmSimpleTypeKind.String, funcImpList.get(0).getType());
+      assertEquals(Mode.IN.toString(), funcImpList.get(0).getMode());
+
+      assertEquals("Param3", funcImpList.get(1).getName());
+      assertEquals(EdmSimpleTypeKind.Double, funcImpList.get(1).getType());
+      assertEquals(Mode.IN.toString(), funcImpList.get(1).getMode());
+
+    }
+
+  }
+
+  /**
+   * Test Case - Enable a method that does not exists
+   */
+  @Test
+  public void testFunctionImportNoSuchMethod() {
+    VARIANT = 1;
+
+    build();
+
+    List<FunctionImport> functionImportList = jpaEdmfunctionImport.getConsistentFunctionImportList();
+
+    assertEquals(functionImportList.size(), 0);
+
+  }
+
+  /**
+   * Test Case - Enable all annotated methods in a class as function imports
+   */
+  @Test
+  public void testFunctionImportAllMethods() {
+    VARIANT = 2;
+
+    build();
+
+    List<FunctionImport> functionImportList = jpaEdmfunctionImport.getConsistentFunctionImportList();
+
+    assertEquals(METHOD_COUNT, functionImportList.size());
+
+  }
+
+  /**
+   * Test Case - Function Import with no names. Default name is Java method
+   * name.
+   */
+  @Test
+  public void testFunctionImportNoName() {
+    VARIANT = 3;
+
+    build();
+
+    List<FunctionImport> functionImportList = jpaEdmfunctionImport.getConsistentFunctionImportList();
+
+    assertEquals(functionImportList.size(), 1);
+
+    FunctionImport functionImport = functionImportList.get(0);
+    assertEquals(functionImport.getName(), "method3");
+    assertNotNull(functionImport.getMapping());
+
+    ReturnType returnType = functionImport.getReturnType();
+    assertNotNull(returnType);
+    assertEquals(EdmMultiplicity.ONE, returnType.getMultiplicity());
+    assertEquals(returnType.getTypeName().toString(), EdmSimpleTypeKind.Int32.getFullQualifiedName().toString());
+  }
+
+  /**
+   * Test Case - Function Import with No return type defined - Negative case
+   */
+  @Test
+  public void testNoReturnType() {
+    VARIANT = 4;
+
+    build();
+
+    List<FunctionImport> functionImportList = jpaEdmfunctionImport.getConsistentFunctionImportList();
+
+    assertEquals(functionImportList.size(), 0);
+
+  }
+
+  /**
+   * Test Case - Function Import with return type as Entity and Multiplicity
+   * as Many but no Entity set defined. --> Negative Case
+   */
+  @Test
+  public void testNoEntitySet() {
+    VARIANT = 5;
+
+    try {
+      jpaEdmfunctionImport.getBuilder().build();
+      fail("Exception Expected");
+    } catch (ODataJPAModelException e) {
+      assertEquals(ODataJPAModelException.FUNC_ENTITYSET_EXP.getKey(), e.getMessageReference().getKey());
+    } catch (ODataJPARuntimeException e) {
+      fail("Model Exception Expected");
+    }
+  }
+
+  /**
+   * Test Case - Function Import with return type as Entity Type but method
+   * has returns void. --> Negative Case
+   */
+  @Test
+  public void testNoReturnTypeButAnnotated() {
+    VARIANT = 6;
+
+    try {
+      jpaEdmfunctionImport.getBuilder().build();
+      fail("Exception Expected");
+    } catch (ODataJPAModelException e) {
+      assertEquals(ODataJPAModelException.FUNC_RETURN_TYPE_EXP.getKey(), e.getMessageReference().getKey());
+    } catch (ODataJPARuntimeException e) {
+      fail("Model Exception Expected");
+    }
+  }
+
+  /**
+   * Test Case - Function Import that returns an Entity Type with Multiplicity
+   * as ONE. -->Positive Case
+   */
+  @Test
+  public void testFunctionImportEntityTypeSingleReturn() {
+    VARIANT = 7;
+
+    build();
+
+    List<FunctionImport> functionImportList = jpaEdmfunctionImport.getConsistentFunctionImportList();
+
+    assertEquals(functionImportList.size(), 1);
+
+    FunctionImport functionImport = functionImportList.get(0);
+    assertEquals(functionImport.getName(), "method7");
+    assertNotNull(functionImport.getMapping());
+    JPAEdmMapping mapping = (JPAEdmMapping) functionImport.getMapping();
+    assertEquals(_JPACustomProcessorMock.class, mapping.getJPAType());
+
+    ReturnType returnType = functionImport.getReturnType();
+    assertNotNull(returnType);
+    assertEquals(EdmMultiplicity.ONE, returnType.getMultiplicity());
+    assertEquals(returnType.getTypeName().toString(), ODataJPAContextMock.PERSISTENCE_UNIT_NAME + "."
+        + _JPACustomProcessorMock.edmName);
+  }
+
+  /**
+   * Test Case - Function Import that returns an Entity Type that is not found
+   * in JPA Model
+   */
+  @Test
+  public void testFunctionImportEntityTypeInvalid() {
+    VARIANT = 8;
+
+    try {
+      jpaEdmfunctionImport.getBuilder().build();
+      fail("Exception Expected");
+    } catch (ODataJPAModelException e) {
+      assertEquals(ODataJPAModelException.FUNC_RETURN_TYPE_ENTITY_NOT_FOUND.getKey(), e.getMessageReference().getKey());
+    } catch (ODataJPARuntimeException e) {
+      fail("Model Exception Expected");
+    }
+
+  }
+
+  /**
+   * Test Case - Function Import that returns a complex Type
+   */
+  @Test
+  public void testFunctionImportComplexType() {
+    VARIANT = 9;
+
+    build();
+
+    List<FunctionImport> functionImportList = jpaEdmfunctionImport.getConsistentFunctionImportList();
+
+    assertEquals(functionImportList.size(), 1);
+
+    FunctionImport functionImport = functionImportList.get(0);
+    assertEquals(functionImport.getName(), "method9");
+    assertNotNull(functionImport.getMapping());
+
+    ReturnType returnType = functionImport.getReturnType();
+    assertNotNull(returnType);
+    assertEquals(EdmMultiplicity.ONE, returnType.getMultiplicity());
+    assertEquals(returnType.getTypeName().toString(), ODataJPAContextMock.PERSISTENCE_UNIT_NAME + "."
+        + _JPACustomProcessorMock.edmName);
+
+  }
+
+  /**
+   * Test Case - Function Import that returns a complex Type with multiplicity
+   * Many
+   */
+  @Test
+  public void testFunctionImportComplexTypeMany() {
+    VARIANT = 10;
+
+    build();
+
+    List<FunctionImport> functionImportList = jpaEdmfunctionImport.getConsistentFunctionImportList();
+
+    assertEquals(functionImportList.size(), 1);
+
+    FunctionImport functionImport = functionImportList.get(0);
+    assertEquals(functionImport.getName(), "method10");
+    assertNotNull(functionImport.getMapping());
+
+    ReturnType returnType = functionImport.getReturnType();
+    assertNotNull(returnType);
+    assertEquals(EdmMultiplicity.MANY, returnType.getMultiplicity());
+    assertEquals(returnType.getTypeName().toString(), ODataJPAContextMock.PERSISTENCE_UNIT_NAME + "."
+        + _JPACustomProcessorMock.edmName);
+
+  }
+
+  /**
+   * Test Case - Function Import that returns an Complex Type that is not
+   * found in JPA Model
+   */
+  @Test
+  public void testFunctionImportComplexTypeInvalid() {
+    VARIANT = 11;
+
+    try {
+      jpaEdmfunctionImport.getBuilder().build();
+      fail("Exception Expected");
+    } catch (ODataJPAModelException e) {
+      assertEquals(ODataJPAModelException.FUNC_RETURN_TYPE_ENTITY_NOT_FOUND.getKey(), e.getMessageReference().getKey());
+    } catch (ODataJPARuntimeException e) {
+      fail("Model Exception Expected");
+    }
+
+  }
+
+  /**
+   * Test Case - Function Import that returns an scalar Type that is not valid
+   */
+  @Test
+  public void testFunctionImportScalarTypeInvalid() {
+    VARIANT = 12;
+
+    try {
+      jpaEdmfunctionImport.getBuilder().build();
+      fail("Exception Expected");
+    } catch (ODataJPAModelException e) {
+      assertEquals(ODataJPAModelException.TYPE_NOT_SUPPORTED.getKey(), e.getMessageReference().getKey());
+    } catch (ODataJPARuntimeException e) {
+      fail("Model Exception Expected");
+    }
+
+  }
+
+  /**
+   * Test Case - Function Import that takes a parameter with no name
+   */
+  @Test
+  public void testFunctionImportParamNoName() {
+    VARIANT = 13;
+
+    try {
+      jpaEdmfunctionImport.getBuilder().build();
+      fail("Exception Expected");
+    } catch (ODataJPAModelException e) {
+      assertEquals(ODataJPAModelException.FUNC_PARAM_NAME_EXP.getKey(), e.getMessageReference().getKey());
+    } catch (ODataJPARuntimeException e) {
+      fail("Model Exception Expected");
+    }
+
+  }
+
+  /**
+   * Test Case - Function Import test for facets
+   */
+  @Test
+  public void testFunctionImportParamFacets() {
+    VARIANT = 14;
+
+    build();
+
+    List<FunctionImport> functionImportList = jpaEdmfunctionImport.getConsistentFunctionImportList();
+
+    assertEquals(functionImportList.size(), 1);
+
+    List<FunctionImportParameter> funcImpParamList = functionImportList.get(0).getParameters();
+    EdmFacets facets = funcImpParamList.get(0).getFacets();
+    assertNotNull(facets);
+    assertEquals(2, facets.getMaxLength().intValue());
+    assertEquals(true, facets.isNullable());
+
+    facets = funcImpParamList.get(1).getFacets();
+    assertNotNull(facets);
+    assertEquals(false, facets.isNullable());
+    assertEquals(10, facets.getPrecision().intValue());
+    assertEquals(2, facets.getScale().intValue());
+
+  }
+
+  /**
+   * Test Case - Function Import test for default facets
+   */
+  @Test
+  public void testFunctionImportParamFacetsDefault() {
+    VARIANT = 15;
+
+    build();
+
+    List<FunctionImport> functionImportList = jpaEdmfunctionImport.getConsistentFunctionImportList();
+
+    assertEquals(functionImportList.size(), 1);
+
+    List<FunctionImportParameter> funcImpParamList = functionImportList.get(0).getParameters();
+    EdmFacets facets = funcImpParamList.get(0).getFacets();
+    assertNotNull(facets);
+    assertNull(facets.getMaxLength());
+    assertEquals(false, facets.isNullable());
+    assertNull(facets.getPrecision());
+    assertNull(facets.getScale());
+
+  }
+
+  /**
+   * Test Case - Function Import test for ReturnType.SCALAR but method returns
+   * void
+   */
+  @Test
+  public void testWrongReturnTypeScalar() {
+    VARIANT = 16;
+
+    try {
+      jpaEdmfunctionImport.getBuilder().build();
+      fail("Exception Expected");
+    } catch (ODataJPAModelException e) {
+      assertEquals(ODataJPAModelException.FUNC_RETURN_TYPE_EXP.getKey(), e.getMessageReference().getKey());
+    } catch (ODataJPARuntimeException e) {
+      fail("Model Exception Expected");
+    }
+
+  }
+
+  /**
+   * Test Case - Function Import test for ReturnType.COMPLEX but method returns
+   * void
+   */
+  @Test
+  public void testWrongReturnTypeComplex() {
+    VARIANT = 17;
+
+    try {
+      jpaEdmfunctionImport.getBuilder().build();
+      fail("Exception Expected");
+    } catch (ODataJPAModelException e) {
+      assertEquals(ODataJPAModelException.FUNC_RETURN_TYPE_EXP.getKey(), e.getMessageReference().getKey());
+    } catch (ODataJPARuntimeException e) {
+      fail("Model Exception Expected");
+    }
+
+  }
+
+  @Test
+  public void testNoFunctionImport() {
+    VARIANT = 99;
+
+    build();
+
+    List<FunctionImport> functionImportList = jpaEdmfunctionImport.getConsistentFunctionImportList();
+
+    assertEquals(functionImportList.size(), 0);
+
+  }
+
+  @Test
+  public void testGetBuilderIdempotent() {
+    JPAEdmFunctionImport jpaEdmfunctionImport = new JPAEdmFunctionImport(this);
+
+    JPAEdmBuilder builder1 = jpaEdmfunctionImport.getBuilder();
+    JPAEdmBuilder builder2 = jpaEdmfunctionImport.getBuilder();
+
+    assertEquals(builder1.hashCode(), builder2.hashCode());
+  }
+
+  @Override
+  public HashMap<Class<?>, String[]> getRegisteredOperations() {
+
+    HashMap<Class<?>, String[]> customOperations = new HashMap<Class<?>, String[]>();
+
+    if (VARIANT == 0) {
+      customOperations.put(_JPACustomProcessorMock.class, new String[] { "method1" });
+    } else if (VARIANT == 1) {
+      customOperations.put(_JPACustomProcessorMock.class, new String[] { "XYX" });
+    } else if (VARIANT == 2) {
+      customOperations.put(_JPACustomProcessorMock.class, null);
+    } else if (VARIANT == 3) {
+      customOperations.put(_JPACustomProcessorMock.class, new String[] { "method3" });
+    } else if (VARIANT == 4) {
+      customOperations.put(_JPACustomProcessorMock.class, new String[] { "method4" });
+    } else if (VARIANT == 5) {
+      customOperations.put(_JPACustomProcessorNegativeMock.class, new String[] { "method5" });
+    } else if (VARIANT == 6) {
+      customOperations.put(_JPACustomProcessorNegativeMock.class, new String[] { "method6" });
+    } else if (VARIANT == 7) {
+      customOperations.put(_JPACustomProcessorMock.class, new String[] { "method7" });
+    } else if (VARIANT == 8) {
+      customOperations.put(_JPACustomProcessorNegativeMock.class, new String[] { "method8" });
+    } else if (VARIANT == 9) {
+      customOperations.put(_JPACustomProcessorMock.class, new String[] { "method9" });
+    } else if (VARIANT == 10) {
+      customOperations.put(_JPACustomProcessorMock.class, new String[] { "method10" });
+    } else if (VARIANT == 11) {
+      customOperations.put(_JPACustomProcessorNegativeMock.class, new String[] { "method11" });
+    } else if (VARIANT == 12) {
+      customOperations.put(_JPACustomProcessorNegativeMock.class, new String[] { "method12" });
+    } else if (VARIANT == 13) {
+      customOperations.put(_JPACustomProcessorNegativeMock.class, new String[] { "method13" });
+    } else if (VARIANT == 14) {
+      customOperations.put(_JPACustomProcessorMock.class, new String[] { "method1" });
+    } else if (VARIANT == 15) {
+      customOperations.put(_JPACustomProcessorMock.class, new String[] { "method3" });
+    } else if (VARIANT == 16) {
+      customOperations.put(_JPACustomProcessorNegativeMock.class, new String[] { "method16" });
+    } else if (VARIANT == 17) {
+      customOperations.put(_JPACustomProcessorNegativeMock.class, new String[] { "method17" });
+    } else {
+      return null;
+    }
+
+    return customOperations;
+  }
+
+  @Override
+  public JPAEdmEntityContainerView getJPAEdmEntityContainerView() {
+    return this;
+  }
+
+  @Override
+  public JPAEdmEntitySetView getJPAEdmEntitySetView() {
+    return this;
+  }
+
+  @Override
+  public JPAEdmEntityTypeView getJPAEdmEntityTypeView() {
+    return this;
+  }
+
+  @Override
+  public JPAEdmComplexTypeView getJPAEdmComplexTypeView() {
+    return this;
+  }
+
+  @Override
+  public EntityType searchEdmEntityType(final String arg0) {
+    if (arg0.equals(_JPACustomProcessorMock.class.getSimpleName())) {
+      return new EntityType().setName(_JPACustomProcessorMock.edmName);
+    } else {
+      return null;
+    }
+  }
+
+  @Override
+  public ComplexType searchEdmComplexType(final String arg0) {
+    if (arg0.equals(_JPACustomProcessorMock.class.getName())) {
+      return new ComplexType().setName(_JPACustomProcessorMock.edmName);
+    } else {
+      return null;
+    }
+  }
+
+  @Override
+  public String getpUnitName() {
+    return ODataJPAContextMock.PERSISTENCE_UNIT_NAME;
+  }
+
+  private void build() {
+    try {
+      jpaEdmfunctionImport.getBuilder().build();
+    } catch (ODataJPAModelException e) {
+      fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+    } catch (ODataJPARuntimeException e) {
+      fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/09474017/odata2-processor-jpa/jpa-web/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/extension/SalesOrderHeaderProcessor.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-web/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/extension/SalesOrderHeaderProcessor.java b/odata2-processor-jpa/jpa-web/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/extension/SalesOrderHeaderProcessor.java
index a212d23..0ff659b 100644
--- a/odata2-processor-jpa/jpa-web/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/extension/SalesOrderHeaderProcessor.java
+++ b/odata2-processor-jpa/jpa-web/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/extension/SalesOrderHeaderProcessor.java
@@ -1,126 +1,115 @@
-/*******************************************************************************
- * 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.jpa.processor.ref.extension;
-
-import java.util.List;
-
-import javax.persistence.EntityManager;
-import javax.persistence.Persistence;
-import javax.persistence.Query;
-
-import org.apache.olingo.odata2.api.annotation.edm.Facets;
-import org.apache.olingo.odata2.api.annotation.edm.FunctionImport;
-import org.apache.olingo.odata2.api.annotation.edm.FunctionImport.Multiplicity;
-import org.apache.olingo.odata2.api.annotation.edm.FunctionImport.ReturnType;
-import org.apache.olingo.odata2.api.annotation.edm.Parameter;
-import org.apache.olingo.odata2.api.annotation.edm.Parameter.Mode;
-import org.apache.olingo.odata2.api.annotation.edmx.HttpMethod;
-import org.apache.olingo.odata2.api.annotation.edmx.HttpMethod.Name;
-import org.apache.olingo.odata2.api.exception.ODataException;
-import org.apache.olingo.odata2.jpa.processor.ref.model.Address;
-import org.apache.olingo.odata2.jpa.processor.ref.model.SalesOrderHeader;
-import org.apache.olingo.odata2.jpa.processor.ref.model.SalesOrderItem;
-
-public class SalesOrderHeaderProcessor {
-
-  private EntityManager em;
-
-  public SalesOrderHeaderProcessor() {
-    em = Persistence.createEntityManagerFactory("salesorderprocessing")
-        .createEntityManager();
-  }
-
-  @SuppressWarnings("unchecked")
-  @FunctionImport(name = "FindAllSalesOrders", entitySet = "SalesOrders", returnType = ReturnType.ENTITY_TYPE,
-      multiplicity = Multiplicity.MANY)
-  public List<SalesOrderHeader> findAllSalesOrders(
-      @Parameter(name = "DeliveryStatusCode", facets = @Facets(maxLength = 2)) final String status) {
-
-    Query q = em
-        .createQuery("SELECT E1 from SalesOrderHeader E1 WHERE E1.deliveryStatus = '"
-            + status + "'");
-    List<SalesOrderHeader> soList = (List<SalesOrderHeader>) q
-        .getResultList();
-    return soList;
-  }
-
-  @FunctionImport(name = "CheckATP", returnType = ReturnType.SCALAR, multiplicity = Multiplicity.ONE,
-      httpMethod = @HttpMethod(name = Name.GET))
-  public boolean checkATP(
-      @Parameter(name = "SoID", facets = @Facets(nullable = false), mode = Mode.IN) final Long soID,
-      @Parameter(name = "LiId", facets = @Facets(nullable = false), mode = Mode.IN) final Long lineItemID) {
-    if (soID == 2L) {
-      return false;
-    } else {
-      return true;
-    }
-  }
-
-  @FunctionImport(returnType = ReturnType.ENTITY_TYPE, entitySet = "SalesOrders")
-  public SalesOrderHeader calculateNetAmount(
-      @Parameter(name = "SoID", facets = @Facets(nullable = false)) final Long soID)
-      throws ODataException {
-
-    if (soID <= 0L) {
-      throw new ODataException("Invalid SoID");
-    }
-
-    Query q = em
-        .createQuery("SELECT E1 from SalesOrderHeader E1 WHERE E1.soId = "
-            + soID + "l");
-    if (q.getResultList().isEmpty()) {
-      return null;
-    }
-    SalesOrderHeader so = (SalesOrderHeader) q.getResultList().get(0);
-    double amount = 0;
-    for (SalesOrderItem soi : so.getSalesOrderItem()) {
-      amount = amount
-          + (soi.getAmount() * soi.getDiscount() * soi.getQuantity());
-    }
-    so.setNetAmount(amount);
-    return so;
-  }
-
-  @SuppressWarnings("unchecked")
-  @FunctionImport(returnType = ReturnType.COMPLEX_TYPE)
-  public Address getAddress(
-      @Parameter(name = "SoID", facets = @Facets(nullable = false)) final Long soID) {
-    Query q = em
-        .createQuery("SELECT E1 from SalesOrderHeader E1 WHERE E1.soId = "
-            + soID + "l");
-    List<SalesOrderHeader> soList = (List<SalesOrderHeader>) q
-        .getResultList();
-    if (!soList.isEmpty()) {
-      return soList.get(0).getBuyerAddress();
-    } else {
-      return null;
-    }
-  }
-
-  /*
-   * This method will not be transformed into Function Import Function Import
-   * with return type as void is not supported yet.
-   */
-  @FunctionImport(returnType = ReturnType.NONE)
-  public void process(
-      @Parameter(name = "SoID", facets = @Facets(nullable = false)) final Long soID) {
-    return;
-  }
-
-}
+/*******************************************************************************
+ * 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.jpa.processor.ref.extension;
+
+import java.util.List;
+
+import javax.persistence.EntityManager;
+import javax.persistence.Persistence;
+import javax.persistence.Query;
+
+import org.apache.olingo.odata2.api.annotation.edm.EdmFacets;
+import org.apache.olingo.odata2.api.annotation.edm.EdmFunctionImport;
+import org.apache.olingo.odata2.api.annotation.edm.EdmFunctionImport.HttpMethod;
+import org.apache.olingo.odata2.api.annotation.edm.EdmFunctionImport.ReturnType;
+import org.apache.olingo.odata2.api.annotation.edm.EdmFunctionImport.ReturnType.Type;
+import org.apache.olingo.odata2.api.annotation.edm.EdmFunctionImportParameter;
+import org.apache.olingo.odata2.api.exception.ODataException;
+import org.apache.olingo.odata2.jpa.processor.ref.model.Address;
+import org.apache.olingo.odata2.jpa.processor.ref.model.SalesOrderHeader;
+import org.apache.olingo.odata2.jpa.processor.ref.model.SalesOrderItem;
+
+public class SalesOrderHeaderProcessor {
+
+  private EntityManager em;
+
+  public SalesOrderHeaderProcessor() {
+    em = Persistence.createEntityManagerFactory("salesorderprocessing")
+        .createEntityManager();
+  }
+
+  @SuppressWarnings("unchecked")
+  @EdmFunctionImport(name = "FindAllSalesOrders", entitySet = "SalesOrders", returnType = @ReturnType(
+      type = Type.ENTITY, isCollection = true))
+  public List<SalesOrderHeader> findAllSalesOrders(
+      @EdmFunctionImportParameter(name = "DeliveryStatusCode",
+          facets = @EdmFacets(maxLength = 2)) final String status) {
+
+    Query q = em
+        .createQuery("SELECT E1 from SalesOrderHeader E1 WHERE E1.deliveryStatus = '"
+            + status + "'");
+    List<SalesOrderHeader> soList = (List<SalesOrderHeader>) q
+        .getResultList();
+    return soList;
+  }
+
+  @EdmFunctionImport(name = "CheckATP", returnType = @ReturnType(type = Type.SIMPLE, isCollection = false),
+      httpMethod = HttpMethod.GET)
+  public boolean checkATP(
+      @EdmFunctionImportParameter(name = "SoID", facets = @EdmFacets(nullable = false)) final Long soID,
+      @EdmFunctionImportParameter(name = "LiId", facets = @EdmFacets(nullable = false)) final Long lineItemID) {
+    if (soID == 2L) {
+      return false;
+    } else {
+      return true;
+    }
+  }
+
+  @EdmFunctionImport(returnType = @ReturnType(type = Type.ENTITY, isCollection = true), entitySet = "SalesOrders")
+  public SalesOrderHeader calculateNetAmount(
+      @EdmFunctionImportParameter(name = "SoID", facets = @EdmFacets(nullable = false)) final Long soID)
+      throws ODataException {
+
+    if (soID <= 0L) {
+      throw new ODataException("Invalid SoID");
+    }
+
+    Query q = em
+        .createQuery("SELECT E1 from SalesOrderHeader E1 WHERE E1.soId = "
+            + soID + "l");
+    if (q.getResultList().isEmpty()) {
+      return null;
+    }
+    SalesOrderHeader so = (SalesOrderHeader) q.getResultList().get(0);
+    double amount = 0;
+    for (SalesOrderItem soi : so.getSalesOrderItem()) {
+      amount = amount
+          + (soi.getAmount() * soi.getDiscount() * soi.getQuantity());
+    }
+    so.setNetAmount(amount);
+    return so;
+  }
+
+  @SuppressWarnings("unchecked")
+  @EdmFunctionImport(returnType = @ReturnType(type = Type.COMPLEX))
+  public Address getAddress(
+      @EdmFunctionImportParameter(name = "SoID", facets = @EdmFacets(nullable = false)) final Long soID) {
+    Query q = em
+        .createQuery("SELECT E1 from SalesOrderHeader E1 WHERE E1.soId = "
+            + soID + "l");
+    List<SalesOrderHeader> soList = (List<SalesOrderHeader>) q
+        .getResultList();
+    if (!soList.isEmpty()) {
+      return soList.get(0).getBuyerAddress();
+    } else {
+      return null;
+    }
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/09474017/odata2-processor-jpa/jpa-web/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/extension/_SalesOrderHeaderProcessor.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-web/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/extension/_SalesOrderHeaderProcessor.java b/odata2-processor-jpa/jpa-web/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/extension/_SalesOrderHeaderProcessor.java
new file mode 100644
index 0000000..4bc0a29
--- /dev/null
+++ b/odata2-processor-jpa/jpa-web/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/extension/_SalesOrderHeaderProcessor.java
@@ -0,0 +1,127 @@
+/*******************************************************************************
+ * 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.jpa.processor.ref.extension;
+
+import java.util.List;
+
+import javax.persistence.EntityManager;
+import javax.persistence.Persistence;
+import javax.persistence.Query;
+
+import org.apache.olingo.odata2.api.annotation.edm.Facets;
+import org.apache.olingo.odata2.api.annotation.edm.FunctionImport;
+import org.apache.olingo.odata2.api.annotation.edm.FunctionImport.Multiplicity;
+import org.apache.olingo.odata2.api.annotation.edm.FunctionImport.ReturnType;
+import org.apache.olingo.odata2.api.annotation.edm.Parameter;
+import org.apache.olingo.odata2.api.annotation.edm.Parameter.Mode;
+import org.apache.olingo.odata2.api.annotation.edmx.HttpMethod;
+import org.apache.olingo.odata2.api.annotation.edmx.HttpMethod.Name;
+import org.apache.olingo.odata2.api.exception.ODataException;
+import org.apache.olingo.odata2.jpa.processor.ref.model.Address;
+import org.apache.olingo.odata2.jpa.processor.ref.model.SalesOrderHeader;
+import org.apache.olingo.odata2.jpa.processor.ref.model.SalesOrderItem;
+
+@Deprecated
+public class _SalesOrderHeaderProcessor {
+
+  private EntityManager em;
+
+  public _SalesOrderHeaderProcessor() {
+    em = Persistence.createEntityManagerFactory("salesorderprocessing")
+        .createEntityManager();
+  }
+
+  @SuppressWarnings("unchecked")
+  @FunctionImport(name = "FindAllSalesOrders", entitySet = "SalesOrders", returnType = ReturnType.ENTITY_TYPE,
+      multiplicity = Multiplicity.MANY)
+  public List<SalesOrderHeader> findAllSalesOrders(
+      @Parameter(name = "DeliveryStatusCode", facets = @Facets(maxLength = 2)) final String status) {
+
+    Query q = em
+        .createQuery("SELECT E1 from SalesOrderHeader E1 WHERE E1.deliveryStatus = '"
+            + status + "'");
+    List<SalesOrderHeader> soList = (List<SalesOrderHeader>) q
+        .getResultList();
+    return soList;
+  }
+
+  @FunctionImport(name = "CheckATP", returnType = ReturnType.SCALAR, multiplicity = Multiplicity.ONE,
+      httpMethod = @HttpMethod(name = Name.GET))
+  public boolean checkATP(
+      @Parameter(name = "SoID", facets = @Facets(nullable = false), mode = Mode.IN) final Long soID,
+      @Parameter(name = "LiId", facets = @Facets(nullable = false), mode = Mode.IN) final Long lineItemID) {
+    if (soID == 2L) {
+      return false;
+    } else {
+      return true;
+    }
+  }
+
+  @FunctionImport(returnType = ReturnType.ENTITY_TYPE, entitySet = "SalesOrders")
+  public SalesOrderHeader calculateNetAmount(
+      @Parameter(name = "SoID", facets = @Facets(nullable = false)) final Long soID)
+      throws ODataException {
+
+    if (soID <= 0L) {
+      throw new ODataException("Invalid SoID");
+    }
+
+    Query q = em
+        .createQuery("SELECT E1 from SalesOrderHeader E1 WHERE E1.soId = "
+            + soID + "l");
+    if (q.getResultList().isEmpty()) {
+      return null;
+    }
+    SalesOrderHeader so = (SalesOrderHeader) q.getResultList().get(0);
+    double amount = 0;
+    for (SalesOrderItem soi : so.getSalesOrderItem()) {
+      amount = amount
+          + (soi.getAmount() * soi.getDiscount() * soi.getQuantity());
+    }
+    so.setNetAmount(amount);
+    return so;
+  }
+
+  @SuppressWarnings("unchecked")
+  @FunctionImport(returnType = ReturnType.COMPLEX_TYPE)
+  public Address getAddress(
+      @Parameter(name = "SoID", facets = @Facets(nullable = false)) final Long soID) {
+    Query q = em
+        .createQuery("SELECT E1 from SalesOrderHeader E1 WHERE E1.soId = "
+            + soID + "l");
+    List<SalesOrderHeader> soList = (List<SalesOrderHeader>) q
+        .getResultList();
+    if (!soList.isEmpty()) {
+      return soList.get(0).getBuyerAddress();
+    } else {
+      return null;
+    }
+  }
+
+  /*
+   * This method will not be transformed into Function Import Function Import
+   * with return type as void is not supported yet.
+   */
+  @FunctionImport(returnType = ReturnType.NONE)
+  public void process(
+      @Parameter(name = "SoID", facets = @Facets(nullable = false)) final Long soID) {
+    return;
+  }
+
+}