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/18 10:11:59 UTC
[01/37] [OLINGO-82] Renamed the project folder name to
odata2-jpa-processor
Updated Branches:
refs/heads/master 33c4701f7 -> 1b479e6c0
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-web/src/main/webapp/index.jsp
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-web/src/main/webapp/index.jsp b/odata2-processor-jpa/jpa-web/src/main/webapp/index.jsp
deleted file mode 100644
index cc5522e..0000000
--- a/odata2-processor-jpa/jpa-web/src/main/webapp/index.jsp
+++ /dev/null
@@ -1,312 +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.
--->
-<%@page
- import="org.apache.olingo.odata2.jpa.processor.ref.factory.JPAEntityManagerFactory"%>
-<%@page import="java.util.List"%>
-<%@page import="javax.persistence.EntityManager"%>
-<%@page import="javax.persistence.EntityManagerFactory"%>
-<%@page import="javax.persistence.Persistence"%>
-<%@page import="javax.persistence.Query"%>
-<%@page
- import="org.apache.olingo.odata2.jpa.processor.ref.web.JPAReferenceServiceFactory"%>
-<%@page
- import="org.apache.olingo.odata2.jpa.processor.ref.util.DataGenerator"%>
-
-<%@ page language="java" contentType="text/html; charset=UTF-8"
- pageEncoding="UTF-8"%>
-<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
-<html>
-<head>
-<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
-<title>Apache Olingo - OData2 JPA Processor Library</title>
-<style type="text/css">
-body {
- font-family: Arial, sans-serif;
- font-size: 13px;
- line-height: 18px;
- color: blue;
- background-color: #ffffff;
-}
-
-a {
- color: blue;
- text-decoration: none;
-}
-
-a:focus {
- outline: thin dotted #4076cb;
- outline-offset: -1px;
-}
-
-a:hover,a:active {
- outline: 0;
-}
-
-a:hover {
- color: #404a7e;
- text-decoration: underline;
-}
-
-h1,h2,h3,h4,h5,h6 {
- margin: 9px 0;
- font-family: inherit;
- font-weight: bold;
- line-height: 1;
- color: blue;
-}
-
-h1 {
- font-size: 36px;
- line-height: 40px;
-}
-
-h2 {
- font-size: 30px;
- line-height: 40px;
-}
-
-h3 {
- font-size: 24px;
- line-height: 40px;
-}
-
-h4 {
- font-size: 18px;
- line-height: 20px;
-}
-
-h5 {
- font-size: 14px;
- line-height: 20px;
-}
-
-h6 {
- font-size: 12px;
- line-height: 20px;
-}
-
-.logo {
- float: right;
-}
-
-ul {
- padding: 0;
- margin: 0 0 9px 25px;
-}
-
-ul ul {
- margin-bottom: 0;
-}
-
-li {
- line-height: 18px;
-}
-
-hr {
- margin: 18px 0;
- border: 0;
- border-top: 1px solid #cccccc;
- border-bottom: 1px solid #ffffff;
-}
-
-table {
- border-collapse: collapse;
- border-spacing: 10px;
- border: 0px;
-}
-
-th,td {
- border: 0px solid;
- padding: 20px;
-}
-
-.code {
- font-family: "Courier New", monospace;
- font-size: 13px;
- line-height: 18px;
-}
-</style>
-</head>
-<body>
- <h1>Apache Olingo - OData2 JPA Processor Library</h1>
- <hr />
- <table width=100% cellspacing="1" cellpadding="1">
- <tr>
- <td width=50%><h2>Reference Scenario</h2></td>
- <td width="50%">
- <table cellspacing="1" cellpadding="1">
- <tr align="center">
- <td align="right" width="80%"><font color="green"><small>
- <%
- EntityManagerFactory entityManagerFactory =
- JPAEntityManagerFactory.getEntityManagerFactory("salesorderprocessing");
- EntityManager entityManager = entityManagerFactory
- .createEntityManager();
- System.out.println("Data Gen " + entityManager.hashCode());
- DataGenerator dataGenerator = new DataGenerator(entityManager);
-
- Number result1 = null;
- Number existingCount = null;
-
- String msg = null;
- if (request.getParameter("button") != null) {
- if (request.getParameter("button").equalsIgnoreCase("Generate")) {
- Query q = entityManager
- .createQuery("SELECT COUNT(x) FROM SalesOrderHeader x");
- existingCount = (Number) q.getSingleResult();
- if (existingCount.intValue() < 10) { // Generate only if no data!
- dataGenerator.generate();
- result1 = (Number) q.getSingleResult();
- System.out
- .println("Data not existing earlier.... Generated number of Items - "
- + result1);
- msg = result1 + " items generated. ";
-
- } else {
- System.err
- .println("Data already existing.... No Item generated by Data Generator !!");
- msg = "Data exists. No Item generated !!";
- }
- } else { //Clean
-
- // Check if data already exists
- Query q = entityManager
- .createQuery("SELECT COUNT(x) FROM SalesOrderHeader x");
- Number result = (Number) q.getSingleResult();
- if (result.intValue() > 0) { // Generate only if no data!
- dataGenerator.clean();
- msg = "Data Cleaned. " + result + " items cleaned.";
- } else {
- msg = " Nothing to clean!!";
- }
- }
- %> <%=(msg)%>
- </small> </font></td>
- <%
- }
- %>
- <td width="10%">
- <form name="form1" method="get">
- <input type="hidden" name="button" value="Generate"> <input
- type="submit" value="Generate Data" width="100%">
- </form>
- </td>
- <td width="10%">
-
- <form name="form2" method="get">
- <input type="hidden" name="button" value="Clean"> <input
- type="submit" value=" Clean Data " width="100%">
- </form>
- </td>
- </tr>
- </table>
- </td>
- </tr>
- </table>
- <table width=100%>
- <tr>
- <td valign="top">
- <h3>Service Document and Metadata</h3>
- <ul>
- <li><a href="SalesOrderProcessing.svc?_wadl" target="_blank">wadl</a></li>
- <li><a href="SalesOrderProcessing.svc/" target="_blank">service
- document</a></li>
- <li><a href="SalesOrderProcessing.svc/$metadata"
- target="_blank">metadata</a></li>
- </ul>
- <h3>EntitySets</h3>
- <ul>
- <li><a href="SalesOrderProcessing.svc/SalesOrders"
- target="_blank">SalesOrders</a></li>
- <li><a href="SalesOrderProcessing.svc/SalesOrderLineItems"
- target="_blank">SalesOrderLineItems</a></li>
- <li><a href="SalesOrderProcessing.svc/Materials"
- target="_blank">Materials</a></li>
- <li><a href="SalesOrderProcessing.svc/Stores" target="_blank">Stores</a></li>
- </ul>
- <h3>Entities</h3>
- <ul>
- <li><a href="SalesOrderProcessing.svc/SalesOrders(2L)"
- target="_blank">SalesOrders(2L)</a></li>
- <li><a
- href="SalesOrderProcessing.svc/SalesOrderLineItems(LiId=10L,SoId=2L)"
- target="_blank">SalesOrderLineItems(LiId=10L,SoId=2L)</a></li>
- <li><a href="SalesOrderProcessing.svc/Materials(111L)"
- target="_blank">Materials(111L)</a></li>
- <li><a href="SalesOrderProcessing.svc/Stores(131L)"
- target="_blank">Stores(131L)</a></li>
-
- </ul>
- <h3>Navigation</h3>
- <ul>
- <li><a
- href="SalesOrderProcessing.svc/SalesOrders(2L)/SalesOrderLineItemDetails"
- target="_blank">SalesOrders(2L)/SalesOrderLineItemDetails</a></li>
- <li><a
- href="SalesOrderProcessing.svc/SalesOrders(2L)/SalesOrderLineItemDetails"
- target="_blank">SalesOrders(2L)/SalesOrderLineItemDetails</a></li>
- <li><a
- href="SalesOrderProcessing.svc/SalesOrderLineItems(LiId=10L,SoId=2L)/MaterialDetails"
- target="_blank">SalesOrderLineItems(LiId=10L,SoId=2L)/MaterialDetails</a></li>
- <li><a
- href="SalesOrderProcessing.svc/Materials(112L)/StoreDetails"
- target="_blank">Materials(112L)/StoreDetails</a></li>
-
- </ul>
- <h3>$expand</h3>
- <ul>
- <li><a
- href="SalesOrderProcessing.svc/SalesOrders?$expand=SalesOrderLineItemDetails"
- target="_blank">SalesOrders?$expand=SalesOrderLineItemDetails</a></li>
- <li><a
- href="SalesOrderProcessing.svc/SalesOrders(2L)?$expand=SalesOrderLineItemDetails"
- target="_blank">SalesOrders(2L)?$expand=SalesOrderLineItemDetails</a></li>
- <li><a
- href="SalesOrderProcessing.svc/SalesOrders?$expand=SalesOrderLineItemDetails/MaterialDetails,SalesOrderLineItemDetails/MaterialDetails/StoreDetails,NotesDetails"
- target="_blank">SalesOrders?$expand=SalesOrderLineItemDetails/MaterialDetails,SalesOrderLineItemDetails/MaterialDetails/StoreDetails,NotesDetails</a></li>
- <li><a
- href="SalesOrderProcessing.svc/SalesOrders(2L)?$expand=SalesOrderLineItemDetails/MaterialDetails,SalesOrderLineItemDetails/MaterialDetails/StoreDetails,NotesDetails"
- target="_blank">SalesOrders(2L)?$expand=SalesOrderLineItemDetails/MaterialDetails,SalesOrderLineItemDetails/MaterialDetails/StoreDetails,NotesDetails</a></li>
-
- </ul>
- </td>
- <td valign="top"> </td>
- <td valign="bottom">
- <div class="code">
- <%
- String version = "gen/version.html";
- %>
- <%
- try {
- %>
- <jsp:include page='<%=version%>' />
- <%
- } catch (Exception e) {
- %>
- <p>IDE Build</p>
- <%
- }
- %>
- </div>
- </td>
- </tr>
- </table>
-</body>
-</html>
-
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/pom.xml
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/pom.xml b/odata2-processor-jpa/pom.xml
deleted file mode 100644
index f6f4706..0000000
--- a/odata2-processor-jpa/pom.xml
+++ /dev/null
@@ -1,31 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- 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. -->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <groupId>org.apache.olingo</groupId>
- <artifactId>olingo-odata2-jpa-processor-incubating</artifactId>
- <packaging>pom</packaging>
- <name>${project.artifactId}</name>
-
- <parent>
- <groupId>org.apache.olingo</groupId>
- <artifactId>olingo-odata2-parent-incubating</artifactId>
- <version>1.1.0-SNAPSHOT</version>
- <relativePath>..</relativePath>
- </parent>
-
- <modules>
- <module>jpa-api</module>
- <module>jpa-core</module>
- <module>jpa-ref</module>
- <module>jpa-web</module>
- </modules>
-</project>
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 19c21a0..e3d43ea 100644
--- a/pom.xml
+++ b/pom.xml
@@ -74,7 +74,7 @@
<modules>
<module>odata2-lib</module>
- <module>odata2-processor-jpa</module>
+ <module>odata2-jpa-processor</module>
<module>odata2-annotation-processor</module>
<module>odata2-dist</module>
<module>odata2-sample</module>
[23/37] [OLINGO-82] Renamed the project folder name to
odata2-jpa-processor
Posted by ch...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmAssociationSetTest.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmAssociationSetTest.java b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmAssociationSetTest.java
new file mode 100644
index 0000000..965d3d7
--- /dev/null
+++ b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmAssociationSetTest.java
@@ -0,0 +1,184 @@
+/*******************************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ ******************************************************************************/
+package org.apache.olingo.odata2.processor.core.jpa.model;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.olingo.odata2.api.edm.FullQualifiedName;
+import org.apache.olingo.odata2.api.edm.provider.Association;
+import org.apache.olingo.odata2.api.edm.provider.AssociationEnd;
+import org.apache.olingo.odata2.api.edm.provider.AssociationSet;
+import org.apache.olingo.odata2.api.edm.provider.AssociationSetEnd;
+import org.apache.olingo.odata2.api.edm.provider.EntitySet;
+import org.apache.olingo.odata2.api.edm.provider.Schema;
+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.JPAEdmAssociationView;
+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.core.jpa.common.ODataJPATestConstants;
+import org.junit.Before;
+import org.junit.Test;
+
+public class JPAEdmAssociationSetTest extends JPAEdmTestModelView {
+
+ private JPAEdmAssociationSetTest objJPAEdmAssociationSetTest;
+ private JPAEdmAssociationSet objJPAEdmAssociationSet;
+
+ @Before
+ public void setUp() {
+ objJPAEdmAssociationSetTest = new JPAEdmAssociationSetTest();
+ objJPAEdmAssociationSet = new JPAEdmAssociationSet(objJPAEdmAssociationSetTest);
+ try {
+ objJPAEdmAssociationSet.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);
+ }
+
+ }
+
+ @Test
+ public void testGetBuilder() {
+ assertNotNull(objJPAEdmAssociationSet.getBuilder());
+ }
+
+ @Test
+ public void testGetConsistentEdmAssociationSetList() {
+ assertNotNull(objJPAEdmAssociationSet.getConsistentEdmAssociationSetList());
+ }
+
+ @Test
+ public void testGetEdmAssociationSet() {
+ assertNotNull(objJPAEdmAssociationSet.getEdmAssociationSet());
+ }
+
+ @Test
+ public void testGetEdmAssociation() {
+ assertNotNull(objJPAEdmAssociationSet.getEdmAssociation());
+ }
+
+ @Test
+ public void testIsConsistent() {
+ assertTrue(objJPAEdmAssociationSet.isConsistent());
+ }
+
+ @Test
+ public void testGetBuilderIdempotent() {
+ JPAEdmBuilder builder1 = objJPAEdmAssociationSet.getBuilder();
+ JPAEdmBuilder builder2 = objJPAEdmAssociationSet.getBuilder();
+
+ assertEquals(builder1.hashCode(), builder2.hashCode());
+ }
+
+ @Override
+ public JPAEdmEntityContainerView getJPAEdmEntityContainerView() {
+ return this;
+ }
+
+ @Override
+ public JPAEdmEntitySetView getJPAEdmEntitySetView() {
+ return this;
+ }
+
+ @Override
+ public JPAEdmAssociationView getJPAEdmAssociationView() {
+ return this;
+ }
+
+ @Override
+ public AssociationSet getEdmAssociationSet() {
+ AssociationSet associationSet = new AssociationSet();
+ associationSet.setEnd1(new AssociationSetEnd());
+ associationSet.setEnd2(new AssociationSetEnd());
+
+ return associationSet;
+ }
+
+ @Override
+ public List<Association> getConsistentEdmAssociationList() {
+ return getEdmAssociationListLocal();
+ }
+
+ @Override
+ public List<AssociationSet> getConsistentEdmAssociationSetList() {
+
+ List<AssociationSet> associationSetList = new ArrayList<AssociationSet>();
+ associationSetList.add(getEdmAssociationSet());
+ associationSetList.add(getEdmAssociationSet());
+
+ return associationSetList;
+ }
+
+ @Override
+ public List<EntitySet> getConsistentEdmEntitySetList() {
+ return getEntitySetListLocal();
+ }
+
+ @Override
+ public boolean isConsistent() {
+ return true;
+ }
+
+ @Override
+ public Schema getEdmSchema() {
+ Schema schema = new Schema();
+ schema.setNamespace("salesordereprocessing");
+ return schema;
+ }
+
+ private List<EntitySet> getEntitySetListLocal() {
+ List<EntitySet> entitySetList = new ArrayList<EntitySet>();
+
+ EntitySet entitySet = new EntitySet();
+ entitySet.setName("SalesOrderHeader");
+ entitySet.setEntityType(new FullQualifiedName("salesorderprocessing", "SOID"));
+
+ EntitySet entitySet2 = new EntitySet();
+ entitySet2.setName("SalesOrderItem");
+ entitySet2.setEntityType(new FullQualifiedName("salesorderprocessing", "SOID"));
+
+ entitySetList.add(entitySet);
+ entitySetList.add(entitySet2);
+ return entitySetList;
+ }
+
+ private List<Association> getEdmAssociationListLocal() {
+ List<Association> associationList = new ArrayList<Association>();
+
+ Association association = new Association();
+ association.setName("Assoc_SalesOrderHeader_SalesOrderItem");
+ association.setEnd1(new AssociationEnd().setType(new FullQualifiedName("salesorderprocessing", "String")).setRole(
+ "SalesOrderHeader"));
+ association.setEnd2(new AssociationEnd().setType(new FullQualifiedName("salesorderprocessing", "SalesOrderItem"))
+ .setRole("SalesOrderItem"));
+
+ associationList.add(association);
+ return associationList;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmAssociationTest.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmAssociationTest.java b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmAssociationTest.java
new file mode 100644
index 0000000..8c6d1f9
--- /dev/null
+++ b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmAssociationTest.java
@@ -0,0 +1,423 @@
+/*******************************************************************************
+
+ * 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.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.AnnotatedElement;
+import java.lang.reflect.Field;
+import java.lang.reflect.Member;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.persistence.JoinColumn;
+import javax.persistence.OneToMany;
+import javax.persistence.metamodel.Attribute;
+
+import org.apache.olingo.odata2.api.edm.EdmMultiplicity;
+import org.apache.olingo.odata2.api.edm.FullQualifiedName;
+import org.apache.olingo.odata2.api.edm.provider.Association;
+import org.apache.olingo.odata2.api.edm.provider.AssociationEnd;
+import org.apache.olingo.odata2.api.edm.provider.EntityType;
+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.JPAEdmAssociationEndView;
+import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmReferentialConstraintView;
+import org.apache.olingo.odata2.processor.core.jpa.common.ODataJPATestConstants;
+import org.apache.olingo.odata2.processor.core.jpa.mock.model.JPAAttributeMock;
+import org.apache.olingo.odata2.processor.core.jpa.mock.model.JPAEdmMockData.SimpleType;
+import org.apache.olingo.odata2.processor.core.jpa.mock.model.JPAEdmMockData.SimpleType.SimpleTypeA;
+import org.easymock.EasyMock;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class JPAEdmAssociationTest extends JPAEdmTestModelView {
+
+ private static JPAEdmAssociation objAssociation = null;
+ private static String ASSOCIATION_NAME = "SalesOrderHeader_String";
+ private static JPAEdmAssociationTest localView = null;
+ private static final String PUNIT_NAME = "salesorderprocessing";
+ private int variant;
+
+ @BeforeClass
+ public static void setup() {
+ localView = new JPAEdmAssociationTest();
+ objAssociation = new JPAEdmAssociation(localView, localView, localView, 1);
+ try {
+ objAssociation.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);
+ }
+ }
+
+ @Override
+ public AssociationEnd getEdmAssociationEnd1() {
+ AssociationEnd associationEnd = new AssociationEnd();
+ associationEnd.setType(new FullQualifiedName("salesorderprocessing", "SalesOrderHeader"));
+ associationEnd.setRole("SalesOrderHeader");
+ associationEnd.setMultiplicity(EdmMultiplicity.ONE);
+ return associationEnd;
+ }
+
+ @Override
+ public AssociationEnd getEdmAssociationEnd2() {
+ AssociationEnd associationEnd = new AssociationEnd();
+ associationEnd.setType(new FullQualifiedName("salesorderprocessing", "String"));
+ associationEnd.setRole("String");
+ associationEnd.setMultiplicity(EdmMultiplicity.MANY);
+ return associationEnd;
+ }
+
+ @Override
+ public Association getEdmAssociation() {
+ Association association = new Association();
+ association
+ .setEnd1(new AssociationEnd().setType(new FullQualifiedName("salesorderprocessing", "SalesOrderHeader")));
+ association.setEnd2(new AssociationEnd().setType(new FullQualifiedName("salesorderprocessing", "String")));
+
+ return association;
+ }
+
+ @Override
+ public boolean isExists() {
+ return true;
+ }
+
+ @Override
+ public JPAEdmReferentialConstraintView getJPAEdmReferentialConstraintView() {
+ JPAEdmReferentialConstraint refConstraintView = new JPAEdmReferentialConstraint(localView, localView, localView);
+ return refConstraintView;
+ }
+
+ @Override
+ public Attribute<?, ?> getJPAAttribute() {
+ return getJPAAttributeLocal();
+ }
+
+ @Override
+ public String getpUnitName() {
+ return PUNIT_NAME;
+ }
+
+ @Override
+ public EntityType getEdmEntityType() {
+ EntityType entityType = new EntityType();
+ entityType.setName(SimpleTypeA.NAME);
+ return entityType;
+ }
+
+ // The inner class which gives us an replica of the jpa attribute
+ @SuppressWarnings("hiding")
+ private class AttributeMock<Object, String> extends JPAAttributeMock<Object, String> {
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public Class<String> getJavaType() {
+ return (Class<String>) SimpleType.SimpleTypeA.clazz;
+ }
+
+ @Override
+ public PersistentAttributeType getPersistentAttributeType() {
+ if (variant == 1) {
+ return PersistentAttributeType.ONE_TO_MANY;
+ } else if (variant == 2) {
+ return PersistentAttributeType.ONE_TO_ONE;
+ } else if (variant == 2) {
+ return PersistentAttributeType.MANY_TO_ONE;
+ } else {
+ return PersistentAttributeType.MANY_TO_MANY;
+ }
+
+ }
+ }
+
+ private Attribute<?, ?> getJPAAttributeLocal() {
+ AttributeMock<Object, String> attr = new AttributeMock<Object, String>();
+ return attr;
+ }
+
+ @Test
+ public void testGetBuilder() {
+ assertNotNull(objAssociation.getBuilder());
+ }
+
+ @Test
+ public void testGetEdmAssociation() {
+ assertNotNull(objAssociation.getEdmAssociation());
+ assertEquals(objAssociation.getEdmAssociation().getName(), ASSOCIATION_NAME);
+ }
+
+ @Test
+ public void testGetConsistentEdmAssociationList() {
+ assertTrue(objAssociation.getConsistentEdmAssociationList().size() > 0);
+ }
+
+ @Override
+ public String getEdmRelationShipName() {
+ return "Association_SalesOrderHeader_String";
+ }
+
+ @Test
+ public void testSearchAssociation1() {
+ class TestAssociationEndView extends JPAEdmTestModelView {
+ @Override
+ public String getEdmRelationShipName() {
+ return "SalesOrderHeader_String1";
+ }
+
+ private Attribute<?, ?> getJPAAttributeLocal() {
+ AttributeMock<Object, String> attr = new AttributeMock<Object, String>();
+ return attr;
+ }
+
+ @Override
+ public Attribute<?, ?> getJPAAttribute() {
+ return getJPAAttributeLocal();
+ }
+
+ @Override
+ public String getJoinColumnName() {
+ return "SO_ID";
+ }
+
+ @Override
+ public String getJoinColumnReferenceColumnName() {
+ return "DEMO_ID";
+ }
+
+ @Override
+ public String getMappedByName() {
+ return "demo";
+ }
+
+ @Override
+ public String getOwningPropertyName() {
+ return "salesOrder";
+ }
+
+ @Override
+ public int getNumberOfAssociationsWithSimilarEndPoints(final JPAEdmAssociationEndView view) {
+ return 1;
+ }
+
+ @Override
+ public String getpUnitName() {
+ return "salesorderprocessing";
+ }
+
+ @Override
+ public EntityType getEdmEntityType() {
+ EntityType entityType = new EntityType();
+ entityType.setName("SalesOrderHeader");
+ return entityType;
+ }
+
+ @SuppressWarnings("hiding")
+ class AttributeMock<Object, String> extends JPAAttributeMock<Object, String> {
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public Class<String> getJavaType() {
+ return (Class<String>) SimpleType.SimpleTypeA.clazz;
+ }
+
+ @Override
+ public PersistentAttributeType getPersistentAttributeType() {
+
+ return PersistentAttributeType.ONE_TO_MANY;
+
+ }
+
+ @Override
+ public Member getJavaMember() {
+ return new AnnotatedElementMock();
+ }
+
+ @Override
+ public java.lang.String getName() {
+ // TODO Auto-generated method stub
+ return super.getName();
+ }
+
+ class AnnotatedElementMock implements AnnotatedElement, Member {
+
+ @Override
+ public boolean isAnnotationPresent(final Class<? extends Annotation> annotationClass) {
+ return true;
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public Annotation getAnnotation(@SuppressWarnings("rawtypes") final Class annotationClass) {
+ if (annotationClass.equals(JoinColumn.class)) {
+ JoinColumn joinColumn = EasyMock.createMock(JoinColumn.class);
+ EasyMock.expect(joinColumn.name()).andStubReturn("SO_ID");
+ EasyMock.expect(joinColumn.referencedColumnName()).andStubReturn("DEMO_ID");
+ EasyMock.replay(joinColumn);
+ return joinColumn;
+ } else {
+ OneToMany oneToMany = EasyMock.createMock(OneToMany.class);
+ EasyMock.expect(oneToMany.mappedBy()).andStubReturn("demo");
+ EasyMock.replay(oneToMany);
+ return oneToMany;
+ }
+ }
+
+ @Override
+ public Annotation[] getAnnotations() {
+ return null;
+ }
+
+ @Override
+ public Annotation[] getDeclaredAnnotations() {
+ return null;
+ }
+
+ @Override
+ public Class<?> getDeclaringClass() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public java.lang.String getName() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public int getModifiers() {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public boolean isSynthetic() {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ }
+
+ }
+ }
+ TestAssociationEndView objJPAEdmAssociationEndTest = new TestAssociationEndView();
+ JPAEdmAssociationEnd objJPAEdmAssociationEnd =
+ new JPAEdmAssociationEnd(objJPAEdmAssociationEndTest, objJPAEdmAssociationEndTest);
+ try {
+ objJPAEdmAssociationEnd.getBuilder().build();
+ Field field = objAssociation.getClass().getDeclaredField("associationEndMap");
+ field.setAccessible(true);
+ Map<String, JPAEdmAssociationEndView> associationEndMap = new HashMap<String, JPAEdmAssociationEndView>();
+ associationEndMap.put("SalesOrderHeader_String", objJPAEdmAssociationEnd);
+ field.set(objAssociation, associationEndMap);
+ } catch (ODataJPARuntimeException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ } catch (ODataJPAModelException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ } catch (SecurityException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ } catch (NoSuchFieldException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ } catch (IllegalArgumentException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ } catch (IllegalAccessException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+
+ assertEquals("SalesOrderHeader_String", objAssociation.searchAssociation(objJPAEdmAssociationEnd).getName());
+
+ }
+
+ @Test
+ public void testAddJPAEdmAssociationView() {
+
+ class LocalJPAAssociationView extends JPAEdmTestModelView {
+ @Override
+ public AssociationEnd getEdmAssociationEnd1() {
+ AssociationEnd associationEnd = new AssociationEnd();
+ associationEnd.setType(new FullQualifiedName("salesorderprocessing", "SalesOrderHeader"));
+ associationEnd.setRole("SalesOrderHeader");
+ associationEnd.setMultiplicity(EdmMultiplicity.ONE);
+ return associationEnd;
+ }
+
+ @Override
+ public AssociationEnd getEdmAssociationEnd2() {
+ AssociationEnd associationEnd = new AssociationEnd();
+ associationEnd.setType(new FullQualifiedName("salesorderprocessing", "SalesOrderItem"));
+ associationEnd.setRole("SalesOrderItem");
+ associationEnd.setMultiplicity(EdmMultiplicity.MANY);
+ return associationEnd;
+ }
+
+ @Override
+ public Association getEdmAssociation() {
+ Association association = new Association();
+ association.setEnd1(new AssociationEnd().setType(new FullQualifiedName("salesorderprocessing",
+ "SalesOrderHeader")));
+ association.setEnd2(new AssociationEnd()
+ .setType(new FullQualifiedName("salesorderprocessing", "SalesOrderItem")));
+
+ return association;
+ }
+ }
+ LocalJPAAssociationView assocViewObj = new LocalJPAAssociationView();
+ JPAEdmAssociation objLocalAssociation = new JPAEdmAssociation(assocViewObj, assocViewObj, assocViewObj, 1);
+ try {
+ objLocalAssociation.getBuilder().build();
+ } catch (ODataJPARuntimeException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ } catch (ODataJPAModelException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+
+ objAssociation.addJPAEdmAssociationView(objLocalAssociation, localView);
+
+ }
+
+ @Test
+ public void testAddJPAEdmRefConstraintView() {
+
+ localView = new JPAEdmAssociationTest();
+ objAssociation = new JPAEdmAssociation(localView, localView, localView, 1);
+ try {
+ objAssociation.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);
+ }
+
+ objAssociation.addJPAEdmRefConstraintView(localView);
+ assertTrue(objAssociation.getConsistentEdmAssociationList().size() > 0);
+ }
+
+ @Test
+ public void testGetJPAEdmReferentialConstraintView() {
+
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmBaseViewImplTest.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmBaseViewImplTest.java b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmBaseViewImplTest.java
new file mode 100644
index 0000000..bdbf104
--- /dev/null
+++ b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmBaseViewImplTest.java
@@ -0,0 +1,89 @@
+/*******************************************************************************
+ * 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.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import javax.persistence.metamodel.Metamodel;
+
+import org.apache.olingo.odata2.processor.api.jpa.access.JPAEdmBuilder;
+import org.apache.olingo.odata2.processor.core.jpa.mock.model.JPAMetaModelMock;
+import org.junit.Before;
+import org.junit.Test;
+
+public class JPAEdmBaseViewImplTest extends JPAEdmTestModelView {
+
+ private JPAEdmBaseViewImplTest objJPAEdmBaseViewImplTest;
+ private JPAEdmBaseViewImpl objJPAEdmBaseViewImpl;
+
+ @Before
+ public void setUp() {
+ objJPAEdmBaseViewImplTest = new JPAEdmBaseViewImplTest();
+ objJPAEdmBaseViewImpl = new JPAEdmBaseViewImpl(objJPAEdmBaseViewImplTest) {
+
+ @Override
+ public JPAEdmBuilder getBuilder() {
+ return null;
+ }
+ };
+
+ objJPAEdmBaseViewImpl = new JPAEdmBaseViewImpl(getJPAMetaModel(), getpUnitName()) {
+
+ @Override
+ public JPAEdmBuilder getBuilder() {
+ return null;
+ }
+ };
+
+ }
+
+ @Test
+ public void testGetpUnitName() {
+ assertTrue(objJPAEdmBaseViewImpl.getpUnitName().equals("salesorderprocessing"));
+ }
+
+ @Test
+ public void testGetJPAMetaModel() {
+ assertNotNull(objJPAEdmBaseViewImpl.getJPAMetaModel());
+ }
+
+ @Test
+ public void testIsConsistent() {
+ assertTrue(objJPAEdmBaseViewImpl.isConsistent());
+ }
+
+ @Test
+ public void testClean() {
+ objJPAEdmBaseViewImpl.clean();
+ assertFalse(objJPAEdmBaseViewImpl.isConsistent());
+ }
+
+ @Override
+ public String getpUnitName() {
+ return "salesorderprocessing";
+ }
+
+ @Override
+ public Metamodel getJPAMetaModel() {
+ return new JPAMetaModelMock();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmComplexTypeTest.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmComplexTypeTest.java b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmComplexTypeTest.java
new file mode 100644
index 0000000..2fabe8c
--- /dev/null
+++ b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmComplexTypeTest.java
@@ -0,0 +1,268 @@
+/*******************************************************************************
+ * 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.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import javax.persistence.metamodel.Attribute;
+import javax.persistence.metamodel.EmbeddableType;
+import javax.persistence.metamodel.Metamodel;
+
+import org.apache.olingo.odata2.api.edm.FullQualifiedName;
+import org.apache.olingo.odata2.api.edm.provider.ComplexType;
+import org.apache.olingo.odata2.api.edm.provider.Mapping;
+import org.apache.olingo.odata2.api.edm.provider.Property;
+import org.apache.olingo.odata2.api.edm.provider.SimpleProperty;
+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.JPAEdmMapping;
+import org.apache.olingo.odata2.processor.core.jpa.common.ODataJPATestConstants;
+import org.apache.olingo.odata2.processor.core.jpa.mock.model.JPAEmbeddableMock;
+import org.apache.olingo.odata2.processor.core.jpa.mock.model.JPAMetaModelMock;
+import org.apache.olingo.odata2.processor.core.jpa.mock.model.JPASingularAttributeMock;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class JPAEdmComplexTypeTest extends JPAEdmTestModelView {
+
+ private static JPAEdmComplexType objComplexType = null;
+ private static JPAEdmComplexTypeTest localView = null;
+
+ @BeforeClass
+ public static void setup() {
+ localView = new JPAEdmComplexTypeTest();
+ objComplexType = new JPAEdmComplexType(localView);
+ try {
+ objComplexType.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);
+ }
+ }
+
+ @SuppressWarnings("rawtypes")
+ @Override
+ public EmbeddableType<?> getJPAEmbeddableType() {
+ @SuppressWarnings("hiding")
+ class JPAComplexAttribute<Long> extends JPAEmbeddableMock<Long> {
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public Class<Long> getJavaType() {
+
+ return (Class<Long>) java.lang.Long.class;
+ }
+
+ }
+ return new JPAComplexAttribute();
+ }
+
+ @Override
+ public String getpUnitName() {
+ return "salesorderprocessing";
+ }
+
+ @Override
+ public Metamodel getJPAMetaModel() {
+ return new JPAEdmMetaModel();
+ }
+
+ @Test
+ public void testGetBuilder() {
+
+ assertNotNull(objComplexType.getBuilder());
+ }
+
+ @Test
+ public void testGetEdmComplexType() {
+ assertEquals(objComplexType.getEdmComplexType().getName(), "String");
+ }
+
+ @Test
+ public void testSearchComplexTypeString() {
+ assertNotNull(objComplexType.searchEdmComplexType("java.lang.String"));
+
+ }
+
+ @Test
+ public void testGetJPAEmbeddableType() {
+ assertTrue(objComplexType.getJPAEmbeddableType().getAttributes().size() > 0);
+
+ }
+
+ @Test
+ public void testGetConsistentEdmComplexTypes() {
+ assertTrue(objComplexType.getConsistentEdmComplexTypes().size() > 0);
+ }
+
+ @Test
+ public void testSearchComplexTypeFullQualifiedName() {
+ assertNotNull(objComplexType.searchEdmComplexType(new FullQualifiedName("salesorderprocessing", "String")));
+
+ }
+
+ @Test
+ public void testSearchComplexTypeFullQualifiedNameNegative() {
+ assertNull(objComplexType.searchEdmComplexType(new FullQualifiedName("salesorderprocessing", "lang.String")));
+ }
+
+ @Test
+ public void testGetBuilderIdempotent() {
+ JPAEdmBuilder builder1 = objComplexType.getBuilder();
+ JPAEdmBuilder builder2 = objComplexType.getBuilder();
+
+ assertEquals(builder1.hashCode(), builder2.hashCode());
+ }
+
+ @Test
+ public void testAddCompleTypeView() {
+ localView = new JPAEdmComplexTypeTest();
+ objComplexType = new JPAEdmComplexType(localView);
+ try {
+ objComplexType.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);
+ }
+
+ objComplexType.addJPAEdmCompleTypeView(localView);
+ assertTrue(objComplexType.getConsistentEdmComplexTypes().size() > 1);
+ }
+
+ @Test
+ public void testExpandEdmComplexType() {
+ ComplexType complexType = new ComplexType();
+ List<Property> properties = new ArrayList<Property>();
+ JPAEdmMapping mapping1 = new JPAEdmMappingImpl();
+ mapping1.setJPAColumnName("LINEITEMID");
+ ((Mapping) mapping1).setInternalName("LineItemKey.LiId");
+ JPAEdmMapping mapping2 = new JPAEdmMappingImpl();
+ mapping2.setJPAColumnName("LINEITEMNAME");
+ ((Mapping) mapping2).setInternalName("LineItemKey.LiName");
+ properties.add(new SimpleProperty().setName("LIID").setMapping((Mapping) mapping1));
+ properties.add(new SimpleProperty().setName("LINAME").setMapping((Mapping) mapping2));
+ complexType.setProperties(properties);
+ List<Property> expandedList = null;
+ try {
+ objComplexType.expandEdmComplexType(complexType, expandedList, "SalesOrderItemKey");
+ } catch (ClassCastException e) {
+ assertTrue(false);
+ }
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testComplexTypeCreation() {
+ try {
+ objComplexType.getBuilder().build();
+ } catch (ODataJPARuntimeException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ } catch (ODataJPAModelException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+ assertEquals(objComplexType.pUnitName, "salesorderprocessing");
+ }
+
+ private class JPAEdmMetaModel extends JPAMetaModelMock {
+ Set<EmbeddableType<?>> embeddableSet;
+
+ public JPAEdmMetaModel() {
+ embeddableSet = new HashSet<EmbeddableType<?>>();
+ }
+
+ @Override
+ public Set<EmbeddableType<?>> getEmbeddables() {
+ embeddableSet.add(new JPAEdmEmbeddable<String>());
+ return embeddableSet;
+ }
+
+ }
+
+ @SuppressWarnings("hiding")
+ private class JPAEdmEmbeddable<String> extends JPAEmbeddableMock<String> {
+
+ Set<Attribute<? super String, ?>> attributeSet = new HashSet<Attribute<? super String, ?>>();
+
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ private void setValuesToSet() {
+ attributeSet.add((Attribute<? super String, String>) new JPAEdmAttribute(java.lang.String.class, "SOID"));
+ attributeSet.add((Attribute<? super String, String>) new JPAEdmAttribute(java.lang.String.class, "SONAME"));
+ }
+
+ @Override
+ public Set<Attribute<? super String, ?>> getAttributes() {
+ setValuesToSet();
+ return attributeSet;
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public Class<String> getJavaType() {
+ return (Class<String>) java.lang.String.class;
+ }
+
+ }
+
+ @SuppressWarnings("hiding")
+ private class JPAEdmAttribute<Object, String> extends JPASingularAttributeMock<Object, String> {
+
+ @Override
+ public PersistentAttributeType getPersistentAttributeType() {
+ return PersistentAttributeType.BASIC;
+ }
+
+ Class<String> clazz;
+ java.lang.String attributeName;
+
+ public JPAEdmAttribute(final Class<String> javaType, final java.lang.String name) {
+ this.clazz = javaType;
+ this.attributeName = name;
+
+ }
+
+ @Override
+ public Class<String> getJavaType() {
+ return clazz;
+ }
+
+ @Override
+ public java.lang.String getName() {
+ return this.attributeName;
+ }
+
+ @Override
+ public boolean isId() {
+ return false;
+ }
+
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmEntityContainerTest.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmEntityContainerTest.java b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmEntityContainerTest.java
new file mode 100644
index 0000000..4e9355b
--- /dev/null
+++ b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmEntityContainerTest.java
@@ -0,0 +1,234 @@
+/*******************************************************************************
+ * 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.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.persistence.metamodel.Attribute;
+import javax.persistence.metamodel.EntityType;
+import javax.persistence.metamodel.Metamodel;
+
+import org.apache.olingo.odata2.api.edm.provider.Schema;
+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.JPAEdmAssociationView;
+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.core.jpa.common.ODataJPATestConstants;
+import org.apache.olingo.odata2.processor.core.jpa.mock.model.JPAEntityTypeMock;
+import org.apache.olingo.odata2.processor.core.jpa.mock.model.JPAMetaModelMock;
+import org.apache.olingo.odata2.processor.core.jpa.mock.model.JPASingularAttributeMock;
+import org.junit.Before;
+import org.junit.Test;
+
+public class JPAEdmEntityContainerTest extends JPAEdmTestModelView {
+
+ private JPAEdmEntityContainer objJPAEdmEntityContainer;
+ private JPAEdmEntityContainerTest objJPAEdmEntityContainerTest;
+
+ @Before
+ public void setUp() {
+ objJPAEdmEntityContainerTest = new JPAEdmEntityContainerTest();
+ objJPAEdmEntityContainer = new JPAEdmEntityContainer(objJPAEdmEntityContainerTest);
+ try {
+ objJPAEdmEntityContainer.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);
+ }
+ }
+
+ @Test
+ public void testGetBuilder() {
+ assertNotNull(objJPAEdmEntityContainer.getBuilder());
+ }
+
+ @Test
+ public void testGetEdmEntityContainer() {
+ assertNotNull(objJPAEdmEntityContainer.getEdmEntityContainer());
+ assertTrue(objJPAEdmEntityContainer.getEdmEntityContainer().getEntitySets().size() > 0);
+ }
+
+ @Test
+ public void testGetConsistentEdmEntityContainerList() {
+ assertNotNull(objJPAEdmEntityContainer.getConsistentEdmEntityContainerList());
+ assertTrue(objJPAEdmEntityContainer.getConsistentEdmEntityContainerList().size() > 0);
+
+ }
+
+ @Test
+ public void testGetJPAEdmEntitySetView() {
+ assertNotNull(objJPAEdmEntityContainer.getJPAEdmEntitySetView());
+ assertEquals("salesorderprocessing", objJPAEdmEntityContainer.getJPAEdmEntitySetView().getpUnitName());
+ }
+
+ @Test
+ public void testIsConsistent() {
+ assertTrue(objJPAEdmEntityContainer.isConsistent());
+ objJPAEdmEntityContainer.clean();
+ assertFalse(objJPAEdmEntityContainer.isConsistent());
+ }
+
+ @Test
+ public void testGetEdmAssociationSetView() {
+ assertNotNull(objJPAEdmEntityContainer.getEdmAssociationSetView());
+ }
+
+ @Test
+ public void testGetBuilderIdempotent() {
+ JPAEdmBuilder builder1 = objJPAEdmEntityContainer.getBuilder();
+ JPAEdmBuilder builder2 = objJPAEdmEntityContainer.getBuilder();
+
+ assertEquals(builder1.hashCode(), builder2.hashCode());
+ }
+
+ @Override
+ public Metamodel getJPAMetaModel() {
+ return new JPAEdmMetaModel();
+ }
+
+ @Override
+ public JPAEdmEntitySetView getJPAEdmEntitySetView() {
+ return this;
+ }
+
+ @Override
+ public JPAEdmEntityContainerView getJPAEdmEntityContainerView() {
+ return this;
+ }
+
+ @Override
+ public EntityType<?> getJPAEntityType() {
+ return new JPAEdmEntityType<String>();
+ }
+
+ @Override
+ public JPAEdmEntityTypeView getJPAEdmEntityTypeView() {
+ return this;
+ }
+
+ @Override
+ public Schema getEdmSchema() {
+ Schema schema = new Schema();
+ schema.setNamespace("salesordereprocessing");
+ return schema;
+ }
+
+ @Override
+ public String getpUnitName() {
+ return "salesorderprocessing";
+ }
+
+ @Override
+ public JPAEdmAssociationView getJPAEdmAssociationView() {
+ return this;
+ }
+
+ @Override
+ public JPAEdmBuilder getBuilder() {
+ return new JPAEdmBuilder() {
+
+ @Override
+ public void build() {
+ // Nothing to do?
+ }
+ };
+ }
+
+ private class JPAEdmMetaModel extends JPAMetaModelMock {
+ Set<EntityType<?>> entities;
+
+ public JPAEdmMetaModel() {
+ entities = new HashSet<EntityType<?>>();
+ }
+
+ @Override
+ public Set<EntityType<?>> getEntities() {
+ entities.add(new JPAEdmEntityType());
+ return entities;
+ }
+
+ private class JPAEdmEntityType extends JPAEntityTypeMock<String> {
+ @Override
+ public String getName() {
+ return "SalesOrderHeader";
+ }
+ }
+ }
+
+ @SuppressWarnings("hiding")
+ private class JPAEdmEntityType<String> extends JPAEntityTypeMock<String> {
+ Set<Attribute<? super String, ?>> attributeSet = new HashSet<Attribute<? super String, ?>>();
+
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ private void setValuesToSet() {
+ attributeSet.add((Attribute<? super String, String>) new JPAEdmAttribute(java.lang.String.class, "SOID"));
+ attributeSet.add((Attribute<? super String, String>) new JPAEdmAttribute(java.lang.String.class, "SONAME"));
+ }
+
+ @Override
+ public Set<Attribute<? super String, ?>> getAttributes() {
+ setValuesToSet();
+ return attributeSet;
+ }
+
+ private class JPAEdmAttribute<Object, String> extends JPASingularAttributeMock<Object, String> {
+
+ @Override
+ public PersistentAttributeType getPersistentAttributeType() {
+ return PersistentAttributeType.BASIC;
+ }
+
+ Class<String> clazz;
+ java.lang.String attributeName;
+
+ public JPAEdmAttribute(final Class<String> javaType, final java.lang.String name) {
+ this.clazz = javaType;
+ this.attributeName = name;
+
+ }
+
+ @Override
+ public Class<String> getJavaType() {
+ return clazz;
+ }
+
+ @Override
+ public java.lang.String getName() {
+ return this.attributeName;
+ }
+
+ @Override
+ public boolean isId() {
+ return true;
+ }
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmEntitySetTest.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmEntitySetTest.java b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmEntitySetTest.java
new file mode 100644
index 0000000..74c203e
--- /dev/null
+++ b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmEntitySetTest.java
@@ -0,0 +1,224 @@
+/*******************************************************************************
+ * 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.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.persistence.metamodel.Attribute;
+import javax.persistence.metamodel.EntityType;
+import javax.persistence.metamodel.Metamodel;
+
+import org.apache.olingo.odata2.api.edm.provider.Schema;
+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.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.JPAEdmKeyView;
+import org.apache.olingo.odata2.processor.core.jpa.common.ODataJPATestConstants;
+import org.apache.olingo.odata2.processor.core.jpa.mock.model.JPAEntityTypeMock;
+import org.apache.olingo.odata2.processor.core.jpa.mock.model.JPAMetaModelMock;
+import org.apache.olingo.odata2.processor.core.jpa.mock.model.JPASingularAttributeMock;
+import org.junit.Before;
+import org.junit.Test;
+
+public class JPAEdmEntitySetTest extends JPAEdmTestModelView {
+
+ private static JPAEdmEntitySet objJPAEdmEntitySet;
+ private static JPAEdmEntitySetTest objJPAEdmEntitySetTest;
+
+ @Before
+ public void setUp() {
+ objJPAEdmEntitySetTest = new JPAEdmEntitySetTest();
+ objJPAEdmEntitySet = new JPAEdmEntitySet(objJPAEdmEntitySetTest);
+ try {
+ objJPAEdmEntitySet.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);
+ }
+ }
+
+ @Test
+ public void testGetBuilder() {
+ assertNotNull(objJPAEdmEntitySet.getBuilder());
+ }
+
+ @Test
+ public void testGetEdmEntitySet() {
+ assertNotNull(objJPAEdmEntitySet.getEdmEntitySet());
+ assertNotNull(objJPAEdmEntitySet.getEdmEntitySet().getEntityType());
+ }
+
+ @Test
+ public void testGetConsistentEntitySetList() {
+ assertTrue(objJPAEdmEntitySet.getConsistentEdmEntitySetList().size() > 0);
+ }
+
+ @Test
+ public void testGetJPAEdmEntityTypeView() {
+ assertNotNull(objJPAEdmEntitySet.getJPAEdmEntityTypeView());
+ assertEquals("salesorderprocessing", objJPAEdmEntitySet.getJPAEdmEntityTypeView().getpUnitName());
+ }
+
+ @Test
+ public void testIsConsistent() {
+ assertTrue(objJPAEdmEntitySet.isConsistent());
+
+ objJPAEdmEntitySet.getJPAEdmEntityTypeView().clean();
+ assertFalse(objJPAEdmEntitySet.getJPAEdmEntityTypeView().isConsistent());
+
+ objJPAEdmEntitySet.clean();
+ assertFalse(objJPAEdmEntitySet.isConsistent());
+ }
+
+ @Test
+ public void testGetBuilderIdempotent() {
+ JPAEdmBuilder builder1 = objJPAEdmEntitySet.getBuilder();
+ JPAEdmBuilder builder2 = objJPAEdmEntitySet.getBuilder();
+
+ assertEquals(builder1.hashCode(), builder2.hashCode());
+ }
+
+ @Override
+ public Metamodel getJPAMetaModel() {
+ return new JPAEdmMetaModel();
+ }
+
+ @Override
+ public JPAEdmEntityContainerView getJPAEdmEntityContainerView() {
+ return this;
+ }
+
+ @Override
+ public JPAEdmEntitySetView getJPAEdmEntitySetView() {
+ return this;
+ }
+
+ @Override
+ public JPAEdmEntityTypeView getJPAEdmEntityTypeView() {
+ return this;
+ }
+
+ @Override
+ public EntityType<?> getJPAEntityType() {
+ return new JPAEdmEntityType<String>();
+ }
+
+ @Override
+ public JPAEdmKeyView getJPAEdmKeyView() {
+ return this;
+ }
+
+ @Override
+ public Schema getEdmSchema() {
+ Schema schema = new Schema();
+ schema.setNamespace("salesordereprocessing");
+ return schema;
+ }
+
+ @Override
+ public String getpUnitName() {
+ return "salesorderprocessing";
+ }
+
+ @SuppressWarnings("hiding")
+ private class JPAEdmEntityType<String> extends JPAEntityTypeMock<String> {
+ Set<Attribute<? super String, ?>> attributeSet = new HashSet<Attribute<? super String, ?>>();
+
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ private void setValuesToSet() {
+ attributeSet.add((Attribute<? super String, String>) new JPAEdmAttribute(java.lang.String.class, "SOID"));
+ attributeSet.add((Attribute<? super String, String>) new JPAEdmAttribute(java.lang.String.class, "SONAME"));
+ }
+
+ @Override
+ public java.lang.String getName() {
+ return "SalesOrderHeader";
+ }
+
+ @Override
+ public Set<Attribute<? super String, ?>> getAttributes() {
+ setValuesToSet();
+ return attributeSet;
+ }
+
+ private class JPAEdmAttribute<Object, String> extends JPASingularAttributeMock<Object, String> {
+
+ @Override
+ public PersistentAttributeType getPersistentAttributeType() {
+ return PersistentAttributeType.BASIC;
+ }
+
+ Class<String> clazz;
+ java.lang.String attributeName;
+
+ public JPAEdmAttribute(final Class<String> javaType, final java.lang.String name) {
+ this.clazz = javaType;
+ this.attributeName = name;
+
+ }
+
+ @Override
+ public Class<String> getJavaType() {
+ return clazz;
+ }
+
+ @Override
+ public java.lang.String getName() {
+ return this.attributeName;
+ }
+
+ @Override
+ public boolean isId() {
+ return true;
+ }
+ }
+ }
+
+ private class JPAEdmMetaModel extends JPAMetaModelMock {
+ Set<EntityType<?>> entities;
+
+ public JPAEdmMetaModel() {
+ entities = new HashSet<EntityType<?>>();
+ }
+
+ @Override
+ public Set<EntityType<?>> getEntities() {
+ entities.add(new JPAEdmEntityType());
+ return entities;
+ }
+
+ private class JPAEdmEntityType extends JPAEntityTypeMock<String> {
+ @Override
+ public String getName() {
+ return "SalesOrderHeader";
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmEntityTypeTest.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmEntityTypeTest.java b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmEntityTypeTest.java
new file mode 100644
index 0000000..dfbe879
--- /dev/null
+++ b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmEntityTypeTest.java
@@ -0,0 +1,198 @@
+/*******************************************************************************
+ * 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.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.persistence.metamodel.Attribute;
+import javax.persistence.metamodel.EntityType;
+import javax.persistence.metamodel.Metamodel;
+
+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.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.core.jpa.common.ODataJPATestConstants;
+import org.apache.olingo.odata2.processor.core.jpa.mock.model.JPAEntityTypeMock;
+import org.apache.olingo.odata2.processor.core.jpa.mock.model.JPAMetaModelMock;
+import org.apache.olingo.odata2.processor.core.jpa.mock.model.JPASingularAttributeMock;
+import org.junit.Before;
+import org.junit.Test;
+
+public class JPAEdmEntityTypeTest extends JPAEdmTestModelView {
+
+ private static JPAEdmEntityTypeTest objJPAEdmEntityTypeTest;
+ private static JPAEdmEntityType objJPAEdmEntityType;
+
+ @Before
+ public void setUp() {
+ objJPAEdmEntityTypeTest = new JPAEdmEntityTypeTest();
+ objJPAEdmEntityType = new JPAEdmEntityType(objJPAEdmEntityTypeTest);
+ try {
+ objJPAEdmEntityType.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);
+ }
+ }
+
+ @Test
+ public void testGetBuilder() {
+ assertNotNull(objJPAEdmEntityType.getBuilder());
+ }
+
+ @Test
+ public void testGetBuilderIdempotent() {
+ JPAEdmBuilder builder1 = objJPAEdmEntityType.getBuilder();
+ JPAEdmBuilder builder2 = objJPAEdmEntityType.getBuilder();
+
+ assertEquals(builder1.hashCode(), builder2.hashCode());
+ }
+
+ @Test
+ public void testGetEdmEntityType() {
+ assertNotNull(objJPAEdmEntityType.getEdmEntityType());
+ assertNotNull(objJPAEdmEntityType.getEdmEntityType().getKey());
+ }
+
+ @Test
+ public void testGetJPAEntityType() {
+ assertNotNull(objJPAEdmEntityType.getJPAEntityType());
+
+ }
+
+ @Test
+ public void testGetConsistentEdmEntityTypes() {
+ assertTrue(objJPAEdmEntityType.getConsistentEdmEntityTypes().size() > 0);
+ }
+
+ @Test
+ public void testSearchEdmEntityType() {
+ assertNotNull(objJPAEdmEntityType.searchEdmEntityType("SalesOrderHeader"));
+ }
+
+ @Test
+ public void testIsConsistent() {
+ assertTrue(objJPAEdmEntityType.isConsistent());
+ }
+
+ @Override
+ public Metamodel getJPAMetaModel() {
+ return new JPAEdmMetaModel();
+ }
+
+ @Override
+ public JPAEdmEntitySetView getJPAEdmEntitySetView() {
+ return this;
+ }
+
+ @Override
+ public JPAEdmEntityContainerView getJPAEdmEntityContainerView() {
+ return this;
+ }
+
+ @Override
+ public EntityType<?> getJPAEntityType() {
+ return new JPAEdmEntityTypeLocal<String>();
+ }
+
+ @Override
+ public JPAEdmEntityTypeView getJPAEdmEntityTypeView() {
+ return this;
+ }
+
+ private class JPAEdmMetaModel extends JPAMetaModelMock {
+ Set<EntityType<?>> entities;
+
+ public JPAEdmMetaModel() {
+ entities = new HashSet<EntityType<?>>();
+ }
+
+ @Override
+ public Set<EntityType<?>> getEntities() {
+ entities.add(new JPAEdmEntityType());
+ return entities;
+ }
+
+ private class JPAEdmEntityType extends JPAEntityTypeMock<String> {
+ @Override
+ public String getName() {
+ return "SalesOrderHeader";
+ }
+ }
+ }
+
+ @SuppressWarnings("hiding")
+ private class JPAEdmEntityTypeLocal<String> extends JPAEntityTypeMock<String> {
+ Set<Attribute<? super String, ?>> attributeSet = new HashSet<Attribute<? super String, ?>>();
+
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ private void setValuesToSet() {
+ attributeSet.add((Attribute<? super String, String>) new JPAEdmAttribute(java.lang.String.class, "SOID"));
+ attributeSet.add((Attribute<? super String, String>) new JPAEdmAttribute(java.lang.String.class, "SONAME"));
+ }
+
+ @Override
+ public Set<Attribute<? super String, ?>> getAttributes() {
+ setValuesToSet();
+ return attributeSet;
+ }
+
+ private class JPAEdmAttribute<Object, String> extends JPASingularAttributeMock<Object, String> {
+
+ @Override
+ public PersistentAttributeType getPersistentAttributeType() {
+ return PersistentAttributeType.BASIC;
+ }
+
+ Class<String> clazz;
+ java.lang.String attributeName;
+
+ public JPAEdmAttribute(final Class<String> javaType, final java.lang.String name) {
+ this.clazz = javaType;
+ this.attributeName = name;
+
+ }
+
+ @Override
+ public Class<String> getJavaType() {
+ return clazz;
+ }
+
+ @Override
+ public java.lang.String getName() {
+ return this.attributeName;
+ }
+
+ @Override
+ public boolean isId() {
+ return true;
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmFunctionImportTest.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmFunctionImportTest.java b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmFunctionImportTest.java
new file mode 100644
index 0000000..94665d7
--- /dev/null
+++ b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmFunctionImportTest.java
@@ -0,0 +1,566 @@
+/*******************************************************************************
+ * 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.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;
+
+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("Param3", funcImpList.get(1).getName());
+ assertEquals(EdmSimpleTypeKind.Double, funcImpList.get(1).getType());
+
+ }
+
+ }
+
+ /**
+ * 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/1b479e6c/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmKeyTest.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmKeyTest.java b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmKeyTest.java
new file mode 100644
index 0000000..0ec45df
--- /dev/null
+++ b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmKeyTest.java
@@ -0,0 +1,176 @@
+/*******************************************************************************
+ * 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.fail;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.persistence.metamodel.Attribute;
+
+import org.apache.olingo.odata2.api.edm.EdmSimpleTypeKind;
+import org.apache.olingo.odata2.api.edm.FullQualifiedName;
+import org.apache.olingo.odata2.api.edm.provider.ComplexProperty;
+import org.apache.olingo.odata2.api.edm.provider.ComplexType;
+import org.apache.olingo.odata2.api.edm.provider.Key;
+import org.apache.olingo.odata2.api.edm.provider.Property;
+import org.apache.olingo.odata2.api.edm.provider.SimpleProperty;
+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.JPAEdmKeyView;
+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.JPAAttributeMock;
+import org.apache.olingo.odata2.processor.core.jpa.mock.model.JPAEdmMockData;
+import org.apache.olingo.odata2.processor.core.jpa.mock.model.JPAEdmMockData.ComplexType.ComplexTypeA;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class JPAEdmKeyTest extends JPAEdmTestModelView {
+
+ private static JPAEdmKeyView keyView;
+ private static JPAEdmKeyTest objJpaEdmKeyTest;
+
+ @BeforeClass
+ public static void setup() {
+ objJpaEdmKeyTest = new JPAEdmKeyTest();
+ keyView = new JPAEdmKey(objJpaEdmKeyTest, objJpaEdmKeyTest);
+ }
+
+ @SuppressWarnings("hiding")
+ private class JPAAttributeA<Object, ComplexTypeA> extends JPAAttributeMock<Object, ComplexTypeA> {
+ @SuppressWarnings("unchecked")
+ @Override
+ public Class<ComplexTypeA> getJavaType() {
+ return (Class<ComplexTypeA>) JPAEdmMockData.ComplexType.ComplexTypeA.class;
+ }
+ }
+
+ @Test
+ public void testBuildComplexKey() {
+ try {
+ keyView.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);
+ }
+
+ Key key = keyView.getEdmKey();
+
+ assertEquals(JPAEdmMockData.ComplexType.ComplexTypeA.Property.PROPERTY_A, key.getKeys().get(0).getName());
+ assertEquals(JPAEdmMockData.ComplexType.ComplexTypeA.Property.PROPERTY_B, key.getKeys().get(1).getName());
+ assertEquals(JPAEdmMockData.ComplexType.ComplexTypeB.Property.PROPERTY_D, key.getKeys().get(2).getName());
+ assertEquals(JPAEdmMockData.ComplexType.ComplexTypeB.Property.PROPERTY_E, key.getKeys().get(3).getName());
+
+ }
+
+ @Test
+ public void testGetBuilderIdempotent() {
+ JPAEdmBuilder builder1 = keyView.getBuilder();
+ JPAEdmBuilder builder2 = keyView.getBuilder();
+
+ assertEquals(builder1.hashCode(), builder2.hashCode());
+ }
+
+ @Override
+ public Attribute<?, ?> getJPAAttribute() {
+ return new JPAAttributeA<Object, ComplexTypeA>();
+
+ }
+
+ @Override
+ public ComplexType searchEdmComplexType(final FullQualifiedName arg0) {
+ return searchEdmComplexType(arg0.getName());
+ }
+
+ @Override
+ public ComplexType searchEdmComplexType(final String arg0) {
+ if (arg0.equals(JPAEdmMockData.ComplexType.ComplexTypeA.class.getName())) {
+ return buildComplexTypeA();
+ } else if (arg0.equals(JPAEdmMockData.ComplexType.ComplexTypeB.class.getSimpleName())) {
+ return buildComplexTypeB();
+ }
+
+ return null;
+
+ }
+
+ private ComplexType buildComplexTypeB() {
+ ComplexType complexType = new ComplexType();
+ complexType.setProperties(buildPropertiesB());
+
+ return complexType;
+ }
+
+ private List<Property> buildPropertiesB() {
+ List<Property> propertyList = new ArrayList<Property>();
+
+ SimpleProperty property = new SimpleProperty();
+ property.setName(JPAEdmMockData.ComplexType.ComplexTypeB.Property.PROPERTY_D);
+ property.setType(EdmSimpleTypeKind.Int16);
+
+ propertyList.add(property);
+
+ property = new SimpleProperty();
+ property.setName(JPAEdmMockData.ComplexType.ComplexTypeB.Property.PROPERTY_E);
+ property.setType(EdmSimpleTypeKind.Int16);
+
+ propertyList.add(property);
+
+ return propertyList;
+ }
+
+ private ComplexType buildComplexTypeA() {
+ ComplexType complexType = new ComplexType();
+ complexType.setProperties(buildPropertiesA());
+
+ return complexType;
+ }
+
+ private List<Property> buildPropertiesA() {
+
+ List<Property> propertyList = new ArrayList<Property>();
+
+ SimpleProperty property = new SimpleProperty();
+ property.setName(JPAEdmMockData.ComplexType.ComplexTypeA.Property.PROPERTY_A);
+ property.setType(EdmSimpleTypeKind.Int16);
+
+ propertyList.add(property);
+
+ property = new SimpleProperty();
+ property.setName(JPAEdmMockData.ComplexType.ComplexTypeA.Property.PROPERTY_B);
+ property.setType(EdmSimpleTypeKind.Int16);
+
+ propertyList.add(property);
+
+ ComplexProperty complexProperty = new ComplexProperty();
+ complexProperty.setName(JPAEdmMockData.ComplexType.ComplexTypeA.Property.PROPERTY_C);
+ complexProperty.setType(new FullQualifiedName(ODataJPAContextMock.NAMESPACE,
+ JPAEdmMockData.ComplexType.ComplexTypeB.name));
+
+ propertyList.add(complexProperty);
+ return propertyList;
+
+ }
+
+}
[18/37] [OLINGO-82] Renamed the project folder name to
odata2-jpa-processor
Posted by ch...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/exception/ODataJPAModelException.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/exception/ODataJPAModelException.java b/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/exception/ODataJPAModelException.java
deleted file mode 100644
index 7800b9e..0000000
--- a/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/exception/ODataJPAModelException.java
+++ /dev/null
@@ -1,92 +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.api.jpa.exception;
-
-import org.apache.olingo.odata2.api.exception.MessageReference;
-import org.apache.olingo.odata2.processor.api.jpa.factory.ODataJPAFactory;
-
-/**
- * The exception is thrown for any unexpected errors raising while
- * accessing/transforming Java Persistence Models.
- *
- *
- *
- */
-public class ODataJPAModelException extends ODataJPAException {
-
- public static final MessageReference INVALID_ENTITY_TYPE = createMessageReference(ODataJPAModelException.class,
- "INVALID_ENTITY_TYPE");
- public static final MessageReference INVALID_COMPLEX_TYPE = createMessageReference(ODataJPAModelException.class,
- "INVLAID_COMPLEX_TYPE");
- public static final MessageReference INVALID_ASSOCIATION = createMessageReference(ODataJPAModelException.class,
- "INVALID_ASSOCIATION");
- public static final MessageReference INVALID_ENTITYSET = createMessageReference(ODataJPAModelException.class,
- "INVALID_ENTITYSET");
- public static final MessageReference INVALID_ENTITYCONTAINER = createMessageReference(ODataJPAModelException.class,
- "INVALID_ENTITYCONTAINER");
- public static final MessageReference INVALID_ASSOCIATION_SET = createMessageReference(ODataJPAModelException.class,
- "INVALID_ASSOCIATION_SET");
- public static final MessageReference INVALID_FUNC_IMPORT = createMessageReference(ODataJPAModelException.class,
- "INVALID_FUNC_IMPORT");
-
- public static final MessageReference BUILDER_NULL = createMessageReference(ODataJPAModelException.class,
- "BUILDER_NULL");
- public static final MessageReference TYPE_NOT_SUPPORTED = createMessageReference(ODataJPAModelException.class,
- "TYPE_NOT_SUPPORTED");
- public static final MessageReference FUNC_ENTITYSET_EXP = createMessageReference(ODataJPAModelException.class,
- "FUNC_ENTITYSET_EXP");
- public static final MessageReference FUNC_RETURN_TYPE_EXP = createMessageReference(ODataJPAModelException.class,
- "FUNC_RETURN_TYPE_EXP");
- public static final MessageReference FUNC_RETURN_TYPE_ENTITY_NOT_FOUND = createMessageReference(
- ODataJPAModelException.class, "FUNC_RETURN_TYPE_ENTITY_NOT_FOUND");
- public static final MessageReference GENERAL = createMessageReference(ODataJPAModelException.class, "GENERAL");
- public static final MessageReference INNER_EXCEPTION = createMessageReference(ODataJPAModelException.class,
- "INNER_EXCEPTION");
- public static final MessageReference FUNC_PARAM_NAME_EXP = createMessageReference(ODataJPAModelException.class,
- "FUNC_PARAM_NAME_EXP");
-
- private ODataJPAModelException(final String localizedMessage, final Throwable e, final MessageReference msgRef) {
- super(localizedMessage, e, msgRef);
- }
-
- /**
- * The method creates an exception object of type ODataJPAModelException
- * with localized error texts.
- *
- * @param messageReference
- * is a <b>mandatory</b> parameter referring to a literal that
- * could be translated to localized error texts.
- * @param e
- * is an optional parameter representing the previous exception
- * in the call stack
- * @return an instance of ODataJPAModelException which can be then raised.
- * @throws ODataJPARuntimeException
- */
- public static ODataJPAModelException throwException(final MessageReference messageReference, final Throwable e) {
-
- ODataJPAMessageService messageService;
- messageService =
- ODataJPAFactory.createFactory().getODataJPAAccessFactory().getODataJPAMessageService(DEFAULT_LOCALE);
- String message = messageService.getLocalizedMessage(messageReference, e);
- return new ODataJPAModelException(message, e, messageReference);
- }
-
- private static final long serialVersionUID = 7940106375606950703L;
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/exception/ODataJPARuntimeException.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/exception/ODataJPARuntimeException.java b/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/exception/ODataJPARuntimeException.java
deleted file mode 100644
index b3195c3..0000000
--- a/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/exception/ODataJPARuntimeException.java
+++ /dev/null
@@ -1,97 +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.api.jpa.exception;
-
-import org.apache.olingo.odata2.api.exception.MessageReference;
-import org.apache.olingo.odata2.processor.api.jpa.factory.ODataJPAFactory;
-
-/**
- * The exception is thrown for any unexpected errors raising while accessing
- * data from Java Persistence Models.
- *
- * The exception object is created with localized error texts provided error
- * texts are maintained in localized languages.
- *
- *
- *
- */
-public class ODataJPARuntimeException extends ODataJPAException {
-
- public static final MessageReference ENTITY_MANAGER_NOT_INITIALIZED = createMessageReference(
- ODataJPARuntimeException.class, "ENTITY_MANAGER_NOT_INITIALIZED");
- public static final MessageReference RESOURCE_NOT_FOUND = createMessageReference(ODataJPARuntimeException.class,
- "RESOURCE_NOT_FOUND");
- public static final MessageReference GENERAL = createMessageReference(ODataJPARuntimeException.class, "GENERAL");
- public static final MessageReference INNER_EXCEPTION = createMessageReference(ODataJPARuntimeException.class,
- "INNER_EXCEPTION");
- public static final MessageReference JOIN_CLAUSE_EXPECTED = createMessageReference(ODataJPARuntimeException.class,
- "JOIN_CLAUSE_EXPECTED");
- public static final MessageReference ERROR_JPQLCTXBLDR_CREATE = createMessageReference(
- ODataJPARuntimeException.class, "ERROR_JPQLCTXBLDR_CREATE");
- public static final MessageReference ERROR_ODATA_FILTER_CONDITION = createMessageReference(
- ODataJPARuntimeException.class, "ERROR_ODATA_FILTER_CONDITION");
- public static final MessageReference ERROR_JPQL_QUERY_CREATE = createMessageReference(ODataJPARuntimeException.class,
- "ERROR_JPQL_QUERY_CREATE");
- public static final MessageReference ERROR_JPQL_CREATE_REQUEST = createMessageReference(
- ODataJPARuntimeException.class, "ERROR_JPQL_CREATE_REQUEST");
- public static final MessageReference ERROR_JPQL_UPDATE_REQUEST = createMessageReference(
- ODataJPARuntimeException.class, "ERROR_JPQL_UPDATE_REQUEST");
- public static final MessageReference ERROR_JPQL_DELETE_REQUEST = createMessageReference(
- ODataJPARuntimeException.class, "ERROR_JPQL_DELETE_REQUEST");
- public static final MessageReference ERROR_JPQL_KEY_VALUE = createMessageReference(ODataJPARuntimeException.class,
- "ERROR_JPQL_KEY_VALUE");
- public static final MessageReference ERROR_JPQL_PARAM_VALUE = createMessageReference(ODataJPARuntimeException.class,
- "ERROR_JPQL_PARAM_VALUE");
- public static final MessageReference ERROR_JPQL_UNIQUE_CONSTRAINT = createMessageReference(
- ODataJPARuntimeException.class, "ERROR_JPQL_UNIQUE_CONSTRAINT");
- public static final MessageReference ERROR_JPQL_INTEGRITY_CONSTRAINT = createMessageReference(
- ODataJPARuntimeException.class, "ERROR_JPQL_INTEGRITY_CONSTRAINT");
- public static final MessageReference RELATIONSHIP_INVALID = createMessageReference(ODataJPARuntimeException.class,
- "RELATIONSHIP_INVALID");
- public static final MessageReference RESOURCE_X_NOT_FOUND = createMessageReference(ODataJPARuntimeException.class,
- "RESOURCE_X_NOT_FOUND");
-
- private ODataJPARuntimeException(final String localizedMessage, final Throwable e, final MessageReference msgRef) {
- super(localizedMessage, e, msgRef);
- }
-
- /**
- * The method creates an exception object of type ODataJPARuntimeException
- * with localized error texts.
- *
- * @param messageReference
- * is a <b>mandatory</b> parameter referring to a literal that
- * could be translated to localized error texts.
- * @param e
- * is an optional parameter representing the previous exception
- * in the call stack
- * @return an instance of ODataJPARuntimeException which can be then raised.
- * @throws ODataJPARuntimeException
- */
- public static ODataJPARuntimeException throwException(final MessageReference messageReference, final Throwable e) {
- ODataJPAMessageService messageService;
- messageService =
- ODataJPAFactory.createFactory().getODataJPAAccessFactory().getODataJPAMessageService(DEFAULT_LOCALE);
- String message = messageService.getLocalizedMessage(messageReference, e);
- return new ODataJPARuntimeException(message, e, messageReference);
- }
-
- private static final long serialVersionUID = -5230976355642443012L;
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/exception/package-info.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/exception/package-info.java b/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/exception/package-info.java
deleted file mode 100644
index 5059bb4..0000000
--- a/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/exception/package-info.java
+++ /dev/null
@@ -1,31 +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.
- ******************************************************************************/
-/**
- * <h3>OData JPA Processor API Library - Exceptions</h3>
- * There are two main types of exceptions thrown from the library
- * <ol><li>Model Exception</li>
- * <li>Runtime Exception</li></ol>
- * <br>
- * The Model Exception is thrown while processing JPA metamodels and
- * runtime exception is thrown while processing persistence data.
- *
- *
- */
-package org.apache.olingo.odata2.processor.api.jpa.exception;
-
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/factory/JPAAccessFactory.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/factory/JPAAccessFactory.java b/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/factory/JPAAccessFactory.java
deleted file mode 100644
index 02268de..0000000
--- a/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/factory/JPAAccessFactory.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.api.jpa.factory;
-
-import org.apache.olingo.odata2.processor.api.jpa.ODataJPAContext;
-import org.apache.olingo.odata2.processor.api.jpa.access.JPAEdmMappingModelAccess;
-import org.apache.olingo.odata2.processor.api.jpa.access.JPAProcessor;
-import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmModelView;
-
-/**
- * Factory interface for creating
- * <ol>
- * <li>JPA EDM Model view</li>
- * <li>JPA Processor</li>
- * </ol>
- *
- *
- *
- */
-public interface JPAAccessFactory {
- /**
- * The method returns an instance of JPA EDM model view based on OData JPA
- * Context. The JPA EDM model view thus returned can be used for building
- * EDM models from Java persistence models.
- *
- * @param oDataJPAContext
- * a non null instance of {@link org.apache.olingo.odata2.processor.api.jpa.ODataJPAContext}
- * @return an instance of type {@link org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmModelView}
- */
- public JPAEdmModelView getJPAEdmModelView(ODataJPAContext oDataJPAContext);
-
- /**
- * The method returns an instance of JPA processor based on OData JPA
- * Context. The JPA Processor thus returned can be used for building and
- * processing JPQL statements.
- *
- * @param oDataJPAContext
- * a non null instance of {@link org.apache.olingo.odata2.processor.api.jpa.ODataJPAContext}
- * @return an instance of type {@link org.apache.olingo.odata2.processor.api.jpa.access.JPAProcessor}
- */
- public JPAProcessor getJPAProcessor(ODataJPAContext oDataJPAContext);
-
- /**
- * The method returns an instance of JPA EDM mapping model access based on
- * OData JPA context. The instance thus returned can be used for accessing
- * the mapping details maintained for an OData service
- *
- * @param oDataJPAContext
- * a non null instance of {@link org.apache.olingo.odata2.processor.api.jpa.ODataJPAContext}
- * @return an instance of type {@link org.apache.olingo.odata2.processor.api.jpa.access.JPAEdmMappingModelAccess}
- */
- public JPAEdmMappingModelAccess getJPAEdmMappingModelAccess(ODataJPAContext oDataJPAContext);
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/factory/JPQLBuilderFactory.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/factory/JPQLBuilderFactory.java b/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/factory/JPQLBuilderFactory.java
deleted file mode 100644
index 52d45ab..0000000
--- a/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/factory/JPQLBuilderFactory.java
+++ /dev/null
@@ -1,77 +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.api.jpa.factory;
-
-import org.apache.olingo.odata2.processor.api.jpa.access.JPAMethodContext.JPAMethodContextBuilder;
-import org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLContext.JPQLContextBuilder;
-import org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLContextType;
-import org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLContextView;
-import org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLStatement.JPQLStatementBuilder;
-
-/**
- * Factory interface for creating following instances
- *
- * <p>
- * <ul>
- * <li>JPQL statement builders of type
- * {@link org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLStatement.JPQLStatementBuilder} </li>
- * <li>JPQL context builder of type
- * {@link org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLContext.JPQLContextBuilder} </li>
- * </ul>
- * </p>
- *
- *
- * @see org.apache.olingo.odata2.processor.api.jpa.factory.ODataJPAFactory
- */
-public interface JPQLBuilderFactory {
- /**
- * The method returns JPQL statement builder for building JPQL statements.
- *
- * @param context
- * is {@link org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLContext} that determines the type of JPQL statement
- * builder. The
- * parameter cannot be null.
- * @return an instance of JPQLStatementBuilder
- */
- public JPQLStatementBuilder getStatementBuilder(JPQLContextView context);
-
- /**
- * The method returns a JPQL context builder for building JPQL Context
- * object.
- *
- * @param contextType
- * is {@link org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLContextType} that determines the type of JPQL context
- * builder. The
- * parameter cannot be null.
- * @return an instance of JPQLContextBuilder
- */
- public JPQLContextBuilder getContextBuilder(JPQLContextType contextType);
-
- /**
- * The method returns a JPA method context builder for building JPA Method
- * context object.
- *
- * @param contextType
- * is {@link org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLContextType} that determines the type of JPQL context
- * builder. The
- * parameter cannot be null.
- * @return an instance of JPAMethodContextBuilder
- */
- public JPAMethodContextBuilder getJPAMethodContextBuilder(JPQLContextType contextType);
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/factory/ODataJPAAccessFactory.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/factory/ODataJPAAccessFactory.java b/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/factory/ODataJPAAccessFactory.java
deleted file mode 100644
index 3d8073e..0000000
--- a/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/factory/ODataJPAAccessFactory.java
+++ /dev/null
@@ -1,82 +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.api.jpa.factory;
-
-import java.util.Locale;
-
-import org.apache.olingo.odata2.api.edm.provider.EdmProvider;
-import org.apache.olingo.odata2.api.processor.ODataSingleProcessor;
-import org.apache.olingo.odata2.processor.api.jpa.ODataJPAContext;
-import org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPAMessageService;
-
-/**
- * Factory interface for creating following instances
- *
- * <p>
- * <ul>
- * <li>OData JPA Processor of type {@link org.apache.olingo.odata2.api.processor.ODataSingleProcessor}</li>
- * <li>JPA EDM Provider of type {@link org.apache.olingo.odata2.api.edm.provider.EdmProvider}</li>
- * <li>OData JPA Context {@link org.apache.olingo.odata2.processor.api.jpa.ODataJPAContext}</li>
- * </ul>
- * </p>
- *
- *
- * @see org.apache.olingo.odata2.processor.api.jpa.factory.ODataJPAFactory
- */
-public interface ODataJPAAccessFactory {
- /**
- * The method creates an OData JPA Processor. The processor handles runtime
- * behavior of an OData service.
- *
- * @param oDataJPAContext
- * an instance of type {@link org.apache.olingo.odata2.processor.api.jpa.ODataJPAContext}.
- * The context should be initialized properly and cannot be null.
- * @return An implementation of OData JPA Processor.
- */
- public ODataSingleProcessor createODataProcessor(ODataJPAContext oDataJPAContext);
-
- /**
- *
- * @param oDataJPAContext
- * an instance of type {@link org.apache.olingo.odata2.processor.api.jpa.ODataJPAContext}.
- * The context should be initialized properly and cannot be null.
- * @return An implementation of JPA EdmProvider. EdmProvider handles
- * meta-data.
- */
- public EdmProvider createJPAEdmProvider(ODataJPAContext oDataJPAContext);
-
- /**
- * The method creates an instance of OData JPA Context. An empty instance is
- * returned.
- *
- * @return an instance of type {@link org.apache.olingo.odata2.processor.api.jpa.ODataJPAContext}
- */
- public ODataJPAContext createODataJPAContext();
-
- /**
- * The method creates an instance of message service for loading language
- * dependent message text.
- *
- * @param locale
- * is the language in which the message service should load
- * message texts.
- * @return an instance of type {@link org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPAMessageService}
- */
- public ODataJPAMessageService getODataJPAMessageService(Locale locale);
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/factory/ODataJPAFactory.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/factory/ODataJPAFactory.java b/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/factory/ODataJPAFactory.java
deleted file mode 100644
index b421ce4..0000000
--- a/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/factory/ODataJPAFactory.java
+++ /dev/null
@@ -1,105 +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.api.jpa.factory;
-
-/**
- * The class is an abstract factory for creating default ODataJPAFactory. The
- * class's actual implementation is responsible for creating other factory
- * implementations.The class creates factories implementing interfaces
- * <ul>
- * <li>{@link org.apache.olingo.odata2.processor.api.jpa.factory.JPAAccessFactory}</li>
- * <li>{@link org.apache.olingo.odata2.processor.api.jpa.factory.JPQLBuilderFactory}</li>
- * <li>{@link org.apache.olingo.odata2.processor.api.jpa.factory.JPQLBuilderFactory}</li>
- * </ul>
- *
- * <b>Note: </b>Extend this class only if you don't require library's default
- * factory implementation.
- * <p>
- *
- *
- *
- *
- *
- */
-public abstract class ODataJPAFactory {
-
- private static final String IMPLEMENTATION =
- "org.apache.olingo.odata2.processor.core.jpa.factory.ODataJPAFactoryImpl";
- private static ODataJPAFactory factoryImpl;
-
- /**
- * Method creates a factory instance. The instance returned is singleton.
- * The instance of this factory can be used for creating other factory
- * implementations.
- *
- * @return instance of type {@link org.apache.olingo.odata2.processor.api.jpa.factory.ODataJPAFactory} .
- */
- public static ODataJPAFactory createFactory() {
-
- if (factoryImpl != null) {
- return factoryImpl;
- } else {
- try {
- Class<?> clazz = Class.forName(ODataJPAFactory.IMPLEMENTATION);
-
- Object object = clazz.newInstance();
- factoryImpl = (ODataJPAFactory) object;
-
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
-
- return factoryImpl;
- }
- }
-
- /**
- * The method returns a null reference to JPQL Builder Factory. Override
- * this method to return an implementation of JPQLBuilderFactory if default
- * implementation from library is not required.
- *
- * @return instance of type {@link org.apache.olingo.odata2.processor.api.jpa.factory.JPQLBuilderFactory}
- */
- public JPQLBuilderFactory getJPQLBuilderFactory() {
- return null;
- };
-
- /**
- * The method returns a null reference to JPA Access Factory. Override this
- * method to return an implementation of JPAAccessFactory if default
- * implementation from library is not required.
- *
- * @return instance of type {@link org.apache.olingo.odata2.processor.api.jpa.factory.JPQLBuilderFactory}
- */
- public JPAAccessFactory getJPAAccessFactory() {
- return null;
- };
-
- /**
- * The method returns a null reference to OData JPA Access Factory. Override
- * this method to return an implementation of ODataJPAAccessFactory if
- * default implementation from library is not required.
- *
- * @return instance of type {@link org.apache.olingo.odata2.processor.api.jpa.factory.ODataJPAAccessFactory}
- */
- public ODataJPAAccessFactory getODataJPAAccessFactory() {
- return null;
- };
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/factory/package-info.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/factory/package-info.java b/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/factory/package-info.java
deleted file mode 100644
index de2b699..0000000
--- a/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/factory/package-info.java
+++ /dev/null
@@ -1,33 +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.
- ******************************************************************************/
-/**
- * <h3>OData JPA Processor API Library - Factory</h3>
- * The library provides different types of factories for creating instances for
- * <ul>
- * <li>Accessing Java Persistence Model/Data</li>
- * <li>Building different types of JPQL statements</li>
- * <li>Accessing OData EDM provider and processor</li>
- * </ul>
- *
- * The instances of these factories can be obtained from an abstract ODataJPAFactory.
- *
- *
- */
-package org.apache.olingo.odata2.processor.api.jpa.factory;
-
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/jpql/JPQLContext.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/jpql/JPQLContext.java b/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/jpql/JPQLContext.java
deleted file mode 100644
index ab24e67..0000000
--- a/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/jpql/JPQLContext.java
+++ /dev/null
@@ -1,204 +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.api.jpa.jpql;
-
-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.factory.ODataJPAFactory;
-
-/**
- * The abstract class is a compilation of objects required for building
- * {@link org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLStatement}. Extend this
- * class to implement specific implementations of JPQL context types (Select,
- * Join). A JPQL Context is constructed from an OData
- * request. Depending on OData CRUD operation performed on an Entity, a
- * corresponding JPQL context object is built. The JPQL context object thus
- * built can be used for constructing JPQL statements. <br>
- * A default implementation is provided by the library.
- *
- *
- * @see org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLStatement
- * @see org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLContextType
- * @see org.apache.olingo.odata2.processor.api.jpa.factory.JPQLBuilderFactory
- *
- */
-public abstract class JPQLContext implements JPQLContextView {
-
- /**
- * An alias for Java Persistence Entity
- */
- protected String jpaEntityAlias;
- /**
- * Java Persistence Entity name
- */
- protected String jpaEntityName;
- /**
- * The type of JPQL context. Based on the type JPQL statements can be built.
- */
- protected JPQLContextType type;
-
- /**
- * sets JPA Entity Name into the context
- *
- * @param jpaEntityName
- * is the name of JPA Entity
- */
- protected final void setJPAEntityName(final String jpaEntityName) {
- this.jpaEntityName = jpaEntityName;
- }
-
- /**
- * sets JPA Entity alias name into the context
- *
- * @param jpaEntityAlias
- * is the JPA entity alias name
- */
- protected final void setJPAEntityAlias(final String jpaEntityAlias) {
- this.jpaEntityAlias = jpaEntityAlias;
- }
-
- /**
- * gets the JPA entity alias name set into the context
- */
- @Override
- public final String getJPAEntityAlias() {
- return jpaEntityAlias;
- }
-
- /**
- * sets the JPQL context type into the context
- *
- * @param type
- * is JPQLContextType
- */
- protected final void setType(final JPQLContextType type) {
- this.type = type;
- }
-
- /**
- * gets the JPA entity name set into the context
- */
- @Override
- public final String getJPAEntityName() {
- return jpaEntityName;
- }
-
- /**
- * gets the JPQL context type set into the context
- */
- @Override
- public final JPQLContextType getType() {
- return type;
- }
-
- /**
- * the method returns an instance of type
- * {@link org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLContext.JPQLContextBuilder} based on the
- * JPQLContextType. The context builder can be used for
- * building different JPQL contexts.
- *
- * @param contextType
- * is the JPQLContextType
- * @param resultsView
- * is the OData request view
- * @return an instance of type {@link org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLContext.JPQLContextBuilder}
- * @throws ODataJPARuntimeException
- */
- public final static JPQLContextBuilder createBuilder(final JPQLContextType contextType, final Object resultsView)
- throws ODataJPARuntimeException {
- return JPQLContextBuilder.create(contextType, resultsView);
- }
-
- /**
- * The abstract class is extended by specific JPQLContext builder for
- * building JPQLContexts.
- *
- *
- *
- */
- public static abstract class JPQLContextBuilder {
- /**
- * alias counter is an integer counter that is incremented by "1" for
- * every new alias name generation. The value of counter is used in the
- * generation of JPA entity alias names.
- */
- protected int aliasCounter = 0;
-
- protected JPQLContextBuilder() {}
-
- /**
- * the method instantiates an instance of type JPQLContextBuilder.
- *
- * @param contextType
- * indicates the type of JPQLContextBuilder to instantiate.
- * @param resultsView
- * is the OData request view
- * @return an instance of type
- * {@link org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLContext.JPQLContextBuilder}
- * @throws ODataJPARuntimeException
- */
- private static JPQLContextBuilder create(final JPQLContextType contextType, final Object resultsView)
- throws ODataJPARuntimeException {
- JPQLContextBuilder contextBuilder =
- ODataJPAFactory.createFactory().getJPQLBuilderFactory().getContextBuilder(contextType);
- if (contextBuilder == null) {
- throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.ERROR_JPQLCTXBLDR_CREATE, null);
- }
- contextBuilder.setResultsView(resultsView);
- return contextBuilder;
- }
-
- /**
- * The abstract method is implemented by specific JPQL context builders
- * to build JPQL Contexts. The build method makes use of information set
- * into the context to built JPQL Context Types.
- *
- * @return an instance of {@link org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLContext}
- * @throws ODataJPAModelException
- * @throws ODataJPARuntimeException
- */
- public abstract JPQLContext build() throws ODataJPAModelException, ODataJPARuntimeException;
-
- /**
- * The abstract method is implemented by specific JPQL context builder.
- * The method sets the OData request view into the JPQL context.
- *
- * @param resultsView
- * is an instance representing OData request.
- */
- protected abstract void setResultsView(Object resultsView);
-
- /**
- * The method resets the alias counter value to "0".
- */
- protected void resetAliasCounter() {
- aliasCounter = 0;
- }
-
- /**
- * The method returns a system generated alias name starting with prefix
- * "E" and ending with suffix "aliasCounter".
- *
- * @return a String representing JPA entity alias name
- */
- protected String generateJPAEntityAlias() {
- return new String("E" + ++aliasCounter);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/jpql/JPQLContextType.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/jpql/JPQLContextType.java b/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/jpql/JPQLContextType.java
deleted file mode 100644
index 17df83a..0000000
--- a/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/jpql/JPQLContextType.java
+++ /dev/null
@@ -1,73 +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.api.jpa.jpql;
-
-/**
- * Enumerated list of JPQL context Types.
- *
- *
- *
- */
-public enum JPQLContextType {
- /**
- * indicates that the JPQL context can be used for building JPQL select
- * statements
- */
- SELECT,
- /**
- * indicates that the JPQL context can be used for building JPQL modify
- * statements
- */
- MODIFY,
- /**
- * indicates that the JPQL context can be used for building JPQL delete
- * statements
- */
- DELETE,
- /**
- * indicates that the JPQL context can be used for building JPQL select
- * statement that fetches single record
- */
- SELECT_SINGLE,
- /**
- * indicates that the JPQL context can be used for building JPQL join
- * statement
- */
- JOIN,
- /**
- * indicates that the JPQL context can be used for building JPQL join
- * statement that fetches single record
- */
- JOIN_SINGLE,
- /**
- * indicates that the JPQL context can be used for building JPQL select
- * statement that fetches record counts
- */
- SELECT_COUNT,
- /**
- * indicates that the JPQL context can be used for building JPQL join
- * statement that fetches single record
- */
- JOIN_COUNT,
- /**
- * indicates that the JPQL context can be used for building JPA Method
- * context that can be used for invoking custom functions
- */
- FUNCTION
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/jpql/JPQLContextView.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/jpql/JPQLContextView.java b/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/jpql/JPQLContextView.java
deleted file mode 100644
index d1ac24f..0000000
--- a/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/jpql/JPQLContextView.java
+++ /dev/null
@@ -1,53 +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.api.jpa.jpql;
-
-/**
- * The interface provides a view on JPQL Context. The view can be used to access
- * different JPQL context type implementations.
- *
- *
- * @see org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLContextType
- * @see org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLContextType
- */
-public interface JPQLContextView {
- /**
- * The method returns a JPA entity name for which the JPQL context is
- * relevant.
- *
- * @return JPA entity name
- */
- public String getJPAEntityName();
-
- /**
- * The method returns a JPA entity alias name for which the JPQL context is
- * relevant.
- *
- * @return JPA entity alias name
- */
-
- public String getJPAEntityAlias();
-
- /**
- * The method returns a JPQL context type
- *
- * @return an instance of type {@link org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLContextType}
- */
- public JPQLContextType getType();
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/jpql/JPQLJoinContextView.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/jpql/JPQLJoinContextView.java b/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/jpql/JPQLJoinContextView.java
deleted file mode 100644
index 4392015..0000000
--- a/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/jpql/JPQLJoinContextView.java
+++ /dev/null
@@ -1,44 +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.api.jpa.jpql;
-
-import java.util.List;
-
-import org.apache.olingo.odata2.processor.api.jpa.access.JPAJoinClause;
-
-/**
- * The interface provide a view on JPQL Join context.The interface provides
- * methods for accessing the Join Clause which can be part of JPQL Select
- * statement. The interface extends the JPQL Select Context to add JQPL Join
- * clauses to the Select statement. The JPQL Join context view is built from
- * OData read entity set with navigation request.
- *
- *
- * @see org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLSelectContextView
- *
- */
-public interface JPQLJoinContextView extends JPQLSelectContextView {
- /**
- * The method returns a list of JPA Join Clauses. The returned list of
- * values can be used for building JPQL Statements with Join clauses.
- *
- * @return a list of {@link org.apache.olingo.odata2.processor.api.jpa.access.JPAJoinClause}
- */
- public List<JPAJoinClause> getJPAJoinClauses();
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/jpql/JPQLJoinSelectSingleContextView.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/jpql/JPQLJoinSelectSingleContextView.java b/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/jpql/JPQLJoinSelectSingleContextView.java
deleted file mode 100644
index 7d71dc3..0000000
--- a/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/jpql/JPQLJoinSelectSingleContextView.java
+++ /dev/null
@@ -1,45 +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.api.jpa.jpql;
-
-import java.util.List;
-
-import org.apache.olingo.odata2.processor.api.jpa.access.JPAJoinClause;
-
-/**
- * The interface provide a view on JPQL Join Clauses.The interface is an
- * extension to JPQL select single context and provides methods for accessing
- * JPQL Join clauses. The view can be used for building JPQL statements without
- * any WHERE,ORDERBY clauses. The clauses are built from OData read entity
- * request views.
- *
- *
- * @see org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLSelectSingleContextView
- *
- */
-public interface JPQLJoinSelectSingleContextView extends JPQLSelectSingleContextView {
-
- /**
- * The method returns a list of JPA Join Clauses. The returned list of
- * values can be used for building JPQL Statements with Join clauses.
- *
- * @return a list of {@link org.apache.olingo.odata2.processor.api.jpa.access.JPAJoinClause}
- */
- public abstract List<JPAJoinClause> getJPAJoinClauses();
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/jpql/JPQLSelectContextView.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/jpql/JPQLSelectContextView.java b/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/jpql/JPQLSelectContextView.java
deleted file mode 100644
index 58f595e..0000000
--- a/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/jpql/JPQLSelectContextView.java
+++ /dev/null
@@ -1,62 +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.api.jpa.jpql;
-
-import java.util.HashMap;
-
-/**
- * The interface provide a view on JPQL select context.The interface provides
- * methods for accessing the clauses of a JPQL SELECT statement like "SELECT",
- * "ORDERBY", "WHERE". The clauses are built from OData read entity set request
- * views. The clauses thus built can be used for building JPQL Statements.
- *
- *
- * @see org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLStatement
- *
- */
-public interface JPQLSelectContextView extends JPQLContextView {
- /**
- * The method returns a JPQL SELECT clause. The SELECT clause is built from
- * $select OData system Query option.
- *
- * @return a String representing a SELECT clause in JPQL
- */
- public String getSelectExpression();
-
- /**
- * The method returns a Hash Map of JPQL ORDERBY clause. The ORDERBY clause
- * is built from $orderby OData system query option. The hash map contains
- * <ol>
- * <li>Key - JPA Entity Property name to be ordered</li>
- * <li>Value - Sort Order in JPQL (desc,asc)</li>
- * </ol>
- *
- * @return a hash map of (JPA Property Name,Sort Order)
- */
- public HashMap<String, String> getOrderByCollection();
-
- /**
- * The method returns a JPQL WHERE condition as string. The WHERE condition
- * can be built from $filter OData System Query Option and/or Key predicates
- * of an OData Request.
- *
- * @return a String representing a WHERE condition in JPQL
- */
- public String getWhereExpression();
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/jpql/JPQLSelectSingleContextView.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/jpql/JPQLSelectSingleContextView.java b/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/jpql/JPQLSelectSingleContextView.java
deleted file mode 100644
index 5e492be..0000000
--- a/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/jpql/JPQLSelectSingleContextView.java
+++ /dev/null
@@ -1,53 +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.api.jpa.jpql;
-
-import java.util.List;
-
-import org.apache.olingo.odata2.api.uri.KeyPredicate;
-
-/**
- * The interface provide a view on JPQL select single context.The interface
- * provides methods for accessing the clause of a JPQL SELECT statement like
- * "SELECT". The view can be used for building JPQL statements without any
- * WHERE,JOIN,ORDERBY clauses. The clauses are built from OData read entity
- * request views.
- *
- *
- * @see org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLStatement
- *
- */
-public interface JPQLSelectSingleContextView extends JPQLContextView {
- /**
- * The method returns a JPQL SELECT clause. The SELECT clause is built from
- * $select OData system Query option.
- *
- * @return a String representing a SELECT clause in JPQL
- */
- public String getSelectExpression();
-
- /**
- * The method returns the list of key predicates that can be used for
- * constructing the WHERE clause in JPQL statements. The OData entity key
- * predicates are thus converted into JPA entity keys.
- *
- * @return a list of key predicates
- */
- public List<KeyPredicate> getKeyPredicates();
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/jpql/JPQLStatement.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/jpql/JPQLStatement.java b/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/jpql/JPQLStatement.java
deleted file mode 100644
index e68b4d4..0000000
--- a/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/jpql/JPQLStatement.java
+++ /dev/null
@@ -1,148 +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.api.jpa.jpql;
-
-import org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPARuntimeException;
-import org.apache.olingo.odata2.processor.api.jpa.factory.ODataJPAFactory;
-
-/**
- * The class represents a Java Persistence Query Language (JPQL) Statement.
- * The JPQL statement is built using a builder namely
- * {@link org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLStatement.JPQLStatementBuilder} . Based upon the JPQL
- * Context types ( {@link org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLContextType} different
- * kinds of JPQL statements are built.
- * The JPQL statements thus generated can be executed using JPA Query APIs to fetch JPA entities.
- *
- *
- * @see org.apache.olingo.odata2.processor.api.jpa.factory.JPQLBuilderFactory
- * @see org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLContextView
- */
-public class JPQLStatement {
-
- protected String statement;
-
- /**
- * The method is used for creating an instance of JPQL Statement Builder for
- * building JPQL statements. The JPQL Statement builder is created based
- * upon the JPQL Context.
- *
- * @param context
- * a non null value of {@link org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLContextView} . The context is
- * expected to be set to be built with no
- * errors.
- * @return an instance of JPQL statement builder
- * @throws ODataJPARuntimeException
- */
- public static JPQLStatementBuilder createBuilder(final JPQLContextView context) throws ODataJPARuntimeException {
- return JPQLStatementBuilder.create(context);
- }
-
- private JPQLStatement(final String statement) {
- this.statement = statement;
- }
-
- /**
- * The method provides a String representation of JPQLStatement.
- */
- @Override
- public String toString() {
- return statement;
- }
-
- /**
- * The abstract class is extended by specific JPQL statement builders for
- * building JPQL statements like
- * <ol>
- * <li>Select statements</li>
- * <li>Select single statements</li>
- * <li>Select statements with Join</li>
- * <li>Insert/Modify/Delete statements</li>
- * </ol>
- *
- * A default statement builder for building each kind of JPQL statements is
- * provided by the library.
- *
- *
- *
- */
- public static abstract class JPQLStatementBuilder {
-
- protected JPQLStatementBuilder() {}
-
- private static final JPQLStatementBuilder create(final JPQLContextView context) throws ODataJPARuntimeException {
- return ODataJPAFactory.createFactory().getJPQLBuilderFactory().getStatementBuilder(context);
- }
-
- protected final JPQLStatement createStatement(final String statement) {
- return new JPQLStatement(statement);
- }
-
- /**
- * The abstract method is implemented by specific statement builder for
- * building JPQL Statement.
- *
- * @return an instance of {@link org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLStatement}
- * @throws ODataJPARuntimeException
- * in case there are errors building the statements
- */
- public abstract JPQLStatement build() throws ODataJPARuntimeException;
-
- }
-
- public static final class Operator {
- public static final String EQ = "=";
- public static final String NE = "<>";
- public static final String LT = "<";
- public static final String LE = "<=";
- public static final String GT = ">";
- public static final String GE = ">=";
- public static final String AND = "AND";
- public static final String NOT = "NOT";
- public static final String OR = "OR";
-
- }
-
- public static final class KEYWORD {
- public static final String SELECT = "SELECT";
- public static final String FROM = "FROM";
- public static final String WHERE = "WHERE";
- public static final String LEFT_OUTER_JOIN = "LEFT OUTER JOIN";
- public static final String OUTER = "OUTER";
- public static final String JOIN = "JOIN";
- public static final String ORDERBY = "ORDER BY";
- public static final String COUNT = "COUNT";
- public static final String OFFSET = ".000";
- public static final String TIMESTAMP = "ts";
-
- }
-
- public static final class DELIMITER {
- public static final char SPACE = ' ';
- public static final char COMMA = ',';
- public static final char PERIOD = '.';
- public static final char PARENTHESIS_LEFT = '(';
- public static final char PARENTHESIS_RIGHT = ')';
- public static final char COLON = ':';
- public static final char HYPHEN = '-';
- public static final char LEFT_BRACE = '{';
- public static final char RIGHT_BRACE = '}';
- public static final char LONG = 'L';
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/jpql/package-info.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/jpql/package-info.java b/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/jpql/package-info.java
deleted file mode 100644
index dc02b90..0000000
--- a/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/jpql/package-info.java
+++ /dev/null
@@ -1,27 +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.
- ******************************************************************************/
-/**
- * <h3>OData JPA Processor API Library - Java Persistence Query Language</h3>
- * The library provides set of APIs for building JPQL contexts from OData Requests.
- * The JPQL contexts thus built can be used for building JPQL Statements.
- *
- *
- */
-package org.apache.olingo.odata2.processor.api.jpa.jpql;
-
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmAssociationEndView.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmAssociationEndView.java b/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmAssociationEndView.java
deleted file mode 100644
index 9d3238d..0000000
--- a/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmAssociationEndView.java
+++ /dev/null
@@ -1,91 +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.api.jpa.model;
-
-import org.apache.olingo.odata2.api.edm.provider.AssociationEnd;
-
-/**
- * <p>
- * A view on Java Persistence Entity Relationship and Entity Data Model
- * Association End.
- * </p>
- * <p>
- * The implementation of the view provides access to EDM Association Ends
- * created from Java Persistence Entity Relationships. The implementation acts
- * as a container for Association Ends.
- * </p>
- *
- * @org.apache.olingo.odata2.DoNotImplement
- * @see org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmAssociationView
- *
- */
-public interface JPAEdmAssociationEndView extends JPAEdmBaseView {
-
- /**
- * The method gets the one of the association ends present in the container.
- *
- * @return one of the {@link org.apache.olingo.odata2.api.edm.provider.AssociationEnd} for an
- * {@link org.apache.olingo.odata2.api.edm.provider.Association}
- */
- AssociationEnd getEdmAssociationEnd2();
-
- /**
- * The method gets the other association end present in the container.
- *
- * @return one of the {@link org.apache.olingo.odata2.api.edm.provider.AssociationEnd} for an
- * {@link org.apache.olingo.odata2.api.edm.provider.Association}
- */
- AssociationEnd getEdmAssociationEnd1();
-
- /**
- * The method compares two ends {<b>end1, end2</b>} of an
- * {@link org.apache.olingo.odata2.api.edm.provider.AssociationEnd} against its
- * two ends.
- *
- * The Method compares the following properties in each end for equality <i>
- * <ul>
- * <li>{@link org.apache.olingo.odata2.api.edm.FullQualifiedName} of End Type</li>
- * <li>{@link org.apache.olingo.odata2.api.edm.EdmMultiplicity} of End</li>
- * </ul>
- * </i>
- *
- * @param end1
- * one end of type {@link org.apache.olingo.odata2.api.edm.provider.AssociationEnd} of
- * an {@link org.apache.olingo.odata2.api.edm.provider.Association}
- * @param end2
- * other end of type {@link org.apache.olingo.odata2.api.edm.provider.AssociationEnd} of
- * an {@link org.apache.olingo.odata2.api.edm.provider.Association} <p>
- * @return <ul>
- * <li><i>true</i> - Only if the properties of <b>end1</b> matches
- * with all the properties of any one end and only if the properties
- * of <b>end2</b> matches with all the properties of the remaining
- * end</li> <li><i>false</i> - Otherwise</li>
- * </ul>
- */
- boolean compare(AssociationEnd end1, AssociationEnd end2);
-
- String getJoinColumnName();
-
- String getJoinColumnReferenceColumnName();
-
- String getMappedByName();
-
- String getOwningPropertyName();
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmAssociationSetView.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmAssociationSetView.java b/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmAssociationSetView.java
deleted file mode 100644
index 911569d..0000000
--- a/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmAssociationSetView.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.api.jpa.model;
-
-import java.util.List;
-
-import org.apache.olingo.odata2.api.edm.provider.Association;
-import org.apache.olingo.odata2.api.edm.provider.AssociationSet;
-
-/**
- * <p>
- * A view on Java Persistence Entity Relationship and Entity Data Model
- * Association Set.
- * </p>
- * <p>
- * The implementation of the view provides access to EDM Association Set created
- * from Java Persistence Entity Relationship. The implementation act as a
- * container for list of association sets that are consistent.
- * </p>
- *
- *
- * <p>
- * @org.apache.olingo.odata2.DoNotImplement
- * @see org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmAssociationView
- */
-public interface JPAEdmAssociationSetView extends JPAEdmBaseView {
-
- /**
- * The method returns a consistent list of association sets. An association
- * set is set to be consistent only if all its mandatory properties can be
- * completely built from a Java Persistence Relationship.
- *
- * @return a consistent list of {@link org.apache.olingo.odata2.api.edm.provider.AssociationSet}
- *
- */
- List<AssociationSet> getConsistentEdmAssociationSetList();
-
- /**
- * The method returns an association set that is currently being processed.
- *
- * @return an instance of type {@link org.apache.olingo.odata2.api.edm.provider.AssociationSet}
- */
- AssociationSet getEdmAssociationSet();
-
- /**
- * The method returns an association from which the association set is
- * currently being processed.
- *
- * @return an instance of type {@link org.apache.olingo.odata2.api.edm.provider.Association}
- */
- Association getEdmAssociation();
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmAssociationView.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmAssociationView.java b/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmAssociationView.java
deleted file mode 100644
index 7cc7cda..0000000
--- a/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmAssociationView.java
+++ /dev/null
@@ -1,128 +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.api.jpa.model;
-
-import java.util.List;
-
-import org.apache.olingo.odata2.api.edm.provider.Association;
-
-/**
- * <p>
- * A View on Java Persistence Entity Relationship and Entity Data Model
- * Association.
- * </p>
- * <p>
- * The implementation of the view provides access to EDM Association created
- * from Java Persistence Entity Relationships. The implementation acts as a
- * container for list of association that are consistent.
- *
- * An Association is said to be consistent only
- * <ol>
- * <li>If both the Ends of Association are consistent</li>
- * <li>If referential constraint exists for the Association then it should be
- * consistent</li>
- * </ol>
- * </p>
- *
- *
- * <p>
- * @org.apache.olingo.odata2.DoNotImplement
- * @see org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmAssociationSetView
- * @see org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmReferentialConstraintView
- *
- */
-public interface JPAEdmAssociationView extends JPAEdmBaseView {
-
- /**
- * The method returns an association which is currently being processed.
- *
- * @return an {@link org.apache.olingo.odata2.api.edm.provider.Association}
- */
- public Association getEdmAssociation();
-
- /**
- * The method returns a consistent list of associations. An association is
- * set to be consistent only if all its mandatory properties can be
- * completely built from a Java Persistence Relationship.
- *
- * @return a consistent list of {@link org.apache.olingo.odata2.api.edm.provider.Association}
- *
- */
- public List<Association> getConsistentEdmAssociationList();
-
- /**
- * The method adds {@link org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmAssociationView} to its container
- *
- * @param associationView
- * of type {@link org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmAssociationView}
- */
- public void addJPAEdmAssociationView(JPAEdmAssociationView associationView,
- JPAEdmAssociationEndView associationEndView);
-
- /**
- * The method searches for an Association in its container against the
- * search parameter <b>view</b> of type {@link org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmAssociationView}
- * .
- *
- * The Association in the container <b>view</b> is searched against the
- * consistent list of Association stored in this container.
- *
- * @param view
- * of type {@link org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmAssociationView}
- * @return {@link org.apache.olingo.odata2.api.edm.provider.Association} if found
- * in the container
- */
- public Association searchAssociation(JPAEdmAssociationEndView view);
-
- /**
- * The method adds the referential constraint view to its container.
- * <p>
- * <b>Note: </b>The referential constraint view is added only if it exists.
- * </p>
- *
- * @param refView
- * of type {@link org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmReferentialConstraintView}
- */
- public void addJPAEdmRefConstraintView(JPAEdmReferentialConstraintView refView);
-
- /**
- * The method returns the referential constraint view that is currently
- * being processed.
- *
- * @return an instance of type
- * {@link org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmReferentialConstraintView}
- */
- public JPAEdmReferentialConstraintView getJPAEdmReferentialConstraintView();
-
- /**
- * The method searches for the number of associations with similar endpoints in its container against the
- * search parameter <b>view</b> of type {@link org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmAssociationView}
- * .
- *
- * The Association in the container <b>view</b> is searched against the
- * consistent list of Association stored in this container.
- *
- * @param view
- * of type {@link org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmAssociationView}
- * @return {@link org.apache.olingo.odata2.api.edm.provider.Association} if found
- * in the container
- */
- int getNumberOfAssociationsWithSimilarEndPoints(JPAEdmAssociationEndView view);
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmBaseView.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmBaseView.java b/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmBaseView.java
deleted file mode 100644
index 765da7f..0000000
--- a/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmBaseView.java
+++ /dev/null
@@ -1,101 +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.api.jpa.model;
-
-import javax.persistence.metamodel.Metamodel;
-
-import org.apache.olingo.odata2.processor.api.jpa.access.JPAEdmBuilder;
-import org.apache.olingo.odata2.processor.api.jpa.access.JPAEdmMappingModelAccess;
-
-/**
- * <p>
- * A base view on Java Persistence Model and Entity Data Model.
- * </p>
- * <p>
- * The implementation of the view acts as a base container for containers of
- * Java Persistence Model and Entity Data Model elements.
- *
- *
- * <p>
- * @org.apache.olingo.odata2.DoNotImplement
- *
- */
-public interface JPAEdmBaseView {
- /**
- *
- * @return Java Persistence Unit Name
- */
- public String getpUnitName();
-
- /**
- * The method returns the Java Persistence MetaModel
- *
- * @return a meta model of type {@link javax.persistence.metamodel.Metamodel}
- */
- public Metamodel getJPAMetaModel();
-
- /**
- * The method returns a builder for building Entity Data Model elements from
- * Java Persistence Model Elements
- *
- * @return a builder of type {@link org.apache.olingo.odata2.processor.api.jpa.access.JPAEdmBuilder}
- */
- public JPAEdmBuilder getBuilder();
-
- /**
- * The method returns the if the container is consistent without any errors
- *
- * @return <ul>
- * <li>true - if the container is consistent without errors</li>
- * <li>false - if the container is inconsistent with errors</li>
- * </ul>
- *
- */
- public boolean isConsistent();
-
- /**
- * The method cleans the container.
- */
- public void clean();
-
- /**
- * The method returns a reference to JPA EDM mapping model access.
- *
- * @return an instance to JPA EDM mapping model access
- */
- public JPAEdmMappingModelAccess getJPAEdmMappingModelAccess();
-
- /**
- * The method returns a reference to JPA EDM extension if available else
- * null.
- *
- * @return an instance of JPA Edm Extension
- */
- public JPAEdmExtension getJPAEdmExtension();
-
- /**
- * The method returns whether the default naming logic is skipped for the
- * current view.
- *
- * @return <ul><li>true - skip default naming logic</li>
- * <li>false - do not skip default naming logic</li>
- * </ul>
- */
- public boolean isDefaultNamingSkipped();
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmComplexPropertyView.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmComplexPropertyView.java b/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmComplexPropertyView.java
deleted file mode 100644
index 172e5f4..0000000
--- a/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmComplexPropertyView.java
+++ /dev/null
@@ -1,45 +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.api.jpa.model;
-
-import org.apache.olingo.odata2.api.edm.provider.ComplexProperty;
-
-/**
- * <p>
- * A view on properties of Java Persistence embeddable type and EDM complex
- * type. Properties of JPA embeddable types are converted into EDM properties of
- * EDM complex type.
- * </p>
- * <p>
- * The implementation of the view provides access to properties of EDM complex
- * type created for a given JPA EDM complex type. The implementation acts as a
- * container for the properties of EDM complex type.
- * </p>
- *
- * @org.apache.olingo.odata2.DoNotImplement
- * @see org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmComplexTypeView
- */
-public interface JPAEdmComplexPropertyView extends JPAEdmBaseView {
- /**
- * The method returns a complex property for a complex type.
- *
- * @return an instance of {@link org.apache.olingo.odata2.api.edm.provider.ComplexProperty}
- */
- ComplexProperty getEdmComplexProperty();
-}
[33/37] [OLINGO-82] Renamed the project folder name to
odata2-jpa-processor
Posted by ch...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/ODataJPAResponseBuilder.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/ODataJPAResponseBuilder.java b/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/ODataJPAResponseBuilder.java
new file mode 100644
index 0000000..8f3487e
--- /dev/null
+++ b/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/ODataJPAResponseBuilder.java
@@ -0,0 +1,629 @@
+/*******************************************************************************
+ * 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;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.olingo.odata2.api.commons.HttpStatusCodes;
+import org.apache.olingo.odata2.api.commons.InlineCount;
+import org.apache.olingo.odata2.api.edm.EdmEntitySet;
+import org.apache.olingo.odata2.api.edm.EdmEntityType;
+import org.apache.olingo.odata2.api.edm.EdmException;
+import org.apache.olingo.odata2.api.edm.EdmFunctionImport;
+import org.apache.olingo.odata2.api.edm.EdmLiteralKind;
+import org.apache.olingo.odata2.api.edm.EdmMultiplicity;
+import org.apache.olingo.odata2.api.edm.EdmNavigationProperty;
+import org.apache.olingo.odata2.api.edm.EdmProperty;
+import org.apache.olingo.odata2.api.edm.EdmSimpleType;
+import org.apache.olingo.odata2.api.edm.EdmStructuralType;
+import org.apache.olingo.odata2.api.edm.EdmType;
+import org.apache.olingo.odata2.api.edm.EdmTypeKind;
+import org.apache.olingo.odata2.api.ep.EntityProvider;
+import org.apache.olingo.odata2.api.ep.EntityProviderException;
+import org.apache.olingo.odata2.api.ep.EntityProviderWriteProperties;
+import org.apache.olingo.odata2.api.ep.EntityProviderWriteProperties.ODataEntityProviderPropertiesBuilder;
+import org.apache.olingo.odata2.api.exception.ODataException;
+import org.apache.olingo.odata2.api.exception.ODataHttpException;
+import org.apache.olingo.odata2.api.exception.ODataNotFoundException;
+import org.apache.olingo.odata2.api.processor.ODataContext;
+import org.apache.olingo.odata2.api.processor.ODataResponse;
+import org.apache.olingo.odata2.api.uri.ExpandSelectTreeNode;
+import org.apache.olingo.odata2.api.uri.NavigationPropertySegment;
+import org.apache.olingo.odata2.api.uri.SelectItem;
+import org.apache.olingo.odata2.api.uri.UriParser;
+import org.apache.olingo.odata2.api.uri.info.DeleteUriInfo;
+import org.apache.olingo.odata2.api.uri.info.GetEntityLinkUriInfo;
+import org.apache.olingo.odata2.api.uri.info.GetEntitySetLinksUriInfo;
+import org.apache.olingo.odata2.api.uri.info.GetEntitySetUriInfo;
+import org.apache.olingo.odata2.api.uri.info.GetEntityUriInfo;
+import org.apache.olingo.odata2.api.uri.info.GetFunctionImportUriInfo;
+import org.apache.olingo.odata2.api.uri.info.PostUriInfo;
+import org.apache.olingo.odata2.api.uri.info.PutMergePatchUriInfo;
+import org.apache.olingo.odata2.processor.api.jpa.ODataJPAContext;
+import org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPARuntimeException;
+import org.apache.olingo.odata2.processor.core.jpa.access.data.JPAEntityParser;
+import org.apache.olingo.odata2.processor.core.jpa.access.data.JPAExpandCallBack;
+
+public final class ODataJPAResponseBuilder {
+
+ /* Response for Read Entity Set */
+ public static <T> ODataResponse build(final List<T> jpaEntities, final GetEntitySetUriInfo resultsView,
+ final String contentType, final ODataJPAContext odataJPAContext) throws ODataJPARuntimeException {
+
+ EdmEntityType edmEntityType = null;
+ ODataResponse odataResponse = null;
+ List<ArrayList<NavigationPropertySegment>> expandList = null;
+
+ try {
+ edmEntityType = resultsView.getTargetEntitySet().getEntityType();
+ List<Map<String, Object>> edmEntityList = new ArrayList<Map<String, Object>>();
+ Map<String, Object> edmPropertyValueMap = null;
+ JPAEntityParser jpaResultParser = new JPAEntityParser();
+ final List<SelectItem> selectedItems = resultsView.getSelect();
+ if (selectedItems != null && selectedItems.size() > 0) {
+ for (Object jpaEntity : jpaEntities) {
+ edmPropertyValueMap =
+ jpaResultParser.parse2EdmPropertyValueMap(jpaEntity, buildSelectItemList(selectedItems, edmEntityType));
+ edmEntityList.add(edmPropertyValueMap);
+ }
+ } else {
+ for (Object jpaEntity : jpaEntities) {
+ edmPropertyValueMap = jpaResultParser.parse2EdmPropertyValueMap(jpaEntity, edmEntityType);
+ edmEntityList.add(edmPropertyValueMap);
+ }
+ }
+ expandList = resultsView.getExpand();
+ if (expandList != null && expandList.size() != 0) {
+ int count = 0;
+ List<EdmNavigationProperty> edmNavPropertyList = constructListofNavProperty(expandList);
+ for (Object jpaEntity : jpaEntities) {
+ Map<String, Object> relationShipMap = edmEntityList.get(count);
+ HashMap<String, Object> navigationMap =
+ jpaResultParser.parse2EdmNavigationValueMap(jpaEntity, edmNavPropertyList);
+ relationShipMap.putAll(navigationMap);
+ count++;
+ }
+ }
+
+ EntityProviderWriteProperties feedProperties = null;
+
+ feedProperties = getEntityProviderProperties(odataJPAContext, resultsView, edmEntityList);
+ odataResponse =
+ EntityProvider.writeFeed(contentType, resultsView.getTargetEntitySet(), edmEntityList, feedProperties);
+ odataResponse = ODataResponse.fromResponse(odataResponse).status(HttpStatusCodes.OK).build();
+
+ } catch (EntityProviderException e) {
+ throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e);
+ } catch (EdmException e) {
+ throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e);
+ }
+
+ return odataResponse;
+ }
+
+ /* Response for Read Entity */
+ public static ODataResponse build(final Object jpaEntity, final GetEntityUriInfo resultsView,
+ final String contentType, final ODataJPAContext oDataJPAContext) throws ODataJPARuntimeException,
+ ODataNotFoundException {
+
+ List<ArrayList<NavigationPropertySegment>> expandList = null;
+ if (jpaEntity == null) {
+ throw new ODataNotFoundException(ODataNotFoundException.ENTITY);
+ }
+ EdmEntityType edmEntityType = null;
+ ODataResponse odataResponse = null;
+
+ try {
+
+ edmEntityType = resultsView.getTargetEntitySet().getEntityType();
+ Map<String, Object> edmPropertyValueMap = null;
+
+ JPAEntityParser jpaResultParser = new JPAEntityParser();
+ final List<SelectItem> selectedItems = resultsView.getSelect();
+ if (selectedItems != null && selectedItems.size() > 0) {
+ edmPropertyValueMap =
+ jpaResultParser.parse2EdmPropertyValueMap(jpaEntity, buildSelectItemList(selectedItems, resultsView
+ .getTargetEntitySet().getEntityType()));
+ } else {
+ edmPropertyValueMap = jpaResultParser.parse2EdmPropertyValueMap(jpaEntity, edmEntityType);
+ }
+
+ expandList = resultsView.getExpand();
+ if (expandList != null && expandList.size() != 0) {
+ HashMap<String, Object> navigationMap =
+ jpaResultParser.parse2EdmNavigationValueMap(jpaEntity, constructListofNavProperty(expandList));
+ edmPropertyValueMap.putAll(navigationMap);
+ }
+ EntityProviderWriteProperties feedProperties = null;
+ feedProperties = getEntityProviderProperties(oDataJPAContext, resultsView);
+ odataResponse =
+ EntityProvider.writeEntry(contentType, resultsView.getTargetEntitySet(), edmPropertyValueMap, feedProperties);
+
+ odataResponse = ODataResponse.fromResponse(odataResponse).status(HttpStatusCodes.OK).build();
+
+ } catch (EntityProviderException e) {
+ throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e);
+ } catch (EdmException e) {
+ throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e);
+ }
+
+ return odataResponse;
+ }
+
+ /* Response for $count */
+ public static ODataResponse build(final long jpaEntityCount, final ODataJPAContext oDataJPAContext)
+ throws ODataJPARuntimeException {
+
+ ODataResponse odataResponse = null;
+ try {
+ odataResponse = EntityProvider.writeText(String.valueOf(jpaEntityCount));
+ odataResponse = ODataResponse.fromResponse(odataResponse).build();
+ } catch (EntityProviderException e) {
+ throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e);
+ }
+ return odataResponse;
+ }
+
+ /* Response for Create Entity */
+ @SuppressWarnings("unchecked")
+ public static ODataResponse build(final List<Object> createdObjectList, final PostUriInfo uriInfo,
+ final String contentType, final ODataJPAContext oDataJPAContext) throws ODataJPARuntimeException,
+ ODataNotFoundException {
+
+ if (createdObjectList == null || createdObjectList.size() == 0 || createdObjectList.get(0) == null) {
+ throw new ODataNotFoundException(ODataNotFoundException.ENTITY);
+ }
+
+ EdmEntityType edmEntityType = null;
+ ODataResponse odataResponse = null;
+
+ try {
+
+ edmEntityType = uriInfo.getTargetEntitySet().getEntityType();
+ Map<String, Object> edmPropertyValueMap = null;
+
+ JPAEntityParser jpaResultParser = new JPAEntityParser();
+ edmPropertyValueMap = jpaResultParser.parse2EdmPropertyValueMap(createdObjectList.get(0), edmEntityType);
+
+ List<ArrayList<NavigationPropertySegment>> expandList = null;
+ if (createdObjectList.get(1) != null
+ && ((Map<EdmNavigationProperty, EdmEntitySet>) createdObjectList.get(1)).size() > 0) {
+ expandList = getExpandList((Map<EdmNavigationProperty, EdmEntitySet>) createdObjectList.get(1));
+ HashMap<String, Object> navigationMap =
+ jpaResultParser.parse2EdmNavigationValueMap(createdObjectList.get(0),
+ constructListofNavProperty(expandList));
+ edmPropertyValueMap.putAll(navigationMap);
+ }
+ EntityProviderWriteProperties feedProperties = null;
+ try {
+ feedProperties = getEntityProviderPropertiesforPost(oDataJPAContext, uriInfo, expandList);
+ } catch (ODataException e) {
+ throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.INNER_EXCEPTION, e);
+ }
+
+ odataResponse =
+ EntityProvider.writeEntry(contentType, uriInfo.getTargetEntitySet(), edmPropertyValueMap, feedProperties);
+
+ odataResponse = ODataResponse.fromResponse(odataResponse).status(HttpStatusCodes.CREATED).build();
+
+ } catch (EntityProviderException e) {
+ throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e);
+ } catch (EdmException e) {
+ throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e);
+ }
+
+ return odataResponse;
+ }
+
+ /* Response for Update Entity */
+ public static ODataResponse build(final Object updatedObject, final PutMergePatchUriInfo putUriInfo)
+ throws ODataJPARuntimeException, ODataNotFoundException {
+ if (updatedObject == null) {
+ throw new ODataNotFoundException(ODataNotFoundException.ENTITY);
+ }
+ return ODataResponse.status(HttpStatusCodes.NO_CONTENT).build();
+ }
+
+ /* Response for Delete Entity */
+ public static ODataResponse build(final Object deletedObject, final DeleteUriInfo deleteUriInfo)
+ throws ODataJPARuntimeException, ODataNotFoundException {
+
+ if (deletedObject == null) {
+ throw new ODataNotFoundException(ODataNotFoundException.ENTITY);
+ }
+ return ODataResponse.status(HttpStatusCodes.NO_CONTENT).build();
+ }
+
+ /* Response for Function Import Single Result */
+ public static ODataResponse build(final Object result, final GetFunctionImportUriInfo resultsView)
+ throws ODataJPARuntimeException {
+
+ try {
+ final EdmFunctionImport functionImport = resultsView.getFunctionImport();
+ final EdmSimpleType type = (EdmSimpleType) functionImport.getReturnType().getType();
+
+ if (result != null) {
+ ODataResponse response = null;
+
+ final String value = type.valueToString(result, EdmLiteralKind.DEFAULT, null);
+ response = EntityProvider.writeText(value);
+
+ return ODataResponse.fromResponse(response).build();
+ } else {
+ throw new ODataNotFoundException(ODataHttpException.COMMON);
+ }
+ } catch (EdmException e) {
+ throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e);
+ } catch (EntityProviderException e) {
+ throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e);
+ } catch (ODataException e) {
+ throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.INNER_EXCEPTION, e);
+ }
+ }
+
+ /* Response for Function Import Multiple Result */
+ public static ODataResponse build(final List<Object> resultList, final GetFunctionImportUriInfo resultsView,
+ final String contentType, final ODataJPAContext oDataJPAContext) throws ODataJPARuntimeException,
+ ODataNotFoundException {
+
+ ODataResponse odataResponse = null;
+
+ if (resultList != null && !resultList.isEmpty()) {
+ JPAEntityParser jpaResultParser = new JPAEntityParser();
+ EdmType edmType = null;
+ EdmFunctionImport functionImport = null;
+ Map<String, Object> edmPropertyValueMap = null;
+ List<Map<String, Object>> edmEntityList = null;
+ Object result = null;
+ try {
+ EntityProviderWriteProperties feedProperties = null;
+
+ feedProperties =
+ EntityProviderWriteProperties.serviceRoot(oDataJPAContext.getODataContext().getPathInfo().getServiceRoot())
+ .build();
+
+ functionImport = resultsView.getFunctionImport();
+ edmType = functionImport.getReturnType().getType();
+
+ if (edmType.getKind().equals(EdmTypeKind.ENTITY) || edmType.getKind().equals(EdmTypeKind.COMPLEX)) {
+ if (functionImport.getReturnType().getMultiplicity().equals(EdmMultiplicity.MANY)) {
+ edmEntityList = new ArrayList<Map<String, Object>>();
+ for (Object jpaEntity : resultList) {
+ edmPropertyValueMap = jpaResultParser.parse2EdmPropertyValueMap(jpaEntity, (EdmStructuralType) edmType);
+ edmEntityList.add(edmPropertyValueMap);
+ }
+ result = edmEntityList;
+ } else {
+
+ Object resultObject = resultList.get(0);
+ edmPropertyValueMap = jpaResultParser.parse2EdmPropertyValueMap(resultObject, (EdmStructuralType) edmType);
+
+ result = edmPropertyValueMap;
+ }
+
+ } else if (edmType.getKind().equals(EdmTypeKind.SIMPLE)) {
+ result = resultList.get(0);
+ }
+
+ odataResponse =
+ EntityProvider.writeFunctionImport(contentType, resultsView.getFunctionImport(), result, feedProperties);
+ odataResponse = ODataResponse.fromResponse(odataResponse).status(HttpStatusCodes.OK).build();
+
+ } catch (EdmException e) {
+ throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e);
+ } catch (EntityProviderException e) {
+ throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e);
+ } catch (ODataException e) {
+ throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.INNER_EXCEPTION, e);
+ }
+
+ } else {
+ throw new ODataNotFoundException(ODataHttpException.COMMON);
+ }
+
+ return odataResponse;
+ }
+
+ /* Response for Read Entity Link */
+ public static ODataResponse build(final Object jpaEntity, final GetEntityLinkUriInfo resultsView,
+ final String contentType, final ODataJPAContext oDataJPAContext) throws ODataNotFoundException,
+ ODataJPARuntimeException {
+
+ if (jpaEntity == null) {
+ throw new ODataNotFoundException(ODataNotFoundException.ENTITY);
+ }
+ EdmEntityType edmEntityType = null;
+ ODataResponse odataResponse = null;
+
+ try {
+
+ EdmEntitySet entitySet = resultsView.getTargetEntitySet();
+ edmEntityType = entitySet.getEntityType();
+ Map<String, Object> edmPropertyValueMap = null;
+
+ JPAEntityParser jpaResultParser = new JPAEntityParser();
+ edmPropertyValueMap = jpaResultParser.parse2EdmPropertyValueMap(jpaEntity, edmEntityType.getKeyProperties());
+
+ EntityProviderWriteProperties entryProperties =
+ EntityProviderWriteProperties.serviceRoot(oDataJPAContext.getODataContext().getPathInfo().getServiceRoot())
+ .build();
+
+ ODataResponse response = EntityProvider.writeLink(contentType, entitySet, edmPropertyValueMap, entryProperties);
+
+ odataResponse = ODataResponse.fromResponse(response).build();
+
+ } catch (ODataException e) {
+ throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.INNER_EXCEPTION, e);
+
+ }
+
+ return odataResponse;
+ }
+
+ /* Response for Read Entity Links */
+ public static <T> ODataResponse build(final List<T> jpaEntities, final GetEntitySetLinksUriInfo resultsView,
+ final String contentType, final ODataJPAContext oDataJPAContext) throws ODataJPARuntimeException {
+ EdmEntityType edmEntityType = null;
+ ODataResponse odataResponse = null;
+
+ try {
+
+ EdmEntitySet entitySet = resultsView.getTargetEntitySet();
+ edmEntityType = entitySet.getEntityType();
+ List<EdmProperty> keyProperties = edmEntityType.getKeyProperties();
+
+ List<Map<String, Object>> edmEntityList = new ArrayList<Map<String, Object>>();
+ Map<String, Object> edmPropertyValueMap = null;
+ JPAEntityParser jpaResultParser = new JPAEntityParser();
+
+ for (Object jpaEntity : jpaEntities) {
+ edmPropertyValueMap = jpaResultParser.parse2EdmPropertyValueMap(jpaEntity, keyProperties);
+ edmEntityList.add(edmPropertyValueMap);
+ }
+
+ Integer count = null;
+ if (resultsView.getInlineCount() != null) {
+ if ((resultsView.getSkip() != null || resultsView.getTop() != null)) {
+ // when $skip and/or $top is present with $inlinecount
+ count = getInlineCountForNonFilterQueryLinks(edmEntityList, resultsView);
+ } else {
+ // In all other cases
+ count = resultsView.getInlineCount() == InlineCount.ALLPAGES ? edmEntityList.size() : null;
+ }
+ }
+
+ ODataContext context = oDataJPAContext.getODataContext();
+ EntityProviderWriteProperties entryProperties =
+ EntityProviderWriteProperties.serviceRoot(context.getPathInfo().getServiceRoot()).inlineCountType(
+ resultsView.getInlineCount()).inlineCount(count).build();
+
+ odataResponse = EntityProvider.writeLinks(contentType, entitySet, edmEntityList, entryProperties);
+
+ odataResponse = ODataResponse.fromResponse(odataResponse).build();
+
+ } catch (ODataException e) {
+ throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e);
+ }
+
+ return odataResponse;
+
+ }
+
+ /*
+ * This method handles $inlinecount request. It also modifies the list of results in case of
+ * $inlinecount and $top/$skip combinations. Specific to LinksUriInfo.
+ *
+ * @param edmEntityList
+ *
+ * @param resultsView
+ *
+ * @return
+ */
+ private static Integer getInlineCountForNonFilterQueryLinks(final List<Map<String, Object>> edmEntityList,
+ final GetEntitySetLinksUriInfo resultsView) {
+ // when $skip and/or $top is present with $inlinecount, first get the total count
+ Integer count = null;
+ if (resultsView.getInlineCount() == InlineCount.ALLPAGES) {
+ if (resultsView.getSkip() != null || resultsView.getTop() != null) {
+ count = edmEntityList.size();
+ // Now update the list
+ if (resultsView.getSkip() != null) {
+ // Index checks to avoid IndexOutOfBoundsException
+ if (resultsView.getSkip() > edmEntityList.size()) {
+ edmEntityList.clear();
+ return count;
+ }
+ edmEntityList.subList(0, resultsView.getSkip()).clear();
+ }
+ if (resultsView.getTop() != null && resultsView.getTop() >= 0 && resultsView.getTop() < edmEntityList.size()) {
+ edmEntityList.subList(0, resultsView.getTop());
+ }
+ }
+ }// Inlinecount of None is handled by default - null
+ return count;
+ }
+
+ /*
+ * Method to build the entity provider Property.Callbacks for $expand would
+ * be registered here
+ */
+ private static EntityProviderWriteProperties getEntityProviderProperties(final ODataJPAContext odataJPAContext,
+ final GetEntitySetUriInfo resultsView, final List<Map<String, Object>> edmEntityList)
+ throws ODataJPARuntimeException {
+ ODataEntityProviderPropertiesBuilder entityFeedPropertiesBuilder = null;
+
+ Integer count = null;
+ if (resultsView.getInlineCount() != null) {
+ if ((resultsView.getSkip() != null || resultsView.getTop() != null)) {
+ // when $skip and/or $top is present with $inlinecount
+ count = getInlineCountForNonFilterQueryEntitySet(edmEntityList, resultsView);
+ } else {
+ // In all other cases
+ count = resultsView.getInlineCount() == InlineCount.ALLPAGES ? edmEntityList.size() : null;
+ }
+ }
+
+ try {
+ entityFeedPropertiesBuilder =
+ EntityProviderWriteProperties.serviceRoot(odataJPAContext.getODataContext().getPathInfo().getServiceRoot());
+ entityFeedPropertiesBuilder.inlineCount(count);
+ entityFeedPropertiesBuilder.inlineCountType(resultsView.getInlineCount());
+ ExpandSelectTreeNode expandSelectTree =
+ UriParser.createExpandSelectTree(resultsView.getSelect(), resultsView.getExpand());
+ entityFeedPropertiesBuilder.callbacks(JPAExpandCallBack.getCallbacks(odataJPAContext.getODataContext()
+ .getPathInfo().getServiceRoot(), expandSelectTree, resultsView.getExpand()));
+ entityFeedPropertiesBuilder.expandSelectTree(expandSelectTree);
+
+ } catch (ODataException e) {
+ throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.INNER_EXCEPTION, e);
+ }
+
+ return entityFeedPropertiesBuilder.build();
+ }
+
+ /*
+ * This method handles $inlinecount request. It also modifies the list of results in case of
+ * $inlinecount and $top/$skip combinations. Specific to Entity Set.
+ */
+ private static Integer getInlineCountForNonFilterQueryEntitySet(final List<Map<String, Object>> edmEntityList,
+ final GetEntitySetUriInfo resultsView) {
+ // when $skip and/or $top is present with $inlinecount, first get the total count
+ Integer count = null;
+ if (resultsView.getInlineCount() == InlineCount.ALLPAGES) {
+ if (resultsView.getSkip() != null || resultsView.getTop() != null) {
+ count = edmEntityList.size();
+ // Now update the list
+ if (resultsView.getSkip() != null) {
+ // Index checks to avoid IndexOutOfBoundsException
+ if (resultsView.getSkip() > edmEntityList.size()) {
+ edmEntityList.clear();
+ return count;
+ }
+ edmEntityList.subList(0, resultsView.getSkip()).clear();
+ }
+ if (resultsView.getTop() != null && resultsView.getTop() >= 0 && resultsView.getTop() < edmEntityList.size()) {
+ edmEntityList.retainAll(edmEntityList.subList(0, resultsView.getTop()));
+ }
+ }
+ }// Inlinecount of None is handled by default - null
+ return count;
+ }
+
+ private static EntityProviderWriteProperties getEntityProviderProperties(final ODataJPAContext odataJPAContext,
+ final GetEntityUriInfo resultsView) throws ODataJPARuntimeException {
+ ODataEntityProviderPropertiesBuilder entityFeedPropertiesBuilder = null;
+ ExpandSelectTreeNode expandSelectTree = null;
+ try {
+ entityFeedPropertiesBuilder =
+ EntityProviderWriteProperties.serviceRoot(odataJPAContext.getODataContext().getPathInfo().getServiceRoot());
+ expandSelectTree = UriParser.createExpandSelectTree(resultsView.getSelect(), resultsView.getExpand());
+ entityFeedPropertiesBuilder.expandSelectTree(expandSelectTree);
+ entityFeedPropertiesBuilder.callbacks(JPAExpandCallBack.getCallbacks(odataJPAContext.getODataContext()
+ .getPathInfo().getServiceRoot(), expandSelectTree, resultsView.getExpand()));
+ } catch (ODataException e) {
+ throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.INNER_EXCEPTION, e);
+ }
+
+ return entityFeedPropertiesBuilder.build();
+ }
+
+ private static EntityProviderWriteProperties getEntityProviderPropertiesforPost(
+ final ODataJPAContext odataJPAContext, final PostUriInfo resultsView,
+ final List<ArrayList<NavigationPropertySegment>> expandList) throws ODataJPARuntimeException {
+ ODataEntityProviderPropertiesBuilder entityFeedPropertiesBuilder = null;
+ ExpandSelectTreeNode expandSelectTree = null;
+ try {
+ entityFeedPropertiesBuilder =
+ EntityProviderWriteProperties.serviceRoot(odataJPAContext.getODataContext().getPathInfo().getServiceRoot());
+ expandSelectTree = UriParser.createExpandSelectTree(null, expandList);
+ entityFeedPropertiesBuilder.expandSelectTree(expandSelectTree);
+ entityFeedPropertiesBuilder.callbacks(JPAExpandCallBack.getCallbacks(odataJPAContext.getODataContext()
+ .getPathInfo().getServiceRoot(), expandSelectTree, expandList));
+ } catch (ODataException e) {
+ throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.INNER_EXCEPTION, e);
+ }
+
+ return entityFeedPropertiesBuilder.build();
+ }
+
+ private static List<ArrayList<NavigationPropertySegment>> getExpandList(
+ final Map<EdmNavigationProperty, EdmEntitySet> navPropEntitySetMap) {
+ List<ArrayList<NavigationPropertySegment>> expandList = new ArrayList<ArrayList<NavigationPropertySegment>>();
+ ArrayList<NavigationPropertySegment> navigationPropertySegmentList = new ArrayList<NavigationPropertySegment>();
+ for (Map.Entry<EdmNavigationProperty, EdmEntitySet> entry : navPropEntitySetMap.entrySet()) {
+ final EdmNavigationProperty edmNavigationProperty = entry.getKey();
+ final EdmEntitySet edmEntitySet = entry.getValue();
+ NavigationPropertySegment navigationPropertySegment = new NavigationPropertySegment() {
+
+ @Override
+ public EdmEntitySet getTargetEntitySet() {
+ return edmEntitySet;
+ }
+
+ @Override
+ public EdmNavigationProperty getNavigationProperty() {
+ return edmNavigationProperty;
+ }
+ };
+ navigationPropertySegmentList.add(navigationPropertySegment);
+ }
+ expandList.add(navigationPropertySegmentList);
+ return expandList;
+ }
+
+ private static List<EdmProperty> buildSelectItemList(final List<SelectItem> selectItems, final EdmEntityType entity)
+ throws ODataJPARuntimeException {
+ boolean flag = false;
+ List<EdmProperty> selectPropertyList = new ArrayList<EdmProperty>();
+ try {
+ for (SelectItem selectItem : selectItems) {
+ selectPropertyList.add(selectItem.getProperty());
+ }
+ for (EdmProperty keyProperty : entity.getKeyProperties()) {
+ flag = true;
+ for (SelectItem selectedItem : selectItems) {
+ if (selectedItem.getProperty().equals(keyProperty)) {
+ flag = false;
+ break;
+ }
+ }
+ if (flag == true) {
+ selectPropertyList.add(keyProperty);
+ }
+ }
+
+ } catch (EdmException e) {
+ throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e);
+ }
+ return selectPropertyList;
+ }
+
+ private static List<EdmNavigationProperty> constructListofNavProperty(
+ final List<ArrayList<NavigationPropertySegment>> expandList) {
+ List<EdmNavigationProperty> navigationPropertyList = new ArrayList<EdmNavigationProperty>();
+ for (ArrayList<NavigationPropertySegment> navpropSegment : expandList) {
+ navigationPropertyList.add(navpropSegment.get(0).getNavigationProperty());
+ }
+ return navigationPropertyList;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/access/data/JPAEntity.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/access/data/JPAEntity.java b/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/access/data/JPAEntity.java
new file mode 100644
index 0000000..7c2ad29
--- /dev/null
+++ b/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/access/data/JPAEntity.java
@@ -0,0 +1,355 @@
+/*******************************************************************************
+ * 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.access.data;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.olingo.odata2.api.edm.EdmEntitySet;
+import org.apache.olingo.odata2.api.edm.EdmEntityType;
+import org.apache.olingo.odata2.api.edm.EdmException;
+import org.apache.olingo.odata2.api.edm.EdmNavigationProperty;
+import org.apache.olingo.odata2.api.edm.EdmProperty;
+import org.apache.olingo.odata2.api.edm.EdmStructuralType;
+import org.apache.olingo.odata2.api.edm.EdmTypeKind;
+import org.apache.olingo.odata2.api.edm.EdmTyped;
+import org.apache.olingo.odata2.api.ep.entry.ODataEntry;
+import org.apache.olingo.odata2.api.ep.feed.ODataFeed;
+import org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPARuntimeException;
+import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmMapping;
+
+public class JPAEntity {
+
+ private Object jpaEntity = null;
+ private EdmEntityType oDataEntityType = null;
+ private EdmEntitySet oDataEntitySet = null;
+ private Class<?> jpaType = null;
+ private HashMap<String, Method> accessModifiersWrite = null;
+ private JPAEntityParser jpaEntityParser = null;
+ public HashMap<EdmNavigationProperty, EdmEntitySet> inlinedEntities = null;
+
+ public JPAEntity(final EdmEntityType oDataEntityType, final EdmEntitySet oDataEntitySet) {
+ this.oDataEntityType = oDataEntityType;
+ this.oDataEntitySet = oDataEntitySet;
+ try {
+ JPAEdmMapping mapping = (JPAEdmMapping) oDataEntityType.getMapping();
+ jpaType = mapping.getJPAType();
+ } catch (EdmException e) {
+ return;
+ }
+ jpaEntityParser = new JPAEntityParser();
+ }
+
+ public void setAccessModifersWrite(final HashMap<String, Method> accessModifiersWrite) {
+ this.accessModifiersWrite = accessModifiersWrite;
+ }
+
+ public Object getJPAEntity() {
+ return jpaEntity;
+ }
+
+ @SuppressWarnings("unchecked")
+ private void write(final Map<String, Object> oDataEntryProperties, final boolean isCreate)
+ throws ODataJPARuntimeException {
+ try {
+
+ EdmStructuralType structuralType = null;
+ final List<String> keyNames = oDataEntityType.getKeyPropertyNames();
+
+ if (isCreate) {
+ jpaEntity = instantiateJPAEntity();
+ } else if (jpaEntity == null) {
+ throw ODataJPARuntimeException
+ .throwException(ODataJPARuntimeException.RESOURCE_NOT_FOUND, null);
+ }
+
+ if (accessModifiersWrite == null) {
+ accessModifiersWrite =
+ jpaEntityParser.getAccessModifiers(jpaEntity, oDataEntityType, JPAEntityParser.ACCESS_MODIFIER_SET);
+ }
+
+ if (oDataEntityType == null || oDataEntryProperties == null) {
+ throw ODataJPARuntimeException
+ .throwException(ODataJPARuntimeException.GENERAL, null);
+ }
+
+ final HashMap<String, String> embeddableKeys =
+ jpaEntityParser.getJPAEmbeddableKeyMap(jpaEntity.getClass().getName());
+ Set<String> propertyNames = null;
+ if (embeddableKeys != null) {
+ setEmbeddableKeyProperty(embeddableKeys, oDataEntityType.getKeyProperties(), oDataEntryProperties, jpaEntity);
+ propertyNames = new HashSet<String>();
+ propertyNames.addAll(oDataEntryProperties.keySet());
+ for (String propertyName : oDataEntityType.getKeyPropertyNames()) {
+ propertyNames.remove(propertyName);
+ }
+ } else {
+ propertyNames = oDataEntryProperties.keySet();
+ }
+
+ for (String propertyName : propertyNames) {
+ EdmTyped edmTyped = (EdmTyped) oDataEntityType.getProperty(propertyName);
+
+ Method accessModifier = null;
+
+ switch (edmTyped.getType().getKind()) {
+ case SIMPLE:
+ if (isCreate == false) {
+ if (keyNames.contains(edmTyped.getName())) {
+ continue;
+ }
+ }
+ accessModifier = accessModifiersWrite.get(propertyName);
+ setProperty(accessModifier, jpaEntity, oDataEntryProperties.get(propertyName));
+ break;
+ case COMPLEX:
+ structuralType = (EdmStructuralType) edmTyped.getType();
+ accessModifier = accessModifiersWrite.get(propertyName);
+ setComplexProperty(accessModifier, jpaEntity,
+ structuralType,
+ (HashMap<String, Object>) oDataEntryProperties.get(propertyName));
+ break;
+ case NAVIGATION:
+ case ENTITY:
+ structuralType = (EdmStructuralType) edmTyped.getType();
+ EdmNavigationProperty navProperty = (EdmNavigationProperty) edmTyped;
+ accessModifier =
+ jpaEntityParser.getAccessModifier(jpaEntity, navProperty,
+ JPAEntityParser.ACCESS_MODIFIER_SET);
+ EdmEntitySet edmRelatedEntitySet = oDataEntitySet.getRelatedEntitySet(navProperty);
+ List<ODataEntry> relatedEntries = (List<ODataEntry>) oDataEntryProperties.get(propertyName);
+ Collection<Object> relatedJPAEntites = instantiateRelatedJPAEntities(jpaEntity, navProperty);
+ JPAEntity relatedEntity = new JPAEntity((EdmEntityType) structuralType, edmRelatedEntitySet);
+ for (ODataEntry oDataEntry : relatedEntries) {
+ relatedEntity.create(oDataEntry);
+ relatedJPAEntites.add(relatedEntity.getJPAEntity());
+ }
+
+ switch (navProperty.getMultiplicity()) {
+ case MANY:
+ accessModifier.invoke(jpaEntity, relatedJPAEntites);
+ break;
+ case ONE:
+ case ZERO_TO_ONE:
+ accessModifier.invoke(jpaEntity, relatedJPAEntites.iterator().next());
+ break;
+ }
+
+ if (inlinedEntities == null) {
+ inlinedEntities = new HashMap<EdmNavigationProperty, EdmEntitySet>();
+ }
+
+ inlinedEntities.put((EdmNavigationProperty) edmTyped, edmRelatedEntitySet);
+ default:
+ continue;
+ }
+ }
+ } catch (Exception e) {
+ throw ODataJPARuntimeException
+ .throwException(ODataJPARuntimeException.GENERAL
+ .addContent(e.getMessage()), e);
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ private Collection<Object> instantiateRelatedJPAEntities(final Object jpaEntity,
+ final EdmNavigationProperty navProperty)
+ throws InstantiationException,
+ IllegalAccessException, EdmException, ODataJPARuntimeException, IllegalArgumentException,
+ InvocationTargetException {
+ Method accessModifier =
+ jpaEntityParser.getAccessModifier(jpaEntity, navProperty, JPAEntityParser.ACCESS_MODIFIER_GET);
+ Collection<Object> relatedJPAEntities = (Collection<Object>) accessModifier.invoke(jpaEntity);
+ if (relatedJPAEntities == null) {
+ relatedJPAEntities = new ArrayList<Object>();
+ }
+ return relatedJPAEntities;
+ }
+
+ public void create(final ODataEntry oDataEntry) throws ODataJPARuntimeException {
+ if (oDataEntry == null) {
+ throw ODataJPARuntimeException
+ .throwException(ODataJPARuntimeException.GENERAL, null);
+ }
+ Map<String, Object> oDataEntryProperties = oDataEntry.getProperties();
+ if (oDataEntry.containsInlineEntry()) {
+ normalizeInlineEntries(oDataEntryProperties);
+ }
+ write(oDataEntryProperties, true);
+ }
+
+ public void create(final Map<String, Object> oDataEntryProperties) throws ODataJPARuntimeException {
+ normalizeInlineEntries(oDataEntryProperties);
+ write(oDataEntryProperties, true);
+ }
+
+ public void update(final ODataEntry oDataEntry) throws ODataJPARuntimeException {
+ if (oDataEntry == null) {
+ throw ODataJPARuntimeException
+ .throwException(ODataJPARuntimeException.GENERAL, null);
+ }
+ Map<String, Object> oDataEntryProperties = oDataEntry.getProperties();
+ write(oDataEntryProperties, false);
+ }
+
+ public void update(final Map<String, Object> oDataEntryProperties) throws ODataJPARuntimeException {
+ write(oDataEntryProperties, false);
+ }
+
+ public HashMap<EdmNavigationProperty, EdmEntitySet> getInlineJPAEntities() {
+ return inlinedEntities;
+ }
+
+ public void setJPAEntity(final Object jpaEntity) {
+ this.jpaEntity = jpaEntity;
+ }
+
+ @SuppressWarnings("unchecked")
+ protected void setComplexProperty(Method accessModifier, final Object jpaEntity,
+ final EdmStructuralType edmComplexType, final HashMap<String, Object> propertyValue)
+ throws EdmException, IllegalAccessException, IllegalArgumentException, InvocationTargetException,
+ InstantiationException, ODataJPARuntimeException {
+
+ JPAEdmMapping mapping = (JPAEdmMapping) edmComplexType.getMapping();
+ Object embeddableObject = mapping.getJPAType().newInstance();
+ accessModifier.invoke(jpaEntity, embeddableObject);
+
+ HashMap<String, Method> accessModifiers =
+ jpaEntityParser.getAccessModifiers(embeddableObject, edmComplexType, JPAEntityParser.ACCESS_MODIFIER_SET);
+
+ for (String edmPropertyName : edmComplexType.getPropertyNames()) {
+ EdmTyped edmTyped = (EdmTyped) edmComplexType.getProperty(edmPropertyName);
+ accessModifier = accessModifiers.get(edmPropertyName);
+ if (edmTyped.getType().getKind().toString().equals(EdmTypeKind.COMPLEX.toString())) {
+ EdmStructuralType structualType = (EdmStructuralType) edmTyped.getType();
+ setComplexProperty(accessModifier, embeddableObject, structualType, (HashMap<String, Object>) propertyValue
+ .get(edmPropertyName));
+ } else {
+ setProperty(accessModifier, embeddableObject, propertyValue.get(edmPropertyName));
+ }
+ }
+ }
+
+ protected void setProperty(final Method method, final Object entity, final Object entityPropertyValue) throws
+ IllegalAccessException, IllegalArgumentException, InvocationTargetException {
+ if (entityPropertyValue != null) {
+ Class<?> parameterType = method.getParameterTypes()[0];
+ if (parameterType.equals(char[].class)) {
+ char[] characters = ((String) entityPropertyValue).toCharArray();
+ method.invoke(entity, characters);
+ } else if (parameterType.equals(char.class)) {
+ char c = ((String) entityPropertyValue).charAt(0);
+ method.invoke(entity, c);
+ } else if (parameterType.equals(Character[].class)) {
+ Character[] characters = JPAEntityParser.toCharacterArray((String) entityPropertyValue);
+ method.invoke(entity, (Object) characters);
+ } else if (parameterType.equals(Character.class)) {
+ Character c = Character.valueOf(((String) entityPropertyValue).charAt(0));
+ method.invoke(entity, c);
+ } else {
+ method.invoke(entity, entityPropertyValue);
+ }
+ }
+ }
+
+ protected void setEmbeddableKeyProperty(final HashMap<String, String> embeddableKeys,
+ final List<EdmProperty> oDataEntryKeyProperties,
+ final Map<String, Object> oDataEntryProperties, final Object entity)
+ throws ODataJPARuntimeException, EdmException, IllegalAccessException, IllegalArgumentException,
+ InvocationTargetException, InstantiationException {
+
+ HashMap<String, Object> embeddableObjMap = new HashMap<String, Object>();
+ List<EdmProperty> leftODataEntryKeyProperties = new ArrayList<EdmProperty>();
+ HashMap<String, String> leftEmbeddableKeys = new HashMap<String, String>();
+
+ for (EdmProperty edmProperty : oDataEntryKeyProperties) {
+ if (oDataEntryProperties.containsKey(edmProperty.getName()) == false) {
+ continue;
+ }
+
+ String edmPropertyName = edmProperty.getName();
+ String embeddableKeyNameComposite = embeddableKeys.get(edmPropertyName);
+ String embeddableKeyNameSplit[] = embeddableKeyNameComposite.split("\\.");
+ String methodPartName = null;
+ Method method = null;
+ Object embeddableObj = null;
+
+ if (embeddableObjMap.containsKey(embeddableKeyNameSplit[0]) == false) {
+ methodPartName = embeddableKeyNameSplit[0];
+ method = jpaEntityParser.getAccessModifierSet(entity, methodPartName);
+ embeddableObj = method.getParameterTypes()[0].newInstance();
+ method.invoke(entity, embeddableObj);
+ embeddableObjMap.put(embeddableKeyNameSplit[0], embeddableObj);
+ } else {
+ embeddableObj = embeddableObjMap.get(embeddableKeyNameSplit[0]);
+ }
+
+ if (embeddableKeyNameSplit.length == 2) {
+ methodPartName = embeddableKeyNameSplit[1];
+ method = jpaEntityParser.getAccessModifierSet(embeddableObj, methodPartName);
+ Object simpleObj = oDataEntryProperties.get(edmProperty.getName());
+ method.invoke(embeddableObj, simpleObj);
+ } else if (embeddableKeyNameSplit.length > 2) { // Deeply nested
+ leftODataEntryKeyProperties.add(edmProperty);
+ leftEmbeddableKeys
+ .put(edmPropertyName, embeddableKeyNameComposite.split(embeddableKeyNameSplit[0] + ".", 2)[1]);
+ setEmbeddableKeyProperty(leftEmbeddableKeys, leftODataEntryKeyProperties, oDataEntryProperties, embeddableObj);
+ }
+
+ }
+ }
+
+ protected Object instantiateJPAEntity() throws InstantiationException, IllegalAccessException {
+ if (jpaType == null) {
+ throw new InstantiationException();
+ }
+
+ return jpaType.newInstance();
+ }
+
+ private void normalizeInlineEntries(final Map<String, Object> oDataEntryProperties) throws ODataJPARuntimeException {
+ List<ODataEntry> entries = null;
+ try {
+ for (String navigationPropertyName : oDataEntityType.getNavigationPropertyNames()) {
+ Object inline = oDataEntryProperties.get(navigationPropertyName);
+ if (inline instanceof ODataFeed) {
+ entries = ((ODataFeed) inline).getEntries();
+ } else if (inline instanceof ODataEntry) {
+ entries = new ArrayList<ODataEntry>();
+ entries.add((ODataEntry) inline);
+ }
+ if (entries != null) {
+ oDataEntryProperties.put(navigationPropertyName, entries);
+ entries = null;
+ }
+ }
+ } catch (EdmException e) {
+ throw ODataJPARuntimeException
+ .throwException(ODataJPARuntimeException.GENERAL
+ .addContent(e.getMessage()), e);
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/access/data/JPAEntityParser.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/access/data/JPAEntityParser.java b/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/access/data/JPAEntityParser.java
new file mode 100644
index 0000000..756e1ca
--- /dev/null
+++ b/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/access/data/JPAEntityParser.java
@@ -0,0 +1,453 @@
+/*******************************************************************************
+ * 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.access.data;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.HashMap;
+import java.util.List;
+
+import org.apache.olingo.odata2.api.edm.EdmAssociationEnd;
+import org.apache.olingo.odata2.api.edm.EdmException;
+import org.apache.olingo.odata2.api.edm.EdmMapping;
+import org.apache.olingo.odata2.api.edm.EdmNavigationProperty;
+import org.apache.olingo.odata2.api.edm.EdmProperty;
+import org.apache.olingo.odata2.api.edm.EdmStructuralType;
+import org.apache.olingo.odata2.api.edm.EdmTypeKind;
+import org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPARuntimeException;
+import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmMapping;
+
+public final class JPAEntityParser {
+
+ /*
+ * List of buffers used by the Parser
+ */
+ private static short MAX_SIZE = 10;
+ public static final String ACCESS_MODIFIER_GET = "get";
+ public static final String ACCESS_MODIFIER_SET = "set";
+
+ private HashMap<String, HashMap<String, Method>> jpaEntityAccessMap = null;
+ private HashMap<String, HashMap<String, String>> jpaEmbeddableKeyMap = null;
+
+ public JPAEntityParser() {
+ jpaEntityAccessMap = new HashMap<String, HashMap<String, Method>>(
+ MAX_SIZE);
+ jpaEmbeddableKeyMap = new HashMap<String, HashMap<String, String>>();
+ };
+
+ public HashMap<String, Method> getJPAEntityAccessMap(final String jpaEntityName) {
+ return jpaEntityAccessMap.get(jpaEntityName);
+ }
+
+ public HashMap<String, String> getJPAEmbeddableKeyMap(final String jpaEntityName) {
+ return jpaEmbeddableKeyMap.get(jpaEntityName);
+ }
+
+ /**
+ * The method returns a Hash Map of Properties and values for selected
+ * properties of an EdmEntity Type
+ *
+ * @param jpaEntity
+ * @param selectedItems
+ * @return a Hash Map of Properties and values for given selected properties
+ * of an EdmEntity Type
+ * @throws ODataJPARuntimeException
+ */
+
+ public final HashMap<String, Object> parse2EdmPropertyValueMap(
+ final Object jpaEntity, final List<EdmProperty> selectPropertyList)
+ throws ODataJPARuntimeException {
+ HashMap<String, Object> edmEntity = new HashMap<String, Object>();
+ String methodName = null;
+ Method method = null;
+ for (int i = 0; i < selectPropertyList.size(); i++) {
+ String key = null;
+ Object propertyValue = null;
+ EdmProperty property = null;
+ property = selectPropertyList.get(i);
+
+ try {
+ methodName = getAccessModifierName(property.getName(),
+ property.getMapping(), ACCESS_MODIFIER_GET);
+ String[] nameParts = methodName.split("\\.");
+ if (nameParts.length > 1) {
+ Object propertyVal = new Object();
+ propertyVal = jpaEntity;
+ for (String namePart : nameParts) {
+ method = propertyVal.getClass().getMethod(
+ namePart, (Class<?>[]) null);
+ method.setAccessible(true);
+ propertyVal = getProperty(method, propertyVal);
+ }
+ edmEntity.put(property.getName(), propertyVal);
+ } else {
+ method = jpaEntity.getClass().getMethod(methodName,
+ (Class<?>[]) null);
+ method.setAccessible(true);
+ propertyValue = getProperty(method, jpaEntity);
+ key = property.getName();
+ if (property.getType().getKind()
+ .equals(EdmTypeKind.COMPLEX)) {
+ try {
+ propertyValue = parse2EdmPropertyValueMap(
+ propertyValue,
+ (EdmStructuralType) property.getType());
+ } catch (ODataJPARuntimeException e) {
+ throw e;
+ }
+ }
+ edmEntity.put(key, propertyValue);
+ }
+ } catch (EdmException e) {
+ throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.INNER_EXCEPTION, e);
+ } catch (SecurityException e) {
+ throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.INNER_EXCEPTION, e);
+ } catch (NoSuchMethodException e) {
+ throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.INNER_EXCEPTION, e);
+ } catch (IllegalArgumentException e) {
+ throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.INNER_EXCEPTION, e);
+ }
+ }
+
+ return edmEntity;
+ }
+
+ /**
+ * The method returns a Hash Map of Properties and values for an EdmEntity
+ * Type The method uses reflection on object jpaEntity to get the list of
+ * accessModifier method. Then uses the accessModifier method to extract the value from
+ * JPAEntity.
+ *
+ * @param jpaEntity
+ * @param structuralType
+ * @return a Hash Map of Properties and values for given EdmEntity Type
+ * @throws ODataJPARuntimeException
+ */
+ public final HashMap<String, Object> parse2EdmPropertyValueMap(
+ final Object jpaEntity, final EdmStructuralType structuralType)
+ throws ODataJPARuntimeException {
+
+ if (jpaEntity == null || structuralType == null) {
+ return null;
+ }
+
+ String jpaEntityAccessKey = jpaEntity.getClass().getName();
+
+ if (!jpaEntityAccessMap.containsKey(jpaEntityAccessKey)) {
+ jpaEntityAccessMap.put(jpaEntityAccessKey,
+ getAccessModifiers(jpaEntity, structuralType, ACCESS_MODIFIER_GET));
+ }
+
+ HashMap<String, Object> edmEntity = new HashMap<String, Object>();
+ HashMap<String, Method> getters = jpaEntityAccessMap
+ .get(jpaEntityAccessKey);
+ HashMap<String, String> embeddableKeys = jpaEmbeddableKeyMap
+ .get(jpaEntityAccessKey);
+
+ try {
+ for (String key : getters.keySet()) {
+
+ EdmProperty property = (EdmProperty) structuralType
+ .getProperty(key);
+
+ Method method = getters.get(key);
+ Object propertyValue = null;
+
+ if (method != null) {
+ getters.get(key).setAccessible(true);
+ propertyValue = getProperty(method, jpaEntity);
+ }
+ if (property.getType().getKind().equals(EdmTypeKind.COMPLEX)) {
+ propertyValue = parse2EdmPropertyValueMap(propertyValue,
+ (EdmStructuralType) property.getType());
+ }
+
+ edmEntity.put(key, propertyValue);
+
+ }
+
+ if (embeddableKeys != null) {
+ for (String key : embeddableKeys.keySet()) {
+ String name = embeddableKeys.get(key);
+ String[] nameParts = name.split("\\.");
+ Object propertyValue = jpaEntity;
+ Method method = null;
+ for (String namePart : nameParts) {
+ method = propertyValue.getClass().getMethod(
+ namePart, (Class<?>[]) null);
+ method.setAccessible(true);
+ propertyValue = getProperty(method, propertyValue);
+ }
+ edmEntity.put(key, propertyValue);
+ }
+ }
+ } catch (EdmException e) {
+ throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.INNER_EXCEPTION, e);
+ } catch (SecurityException e) {
+ throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.INNER_EXCEPTION, e);
+ } catch (NoSuchMethodException e) {
+ throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.INNER_EXCEPTION, e);
+ } catch (IllegalArgumentException e) {
+ throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.INNER_EXCEPTION, e);
+ }
+ return edmEntity;
+ }
+
+ // This method appends the associated entities as a java list to an expanded
+ // map of a source entity
+ public final HashMap<String, Object> parse2EdmNavigationValueMap(
+ final Object jpaEntity, final List<EdmNavigationProperty> navigationPropertyList)
+ throws ODataJPARuntimeException {
+ Object result = null;
+ String methodName = null;
+ HashMap<String, Object> navigationMap = new HashMap<String, Object>();
+ if (navigationPropertyList != null
+ && navigationPropertyList.size() != 0) {
+
+ try {
+ for (EdmNavigationProperty navigationProperty : navigationPropertyList) {
+ methodName = getAccessModifierName(navigationProperty.getName(),
+ navigationProperty.getMapping(), ACCESS_MODIFIER_GET);
+ Method getterMethod = jpaEntity.getClass()
+ .getDeclaredMethod(methodName, (Class<?>[]) null);
+ getterMethod.setAccessible(true);
+ result = getProperty(getterMethod, jpaEntity);
+ navigationMap.put(navigationProperty.getName(), result);
+ }
+ } catch (IllegalArgumentException e) {
+ throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.INNER_EXCEPTION, e);
+ } catch (EdmException e) {
+ throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.INNER_EXCEPTION, e);
+ } catch (SecurityException e) {
+ throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.INNER_EXCEPTION, e);
+ } catch (NoSuchMethodException e) {
+ throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.INNER_EXCEPTION, e);
+ }
+ }
+ return navigationMap;
+ }
+
+ public Method getAccessModifierSet(final Object jpaEntity, final String methodName) throws ODataJPARuntimeException {
+ Class<?> jpaType = jpaEntity.getClass();
+ String methodNameGet = ACCESS_MODIFIER_GET + methodName.substring(3);
+ Method method = null;
+
+ try {
+ method = jpaType.getMethod(methodNameGet, (Class<?>[]) null);
+ Class<?> parameterType = method.getReturnType();
+ method = jpaType.getMethod(methodName, new Class<?>[] { parameterType });
+ } catch (NoSuchMethodException e) {
+ throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.INNER_EXCEPTION, e);
+ } catch (SecurityException e) {
+ throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.INNER_EXCEPTION, e);
+ }
+
+ return method;
+ }
+
+ public HashMap<String, Method> getAccessModifiers(final Object jpaEntity,
+ final EdmStructuralType structuralType, final String accessModifier) throws ODataJPARuntimeException {
+
+ HashMap<String, Method> accessModifierMap = new HashMap<String, Method>();
+ HashMap<String, String> embeddableKey = new HashMap<String, String>();
+ try {
+ for (String propertyName : structuralType.getPropertyNames()) {
+
+ EdmProperty property = (EdmProperty) structuralType
+ .getProperty(propertyName);
+
+ String name = getAccessModifierName(property.getName(),
+ property.getMapping(), accessModifier);
+ String[] nameParts = name.split("\\.");
+ if (nameParts.length > 1) {
+ embeddableKey.put(propertyName, name);
+ } else {
+ if (accessModifier.equals(ACCESS_MODIFIER_SET)) {
+ JPAEdmMapping jpaEdmMapping = (JPAEdmMapping) property.getMapping();
+ accessModifierMap.put(
+ propertyName,
+ jpaEntity.getClass().getMethod(name, new Class<?>[] { jpaEdmMapping.getJPAType() }));
+ } else {
+ accessModifierMap.put(
+ propertyName,
+ jpaEntity.getClass().getMethod(name,
+ (Class<?>[]) null));
+ }
+ }
+ }
+ } catch (NoSuchMethodException e) {
+ throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.INNER_EXCEPTION, e);
+ } catch (SecurityException e) {
+ throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.INNER_EXCEPTION, e);
+ } catch (EdmException e) {
+ throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.INNER_EXCEPTION, e);
+ }
+
+ if (!embeddableKey.isEmpty()) {
+ jpaEmbeddableKeyMap.put(jpaEntity.getClass().getName(),
+ embeddableKey);
+ }
+ return accessModifierMap;
+ }
+
+ public static Object getProperty(final Method method, final Object entity) throws ODataJPARuntimeException {
+ Object propertyValue = null;
+ try {
+ Class<?> returnType = method.getReturnType();
+
+ if (returnType.equals(char[].class)) {
+ char[] ch = (char[]) method.invoke(entity);
+ if (ch != null) {
+ propertyValue = (String) String.valueOf((char[]) method.invoke(entity));
+ }
+ } else if (returnType.equals(Character[].class)) {
+ propertyValue = (String) toString((Character[]) method.invoke(entity));
+ } else if (returnType.equals(char.class)) {
+ char c = (Character) method.invoke(entity);
+ if (c != '\u0000') {
+ propertyValue = (String) String.valueOf(c);
+ }
+ } else if (returnType.equals(Character.class)) {
+ Character c = (Character) method.invoke(entity);
+ if (c != null) {
+ propertyValue = toString(new Character[] { c });
+ }
+ } else {
+ propertyValue = method.invoke(entity);
+ }
+ } catch (IllegalAccessException e) {
+ throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.INNER_EXCEPTION, e);
+ } catch (IllegalArgumentException e) {
+ throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.INNER_EXCEPTION, e);
+ } catch (InvocationTargetException e) {
+ throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.INNER_EXCEPTION, e);
+ }
+ return propertyValue;
+ }
+
+ public static String toString(final Character[] input) {
+ if (input == null) {
+ return null;
+ }
+
+ StringBuilder builder = new StringBuilder();
+ for (Character element : input) {
+ if (element == null) {
+ continue;
+ }
+ builder.append(element.charValue());
+ }
+ return builder.toString();
+
+ }
+
+ public static Character[] toCharacterArray(final String input) {
+ if (input == null) {
+ return null;
+ }
+
+ Character[] characters = new Character[input.length()];
+ char[] chars = ((String) input).toCharArray();
+ for (int i = 0; i < input.length(); i++) {
+ characters[i] = new Character(chars[i]);
+ }
+
+ return characters;
+ }
+
+ public static String getAccessModifierName(final String propertyName, final EdmMapping mapping,
+ final String accessModifier)
+ throws ODataJPARuntimeException {
+ String name = null;
+ StringBuilder builder = new StringBuilder();
+ String[] nameParts = {};
+ if (mapping == null || mapping.getInternalName() == null) {
+ name = propertyName;
+ } else {
+ name = mapping.getInternalName();
+ }
+ if (name != null) {
+ nameParts = name.split("\\.");
+ }
+ if (nameParts.length == 1) {
+ if (name != null) {
+ char c = Character.toUpperCase(name.charAt(0));
+
+ builder.append(accessModifier).append(c).append(name.substring(1))
+ .toString();
+ }
+ } else if (nameParts.length > 1) {
+
+ for (int i = 0; i < nameParts.length; i++) {
+ name = nameParts[i];
+ char c = Character.toUpperCase(name.charAt(0));
+ if (i == 0) {
+ builder.append(accessModifier).append(c).append(name.substring(1));
+ } else {
+ builder.append(".").append(accessModifier).append(c)
+ .append(name.substring(1));
+ }
+ }
+ } else {
+ return null;
+ }
+
+ if (builder.length() > 0) {
+ return builder.toString();
+ } else {
+ return null;
+ }
+
+ }
+
+ public Method getAccessModifier(final Object jpaEntity, final EdmNavigationProperty navigationProperty,
+ final String accessModifier)
+ throws ODataJPARuntimeException {
+
+ try {
+
+ JPAEdmMapping navPropMapping = (JPAEdmMapping) navigationProperty.getMapping();
+ String name = getAccessModifierName(navigationProperty.getName(), (EdmMapping) navPropMapping, accessModifier);
+
+ Class<?>[] params = null;
+ if (accessModifier.equals(ACCESS_MODIFIER_SET)) {
+ EdmAssociationEnd end = navigationProperty.getRelationship().getEnd(navigationProperty.getToRole());
+ switch (end.getMultiplicity()) {
+ case MANY:
+ params = new Class<?>[] { navPropMapping.getJPAType() };
+ break;
+ case ONE:
+ params = new Class<?>[] { ((JPAEdmMapping) end.getEntityType().getMapping()).getJPAType() };
+ default:
+ break;
+ }
+ }
+ return jpaEntity.getClass().getMethod(name,
+ params);
+
+ } catch (NoSuchMethodException e) {
+ throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.INNER_EXCEPTION, e);
+ } catch (SecurityException e) {
+ throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.INNER_EXCEPTION, e);
+ } catch (EdmException e) {
+ throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.INNER_EXCEPTION, e);
+ }
+
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/access/data/JPAExpandCallBack.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/access/data/JPAExpandCallBack.java b/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/access/data/JPAExpandCallBack.java
new file mode 100644
index 0000000..78a9ea5
--- /dev/null
+++ b/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/access/data/JPAExpandCallBack.java
@@ -0,0 +1,180 @@
+/*******************************************************************************
+ * 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.access.data;
+
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.olingo.odata2.api.ODataCallback;
+import org.apache.olingo.odata2.api.edm.EdmEntitySet;
+import org.apache.olingo.odata2.api.edm.EdmEntityType;
+import org.apache.olingo.odata2.api.edm.EdmException;
+import org.apache.olingo.odata2.api.edm.EdmNavigationProperty;
+import org.apache.olingo.odata2.api.ep.EntityProviderWriteProperties;
+import org.apache.olingo.odata2.api.ep.EntityProviderWriteProperties.ODataEntityProviderPropertiesBuilder;
+import org.apache.olingo.odata2.api.ep.callback.OnWriteEntryContent;
+import org.apache.olingo.odata2.api.ep.callback.OnWriteFeedContent;
+import org.apache.olingo.odata2.api.ep.callback.WriteCallbackContext;
+import org.apache.olingo.odata2.api.ep.callback.WriteEntryCallbackContext;
+import org.apache.olingo.odata2.api.ep.callback.WriteEntryCallbackResult;
+import org.apache.olingo.odata2.api.ep.callback.WriteFeedCallbackContext;
+import org.apache.olingo.odata2.api.ep.callback.WriteFeedCallbackResult;
+import org.apache.olingo.odata2.api.uri.ExpandSelectTreeNode;
+import org.apache.olingo.odata2.api.uri.NavigationPropertySegment;
+import org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPARuntimeException;
+
+public class JPAExpandCallBack implements OnWriteFeedContent, OnWriteEntryContent, ODataCallback {
+
+ private URI baseUri;
+ private List<ArrayList<NavigationPropertySegment>> expandList;
+ private EdmEntitySet nextEntitySet = null;
+
+ private JPAExpandCallBack(final URI baseUri, final List<ArrayList<NavigationPropertySegment>> expandList) {
+ super();
+ this.baseUri = baseUri;
+ this.expandList = expandList;
+ }
+
+ @Override
+ public WriteEntryCallbackResult retrieveEntryResult(final WriteEntryCallbackContext context) {
+ WriteEntryCallbackResult result = new WriteEntryCallbackResult();
+ Map<String, Object> entry = context.getEntryData();
+ Map<String, Object> edmPropertyValueMap = null;
+ List<EdmNavigationProperty> currentNavPropertyList = null;
+ Map<String, ExpandSelectTreeNode> navigationLinks = null;
+ JPAEntityParser jpaResultParser = new JPAEntityParser();
+ EdmNavigationProperty currentNavigationProperty = context.getNavigationProperty();
+ try {
+ Object inlinedEntry = entry.get(currentNavigationProperty.getName());
+ if (nextEntitySet == null) {
+ nextEntitySet = context.getSourceEntitySet().getRelatedEntitySet(currentNavigationProperty);
+ }
+ edmPropertyValueMap = jpaResultParser.parse2EdmPropertyValueMap(inlinedEntry, nextEntitySet.getEntityType());
+ result.setEntryData(edmPropertyValueMap);
+ navigationLinks = context.getCurrentExpandSelectTreeNode().getLinks();
+ if (navigationLinks.size() > 0) {
+ currentNavPropertyList = new ArrayList<EdmNavigationProperty>();
+ EdmNavigationProperty nextNavProperty =
+ getNextNavigationProperty(context.getSourceEntitySet().getEntityType(), context.getNavigationProperty());
+ if (nextNavProperty != null) {
+ currentNavPropertyList.add(nextNavProperty);
+ }
+ HashMap<String, Object> navigationMap =
+ jpaResultParser.parse2EdmNavigationValueMap(inlinedEntry, currentNavPropertyList);
+ edmPropertyValueMap.putAll(navigationMap);
+ result.setEntryData(edmPropertyValueMap);
+ }
+ result.setInlineProperties(getInlineEntityProviderProperties(context));
+ } catch (EdmException e) {
+
+ } catch (ODataJPARuntimeException e) {
+
+ }
+
+ return result;
+ }
+
+ @Override
+ public WriteFeedCallbackResult retrieveFeedResult(final WriteFeedCallbackContext context) {
+ WriteFeedCallbackResult result = new WriteFeedCallbackResult();
+ HashMap<String, Object> inlinedEntry = (HashMap<String, Object>) context.getEntryData();
+ List<Map<String, Object>> edmEntityList = new ArrayList<Map<String, Object>>();
+ Map<String, Object> edmPropertyValueMap = null;
+ JPAEntityParser jpaResultParser = new JPAEntityParser();
+ List<EdmNavigationProperty> currentNavPropertyList = null;
+ EdmNavigationProperty currentNavigationProperty = context.getNavigationProperty();
+ try {
+ @SuppressWarnings({ "unchecked" })
+ Collection<Object> listOfItems = (Collection<Object>) inlinedEntry.get(context.getNavigationProperty().getName());
+ if (nextEntitySet == null) {
+ nextEntitySet = context.getSourceEntitySet().getRelatedEntitySet(currentNavigationProperty);
+ }
+ for (Object object : listOfItems) {
+ edmPropertyValueMap = jpaResultParser.parse2EdmPropertyValueMap(object, nextEntitySet.getEntityType());
+ edmEntityList.add(edmPropertyValueMap);
+ }
+ result.setFeedData(edmEntityList);
+ if (context.getCurrentExpandSelectTreeNode().getLinks().size() > 0) {
+ currentNavPropertyList = new ArrayList<EdmNavigationProperty>();
+ EdmNavigationProperty nextNavProperty =
+ getNextNavigationProperty(context.getSourceEntitySet().getEntityType(), context.getNavigationProperty());
+ if (nextNavProperty != null) {
+ currentNavPropertyList.add(nextNavProperty);
+ }
+ int count = 0;
+ for (Object object : listOfItems) {
+ HashMap<String, Object> navigationMap =
+ jpaResultParser.parse2EdmNavigationValueMap(object, currentNavPropertyList);
+ edmEntityList.get(count).putAll(navigationMap);
+ count++;
+ }
+ result.setFeedData(edmEntityList);
+ }
+ result.setInlineProperties(getInlineEntityProviderProperties(context));
+ } catch (EdmException e) {
+
+ } catch (ODataJPARuntimeException e) {
+
+ }
+ return result;
+ }
+
+ private EdmNavigationProperty getNextNavigationProperty(final EdmEntityType sourceEntityType,
+ final EdmNavigationProperty navigationProperty) throws EdmException {
+ for (ArrayList<NavigationPropertySegment> navPropSegments : expandList) {
+ int size = navPropSegments.size();
+ for (int i = 0; i < size; i++) {
+ EdmNavigationProperty navProperty = navPropSegments.get(i).getNavigationProperty();
+ if (navProperty.getFromRole().equalsIgnoreCase(sourceEntityType.getName())
+ && navProperty.getName().equals(navigationProperty.getName())) {
+ if (i < size - 1) {
+ return navPropSegments.get(i + 1).getNavigationProperty();
+ }
+ }
+ }
+ }
+ return null;
+ }
+
+ public static <T> Map<String, ODataCallback> getCallbacks(final URI baseUri,
+ final ExpandSelectTreeNode expandSelectTreeNode, final List<ArrayList<NavigationPropertySegment>> expandList)
+ throws EdmException {
+ Map<String, ODataCallback> callbacks = new HashMap<String, ODataCallback>();
+
+ for (String navigationPropertyName : expandSelectTreeNode.getLinks().keySet()) {
+ callbacks.put(navigationPropertyName, new JPAExpandCallBack(baseUri, expandList));
+ }
+
+ return callbacks;
+
+ }
+
+ private EntityProviderWriteProperties getInlineEntityProviderProperties(final WriteCallbackContext context)
+ throws EdmException {
+ ODataEntityProviderPropertiesBuilder propertiesBuilder = EntityProviderWriteProperties.serviceRoot(baseUri);
+ propertiesBuilder.callbacks(getCallbacks(baseUri, context.getCurrentExpandSelectTreeNode(), expandList));
+ propertiesBuilder.expandSelectTree(context.getCurrentExpandSelectTreeNode());
+ return propertiesBuilder.build();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/access/data/JPAFunctionContext.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/access/data/JPAFunctionContext.java b/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/access/data/JPAFunctionContext.java
new file mode 100644
index 0000000..8f79c92
--- /dev/null
+++ b/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/access/data/JPAFunctionContext.java
@@ -0,0 +1,170 @@
+/*******************************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ ******************************************************************************/
+package org.apache.olingo.odata2.processor.core.jpa.access.data;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.lang.reflect.Type;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.olingo.odata2.api.edm.EdmException;
+import org.apache.olingo.odata2.api.edm.EdmFacets;
+import org.apache.olingo.odata2.api.edm.EdmFunctionImport;
+import org.apache.olingo.odata2.api.edm.EdmLiteral;
+import org.apache.olingo.odata2.api.edm.EdmLiteralKind;
+import org.apache.olingo.odata2.api.edm.EdmMapping;
+import org.apache.olingo.odata2.api.edm.EdmParameter;
+import org.apache.olingo.odata2.api.edm.EdmSimpleType;
+import org.apache.olingo.odata2.api.edm.EdmSimpleTypeException;
+import org.apache.olingo.odata2.api.uri.info.GetFunctionImportUriInfo;
+import org.apache.olingo.odata2.processor.api.jpa.access.JPAFunction;
+import org.apache.olingo.odata2.processor.api.jpa.access.JPAMethodContext;
+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.JPAEdmMapping;
+
+public class JPAFunctionContext extends JPAMethodContext {
+
+ public class JPAFunctionContextBuilder extends JPAMethodContextBuilder {
+
+ protected GetFunctionImportUriInfo functiontView;
+ private EdmFunctionImport functionImport;
+ private EdmMapping mapping;
+
+ @Override
+ public JPAMethodContext build() throws ODataJPAModelException, ODataJPARuntimeException {
+ if (functiontView != null) {
+
+ functionImport = functiontView.getFunctionImport();
+ try {
+ mapping = functionImport.getMapping();
+
+ List<JPAFunction> jpaFunctionList = new ArrayList<JPAFunction>();
+ jpaFunctionList.add(generateJPAFunction());
+ setJpaFunction(jpaFunctionList);
+ setEnclosingObject(generateEnclosingObject());
+ } catch (EdmException e) {
+ throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e);
+ } catch (InstantiationException e) {
+ throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e);
+ } catch (IllegalAccessException e) {
+ throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e);
+ } catch (IllegalArgumentException e) {
+ throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e);
+ } catch (InvocationTargetException e) {
+ throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e);
+ } catch (NoSuchMethodException e) {
+ throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e);
+ } catch (SecurityException e) {
+ throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e);
+ }
+ }
+
+ return JPAFunctionContext.this;
+ }
+
+ private JPAFunction generateJPAFunction() throws EdmException, NoSuchMethodException, SecurityException,
+ ODataJPAModelException, ODataJPARuntimeException {
+
+ Class<?>[] parameterTypes = getParameterTypes();
+ Method method = getMethod(parameterTypes);
+ Type returnType = getReturnType();
+ Object[] args = getAruguments();
+
+ JPAFunction jpafunction = new JPAFunction(method, parameterTypes, returnType, args);
+
+ return jpafunction;
+ }
+
+ private Object[] getAruguments() throws EdmException {
+ Map<String, EdmLiteral> edmArguements = functiontView.getFunctionImportParameters();
+
+ if (edmArguements == null) {
+ return null;
+ } else {
+ Object[] args = new Object[edmArguements.size()];
+ int i = 0;
+ for (String paramName : functionImport.getParameterNames()) {
+ EdmLiteral literal = edmArguements.get(paramName);
+ EdmParameter parameter = functionImport.getParameter(paramName);
+ JPAEdmMapping mapping = (JPAEdmMapping) parameter.getMapping();
+ args[i] = convertArguement(literal, parameter.getFacets(), mapping.getJPAType());
+ i++;
+ }
+ return args;
+ }
+
+ }
+
+ private Object convertArguement(final EdmLiteral edmLiteral, final EdmFacets facets, final Class<?> targetType)
+ throws EdmSimpleTypeException {
+ EdmSimpleType edmType = edmLiteral.getType();
+ Object value = edmType.valueOfString(edmLiteral.getLiteral(), EdmLiteralKind.DEFAULT, facets, targetType);
+
+ return value;
+ }
+
+ private Class<?>[] getParameterTypes() throws EdmException {
+
+ Class<?>[] parameterTypes = new Class<?>[functionImport.getParameterNames().size()];
+ int i = 0;
+ for (String parameterName : functionImport.getParameterNames()) {
+ EdmParameter parameter = functionImport.getParameter(parameterName);
+ parameterTypes[i] = ((JPAEdmMapping) parameter.getMapping()).getJPAType();
+ i++;
+ }
+
+ return parameterTypes;
+ }
+
+ private Method getMethod(final Class<?>[] parameterTypes) throws NoSuchMethodException, SecurityException {
+
+ Class<?> type = ((JPAEdmMapping) mapping).getJPAType();
+ Method method;
+ method = type.getMethod(mapping.getInternalName(), parameterTypes);
+
+ return method;
+ }
+
+ private Type getReturnType() throws ODataJPAModelException, ODataJPARuntimeException, EdmException {
+ return null;
+ }
+
+ private Object generateEnclosingObject() throws InstantiationException, IllegalAccessException,
+ IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException {
+
+ Class<?> type = ((JPAEdmMapping) mapping).getJPAType();
+ Object[] params = null;
+
+ return type.getConstructor((Class<?>[]) params).newInstance(params);
+
+ }
+
+ @Override
+ protected void setResultsView(final Object resultsView) {
+ if (resultsView instanceof GetFunctionImportUriInfo) {
+ functiontView = (GetFunctionImportUriInfo) resultsView;
+ }
+
+ }
+
+ }
+}
[20/37] [OLINGO-82] Renamed the project folder name to
odata2-jpa-processor
Posted by ch...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-web/src/main/resources/META-INF/LICENSE
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-web/src/main/resources/META-INF/LICENSE b/odata2-jpa-processor/jpa-web/src/main/resources/META-INF/LICENSE
new file mode 100644
index 0000000..325ef4a
--- /dev/null
+++ b/odata2-jpa-processor/jpa-web/src/main/resources/META-INF/LICENSE
@@ -0,0 +1,1252 @@
+
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed 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.
+
+=====================================================================
+ - WSDL4J (http://sf.net/projects/wsdl4j) wsdl4j:wsdl4j:jar:1.6.3
+ License: CPL (http://www.opensource.org/licenses/cpl1.0.txt)
+=====================================================================
+ Common Public License Version 1.0
+
+ THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS
+ COMMON PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR
+ DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF
+ THIS AGREEMENT.
+
+ 1. DEFINITIONS
+
+ "Contribution" means:
+
+ a) in the case of the initial Contributor, the initial code and
+ documentation distributed under this Agreement, and
+
+ b) in the case of each subsequent Contributor:
+
+ i) changes to the Program, and
+
+ ii) additions to the Program;
+
+ where such changes and/or additions to the Program originate from
+ and are distributed by that particular Contributor. A
+ Contribution 'originates' from a Contributor if it was added to
+ the Program by such Contributor itself or anyone acting on such
+ Contributor's behalf. Contributions do not include additions to
+ the Program which: (i) are separate modules of software
+ distributed in conjunction with the Program under their own
+ license agreement, and (ii) are not derivative works of the
+ Program.
+
+ "Contributor" means any person or entity that distributes the
+ Program.
+
+ "Licensed Patents " mean patent claims licensable by a
+ Contributor which are necessarily infringed by the use or sale of
+ its Contribution alone or when combined with the Program.
+
+ "Program" means the Contributions distributed in accordance with
+ this Agreement.
+
+ "Recipient" means anyone who receives the Program under this
+ Agreement, including all Contributors.
+
+ 2. GRANT OF RIGHTS
+
+ a) Subject to the terms of this Agreement, each Contributor
+ hereby grants Recipient a non-exclusive, worldwide, royalty-free
+ copyright license to reproduce, prepare derivative works of,
+ publicly display, publicly perform, distribute and sublicense the
+ Contribution of such Contributor, if any, and such derivative
+ works, in source code and object code form.
+
+ b) Subject to the terms of this Agreement, each Contributor
+ hereby grants Recipient a non-exclusive, worldwide, royalty-free
+ patent license under Licensed Patents to make, use, sell, offer
+ to sell, import and otherwise transfer the Contribution of such
+ Contributor, if any, in source code and object code form. This
+ patent license shall apply to the combination of the Contribution
+ and the Program if, at the time the Contribution is added by the
+ Contributor, such addition of the Contribution causes such
+ combination to be covered by the Licensed Patents. The patent
+ license shall not apply to any other combinations which include
+ the Contribution. No hardware per se is licensed hereunder.
+
+ c) Recipient understands that although each Contributor grants
+ the licenses to its Contributions set forth herein, no assurances
+ are provided by any Contributor that the Program does not
+ infringe the patent or other intellectual property rights of any
+ other entity. Each Contributor disclaims any liability to
+ Recipient for claims brought by any other entity based on
+ infringement of intellectual property rights or otherwise. As a
+ condition to exercising the rights and licenses granted
+ hereunder, each Recipient hereby assumes sole responsibility to
+ secure any other intellectual property rights needed, if any. For
+ example, if a third party patent license is required to allow
+ Recipient to distribute the Program, it is Recipient's
+ responsibility to acquire that license before distributing the
+ Program.
+
+ d) Each Contributor represents that to its knowledge it has
+ sufficient copyright rights in its Contribution, if any, to grant
+ the copyright license set forth in this Agreement.
+
+ 3. REQUIREMENTS
+
+ A Contributor may choose to distribute the Program in object code
+ form under its own license agreement, provided that:
+
+ a) it complies with the terms and conditions of this Agreement;
+ and
+
+ b) its license agreement:
+
+ i) effectively disclaims on behalf of all Contributors all
+ warranties and conditions, express and implied, including
+ warranties or conditions of title and non-infringement, and
+ implied warranties or conditions of merchantability and fitness
+ for a particular purpose;
+
+ ii) effectively excludes on behalf of all Contributors all
+ liability for damages, including direct, indirect, special,
+ incidental and consequential damages, such as lost profits;
+
+ iii) states that any provisions which differ from this Agreement
+ are offered by that Contributor alone and not by any other party;
+ and
+
+ iv) states that source code for the Program is available from
+ such Contributor, and informs licensees how to obtain it in a
+ reasonable manner on or through a medium customarily used for
+ software exchange.
+
+ When the Program is made available in source code form:
+
+ a) it must be made available under this Agreement; and
+
+ b) a copy of this Agreement must be included with each copy of
+ the Program.
+
+ Contributors may not remove or alter any copyright notices
+ contained within the Program.
+
+ Each Contributor must identify itself as the originator of its
+ Contribution, if any, in a manner that reasonably allows
+ subsequent Recipients to identify the originator of the
+ Contribution.
+
+ 4. COMMERCIAL DISTRIBUTION
+
+ Commercial distributors of software may accept certain
+ responsibilities with respect to end users, business partners and
+ the like. While this license is intended to facilitate the
+ commercial use of the Program, the Contributor who includes the
+ Program in a commercial product offering should do so in a manner
+ which does not create potential liability for other Contributors.
+ Therefore, if a Contributor includes the Program in a commercial
+ product offering, such Contributor ("Commercial Contributor")
+ hereby agrees to defend and indemnify every other Contributor
+ ("Indemnified Contributor") against any losses, damages and costs
+ (collectively "Losses") arising from claims, lawsuits and other
+ legal actions brought by a third party against the Indemnified
+ Contributor to the extent caused by the acts or omissions of such
+ Commercial Contributor in connection with its distribution of the
+ Program in a commercial product offering. The obligations in this
+ section do not apply to any claims or Losses relating to any
+ actual or alleged intellectual property infringement. In order to
+ qualify, an Indemnified Contributor must: a) promptly notify the
+ Commercial Contributor in writing of such claim, and b) allow the
+ Commercial Contributor to control, and cooperate with the
+ Commercial Contributor in, the defense and any related settlement
+ negotiations. The Indemnified Contributor may participate in any
+ such claim at its own expense.
+
+ For example, a Contributor might include the Program in a
+ commercial product offering, Product X. That Contributor is then
+ a Commercial Contributor. If that Commercial Contributor then
+ makes performance claims, or offers warranties related to Product
+ X, those performance claims and warranties are such Commercial
+ Contributor's responsibility alone. Under this section, the
+ Commercial Contributor would have to defend claims against the
+ other Contributors related to those performance claims and
+ warranties, and if a court requires any other Contributor to pay
+ any damages as a result, the Commercial Contributor must pay
+ those damages.
+
+ 5. NO WARRANTY
+
+ EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS
+ PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
+ ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT
+ LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE,
+ NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR
+ PURPOSE. Each Recipient is solely responsible for determining the
+ appropriateness of using and distributing the Program and assumes
+ all risks associated with its exercise of rights under this
+ Agreement, including but not limited to the risks and costs of
+ program errors, compliance with applicable laws, damage to or
+ loss of data, programs or equipment, and unavailability or
+ interruption of operations.
+
+ 6. DISCLAIMER OF LIABILITY
+
+ EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER
+ RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST
+ PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
+ IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF
+ THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN
+ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+
+ 7. GENERAL
+
+ If any provision of this Agreement is invalid or unenforceable
+ under applicable law, it shall not affect the validity or
+ enforceability of the remainder of the terms of this Agreement,
+ and without further action by the parties hereto, such provision
+ shall be reformed to the minimum extent necessary to make such
+ provision valid and enforceable.
+
+ If Recipient institutes patent litigation against a Contributor
+ with respect to a patent applicable to software (including a
+ cross-claim or counterclaim in a lawsuit), then any patent
+ licenses granted by that Contributor to such Recipient under this
+ Agreement shall terminate as of the date such litigation is
+ filed. In addition, if Recipient institutes patent litigation
+ against any entity (including a cross-claim or counterclaim in a
+ lawsuit) alleging that the Program itself (excluding combinations
+ of the Program with other software or hardware) infringes such
+ Recipient's patent(s), then such Recipient's rights granted under
+ Section 2(b) shall terminate as of the date such litigation is
+ filed.
+
+ All Recipient's rights under this Agreement shall terminate if it
+ fails to comply with any of the material terms or conditions of
+ this Agreement and does not cure such failure in a reasonable
+ period of time after becoming aware of such noncompliance. If all
+ Recipient's rights under this Agreement terminate, Recipient
+ agrees to cease use and distribution of the Program as soon as
+ reasonably practicable. However, Recipient's obligations under
+ this Agreement and any licenses granted by Recipient relating to
+ the Program shall continue and survive.
+
+ Everyone is permitted to copy and distribute copies of this
+ Agreement, but in order to avoid inconsistency the Agreement is
+ copyrighted and may only be modified in the following manner. The
+ Agreement Steward reserves the right to publish new versions
+ (including revisions) of this Agreement from time to time. No one
+ other than the Agreement Steward has the right to modify this
+ Agreement. IBM is the initial Agreement Steward. IBM may assign
+ the responsibility to serve as the Agreement Steward to a
+ suitable separate entity. Each new version of the Agreement will
+ be given a distinguishing version number. The Program (including
+ Contributions) may always be distributed subject to the version
+ of the Agreement under which it was received. In addition, after
+ a new version of the Agreement is published, Contributor may
+ elect to distribute the Program (including its Contributions)
+ under the new version. Except as expressly stated in Sections
+ 2(a) and 2(b) above, Recipient receives no rights or licenses to
+ the intellectual property of any Contributor under this
+ Agreement, whether expressly, by implication, estoppel or
+ otherwise. All rights in the Program not expressly granted under
+ this Agreement are reserved.
+
+ This Agreement is governed by the laws of the State of New York
+ and the intellectual property laws of the United States of
+ America. No party to this Agreement will bring a legal action
+ under this Agreement more than one year after the cause of action
+ arose. Each party waives its rights to a jury trial in any
+ resulting litigation.
+
+=====================================================================
+ - Stax2 API (http://woodstox.codehaus.org/StAX2)
+ org.codehaus.woodstox:stax2-api:jar:3.1.1
+ License: The BSD License
+ (http://www.opensource.org/licenses/bsd-license.php)
+=====================================================================
+ Copyright (c) 2004-2010, Woodstox Project
+ (http://woodstox.codehaus.org/) All rights reserved.
+
+ Redistribution and use in source and binary forms, with or
+ without modification, are permitted provided that the following
+ conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer. 2.
+ Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in
+ the documentation and/or other materials provided with the
+ distribution. 3. Neither the name of the Woodstox XML Processor
+ nor the names of its contributors may be used to endorse or
+ promote products derived from this software without specific
+ prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+
+
+=====================================================================
+ - javax.ws.rs-api (http://jax-rs-spec.java.net)
+ javax.ws.rs:javax.ws.rs-api:jar:2.0-m10
+ - JAXB Reference Implementation (http://jaxb.java.net/)
+ com.sun.xml.bind:jaxb-impl:jar:2.2.6
+ License: CDDL 1.1 (https://glassfish.java.net/public/CDDL+GPL_1_1.html)
+=====================================================================
+
+ COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL)Version 1.1
+
+ 1. Definitions.
+
+ 1.1. “Contributor” means each individual or entity that creates
+ or contributes to the creation of Modifications.
+
+ 1.2. “Contributor Version” means the combination of the Original
+ Software, prior Modifications used by a Contributor (if any), and
+ the Modifications made by that particular Contributor.
+
+ 1.3. “Covered Software” means (a) the Original Software, or (b)
+ Modifications, or (c) the combination of files containing
+ Original Software with files containing Modifications, in each
+ case including portions thereof.
+
+ 1.4. “Executable” means the Covered Software in any form other
+ than Source Code.
+
+ 1.5. “Initial Developer” means the individual or entity that
+ first makes Original Software available under this License.
+
+ 1.6. “Larger Work” means a work which combines Covered Software
+ or portions thereof with code not governed by the terms of this
+ License.
+
+ 1.7. “License” means this document.
+
+ 1.8. “Licensable” means having the right to grant, to the maximum
+ extent possible, whether at the time of the initial grant or
+ subsequently acquired, any and all of the rights conveyed herein.
+
+ 1.9. “Modifications” means the Source Code and Executable form of
+ any of the following:
+
+ A. Any file that results from an addition to, deletion from or
+ modification of the contents of a file containing Original
+ Software or previous Modifications;
+
+ B. Any new file that contains any part of the Original Software
+ or previous Modification; or
+
+ C. Any new file that is contributed or otherwise made available
+ under the terms of this License.
+
+ 1.10. “Original Software” means the Source Code and Executable
+ form of computer software code that is originally released under
+ this License.
+
+ 1.11. “Patent Claims” means any patent claim(s), now owned or
+ hereafter acquired, including without limitation, method,
+ process, and apparatus claims, in any patent Licensable by
+ grantor.
+
+ 1.12. “Source Code” means (a) the common form of computer
+ software code in which modifications are made and (b) associated
+ documentation included in or with such code.
+
+ 1.13. “You” (or “Your”) means an individual or a legal entity
+ exercising rights under, and complying with all of the terms of,
+ this License. For legal entities, “You” includes any entity which
+ controls, is controlled by, or is under common control with You.
+ For purposes of this definition, “control” means (a) the power,
+ direct or indirect, to cause the direction or management of such
+ entity, whether by contract or otherwise, or (b) ownership of
+ more than fifty percent (50%) of the outstanding shares or
+ beneficial ownership of such entity.
+
+ 2. License Grants.
+
+ 2.1. The Initial Developer Grant.
+
+ Conditioned upon Your compliance with Section 3.1 below and
+ subject to third party intellectual property claims, the Initial
+ Developer hereby grants You a world-wide, royalty-free,
+ non-exclusive license:
+
+ (a) under intellectual property rights (other than patent or
+ trademark) Licensable by Initial Developer, to use, reproduce,
+ modify, display, perform, sublicense and distribute the Original
+ Software (or portions thereof), with or without Modifications,
+ and/or as part of a Larger Work; and
+
+ (b) under Patent Claims infringed by the making, using or selling
+ of Original Software, to make, have made, use, practice, sell,
+ and offer for sale, and/or otherwise dispose of the Original
+ Software (or portions thereof).
+
+ (c) The licenses granted in Sections 2.1(a) and (b) are effective
+ on the date Initial Developer first distributes or otherwise
+ makes the Original Software available to a third party under the
+ terms of this License.
+
+ (d) Notwithstanding Section 2.1(b) above, no patent license is
+ granted: (1) for code that You delete from the Original Software,
+ or (2) for infringements caused by: (i) the modification of the
+ Original Software, or (ii) the combination of the Original
+ Software with other software or devices.
+
+ 2.2. Contributor Grant.
+
+ Conditioned upon Your compliance with Section 3.1 below and
+ subject to third party intellectual property claims, each
+ Contributor hereby grants You a world-wide, royalty-free,
+ non-exclusive license:
+
+ (a) under intellectual property rights (other than patent or
+ trademark) Licensable by Contributor to use, reproduce, modify,
+ display, perform, sublicense and distribute the Modifications
+ created by such Contributor (or portions thereof), either on an
+ unmodified basis, with other Modifications, as Covered Software
+ and/or as part of a Larger Work; and
+
+ (b) under Patent Claims infringed by the making, using, or
+ selling of Modifications made by that Contributor either alone
+ and/or in combination with its Contributor Version (or portions
+ of such combination), to make, use, sell, offer for sale, have
+ made, and/or otherwise dispose of: (1) Modifications made by that
+ Contributor (or portions thereof); and (2) the combination of
+ Modifications made by that Contributor with its Contributor
+ Version (or portions of such combination).
+
+ (c) The licenses granted in Sections 2.2(a) and 2.2(b) are
+ effective on the date Contributor first distributes or otherwise
+ makes the Modifications available to a third party.
+
+ (d) Notwithstanding Section 2.2(b) above, no patent license is
+ granted: (1) for any code that Contributor has deleted from the
+ Contributor Version; (2) for infringements caused by: (i) third
+ party modifications of Contributor Version, or (ii) the
+ combination of Modifications made by that Contributor with other
+ software (except as part of the Contributor Version) or other
+ devices; or (3) under Patent Claims infringed by Covered Software
+ in the absence of Modifications made by that Contributor.
+
+ 3. Distribution Obligations.
+
+ 3.1. Availability of Source Code.
+
+ Any Covered Software that You distribute or otherwise make
+ available in Executable form must also be made available in
+ Source Code form and that Source Code form must be distributed
+ only under the terms of this License. You must include a copy of
+ this License with every copy of the Source Code form of the
+ Covered Software You distribute or otherwise make available. You
+ must inform recipients of any such Covered Software in Executable
+ form as to how they can obtain such Covered Software in Source
+ Code form in a reasonable manner on or through a medium
+ customarily used for software exchange.
+
+ 3.2. Modifications.
+
+ The Modifications that You create or to which You contribute are
+ governed by the terms of this License. You represent that You
+ believe Your Modifications are Your original creation(s) and/or
+ You have sufficient rights to grant the rights conveyed by this
+ License.
+
+ 3.3. Required Notices.
+
+ You must include a notice in each of Your Modifications that
+ identifies You as the Contributor of the Modification. You may
+ not remove or alter any copyright, patent or trademark notices
+ contained within the Covered Software, or any notices of
+ licensing or any descriptive text giving attribution to any
+ Contributor or the Initial Developer.
+
+ 3.4. Application of Additional Terms.
+
+ You may not offer or impose any terms on any Covered Software in
+ Source Code form that alters or restricts the applicable version
+ of this License or the recipients' rights hereunder. You may
+ choose to offer, and to charge a fee for, warranty, support,
+ indemnity or liability obligations to one or more recipients of
+ Covered Software. However, you may do so only on Your own behalf,
+ and not on behalf of the Initial Developer or any Contributor.
+ You must make it absolutely clear that any such warranty,
+ support, indemnity or liability obligation is offered by You
+ alone, and You hereby agree to indemnify the Initial Developer
+ and every Contributor for any liability incurred by the Initial
+ Developer or such Contributor as a result of warranty, support,
+ indemnity or liability terms You offer.
+
+ 3.5. Distribution of Executable Versions.
+
+ You may distribute the Executable form of the Covered Software
+ under the terms of this License or under the terms of a license
+ of Your choice, which may contain terms different from this
+ License, provided that You are in compliance with the terms of
+ this License and that the license for the Executable form does
+ not attempt to limit or alter the recipient's rights in the
+ Source Code form from the rights set forth in this License. If
+ You distribute the Covered Software in Executable form under a
+ different license, You must make it absolutely clear that any
+ terms which differ from this License are offered by You alone,
+ not by the Initial Developer or Contributor. You hereby agree to
+ indemnify the Initial Developer and every Contributor for any
+ liability incurred by the Initial Developer or such Contributor
+ as a result of any such terms You offer.
+
+ 3.6. Larger Works.
+
+ You may create a Larger Work by combining Covered Software with
+ other code not governed by the terms of this License and
+ distribute the Larger Work as a single product. In such a case,
+ You must make sure the requirements of this License are fulfilled
+ for the Covered Software.
+
+ 4. Versions of the License.
+
+ 4.1. New Versions.
+
+ Oracle is the initial license steward and may publish revised
+ and/or new versions of this License from time to time. Each
+ version will be given a distinguishing version number. Except as
+ provided in Section 4.3, no one other than the license steward
+ has the right to modify this License.
+
+ 4.2. Effect of New Versions.
+
+ You may always continue to use, distribute or otherwise make the
+ Covered Software available under the terms of the version of the
+ License under which You originally received the Covered Software.
+ If the Initial Developer includes a notice in the Original
+ Software prohibiting it from being distributed or otherwise made
+ available under any subsequent version of the License, You must
+ distribute and make the Covered Software available under the
+ terms of the version of the License under which You originally
+ received the Covered Software. Otherwise, You may also choose to
+ use, distribute or otherwise make the Covered Software available
+ under the terms of any subsequent version of the License
+ published by the license steward.
+
+ 4.3. Modified Versions.
+
+ When You are an Initial Developer and You want to create a new
+ license for Your Original Software, You may create and use a
+ modified version of this License if You: (a) rename the license
+ and remove any references to the name of the license steward
+ (except to note that the license differs from this License); and
+ (b) otherwise make it clear that the license contains terms which
+ differ from this License.
+
+ 5. DISCLAIMER OF WARRANTY.
+
+ COVERED SOFTWARE IS PROVIDED UNDER THIS LICENSE ON AN “AS IS”
+ BASIS, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED,
+ INCLUDING, WITHOUT LIMITATION, WARRANTIES THAT THE COVERED
+ SOFTWARE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR
+ PURPOSE OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND
+ PERFORMANCE OF THE COVERED SOFTWARE IS WITH YOU. SHOULD ANY
+ COVERED SOFTWARE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT THE
+ INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF
+ ANY NECESSARY SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF
+ WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE. NO USE OF
+ ANY COVERED SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER THIS
+ DISCLAIMER.
+
+ 6. TERMINATION.
+
+ 6.1. This License and the rights granted hereunder will terminate
+ automatically if You fail to comply with terms herein and fail to
+ cure such breach within 30 days of becoming aware of the breach.
+ Provisions which, by their nature, must remain in effect beyond
+ the termination of this License shall survive.
+
+ 6.2. If You assert a patent infringement claim (excluding
+ declaratory judgment actions) against Initial Developer or a
+ Contributor (the Initial Developer or Contributor against whom
+ You assert such claim is referred to as “Participant”) alleging
+ that the Participant Software (meaning the Contributor Version
+ where the Participant is a Contributor or the Original Software
+ where the Participant is the Initial Developer) directly or
+ indirectly infringes any patent, then any and all rights granted
+ directly or indirectly to You by such Participant, the Initial
+ Developer (if the Initial Developer is not the Participant) and
+ all Contributors under Sections 2.1 and/or 2.2 of this License
+ shall, upon 60 days notice from Participant terminate
+ prospectively and automatically at the expiration of such 60 day
+ notice period, unless if within such 60 day period You withdraw
+ Your claim with respect to the Participant Software against such
+ Participant either unilaterally or pursuant to a written
+ agreement with Participant.
+
+ 6.3. If You assert a patent infringement claim against
+ Participant alleging that the Participant Software directly or
+ indirectly infringes any patent where such claim is resolved
+ (such as by license or settlement) prior to the initiation of
+ patent infringement litigation, then the reasonable value of the
+ licenses granted by such Participant under Sections 2.1 or 2.2
+ shall be taken into account in determining the amount or value of
+ any payment or license.
+
+ 6.4. In the event of termination under Sections 6.1 or 6.2 above,
+ all end user licenses that have been validly granted by You or
+ any distributor hereunder prior to termination (excluding
+ licenses granted to You by any distributor) shall survive
+ termination.
+
+ 7. LIMITATION OF LIABILITY.
+
+ UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, WHETHER TORT
+ (INCLUDING NEGLIGENCE), CONTRACT, OR OTHERWISE, SHALL YOU, THE
+ INITIAL DEVELOPER, ANY OTHER CONTRIBUTOR, OR ANY DISTRIBUTOR OF
+ COVERED SOFTWARE, OR ANY SUPPLIER OF ANY OF SUCH PARTIES, BE
+ LIABLE TO ANY PERSON FOR ANY INDIRECT, SPECIAL, INCIDENTAL, OR
+ CONSEQUENTIAL DAMAGES OF ANY CHARACTER INCLUDING, WITHOUT
+ LIMITATION, DAMAGES FOR LOSS OF GOODWILL, WORK STOPPAGE, COMPUTER
+ FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER COMMERCIAL DAMAGES
+ OR LOSSES, EVEN IF SUCH PARTY SHALL HAVE BEEN INFORMED OF THE
+ POSSIBILITY OF SUCH DAMAGES. THIS LIMITATION OF LIABILITY SHALL
+ NOT APPLY TO LIABILITY FOR DEATH OR PERSONAL INJURY RESULTING
+ FROM SUCH PARTY'S NEGLIGENCE TO THE EXTENT APPLICABLE LAW
+ PROHIBITS SUCH LIMITATION. SOME JURISDICTIONS DO NOT ALLOW THE
+ EXCLUSION OR LIMITATION OF INCIDENTAL OR CONSEQUENTIAL DAMAGES,
+ SO THIS EXCLUSION AND LIMITATION MAY NOT APPLY TO YOU.
+
+ 8. U.S. GOVERNMENT END USERS.
+
+ The Covered Software is a “commercial item,” as that term is
+ defined in 48 C.F.R. 2.101 (Oct. 1995), consisting of “commercial
+ computer software” (as that term is defined at 48 C.F.R. §
+ 252.227-7014(a)(1)) and “commercial computer software
+ documentation” as such terms are used in 48 C.F.R. 12.212 (Sept.
+ 1995). Consistent with 48 C.F.R. 12.212 and 48 C.F.R. 227.7202-1
+ through 227.7202-4 (June 1995), all U.S. Government End Users
+ acquire Covered Software with only those rights set forth herein.
+ This U.S. Government Rights clause is in lieu of, and supersedes,
+ any other FAR, DFAR, or other clause or provision that addresses
+ Government rights in computer software under this License.
+
+ 9. MISCELLANEOUS.
+
+ This License represents the complete agreement concerning subject
+ matter hereof. If any provision of this License is held to be
+ unenforceable, such provision shall be reformed only to the
+ extent necessary to make it enforceable. This License shall be
+ governed by the law of the jurisdiction specified in a notice
+ contained within the Original Software (except to the extent
+ applicable law, if any, provides otherwise), excluding such
+ jurisdiction's conflict-of-law provisions. Any litigation
+ relating to this License shall be subject to the jurisdiction of
+ the courts located in the jurisdiction and venue specified in a
+ notice contained within the Original Software, with the losing
+ party responsible for costs, including, without limitation, court
+ costs and reasonable attorneys' fees and expenses. The
+ application of the United Nations Convention on Contracts for the
+ International Sale of Goods is expressly excluded. Any law or
+ regulation which provides that the language of a contract shall
+ be construed against the drafter shall not apply to this License.
+ You agree that You alone are responsible for compliance with the
+ United States export administration regulations (and the export
+ control laws and regulation of any other countries) when You use,
+ distribute or otherwise make available any Covered Software.
+
+ 10. RESPONSIBILITY FOR CLAIMS.
+
+ As between Initial Developer and the Contributors, each party is
+ responsible for claims and damages arising, directly or
+ indirectly, out of its utilization of rights under this License
+ and You agree to work with Initial Developer and Contributors to
+ distribute such responsibility on an equitable basis. Nothing
+ herein is intended or shall be deemed to constitute any admission
+ of liability.
+
+ NOTICE PURSUANT TO SECTION 9 OF THE COMMON DEVELOPMENT AND
+ DISTRIBUTION LICENSE (CDDL)
+
+ The code released under the CDDL shall be governed by the laws of
+ the State of California (excluding conflict-of-law provisions).
+ Any litigation relating to this License shall be subject to the
+ jurisdiction of the Federal Courts of the Northern District of
+ California and the state courts of the State of California, with
+ venue lying in Santa Clara County, California.
+
+=====================================================================
+ - SLF4J API Module (http://www.slf4j.org) org.slf4j:slf4j-api:jar:1.7.1
+ - SLF4J LOG4J-12 Binding (http://www.slf4j.org) org.slf4j:slf4j-log4j12:jar:1.7.1
+ License: MIT License (http://www.opensource.org/licenses/mit-license.php)
+=====================================================================
+ Copyright (c) 2004-2013 QOS.ch All rights reserved.
+
+ Permission is hereby granted, free of charge, to any person
+ obtaining a copy of this software and associated documentation
+ files (the "Software"), to deal in the Software without
+ restriction, including without limitation the rights to use,
+ copy, modify, merge, publish, distribute, sublicense, and/or sell
+ copies of the Software, and to permit persons to whom the
+ Software is furnished to do so, subject to the following
+ conditions:
+
+ The above copyright notice and this permission notice shall be
+ included in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ OTHER DEALINGS IN THE SOFTWARE.
+
+=====================================================================
+
+ - SDO API (http://www.eclipse.org/eclipselink)
+ org.eclipse.persistence:commonj.sdo:jar:2.1.1
+ - EclipseLink (non-OSGi) (http://www.eclipse.org/eclipselink)
+ org.eclipse.persistence:eclipselink:jar:2.5.0
+ - Javax Persistence (http://www.eclipse.org/eclipselink)
+ org.eclipse.persistence:javax.persistence:jar:2.0.5
+ License: Eclipse Public License v1.0 (http://www.eclipse.org/legal/epl-v10.html)
+ License: Eclipse Distribution License v. 1.0
+ (http://www.eclipse.org/org/documents/edl-v10.php)
+=====================================================================
+
+ Eclipse Public License - v 1.0
+
+ THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS
+ ECLIPSE PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR
+ DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF
+ THIS AGREEMENT.
+
+ 1. DEFINITIONS
+
+ "Contribution" means:
+
+ a) in the case of the initial Contributor, the initial code and
+ documentation distributed under this Agreement, and
+
+ b) in the case of each subsequent Contributor:
+
+ i) changes to the Program, and
+
+ ii) additions to the Program;
+
+ where such changes and/or additions to the Program originate from
+ and are distributed by that particular Contributor. A
+ Contribution 'originates' from a Contributor if it was added to
+ the Program by such Contributor itself or anyone acting on such
+ Contributor's behalf. Contributions do not include additions to
+ the Program which: (i) are separate modules of software
+ distributed in conjunction with the Program under their own
+ license agreement, and (ii) are not derivative works of the
+ Program.
+
+ "Contributor" means any person or entity that distributes the
+ Program.
+
+ "Licensed Patents" mean patent claims licensable by a Contributor
+ which are necessarily infringed by the use or sale of its
+ Contribution alone or when combined with the Program.
+
+ "Program" means the Contributions distributed in accordance with
+ this Agreement.
+
+ "Recipient" means anyone who receives the Program under this
+ Agreement, including all Contributors.
+
+ 2. GRANT OF RIGHTS
+
+ a) Subject to the terms of this Agreement, each Contributor
+ hereby grants Recipient a non-exclusive, worldwide, royalty-free
+ copyright license to reproduce, prepare derivative works of,
+ publicly display, publicly perform, distribute and sublicense the
+ Contribution of such Contributor, if any, and such derivative
+ works, in source code and object code form.
+
+ b) Subject to the terms of this Agreement, each Contributor
+ hereby grants Recipient a non-exclusive, worldwide, royalty-free
+ patent license under Licensed Patents to make, use, sell, offer
+ to sell, import and otherwise transfer the Contribution of such
+ Contributor, if any, in source code and object code form. This
+ patent license shall apply to the combination of the Contribution
+ and the Program if, at the time the Contribution is added by the
+ Contributor, such addition of the Contribution causes such
+ combination to be covered by the Licensed Patents. The patent
+ license shall not apply to any other combinations which include
+ the Contribution. No hardware per se is licensed hereunder.
+
+ c) Recipient understands that although each Contributor grants
+ the licenses to its Contributions set forth herein, no assurances
+ are provided by any Contributor that the Program does not
+ infringe the patent or other intellectual property rights of any
+ other entity. Each Contributor disclaims any liability to
+ Recipient for claims brought by any other entity based on
+ infringement of intellectual property rights or otherwise. As a
+ condition to exercising the rights and licenses granted
+ hereunder, each Recipient hereby assumes sole responsibility to
+ secure any other intellectual property rights needed, if any. For
+ example, if a third party patent license is required to allow
+ Recipient to distribute the Program, it is Recipient's
+ responsibility to acquire that license before distributing the
+ Program.
+
+ d) Each Contributor represents that to its knowledge it has
+ sufficient copyright rights in its Contribution, if any, to grant
+ the copyright license set forth in this Agreement.
+
+ 3. REQUIREMENTS
+
+ A Contributor may choose to distribute the Program in object code
+ form under its own license agreement, provided that:
+
+ a) it complies with the terms and conditions of this Agreement;
+ and
+
+ b) its license agreement:
+
+ i) effectively disclaims on behalf of all Contributors all
+ warranties and conditions, express and implied, including
+ warranties or conditions of title and non-infringement, and
+ implied warranties or conditions of merchantability and fitness
+ for a particular purpose;
+
+ ii) effectively excludes on behalf of all Contributors all
+ liability for damages, including direct, indirect, special,
+ incidental and consequential damages, such as lost profits;
+
+ iii) states that any provisions which differ from this Agreement
+ are offered by that Contributor alone and not by any other party;
+ and
+
+ iv) states that source code for the Program is available from
+ such Contributor, and informs licensees how to obtain it in a
+ reasonable manner on or through a medium customarily used for
+ software exchange.
+
+ When the Program is made available in source code form:
+
+ a) it must be made available under this Agreement; and
+
+ b) a copy of this Agreement must be included with each copy of
+ the Program.
+
+ Contributors may not remove or alter any copyright notices
+ contained within the Program.
+
+ Each Contributor must identify itself as the originator of its
+ Contribution, if any, in a manner that reasonably allows
+ subsequent Recipients to identify the originator of the
+ Contribution.
+
+ 4. COMMERCIAL DISTRIBUTION
+
+ Commercial distributors of software may accept certain
+ responsibilities with respect to end users, business partners and
+ the like. While this license is intended to facilitate the
+ commercial use of the Program, the Contributor who includes the
+ Program in a commercial product offering should do so in a manner
+ which does not create potential liability for other Contributors.
+ Therefore, if a Contributor includes the Program in a commercial
+ product offering, such Contributor ("Commercial Contributor")
+ hereby agrees to defend and indemnify every other Contributor
+ ("Indemnified Contributor") against any losses, damages and costs
+ (collectively "Losses") arising from claims, lawsuits and other
+ legal actions brought by a third party against the Indemnified
+ Contributor to the extent caused by the acts or omissions of such
+ Commercial Contributor in connection with its distribution of the
+ Program in a commercial product offering. The obligations in this
+ section do not apply to any claims or Losses relating to any
+ actual or alleged intellectual property infringement. In order to
+ qualify, an Indemnified Contributor must: a) promptly notify the
+ Commercial Contributor in writing of such claim, and b) allow the
+ Commercial Contributor to control, and cooperate with the
+ Commercial Contributor in, the defense and any related settlement
+ negotiations. The Indemnified Contributor may participate in any
+ such claim at its own expense.
+
+ For example, a Contributor might include the Program in a
+ commercial product offering, Product X. That Contributor is then
+ a Commercial Contributor. If that Commercial Contributor then
+ makes performance claims, or offers warranties related to Product
+ X, those performance claims and warranties are such Commercial
+ Contributor's responsibility alone. Under this section, the
+ Commercial Contributor would have to defend claims against the
+ other Contributors related to those performance claims and
+ warranties, and if a court requires any other Contributor to pay
+ any damages as a result, the Commercial Contributor must pay
+ those damages.
+
+ 5. NO WARRANTY
+
+ EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS
+ PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
+ ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT
+ LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE,
+ NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR
+ PURPOSE. Each Recipient is solely responsible for determining the
+ appropriateness of using and distributing the Program and assumes
+ all risks associated with its exercise of rights under this
+ Agreement , including but not limited to the risks and costs of
+ program errors, compliance with applicable laws, damage to or
+ loss of data, programs or equipment, and unavailability or
+ interruption of operations.
+
+ 6. DISCLAIMER OF LIABILITY
+
+ EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER
+ RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST
+ PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
+ IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF
+ THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN
+ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+
+ 7. GENERAL
+
+ If any provision of this Agreement is invalid or unenforceable
+ under applicable law, it shall not affect the validity or
+ enforceability of the remainder of the terms of this Agreement,
+ and without further action by the parties hereto, such provision
+ shall be reformed to the minimum extent necessary to make such
+ provision valid and enforceable.
+
+ If Recipient institutes patent litigation against any entity
+ (including a cross-claim or counterclaim in a lawsuit) alleging
+ that the Program itself (excluding combinations of the Program
+ with other software or hardware) infringes such Recipient's
+ patent(s), then such Recipient's rights granted under Section
+ 2(b) shall terminate as of the date such litigation is filed.
+
+ All Recipient's rights under this Agreement shall terminate if it
+ fails to comply with any of the material terms or conditions of
+ this Agreement and does not cure such failure in a reasonable
+ period of time after becoming aware of such noncompliance. If all
+ Recipient's rights under this Agreement terminate, Recipient
+ agrees to cease use and distribution of the Program as soon as
+ reasonably practicable. However, Recipient's obligations under
+ this Agreement and any licenses granted by Recipient relating to
+ the Program shall continue and survive.
+
+ Everyone is permitted to copy and distribute copies of this
+ Agreement, but in order to avoid inconsistency the Agreement is
+ copyrighted and may only be modified in the following manner. The
+ Agreement Steward reserves the right to publish new versions
+ (including revisions) of this Agreement from time to time. No one
+ other than the Agreement Steward has the right to modify this
+ Agreement. The Eclipse Foundation is the initial Agreement
+ Steward. The Eclipse Foundation may assign the responsibility to
+ serve as the Agreement Steward to a suitable separate entity.
+ Each new version of the Agreement will be given a distinguishing
+ version number. The Program (including Contributions) may always
+ be distributed subject to the version of the Agreement under
+ which it was received. In addition, after a new version of the
+ Agreement is published, Contributor may elect to distribute the
+ Program (including its Contributions) under the new version.
+ Except as expressly stated in Sections 2(a) and 2(b) above,
+ Recipient receives no rights or licenses to the intellectual
+ property of any Contributor under this Agreement, whether
+ expressly, by implication, estoppel or otherwise. All rights in
+ the Program not expressly granted under this Agreement are
+ reserved.
+
+ This Agreement is governed by the laws of the State of New York
+ and the intellectual property laws of the United States of
+ America. No party to this Agreement will bring a legal action
+ under this Agreement more than one year after the cause of action
+ arose. Each party waives its rights to a jury trial in any
+ resulting litigation.
+
+=====================================================================
+ - HSQLDB Database (http://hsqldb.org/) org.hsqldb:hsqldb:jar:1.8.0.10
+ License: HSQLDB License, a BSD open source license
+ (http://hsqldb.org/web/hsqlLicense.html)
+=====================================================================
+ COPYRIGHTS AND LICENSES (based on BSD License)
+
+ For work developed by the HSQL Development Group:
+
+ Copyright (c) 2001-2010, The HSQL Development Group All rights
+ reserved.
+
+ Redistribution and use in source and binary forms, with or
+ without modification, are permitted provided that the following
+ conditions are met:
+
+ Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+ Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in
+ the documentation and/or other materials provided with the
+ distribution.
+
+ Neither the name of the HSQL Development Group nor the names of
+ its contributors may be used to endorse or promote products
+ derived from this software without specific prior written
+ permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ DISCLAIMED. IN NO EVENT SHALL HSQL DEVELOPMENT GROUP, HSQLDB.ORG,
+ OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+
+
+ For work originally developed by the Hypersonic SQL Group:
+
+ Copyright (c) 1995-2000 by the Hypersonic SQL Group. All rights
+ reserved.
+
+ Redistribution and use in source and binary forms, with or
+ without modification, are permitted provided that the following
+ conditions are met:
+
+ Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+ Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in
+ the documentation and/or other materials provided with the
+ distribution.
+
+ Neither the name of the Hypersonic SQL Group nor the names of its
+ contributors may be used to endorse or promote products derived
+ from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ DISCLAIMED. IN NO EVENT SHALL THE HYPERSONIC SQL GROUP, OR
+ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+
+ This software consists of voluntary contributions made by many
+ individuals on behalf of the Hypersonic SQL Group.
+
+=====================================================================
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-web/src/main/resources/MaterialSQLs.properties
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-web/src/main/resources/MaterialSQLs.properties b/odata2-jpa-processor/jpa-web/src/main/resources/MaterialSQLs.properties
new file mode 100644
index 0000000..0faf9ce
--- /dev/null
+++ b/odata2-jpa-processor/jpa-web/src/main/resources/MaterialSQLs.properties
@@ -0,0 +1,30 @@
+#-------------------------------------------------------------------------------
+# 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.
+#-------------------------------------------------------------------------------
+
+material_query_1 = insert into T_MATERIAL (MATERIAL_ID , MATERIAL_NAME, TYPE_CODE, PRICE, MEASUREMENT_UNIT) values(111, 'Test_Material_Name_1', 'Test_Type_Code_1', 111.1, 'Dollar');
+material_query_2 = insert into T_MATERIAL (MATERIAL_ID , MATERIAL_NAME, TYPE_CODE, PRICE, MEASUREMENT_UNIT) values(112, 'Test_Material_Name_2', 'Test_Type_Code_2', 112.1, 'Pound');
+material_query_3 = insert into T_MATERIAL (MATERIAL_ID , MATERIAL_NAME, TYPE_CODE, PRICE, MEASUREMENT_UNIT) values(113, 'Test_Material_Name_3', 'Test_Type_Code_3', 113.1, 'Yen');
+material_query_4 = insert into T_MATERIAL (MATERIAL_ID , MATERIAL_NAME, TYPE_CODE, PRICE, MEASUREMENT_UNIT) values(114, 'Test_Material_Name_4', 'Test_Type_Code_4', 114.1, 'Rupee');
+material_query_5 = insert into T_MATERIAL (MATERIAL_ID , MATERIAL_NAME, TYPE_CODE, PRICE, MEASUREMENT_UNIT) values(115, 'Test_Material_Name_5', 'Test_Type_Code_5', 115.1, 'Dollar');
+material_query_6 = insert into T_MATERIAL (MATERIAL_ID , MATERIAL_NAME, TYPE_CODE, PRICE, MEASUREMENT_UNIT) values(116, 'Test_Material_Name_6', 'Test_Type_Code_6', 116.1, 'Dollar');
+material_query_7 = insert into T_MATERIAL (MATERIAL_ID , MATERIAL_NAME, TYPE_CODE, PRICE, MEASUREMENT_UNIT) values(117, 'Test_Material_Name_7', 'Test_Type_Code_7', 117.1, 'Dollar');
+material_query_8 = insert into T_MATERIAL (MATERIAL_ID , MATERIAL_NAME, TYPE_CODE, PRICE, MEASUREMENT_UNIT) values(118, 'Test_Material_Name_8', 'Test_Type_Code_8', 118.1, 'Dollar');
+material_query_9 = insert into T_MATERIAL (MATERIAL_ID , MATERIAL_NAME, TYPE_CODE, PRICE, MEASUREMENT_UNIT) values(119, 'Test_Material_Name_9', 'Test_Type_Code_9', 119.1, 'Dollar');
+material_query_10 = insert into T_MATERIAL (MATERIAL_ID , MATERIAL_NAME, TYPE_CODE, PRICE, MEASUREMENT_UNIT) values(120, 'Test_Material_Name_10', 'Test_Type_Code_10', 120.1, 'Dollar');
+material_query_11 = insert into T_MATERIAL (MATERIAL_ID , MATERIAL_NAME, TYPE_CODE, PRICE, MEASUREMENT_UNIT) values(121, 'Test_Material_Name_11', 'Test_Type_Code_11', 121.1, 'Dollar');
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-web/src/main/resources/NoteSQLs.properties
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-web/src/main/resources/NoteSQLs.properties b/odata2-jpa-processor/jpa-web/src/main/resources/NoteSQLs.properties
new file mode 100644
index 0000000..347c37a
--- /dev/null
+++ b/odata2-jpa-processor/jpa-web/src/main/resources/NoteSQLs.properties
@@ -0,0 +1,20 @@
+#-------------------------------------------------------------------------------
+# 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.
+#-------------------------------------------------------------------------------
+
+note_query_1 = insert into T_NOTE (SO_ID , text, createdBy, creationDate,creationTime) values(2, 'Test_Note_1', 'CreatedBy_1','2013-01-01 00:00:00','00:00:23');
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-web/src/main/resources/SQLInsertConfig.properties
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-web/src/main/resources/SQLInsertConfig.properties b/odata2-jpa-processor/jpa-web/src/main/resources/SQLInsertConfig.properties
new file mode 100644
index 0000000..915a8e8
--- /dev/null
+++ b/odata2-jpa-processor/jpa-web/src/main/resources/SQLInsertConfig.properties
@@ -0,0 +1,22 @@
+#-------------------------------------------------------------------------------
+# 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.
+#-------------------------------------------------------------------------------
+
+#This file contains names of file which will contain the SQL statements to be executed by Data generator. Add a file name here and it will be picked up by Generator
+#You need to put the file names in order you want to get them called. First Entry will be inserted first.
+insert_file_names = SalesOrderHeaderSQLs,StoreSQLs,MaterialSQLs,SalesOrderItemSQLs,NoteSQLs
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-web/src/main/resources/SalesOrderHeaderSQLs.properties
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-web/src/main/resources/SalesOrderHeaderSQLs.properties b/odata2-jpa-processor/jpa-web/src/main/resources/SalesOrderHeaderSQLs.properties
new file mode 100644
index 0000000..bc3e5a3
--- /dev/null
+++ b/odata2-jpa-processor/jpa-web/src/main/resources/SalesOrderHeaderSQLs.properties
@@ -0,0 +1,30 @@
+#-------------------------------------------------------------------------------
+# 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.
+#-------------------------------------------------------------------------------
+
+query1 = insert into T_SALESORDERHEADER (SO_ID, BUYER_ID, BUYER_NAME, CURRENCY_CODE, DELIVERY_STATUS, creationDate, HOUSE_NUMBER, STREET_NAME, CITY, COUNTRY) values(20130320170725, 1, 'buyerName_1', 'INR', '01', '2012-11-01 00:01:00', 1, 'Test_Street_Name_1', 'Test_City_1', 'Test_Country_1');
+query2 = insert into T_SALESORDERHEADER (SO_ID, BUYER_ID, BUYER_NAME, CURRENCY_CODE, DELIVERY_STATUS, creationDate, HOUSE_NUMBER, STREET_NAME, CITY, COUNTRY) values(2, 2, 'buyerName_2', 'USD', '01', '2013-01-02 00:00:00', 2, 'Test_Street_Name_2', 'Test_City_2', 'Test_Country_2');
+query3 = insert into T_SALESORDERHEADER (SO_ID, BUYER_ID, BUYER_NAME, CURRENCY_CODE, DELIVERY_STATUS, creationDate, HOUSE_NUMBER, STREET_NAME, CITY, COUNTRY) values(3, 3, 'buyerName_3', 'USD', '02', '2013-01-01 14:00:00', 3, 'Test_Street_Name_3', 'Test_City_3', 'Test_Country_3');
+query4 = insert into T_SALESORDERHEADER (SO_ID, BUYER_ID, BUYER_NAME, CURRENCY_CODE, DELIVERY_STATUS, creationDate, HOUSE_NUMBER, STREET_NAME, CITY, COUNTRY) values(4, 4, 'buyerName_4', 'INR', '01', '2013-01-02 00:00:00', 4, 'Test_Street_Name_4', 'Test_City_4', 'Test_Country_4');
+query5 = insert into T_SALESORDERHEADER (SO_ID, BUYER_ID, BUYER_NAME, CURRENCY_CODE, DELIVERY_STATUS, creationDate, HOUSE_NUMBER, STREET_NAME, CITY, COUNTRY) values(5, 5, 'buyerName_5', 'INR', '02', '2013-01-01 14:14:14', 5, 'Test_Street_Name_5', 'Test_City_5', 'Test_Country_5');
+query6 = insert into T_SALESORDERHEADER (SO_ID, BUYER_ID, BUYER_NAME, CURRENCY_CODE, DELIVERY_STATUS, creationDate, HOUSE_NUMBER, STREET_NAME, CITY, COUNTRY) values(6, 6, 'buyerName_6', 'EUR', '01', '2013-01-02 00:00:00', 6, 'Test_Street_Name_6', 'Test_City_6', 'Test_Country_6');
+query7 = insert into T_SALESORDERHEADER (SO_ID, BUYER_ID, BUYER_NAME, CURRENCY_CODE, DELIVERY_STATUS, creationDate, HOUSE_NUMBER, STREET_NAME, CITY, COUNTRY) values(7, 7, 'buyerName_7', 'EUR', '02', '2013-01-01 14:14:00', 7, 'Test_Street_Name_7', 'Test_City_7', 'Test_Country_7');
+query8 = insert into T_SALESORDERHEADER (SO_ID, BUYER_ID, BUYER_NAME, CURRENCY_CODE, DELIVERY_STATUS, creationDate, HOUSE_NUMBER, STREET_NAME, CITY, COUNTRY) values(8, 8, 'buyerName_8', 'GBR', '01', '2013-01-02 00:00:00', 8, 'Test_Street_Name_8', 'Test_City_8', 'Test_Country_8');
+query9 = insert into T_SALESORDERHEADER (SO_ID, BUYER_ID, BUYER_NAME, CURRENCY_CODE, DELIVERY_STATUS, creationDate, HOUSE_NUMBER, STREET_NAME, CITY, COUNTRY) values(9, 9, 'buyerName_9', 'GBR', '02', '2013-01-01 00:00:00', 9, 'Test_Street_Name_9', 'Test_City_9', 'Test_Country_9');
+query10 = insert into T_SALESORDERHEADER (SO_ID, BUYER_ID, BUYER_NAME, CURRENCY_CODE, DELIVERY_STATUS, creationDate, HOUSE_NUMBER, STREET_NAME, CITY, COUNTRY) values(10, 10, 'buyerName_10', 'AUD', '01', '2013-01-01 00:00:00', 10, 'Test_Street_Name_10', 'Test_City_10', 'Test_Country_10');
+query11 = insert into T_SALESORDERHEADER (SO_ID, BUYER_ID, BUYER_NAME, CURRENCY_CODE, DELIVERY_STATUS, creationDate, HOUSE_NUMBER, STREET_NAME, CITY, COUNTRY) values(11, 11, 'buyerName_11', 'AUD', '02', '2013-01-02 00:00:00', 7, 'Test_Street_Name_11', 'Test_City_11', 'Test_Country_3');
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-web/src/main/resources/SalesOrderItemSQLs.properties
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-web/src/main/resources/SalesOrderItemSQLs.properties b/odata2-jpa-processor/jpa-web/src/main/resources/SalesOrderItemSQLs.properties
new file mode 100644
index 0000000..46c8655
--- /dev/null
+++ b/odata2-jpa-processor/jpa-web/src/main/resources/SalesOrderItemSQLs.properties
@@ -0,0 +1,30 @@
+#-------------------------------------------------------------------------------
+# 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.
+#-------------------------------------------------------------------------------
+
+line_item_query1 = insert into T_SALESORDERITEM (Material_Id , quantity , amount , discount , Sales_Order_Id , Sales_Order_Item_Id ) values(111, 1, 1.1, 1.11, 3, 11);
+line_item_query2 = insert into T_SALESORDERITEM (Material_Id , quantity , amount , discount , Sales_Order_Id , Sales_Order_Item_Id ) values(112, 1, 1.1, 1.12, 2, 10);
+line_item_query3 = insert into T_SALESORDERITEM (Material_Id , quantity , amount , discount , Sales_Order_Id , Sales_Order_Item_Id ) values(113, 1, 1.1, 1.13, 3, 9);
+line_item_query4 = insert into T_SALESORDERITEM (Material_Id , quantity , amount , discount , Sales_Order_Id , Sales_Order_Item_Id ) values(114, 1, 1.1, 1.14, 4, 8);
+line_item_query5 = insert into T_SALESORDERITEM (Material_Id , quantity , amount , discount , Sales_Order_Id , Sales_Order_Item_Id ) values(115, 1, 1.1, 1.15, 5, 7);
+line_item_query6 = insert into T_SALESORDERITEM (Material_Id , quantity , amount , discount , Sales_Order_Id , Sales_Order_Item_Id ) values(116, 1, 1.1, 1.16, 6, 6);
+line_item_query7 = insert into T_SALESORDERITEM (Material_Id , quantity , amount , discount , Sales_Order_Id , Sales_Order_Item_Id ) values(117, 1, 1.1, 1.17, 7, 5);
+line_item_query8 = insert into T_SALESORDERITEM (Material_Id , quantity , amount , discount , Sales_Order_Id , Sales_Order_Item_Id ) values(118, 1, 1.1, 1.18, 8, 4);
+line_item_query9 = insert into T_SALESORDERITEM (Material_Id , quantity , amount , discount , Sales_Order_Id , Sales_Order_Item_Id ) values(119, 1, 1.1, 1.19, 9, 3);
+line_item_query10 = insert into T_SALESORDERITEM (Material_Id , quantity , amount , discount , Sales_Order_Id , Sales_Order_Item_Id ) values(120, 1, 1.1, 1.20, 10, 2);
+line_item_query11 = insert into T_SALESORDERITEM (Material_Id , quantity , amount , discount , Sales_Order_Id , Sales_Order_Item_Id ) values(121, 1, 1.1, 1.21, 3, 1);
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-web/src/main/resources/StoreSQLs.properties
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-web/src/main/resources/StoreSQLs.properties b/odata2-jpa-processor/jpa-web/src/main/resources/StoreSQLs.properties
new file mode 100644
index 0000000..69af954
--- /dev/null
+++ b/odata2-jpa-processor/jpa-web/src/main/resources/StoreSQLs.properties
@@ -0,0 +1,30 @@
+#-------------------------------------------------------------------------------
+# 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.
+#-------------------------------------------------------------------------------
+
+store_query_1 = insert into T_STORE (STORE_ID , STORE_NAME, HOUSE_NUMBER, STREET_NAME, CITY, COUNTRY) values(131, 'Test_Store_1', 1, 'Test_Street_Name_1', 'Test_City_1', 'Test_Country_1');
+store_query_2 = insert into T_STORE (STORE_ID , STORE_NAME, HOUSE_NUMBER, STREET_NAME, CITY, COUNTRY) values(132, 'Test_Store_2', 1, 'Test_Street_Name_2', 'Test_City_2', 'Test_Country_2');
+store_query_3 = insert into T_STORE (STORE_ID , STORE_NAME, HOUSE_NUMBER, STREET_NAME, CITY, COUNTRY) values(133, 'Test_Store_3', 1, 'Test_Street_Name_3', 'Test_City_3', 'Test_Country_3');
+store_query_4 = insert into T_STORE (STORE_ID , STORE_NAME, HOUSE_NUMBER, STREET_NAME, CITY, COUNTRY) values(134, 'Test_Store_4', 1, 'Test_Street_Name_4', 'Test_City_4', 'Test_Country_4');
+store_query_5 = insert into T_STORE (STORE_ID , STORE_NAME, HOUSE_NUMBER, STREET_NAME, CITY, COUNTRY) values(135, 'Test_Store_5', 1, 'Test_Street_Name_5', 'Test_City_5', 'Test_Country_5');
+store_query_6 = insert into T_STORE (STORE_ID , STORE_NAME, HOUSE_NUMBER, STREET_NAME, CITY, COUNTRY) values(136, 'Test_Store_6', 1, 'Test_Street_Name_6', 'Test_City_6', 'Test_Country_6');
+store_query_7 = insert into T_STORE (STORE_ID , STORE_NAME, HOUSE_NUMBER, STREET_NAME, CITY, COUNTRY) values(137, 'Test_Store_7', 1, 'Test_Street_Name_7', 'Test_City_7', 'Test_Country_7');
+store_query_8 = insert into T_STORE (STORE_ID , STORE_NAME, HOUSE_NUMBER, STREET_NAME, CITY, COUNTRY) values(138, 'Test_Store_8', 1, 'Test_Street_Name_8', 'Test_City_8', 'Test_Country_8');
+store_query_9 = insert into T_STORE (STORE_ID , STORE_NAME, HOUSE_NUMBER, STREET_NAME, CITY, COUNTRY) values(139, 'Test_Store_9', 1, 'Test_Street_Name_9', 'Test_City_9', 'Test_Country_9');
+store_query_10 = insert into T_STORE (STORE_ID , STORE_NAME, HOUSE_NUMBER, STREET_NAME, CITY, COUNTRY) values(140, 'Test_Store_10', 1, 'Test_Street_Name_10', 'Test_City_10', 'Test_Country_10');
+store_query_11 = insert into T_STORE (STORE_ID , STORE_NAME, HOUSE_NUMBER, STREET_NAME, CITY, COUNTRY) values(141, 'Test_Store_11', 1, 'Test_Street_Name_11', 'Test_City_11', 'Test_Country_11');
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-web/src/main/resources/serviceConfig.properties
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-web/src/main/resources/serviceConfig.properties b/odata2-jpa-processor/jpa-web/src/main/resources/serviceConfig.properties
new file mode 100644
index 0000000..747277e
--- /dev/null
+++ b/odata2-jpa-processor/jpa-web/src/main/resources/serviceConfig.properties
@@ -0,0 +1,19 @@
+#-------------------------------------------------------------------------------
+# 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.
+#-------------------------------------------------------------------------------
+showDetailError=true
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-web/src/main/webapp/SalesOrderProcessingMappingModel.xml
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-web/src/main/webapp/SalesOrderProcessingMappingModel.xml b/odata2-jpa-processor/jpa-web/src/main/webapp/SalesOrderProcessingMappingModel.xml
new file mode 100644
index 0000000..6a0f911
--- /dev/null
+++ b/odata2-jpa-processor/jpa-web/src/main/webapp/SalesOrderProcessingMappingModel.xml
@@ -0,0 +1,61 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- 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. -->
+<JPAEDMMappingModel
+ xmlns="http://www.apache.org/olingo/odata2/processor/api/jpa/model/mapping">
+ <PersistenceUnit name="salesorderprocessing">
+ <EDMSchemaNamespace>SalesOrderProcessing</EDMSchemaNamespace>
+ <JPAEntityTypes>
+ <JPAEntityType name="SalesOrderHeader">
+ <EDMEntityType>SalesOrder</EDMEntityType>
+ <EDMEntitySet>SalesOrders</EDMEntitySet>
+ <JPAAttributes>
+ <JPAAttribute name="soId">ID</JPAAttribute>
+ <JPAAttribute name="netAmount">NetAmount</JPAAttribute>
+ <JPAAttribute name="buyerAddress">BuyerAddressInfo</JPAAttribute>
+ </JPAAttributes>
+ <JPARelationships>
+ <JPARelationship name="salesOrderItem">SalesOrderLineItemDetails</JPARelationship>
+ <JPARelationship name="notes">NotesDetails</JPARelationship>
+ </JPARelationships>
+ </JPAEntityType>
+ <JPAEntityType name="SalesOrderItem">
+ <EDMEntityType>SalesOrderLineItem</EDMEntityType>
+ <EDMEntitySet>SalesOrderLineItems</EDMEntitySet>
+ <JPAAttributes>
+ <JPAAttribute name="liId">ID</JPAAttribute>
+ <JPAAttribute name="soId">SalesOrderID</JPAAttribute>
+ </JPAAttributes>
+ <JPARelationships>
+ <JPARelationship name="salesOrderHeader">SalesOrderHeaderDetails</JPARelationship>
+ <JPARelationship name="materials">MaterialDetails</JPARelationship>
+ </JPARelationships>
+ </JPAEntityType>
+ <JPAEntityType name="EmailActivity">
+ <EDMEntityType>Email</EDMEntityType>
+ <EDMEntitySet>Emails</EDMEntitySet>
+ </JPAEntityType>
+ <JPAEntityType name="AppointmentActivity">
+ <EDMEntityType>Appointment</EDMEntityType>
+ <EDMEntitySet>Appointments</EDMEntitySet>
+ </JPAEntityType>
+ </JPAEntityTypes>
+ <JPAEmbeddableTypes>
+ <JPAEmbeddableType name="Address">
+ <EDMComplexType>AddressInfo</EDMComplexType>
+ <JPAAttributes>
+ <JPAAttribute name="houseNumber">Number</JPAAttribute>
+ <JPAAttribute name="streetName">Street</JPAAttribute>
+ </JPAAttributes>
+ </JPAEmbeddableType>
+ </JPAEmbeddableTypes>
+ </PersistenceUnit>
+</JPAEDMMappingModel>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-web/src/main/webapp/WEB-INF/web.xml
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-web/src/main/webapp/WEB-INF/web.xml b/odata2-jpa-processor/jpa-web/src/main/webapp/WEB-INF/web.xml
new file mode 100644
index 0000000..df2bba0
--- /dev/null
+++ b/odata2-jpa-processor/jpa-web/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+
+<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
+ id="WebApp_ID" version="2.5">
+ <display-name>OData - JPA Reference</display-name>
+ <welcome-file-list>
+ <welcome-file>index.jsp</welcome-file>
+ </welcome-file-list>
+
+ <servlet>
+ <servlet-name>JPARefScenarioServlet</servlet-name>
+ <servlet-class>org.apache.cxf.jaxrs.servlet.CXFNonSpringJaxrsServlet</servlet-class>
+ <init-param>
+ <param-name>javax.ws.rs.Application</param-name>
+ <param-value>org.apache.olingo.odata2.core.rest.app.ODataApplication</param-value>
+ </init-param>
+ <init-param>
+ <param-name>org.apache.olingo.odata2.service.factory</param-name>
+ <param-value>org.apache.olingo.odata2.jpa.processor.ref.web.JPAReferenceServiceFactory</param-value>
+ </init-param>
+ <load-on-startup>1</load-on-startup>
+ </servlet>
+ <servlet-mapping>
+ <servlet-name>JPARefScenarioServlet</servlet-name>
+ <url-pattern>/SalesOrderProcessing.svc/*</url-pattern>
+ </servlet-mapping>
+</web-app>
[30/37] [OLINGO-82] Renamed the project folder name to
odata2-jpa-processor
Posted by ch...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmBaseViewImpl.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmBaseViewImpl.java b/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmBaseViewImpl.java
new file mode 100644
index 0000000..0798487
--- /dev/null
+++ b/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmBaseViewImpl.java
@@ -0,0 +1,101 @@
+/*******************************************************************************
+ * 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 javax.persistence.metamodel.Metamodel;
+
+import org.apache.olingo.odata2.processor.api.jpa.ODataJPAContext;
+import org.apache.olingo.odata2.processor.api.jpa.access.JPAEdmBuilder;
+import org.apache.olingo.odata2.processor.api.jpa.access.JPAEdmMappingModelAccess;
+import org.apache.olingo.odata2.processor.api.jpa.factory.ODataJPAFactory;
+import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmBaseView;
+import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmExtension;
+
+public abstract class JPAEdmBaseViewImpl implements JPAEdmBaseView {
+
+ protected boolean skipDefaultNaming = false;
+ protected String pUnitName = null;
+ protected Metamodel metaModel = null;
+ protected boolean isConsistent = true;
+ protected JPAEdmBuilder builder = null;
+ protected JPAEdmExtension jpaEdmExtension = null;
+ private JPAEdmMappingModelAccess jpaEdmMappingModelAccess = null;
+
+ public JPAEdmBaseViewImpl(final JPAEdmBaseView view) {
+ pUnitName = view.getpUnitName();
+ metaModel = view.getJPAMetaModel();
+ jpaEdmMappingModelAccess = view.getJPAEdmMappingModelAccess();
+ jpaEdmExtension = view.getJPAEdmExtension();
+ skipDefaultNaming = view.isDefaultNamingSkipped();
+ }
+
+ public JPAEdmBaseViewImpl(final ODataJPAContext context) {
+ pUnitName = context.getPersistenceUnitName();
+ metaModel = context.getEntityManagerFactory().getMetamodel();
+ jpaEdmMappingModelAccess =
+ ODataJPAFactory.createFactory().getJPAAccessFactory().getJPAEdmMappingModelAccess(context);
+ jpaEdmExtension = context.getJPAEdmExtension();
+ jpaEdmMappingModelAccess.loadMappingModel();
+ skipDefaultNaming = !context.getDefaultNaming();
+ }
+
+ public JPAEdmBaseViewImpl(final Metamodel metaModel, final String pUnitName) {
+ this.metaModel = metaModel;
+ this.pUnitName = pUnitName;
+ }
+
+ @Override
+ public String getpUnitName() {
+ return pUnitName;
+ }
+
+ @Override
+ public Metamodel getJPAMetaModel() {
+ return metaModel;
+ }
+
+ @Override
+ public boolean isConsistent() {
+ return isConsistent;
+ }
+
+ @Override
+ public void clean() {
+ pUnitName = null;
+ metaModel = null;
+ isConsistent = false;
+ }
+
+ @Override
+ public JPAEdmMappingModelAccess getJPAEdmMappingModelAccess() {
+ return jpaEdmMappingModelAccess;
+
+ }
+
+ @Override
+ public JPAEdmExtension getJPAEdmExtension() {
+ return jpaEdmExtension;
+ }
+
+ @Override
+ public boolean isDefaultNamingSkipped() {
+ return skipDefaultNaming;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmComplexType.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmComplexType.java b/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmComplexType.java
new file mode 100644
index 0000000..ad25a1b
--- /dev/null
+++ b/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmComplexType.java
@@ -0,0 +1,254 @@
+/*******************************************************************************
+ * 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.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import javax.persistence.metamodel.Attribute;
+import javax.persistence.metamodel.EmbeddableType;
+
+import org.apache.olingo.odata2.api.edm.FullQualifiedName;
+import org.apache.olingo.odata2.api.edm.provider.ComplexProperty;
+import org.apache.olingo.odata2.api.edm.provider.ComplexType;
+import org.apache.olingo.odata2.api.edm.provider.Mapping;
+import org.apache.olingo.odata2.api.edm.provider.Property;
+import org.apache.olingo.odata2.api.edm.provider.SimpleProperty;
+import org.apache.olingo.odata2.processor.api.jpa.access.JPAEdmBuilder;
+import org.apache.olingo.odata2.processor.api.jpa.access.JPAEdmMappingModelAccess;
+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.JPAEdmMapping;
+import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmPropertyView;
+import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmSchemaView;
+import org.apache.olingo.odata2.processor.core.jpa.access.model.JPAEdmNameBuilder;
+
+public class JPAEdmComplexType extends JPAEdmBaseViewImpl implements JPAEdmComplexTypeView {
+
+ private JPAEdmSchemaView schemaView;
+ private ComplexType currentComplexType = null;
+ private EmbeddableType<?> currentEmbeddableType = null;
+ private HashMap<String, ComplexType> searchMap = null;
+ private List<ComplexType> consistentComplextTypes = null;
+ private boolean directBuild;
+ private EmbeddableType<?> nestedComplexType = null;
+
+ public JPAEdmComplexType(final JPAEdmSchemaView view) {
+ super(view);
+ schemaView = view;
+ directBuild = true;
+ }
+
+ public JPAEdmComplexType(final JPAEdmSchemaView view, final Attribute<?, ?> complexAttribute) {
+ super(view);
+ schemaView = view;
+ for (EmbeddableType<?> jpaEmbeddable : schemaView.getJPAMetaModel().getEmbeddables()) {
+ if (jpaEmbeddable.getJavaType().getName().equals(complexAttribute.getJavaType().getName())) {
+ nestedComplexType = jpaEmbeddable;
+ break;
+ }
+ }
+ directBuild = false;
+ }
+
+ @Override
+ public JPAEdmBuilder getBuilder() {
+ if (builder == null) {
+ builder = new JPAEdmComplexTypeBuilder();
+ }
+
+ return builder;
+ }
+
+ @Override
+ public ComplexType getEdmComplexType() {
+ return currentComplexType;
+ }
+
+ @Override
+ public ComplexType searchEdmComplexType(final String embeddableTypeName) {
+ return searchMap.get(embeddableTypeName);
+ }
+
+ @Override
+ public EmbeddableType<?> getJPAEmbeddableType() {
+ return currentEmbeddableType;
+ }
+
+ @Override
+ public List<ComplexType> getConsistentEdmComplexTypes() {
+ return consistentComplextTypes;
+ }
+
+ @Override
+ public ComplexType searchEdmComplexType(final FullQualifiedName type) {
+ String name = type.getName();
+ return searchComplexTypeByName(name);
+
+ }
+
+ private ComplexType searchComplexTypeByName(final String name) {
+ for (ComplexType complexType : consistentComplextTypes) {
+ if (null != complexType && null != complexType.getName() && complexType.getName().equals(name)) {
+ return complexType;
+ }
+ }
+
+ return null;
+ }
+
+ @Override
+ public void addJPAEdmCompleTypeView(final JPAEdmComplexTypeView view) {
+ String searchKey = view.getJPAEmbeddableType().getJavaType().getName();
+
+ if (!searchMap.containsKey(searchKey)) {
+ consistentComplextTypes.add(view.getEdmComplexType());
+ searchMap.put(searchKey, view.getEdmComplexType());
+ }
+ }
+
+ @Override
+ public void expandEdmComplexType(final ComplexType complexType, List<Property> expandedList,
+ final String embeddablePropertyName) {
+
+ if (expandedList == null) {
+ expandedList = new ArrayList<Property>();
+ }
+ for (Property property : complexType.getProperties()) {
+ try {
+ SimpleProperty newSimpleProperty = new SimpleProperty();
+ SimpleProperty oldSimpleProperty = (SimpleProperty) property;
+ newSimpleProperty.setAnnotationAttributes(oldSimpleProperty.getAnnotationAttributes());
+ newSimpleProperty.setAnnotationElements(oldSimpleProperty.getAnnotationElements());
+ newSimpleProperty.setCustomizableFeedMappings(oldSimpleProperty.getCustomizableFeedMappings());
+ newSimpleProperty.setDocumentation(oldSimpleProperty.getDocumentation());
+ newSimpleProperty.setFacets(oldSimpleProperty.getFacets());
+ newSimpleProperty.setMimeType(oldSimpleProperty.getMimeType());
+ newSimpleProperty.setName(oldSimpleProperty.getName());
+ newSimpleProperty.setType(oldSimpleProperty.getType());
+ JPAEdmMappingImpl newMapping = new JPAEdmMappingImpl();
+ Mapping mapping = oldSimpleProperty.getMapping();
+ JPAEdmMapping oldMapping = (JPAEdmMapping) mapping;
+ newMapping.setJPAColumnName(oldMapping.getJPAColumnName());
+ newMapping.setInternalName(embeddablePropertyName + "." + mapping.getInternalName());
+ newMapping.setMimeType(mapping.getMimeType());
+ newMapping.setObject(mapping.getObject());
+ newMapping.setJPAType(oldMapping.getJPAType());
+ newSimpleProperty.setMapping(newMapping);
+ expandedList.add(newSimpleProperty);
+ } catch (ClassCastException e) {
+ ComplexProperty complexProperty = (ComplexProperty) property;
+ String name = embeddablePropertyName + "." + complexProperty.getMapping().getInternalName();
+ expandEdmComplexType(searchComplexTypeByName(complexProperty.getName()), expandedList, name);
+ }
+ }
+
+ }
+
+ private class JPAEdmComplexTypeBuilder implements JPAEdmBuilder {
+ /*
+ *
+ * Each call to build method creates a new Complex Type.
+ * The Complex Type is created only if it is not created
+ * earlier. A local buffer is maintained to track the list
+ * of complex types created.
+ *
+ * ************************************************************
+ * Build EDM Complex Type - STEPS
+ * ************************************************************
+ * 1) Fetch list of embeddable types from JPA Model
+ * 2) Search local buffer if there exists already a Complex
+ * type for the embeddable type.
+ * 3) If the complex type was already been built continue with
+ * the next embeddable type, else create new EDM Complex Type.
+ * 4) Create a Property view with Complex Type
+ * 5) Get Property Builder and build the Property with Complex
+ * type.
+ * 6) Set EDM complex type with list of properties built by
+ * the property view
+ * 7) Provide name for EDM complex type.
+ *
+ * ************************************************************
+ * Build EDM Complex Type - STEPS
+ * ************************************************************
+ */
+ @Override
+ public void build() throws ODataJPAModelException, ODataJPARuntimeException {
+ Set<EmbeddableType<?>> embeddables = new HashSet<EmbeddableType<?>>();
+
+ if (consistentComplextTypes == null) {
+ consistentComplextTypes = new ArrayList<ComplexType>();
+ }
+
+ if (searchMap == null) {
+ searchMap = new HashMap<String, ComplexType>();
+ }
+
+ if (directBuild) {
+ embeddables = schemaView.getJPAMetaModel().getEmbeddables();
+ } else {
+ embeddables.add(nestedComplexType);
+ }
+
+ for (EmbeddableType<?> embeddableType : embeddables) {
+
+ currentEmbeddableType = embeddableType;
+ String searchKey = embeddableType.getJavaType().getName();
+
+ if (searchMap.containsKey(searchKey)) {
+ continue;
+ }
+
+ // Check for need to Exclude
+ if (isExcluded(JPAEdmComplexType.this)) {
+ continue;
+ }
+
+ JPAEdmPropertyView propertyView = new JPAEdmProperty(schemaView, JPAEdmComplexType.this);
+ propertyView.getBuilder().build();
+
+ currentComplexType = new ComplexType();
+ currentComplexType.setProperties(propertyView.getEdmPropertyList());
+ JPAEdmNameBuilder.build(JPAEdmComplexType.this);
+
+ searchMap.put(searchKey, currentComplexType);
+ consistentComplextTypes.add(currentComplexType);
+
+ }
+
+ }
+
+ private boolean isExcluded(final JPAEdmComplexType jpaEdmComplexType) {
+
+ JPAEdmMappingModelAccess mappingModelAccess = jpaEdmComplexType.getJPAEdmMappingModelAccess();
+ if (mappingModelAccess != null
+ && mappingModelAccess.isMappingModelExists()
+ && mappingModelAccess.checkExclusionOfJPAEmbeddableType(jpaEdmComplexType.getJPAEmbeddableType()
+ .getJavaType().getSimpleName())) {
+ return true;
+ }
+ return false;
+ }
+
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmEntityContainer.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmEntityContainer.java b/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmEntityContainer.java
new file mode 100644
index 0000000..fee40c2
--- /dev/null
+++ b/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmEntityContainer.java
@@ -0,0 +1,154 @@
+/*******************************************************************************
+ * 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.util.ArrayList;
+import java.util.List;
+
+import org.apache.olingo.odata2.api.edm.provider.EntityContainer;
+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.JPAEdmAssociationSetView;
+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.JPAEdmFunctionImportView;
+import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmSchemaView;
+import org.apache.olingo.odata2.processor.core.jpa.access.model.JPAEdmNameBuilder;
+
+public class JPAEdmEntityContainer extends JPAEdmBaseViewImpl implements JPAEdmEntityContainerView {
+
+ private JPAEdmEntitySetView entitySetView;
+ private JPAEdmSchemaView schemaView;
+ private JPAEdmAssociationSetView associationSetView;
+
+ private EntityContainer currentEntityContainer;
+ private List<EntityContainer> consistentEntityContainerList;
+
+ public JPAEdmEntityContainer(final JPAEdmSchemaView view) {
+ super(view);
+ schemaView = view;
+ }
+
+ @Override
+ public JPAEdmBuilder getBuilder() {
+ if (builder == null) {
+ builder = new JPAEdmEntityContainerBuilder();
+ }
+
+ return builder;
+ }
+
+ @Override
+ public EntityContainer getEdmEntityContainer() {
+ return currentEntityContainer;
+ }
+
+ @Override
+ public List<EntityContainer> getConsistentEdmEntityContainerList() {
+ return consistentEntityContainerList;
+ }
+
+ @Override
+ public JPAEdmEntitySetView getJPAEdmEntitySetView() {
+ return entitySetView;
+ }
+
+ @Override
+ public JPAEdmAssociationSetView getEdmAssociationSetView() {
+ return associationSetView;
+ }
+
+ @Override
+ public void clean() {
+ super.clean();
+ entitySetView = null;
+ associationSetView = null;
+ currentEntityContainer = null;
+ consistentEntityContainerList = null;
+ }
+
+ private class JPAEdmEntityContainerBuilder implements JPAEdmBuilder {
+ /*
+ *
+ * Each call to build method creates a new Entity Container and builds
+ * the entity container with Association Sets and Entity Sets. The newly
+ * created and built entity container is added to the exiting Entity
+ * Container List.
+ *
+ * ************************************************************ Build
+ * EDM Entity Container - STEPS
+ * ************************************************************ 1)
+ * Instantiate New EDM Entity Container 2) Build Name for EDM Entity
+ * Container 2) Create Entity Container List (if does not exists) 3)
+ * Build EDM Entity Set 4) Add EDM Entity Set to EDM Entity Container 6)
+ * Build EDM Association Set 7) Add EDM Association Set to EDM Entity
+ * Container 8) Add EDM Entity Container to the Container List
+ * ************************************************************ Build
+ * EDM Entity Container - STEPS
+ * ************************************************************
+ */
+ @Override
+ public void build() throws ODataJPAModelException, ODataJPARuntimeException {
+
+ currentEntityContainer = new EntityContainer();
+
+ if (consistentEntityContainerList == null) {
+ currentEntityContainer.setDefaultEntityContainer(true);
+ consistentEntityContainerList = new ArrayList<EntityContainer>();
+ }
+
+ entitySetView = new JPAEdmEntitySet(schemaView);
+ entitySetView.getBuilder().build();
+ if (entitySetView.isConsistent()) {
+ currentEntityContainer.setEntitySets(entitySetView.getConsistentEdmEntitySetList());
+ } else {
+ isConsistent = false;
+ return;
+ }
+
+ if (!schemaView.getJPAEdmAssociationView().isConsistent()) {
+ schemaView.getJPAEdmAssociationView().getBuilder().build();
+ }
+
+ associationSetView = new JPAEdmAssociationSet(schemaView);
+ associationSetView.getBuilder().build();
+ if (associationSetView.isConsistent()) {
+ currentEntityContainer.setAssociationSets(associationSetView.getConsistentEdmAssociationSetList());
+ } else {
+ isConsistent = false;
+ return;
+ }
+
+ JPAEdmNameBuilder.build(JPAEdmEntityContainer.this);
+ if (schemaView.getJPAEdmExtension() != null) {
+ JPAEdmFunctionImportView functionImportView = new JPAEdmFunctionImport(schemaView);
+ functionImportView.getBuilder().build();
+ if (functionImportView.getConsistentFunctionImportList() != null) {
+ currentEntityContainer.setFunctionImports(functionImportView.getConsistentFunctionImportList());
+ }
+ }
+
+ consistentEntityContainerList.add(currentEntityContainer);
+ isConsistent = true;
+
+ }
+
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmEntitySet.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmEntitySet.java b/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmEntitySet.java
new file mode 100644
index 0000000..9e5248f
--- /dev/null
+++ b/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmEntitySet.java
@@ -0,0 +1,112 @@
+/*******************************************************************************
+ * 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.util.ArrayList;
+import java.util.List;
+
+import org.apache.olingo.odata2.api.edm.FullQualifiedName;
+import org.apache.olingo.odata2.api.edm.provider.EntitySet;
+import org.apache.olingo.odata2.api.edm.provider.EntityType;
+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.JPAEdmEntitySetView;
+import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmEntityTypeView;
+import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmSchemaView;
+import org.apache.olingo.odata2.processor.core.jpa.access.model.JPAEdmNameBuilder;
+
+public class JPAEdmEntitySet extends JPAEdmBaseViewImpl implements JPAEdmEntitySetView {
+
+ private EntitySet currentEntitySet = null;
+ private List<EntitySet> consistentEntitySetList = null;
+ private JPAEdmEntityTypeView entityTypeView = null;
+ private JPAEdmSchemaView schemaView;
+
+ public JPAEdmEntitySet(final JPAEdmSchemaView view) {
+ super(view);
+ schemaView = view;
+ }
+
+ @Override
+ public JPAEdmBuilder getBuilder() {
+ if (builder == null) {
+ builder = new JPAEdmEntitySetBuilder();
+ }
+
+ return builder;
+ }
+
+ @Override
+ public EntitySet getEdmEntitySet() {
+ return currentEntitySet;
+ }
+
+ @Override
+ public List<EntitySet> getConsistentEdmEntitySetList() {
+ return consistentEntitySetList;
+ }
+
+ @Override
+ public JPAEdmEntityTypeView getJPAEdmEntityTypeView() {
+ return entityTypeView;
+ }
+
+ @Override
+ public void clean() {
+ currentEntitySet = null;
+ consistentEntitySetList = null;
+ entityTypeView = null;
+ isConsistent = false;
+ }
+
+ private class JPAEdmEntitySetBuilder implements JPAEdmBuilder {
+
+ @Override
+ public void build() throws ODataJPAModelException, ODataJPARuntimeException {
+
+ if (consistentEntitySetList == null) {
+ consistentEntitySetList = new ArrayList<EntitySet>();
+ }
+
+ entityTypeView = new JPAEdmEntityType(schemaView);
+ entityTypeView.getBuilder().build();
+
+ if (entityTypeView.isConsistent() && entityTypeView.getConsistentEdmEntityTypes() != null) {
+
+ String nameSpace = schemaView.getEdmSchema().getNamespace();
+ for (EntityType entityType : entityTypeView.getConsistentEdmEntityTypes()) {
+
+ currentEntitySet = new EntitySet();
+ currentEntitySet.setEntityType(new FullQualifiedName(nameSpace, entityType.getName()));
+ JPAEdmNameBuilder.build(JPAEdmEntitySet.this, entityTypeView);
+ consistentEntitySetList.add(currentEntitySet);
+
+ }
+ isConsistent = true;
+ } else {
+ isConsistent = false;
+ return;
+ }
+
+ }
+
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmEntityType.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmEntityType.java b/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmEntityType.java
new file mode 100644
index 0000000..5864a1c
--- /dev/null
+++ b/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmEntityType.java
@@ -0,0 +1,230 @@
+/*******************************************************************************
+ * 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.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.ListIterator;
+import java.util.Set;
+
+import org.apache.olingo.odata2.api.edm.provider.EntityType;
+import org.apache.olingo.odata2.processor.api.jpa.access.JPAEdmBuilder;
+import org.apache.olingo.odata2.processor.api.jpa.access.JPAEdmMappingModelAccess;
+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.JPAEdmEntityTypeView;
+import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmKeyView;
+import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmNavigationPropertyView;
+import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmPropertyView;
+import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmSchemaView;
+import org.apache.olingo.odata2.processor.core.jpa.access.model.JPAEdmNameBuilder;
+
+public class JPAEdmEntityType extends JPAEdmBaseViewImpl implements JPAEdmEntityTypeView {
+
+ private JPAEdmSchemaView schemaView = null;
+ private EntityType currentEdmEntityType = null;
+ private javax.persistence.metamodel.EntityType<?> currentJPAEntityType = null;
+ private EntityTypeList<EntityType> consistentEntityTypes = null;
+
+ private HashMap<String, EntityType> consistentEntityTypeMap;
+
+ public JPAEdmEntityType(final JPAEdmSchemaView view) {
+ super(view);
+ schemaView = view;
+ consistentEntityTypeMap = new HashMap<String, EntityType>();
+ }
+
+ @Override
+ public JPAEdmBuilder getBuilder() {
+ if (builder == null) {
+ builder = new JPAEdmEntityTypeBuilder();
+ }
+
+ return builder;
+ }
+
+ @Override
+ public EntityType getEdmEntityType() {
+ return currentEdmEntityType;
+ }
+
+ @Override
+ public javax.persistence.metamodel.EntityType<?> getJPAEntityType() {
+ return currentJPAEntityType;
+ }
+
+ @Override
+ public List<EntityType> getConsistentEdmEntityTypes() {
+ return consistentEntityTypes;
+ }
+
+ @Override
+ public EntityType searchEdmEntityType(final String jpaEntityTypeName) {
+ return consistentEntityTypeMap.get(jpaEntityTypeName);
+ }
+
+ private class JPAEdmEntityTypeBuilder implements JPAEdmBuilder {
+
+ @Override
+ public void build() throws ODataJPAModelException, ODataJPARuntimeException {
+
+ Set<javax.persistence.metamodel.EntityType<?>> jpaEntityTypes = metaModel.getEntities();
+
+ if (jpaEntityTypes == null || jpaEntityTypes.isEmpty() == true) {
+ return;
+ } else if (consistentEntityTypes == null) {
+ consistentEntityTypes = new EntityTypeList<EntityType>();
+
+ }
+
+ for (javax.persistence.metamodel.EntityType<?> jpaEntityType : jpaEntityTypes) {
+ currentEdmEntityType = new EntityType();
+ currentJPAEntityType = jpaEntityType;
+
+ // Check for need to Exclude
+ if (isExcluded(JPAEdmEntityType.this)) {
+ continue;
+ }
+
+ JPAEdmNameBuilder.build(JPAEdmEntityType.this);
+
+ JPAEdmPropertyView propertyView = new JPAEdmProperty(schemaView);
+ propertyView.getBuilder().build();
+
+ currentEdmEntityType.setProperties(propertyView.getEdmPropertyList());
+ if (propertyView.getJPAEdmNavigationPropertyView() != null) {
+ JPAEdmNavigationPropertyView navPropView = propertyView.getJPAEdmNavigationPropertyView();
+ if (navPropView.getConsistentEdmNavigationProperties() != null
+ && !navPropView.getConsistentEdmNavigationProperties().isEmpty()) {
+ currentEdmEntityType.setNavigationProperties(navPropView.getConsistentEdmNavigationProperties());
+ }
+ }
+ JPAEdmKeyView keyView = propertyView.getJPAEdmKeyView();
+ currentEdmEntityType.setKey(keyView.getEdmKey());
+
+ consistentEntityTypes.add(currentEdmEntityType);
+ consistentEntityTypeMap.put(currentJPAEntityType.getName(), currentEdmEntityType);
+ }
+
+ }
+
+ private boolean isExcluded(final JPAEdmEntityType jpaEdmEntityType) {
+ JPAEdmMappingModelAccess mappingModelAccess = jpaEdmEntityType.getJPAEdmMappingModelAccess();
+ if (mappingModelAccess != null && mappingModelAccess.isMappingModelExists()
+ && mappingModelAccess.checkExclusionOfJPAEntityType(jpaEdmEntityType.getJPAEntityType().getName())) {
+ return true;
+ }
+ return false;
+ }
+
+ }
+
+ private class EntityTypeList<X> extends ArrayList<EntityType> {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 719079109608251592L;
+
+ @Override
+ public Iterator<EntityType> iterator() {
+ return new EntityTypeListIterator<X>(size());
+ }
+
+ }
+
+ private class EntityTypeListIterator<E> implements ListIterator<EntityType> {
+
+ private int size = 0;
+ private int pos = 0;
+
+ public EntityTypeListIterator(final int listSize) {
+ this.size = listSize;
+ }
+
+ @Override
+ public void add(final EntityType e) {
+ consistentEntityTypes.add(e);
+ size++;
+ }
+
+ @Override
+ public boolean hasNext() {
+ if (pos < size) {
+ return true;
+ }
+
+ return false;
+ }
+
+ @Override
+ public boolean hasPrevious() {
+ if (pos > 0) {
+ return true;
+ }
+ return false;
+ }
+
+ @Override
+ public EntityType next() {
+ if (pos < size) {
+ currentEdmEntityType = consistentEntityTypes.get(pos++);
+ return currentEdmEntityType;
+ }
+
+ return null;
+ }
+
+ @Override
+ public int nextIndex() {
+ return pos;
+ }
+
+ @Override
+ public EntityType previous() {
+ if (pos > 0 && pos < size) {
+ currentEdmEntityType = consistentEntityTypes.get(--pos);
+ return currentEdmEntityType;
+ }
+ return null;
+ }
+
+ @Override
+ public int previousIndex() {
+ if (pos > 0) {
+ return pos - 1;
+ }
+
+ return 0;
+ }
+
+ @Override
+ public void remove() {
+ consistentEntityTypes.remove(pos);
+ }
+
+ @Override
+ public void set(final EntityType e) {
+ consistentEntityTypes.set(pos, e);
+ }
+
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmFacets.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmFacets.java b/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmFacets.java
new file mode 100644
index 0000000..61f984f
--- /dev/null
+++ b/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmFacets.java
@@ -0,0 +1,94 @@
+/*******************************************************************************
+ * 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.reflect.AnnotatedElement;
+
+import javax.persistence.Column;
+import javax.persistence.metamodel.Attribute;
+
+import org.apache.olingo.odata2.api.edm.EdmSimpleTypeKind;
+import org.apache.olingo.odata2.api.edm.provider.Facets;
+import org.apache.olingo.odata2.api.edm.provider.SimpleProperty;
+
+public class JPAEdmFacets {
+ public static void setFacets(final Attribute<?, ?> jpaAttribute, final SimpleProperty edmProperty) {
+ EdmSimpleTypeKind edmTypeKind = edmProperty.getType();
+ Facets facets = new Facets();
+ edmProperty.setFacets(facets);
+
+ Column column = null;
+ if (jpaAttribute.getJavaMember() instanceof AnnotatedElement) {
+ column = ((AnnotatedElement) jpaAttribute
+ .getJavaMember()).getAnnotation(Column.class);
+ }
+
+ if (column == null) {
+ return;
+ }
+
+ setNullable(column, edmProperty);
+
+ switch (edmTypeKind) {
+ case Binary:
+ setMaxLength(column, edmProperty);
+ break;
+ case DateTime:
+ setPrecision(column, edmProperty);
+ break;
+ case DateTimeOffset:
+ setPrecision(column, edmProperty);
+ break;
+ case Time:
+ setPrecision(column, edmProperty);
+ break;
+ case Decimal:
+ setPrecision(column, edmProperty);
+ setScale(column, edmProperty);
+ break;
+ case String:
+ setMaxLength(column, edmProperty);
+ break;
+ default:
+ break;
+ }
+ }
+
+ private static void setNullable(final Column column, final SimpleProperty edmProperty) {
+ ((Facets) edmProperty.getFacets()).setNullable(column.nullable());
+ }
+
+ private static void setMaxLength(final Column column, final SimpleProperty edmProperty) {
+ if (column.length() > 0) {
+ ((Facets) edmProperty.getFacets()).setMaxLength(column.length());
+ }
+ }
+
+ private static void setPrecision(final Column column, final SimpleProperty edmProperty) {
+ if (column.precision() > 0) {
+ ((Facets) edmProperty.getFacets()).setPrecision(column.precision());
+ }
+ }
+
+ private static void setScale(final Column column, final SimpleProperty edmProperty) {
+ if (column.scale() > 0) {
+ ((Facets) edmProperty.getFacets()).setScale(column.scale());
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmFunctionImport.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmFunctionImport.java b/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmFunctionImport.java
new file mode 100644
index 0000000..b64f61c
--- /dev/null
+++ b/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmFunctionImport.java
@@ -0,0 +1,331 @@
+/*******************************************************************************
+ * 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.HashMap;
+import java.util.List;
+
+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;
+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.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.JPAEdmEntityTypeView;
+import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmFunctionImportView;
+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;
+
+public class JPAEdmFunctionImport extends JPAEdmBaseViewImpl implements JPAEdmFunctionImportView {
+
+ private List<FunctionImport> consistentFunctionImportList = new ArrayList<FunctionImport>();
+ private JPAEdmBuilder builder = null;
+ private JPAEdmSchemaView schemaView;
+
+ public JPAEdmFunctionImport(final JPAEdmSchemaView view) {
+ super(view);
+ schemaView = view;
+ }
+
+ @Override
+ public JPAEdmBuilder getBuilder() {
+ if (builder == null) {
+ builder = new JPAEdmFunctionImportBuilder();
+ }
+ return builder;
+ }
+
+ @Override
+ public List<FunctionImport> getConsistentFunctionImportList() {
+ return consistentFunctionImportList;
+ }
+
+ protected class JPAEdmFunctionImportBuilder implements JPAEdmBuilder {
+
+ private JPAEdmEntityTypeView jpaEdmEntityTypeView = null;
+ private JPAEdmComplexTypeView jpaEdmComplexTypeView = null;
+ @SuppressWarnings("deprecation")
+ private _JPAEdmFunctionImportBuilder builderDeprecated = new _JPAEdmFunctionImportBuilder();
+
+ @SuppressWarnings("deprecation")
+ @Override
+ public void build() throws ODataJPAModelException, ODataJPARuntimeException {
+
+ HashMap<Class<?>, String[]> customOperations = schemaView.getRegisteredOperations();
+
+ jpaEdmEntityTypeView =
+ schemaView.getJPAEdmEntityContainerView().getJPAEdmEntitySetView().getJPAEdmEntityTypeView();
+ jpaEdmComplexTypeView = schemaView.getJPAEdmComplexTypeView();
+
+ if (customOperations != null) {
+ // Initialize deprecated Builder
+ builderDeprecated.setJPAEdmComplexTypeView(jpaEdmComplexTypeView);
+ builderDeprecated.setJPAEdmEntityTypeView(jpaEdmEntityTypeView);
+ builderDeprecated.setSchemaView(schemaView);
+
+ for (Class<?> clazz : customOperations.keySet()) {
+
+ String[] operationNames = customOperations.get(clazz);
+ Method[] methods = clazz.getMethods();
+ Method method = null;
+
+ int length = 0;
+ if (operationNames != null) {
+ length = operationNames.length;
+ } else {
+ length = methods.length;
+ }
+
+ boolean found = false;
+ for (int i = 0; i < length; i++) {
+
+ try {
+ if (operationNames != null) {
+ for (Method method2 : methods) {
+ if (method2.getName().equals(operationNames[i])) {
+ found = true;
+ method = method2;
+ break;
+ }
+ }
+ if (found == true) {
+ found = false;
+ } else {
+ continue;
+ }
+ } else {
+ method = methods[i];
+ }
+
+ FunctionImport functionImport = buildFunctionImport(method);
+ if (functionImport != null) {
+ consistentFunctionImportList.add(functionImport);
+ }
+
+ } catch (SecurityException e) {
+ throw ODataJPAModelException.throwException(ODataJPAModelException.GENERAL, e);
+ }
+ }
+ }
+ }
+ }
+
+ @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) {
+ 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 (edmAnnotationFunctionImport.name().equals("")) {
+ functionImport.setName(method.getName());
+ } else {
+ functionImport.setName(edmAnnotationFunctionImport.name());
+ }
+
+ JPAEdmMapping mapping = new JPAEdmMappingImpl();
+ ((Mapping) mapping).setInternalName(method.getName());
+ mapping.setJPAType(method.getDeclaringClass());
+ functionImport.setMapping((Mapping) mapping);
+
+ functionImport.setHttpMethod(edmAnnotationFunctionImport.httpMethod().name().toString());
+
+ buildEdmReturnType(functionImport, method, edmAnnotationFunctionImport);
+ buildEdmParameter(functionImport, method);
+
+ return functionImport;
+ }
+ return null;
+ }
+
+ 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>();
+ JPAEdmMapping mapping = null;
+ int j = 0;
+ for (Annotation[] annotationArr : annotations) {
+ Class<?> parameterType = parameterTypes[j++];
+
+ for (Annotation element : annotationArr) {
+ 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
+ .getDeclaringClass().getName(), method.getName()), null);
+ } else {
+ functionImportParameter.setName(annotation.name());
+ }
+
+ functionImportParameter.setType(JPATypeConvertor.convertToEdmSimpleType(parameterType, null));
+
+ 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 buildEdmReturnType(final FunctionImport functionImport, final Method method,
+ final EdmFunctionImport edmAnnotationFunctionImport) throws ODataJPAModelException {
+ ReturnType returnType = edmAnnotationFunctionImport.returnType();
+
+ if (returnType != null) {
+ org.apache.olingo.odata2.api.edm.provider.ReturnType functionReturnType =
+ new org.apache.olingo.odata2.api.edm.provider.ReturnType();
+
+ if (returnType.isCollection()) {
+ functionReturnType.setMultiplicity(EdmMultiplicity.MANY);
+ } else {
+ functionReturnType.setMultiplicity(EdmMultiplicity.ONE);
+ }
+
+ if (returnType.type() == ReturnType.Type.ENTITY) {
+ String entitySet = edmAnnotationFunctionImport.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.type()) {
+ case ENTITY:
+ EntityType edmEntityType = null;
+ if (returnType.isCollection() == false) {
+ edmEntityType = jpaEdmEntityTypeView.searchEdmEntityType(methodReturnType.getSimpleName());
+ } else {
+ 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 SIMPLE:
+ EdmSimpleTypeKind edmSimpleTypeKind = JPATypeConvertor.convertToEdmSimpleType(methodReturnType, null);
+ functionReturnType.setTypeName(edmSimpleTypeKind.getFullQualifiedName());
+
+ break;
+ case COMPLEX:
+ ComplexType complexType = null;
+ if (returnType.isCollection() == false) {
+ complexType = jpaEdmComplexTypeView.searchEdmComplexType(methodReturnType.getName());
+ } else {
+ 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/1b479e6c/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmKey.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmKey.java b/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmKey.java
new file mode 100644
index 0000000..15cd26e
--- /dev/null
+++ b/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmKey.java
@@ -0,0 +1,129 @@
+/*******************************************************************************
+ * 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.util.ArrayList;
+import java.util.List;
+
+import org.apache.olingo.odata2.api.edm.provider.ComplexProperty;
+import org.apache.olingo.odata2.api.edm.provider.ComplexType;
+import org.apache.olingo.odata2.api.edm.provider.Facets;
+import org.apache.olingo.odata2.api.edm.provider.Key;
+import org.apache.olingo.odata2.api.edm.provider.Property;
+import org.apache.olingo.odata2.api.edm.provider.PropertyRef;
+import org.apache.olingo.odata2.api.edm.provider.SimpleProperty;
+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.model.JPAEdmComplexTypeView;
+import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmKeyView;
+import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmPropertyView;
+
+public class JPAEdmKey extends JPAEdmBaseViewImpl implements JPAEdmKeyView {
+
+ private JPAEdmPropertyView propertyView;
+ private JPAEdmComplexTypeView complexTypeView = null;
+ private boolean isBuildModeComplexType = false;
+ private Key key;
+
+ public JPAEdmKey(final JPAEdmProperty view) {
+ super(view);
+ propertyView = view;
+ }
+
+ public JPAEdmKey(final JPAEdmComplexTypeView complexTypeView, final JPAEdmPropertyView propertyView) {
+ super(complexTypeView);
+ this.propertyView = propertyView;
+ this.complexTypeView = complexTypeView;
+ isBuildModeComplexType = true;
+ }
+
+ @Override
+ public JPAEdmBuilder getBuilder() {
+ if (builder == null) {
+ builder = new JPAEdmKeyBuider();
+ }
+
+ return builder;
+ }
+
+ @Override
+ public Key getEdmKey() {
+ return key;
+ }
+
+ private class JPAEdmKeyBuider implements JPAEdmBuilder {
+
+ @Override
+ public void build() throws ODataJPAModelException {
+
+ List<PropertyRef> propertyRefList = null;
+ if (key == null) {
+ key = new Key();
+ }
+
+ if (key.getKeys() == null) {
+ propertyRefList = new ArrayList<PropertyRef>();
+ key.setKeys(propertyRefList);
+ } else {
+ propertyRefList = key.getKeys();
+ }
+
+ if (isBuildModeComplexType) {
+ ComplexType complexType =
+ complexTypeView.searchEdmComplexType(propertyView.getJPAAttribute().getJavaType().getName());
+ normalizeComplexKey(complexType, propertyRefList);
+ } else {
+ PropertyRef propertyRef = new PropertyRef();
+ propertyRef.setName(propertyView.getEdmSimpleProperty().getName());
+ Facets facets = (Facets) propertyView.getEdmSimpleProperty().getFacets();
+ if (facets == null) {
+ propertyView.getEdmSimpleProperty().setFacets(new Facets().setNullable(false));
+ } else {
+ facets.setNullable(false);
+ }
+ propertyRefList.add(propertyRef);
+ }
+
+ }
+
+ // TODO think how to stop the recursion if A includes B and B includes A!!!!!!
+ public void normalizeComplexKey(final ComplexType complexType, final List<PropertyRef> propertyRefList) {
+ for (Property property : complexType.getProperties()) {
+ try {
+
+ SimpleProperty simpleProperty = (SimpleProperty) property;
+ Facets facets = (Facets) simpleProperty.getFacets();
+ if (facets == null) {
+ simpleProperty.setFacets(new Facets().setNullable(false));
+ } else {
+ facets.setNullable(false);
+ }
+ PropertyRef propertyRef = new PropertyRef();
+ propertyRef.setName(simpleProperty.getName());
+ propertyRefList.add(propertyRef);
+
+ } catch (ClassCastException e) {
+ ComplexProperty complexProperty = (ComplexProperty) property;
+ normalizeComplexKey(complexTypeView.searchEdmComplexType(complexProperty.getType()), propertyRefList);
+ }
+
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmMappingImpl.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmMappingImpl.java b/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmMappingImpl.java
new file mode 100644
index 0000000..99d9f5f
--- /dev/null
+++ b/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmMappingImpl.java
@@ -0,0 +1,51 @@
+/*******************************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ ******************************************************************************/
+package org.apache.olingo.odata2.processor.core.jpa.model;
+
+import org.apache.olingo.odata2.api.edm.provider.Mapping;
+import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmMapping;
+
+public class JPAEdmMappingImpl extends Mapping implements JPAEdmMapping {
+
+ private String columnName = null;
+ private Class<?> type = null;
+
+ @Override
+ public void setJPAColumnName(final String name) {
+ columnName = name;
+
+ }
+
+ @Override
+ public String getJPAColumnName() {
+ return columnName;
+ }
+
+ @Override
+ public void setJPAType(final Class<?> type) {
+ this.type = type;
+
+ }
+
+ @Override
+ public Class<?> getJPAType() {
+ return type;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmModel.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmModel.java b/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmModel.java
new file mode 100644
index 0000000..fac5614
--- /dev/null
+++ b/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmModel.java
@@ -0,0 +1,65 @@
+/*******************************************************************************
+ * 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 javax.persistence.metamodel.Metamodel;
+
+import org.apache.olingo.odata2.processor.api.jpa.ODataJPAContext;
+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.JPAEdmModelView;
+import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmSchemaView;
+
+public class JPAEdmModel extends JPAEdmBaseViewImpl implements JPAEdmModelView {
+
+ protected JPAEdmSchemaView schemaView;
+
+ public JPAEdmModel(final Metamodel metaModel, final String pUnitName) {
+ super(metaModel, pUnitName);
+ }
+
+ public JPAEdmModel(final ODataJPAContext ctx) {
+ super(ctx);
+ }
+
+ @Override
+ public JPAEdmSchemaView getEdmSchemaView() {
+ return schemaView;
+ }
+
+ @Override
+ public JPAEdmBuilder getBuilder() {
+ if (builder == null) {
+ builder = new JPAEdmModelBuilder();
+ }
+
+ return builder;
+ }
+
+ private class JPAEdmModelBuilder implements JPAEdmBuilder {
+
+ @Override
+ public void build() throws ODataJPAModelException, ODataJPARuntimeException {
+ schemaView = new JPAEdmSchema(JPAEdmModel.this);
+ schemaView.getBuilder().build();
+ }
+
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmNavigationProperty.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmNavigationProperty.java b/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmNavigationProperty.java
new file mode 100644
index 0000000..4757c9a
--- /dev/null
+++ b/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmNavigationProperty.java
@@ -0,0 +1,98 @@
+/*******************************************************************************
+ * 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.util.ArrayList;
+import java.util.List;
+
+import org.apache.olingo.odata2.api.edm.provider.NavigationProperty;
+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.model.JPAEdmAssociationView;
+import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmNavigationPropertyView;
+import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmPropertyView;
+import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmSchemaView;
+import org.apache.olingo.odata2.processor.core.jpa.access.model.JPAEdmNameBuilder;
+
+public class JPAEdmNavigationProperty extends JPAEdmBaseViewImpl implements JPAEdmNavigationPropertyView {
+
+ private JPAEdmAssociationView associationView = null;
+ private NavigationProperty currentNavigationProperty = null;
+ private JPAEdmPropertyView propertyView = null;
+ private List<NavigationProperty> consistentNavigationProperties = null;
+ private int count;
+
+ public JPAEdmNavigationProperty(final JPAEdmAssociationView associationView, final JPAEdmPropertyView propertyView,
+ final int countNumber) {
+ super(associationView);
+ this.associationView = associationView;
+ this.propertyView = propertyView;
+ count = countNumber;
+ if (consistentNavigationProperties == null) {
+ consistentNavigationProperties = new ArrayList<NavigationProperty>();
+ }
+ }
+
+ public JPAEdmNavigationProperty(final JPAEdmSchemaView schemaView) {
+ super(schemaView);
+ consistentNavigationProperties = new ArrayList<NavigationProperty>();
+
+ }
+
+ @Override
+ public JPAEdmBuilder getBuilder() {
+ if (builder == null) {
+ builder = new JPAEdmNavigationPropertyBuilder();
+ }
+
+ return builder;
+ }
+
+ private class JPAEdmNavigationPropertyBuilder implements JPAEdmBuilder {
+
+ @Override
+ public void build() throws ODataJPAModelException {
+
+ currentNavigationProperty = new NavigationProperty();
+ JPAEdmNameBuilder.build(associationView, propertyView, JPAEdmNavigationProperty.this, skipDefaultNaming, count);
+ consistentNavigationProperties.add(currentNavigationProperty);
+ }
+
+ }
+
+ @Override
+ public NavigationProperty getEdmNavigationProperty() {
+ return currentNavigationProperty;
+ }
+
+ @Override
+ public List<NavigationProperty> getConsistentEdmNavigationProperties() {
+ return consistentNavigationProperties;
+ }
+
+ @Override
+ public void addJPAEdmNavigationPropertyView(final JPAEdmNavigationPropertyView view) {
+ if (view != null && view.isConsistent()) {
+ currentNavigationProperty = view.getEdmNavigationProperty();
+ consistentNavigationProperties.add(currentNavigationProperty);
+
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmProperty.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmProperty.java b/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmProperty.java
new file mode 100644
index 0000000..b34a71d
--- /dev/null
+++ b/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmProperty.java
@@ -0,0 +1,378 @@
+/*******************************************************************************
+ * 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.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import javax.persistence.metamodel.Attribute;
+import javax.persistence.metamodel.Attribute.PersistentAttributeType;
+import javax.persistence.metamodel.PluralAttribute;
+import javax.persistence.metamodel.SingularAttribute;
+
+import org.apache.olingo.odata2.api.edm.EdmSimpleTypeKind;
+import org.apache.olingo.odata2.api.edm.FullQualifiedName;
+import org.apache.olingo.odata2.api.edm.provider.ComplexProperty;
+import org.apache.olingo.odata2.api.edm.provider.ComplexType;
+import org.apache.olingo.odata2.api.edm.provider.Property;
+import org.apache.olingo.odata2.api.edm.provider.SimpleProperty;
+import org.apache.olingo.odata2.processor.api.jpa.access.JPAEdmBuilder;
+import org.apache.olingo.odata2.processor.api.jpa.access.JPAEdmMappingModelAccess;
+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.JPAEdmAssociationEndView;
+import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmAssociationView;
+import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmComplexPropertyView;
+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.JPAEdmKeyView;
+import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmNavigationPropertyView;
+import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmPropertyView;
+import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmReferentialConstraintView;
+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;
+
+public class JPAEdmProperty extends JPAEdmBaseViewImpl implements
+ JPAEdmPropertyView, JPAEdmComplexPropertyView {
+
+ private JPAEdmSchemaView schemaView;
+ private JPAEdmEntityTypeView entityTypeView;
+ private JPAEdmComplexTypeView complexTypeView;
+ private JPAEdmNavigationPropertyView navigationPropertyView = null;
+
+ private JPAEdmKeyView keyView;
+ private List<Property> properties;
+ private SimpleProperty currentSimpleProperty = null;
+ private ComplexProperty currentComplexProperty = null;
+ private Attribute<?, ?> currentAttribute;
+ private boolean isBuildModeComplexType;
+ private Map<String, Integer> associationCount;
+
+ public JPAEdmProperty(final JPAEdmSchemaView view) {
+ super(view);
+ schemaView = view;
+ entityTypeView = schemaView.getJPAEdmEntityContainerView()
+ .getJPAEdmEntitySetView().getJPAEdmEntityTypeView();
+ complexTypeView = schemaView.getJPAEdmComplexTypeView();
+ navigationPropertyView = new JPAEdmNavigationProperty(schemaView);
+ isBuildModeComplexType = false;
+ associationCount = new HashMap<String, Integer>();
+ }
+
+ public JPAEdmProperty(final JPAEdmSchemaView schemaView,
+ final JPAEdmComplexTypeView view) {
+ super(view);
+ this.schemaView = schemaView;
+ complexTypeView = view;
+ isBuildModeComplexType = true;
+ }
+
+ @Override
+ public JPAEdmBuilder getBuilder() {
+ if (builder == null) {
+ builder = new JPAEdmPropertyBuilder();
+ }
+
+ return builder;
+ }
+
+ @Override
+ public List<Property> getEdmPropertyList() {
+ return properties;
+ }
+
+ @Override
+ public JPAEdmKeyView getJPAEdmKeyView() {
+ return keyView;
+ }
+
+ @Override
+ public SimpleProperty getEdmSimpleProperty() {
+ return currentSimpleProperty;
+ }
+
+ @Override
+ public Attribute<?, ?> getJPAAttribute() {
+ return currentAttribute;
+ }
+
+ @Override
+ public ComplexProperty getEdmComplexProperty() {
+ return currentComplexProperty;
+ }
+
+ @Override
+ public JPAEdmNavigationPropertyView getJPAEdmNavigationPropertyView() {
+ return navigationPropertyView;
+ }
+
+ private class JPAEdmPropertyBuilder implements JPAEdmBuilder {
+ /*
+ *
+ * Each call to build method creates a new EDM Property List.
+ * The Property List can be created either by an Entity type or
+ * ComplexType. The flag isBuildModeComplexType tells if the
+ * Properties are built for complex type or for Entity Type.
+ *
+ * While Building Properties Associations are built. However
+ * the associations thus built does not contain Referential
+ * constraint. Associations thus built only contains
+ * information about Referential constraints. Adding of
+ * referential constraints to Associations is the taken care
+ * by Schema.
+ *
+ * Building Properties is divided into four parts
+ * A) Building Simple Properties
+ * B) Building Complex Properties
+ * C) Building Associations
+ * D) Building Navigation Properties
+ *
+ * ************************************************************
+ * Build EDM Schema - STEPS
+ * ************************************************************
+ * A) Building Simple Properties:
+ *
+ * 1) Fetch JPA Attribute List from
+ * A) Complex Type
+ * B) Entity Type
+ * depending on isBuildModeComplexType.
+ * B) Building Complex Properties
+ * C) Building Associations
+ * D) Building Navigation Properties
+ *
+ * ************************************************************
+ * Build EDM Schema - STEPS
+ * ************************************************************
+ */
+ @Override
+ public void build() throws ODataJPAModelException, ODataJPARuntimeException {
+
+ JPAEdmBuilder keyViewBuilder = null;
+
+ properties = new ArrayList<Property>();
+
+ List<Attribute<?, ?>> jpaAttributes = null;
+ String currentEntityName = null;
+ String targetEntityName = null;
+ String entityTypeName = null;
+ if (isBuildModeComplexType) {
+ jpaAttributes = sortInAscendingOrder(complexTypeView.getJPAEmbeddableType()
+ .getAttributes());
+ entityTypeName = complexTypeView.getJPAEmbeddableType().getJavaType()
+ .getSimpleName();
+ } else {
+ jpaAttributes = sortInAscendingOrder(entityTypeView.getJPAEntityType()
+ .getAttributes());
+ entityTypeName = entityTypeView.getJPAEntityType().getName();
+ }
+
+ for (Object jpaAttribute : jpaAttributes) {
+ currentAttribute = (Attribute<?, ?>) jpaAttribute;
+
+ // Check for need to Exclude
+ if (isExcluded((JPAEdmPropertyView) JPAEdmProperty.this, entityTypeName, currentAttribute.getName())) {
+ continue;
+ }
+
+ PersistentAttributeType attributeType = currentAttribute
+ .getPersistentAttributeType();
+
+ switch (attributeType) {
+ case BASIC:
+
+ currentSimpleProperty = new SimpleProperty();
+ JPAEdmNameBuilder
+ .build((JPAEdmPropertyView) JPAEdmProperty.this, isBuildModeComplexType, skipDefaultNaming);
+
+ EdmSimpleTypeKind simpleTypeKind = JPATypeConvertor
+ .convertToEdmSimpleType(currentAttribute
+ .getJavaType(), currentAttribute);
+
+ currentSimpleProperty.setType(simpleTypeKind);
+ JPAEdmFacets.setFacets(currentAttribute, currentSimpleProperty);
+
+ properties.add(currentSimpleProperty);
+
+ if (((SingularAttribute<?, ?>) currentAttribute).isId()) {
+ if (keyView == null) {
+ keyView = new JPAEdmKey(JPAEdmProperty.this);
+ keyViewBuilder = keyView.getBuilder();
+ }
+
+ keyViewBuilder.build();
+ }
+
+ break;
+ case EMBEDDED:
+ ComplexType complexType = complexTypeView
+ .searchEdmComplexType(currentAttribute.getJavaType().getName());
+
+ if (complexType == null) {
+ JPAEdmComplexTypeView complexTypeViewLocal = new JPAEdmComplexType(
+ schemaView, currentAttribute);
+ complexTypeViewLocal.getBuilder().build();
+ complexType = complexTypeViewLocal.getEdmComplexType();
+ complexTypeView.addJPAEdmCompleTypeView(complexTypeViewLocal);
+
+ }
+
+ if (isBuildModeComplexType == false
+ && entityTypeView.getJPAEntityType().getIdType()
+ .getJavaType()
+ .equals(currentAttribute.getJavaType())) {
+
+ if (keyView == null) {
+ keyView = new JPAEdmKey(complexTypeView,
+ JPAEdmProperty.this);
+ }
+ keyView.getBuilder().build();
+ complexTypeView.expandEdmComplexType(complexType, properties, currentAttribute.getName());
+ } else {
+ currentComplexProperty = new ComplexProperty();
+ if (isBuildModeComplexType) {
+ JPAEdmNameBuilder
+ .build((JPAEdmComplexPropertyView) JPAEdmProperty.this,
+ complexTypeView.getJPAEmbeddableType().getJavaType().getSimpleName());
+ } else {
+ JPAEdmNameBuilder
+ .build((JPAEdmComplexPropertyView) JPAEdmProperty.this,
+ JPAEdmProperty.this, skipDefaultNaming);
+ }
+ currentComplexProperty.setType(new FullQualifiedName(
+ schemaView.getEdmSchema().getNamespace(),
+ complexType.getName()));
+
+ properties.add(currentComplexProperty);
+ List<String> nonKeyComplexTypes = schemaView.getNonKeyComplexTypeList();
+ if (!nonKeyComplexTypes.contains(currentComplexProperty.getType().getName()))
+ {
+ schemaView.addNonKeyComplexName(currentComplexProperty.getType().getName());
+ }
+ }
+
+ break;
+ case MANY_TO_MANY:
+ case ONE_TO_MANY:
+ case ONE_TO_ONE:
+ case MANY_TO_ONE:
+
+ JPAEdmAssociationEndView associationEndView = new JPAEdmAssociationEnd(entityTypeView, JPAEdmProperty.this);
+ associationEndView.getBuilder().build();
+ JPAEdmAssociationView associationView = schemaView.getJPAEdmAssociationView();
+ if (associationView.searchAssociation(associationEndView) == null) {
+ int count = associationView.getNumberOfAssociationsWithSimilarEndPoints(associationEndView);
+ JPAEdmAssociationView associationViewLocal =
+ new JPAEdmAssociation(associationEndView, entityTypeView, JPAEdmProperty.this, count);
+ associationViewLocal.getBuilder().build();
+ associationView.addJPAEdmAssociationView(associationViewLocal, associationEndView);
+ }
+
+ JPAEdmReferentialConstraintView refConstraintView = new JPAEdmReferentialConstraint(
+ associationView, entityTypeView, JPAEdmProperty.this);
+ refConstraintView.getBuilder().build();
+
+ if (refConstraintView.isExists()) {
+ associationView.addJPAEdmRefConstraintView(refConstraintView);
+ }
+
+ if (navigationPropertyView == null) {
+ navigationPropertyView = new JPAEdmNavigationProperty(schemaView);
+ }
+ currentEntityName = entityTypeView.getJPAEntityType().getName();
+
+ if (currentAttribute.isCollection()) {
+ targetEntityName = ((PluralAttribute<?, ?, ?>) currentAttribute).getElementType().getJavaType()
+ .getSimpleName();
+ } else {
+ targetEntityName = currentAttribute.getJavaType().getSimpleName();
+ }
+ Integer sequenceNumber = associationCount.get(currentEntityName + targetEntityName);
+ if (sequenceNumber == null) {
+ sequenceNumber = new Integer(1);
+ } else {
+ sequenceNumber = new Integer(sequenceNumber.intValue() + 1);
+ }
+ associationCount.put(currentEntityName + targetEntityName, sequenceNumber);
+ JPAEdmNavigationPropertyView localNavigationPropertyView =
+ new JPAEdmNavigationProperty(associationView, JPAEdmProperty.this, sequenceNumber.intValue());
+ localNavigationPropertyView.getBuilder().build();
+ navigationPropertyView.addJPAEdmNavigationPropertyView(localNavigationPropertyView);
+ break;
+ default:
+ break;
+ }
+ }
+
+ }
+
+ @SuppressWarnings("rawtypes")
+ private List<Attribute<?, ?>> sortInAscendingOrder(final Set<?> jpaAttributes) {
+ List<Attribute<?, ?>> jpaAttributeList = new ArrayList<Attribute<?, ?>>();
+ Iterator itr = null;
+ Attribute<?, ?> smallestJpaAttribute;
+ Attribute<?, ?> currentJpaAttribute;
+ while (!jpaAttributes.isEmpty()) {
+ itr = jpaAttributes.iterator();
+ smallestJpaAttribute = (Attribute<?, ?>) itr.next();
+ while (itr.hasNext()) {
+ currentJpaAttribute = (Attribute<?, ?>) itr.next();
+ if (smallestJpaAttribute.getName().compareTo(currentJpaAttribute.getName()) > 0) {
+ smallestJpaAttribute = currentJpaAttribute;
+ }
+ }
+ jpaAttributeList.add(smallestJpaAttribute);
+ jpaAttributes.remove(smallestJpaAttribute);
+ }
+ return jpaAttributeList;
+ }
+ }
+
+ @Override
+ public JPAEdmEntityTypeView getJPAEdmEntityTypeView() {
+ return entityTypeView;
+ }
+
+ @Override
+ public JPAEdmComplexTypeView getJPAEdmComplexTypeView() {
+ return complexTypeView;
+ }
+
+ private boolean isExcluded(final JPAEdmPropertyView jpaEdmPropertyView, final String jpaEntityTypeName,
+ final String jpaAttributeName) {
+ JPAEdmMappingModelAccess mappingModelAccess = jpaEdmPropertyView
+ .getJPAEdmMappingModelAccess();
+ boolean isExcluded = false;
+ if (mappingModelAccess != null && mappingModelAccess.isMappingModelExists()) {
+ // Exclusion of a simple property in a complex type
+ if (isBuildModeComplexType
+ && mappingModelAccess.checkExclusionOfJPAEmbeddableAttributeType(jpaEntityTypeName, jpaAttributeName)
+ // Exclusion of a simple property of an Entity Type
+ || (!isBuildModeComplexType && mappingModelAccess.checkExclusionOfJPAAttributeType(jpaEntityTypeName,
+ jpaAttributeName))) {
+ isExcluded = true;
+ }
+ }
+ return isExcluded;
+ }
+}
[13/37] [OLINGO-82] Renamed the project folder name to
odata2-jpa-processor
Posted by ch...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/exception/ODataJPAMessageServiceDefault.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/exception/ODataJPAMessageServiceDefault.java b/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/exception/ODataJPAMessageServiceDefault.java
deleted file mode 100644
index d7f3964..0000000
--- a/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/exception/ODataJPAMessageServiceDefault.java
+++ /dev/null
@@ -1,122 +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.exception;
-
-import java.util.Arrays;
-import java.util.Formatter;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-import java.util.MissingFormatArgumentException;
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
-
-import org.apache.olingo.odata2.api.exception.MessageReference;
-import org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPAMessageService;
-import org.apache.olingo.odata2.processor.core.jpa.ODataJPAContextImpl;
-
-public class ODataJPAMessageServiceDefault implements ODataJPAMessageService {
-
- private static final String BUNDLE_NAME = "jpaprocessor_msg"; //$NON-NLS-1$
- private static final Map<Locale, ODataJPAMessageService> LOCALE_2_MESSAGE_SERVICE =
- new HashMap<Locale, ODataJPAMessageService>();
- private static final ResourceBundle defaultResourceBundle = ResourceBundle.getBundle(BUNDLE_NAME);
- private final ResourceBundle resourceBundle;
- private final Locale lanLocale;
-
- @Override
- public String getLocalizedMessage(final MessageReference context, final Throwable exception) {
-
- Object[] contentAsArray = context.getContent().toArray(new Object[0]);
-
- if (contentAsArray.length == 0 && exception != null) {
- contentAsArray = new Object[2];
- contentAsArray[0] = exception.getStackTrace()[1].getClassName();
- contentAsArray[1] = exception.getMessage();
- }
- String value = null;
- String key = context.getKey();
-
- try {
- value = getMessage(key);
- StringBuilder builder = new StringBuilder();
- Formatter f = null;
- if (lanLocale == null) {
- f = new Formatter();
- } else {
- f = new Formatter(builder, lanLocale);
- }
- f.format(value, contentAsArray);
- f.close();
- return builder.toString();
-
- } catch (MissingResourceException e) {
- return "Missing message for key '" + key + "'!";
- } catch (MissingFormatArgumentException e) {
- return "Missing replacement for place holder in value '" + value + "' for following arguments '"
- + Arrays.toString(contentAsArray) + "'!";
- }
- }
-
- private ODataJPAMessageServiceDefault(final ResourceBundle resourceBundle, final Locale locale) {
- this.resourceBundle = resourceBundle;
- lanLocale = locale;
- }
-
- public static ODataJPAMessageService getInstance(final Locale locale) {
-
- Locale acceptedLocale = Locale.ENGLISH;
- if ((ODataJPAContextImpl.getContextInThreadLocal() != null)
- && (ODataJPAContextImpl.getContextInThreadLocal().getAcceptableLanguages() != null)) {
-
- List<Locale> acceptedLanguages = ODataJPAContextImpl.getContextInThreadLocal().getAcceptableLanguages();
-
- Iterator<Locale> itr = acceptedLanguages.iterator();
-
- while (itr.hasNext()) {
-
- Locale tempLocale = itr.next();
- if (ResourceBundle.getBundle(BUNDLE_NAME, tempLocale).getLocale().equals(tempLocale)) {
- acceptedLocale = tempLocale;
- break;
- }
- }
- }
-
- ODataJPAMessageService messagesInstance = LOCALE_2_MESSAGE_SERVICE.get(acceptedLocale);
- if (messagesInstance == null) {
- ResourceBundle resourceBundle = ResourceBundle.getBundle(BUNDLE_NAME, acceptedLocale);
-
- if (resourceBundle != null) {
- messagesInstance = new ODataJPAMessageServiceDefault(resourceBundle, acceptedLocale);
- LOCALE_2_MESSAGE_SERVICE.put(acceptedLocale, messagesInstance);
- } else if (defaultResourceBundle != null) {
- messagesInstance = new ODataJPAMessageServiceDefault(defaultResourceBundle, null);
- }
-
- }
- return messagesInstance;
- }
-
- private String getMessage(final String key) {
- return resourceBundle.getString(key);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/factory/ODataJPAFactoryImpl.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/factory/ODataJPAFactoryImpl.java b/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/factory/ODataJPAFactoryImpl.java
deleted file mode 100644
index 2b14f9d..0000000
--- a/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/factory/ODataJPAFactoryImpl.java
+++ /dev/null
@@ -1,237 +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.factory;
-
-import java.util.Locale;
-
-import org.apache.olingo.odata2.api.edm.provider.EdmProvider;
-import org.apache.olingo.odata2.api.processor.ODataSingleProcessor;
-import org.apache.olingo.odata2.processor.api.jpa.ODataJPAContext;
-import org.apache.olingo.odata2.processor.api.jpa.access.JPAEdmMappingModelAccess;
-import org.apache.olingo.odata2.processor.api.jpa.access.JPAMethodContext.JPAMethodContextBuilder;
-import org.apache.olingo.odata2.processor.api.jpa.access.JPAProcessor;
-import org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPAMessageService;
-import org.apache.olingo.odata2.processor.api.jpa.factory.JPAAccessFactory;
-import org.apache.olingo.odata2.processor.api.jpa.factory.JPQLBuilderFactory;
-import org.apache.olingo.odata2.processor.api.jpa.factory.ODataJPAAccessFactory;
-import org.apache.olingo.odata2.processor.api.jpa.factory.ODataJPAFactory;
-import org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLContext.JPQLContextBuilder;
-import org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLContextType;
-import org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLContextView;
-import org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLStatement.JPQLStatementBuilder;
-import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmModelView;
-import org.apache.olingo.odata2.processor.core.jpa.ODataJPAContextImpl;
-import org.apache.olingo.odata2.processor.core.jpa.ODataJPAProcessorDefault;
-import org.apache.olingo.odata2.processor.core.jpa.access.data.JPAFunctionContext;
-import org.apache.olingo.odata2.processor.core.jpa.access.data.JPAProcessorImpl;
-import org.apache.olingo.odata2.processor.core.jpa.access.model.JPAEdmMappingModelService;
-import org.apache.olingo.odata2.processor.core.jpa.edm.ODataJPAEdmProvider;
-import org.apache.olingo.odata2.processor.core.jpa.exception.ODataJPAMessageServiceDefault;
-import org.apache.olingo.odata2.processor.core.jpa.jpql.JPQLJoinSelectContext;
-import org.apache.olingo.odata2.processor.core.jpa.jpql.JPQLJoinSelectSingleContext;
-import org.apache.olingo.odata2.processor.core.jpa.jpql.JPQLJoinSelectSingleStatementBuilder;
-import org.apache.olingo.odata2.processor.core.jpa.jpql.JPQLJoinStatementBuilder;
-import org.apache.olingo.odata2.processor.core.jpa.jpql.JPQLSelectContext;
-import org.apache.olingo.odata2.processor.core.jpa.jpql.JPQLSelectSingleContext;
-import org.apache.olingo.odata2.processor.core.jpa.jpql.JPQLSelectSingleStatementBuilder;
-import org.apache.olingo.odata2.processor.core.jpa.jpql.JPQLSelectStatementBuilder;
-import org.apache.olingo.odata2.processor.core.jpa.model.JPAEdmModel;
-
-public class ODataJPAFactoryImpl extends ODataJPAFactory {
-
- @Override
- public JPQLBuilderFactory getJPQLBuilderFactory() {
- return JPQLBuilderFactoryImpl.create();
- };
-
- @Override
- public JPAAccessFactory getJPAAccessFactory() {
- return JPAAccessFactoryImpl.create();
- };
-
- @Override
- public ODataJPAAccessFactory getODataJPAAccessFactory() {
- return ODataJPAAccessFactoryImpl.create();
- };
-
- private static class JPQLBuilderFactoryImpl implements JPQLBuilderFactory {
-
- private static JPQLBuilderFactoryImpl factory = null;
-
- private JPQLBuilderFactoryImpl() {}
-
- @Override
- public JPQLStatementBuilder getStatementBuilder(final JPQLContextView context) {
- JPQLStatementBuilder builder = null;
- switch (context.getType()) {
- case SELECT:
- case SELECT_COUNT: // for $count, Same as select
- builder = new JPQLSelectStatementBuilder(context);
- break;
- case SELECT_SINGLE:
- builder = new JPQLSelectSingleStatementBuilder(context);
- break;
- case JOIN:
- case JOIN_COUNT: // for $count, Same as join
- builder = new JPQLJoinStatementBuilder(context);
- break;
- case JOIN_SINGLE:
- builder = new JPQLJoinSelectSingleStatementBuilder(context);
- default:
- break;
- }
-
- return builder;
- }
-
- @Override
- public JPQLContextBuilder getContextBuilder(final JPQLContextType contextType) {
- JPQLContextBuilder contextBuilder = null;
-
- switch (contextType) {
- case SELECT:
- JPQLSelectContext selectContext = new JPQLSelectContext(false);
- contextBuilder = selectContext.new JPQLSelectContextBuilder();
- break;
- case SELECT_SINGLE:
- JPQLSelectSingleContext singleSelectContext = new JPQLSelectSingleContext();
- contextBuilder = singleSelectContext.new JPQLSelectSingleContextBuilder();
- break;
- case JOIN:
- JPQLJoinSelectContext joinContext = new JPQLJoinSelectContext(false);
- contextBuilder = joinContext.new JPQLJoinContextBuilder();
- break;
- case JOIN_SINGLE:
- JPQLJoinSelectSingleContext joinSingleContext = new JPQLJoinSelectSingleContext();
- contextBuilder = joinSingleContext.new JPQLJoinSelectSingleContextBuilder();
- break;
- case SELECT_COUNT:
- JPQLSelectContext selectCountContext = new JPQLSelectContext(true);
- contextBuilder = selectCountContext.new JPQLSelectContextBuilder();
- break;
- case JOIN_COUNT:
- JPQLJoinSelectContext joinCountContext = new JPQLJoinSelectContext(true);
- contextBuilder = joinCountContext.new JPQLJoinContextBuilder();
- default:
- break;
- }
-
- return contextBuilder;
- }
-
- private static JPQLBuilderFactory create() {
- if (factory == null) {
- return new JPQLBuilderFactoryImpl();
- } else {
- return factory;
- }
- }
-
- @Override
- public JPAMethodContextBuilder getJPAMethodContextBuilder(final JPQLContextType contextType) {
-
- JPAMethodContextBuilder contextBuilder = null;
- switch (contextType) {
- case FUNCTION:
- JPAFunctionContext methodConext = new JPAFunctionContext();
- contextBuilder = methodConext.new JPAFunctionContextBuilder();
-
- break;
- default:
- break;
- }
- return contextBuilder;
- }
-
- }
-
- private static class ODataJPAAccessFactoryImpl implements ODataJPAAccessFactory {
-
- private static ODataJPAAccessFactoryImpl factory = null;
-
- private ODataJPAAccessFactoryImpl() {}
-
- @Override
- public ODataSingleProcessor createODataProcessor(final ODataJPAContext oDataJPAContext) {
- return new ODataJPAProcessorDefault(oDataJPAContext);
- }
-
- @Override
- public EdmProvider createJPAEdmProvider(final ODataJPAContext oDataJPAContext) {
- return new ODataJPAEdmProvider(oDataJPAContext);
- }
-
- @Override
- public ODataJPAContext createODataJPAContext() {
- return new ODataJPAContextImpl();
- }
-
- private static ODataJPAAccessFactoryImpl create() {
- if (factory == null) {
- return new ODataJPAAccessFactoryImpl();
- } else {
- return factory;
- }
- }
-
- @Override
- public ODataJPAMessageService getODataJPAMessageService(final Locale locale) {
- return ODataJPAMessageServiceDefault.getInstance(locale);
- }
-
- }
-
- private static class JPAAccessFactoryImpl implements JPAAccessFactory {
-
- private static JPAAccessFactoryImpl factory = null;
-
- private JPAAccessFactoryImpl() {}
-
- @Override
- public JPAEdmModelView getJPAEdmModelView(final ODataJPAContext oDataJPAContext) {
- JPAEdmModelView view = null;
-
- view = new JPAEdmModel(oDataJPAContext);
- return view;
- }
-
- @Override
- public JPAProcessor getJPAProcessor(final ODataJPAContext oDataJPAContext) {
- JPAProcessor jpaProcessor = new JPAProcessorImpl(oDataJPAContext);
-
- return jpaProcessor;
- }
-
- private static JPAAccessFactoryImpl create() {
- if (factory == null) {
- return new JPAAccessFactoryImpl();
- } else {
- return factory;
- }
- }
-
- @Override
- public JPAEdmMappingModelAccess getJPAEdmMappingModelAccess(final ODataJPAContext oDataJPAContext) {
- JPAEdmMappingModelAccess mappingModelAccess = new JPAEdmMappingModelService(oDataJPAContext);
-
- return mappingModelAccess;
- }
-
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLJoinSelectContext.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLJoinSelectContext.java b/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLJoinSelectContext.java
deleted file mode 100644
index 6026464..0000000
--- a/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLJoinSelectContext.java
+++ /dev/null
@@ -1,171 +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.jpql;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.olingo.odata2.api.edm.EdmEntityType;
-import org.apache.olingo.odata2.api.edm.EdmException;
-import org.apache.olingo.odata2.api.edm.EdmMapping;
-import org.apache.olingo.odata2.api.edm.EdmNavigationProperty;
-import org.apache.olingo.odata2.api.edm.provider.Mapping;
-import org.apache.olingo.odata2.api.exception.ODataException;
-import org.apache.olingo.odata2.api.uri.NavigationSegment;
-import org.apache.olingo.odata2.processor.api.jpa.access.JPAJoinClause;
-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.jpql.JPQLContext;
-import org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLContextType;
-import org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLJoinContextView;
-import org.apache.olingo.odata2.processor.core.jpa.ODataExpressionParser;
-
-public class JPQLJoinSelectContext extends JPQLSelectContext implements JPQLJoinContextView {
-
- private List<JPAJoinClause> jpaJoinClauses = null;
-
- protected void setJPAOuterJoinClause(final List<JPAJoinClause> jpaOuterJoinClauses) {
- jpaJoinClauses = jpaOuterJoinClauses;
- }
-
- public JPQLJoinSelectContext(final boolean isCountOnly) {
- super(isCountOnly);
- }
-
- public class JPQLJoinContextBuilder extends JPQLSelectContextBuilder {
-
- protected int relationShipAliasCounter = 0;
-
- @Override
- public JPQLContext build() throws ODataJPAModelException, ODataJPARuntimeException {
- try {
-
- if (JPQLJoinSelectContext.this.isCountOnly) {
- setType(JPQLContextType.JOIN_COUNT);
- } else {
- setType(JPQLContextType.JOIN);
- }
-
- setJPAOuterJoinClause(generateJoinClauses());
-
- if (!jpaJoinClauses.isEmpty()) {
- JPAJoinClause joinClause = jpaJoinClauses.get(jpaJoinClauses.size() - 1);
- setJPAEntityName(joinClause.getEntityName());
- setJPAEntityAlias(joinClause.getEntityRelationShipAlias());
- }
-
- setOrderByCollection(generateOrderByFileds());
-
- setSelectExpression(generateSelectExpression());
-
- setWhereExpression(generateWhereExpression());
-
- } catch (ODataException e) {
- throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.INNER_EXCEPTION, e);
- }
-
- return JPQLJoinSelectContext.this;
- }
-
- protected List<JPAJoinClause> generateJoinClauses() throws ODataJPARuntimeException, EdmException {
-
- List<JPAJoinClause> jpaOuterJoinClauses = new ArrayList<JPAJoinClause>();
- JPAJoinClause jpaOuterJoinClause = null;
- String joinCondition = null;
- String entityAlias = generateJPAEntityAlias();
- joinCondition = ODataExpressionParser.parseKeyPredicates(entitySetView.getKeyPredicates(), entityAlias);
-
- EdmEntityType entityType = entitySetView.getStartEntitySet().getEntityType();
- Mapping mapping = (Mapping) entityType.getMapping();
- String entityTypeName = null;
- if (mapping != null) {
- entityTypeName = mapping.getInternalName();
- } else {
- entityTypeName = entityType.getName();
- }
-
- jpaOuterJoinClause =
- new JPAJoinClause(entityTypeName, entityAlias, null, null, joinCondition, JPAJoinClause.JOIN.INNER);
-
- jpaOuterJoinClauses.add(jpaOuterJoinClause);
-
- for (NavigationSegment navigationSegment : entitySetView.getNavigationSegments()) {
-
- EdmNavigationProperty navigationProperty = navigationSegment.getNavigationProperty();
-
- String relationShipAlias = generateRelationShipAlias();
-
- joinCondition =
- ODataExpressionParser.parseKeyPredicates(navigationSegment.getKeyPredicates(), relationShipAlias);
-
- jpaOuterJoinClause =
- new JPAJoinClause(getFromEntityName(navigationProperty), entityAlias,
- getRelationShipName(navigationProperty), relationShipAlias, joinCondition, JPAJoinClause.JOIN.INNER);
-
- jpaOuterJoinClauses.add(jpaOuterJoinClause);
-
- }
-
- return jpaOuterJoinClauses;
- }
-
- private String getFromEntityName(final EdmNavigationProperty navigationProperty) throws EdmException {
-
- String fromRole = navigationProperty.getFromRole();
-
- EdmEntityType toEntityType = navigationProperty.getRelationship().getEnd(fromRole).getEntityType();
-
- EdmMapping mapping = toEntityType.getMapping();
-
- String entityName = null;
- if (mapping != null) {
- entityName = mapping.getInternalName();
- } else {
- entityName = toEntityType.getName();
- }
-
- return entityName;
-
- }
-
- private String getRelationShipName(final EdmNavigationProperty navigationProperty) throws EdmException {
-
- EdmMapping mapping = navigationProperty.getMapping();
-
- String relationShipName = null;
- if (mapping != null) {
- relationShipName = mapping.getInternalName();
- } else {
- relationShipName = navigationProperty.getName();
- }
-
- return relationShipName;
- }
-
- private String generateRelationShipAlias() {
- return new String("R" + ++relationShipAliasCounter);
- }
- }
-
- @Override
- public List<JPAJoinClause> getJPAJoinClauses() {
- return jpaJoinClauses;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLJoinSelectSingleContext.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLJoinSelectSingleContext.java b/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLJoinSelectSingleContext.java
deleted file mode 100644
index c25eae9..0000000
--- a/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLJoinSelectSingleContext.java
+++ /dev/null
@@ -1,158 +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.jpql;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.olingo.odata2.api.edm.EdmEntityType;
-import org.apache.olingo.odata2.api.edm.EdmException;
-import org.apache.olingo.odata2.api.edm.EdmMapping;
-import org.apache.olingo.odata2.api.edm.EdmNavigationProperty;
-import org.apache.olingo.odata2.api.edm.provider.Mapping;
-import org.apache.olingo.odata2.api.uri.NavigationSegment;
-import org.apache.olingo.odata2.processor.api.jpa.access.JPAJoinClause;
-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.jpql.JPQLContext;
-import org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLContextType;
-import org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLJoinSelectSingleContextView;
-import org.apache.olingo.odata2.processor.core.jpa.ODataExpressionParser;
-
-public class JPQLJoinSelectSingleContext extends JPQLSelectSingleContext implements JPQLJoinSelectSingleContextView {
-
- private List<JPAJoinClause> jpaJoinClauses = null;
-
- protected void setJPAJoinClause(final List<JPAJoinClause> jpaJoinClauses) {
- this.jpaJoinClauses = jpaJoinClauses;
- }
-
- public class JPQLJoinSelectSingleContextBuilder extends JPQLSelectSingleContextBuilder {
-
- protected int relationShipAliasCounter = 0;
-
- @Override
- public JPQLContext build() throws ODataJPAModelException, ODataJPARuntimeException {
- try {
- setType(JPQLContextType.JOIN_SINGLE);
- setJPAJoinClause(generateJoinClauses());
-
- if (!jpaJoinClauses.isEmpty()) {
- JPAJoinClause joinClause = jpaJoinClauses.get(jpaJoinClauses.size() - 1);
- setJPAEntityName(joinClause.getEntityName());
- setJPAEntityAlias(joinClause.getEntityRelationShipAlias());
- }
-
- setKeyPredicates(entityView.getKeyPredicates());
-
- setSelectExpression(generateSelectExpression());
-
- } catch (EdmException e) {
- throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL, e);
- }
-
- return JPQLJoinSelectSingleContext.this;
- }
-
- protected List<JPAJoinClause> generateJoinClauses() throws ODataJPARuntimeException, EdmException {
-
- List<JPAJoinClause> jpaOuterJoinClauses = new ArrayList<JPAJoinClause>();
- JPAJoinClause jpaOuterJoinClause = null;
- String joinCondition = null;
- String entityAlias = generateJPAEntityAlias();
- joinCondition = ODataExpressionParser.parseKeyPredicates(entityView.getKeyPredicates(), entityAlias);
-
- EdmEntityType entityType = entityView.getStartEntitySet().getEntityType();
- Mapping mapping = (Mapping) entityType.getMapping();
- String entityTypeName = null;
- if (mapping != null) {
- entityTypeName = mapping.getInternalName();
- } else {
- entityTypeName = entityType.getName();
- }
-
- jpaOuterJoinClause =
- new JPAJoinClause(entityTypeName, entityAlias, null, null, joinCondition, JPAJoinClause.JOIN.INNER);
-
- jpaOuterJoinClauses.add(jpaOuterJoinClause);
-
- for (NavigationSegment navigationSegment : entityView.getNavigationSegments()) {
-
- EdmNavigationProperty navigationProperty = navigationSegment.getNavigationProperty();
-
- String relationShipAlias = generateRelationShipAlias();
-
- joinCondition =
- ODataExpressionParser.parseKeyPredicates(navigationSegment.getKeyPredicates(), relationShipAlias);
-
- jpaOuterJoinClause =
- new JPAJoinClause(getFromEntityName(navigationProperty), entityAlias,
- getRelationShipName(navigationProperty), relationShipAlias, joinCondition, JPAJoinClause.JOIN.INNER);
-
- jpaOuterJoinClauses.add(jpaOuterJoinClause);
-
- }
-
- return jpaOuterJoinClauses;
- }
-
- private String getFromEntityName(final EdmNavigationProperty navigationProperty) throws EdmException {
-
- String fromRole = navigationProperty.getFromRole();
-
- EdmEntityType fromEntityType = navigationProperty.getRelationship().getEnd(fromRole).getEntityType();
-
- EdmMapping mapping = fromEntityType.getMapping();
-
- String entityName = null;
- if (mapping != null) {
- entityName = mapping.getInternalName();
- } else {
- entityName = fromEntityType.getName();
- }
-
- return entityName;
-
- }
-
- private String getRelationShipName(final EdmNavigationProperty navigationProperty) throws EdmException {
-
- EdmMapping mapping = navigationProperty.getMapping();
-
- String relationShipName = null;
- if (mapping != null) {
- relationShipName = mapping.getInternalName();
- } else {
- relationShipName = navigationProperty.getName();
- }
-
- return relationShipName;
- }
-
- private String generateRelationShipAlias() {
- return new String("R" + ++relationShipAliasCounter);
- }
- }
-
- @Override
- public List<JPAJoinClause> getJPAJoinClauses() {
- return jpaJoinClauses;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLJoinSelectSingleStatementBuilder.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLJoinSelectSingleStatementBuilder.java b/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLJoinSelectSingleStatementBuilder.java
deleted file mode 100644
index fd06892..0000000
--- a/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLJoinSelectSingleStatementBuilder.java
+++ /dev/null
@@ -1,106 +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.jpql;
-
-import java.util.List;
-
-import org.apache.olingo.odata2.processor.api.jpa.access.JPAJoinClause;
-import org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPARuntimeException;
-import org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLContextView;
-import org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLJoinSelectSingleContextView;
-import org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLStatement;
-import org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLStatement.JPQLStatementBuilder;
-
-public class JPQLJoinSelectSingleStatementBuilder extends JPQLStatementBuilder {
-
- JPQLStatement jpqlStatement;
- private JPQLJoinSelectSingleContextView context;
-
- public JPQLJoinSelectSingleStatementBuilder(final JPQLContextView context) {
- this.context = (JPQLJoinSelectSingleContextView) context;
- }
-
- @Override
- public JPQLStatement build() throws ODataJPARuntimeException {
- jpqlStatement = createStatement(createJPQLQuery());
- return jpqlStatement;
-
- }
-
- private String createJPQLQuery() throws ODataJPARuntimeException {
-
- StringBuilder jpqlQuery = new StringBuilder();
- StringBuilder joinWhereCondition = null;
-
- jpqlQuery.append(JPQLStatement.KEYWORD.SELECT).append(JPQLStatement.DELIMITER.SPACE);
- jpqlQuery.append(context.getSelectExpression()).append(JPQLStatement.DELIMITER.SPACE);
- jpqlQuery.append(JPQLStatement.KEYWORD.FROM).append(JPQLStatement.DELIMITER.SPACE);
-
- if (context.getJPAJoinClauses() != null && context.getJPAJoinClauses().size() > 0) {
- List<JPAJoinClause> joinClauseList = context.getJPAJoinClauses();
- JPAJoinClause joinClause = joinClauseList.get(0);
- String joinCondition = joinClause.getJoinCondition();
- joinWhereCondition = new StringBuilder();
- if (joinCondition != null) {
- joinWhereCondition.append(joinCondition);
- }
- String relationShipAlias = null;
- joinClause = joinClauseList.get(1);
- jpqlQuery.append(joinClause.getEntityName()).append(JPQLStatement.DELIMITER.SPACE);
- jpqlQuery.append(joinClause.getEntityAlias());
-
- int i = 1;
- int limit = joinClauseList.size();
- relationShipAlias = joinClause.getEntityAlias();
- while (i < limit) {
- jpqlQuery.append(JPQLStatement.DELIMITER.SPACE);
- jpqlQuery.append(JPQLStatement.KEYWORD.JOIN).append(JPQLStatement.DELIMITER.SPACE);
-
- joinClause = joinClauseList.get(i);
- jpqlQuery.append(relationShipAlias).append(JPQLStatement.DELIMITER.PERIOD);
- jpqlQuery.append(joinClause.getEntityRelationShip()).append(JPQLStatement.DELIMITER.SPACE);
- jpqlQuery.append(joinClause.getEntityRelationShipAlias());
-
- relationShipAlias = joinClause.getEntityRelationShipAlias();
- i++;
-
- joinCondition = joinClause.getJoinCondition();
- if (joinCondition != null) {
- joinWhereCondition.append(JPQLStatement.DELIMITER.SPACE + JPQLStatement.Operator.AND
- + JPQLStatement.DELIMITER.SPACE);
-
- joinWhereCondition.append(joinCondition);
- }
-
- }
- } else {
- throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.JOIN_CLAUSE_EXPECTED, null);
- }
-
- if (joinWhereCondition.length() > 0) {
- jpqlQuery.append(JPQLStatement.DELIMITER.SPACE);
- jpqlQuery.append(JPQLStatement.KEYWORD.WHERE).append(JPQLStatement.DELIMITER.SPACE);
- jpqlQuery.append(joinWhereCondition.toString());
- }
-
- return jpqlQuery.toString();
-
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLJoinStatementBuilder.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLJoinStatementBuilder.java b/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLJoinStatementBuilder.java
deleted file mode 100644
index 57d0e28..0000000
--- a/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLJoinStatementBuilder.java
+++ /dev/null
@@ -1,145 +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.jpql;
-
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map.Entry;
-
-import org.apache.olingo.odata2.processor.api.jpa.access.JPAJoinClause;
-import org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPARuntimeException;
-import org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLContextType;
-import org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLContextView;
-import org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLJoinContextView;
-import org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLStatement;
-import org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLStatement.JPQLStatementBuilder;
-
-public class JPQLJoinStatementBuilder extends JPQLStatementBuilder {
-
- JPQLStatement jpqlStatement;
- private JPQLJoinContextView context;
-
- public JPQLJoinStatementBuilder(final JPQLContextView context) {
- this.context = (JPQLJoinContextView) context;
- }
-
- @Override
- public JPQLStatement build() throws ODataJPARuntimeException {
- jpqlStatement = createStatement(createJPQLQuery());
- return jpqlStatement;
-
- }
-
- private String createJPQLQuery() throws ODataJPARuntimeException {
-
- StringBuilder jpqlQuery = new StringBuilder();
- StringBuilder joinWhereCondition = null;
-
- jpqlQuery.append(JPQLStatement.KEYWORD.SELECT).append(JPQLStatement.DELIMITER.SPACE);
- if (context.getType().equals(JPQLContextType.JOIN_COUNT)) {// $COUNT
- jpqlQuery.append(JPQLStatement.KEYWORD.COUNT).append(JPQLStatement.DELIMITER.SPACE);
- jpqlQuery.append(JPQLStatement.DELIMITER.PARENTHESIS_LEFT).append(JPQLStatement.DELIMITER.SPACE);
- jpqlQuery.append(context.getSelectExpression()).append(JPQLStatement.DELIMITER.SPACE);
- jpqlQuery.append(JPQLStatement.DELIMITER.PARENTHESIS_RIGHT).append(JPQLStatement.DELIMITER.SPACE);
- } else { // Normal
- jpqlQuery.append(context.getSelectExpression()).append(JPQLStatement.DELIMITER.SPACE);
- }
-
- jpqlQuery.append(JPQLStatement.KEYWORD.FROM).append(JPQLStatement.DELIMITER.SPACE);
-
- if (context.getJPAJoinClauses() != null && context.getJPAJoinClauses().size() > 0) {
- List<JPAJoinClause> joinClauseList = context.getJPAJoinClauses();
- JPAJoinClause joinClause = joinClauseList.get(0);
- String joinCondition = joinClause.getJoinCondition();
- joinWhereCondition = new StringBuilder();
- if (joinCondition != null) {
- joinWhereCondition.append(joinCondition);
- }
- String relationShipAlias = null;
- joinClause = joinClauseList.get(1);
- jpqlQuery.append(joinClause.getEntityName()).append(JPQLStatement.DELIMITER.SPACE);
- jpqlQuery.append(joinClause.getEntityAlias());
-
- int i = 1;
- int limit = joinClauseList.size();
- relationShipAlias = joinClause.getEntityAlias();
- while (i < limit) {
- jpqlQuery.append(JPQLStatement.DELIMITER.SPACE);
- jpqlQuery.append(JPQLStatement.KEYWORD.JOIN).append(JPQLStatement.DELIMITER.SPACE);
-
- joinClause = joinClauseList.get(i);
- jpqlQuery.append(relationShipAlias).append(JPQLStatement.DELIMITER.PERIOD);
- jpqlQuery.append(joinClause.getEntityRelationShip()).append(JPQLStatement.DELIMITER.SPACE);
- jpqlQuery.append(joinClause.getEntityRelationShipAlias());
-
- relationShipAlias = joinClause.getEntityRelationShipAlias();
- i++;
-
- joinCondition = joinClause.getJoinCondition();
- if (joinCondition != null) {
- joinWhereCondition.append(JPQLStatement.DELIMITER.SPACE + JPQLStatement.Operator.AND
- + JPQLStatement.DELIMITER.SPACE);
-
- joinWhereCondition.append(joinCondition);
- }
- }
- } else {
- throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.JOIN_CLAUSE_EXPECTED, null);
- }
- String whereExpression = context.getWhereExpression();
- if (whereExpression != null || joinWhereCondition.length() > 0) {
- jpqlQuery.append(JPQLStatement.DELIMITER.SPACE).append(JPQLStatement.KEYWORD.WHERE).append(
- JPQLStatement.DELIMITER.SPACE);
- if (whereExpression != null) {
- jpqlQuery.append(whereExpression);
- if (joinWhereCondition != null) {
- jpqlQuery.append(JPQLStatement.DELIMITER.SPACE + JPQLStatement.Operator.AND + JPQLStatement.DELIMITER.SPACE);
- }
- }
- if (joinWhereCondition != null) {
- jpqlQuery.append(joinWhereCondition.toString());
- }
-
- }
-
- if (context.getOrderByCollection() != null && context.getOrderByCollection().size() > 0) {
-
- StringBuilder orderByBuilder = new StringBuilder();
- Iterator<Entry<String, String>> orderItr = context.getOrderByCollection().entrySet().iterator();
-
- int i = 0;
-
- while (orderItr.hasNext()) {
- if (i != 0) {
- orderByBuilder.append(JPQLStatement.DELIMITER.SPACE).append(JPQLStatement.DELIMITER.COMMA).append(
- JPQLStatement.DELIMITER.SPACE);
- }
- Entry<String, String> entry = orderItr.next();
- orderByBuilder.append(entry.getKey()).append(JPQLStatement.DELIMITER.SPACE);
- orderByBuilder.append(entry.getValue());
- i++;
- }
- jpqlQuery.append(JPQLStatement.DELIMITER.SPACE).append(JPQLStatement.KEYWORD.ORDERBY).append(
- JPQLStatement.DELIMITER.SPACE);
- jpqlQuery.append(orderByBuilder);
- }
-
- return jpqlQuery.toString();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLSelectContext.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLSelectContext.java b/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLSelectContext.java
deleted file mode 100644
index ef588aa..0000000
--- a/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLSelectContext.java
+++ /dev/null
@@ -1,159 +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.jpql;
-
-import java.util.HashMap;
-
-import org.apache.olingo.odata2.api.edm.EdmEntityType;
-import org.apache.olingo.odata2.api.edm.EdmException;
-import org.apache.olingo.odata2.api.edm.EdmMapping;
-import org.apache.olingo.odata2.api.exception.ODataException;
-import org.apache.olingo.odata2.api.uri.info.GetEntitySetUriInfo;
-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.jpql.JPQLContext;
-import org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLContextType;
-import org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLSelectContextView;
-import org.apache.olingo.odata2.processor.core.jpa.ODataExpressionParser;
-
-public class JPQLSelectContext extends JPQLContext implements JPQLSelectContextView {
-
- protected String selectExpression;
- protected HashMap<String, String> orderByCollection;
- protected String whereCondition;
-
- protected boolean isCountOnly = false;// Support for $count
-
- public JPQLSelectContext(final boolean isCountOnly) {
- this.isCountOnly = isCountOnly;
- }
-
- protected final void setOrderByCollection(final HashMap<String, String> orderByCollection) {
- this.orderByCollection = orderByCollection;
- }
-
- protected final void setWhereExpression(final String filterExpression) {
- whereCondition = filterExpression;
- }
-
- protected final void setSelectExpression(final String selectExpression) {
- this.selectExpression = selectExpression;
- }
-
- @Override
- public String getSelectExpression() {
- return selectExpression;
- }
-
- @Override
- public HashMap<String, String> getOrderByCollection() {
- return orderByCollection;
- }
-
- @Override
- public String getWhereExpression() {
- return whereCondition;
- }
-
- public class JPQLSelectContextBuilder extends
- org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLContext.JPQLContextBuilder {
-
- protected GetEntitySetUriInfo entitySetView;
-
- @Override
- public JPQLContext build() throws ODataJPAModelException, ODataJPARuntimeException {
- if (entitySetView != null) {
-
- try {
-
- if (isCountOnly) {
- setType(JPQLContextType.SELECT_COUNT);
- } else {
- setType(JPQLContextType.SELECT);
- }
- EdmEntityType entityType = entitySetView.getTargetEntitySet().getEntityType();
- EdmMapping mapping = entityType.getMapping();
- if (mapping != null) {
- setJPAEntityName(mapping.getInternalName());
- } else {
- setJPAEntityName(entityType.getName());
- }
-
- setJPAEntityAlias(generateJPAEntityAlias());
-
- setOrderByCollection(generateOrderByFileds());
-
- setSelectExpression(generateSelectExpression());
-
- setWhereExpression(generateWhereExpression());
- } catch (ODataException e) {
- throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.INNER_EXCEPTION, e);
- }
- }
-
- return JPQLSelectContext.this;
-
- }
-
- @Override
- protected void setResultsView(final Object resultsView) {
- if (resultsView instanceof GetEntitySetUriInfo) {
- entitySetView = (GetEntitySetUriInfo) resultsView;
- }
-
- }
-
- /*
- * Generate Select Clause
- */
- protected String generateSelectExpression() throws EdmException {
- return getJPAEntityAlias();
- }
-
- /*
- * Generate Order By Clause Fields
- */
- protected HashMap<String, String> generateOrderByFileds() throws ODataJPARuntimeException, EdmException {
-
- if (entitySetView.getOrderBy() != null) {
-
- return ODataExpressionParser.parseToJPAOrderByExpression(entitySetView.getOrderBy(), getJPAEntityAlias());
-
- } else if (entitySetView.getTop() != null || entitySetView.getSkip() != null) {
-
- return ODataExpressionParser.parseKeyPropertiesToJPAOrderByExpression(entitySetView.getTargetEntitySet()
- .getEntityType().getKeyProperties(), getJPAEntityAlias());
- } else {
- return null;
- }
-
- }
-
- /*
- * Generate Where Clause Expression
- */
- protected String generateWhereExpression() throws ODataException {
- if (entitySetView.getFilter() != null) {
- return ODataExpressionParser.parseToJPAWhereExpression(entitySetView.getFilter(), getJPAEntityAlias());
- }
- return null;
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLSelectSingleContext.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLSelectSingleContext.java b/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLSelectSingleContext.java
deleted file mode 100644
index 9d2884d..0000000
--- a/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLSelectSingleContext.java
+++ /dev/null
@@ -1,109 +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.jpql;
-
-import java.util.List;
-
-import org.apache.olingo.odata2.api.edm.EdmEntityType;
-import org.apache.olingo.odata2.api.edm.EdmException;
-import org.apache.olingo.odata2.api.edm.EdmMapping;
-import org.apache.olingo.odata2.api.uri.KeyPredicate;
-import org.apache.olingo.odata2.api.uri.info.GetEntityUriInfo;
-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.jpql.JPQLContext;
-import org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLContextType;
-import org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLSelectSingleContextView;
-
-public class JPQLSelectSingleContext extends JPQLContext implements JPQLSelectSingleContextView {
-
- private String selectExpression;
- private List<KeyPredicate> keyPredicates;
-
- protected void setKeyPredicates(final List<KeyPredicate> keyPredicates) {
- this.keyPredicates = keyPredicates;
- }
-
- @Override
- public List<KeyPredicate> getKeyPredicates() {
- return keyPredicates;
- }
-
- protected final void setSelectExpression(final String selectExpression) {
- this.selectExpression = selectExpression;
- }
-
- @Override
- public String getSelectExpression() {
- return selectExpression;
- }
-
- public class JPQLSelectSingleContextBuilder extends
- org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLContext.JPQLContextBuilder {
-
- protected GetEntityUriInfo entityView;
-
- @Override
- public JPQLContext build() throws ODataJPAModelException, ODataJPARuntimeException {
- if (entityView != null) {
-
- try {
-
- setType(JPQLContextType.SELECT_SINGLE);
-
- EdmEntityType entityType = entityView.getTargetEntitySet().getEntityType();
- EdmMapping mapping = entityType.getMapping();
- if (mapping != null) {
- setJPAEntityName(mapping.getInternalName());
- } else {
- setJPAEntityName(entityType.getName());
- }
-
- setJPAEntityAlias(generateJPAEntityAlias());
-
- setKeyPredicates(entityView.getKeyPredicates());
-
- setSelectExpression(generateSelectExpression());
-
- } catch (EdmException e) {
- throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e);
- }
-
- }
-
- return JPQLSelectSingleContext.this;
-
- }
-
- @Override
- protected void setResultsView(final Object resultsView) {
- if (resultsView instanceof GetEntityUriInfo) {
- entityView = (GetEntityUriInfo) resultsView;
- }
-
- }
-
- /*
- * Generate Select Clause
- */
- protected String generateSelectExpression() throws EdmException {
- return getJPAEntityAlias();
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLSelectSingleStatementBuilder.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLSelectSingleStatementBuilder.java b/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLSelectSingleStatementBuilder.java
deleted file mode 100644
index 06e2444..0000000
--- a/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLSelectSingleStatementBuilder.java
+++ /dev/null
@@ -1,66 +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.jpql;
-
-import org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPARuntimeException;
-import org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLContextView;
-import org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLSelectSingleContextView;
-import org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLStatement;
-import org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLStatement.JPQLStatementBuilder;
-import org.apache.olingo.odata2.processor.core.jpa.ODataExpressionParser;
-
-public class JPQLSelectSingleStatementBuilder extends JPQLStatementBuilder {
-
- JPQLStatement jpqlStatement;
- private JPQLSelectSingleContextView context;
-
- public JPQLSelectSingleStatementBuilder(final JPQLContextView context) {
- this.context = (JPQLSelectSingleContextView) context;
- }
-
- @Override
- public JPQLStatement build() throws ODataJPARuntimeException {
- jpqlStatement = createStatement(createJPQLQuery());
- return jpqlStatement;
-
- }
-
- private String createJPQLQuery() throws ODataJPARuntimeException {
-
- StringBuilder jpqlQuery = new StringBuilder();
- String tableAlias = context.getJPAEntityAlias();
- String fromClause = context.getJPAEntityName() + JPQLStatement.DELIMITER.SPACE + tableAlias;
-
- jpqlQuery.append(JPQLStatement.KEYWORD.SELECT).append(JPQLStatement.DELIMITER.SPACE);
- jpqlQuery.append(context.getSelectExpression()).append(JPQLStatement.DELIMITER.SPACE);
- jpqlQuery.append(JPQLStatement.KEYWORD.FROM).append(JPQLStatement.DELIMITER.SPACE);
- jpqlQuery.append(fromClause);
-
- if (context.getKeyPredicates() != null && context.getKeyPredicates().size() > 0) {
- jpqlQuery.append(JPQLStatement.DELIMITER.SPACE);
- jpqlQuery.append(JPQLStatement.KEYWORD.WHERE).append(JPQLStatement.DELIMITER.SPACE);
- jpqlQuery.append(ODataExpressionParser
- .parseKeyPredicates(context.getKeyPredicates(), context.getJPAEntityAlias()));
- }
-
- return jpqlQuery.toString();
-
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLSelectStatementBuilder.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLSelectStatementBuilder.java b/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLSelectStatementBuilder.java
deleted file mode 100644
index 22059f1..0000000
--- a/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLSelectStatementBuilder.java
+++ /dev/null
@@ -1,98 +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.jpql;
-
-import java.util.Iterator;
-import java.util.Map.Entry;
-
-import org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPARuntimeException;
-import org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLContextType;
-import org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLContextView;
-import org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLSelectContextView;
-import org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLStatement;
-import org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLStatement.JPQLStatementBuilder;
-
-public class JPQLSelectStatementBuilder extends JPQLStatementBuilder {
-
- JPQLStatement jpqlStatement;
- private JPQLSelectContextView context;
-
- public JPQLSelectStatementBuilder(final JPQLContextView context) {
- this.context = (JPQLSelectContextView) context;
- }
-
- @Override
- public JPQLStatement build() throws ODataJPARuntimeException {
- jpqlStatement = createStatement(createJPQLQuery());
- return jpqlStatement;
-
- }
-
- private String createJPQLQuery() throws ODataJPARuntimeException {
-
- StringBuilder jpqlQuery = new StringBuilder();
- String tableAlias = context.getJPAEntityAlias();
- String fromClause = context.getJPAEntityName() + JPQLStatement.DELIMITER.SPACE + tableAlias;
-
- jpqlQuery.append(JPQLStatement.KEYWORD.SELECT).append(JPQLStatement.DELIMITER.SPACE);
- if (context.getType().equals(JPQLContextType.SELECT_COUNT)) { // $COUNT
- jpqlQuery.append(JPQLStatement.KEYWORD.COUNT).append(JPQLStatement.DELIMITER.SPACE);
- jpqlQuery.append(JPQLStatement.DELIMITER.PARENTHESIS_LEFT).append(JPQLStatement.DELIMITER.SPACE);
- jpqlQuery.append(context.getSelectExpression()).append(JPQLStatement.DELIMITER.SPACE);
- jpqlQuery.append(JPQLStatement.DELIMITER.PARENTHESIS_RIGHT).append(JPQLStatement.DELIMITER.SPACE);
- } else {// Normal
- jpqlQuery.append(context.getSelectExpression()).append(JPQLStatement.DELIMITER.SPACE);
- }
-
- jpqlQuery.append(JPQLStatement.KEYWORD.FROM).append(JPQLStatement.DELIMITER.SPACE);
- jpqlQuery.append(fromClause);
-
- if (context.getWhereExpression() != null) {
- jpqlQuery.append(JPQLStatement.DELIMITER.SPACE);
- jpqlQuery.append(JPQLStatement.KEYWORD.WHERE).append(JPQLStatement.DELIMITER.SPACE);
- jpqlQuery.append(context.getWhereExpression());
- }
-
- if (context.getOrderByCollection() != null && context.getOrderByCollection().size() > 0) {
-
- StringBuilder orderByBuilder = new StringBuilder();
- Iterator<Entry<String, String>> orderItr = context.getOrderByCollection().entrySet().iterator();
-
- int i = 0;
-
- while (orderItr.hasNext()) {
- if (i != 0) {
- orderByBuilder.append(JPQLStatement.DELIMITER.SPACE).append(JPQLStatement.DELIMITER.COMMA).append(
- JPQLStatement.DELIMITER.SPACE);
- }
- Entry<String, String> entry = orderItr.next();
- orderByBuilder.append(entry.getKey()).append(JPQLStatement.DELIMITER.SPACE);
- orderByBuilder.append(entry.getValue());
- i++;
- }
- jpqlQuery.append(JPQLStatement.DELIMITER.SPACE);
- jpqlQuery.append(JPQLStatement.KEYWORD.ORDERBY).append(JPQLStatement.DELIMITER.SPACE);
- jpqlQuery.append(orderByBuilder);
- }
-
- return jpqlQuery.toString();
-
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmAssociation.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmAssociation.java b/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmAssociation.java
deleted file mode 100644
index aa10ef8..0000000
--- a/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmAssociation.java
+++ /dev/null
@@ -1,237 +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.model;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.LinkedList;
-import java.util.List;
-
-import org.apache.olingo.odata2.api.edm.provider.Association;
-import org.apache.olingo.odata2.api.edm.provider.AssociationEnd;
-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.JPAEdmAssociationEndView;
-import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmAssociationView;
-import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmEntityTypeView;
-import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmPropertyView;
-import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmReferentialConstraintView;
-import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmSchemaView;
-import org.apache.olingo.odata2.processor.core.jpa.access.model.JPAEdmNameBuilder;
-
-public class JPAEdmAssociation extends JPAEdmBaseViewImpl implements JPAEdmAssociationView {
-
- private JPAEdmAssociationEndView associationEndView;
-
- private Association currentAssociation;
- private List<Association> consistentAssociatonList;
- private HashMap<String, Association> associationMap;
- private HashMap<String, JPAEdmAssociationEndView> associationEndMap;
- private List<JPAEdmReferentialConstraintView> inconsistentRefConstraintViewList;
- private int numberOfSimilarEndPoints;
-
- public JPAEdmAssociation(final JPAEdmAssociationEndView associationEndview,
- final JPAEdmEntityTypeView entityTypeView, final JPAEdmPropertyView propertyView, final int value) {
- super(associationEndview);
- associationEndView = associationEndview;
- numberOfSimilarEndPoints = value;
- init();
- }
-
- public JPAEdmAssociation(final JPAEdmSchemaView view) {
- super(view);
- init();
- }
-
- private void init() {
- isConsistent = false;
- consistentAssociatonList = new ArrayList<Association>();
- inconsistentRefConstraintViewList = new LinkedList<JPAEdmReferentialConstraintView>();
- associationMap = new HashMap<String, Association>();
- associationEndMap = new HashMap<String, JPAEdmAssociationEndView>();
- }
-
- @Override
- public JPAEdmBuilder getBuilder() {
- if (builder == null) {
- builder = new JPAEdmAssociationBuilder();
- }
- return builder;
- }
-
- @Override
- public Association getEdmAssociation() {
- return currentAssociation;
- }
-
- @Override
- public List<Association> getConsistentEdmAssociationList() {
- return consistentAssociatonList;
- }
-
- @Override
- public Association searchAssociation(final JPAEdmAssociationEndView view) {
- if (view != null) {
- for (String key : associationMap.keySet()) {
- Association association = associationMap.get(key);
- if (association != null) {
- if (view.compare(association.getEnd1(), association.getEnd2())) {
- JPAEdmAssociationEndView associationEnd = associationEndMap.get(association.getName());
- if (associationEnd.getJoinColumnName() != null && associationEnd.getJoinColumnReferenceColumnName() != null
- && view.getJoinColumnName() != null && view.getJoinColumnReferenceColumnName() != null) {
- if (view.getJoinColumnName().equals(associationEnd.getJoinColumnName())
- && view.getJoinColumnReferenceColumnName()
- .equals(associationEnd.getJoinColumnReferenceColumnName())) {
- currentAssociation = association;
- return association;
- }
-
- }
- if (associationEnd.getMappedByName() != null) {
- if (associationEnd.getMappedByName().equals(view.getOwningPropertyName())) {
- currentAssociation = association;
- return association;
- }
- }
- if (associationEnd.getOwningPropertyName() != null) {
- if (associationEnd.getOwningPropertyName().equals(view.getMappedByName())) {
- currentAssociation = association;
- return association;
- }
- }
- }
- }
- }
- }
- return null;
- }
-
- @Override
- public void addJPAEdmAssociationView(final JPAEdmAssociationView associationView,
- final JPAEdmAssociationEndView associationEndView) {
- if (associationView != null) {
- currentAssociation = associationView.getEdmAssociation();
- associationMap.put(currentAssociation.getName(), currentAssociation);
- associationEndMap.put(currentAssociation.getName(), associationEndView);
- addJPAEdmRefConstraintView(associationView.getJPAEdmReferentialConstraintView());
- }
- }
-
- @Override
- public void addJPAEdmRefConstraintView(final JPAEdmReferentialConstraintView refView) {
- if (refView != null && refView.isExists()) {
- inconsistentRefConstraintViewList.add(refView);
- }
- }
-
- @Override
- public JPAEdmReferentialConstraintView getJPAEdmReferentialConstraintView() {
- if (inconsistentRefConstraintViewList.isEmpty()) {
- return null;
- }
- return inconsistentRefConstraintViewList.get(0);
- }
-
- private class JPAEdmAssociationBuilder implements JPAEdmBuilder {
-
- @Override
- public void build() throws ODataJPAModelException, ODataJPARuntimeException {
-
- if (associationEndView != null && searchAssociation(associationEndView) == null) {
- currentAssociation = new Association();
- currentAssociation.setEnd1(associationEndView.getEdmAssociationEnd1());
- currentAssociation.setEnd2(associationEndView.getEdmAssociationEnd2());
-
- JPAEdmNameBuilder.build(JPAEdmAssociation.this, numberOfSimilarEndPoints);
-
- associationMap.put(currentAssociation.getName(), currentAssociation);
-
- } else if (!inconsistentRefConstraintViewList.isEmpty()) {
- int inconsistentRefConstraintViewSize = inconsistentRefConstraintViewList.size();
- int index = 0;
- for (int i = 0; i < inconsistentRefConstraintViewSize; i++) {
- JPAEdmReferentialConstraintView view = inconsistentRefConstraintViewList.get(index);
-
- if (view.isExists() && !view.isConsistent()) {
- view.getBuilder().build();
- }
- if (view.isConsistent()) {
- Association newAssociation = new Association();
- copyAssociation(newAssociation, associationMap.get(view.getEdmRelationShipName()));
- newAssociation.setReferentialConstraint(view.getEdmReferentialConstraint());
- consistentAssociatonList.add(newAssociation);
- associationMap.put(view.getEdmRelationShipName(), newAssociation);
- inconsistentRefConstraintViewList.remove(index);
- } else {
- associationMap.remove(view.getEdmRelationShipName());
- index++;
- }
- }
- }
-
- if (associationMap.size() == consistentAssociatonList.size()) {
- isConsistent = true;
- } else {
- for (String key : associationMap.keySet()) {
- Association association = associationMap.get(key);
- if (!consistentAssociatonList.contains(association)) {
- consistentAssociatonList.add(association);
- }
- }
- isConsistent = true;
- }
-
- }
-
- private void copyAssociation(final Association copyToAssociation, final Association copyFromAssociation) {
- copyToAssociation.setEnd1(copyFromAssociation.getEnd1());
- copyToAssociation.setEnd2(copyFromAssociation.getEnd2());
- copyToAssociation.setName(copyFromAssociation.getName());
- copyToAssociation.setAnnotationAttributes(copyFromAssociation.getAnnotationAttributes());
- copyToAssociation.setAnnotationElements(copyFromAssociation.getAnnotationElements());
- copyToAssociation.setDocumentation(copyFromAssociation.getDocumentation());
-
- }
- }
-
- @Override
- public int getNumberOfAssociationsWithSimilarEndPoints(final JPAEdmAssociationEndView view) {
- int count = 0;
- AssociationEnd currentAssociationEnd1 = view.getEdmAssociationEnd1();
- AssociationEnd currentAssociationEnd2 = view.getEdmAssociationEnd2();
- AssociationEnd end1 = null;
- AssociationEnd end2 = null;
- for (String key : associationMap.keySet()) {
- Association association = associationMap.get(key);
- if (association != null) {
- end1 = association.getEnd1();
- end2 = association.getEnd2();
- if ((end1.getType().equals(currentAssociationEnd1.getType()) && end2.getType().equals(
- currentAssociationEnd2.getType()))
- || (end1.getType().equals(currentAssociationEnd2.getType()) && end2.getType().equals(
- currentAssociationEnd1.getType()))) {
- count++;
- }
- }
- }
- return count;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmAssociationEnd.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmAssociationEnd.java b/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmAssociationEnd.java
deleted file mode 100644
index 1b648ae..0000000
--- a/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmAssociationEnd.java
+++ /dev/null
@@ -1,183 +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.model;
-
-import java.lang.reflect.AnnotatedElement;
-
-import javax.persistence.JoinColumn;
-import javax.persistence.ManyToMany;
-import javax.persistence.OneToMany;
-import javax.persistence.OneToOne;
-import javax.persistence.metamodel.Attribute.PersistentAttributeType;
-
-import org.apache.olingo.odata2.api.edm.EdmMultiplicity;
-import org.apache.olingo.odata2.api.edm.provider.AssociationEnd;
-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.model.JPAEdmAssociationEndView;
-import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmEntityTypeView;
-import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmPropertyView;
-import org.apache.olingo.odata2.processor.core.jpa.access.model.JPAEdmNameBuilder;
-
-public class JPAEdmAssociationEnd extends JPAEdmBaseViewImpl implements JPAEdmAssociationEndView {
-
- private JPAEdmEntityTypeView entityTypeView = null;
- private JPAEdmPropertyView propertyView = null;
- private AssociationEnd currentAssociationEnd1 = null;
- private AssociationEnd currentAssociationEnd2 = null;
- private String columnName;
- private String referencedColumnName;
- private String mappedBy;
- private String ownerPropertyName;
-
- public JPAEdmAssociationEnd(final JPAEdmEntityTypeView entityTypeView, final JPAEdmPropertyView propertyView) {
- super(entityTypeView);
- this.entityTypeView = entityTypeView;
- this.propertyView = propertyView;
- }
-
- @Override
- public JPAEdmBuilder getBuilder() {
- if (builder == null) {
- builder = new JPAEdmAssociationEndBuilder();
- }
-
- return builder;
- }
-
- @Override
- public AssociationEnd getEdmAssociationEnd1() {
- return currentAssociationEnd1;
- }
-
- @Override
- public AssociationEnd getEdmAssociationEnd2() {
- return currentAssociationEnd2;
- }
-
- private class JPAEdmAssociationEndBuilder implements JPAEdmBuilder {
-
- @Override
- public void build() throws ODataJPAModelException {
-
- JoinColumn joinColumn = null;
-
- currentAssociationEnd1 = new AssociationEnd();
- currentAssociationEnd2 = new AssociationEnd();
-
- JPAEdmNameBuilder.build(JPAEdmAssociationEnd.this, entityTypeView, propertyView);
-
- currentAssociationEnd1.setRole(currentAssociationEnd1.getType().getName());
- currentAssociationEnd2.setRole(currentAssociationEnd2.getType().getName());
-
- setEdmMultiplicity(propertyView.getJPAAttribute().getPersistentAttributeType());
-
- AnnotatedElement annotatedElement = (AnnotatedElement) propertyView.getJPAAttribute().getJavaMember();
- if (annotatedElement != null) {
- joinColumn = annotatedElement.getAnnotation(JoinColumn.class);
- if (joinColumn != null) {
- columnName = joinColumn.name();
- referencedColumnName = joinColumn.referencedColumnName();
- }
-
- }
- ownerPropertyName = propertyView.getJPAAttribute().getName();
-
- }
-
- private void setEdmMultiplicity(final PersistentAttributeType type) {
- AnnotatedElement annotatedElement = (AnnotatedElement) propertyView.getJPAAttribute().getJavaMember();
- switch (type) {
- case ONE_TO_MANY:
- currentAssociationEnd1.setMultiplicity(EdmMultiplicity.ONE);
- currentAssociationEnd2.setMultiplicity(EdmMultiplicity.MANY);
- if (annotatedElement != null) {
- OneToMany reln = annotatedElement.getAnnotation(OneToMany.class);
- if (reln != null) {
- mappedBy = reln.mappedBy();
- }
- }
- break;
- case MANY_TO_MANY:
- currentAssociationEnd1.setMultiplicity(EdmMultiplicity.MANY);
- currentAssociationEnd2.setMultiplicity(EdmMultiplicity.MANY);
- if (annotatedElement != null) {
- ManyToMany reln = annotatedElement.getAnnotation(ManyToMany.class);
- if (reln != null) {
- mappedBy = reln.mappedBy();
- }
- }
- break;
- case MANY_TO_ONE:
- currentAssociationEnd1.setMultiplicity(EdmMultiplicity.MANY);
- currentAssociationEnd2.setMultiplicity(EdmMultiplicity.ONE);
- break;
- case ONE_TO_ONE:
- currentAssociationEnd1.setMultiplicity(EdmMultiplicity.ONE);
- currentAssociationEnd2.setMultiplicity(EdmMultiplicity.ONE);
- if (annotatedElement != null) {
- OneToOne reln = annotatedElement.getAnnotation(OneToOne.class);
- if (reln != null) {
- mappedBy = reln.mappedBy();
- }
- }
- break;
- default:
- break;
- }
- }
- }
-
- @Override
- public boolean compare(final AssociationEnd end1, final AssociationEnd end2) {
- if ((end1.getType().equals(currentAssociationEnd1.getType())
- && end2.getType().equals(currentAssociationEnd2.getType())
- && end1.getMultiplicity().equals(currentAssociationEnd1.getMultiplicity()) && end2.getMultiplicity().equals(
- currentAssociationEnd2.getMultiplicity()))
- || (end1.getType().equals(currentAssociationEnd2.getType())
- && end2.getType().equals(currentAssociationEnd1.getType())
- && end1.getMultiplicity().equals(currentAssociationEnd2.getMultiplicity()) && end2.getMultiplicity()
- .equals(currentAssociationEnd1.getMultiplicity()))) {
- return true;
- }
-
- return false;
- }
-
- @Override
- public String getJoinColumnName() {
- return columnName;
- }
-
- @Override
- public String getJoinColumnReferenceColumnName() {
- return referencedColumnName;
- }
-
- @Override
- public String getMappedByName() {
- return mappedBy;
- }
-
- @Override
- public String getOwningPropertyName() {
- return ownerPropertyName;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmAssociationSet.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmAssociationSet.java b/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmAssociationSet.java
deleted file mode 100644
index 925a497..0000000
--- a/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmAssociationSet.java
+++ /dev/null
@@ -1,131 +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.model;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.olingo.odata2.api.edm.FullQualifiedName;
-import org.apache.olingo.odata2.api.edm.provider.Association;
-import org.apache.olingo.odata2.api.edm.provider.AssociationSet;
-import org.apache.olingo.odata2.api.edm.provider.AssociationSetEnd;
-import org.apache.olingo.odata2.api.edm.provider.EntitySet;
-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.model.JPAEdmAssociationSetView;
-import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmAssociationView;
-import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmEntitySetView;
-import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmSchemaView;
-import org.apache.olingo.odata2.processor.core.jpa.access.model.JPAEdmNameBuilder;
-
-public class JPAEdmAssociationSet extends JPAEdmBaseViewImpl implements JPAEdmAssociationSetView {
-
- private JPAEdmSchemaView schemaView;
- private AssociationSet currentAssociationSet;
- private List<AssociationSet> associationSetList;
- private Association currentAssociation;
-
- public JPAEdmAssociationSet(final JPAEdmSchemaView view) {
- super(view);
- schemaView = view;
- }
-
- @Override
- public JPAEdmBuilder getBuilder() {
- if (builder == null) {
- builder = new JPAEdmAssociationSetBuilder();
- }
-
- return builder;
- }
-
- @Override
- public List<AssociationSet> getConsistentEdmAssociationSetList() {
- return associationSetList;
- }
-
- @Override
- public AssociationSet getEdmAssociationSet() {
- return currentAssociationSet;
- }
-
- @Override
- public Association getEdmAssociation() {
- return currentAssociation;
- }
-
- private class JPAEdmAssociationSetBuilder implements JPAEdmBuilder {
-
- @Override
- public void build() throws ODataJPAModelException {
-
- if (associationSetList == null) {
- associationSetList = new ArrayList<AssociationSet>();
- }
-
- JPAEdmAssociationView associationView = schemaView.getJPAEdmAssociationView();
- JPAEdmEntitySetView entitySetView = schemaView.getJPAEdmEntityContainerView().getJPAEdmEntitySetView();
-
- List<EntitySet> entitySetList = entitySetView.getConsistentEdmEntitySetList();
- if (associationView.isConsistent()) {
- for (Association association : associationView.getConsistentEdmAssociationList()) {
-
- currentAssociation = association;
-
- FullQualifiedName fQname =
- new FullQualifiedName(schemaView.getEdmSchema().getNamespace(), association.getName());
- currentAssociationSet = new AssociationSet();
- currentAssociationSet.setAssociation(fQname);
-
- int endCount = 0;
- short endFlag = 0;
- for (EntitySet entitySet : entitySetList) {
- fQname = entitySet.getEntityType();
- endFlag = 0;
- if (fQname.equals(association.getEnd1().getType()) || ++endFlag > 1
- || fQname.equals(association.getEnd2().getType())) {
-
- AssociationSetEnd end = new AssociationSetEnd();
- end.setEntitySet(entitySet.getName());
- if (endFlag == 0) {
- currentAssociationSet.setEnd1(end);
- end.setRole(association.getEnd1().getRole());
- endCount++;
- } else {
- endCount++;
- currentAssociationSet.setEnd2(end);
- end.setRole(association.getEnd2().getRole());
- }
-
- if (endCount == 2) {
- break;
- }
- }
- }
- if (endCount == 2) {
- JPAEdmNameBuilder.build(JPAEdmAssociationSet.this);
- associationSetList.add(currentAssociationSet);
- }
-
- }
-
- }
- }
- }
-}
[31/37] [OLINGO-82] Renamed the project folder name to
odata2-jpa-processor
Posted by ch...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/exception/ODataJPAMessageServiceDefault.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/exception/ODataJPAMessageServiceDefault.java b/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/exception/ODataJPAMessageServiceDefault.java
new file mode 100644
index 0000000..d7f3964
--- /dev/null
+++ b/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/exception/ODataJPAMessageServiceDefault.java
@@ -0,0 +1,122 @@
+/*******************************************************************************
+ * 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.exception;
+
+import java.util.Arrays;
+import java.util.Formatter;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.MissingFormatArgumentException;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+import org.apache.olingo.odata2.api.exception.MessageReference;
+import org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPAMessageService;
+import org.apache.olingo.odata2.processor.core.jpa.ODataJPAContextImpl;
+
+public class ODataJPAMessageServiceDefault implements ODataJPAMessageService {
+
+ private static final String BUNDLE_NAME = "jpaprocessor_msg"; //$NON-NLS-1$
+ private static final Map<Locale, ODataJPAMessageService> LOCALE_2_MESSAGE_SERVICE =
+ new HashMap<Locale, ODataJPAMessageService>();
+ private static final ResourceBundle defaultResourceBundle = ResourceBundle.getBundle(BUNDLE_NAME);
+ private final ResourceBundle resourceBundle;
+ private final Locale lanLocale;
+
+ @Override
+ public String getLocalizedMessage(final MessageReference context, final Throwable exception) {
+
+ Object[] contentAsArray = context.getContent().toArray(new Object[0]);
+
+ if (contentAsArray.length == 0 && exception != null) {
+ contentAsArray = new Object[2];
+ contentAsArray[0] = exception.getStackTrace()[1].getClassName();
+ contentAsArray[1] = exception.getMessage();
+ }
+ String value = null;
+ String key = context.getKey();
+
+ try {
+ value = getMessage(key);
+ StringBuilder builder = new StringBuilder();
+ Formatter f = null;
+ if (lanLocale == null) {
+ f = new Formatter();
+ } else {
+ f = new Formatter(builder, lanLocale);
+ }
+ f.format(value, contentAsArray);
+ f.close();
+ return builder.toString();
+
+ } catch (MissingResourceException e) {
+ return "Missing message for key '" + key + "'!";
+ } catch (MissingFormatArgumentException e) {
+ return "Missing replacement for place holder in value '" + value + "' for following arguments '"
+ + Arrays.toString(contentAsArray) + "'!";
+ }
+ }
+
+ private ODataJPAMessageServiceDefault(final ResourceBundle resourceBundle, final Locale locale) {
+ this.resourceBundle = resourceBundle;
+ lanLocale = locale;
+ }
+
+ public static ODataJPAMessageService getInstance(final Locale locale) {
+
+ Locale acceptedLocale = Locale.ENGLISH;
+ if ((ODataJPAContextImpl.getContextInThreadLocal() != null)
+ && (ODataJPAContextImpl.getContextInThreadLocal().getAcceptableLanguages() != null)) {
+
+ List<Locale> acceptedLanguages = ODataJPAContextImpl.getContextInThreadLocal().getAcceptableLanguages();
+
+ Iterator<Locale> itr = acceptedLanguages.iterator();
+
+ while (itr.hasNext()) {
+
+ Locale tempLocale = itr.next();
+ if (ResourceBundle.getBundle(BUNDLE_NAME, tempLocale).getLocale().equals(tempLocale)) {
+ acceptedLocale = tempLocale;
+ break;
+ }
+ }
+ }
+
+ ODataJPAMessageService messagesInstance = LOCALE_2_MESSAGE_SERVICE.get(acceptedLocale);
+ if (messagesInstance == null) {
+ ResourceBundle resourceBundle = ResourceBundle.getBundle(BUNDLE_NAME, acceptedLocale);
+
+ if (resourceBundle != null) {
+ messagesInstance = new ODataJPAMessageServiceDefault(resourceBundle, acceptedLocale);
+ LOCALE_2_MESSAGE_SERVICE.put(acceptedLocale, messagesInstance);
+ } else if (defaultResourceBundle != null) {
+ messagesInstance = new ODataJPAMessageServiceDefault(defaultResourceBundle, null);
+ }
+
+ }
+ return messagesInstance;
+ }
+
+ private String getMessage(final String key) {
+ return resourceBundle.getString(key);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/factory/ODataJPAFactoryImpl.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/factory/ODataJPAFactoryImpl.java b/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/factory/ODataJPAFactoryImpl.java
new file mode 100644
index 0000000..2b14f9d
--- /dev/null
+++ b/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/factory/ODataJPAFactoryImpl.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.factory;
+
+import java.util.Locale;
+
+import org.apache.olingo.odata2.api.edm.provider.EdmProvider;
+import org.apache.olingo.odata2.api.processor.ODataSingleProcessor;
+import org.apache.olingo.odata2.processor.api.jpa.ODataJPAContext;
+import org.apache.olingo.odata2.processor.api.jpa.access.JPAEdmMappingModelAccess;
+import org.apache.olingo.odata2.processor.api.jpa.access.JPAMethodContext.JPAMethodContextBuilder;
+import org.apache.olingo.odata2.processor.api.jpa.access.JPAProcessor;
+import org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPAMessageService;
+import org.apache.olingo.odata2.processor.api.jpa.factory.JPAAccessFactory;
+import org.apache.olingo.odata2.processor.api.jpa.factory.JPQLBuilderFactory;
+import org.apache.olingo.odata2.processor.api.jpa.factory.ODataJPAAccessFactory;
+import org.apache.olingo.odata2.processor.api.jpa.factory.ODataJPAFactory;
+import org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLContext.JPQLContextBuilder;
+import org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLContextType;
+import org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLContextView;
+import org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLStatement.JPQLStatementBuilder;
+import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmModelView;
+import org.apache.olingo.odata2.processor.core.jpa.ODataJPAContextImpl;
+import org.apache.olingo.odata2.processor.core.jpa.ODataJPAProcessorDefault;
+import org.apache.olingo.odata2.processor.core.jpa.access.data.JPAFunctionContext;
+import org.apache.olingo.odata2.processor.core.jpa.access.data.JPAProcessorImpl;
+import org.apache.olingo.odata2.processor.core.jpa.access.model.JPAEdmMappingModelService;
+import org.apache.olingo.odata2.processor.core.jpa.edm.ODataJPAEdmProvider;
+import org.apache.olingo.odata2.processor.core.jpa.exception.ODataJPAMessageServiceDefault;
+import org.apache.olingo.odata2.processor.core.jpa.jpql.JPQLJoinSelectContext;
+import org.apache.olingo.odata2.processor.core.jpa.jpql.JPQLJoinSelectSingleContext;
+import org.apache.olingo.odata2.processor.core.jpa.jpql.JPQLJoinSelectSingleStatementBuilder;
+import org.apache.olingo.odata2.processor.core.jpa.jpql.JPQLJoinStatementBuilder;
+import org.apache.olingo.odata2.processor.core.jpa.jpql.JPQLSelectContext;
+import org.apache.olingo.odata2.processor.core.jpa.jpql.JPQLSelectSingleContext;
+import org.apache.olingo.odata2.processor.core.jpa.jpql.JPQLSelectSingleStatementBuilder;
+import org.apache.olingo.odata2.processor.core.jpa.jpql.JPQLSelectStatementBuilder;
+import org.apache.olingo.odata2.processor.core.jpa.model.JPAEdmModel;
+
+public class ODataJPAFactoryImpl extends ODataJPAFactory {
+
+ @Override
+ public JPQLBuilderFactory getJPQLBuilderFactory() {
+ return JPQLBuilderFactoryImpl.create();
+ };
+
+ @Override
+ public JPAAccessFactory getJPAAccessFactory() {
+ return JPAAccessFactoryImpl.create();
+ };
+
+ @Override
+ public ODataJPAAccessFactory getODataJPAAccessFactory() {
+ return ODataJPAAccessFactoryImpl.create();
+ };
+
+ private static class JPQLBuilderFactoryImpl implements JPQLBuilderFactory {
+
+ private static JPQLBuilderFactoryImpl factory = null;
+
+ private JPQLBuilderFactoryImpl() {}
+
+ @Override
+ public JPQLStatementBuilder getStatementBuilder(final JPQLContextView context) {
+ JPQLStatementBuilder builder = null;
+ switch (context.getType()) {
+ case SELECT:
+ case SELECT_COUNT: // for $count, Same as select
+ builder = new JPQLSelectStatementBuilder(context);
+ break;
+ case SELECT_SINGLE:
+ builder = new JPQLSelectSingleStatementBuilder(context);
+ break;
+ case JOIN:
+ case JOIN_COUNT: // for $count, Same as join
+ builder = new JPQLJoinStatementBuilder(context);
+ break;
+ case JOIN_SINGLE:
+ builder = new JPQLJoinSelectSingleStatementBuilder(context);
+ default:
+ break;
+ }
+
+ return builder;
+ }
+
+ @Override
+ public JPQLContextBuilder getContextBuilder(final JPQLContextType contextType) {
+ JPQLContextBuilder contextBuilder = null;
+
+ switch (contextType) {
+ case SELECT:
+ JPQLSelectContext selectContext = new JPQLSelectContext(false);
+ contextBuilder = selectContext.new JPQLSelectContextBuilder();
+ break;
+ case SELECT_SINGLE:
+ JPQLSelectSingleContext singleSelectContext = new JPQLSelectSingleContext();
+ contextBuilder = singleSelectContext.new JPQLSelectSingleContextBuilder();
+ break;
+ case JOIN:
+ JPQLJoinSelectContext joinContext = new JPQLJoinSelectContext(false);
+ contextBuilder = joinContext.new JPQLJoinContextBuilder();
+ break;
+ case JOIN_SINGLE:
+ JPQLJoinSelectSingleContext joinSingleContext = new JPQLJoinSelectSingleContext();
+ contextBuilder = joinSingleContext.new JPQLJoinSelectSingleContextBuilder();
+ break;
+ case SELECT_COUNT:
+ JPQLSelectContext selectCountContext = new JPQLSelectContext(true);
+ contextBuilder = selectCountContext.new JPQLSelectContextBuilder();
+ break;
+ case JOIN_COUNT:
+ JPQLJoinSelectContext joinCountContext = new JPQLJoinSelectContext(true);
+ contextBuilder = joinCountContext.new JPQLJoinContextBuilder();
+ default:
+ break;
+ }
+
+ return contextBuilder;
+ }
+
+ private static JPQLBuilderFactory create() {
+ if (factory == null) {
+ return new JPQLBuilderFactoryImpl();
+ } else {
+ return factory;
+ }
+ }
+
+ @Override
+ public JPAMethodContextBuilder getJPAMethodContextBuilder(final JPQLContextType contextType) {
+
+ JPAMethodContextBuilder contextBuilder = null;
+ switch (contextType) {
+ case FUNCTION:
+ JPAFunctionContext methodConext = new JPAFunctionContext();
+ contextBuilder = methodConext.new JPAFunctionContextBuilder();
+
+ break;
+ default:
+ break;
+ }
+ return contextBuilder;
+ }
+
+ }
+
+ private static class ODataJPAAccessFactoryImpl implements ODataJPAAccessFactory {
+
+ private static ODataJPAAccessFactoryImpl factory = null;
+
+ private ODataJPAAccessFactoryImpl() {}
+
+ @Override
+ public ODataSingleProcessor createODataProcessor(final ODataJPAContext oDataJPAContext) {
+ return new ODataJPAProcessorDefault(oDataJPAContext);
+ }
+
+ @Override
+ public EdmProvider createJPAEdmProvider(final ODataJPAContext oDataJPAContext) {
+ return new ODataJPAEdmProvider(oDataJPAContext);
+ }
+
+ @Override
+ public ODataJPAContext createODataJPAContext() {
+ return new ODataJPAContextImpl();
+ }
+
+ private static ODataJPAAccessFactoryImpl create() {
+ if (factory == null) {
+ return new ODataJPAAccessFactoryImpl();
+ } else {
+ return factory;
+ }
+ }
+
+ @Override
+ public ODataJPAMessageService getODataJPAMessageService(final Locale locale) {
+ return ODataJPAMessageServiceDefault.getInstance(locale);
+ }
+
+ }
+
+ private static class JPAAccessFactoryImpl implements JPAAccessFactory {
+
+ private static JPAAccessFactoryImpl factory = null;
+
+ private JPAAccessFactoryImpl() {}
+
+ @Override
+ public JPAEdmModelView getJPAEdmModelView(final ODataJPAContext oDataJPAContext) {
+ JPAEdmModelView view = null;
+
+ view = new JPAEdmModel(oDataJPAContext);
+ return view;
+ }
+
+ @Override
+ public JPAProcessor getJPAProcessor(final ODataJPAContext oDataJPAContext) {
+ JPAProcessor jpaProcessor = new JPAProcessorImpl(oDataJPAContext);
+
+ return jpaProcessor;
+ }
+
+ private static JPAAccessFactoryImpl create() {
+ if (factory == null) {
+ return new JPAAccessFactoryImpl();
+ } else {
+ return factory;
+ }
+ }
+
+ @Override
+ public JPAEdmMappingModelAccess getJPAEdmMappingModelAccess(final ODataJPAContext oDataJPAContext) {
+ JPAEdmMappingModelAccess mappingModelAccess = new JPAEdmMappingModelService(oDataJPAContext);
+
+ return mappingModelAccess;
+ }
+
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLJoinSelectContext.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLJoinSelectContext.java b/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLJoinSelectContext.java
new file mode 100644
index 0000000..6026464
--- /dev/null
+++ b/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLJoinSelectContext.java
@@ -0,0 +1,171 @@
+/*******************************************************************************
+ * 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.jpql;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.olingo.odata2.api.edm.EdmEntityType;
+import org.apache.olingo.odata2.api.edm.EdmException;
+import org.apache.olingo.odata2.api.edm.EdmMapping;
+import org.apache.olingo.odata2.api.edm.EdmNavigationProperty;
+import org.apache.olingo.odata2.api.edm.provider.Mapping;
+import org.apache.olingo.odata2.api.exception.ODataException;
+import org.apache.olingo.odata2.api.uri.NavigationSegment;
+import org.apache.olingo.odata2.processor.api.jpa.access.JPAJoinClause;
+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.jpql.JPQLContext;
+import org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLContextType;
+import org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLJoinContextView;
+import org.apache.olingo.odata2.processor.core.jpa.ODataExpressionParser;
+
+public class JPQLJoinSelectContext extends JPQLSelectContext implements JPQLJoinContextView {
+
+ private List<JPAJoinClause> jpaJoinClauses = null;
+
+ protected void setJPAOuterJoinClause(final List<JPAJoinClause> jpaOuterJoinClauses) {
+ jpaJoinClauses = jpaOuterJoinClauses;
+ }
+
+ public JPQLJoinSelectContext(final boolean isCountOnly) {
+ super(isCountOnly);
+ }
+
+ public class JPQLJoinContextBuilder extends JPQLSelectContextBuilder {
+
+ protected int relationShipAliasCounter = 0;
+
+ @Override
+ public JPQLContext build() throws ODataJPAModelException, ODataJPARuntimeException {
+ try {
+
+ if (JPQLJoinSelectContext.this.isCountOnly) {
+ setType(JPQLContextType.JOIN_COUNT);
+ } else {
+ setType(JPQLContextType.JOIN);
+ }
+
+ setJPAOuterJoinClause(generateJoinClauses());
+
+ if (!jpaJoinClauses.isEmpty()) {
+ JPAJoinClause joinClause = jpaJoinClauses.get(jpaJoinClauses.size() - 1);
+ setJPAEntityName(joinClause.getEntityName());
+ setJPAEntityAlias(joinClause.getEntityRelationShipAlias());
+ }
+
+ setOrderByCollection(generateOrderByFileds());
+
+ setSelectExpression(generateSelectExpression());
+
+ setWhereExpression(generateWhereExpression());
+
+ } catch (ODataException e) {
+ throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.INNER_EXCEPTION, e);
+ }
+
+ return JPQLJoinSelectContext.this;
+ }
+
+ protected List<JPAJoinClause> generateJoinClauses() throws ODataJPARuntimeException, EdmException {
+
+ List<JPAJoinClause> jpaOuterJoinClauses = new ArrayList<JPAJoinClause>();
+ JPAJoinClause jpaOuterJoinClause = null;
+ String joinCondition = null;
+ String entityAlias = generateJPAEntityAlias();
+ joinCondition = ODataExpressionParser.parseKeyPredicates(entitySetView.getKeyPredicates(), entityAlias);
+
+ EdmEntityType entityType = entitySetView.getStartEntitySet().getEntityType();
+ Mapping mapping = (Mapping) entityType.getMapping();
+ String entityTypeName = null;
+ if (mapping != null) {
+ entityTypeName = mapping.getInternalName();
+ } else {
+ entityTypeName = entityType.getName();
+ }
+
+ jpaOuterJoinClause =
+ new JPAJoinClause(entityTypeName, entityAlias, null, null, joinCondition, JPAJoinClause.JOIN.INNER);
+
+ jpaOuterJoinClauses.add(jpaOuterJoinClause);
+
+ for (NavigationSegment navigationSegment : entitySetView.getNavigationSegments()) {
+
+ EdmNavigationProperty navigationProperty = navigationSegment.getNavigationProperty();
+
+ String relationShipAlias = generateRelationShipAlias();
+
+ joinCondition =
+ ODataExpressionParser.parseKeyPredicates(navigationSegment.getKeyPredicates(), relationShipAlias);
+
+ jpaOuterJoinClause =
+ new JPAJoinClause(getFromEntityName(navigationProperty), entityAlias,
+ getRelationShipName(navigationProperty), relationShipAlias, joinCondition, JPAJoinClause.JOIN.INNER);
+
+ jpaOuterJoinClauses.add(jpaOuterJoinClause);
+
+ }
+
+ return jpaOuterJoinClauses;
+ }
+
+ private String getFromEntityName(final EdmNavigationProperty navigationProperty) throws EdmException {
+
+ String fromRole = navigationProperty.getFromRole();
+
+ EdmEntityType toEntityType = navigationProperty.getRelationship().getEnd(fromRole).getEntityType();
+
+ EdmMapping mapping = toEntityType.getMapping();
+
+ String entityName = null;
+ if (mapping != null) {
+ entityName = mapping.getInternalName();
+ } else {
+ entityName = toEntityType.getName();
+ }
+
+ return entityName;
+
+ }
+
+ private String getRelationShipName(final EdmNavigationProperty navigationProperty) throws EdmException {
+
+ EdmMapping mapping = navigationProperty.getMapping();
+
+ String relationShipName = null;
+ if (mapping != null) {
+ relationShipName = mapping.getInternalName();
+ } else {
+ relationShipName = navigationProperty.getName();
+ }
+
+ return relationShipName;
+ }
+
+ private String generateRelationShipAlias() {
+ return new String("R" + ++relationShipAliasCounter);
+ }
+ }
+
+ @Override
+ public List<JPAJoinClause> getJPAJoinClauses() {
+ return jpaJoinClauses;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLJoinSelectSingleContext.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLJoinSelectSingleContext.java b/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLJoinSelectSingleContext.java
new file mode 100644
index 0000000..c25eae9
--- /dev/null
+++ b/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLJoinSelectSingleContext.java
@@ -0,0 +1,158 @@
+/*******************************************************************************
+ * 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.jpql;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.olingo.odata2.api.edm.EdmEntityType;
+import org.apache.olingo.odata2.api.edm.EdmException;
+import org.apache.olingo.odata2.api.edm.EdmMapping;
+import org.apache.olingo.odata2.api.edm.EdmNavigationProperty;
+import org.apache.olingo.odata2.api.edm.provider.Mapping;
+import org.apache.olingo.odata2.api.uri.NavigationSegment;
+import org.apache.olingo.odata2.processor.api.jpa.access.JPAJoinClause;
+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.jpql.JPQLContext;
+import org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLContextType;
+import org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLJoinSelectSingleContextView;
+import org.apache.olingo.odata2.processor.core.jpa.ODataExpressionParser;
+
+public class JPQLJoinSelectSingleContext extends JPQLSelectSingleContext implements JPQLJoinSelectSingleContextView {
+
+ private List<JPAJoinClause> jpaJoinClauses = null;
+
+ protected void setJPAJoinClause(final List<JPAJoinClause> jpaJoinClauses) {
+ this.jpaJoinClauses = jpaJoinClauses;
+ }
+
+ public class JPQLJoinSelectSingleContextBuilder extends JPQLSelectSingleContextBuilder {
+
+ protected int relationShipAliasCounter = 0;
+
+ @Override
+ public JPQLContext build() throws ODataJPAModelException, ODataJPARuntimeException {
+ try {
+ setType(JPQLContextType.JOIN_SINGLE);
+ setJPAJoinClause(generateJoinClauses());
+
+ if (!jpaJoinClauses.isEmpty()) {
+ JPAJoinClause joinClause = jpaJoinClauses.get(jpaJoinClauses.size() - 1);
+ setJPAEntityName(joinClause.getEntityName());
+ setJPAEntityAlias(joinClause.getEntityRelationShipAlias());
+ }
+
+ setKeyPredicates(entityView.getKeyPredicates());
+
+ setSelectExpression(generateSelectExpression());
+
+ } catch (EdmException e) {
+ throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL, e);
+ }
+
+ return JPQLJoinSelectSingleContext.this;
+ }
+
+ protected List<JPAJoinClause> generateJoinClauses() throws ODataJPARuntimeException, EdmException {
+
+ List<JPAJoinClause> jpaOuterJoinClauses = new ArrayList<JPAJoinClause>();
+ JPAJoinClause jpaOuterJoinClause = null;
+ String joinCondition = null;
+ String entityAlias = generateJPAEntityAlias();
+ joinCondition = ODataExpressionParser.parseKeyPredicates(entityView.getKeyPredicates(), entityAlias);
+
+ EdmEntityType entityType = entityView.getStartEntitySet().getEntityType();
+ Mapping mapping = (Mapping) entityType.getMapping();
+ String entityTypeName = null;
+ if (mapping != null) {
+ entityTypeName = mapping.getInternalName();
+ } else {
+ entityTypeName = entityType.getName();
+ }
+
+ jpaOuterJoinClause =
+ new JPAJoinClause(entityTypeName, entityAlias, null, null, joinCondition, JPAJoinClause.JOIN.INNER);
+
+ jpaOuterJoinClauses.add(jpaOuterJoinClause);
+
+ for (NavigationSegment navigationSegment : entityView.getNavigationSegments()) {
+
+ EdmNavigationProperty navigationProperty = navigationSegment.getNavigationProperty();
+
+ String relationShipAlias = generateRelationShipAlias();
+
+ joinCondition =
+ ODataExpressionParser.parseKeyPredicates(navigationSegment.getKeyPredicates(), relationShipAlias);
+
+ jpaOuterJoinClause =
+ new JPAJoinClause(getFromEntityName(navigationProperty), entityAlias,
+ getRelationShipName(navigationProperty), relationShipAlias, joinCondition, JPAJoinClause.JOIN.INNER);
+
+ jpaOuterJoinClauses.add(jpaOuterJoinClause);
+
+ }
+
+ return jpaOuterJoinClauses;
+ }
+
+ private String getFromEntityName(final EdmNavigationProperty navigationProperty) throws EdmException {
+
+ String fromRole = navigationProperty.getFromRole();
+
+ EdmEntityType fromEntityType = navigationProperty.getRelationship().getEnd(fromRole).getEntityType();
+
+ EdmMapping mapping = fromEntityType.getMapping();
+
+ String entityName = null;
+ if (mapping != null) {
+ entityName = mapping.getInternalName();
+ } else {
+ entityName = fromEntityType.getName();
+ }
+
+ return entityName;
+
+ }
+
+ private String getRelationShipName(final EdmNavigationProperty navigationProperty) throws EdmException {
+
+ EdmMapping mapping = navigationProperty.getMapping();
+
+ String relationShipName = null;
+ if (mapping != null) {
+ relationShipName = mapping.getInternalName();
+ } else {
+ relationShipName = navigationProperty.getName();
+ }
+
+ return relationShipName;
+ }
+
+ private String generateRelationShipAlias() {
+ return new String("R" + ++relationShipAliasCounter);
+ }
+ }
+
+ @Override
+ public List<JPAJoinClause> getJPAJoinClauses() {
+ return jpaJoinClauses;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLJoinSelectSingleStatementBuilder.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLJoinSelectSingleStatementBuilder.java b/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLJoinSelectSingleStatementBuilder.java
new file mode 100644
index 0000000..fd06892
--- /dev/null
+++ b/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLJoinSelectSingleStatementBuilder.java
@@ -0,0 +1,106 @@
+/*******************************************************************************
+ * 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.jpql;
+
+import java.util.List;
+
+import org.apache.olingo.odata2.processor.api.jpa.access.JPAJoinClause;
+import org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPARuntimeException;
+import org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLContextView;
+import org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLJoinSelectSingleContextView;
+import org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLStatement;
+import org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLStatement.JPQLStatementBuilder;
+
+public class JPQLJoinSelectSingleStatementBuilder extends JPQLStatementBuilder {
+
+ JPQLStatement jpqlStatement;
+ private JPQLJoinSelectSingleContextView context;
+
+ public JPQLJoinSelectSingleStatementBuilder(final JPQLContextView context) {
+ this.context = (JPQLJoinSelectSingleContextView) context;
+ }
+
+ @Override
+ public JPQLStatement build() throws ODataJPARuntimeException {
+ jpqlStatement = createStatement(createJPQLQuery());
+ return jpqlStatement;
+
+ }
+
+ private String createJPQLQuery() throws ODataJPARuntimeException {
+
+ StringBuilder jpqlQuery = new StringBuilder();
+ StringBuilder joinWhereCondition = null;
+
+ jpqlQuery.append(JPQLStatement.KEYWORD.SELECT).append(JPQLStatement.DELIMITER.SPACE);
+ jpqlQuery.append(context.getSelectExpression()).append(JPQLStatement.DELIMITER.SPACE);
+ jpqlQuery.append(JPQLStatement.KEYWORD.FROM).append(JPQLStatement.DELIMITER.SPACE);
+
+ if (context.getJPAJoinClauses() != null && context.getJPAJoinClauses().size() > 0) {
+ List<JPAJoinClause> joinClauseList = context.getJPAJoinClauses();
+ JPAJoinClause joinClause = joinClauseList.get(0);
+ String joinCondition = joinClause.getJoinCondition();
+ joinWhereCondition = new StringBuilder();
+ if (joinCondition != null) {
+ joinWhereCondition.append(joinCondition);
+ }
+ String relationShipAlias = null;
+ joinClause = joinClauseList.get(1);
+ jpqlQuery.append(joinClause.getEntityName()).append(JPQLStatement.DELIMITER.SPACE);
+ jpqlQuery.append(joinClause.getEntityAlias());
+
+ int i = 1;
+ int limit = joinClauseList.size();
+ relationShipAlias = joinClause.getEntityAlias();
+ while (i < limit) {
+ jpqlQuery.append(JPQLStatement.DELIMITER.SPACE);
+ jpqlQuery.append(JPQLStatement.KEYWORD.JOIN).append(JPQLStatement.DELIMITER.SPACE);
+
+ joinClause = joinClauseList.get(i);
+ jpqlQuery.append(relationShipAlias).append(JPQLStatement.DELIMITER.PERIOD);
+ jpqlQuery.append(joinClause.getEntityRelationShip()).append(JPQLStatement.DELIMITER.SPACE);
+ jpqlQuery.append(joinClause.getEntityRelationShipAlias());
+
+ relationShipAlias = joinClause.getEntityRelationShipAlias();
+ i++;
+
+ joinCondition = joinClause.getJoinCondition();
+ if (joinCondition != null) {
+ joinWhereCondition.append(JPQLStatement.DELIMITER.SPACE + JPQLStatement.Operator.AND
+ + JPQLStatement.DELIMITER.SPACE);
+
+ joinWhereCondition.append(joinCondition);
+ }
+
+ }
+ } else {
+ throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.JOIN_CLAUSE_EXPECTED, null);
+ }
+
+ if (joinWhereCondition.length() > 0) {
+ jpqlQuery.append(JPQLStatement.DELIMITER.SPACE);
+ jpqlQuery.append(JPQLStatement.KEYWORD.WHERE).append(JPQLStatement.DELIMITER.SPACE);
+ jpqlQuery.append(joinWhereCondition.toString());
+ }
+
+ return jpqlQuery.toString();
+
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLJoinStatementBuilder.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLJoinStatementBuilder.java b/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLJoinStatementBuilder.java
new file mode 100644
index 0000000..57d0e28
--- /dev/null
+++ b/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLJoinStatementBuilder.java
@@ -0,0 +1,145 @@
+/*******************************************************************************
+ * 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.jpql;
+
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map.Entry;
+
+import org.apache.olingo.odata2.processor.api.jpa.access.JPAJoinClause;
+import org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPARuntimeException;
+import org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLContextType;
+import org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLContextView;
+import org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLJoinContextView;
+import org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLStatement;
+import org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLStatement.JPQLStatementBuilder;
+
+public class JPQLJoinStatementBuilder extends JPQLStatementBuilder {
+
+ JPQLStatement jpqlStatement;
+ private JPQLJoinContextView context;
+
+ public JPQLJoinStatementBuilder(final JPQLContextView context) {
+ this.context = (JPQLJoinContextView) context;
+ }
+
+ @Override
+ public JPQLStatement build() throws ODataJPARuntimeException {
+ jpqlStatement = createStatement(createJPQLQuery());
+ return jpqlStatement;
+
+ }
+
+ private String createJPQLQuery() throws ODataJPARuntimeException {
+
+ StringBuilder jpqlQuery = new StringBuilder();
+ StringBuilder joinWhereCondition = null;
+
+ jpqlQuery.append(JPQLStatement.KEYWORD.SELECT).append(JPQLStatement.DELIMITER.SPACE);
+ if (context.getType().equals(JPQLContextType.JOIN_COUNT)) {// $COUNT
+ jpqlQuery.append(JPQLStatement.KEYWORD.COUNT).append(JPQLStatement.DELIMITER.SPACE);
+ jpqlQuery.append(JPQLStatement.DELIMITER.PARENTHESIS_LEFT).append(JPQLStatement.DELIMITER.SPACE);
+ jpqlQuery.append(context.getSelectExpression()).append(JPQLStatement.DELIMITER.SPACE);
+ jpqlQuery.append(JPQLStatement.DELIMITER.PARENTHESIS_RIGHT).append(JPQLStatement.DELIMITER.SPACE);
+ } else { // Normal
+ jpqlQuery.append(context.getSelectExpression()).append(JPQLStatement.DELIMITER.SPACE);
+ }
+
+ jpqlQuery.append(JPQLStatement.KEYWORD.FROM).append(JPQLStatement.DELIMITER.SPACE);
+
+ if (context.getJPAJoinClauses() != null && context.getJPAJoinClauses().size() > 0) {
+ List<JPAJoinClause> joinClauseList = context.getJPAJoinClauses();
+ JPAJoinClause joinClause = joinClauseList.get(0);
+ String joinCondition = joinClause.getJoinCondition();
+ joinWhereCondition = new StringBuilder();
+ if (joinCondition != null) {
+ joinWhereCondition.append(joinCondition);
+ }
+ String relationShipAlias = null;
+ joinClause = joinClauseList.get(1);
+ jpqlQuery.append(joinClause.getEntityName()).append(JPQLStatement.DELIMITER.SPACE);
+ jpqlQuery.append(joinClause.getEntityAlias());
+
+ int i = 1;
+ int limit = joinClauseList.size();
+ relationShipAlias = joinClause.getEntityAlias();
+ while (i < limit) {
+ jpqlQuery.append(JPQLStatement.DELIMITER.SPACE);
+ jpqlQuery.append(JPQLStatement.KEYWORD.JOIN).append(JPQLStatement.DELIMITER.SPACE);
+
+ joinClause = joinClauseList.get(i);
+ jpqlQuery.append(relationShipAlias).append(JPQLStatement.DELIMITER.PERIOD);
+ jpqlQuery.append(joinClause.getEntityRelationShip()).append(JPQLStatement.DELIMITER.SPACE);
+ jpqlQuery.append(joinClause.getEntityRelationShipAlias());
+
+ relationShipAlias = joinClause.getEntityRelationShipAlias();
+ i++;
+
+ joinCondition = joinClause.getJoinCondition();
+ if (joinCondition != null) {
+ joinWhereCondition.append(JPQLStatement.DELIMITER.SPACE + JPQLStatement.Operator.AND
+ + JPQLStatement.DELIMITER.SPACE);
+
+ joinWhereCondition.append(joinCondition);
+ }
+ }
+ } else {
+ throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.JOIN_CLAUSE_EXPECTED, null);
+ }
+ String whereExpression = context.getWhereExpression();
+ if (whereExpression != null || joinWhereCondition.length() > 0) {
+ jpqlQuery.append(JPQLStatement.DELIMITER.SPACE).append(JPQLStatement.KEYWORD.WHERE).append(
+ JPQLStatement.DELIMITER.SPACE);
+ if (whereExpression != null) {
+ jpqlQuery.append(whereExpression);
+ if (joinWhereCondition != null) {
+ jpqlQuery.append(JPQLStatement.DELIMITER.SPACE + JPQLStatement.Operator.AND + JPQLStatement.DELIMITER.SPACE);
+ }
+ }
+ if (joinWhereCondition != null) {
+ jpqlQuery.append(joinWhereCondition.toString());
+ }
+
+ }
+
+ if (context.getOrderByCollection() != null && context.getOrderByCollection().size() > 0) {
+
+ StringBuilder orderByBuilder = new StringBuilder();
+ Iterator<Entry<String, String>> orderItr = context.getOrderByCollection().entrySet().iterator();
+
+ int i = 0;
+
+ while (orderItr.hasNext()) {
+ if (i != 0) {
+ orderByBuilder.append(JPQLStatement.DELIMITER.SPACE).append(JPQLStatement.DELIMITER.COMMA).append(
+ JPQLStatement.DELIMITER.SPACE);
+ }
+ Entry<String, String> entry = orderItr.next();
+ orderByBuilder.append(entry.getKey()).append(JPQLStatement.DELIMITER.SPACE);
+ orderByBuilder.append(entry.getValue());
+ i++;
+ }
+ jpqlQuery.append(JPQLStatement.DELIMITER.SPACE).append(JPQLStatement.KEYWORD.ORDERBY).append(
+ JPQLStatement.DELIMITER.SPACE);
+ jpqlQuery.append(orderByBuilder);
+ }
+
+ return jpqlQuery.toString();
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLSelectContext.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLSelectContext.java b/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLSelectContext.java
new file mode 100644
index 0000000..ef588aa
--- /dev/null
+++ b/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLSelectContext.java
@@ -0,0 +1,159 @@
+/*******************************************************************************
+ * 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.jpql;
+
+import java.util.HashMap;
+
+import org.apache.olingo.odata2.api.edm.EdmEntityType;
+import org.apache.olingo.odata2.api.edm.EdmException;
+import org.apache.olingo.odata2.api.edm.EdmMapping;
+import org.apache.olingo.odata2.api.exception.ODataException;
+import org.apache.olingo.odata2.api.uri.info.GetEntitySetUriInfo;
+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.jpql.JPQLContext;
+import org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLContextType;
+import org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLSelectContextView;
+import org.apache.olingo.odata2.processor.core.jpa.ODataExpressionParser;
+
+public class JPQLSelectContext extends JPQLContext implements JPQLSelectContextView {
+
+ protected String selectExpression;
+ protected HashMap<String, String> orderByCollection;
+ protected String whereCondition;
+
+ protected boolean isCountOnly = false;// Support for $count
+
+ public JPQLSelectContext(final boolean isCountOnly) {
+ this.isCountOnly = isCountOnly;
+ }
+
+ protected final void setOrderByCollection(final HashMap<String, String> orderByCollection) {
+ this.orderByCollection = orderByCollection;
+ }
+
+ protected final void setWhereExpression(final String filterExpression) {
+ whereCondition = filterExpression;
+ }
+
+ protected final void setSelectExpression(final String selectExpression) {
+ this.selectExpression = selectExpression;
+ }
+
+ @Override
+ public String getSelectExpression() {
+ return selectExpression;
+ }
+
+ @Override
+ public HashMap<String, String> getOrderByCollection() {
+ return orderByCollection;
+ }
+
+ @Override
+ public String getWhereExpression() {
+ return whereCondition;
+ }
+
+ public class JPQLSelectContextBuilder extends
+ org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLContext.JPQLContextBuilder {
+
+ protected GetEntitySetUriInfo entitySetView;
+
+ @Override
+ public JPQLContext build() throws ODataJPAModelException, ODataJPARuntimeException {
+ if (entitySetView != null) {
+
+ try {
+
+ if (isCountOnly) {
+ setType(JPQLContextType.SELECT_COUNT);
+ } else {
+ setType(JPQLContextType.SELECT);
+ }
+ EdmEntityType entityType = entitySetView.getTargetEntitySet().getEntityType();
+ EdmMapping mapping = entityType.getMapping();
+ if (mapping != null) {
+ setJPAEntityName(mapping.getInternalName());
+ } else {
+ setJPAEntityName(entityType.getName());
+ }
+
+ setJPAEntityAlias(generateJPAEntityAlias());
+
+ setOrderByCollection(generateOrderByFileds());
+
+ setSelectExpression(generateSelectExpression());
+
+ setWhereExpression(generateWhereExpression());
+ } catch (ODataException e) {
+ throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.INNER_EXCEPTION, e);
+ }
+ }
+
+ return JPQLSelectContext.this;
+
+ }
+
+ @Override
+ protected void setResultsView(final Object resultsView) {
+ if (resultsView instanceof GetEntitySetUriInfo) {
+ entitySetView = (GetEntitySetUriInfo) resultsView;
+ }
+
+ }
+
+ /*
+ * Generate Select Clause
+ */
+ protected String generateSelectExpression() throws EdmException {
+ return getJPAEntityAlias();
+ }
+
+ /*
+ * Generate Order By Clause Fields
+ */
+ protected HashMap<String, String> generateOrderByFileds() throws ODataJPARuntimeException, EdmException {
+
+ if (entitySetView.getOrderBy() != null) {
+
+ return ODataExpressionParser.parseToJPAOrderByExpression(entitySetView.getOrderBy(), getJPAEntityAlias());
+
+ } else if (entitySetView.getTop() != null || entitySetView.getSkip() != null) {
+
+ return ODataExpressionParser.parseKeyPropertiesToJPAOrderByExpression(entitySetView.getTargetEntitySet()
+ .getEntityType().getKeyProperties(), getJPAEntityAlias());
+ } else {
+ return null;
+ }
+
+ }
+
+ /*
+ * Generate Where Clause Expression
+ */
+ protected String generateWhereExpression() throws ODataException {
+ if (entitySetView.getFilter() != null) {
+ return ODataExpressionParser.parseToJPAWhereExpression(entitySetView.getFilter(), getJPAEntityAlias());
+ }
+ return null;
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLSelectSingleContext.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLSelectSingleContext.java b/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLSelectSingleContext.java
new file mode 100644
index 0000000..9d2884d
--- /dev/null
+++ b/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLSelectSingleContext.java
@@ -0,0 +1,109 @@
+/*******************************************************************************
+ * 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.jpql;
+
+import java.util.List;
+
+import org.apache.olingo.odata2.api.edm.EdmEntityType;
+import org.apache.olingo.odata2.api.edm.EdmException;
+import org.apache.olingo.odata2.api.edm.EdmMapping;
+import org.apache.olingo.odata2.api.uri.KeyPredicate;
+import org.apache.olingo.odata2.api.uri.info.GetEntityUriInfo;
+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.jpql.JPQLContext;
+import org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLContextType;
+import org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLSelectSingleContextView;
+
+public class JPQLSelectSingleContext extends JPQLContext implements JPQLSelectSingleContextView {
+
+ private String selectExpression;
+ private List<KeyPredicate> keyPredicates;
+
+ protected void setKeyPredicates(final List<KeyPredicate> keyPredicates) {
+ this.keyPredicates = keyPredicates;
+ }
+
+ @Override
+ public List<KeyPredicate> getKeyPredicates() {
+ return keyPredicates;
+ }
+
+ protected final void setSelectExpression(final String selectExpression) {
+ this.selectExpression = selectExpression;
+ }
+
+ @Override
+ public String getSelectExpression() {
+ return selectExpression;
+ }
+
+ public class JPQLSelectSingleContextBuilder extends
+ org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLContext.JPQLContextBuilder {
+
+ protected GetEntityUriInfo entityView;
+
+ @Override
+ public JPQLContext build() throws ODataJPAModelException, ODataJPARuntimeException {
+ if (entityView != null) {
+
+ try {
+
+ setType(JPQLContextType.SELECT_SINGLE);
+
+ EdmEntityType entityType = entityView.getTargetEntitySet().getEntityType();
+ EdmMapping mapping = entityType.getMapping();
+ if (mapping != null) {
+ setJPAEntityName(mapping.getInternalName());
+ } else {
+ setJPAEntityName(entityType.getName());
+ }
+
+ setJPAEntityAlias(generateJPAEntityAlias());
+
+ setKeyPredicates(entityView.getKeyPredicates());
+
+ setSelectExpression(generateSelectExpression());
+
+ } catch (EdmException e) {
+ throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e);
+ }
+
+ }
+
+ return JPQLSelectSingleContext.this;
+
+ }
+
+ @Override
+ protected void setResultsView(final Object resultsView) {
+ if (resultsView instanceof GetEntityUriInfo) {
+ entityView = (GetEntityUriInfo) resultsView;
+ }
+
+ }
+
+ /*
+ * Generate Select Clause
+ */
+ protected String generateSelectExpression() throws EdmException {
+ return getJPAEntityAlias();
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLSelectSingleStatementBuilder.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLSelectSingleStatementBuilder.java b/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLSelectSingleStatementBuilder.java
new file mode 100644
index 0000000..06e2444
--- /dev/null
+++ b/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLSelectSingleStatementBuilder.java
@@ -0,0 +1,66 @@
+/*******************************************************************************
+ * 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.jpql;
+
+import org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPARuntimeException;
+import org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLContextView;
+import org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLSelectSingleContextView;
+import org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLStatement;
+import org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLStatement.JPQLStatementBuilder;
+import org.apache.olingo.odata2.processor.core.jpa.ODataExpressionParser;
+
+public class JPQLSelectSingleStatementBuilder extends JPQLStatementBuilder {
+
+ JPQLStatement jpqlStatement;
+ private JPQLSelectSingleContextView context;
+
+ public JPQLSelectSingleStatementBuilder(final JPQLContextView context) {
+ this.context = (JPQLSelectSingleContextView) context;
+ }
+
+ @Override
+ public JPQLStatement build() throws ODataJPARuntimeException {
+ jpqlStatement = createStatement(createJPQLQuery());
+ return jpqlStatement;
+
+ }
+
+ private String createJPQLQuery() throws ODataJPARuntimeException {
+
+ StringBuilder jpqlQuery = new StringBuilder();
+ String tableAlias = context.getJPAEntityAlias();
+ String fromClause = context.getJPAEntityName() + JPQLStatement.DELIMITER.SPACE + tableAlias;
+
+ jpqlQuery.append(JPQLStatement.KEYWORD.SELECT).append(JPQLStatement.DELIMITER.SPACE);
+ jpqlQuery.append(context.getSelectExpression()).append(JPQLStatement.DELIMITER.SPACE);
+ jpqlQuery.append(JPQLStatement.KEYWORD.FROM).append(JPQLStatement.DELIMITER.SPACE);
+ jpqlQuery.append(fromClause);
+
+ if (context.getKeyPredicates() != null && context.getKeyPredicates().size() > 0) {
+ jpqlQuery.append(JPQLStatement.DELIMITER.SPACE);
+ jpqlQuery.append(JPQLStatement.KEYWORD.WHERE).append(JPQLStatement.DELIMITER.SPACE);
+ jpqlQuery.append(ODataExpressionParser
+ .parseKeyPredicates(context.getKeyPredicates(), context.getJPAEntityAlias()));
+ }
+
+ return jpqlQuery.toString();
+
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLSelectStatementBuilder.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLSelectStatementBuilder.java b/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLSelectStatementBuilder.java
new file mode 100644
index 0000000..22059f1
--- /dev/null
+++ b/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLSelectStatementBuilder.java
@@ -0,0 +1,98 @@
+/*******************************************************************************
+ * 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.jpql;
+
+import java.util.Iterator;
+import java.util.Map.Entry;
+
+import org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPARuntimeException;
+import org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLContextType;
+import org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLContextView;
+import org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLSelectContextView;
+import org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLStatement;
+import org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLStatement.JPQLStatementBuilder;
+
+public class JPQLSelectStatementBuilder extends JPQLStatementBuilder {
+
+ JPQLStatement jpqlStatement;
+ private JPQLSelectContextView context;
+
+ public JPQLSelectStatementBuilder(final JPQLContextView context) {
+ this.context = (JPQLSelectContextView) context;
+ }
+
+ @Override
+ public JPQLStatement build() throws ODataJPARuntimeException {
+ jpqlStatement = createStatement(createJPQLQuery());
+ return jpqlStatement;
+
+ }
+
+ private String createJPQLQuery() throws ODataJPARuntimeException {
+
+ StringBuilder jpqlQuery = new StringBuilder();
+ String tableAlias = context.getJPAEntityAlias();
+ String fromClause = context.getJPAEntityName() + JPQLStatement.DELIMITER.SPACE + tableAlias;
+
+ jpqlQuery.append(JPQLStatement.KEYWORD.SELECT).append(JPQLStatement.DELIMITER.SPACE);
+ if (context.getType().equals(JPQLContextType.SELECT_COUNT)) { // $COUNT
+ jpqlQuery.append(JPQLStatement.KEYWORD.COUNT).append(JPQLStatement.DELIMITER.SPACE);
+ jpqlQuery.append(JPQLStatement.DELIMITER.PARENTHESIS_LEFT).append(JPQLStatement.DELIMITER.SPACE);
+ jpqlQuery.append(context.getSelectExpression()).append(JPQLStatement.DELIMITER.SPACE);
+ jpqlQuery.append(JPQLStatement.DELIMITER.PARENTHESIS_RIGHT).append(JPQLStatement.DELIMITER.SPACE);
+ } else {// Normal
+ jpqlQuery.append(context.getSelectExpression()).append(JPQLStatement.DELIMITER.SPACE);
+ }
+
+ jpqlQuery.append(JPQLStatement.KEYWORD.FROM).append(JPQLStatement.DELIMITER.SPACE);
+ jpqlQuery.append(fromClause);
+
+ if (context.getWhereExpression() != null) {
+ jpqlQuery.append(JPQLStatement.DELIMITER.SPACE);
+ jpqlQuery.append(JPQLStatement.KEYWORD.WHERE).append(JPQLStatement.DELIMITER.SPACE);
+ jpqlQuery.append(context.getWhereExpression());
+ }
+
+ if (context.getOrderByCollection() != null && context.getOrderByCollection().size() > 0) {
+
+ StringBuilder orderByBuilder = new StringBuilder();
+ Iterator<Entry<String, String>> orderItr = context.getOrderByCollection().entrySet().iterator();
+
+ int i = 0;
+
+ while (orderItr.hasNext()) {
+ if (i != 0) {
+ orderByBuilder.append(JPQLStatement.DELIMITER.SPACE).append(JPQLStatement.DELIMITER.COMMA).append(
+ JPQLStatement.DELIMITER.SPACE);
+ }
+ Entry<String, String> entry = orderItr.next();
+ orderByBuilder.append(entry.getKey()).append(JPQLStatement.DELIMITER.SPACE);
+ orderByBuilder.append(entry.getValue());
+ i++;
+ }
+ jpqlQuery.append(JPQLStatement.DELIMITER.SPACE);
+ jpqlQuery.append(JPQLStatement.KEYWORD.ORDERBY).append(JPQLStatement.DELIMITER.SPACE);
+ jpqlQuery.append(orderByBuilder);
+ }
+
+ return jpqlQuery.toString();
+
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmAssociation.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmAssociation.java b/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmAssociation.java
new file mode 100644
index 0000000..aa10ef8
--- /dev/null
+++ b/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmAssociation.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.util.ArrayList;
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+
+import org.apache.olingo.odata2.api.edm.provider.Association;
+import org.apache.olingo.odata2.api.edm.provider.AssociationEnd;
+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.JPAEdmAssociationEndView;
+import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmAssociationView;
+import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmEntityTypeView;
+import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmPropertyView;
+import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmReferentialConstraintView;
+import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmSchemaView;
+import org.apache.olingo.odata2.processor.core.jpa.access.model.JPAEdmNameBuilder;
+
+public class JPAEdmAssociation extends JPAEdmBaseViewImpl implements JPAEdmAssociationView {
+
+ private JPAEdmAssociationEndView associationEndView;
+
+ private Association currentAssociation;
+ private List<Association> consistentAssociatonList;
+ private HashMap<String, Association> associationMap;
+ private HashMap<String, JPAEdmAssociationEndView> associationEndMap;
+ private List<JPAEdmReferentialConstraintView> inconsistentRefConstraintViewList;
+ private int numberOfSimilarEndPoints;
+
+ public JPAEdmAssociation(final JPAEdmAssociationEndView associationEndview,
+ final JPAEdmEntityTypeView entityTypeView, final JPAEdmPropertyView propertyView, final int value) {
+ super(associationEndview);
+ associationEndView = associationEndview;
+ numberOfSimilarEndPoints = value;
+ init();
+ }
+
+ public JPAEdmAssociation(final JPAEdmSchemaView view) {
+ super(view);
+ init();
+ }
+
+ private void init() {
+ isConsistent = false;
+ consistentAssociatonList = new ArrayList<Association>();
+ inconsistentRefConstraintViewList = new LinkedList<JPAEdmReferentialConstraintView>();
+ associationMap = new HashMap<String, Association>();
+ associationEndMap = new HashMap<String, JPAEdmAssociationEndView>();
+ }
+
+ @Override
+ public JPAEdmBuilder getBuilder() {
+ if (builder == null) {
+ builder = new JPAEdmAssociationBuilder();
+ }
+ return builder;
+ }
+
+ @Override
+ public Association getEdmAssociation() {
+ return currentAssociation;
+ }
+
+ @Override
+ public List<Association> getConsistentEdmAssociationList() {
+ return consistentAssociatonList;
+ }
+
+ @Override
+ public Association searchAssociation(final JPAEdmAssociationEndView view) {
+ if (view != null) {
+ for (String key : associationMap.keySet()) {
+ Association association = associationMap.get(key);
+ if (association != null) {
+ if (view.compare(association.getEnd1(), association.getEnd2())) {
+ JPAEdmAssociationEndView associationEnd = associationEndMap.get(association.getName());
+ if (associationEnd.getJoinColumnName() != null && associationEnd.getJoinColumnReferenceColumnName() != null
+ && view.getJoinColumnName() != null && view.getJoinColumnReferenceColumnName() != null) {
+ if (view.getJoinColumnName().equals(associationEnd.getJoinColumnName())
+ && view.getJoinColumnReferenceColumnName()
+ .equals(associationEnd.getJoinColumnReferenceColumnName())) {
+ currentAssociation = association;
+ return association;
+ }
+
+ }
+ if (associationEnd.getMappedByName() != null) {
+ if (associationEnd.getMappedByName().equals(view.getOwningPropertyName())) {
+ currentAssociation = association;
+ return association;
+ }
+ }
+ if (associationEnd.getOwningPropertyName() != null) {
+ if (associationEnd.getOwningPropertyName().equals(view.getMappedByName())) {
+ currentAssociation = association;
+ return association;
+ }
+ }
+ }
+ }
+ }
+ }
+ return null;
+ }
+
+ @Override
+ public void addJPAEdmAssociationView(final JPAEdmAssociationView associationView,
+ final JPAEdmAssociationEndView associationEndView) {
+ if (associationView != null) {
+ currentAssociation = associationView.getEdmAssociation();
+ associationMap.put(currentAssociation.getName(), currentAssociation);
+ associationEndMap.put(currentAssociation.getName(), associationEndView);
+ addJPAEdmRefConstraintView(associationView.getJPAEdmReferentialConstraintView());
+ }
+ }
+
+ @Override
+ public void addJPAEdmRefConstraintView(final JPAEdmReferentialConstraintView refView) {
+ if (refView != null && refView.isExists()) {
+ inconsistentRefConstraintViewList.add(refView);
+ }
+ }
+
+ @Override
+ public JPAEdmReferentialConstraintView getJPAEdmReferentialConstraintView() {
+ if (inconsistentRefConstraintViewList.isEmpty()) {
+ return null;
+ }
+ return inconsistentRefConstraintViewList.get(0);
+ }
+
+ private class JPAEdmAssociationBuilder implements JPAEdmBuilder {
+
+ @Override
+ public void build() throws ODataJPAModelException, ODataJPARuntimeException {
+
+ if (associationEndView != null && searchAssociation(associationEndView) == null) {
+ currentAssociation = new Association();
+ currentAssociation.setEnd1(associationEndView.getEdmAssociationEnd1());
+ currentAssociation.setEnd2(associationEndView.getEdmAssociationEnd2());
+
+ JPAEdmNameBuilder.build(JPAEdmAssociation.this, numberOfSimilarEndPoints);
+
+ associationMap.put(currentAssociation.getName(), currentAssociation);
+
+ } else if (!inconsistentRefConstraintViewList.isEmpty()) {
+ int inconsistentRefConstraintViewSize = inconsistentRefConstraintViewList.size();
+ int index = 0;
+ for (int i = 0; i < inconsistentRefConstraintViewSize; i++) {
+ JPAEdmReferentialConstraintView view = inconsistentRefConstraintViewList.get(index);
+
+ if (view.isExists() && !view.isConsistent()) {
+ view.getBuilder().build();
+ }
+ if (view.isConsistent()) {
+ Association newAssociation = new Association();
+ copyAssociation(newAssociation, associationMap.get(view.getEdmRelationShipName()));
+ newAssociation.setReferentialConstraint(view.getEdmReferentialConstraint());
+ consistentAssociatonList.add(newAssociation);
+ associationMap.put(view.getEdmRelationShipName(), newAssociation);
+ inconsistentRefConstraintViewList.remove(index);
+ } else {
+ associationMap.remove(view.getEdmRelationShipName());
+ index++;
+ }
+ }
+ }
+
+ if (associationMap.size() == consistentAssociatonList.size()) {
+ isConsistent = true;
+ } else {
+ for (String key : associationMap.keySet()) {
+ Association association = associationMap.get(key);
+ if (!consistentAssociatonList.contains(association)) {
+ consistentAssociatonList.add(association);
+ }
+ }
+ isConsistent = true;
+ }
+
+ }
+
+ private void copyAssociation(final Association copyToAssociation, final Association copyFromAssociation) {
+ copyToAssociation.setEnd1(copyFromAssociation.getEnd1());
+ copyToAssociation.setEnd2(copyFromAssociation.getEnd2());
+ copyToAssociation.setName(copyFromAssociation.getName());
+ copyToAssociation.setAnnotationAttributes(copyFromAssociation.getAnnotationAttributes());
+ copyToAssociation.setAnnotationElements(copyFromAssociation.getAnnotationElements());
+ copyToAssociation.setDocumentation(copyFromAssociation.getDocumentation());
+
+ }
+ }
+
+ @Override
+ public int getNumberOfAssociationsWithSimilarEndPoints(final JPAEdmAssociationEndView view) {
+ int count = 0;
+ AssociationEnd currentAssociationEnd1 = view.getEdmAssociationEnd1();
+ AssociationEnd currentAssociationEnd2 = view.getEdmAssociationEnd2();
+ AssociationEnd end1 = null;
+ AssociationEnd end2 = null;
+ for (String key : associationMap.keySet()) {
+ Association association = associationMap.get(key);
+ if (association != null) {
+ end1 = association.getEnd1();
+ end2 = association.getEnd2();
+ if ((end1.getType().equals(currentAssociationEnd1.getType()) && end2.getType().equals(
+ currentAssociationEnd2.getType()))
+ || (end1.getType().equals(currentAssociationEnd2.getType()) && end2.getType().equals(
+ currentAssociationEnd1.getType()))) {
+ count++;
+ }
+ }
+ }
+ return count;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmAssociationEnd.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmAssociationEnd.java b/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmAssociationEnd.java
new file mode 100644
index 0000000..1b648ae
--- /dev/null
+++ b/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmAssociationEnd.java
@@ -0,0 +1,183 @@
+/*******************************************************************************
+ * 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.reflect.AnnotatedElement;
+
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToMany;
+import javax.persistence.OneToMany;
+import javax.persistence.OneToOne;
+import javax.persistence.metamodel.Attribute.PersistentAttributeType;
+
+import org.apache.olingo.odata2.api.edm.EdmMultiplicity;
+import org.apache.olingo.odata2.api.edm.provider.AssociationEnd;
+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.model.JPAEdmAssociationEndView;
+import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmEntityTypeView;
+import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmPropertyView;
+import org.apache.olingo.odata2.processor.core.jpa.access.model.JPAEdmNameBuilder;
+
+public class JPAEdmAssociationEnd extends JPAEdmBaseViewImpl implements JPAEdmAssociationEndView {
+
+ private JPAEdmEntityTypeView entityTypeView = null;
+ private JPAEdmPropertyView propertyView = null;
+ private AssociationEnd currentAssociationEnd1 = null;
+ private AssociationEnd currentAssociationEnd2 = null;
+ private String columnName;
+ private String referencedColumnName;
+ private String mappedBy;
+ private String ownerPropertyName;
+
+ public JPAEdmAssociationEnd(final JPAEdmEntityTypeView entityTypeView, final JPAEdmPropertyView propertyView) {
+ super(entityTypeView);
+ this.entityTypeView = entityTypeView;
+ this.propertyView = propertyView;
+ }
+
+ @Override
+ public JPAEdmBuilder getBuilder() {
+ if (builder == null) {
+ builder = new JPAEdmAssociationEndBuilder();
+ }
+
+ return builder;
+ }
+
+ @Override
+ public AssociationEnd getEdmAssociationEnd1() {
+ return currentAssociationEnd1;
+ }
+
+ @Override
+ public AssociationEnd getEdmAssociationEnd2() {
+ return currentAssociationEnd2;
+ }
+
+ private class JPAEdmAssociationEndBuilder implements JPAEdmBuilder {
+
+ @Override
+ public void build() throws ODataJPAModelException {
+
+ JoinColumn joinColumn = null;
+
+ currentAssociationEnd1 = new AssociationEnd();
+ currentAssociationEnd2 = new AssociationEnd();
+
+ JPAEdmNameBuilder.build(JPAEdmAssociationEnd.this, entityTypeView, propertyView);
+
+ currentAssociationEnd1.setRole(currentAssociationEnd1.getType().getName());
+ currentAssociationEnd2.setRole(currentAssociationEnd2.getType().getName());
+
+ setEdmMultiplicity(propertyView.getJPAAttribute().getPersistentAttributeType());
+
+ AnnotatedElement annotatedElement = (AnnotatedElement) propertyView.getJPAAttribute().getJavaMember();
+ if (annotatedElement != null) {
+ joinColumn = annotatedElement.getAnnotation(JoinColumn.class);
+ if (joinColumn != null) {
+ columnName = joinColumn.name();
+ referencedColumnName = joinColumn.referencedColumnName();
+ }
+
+ }
+ ownerPropertyName = propertyView.getJPAAttribute().getName();
+
+ }
+
+ private void setEdmMultiplicity(final PersistentAttributeType type) {
+ AnnotatedElement annotatedElement = (AnnotatedElement) propertyView.getJPAAttribute().getJavaMember();
+ switch (type) {
+ case ONE_TO_MANY:
+ currentAssociationEnd1.setMultiplicity(EdmMultiplicity.ONE);
+ currentAssociationEnd2.setMultiplicity(EdmMultiplicity.MANY);
+ if (annotatedElement != null) {
+ OneToMany reln = annotatedElement.getAnnotation(OneToMany.class);
+ if (reln != null) {
+ mappedBy = reln.mappedBy();
+ }
+ }
+ break;
+ case MANY_TO_MANY:
+ currentAssociationEnd1.setMultiplicity(EdmMultiplicity.MANY);
+ currentAssociationEnd2.setMultiplicity(EdmMultiplicity.MANY);
+ if (annotatedElement != null) {
+ ManyToMany reln = annotatedElement.getAnnotation(ManyToMany.class);
+ if (reln != null) {
+ mappedBy = reln.mappedBy();
+ }
+ }
+ break;
+ case MANY_TO_ONE:
+ currentAssociationEnd1.setMultiplicity(EdmMultiplicity.MANY);
+ currentAssociationEnd2.setMultiplicity(EdmMultiplicity.ONE);
+ break;
+ case ONE_TO_ONE:
+ currentAssociationEnd1.setMultiplicity(EdmMultiplicity.ONE);
+ currentAssociationEnd2.setMultiplicity(EdmMultiplicity.ONE);
+ if (annotatedElement != null) {
+ OneToOne reln = annotatedElement.getAnnotation(OneToOne.class);
+ if (reln != null) {
+ mappedBy = reln.mappedBy();
+ }
+ }
+ break;
+ default:
+ break;
+ }
+ }
+ }
+
+ @Override
+ public boolean compare(final AssociationEnd end1, final AssociationEnd end2) {
+ if ((end1.getType().equals(currentAssociationEnd1.getType())
+ && end2.getType().equals(currentAssociationEnd2.getType())
+ && end1.getMultiplicity().equals(currentAssociationEnd1.getMultiplicity()) && end2.getMultiplicity().equals(
+ currentAssociationEnd2.getMultiplicity()))
+ || (end1.getType().equals(currentAssociationEnd2.getType())
+ && end2.getType().equals(currentAssociationEnd1.getType())
+ && end1.getMultiplicity().equals(currentAssociationEnd2.getMultiplicity()) && end2.getMultiplicity()
+ .equals(currentAssociationEnd1.getMultiplicity()))) {
+ return true;
+ }
+
+ return false;
+ }
+
+ @Override
+ public String getJoinColumnName() {
+ return columnName;
+ }
+
+ @Override
+ public String getJoinColumnReferenceColumnName() {
+ return referencedColumnName;
+ }
+
+ @Override
+ public String getMappedByName() {
+ return mappedBy;
+ }
+
+ @Override
+ public String getOwningPropertyName() {
+ return ownerPropertyName;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmAssociationSet.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmAssociationSet.java b/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmAssociationSet.java
new file mode 100644
index 0000000..925a497
--- /dev/null
+++ b/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmAssociationSet.java
@@ -0,0 +1,131 @@
+/*******************************************************************************
+ * 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.util.ArrayList;
+import java.util.List;
+
+import org.apache.olingo.odata2.api.edm.FullQualifiedName;
+import org.apache.olingo.odata2.api.edm.provider.Association;
+import org.apache.olingo.odata2.api.edm.provider.AssociationSet;
+import org.apache.olingo.odata2.api.edm.provider.AssociationSetEnd;
+import org.apache.olingo.odata2.api.edm.provider.EntitySet;
+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.model.JPAEdmAssociationSetView;
+import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmAssociationView;
+import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmEntitySetView;
+import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmSchemaView;
+import org.apache.olingo.odata2.processor.core.jpa.access.model.JPAEdmNameBuilder;
+
+public class JPAEdmAssociationSet extends JPAEdmBaseViewImpl implements JPAEdmAssociationSetView {
+
+ private JPAEdmSchemaView schemaView;
+ private AssociationSet currentAssociationSet;
+ private List<AssociationSet> associationSetList;
+ private Association currentAssociation;
+
+ public JPAEdmAssociationSet(final JPAEdmSchemaView view) {
+ super(view);
+ schemaView = view;
+ }
+
+ @Override
+ public JPAEdmBuilder getBuilder() {
+ if (builder == null) {
+ builder = new JPAEdmAssociationSetBuilder();
+ }
+
+ return builder;
+ }
+
+ @Override
+ public List<AssociationSet> getConsistentEdmAssociationSetList() {
+ return associationSetList;
+ }
+
+ @Override
+ public AssociationSet getEdmAssociationSet() {
+ return currentAssociationSet;
+ }
+
+ @Override
+ public Association getEdmAssociation() {
+ return currentAssociation;
+ }
+
+ private class JPAEdmAssociationSetBuilder implements JPAEdmBuilder {
+
+ @Override
+ public void build() throws ODataJPAModelException {
+
+ if (associationSetList == null) {
+ associationSetList = new ArrayList<AssociationSet>();
+ }
+
+ JPAEdmAssociationView associationView = schemaView.getJPAEdmAssociationView();
+ JPAEdmEntitySetView entitySetView = schemaView.getJPAEdmEntityContainerView().getJPAEdmEntitySetView();
+
+ List<EntitySet> entitySetList = entitySetView.getConsistentEdmEntitySetList();
+ if (associationView.isConsistent()) {
+ for (Association association : associationView.getConsistentEdmAssociationList()) {
+
+ currentAssociation = association;
+
+ FullQualifiedName fQname =
+ new FullQualifiedName(schemaView.getEdmSchema().getNamespace(), association.getName());
+ currentAssociationSet = new AssociationSet();
+ currentAssociationSet.setAssociation(fQname);
+
+ int endCount = 0;
+ short endFlag = 0;
+ for (EntitySet entitySet : entitySetList) {
+ fQname = entitySet.getEntityType();
+ endFlag = 0;
+ if (fQname.equals(association.getEnd1().getType()) || ++endFlag > 1
+ || fQname.equals(association.getEnd2().getType())) {
+
+ AssociationSetEnd end = new AssociationSetEnd();
+ end.setEntitySet(entitySet.getName());
+ if (endFlag == 0) {
+ currentAssociationSet.setEnd1(end);
+ end.setRole(association.getEnd1().getRole());
+ endCount++;
+ } else {
+ endCount++;
+ currentAssociationSet.setEnd2(end);
+ end.setRole(association.getEnd2().getRole());
+ }
+
+ if (endCount == 2) {
+ break;
+ }
+ }
+ }
+ if (endCount == 2) {
+ JPAEdmNameBuilder.build(JPAEdmAssociationSet.this);
+ associationSetList.add(currentAssociationSet);
+ }
+
+ }
+
+ }
+ }
+ }
+}
[32/37] [OLINGO-82] Renamed the project folder name to
odata2-jpa-processor
Posted by ch...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/access/data/JPALink.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/access/data/JPALink.java b/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/access/data/JPALink.java
new file mode 100644
index 0000000..872a99b
--- /dev/null
+++ b/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/access/data/JPALink.java
@@ -0,0 +1,225 @@
+/*******************************************************************************
+ * 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.access.data;
+
+import java.io.InputStream;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.persistence.EntityManager;
+import javax.persistence.EntityTransaction;
+
+import org.apache.olingo.odata2.api.edm.EdmEntitySet;
+import org.apache.olingo.odata2.api.edm.EdmException;
+import org.apache.olingo.odata2.api.edm.EdmNavigationProperty;
+import org.apache.olingo.odata2.api.uri.UriInfo;
+import org.apache.olingo.odata2.api.uri.info.GetEntityUriInfo;
+import org.apache.olingo.odata2.api.uri.info.PostUriInfo;
+import org.apache.olingo.odata2.api.uri.info.PutMergePatchUriInfo;
+import org.apache.olingo.odata2.processor.api.jpa.ODataJPAContext;
+import org.apache.olingo.odata2.processor.api.jpa.access.JPAProcessor;
+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.factory.ODataJPAFactory;
+import org.apache.olingo.odata2.processor.core.jpa.ODataEntityParser;
+
+public class JPALink {
+
+ private ODataJPAContext context;
+ private JPAProcessor jpaProcessor;
+ private ODataEntityParser parser;
+ private Object targetJPAEntity;
+ private Object sourceJPAEntity;
+
+ public JPALink(final ODataJPAContext context) {
+ this.context = context;
+ jpaProcessor = ODataJPAFactory.createFactory().getJPAAccessFactory().getJPAProcessor(this.context);
+ parser = new ODataEntityParser(this.context);
+ }
+
+ public void setSourceJPAEntity(final Object jpaEntity) {
+ sourceJPAEntity = jpaEntity;
+ }
+
+ public void create(final PostUriInfo uriInfo, final InputStream content, final String requestContentType,
+ final String contentType) throws ODataJPARuntimeException, ODataJPAModelException {
+
+ EdmEntitySet targetEntitySet = uriInfo.getTargetEntitySet();
+ String targerEntitySetName;
+ EdmNavigationProperty navigationProperty = null;
+ try {
+ targerEntitySetName = targetEntitySet.getName();
+ } catch (EdmException e) {
+ throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e);
+ }
+
+ List<UriInfo> uriInfoList = new ArrayList<UriInfo>();
+
+ if (((UriInfo) uriInfo).isLinks()) {
+ UriInfo getUriInfo = parser.parseLink(targetEntitySet, content, requestContentType);
+ uriInfoList = new ArrayList<UriInfo>();
+ uriInfoList.add(getUriInfo);
+ navigationProperty = uriInfo.getNavigationSegments().get(0).getNavigationProperty();
+ } else {
+ uriInfoList = parser.parseLinks(targetEntitySet, content, contentType);
+ }
+
+ if (uriInfoList == null) {
+ return;
+ }
+ try {
+ for (UriInfo getUriInfo : uriInfoList) {
+
+ if (!getUriInfo.getTargetEntitySet().getName().equals(targerEntitySetName)) {
+ throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.RELATIONSHIP_INVALID, null);
+ }
+ if (!((UriInfo) uriInfo).isLinks()) {
+ navigationProperty = getUriInfo.getNavigationSegments().get(0).getNavigationProperty();
+ }
+
+ targetJPAEntity = jpaProcessor.process((GetEntityUriInfo) getUriInfo);
+ if (targetJPAEntity != null && ((UriInfo) uriInfo).isLinks()) {
+ getUriInfo = parser.parseLinkURI();
+ sourceJPAEntity = jpaProcessor.process((GetEntityUriInfo) getUriInfo);
+ if (sourceJPAEntity == null) {
+ throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.RESOURCE_X_NOT_FOUND
+ .addContent(getUriInfo.getTargetEntitySet().getName()), null);
+ }
+ }
+
+ JPAEntityParser entityParser = new JPAEntityParser();
+ Method setMethod =
+ entityParser.getAccessModifier(sourceJPAEntity, navigationProperty, JPAEntityParser.ACCESS_MODIFIER_SET);
+
+ Method getMethod =
+ entityParser.getAccessModifier(sourceJPAEntity, navigationProperty, JPAEntityParser.ACCESS_MODIFIER_GET);
+
+ if (getMethod.getReturnType().getTypeParameters() != null) {
+ @SuppressWarnings("unchecked")
+ List<Object> relatedEntities = (List<Object>) getMethod.invoke(sourceJPAEntity);
+ relatedEntities.add(targetJPAEntity);
+ setMethod.invoke(sourceJPAEntity, relatedEntities);
+ } else {
+ setMethod.invoke(sourceJPAEntity, targetJPAEntity);
+ }
+ }
+ } catch (IllegalAccessException e) {
+ throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e);
+ } catch (IllegalArgumentException e) {
+ throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e);
+ } catch (InvocationTargetException e) {
+ throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e);
+ } catch (EdmException e) {
+ throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e);
+ }
+ }
+
+ public void delete() {}
+
+ public void save() {
+ EntityManager em = context.getEntityManager();
+ EntityTransaction tx = em.getTransaction();
+
+ if (!tx.isActive()) {
+ em.getTransaction().begin();
+ em.persist(sourceJPAEntity);
+ em.getTransaction().commit();
+ }
+
+ }
+
+ public void update(final PutMergePatchUriInfo putUriInfo, final InputStream content, final String requestContentType,
+ final String contentType) throws ODataJPARuntimeException, ODataJPAModelException {
+ UriInfo uriInfo = (UriInfo) putUriInfo;
+
+ EdmEntitySet targetEntitySet = uriInfo.getTargetEntitySet();
+ String targerEntitySetName;
+ EdmNavigationProperty navigationProperty = null;
+ try {
+ targerEntitySetName = targetEntitySet.getName();
+ } catch (EdmException e) {
+ throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e);
+ }
+
+ List<UriInfo> uriInfoList = new ArrayList<UriInfo>();
+
+ if (((UriInfo) uriInfo).isLinks()) {
+ UriInfo getUriInfo = parser.parseLink(targetEntitySet, content, requestContentType);
+ uriInfoList = new ArrayList<UriInfo>();
+ uriInfoList.add(getUriInfo);
+ navigationProperty = uriInfo.getNavigationSegments().get(0).getNavigationProperty();
+ } else {
+ uriInfoList = parser.parseLinks(targetEntitySet, content, contentType);
+ }
+
+ if (uriInfoList == null) {
+ return;
+ }
+ try {
+ for (UriInfo getUriInfo : uriInfoList) {
+
+ if (!getUriInfo.getTargetEntitySet().getName().equals(targerEntitySetName)) {
+ throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.RELATIONSHIP_INVALID, null);
+ }
+ if (!((UriInfo) uriInfo).isLinks()) {
+ navigationProperty = getUriInfo.getNavigationSegments().get(0).getNavigationProperty();
+ }
+
+ targetJPAEntity = jpaProcessor.process((GetEntityUriInfo) getUriInfo);
+ if (targetJPAEntity != null && ((UriInfo) uriInfo).isLinks()) {
+ getUriInfo = parser.parseLinkURI();
+ sourceJPAEntity = jpaProcessor.process((GetEntityUriInfo) getUriInfo);
+ if (sourceJPAEntity == null) {
+ throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.RESOURCE_X_NOT_FOUND
+ .addContent(getUriInfo.getTargetEntitySet().getName()), null);
+ }
+ }
+
+ JPAEntityParser entityParser = new JPAEntityParser();
+ Method setMethod =
+ entityParser.getAccessModifier(sourceJPAEntity, navigationProperty, JPAEntityParser.ACCESS_MODIFIER_SET);
+
+ Method getMethod =
+ entityParser.getAccessModifier(sourceJPAEntity, navigationProperty, JPAEntityParser.ACCESS_MODIFIER_GET);
+
+ if (getMethod.getReturnType().getTypeParameters() != null
+ && getMethod.getReturnType().getTypeParameters().length != 0) {
+ @SuppressWarnings("unchecked")
+ List<Object> relatedEntities = (List<Object>) getMethod.invoke(sourceJPAEntity);
+ relatedEntities.add(targetJPAEntity);
+ setMethod.invoke(sourceJPAEntity, relatedEntities);
+ } else {
+ setMethod.invoke(sourceJPAEntity, targetJPAEntity);
+ }
+ }
+ } catch (IllegalAccessException e) {
+ throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e);
+ } catch (IllegalArgumentException e) {
+ throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e);
+ } catch (InvocationTargetException e) {
+ throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e);
+ } catch (EdmException e) {
+ throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e);
+ }
+
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/access/data/JPAProcessorImpl.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/access/data/JPAProcessorImpl.java b/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/access/data/JPAProcessorImpl.java
new file mode 100644
index 0000000..8501b77
--- /dev/null
+++ b/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/access/data/JPAProcessorImpl.java
@@ -0,0 +1,491 @@
+/*******************************************************************************
+ * 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.access.data;
+
+import java.io.InputStream;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import javax.persistence.EntityManager;
+import javax.persistence.Query;
+
+import org.apache.olingo.odata2.api.edm.EdmEntitySet;
+import org.apache.olingo.odata2.api.edm.EdmEntityType;
+import org.apache.olingo.odata2.api.edm.EdmException;
+import org.apache.olingo.odata2.api.edm.EdmMultiplicity;
+import org.apache.olingo.odata2.api.ep.entry.ODataEntry;
+import org.apache.olingo.odata2.api.uri.info.DeleteUriInfo;
+import org.apache.olingo.odata2.api.uri.info.GetEntityCountUriInfo;
+import org.apache.olingo.odata2.api.uri.info.GetEntityLinkUriInfo;
+import org.apache.olingo.odata2.api.uri.info.GetEntitySetCountUriInfo;
+import org.apache.olingo.odata2.api.uri.info.GetEntitySetLinksUriInfo;
+import org.apache.olingo.odata2.api.uri.info.GetEntitySetUriInfo;
+import org.apache.olingo.odata2.api.uri.info.GetEntityUriInfo;
+import org.apache.olingo.odata2.api.uri.info.GetFunctionImportUriInfo;
+import org.apache.olingo.odata2.api.uri.info.PostUriInfo;
+import org.apache.olingo.odata2.api.uri.info.PutMergePatchUriInfo;
+import org.apache.olingo.odata2.processor.api.jpa.ODataJPAContext;
+import org.apache.olingo.odata2.processor.api.jpa.access.JPAFunction;
+import org.apache.olingo.odata2.processor.api.jpa.access.JPAMethodContext;
+import org.apache.olingo.odata2.processor.api.jpa.access.JPAProcessor;
+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.jpql.JPQLContext;
+import org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLContextType;
+import org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLStatement;
+import org.apache.olingo.odata2.processor.core.jpa.ODataEntityParser;
+
+public class JPAProcessorImpl implements JPAProcessor {
+
+ ODataJPAContext oDataJPAContext;
+ EntityManager em;
+
+ public JPAProcessorImpl(final ODataJPAContext oDataJPAContext) {
+ this.oDataJPAContext = oDataJPAContext;
+ em = oDataJPAContext.getEntityManager();
+ }
+
+ /* Process Function Import Request */
+ @SuppressWarnings("unchecked")
+ @Override
+ public List<Object> process(final GetFunctionImportUriInfo uriParserResultView)
+ throws ODataJPAModelException, ODataJPARuntimeException {
+
+ JPAMethodContext jpaMethodContext = JPAMethodContext.createBuilder(
+ JPQLContextType.FUNCTION, uriParserResultView).build();
+
+ List<Object> resultObj = null;
+
+ try {
+
+ JPAFunction jpaFunction = jpaMethodContext.getJPAFunctionList()
+ .get(0);
+ Method method = jpaFunction.getFunction();
+ Object[] args = jpaFunction.getArguments();
+
+ if (uriParserResultView.getFunctionImport().getReturnType()
+ .getMultiplicity().equals(EdmMultiplicity.MANY)) {
+
+ resultObj = (List<Object>) method.invoke(
+ jpaMethodContext.getEnclosingObject(), args);
+ } else {
+ resultObj = new ArrayList<Object>();
+ Object result = method.invoke(
+ jpaMethodContext.getEnclosingObject(), args);
+ resultObj.add(result);
+ }
+
+ } catch (EdmException e) {
+ throw ODataJPARuntimeException
+ .throwException(ODataJPARuntimeException.GENERAL
+ .addContent(e.getMessage()), e);
+ } catch (IllegalAccessException e) {
+ throw ODataJPARuntimeException
+ .throwException(ODataJPARuntimeException.GENERAL
+ .addContent(e.getMessage()), e);
+ } catch (IllegalArgumentException e) {
+ throw ODataJPARuntimeException
+ .throwException(ODataJPARuntimeException.GENERAL
+ .addContent(e.getMessage()), e);
+ } catch (InvocationTargetException e) {
+ throw ODataJPARuntimeException
+ .throwException(ODataJPARuntimeException.GENERAL
+ .addContent(e.getTargetException().getMessage()), e.getTargetException());
+ }
+
+ return resultObj;
+ }
+
+ /* Process Get Entity Set Request (Query) */
+ @SuppressWarnings("unchecked")
+ @Override
+ public <T> List<T> process(final GetEntitySetUriInfo uriParserResultView)
+ throws ODataJPAModelException, ODataJPARuntimeException {
+
+ if (uriParserResultView.getFunctionImport() != null) {
+ return (List<T>) process((GetFunctionImportUriInfo) uriParserResultView);
+ }
+ JPQLContextType contextType = null;
+ try {
+ if (!uriParserResultView.getStartEntitySet().getName()
+ .equals(uriParserResultView.getTargetEntitySet().getName())) {
+ contextType = JPQLContextType.JOIN;
+ } else {
+ contextType = JPQLContextType.SELECT;
+ }
+
+ } catch (EdmException e) {
+ ODataJPARuntimeException.throwException(
+ ODataJPARuntimeException.GENERAL, e);
+ }
+
+ JPQLContext jpqlContext = JPQLContext.createBuilder(contextType,
+ uriParserResultView).build();
+
+ JPQLStatement jpqlStatement = JPQLStatement.createBuilder(jpqlContext)
+ .build();
+ Query query = null;
+ try {
+ query = em.createQuery(jpqlStatement.toString());
+ // $top/$skip with $inlinecount case handled in response builder to avoid multiple DB call
+ if (uriParserResultView.getSkip() != null && uriParserResultView.getInlineCount() == null) {
+ query.setFirstResult(uriParserResultView.getSkip());
+ }
+
+ if (uriParserResultView.getTop() != null && uriParserResultView.getInlineCount() == null) {
+ if (uriParserResultView.getTop() == 0) {
+ List<T> resultList = new ArrayList<T>();
+ return resultList;
+ } else {
+ query.setMaxResults(uriParserResultView.getTop());
+ }
+ }
+ return query.getResultList();
+ } catch (Exception e) {
+ throw ODataJPARuntimeException.throwException(
+ ODataJPARuntimeException.ERROR_JPQL_QUERY_CREATE, e);
+
+ }
+ }
+
+ /* Process Get Entity Request (Read) */
+ @Override
+ public <T> Object process(GetEntityUriInfo uriParserResultView)
+ throws ODataJPAModelException, ODataJPARuntimeException {
+
+ JPQLContextType contextType = null;
+ try {
+ if (uriParserResultView instanceof GetEntityUriInfo) {
+ uriParserResultView = ((GetEntityUriInfo) uriParserResultView);
+ if (!((GetEntityUriInfo) uriParserResultView).getStartEntitySet().getName()
+ .equals(((GetEntityUriInfo) uriParserResultView).getTargetEntitySet().getName())) {
+ contextType = JPQLContextType.JOIN_SINGLE;
+ } else {
+ contextType = JPQLContextType.SELECT_SINGLE;
+ }
+ }
+ } catch (EdmException e) {
+ ODataJPARuntimeException.throwException(
+ ODataJPARuntimeException.GENERAL, e);
+ }
+
+ return readEntity(uriParserResultView, contextType);
+ }
+
+ /* Process $count for Get Entity Set Request */
+ @Override
+ public long process(final GetEntitySetCountUriInfo resultsView)
+ throws ODataJPAModelException, ODataJPARuntimeException {
+
+ JPQLContextType contextType = null;
+ try {
+ if (!resultsView.getStartEntitySet().getName()
+ .equals(resultsView.getTargetEntitySet().getName())) {
+ contextType = JPQLContextType.JOIN_COUNT;
+ } else {
+ contextType = JPQLContextType.SELECT_COUNT;
+ }
+ } catch (EdmException e) {
+ ODataJPARuntimeException.throwException(
+ ODataJPARuntimeException.GENERAL, e);
+ }
+
+ JPQLContext jpqlContext = JPQLContext.createBuilder(contextType,
+ resultsView).build();
+
+ JPQLStatement jpqlStatement = JPQLStatement.createBuilder(jpqlContext)
+ .build();
+ Query query = null;
+ try {
+
+ query = em.createQuery(jpqlStatement.toString());
+ List<?> resultList = query.getResultList();
+ if (resultList != null && resultList.size() == 1) {
+ return Long.valueOf(resultList.get(0).toString());
+ }
+ } catch (IllegalArgumentException e) {
+ throw ODataJPARuntimeException.throwException(
+ ODataJPARuntimeException.ERROR_JPQL_QUERY_CREATE, e);
+ }
+ return 0;
+ }
+
+ /* Process $count for Get Entity Request */
+ @Override
+ public long process(final GetEntityCountUriInfo resultsView) throws ODataJPAModelException, ODataJPARuntimeException {
+
+ JPQLContextType contextType = null;
+ try {
+ if (!resultsView.getStartEntitySet().getName()
+ .equals(resultsView.getTargetEntitySet().getName())) {
+ contextType = JPQLContextType.JOIN_COUNT;
+ } else {
+ contextType = JPQLContextType.SELECT_COUNT;
+ }
+ } catch (EdmException e) {
+ ODataJPARuntimeException.throwException(
+ ODataJPARuntimeException.GENERAL, e);
+ }
+
+ JPQLContext jpqlContext = JPQLContext.createBuilder(contextType,
+ resultsView).build();
+
+ JPQLStatement jpqlStatement = JPQLStatement.createBuilder(jpqlContext)
+ .build();
+ Query query = null;
+ try {
+
+ query = em.createQuery(jpqlStatement.toString());
+ List<?> resultList = query.getResultList();
+ if (resultList != null && resultList.size() == 1) {
+ return Long.valueOf(resultList.get(0).toString());
+ }
+ } catch (IllegalArgumentException e) {
+ throw ODataJPARuntimeException.throwException(
+ ODataJPARuntimeException.ERROR_JPQL_QUERY_CREATE, e);
+ }
+
+ return 0;
+ }
+
+ /* Process Create Entity Request */
+ @Override
+ public <T> List<T> process(final PostUriInfo createView, final InputStream content,
+ final String requestedContentType) throws ODataJPAModelException,
+ ODataJPARuntimeException {
+ return processCreate(createView, content, null, requestedContentType);
+ }
+
+ @Override
+ public <T> List<T> process(final PostUriInfo createView, final Map<String, Object> content)
+ throws ODataJPAModelException, ODataJPARuntimeException {
+ return processCreate(createView, null, content, null);
+ }
+
+ /* Process Update Entity Request */
+ @Override
+ public <T> Object process(final PutMergePatchUriInfo updateView,
+ final InputStream content, final String requestContentType)
+ throws ODataJPAModelException, ODataJPARuntimeException {
+ return processUpdate(updateView, content, null, requestContentType);
+ }
+
+ @Override
+ public <T> Object process(final PutMergePatchUriInfo updateView, final Map<String, Object> content)
+ throws ODataJPAModelException, ODataJPARuntimeException {
+ return processUpdate(updateView, null, content, null);
+ }
+
+ @SuppressWarnings("unchecked")
+ private <T> List<T> processCreate(final PostUriInfo createView, final InputStream content,
+ final Map<String, Object> properties,
+ final String requestedContentType) throws ODataJPAModelException,
+ ODataJPARuntimeException {
+ try {
+
+ final EdmEntitySet oDataEntitySet = createView.getTargetEntitySet();
+ final EdmEntityType oDataEntityType = oDataEntitySet.getEntityType();
+ final JPAEntity virtualJPAEntity = new JPAEntity(oDataEntityType, oDataEntitySet);
+ final List<Object> createList = new ArrayList<Object>();
+ Object jpaEntity = null;
+
+ if (content != null) {
+ final ODataEntityParser oDataEntityParser = new ODataEntityParser(oDataJPAContext);
+ final ODataEntry oDataEntry =
+ oDataEntityParser.parseEntry(oDataEntitySet, content, requestedContentType, false);
+ virtualJPAEntity.create(oDataEntry);
+ JPALink link = new JPALink(oDataJPAContext);
+ link.setSourceJPAEntity(jpaEntity);
+ link.create(createView, content, requestedContentType, requestedContentType);
+ } else if (properties != null) {
+ virtualJPAEntity.create(properties);
+ } else {
+ return null;
+ }
+
+ em.getTransaction().begin();
+ jpaEntity = virtualJPAEntity.getJPAEntity();
+
+ em.persist(jpaEntity);
+ if (em.contains(jpaEntity)) {
+ em.getTransaction().commit();
+
+ createList.add(virtualJPAEntity.getJPAEntity());
+ createList.add(virtualJPAEntity.getInlineJPAEntities());
+
+ return (List<T>) createList;
+ }
+ } catch (Exception e) {
+ throw ODataJPARuntimeException.throwException(
+ ODataJPARuntimeException.ERROR_JPQL_CREATE_REQUEST, e);
+ }
+ return null;
+ }
+
+ public <T> Object processUpdate(PutMergePatchUriInfo updateView,
+ final InputStream content, final Map<String, Object> properties, final String requestContentType)
+ throws ODataJPAModelException, ODataJPARuntimeException {
+ JPQLContextType contextType = null;
+ Object jpaEntity = null;
+ try {
+ em.getTransaction().begin();
+ if (updateView instanceof PutMergePatchUriInfo) {
+ updateView = ((PutMergePatchUriInfo) updateView);
+ if (!((PutMergePatchUriInfo) updateView).getStartEntitySet().getName()
+ .equals(((PutMergePatchUriInfo) updateView).getTargetEntitySet().getName())) {
+ contextType = JPQLContextType.JOIN_SINGLE;
+ } else {
+ contextType = JPQLContextType.SELECT_SINGLE;
+ }
+ }
+
+ jpaEntity = readEntity(updateView, contextType);
+
+ if (jpaEntity == null) {
+ throw ODataJPARuntimeException
+ .throwException(ODataJPARuntimeException.RESOURCE_NOT_FOUND, null);
+ }
+
+ final EdmEntitySet oDataEntitySet = updateView.getTargetEntitySet();
+ final EdmEntityType oDataEntityType = oDataEntitySet.getEntityType();
+ final JPAEntity virtualJPAEntity = new JPAEntity(oDataEntityType, oDataEntitySet);
+ virtualJPAEntity.setJPAEntity(jpaEntity);
+
+ if (content != null) {
+ final ODataEntityParser oDataEntityParser = new ODataEntityParser(oDataJPAContext);
+ final ODataEntry oDataEntry = oDataEntityParser.parseEntry(oDataEntitySet, content, requestContentType, false);
+ virtualJPAEntity.update(oDataEntry);
+ } else if (properties != null) {
+ virtualJPAEntity.update(properties);
+ } else {
+ return null;
+ }
+ em.flush();
+ em.getTransaction().commit();
+ } catch (Exception e) {
+ throw ODataJPARuntimeException.throwException(
+ ODataJPARuntimeException.ERROR_JPQL_UPDATE_REQUEST, e);
+ }
+
+ return jpaEntity;
+ }
+
+ /* Process Delete Entity Request */
+ @Override
+ public Object process(DeleteUriInfo uriParserResultView, final String contentType)
+ throws ODataJPAModelException, ODataJPARuntimeException {
+ JPQLContextType contextType = null;
+ try {
+ if (uriParserResultView instanceof DeleteUriInfo) {
+ uriParserResultView = ((DeleteUriInfo) uriParserResultView);
+ if (!((DeleteUriInfo) uriParserResultView).getStartEntitySet().getName()
+ .equals(((DeleteUriInfo) uriParserResultView).getTargetEntitySet().getName())) {
+ contextType = JPQLContextType.JOIN_SINGLE;
+ } else {
+ contextType = JPQLContextType.SELECT_SINGLE;
+ }
+ }
+ } catch (EdmException e) {
+ ODataJPARuntimeException.throwException(
+ ODataJPARuntimeException.GENERAL, e);
+ }
+
+ // First read the entity with read operation.
+ Object selectedObject = readEntity(uriParserResultView, contextType);
+ // Read operation done. This object would be passed on to entity manager for delete
+ if (selectedObject != null) {
+ try {
+ em.getTransaction().begin();
+ em.remove(selectedObject);
+ em.flush();
+ em.getTransaction().commit();
+ } catch (Exception e) {
+ throw ODataJPARuntimeException.throwException(
+ ODataJPARuntimeException.ERROR_JPQL_DELETE_REQUEST, e);
+ }
+ }
+ return selectedObject;
+ }
+
+ /* Process Get Entity Link Request */
+ @Override
+ public Object process(final GetEntityLinkUriInfo uriParserResultView)
+ throws ODataJPAModelException, ODataJPARuntimeException {
+
+ return this.process((GetEntityUriInfo) uriParserResultView);
+ }
+
+ /* Process Get Entity Set Link Request */
+ @Override
+ public <T> List<T> process(final GetEntitySetLinksUriInfo uriParserResultView)
+ throws ODataJPAModelException, ODataJPARuntimeException {
+ return this.process((GetEntitySetUriInfo) uriParserResultView);
+ }
+
+ @Override
+ public void process(final PostUriInfo uriInfo,
+ final InputStream content, final String requestContentType, final String contentType)
+ throws ODataJPARuntimeException, ODataJPAModelException {
+ JPALink link = new JPALink(oDataJPAContext);
+ link.create(uriInfo, content, requestContentType, contentType);
+ link.save();
+ }
+
+ /* Common method for Read and Delete */
+ private Object readEntity(final Object uriParserResultView, final JPQLContextType contextType)
+ throws ODataJPAModelException, ODataJPARuntimeException {
+
+ Object selectedObject = null;
+
+ if (uriParserResultView instanceof DeleteUriInfo || uriParserResultView instanceof GetEntityUriInfo
+ || uriParserResultView instanceof PutMergePatchUriInfo) {
+
+ JPQLContext selectJPQLContext = JPQLContext.createBuilder(
+ contextType, uriParserResultView).build();
+
+ JPQLStatement selectJPQLStatement = JPQLStatement.createBuilder(
+ selectJPQLContext).build();
+ Query query = null;
+ try {
+ query = em.createQuery(selectJPQLStatement.toString());
+ if (!query.getResultList().isEmpty()) {
+ selectedObject = query.getResultList().get(0);
+ }
+ } catch (IllegalArgumentException e) {
+ throw ODataJPARuntimeException.throwException(
+ ODataJPARuntimeException.ERROR_JPQL_QUERY_CREATE, e);
+ }
+ }
+ return selectedObject;
+ }
+
+ @Override
+ public void process(final PutMergePatchUriInfo putUriInfo,
+ final InputStream content, final String requestContentType, final String contentType)
+ throws ODataJPARuntimeException, ODataJPAModelException {
+
+ JPALink link = new JPALink(oDataJPAContext);
+ link.update(putUriInfo, content, requestContentType, contentType);
+ link.save();
+
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/access/model/EdmTypeConvertor.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/access/model/EdmTypeConvertor.java b/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/access/model/EdmTypeConvertor.java
new file mode 100644
index 0000000..f3c3e88
--- /dev/null
+++ b/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/access/model/EdmTypeConvertor.java
@@ -0,0 +1,69 @@
+/*******************************************************************************
+ * 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.access.model;
+
+import java.math.BigDecimal;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.UUID;
+
+import org.apache.olingo.odata2.api.edm.EdmSimpleType;
+import org.apache.olingo.odata2.api.edm.EdmSimpleTypeKind;
+import org.apache.olingo.odata2.api.edm.EdmType;
+import org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPAModelException;
+import org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPARuntimeException;
+
+public class EdmTypeConvertor {
+
+ public static Class<?> convertToJavaType(final EdmType edmType) throws ODataJPAModelException,
+ ODataJPARuntimeException {
+ if (edmType instanceof EdmSimpleType) {
+ EdmSimpleType edmSimpleType = (EdmSimpleType) edmType;
+ if (edmSimpleType == EdmSimpleTypeKind.String.getEdmSimpleTypeInstance()) {
+ return String.class;
+ } else if (edmSimpleType == EdmSimpleTypeKind.Int64.getEdmSimpleTypeInstance()) {
+ return Long.TYPE;
+ } else if (edmSimpleType == EdmSimpleTypeKind.Int16.getEdmSimpleTypeInstance()) {
+ return Short.TYPE;
+ } else if (edmSimpleType == EdmSimpleTypeKind.Int32.getEdmSimpleTypeInstance()) {
+ return Integer.TYPE;
+ } else if (edmSimpleType == EdmSimpleTypeKind.Double.getEdmSimpleTypeInstance()) {
+ return Double.TYPE;
+ } else if (edmSimpleType == EdmSimpleTypeKind.Single.getEdmSimpleTypeInstance()) {
+ return Float.TYPE;
+ } else if (edmSimpleType == EdmSimpleTypeKind.Decimal.getEdmSimpleTypeInstance()) {
+ return BigDecimal.class;
+ } else if (edmSimpleType == EdmSimpleTypeKind.Binary.getEdmSimpleTypeInstance()) {
+ return byte[].class;
+ } else if (edmSimpleType == EdmSimpleTypeKind.Byte.getEdmSimpleTypeInstance()) {
+ return Byte.TYPE;
+ } else if (edmSimpleType == EdmSimpleTypeKind.Boolean.getEdmSimpleTypeInstance()) {
+ return Boolean.TYPE;
+ } else if (edmSimpleType == EdmSimpleTypeKind.DateTime.getEdmSimpleTypeInstance()) {
+ return Date.class;
+ } else if (edmSimpleType == EdmSimpleTypeKind.DateTimeOffset.getEdmSimpleTypeInstance()) {
+ return Calendar.class;
+ } else if (edmSimpleType == EdmSimpleTypeKind.Guid.getEdmSimpleTypeInstance()) {
+ return UUID.class;
+ }
+ }
+ throw ODataJPAModelException.throwException(ODataJPAModelException.TYPE_NOT_SUPPORTED
+ .addContent(edmType.toString()), null);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/access/model/JPAEdmMappingModelService.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/access/model/JPAEdmMappingModelService.java b/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/access/model/JPAEdmMappingModelService.java
new file mode 100644
index 0000000..d00638e
--- /dev/null
+++ b/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/access/model/JPAEdmMappingModelService.java
@@ -0,0 +1,247 @@
+/*******************************************************************************
+ * 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.access.model;
+
+import java.io.InputStream;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBException;
+import javax.xml.bind.Unmarshaller;
+
+import org.apache.olingo.odata2.processor.api.jpa.ODataJPAContext;
+import org.apache.olingo.odata2.processor.api.jpa.access.JPAEdmMappingModelAccess;
+import org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPAModelException;
+import org.apache.olingo.odata2.processor.api.jpa.model.mapping.JPAAttributeMapType.JPAAttribute;
+import org.apache.olingo.odata2.processor.api.jpa.model.mapping.JPAEdmMappingModel;
+import org.apache.olingo.odata2.processor.api.jpa.model.mapping.JPAEmbeddableTypeMapType;
+import org.apache.olingo.odata2.processor.api.jpa.model.mapping.JPAEntityTypeMapType;
+import org.apache.olingo.odata2.processor.api.jpa.model.mapping.JPAPersistenceUnitMapType;
+import org.apache.olingo.odata2.processor.api.jpa.model.mapping.JPARelationshipMapType.JPARelationship;
+
+public class JPAEdmMappingModelService implements JPAEdmMappingModelAccess {
+
+ boolean mappingModelExists = true;
+ private JPAEdmMappingModel mappingModel;
+ private String mappingModelName;
+
+ public JPAEdmMappingModelService(final ODataJPAContext ctx) {
+ mappingModelName = ctx.getJPAEdmMappingModel();
+ if (mappingModelName == null) {
+ mappingModelExists = false;
+ }
+ }
+
+ @Override
+ public void loadMappingModel() {
+
+ if (mappingModelExists) {
+ JAXBContext context;
+ try {
+ context = JAXBContext.newInstance(JPAEdmMappingModel.class);
+
+ Unmarshaller unmarshaller = context.createUnmarshaller();
+ InputStream is = loadMappingModelInputStream();
+ if (is == null) {
+ mappingModelExists = false;
+ return;
+ }
+
+ mappingModel = (JPAEdmMappingModel) unmarshaller.unmarshal(is);
+
+ if (mappingModel != null) {
+ mappingModelExists = true;
+ }
+
+ } catch (JAXBException e) {
+ mappingModelExists = false;
+ ODataJPAModelException.throwException(ODataJPAModelException.GENERAL, e);
+ }
+ }
+ }
+
+ @Override
+ public boolean isMappingModelExists() {
+ return mappingModelExists;
+ }
+
+ @Override
+ public JPAEdmMappingModel getJPAEdmMappingModel() {
+ return mappingModel;
+ }
+
+ @Override
+ public String mapJPAPersistenceUnit(final String persistenceUnitName) {
+
+ JPAPersistenceUnitMapType persistenceUnit = mappingModel.getPersistenceUnit();
+ if (persistenceUnit.getName().equals(persistenceUnitName)) {
+ return persistenceUnit.getEDMSchemaNamespace();
+ }
+
+ return null;
+ }
+
+ @Override
+ public String mapJPAEntityType(final String jpaEntityTypeName) {
+
+ JPAEntityTypeMapType jpaEntityTypeMap = searchJPAEntityTypeMapType(jpaEntityTypeName);
+ if (jpaEntityTypeMap != null) {
+ return jpaEntityTypeMap.getEDMEntityType();
+ } else {
+ return null;
+ }
+ }
+
+ @Override
+ public String mapJPAEntitySet(final String jpaEntityTypeName) {
+ JPAEntityTypeMapType jpaEntityTypeMap = searchJPAEntityTypeMapType(jpaEntityTypeName);
+ if (jpaEntityTypeMap != null) {
+ return jpaEntityTypeMap.getEDMEntitySet();
+ } else {
+ return null;
+ }
+ }
+
+ @Override
+ public String mapJPAAttribute(final String jpaEntityTypeName, final String jpaAttributeName) {
+ JPAEntityTypeMapType jpaEntityTypeMap = searchJPAEntityTypeMapType(jpaEntityTypeName);
+ if (jpaEntityTypeMap != null && jpaEntityTypeMap.getJPAAttributes() != null) {
+ // fixing attributes
+ // removal issue
+ // from mapping
+ for (JPAAttribute jpaAttribute : jpaEntityTypeMap.getJPAAttributes().getJPAAttribute()) {
+ if (jpaAttribute.getName().equals(jpaAttributeName)) {
+ return jpaAttribute.getValue();
+ }
+ }
+ }
+
+ return null;
+ }
+
+ @Override
+ public String mapJPARelationship(final String jpaEntityTypeName, final String jpaRelationshipName) {
+ JPAEntityTypeMapType jpaEntityTypeMap = searchJPAEntityTypeMapType(jpaEntityTypeName);
+ if (jpaEntityTypeMap != null && jpaEntityTypeMap.getJPARelationships() != null) {
+ for (JPARelationship jpaRealtionship : jpaEntityTypeMap.getJPARelationships().getJPARelationship()) {
+ if (jpaRealtionship.getName().equals(jpaRelationshipName)) {
+ return jpaRealtionship.getValue();
+ }
+ }
+ }
+
+ return null;
+ }
+
+ @Override
+ public String mapJPAEmbeddableType(final String jpaEmbeddableTypeName) {
+ JPAEmbeddableTypeMapType jpaEmbeddableType = searchJPAEmbeddableTypeMapType(jpaEmbeddableTypeName);
+ if (jpaEmbeddableType != null) {
+ return jpaEmbeddableType.getEDMComplexType();
+ } else {
+ return null;
+ }
+ }
+
+ @Override
+ public String mapJPAEmbeddableTypeAttribute(final String jpaEmbeddableTypeName, final String jpaAttributeName) {
+ JPAEmbeddableTypeMapType jpaEmbeddableType = searchJPAEmbeddableTypeMapType(jpaEmbeddableTypeName);
+ if (jpaEmbeddableType != null && jpaEmbeddableType.getJPAAttributes() != null) {
+ for (JPAAttribute jpaAttribute : jpaEmbeddableType.getJPAAttributes().getJPAAttribute()) {
+ if (jpaAttribute.getName().equals(jpaAttributeName)) {
+ return jpaAttribute.getValue();
+ }
+ }
+ }
+ return null;
+ }
+
+ private JPAEntityTypeMapType searchJPAEntityTypeMapType(final String jpaEntityTypeName) {
+ for (JPAEntityTypeMapType jpaEntityType : mappingModel.getPersistenceUnit().getJPAEntityTypes()
+ .getJPAEntityType()) {
+ if (jpaEntityType.getName().equals(jpaEntityTypeName)) {
+ return jpaEntityType;
+ }
+ }
+
+ return null;
+ }
+
+ private JPAEmbeddableTypeMapType searchJPAEmbeddableTypeMapType(final String jpaEmbeddableTypeName) {
+ for (JPAEmbeddableTypeMapType jpaEmbeddableType : mappingModel.getPersistenceUnit().getJPAEmbeddableTypes()
+ .getJPAEmbeddableType()) {
+ if (jpaEmbeddableType.getName().equals(jpaEmbeddableTypeName)) {
+ return jpaEmbeddableType;
+ }
+ }
+
+ return null;
+ }
+
+ protected InputStream loadMappingModelInputStream() {
+ InputStream is = JPAEdmMappingModelService.class.getClassLoader().getResourceAsStream("../../" + mappingModelName);
+
+ return is;
+
+ }
+
+ @Override
+ public boolean checkExclusionOfJPAEntityType(final String jpaEntityTypeName) {
+ JPAEntityTypeMapType type = searchJPAEntityTypeMapType(jpaEntityTypeName);
+ if (type != null) {
+ return type.isExclude();
+ }
+ return false;
+ }
+
+ @Override
+ public boolean checkExclusionOfJPAAttributeType(final String jpaEntityTypeName, final String jpaAttributeName) {
+ JPAEntityTypeMapType type = searchJPAEntityTypeMapType(jpaEntityTypeName);
+ if (type != null && type.getJPAAttributes() != null) {
+ for (JPAAttribute jpaAttribute : type.getJPAAttributes().getJPAAttribute()) {
+ if (jpaAttribute.getName().equals(jpaAttributeName)) {
+ return jpaAttribute.isExclude();
+ }
+ }
+ }
+ return false;
+ }
+
+ @Override
+ public boolean checkExclusionOfJPAEmbeddableType(final String jpaEmbeddableTypeName) {
+ JPAEmbeddableTypeMapType type = searchJPAEmbeddableTypeMapType(jpaEmbeddableTypeName);
+ if (type != null) {
+ return type.isExclude();
+ }
+ return false;
+ }
+
+ @Override
+ public boolean checkExclusionOfJPAEmbeddableAttributeType(final String jpaEmbeddableTypeName,
+ final String jpaAttributeName) {
+ JPAEmbeddableTypeMapType type = searchJPAEmbeddableTypeMapType(jpaEmbeddableTypeName);
+ if (type != null && type.getJPAAttributes() != null) {
+ for (JPAAttribute jpaAttribute : type.getJPAAttributes().getJPAAttribute()) {
+ if (jpaAttribute.getName().equals(jpaAttributeName)) {
+ return jpaAttribute.isExclude();
+ }
+ }
+ }
+ return false;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/access/model/JPAEdmNameBuilder.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/access/model/JPAEdmNameBuilder.java b/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/access/model/JPAEdmNameBuilder.java
new file mode 100644
index 0000000..2a96ac9
--- /dev/null
+++ b/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/access/model/JPAEdmNameBuilder.java
@@ -0,0 +1,499 @@
+/*******************************************************************************
+ * 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.access.model;
+
+import java.lang.reflect.AnnotatedElement;
+import java.lang.reflect.Field;
+
+import javax.persistence.Column;
+import javax.persistence.metamodel.Attribute;
+import javax.persistence.metamodel.ManagedType;
+import javax.persistence.metamodel.PluralAttribute;
+
+import org.apache.olingo.odata2.api.edm.FullQualifiedName;
+import org.apache.olingo.odata2.api.edm.provider.Association;
+import org.apache.olingo.odata2.api.edm.provider.AssociationSet;
+import org.apache.olingo.odata2.api.edm.provider.ComplexProperty;
+import org.apache.olingo.odata2.api.edm.provider.ComplexType;
+import org.apache.olingo.odata2.api.edm.provider.EntityType;
+import org.apache.olingo.odata2.api.edm.provider.Mapping;
+import org.apache.olingo.odata2.api.edm.provider.NavigationProperty;
+import org.apache.olingo.odata2.processor.api.jpa.access.JPAEdmMappingModelAccess;
+import org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPAModelException;
+import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmAssociationEndView;
+import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmAssociationSetView;
+import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmAssociationView;
+import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmBaseView;
+import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmComplexPropertyView;
+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.api.jpa.model.JPAEdmNavigationPropertyView;
+import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmPropertyView;
+import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmSchemaView;
+import org.apache.olingo.odata2.processor.core.jpa.model.JPAEdmComplexType;
+import org.apache.olingo.odata2.processor.core.jpa.model.JPAEdmMappingImpl;
+
+public class JPAEdmNameBuilder {
+ private static final String ENTITY_CONTAINER_SUFFIX = "Container";
+ private static final String ENTITY_SET_SUFFIX = "s";
+ private static final String ASSOCIATIONSET_SUFFIX = "Set";
+ private static final String NAVIGATION_NAME = "Details";
+ private static final String UNDERSCORE = "_";
+
+ public static FullQualifiedName build(final JPAEdmBaseView view, final String name) {
+ FullQualifiedName fqName = new FullQualifiedName(buildNamespace(view), name);
+ return fqName;
+ }
+
+ /*
+ * ************************************************************************
+ * EDM EntityType Name - RULES
+ * ************************************************************************
+ * EDM Entity Type Name = JPA Entity Name EDM Entity Type Internal Name =
+ * JPA Entity Name
+ * ************************************************************************
+ * EDM Entity Type Name - RULES
+ * ************************************************************************
+ */
+ public static void build(final JPAEdmEntityTypeView view) {
+
+ EntityType edmEntityType = view.getEdmEntityType();
+ String jpaEntityName = view.getJPAEntityType().getName();
+ JPAEdmMappingModelAccess mappingModelAccess = view.getJPAEdmMappingModelAccess();
+ String edmEntityTypeName = null;
+ if (mappingModelAccess != null && mappingModelAccess.isMappingModelExists()) {
+ edmEntityTypeName = mappingModelAccess.mapJPAEntityType(jpaEntityName);
+ }
+
+ JPAEdmMapping mapping = new JPAEdmMappingImpl();
+ mapping.setJPAType(view.getJPAEntityType().getJavaType());
+
+ if (edmEntityTypeName == null) {
+ edmEntityTypeName = jpaEntityName;
+ }
+ // Setting the mapping object
+ edmEntityType.setMapping(((Mapping) mapping).setInternalName(jpaEntityName));
+
+ edmEntityType.setName(edmEntityTypeName);
+
+ }
+
+ /*
+ * ************************************************************************
+ * EDM Schema Name - RULES
+ * ************************************************************************
+ * Java Persistence Unit name is set as Schema's Namespace
+ * ************************************************************************
+ * EDM Schema Name - RULES
+ * ************************************************************************
+ */
+ public static void build(final JPAEdmSchemaView view) throws ODataJPAModelException {
+ view.getEdmSchema().setNamespace(buildNamespace(view));
+ }
+
+ /*
+ * ************************************************************************
+ * EDM Property Name - RULES
+ * ************************************************************************
+ * OData Property Names are represented in Camel Case. The first character
+ * of JPA Attribute Name is converted to an UpperCase Character and set as
+ * OData Property Name. JPA Attribute Name is set as Internal Name for OData
+ * Property. The Column name (annotated as @Column(name="x")) is set as
+ * column name in the mapping object.
+ * ************************************************************************
+ * EDM Property Name - RULES
+ * ************************************************************************
+ */
+ public static void build(final JPAEdmPropertyView view, final boolean isComplexMode,
+ final boolean skipDefaultNaming) {
+ Attribute<?, ?> jpaAttribute = view.getJPAAttribute();
+ String jpaAttributeName = jpaAttribute.getName();
+ String propertyName = null;
+
+ JPAEdmMappingModelAccess mappingModelAccess = view.getJPAEdmMappingModelAccess();
+ if (mappingModelAccess != null && mappingModelAccess.isMappingModelExists()) {
+ if (isComplexMode) {
+ propertyName =
+ mappingModelAccess.mapJPAEmbeddableTypeAttribute(view.getJPAEdmComplexTypeView().getJPAEmbeddableType()
+ .getJavaType().getSimpleName(), jpaAttributeName);
+ } else {
+ propertyName =
+ mappingModelAccess.mapJPAAttribute(view.getJPAEdmEntityTypeView().getJPAEntityType().getName(),
+ jpaAttributeName);
+ }
+ }
+ if (skipDefaultNaming == false && propertyName == null) {
+ propertyName = Character.toUpperCase(jpaAttributeName.charAt(0)) + jpaAttributeName.substring(1);
+ } else if (propertyName == null) {
+ propertyName = jpaAttributeName;
+ }
+
+ view.getEdmSimpleProperty().setName(propertyName);
+
+ JPAEdmMapping mapping = new JPAEdmMappingImpl();
+ ((Mapping) mapping).setInternalName(jpaAttributeName);
+ mapping.setJPAType(jpaAttribute.getJavaType());
+
+ AnnotatedElement annotatedElement = (AnnotatedElement) jpaAttribute.getJavaMember();
+ if (annotatedElement != null) {
+ Column column = annotatedElement.getAnnotation(Column.class);
+ if (column != null) {
+ mapping.setJPAColumnName(column.name());
+ }
+ } else {
+ ManagedType<?> managedType = jpaAttribute.getDeclaringType();
+ if (managedType != null) {
+ Class<?> clazz = managedType.getJavaType();
+ try {
+ Field field = clazz.getField(jpaAttributeName);
+ Column column = field.getAnnotation(Column.class);
+ if (column != null) {
+ mapping.setJPAColumnName(column.name());
+ }
+ } catch (SecurityException e) {
+
+ } catch (NoSuchFieldException e) {
+
+ }
+ }
+
+ }
+ view.getEdmSimpleProperty().setMapping((Mapping) mapping);
+ }
+
+ /*
+ * ************************************************************************
+ * EDM EntityContainer Name - RULES
+ * ************************************************************************
+ * Entity Container Name = EDM Namespace + Literal "Container"
+ * ************************************************************************
+ * EDM EntityContainer Name - RULES
+ * ************************************************************************
+ */
+ public static void build(final JPAEdmEntityContainerView view) {
+ view.getEdmEntityContainer().setName(buildNamespace(view) + ENTITY_CONTAINER_SUFFIX);
+ }
+
+ /*
+ * ************************************************************************
+ * EDM EntitySet Name - RULES
+ * ************************************************************************
+ * Entity Set Name = JPA Entity Type Name + Literal "s"
+ * ************************************************************************
+ * EDM EntitySet Name - RULES
+ * ************************************************************************
+ */
+ public static void build(final JPAEdmEntitySetView view, final JPAEdmEntityTypeView entityTypeView) {
+ FullQualifiedName fQname = view.getEdmEntitySet().getEntityType();
+ JPAEdmMappingModelAccess mappingModelAccess = view.getJPAEdmMappingModelAccess();
+ String entitySetName = null;
+ if (mappingModelAccess != null && mappingModelAccess.isMappingModelExists()) {
+ Mapping mapping = entityTypeView.getEdmEntityType().getMapping();
+ if (mapping != null) {
+ entitySetName = mappingModelAccess.mapJPAEntitySet(mapping.getInternalName());
+ }
+ }
+
+ if (entitySetName == null) {
+ entitySetName = fQname.getName() + ENTITY_SET_SUFFIX;
+ }
+
+ view.getEdmEntitySet().setName(entitySetName);
+ }
+
+ /*
+ * ************************************************************************
+ * EDM Complex Type Name - RULES
+ * ************************************************************************
+ * Complex Type Name = JPA Embeddable Type Simple Name.
+ * ************************************************************************
+ * EDM Complex Type Name - RULES
+ * ************************************************************************
+ */
+ public static void build(final JPAEdmComplexType view) {
+
+ JPAEdmMappingModelAccess mappingModelAccess = view.getJPAEdmMappingModelAccess();
+ String jpaEmbeddableTypeName = view.getJPAEmbeddableType().getJavaType().getSimpleName();
+ String edmComplexTypeName = null;
+ if (mappingModelAccess != null && mappingModelAccess.isMappingModelExists()) {
+ edmComplexTypeName = mappingModelAccess.mapJPAEmbeddableType(jpaEmbeddableTypeName);
+ }
+
+ if (edmComplexTypeName == null) {
+ edmComplexTypeName = jpaEmbeddableTypeName;
+ }
+
+ view.getEdmComplexType().setName(edmComplexTypeName);
+ ComplexType complexType = view.getEdmComplexType();
+ complexType.setName(edmComplexTypeName);
+ JPAEdmMapping mapping = new JPAEdmMappingImpl();
+ mapping.setJPAType(view.getJPAEmbeddableType().getJavaType());
+ complexType.setMapping((Mapping) mapping);
+
+ }
+
+ /*
+ * ************************************************************************
+ * EDM Complex Property Name - RULES
+ * ************************************************************************
+ * The first character of JPA complex attribute name is converted to
+ * uppercase. The modified JPA complex attribute name is assigned as EDM
+ * complex property name. The unmodified JPA complex attribute name is
+ * assigned as internal name.
+ * ************************************************************************
+ * EDM Complex Property Name - RULES
+ * ************************************************************************
+ */
+ public static void build(final JPAEdmComplexPropertyView complexView,
+ final JPAEdmPropertyView propertyView, final boolean skipDefaultNaming) {
+
+ ComplexProperty complexProperty = complexView.getEdmComplexProperty();
+
+ String jpaAttributeName = propertyView.getJPAAttribute().getName();
+ String jpaEntityTypeName = propertyView.getJPAEdmEntityTypeView().getJPAEntityType().getName();
+
+ JPAEdmMappingModelAccess mappingModelAccess = complexView.getJPAEdmMappingModelAccess();
+ String propertyName = null;
+
+ if (mappingModelAccess != null && mappingModelAccess.isMappingModelExists()) {
+ propertyName = mappingModelAccess.mapJPAAttribute(jpaEntityTypeName, jpaAttributeName);
+ }
+
+ if (skipDefaultNaming == false && propertyName == null) {
+ propertyName = Character.toUpperCase(jpaAttributeName.charAt(0)) + jpaAttributeName.substring(1);
+ } else if (propertyName == null) {
+ propertyName = jpaAttributeName;
+ }
+
+ // change for navigation property issue
+ JPAEdmMapping mapping = new JPAEdmMappingImpl();
+ ((Mapping) mapping).setInternalName(jpaAttributeName);
+ mapping.setJPAType(propertyView.getJPAAttribute().getJavaType());
+ complexProperty.setMapping((Mapping) mapping);
+
+ complexProperty.setName(propertyName);
+
+ }
+
+ public static void build(final JPAEdmComplexPropertyView complexView,
+ final String parentComplexTypeName, final boolean skipDefaultNaming) {
+ ComplexProperty complexProperty = complexView.getEdmComplexProperty();
+
+ JPAEdmMappingModelAccess mappingModelAccess = complexView.getJPAEdmMappingModelAccess();
+ JPAEdmPropertyView propertyView = ((JPAEdmPropertyView) complexView);
+ String jpaAttributeName = propertyView.getJPAAttribute().getName();
+ String propertyName = null;
+ if (mappingModelAccess != null && mappingModelAccess.isMappingModelExists()) {
+ propertyName = mappingModelAccess.mapJPAEmbeddableTypeAttribute(parentComplexTypeName, jpaAttributeName);
+ }
+ if (skipDefaultNaming == false && propertyName == null) {
+ propertyName = Character.toUpperCase(jpaAttributeName.charAt(0)) + jpaAttributeName.substring(1);
+ } else if (propertyName == null) {
+ propertyName = jpaAttributeName;
+ }
+
+ JPAEdmMapping mapping = new JPAEdmMappingImpl();
+ ((Mapping) mapping).setInternalName(jpaAttributeName);
+ mapping.setJPAType(propertyView.getJPAAttribute().getJavaType());
+ complexProperty.setMapping((Mapping) mapping);
+ complexProperty.setName(propertyName);
+
+ }
+
+ /*
+ * ************************************************************************
+ * EDM Association End Name - RULES
+ * ************************************************************************
+ * Association End name = Namespace + Entity Type Name
+ * ************************************************************************
+ * EDM Association End Name - RULES
+ * ************************************************************************
+ */
+ public static void build(final JPAEdmAssociationEndView assocaitionEndView,
+ final JPAEdmEntityTypeView entityTypeView, final JPAEdmPropertyView propertyView) {
+
+ String namespace = buildNamespace(assocaitionEndView);
+
+ String name = entityTypeView.getEdmEntityType().getName();
+ FullQualifiedName fQName = new FullQualifiedName(namespace, name);
+ assocaitionEndView.getEdmAssociationEnd1().setType(fQName);
+
+ name = null;
+ String jpaEntityTypeName = null;
+ Attribute<?, ?> jpaAttribute = propertyView.getJPAAttribute();
+ if (jpaAttribute.isCollection()) {
+ jpaEntityTypeName = ((PluralAttribute<?, ?, ?>) jpaAttribute).getElementType().getJavaType()
+ .getSimpleName();
+ } else {
+ jpaEntityTypeName = propertyView.getJPAAttribute().getJavaType()
+ .getSimpleName();
+ }
+
+ JPAEdmMappingModelAccess mappingModelAccess = assocaitionEndView.getJPAEdmMappingModelAccess();
+
+ if (mappingModelAccess != null && mappingModelAccess.isMappingModelExists()) {
+ name = mappingModelAccess.mapJPAEntityType(jpaEntityTypeName);
+ }
+
+ if (name == null) {
+ name = jpaEntityTypeName;
+ }
+
+ fQName = new FullQualifiedName(namespace, name);
+ assocaitionEndView.getEdmAssociationEnd2().setType(fQName);
+
+ }
+
+ private static String buildNamespace(final JPAEdmBaseView view) {
+ JPAEdmMappingModelAccess mappingModelAccess = view.getJPAEdmMappingModelAccess();
+ String namespace = null;
+ if (mappingModelAccess != null && mappingModelAccess.isMappingModelExists()) {
+ namespace = mappingModelAccess.mapJPAPersistenceUnit(view.getpUnitName());
+ }
+ if (namespace == null) {
+ namespace = view.getpUnitName();
+ }
+
+ return namespace;
+ }
+
+ /*
+ * ************************************************************************
+ * EDM Association Name - RULES
+ * ************************************************************************
+ * Association name = Association + End1 Name + End2 Name
+ * ************************************************************************
+ * EDM Association Name - RULES
+ * ************************************************************************
+ */
+
+ public static void build(final JPAEdmAssociationView view, final int count) {
+ Association association = view.getEdmAssociation();
+ String associationName = null;
+ String end1Name = association.getEnd1().getType().getName();
+ String end2Name = association.getEnd2().getType().getName();
+
+ if (end1Name.compareToIgnoreCase(end2Name) > 0) {
+ associationName = end2Name + UNDERSCORE + end1Name;
+ } else {
+ associationName = end1Name + UNDERSCORE + end2Name;
+ }
+ if (count > 1) {
+ associationName = associationName + Integer.toString(count - 1);
+ }
+ association.setName(associationName);
+
+ }
+
+ /*
+ * ************************************************************************
+ * EDM Association Set Name - RULES
+ * ************************************************************************
+ * Association Set name = Association Name + "Set"
+ * ************************************************************************
+ * EDM Association Set Name - RULES
+ * ************************************************************************
+ */
+ public static void build(final JPAEdmAssociationSetView view) {
+ AssociationSet associationSet = view.getEdmAssociationSet();
+
+ String name = view.getEdmAssociation().getName();
+ associationSet.setName(name + ASSOCIATIONSET_SUFFIX);
+
+ }
+
+ public static void build(final JPAEdmAssociationView associationView,
+ final JPAEdmPropertyView propertyView,
+ final JPAEdmNavigationPropertyView navPropertyView, final boolean skipDefaultNaming, final int count) {
+
+ String toName = null;
+ String fromName = null;
+ String navPropName = null;
+ NavigationProperty navProp = navPropertyView.getEdmNavigationProperty();
+ String namespace = buildNamespace(associationView);
+
+ Association association = associationView.getEdmAssociation();
+ navProp.setRelationship(new FullQualifiedName(namespace, association
+ .getName()));
+
+ FullQualifiedName associationEndTypeOne = association.getEnd1()
+ .getType();
+ FullQualifiedName associationEndTypeTwo = association.getEnd2()
+ .getType();
+
+ Attribute<?, ?> jpaAttribute = propertyView.getJPAAttribute();
+ JPAEdmMapping mapping = new JPAEdmMappingImpl();
+ ((Mapping) mapping).setInternalName(jpaAttribute.getName());
+ mapping.setJPAType(jpaAttribute.getJavaType());
+ navProp.setMapping((Mapping) mapping);
+
+ String jpaEntityTypeName = propertyView.getJPAEdmEntityTypeView()
+ .getJPAEntityType().getName();
+ JPAEdmMappingModelAccess mappingModelAccess = navPropertyView
+ .getJPAEdmMappingModelAccess();
+
+ String targetEntityTypeName = null;
+ if (jpaAttribute.isCollection()) {
+ targetEntityTypeName = ((PluralAttribute<?, ?, ?>) jpaAttribute).getElementType().getJavaType().getSimpleName();
+ } else {
+ targetEntityTypeName = jpaAttribute.getJavaType().getSimpleName();
+ }
+
+ if (mappingModelAccess != null
+ && mappingModelAccess.isMappingModelExists()) {
+ navPropName = mappingModelAccess.mapJPARelationship(
+ jpaEntityTypeName, jpaAttribute.getName());
+ toName = mappingModelAccess.mapJPAEntityType(targetEntityTypeName);
+ fromName = mappingModelAccess
+ .mapJPAEntityType(jpaEntityTypeName);
+ }
+ if (toName == null) {
+ toName = targetEntityTypeName;
+ }
+
+ if (fromName == null) {
+ fromName = jpaEntityTypeName;
+ }
+
+ if (skipDefaultNaming == false) {
+ if (navPropName == null) {
+ navPropName = toName.concat(NAVIGATION_NAME);
+ }
+ if (count > 1) {
+ navPropName = navPropName + Integer.toString(count - 1);
+ }
+ } else if (navPropName == null) {
+ navPropName = jpaAttribute.getName();
+ }
+
+ navProp.setName(navPropName);
+
+ if (toName.equals(associationEndTypeOne.getName())) {
+ navProp.setFromRole(association.getEnd2().getRole());
+ navProp.setToRole(association.getEnd1().getRole());
+ } else if (toName.equals(associationEndTypeTwo.getName())) {
+
+ navProp.setToRole(association.getEnd2().getRole());
+ navProp.setFromRole(association.getEnd1().getRole());
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/access/model/JPATypeConvertor.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/access/model/JPATypeConvertor.java b/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/access/model/JPATypeConvertor.java
new file mode 100644
index 0000000..e7b8a6e
--- /dev/null
+++ b/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/access/model/JPATypeConvertor.java
@@ -0,0 +1,119 @@
+/*******************************************************************************
+ * 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.access.model;
+
+import java.lang.reflect.Field;
+import java.math.BigDecimal;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.UUID;
+
+import javax.persistence.Temporal;
+import javax.persistence.TemporalType;
+import javax.persistence.metamodel.Attribute;
+
+import org.apache.olingo.odata2.api.edm.EdmSimpleTypeKind;
+import org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPAModelException;
+
+/**
+ * This class holds utility methods for Type conversions between JPA and OData Types.
+ *
+ *
+ *
+ */
+public class JPATypeConvertor {
+
+ /**
+ * This utility method converts a given jpa Type to equivalent
+ * EdmSimpleTypeKind for maintaining compatibility between Java and OData
+ * Types.
+ *
+ * @param jpaType
+ * The JPA Type input.
+ * @return The corresponding EdmSimpleTypeKind.
+ * @throws ODataJPAModelException
+ * @throws org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPARuntimeException
+ *
+ * @see EdmSimpleTypeKind
+ */
+
+ private static final String OBJECT_TYPE = "java.lang.Object";
+
+ public static EdmSimpleTypeKind
+ convertToEdmSimpleType(final Class<?> jpaType, final Attribute<?, ?> currentAttribute)
+ throws ODataJPAModelException {
+ if (jpaType.equals(String.class) || jpaType.equals(Character.class) || jpaType.equals(char.class)
+ || jpaType.equals(char[].class) ||
+ jpaType.equals(Character[].class)) {
+ return EdmSimpleTypeKind.String;
+ } else if (jpaType.equals(Long.class) || jpaType.equals(long.class)) {
+ return EdmSimpleTypeKind.Int64;
+ } else if (jpaType.equals(Short.class) || jpaType.equals(short.class)) {
+ return EdmSimpleTypeKind.Int16;
+ } else if (jpaType.equals(Integer.class) || jpaType.equals(int.class)) {
+ return EdmSimpleTypeKind.Int32;
+ } else if (jpaType.equals(Double.class) || jpaType.equals(double.class)) {
+ return EdmSimpleTypeKind.Double;
+ } else if (jpaType.equals(Float.class) || jpaType.equals(float.class)) {
+ return EdmSimpleTypeKind.Single;
+ } else if (jpaType.equals(BigDecimal.class)) {
+ return EdmSimpleTypeKind.Decimal;
+ } else if (jpaType.equals(byte[].class)) {
+ return EdmSimpleTypeKind.Binary;
+ } else if (jpaType.equals(Byte.class) || jpaType.equals(byte.class)) {
+ return EdmSimpleTypeKind.Byte;
+ } else if (jpaType.equals(Byte[].class)) {
+ return EdmSimpleTypeKind.Binary;
+ } else if (jpaType.equals(Boolean.class) || jpaType.equals(boolean.class)) {
+ return EdmSimpleTypeKind.Boolean;
+ } else if ((jpaType.equals(Date.class)) || (jpaType.equals(Calendar.class))) {
+ try {
+ if ((currentAttribute != null)
+ && (determineTemporalType(currentAttribute.getDeclaringType().getJavaType(), currentAttribute.getName())
+ == TemporalType.TIME)) {
+ return EdmSimpleTypeKind.Time;
+ } else {
+ return EdmSimpleTypeKind.DateTime;
+ }
+ } catch (SecurityException e) {
+ throw ODataJPAModelException.throwException(ODataJPAModelException.GENERAL.addContent(e.getMessage()), e);
+ }
+ } else if (jpaType.equals(UUID.class)) {
+ return EdmSimpleTypeKind.Guid;
+ }
+ throw ODataJPAModelException.throwException(ODataJPAModelException.TYPE_NOT_SUPPORTED
+ .addContent(jpaType.toString()), null);
+ }
+
+ private static TemporalType determineTemporalType(final Class<?> type, final String fieldName)
+ throws ODataJPAModelException {
+ if (type != null && !type.getName().equals(OBJECT_TYPE)) {
+ try {
+ Field field = type.getField(fieldName);
+ return field.getAnnotation(Temporal.class).value();
+ } catch (NoSuchFieldException e) {
+ determineTemporalType(type.getSuperclass(), fieldName);
+ } catch (SecurityException e) {
+ throw ODataJPAModelException.throwException(ODataJPAModelException.GENERAL.addContent(e.getMessage()), e);
+ }
+ }
+ return null;
+
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/edm/ODataJPAEdmProvider.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/edm/ODataJPAEdmProvider.java b/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/edm/ODataJPAEdmProvider.java
new file mode 100644
index 0000000..e0014e5
--- /dev/null
+++ b/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/edm/ODataJPAEdmProvider.java
@@ -0,0 +1,295 @@
+/*******************************************************************************
+ * 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.edm;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+
+import org.apache.olingo.odata2.api.edm.FullQualifiedName;
+import org.apache.olingo.odata2.api.edm.provider.Association;
+import org.apache.olingo.odata2.api.edm.provider.AssociationSet;
+import org.apache.olingo.odata2.api.edm.provider.AssociationSetEnd;
+import org.apache.olingo.odata2.api.edm.provider.ComplexType;
+import org.apache.olingo.odata2.api.edm.provider.EdmProvider;
+import org.apache.olingo.odata2.api.edm.provider.EntityContainer;
+import org.apache.olingo.odata2.api.edm.provider.EntityContainerInfo;
+import org.apache.olingo.odata2.api.edm.provider.EntitySet;
+import org.apache.olingo.odata2.api.edm.provider.EntityType;
+import org.apache.olingo.odata2.api.edm.provider.FunctionImport;
+import org.apache.olingo.odata2.api.edm.provider.Schema;
+import org.apache.olingo.odata2.api.exception.ODataException;
+import org.apache.olingo.odata2.processor.api.jpa.ODataJPAContext;
+import org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPAException;
+import org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPAModelException;
+import org.apache.olingo.odata2.processor.api.jpa.factory.ODataJPAFactory;
+import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmModelView;
+
+public class ODataJPAEdmProvider extends EdmProvider {
+
+ private ODataJPAContext oDataJPAContext;
+ private JPAEdmModelView jpaEdmModel;
+
+ private List<Schema> schemas;
+ private HashMap<String, EntityType> entityTypes;
+ private HashMap<String, EntityContainerInfo> entityContainerInfos;
+ private HashMap<String, ComplexType> complexTypes;
+ private HashMap<String, Association> associations;
+ private HashMap<String, FunctionImport> functionImports;
+
+ public ODataJPAEdmProvider() {
+ entityTypes = new HashMap<String, EntityType>();
+ entityContainerInfos = new HashMap<String, EntityContainerInfo>();
+ complexTypes = new HashMap<String, ComplexType>();
+ associations = new HashMap<String, Association>();
+ functionImports = new HashMap<String, FunctionImport>();
+ }
+
+ public ODataJPAEdmProvider(final ODataJPAContext oDataJPAContext) {
+ if (oDataJPAContext == null) {
+ throw new IllegalArgumentException(ODataJPAException.ODATA_JPACTX_NULL);
+ }
+ entityTypes = new HashMap<String, EntityType>();
+ entityContainerInfos = new HashMap<String, EntityContainerInfo>();
+ complexTypes = new HashMap<String, ComplexType>();
+ associations = new HashMap<String, Association>();
+ functionImports = new HashMap<String, FunctionImport>();
+ jpaEdmModel = ODataJPAFactory.createFactory().getJPAAccessFactory().getJPAEdmModelView(oDataJPAContext);
+ }
+
+ public ODataJPAContext getODataJPAContext() {
+ return oDataJPAContext;
+ }
+
+ public void setODataJPAContext(final ODataJPAContext jpaContext) {
+ oDataJPAContext = jpaContext;
+ }
+
+ @Override
+ public EntityContainerInfo getEntityContainerInfo(final String name) throws ODataException {
+
+ if (entityContainerInfos.containsKey(name)) {
+ return entityContainerInfos.get(name);
+ } else {
+
+ if (schemas == null) {
+ getSchemas();
+ }
+ List<EntityContainer> containerList = schemas.get(0).getEntityContainers();
+ if (containerList == null) {
+ return null;
+ }
+ for (EntityContainer container : containerList) {
+ if (name == null && container.isDefaultEntityContainer()) {
+ entityContainerInfos.put(name, container);
+ return container;
+ } else if (name != null && name.equals(container.getName())) {
+ return container;
+ }
+ }
+ }
+ return null;
+ }
+
+ @Override
+ public EntityType getEntityType(final FullQualifiedName edmFQName) throws ODataException {
+
+ String strEdmFQName = edmFQName.toString();
+
+ if (edmFQName != null) {
+ if (entityTypes.containsKey(strEdmFQName)) {
+ return entityTypes.get(strEdmFQName);
+ } else if (schemas == null) {
+ getSchemas();
+ }
+
+ String entityTypeNamespace = edmFQName.getNamespace();
+ String entityTypeName = edmFQName.getName();
+
+ for (Schema schema : schemas) {
+ String schemaNamespace = schema.getNamespace();
+ if (schemaNamespace.equals(entityTypeNamespace)) {
+ if (schema.getEntityTypes() == null) {
+ return null;
+ }
+ for (EntityType et : schema.getEntityTypes()) {
+ if (et.getName().equals(entityTypeName)) {
+ entityTypes.put(strEdmFQName, et);
+ return et;
+ }
+ }
+ }
+ }
+ }
+
+ return null;
+ }
+
+ @Override
+ public ComplexType getComplexType(final FullQualifiedName edmFQName) throws ODataException {
+
+ if (edmFQName != null) {
+ if (complexTypes.containsKey(edmFQName.toString())) {
+ return complexTypes.get(edmFQName.toString());
+ } else if (schemas == null) {
+ getSchemas();
+ }
+
+ for (Schema schema : schemas) {
+ if (schema.getNamespace().equals(edmFQName.getNamespace())) {
+ if (schema.getComplexTypes() == null) {
+ return null;
+ }
+ for (ComplexType ct : schema.getComplexTypes()) {
+ if (ct.getName().equals(edmFQName.getName())) {
+ complexTypes.put(edmFQName.toString(), ct);
+ return ct;
+ }
+ }
+ }
+ }
+ }
+
+ return null;
+ }
+
+ @Override
+ public Association getAssociation(final FullQualifiedName edmFQName) throws ODataException {
+ if (edmFQName != null) {
+ if (associations.containsKey(edmFQName.toString())) {
+ return associations.get(edmFQName.toString());
+ } else if (schemas == null) {
+ getSchemas();
+ }
+
+ for (Schema schema : schemas) {
+ if (schema.getNamespace().equals(edmFQName.getNamespace())) {
+ if (schema.getAssociations() == null) {
+ return null;
+ }
+ for (Association association : schema.getAssociations()) {
+ if (association.getName().equals(edmFQName.getName())) {
+ associations.put(edmFQName.toString(), association);
+ return association;
+ }
+ }
+ }
+ }
+
+ }
+ return null;
+ }
+
+ @Override
+ public EntitySet getEntitySet(final String entityContainer, final String name) throws ODataException {
+
+ EntitySet returnedSet = null;
+ EntityContainer container = null;
+ if (!entityContainerInfos.containsKey(entityContainer)) {
+ container = (EntityContainer) getEntityContainerInfo(entityContainer);
+ } else {
+ container = (EntityContainer) entityContainerInfos.get(entityContainer);
+ }
+
+ if (container != null && name != null) {
+ for (EntitySet es : container.getEntitySets()) {
+ if (name.equals(es.getName())) {
+ returnedSet = es;
+ break;
+ }
+ }
+ }
+
+ return returnedSet;
+ }
+
+ @Override
+ public AssociationSet getAssociationSet(final String entityContainer, final FullQualifiedName association,
+ final String sourceEntitySetName, final String sourceEntitySetRole) throws ODataException {
+
+ EntityContainer container = null;
+ if (!entityContainerInfos.containsKey(entityContainer)) {
+ container = (EntityContainer) getEntityContainerInfo(entityContainer);
+ } else {
+ container = (EntityContainer) entityContainerInfos.get(entityContainer);
+ }
+
+ if (container != null && association != null && container.getAssociationSets() != null) {
+ for (AssociationSet as : container.getAssociationSets()) {
+ if (association.equals(as.getAssociation())) {
+ AssociationSetEnd end = as.getEnd1();
+ if (sourceEntitySetName.equals(end.getEntitySet()) && sourceEntitySetRole.equals(end.getRole())) {
+ return as;
+ } else {
+ end = as.getEnd2();
+ if (sourceEntitySetName.equals(end.getEntitySet()) && sourceEntitySetRole.equals(end.getRole())) {
+ return as;
+ }
+ }
+ }
+ }
+ }
+ return null;
+ }
+
+ @Override
+ public FunctionImport getFunctionImport(final String entityContainer, final String name) throws ODataException {
+
+ if (functionImports.containsKey(name)) {
+ return functionImports.get(name);
+ }
+
+ EntityContainer container = null;
+ if (!entityContainerInfos.containsKey(entityContainer)) {
+ container = (EntityContainer) getEntityContainerInfo(entityContainer);
+ } else {
+ container = (EntityContainer) entityContainerInfos.get(entityContainer);
+ }
+
+ if (container != null && name != null) {
+ if (container.getFunctionImports() == null) {
+ return null;
+ }
+ for (FunctionImport fi : container.getFunctionImports()) {
+ if (name.equals(fi.getName())) {
+ functionImports.put(name, fi);
+ return fi;
+ }
+ }
+ }
+ return null;
+ }
+
+ @Override
+ public List<Schema> getSchemas() throws ODataException {
+ if (schemas == null && jpaEdmModel != null) {
+ jpaEdmModel.getBuilder().build();
+ schemas = new ArrayList<Schema>();
+ schemas.add(jpaEdmModel.getEdmSchemaView().getEdmSchema());
+ }
+ if (jpaEdmModel == null) {
+
+ throw ODataJPAModelException.throwException(ODataJPAModelException.BUILDER_NULL, null);
+ }
+
+ return schemas;
+
+ }
+
+}
[09/37] [OLINGO-82] Renamed the project folder name to
odata2-jpa-processor
Posted by ch...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/access/data/JPAEntityParserTestForStaticMethods.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/access/data/JPAEntityParserTestForStaticMethods.java b/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/access/data/JPAEntityParserTestForStaticMethods.java
deleted file mode 100644
index 86514b4..0000000
--- a/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/access/data/JPAEntityParserTestForStaticMethods.java
+++ /dev/null
@@ -1,251 +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.access.data;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import java.lang.reflect.Method;
-
-import org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPARuntimeException;
-import org.apache.olingo.odata2.processor.core.jpa.common.ODataJPATestConstants;
-import org.junit.Test;
-
-public class JPAEntityParserTestForStaticMethods {
-
- @Test
- public void testToStringDefault() {
-
- Character[] input = new Character[] { 'A', 'B' };
- assertEquals("AB", JPAEntityParser.toString(input));
-
- }
-
- @Test
- public void testToStringNull() {
- Character[] input = null;
- assertNull(JPAEntityParser.toString(input));
- }
-
- @Test
- public void testToStringPartialNull() {
- Character[] input = new Character[] { 'A', null };
- assertEquals("A", JPAEntityParser.toString(input));
- }
-
- @Test
- public void testToCharacterArrayDefault() {
- String input = new String("AB");
- Character[] ch = JPAEntityParser.toCharacterArray(input);
-
- assertEquals(2, ch.length);
- assertTrue(ch[0].equals('A'));
- assertTrue(ch[1].equals('B'));
- }
-
- @Test
- public void testToCharacterArrayNull() {
- String input = null;
- Character[] ch = JPAEntityParser.toCharacterArray(input);
-
- assertNull(ch);
- }
-
- @Test
- public void testGetPropertyCharacter() {
- try {
- Method method = JPAEntityParserTestForStaticMethods.class.getMethod("getCharacter", (Class<?>[]) null);
- String output = (String) JPAEntityParser.getProperty(method, this);
- assertEquals("A", output);
-
- } catch (NoSuchMethodException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- } catch (SecurityException 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);
- }
- }
-
- @Test
- public void testGetPropertyCharacterNull() {
- try {
- Method method = JPAEntityParserTestForStaticMethods.class.getMethod("getCharacterNull", (Class<?>[]) null);
- String output = (String) JPAEntityParser.getProperty(method, this);
- assertNull(output);
-
- } catch (NoSuchMethodException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- } catch (SecurityException 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);
- }
- }
-
- @Test
- public void testGetPropertyCharacterArray() {
- try {
- Method method = JPAEntityParserTestForStaticMethods.class.getMethod("getCharacterArray", (Class<?>[]) null);
- String output = (String) JPAEntityParser.getProperty(method, this);
- assertEquals("AB", output);
-
- } catch (NoSuchMethodException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- } catch (SecurityException 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);
- }
- }
-
- @Test
- public void testGetPropertyCharacterArrayNull() {
- try {
- Method method = JPAEntityParserTestForStaticMethods.class.getMethod("getCharacterArrayNull", (Class<?>[]) null);
- String output = (String) JPAEntityParser.getProperty(method, this);
- assertNull(output);
-
- } catch (NoSuchMethodException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- } catch (SecurityException 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);
- }
- }
-
- @Test
- public void testGetPropertyChar() {
- try {
- Method method = JPAEntityParserTestForStaticMethods.class.getMethod("getChar", (Class<?>[]) null);
- String output = (String) JPAEntityParser.getProperty(method, this);
- assertEquals("A", output);
-
- } catch (NoSuchMethodException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- } catch (SecurityException 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);
- }
- }
-
- @Test
- public void testGetPropertyCharNull() {
- try {
- Method method = JPAEntityParserTestForStaticMethods.class.getMethod("getCharNull", (Class<?>[]) null);
- String output = (String) JPAEntityParser.getProperty(method, this);
- assertNull(output);
-
- } catch (NoSuchMethodException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- } catch (SecurityException 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);
- }
- }
-
- @Test
- public void testGetPropertyCharArray() {
- try {
- Method method = JPAEntityParserTestForStaticMethods.class.getMethod("getCharArray", (Class<?>[]) null);
- String output = (String) JPAEntityParser.getProperty(method, this);
- assertEquals("AB", output);
-
- } catch (NoSuchMethodException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- } catch (SecurityException 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);
- }
- }
-
- @Test
- public void testGetPropertyCharArrayNull() {
- try {
- Method method = JPAEntityParserTestForStaticMethods.class.getMethod("getCharArrayNull", (Class<?>[]) null);
- String output = (String) JPAEntityParser.getProperty(method, this);
- assertNull(output);
-
- } catch (NoSuchMethodException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- } catch (SecurityException 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);
- }
- }
-
- @Test
- public void testGetPropertyCharArrayValueNull() {
- try {
- Method method = JPAEntityParserTestForStaticMethods.class.getMethod("getCharArrayValueNull", (Class<?>[]) null);
- String output = (String) JPAEntityParser.getProperty(method, this);
- assertEquals("A\u0000", output);
-
- } catch (NoSuchMethodException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- } catch (SecurityException 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);
- }
- }
-
- public Character getCharacter() {
- return new Character('A');
- }
-
- public Character getCharacterNull() {
- return null;
- }
-
- public Character[] getCharacterArray() {
- return new Character[] { 'A', 'B' };
- }
-
- public Character[] getCharacterArrayNull() {
- return null;
- }
-
- public char getChar() {
- return 'A';
- }
-
- public char getCharNull() {
- return '\u0000';
- }
-
- public char[] getCharArray() {
- return new char[] { 'A', 'B' };
- }
-
- public char[] getCharArrayNull() {
- return null;
- }
-
- public char[] getCharArrayValueNull() {
- return new char[] { 'A', '\u0000' };
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/access/data/JPAEntityTest.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/access/data/JPAEntityTest.java b/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/access/data/JPAEntityTest.java
deleted file mode 100644
index 8fbbed9..0000000
--- a/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/access/data/JPAEntityTest.java
+++ /dev/null
@@ -1,187 +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.access.data;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import org.apache.olingo.odata2.api.edm.EdmEntitySet;
-import org.apache.olingo.odata2.api.edm.EdmEntityType;
-import org.apache.olingo.odata2.api.edm.EdmException;
-import org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPARuntimeException;
-import org.apache.olingo.odata2.processor.core.jpa.common.ODataJPATestConstants;
-import org.apache.olingo.odata2.processor.core.jpa.mock.data.EdmMockUtilV2;
-import org.apache.olingo.odata2.processor.core.jpa.mock.data.JPATypeMock;
-import org.apache.olingo.odata2.processor.core.jpa.mock.data.JPATypeMock.JPARelatedTypeMock;
-import org.apache.olingo.odata2.processor.core.jpa.mock.data.JPATypeMock.JPATypeEmbeddableMock;
-import org.apache.olingo.odata2.processor.core.jpa.mock.data.JPATypeMock.JPATypeEmbeddableMock2;
-import org.apache.olingo.odata2.processor.core.jpa.mock.data.ODataEntryMockUtil;
-import org.junit.Test;
-
-public class JPAEntityTest {
-
- private JPAEntity jpaEntity = null;
-
- @Test
- public void testCreateODataEntryWithComplexType() {
- try {
- EdmEntitySet edmEntitySet = EdmMockUtilV2.mockEdmEntitySet(JPATypeMock.ENTITY_NAME, true);
- EdmEntityType edmEntityType = edmEntitySet.getEntityType();
-
- jpaEntity = new JPAEntity(edmEntityType, edmEntitySet);
- jpaEntity.create(ODataEntryMockUtil.mockODataEntryWithComplexType(JPATypeMock.ENTITY_NAME));
- } catch (ODataJPARuntimeException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage()
- + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- } catch (EdmException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage()
- + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
- JPATypeMock jpaTypeMock = (JPATypeMock) jpaEntity.getJPAEntity();
- assertEquals(jpaTypeMock.getMInt(), ODataEntryMockUtil.VALUE_MINT);
- assertEquals(jpaTypeMock.getMString(), ODataEntryMockUtil.VALUE_MSTRING);
- assertTrue(jpaTypeMock.getMDateTime().equals(ODataEntryMockUtil.VALUE_DATE_TIME));
- JPATypeEmbeddableMock jpaEmbeddableMock = jpaTypeMock.getComplexType();
- assertNotNull(jpaEmbeddableMock);
-
- assertEquals(jpaEmbeddableMock.getMShort(), ODataEntryMockUtil.VALUE_SHORT);
- JPATypeEmbeddableMock2 jpaEmbeddableMock2 = jpaEmbeddableMock.getMEmbeddable();
- assertNotNull(jpaEmbeddableMock2);
- assertEquals(jpaEmbeddableMock2.getMFloat(), ODataEntryMockUtil.VALUE_MFLOAT, 1);
- assertEquals(jpaEmbeddableMock2.getMUUID(), ODataEntryMockUtil.VALUE_UUID);
- }
-
- @Test
- public void testCreateODataEntry() {
- try {
- EdmEntitySet edmEntitySet = EdmMockUtilV2.mockEdmEntitySet(JPATypeMock.ENTITY_NAME, false);
- EdmEntityType edmEntityType = edmEntitySet.getEntityType();
-
- jpaEntity = new JPAEntity(edmEntityType, edmEntitySet);
- jpaEntity.create(ODataEntryMockUtil.mockODataEntry(JPATypeMock.ENTITY_NAME));
- } catch (ODataJPARuntimeException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage()
- + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- } catch (EdmException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage()
- + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
- JPATypeMock jpaTypeMock = (JPATypeMock) jpaEntity.getJPAEntity();
- assertEquals(jpaTypeMock.getMInt(), ODataEntryMockUtil.VALUE_MINT);
- assertEquals(jpaTypeMock.getMString(), ODataEntryMockUtil.VALUE_MSTRING);
- assertTrue(jpaTypeMock.getMDateTime().equals(ODataEntryMockUtil.VALUE_DATE_TIME));
- }
-
- @Test
- public void testCreateODataEntryWithInline() {
- try {
- EdmEntitySet edmEntitySet = EdmMockUtilV2.mockEdmEntitySet(JPATypeMock.ENTITY_NAME, false);
- EdmEntityType edmEntityType = edmEntitySet.getEntityType();
-
- jpaEntity = new JPAEntity(edmEntityType, edmEntitySet);
- jpaEntity.create(ODataEntryMockUtil.mockODataEntryWithInline(JPATypeMock.ENTITY_NAME));
- } catch (ODataJPARuntimeException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage()
- + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- } catch (EdmException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage()
- + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
- JPATypeMock jpaTypeMock = (JPATypeMock) jpaEntity.getJPAEntity();
- assertEquals(jpaTypeMock.getMInt(), ODataEntryMockUtil.VALUE_MINT);
- assertEquals(jpaTypeMock.getMString(), ODataEntryMockUtil.VALUE_MSTRING);
- assertTrue(jpaTypeMock.getMDateTime().equals(ODataEntryMockUtil.VALUE_DATE_TIME));
-
- JPARelatedTypeMock relatedType = jpaTypeMock.getMRelatedEntity();
- assertNotNull(jpaTypeMock.getMRelatedEntity());
- assertEquals(relatedType.getMByte(), ODataEntryMockUtil.VALUE_MBYTE);
- assertEquals(relatedType.getMByteArray(), ODataEntryMockUtil.VALUE_MBYTEARRAY);
- assertEquals(relatedType.getMDouble(), ODataEntryMockUtil.VALUE_MDOUBLE, 0.0);
- assertEquals(relatedType.getMLong(), ODataEntryMockUtil.VALUE_MLONG);
- }
-
- @Test
- public void testCreateODataEntryProperty() {
- try {
- EdmEntitySet edmEntitySet = EdmMockUtilV2.mockEdmEntitySet(JPATypeMock.ENTITY_NAME, false);
- EdmEntityType edmEntityType = edmEntitySet.getEntityType();
-
- jpaEntity = new JPAEntity(edmEntityType, edmEntitySet);
- jpaEntity.create(ODataEntryMockUtil.mockODataEntryProperties(JPATypeMock.ENTITY_NAME));
- } catch (ODataJPARuntimeException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage()
- + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- } catch (EdmException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage()
- + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
- JPATypeMock jpaTypeMock = (JPATypeMock) jpaEntity.getJPAEntity();
- assertEquals(jpaTypeMock.getMInt(), ODataEntryMockUtil.VALUE_MINT);
- assertEquals(jpaTypeMock.getMString(), ODataEntryMockUtil.VALUE_MSTRING);
- assertTrue(jpaTypeMock.getMDateTime().equals(ODataEntryMockUtil.VALUE_DATE_TIME));
- }
-
- @Test
- public void testUpdateODataEntry() {
- try {
- EdmEntitySet edmEntitySet = EdmMockUtilV2.mockEdmEntitySet(JPATypeMock.ENTITY_NAME, false);
- EdmEntityType edmEntityType = edmEntitySet.getEntityType();
-
- jpaEntity = new JPAEntity(edmEntityType, edmEntitySet);
- JPATypeMock jpaTypeMock = new JPATypeMock();
- jpaEntity.setJPAEntity(jpaTypeMock);
- jpaEntity.update(ODataEntryMockUtil.mockODataEntry(JPATypeMock.ENTITY_NAME));
- } catch (ODataJPARuntimeException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage()
- + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- } catch (EdmException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage()
- + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
- JPATypeMock jpaTypeMock = (JPATypeMock) jpaEntity.getJPAEntity();
- assertEquals(jpaTypeMock.getMInt(), 0);// Key should not be changed
- assertEquals(jpaTypeMock.getMString(), ODataEntryMockUtil.VALUE_MSTRING);
- assertTrue(jpaTypeMock.getMDateTime().equals(ODataEntryMockUtil.VALUE_DATE_TIME));
- }
-
- @Test
- public void testUpdateODataEntryProperty() {
- try {
- EdmEntitySet edmEntitySet = EdmMockUtilV2.mockEdmEntitySet(JPATypeMock.ENTITY_NAME, false);
- EdmEntityType edmEntityType = edmEntitySet.getEntityType();
-
- jpaEntity = new JPAEntity(edmEntityType, edmEntitySet);
- JPATypeMock jpaTypeMock = new JPATypeMock();
- jpaEntity.setJPAEntity(jpaTypeMock);
- jpaEntity.update(ODataEntryMockUtil.mockODataEntryProperties(JPATypeMock.ENTITY_NAME));
- } catch (ODataJPARuntimeException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage()
- + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- } catch (EdmException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage()
- + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
- JPATypeMock jpaTypeMock = (JPATypeMock) jpaEntity.getJPAEntity();
- assertEquals(jpaTypeMock.getMInt(), 0);// Key should not be changed
- assertEquals(jpaTypeMock.getMString(), ODataEntryMockUtil.VALUE_MSTRING);
- assertTrue(jpaTypeMock.getMDateTime().equals(ODataEntryMockUtil.VALUE_DATE_TIME));
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/access/data/JPAExpandCallBackTest.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/access/data/JPAExpandCallBackTest.java b/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/access/data/JPAExpandCallBackTest.java
deleted file mode 100644
index 021c353..0000000
--- a/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/access/data/JPAExpandCallBackTest.java
+++ /dev/null
@@ -1,160 +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.access.data;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
-
-import java.lang.reflect.Field;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.olingo.odata2.api.ODataCallback;
-import org.apache.olingo.odata2.api.edm.EdmEntityType;
-import org.apache.olingo.odata2.api.edm.EdmException;
-import org.apache.olingo.odata2.api.edm.EdmNavigationProperty;
-import org.apache.olingo.odata2.api.ep.callback.WriteEntryCallbackContext;
-import org.apache.olingo.odata2.api.ep.callback.WriteEntryCallbackResult;
-import org.apache.olingo.odata2.api.ep.callback.WriteFeedCallbackContext;
-import org.apache.olingo.odata2.api.ep.callback.WriteFeedCallbackResult;
-import org.apache.olingo.odata2.api.uri.ExpandSelectTreeNode;
-import org.apache.olingo.odata2.api.uri.NavigationPropertySegment;
-import org.apache.olingo.odata2.processor.core.jpa.common.ODataJPATestConstants;
-import org.apache.olingo.odata2.processor.core.jpa.mock.data.EdmMockUtil;
-import org.junit.Test;
-
-public class JPAExpandCallBackTest {
-
- @Test
- public void testRetrieveEntryResult() {
- JPAExpandCallBack callBack = getJPAExpandCallBackObject();
- WriteEntryCallbackContext writeFeedContext = EdmMockUtil.getWriteEntryCallBackContext();
- try {
- Field field = callBack.getClass().getDeclaredField("nextEntitySet");
- field.setAccessible(true);
- field.set(callBack, EdmMockUtil.mockTargetEntitySet());
- WriteEntryCallbackResult result = callBack.retrieveEntryResult(writeFeedContext);
- assertEquals(1, result.getEntryData().size());
- } catch (SecurityException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- } catch (NoSuchFieldException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- } catch (IllegalArgumentException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- } catch (IllegalAccessException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
- }
-
- @Test
- public void testRetrieveFeedResult() {
- JPAExpandCallBack callBack = getJPAExpandCallBackObject();
- WriteFeedCallbackContext writeFeedContext = EdmMockUtil.getWriteFeedCallBackContext();
- try {
- Field field = callBack.getClass().getDeclaredField("nextEntitySet");
- field.setAccessible(true);
- field.set(callBack, EdmMockUtil.mockTargetEntitySet());
- WriteFeedCallbackResult result = callBack.retrieveFeedResult(writeFeedContext);
- assertEquals(2, result.getFeedData().size());
- } catch (SecurityException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- } catch (NoSuchFieldException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- } catch (IllegalArgumentException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- } catch (IllegalAccessException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
- }
-
- @Test
- public void testGetCallbacks() {
- Map<String, ODataCallback> callBacks = null;
- try {
- URI baseUri =
- new URI("http://localhost:8080/org.apache.olingo.odata2.processor.ref.web/SalesOrderProcessing.svc/");
- ExpandSelectTreeNode expandSelectTreeNode = EdmMockUtil.mockExpandSelectTreeNode();
- List<ArrayList<NavigationPropertySegment>> expandList = EdmMockUtil.getExpandList();
- callBacks = JPAExpandCallBack.getCallbacks(baseUri, expandSelectTreeNode, expandList);
- } catch (URISyntaxException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- } catch (EdmException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
- assertEquals(1, callBacks.size());
-
- }
-
- @Test
- public void testGetNextNavigationProperty() {
- JPAExpandCallBack callBack = getJPAExpandCallBackObject();
- List<ArrayList<NavigationPropertySegment>> expandList = EdmMockUtil.getExpandList();
- ArrayList<NavigationPropertySegment> expands = expandList.get(0);
- expands.add(EdmMockUtil.mockThirdNavigationPropertySegment());
- EdmNavigationProperty result = null;
- try {
- Field field = callBack.getClass().getDeclaredField("expandList");
- field.setAccessible(true);
- field.set(callBack, expandList);
- Class<?>[] formalParams = { EdmEntityType.class, EdmNavigationProperty.class };
- Object[] actualParams = { EdmMockUtil.mockSourceEdmEntityType(), EdmMockUtil.mockNavigationProperty() };
- Method method = callBack.getClass().getDeclaredMethod("getNextNavigationProperty", formalParams);
- method.setAccessible(true);
- result = (EdmNavigationProperty) method.invoke(callBack, actualParams);
- assertEquals("MaterialDetails", result.getName());
-
- } catch (SecurityException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- } catch (NoSuchFieldException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- } catch (IllegalArgumentException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- } catch (IllegalAccessException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- } catch (NoSuchMethodException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- } catch (InvocationTargetException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- } catch (EdmException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
- }
-
- private JPAExpandCallBack getJPAExpandCallBackObject() {
- Map<String, ODataCallback> callBacks = null;
- try {
- URI baseUri =
- new URI("http://localhost:8080/org.apache.olingo.odata2.processor.ref.web/SalesOrderProcessing.svc/");
- ExpandSelectTreeNode expandSelectTreeNode = EdmMockUtil.mockExpandSelectTreeNode();
- List<ArrayList<NavigationPropertySegment>> expandList = EdmMockUtil.getExpandList();
- callBacks = JPAExpandCallBack.getCallbacks(baseUri, expandSelectTreeNode, expandList);
- } catch (URISyntaxException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- } catch (EdmException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
- return (JPAExpandCallBack) callBacks.get("SalesOrderLineItemDetails");
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/access/data/JPAFunctionContextTest.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/access/data/JPAFunctionContextTest.java b/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/access/data/JPAFunctionContextTest.java
deleted file mode 100644
index 1b2d7b6..0000000
--- a/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/access/data/JPAFunctionContextTest.java
+++ /dev/null
@@ -1,143 +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.access.data;
-
-import static org.junit.Assert.fail;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Map;
-
-import junit.framework.Assert;
-
-import org.apache.olingo.odata2.api.edm.EdmException;
-import org.apache.olingo.odata2.api.edm.EdmFunctionImport;
-import org.apache.olingo.odata2.api.edm.EdmLiteral;
-import org.apache.olingo.odata2.api.edm.EdmMapping;
-import org.apache.olingo.odata2.api.edm.EdmParameter;
-import org.apache.olingo.odata2.api.edm.provider.Mapping;
-import org.apache.olingo.odata2.api.uri.info.GetFunctionImportUriInfo;
-import org.apache.olingo.odata2.processor.api.jpa.access.JPAMethodContext;
-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.jpql.JPQLContextType;
-import org.apache.olingo.odata2.processor.core.jpa.common.ODataJPATestConstants;
-import org.apache.olingo.odata2.processor.core.jpa.model.JPAEdmMappingImpl;
-import org.easymock.EasyMock;
-import org.junit.Test;
-
-public class JPAFunctionContextTest {
-
- private int VARIANT = 0;
-
- public JPAFunctionContext build() {
- JPAFunctionContext functionContext = null;
- try {
- if (VARIANT == 0) {
- functionContext =
- (JPAFunctionContext) JPAMethodContext.createBuilder(JPQLContextType.FUNCTION, getView()).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);
- }
-
- return functionContext;
- }
-
- @Test
- public void testGetEnclosingObject() {
-
- VARIANT = 0;
-
- Assert.assertNotNull(build());
-
- }
-
- private GetFunctionImportUriInfo getView() {
- GetFunctionImportUriInfo functiontView = EasyMock.createMock(GetFunctionImportUriInfo.class);
- EasyMock.expect(functiontView.getFunctionImport()).andStubReturn(getEdmFunctionImport());
- EasyMock.expect(functiontView.getFunctionImportParameters()).andStubReturn(getFunctionImportParameters());
-
- EasyMock.replay(functiontView);
- return functiontView;
- }
-
- private Map<String, EdmLiteral> getFunctionImportParameters() {
- return null;
- }
-
- private EdmFunctionImport getEdmFunctionImport() {
- EdmFunctionImport edmFunctionImport = EasyMock.createMock(EdmFunctionImport.class);
- try {
- EasyMock.expect(edmFunctionImport.getMapping()).andStubReturn(getMapping());
- EasyMock.expect(edmFunctionImport.getParameterNames()).andStubReturn(getParameterNames());
- EasyMock.expect(edmFunctionImport.getParameter("Gentleman")).andStubReturn(getParameter("Gentleman"));
- } catch (EdmException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
-
- EasyMock.replay(edmFunctionImport);
- return edmFunctionImport;
- }
-
- private EdmParameter getParameter(final String string) {
- EdmParameter edmParameter = EasyMock.createMock(EdmParameter.class);
- try {
- EasyMock.expect(edmParameter.getMapping()).andStubReturn(getEdmMapping());
- } catch (EdmException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
- EasyMock.replay(edmParameter);
- return edmParameter;
- }
-
- private EdmMapping getEdmMapping() {
- JPAEdmMappingImpl mapping = new JPAEdmMappingImpl();
- mapping.setJPAType(String.class);
- ((Mapping) mapping).setInternalName("Gentleman");
- return mapping;
- }
-
- private JPAEdmMappingImpl getMapping() {
- JPAEdmMappingImpl mapping = new JPAEdmMappingImpl();
- mapping.setJPAType(FunctionImportTestClass.class);
- ((Mapping) mapping).setInternalName("testMethod");
- return mapping;
- }
-
- private Collection<String> getParameterNames() {
- Collection<String> parametersList = new ArrayList<String>();
- parametersList.add("Gentleman");
- return parametersList;
- }
-
- public static class FunctionImportTestClass {
-
- public FunctionImportTestClass() {
-
- }
-
- public String testMethod(final String message) {
- return "Hello " + message + "!!";
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/access/data/JPAProcessorImplTest.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/access/data/JPAProcessorImplTest.java b/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/access/data/JPAProcessorImplTest.java
deleted file mode 100644
index 45f0528..0000000
--- a/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/access/data/JPAProcessorImplTest.java
+++ /dev/null
@@ -1,447 +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.access.data;
-
-import static org.junit.Assert.fail;
-
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.persistence.EntityManager;
-import javax.persistence.EntityManagerFactory;
-import javax.persistence.EntityTransaction;
-import javax.persistence.Query;
-import javax.persistence.metamodel.Metamodel;
-
-import junit.framework.Assert;
-
-import org.apache.olingo.odata2.api.commons.InlineCount;
-import org.apache.olingo.odata2.api.edm.EdmConcurrencyMode;
-import org.apache.olingo.odata2.api.edm.EdmEntityContainer;
-import org.apache.olingo.odata2.api.edm.EdmEntitySet;
-import org.apache.olingo.odata2.api.edm.EdmEntityType;
-import org.apache.olingo.odata2.api.edm.EdmException;
-import org.apache.olingo.odata2.api.edm.EdmFacets;
-import org.apache.olingo.odata2.api.edm.EdmMapping;
-import org.apache.olingo.odata2.api.edm.EdmProperty;
-import org.apache.olingo.odata2.api.edm.EdmType;
-import org.apache.olingo.odata2.api.edm.EdmTypeKind;
-import org.apache.olingo.odata2.api.edm.EdmTyped;
-import org.apache.olingo.odata2.api.exception.ODataException;
-import org.apache.olingo.odata2.api.processor.ODataContext;
-import org.apache.olingo.odata2.api.uri.KeyPredicate;
-import org.apache.olingo.odata2.api.uri.PathInfo;
-import org.apache.olingo.odata2.api.uri.UriInfo;
-import org.apache.olingo.odata2.api.uri.expression.FilterExpression;
-import org.apache.olingo.odata2.api.uri.expression.OrderByExpression;
-import org.apache.olingo.odata2.api.uri.info.DeleteUriInfo;
-import org.apache.olingo.odata2.api.uri.info.GetEntityCountUriInfo;
-import org.apache.olingo.odata2.api.uri.info.GetEntitySetCountUriInfo;
-import org.apache.olingo.odata2.api.uri.info.GetEntitySetUriInfo;
-import org.apache.olingo.odata2.processor.api.jpa.ODataJPAContext;
-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.core.jpa.common.ODataJPATestConstants;
-import org.easymock.EasyMock;
-import org.junit.Before;
-import org.junit.Test;
-
-public class JPAProcessorImplTest {
-
- // -------------------------------- Common Start ------------------------------------common in
- // ODataJPAProcessorDefaultTest as well
- private static final String STR_LOCAL_URI = "http://localhost:8080/org.apache.olingo.odata2.processor.ref.web/";
- private static final String SALESORDERPROCESSING_CONTAINER = "salesorderprocessingContainer";
- private static final String SO_ID = "SoId";
- private static final String SALES_ORDER = "SalesOrder";
- private static final String SALES_ORDER_HEADERS = "SalesOrderHeaders";
- // -------------------------------- Common End ------------------------------------
-
- JPAProcessorImpl objJPAProcessorImpl;
-
- @Before
- public void setUp() throws Exception {
- objJPAProcessorImpl = new JPAProcessorImpl(getLocalmockODataJPAContext());
- }
-
- @Test
- public void testProcessGetEntitySetCountUriInfo() {
- try {
- Assert.assertEquals(11, objJPAProcessorImpl.process(getEntitySetCountUriInfo()));
- } 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);
- }
- }
-
- @Test
- public void testProcessGetEntityCountUriInfo() {
- try {
- Assert.assertEquals(11, objJPAProcessorImpl.process(getEntityCountUriInfo()));
- } 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);
- }
- }
-
- @Test
- public void testProcessGetEntitySetUriInfo() {
- try {
- Assert.assertNotNull(objJPAProcessorImpl.process(getEntitySetUriInfo()));
- } 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);
- }
- }
-
- @Test
- public void testProcessDeleteUriInfo() {
- try {
- Assert.assertNotNull(objJPAProcessorImpl.process(getDeletetUriInfo(), "application/xml"));
- Assert.assertEquals(new Address(), objJPAProcessorImpl.process(getDeletetUriInfo(), "application/xml"));
- } 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);
- }
- }
-
- @Test
- public void testProcessDeleteUriInfoNegative() {
- try {
- Assert.assertNotNull(objJPAProcessorImpl.process(getDeletetUriInfo(), "application/xml"));
- Assert.assertNotSame(new Object(), objJPAProcessorImpl.process(getDeletetUriInfo(), "application/xml"));
- } 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);
- }
- }
-
- // ---------------------------- Common Code Start ---------------- TODO - common in ODataJPAProcessorDefaultTest as
- // well
-
- private DeleteUriInfo getDeletetUriInfo() {
- UriInfo objUriInfo = EasyMock.createMock(UriInfo.class);
- EasyMock.expect(objUriInfo.getStartEntitySet()).andStubReturn(getLocalEdmEntitySet());
- EasyMock.expect(objUriInfo.getTargetEntitySet()).andStubReturn(getLocalEdmEntitySet());
- EasyMock.expect(objUriInfo.getSelect()).andStubReturn(null);
- EasyMock.expect(objUriInfo.getOrderBy()).andStubReturn(getOrderByExpression());
- EasyMock.expect(objUriInfo.getTop()).andStubReturn(getTop());
- EasyMock.expect(objUriInfo.getSkip()).andStubReturn(getSkip());
- EasyMock.expect(objUriInfo.getInlineCount()).andStubReturn(getInlineCount());
- EasyMock.expect(objUriInfo.getFilter()).andStubReturn(getFilter());
- EasyMock.expect(objUriInfo.getKeyPredicates()).andStubReturn(getKeyPredicates());
- EasyMock.replay(objUriInfo);
- return objUriInfo;
- }
-
- private List<KeyPredicate> getKeyPredicates() {
- List<KeyPredicate> keyPredicates = new ArrayList<KeyPredicate>();
- return keyPredicates;
- }
-
- private GetEntitySetCountUriInfo getEntitySetCountUriInfo() {
- return getLocalUriInfo();
- }
-
- private GetEntityCountUriInfo getEntityCountUriInfo() {
- return getLocalUriInfo();
- }
-
- private GetEntitySetUriInfo getEntitySetUriInfo() {
-
- UriInfo objUriInfo = EasyMock.createMock(UriInfo.class);
- EasyMock.expect(objUriInfo.getStartEntitySet()).andStubReturn(getLocalEdmEntitySet());
- EasyMock.expect(objUriInfo.getTargetEntitySet()).andStubReturn(getLocalEdmEntitySet());
- EasyMock.expect(objUriInfo.getSelect()).andStubReturn(null);
- EasyMock.expect(objUriInfo.getOrderBy()).andStubReturn(getOrderByExpression());
- EasyMock.expect(objUriInfo.getTop()).andStubReturn(getTop());
- EasyMock.expect(objUriInfo.getSkip()).andStubReturn(getSkip());
- EasyMock.expect(objUriInfo.getInlineCount()).andStubReturn(getInlineCount());
- EasyMock.expect(objUriInfo.getFilter()).andStubReturn(getFilter());
- // EasyMock.expect(objUriInfo.getFunctionImport()).andStubReturn(getFunctionImport());
- EasyMock.expect(objUriInfo.getFunctionImport()).andStubReturn(null);
- EasyMock.replay(objUriInfo);
- return objUriInfo;
- }
-
- /**
- * @return
- */
- private UriInfo getLocalUriInfo() {
- UriInfo objUriInfo = EasyMock.createMock(UriInfo.class);
- EasyMock.expect(objUriInfo.getStartEntitySet()).andStubReturn(getLocalEdmEntitySet());
- EasyMock.expect(objUriInfo.getTargetEntitySet()).andStubReturn(getLocalEdmEntitySet());
- EasyMock.expect(objUriInfo.getSelect()).andStubReturn(null);
- EasyMock.expect(objUriInfo.getOrderBy()).andStubReturn(getOrderByExpression());
- EasyMock.expect(objUriInfo.getTop()).andStubReturn(getTop());
- EasyMock.expect(objUriInfo.getSkip()).andStubReturn(getSkip());
- EasyMock.expect(objUriInfo.getInlineCount()).andStubReturn(getInlineCount());
- EasyMock.expect(objUriInfo.getFilter()).andStubReturn(getFilter());
- EasyMock.replay(objUriInfo);
- return objUriInfo;
- }
-
- /**
- * @return
- * @throws EdmException
- */
- private EdmEntitySet getLocalEdmEntitySet() {
- EdmEntitySet edmEntitySet = EasyMock.createMock(EdmEntitySet.class);
- try {
- EasyMock.expect(edmEntitySet.getName()).andStubReturn(SALES_ORDER_HEADERS);
- EasyMock.expect(edmEntitySet.getEntityContainer()).andStubReturn(getLocalEdmEntityContainer());
- EasyMock.expect(edmEntitySet.getEntityType()).andStubReturn(getLocalEdmEntityType());
- EasyMock.replay(edmEntitySet);
- } catch (EdmException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
- return edmEntitySet;
- }
-
- /**
- * @return
- * @throws EdmException
- */
- private EdmEntityType getLocalEdmEntityType() {
- EdmEntityType edmEntityType = EasyMock.createMock(EdmEntityType.class);
- try {
- EasyMock.expect(edmEntityType.getKeyProperties()).andStubReturn(new ArrayList<EdmProperty>());
- EasyMock.expect(edmEntityType.getPropertyNames()).andStubReturn(getLocalPropertyNames());
- EasyMock.expect(edmEntityType.getProperty(SO_ID)).andStubReturn(getEdmTypedMockedObj(SALES_ORDER));
- EasyMock.expect(edmEntityType.getKind()).andStubReturn(EdmTypeKind.SIMPLE);
- EasyMock.expect(edmEntityType.getNamespace()).andStubReturn(SALES_ORDER_HEADERS);
- EasyMock.expect(edmEntityType.getName()).andStubReturn(SALES_ORDER_HEADERS);
- EasyMock.expect(edmEntityType.hasStream()).andStubReturn(false);
- EasyMock.expect(edmEntityType.getNavigationPropertyNames()).andStubReturn(new ArrayList<String>());
- EasyMock.expect(edmEntityType.getKeyPropertyNames()).andStubReturn(new ArrayList<String>());
- EasyMock.expect(edmEntityType.getMapping()).andStubReturn(getEdmMappingMockedObj(SALES_ORDER));// ID vs Salesorder
- // ID
- EasyMock.replay(edmEntityType);
- } catch (EdmException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
- return edmEntityType;
- }
-
- private InlineCount getInlineCount() {
- return InlineCount.NONE;
- }
-
- private FilterExpression getFilter() {
- return null;
- }
-
- private Integer getSkip() {
- return null;
- }
-
- private Integer getTop() {
- return null;
- }
-
- private OrderByExpression getOrderByExpression() {
- return null;
- }
-
- private ODataJPAContext getLocalmockODataJPAContext() {
- ODataJPAContext odataJPAContext = EasyMock.createMock(ODataJPAContext.class);
- EasyMock.expect(odataJPAContext.getPersistenceUnitName()).andStubReturn("salesorderprocessing");
- EasyMock.expect(odataJPAContext.getEntityManagerFactory()).andStubReturn(mockEntityManagerFactory());
- EasyMock.expect(odataJPAContext.getODataContext()).andStubReturn(getLocalODataContext());
- EasyMock.expect(odataJPAContext.getEntityManager()).andStubReturn(getLocalEntityManager());
- EasyMock.replay(odataJPAContext);
- return odataJPAContext;
- }
-
- private EntityManagerFactory mockEntityManagerFactory() {
- EntityManagerFactory emf = EasyMock.createMock(EntityManagerFactory.class);
- EasyMock.expect(emf.getMetamodel()).andStubReturn(mockMetaModel());
- EasyMock.expect(emf.createEntityManager()).andStubReturn(getLocalEntityManager());
- EasyMock.replay(emf);
- return emf;
- }
-
- public EntityManager getLocalEntityManager() {
- EntityManager em = EasyMock.createMock(EntityManager.class);
- EasyMock.expect(em.createQuery("SELECT E1 FROM SalesOrderHeaders E1")).andStubReturn(getQuery());
- EasyMock.expect(em.createQuery("SELECT COUNT ( E1 ) FROM SalesOrderHeaders E1")).andStubReturn(
- getQueryForSelectCount());
- EasyMock.expect(em.getTransaction()).andStubReturn(getLocalTransaction()); // For Delete
- em.flush();
- em.flush();
- Address obj = new Address();
- em.remove(obj);// testing void method
- em.remove(obj);// testing void method
- EasyMock.replay(em);
- return em;
- }
-
- private EntityTransaction getLocalTransaction() {
- EntityTransaction entityTransaction = EasyMock.createMock(EntityTransaction.class);
- entityTransaction.begin(); // testing void method
- entityTransaction.begin(); // testing void method
- entityTransaction.commit();// testing void method
- entityTransaction.commit();// testing void method
- EasyMock.replay(entityTransaction);
- return entityTransaction;
- }
-
- private Query getQuery() {
- Query query = EasyMock.createMock(Query.class);
- EasyMock.expect(query.getResultList()).andStubReturn(getResultList());
- EasyMock.replay(query);
- return query;
- }
-
- private Query getQueryForSelectCount() {
- Query query = EasyMock.createMock(Query.class);
- EasyMock.expect(query.getResultList()).andStubReturn(getResultListForSelectCount());
- EasyMock.replay(query);
- return query;
- }
-
- private List<?> getResultList() {
- List<Object> list = new ArrayList<Object>();
- list.add(new Address());
- return list;
- }
-
- private List<?> getResultListForSelectCount() {
- List<Object> list = new ArrayList<Object>();
- list.add(new Long(11));
- return list;
- }
-
- private class Address {
- private String soId = "12";
-
- public String getSoId() {
- return soId;
- }
-
- @Override
- public boolean equals(final Object obj) {
- boolean isEqual = false;
- if (obj instanceof Address) {
- isEqual = getSoId().equalsIgnoreCase(((Address) obj).getSoId());//
- }
- return isEqual;
- }
- }
-
- private Metamodel mockMetaModel() {
- Metamodel metaModel = EasyMock.createMock(Metamodel.class);
- EasyMock.replay(metaModel);
- return metaModel;
- }
-
- private EdmEntityContainer getLocalEdmEntityContainer() {
- EdmEntityContainer edmEntityContainer = EasyMock.createMock(EdmEntityContainer.class);
- EasyMock.expect(edmEntityContainer.isDefaultEntityContainer()).andStubReturn(true);
- try {
- EasyMock.expect(edmEntityContainer.getName()).andStubReturn(SALESORDERPROCESSING_CONTAINER);
- } catch (EdmException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
-
- EasyMock.replay(edmEntityContainer);
- return edmEntityContainer;
- }
-
- private EdmTyped getEdmTypedMockedObj(final String propertyName) {
- EdmProperty mockedEdmProperty = EasyMock.createMock(EdmProperty.class);
- try {
- EasyMock.expect(mockedEdmProperty.getMapping()).andStubReturn(getEdmMappingMockedObj(propertyName));
- EdmType edmType = EasyMock.createMock(EdmType.class);
- EasyMock.expect(edmType.getKind()).andStubReturn(EdmTypeKind.SIMPLE);
- EasyMock.replay(edmType);
- EasyMock.expect(mockedEdmProperty.getName()).andStubReturn("identifier");
- EasyMock.expect(mockedEdmProperty.getType()).andStubReturn(edmType);
- EasyMock.expect(mockedEdmProperty.getFacets()).andStubReturn(getEdmFacetsMockedObj());
-
- EasyMock.replay(mockedEdmProperty);
- } catch (EdmException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
- return mockedEdmProperty;
- }
-
- private EdmFacets getEdmFacetsMockedObj() {
- EdmFacets facets = EasyMock.createMock(EdmFacets.class);
- EasyMock.expect(facets.getConcurrencyMode()).andStubReturn(EdmConcurrencyMode.Fixed);
-
- EasyMock.replay(facets);
- return facets;
- }
-
- private EdmMapping getEdmMappingMockedObj(final String propertyName) {
- EdmMapping mockedEdmMapping = EasyMock.createMock(EdmMapping.class);
- if (propertyName.equalsIgnoreCase(SALES_ORDER)) {
- EasyMock.expect(mockedEdmMapping.getInternalName()).andStubReturn(SALES_ORDER_HEADERS);
- } else {
- EasyMock.expect(mockedEdmMapping.getInternalName()).andStubReturn(propertyName);
- }
- EasyMock.replay(mockedEdmMapping);
- return mockedEdmMapping;
- }
-
- private List<String> getLocalPropertyNames() {
- List<String> list = new ArrayList<String>();
- list.add(SO_ID);
- return list;
- }
-
- private ODataContext getLocalODataContext() {
- ODataContext objODataContext = EasyMock.createMock(ODataContext.class);
- try {
- EasyMock.expect(objODataContext.getPathInfo()).andStubReturn(getLocalPathInfo());
- } catch (ODataException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
- EasyMock.replay(objODataContext);
- return objODataContext;
- }
-
- private PathInfo getLocalPathInfo() {
- PathInfo pathInfo = EasyMock.createMock(PathInfo.class);
- EasyMock.expect(pathInfo.getServiceRoot()).andStubReturn(getLocalURI());
- EasyMock.replay(pathInfo);
- return pathInfo;
- }
-
- private URI getLocalURI() {
- URI uri = null;
- try {
- uri = new URI(STR_LOCAL_URI);
- } catch (URISyntaxException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
- return uri;
- }
-
- // -------------------------------- Common End ------------------------------------
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/access/model/JPAEdmMappingModelServiceTest.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/access/model/JPAEdmMappingModelServiceTest.java b/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/access/model/JPAEdmMappingModelServiceTest.java
deleted file mode 100644
index 76ea726..0000000
--- a/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/access/model/JPAEdmMappingModelServiceTest.java
+++ /dev/null
@@ -1,213 +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.access.model;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-
-import java.io.InputStream;
-
-import org.apache.olingo.odata2.processor.core.jpa.mock.ODataJPAContextMock;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-public class JPAEdmMappingModelServiceTest extends JPAEdmMappingModelService {
-
- private static JPAEdmMappingModelServiceTest objJPAEdmMappingModelServiceTest;
-
- private static final String MAPPING_FILE_CORRECT = "SalesOrderProcessingMappingModels.xml";
- private static final String MAPPING_FILE_INCORRECT = "TEST.xml";
-
- private static int VARIANT_MAPPING_FILE; // 0 FOR INCORRECT, 1 FOR CORRECT
-
- private static String PERSISTENCE_UNIT_NAME_JPA = "salesorderprocessing";
- private static String PERSISTENCE_UNIT_NAME_EDM = "SalesOrderProcessing";
-
- private static String ENTITY_TYPE_NAME_JPA = "SalesOrderHeader";
- private static String ENTITY_TYPE_NAME_EDM = "SalesOrder";
- private static String ENTITY_SET_NAME_EDM = "SalesOrders";
- private static String RELATIONSHIP_NAME_JPA = "salesOrderItems";
- private static String RELATIONSHIP_NAME_EDM = "SalesOrderItemDetails";
- private static String ATTRIBUTE_NAME_JPA = "netAmount";
- private static String ATTRIBUTE_NAME_EDM = "NetAmount";
- private static String EMBEDDABLE_TYPE_NAME_JPA = "SalesOrderItemKey";
- private static String EMBEDDABLE_ATTRIBUTE_NAME_JPA = "liId";
- private static String EMBEDDABLE_ATTRIBUTE_NAME_EDM = "ID";
- private static String EMBEDDABLE_TYPE_2_NAME_JPA = "SalesOrderItemKey";
-
- private static String ENTITY_TYPE_NAME_JPA_WRONG = "SalesOrderHeaders";
- private static String RELATIONSHIP_NAME_JPA_WRONG = "value";
- private static String EMBEDDABLE_TYPE_NAME_JPA_WRONG = "SalesOrderItemKeys";
-
- public JPAEdmMappingModelServiceTest() {
- super(ODataJPAContextMock.mockODataJPAContext());
- }
-
- @BeforeClass
- public static void setup() {
- objJPAEdmMappingModelServiceTest = new JPAEdmMappingModelServiceTest();
- VARIANT_MAPPING_FILE = 1;
- objJPAEdmMappingModelServiceTest.loadMappingModel();
- }
-
- @Test
- public void testLoadMappingModel() {
- VARIANT_MAPPING_FILE = 1;
- loadMappingModel();
- assertTrue(isMappingModelExists());
- }
-
- @Test
- public void testLoadMappingModelNegative() {
- VARIANT_MAPPING_FILE = 0;
- loadMappingModel();
- assertFalse(isMappingModelExists());
- // reset it for other JUnits
- VARIANT_MAPPING_FILE = 1;
- loadMappingModel();
- }
-
- @Test
- public void testIsMappingModelExists() {
- assertTrue(objJPAEdmMappingModelServiceTest.isMappingModelExists());
- }
-
- @Test
- public void testGetJPAEdmMappingModel() {
- assertNotNull(objJPAEdmMappingModelServiceTest.getJPAEdmMappingModel());
- }
-
- @Test
- public void testMapJPAPersistenceUnit() {
- assertEquals(PERSISTENCE_UNIT_NAME_EDM, objJPAEdmMappingModelServiceTest
- .mapJPAPersistenceUnit(PERSISTENCE_UNIT_NAME_JPA));
- }
-
- @Test
- public void testMapJPAPersistenceUnitNegative() {
- assertNull(objJPAEdmMappingModelServiceTest.mapJPAPersistenceUnit(PERSISTENCE_UNIT_NAME_EDM));// Wrong value to
- // bring null
- }
-
- @Test
- public void testMapJPAEntityType() {
- assertEquals(ENTITY_TYPE_NAME_EDM, objJPAEdmMappingModelServiceTest.mapJPAEntityType(ENTITY_TYPE_NAME_JPA));
- }
-
- @Test
- public void testMapJPAEntityTypeNegative() {
- assertNull(objJPAEdmMappingModelServiceTest.mapJPAEntityType(ENTITY_TYPE_NAME_JPA_WRONG));// Wrong value to bring
- // null
- }
-
- @Test
- public void testMapJPAEntitySet() {
- assertEquals(ENTITY_SET_NAME_EDM, objJPAEdmMappingModelServiceTest.mapJPAEntitySet(ENTITY_TYPE_NAME_JPA));
- }
-
- @Test
- public void testMapJPAEntitySetNegative() {
- assertNull(objJPAEdmMappingModelServiceTest.mapJPAEntitySet(ENTITY_TYPE_NAME_JPA_WRONG));// Wrong value to bring
- // null
- }
-
- @Test
- public void testMapJPAAttribute() {
- assertEquals(ATTRIBUTE_NAME_EDM, objJPAEdmMappingModelServiceTest.mapJPAAttribute(ENTITY_TYPE_NAME_JPA,
- ATTRIBUTE_NAME_JPA));
- }
-
- @Test
- public void testMapJPAAttributeNegative() {
- // Wrong value to bring null
- assertNull(objJPAEdmMappingModelServiceTest.mapJPAAttribute(ENTITY_TYPE_NAME_JPA, ATTRIBUTE_NAME_JPA + "AA"));
- }
-
- @Test
- public void testMapJPARelationship() {
- assertEquals(RELATIONSHIP_NAME_EDM, objJPAEdmMappingModelServiceTest.mapJPARelationship(ENTITY_TYPE_NAME_JPA,
- RELATIONSHIP_NAME_JPA));
- }
-
- @Test
- public void testMapJPARelationshipNegative() {
- // Wrong value to bring null
- assertNull(objJPAEdmMappingModelServiceTest.mapJPARelationship(ENTITY_TYPE_NAME_JPA, RELATIONSHIP_NAME_JPA_WRONG));
- }
-
- @Test
- public void testMapJPAEmbeddableType() {
- assertEquals("SalesOrderLineItemKey", objJPAEdmMappingModelServiceTest.mapJPAEmbeddableType("SalesOrderItemKey"));
- }
-
- @Test
- public void testMapJPAEmbeddableTypeNegative() {
- assertNull(objJPAEdmMappingModelServiceTest.mapJPAEmbeddableType(EMBEDDABLE_TYPE_NAME_JPA_WRONG));// Wrong value to
- // bring null
- }
-
- @Test
- public void testMapJPAEmbeddableTypeAttribute() {
- assertEquals(EMBEDDABLE_ATTRIBUTE_NAME_EDM, objJPAEdmMappingModelServiceTest.mapJPAEmbeddableTypeAttribute(
- EMBEDDABLE_TYPE_NAME_JPA, EMBEDDABLE_ATTRIBUTE_NAME_JPA));
- }
-
- @Test
- public void testMapJPAEmbeddableTypeAttributeNegative() {
- assertNull(objJPAEdmMappingModelServiceTest.mapJPAEmbeddableTypeAttribute(EMBEDDABLE_TYPE_NAME_JPA_WRONG,
- EMBEDDABLE_ATTRIBUTE_NAME_JPA));
- }
-
- @Test
- public void testCheckExclusionOfJPAEntityType() {
- assertTrue(!objJPAEdmMappingModelServiceTest.checkExclusionOfJPAEntityType(ENTITY_TYPE_NAME_JPA));
- }
-
- @Test
- public void testCheckExclusionOfJPAAttributeType() {
- assertTrue(!objJPAEdmMappingModelServiceTest.checkExclusionOfJPAAttributeType(ENTITY_TYPE_NAME_JPA,
- ATTRIBUTE_NAME_JPA));
- }
-
- @Test
- public void testCheckExclusionOfJPAEmbeddableType() {
- assertTrue(!objJPAEdmMappingModelServiceTest.checkExclusionOfJPAEmbeddableType(EMBEDDABLE_TYPE_2_NAME_JPA));
- }
-
- @Test
- public void testCheckExclusionOfJPAEmbeddableAttributeType() {
- assertTrue(!objJPAEdmMappingModelServiceTest.checkExclusionOfJPAEmbeddableAttributeType(EMBEDDABLE_TYPE_NAME_JPA,
- EMBEDDABLE_ATTRIBUTE_NAME_JPA));
- }
-
- /**
- * This method is for loading the xml file for testing.
- */
- @Override
- protected InputStream loadMappingModelInputStream() {
- if (VARIANT_MAPPING_FILE == 1) {
- return ClassLoader.getSystemResourceAsStream(MAPPING_FILE_CORRECT);
- } else {
- return ClassLoader.getSystemResourceAsStream(MAPPING_FILE_INCORRECT);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/access/model/JPAEdmNameBuilderTest.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/access/model/JPAEdmNameBuilderTest.java b/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/access/model/JPAEdmNameBuilderTest.java
deleted file mode 100644
index 3808909..0000000
--- a/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/access/model/JPAEdmNameBuilderTest.java
+++ /dev/null
@@ -1,151 +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.access.model;
-
-import static org.junit.Assert.assertEquals;
-
-import org.apache.olingo.odata2.api.edm.provider.ComplexProperty;
-import org.apache.olingo.odata2.api.edm.provider.SimpleProperty;
-import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmComplexPropertyView;
-import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmEntityTypeView;
-import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmPropertyView;
-import org.apache.olingo.odata2.processor.core.jpa.ODataJPAContextImpl;
-import org.apache.olingo.odata2.processor.core.jpa.mock.model.JPAAttributeMock;
-import org.apache.olingo.odata2.processor.core.jpa.mock.model.JPAEntityTypeMock;
-import org.easymock.EasyMock;
-import org.junit.Test;
-
-public class JPAEdmNameBuilderTest {
-
- @SuppressWarnings({ "unchecked", "rawtypes" })
- @Test
- public void testBuildJPAEdmPropertyView() {
-
- SimpleProperty simpleProperty = new SimpleProperty();
-
- // Mocking EDMProperty
- JPAEdmPropertyView propertyView = EasyMock.createMock(JPAEdmPropertyView.class);
- JPAEdmEntityTypeView entityTypeView = EasyMock.createMock(JPAEdmEntityTypeView.class);
-
- EasyMock.expect(propertyView.getJPAAttribute()).andStubReturn(new JPAAttribute());
- EasyMock.expect(propertyView.getJPAEdmEntityTypeView()).andStubReturn(entityTypeView);
- EasyMock.expect(propertyView.getJPAEdmMappingModelAccess()).andStubReturn(null);
- EasyMock.expect(propertyView.getEdmSimpleProperty()).andStubReturn(simpleProperty);
- EasyMock.replay(propertyView);
-
- JPAEdmNameBuilder.build(propertyView, false, false);
- assertEquals("Id", simpleProperty.getName());
- }
-
- @SuppressWarnings({ "unchecked", "rawtypes" })
- @Test
- public void testBuildJPAEdmPropertyViewWithNoDefaultNaming() {
-
- SimpleProperty simpleProperty = new SimpleProperty();
-
- // Mocking EDMProperty
- JPAEdmPropertyView propertyView = EasyMock.createMock(JPAEdmPropertyView.class);
- JPAEdmEntityTypeView entityTypeView = EasyMock.createMock(JPAEdmEntityTypeView.class);
-
- EasyMock.expect(propertyView.getJPAAttribute()).andStubReturn(new JPAAttribute());
- EasyMock.expect(propertyView.getJPAEdmEntityTypeView()).andStubReturn(entityTypeView);
- EasyMock.expect(propertyView.getJPAEdmMappingModelAccess()).andStubReturn(null);
- EasyMock.expect(propertyView.getEdmSimpleProperty()).andStubReturn(simpleProperty);
- EasyMock.replay(propertyView);
-
- JPAEdmNameBuilder.build(propertyView, false, true);
- assertEquals("id", simpleProperty.getName());
- }
-
- @SuppressWarnings({ "rawtypes", "unchecked" })
- @Test
- public void testBuildJPAEdmComplexPropertyView() {
- JPAEdmComplexPropertyView complexPropertyView = EasyMock.createMock(JPAEdmComplexPropertyView.class);
- ComplexProperty complexProperty = new ComplexProperty();
- EasyMock.expect(complexPropertyView.getEdmComplexProperty()).andStubReturn(complexProperty);
- ODataJPAContextImpl oDataJPAContext = new ODataJPAContextImpl();
- JPAEdmMappingModelService mappingModelService = new JPAEdmMappingModelService(oDataJPAContext);
- EasyMock.expect(complexPropertyView.getJPAEdmMappingModelAccess()).andStubReturn(mappingModelService);
-
- // Mocking EDMProperty
- JPAEdmPropertyView propertyView = EasyMock.createMock(JPAEdmPropertyView.class);
- JPAEdmEntityTypeView entityTypeView = EasyMock.createMock(JPAEdmEntityTypeView.class);
- EasyMock.expect(entityTypeView.getJPAEntityType()).andStubReturn(new JPAEntityType());
- EasyMock.replay(entityTypeView);
- EasyMock.expect(propertyView.getJPAAttribute()).andStubReturn(new JPAAttribute());
- EasyMock.expect(propertyView.getJPAEdmEntityTypeView()).andStubReturn(entityTypeView);
- EasyMock.replay(complexPropertyView);
- EasyMock.replay(propertyView);
-
- JPAEdmNameBuilder.build(complexPropertyView, propertyView, false);
- assertEquals("Id", complexPropertyView.getEdmComplexProperty().getName());
-
- }
-
- @SuppressWarnings({ "rawtypes", "unchecked" })
- @Test
- public void testBuildJPAEdmComplexPropertyViewWithNoDefaultNaming() {
- JPAEdmComplexPropertyView complexPropertyView = EasyMock.createMock(JPAEdmComplexPropertyView.class);
- ComplexProperty complexProperty = new ComplexProperty();
- EasyMock.expect(complexPropertyView.getEdmComplexProperty()).andStubReturn(complexProperty);
- ODataJPAContextImpl oDataJPAContext = new ODataJPAContextImpl();
- JPAEdmMappingModelService mappingModelService = new JPAEdmMappingModelService(oDataJPAContext);
- EasyMock.expect(complexPropertyView.getJPAEdmMappingModelAccess()).andStubReturn(mappingModelService);
-
- // Mocking EDMProperty
- JPAEdmPropertyView propertyView = EasyMock.createMock(JPAEdmPropertyView.class);
- JPAEdmEntityTypeView entityTypeView = EasyMock.createMock(JPAEdmEntityTypeView.class);
- EasyMock.expect(entityTypeView.getJPAEntityType()).andStubReturn(new JPAEntityType());
- EasyMock.replay(entityTypeView);
- EasyMock.expect(propertyView.getJPAAttribute()).andStubReturn(new JPAAttribute());
- EasyMock.expect(propertyView.getJPAEdmEntityTypeView()).andStubReturn(entityTypeView);
- EasyMock.replay(complexPropertyView);
- EasyMock.replay(propertyView);
-
- JPAEdmNameBuilder.build(complexPropertyView, propertyView, true);
- assertEquals("id", complexPropertyView.getEdmComplexProperty().getName());
-
- }
-
- @SuppressWarnings("hiding")
- class JPAAttribute<Object, String> extends JPAAttributeMock<Object, java.lang.String> {
-
- @Override
- public java.lang.String getName() {
- return "id";
- }
-
- @Override
- public Class<java.lang.String> getJavaType() {
- return java.lang.String.class;
- }
-
- }
-
- @SuppressWarnings("hiding")
- class JPAEntityType<Object> extends JPAEntityTypeMock<Object> {
-
- @Override
- public java.lang.String getName() {
- return "SalesOrderHeader";
- }
-
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/access/model/JPATypeConvertorTest.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/access/model/JPATypeConvertorTest.java b/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/access/model/JPATypeConvertorTest.java
deleted file mode 100644
index 3a4057f..0000000
--- a/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/access/model/JPATypeConvertorTest.java
+++ /dev/null
@@ -1,94 +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.access.model;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
-
-import java.math.BigDecimal;
-import java.util.UUID;
-
-import org.apache.olingo.odata2.api.edm.EdmSimpleTypeKind;
-import org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPAModelException;
-import org.apache.olingo.odata2.processor.core.jpa.common.ODataJPATestConstants;
-import org.junit.Test;
-
-public class JPATypeConvertorTest {
-
- private EdmSimpleTypeKind edmSimpleKindTypeString;
- private EdmSimpleTypeKind edmSimpleKindTypeByteArr;
- private EdmSimpleTypeKind edmSimpleKindTypeLong;
- private EdmSimpleTypeKind edmSimpleKindTypeShort;
- private EdmSimpleTypeKind edmSimpleKindTypeInteger;
- private EdmSimpleTypeKind edmSimpleKindTypeDouble;
- private EdmSimpleTypeKind edmSimpleKindTypeFloat;
- private EdmSimpleTypeKind edmSimpleKindTypeBigDecimal;
- private EdmSimpleTypeKind edmSimpleKindTypeByte;
- private EdmSimpleTypeKind edmSimpleKindTypeBoolean;
- private EdmSimpleTypeKind edmSimpleKindTypeUUID;
-
- @Test
- public void testConvertToEdmSimpleType() {
- String str = "entity";
- byte[] byteArr = new byte[3];
- Long longObj = new Long(0);
- Short shortObj = new Short((short) 0);
- Integer integerObj = new Integer(0);
- Double doubleObj = new Double(0);
- Float floatObj = new Float(0);
- BigDecimal bigDecimalObj = new BigDecimal(0);
- Byte byteObj = new Byte((byte) 0);
- Boolean booleanObj = Boolean.TRUE;
- UUID uUID = new UUID(0, 0);
-
- try {
- edmSimpleKindTypeString = JPATypeConvertor.convertToEdmSimpleType(str.getClass(), null);
- edmSimpleKindTypeByteArr = JPATypeConvertor.convertToEdmSimpleType(byteArr.getClass(), null);
- edmSimpleKindTypeLong = JPATypeConvertor.convertToEdmSimpleType(longObj.getClass(), null);
- edmSimpleKindTypeShort = JPATypeConvertor.convertToEdmSimpleType(shortObj.getClass(), null);
- edmSimpleKindTypeInteger = JPATypeConvertor.convertToEdmSimpleType(integerObj.getClass(), null);
- edmSimpleKindTypeDouble = JPATypeConvertor.convertToEdmSimpleType(doubleObj.getClass(), null);
- edmSimpleKindTypeFloat = JPATypeConvertor.convertToEdmSimpleType(floatObj.getClass(), null);
- edmSimpleKindTypeBigDecimal = JPATypeConvertor.convertToEdmSimpleType(bigDecimalObj.getClass(), null);
- edmSimpleKindTypeByte = JPATypeConvertor.convertToEdmSimpleType(byteObj.getClass(), null);
- edmSimpleKindTypeBoolean = JPATypeConvertor.convertToEdmSimpleType(booleanObj.getClass(), null);
- /*
- * edmSimpleKindTypeDate = JPATypeConvertor
- * .convertToEdmSimpleType(dateObj.getClass(),null);
- */
- edmSimpleKindTypeUUID = JPATypeConvertor.convertToEdmSimpleType(uUID.getClass(), null);
- } catch (ODataJPAModelException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
-
- assertEquals(EdmSimpleTypeKind.String, edmSimpleKindTypeString);
- assertEquals(EdmSimpleTypeKind.Binary, edmSimpleKindTypeByteArr);
- assertEquals(EdmSimpleTypeKind.Int64, edmSimpleKindTypeLong);
- assertEquals(EdmSimpleTypeKind.Int16, edmSimpleKindTypeShort);
- assertEquals(EdmSimpleTypeKind.Int32, edmSimpleKindTypeInteger);
- assertEquals(EdmSimpleTypeKind.Double, edmSimpleKindTypeDouble);
- assertEquals(EdmSimpleTypeKind.Single, edmSimpleKindTypeFloat);
- assertEquals(EdmSimpleTypeKind.Decimal, edmSimpleKindTypeBigDecimal);
- assertEquals(EdmSimpleTypeKind.Byte, edmSimpleKindTypeByte);
- assertEquals(EdmSimpleTypeKind.Boolean, edmSimpleKindTypeBoolean);
- // assertEquals(EdmSimpleTypeKind.DateTime, edmSimpleKindTypeDate);
- assertEquals(EdmSimpleTypeKind.Guid, edmSimpleKindTypeUUID);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/common/ODataJPATestConstants.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/common/ODataJPATestConstants.java b/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/common/ODataJPATestConstants.java
deleted file mode 100644
index cd6caee..0000000
--- a/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/common/ODataJPATestConstants.java
+++ /dev/null
@@ -1,27 +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.common;
-
-public final class ODataJPATestConstants {
-
- public static final String EXCEPTION_MSG_PART_1 = "Exception [ ";
- public static final String EXCEPTION_MSG_PART_2 = " ] not expected";
- public static final String EMPTY_STRING = "gwt1";
- public static final String EXCEPTION_EXPECTED = "Exception expected";
-}
[19/37] [OLINGO-82] Renamed the project folder name to
odata2-jpa-processor
Posted by ch...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-web/src/main/webapp/index.jsp
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-web/src/main/webapp/index.jsp b/odata2-jpa-processor/jpa-web/src/main/webapp/index.jsp
new file mode 100644
index 0000000..cc5522e
--- /dev/null
+++ b/odata2-jpa-processor/jpa-web/src/main/webapp/index.jsp
@@ -0,0 +1,312 @@
+<!--
+ 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.
+-->
+<%@page
+ import="org.apache.olingo.odata2.jpa.processor.ref.factory.JPAEntityManagerFactory"%>
+<%@page import="java.util.List"%>
+<%@page import="javax.persistence.EntityManager"%>
+<%@page import="javax.persistence.EntityManagerFactory"%>
+<%@page import="javax.persistence.Persistence"%>
+<%@page import="javax.persistence.Query"%>
+<%@page
+ import="org.apache.olingo.odata2.jpa.processor.ref.web.JPAReferenceServiceFactory"%>
+<%@page
+ import="org.apache.olingo.odata2.jpa.processor.ref.util.DataGenerator"%>
+
+<%@ page language="java" contentType="text/html; charset=UTF-8"
+ pageEncoding="UTF-8"%>
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+<title>Apache Olingo - OData2 JPA Processor Library</title>
+<style type="text/css">
+body {
+ font-family: Arial, sans-serif;
+ font-size: 13px;
+ line-height: 18px;
+ color: blue;
+ background-color: #ffffff;
+}
+
+a {
+ color: blue;
+ text-decoration: none;
+}
+
+a:focus {
+ outline: thin dotted #4076cb;
+ outline-offset: -1px;
+}
+
+a:hover,a:active {
+ outline: 0;
+}
+
+a:hover {
+ color: #404a7e;
+ text-decoration: underline;
+}
+
+h1,h2,h3,h4,h5,h6 {
+ margin: 9px 0;
+ font-family: inherit;
+ font-weight: bold;
+ line-height: 1;
+ color: blue;
+}
+
+h1 {
+ font-size: 36px;
+ line-height: 40px;
+}
+
+h2 {
+ font-size: 30px;
+ line-height: 40px;
+}
+
+h3 {
+ font-size: 24px;
+ line-height: 40px;
+}
+
+h4 {
+ font-size: 18px;
+ line-height: 20px;
+}
+
+h5 {
+ font-size: 14px;
+ line-height: 20px;
+}
+
+h6 {
+ font-size: 12px;
+ line-height: 20px;
+}
+
+.logo {
+ float: right;
+}
+
+ul {
+ padding: 0;
+ margin: 0 0 9px 25px;
+}
+
+ul ul {
+ margin-bottom: 0;
+}
+
+li {
+ line-height: 18px;
+}
+
+hr {
+ margin: 18px 0;
+ border: 0;
+ border-top: 1px solid #cccccc;
+ border-bottom: 1px solid #ffffff;
+}
+
+table {
+ border-collapse: collapse;
+ border-spacing: 10px;
+ border: 0px;
+}
+
+th,td {
+ border: 0px solid;
+ padding: 20px;
+}
+
+.code {
+ font-family: "Courier New", monospace;
+ font-size: 13px;
+ line-height: 18px;
+}
+</style>
+</head>
+<body>
+ <h1>Apache Olingo - OData2 JPA Processor Library</h1>
+ <hr />
+ <table width=100% cellspacing="1" cellpadding="1">
+ <tr>
+ <td width=50%><h2>Reference Scenario</h2></td>
+ <td width="50%">
+ <table cellspacing="1" cellpadding="1">
+ <tr align="center">
+ <td align="right" width="80%"><font color="green"><small>
+ <%
+ EntityManagerFactory entityManagerFactory =
+ JPAEntityManagerFactory.getEntityManagerFactory("salesorderprocessing");
+ EntityManager entityManager = entityManagerFactory
+ .createEntityManager();
+ System.out.println("Data Gen " + entityManager.hashCode());
+ DataGenerator dataGenerator = new DataGenerator(entityManager);
+
+ Number result1 = null;
+ Number existingCount = null;
+
+ String msg = null;
+ if (request.getParameter("button") != null) {
+ if (request.getParameter("button").equalsIgnoreCase("Generate")) {
+ Query q = entityManager
+ .createQuery("SELECT COUNT(x) FROM SalesOrderHeader x");
+ existingCount = (Number) q.getSingleResult();
+ if (existingCount.intValue() < 10) { // Generate only if no data!
+ dataGenerator.generate();
+ result1 = (Number) q.getSingleResult();
+ System.out
+ .println("Data not existing earlier.... Generated number of Items - "
+ + result1);
+ msg = result1 + " items generated. ";
+
+ } else {
+ System.err
+ .println("Data already existing.... No Item generated by Data Generator !!");
+ msg = "Data exists. No Item generated !!";
+ }
+ } else { //Clean
+
+ // Check if data already exists
+ Query q = entityManager
+ .createQuery("SELECT COUNT(x) FROM SalesOrderHeader x");
+ Number result = (Number) q.getSingleResult();
+ if (result.intValue() > 0) { // Generate only if no data!
+ dataGenerator.clean();
+ msg = "Data Cleaned. " + result + " items cleaned.";
+ } else {
+ msg = " Nothing to clean!!";
+ }
+ }
+ %> <%=(msg)%>
+ </small> </font></td>
+ <%
+ }
+ %>
+ <td width="10%">
+ <form name="form1" method="get">
+ <input type="hidden" name="button" value="Generate"> <input
+ type="submit" value="Generate Data" width="100%">
+ </form>
+ </td>
+ <td width="10%">
+
+ <form name="form2" method="get">
+ <input type="hidden" name="button" value="Clean"> <input
+ type="submit" value=" Clean Data " width="100%">
+ </form>
+ </td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ </table>
+ <table width=100%>
+ <tr>
+ <td valign="top">
+ <h3>Service Document and Metadata</h3>
+ <ul>
+ <li><a href="SalesOrderProcessing.svc?_wadl" target="_blank">wadl</a></li>
+ <li><a href="SalesOrderProcessing.svc/" target="_blank">service
+ document</a></li>
+ <li><a href="SalesOrderProcessing.svc/$metadata"
+ target="_blank">metadata</a></li>
+ </ul>
+ <h3>EntitySets</h3>
+ <ul>
+ <li><a href="SalesOrderProcessing.svc/SalesOrders"
+ target="_blank">SalesOrders</a></li>
+ <li><a href="SalesOrderProcessing.svc/SalesOrderLineItems"
+ target="_blank">SalesOrderLineItems</a></li>
+ <li><a href="SalesOrderProcessing.svc/Materials"
+ target="_blank">Materials</a></li>
+ <li><a href="SalesOrderProcessing.svc/Stores" target="_blank">Stores</a></li>
+ </ul>
+ <h3>Entities</h3>
+ <ul>
+ <li><a href="SalesOrderProcessing.svc/SalesOrders(2L)"
+ target="_blank">SalesOrders(2L)</a></li>
+ <li><a
+ href="SalesOrderProcessing.svc/SalesOrderLineItems(LiId=10L,SoId=2L)"
+ target="_blank">SalesOrderLineItems(LiId=10L,SoId=2L)</a></li>
+ <li><a href="SalesOrderProcessing.svc/Materials(111L)"
+ target="_blank">Materials(111L)</a></li>
+ <li><a href="SalesOrderProcessing.svc/Stores(131L)"
+ target="_blank">Stores(131L)</a></li>
+
+ </ul>
+ <h3>Navigation</h3>
+ <ul>
+ <li><a
+ href="SalesOrderProcessing.svc/SalesOrders(2L)/SalesOrderLineItemDetails"
+ target="_blank">SalesOrders(2L)/SalesOrderLineItemDetails</a></li>
+ <li><a
+ href="SalesOrderProcessing.svc/SalesOrders(2L)/SalesOrderLineItemDetails"
+ target="_blank">SalesOrders(2L)/SalesOrderLineItemDetails</a></li>
+ <li><a
+ href="SalesOrderProcessing.svc/SalesOrderLineItems(LiId=10L,SoId=2L)/MaterialDetails"
+ target="_blank">SalesOrderLineItems(LiId=10L,SoId=2L)/MaterialDetails</a></li>
+ <li><a
+ href="SalesOrderProcessing.svc/Materials(112L)/StoreDetails"
+ target="_blank">Materials(112L)/StoreDetails</a></li>
+
+ </ul>
+ <h3>$expand</h3>
+ <ul>
+ <li><a
+ href="SalesOrderProcessing.svc/SalesOrders?$expand=SalesOrderLineItemDetails"
+ target="_blank">SalesOrders?$expand=SalesOrderLineItemDetails</a></li>
+ <li><a
+ href="SalesOrderProcessing.svc/SalesOrders(2L)?$expand=SalesOrderLineItemDetails"
+ target="_blank">SalesOrders(2L)?$expand=SalesOrderLineItemDetails</a></li>
+ <li><a
+ href="SalesOrderProcessing.svc/SalesOrders?$expand=SalesOrderLineItemDetails/MaterialDetails,SalesOrderLineItemDetails/MaterialDetails/StoreDetails,NotesDetails"
+ target="_blank">SalesOrders?$expand=SalesOrderLineItemDetails/MaterialDetails,SalesOrderLineItemDetails/MaterialDetails/StoreDetails,NotesDetails</a></li>
+ <li><a
+ href="SalesOrderProcessing.svc/SalesOrders(2L)?$expand=SalesOrderLineItemDetails/MaterialDetails,SalesOrderLineItemDetails/MaterialDetails/StoreDetails,NotesDetails"
+ target="_blank">SalesOrders(2L)?$expand=SalesOrderLineItemDetails/MaterialDetails,SalesOrderLineItemDetails/MaterialDetails/StoreDetails,NotesDetails</a></li>
+
+ </ul>
+ </td>
+ <td valign="top"> </td>
+ <td valign="bottom">
+ <div class="code">
+ <%
+ String version = "gen/version.html";
+ %>
+ <%
+ try {
+ %>
+ <jsp:include page='<%=version%>' />
+ <%
+ } catch (Exception e) {
+ %>
+ <p>IDE Build</p>
+ <%
+ }
+ %>
+ </div>
+ </td>
+ </tr>
+ </table>
+</body>
+</html>
+
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/pom.xml
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/pom.xml b/odata2-jpa-processor/pom.xml
new file mode 100644
index 0000000..f6f4706
--- /dev/null
+++ b/odata2-jpa-processor/pom.xml
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- 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. -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.apache.olingo</groupId>
+ <artifactId>olingo-odata2-jpa-processor-incubating</artifactId>
+ <packaging>pom</packaging>
+ <name>${project.artifactId}</name>
+
+ <parent>
+ <groupId>org.apache.olingo</groupId>
+ <artifactId>olingo-odata2-parent-incubating</artifactId>
+ <version>1.1.0-SNAPSHOT</version>
+ <relativePath>..</relativePath>
+ </parent>
+
+ <modules>
+ <module>jpa-api</module>
+ <module>jpa-core</module>
+ <module>jpa-ref</module>
+ <module>jpa-web</module>
+ </modules>
+</project>
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-api/.gitignore
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-api/.gitignore b/odata2-processor-jpa/jpa-api/.gitignore
deleted file mode 100644
index fe5d89b..0000000
--- a/odata2-processor-jpa/jpa-api/.gitignore
+++ /dev/null
@@ -1,8 +0,0 @@
-.project
-.classpath
-.settings
-target
-bin
-*.bak
-classes
-.DS_Store
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-api/pom.xml
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-api/pom.xml b/odata2-processor-jpa/jpa-api/pom.xml
deleted file mode 100644
index d0c8e0b..0000000
--- a/odata2-processor-jpa/jpa-api/pom.xml
+++ /dev/null
@@ -1,91 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- 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.
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.apache.olingo</groupId>
- <artifactId>olingo-odata2-jpa-processor-incubating</artifactId>
- <version>1.1.0-SNAPSHOT</version>
- <relativePath>../</relativePath>
- </parent>
-
- <artifactId>olingo-odata2-jpa-processor-api-incubating</artifactId>
- <packaging>jar</packaging>
- <name>${project.artifactId}</name>
-
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-jar-plugin</artifactId>
- <configuration>
- <archive>
- <manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
- </archive>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <extensions>true</extensions>
- <executions>
- <execution>
- <id>bundle-manifest</id>
- <phase>process-classes</phase>
- <goals>
- <goal>manifest</goal>
- </goals>
- </execution>
- </executions>
- <configuration>
- <instructions>
- <Import-Package>
- org.apache.olingo.odata2.processor.core.jpa.factory;resolution:=optional,
- *
- </Import-Package>
- <Export-Package>
- org.apache.olingo.odata2.processor.api.*;version=${project.version}
- </Export-Package>
- <Bundle-DocURL>${project.url}</Bundle-DocURL>
- <Bundle-ActivationPolicy>lazy</Bundle-ActivationPolicy>
- <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
- </instructions>
- </configuration>
- </plugin>
- </plugins>
- </build>
-
- <dependencies>
- <!-- JPA Support -->
- <dependency>
- <groupId>org.eclipse.persistence</groupId>
- <artifactId>javax.persistence</artifactId>
- <version>${version.javax.persistence}</version>
- </dependency>
-
- <!-- OData Java Library -->
- <dependency>
- <groupId>org.apache.olingo</groupId>
- <artifactId>olingo-odata2-api-incubating</artifactId>
- <version>${project.version}</version>
- </dependency>
- </dependencies>
-</project>
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-api/src/main/java/META-INF/MANIFEST.MF
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-api/src/main/java/META-INF/MANIFEST.MF b/odata2-processor-jpa/jpa-api/src/main/java/META-INF/MANIFEST.MF
deleted file mode 100644
index 5e94951..0000000
--- a/odata2-processor-jpa/jpa-api/src/main/java/META-INF/MANIFEST.MF
+++ /dev/null
@@ -1,3 +0,0 @@
-Manifest-Version: 1.0
-Class-Path:
-
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/ODataJPAContext.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/ODataJPAContext.java b/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/ODataJPAContext.java
deleted file mode 100644
index 9974434..0000000
--- a/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/ODataJPAContext.java
+++ /dev/null
@@ -1,206 +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.api.jpa;
-
-import javax.persistence.EntityManager;
-import javax.persistence.EntityManagerFactory;
-
-import org.apache.olingo.odata2.api.edm.provider.EdmProvider;
-import org.apache.olingo.odata2.api.processor.ODataContext;
-import org.apache.olingo.odata2.api.processor.ODataProcessor;
-import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmExtension;
-
-/**
- * This class does the compilation of context objects required for OData JPA
- * Runtime. The context object should be properly initialized with values else
- * the behavior of processor and EDM provider can result in exception.
- *
- * Following are the mandatory parameter to be set into the context object
- * <ol>
- * <li>Persistence Unit Name</li>
- * <li>An instance of Java Persistence Entity Manager Factory</li>
- * </ol>
- *
- * <br>
- * @org.apache.olingo.odata2.DoNotImplement
- * @see org.apache.olingo.odata2.processor.api.jpa.factory.ODataJPAFactory
- * @see org.apache.olingo.odata2.processor.api.jpa.factory.ODataJPAAccessFactory
- *
- */
-public interface ODataJPAContext {
-
- /**
- * The method gets the Java Persistence Unit Name set into the context.
- *
- * @return Java Persistence Unit Name
- */
- public String getPersistenceUnitName();
-
- /**
- * The method sets the Java Persistence Unit Name into the context.
- *
- * @param pUnitName
- * is the Java Persistence Unit Name.
- *
- */
- public void setPersistenceUnitName(String pUnitName);
-
- /**
- * The method gets the OData Processor for JPA from the context.
- *
- * @return OData JPA Processor
- */
- public ODataProcessor getODataProcessor();
-
- /**
- * The method sets the OData Processor for JPA into the context.
- *
- * @param processor
- * is the specific implementation of {@link org.apache.olingo.odata2.processor.api.jpa.ODataJPAProcessor} for
- * processing OData service requests.
- */
- public void setODataProcessor(ODataProcessor processor);
-
- /**
- * The method gets the EDM provider for JPA from the context.
- *
- * @return EDM provider
- */
- public EdmProvider getEdmProvider();
-
- /**
- * The method sets EDM provider into the context
- *
- * @param edmProvider
- * is the specific implementation of {@link org.apache.olingo.odata2.api.edm.provider.EdmProvider} for
- * transforming Java persistence models to Entity Data Model
- *
- */
- public void setEdmProvider(EdmProvider edmProvider);
-
- /**
- * The method gets the Java Persistence Entity Manager factory from the
- * context. <br>
- * <b>CAUTION:-</b> Don't use the Entity Manager Factory to instantiate
- * Entity Managers. Instead get reference to Entity Manager using
- * {@link org.apache.olingo.odata2.processor.api.jpa.ODataJPAContext#getEntityManager()}
- *
- * @return an instance of Java Persistence Entity Manager Factory
- */
- public EntityManagerFactory getEntityManagerFactory();
-
- /**
- * The method sets the Java Persistence Entity Manager factory into the
- * context.
- *
- * @param emf
- * is of type {@link javax.persistence.EntityManagerFactory}
- *
- */
- public void setEntityManagerFactory(EntityManagerFactory emf);
-
- /**
- * The method gets OData Context into the context.
- *
- * @return OData Context
- */
- public ODataContext getODataContext();
-
- /**
- * The method sets OData context into the context.
- *
- * @param ctx
- * is an OData context of type {@link org.apache.olingo.odata2.api.processor.ODataContext}
- */
- public void setODataContext(ODataContext ctx);
-
- /**
- * The method sets the JPA EDM mapping model name into the context. JPA EDM
- * mapping model is an XML document based on JPAEDMMappingModel.xsd
- *
- * @param name
- * is the name of JPA EDM mapping model
- */
- public void setJPAEdmMappingModel(String name);
-
- /**
- * The method gets the JPA EDM mapping model name from the context.
- *
- * @return name of JPA EDM mapping model
- */
- public String getJPAEdmMappingModel();
-
- /**
- * The method returns an instance of type entity manager. The entity manager
- * thus returns a single persistence context for the current OData request.
- * Hence all entities that are accessed within JPA processor are managed by
- * single entity manager.
- *
- * @return an instance of type {@link javax.persistence.EntityManager}
- */
- public EntityManager getEntityManager();
-
- /**
- * The method sets the JPA Edm Extension instance into the context. There
- * can be at most only one extension for a context. Invoking the method
- * several times overwrites already set extension instance in the context.
- *
- * @param jpaEdmExtension
- * is an instance of type {@link org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmExtension}
- *
- */
- public void setJPAEdmExtension(JPAEdmExtension jpaEdmExtension);
-
- /**
- * The method returns the JPA Edm Extension instance set into the context.
- *
- * @return an instance of type
- * {@link org.apache.olingo.odata2.processor.api.jpa.model.mapping.JPAEmbeddableTypeMapType}
- */
- public JPAEdmExtension getJPAEdmExtension();
-
- /**
- * The method sets into the context whether the library should consider default naming for
- * <ul><li>EdmProperty</li>
- * <li>EdmComplexProperty</li>
- * <li>EdmNavigationProperty</li></ul>
- *
- * @param defaultNaming is a boolean value that indicates if set to
- * <ul><li>true - default naming is considered in case no mapping is provided.</li>
- * <li>false - default naming is not considered in case no mapping is provided. The
- * name provided in JPA Entity Model is considered.</li>
- * </ul>
- */
- public void setDefaultNaming(boolean defaultNaming);
-
- /**
- * The method returns whether the library should consider default naming for
- * <ul><li>EdmProperty</li>
- * <li>EdmComplexProperty</li>
- * <li>EdmNavigationProperty</li></ul>
- *
- * @return
- * <ul><li>true - default naming is considered in case no mapping is provided.</li>
- * <li>false - default naming is not considered in case no mapping is provided. The
- * name provided in JPA Entity Model is considered.</li>
- * </ul>
- */
- public boolean getDefaultNaming();
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/ODataJPAProcessor.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/ODataJPAProcessor.java b/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/ODataJPAProcessor.java
deleted file mode 100644
index 441d38e..0000000
--- a/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/ODataJPAProcessor.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.api.jpa;
-
-import org.apache.olingo.odata2.api.processor.ODataSingleProcessor;
-import org.apache.olingo.odata2.processor.api.jpa.access.JPAProcessor;
-import org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPAException;
-import org.apache.olingo.odata2.processor.api.jpa.factory.ODataJPAFactory;
-
-/**
- * Extend this class and implement an OData JPA processor if the default
- * behavior of OData JPA Processor library has to be overwritten.
- *
- *
- *
- *
- */
-public abstract class ODataJPAProcessor extends ODataSingleProcessor {
-
- /**
- * An instance of {@link org.apache.olingo.odata2.processor.api.jpa.ODataJPAContext} object
- */
- protected ODataJPAContext oDataJPAContext;
-
- /**
- * An instance of {@link org.apache.olingo.odata2.processor.api.jpa.access.JPAProcessor}. The
- * instance is created using {@link org.apache.olingo.odata2.processor.api.jpa.factory.JPAAccessFactory}.
- */
- protected JPAProcessor jpaProcessor;
-
- public ODataJPAContext getOdataJPAContext() {
- return oDataJPAContext;
- }
-
- public void setOdataJPAContext(final ODataJPAContext odataJPAContext) {
- oDataJPAContext = odataJPAContext;
- }
-
- /**
- * Constructor
- *
- * @param oDataJPAContext
- * non null OData JPA Context object
- */
- public ODataJPAProcessor(final ODataJPAContext oDataJPAContext) {
- if (oDataJPAContext == null) {
- throw new IllegalArgumentException(ODataJPAException.ODATA_JPACTX_NULL);
- }
- this.oDataJPAContext = oDataJPAContext;
- jpaProcessor = ODataJPAFactory.createFactory().getJPAAccessFactory().getJPAProcessor(this.oDataJPAContext);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/ODataJPAServiceFactory.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/ODataJPAServiceFactory.java b/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/ODataJPAServiceFactory.java
deleted file mode 100644
index 4968107..0000000
--- a/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/ODataJPAServiceFactory.java
+++ /dev/null
@@ -1,190 +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.api.jpa;
-
-import org.apache.olingo.odata2.api.ODataCallback;
-import org.apache.olingo.odata2.api.ODataService;
-import org.apache.olingo.odata2.api.ODataServiceFactory;
-import org.apache.olingo.odata2.api.edm.provider.EdmProvider;
-import org.apache.olingo.odata2.api.exception.ODataException;
-import org.apache.olingo.odata2.api.processor.ODataContext;
-import org.apache.olingo.odata2.api.processor.ODataErrorCallback;
-import org.apache.olingo.odata2.api.processor.ODataSingleProcessor;
-import org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPAErrorCallback;
-import org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPARuntimeException;
-import org.apache.olingo.odata2.processor.api.jpa.factory.ODataJPAAccessFactory;
-import org.apache.olingo.odata2.processor.api.jpa.factory.ODataJPAFactory;
-
-/**
- * <p>
- * Extend this factory class and create own instance of {@link org.apache.olingo.odata2.api.ODataService} that
- * transforms Java Persistence
- * Models into an OData Service. The factory class instantiates instances of
- * type {@link org.apache.olingo.odata2.api.edm.provider.EdmProvider} and
- * {@link org.apache.olingo.odata2.api.processor.ODataSingleProcessor}. The OData
- * JPA Processor library provides a default implementation for EdmProvider and
- * OData Single Processor.
- * </p>
- * <p>
- * The factory implementation is passed as servlet init parameter to a JAX-RS
- * runtime which will instantiate a {@link org.apache.olingo.odata2.api.ODataService} implementation using this factory.
- * </p>
- *
- * <p>
- * <b>Mandatory:</b> Implement the abstract method initializeODataJPAContext. Fill
- * {@link org.apache.olingo.odata2.processor.api.jpa.ODataJPAContext} with context
- * values.
- * </p>
- *
- * <b>Sample Configuration:</b>
- *
- * <pre> {@code
- * <servlet>
- * <servlet-name>ReferenceScenarioServlet</servlet-name>
- * <servlet-class>org.apache.cxf.jaxrs.servlet.CXFNonSpringJaxrsServlet</servlet-class>
- * <init-param>
- * <param-name>javax.ws.rs.Application</param-name>
- * <param-value>org.apache.olingo.odata2.core.rest.ODataApplication</param-value>
- * </init-param>
- * <init-param>
- * <param-name>org.apache.olingo.odata2.processor.factory</param-name>
- * <param-value>foo.bar.sample.processor.SampleProcessorFactory</param-value>
- * </init-param>
- * <init-param>
- * <param-name>org.apache.olingo.odata2.path.split</param-name>
- * <param-value>2</param-value>
- * </init-param>
- * <load-on-startup>1</load-on-startup>
- * </servlet>
- * } </pre>
- */
-
-public abstract class ODataJPAServiceFactory extends ODataServiceFactory {
-
- private ODataJPAContext oDataJPAContext;
- private ODataContext oDataContext;
- private boolean setDetailErrors = false;
-
- /**
- * Creates an OData Service based on the values set in
- * {@link org.apache.olingo.odata2.processor.api.jpa.ODataJPAContext} and
- * {@link org.apache.olingo.odata2.api.processor.ODataContext}.
- */
- @Override
- public final ODataService createService(final ODataContext ctx) throws ODataException {
-
- oDataContext = ctx;
-
- // Initialize OData JPA Context
- oDataJPAContext = initializeODataJPAContext();
-
- validatePreConditions();
-
- ODataJPAFactory factory = ODataJPAFactory.createFactory();
- ODataJPAAccessFactory accessFactory = factory.getODataJPAAccessFactory();
-
- // OData JPA Processor
- if (oDataJPAContext.getODataContext() == null) {
- oDataJPAContext.setODataContext(ctx);
- }
-
- ODataSingleProcessor odataJPAProcessor = accessFactory.createODataProcessor(oDataJPAContext);
-
- // OData Entity Data Model Provider based on JPA
- EdmProvider edmProvider = accessFactory.createJPAEdmProvider(oDataJPAContext);
-
- return createODataSingleProcessorService(edmProvider, odataJPAProcessor);
- }
-
- private void validatePreConditions() throws ODataJPARuntimeException {
-
- if (oDataJPAContext.getEntityManagerFactory() == null) {
- throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.ENTITY_MANAGER_NOT_INITIALIZED, null);
- }
-
- }
-
- /**
- * Implement this method and initialize OData JPA Context. It is mandatory
- * to set an instance of type {@link javax.persistence.EntityManagerFactory} into the context. An exception of type
- * {@link org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPARuntimeException} is thrown if
- * EntityManagerFactory is not initialized. <br>
- * <br>
- * <b>Sample Code:</b> <code>
- * <p>public class JPAReferenceServiceFactory extends ODataJPAServiceFactory{</p>
- *
- * <blockquote>private static final String PUNIT_NAME = "punit";
- * <br>
- * public ODataJPAContext initializeODataJPAContext() {
- * <blockquote>ODataJPAContext oDataJPAContext = this.getODataJPAContext();
- * <br>
- * EntityManagerFactory emf = Persistence.createEntityManagerFactory(PUNIT_NAME);
- * <br>
- * oDataJPAContext.setEntityManagerFactory(emf);
- * oDataJPAContext.setPersistenceUnitName(PUNIT_NAME);
- * <br> return oDataJPAContext;</blockquote>
- * }</blockquote>
- * } </code>
- * <p>
- *
- * @return an instance of type {@link org.apache.olingo.odata2.processor.api.jpa.ODataJPAContext}
- * @throws ODataJPARuntimeException
- */
- public abstract ODataJPAContext initializeODataJPAContext() throws ODataJPARuntimeException;
-
- /**
- * @return an instance of type {@link ODataJPAContext}
- * @throws ODataJPARuntimeException
- */
- public final ODataJPAContext getODataJPAContext() throws ODataJPARuntimeException {
- if (oDataJPAContext == null) {
- oDataJPAContext = ODataJPAFactory.createFactory().getODataJPAAccessFactory().createODataJPAContext();
- }
- if (oDataContext != null) {
- oDataJPAContext.setODataContext(oDataContext);
- }
- return oDataJPAContext;
-
- }
-
- /**
- * The method sets the context whether a detail error message should be thrown
- * or a less detail error message should be thrown by the library.
- * @param setDetailErrors takes
- * <ul><li>true - to indicate that library should throw a detailed error message</li>
- * <li>false - to indicate that library should not throw a detailed error message</li>
- * </ul>
- *
- */
- protected void setDetailErrors(final boolean setDetailErrors) {
- this.setDetailErrors = setDetailErrors;
- }
-
- @SuppressWarnings("unchecked")
- @Override
- public <T extends ODataCallback> T getCallback(final Class<? extends ODataCallback> callbackInterface) {
- if (setDetailErrors == true) {
- if (callbackInterface.isAssignableFrom(ODataErrorCallback.class)) {
- return (T) new ODataJPAErrorCallback();
- }
- }
- return null;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/access/JPAEdmBuilder.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/access/JPAEdmBuilder.java b/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/access/JPAEdmBuilder.java
deleted file mode 100644
index 110a1f1..0000000
--- a/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/access/JPAEdmBuilder.java
+++ /dev/null
@@ -1,57 +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.api.jpa.access;
-
-import org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPAModelException;
-import org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPARuntimeException;
-
-/**
- * JPAEdmBuilder interface provides methods for building elements of an Entity Data Model (EDM) from
- * a Java Persistence Model.
- *
- *
- *
- */
-public interface JPAEdmBuilder {
- /**
- * The Method builds EDM Elements by transforming JPA MetaModel. The method
- * processes EDM JPA Containers which could be accessed using the following
- * views,
- * <ul>
- * <li> {@link org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmAssociationSetView} </li>
- * <li> {@link org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmAssociationView}</li>
- * <li> {@link org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmBaseView}</li>
- * <li> {@link org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmComplexPropertyView} </li>
- * <li> {@link org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmComplexTypeView}</li>
- * <li> {@link org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmEntityContainerView} </li>
- * <li> {@link org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmEntitySetView}</li>
- * <li> {@link org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmEntityTypeView}</li>
- * <li> {@link org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmKeyView}</li>
- * <li> {@link org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmModelView}</li>
- * <li> {@link org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmNavigationPropertyView} </li>
- * <li> {@link org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmPropertyView}</li>
- * <li> {@link org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmReferentialConstraintRoleView} </li>
- * <li> {@link org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmReferentialConstraintView} </li>
- * <li> {@link org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmSchemaView}</li>
- * </ul>
- *
- * @throws ODataJPARuntimeException
- **/
- public void build() throws ODataJPAModelException, ODataJPARuntimeException;
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/access/JPAEdmMappingModelAccess.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/access/JPAEdmMappingModelAccess.java b/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/access/JPAEdmMappingModelAccess.java
deleted file mode 100644
index 216db55..0000000
--- a/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/access/JPAEdmMappingModelAccess.java
+++ /dev/null
@@ -1,191 +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.api.jpa.access;
-
-import org.apache.olingo.odata2.processor.api.jpa.model.mapping.JPAEdmMappingModel;
-
-/**
- * Interface provides methods to access JPA EDM mapping model.
- *
- *
- * @see JPAEdmMappingModel
- *
- */
-public interface JPAEdmMappingModelAccess {
-
- /**
- * The method searches and loads the mapping model stored in <file>.xml
- * file into the java object {@link org.apache.olingo.odata2.processor.api.jpa.model.mapping.JPAEdmMappingModel} . The
- * name of the file is set into ODataJPAContext method.
- *
- * @see org.apache.olingo.odata2.processor.api.jpa.ODataJPAContext#setJPAEdmMappingModel(String)
- */
- public void loadMappingModel();
-
- /**
- * The method returns if there exists a mapping model.
- *
- * @return true - if there exists a mapping model for the OData service else
- * false
- */
- public boolean isMappingModelExists();
-
- /**
- * The method returns a JPA EDM mapping model Java object. The mapping model
- * in XML files is un-marshaled into the Java object.
- *
- * @return an instance of type {@link org.apache.olingo.odata2.processor.api.jpa.model.mapping.JPAEdmMappingModel}
- */
- public JPAEdmMappingModel getJPAEdmMappingModel();
-
- /**
- * The method returns EDM Schema namespace for the persistence unit name
- *
- * @param persistenceUnitName
- * is the Java persistence unit name
- * @return EDM schema name space mapped to Java persistence unit name or
- * null if no mapping is available
- */
- public String mapJPAPersistenceUnit(String persistenceUnitName);
-
- /**
- * The method returns EDM entity type name for the Java persistence entity
- * type name
- *
- * @param jpaEntityTypeName
- * is the Java persistence entity type name
- * @return EDM entity type name mapped to Java persistence entity type name
- * or null if no mapping is available
- */
- public String mapJPAEntityType(String jpaEntityTypeName);
-
- /**
- * The method returns EDM entity set name for the Java persistence entity
- * type name
- *
- * @param jpaEntityTypeName
- * is the Java persistence entity type name
- * @return EDM entity set name mapped to Java persistence entity type name
- * or null if no mapping is available
- */
- public String mapJPAEntitySet(String jpaEntityTypeName);
-
- /**
- * The method returns EDM property name for the Java persistence entity
- * attribute name.
- *
- * @param jpaEntityTypeName
- * is the Java persistence entity type name
- * @param jpaAttributeName
- * is the Java persistence attribute name
- * @return EDM property name mapped to Java persistence attribute name or
- * null if no mapping is available
- */
- public String mapJPAAttribute(String jpaEntityTypeName, String jpaAttributeName);
-
- /**
- * The method returns EDM navigation property name for the Java persistence
- * entity relationship name.
- *
- * @param jpaEntityTypeName
- * is the Java persistence entity type name
- * @param jpaRelationshipName
- * is the Java persistence relationship name
- * @return EDM navigation property name mapped to Java persistence entity
- * relationship name or null if no mapping is available
- */
- public String mapJPARelationship(String jpaEntityTypeName, String jpaRelationshipName);
-
- /**
- * The method returns EDM complex type name for the Java embeddable type
- * name.
- *
- * @param jpaEmbeddableTypeName
- * is the Java persistence embeddable type name
- * @return EDM complex type name mapped to Java persistence entity
- * relationship name or null if no mapping is available
- */
- public String mapJPAEmbeddableType(String jpaEmbeddableTypeName);
-
- /**
- * The method returns EDM property name for the Java persistence embeddable
- * type's attribute name.
- *
- * @param jpaEmbeddableTypeName
- * is the Java persistence
- * @param jpaAttributeName
- * is the Java persistence attribute name
- * @return EDM property name mapped to Java persistence attribute name or
- * null if no mapping is available
- */
- public String mapJPAEmbeddableTypeAttribute(String jpaEmbeddableTypeName, String jpaAttributeName);
-
- /**
- * The method returns whether the JPA Entity should be excluded from EDM
- * model
- *
- * @param jpaEntityTypeName
- * is the name of JPA Entity Type
- * @return <b>true</b> - if JPA Entity should be excluded<br>
- * <b>false</b> - if JPA Entity should be not be excluded
- *
- */
- public boolean checkExclusionOfJPAEntityType(String jpaEntityTypeName);
-
- /**
- * The method returns whether the JPA Attribute should be excluded from EDM
- * Entity Type
- *
- * @param jpaEntityTypeName
- * is the name of JPA Entity Type
- * @param jpaAttributeName
- * is the name of JPA attribute
- * @return <b>true</b> - if JPA attribute should be excluded<br>
- * <b>false</b> - if JPA attribute should be not be excluded
- *
- */
- public boolean checkExclusionOfJPAAttributeType(String jpaEntityTypeName, String jpaAttributeName);
-
- /**
- * The method returns whether the JPA Embeddable Type should be excluded
- * from EDM model
- *
- * @param jpaEmbeddableTypeName
- * is the name of JPA Embeddable Type
- * @return <b>true</b> - if JPA Embeddable Type should be excluded<br>
- * <b>false</b> - if JPA Embeddable Type should be not be excluded
- *
- */
- public boolean checkExclusionOfJPAEmbeddableType(String jpaEmbeddableTypeName);
-
- /**
- * The method returns whether the JPA Embeddable Attribute Type should be
- * excluded from EDM model
- *
- * @param jpaEmbeddableTypeName
- * is the name of JPA Embeddable Attribute Type
- * @param jpaAttributeName
- * is the name of JPA Attribute name
- * @return <b>true</b> - if JPA Embeddable Attribute Type should be excluded<br>
- * <b>false</b> - if JPA Embeddable Attribute Type should be not be
- * excluded
- *
- */
- public boolean checkExclusionOfJPAEmbeddableAttributeType(String jpaEmbeddableTypeName, String jpaAttributeName);
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/access/JPAFunction.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/access/JPAFunction.java b/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/access/JPAFunction.java
deleted file mode 100644
index 648a09c..0000000
--- a/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/access/JPAFunction.java
+++ /dev/null
@@ -1,85 +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.api.jpa.access;
-
-import java.lang.reflect.Method;
-import java.lang.reflect.Type;
-
-/**
- * A container for JPA Functions. A JPA function can be
- * <ol>
- * <li>Property Access method</li>
- * <li>Custom Operation (Annotated with EDM Annotation FunctionImport)</li>
- * </ol>
- *
- *
- *
- */
-public class JPAFunction {
-
- private Method function;
- private Class<?>[] parameterTypes;
- private Type returnType;
- private Object[] args;
-
- public JPAFunction(final Method function, final Class<?>[] parameterTypes, final Type returnType,
- final Object[] args) {
- this.function = function;
- this.parameterTypes = parameterTypes;
- this.returnType = returnType;
- this.args = args;
- }
-
- /**
- * The method returns the Java method.
- *
- * @return an instance of {@link java.lang.reflect.Method}
- */
- public Method getFunction() {
- return function;
- }
-
- /**
- * The method returns the parameter types for the Java method.
- *
- * @return an array of type {@link java.lang.Class}
- */
- public Class<?>[] getParameterTypes() {
- return parameterTypes;
- }
-
- /**
- * The method returns the return type for the Java method.
- *
- * @return an instance of {@link java.lang.reflect.Type}
- */
- public Type getReturnType() {
- return returnType;
- }
-
- /**
- * The method returns an array of arguments for invoking the Java method.
- *
- * @return an array of Objects
- */
- public Object[] getArguments() {
- return args;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/access/JPAJoinClause.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/access/JPAJoinClause.java b/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/access/JPAJoinClause.java
deleted file mode 100644
index f0a4c8d..0000000
--- a/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/access/JPAJoinClause.java
+++ /dev/null
@@ -1,148 +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.api.jpa.access;
-
-/**
- * A container for Java Persistence Join Clause that can be used for building
- * JPQL statements. The container has two main elements <b>
- * <ol>
- * <li>Java Persistence Entity -</li> is the source entity participating in the
- * join. <br>
- * <li>Java Persistence Entity Relationship -</li> is the entity relationship of
- * the source entity participating in the join.
- * </ol>
- * </b>
- *
- *
- *
- */
-public class JPAJoinClause {
-
- /**
- * Enumerated list of possible Joins in JPQL
- * <ol>
- * <li>LEFT - left outer join</li>
- * <li>FETCH - enable fetching of an association as a side effect of the
- * execution of a query</li>
- * <li>INNER - inner join
- * </ol>
- *
- *
- *
- */
- public enum JOIN {
- LEFT, FETCH, INNER
- }
-
- private String entityName;
- private String entityAlias;
- private String entityRelationShip;
- private String entityRelationShipAlias;
- private JOIN joinType;
- private String joinCondition;
-
- /**
- * The method returns Java Persistence Entity participating in the join.
- *
- * @return an entity name
- */
- public String getEntityName() {
- return entityName;
- }
-
- /**
- * The method returns Java Persistence Entity alias name participating in
- * the join.
- *
- * @return a entity alias name
- */
- public String getEntityAlias() {
- return entityAlias;
- }
-
- /**
- * The method returns Java Persistence Entity Relationship name
- * participating in the join.
- *
- * @return entity alias relationship
- */
- public String getEntityRelationShip() {
- return entityRelationShip;
- }
-
- /**
- * The method returns Java Persistence Entity Relationship Alias name
- * participating in the join.
- *
- * @return entity entity relationship alias
- */
- public String getEntityRelationShipAlias() {
- return entityRelationShipAlias;
- }
-
- /**
- * Constructor for creating elements of JPA Join Clause container.
- *
- * @param entityName
- * is the name of the JPA entity participating in the join
- * @param entityAlias
- * is the alias for the JPA entity participating in the join
- * @param entityRelationShip
- * is the name of the JPA entity relationship participating in
- * the join
- * @param entityRelationShipAlias
- * is the alias name of the JPA entity relationship participating
- * in the join
- * @param joinCondition
- * is the condition on which the joins should occur
- * @param joinType
- * is the type of join {@link org.apache.olingo.odata2.processor.api.jpa.access.JPAJoinClause.JOIN} to execute
- */
- public JPAJoinClause(final String entityName, final String entityAlias, final String entityRelationShip,
- final String entityRelationShipAlias, final String joinCondition, final JOIN joinType) {
-
- this.entityName = entityName;
- this.entityAlias = entityAlias;
- this.entityRelationShip = entityRelationShip;
- this.entityRelationShipAlias = entityRelationShipAlias;
- this.joinCondition = joinCondition;
- this.joinType = joinType;
- }
-
- /**
- * The method returns a join condition that can be used for building JPQL
- * join statements.
- *
- * @return a join condition
- */
- public String getJoinCondition() {
- return joinCondition;
- }
-
- /**
- * The method returns the type of {@link org.apache.olingo.odata2.processor.api.jpa.access.JPAJoinClause.JOIN} that
- * can be used for building JPQL join statements.
- *
- * @return join type
- */
- public JOIN getJoinType() {
- return joinType;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/access/JPAMethodContext.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/access/JPAMethodContext.java b/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/access/JPAMethodContext.java
deleted file mode 100644
index fd44200..0000000
--- a/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/access/JPAMethodContext.java
+++ /dev/null
@@ -1,130 +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.api.jpa.access;
-
-import java.util.ArrayList;
-import java.util.List;
-
-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.factory.ODataJPAFactory;
-import org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLContextType;
-
-/**
- * The abstract class is a compilation of objects required for building specific
- * instances of JPA Method Context. Extend this class to implement specific
- * implementations of JPQL context types (Create,Update,Function). A JPA method
- * Context is constructed from an OData request. Depending on OData
- * CUD/FunctionImport operation performed on an Entity, a corresponding JPA
- * method context object is built. The object thus built can be used for
- * executing operations on JPA Entity/Custom processor objects. <br>
- * A default implementation is provided by the library.
- *
- *
- * @see org.apache.olingo.odata2.processor.api.jpa.access.JPAMethodContextView
- * @see org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLContextType
- *
- */
-
-public abstract class JPAMethodContext implements JPAMethodContextView {
-
- protected Object enclosingObject;
- protected ArrayList<JPAFunction> jpaFunction;
-
- @Override
- /**
- * The method returns list of JPA functions that can be executed on the
- * enclosing object.
- *
- * @return an instance of list of JPA Function
- */
- public Object getEnclosingObject() {
- return enclosingObject;
- }
-
- @Override
- /**
- * The method returns list of JPA functions that can be executed on the
- * enclosing object.
- *
- * @return an instance of list of JPA Function
- */
- public List<JPAFunction> getJPAFunctionList() {
- return jpaFunction;
- }
-
- protected void setEnclosingObject(final Object enclosingObject) {
- this.enclosingObject = enclosingObject;
- }
-
- protected void setJpaFunction(final List<JPAFunction> jpaFunctionList) {
- jpaFunction = (ArrayList<JPAFunction>) jpaFunctionList;
- }
-
- /**
- * the method instantiates an instance of type JPAMethodContextBuilder.
- *
- * @param contextType
- * indicates the type of JPQLContextBuilder to instantiate.
- * @param resultsView
- * is the OData request view
- * @return {@link org.apache.olingo.odata2.processor.api.jpa.access.JPAMethodContext.JPAMethodContextBuilder}
- *
- * @throws ODataJPARuntimeException
- */
- public final static JPAMethodContextBuilder
- createBuilder(final JPQLContextType contextType, final Object resultsView) throws ODataJPARuntimeException {
- return JPAMethodContextBuilder.create(contextType, resultsView);
- }
-
- /**
- * The abstract class is extended by specific JPA Method Context Builder to
- * build JPA Method Context types.
- *
- *
- *
- */
- public static abstract class JPAMethodContextBuilder {
-
- /**
- * Implement this method to build JPAMethodContext
- *
- * @return an instance of type JPAMethodContext
- * @throws ODataJPAModelException
- * @throws ODataJPARuntimeException
- */
- public abstract JPAMethodContext build() throws ODataJPAModelException, ODataJPARuntimeException;
-
- protected JPAMethodContextBuilder() {}
-
- private static JPAMethodContextBuilder create(final JPQLContextType contextType, final Object resultsView)
- throws ODataJPARuntimeException {
- JPAMethodContextBuilder contextBuilder =
- ODataJPAFactory.createFactory().getJPQLBuilderFactory().getJPAMethodContextBuilder(contextType);
-
- if (contextBuilder == null) {
- throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.ERROR_JPQLCTXBLDR_CREATE, null);
- }
- contextBuilder.setResultsView(resultsView);
- return contextBuilder;
- }
-
- protected abstract void setResultsView(Object resultsView);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/access/JPAMethodContextView.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/access/JPAMethodContextView.java b/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/access/JPAMethodContextView.java
deleted file mode 100644
index fb057a0..0000000
--- a/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/access/JPAMethodContextView.java
+++ /dev/null
@@ -1,46 +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.api.jpa.access;
-
-import java.util.List;
-
-/**
- * The interface provides view on JPA Method Context. JPA Method context can be
- * used to access custom operations or JPA Entity property access methods.
- *
- *
- *
- */
-public interface JPAMethodContextView {
- /**
- * The method returns an instance of Object on which the methods/custom
- * operations can be executed.
- *
- * @return instance of enclosing object for the method
- */
- public Object getEnclosingObject();
-
- /**
- * The method returns list of JPA functions that can be executed on the
- * enclosing object.
- *
- * @return an instance of list of JPA Function
- */
- public List<JPAFunction> getJPAFunctionList();
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/access/JPAProcessor.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/access/JPAProcessor.java b/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/access/JPAProcessor.java
deleted file mode 100644
index af9b77d..0000000
--- a/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/access/JPAProcessor.java
+++ /dev/null
@@ -1,260 +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.api.jpa.access;
-
-import java.io.InputStream;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.olingo.odata2.api.uri.info.DeleteUriInfo;
-import org.apache.olingo.odata2.api.uri.info.GetEntityCountUriInfo;
-import org.apache.olingo.odata2.api.uri.info.GetEntityLinkUriInfo;
-import org.apache.olingo.odata2.api.uri.info.GetEntitySetCountUriInfo;
-import org.apache.olingo.odata2.api.uri.info.GetEntitySetLinksUriInfo;
-import org.apache.olingo.odata2.api.uri.info.GetEntitySetUriInfo;
-import org.apache.olingo.odata2.api.uri.info.GetEntityUriInfo;
-import org.apache.olingo.odata2.api.uri.info.GetFunctionImportUriInfo;
-import org.apache.olingo.odata2.api.uri.info.PostUriInfo;
-import org.apache.olingo.odata2.api.uri.info.PutMergePatchUriInfo;
-import org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPAModelException;
-import org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPARuntimeException;
-
-/**
- * The interface provides methods for processing OData Requests for Create, Read, Update, Delete operations.
- * Pass the OData request or parsed OData request (Map of properties) as request.
- * A JPA entity is returned as a response.
- *
- */
-public interface JPAProcessor {
- /**
- * Processes OData request for querying an Entity Set. The method returns
- * list of Objects of type representing JPA Entity Types.
- *
- * @param <T>
- * Template parameter representing Java Persistence Entity Type.
- * <p>
- * <b>Note:-</b> Default parameter is Object.
- * </p>
- *
- * @param requestView
- * is an OData request for querying an entity set
- * <p>
- * @return list of objects representing JPA entity types
- **/
- public <T> List<T> process(GetEntitySetUriInfo requestView)
- throws ODataJPAModelException, ODataJPARuntimeException;
-
- /**
- * Processes OData request for reading an Entity. The method returns an
- * Object of type representing JPA Entity Type.
- *
- * @param <T>
- * Template parameter representing Java Persistence Entity Type.
- * <p>
- * <b>Note:-</b> Default parameter is Object.
- * </p>
- *
- * @param requestView
- * OData request for reading an entity
- *
- * <p>
- * @return object representing JPA entity type
- **/
- public <T> Object process(GetEntityUriInfo requestView)
- throws ODataJPAModelException, ODataJPARuntimeException;
-
- /**
- * Processes OData request for fetching Entity count. The method returns JPA Entity count
- *
- * @param requestView
- * OData request for counting an entity set
- * @return long value representing count of JPA entity set
- *
- * @throws ODataJPAModelException
- * @throws ODataJPARuntimeException
- */
-
- public long process(GetEntitySetCountUriInfo requestView)
- throws ODataJPAModelException, ODataJPARuntimeException;
-
- /**
- * Processes OData request for fetching Entity count. The method returns count of target entity.
- * This is specific to situation where cardinality is 1:1
- *
- * @param resultsView
- * OData request for counting target entity.
- * @return long value representing count of JPA entity
- *
- * @throws ODataJPAModelException
- * @throws ODataJPARuntimeException
- */
- public long process(GetEntityCountUriInfo resultsView)
- throws ODataJPAModelException, ODataJPARuntimeException;
-
- /**
- * Processes OData request for executing custom operations. The method
- * returns a List of Object. The list contains one entry if the the custom
- * operations return type has multiplicity of ONE.
- *
- * @param requestView
- * OData request for executing function import
- * @return result of executing function import
- * @throws ODataJPAModelException
- * @throws ODataJPARuntimeException
- */
- public List<Object> process(GetFunctionImportUriInfo requestView)
- throws ODataJPAModelException, ODataJPARuntimeException;
-
- /**
- * Processes OData request for executing $links OData command for N:1 relation.
- * The method returns an Object of type representing OData entity.
- *
- * @param uriParserResultView
- * OData request for Entity Link URI
- * @return an object representing JPA entity
- * @throws ODataJPAModelException
- * @throws ODataJPARuntimeException
- */
- public Object process(GetEntityLinkUriInfo uriParserResultView)
- throws ODataJPAModelException, ODataJPARuntimeException;
-
- /**
- * Processes OData request for executing $links OData command for N:1 relation.
- * The method returns an Object of type representing OData entity.
- *
- * @param uriParserResultView
- * OData request for Entity Set Link URI
- * @return a list of object representing JPA entities
- * @throws ODataJPAModelException
- * @throws ODataJPARuntimeException
- */
- public <T> List<T> process(GetEntitySetLinksUriInfo uriParserResultView)
- throws ODataJPAModelException, ODataJPARuntimeException;
-
- /**
- * Processes OData request for creating Entity. The method returns an Object
- * which is created. A Null reference implies object was not created.
- *
- * @param createView
- * @param content
- * @param requestContentType
- * @return Created Object
- *
- * @throws ODataJPAModelException
- * @throws ODataJPARuntimeException
- */
-
- public <T> List<T> process(PostUriInfo createView, InputStream content,
- String requestContentType) throws ODataJPAModelException,
- ODataJPARuntimeException;
-
- /**
- * Processes OData request for creating Entity. The method expects a parsed OData request which is a Map of
- * properties.
- * The method returns an Object that is created. A Null reference implies object was not created.
- *
- * @param createView
- * @param content
- * @return Created Object
- *
- * @throws ODataJPAModelException
- * @throws ODataJPARuntimeException
- */
-
- public <T> List<T> process(PostUriInfo createView, Map<String, Object> content) throws ODataJPAModelException,
- ODataJPARuntimeException;
-
- /**
- * Processes OData request for updating Entity. The method returns an Object
- * which is updated. A Null reference implies object was not created.
- *
- * @param updateView
- * @param content
- * @param requestContentType
- * @return Deleted Object
- *
- * @throws ODataJPAModelException
- * @throws ODataJPARuntimeException
- */
- public <T> Object process(PutMergePatchUriInfo updateView,
- InputStream content, String requestContentType)
- throws ODataJPAModelException, ODataJPARuntimeException;
-
- /**
- * Processes OData request for updating Entity. The method returns an Object
- * which is updated. A Null reference implies object was not created.
- *
- * @param updateView
- * @param content
- * @return Deleted Object
- *
- * @throws ODataJPAModelException
- * @throws ODataJPARuntimeException
- */
- public <T> Object process(PutMergePatchUriInfo updateView, Map<String, Object> content)
- throws ODataJPAModelException, ODataJPARuntimeException;
-
- /**
- * Processes OData request for deleting Entity. The method returns an Object
- * which is deleted. A Null reference implies object was not created.
- *
- * @param deleteuriInfo
- * @param contentType
- * @return Deleted Object
- *
- * @throws ODataJPAModelException
- * @throws ODataJPARuntimeException
- */
- public Object process(DeleteUriInfo deleteuriInfo, String contentType)
- throws ODataJPAModelException, ODataJPARuntimeException;
-
- /**
- * Process OData request for creating Links. The OData request should contain
- * $links OData command.
- *
- * @param uriParserResultView
- * OData request for creating Links
- * @param content
- * @param requestContentType
- * @param contentType
- *
- * @throws ODataJPARuntimeException
- * @throws ODataJPAModelException
- */
- public void process(PostUriInfo uriParserResultView,
- InputStream content, String requestContentType, String contentType)
- throws ODataJPARuntimeException, ODataJPAModelException;
-
- /**
- * Process OData request for updating Links. The OData request should contain
- * $links OData command.
- *
- * @param uriParserResultView
- * OData request for updating Links
- * @param content
- * @param requestContentType
- * @param contentType
- *
- * @throws ODataJPARuntimeException
- * @throws ODataJPAModelException
- */
- public void process(PutMergePatchUriInfo uriParserResultView,
- InputStream content, String requestContentType, String contentType)
- throws ODataJPARuntimeException, ODataJPAModelException;
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/access/package-info.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/access/package-info.java b/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/access/package-info.java
deleted file mode 100644
index 38671c1..0000000
--- a/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/access/package-info.java
+++ /dev/null
@@ -1,26 +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.
- ******************************************************************************/
-/**
- * <h3>OData JPA Processor API Library - Java Persistence Access</h3>
- * The library provides a set of APIs to access Java Persistence Models and Data.
- *
- *
- */
-package org.apache.olingo.odata2.processor.api.jpa.access;
-
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/exception/ODataJPAErrorCallback.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/exception/ODataJPAErrorCallback.java b/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/exception/ODataJPAErrorCallback.java
deleted file mode 100644
index 9f78af0..0000000
--- a/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/exception/ODataJPAErrorCallback.java
+++ /dev/null
@@ -1,45 +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.api.jpa.exception;
-
-import org.apache.olingo.odata2.api.ep.EntityProvider;
-import org.apache.olingo.odata2.api.exception.ODataApplicationException;
-import org.apache.olingo.odata2.api.processor.ODataErrorCallback;
-import org.apache.olingo.odata2.api.processor.ODataErrorContext;
-import org.apache.olingo.odata2.api.processor.ODataResponse;
-
-public class ODataJPAErrorCallback implements ODataErrorCallback {
-
- @Override
- public ODataResponse handleError(final ODataErrorContext context) throws ODataApplicationException {
-
- final String SEPARATOR = " : ";
-
- Throwable t = context.getException();
- if (t instanceof ODataJPAException) {
- StringBuilder errorBuilder = new StringBuilder();
- errorBuilder.append(t.getCause().getClass().toString());
- errorBuilder.append(SEPARATOR);
- errorBuilder.append(t.getCause().getMessage());
- context.setInnerError(errorBuilder.toString());
- }
- return EntityProvider.writeErrorDocument(context);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/exception/ODataJPAException.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/exception/ODataJPAException.java b/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/exception/ODataJPAException.java
deleted file mode 100644
index 3347ee0..0000000
--- a/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/exception/ODataJPAException.java
+++ /dev/null
@@ -1,68 +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.api.jpa.exception;
-
-import java.util.Locale;
-
-import org.apache.olingo.odata2.api.exception.MessageReference;
-import org.apache.olingo.odata2.api.exception.ODataException;
-
-/**
- * The exception class is the base of OData JPA exceptions. The class also
- * provides non localized error texts that can be used for raising OData JPA
- * exceptions with non localized error texts.
- *
- *
- *
- */
-public abstract class ODataJPAException extends ODataException {
-
- protected MessageReference messageReference;
-
- public static final String ODATA_JPACTX_NULL = "OData JPA Context cannot be null";
-
- private static final long serialVersionUID = -6884673558124441214L;
- protected static final Locale DEFAULT_LOCALE = Locale.ENGLISH;
-
- protected ODataJPAException(final String localizedMessage, final Throwable e, final MessageReference msgRef) {
- super(localizedMessage, e);
- messageReference = msgRef;
- }
-
- /**
- * The method creates a Reference to Message Object {@link org.apache.olingo.odata2.api.exception.MessageReference} .
- * The message
- * text key is derived out of parameters clazz.messageReferenceKey.
- *
- * @param clazz
- * is name of the class extending {@link org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPAException}
- * @param messageReferenceKey
- * is the key of the message
- * @return an instance of type {@link org.apache.olingo.odata2.api.exception.MessageReference}
- */
- protected static MessageReference createMessageReference(final Class<? extends ODataJPAException> clazz,
- final String messageReferenceKey) {
- return MessageReference.create(clazz, messageReferenceKey);
- }
-
- public MessageReference getMessageReference() {
- return messageReference;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/exception/ODataJPAMessageService.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/exception/ODataJPAMessageService.java b/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/exception/ODataJPAMessageService.java
deleted file mode 100644
index 97dc1bf..0000000
--- a/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/exception/ODataJPAMessageService.java
+++ /dev/null
@@ -1,49 +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.api.jpa.exception;
-
-import org.apache.olingo.odata2.api.exception.MessageReference;
-
-/**
- * The interface is used to access language dependent message texts. Default
- * language is "English - EN". <br>
- * The default implementation of the interface shipped with the library loads
- * message texts from language dependent property files. If the message text is
- * not found for the given language then the default language -EN is used for
- * the message texts.
- *
- *
- * @see org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPAException
- * @see org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPARuntimeException
- * @see org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPAModelException
- * @see org.apache.olingo.odata2.api.exception.MessageReference
- */
-public interface ODataJPAMessageService {
- /**
- * The method returns a language dependent message texts for the given
- * {@link org.apache.olingo.odata2.api.exception.MessageReference}.
- *
- * @param context
- * is a Message Reference
- * exception
- * is a Throwable Exception
- * @return a language dependent message text
- */
- public String getLocalizedMessage(MessageReference context, Throwable exception);
-}
[27/37] [OLINGO-82] Renamed the project folder name to
odata2-jpa-processor
Posted by ch...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/access/data/JPAEntityParserTestForStaticMethods.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/access/data/JPAEntityParserTestForStaticMethods.java b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/access/data/JPAEntityParserTestForStaticMethods.java
new file mode 100644
index 0000000..86514b4
--- /dev/null
+++ b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/access/data/JPAEntityParserTestForStaticMethods.java
@@ -0,0 +1,251 @@
+/*******************************************************************************
+ * 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.access.data;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.lang.reflect.Method;
+
+import org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPARuntimeException;
+import org.apache.olingo.odata2.processor.core.jpa.common.ODataJPATestConstants;
+import org.junit.Test;
+
+public class JPAEntityParserTestForStaticMethods {
+
+ @Test
+ public void testToStringDefault() {
+
+ Character[] input = new Character[] { 'A', 'B' };
+ assertEquals("AB", JPAEntityParser.toString(input));
+
+ }
+
+ @Test
+ public void testToStringNull() {
+ Character[] input = null;
+ assertNull(JPAEntityParser.toString(input));
+ }
+
+ @Test
+ public void testToStringPartialNull() {
+ Character[] input = new Character[] { 'A', null };
+ assertEquals("A", JPAEntityParser.toString(input));
+ }
+
+ @Test
+ public void testToCharacterArrayDefault() {
+ String input = new String("AB");
+ Character[] ch = JPAEntityParser.toCharacterArray(input);
+
+ assertEquals(2, ch.length);
+ assertTrue(ch[0].equals('A'));
+ assertTrue(ch[1].equals('B'));
+ }
+
+ @Test
+ public void testToCharacterArrayNull() {
+ String input = null;
+ Character[] ch = JPAEntityParser.toCharacterArray(input);
+
+ assertNull(ch);
+ }
+
+ @Test
+ public void testGetPropertyCharacter() {
+ try {
+ Method method = JPAEntityParserTestForStaticMethods.class.getMethod("getCharacter", (Class<?>[]) null);
+ String output = (String) JPAEntityParser.getProperty(method, this);
+ assertEquals("A", output);
+
+ } catch (NoSuchMethodException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ } catch (SecurityException 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);
+ }
+ }
+
+ @Test
+ public void testGetPropertyCharacterNull() {
+ try {
+ Method method = JPAEntityParserTestForStaticMethods.class.getMethod("getCharacterNull", (Class<?>[]) null);
+ String output = (String) JPAEntityParser.getProperty(method, this);
+ assertNull(output);
+
+ } catch (NoSuchMethodException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ } catch (SecurityException 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);
+ }
+ }
+
+ @Test
+ public void testGetPropertyCharacterArray() {
+ try {
+ Method method = JPAEntityParserTestForStaticMethods.class.getMethod("getCharacterArray", (Class<?>[]) null);
+ String output = (String) JPAEntityParser.getProperty(method, this);
+ assertEquals("AB", output);
+
+ } catch (NoSuchMethodException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ } catch (SecurityException 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);
+ }
+ }
+
+ @Test
+ public void testGetPropertyCharacterArrayNull() {
+ try {
+ Method method = JPAEntityParserTestForStaticMethods.class.getMethod("getCharacterArrayNull", (Class<?>[]) null);
+ String output = (String) JPAEntityParser.getProperty(method, this);
+ assertNull(output);
+
+ } catch (NoSuchMethodException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ } catch (SecurityException 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);
+ }
+ }
+
+ @Test
+ public void testGetPropertyChar() {
+ try {
+ Method method = JPAEntityParserTestForStaticMethods.class.getMethod("getChar", (Class<?>[]) null);
+ String output = (String) JPAEntityParser.getProperty(method, this);
+ assertEquals("A", output);
+
+ } catch (NoSuchMethodException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ } catch (SecurityException 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);
+ }
+ }
+
+ @Test
+ public void testGetPropertyCharNull() {
+ try {
+ Method method = JPAEntityParserTestForStaticMethods.class.getMethod("getCharNull", (Class<?>[]) null);
+ String output = (String) JPAEntityParser.getProperty(method, this);
+ assertNull(output);
+
+ } catch (NoSuchMethodException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ } catch (SecurityException 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);
+ }
+ }
+
+ @Test
+ public void testGetPropertyCharArray() {
+ try {
+ Method method = JPAEntityParserTestForStaticMethods.class.getMethod("getCharArray", (Class<?>[]) null);
+ String output = (String) JPAEntityParser.getProperty(method, this);
+ assertEquals("AB", output);
+
+ } catch (NoSuchMethodException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ } catch (SecurityException 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);
+ }
+ }
+
+ @Test
+ public void testGetPropertyCharArrayNull() {
+ try {
+ Method method = JPAEntityParserTestForStaticMethods.class.getMethod("getCharArrayNull", (Class<?>[]) null);
+ String output = (String) JPAEntityParser.getProperty(method, this);
+ assertNull(output);
+
+ } catch (NoSuchMethodException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ } catch (SecurityException 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);
+ }
+ }
+
+ @Test
+ public void testGetPropertyCharArrayValueNull() {
+ try {
+ Method method = JPAEntityParserTestForStaticMethods.class.getMethod("getCharArrayValueNull", (Class<?>[]) null);
+ String output = (String) JPAEntityParser.getProperty(method, this);
+ assertEquals("A\u0000", output);
+
+ } catch (NoSuchMethodException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ } catch (SecurityException 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);
+ }
+ }
+
+ public Character getCharacter() {
+ return new Character('A');
+ }
+
+ public Character getCharacterNull() {
+ return null;
+ }
+
+ public Character[] getCharacterArray() {
+ return new Character[] { 'A', 'B' };
+ }
+
+ public Character[] getCharacterArrayNull() {
+ return null;
+ }
+
+ public char getChar() {
+ return 'A';
+ }
+
+ public char getCharNull() {
+ return '\u0000';
+ }
+
+ public char[] getCharArray() {
+ return new char[] { 'A', 'B' };
+ }
+
+ public char[] getCharArrayNull() {
+ return null;
+ }
+
+ public char[] getCharArrayValueNull() {
+ return new char[] { 'A', '\u0000' };
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/access/data/JPAEntityTest.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/access/data/JPAEntityTest.java b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/access/data/JPAEntityTest.java
new file mode 100644
index 0000000..8fbbed9
--- /dev/null
+++ b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/access/data/JPAEntityTest.java
@@ -0,0 +1,187 @@
+/*******************************************************************************
+ * 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.access.data;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import org.apache.olingo.odata2.api.edm.EdmEntitySet;
+import org.apache.olingo.odata2.api.edm.EdmEntityType;
+import org.apache.olingo.odata2.api.edm.EdmException;
+import org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPARuntimeException;
+import org.apache.olingo.odata2.processor.core.jpa.common.ODataJPATestConstants;
+import org.apache.olingo.odata2.processor.core.jpa.mock.data.EdmMockUtilV2;
+import org.apache.olingo.odata2.processor.core.jpa.mock.data.JPATypeMock;
+import org.apache.olingo.odata2.processor.core.jpa.mock.data.JPATypeMock.JPARelatedTypeMock;
+import org.apache.olingo.odata2.processor.core.jpa.mock.data.JPATypeMock.JPATypeEmbeddableMock;
+import org.apache.olingo.odata2.processor.core.jpa.mock.data.JPATypeMock.JPATypeEmbeddableMock2;
+import org.apache.olingo.odata2.processor.core.jpa.mock.data.ODataEntryMockUtil;
+import org.junit.Test;
+
+public class JPAEntityTest {
+
+ private JPAEntity jpaEntity = null;
+
+ @Test
+ public void testCreateODataEntryWithComplexType() {
+ try {
+ EdmEntitySet edmEntitySet = EdmMockUtilV2.mockEdmEntitySet(JPATypeMock.ENTITY_NAME, true);
+ EdmEntityType edmEntityType = edmEntitySet.getEntityType();
+
+ jpaEntity = new JPAEntity(edmEntityType, edmEntitySet);
+ jpaEntity.create(ODataEntryMockUtil.mockODataEntryWithComplexType(JPATypeMock.ENTITY_NAME));
+ } catch (ODataJPARuntimeException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage()
+ + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ } catch (EdmException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage()
+ + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+ JPATypeMock jpaTypeMock = (JPATypeMock) jpaEntity.getJPAEntity();
+ assertEquals(jpaTypeMock.getMInt(), ODataEntryMockUtil.VALUE_MINT);
+ assertEquals(jpaTypeMock.getMString(), ODataEntryMockUtil.VALUE_MSTRING);
+ assertTrue(jpaTypeMock.getMDateTime().equals(ODataEntryMockUtil.VALUE_DATE_TIME));
+ JPATypeEmbeddableMock jpaEmbeddableMock = jpaTypeMock.getComplexType();
+ assertNotNull(jpaEmbeddableMock);
+
+ assertEquals(jpaEmbeddableMock.getMShort(), ODataEntryMockUtil.VALUE_SHORT);
+ JPATypeEmbeddableMock2 jpaEmbeddableMock2 = jpaEmbeddableMock.getMEmbeddable();
+ assertNotNull(jpaEmbeddableMock2);
+ assertEquals(jpaEmbeddableMock2.getMFloat(), ODataEntryMockUtil.VALUE_MFLOAT, 1);
+ assertEquals(jpaEmbeddableMock2.getMUUID(), ODataEntryMockUtil.VALUE_UUID);
+ }
+
+ @Test
+ public void testCreateODataEntry() {
+ try {
+ EdmEntitySet edmEntitySet = EdmMockUtilV2.mockEdmEntitySet(JPATypeMock.ENTITY_NAME, false);
+ EdmEntityType edmEntityType = edmEntitySet.getEntityType();
+
+ jpaEntity = new JPAEntity(edmEntityType, edmEntitySet);
+ jpaEntity.create(ODataEntryMockUtil.mockODataEntry(JPATypeMock.ENTITY_NAME));
+ } catch (ODataJPARuntimeException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage()
+ + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ } catch (EdmException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage()
+ + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+ JPATypeMock jpaTypeMock = (JPATypeMock) jpaEntity.getJPAEntity();
+ assertEquals(jpaTypeMock.getMInt(), ODataEntryMockUtil.VALUE_MINT);
+ assertEquals(jpaTypeMock.getMString(), ODataEntryMockUtil.VALUE_MSTRING);
+ assertTrue(jpaTypeMock.getMDateTime().equals(ODataEntryMockUtil.VALUE_DATE_TIME));
+ }
+
+ @Test
+ public void testCreateODataEntryWithInline() {
+ try {
+ EdmEntitySet edmEntitySet = EdmMockUtilV2.mockEdmEntitySet(JPATypeMock.ENTITY_NAME, false);
+ EdmEntityType edmEntityType = edmEntitySet.getEntityType();
+
+ jpaEntity = new JPAEntity(edmEntityType, edmEntitySet);
+ jpaEntity.create(ODataEntryMockUtil.mockODataEntryWithInline(JPATypeMock.ENTITY_NAME));
+ } catch (ODataJPARuntimeException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage()
+ + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ } catch (EdmException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage()
+ + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+ JPATypeMock jpaTypeMock = (JPATypeMock) jpaEntity.getJPAEntity();
+ assertEquals(jpaTypeMock.getMInt(), ODataEntryMockUtil.VALUE_MINT);
+ assertEquals(jpaTypeMock.getMString(), ODataEntryMockUtil.VALUE_MSTRING);
+ assertTrue(jpaTypeMock.getMDateTime().equals(ODataEntryMockUtil.VALUE_DATE_TIME));
+
+ JPARelatedTypeMock relatedType = jpaTypeMock.getMRelatedEntity();
+ assertNotNull(jpaTypeMock.getMRelatedEntity());
+ assertEquals(relatedType.getMByte(), ODataEntryMockUtil.VALUE_MBYTE);
+ assertEquals(relatedType.getMByteArray(), ODataEntryMockUtil.VALUE_MBYTEARRAY);
+ assertEquals(relatedType.getMDouble(), ODataEntryMockUtil.VALUE_MDOUBLE, 0.0);
+ assertEquals(relatedType.getMLong(), ODataEntryMockUtil.VALUE_MLONG);
+ }
+
+ @Test
+ public void testCreateODataEntryProperty() {
+ try {
+ EdmEntitySet edmEntitySet = EdmMockUtilV2.mockEdmEntitySet(JPATypeMock.ENTITY_NAME, false);
+ EdmEntityType edmEntityType = edmEntitySet.getEntityType();
+
+ jpaEntity = new JPAEntity(edmEntityType, edmEntitySet);
+ jpaEntity.create(ODataEntryMockUtil.mockODataEntryProperties(JPATypeMock.ENTITY_NAME));
+ } catch (ODataJPARuntimeException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage()
+ + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ } catch (EdmException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage()
+ + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+ JPATypeMock jpaTypeMock = (JPATypeMock) jpaEntity.getJPAEntity();
+ assertEquals(jpaTypeMock.getMInt(), ODataEntryMockUtil.VALUE_MINT);
+ assertEquals(jpaTypeMock.getMString(), ODataEntryMockUtil.VALUE_MSTRING);
+ assertTrue(jpaTypeMock.getMDateTime().equals(ODataEntryMockUtil.VALUE_DATE_TIME));
+ }
+
+ @Test
+ public void testUpdateODataEntry() {
+ try {
+ EdmEntitySet edmEntitySet = EdmMockUtilV2.mockEdmEntitySet(JPATypeMock.ENTITY_NAME, false);
+ EdmEntityType edmEntityType = edmEntitySet.getEntityType();
+
+ jpaEntity = new JPAEntity(edmEntityType, edmEntitySet);
+ JPATypeMock jpaTypeMock = new JPATypeMock();
+ jpaEntity.setJPAEntity(jpaTypeMock);
+ jpaEntity.update(ODataEntryMockUtil.mockODataEntry(JPATypeMock.ENTITY_NAME));
+ } catch (ODataJPARuntimeException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage()
+ + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ } catch (EdmException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage()
+ + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+ JPATypeMock jpaTypeMock = (JPATypeMock) jpaEntity.getJPAEntity();
+ assertEquals(jpaTypeMock.getMInt(), 0);// Key should not be changed
+ assertEquals(jpaTypeMock.getMString(), ODataEntryMockUtil.VALUE_MSTRING);
+ assertTrue(jpaTypeMock.getMDateTime().equals(ODataEntryMockUtil.VALUE_DATE_TIME));
+ }
+
+ @Test
+ public void testUpdateODataEntryProperty() {
+ try {
+ EdmEntitySet edmEntitySet = EdmMockUtilV2.mockEdmEntitySet(JPATypeMock.ENTITY_NAME, false);
+ EdmEntityType edmEntityType = edmEntitySet.getEntityType();
+
+ jpaEntity = new JPAEntity(edmEntityType, edmEntitySet);
+ JPATypeMock jpaTypeMock = new JPATypeMock();
+ jpaEntity.setJPAEntity(jpaTypeMock);
+ jpaEntity.update(ODataEntryMockUtil.mockODataEntryProperties(JPATypeMock.ENTITY_NAME));
+ } catch (ODataJPARuntimeException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage()
+ + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ } catch (EdmException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage()
+ + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+ JPATypeMock jpaTypeMock = (JPATypeMock) jpaEntity.getJPAEntity();
+ assertEquals(jpaTypeMock.getMInt(), 0);// Key should not be changed
+ assertEquals(jpaTypeMock.getMString(), ODataEntryMockUtil.VALUE_MSTRING);
+ assertTrue(jpaTypeMock.getMDateTime().equals(ODataEntryMockUtil.VALUE_DATE_TIME));
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/access/data/JPAExpandCallBackTest.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/access/data/JPAExpandCallBackTest.java b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/access/data/JPAExpandCallBackTest.java
new file mode 100644
index 0000000..021c353
--- /dev/null
+++ b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/access/data/JPAExpandCallBackTest.java
@@ -0,0 +1,160 @@
+/*******************************************************************************
+ * 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.access.data;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.olingo.odata2.api.ODataCallback;
+import org.apache.olingo.odata2.api.edm.EdmEntityType;
+import org.apache.olingo.odata2.api.edm.EdmException;
+import org.apache.olingo.odata2.api.edm.EdmNavigationProperty;
+import org.apache.olingo.odata2.api.ep.callback.WriteEntryCallbackContext;
+import org.apache.olingo.odata2.api.ep.callback.WriteEntryCallbackResult;
+import org.apache.olingo.odata2.api.ep.callback.WriteFeedCallbackContext;
+import org.apache.olingo.odata2.api.ep.callback.WriteFeedCallbackResult;
+import org.apache.olingo.odata2.api.uri.ExpandSelectTreeNode;
+import org.apache.olingo.odata2.api.uri.NavigationPropertySegment;
+import org.apache.olingo.odata2.processor.core.jpa.common.ODataJPATestConstants;
+import org.apache.olingo.odata2.processor.core.jpa.mock.data.EdmMockUtil;
+import org.junit.Test;
+
+public class JPAExpandCallBackTest {
+
+ @Test
+ public void testRetrieveEntryResult() {
+ JPAExpandCallBack callBack = getJPAExpandCallBackObject();
+ WriteEntryCallbackContext writeFeedContext = EdmMockUtil.getWriteEntryCallBackContext();
+ try {
+ Field field = callBack.getClass().getDeclaredField("nextEntitySet");
+ field.setAccessible(true);
+ field.set(callBack, EdmMockUtil.mockTargetEntitySet());
+ WriteEntryCallbackResult result = callBack.retrieveEntryResult(writeFeedContext);
+ assertEquals(1, result.getEntryData().size());
+ } catch (SecurityException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ } catch (NoSuchFieldException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ } catch (IllegalArgumentException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ } catch (IllegalAccessException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+ }
+
+ @Test
+ public void testRetrieveFeedResult() {
+ JPAExpandCallBack callBack = getJPAExpandCallBackObject();
+ WriteFeedCallbackContext writeFeedContext = EdmMockUtil.getWriteFeedCallBackContext();
+ try {
+ Field field = callBack.getClass().getDeclaredField("nextEntitySet");
+ field.setAccessible(true);
+ field.set(callBack, EdmMockUtil.mockTargetEntitySet());
+ WriteFeedCallbackResult result = callBack.retrieveFeedResult(writeFeedContext);
+ assertEquals(2, result.getFeedData().size());
+ } catch (SecurityException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ } catch (NoSuchFieldException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ } catch (IllegalArgumentException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ } catch (IllegalAccessException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+ }
+
+ @Test
+ public void testGetCallbacks() {
+ Map<String, ODataCallback> callBacks = null;
+ try {
+ URI baseUri =
+ new URI("http://localhost:8080/org.apache.olingo.odata2.processor.ref.web/SalesOrderProcessing.svc/");
+ ExpandSelectTreeNode expandSelectTreeNode = EdmMockUtil.mockExpandSelectTreeNode();
+ List<ArrayList<NavigationPropertySegment>> expandList = EdmMockUtil.getExpandList();
+ callBacks = JPAExpandCallBack.getCallbacks(baseUri, expandSelectTreeNode, expandList);
+ } catch (URISyntaxException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ } catch (EdmException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+ assertEquals(1, callBacks.size());
+
+ }
+
+ @Test
+ public void testGetNextNavigationProperty() {
+ JPAExpandCallBack callBack = getJPAExpandCallBackObject();
+ List<ArrayList<NavigationPropertySegment>> expandList = EdmMockUtil.getExpandList();
+ ArrayList<NavigationPropertySegment> expands = expandList.get(0);
+ expands.add(EdmMockUtil.mockThirdNavigationPropertySegment());
+ EdmNavigationProperty result = null;
+ try {
+ Field field = callBack.getClass().getDeclaredField("expandList");
+ field.setAccessible(true);
+ field.set(callBack, expandList);
+ Class<?>[] formalParams = { EdmEntityType.class, EdmNavigationProperty.class };
+ Object[] actualParams = { EdmMockUtil.mockSourceEdmEntityType(), EdmMockUtil.mockNavigationProperty() };
+ Method method = callBack.getClass().getDeclaredMethod("getNextNavigationProperty", formalParams);
+ method.setAccessible(true);
+ result = (EdmNavigationProperty) method.invoke(callBack, actualParams);
+ assertEquals("MaterialDetails", result.getName());
+
+ } catch (SecurityException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ } catch (NoSuchFieldException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ } catch (IllegalArgumentException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ } catch (IllegalAccessException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ } catch (NoSuchMethodException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ } catch (InvocationTargetException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ } catch (EdmException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+ }
+
+ private JPAExpandCallBack getJPAExpandCallBackObject() {
+ Map<String, ODataCallback> callBacks = null;
+ try {
+ URI baseUri =
+ new URI("http://localhost:8080/org.apache.olingo.odata2.processor.ref.web/SalesOrderProcessing.svc/");
+ ExpandSelectTreeNode expandSelectTreeNode = EdmMockUtil.mockExpandSelectTreeNode();
+ List<ArrayList<NavigationPropertySegment>> expandList = EdmMockUtil.getExpandList();
+ callBacks = JPAExpandCallBack.getCallbacks(baseUri, expandSelectTreeNode, expandList);
+ } catch (URISyntaxException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ } catch (EdmException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+ return (JPAExpandCallBack) callBacks.get("SalesOrderLineItemDetails");
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/access/data/JPAFunctionContextTest.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/access/data/JPAFunctionContextTest.java b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/access/data/JPAFunctionContextTest.java
new file mode 100644
index 0000000..1b2d7b6
--- /dev/null
+++ b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/access/data/JPAFunctionContextTest.java
@@ -0,0 +1,143 @@
+/*******************************************************************************
+ * 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.access.data;
+
+import static org.junit.Assert.fail;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Map;
+
+import junit.framework.Assert;
+
+import org.apache.olingo.odata2.api.edm.EdmException;
+import org.apache.olingo.odata2.api.edm.EdmFunctionImport;
+import org.apache.olingo.odata2.api.edm.EdmLiteral;
+import org.apache.olingo.odata2.api.edm.EdmMapping;
+import org.apache.olingo.odata2.api.edm.EdmParameter;
+import org.apache.olingo.odata2.api.edm.provider.Mapping;
+import org.apache.olingo.odata2.api.uri.info.GetFunctionImportUriInfo;
+import org.apache.olingo.odata2.processor.api.jpa.access.JPAMethodContext;
+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.jpql.JPQLContextType;
+import org.apache.olingo.odata2.processor.core.jpa.common.ODataJPATestConstants;
+import org.apache.olingo.odata2.processor.core.jpa.model.JPAEdmMappingImpl;
+import org.easymock.EasyMock;
+import org.junit.Test;
+
+public class JPAFunctionContextTest {
+
+ private int VARIANT = 0;
+
+ public JPAFunctionContext build() {
+ JPAFunctionContext functionContext = null;
+ try {
+ if (VARIANT == 0) {
+ functionContext =
+ (JPAFunctionContext) JPAMethodContext.createBuilder(JPQLContextType.FUNCTION, getView()).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);
+ }
+
+ return functionContext;
+ }
+
+ @Test
+ public void testGetEnclosingObject() {
+
+ VARIANT = 0;
+
+ Assert.assertNotNull(build());
+
+ }
+
+ private GetFunctionImportUriInfo getView() {
+ GetFunctionImportUriInfo functiontView = EasyMock.createMock(GetFunctionImportUriInfo.class);
+ EasyMock.expect(functiontView.getFunctionImport()).andStubReturn(getEdmFunctionImport());
+ EasyMock.expect(functiontView.getFunctionImportParameters()).andStubReturn(getFunctionImportParameters());
+
+ EasyMock.replay(functiontView);
+ return functiontView;
+ }
+
+ private Map<String, EdmLiteral> getFunctionImportParameters() {
+ return null;
+ }
+
+ private EdmFunctionImport getEdmFunctionImport() {
+ EdmFunctionImport edmFunctionImport = EasyMock.createMock(EdmFunctionImport.class);
+ try {
+ EasyMock.expect(edmFunctionImport.getMapping()).andStubReturn(getMapping());
+ EasyMock.expect(edmFunctionImport.getParameterNames()).andStubReturn(getParameterNames());
+ EasyMock.expect(edmFunctionImport.getParameter("Gentleman")).andStubReturn(getParameter("Gentleman"));
+ } catch (EdmException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+
+ EasyMock.replay(edmFunctionImport);
+ return edmFunctionImport;
+ }
+
+ private EdmParameter getParameter(final String string) {
+ EdmParameter edmParameter = EasyMock.createMock(EdmParameter.class);
+ try {
+ EasyMock.expect(edmParameter.getMapping()).andStubReturn(getEdmMapping());
+ } catch (EdmException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+ EasyMock.replay(edmParameter);
+ return edmParameter;
+ }
+
+ private EdmMapping getEdmMapping() {
+ JPAEdmMappingImpl mapping = new JPAEdmMappingImpl();
+ mapping.setJPAType(String.class);
+ ((Mapping) mapping).setInternalName("Gentleman");
+ return mapping;
+ }
+
+ private JPAEdmMappingImpl getMapping() {
+ JPAEdmMappingImpl mapping = new JPAEdmMappingImpl();
+ mapping.setJPAType(FunctionImportTestClass.class);
+ ((Mapping) mapping).setInternalName("testMethod");
+ return mapping;
+ }
+
+ private Collection<String> getParameterNames() {
+ Collection<String> parametersList = new ArrayList<String>();
+ parametersList.add("Gentleman");
+ return parametersList;
+ }
+
+ public static class FunctionImportTestClass {
+
+ public FunctionImportTestClass() {
+
+ }
+
+ public String testMethod(final String message) {
+ return "Hello " + message + "!!";
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/access/data/JPAProcessorImplTest.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/access/data/JPAProcessorImplTest.java b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/access/data/JPAProcessorImplTest.java
new file mode 100644
index 0000000..45f0528
--- /dev/null
+++ b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/access/data/JPAProcessorImplTest.java
@@ -0,0 +1,447 @@
+/*******************************************************************************
+ * 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.access.data;
+
+import static org.junit.Assert.fail;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.EntityTransaction;
+import javax.persistence.Query;
+import javax.persistence.metamodel.Metamodel;
+
+import junit.framework.Assert;
+
+import org.apache.olingo.odata2.api.commons.InlineCount;
+import org.apache.olingo.odata2.api.edm.EdmConcurrencyMode;
+import org.apache.olingo.odata2.api.edm.EdmEntityContainer;
+import org.apache.olingo.odata2.api.edm.EdmEntitySet;
+import org.apache.olingo.odata2.api.edm.EdmEntityType;
+import org.apache.olingo.odata2.api.edm.EdmException;
+import org.apache.olingo.odata2.api.edm.EdmFacets;
+import org.apache.olingo.odata2.api.edm.EdmMapping;
+import org.apache.olingo.odata2.api.edm.EdmProperty;
+import org.apache.olingo.odata2.api.edm.EdmType;
+import org.apache.olingo.odata2.api.edm.EdmTypeKind;
+import org.apache.olingo.odata2.api.edm.EdmTyped;
+import org.apache.olingo.odata2.api.exception.ODataException;
+import org.apache.olingo.odata2.api.processor.ODataContext;
+import org.apache.olingo.odata2.api.uri.KeyPredicate;
+import org.apache.olingo.odata2.api.uri.PathInfo;
+import org.apache.olingo.odata2.api.uri.UriInfo;
+import org.apache.olingo.odata2.api.uri.expression.FilterExpression;
+import org.apache.olingo.odata2.api.uri.expression.OrderByExpression;
+import org.apache.olingo.odata2.api.uri.info.DeleteUriInfo;
+import org.apache.olingo.odata2.api.uri.info.GetEntityCountUriInfo;
+import org.apache.olingo.odata2.api.uri.info.GetEntitySetCountUriInfo;
+import org.apache.olingo.odata2.api.uri.info.GetEntitySetUriInfo;
+import org.apache.olingo.odata2.processor.api.jpa.ODataJPAContext;
+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.core.jpa.common.ODataJPATestConstants;
+import org.easymock.EasyMock;
+import org.junit.Before;
+import org.junit.Test;
+
+public class JPAProcessorImplTest {
+
+ // -------------------------------- Common Start ------------------------------------common in
+ // ODataJPAProcessorDefaultTest as well
+ private static final String STR_LOCAL_URI = "http://localhost:8080/org.apache.olingo.odata2.processor.ref.web/";
+ private static final String SALESORDERPROCESSING_CONTAINER = "salesorderprocessingContainer";
+ private static final String SO_ID = "SoId";
+ private static final String SALES_ORDER = "SalesOrder";
+ private static final String SALES_ORDER_HEADERS = "SalesOrderHeaders";
+ // -------------------------------- Common End ------------------------------------
+
+ JPAProcessorImpl objJPAProcessorImpl;
+
+ @Before
+ public void setUp() throws Exception {
+ objJPAProcessorImpl = new JPAProcessorImpl(getLocalmockODataJPAContext());
+ }
+
+ @Test
+ public void testProcessGetEntitySetCountUriInfo() {
+ try {
+ Assert.assertEquals(11, objJPAProcessorImpl.process(getEntitySetCountUriInfo()));
+ } 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);
+ }
+ }
+
+ @Test
+ public void testProcessGetEntityCountUriInfo() {
+ try {
+ Assert.assertEquals(11, objJPAProcessorImpl.process(getEntityCountUriInfo()));
+ } 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);
+ }
+ }
+
+ @Test
+ public void testProcessGetEntitySetUriInfo() {
+ try {
+ Assert.assertNotNull(objJPAProcessorImpl.process(getEntitySetUriInfo()));
+ } 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);
+ }
+ }
+
+ @Test
+ public void testProcessDeleteUriInfo() {
+ try {
+ Assert.assertNotNull(objJPAProcessorImpl.process(getDeletetUriInfo(), "application/xml"));
+ Assert.assertEquals(new Address(), objJPAProcessorImpl.process(getDeletetUriInfo(), "application/xml"));
+ } 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);
+ }
+ }
+
+ @Test
+ public void testProcessDeleteUriInfoNegative() {
+ try {
+ Assert.assertNotNull(objJPAProcessorImpl.process(getDeletetUriInfo(), "application/xml"));
+ Assert.assertNotSame(new Object(), objJPAProcessorImpl.process(getDeletetUriInfo(), "application/xml"));
+ } 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);
+ }
+ }
+
+ // ---------------------------- Common Code Start ---------------- TODO - common in ODataJPAProcessorDefaultTest as
+ // well
+
+ private DeleteUriInfo getDeletetUriInfo() {
+ UriInfo objUriInfo = EasyMock.createMock(UriInfo.class);
+ EasyMock.expect(objUriInfo.getStartEntitySet()).andStubReturn(getLocalEdmEntitySet());
+ EasyMock.expect(objUriInfo.getTargetEntitySet()).andStubReturn(getLocalEdmEntitySet());
+ EasyMock.expect(objUriInfo.getSelect()).andStubReturn(null);
+ EasyMock.expect(objUriInfo.getOrderBy()).andStubReturn(getOrderByExpression());
+ EasyMock.expect(objUriInfo.getTop()).andStubReturn(getTop());
+ EasyMock.expect(objUriInfo.getSkip()).andStubReturn(getSkip());
+ EasyMock.expect(objUriInfo.getInlineCount()).andStubReturn(getInlineCount());
+ EasyMock.expect(objUriInfo.getFilter()).andStubReturn(getFilter());
+ EasyMock.expect(objUriInfo.getKeyPredicates()).andStubReturn(getKeyPredicates());
+ EasyMock.replay(objUriInfo);
+ return objUriInfo;
+ }
+
+ private List<KeyPredicate> getKeyPredicates() {
+ List<KeyPredicate> keyPredicates = new ArrayList<KeyPredicate>();
+ return keyPredicates;
+ }
+
+ private GetEntitySetCountUriInfo getEntitySetCountUriInfo() {
+ return getLocalUriInfo();
+ }
+
+ private GetEntityCountUriInfo getEntityCountUriInfo() {
+ return getLocalUriInfo();
+ }
+
+ private GetEntitySetUriInfo getEntitySetUriInfo() {
+
+ UriInfo objUriInfo = EasyMock.createMock(UriInfo.class);
+ EasyMock.expect(objUriInfo.getStartEntitySet()).andStubReturn(getLocalEdmEntitySet());
+ EasyMock.expect(objUriInfo.getTargetEntitySet()).andStubReturn(getLocalEdmEntitySet());
+ EasyMock.expect(objUriInfo.getSelect()).andStubReturn(null);
+ EasyMock.expect(objUriInfo.getOrderBy()).andStubReturn(getOrderByExpression());
+ EasyMock.expect(objUriInfo.getTop()).andStubReturn(getTop());
+ EasyMock.expect(objUriInfo.getSkip()).andStubReturn(getSkip());
+ EasyMock.expect(objUriInfo.getInlineCount()).andStubReturn(getInlineCount());
+ EasyMock.expect(objUriInfo.getFilter()).andStubReturn(getFilter());
+ // EasyMock.expect(objUriInfo.getFunctionImport()).andStubReturn(getFunctionImport());
+ EasyMock.expect(objUriInfo.getFunctionImport()).andStubReturn(null);
+ EasyMock.replay(objUriInfo);
+ return objUriInfo;
+ }
+
+ /**
+ * @return
+ */
+ private UriInfo getLocalUriInfo() {
+ UriInfo objUriInfo = EasyMock.createMock(UriInfo.class);
+ EasyMock.expect(objUriInfo.getStartEntitySet()).andStubReturn(getLocalEdmEntitySet());
+ EasyMock.expect(objUriInfo.getTargetEntitySet()).andStubReturn(getLocalEdmEntitySet());
+ EasyMock.expect(objUriInfo.getSelect()).andStubReturn(null);
+ EasyMock.expect(objUriInfo.getOrderBy()).andStubReturn(getOrderByExpression());
+ EasyMock.expect(objUriInfo.getTop()).andStubReturn(getTop());
+ EasyMock.expect(objUriInfo.getSkip()).andStubReturn(getSkip());
+ EasyMock.expect(objUriInfo.getInlineCount()).andStubReturn(getInlineCount());
+ EasyMock.expect(objUriInfo.getFilter()).andStubReturn(getFilter());
+ EasyMock.replay(objUriInfo);
+ return objUriInfo;
+ }
+
+ /**
+ * @return
+ * @throws EdmException
+ */
+ private EdmEntitySet getLocalEdmEntitySet() {
+ EdmEntitySet edmEntitySet = EasyMock.createMock(EdmEntitySet.class);
+ try {
+ EasyMock.expect(edmEntitySet.getName()).andStubReturn(SALES_ORDER_HEADERS);
+ EasyMock.expect(edmEntitySet.getEntityContainer()).andStubReturn(getLocalEdmEntityContainer());
+ EasyMock.expect(edmEntitySet.getEntityType()).andStubReturn(getLocalEdmEntityType());
+ EasyMock.replay(edmEntitySet);
+ } catch (EdmException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+ return edmEntitySet;
+ }
+
+ /**
+ * @return
+ * @throws EdmException
+ */
+ private EdmEntityType getLocalEdmEntityType() {
+ EdmEntityType edmEntityType = EasyMock.createMock(EdmEntityType.class);
+ try {
+ EasyMock.expect(edmEntityType.getKeyProperties()).andStubReturn(new ArrayList<EdmProperty>());
+ EasyMock.expect(edmEntityType.getPropertyNames()).andStubReturn(getLocalPropertyNames());
+ EasyMock.expect(edmEntityType.getProperty(SO_ID)).andStubReturn(getEdmTypedMockedObj(SALES_ORDER));
+ EasyMock.expect(edmEntityType.getKind()).andStubReturn(EdmTypeKind.SIMPLE);
+ EasyMock.expect(edmEntityType.getNamespace()).andStubReturn(SALES_ORDER_HEADERS);
+ EasyMock.expect(edmEntityType.getName()).andStubReturn(SALES_ORDER_HEADERS);
+ EasyMock.expect(edmEntityType.hasStream()).andStubReturn(false);
+ EasyMock.expect(edmEntityType.getNavigationPropertyNames()).andStubReturn(new ArrayList<String>());
+ EasyMock.expect(edmEntityType.getKeyPropertyNames()).andStubReturn(new ArrayList<String>());
+ EasyMock.expect(edmEntityType.getMapping()).andStubReturn(getEdmMappingMockedObj(SALES_ORDER));// ID vs Salesorder
+ // ID
+ EasyMock.replay(edmEntityType);
+ } catch (EdmException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+ return edmEntityType;
+ }
+
+ private InlineCount getInlineCount() {
+ return InlineCount.NONE;
+ }
+
+ private FilterExpression getFilter() {
+ return null;
+ }
+
+ private Integer getSkip() {
+ return null;
+ }
+
+ private Integer getTop() {
+ return null;
+ }
+
+ private OrderByExpression getOrderByExpression() {
+ return null;
+ }
+
+ private ODataJPAContext getLocalmockODataJPAContext() {
+ ODataJPAContext odataJPAContext = EasyMock.createMock(ODataJPAContext.class);
+ EasyMock.expect(odataJPAContext.getPersistenceUnitName()).andStubReturn("salesorderprocessing");
+ EasyMock.expect(odataJPAContext.getEntityManagerFactory()).andStubReturn(mockEntityManagerFactory());
+ EasyMock.expect(odataJPAContext.getODataContext()).andStubReturn(getLocalODataContext());
+ EasyMock.expect(odataJPAContext.getEntityManager()).andStubReturn(getLocalEntityManager());
+ EasyMock.replay(odataJPAContext);
+ return odataJPAContext;
+ }
+
+ private EntityManagerFactory mockEntityManagerFactory() {
+ EntityManagerFactory emf = EasyMock.createMock(EntityManagerFactory.class);
+ EasyMock.expect(emf.getMetamodel()).andStubReturn(mockMetaModel());
+ EasyMock.expect(emf.createEntityManager()).andStubReturn(getLocalEntityManager());
+ EasyMock.replay(emf);
+ return emf;
+ }
+
+ public EntityManager getLocalEntityManager() {
+ EntityManager em = EasyMock.createMock(EntityManager.class);
+ EasyMock.expect(em.createQuery("SELECT E1 FROM SalesOrderHeaders E1")).andStubReturn(getQuery());
+ EasyMock.expect(em.createQuery("SELECT COUNT ( E1 ) FROM SalesOrderHeaders E1")).andStubReturn(
+ getQueryForSelectCount());
+ EasyMock.expect(em.getTransaction()).andStubReturn(getLocalTransaction()); // For Delete
+ em.flush();
+ em.flush();
+ Address obj = new Address();
+ em.remove(obj);// testing void method
+ em.remove(obj);// testing void method
+ EasyMock.replay(em);
+ return em;
+ }
+
+ private EntityTransaction getLocalTransaction() {
+ EntityTransaction entityTransaction = EasyMock.createMock(EntityTransaction.class);
+ entityTransaction.begin(); // testing void method
+ entityTransaction.begin(); // testing void method
+ entityTransaction.commit();// testing void method
+ entityTransaction.commit();// testing void method
+ EasyMock.replay(entityTransaction);
+ return entityTransaction;
+ }
+
+ private Query getQuery() {
+ Query query = EasyMock.createMock(Query.class);
+ EasyMock.expect(query.getResultList()).andStubReturn(getResultList());
+ EasyMock.replay(query);
+ return query;
+ }
+
+ private Query getQueryForSelectCount() {
+ Query query = EasyMock.createMock(Query.class);
+ EasyMock.expect(query.getResultList()).andStubReturn(getResultListForSelectCount());
+ EasyMock.replay(query);
+ return query;
+ }
+
+ private List<?> getResultList() {
+ List<Object> list = new ArrayList<Object>();
+ list.add(new Address());
+ return list;
+ }
+
+ private List<?> getResultListForSelectCount() {
+ List<Object> list = new ArrayList<Object>();
+ list.add(new Long(11));
+ return list;
+ }
+
+ private class Address {
+ private String soId = "12";
+
+ public String getSoId() {
+ return soId;
+ }
+
+ @Override
+ public boolean equals(final Object obj) {
+ boolean isEqual = false;
+ if (obj instanceof Address) {
+ isEqual = getSoId().equalsIgnoreCase(((Address) obj).getSoId());//
+ }
+ return isEqual;
+ }
+ }
+
+ private Metamodel mockMetaModel() {
+ Metamodel metaModel = EasyMock.createMock(Metamodel.class);
+ EasyMock.replay(metaModel);
+ return metaModel;
+ }
+
+ private EdmEntityContainer getLocalEdmEntityContainer() {
+ EdmEntityContainer edmEntityContainer = EasyMock.createMock(EdmEntityContainer.class);
+ EasyMock.expect(edmEntityContainer.isDefaultEntityContainer()).andStubReturn(true);
+ try {
+ EasyMock.expect(edmEntityContainer.getName()).andStubReturn(SALESORDERPROCESSING_CONTAINER);
+ } catch (EdmException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+
+ EasyMock.replay(edmEntityContainer);
+ return edmEntityContainer;
+ }
+
+ private EdmTyped getEdmTypedMockedObj(final String propertyName) {
+ EdmProperty mockedEdmProperty = EasyMock.createMock(EdmProperty.class);
+ try {
+ EasyMock.expect(mockedEdmProperty.getMapping()).andStubReturn(getEdmMappingMockedObj(propertyName));
+ EdmType edmType = EasyMock.createMock(EdmType.class);
+ EasyMock.expect(edmType.getKind()).andStubReturn(EdmTypeKind.SIMPLE);
+ EasyMock.replay(edmType);
+ EasyMock.expect(mockedEdmProperty.getName()).andStubReturn("identifier");
+ EasyMock.expect(mockedEdmProperty.getType()).andStubReturn(edmType);
+ EasyMock.expect(mockedEdmProperty.getFacets()).andStubReturn(getEdmFacetsMockedObj());
+
+ EasyMock.replay(mockedEdmProperty);
+ } catch (EdmException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+ return mockedEdmProperty;
+ }
+
+ private EdmFacets getEdmFacetsMockedObj() {
+ EdmFacets facets = EasyMock.createMock(EdmFacets.class);
+ EasyMock.expect(facets.getConcurrencyMode()).andStubReturn(EdmConcurrencyMode.Fixed);
+
+ EasyMock.replay(facets);
+ return facets;
+ }
+
+ private EdmMapping getEdmMappingMockedObj(final String propertyName) {
+ EdmMapping mockedEdmMapping = EasyMock.createMock(EdmMapping.class);
+ if (propertyName.equalsIgnoreCase(SALES_ORDER)) {
+ EasyMock.expect(mockedEdmMapping.getInternalName()).andStubReturn(SALES_ORDER_HEADERS);
+ } else {
+ EasyMock.expect(mockedEdmMapping.getInternalName()).andStubReturn(propertyName);
+ }
+ EasyMock.replay(mockedEdmMapping);
+ return mockedEdmMapping;
+ }
+
+ private List<String> getLocalPropertyNames() {
+ List<String> list = new ArrayList<String>();
+ list.add(SO_ID);
+ return list;
+ }
+
+ private ODataContext getLocalODataContext() {
+ ODataContext objODataContext = EasyMock.createMock(ODataContext.class);
+ try {
+ EasyMock.expect(objODataContext.getPathInfo()).andStubReturn(getLocalPathInfo());
+ } catch (ODataException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+ EasyMock.replay(objODataContext);
+ return objODataContext;
+ }
+
+ private PathInfo getLocalPathInfo() {
+ PathInfo pathInfo = EasyMock.createMock(PathInfo.class);
+ EasyMock.expect(pathInfo.getServiceRoot()).andStubReturn(getLocalURI());
+ EasyMock.replay(pathInfo);
+ return pathInfo;
+ }
+
+ private URI getLocalURI() {
+ URI uri = null;
+ try {
+ uri = new URI(STR_LOCAL_URI);
+ } catch (URISyntaxException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+ return uri;
+ }
+
+ // -------------------------------- Common End ------------------------------------
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/access/model/JPAEdmMappingModelServiceTest.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/access/model/JPAEdmMappingModelServiceTest.java b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/access/model/JPAEdmMappingModelServiceTest.java
new file mode 100644
index 0000000..76ea726
--- /dev/null
+++ b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/access/model/JPAEdmMappingModelServiceTest.java
@@ -0,0 +1,213 @@
+/*******************************************************************************
+ * 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.access.model;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+import java.io.InputStream;
+
+import org.apache.olingo.odata2.processor.core.jpa.mock.ODataJPAContextMock;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class JPAEdmMappingModelServiceTest extends JPAEdmMappingModelService {
+
+ private static JPAEdmMappingModelServiceTest objJPAEdmMappingModelServiceTest;
+
+ private static final String MAPPING_FILE_CORRECT = "SalesOrderProcessingMappingModels.xml";
+ private static final String MAPPING_FILE_INCORRECT = "TEST.xml";
+
+ private static int VARIANT_MAPPING_FILE; // 0 FOR INCORRECT, 1 FOR CORRECT
+
+ private static String PERSISTENCE_UNIT_NAME_JPA = "salesorderprocessing";
+ private static String PERSISTENCE_UNIT_NAME_EDM = "SalesOrderProcessing";
+
+ private static String ENTITY_TYPE_NAME_JPA = "SalesOrderHeader";
+ private static String ENTITY_TYPE_NAME_EDM = "SalesOrder";
+ private static String ENTITY_SET_NAME_EDM = "SalesOrders";
+ private static String RELATIONSHIP_NAME_JPA = "salesOrderItems";
+ private static String RELATIONSHIP_NAME_EDM = "SalesOrderItemDetails";
+ private static String ATTRIBUTE_NAME_JPA = "netAmount";
+ private static String ATTRIBUTE_NAME_EDM = "NetAmount";
+ private static String EMBEDDABLE_TYPE_NAME_JPA = "SalesOrderItemKey";
+ private static String EMBEDDABLE_ATTRIBUTE_NAME_JPA = "liId";
+ private static String EMBEDDABLE_ATTRIBUTE_NAME_EDM = "ID";
+ private static String EMBEDDABLE_TYPE_2_NAME_JPA = "SalesOrderItemKey";
+
+ private static String ENTITY_TYPE_NAME_JPA_WRONG = "SalesOrderHeaders";
+ private static String RELATIONSHIP_NAME_JPA_WRONG = "value";
+ private static String EMBEDDABLE_TYPE_NAME_JPA_WRONG = "SalesOrderItemKeys";
+
+ public JPAEdmMappingModelServiceTest() {
+ super(ODataJPAContextMock.mockODataJPAContext());
+ }
+
+ @BeforeClass
+ public static void setup() {
+ objJPAEdmMappingModelServiceTest = new JPAEdmMappingModelServiceTest();
+ VARIANT_MAPPING_FILE = 1;
+ objJPAEdmMappingModelServiceTest.loadMappingModel();
+ }
+
+ @Test
+ public void testLoadMappingModel() {
+ VARIANT_MAPPING_FILE = 1;
+ loadMappingModel();
+ assertTrue(isMappingModelExists());
+ }
+
+ @Test
+ public void testLoadMappingModelNegative() {
+ VARIANT_MAPPING_FILE = 0;
+ loadMappingModel();
+ assertFalse(isMappingModelExists());
+ // reset it for other JUnits
+ VARIANT_MAPPING_FILE = 1;
+ loadMappingModel();
+ }
+
+ @Test
+ public void testIsMappingModelExists() {
+ assertTrue(objJPAEdmMappingModelServiceTest.isMappingModelExists());
+ }
+
+ @Test
+ public void testGetJPAEdmMappingModel() {
+ assertNotNull(objJPAEdmMappingModelServiceTest.getJPAEdmMappingModel());
+ }
+
+ @Test
+ public void testMapJPAPersistenceUnit() {
+ assertEquals(PERSISTENCE_UNIT_NAME_EDM, objJPAEdmMappingModelServiceTest
+ .mapJPAPersistenceUnit(PERSISTENCE_UNIT_NAME_JPA));
+ }
+
+ @Test
+ public void testMapJPAPersistenceUnitNegative() {
+ assertNull(objJPAEdmMappingModelServiceTest.mapJPAPersistenceUnit(PERSISTENCE_UNIT_NAME_EDM));// Wrong value to
+ // bring null
+ }
+
+ @Test
+ public void testMapJPAEntityType() {
+ assertEquals(ENTITY_TYPE_NAME_EDM, objJPAEdmMappingModelServiceTest.mapJPAEntityType(ENTITY_TYPE_NAME_JPA));
+ }
+
+ @Test
+ public void testMapJPAEntityTypeNegative() {
+ assertNull(objJPAEdmMappingModelServiceTest.mapJPAEntityType(ENTITY_TYPE_NAME_JPA_WRONG));// Wrong value to bring
+ // null
+ }
+
+ @Test
+ public void testMapJPAEntitySet() {
+ assertEquals(ENTITY_SET_NAME_EDM, objJPAEdmMappingModelServiceTest.mapJPAEntitySet(ENTITY_TYPE_NAME_JPA));
+ }
+
+ @Test
+ public void testMapJPAEntitySetNegative() {
+ assertNull(objJPAEdmMappingModelServiceTest.mapJPAEntitySet(ENTITY_TYPE_NAME_JPA_WRONG));// Wrong value to bring
+ // null
+ }
+
+ @Test
+ public void testMapJPAAttribute() {
+ assertEquals(ATTRIBUTE_NAME_EDM, objJPAEdmMappingModelServiceTest.mapJPAAttribute(ENTITY_TYPE_NAME_JPA,
+ ATTRIBUTE_NAME_JPA));
+ }
+
+ @Test
+ public void testMapJPAAttributeNegative() {
+ // Wrong value to bring null
+ assertNull(objJPAEdmMappingModelServiceTest.mapJPAAttribute(ENTITY_TYPE_NAME_JPA, ATTRIBUTE_NAME_JPA + "AA"));
+ }
+
+ @Test
+ public void testMapJPARelationship() {
+ assertEquals(RELATIONSHIP_NAME_EDM, objJPAEdmMappingModelServiceTest.mapJPARelationship(ENTITY_TYPE_NAME_JPA,
+ RELATIONSHIP_NAME_JPA));
+ }
+
+ @Test
+ public void testMapJPARelationshipNegative() {
+ // Wrong value to bring null
+ assertNull(objJPAEdmMappingModelServiceTest.mapJPARelationship(ENTITY_TYPE_NAME_JPA, RELATIONSHIP_NAME_JPA_WRONG));
+ }
+
+ @Test
+ public void testMapJPAEmbeddableType() {
+ assertEquals("SalesOrderLineItemKey", objJPAEdmMappingModelServiceTest.mapJPAEmbeddableType("SalesOrderItemKey"));
+ }
+
+ @Test
+ public void testMapJPAEmbeddableTypeNegative() {
+ assertNull(objJPAEdmMappingModelServiceTest.mapJPAEmbeddableType(EMBEDDABLE_TYPE_NAME_JPA_WRONG));// Wrong value to
+ // bring null
+ }
+
+ @Test
+ public void testMapJPAEmbeddableTypeAttribute() {
+ assertEquals(EMBEDDABLE_ATTRIBUTE_NAME_EDM, objJPAEdmMappingModelServiceTest.mapJPAEmbeddableTypeAttribute(
+ EMBEDDABLE_TYPE_NAME_JPA, EMBEDDABLE_ATTRIBUTE_NAME_JPA));
+ }
+
+ @Test
+ public void testMapJPAEmbeddableTypeAttributeNegative() {
+ assertNull(objJPAEdmMappingModelServiceTest.mapJPAEmbeddableTypeAttribute(EMBEDDABLE_TYPE_NAME_JPA_WRONG,
+ EMBEDDABLE_ATTRIBUTE_NAME_JPA));
+ }
+
+ @Test
+ public void testCheckExclusionOfJPAEntityType() {
+ assertTrue(!objJPAEdmMappingModelServiceTest.checkExclusionOfJPAEntityType(ENTITY_TYPE_NAME_JPA));
+ }
+
+ @Test
+ public void testCheckExclusionOfJPAAttributeType() {
+ assertTrue(!objJPAEdmMappingModelServiceTest.checkExclusionOfJPAAttributeType(ENTITY_TYPE_NAME_JPA,
+ ATTRIBUTE_NAME_JPA));
+ }
+
+ @Test
+ public void testCheckExclusionOfJPAEmbeddableType() {
+ assertTrue(!objJPAEdmMappingModelServiceTest.checkExclusionOfJPAEmbeddableType(EMBEDDABLE_TYPE_2_NAME_JPA));
+ }
+
+ @Test
+ public void testCheckExclusionOfJPAEmbeddableAttributeType() {
+ assertTrue(!objJPAEdmMappingModelServiceTest.checkExclusionOfJPAEmbeddableAttributeType(EMBEDDABLE_TYPE_NAME_JPA,
+ EMBEDDABLE_ATTRIBUTE_NAME_JPA));
+ }
+
+ /**
+ * This method is for loading the xml file for testing.
+ */
+ @Override
+ protected InputStream loadMappingModelInputStream() {
+ if (VARIANT_MAPPING_FILE == 1) {
+ return ClassLoader.getSystemResourceAsStream(MAPPING_FILE_CORRECT);
+ } else {
+ return ClassLoader.getSystemResourceAsStream(MAPPING_FILE_INCORRECT);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/access/model/JPAEdmNameBuilderTest.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/access/model/JPAEdmNameBuilderTest.java b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/access/model/JPAEdmNameBuilderTest.java
new file mode 100644
index 0000000..3808909
--- /dev/null
+++ b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/access/model/JPAEdmNameBuilderTest.java
@@ -0,0 +1,151 @@
+/*******************************************************************************
+ * 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.access.model;
+
+import static org.junit.Assert.assertEquals;
+
+import org.apache.olingo.odata2.api.edm.provider.ComplexProperty;
+import org.apache.olingo.odata2.api.edm.provider.SimpleProperty;
+import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmComplexPropertyView;
+import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmEntityTypeView;
+import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmPropertyView;
+import org.apache.olingo.odata2.processor.core.jpa.ODataJPAContextImpl;
+import org.apache.olingo.odata2.processor.core.jpa.mock.model.JPAAttributeMock;
+import org.apache.olingo.odata2.processor.core.jpa.mock.model.JPAEntityTypeMock;
+import org.easymock.EasyMock;
+import org.junit.Test;
+
+public class JPAEdmNameBuilderTest {
+
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ @Test
+ public void testBuildJPAEdmPropertyView() {
+
+ SimpleProperty simpleProperty = new SimpleProperty();
+
+ // Mocking EDMProperty
+ JPAEdmPropertyView propertyView = EasyMock.createMock(JPAEdmPropertyView.class);
+ JPAEdmEntityTypeView entityTypeView = EasyMock.createMock(JPAEdmEntityTypeView.class);
+
+ EasyMock.expect(propertyView.getJPAAttribute()).andStubReturn(new JPAAttribute());
+ EasyMock.expect(propertyView.getJPAEdmEntityTypeView()).andStubReturn(entityTypeView);
+ EasyMock.expect(propertyView.getJPAEdmMappingModelAccess()).andStubReturn(null);
+ EasyMock.expect(propertyView.getEdmSimpleProperty()).andStubReturn(simpleProperty);
+ EasyMock.replay(propertyView);
+
+ JPAEdmNameBuilder.build(propertyView, false, false);
+ assertEquals("Id", simpleProperty.getName());
+ }
+
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ @Test
+ public void testBuildJPAEdmPropertyViewWithNoDefaultNaming() {
+
+ SimpleProperty simpleProperty = new SimpleProperty();
+
+ // Mocking EDMProperty
+ JPAEdmPropertyView propertyView = EasyMock.createMock(JPAEdmPropertyView.class);
+ JPAEdmEntityTypeView entityTypeView = EasyMock.createMock(JPAEdmEntityTypeView.class);
+
+ EasyMock.expect(propertyView.getJPAAttribute()).andStubReturn(new JPAAttribute());
+ EasyMock.expect(propertyView.getJPAEdmEntityTypeView()).andStubReturn(entityTypeView);
+ EasyMock.expect(propertyView.getJPAEdmMappingModelAccess()).andStubReturn(null);
+ EasyMock.expect(propertyView.getEdmSimpleProperty()).andStubReturn(simpleProperty);
+ EasyMock.replay(propertyView);
+
+ JPAEdmNameBuilder.build(propertyView, false, true);
+ assertEquals("id", simpleProperty.getName());
+ }
+
+ @SuppressWarnings({ "rawtypes", "unchecked" })
+ @Test
+ public void testBuildJPAEdmComplexPropertyView() {
+ JPAEdmComplexPropertyView complexPropertyView = EasyMock.createMock(JPAEdmComplexPropertyView.class);
+ ComplexProperty complexProperty = new ComplexProperty();
+ EasyMock.expect(complexPropertyView.getEdmComplexProperty()).andStubReturn(complexProperty);
+ ODataJPAContextImpl oDataJPAContext = new ODataJPAContextImpl();
+ JPAEdmMappingModelService mappingModelService = new JPAEdmMappingModelService(oDataJPAContext);
+ EasyMock.expect(complexPropertyView.getJPAEdmMappingModelAccess()).andStubReturn(mappingModelService);
+
+ // Mocking EDMProperty
+ JPAEdmPropertyView propertyView = EasyMock.createMock(JPAEdmPropertyView.class);
+ JPAEdmEntityTypeView entityTypeView = EasyMock.createMock(JPAEdmEntityTypeView.class);
+ EasyMock.expect(entityTypeView.getJPAEntityType()).andStubReturn(new JPAEntityType());
+ EasyMock.replay(entityTypeView);
+ EasyMock.expect(propertyView.getJPAAttribute()).andStubReturn(new JPAAttribute());
+ EasyMock.expect(propertyView.getJPAEdmEntityTypeView()).andStubReturn(entityTypeView);
+ EasyMock.replay(complexPropertyView);
+ EasyMock.replay(propertyView);
+
+ JPAEdmNameBuilder.build(complexPropertyView, propertyView, false);
+ assertEquals("Id", complexPropertyView.getEdmComplexProperty().getName());
+
+ }
+
+ @SuppressWarnings({ "rawtypes", "unchecked" })
+ @Test
+ public void testBuildJPAEdmComplexPropertyViewWithNoDefaultNaming() {
+ JPAEdmComplexPropertyView complexPropertyView = EasyMock.createMock(JPAEdmComplexPropertyView.class);
+ ComplexProperty complexProperty = new ComplexProperty();
+ EasyMock.expect(complexPropertyView.getEdmComplexProperty()).andStubReturn(complexProperty);
+ ODataJPAContextImpl oDataJPAContext = new ODataJPAContextImpl();
+ JPAEdmMappingModelService mappingModelService = new JPAEdmMappingModelService(oDataJPAContext);
+ EasyMock.expect(complexPropertyView.getJPAEdmMappingModelAccess()).andStubReturn(mappingModelService);
+
+ // Mocking EDMProperty
+ JPAEdmPropertyView propertyView = EasyMock.createMock(JPAEdmPropertyView.class);
+ JPAEdmEntityTypeView entityTypeView = EasyMock.createMock(JPAEdmEntityTypeView.class);
+ EasyMock.expect(entityTypeView.getJPAEntityType()).andStubReturn(new JPAEntityType());
+ EasyMock.replay(entityTypeView);
+ EasyMock.expect(propertyView.getJPAAttribute()).andStubReturn(new JPAAttribute());
+ EasyMock.expect(propertyView.getJPAEdmEntityTypeView()).andStubReturn(entityTypeView);
+ EasyMock.replay(complexPropertyView);
+ EasyMock.replay(propertyView);
+
+ JPAEdmNameBuilder.build(complexPropertyView, propertyView, true);
+ assertEquals("id", complexPropertyView.getEdmComplexProperty().getName());
+
+ }
+
+ @SuppressWarnings("hiding")
+ class JPAAttribute<Object, String> extends JPAAttributeMock<Object, java.lang.String> {
+
+ @Override
+ public java.lang.String getName() {
+ return "id";
+ }
+
+ @Override
+ public Class<java.lang.String> getJavaType() {
+ return java.lang.String.class;
+ }
+
+ }
+
+ @SuppressWarnings("hiding")
+ class JPAEntityType<Object> extends JPAEntityTypeMock<Object> {
+
+ @Override
+ public java.lang.String getName() {
+ return "SalesOrderHeader";
+ }
+
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/access/model/JPATypeConvertorTest.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/access/model/JPATypeConvertorTest.java b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/access/model/JPATypeConvertorTest.java
new file mode 100644
index 0000000..3a4057f
--- /dev/null
+++ b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/access/model/JPATypeConvertorTest.java
@@ -0,0 +1,94 @@
+/*******************************************************************************
+ * 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.access.model;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
+import java.math.BigDecimal;
+import java.util.UUID;
+
+import org.apache.olingo.odata2.api.edm.EdmSimpleTypeKind;
+import org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPAModelException;
+import org.apache.olingo.odata2.processor.core.jpa.common.ODataJPATestConstants;
+import org.junit.Test;
+
+public class JPATypeConvertorTest {
+
+ private EdmSimpleTypeKind edmSimpleKindTypeString;
+ private EdmSimpleTypeKind edmSimpleKindTypeByteArr;
+ private EdmSimpleTypeKind edmSimpleKindTypeLong;
+ private EdmSimpleTypeKind edmSimpleKindTypeShort;
+ private EdmSimpleTypeKind edmSimpleKindTypeInteger;
+ private EdmSimpleTypeKind edmSimpleKindTypeDouble;
+ private EdmSimpleTypeKind edmSimpleKindTypeFloat;
+ private EdmSimpleTypeKind edmSimpleKindTypeBigDecimal;
+ private EdmSimpleTypeKind edmSimpleKindTypeByte;
+ private EdmSimpleTypeKind edmSimpleKindTypeBoolean;
+ private EdmSimpleTypeKind edmSimpleKindTypeUUID;
+
+ @Test
+ public void testConvertToEdmSimpleType() {
+ String str = "entity";
+ byte[] byteArr = new byte[3];
+ Long longObj = new Long(0);
+ Short shortObj = new Short((short) 0);
+ Integer integerObj = new Integer(0);
+ Double doubleObj = new Double(0);
+ Float floatObj = new Float(0);
+ BigDecimal bigDecimalObj = new BigDecimal(0);
+ Byte byteObj = new Byte((byte) 0);
+ Boolean booleanObj = Boolean.TRUE;
+ UUID uUID = new UUID(0, 0);
+
+ try {
+ edmSimpleKindTypeString = JPATypeConvertor.convertToEdmSimpleType(str.getClass(), null);
+ edmSimpleKindTypeByteArr = JPATypeConvertor.convertToEdmSimpleType(byteArr.getClass(), null);
+ edmSimpleKindTypeLong = JPATypeConvertor.convertToEdmSimpleType(longObj.getClass(), null);
+ edmSimpleKindTypeShort = JPATypeConvertor.convertToEdmSimpleType(shortObj.getClass(), null);
+ edmSimpleKindTypeInteger = JPATypeConvertor.convertToEdmSimpleType(integerObj.getClass(), null);
+ edmSimpleKindTypeDouble = JPATypeConvertor.convertToEdmSimpleType(doubleObj.getClass(), null);
+ edmSimpleKindTypeFloat = JPATypeConvertor.convertToEdmSimpleType(floatObj.getClass(), null);
+ edmSimpleKindTypeBigDecimal = JPATypeConvertor.convertToEdmSimpleType(bigDecimalObj.getClass(), null);
+ edmSimpleKindTypeByte = JPATypeConvertor.convertToEdmSimpleType(byteObj.getClass(), null);
+ edmSimpleKindTypeBoolean = JPATypeConvertor.convertToEdmSimpleType(booleanObj.getClass(), null);
+ /*
+ * edmSimpleKindTypeDate = JPATypeConvertor
+ * .convertToEdmSimpleType(dateObj.getClass(),null);
+ */
+ edmSimpleKindTypeUUID = JPATypeConvertor.convertToEdmSimpleType(uUID.getClass(), null);
+ } catch (ODataJPAModelException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+
+ assertEquals(EdmSimpleTypeKind.String, edmSimpleKindTypeString);
+ assertEquals(EdmSimpleTypeKind.Binary, edmSimpleKindTypeByteArr);
+ assertEquals(EdmSimpleTypeKind.Int64, edmSimpleKindTypeLong);
+ assertEquals(EdmSimpleTypeKind.Int16, edmSimpleKindTypeShort);
+ assertEquals(EdmSimpleTypeKind.Int32, edmSimpleKindTypeInteger);
+ assertEquals(EdmSimpleTypeKind.Double, edmSimpleKindTypeDouble);
+ assertEquals(EdmSimpleTypeKind.Single, edmSimpleKindTypeFloat);
+ assertEquals(EdmSimpleTypeKind.Decimal, edmSimpleKindTypeBigDecimal);
+ assertEquals(EdmSimpleTypeKind.Byte, edmSimpleKindTypeByte);
+ assertEquals(EdmSimpleTypeKind.Boolean, edmSimpleKindTypeBoolean);
+ // assertEquals(EdmSimpleTypeKind.DateTime, edmSimpleKindTypeDate);
+ assertEquals(EdmSimpleTypeKind.Guid, edmSimpleKindTypeUUID);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/common/ODataJPATestConstants.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/common/ODataJPATestConstants.java b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/common/ODataJPATestConstants.java
new file mode 100644
index 0000000..cd6caee
--- /dev/null
+++ b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/common/ODataJPATestConstants.java
@@ -0,0 +1,27 @@
+/*******************************************************************************
+ * 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.common;
+
+public final class ODataJPATestConstants {
+
+ public static final String EXCEPTION_MSG_PART_1 = "Exception [ ";
+ public static final String EXCEPTION_MSG_PART_2 = " ] not expected";
+ public static final String EMPTY_STRING = "gwt1";
+ public static final String EXCEPTION_EXPECTED = "Exception expected";
+}
[24/37] [OLINGO-82] Renamed the project folder name to
odata2-jpa-processor
Posted by ch...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/data/ODataEntryMockUtil.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/data/ODataEntryMockUtil.java b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/data/ODataEntryMockUtil.java
new file mode 100644
index 0000000..609017b
--- /dev/null
+++ b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/data/ODataEntryMockUtil.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.processor.core.jpa.mock.data;
+
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.TimeZone;
+import java.util.UUID;
+
+import org.apache.olingo.odata2.api.ep.entry.ODataEntry;
+import org.apache.olingo.odata2.api.ep.feed.ODataFeed;
+import org.apache.olingo.odata2.processor.core.jpa.mock.data.JPATypeMock.JPARelatedTypeMock;
+import org.apache.olingo.odata2.processor.core.jpa.mock.data.JPATypeMock.JPATypeEmbeddableMock;
+import org.apache.olingo.odata2.processor.core.jpa.mock.data.JPATypeMock.JPATypeEmbeddableMock2;
+import org.easymock.EasyMock;
+
+public class ODataEntryMockUtil {
+
+ public static final int VALUE_MINT = 20;
+ public static Calendar VALUE_DATE_TIME = null;
+ public static final String VALUE_MSTRING = "Mock";
+ public static final long VALUE_MLONG = 1234567890L;
+ public static final double VALUE_MDOUBLE = 20.12;
+ public static final byte VALUE_MBYTE = 0XA;
+ public static final byte[] VALUE_MBYTEARRAY = { 0XA, 0XB };
+ public static final float VALUE_MFLOAT = 2.00F;
+ public static final UUID VALUE_UUID = UUID.fromString("38400000-8cf0-11bd-b23e-10b96e4ef00d");
+ public static final short VALUE_SHORT = 2;
+
+ public static ODataEntry mockODataEntry(final String entityName) {
+ ODataEntry oDataEntry = EasyMock.createMock(ODataEntry.class);
+ EasyMock.expect(oDataEntry.getProperties()).andReturn(mockODataEntryProperties(entityName)).anyTimes();
+
+ EasyMock.expect(oDataEntry.containsInlineEntry()).andReturn(false);
+ EasyMock.replay(oDataEntry);
+ return oDataEntry;
+ }
+
+ public static ODataEntry mockODataEntryWithComplexType(final String entityName) {
+ ODataEntry oDataEntry = EasyMock.createMock(ODataEntry.class);
+ EasyMock.expect(oDataEntry.getProperties()).andReturn(mockODataEntryPropertiesWithComplexType(entityName))
+ .anyTimes();
+
+ EasyMock.expect(oDataEntry.containsInlineEntry()).andReturn(false);
+ EasyMock.replay(oDataEntry);
+ return oDataEntry;
+ }
+
+ public static Map<String, Object> mockODataEntryProperties(final String entityName) {
+ Map<String, Object> propertyMap = new HashMap<String, Object>();
+
+ if (entityName.equals(JPATypeMock.ENTITY_NAME)) {
+ propertyMap.put(JPATypeMock.PROPERTY_NAME_MINT, VALUE_MINT);
+
+ VALUE_DATE_TIME = Calendar.getInstance(TimeZone.getDefault());
+ VALUE_DATE_TIME.set(2013, 1, 1, 1, 1, 1);
+ propertyMap.put(JPATypeMock.PROPERTY_NAME_MDATETIME, VALUE_DATE_TIME);
+
+ propertyMap.put(JPATypeMock.PROPERTY_NAME_MSTRING, VALUE_MSTRING);
+ } else if (entityName.equals(JPARelatedTypeMock.ENTITY_NAME)) {
+ propertyMap.put(JPARelatedTypeMock.PROPERTY_NAME_MLONG, VALUE_MLONG);
+ propertyMap.put(JPARelatedTypeMock.PROPERTY_NAME_MDOUBLE, VALUE_MDOUBLE);
+ propertyMap.put(JPARelatedTypeMock.PROPERTY_NAME_MBYTE, VALUE_MBYTE);
+ propertyMap.put(JPARelatedTypeMock.PROPERTY_NAME_MBYTEARRAY, VALUE_MBYTEARRAY);
+ } else if (entityName.equals(JPATypeEmbeddableMock.ENTITY_NAME)) {
+ propertyMap.put(JPATypeEmbeddableMock.PROPERTY_NAME_MSHORT, VALUE_SHORT);
+ propertyMap.put(JPATypeEmbeddableMock.PROPERTY_NAME_MEMBEDDABLE,
+ mockODataEntryProperties(JPATypeEmbeddableMock2.ENTITY_NAME));
+ } else if (entityName.equals(JPATypeEmbeddableMock2.ENTITY_NAME)) {
+ propertyMap.put(JPATypeEmbeddableMock2.PROPERTY_NAME_MFLOAT, VALUE_MFLOAT);
+ propertyMap.put(JPATypeEmbeddableMock2.PROPERTY_NAME_MUUID, VALUE_UUID);
+ }
+
+ return propertyMap;
+ }
+
+ public static Map<String, Object> mockODataEntryPropertiesWithComplexType(final String entityName) {
+ Map<String, Object> propertyMap = mockODataEntryProperties(entityName);
+ propertyMap
+ .put(JPATypeMock.PROPERTY_NAME_MCOMPLEXTYPE, mockODataEntryProperties(JPATypeEmbeddableMock.ENTITY_NAME));
+ return propertyMap;
+ }
+
+ public static Map<String, Object> mockODataEntryPropertiesWithInline(final String entityName) {
+ Map<String, Object> propertyMap = mockODataEntryProperties(entityName);
+ List<ODataEntry> relatedEntries = new ArrayList<ODataEntry>();
+ relatedEntries.add(mockODataEntry(JPARelatedTypeMock.ENTITY_NAME));
+ ODataFeed feed = EasyMock.createMock(ODataFeed.class);
+ EasyMock.expect(feed.getEntries()).andReturn(relatedEntries);
+ EasyMock.replay(feed);
+ propertyMap.put(JPATypeMock.NAVIGATION_PROPERTY_X, feed);
+
+ return propertyMap;
+
+ }
+
+ public static ODataEntry mockODataEntryWithInline(final String entityName) {
+ ODataEntry oDataEntry = EasyMock.createMock(ODataEntry.class);
+ EasyMock.expect(oDataEntry.getProperties()).andReturn(mockODataEntryPropertiesWithInline(entityName)).anyTimes();
+ if (entityName.equals(JPATypeMock.ENTITY_NAME)) {
+ EasyMock.expect(oDataEntry.containsInlineEntry()).andReturn(true);
+ } else {
+ EasyMock.expect(oDataEntry.containsInlineEntry()).andReturn(false);
+ }
+ EasyMock.replay(oDataEntry);
+ return oDataEntry;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/data/SalesOrderHeader.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/data/SalesOrderHeader.java b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/data/SalesOrderHeader.java
new file mode 100644
index 0000000..c54411e
--- /dev/null
+++ b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/data/SalesOrderHeader.java
@@ -0,0 +1,63 @@
+/*******************************************************************************
+ * 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.data;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class SalesOrderHeader {
+
+ private int id;
+ private String description;
+
+ public SalesOrderHeader() {}
+
+ public SalesOrderHeader(final int id, final String description) {
+ super();
+ this.id = id;
+ this.description = description;
+ }
+
+ private List<SalesOrderLineItem> salesOrderLineItems = new ArrayList<SalesOrderLineItem>();
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(final String description) {
+ this.description = description;
+ }
+
+ public int getId() {
+ return id;
+ }
+
+ public void setId(final int id) {
+ this.id = id;
+ }
+
+ public List<SalesOrderLineItem> getSalesOrderLineItems() {
+ return salesOrderLineItems;
+ }
+
+ public void setSalesOrderLineItems(final List<SalesOrderLineItem> salesOrderLineItems) {
+ this.salesOrderLineItems = salesOrderLineItems;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/data/SalesOrderLineItem.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/data/SalesOrderLineItem.java b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/data/SalesOrderLineItem.java
new file mode 100644
index 0000000..ba9c09a
--- /dev/null
+++ b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/data/SalesOrderLineItem.java
@@ -0,0 +1,38 @@
+/*******************************************************************************
+ * 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.data;
+
+public class SalesOrderLineItem {
+
+ private int price;
+
+ public SalesOrderLineItem(final int price) {
+ super();
+ this.price = price;
+ }
+
+ public int getPrice() {
+ return price;
+ }
+
+ public void setPrice(final int price) {
+ this.price = price;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/data/SalesOrderLineItemKey.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/data/SalesOrderLineItemKey.java b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/data/SalesOrderLineItemKey.java
new file mode 100644
index 0000000..d8b7ee3
--- /dev/null
+++ b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/data/SalesOrderLineItemKey.java
@@ -0,0 +1,52 @@
+/*******************************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ ******************************************************************************/
+package org.apache.olingo.odata2.processor.core.jpa.mock.data;
+
+public class SalesOrderLineItemKey {
+
+ private int soId;
+ private int liId;
+
+ public SalesOrderLineItemKey() {
+
+ }
+
+ public SalesOrderLineItemKey(final int soId, final int liId) {
+ super();
+ this.soId = soId;
+ this.liId = liId;
+ }
+
+ public int getSoId() {
+ return soId;
+ }
+
+ public void setSoId(final int soId) {
+ this.soId = soId;
+ }
+
+ public int getLiId() {
+ return liId;
+ }
+
+ public void setLiId(final int liId) {
+ this.liId = liId;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/EdmSchemaMock.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/EdmSchemaMock.java b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/EdmSchemaMock.java
new file mode 100644
index 0000000..879c2c2
--- /dev/null
+++ b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/EdmSchemaMock.java
@@ -0,0 +1,213 @@
+/*******************************************************************************
+ * 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.edm.EdmMultiplicity;
+import org.apache.olingo.odata2.api.edm.EdmSimpleTypeKind;
+import org.apache.olingo.odata2.api.edm.FullQualifiedName;
+import org.apache.olingo.odata2.api.edm.provider.Association;
+import org.apache.olingo.odata2.api.edm.provider.AssociationEnd;
+import org.apache.olingo.odata2.api.edm.provider.AssociationSet;
+import org.apache.olingo.odata2.api.edm.provider.AssociationSetEnd;
+import org.apache.olingo.odata2.api.edm.provider.ComplexType;
+import org.apache.olingo.odata2.api.edm.provider.EntityContainer;
+import org.apache.olingo.odata2.api.edm.provider.EntitySet;
+import org.apache.olingo.odata2.api.edm.provider.EntityType;
+import org.apache.olingo.odata2.api.edm.provider.FunctionImport;
+import org.apache.olingo.odata2.api.edm.provider.Key;
+import org.apache.olingo.odata2.api.edm.provider.Mapping;
+import org.apache.olingo.odata2.api.edm.provider.Property;
+import org.apache.olingo.odata2.api.edm.provider.PropertyRef;
+import org.apache.olingo.odata2.api.edm.provider.Schema;
+import org.apache.olingo.odata2.api.edm.provider.SimpleProperty;
+import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmMapping;
+import org.apache.olingo.odata2.processor.core.jpa.model.JPAEdmMappingImpl;
+
+public class EdmSchemaMock {
+
+ private static final String ASSOCIATION_ROLE_NAME_ONE = "SalesOrderHeader";
+ private static final String ASSOCIATION_NAME = "SalesOrderHeader_SalesOrderItem";
+ private static final String ASSOCIATION_SET_NAME = "SalesOrderHeader_SalesOrderItemSet";
+ private static final String ASSOCIATION_ROLE_NAME_TWO = "SalesOrderItem";
+ private static final String NAMESPACE = "salesorderprocessing";
+ private static final String ENTITY_CONTAINER_NAME = "salesorderprocessingContainer";
+ private static final String ENTITY_NAME_ONE = "SalesOrderHeader";
+ private static final String ENTITY_NAME_TWO = "SalesOrderItem";
+ private static final String ENTITY_SET_NAME_ONE = "SalesOrderHeaders";
+ private static final String FUNCTION_IMPORT_NAME_ONE = "SalesOrder_FunctionImport1";
+ private static final String FUNCTION_IMPORT_NAME_TWO = "SalesOrder_FunctionImport2";
+ private static final String ENTITY_SET_NAME_TWO = "SalesOrderItems";
+ private static final String COMPLEX_TYPE_NAME_ONE = "Address";
+ private static final String COMPLEX_TYPE_NAME_TWO = "SalesOrderItemKey";
+
+ public static Schema createMockEdmSchema() {
+ Schema schema = new Schema();
+ schema.setNamespace(NAMESPACE);
+ schema.setComplexTypes(createComplexTypes());
+ schema.setEntityContainers(createEntityContainer());
+ schema.setEntityTypes(createEntityTypes());
+ schema.setAssociations(createAssociations());
+ return schema;
+ }
+
+ private static List<EntityContainer> createEntityContainer() {
+ List<EntityContainer> entityContainers = new ArrayList<EntityContainer>();
+ EntityContainer entityContainer = new EntityContainer();
+ entityContainer.setDefaultEntityContainer(true);
+ entityContainer.setName(ENTITY_CONTAINER_NAME);
+ entityContainer.setEntitySets(createEntitySets());
+ entityContainer.setAssociationSets(createAssociationSets());
+ entityContainer.setFunctionImports(createFunctionImports());
+ entityContainers.add(entityContainer);
+ return entityContainers;
+ }
+
+ private static List<AssociationSet> createAssociationSets() {
+ List<AssociationSet> associationSets = new ArrayList<AssociationSet>();
+ AssociationSet associationSet = new AssociationSet();
+ associationSet.setName(ASSOCIATION_SET_NAME);
+ associationSet.setAssociation(new FullQualifiedName(NAMESPACE, ASSOCIATION_NAME));
+ associationSet
+ .setEnd1(new AssociationSetEnd().setEntitySet(ENTITY_SET_NAME_ONE).setRole(ASSOCIATION_ROLE_NAME_ONE));
+ associationSet
+ .setEnd2(new AssociationSetEnd().setEntitySet(ENTITY_SET_NAME_TWO).setRole(ASSOCIATION_ROLE_NAME_TWO));
+ associationSets.add(associationSet);
+ return associationSets;
+ }
+
+ private static List<EntitySet> createEntitySets() {
+ List<EntitySet> entitySets = new ArrayList<EntitySet>();
+ EntitySet entitySet = new EntitySet();
+ entitySet.setName(ENTITY_SET_NAME_ONE);
+ entitySet.setEntityType(new FullQualifiedName(NAMESPACE, ENTITY_NAME_ONE));
+ entitySets.add(entitySet);
+ entitySet = new EntitySet();
+ entitySet.setName(ENTITY_SET_NAME_TWO);
+ entitySet.setEntityType(new FullQualifiedName(NAMESPACE, ENTITY_NAME_TWO));
+ entitySets.add(entitySet);
+ return entitySets;
+ }
+
+ private static List<FunctionImport> createFunctionImports() {
+ List<FunctionImport> functionImports = new ArrayList<FunctionImport>();
+ FunctionImport functionImport = new FunctionImport();
+ functionImport.setName(FUNCTION_IMPORT_NAME_ONE);
+ functionImports.add(functionImport);
+ functionImport = new FunctionImport();
+ functionImport.setName(FUNCTION_IMPORT_NAME_TWO);
+ functionImports.add(functionImport);
+ return functionImports;
+ }
+
+ private static List<Association> createAssociations() {
+ List<Association> associations = new ArrayList<Association>();
+ Association association = new Association();
+ association.setName(ASSOCIATION_NAME);
+ association.setEnd1(new AssociationEnd().setMultiplicity(EdmMultiplicity.ONE).setRole(ASSOCIATION_ROLE_NAME_ONE)
+ .setType(new FullQualifiedName(NAMESPACE, ENTITY_NAME_ONE)));
+ association.setEnd2(new AssociationEnd().setMultiplicity(EdmMultiplicity.MANY).setRole(ASSOCIATION_ROLE_NAME_TWO)
+ .setType(new FullQualifiedName(NAMESPACE, ENTITY_NAME_TWO)));
+ associations.add(association);
+ return associations;
+ }
+
+ private static List<EntityType> createEntityTypes() {
+ List<EntityType> entityTypes = new ArrayList<EntityType>();
+ EntityType entityType = new EntityType();
+ entityType.setName(ENTITY_NAME_ONE);
+ String[] keyNamesOne = { "SoId" };
+ entityType.setKey(createKey(keyNamesOne));
+ entityTypes.add(entityType);
+
+ entityType = new EntityType();
+ entityType.setName(ENTITY_NAME_TWO);
+ String[] keyNamesTwo = { "SoId", "LiId" };
+ entityType.setKey(createKey(keyNamesTwo));
+ entityTypes.add(entityType);
+ return entityTypes;
+
+ }
+
+ private static Key createKey(final String[] keyNames) {
+ Key key = new Key();
+ List<PropertyRef> keys = new ArrayList<PropertyRef>();
+ for (String keyName : keyNames) {
+ keys.add(new PropertyRef().setName(keyName));
+ }
+ key.setKeys(keys);
+ return null;
+ }
+
+ private static List<ComplexType> createComplexTypes() {
+ List<ComplexType> complexTypes = new ArrayList<ComplexType>();
+ ComplexType complexTypeOne = new ComplexType();
+ complexTypeOne.setName(COMPLEX_TYPE_NAME_ONE);
+ complexTypeOne.setProperties(createComplexTypePropertiesOne());
+ complexTypes.add(complexTypeOne);
+ ComplexType complexTypeTwo = new ComplexType();
+ complexTypeTwo.setName(COMPLEX_TYPE_NAME_TWO);
+ complexTypeTwo.setProperties(createComplexTypePropertiesTwo());
+ complexTypes.add(complexTypeTwo);
+ return complexTypes;
+ }
+
+ private static List<Property> createComplexTypePropertiesTwo() {
+ List<Property> properties = new ArrayList<Property>();
+ SimpleProperty property = new SimpleProperty();
+ property.setName("SoId");
+ property.setType(EdmSimpleTypeKind.Int64);
+ JPAEdmMapping mapping = new JPAEdmMappingImpl();
+ mapping.setJPAColumnName("Sales_Order_Id");
+ ((Mapping) mapping).setInternalName("SalesOrderItemKey.SoId");
+ property.setMapping((Mapping) mapping);
+ properties.add(property);
+ property = new SimpleProperty();
+ property.setName("LiId");
+ property.setType(EdmSimpleTypeKind.Int64);
+ mapping = new JPAEdmMappingImpl();
+ mapping.setJPAColumnName("Sales_Order_Item_Id");
+ property.setMapping((Mapping) mapping);
+ properties.add(property);
+ return properties;
+
+ }
+
+ private static List<Property> createComplexTypePropertiesOne() {
+ List<Property> properties = new ArrayList<Property>();
+ SimpleProperty property = new SimpleProperty();
+ property.setName("StreetName");
+ property.setType(EdmSimpleTypeKind.String);
+ JPAEdmMapping mapping = new JPAEdmMappingImpl();
+ mapping.setJPAColumnName("STREET_NAME");
+ property.setMapping((Mapping) mapping);
+ properties.add(property);
+ property = new SimpleProperty();
+ property.setName("City");
+ property.setType(EdmSimpleTypeKind.String);
+ mapping = new JPAEdmMappingImpl();
+ mapping.setJPAColumnName("CITY");
+ property.setMapping((Mapping) mapping);
+ properties.add(property);
+ return properties;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/JPAAttributeMock.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/JPAAttributeMock.java b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/JPAAttributeMock.java
new file mode 100644
index 0000000..9d6bad1
--- /dev/null
+++ b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/JPAAttributeMock.java
@@ -0,0 +1,63 @@
+/*******************************************************************************
+ * 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.lang.reflect.Member;
+
+import javax.persistence.metamodel.Attribute;
+import javax.persistence.metamodel.ManagedType;
+
+public abstract class JPAAttributeMock<X, Y> implements Attribute<X, Y> {
+
+ @Override
+ public ManagedType<X> getDeclaringType() {
+ return null;
+ }
+
+ @Override
+ public Member getJavaMember() {
+ return null;
+ }
+
+ @Override
+ public Class<Y> getJavaType() {
+ return null;
+ }
+
+ @Override
+ public String getName() {
+ return null;
+ }
+
+ @Override
+ public javax.persistence.metamodel.Attribute.PersistentAttributeType getPersistentAttributeType() {
+ return null;
+ }
+
+ @Override
+ public boolean isAssociation() {
+ return false;
+ }
+
+ @Override
+ public boolean isCollection() {
+ return false;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/JPACustomProcessorMock.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/JPACustomProcessorMock.java b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/JPACustomProcessorMock.java
new file mode 100644
index 0000000..54a6871
--- /dev/null
+++ b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/JPACustomProcessorMock.java
@@ -0,0 +1,74 @@
+/*******************************************************************************
+ * 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.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";
+
+ @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>();
+ }
+
+ @EdmFunctionImport(name = "Method2", entitySet = "MockSet", returnType = @ReturnType(type = Type.ENTITY,
+ isCollection = true))
+ public List<JPACustomProcessorMock> method2(
+ @EdmFunctionImportParameter(facets = @EdmFacets(maxLength = 2), name = "Param2") final String param2) {
+ return new ArrayList<JPACustomProcessorMock>();
+ }
+
+ @EdmFunctionImport(returnType = @ReturnType(type = Type.SIMPLE))
+ public int method3(@EdmFunctionImportParameter(name = "Param3") final String param3) {
+ return 0;
+ }
+
+ @EdmFunctionImport(returnType = @ReturnType(type = Type.ENTITY,
+ isCollection = false), entitySet = "MockSet")
+ public JPACustomProcessorMock method7() {
+ return null;
+ }
+
+ @EdmFunctionImport(returnType = @ReturnType(type = Type.COMPLEX,
+ isCollection = false))
+ public JPACustomProcessorMock method9() {
+ return null;
+ }
+
+ @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/1b479e6c/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/JPAEdmMockData.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/JPAEdmMockData.java b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/JPAEdmMockData.java
new file mode 100644
index 0000000..9b25115
--- /dev/null
+++ b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/JPAEdmMockData.java
@@ -0,0 +1,72 @@
+/*******************************************************************************
+ * 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 org.apache.olingo.odata2.processor.core.jpa.mock.model.JPAEdmMockData.EntityType.EntityTypeA;
+
+public interface JPAEdmMockData {
+ /*
+ * Edm Complex Type Mock Data
+ */
+ public interface ComplexType {
+
+ public interface ComplexTypeA {
+ public static final String name = "ComplexTypeA";
+ public static final Class<ComplexTypeA> clazz = ComplexTypeA.class;
+
+ public interface Property {
+ public static final String PROPERTY_A = "A";
+ public static final String PROPERTY_B = "B";
+ public static final String PROPERTY_C = "C";
+ }
+
+ }
+
+ public interface ComplexTypeB {
+ public static final String name = "ComplexTypeB";
+
+ public interface Property {
+ public static final String PROPERTY_D = "D";
+ public static final String PROPERTY_E = "E";
+ }
+
+ }
+ }
+
+ public interface EntityType {
+ public interface EntityTypeA {
+ public static final String name = "SalesOrderHeader";
+ public static final Class<EntityTypeA> entityClazz = EntityTypeA.class;
+
+ public interface Property {
+ public static final String PROPERTY_A = SimpleType.SimpleTypeA.NAME;
+
+ }
+
+ }
+ }
+
+ public interface SimpleType {
+ public interface SimpleTypeA {
+ public static final String NAME = "SOID";
+ public static final Class<String> clazz = String.class;
+ public static final Class<EntityTypeA> declaringClazz = EntityType.EntityTypeA.class;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/JPAEmbeddableMock.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/JPAEmbeddableMock.java b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/JPAEmbeddableMock.java
new file mode 100644
index 0000000..397f971
--- /dev/null
+++ b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/JPAEmbeddableMock.java
@@ -0,0 +1,184 @@
+/*******************************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ ******************************************************************************/
+package org.apache.olingo.odata2.processor.core.jpa.mock.model;
+
+import java.util.Set;
+
+import javax.persistence.metamodel.Attribute;
+import javax.persistence.metamodel.CollectionAttribute;
+import javax.persistence.metamodel.EmbeddableType;
+import javax.persistence.metamodel.ListAttribute;
+import javax.persistence.metamodel.MapAttribute;
+import javax.persistence.metamodel.PluralAttribute;
+import javax.persistence.metamodel.SetAttribute;
+import javax.persistence.metamodel.SingularAttribute;
+
+public class JPAEmbeddableMock<X> implements EmbeddableType<X> {
+
+ @Override
+ public Attribute<? super X, ?> getAttribute(final String arg0) {
+ return null;
+ }
+
+ @Override
+ public Set<Attribute<? super X, ?>> getAttributes() {
+ return null;
+ }
+
+ @Override
+ public CollectionAttribute<? super X, ?> getCollection(final String arg0) {
+ return null;
+ }
+
+ @Override
+ public <E> CollectionAttribute<? super X, E> getCollection(final String arg0, final Class<E> arg1) {
+ return null;
+ }
+
+ @Override
+ public Attribute<X, ?> getDeclaredAttribute(final String arg0) {
+ return null;
+ }
+
+ @Override
+ public Set<Attribute<X, ?>> getDeclaredAttributes() {
+ return null;
+ }
+
+ @Override
+ public CollectionAttribute<X, ?> getDeclaredCollection(final String arg0) {
+ return null;
+ }
+
+ @Override
+ public <E> CollectionAttribute<X, E> getDeclaredCollection(final String arg0, final Class<E> arg1) {
+ return null;
+ }
+
+ @Override
+ public ListAttribute<X, ?> getDeclaredList(final String arg0) {
+ return null;
+ }
+
+ @Override
+ public <E> ListAttribute<X, E> getDeclaredList(final String arg0, final Class<E> arg1) {
+ return null;
+ }
+
+ @Override
+ public MapAttribute<X, ?, ?> getDeclaredMap(final String arg0) {
+ return null;
+ }
+
+ @Override
+ public <K, V> MapAttribute<X, K, V> getDeclaredMap(final String arg0, final Class<K> arg1, final Class<V> arg2) {
+ return null;
+ }
+
+ @Override
+ public Set<PluralAttribute<X, ?, ?>> getDeclaredPluralAttributes() {
+ return null;
+ }
+
+ @Override
+ public SetAttribute<X, ?> getDeclaredSet(final String arg0) {
+ return null;
+ }
+
+ @Override
+ public <E> SetAttribute<X, E> getDeclaredSet(final String arg0, final Class<E> arg1) {
+ return null;
+ }
+
+ @Override
+ public SingularAttribute<X, ?> getDeclaredSingularAttribute(final String arg0) {
+ return null;
+ }
+
+ @Override
+ public <Y> SingularAttribute<X, Y> getDeclaredSingularAttribute(final String arg0, final Class<Y> arg1) {
+ return null;
+ }
+
+ @Override
+ public Set<SingularAttribute<X, ?>> getDeclaredSingularAttributes() {
+ return null;
+ }
+
+ @Override
+ public ListAttribute<? super X, ?> getList(final String arg0) {
+ return null;
+ }
+
+ @Override
+ public <E> ListAttribute<? super X, E> getList(final String arg0, final Class<E> arg1) {
+ return null;
+ }
+
+ @Override
+ public MapAttribute<? super X, ?, ?> getMap(final String arg0) {
+ return null;
+ }
+
+ @Override
+ public <K, V> MapAttribute<? super X, K, V> getMap(final String arg0, final Class<K> arg1, final Class<V> arg2) {
+ return null;
+ }
+
+ @Override
+ public Set<PluralAttribute<? super X, ?, ?>> getPluralAttributes() {
+ return null;
+ }
+
+ @Override
+ public SetAttribute<? super X, ?> getSet(final String arg0) {
+ return null;
+ }
+
+ @Override
+ public <E> SetAttribute<? super X, E> getSet(final String arg0, final Class<E> arg1) {
+ return null;
+ }
+
+ @Override
+ public SingularAttribute<? super X, ?> getSingularAttribute(final String arg0) {
+ return null;
+ }
+
+ @Override
+ public <Y> SingularAttribute<? super X, Y> getSingularAttribute(final String arg0, final Class<Y> arg1) {
+ return null;
+ }
+
+ @Override
+ public Set<SingularAttribute<? super X, ?>> getSingularAttributes() {
+ return null;
+ }
+
+ @Override
+ public Class<X> getJavaType() {
+ return null;
+ }
+
+ @Override
+ public javax.persistence.metamodel.Type.PersistenceType getPersistenceType() {
+ return null;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/JPAEmbeddableTypeMock.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/JPAEmbeddableTypeMock.java b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/JPAEmbeddableTypeMock.java
new file mode 100644
index 0000000..7f6adc8
--- /dev/null
+++ b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/JPAEmbeddableTypeMock.java
@@ -0,0 +1,184 @@
+/*******************************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ ******************************************************************************/
+package org.apache.olingo.odata2.processor.core.jpa.mock.model;
+
+import java.util.Set;
+
+import javax.persistence.metamodel.Attribute;
+import javax.persistence.metamodel.CollectionAttribute;
+import javax.persistence.metamodel.EmbeddableType;
+import javax.persistence.metamodel.ListAttribute;
+import javax.persistence.metamodel.MapAttribute;
+import javax.persistence.metamodel.PluralAttribute;
+import javax.persistence.metamodel.SetAttribute;
+import javax.persistence.metamodel.SingularAttribute;
+
+public class JPAEmbeddableTypeMock<X> implements EmbeddableType<X> {
+
+ @Override
+ public Attribute<? super X, ?> getAttribute(final String arg0) {
+ return null;
+ }
+
+ @Override
+ public Set<Attribute<? super X, ?>> getAttributes() {
+ return null;
+ }
+
+ @Override
+ public CollectionAttribute<? super X, ?> getCollection(final String arg0) {
+ return null;
+ }
+
+ @Override
+ public <E> CollectionAttribute<? super X, E> getCollection(final String arg0, final Class<E> arg1) {
+ return null;
+ }
+
+ @Override
+ public Attribute<X, ?> getDeclaredAttribute(final String arg0) {
+ return null;
+ }
+
+ @Override
+ public Set<Attribute<X, ?>> getDeclaredAttributes() {
+ return null;
+ }
+
+ @Override
+ public CollectionAttribute<X, ?> getDeclaredCollection(final String arg0) {
+ return null;
+ }
+
+ @Override
+ public <E> CollectionAttribute<X, E> getDeclaredCollection(final String arg0, final Class<E> arg1) {
+ return null;
+ }
+
+ @Override
+ public ListAttribute<X, ?> getDeclaredList(final String arg0) {
+ return null;
+ }
+
+ @Override
+ public <E> ListAttribute<X, E> getDeclaredList(final String arg0, final Class<E> arg1) {
+ return null;
+ }
+
+ @Override
+ public MapAttribute<X, ?, ?> getDeclaredMap(final String arg0) {
+ return null;
+ }
+
+ @Override
+ public <K, V> MapAttribute<X, K, V> getDeclaredMap(final String arg0, final Class<K> arg1, final Class<V> arg2) {
+ return null;
+ }
+
+ @Override
+ public Set<PluralAttribute<X, ?, ?>> getDeclaredPluralAttributes() {
+ return null;
+ }
+
+ @Override
+ public SetAttribute<X, ?> getDeclaredSet(final String arg0) {
+ return null;
+ }
+
+ @Override
+ public <E> SetAttribute<X, E> getDeclaredSet(final String arg0, final Class<E> arg1) {
+ return null;
+ }
+
+ @Override
+ public SingularAttribute<X, ?> getDeclaredSingularAttribute(final String arg0) {
+ return null;
+ }
+
+ @Override
+ public <Y> SingularAttribute<X, Y> getDeclaredSingularAttribute(final String arg0, final Class<Y> arg1) {
+ return null;
+ }
+
+ @Override
+ public Set<SingularAttribute<X, ?>> getDeclaredSingularAttributes() {
+ return null;
+ }
+
+ @Override
+ public ListAttribute<? super X, ?> getList(final String arg0) {
+ return null;
+ }
+
+ @Override
+ public <E> ListAttribute<? super X, E> getList(final String arg0, final Class<E> arg1) {
+ return null;
+ }
+
+ @Override
+ public MapAttribute<? super X, ?, ?> getMap(final String arg0) {
+ return null;
+ }
+
+ @Override
+ public <K, V> MapAttribute<? super X, K, V> getMap(final String arg0, final Class<K> arg1, final Class<V> arg2) {
+ return null;
+ }
+
+ @Override
+ public Set<PluralAttribute<? super X, ?, ?>> getPluralAttributes() {
+ return null;
+ }
+
+ @Override
+ public SetAttribute<? super X, ?> getSet(final String arg0) {
+ return null;
+ }
+
+ @Override
+ public <E> SetAttribute<? super X, E> getSet(final String arg0, final Class<E> arg1) {
+ return null;
+ }
+
+ @Override
+ public SingularAttribute<? super X, ?> getSingularAttribute(final String arg0) {
+ return null;
+ }
+
+ @Override
+ public <Y> SingularAttribute<? super X, Y> getSingularAttribute(final String arg0, final Class<Y> arg1) {
+ return null;
+ }
+
+ @Override
+ public Set<SingularAttribute<? super X, ?>> getSingularAttributes() {
+ return null;
+ }
+
+ @Override
+ public Class<X> getJavaType() {
+ return null;
+ }
+
+ @Override
+ public javax.persistence.metamodel.Type.PersistenceType getPersistenceType() {
+ return null;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/JPAEntityTypeMock.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/JPAEntityTypeMock.java b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/JPAEntityTypeMock.java
new file mode 100644
index 0000000..602d430
--- /dev/null
+++ b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/JPAEntityTypeMock.java
@@ -0,0 +1,246 @@
+/*******************************************************************************
+ * 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.Set;
+
+import javax.persistence.metamodel.Attribute;
+import javax.persistence.metamodel.CollectionAttribute;
+import javax.persistence.metamodel.EntityType;
+import javax.persistence.metamodel.IdentifiableType;
+import javax.persistence.metamodel.ListAttribute;
+import javax.persistence.metamodel.MapAttribute;
+import javax.persistence.metamodel.PluralAttribute;
+import javax.persistence.metamodel.SetAttribute;
+import javax.persistence.metamodel.SingularAttribute;
+import javax.persistence.metamodel.Type;
+
+public abstract class JPAEntityTypeMock<X> implements EntityType<X> {
+
+ @Override
+ public <Y> SingularAttribute<X, Y> getDeclaredId(final Class<Y> arg0) {
+ return null;
+ }
+
+ @Override
+ public <Y> SingularAttribute<X, Y> getDeclaredVersion(final Class<Y> arg0) {
+ return null;
+ }
+
+ @Override
+ public <Y> SingularAttribute<? super X, Y> getId(final Class<Y> arg0) {
+ return null;
+ }
+
+ @Override
+ public Set<SingularAttribute<? super X, ?>> getIdClassAttributes() {
+ return null;
+ }
+
+ @Override
+ public Type<?> getIdType() {
+ return null;
+ }
+
+ @Override
+ public IdentifiableType<? super X> getSupertype() {
+ return null;
+ }
+
+ @Override
+ public <Y> SingularAttribute<? super X, Y> getVersion(final Class<Y> arg0) {
+ return null;
+ }
+
+ @Override
+ public boolean hasSingleIdAttribute() {
+ return false;
+ }
+
+ @Override
+ public boolean hasVersionAttribute() {
+ return false;
+ }
+
+ @Override
+ public Attribute<? super X, ?> getAttribute(final String arg0) {
+ return null;
+ }
+
+ @Override
+ public Set<Attribute<? super X, ?>> getAttributes() {
+ return null;
+ }
+
+ @Override
+ public CollectionAttribute<? super X, ?> getCollection(final String arg0) {
+ return null;
+ }
+
+ @Override
+ public <E> CollectionAttribute<? super X, E> getCollection(final String arg0, final Class<E> arg1) {
+ return null;
+ }
+
+ @Override
+ public Attribute<X, ?> getDeclaredAttribute(final String arg0) {
+ return null;
+ }
+
+ @Override
+ public Set<Attribute<X, ?>> getDeclaredAttributes() {
+ return null;
+ }
+
+ @Override
+ public CollectionAttribute<X, ?> getDeclaredCollection(final String arg0) {
+ return null;
+ }
+
+ @Override
+ public <E> CollectionAttribute<X, E> getDeclaredCollection(final String arg0, final Class<E> arg1) {
+ return null;
+ }
+
+ @Override
+ public ListAttribute<X, ?> getDeclaredList(final String arg0) {
+ return null;
+ }
+
+ @Override
+ public <E> ListAttribute<X, E> getDeclaredList(final String arg0, final Class<E> arg1) {
+ return null;
+ }
+
+ @Override
+ public MapAttribute<X, ?, ?> getDeclaredMap(final String arg0) {
+ return null;
+ }
+
+ @Override
+ public <K, V> MapAttribute<X, K, V> getDeclaredMap(final String arg0, final Class<K> arg1, final Class<V> arg2) {
+ return null;
+ }
+
+ @Override
+ public Set<PluralAttribute<X, ?, ?>> getDeclaredPluralAttributes() {
+ return null;
+ }
+
+ @Override
+ public SetAttribute<X, ?> getDeclaredSet(final String arg0) {
+ return null;
+ }
+
+ @Override
+ public <E> SetAttribute<X, E> getDeclaredSet(final String arg0, final Class<E> arg1) {
+ return null;
+ }
+
+ @Override
+ public SingularAttribute<X, ?> getDeclaredSingularAttribute(final String arg0) {
+ return null;
+ }
+
+ @Override
+ public <Y> SingularAttribute<X, Y> getDeclaredSingularAttribute(final String arg0, final Class<Y> arg1) {
+ return null;
+ }
+
+ @Override
+ public Set<SingularAttribute<X, ?>> getDeclaredSingularAttributes() {
+ return null;
+ }
+
+ @Override
+ public ListAttribute<? super X, ?> getList(final String arg0) {
+ return null;
+ }
+
+ @Override
+ public <E> ListAttribute<? super X, E> getList(final String arg0, final Class<E> arg1) {
+ return null;
+ }
+
+ @Override
+ public MapAttribute<? super X, ?, ?> getMap(final String arg0) {
+ return null;
+ }
+
+ @Override
+ public <K, V> MapAttribute<? super X, K, V> getMap(final String arg0, final Class<K> arg1, final Class<V> arg2) {
+ return null;
+ }
+
+ @Override
+ public Set<PluralAttribute<? super X, ?, ?>> getPluralAttributes() {
+ return null;
+ }
+
+ @Override
+ public SetAttribute<? super X, ?> getSet(final String arg0) {
+ return null;
+ }
+
+ @Override
+ public <E> SetAttribute<? super X, E> getSet(final String arg0, final Class<E> arg1) {
+ return null;
+ }
+
+ @Override
+ public SingularAttribute<? super X, ?> getSingularAttribute(final String arg0) {
+ return null;
+ }
+
+ @Override
+ public <Y> SingularAttribute<? super X, Y> getSingularAttribute(final String arg0, final Class<Y> arg1) {
+ return null;
+ }
+
+ @Override
+ public Set<SingularAttribute<? super X, ?>> getSingularAttributes() {
+ return null;
+ }
+
+ @Override
+ public Class<X> getJavaType() {
+ return null;
+ }
+
+ @Override
+ public javax.persistence.metamodel.Type.PersistenceType getPersistenceType() {
+ return null;
+ }
+
+ @Override
+ public Class<X> getBindableJavaType() {
+ return null;
+ }
+
+ @Override
+ public javax.persistence.metamodel.Bindable.BindableType getBindableType() {
+ return null;
+ }
+
+ @Override
+ public String getName() {
+ return null;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/JPAJavaMemberMock.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/JPAJavaMemberMock.java b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/JPAJavaMemberMock.java
new file mode 100644
index 0000000..740a2ec
--- /dev/null
+++ b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/JPAJavaMemberMock.java
@@ -0,0 +1,74 @@
+/*******************************************************************************
+ * 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.lang.annotation.Annotation;
+import java.lang.reflect.AnnotatedElement;
+import java.lang.reflect.Member;
+
+import javax.persistence.JoinColumns;
+
+public class JPAJavaMemberMock implements Member, AnnotatedElement, Annotation {
+
+ @Override
+ public Class<?> getDeclaringClass() {
+ return null;
+ }
+
+ @Override
+ public String getName() {
+ return null;
+ }
+
+ @Override
+ public int getModifiers() {
+ return 0;
+ }
+
+ @Override
+ public boolean isSynthetic() {
+ return false;
+ }
+
+ @Override
+ public boolean isAnnotationPresent(final Class<? extends Annotation> annotationClass) {
+ return false;
+ }
+
+ @Override
+ public Annotation[] getAnnotations() {
+ return null;
+ }
+
+ @Override
+ public Annotation[] getDeclaredAnnotations() {
+ return null;
+ }
+
+ @Override
+ public Class<? extends Annotation> annotationType() {
+ return JoinColumns.class;
+ }
+
+ @Override
+ public <T extends Annotation> T getAnnotation(final Class<T> annotationClass) {
+ return null;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/JPAManagedTypeMock.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/JPAManagedTypeMock.java b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/JPAManagedTypeMock.java
new file mode 100644
index 0000000..915c562
--- /dev/null
+++ b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/JPAManagedTypeMock.java
@@ -0,0 +1,184 @@
+/*******************************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ ******************************************************************************/
+package org.apache.olingo.odata2.processor.core.jpa.mock.model;
+
+import java.util.Set;
+
+import javax.persistence.metamodel.Attribute;
+import javax.persistence.metamodel.CollectionAttribute;
+import javax.persistence.metamodel.ListAttribute;
+import javax.persistence.metamodel.ManagedType;
+import javax.persistence.metamodel.MapAttribute;
+import javax.persistence.metamodel.PluralAttribute;
+import javax.persistence.metamodel.SetAttribute;
+import javax.persistence.metamodel.SingularAttribute;
+
+public class JPAManagedTypeMock<X> implements ManagedType<X> {
+
+ @Override
+ public Class<X> getJavaType() {
+ return null;
+ }
+
+ @Override
+ public javax.persistence.metamodel.Type.PersistenceType getPersistenceType() {
+ return null;
+ }
+
+ @Override
+ public Attribute<? super X, ?> getAttribute(final String arg0) {
+ return null;
+ }
+
+ @Override
+ public Set<Attribute<? super X, ?>> getAttributes() {
+ return null;
+ }
+
+ @Override
+ public CollectionAttribute<? super X, ?> getCollection(final String arg0) {
+ return null;
+ }
+
+ @Override
+ public <E> CollectionAttribute<? super X, E> getCollection(final String arg0, final Class<E> arg1) {
+ return null;
+ }
+
+ @Override
+ public Attribute<X, ?> getDeclaredAttribute(final String arg0) {
+ return null;
+ }
+
+ @Override
+ public Set<Attribute<X, ?>> getDeclaredAttributes() {
+ return null;
+ }
+
+ @Override
+ public CollectionAttribute<X, ?> getDeclaredCollection(final String arg0) {
+ return null;
+ }
+
+ @Override
+ public <E> CollectionAttribute<X, E> getDeclaredCollection(final String arg0, final Class<E> arg1) {
+ return null;
+ }
+
+ @Override
+ public ListAttribute<X, ?> getDeclaredList(final String arg0) {
+ return null;
+ }
+
+ @Override
+ public <E> ListAttribute<X, E> getDeclaredList(final String arg0, final Class<E> arg1) {
+ return null;
+ }
+
+ @Override
+ public MapAttribute<X, ?, ?> getDeclaredMap(final String arg0) {
+ return null;
+ }
+
+ @Override
+ public <K, V> MapAttribute<X, K, V> getDeclaredMap(final String arg0, final Class<K> arg1, final Class<V> arg2) {
+ return null;
+ }
+
+ @Override
+ public Set<PluralAttribute<X, ?, ?>> getDeclaredPluralAttributes() {
+ return null;
+ }
+
+ @Override
+ public SetAttribute<X, ?> getDeclaredSet(final String arg0) {
+ return null;
+ }
+
+ @Override
+ public <E> SetAttribute<X, E> getDeclaredSet(final String arg0, final Class<E> arg1) {
+ return null;
+ }
+
+ @Override
+ public SingularAttribute<X, ?> getDeclaredSingularAttribute(final String arg0) {
+ return null;
+ }
+
+ @Override
+ public <Y> SingularAttribute<X, Y> getDeclaredSingularAttribute(final String arg0, final Class<Y> arg1) {
+ return null;
+ }
+
+ @Override
+ public Set<SingularAttribute<X, ?>> getDeclaredSingularAttributes() {
+ return null;
+ }
+
+ @Override
+ public ListAttribute<? super X, ?> getList(final String arg0) {
+ return null;
+ }
+
+ @Override
+ public <E> ListAttribute<? super X, E> getList(final String arg0, final Class<E> arg1) {
+ return null;
+ }
+
+ @Override
+ public MapAttribute<? super X, ?, ?> getMap(final String arg0) {
+ return null;
+ }
+
+ @Override
+ public <K, V> MapAttribute<? super X, K, V> getMap(final String arg0, final Class<K> arg1, final Class<V> arg2) {
+ return null;
+ }
+
+ @Override
+ public Set<PluralAttribute<? super X, ?, ?>> getPluralAttributes() {
+ return null;
+ }
+
+ @Override
+ public SetAttribute<? super X, ?> getSet(final String arg0) {
+ return null;
+ }
+
+ @Override
+ public <E> SetAttribute<? super X, E> getSet(final String arg0, final Class<E> arg1) {
+ return null;
+ }
+
+ @Override
+ public SingularAttribute<? super X, ?> getSingularAttribute(final String arg0) {
+ return null;
+ }
+
+ @Override
+ public <Y> SingularAttribute<? super X, Y> getSingularAttribute(final String arg0, final Class<Y> arg1) {
+ return null;
+ }
+
+ @Override
+ public Set<SingularAttribute<? super X, ?>> getSingularAttributes() {
+ return null;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/JPAMetaModelMock.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/JPAMetaModelMock.java b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/JPAMetaModelMock.java
new file mode 100644
index 0000000..8e528b2
--- /dev/null
+++ b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/JPAMetaModelMock.java
@@ -0,0 +1,60 @@
+/*******************************************************************************
+ * 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.Set;
+
+import javax.persistence.metamodel.EmbeddableType;
+import javax.persistence.metamodel.EntityType;
+import javax.persistence.metamodel.ManagedType;
+import javax.persistence.metamodel.Metamodel;
+
+public class JPAMetaModelMock implements Metamodel {
+
+ @Override
+ public <X> EmbeddableType<X> embeddable(final Class<X> arg0) {
+ return null;
+ }
+
+ @Override
+ public <X> EntityType<X> entity(final Class<X> arg0) {
+ return null;
+ }
+
+ @Override
+ public Set<EmbeddableType<?>> getEmbeddables() {
+ return null;
+ }
+
+ @Override
+ public Set<EntityType<?>> getEntities() {
+ return null;
+ }
+
+ @Override
+ public Set<ManagedType<?>> getManagedTypes() {
+ return null;
+ }
+
+ @Override
+ public <X> ManagedType<X> managedType(final Class<X> arg0) {
+ return null;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/JPAPluralAttributeMock.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/JPAPluralAttributeMock.java b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/JPAPluralAttributeMock.java
new file mode 100644
index 0000000..a4aa2b5
--- /dev/null
+++ b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/JPAPluralAttributeMock.java
@@ -0,0 +1,95 @@
+/*******************************************************************************
+ * 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.lang.reflect.Member;
+import java.util.ArrayList;
+
+import javax.persistence.metamodel.ManagedType;
+import javax.persistence.metamodel.PluralAttribute;
+import javax.persistence.metamodel.Type;
+
+public class JPAPluralAttributeMock implements PluralAttribute<Object, ArrayList<String>, String> {
+
+ @Override
+ public String getName() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public javax.persistence.metamodel.Attribute.PersistentAttributeType getPersistentAttributeType() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public ManagedType<Object> getDeclaringType() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Class<ArrayList<String>> getJavaType() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Member getJavaMember() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public boolean isAssociation() {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean isCollection() {
+ return false;
+ }
+
+ @Override
+ public javax.persistence.metamodel.Bindable.BindableType getBindableType() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Class<String> getBindableJavaType() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public javax.persistence.metamodel.PluralAttribute.CollectionType getCollectionType() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Type<String> getElementType() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/JPASingularAttributeMock.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/JPASingularAttributeMock.java b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/JPASingularAttributeMock.java
new file mode 100644
index 0000000..41124fe
--- /dev/null
+++ b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/JPASingularAttributeMock.java
@@ -0,0 +1,94 @@
+/*******************************************************************************
+ * 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.lang.reflect.Member;
+
+import javax.persistence.metamodel.ManagedType;
+import javax.persistence.metamodel.SingularAttribute;
+import javax.persistence.metamodel.Type;
+
+public class JPASingularAttributeMock<X, T> implements SingularAttribute<X, T> {
+
+ @Override
+ public ManagedType<X> getDeclaringType() {
+ return null;
+ }
+
+ @Override
+ public Member getJavaMember() {
+ return null;
+ }
+
+ @Override
+ public Class<T> getJavaType() {
+ return null;
+ }
+
+ @Override
+ public String getName() {
+ return null;
+ }
+
+ @Override
+ public javax.persistence.metamodel.Attribute.PersistentAttributeType getPersistentAttributeType() {
+ return null;
+ }
+
+ @Override
+ public boolean isAssociation() {
+ return false;
+ }
+
+ @Override
+ public boolean isCollection() {
+ return false;
+ }
+
+ @Override
+ public Class<T> getBindableJavaType() {
+ return null;
+ }
+
+ @Override
+ public javax.persistence.metamodel.Bindable.BindableType getBindableType() {
+ return null;
+ }
+
+ @Override
+ public Type<T> getType() {
+ return null;
+ }
+
+ @Override
+ public boolean isId() {
+ return false;
+ }
+
+ @Override
+ public boolean isOptional() {
+ return false;
+ }
+
+ @Override
+ public boolean isVersion() {
+ return false;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/_JPACustomProcessorMock.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/_JPACustomProcessorMock.java b/odata2-jpa-processor/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-jpa-processor/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/1b479e6c/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/_JPACustomProcessorNegativeMock.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/_JPACustomProcessorNegativeMock.java b/odata2-jpa-processor/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-jpa-processor/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/1b479e6c/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmAssociationEndTest.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmAssociationEndTest.java b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmAssociationEndTest.java
new file mode 100644
index 0000000..05db5ab
--- /dev/null
+++ b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmAssociationEndTest.java
@@ -0,0 +1,177 @@
+/*******************************************************************************
+ * 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.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import javax.persistence.metamodel.Attribute;
+
+import org.apache.olingo.odata2.api.edm.EdmMultiplicity;
+import org.apache.olingo.odata2.api.edm.FullQualifiedName;
+import org.apache.olingo.odata2.api.edm.provider.AssociationEnd;
+import org.apache.olingo.odata2.api.edm.provider.EntityType;
+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.core.jpa.common.ODataJPATestConstants;
+import org.apache.olingo.odata2.processor.core.jpa.mock.model.JPAAttributeMock;
+import org.apache.olingo.odata2.processor.core.jpa.mock.model.JPAEdmMockData.SimpleType;
+import org.apache.olingo.odata2.processor.core.jpa.mock.model.JPAEdmMockData.SimpleType.SimpleTypeA;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class JPAEdmAssociationEndTest extends JPAEdmTestModelView {
+
+ private final static int VARIANT1 = 1;
+ private final static int VARIANT2 = 2;
+ private final static int VARIANT3 = 3;
+
+ private static int variant;
+
+ private static final String PUNIT_NAME = "salesorderprocessing";
+ private static JPAEdmAssociationEnd objJPAEdmAssociationEnd = null;
+ private static JPAEdmAssociationEndTest objJPAEdmAssociationEndTest = null;
+
+ @BeforeClass
+ public static void setup() {
+ objJPAEdmAssociationEndTest = new JPAEdmAssociationEndTest();
+ objJPAEdmAssociationEnd = new JPAEdmAssociationEnd(objJPAEdmAssociationEndTest, objJPAEdmAssociationEndTest);
+ try {
+ objJPAEdmAssociationEnd.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);
+ }
+ }
+
+ @Test
+ public void testGetBuilder() {
+ JPAEdmBuilder builder = objJPAEdmAssociationEnd.getBuilder();
+ assertNotNull(builder);
+
+ }
+
+ @Test
+ public void testGetBuilderIdempotent() {
+ JPAEdmBuilder builder1 = objJPAEdmAssociationEnd.getBuilder();
+ JPAEdmBuilder builder2 = objJPAEdmAssociationEnd.getBuilder();
+
+ assertEquals(builder1.hashCode(), builder2.hashCode());
+ }
+
+ @Test
+ public void testGetAssociationEnd1() {
+ AssociationEnd associationEnd = objJPAEdmAssociationEnd.getEdmAssociationEnd1();
+ assertEquals(associationEnd.getType().getName(), "SOID");
+ }
+
+ @Test
+ public void testGetAssociationEnd2() {
+ AssociationEnd associationEnd = objJPAEdmAssociationEnd.getEdmAssociationEnd2();
+ assertEquals(associationEnd.getType().getName(), "String");
+ }
+
+ @Test
+ public void testCompare() {
+ assertTrue(objJPAEdmAssociationEnd.compare(getAssociationEnd("SOID", 1), getAssociationEnd("String", 1)));
+ assertFalse(objJPAEdmAssociationEnd.compare(getAssociationEnd("String", 2), getAssociationEnd("SOID", 1)));
+ }
+
+ @Test
+ public void testBuildAssociationEnd() {
+ assertEquals("SOID", objJPAEdmAssociationEnd.getEdmAssociationEnd1().getType().getName());
+ assertEquals(new FullQualifiedName("salesorderprocessing", "SOID"), objJPAEdmAssociationEnd.getEdmAssociationEnd1()
+ .getType());
+ assertTrue(objJPAEdmAssociationEnd.isConsistent());
+
+ }
+
+ private AssociationEnd getAssociationEnd(final String typeName, final int variant) {
+ AssociationEnd associationEnd = new AssociationEnd();
+ associationEnd.setType(getFullQualifiedName(typeName));
+ if (variant == VARIANT1) {
+ associationEnd.setMultiplicity(EdmMultiplicity.MANY);
+ } else if (variant == VARIANT2) {
+ associationEnd.setMultiplicity(EdmMultiplicity.ONE);
+ } else if (variant == VARIANT3) {
+ associationEnd.setMultiplicity(EdmMultiplicity.ZERO_TO_ONE);
+ } else {
+ associationEnd.setMultiplicity(EdmMultiplicity.MANY);//
+ }
+ return associationEnd;
+ }
+
+ private FullQualifiedName getFullQualifiedName(final String typeName) {
+ FullQualifiedName fullQualifiedName = new FullQualifiedName(PUNIT_NAME, typeName);
+ return fullQualifiedName;
+ }
+
+ private Attribute<?, ?> getJPAAttributeLocal() {
+ AttributeMock<Object, String> attr = new AttributeMock<Object, String>();
+ return attr;
+ }
+
+ @Override
+ public Attribute<?, ?> getJPAAttribute() {
+ return getJPAAttributeLocal();
+ }
+
+ @Override
+ public String getpUnitName() {
+ return PUNIT_NAME;
+ }
+
+ @Override
+ public EntityType getEdmEntityType() {
+ EntityType entityType = new EntityType();
+ entityType.setName(SimpleTypeA.NAME);
+ return entityType;
+ }
+
+ // The inner class which gives us an replica of the jpa attribute
+ @SuppressWarnings("hiding")
+ public class AttributeMock<Object, String> extends JPAAttributeMock<Object, String> {
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public Class<String> getJavaType() {
+ return (Class<String>) SimpleType.SimpleTypeA.clazz;
+ }
+
+ @Override
+ public PersistentAttributeType getPersistentAttributeType() {
+ if (variant == VARIANT1) {
+ return PersistentAttributeType.ONE_TO_MANY;
+ } else if (variant == VARIANT2) {
+ return PersistentAttributeType.ONE_TO_ONE;
+ } else if (variant == VARIANT3) {
+ return PersistentAttributeType.MANY_TO_ONE;
+ } else {
+ return PersistentAttributeType.MANY_TO_MANY;
+ }
+
+ }
+ }
+
+}
[10/37] [OLINGO-82] Renamed the project folder name to
odata2-jpa-processor
Posted by ch...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/ODataJPAProcessorDefaultTest.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/ODataJPAProcessorDefaultTest.java b/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/ODataJPAProcessorDefaultTest.java
deleted file mode 100644
index af20194..0000000
--- a/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/ODataJPAProcessorDefaultTest.java
+++ /dev/null
@@ -1,554 +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;
-
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import java.io.ByteArrayInputStream;
-import java.io.InputStream;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.nio.charset.Charset;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import javax.persistence.EntityManager;
-import javax.persistence.EntityManagerFactory;
-import javax.persistence.EntityTransaction;
-import javax.persistence.Query;
-import javax.persistence.metamodel.EntityType;
-import javax.persistence.metamodel.Metamodel;
-
-import org.apache.olingo.odata2.api.commons.HttpContentType;
-import org.apache.olingo.odata2.api.commons.InlineCount;
-import org.apache.olingo.odata2.api.edm.EdmConcurrencyMode;
-import org.apache.olingo.odata2.api.edm.EdmEntityContainer;
-import org.apache.olingo.odata2.api.edm.EdmEntitySet;
-import org.apache.olingo.odata2.api.edm.EdmEntityType;
-import org.apache.olingo.odata2.api.edm.EdmException;
-import org.apache.olingo.odata2.api.edm.EdmFacets;
-import org.apache.olingo.odata2.api.edm.EdmMapping;
-import org.apache.olingo.odata2.api.edm.EdmProperty;
-import org.apache.olingo.odata2.api.edm.EdmType;
-import org.apache.olingo.odata2.api.edm.EdmTypeKind;
-import org.apache.olingo.odata2.api.edm.EdmTyped;
-import org.apache.olingo.odata2.api.exception.ODataException;
-import org.apache.olingo.odata2.api.processor.ODataContext;
-import org.apache.olingo.odata2.api.processor.ODataResponse;
-import org.apache.olingo.odata2.api.uri.KeyPredicate;
-import org.apache.olingo.odata2.api.uri.NavigationSegment;
-import org.apache.olingo.odata2.api.uri.PathInfo;
-import org.apache.olingo.odata2.api.uri.UriInfo;
-import org.apache.olingo.odata2.api.uri.expression.FilterExpression;
-import org.apache.olingo.odata2.api.uri.expression.OrderByExpression;
-import org.apache.olingo.odata2.api.uri.info.DeleteUriInfo;
-import org.apache.olingo.odata2.api.uri.info.GetEntityCountUriInfo;
-import org.apache.olingo.odata2.api.uri.info.GetEntitySetCountUriInfo;
-import org.apache.olingo.odata2.api.uri.info.GetEntityUriInfo;
-import org.apache.olingo.odata2.api.uri.info.PostUriInfo;
-import org.apache.olingo.odata2.api.uri.info.PutMergePatchUriInfo;
-import org.apache.olingo.odata2.processor.api.jpa.ODataJPAContext;
-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.core.jpa.common.ODataJPATestConstants;
-import org.apache.olingo.odata2.processor.core.jpa.model.JPAEdmTestModelView;
-import org.easymock.EasyMock;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-
-public class ODataJPAProcessorDefaultTest extends JPAEdmTestModelView {
-
- ODataJPAProcessorDefault objODataJPAProcessorDefault;
- ODataJPAProcessorDefaultTest objODataJPAProcessorDefaultTest;
-
- private static final String STR_LOCAL_URI = "http://localhost:8080/org.apache.olingo.odata2.processor.ref.web/";
- private static final String SALESORDERPROCESSING_CONTAINER = "salesorderprocessingContainer";
- private static final String SO_ID = "SoId";
- private static final String SALES_ORDER = "SalesOrder";
- private static final String SALES_ORDER_HEADERS = "SalesOrderHeaders";
- private static final String STR_CONTENT_TYPE = "Content-Type";
-
- @Before
- public void setUp() {
- objODataJPAProcessorDefaultTest = new ODataJPAProcessorDefaultTest();
- objODataJPAProcessorDefault = new ODataJPAProcessorDefault(getLocalmockODataJPAContext());
- }
-
- @Test
- public void testReadEntitySetGetEntitySetUriInfoString() {
- try {
- GetEntityUriInfo getEntityView = getEntityUriInfo();
- Assert.assertNotNull(objODataJPAProcessorDefault.readEntity(getEntityView, HttpContentType.APPLICATION_XML));
- } catch (ODataJPAModelException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- } catch (ODataJPARuntimeException e1) {// Expected
- assertTrue(true);
- } catch (ODataException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
-
- }
-
- @Test
- public void testcountEntitySet() {
- try {
- ODataResponse countEntitySet =
- objODataJPAProcessorDefault.countEntitySet(getEntitySetCountUriInfo(), HttpContentType.APPLICATION_XML);
- Assert.assertNotNull(countEntitySet);
- Object entity = countEntitySet.getEntity();
- Assert.assertNotNull(entity);
-
- byte[] b = new byte[2];
- ((ByteArrayInputStream) entity).read(b);
- Assert.assertEquals("11", new String(b, Charset.forName("utf-8")));
- } catch (ODataException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- } catch (Exception e) {
- assertTrue(true);
- }
- }
-
- @Test
- public void testExistsEntity() {
- try {
- Assert.assertNotNull(objODataJPAProcessorDefault.existsEntity(getEntityCountCountUriInfo(),
- HttpContentType.APPLICATION_XML));
- Assert.assertNull("ContentType MUST NOT set by entity provider", objODataJPAProcessorDefault.existsEntity(
- getEntityCountCountUriInfo(), HttpContentType.APPLICATION_XML).getHeader(STR_CONTENT_TYPE));
- } catch (ODataException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- } catch (Exception e) {
- assertTrue(true);
- }
- }
-
- @Test
- public void testDeleteEntity() {
- try {
- Assert.assertNotNull(objODataJPAProcessorDefault.deleteEntity(getDeletetUriInfo(),
- HttpContentType.APPLICATION_XML));
- } catch (ODataException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
- }
-
- @Test
- public void testCreateEntity() {
- try {
- Assert.assertNotNull(objODataJPAProcessorDefault.createEntity(getPostUriInfo(), getMockedInputStreamContent(),
- HttpContentType.APPLICATION_XML, HttpContentType.APPLICATION_XML));
- } catch (ODataException e) {
- Assert.assertTrue(true); // Expected TODO - need to revisit
- }
- }
-
- @Test
- public void testUpdateEntity() {
- try {
- Assert.assertNotNull(objODataJPAProcessorDefault.updateEntity(getPutUriInfo(), getMockedInputStreamContent(),
- HttpContentType.APPLICATION_XML, false, HttpContentType.APPLICATION_XML));
- } catch (ODataException e) {
- Assert.assertTrue(true); // Expected TODO - need to revisit
- }
- }
-
- private PutMergePatchUriInfo getPutUriInfo() {
- return (PutMergePatchUriInfo) getDeletetUriInfo();
- }
-
- private PostUriInfo getPostUriInfo() {
- return (PostUriInfo) getDeletetUriInfo();
- }
-
- private InputStream getMockedInputStreamContent() {
- return new ByteArrayInputStream(getEntityBody().getBytes());
- }
-
- private String getEntityBody() {
- return "<entry xmlns=\"http://www.w3.org/2005/Atom\" " +
- "xmlns:m=\"http://schemas.microsoft.com/ado/2007/08/dataservices/metadata\" " +
- "xmlns:d=\"http://schemas.microsoft.com/ado/2007/08/dataservices\" " +
- "xml:base=\"http://localhost:8080/org.apache.olingo.odata2.processor.ref.web/SalesOrderProcessing.svc/\">"
- + "<content type=\"application/xml\">"
- + "<m:properties>"
- + "<d:ID>2</d:ID>"
- + "<d:CreationDate>2013-01-02T00:00:00</d:CreationDate>"
- + "<d:CurrencyCode>Code_555</d:CurrencyCode>"
- + "<d:BuyerAddressInfo m:type=\"SalesOrderProcessing.AddressInfo\">"
- + "<d:Street>Test_Street_Name_055</d:Street>"
- + "<d:Number>2</d:Number>"
- + "<d:Country>Test_Country_2</d:Country>"
- + "<d:City>Test_City_2</d:City>"
- + "</d:BuyerAddressInfo>"
- + "<d:GrossAmount>0.0</d:GrossAmount>"
- + "<d:BuyerId>2</d:BuyerId>"
- + "<d:DeliveryStatus>true</d:DeliveryStatus>"
- + "<d:BuyerName>buyerName_2</d:BuyerName>"
- + "<d:NetAmount>0.0</d:NetAmount>" + "</m:properties>" + "</content>" + "</entry>";
- }
-
- private GetEntitySetCountUriInfo getEntitySetCountUriInfo() {
- return getLocalUriInfo();
- }
-
- private GetEntityCountUriInfo getEntityCountCountUriInfo() {
- return getLocalUriInfo();
- }
-
- private DeleteUriInfo getDeletetUriInfo() {
- UriInfo objUriInfo = EasyMock.createMock(UriInfo.class);
- EasyMock.expect(objUriInfo.getStartEntitySet()).andStubReturn(getLocalEdmEntitySet());
- EasyMock.expect(objUriInfo.getTargetEntitySet()).andStubReturn(getLocalEdmEntitySet());
- EasyMock.expect(objUriInfo.getSelect()).andStubReturn(null);
- EasyMock.expect(objUriInfo.getOrderBy()).andStubReturn(getOrderByExpression());
- EasyMock.expect(objUriInfo.getTop()).andStubReturn(getTop());
- EasyMock.expect(objUriInfo.getSkip()).andStubReturn(getSkip());
- EasyMock.expect(objUriInfo.getInlineCount()).andStubReturn(getInlineCount());
- EasyMock.expect(objUriInfo.getFilter()).andStubReturn(getFilter());
- EasyMock.expect(objUriInfo.getKeyPredicates()).andStubReturn(getKeyPredicates());
- EasyMock.replay(objUriInfo);
- return objUriInfo;
- }
-
- private List<KeyPredicate> getKeyPredicates() {
- List<KeyPredicate> keyPredicates = new ArrayList<KeyPredicate>();
- return keyPredicates;
- }
-
- /**
- * @return
- */
- private UriInfo getLocalUriInfo() {
- UriInfo objUriInfo = EasyMock.createMock(UriInfo.class);
- EasyMock.expect(objUriInfo.getStartEntitySet()).andStubReturn(getLocalEdmEntitySet());
- EasyMock.expect(objUriInfo.getTargetEntitySet()).andStubReturn(getLocalEdmEntitySet());
- EasyMock.expect(objUriInfo.getSelect()).andStubReturn(null);
- EasyMock.expect(objUriInfo.getOrderBy()).andStubReturn(getOrderByExpression());
- EasyMock.expect(objUriInfo.getTop()).andStubReturn(getTop());
- EasyMock.expect(objUriInfo.getSkip()).andStubReturn(getSkip());
- EasyMock.expect(objUriInfo.getInlineCount()).andStubReturn(getInlineCount());
- EasyMock.expect(objUriInfo.getFilter()).andStubReturn(getFilter());
- EasyMock.expect(objUriInfo.getFunctionImport()).andStubReturn(null);
- EasyMock.replay(objUriInfo);
- return objUriInfo;
- }
-
- /**
- * @return
- * @throws EdmException
- */
- private EdmEntitySet getLocalEdmEntitySet() {
- EdmEntitySet edmEntitySet = EasyMock.createMock(EdmEntitySet.class);
- try {
- EasyMock.expect(edmEntitySet.getName()).andStubReturn(SALES_ORDER_HEADERS);
- EasyMock.expect(edmEntitySet.getEntityContainer()).andStubReturn(getLocalEdmEntityContainer());
- EasyMock.expect(edmEntitySet.getEntityType()).andStubReturn(getLocalEdmEntityType());
- EasyMock.replay(edmEntitySet);
- } catch (EdmException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
- return edmEntitySet;
- }
-
- /**
- * @return
- * @throws EdmException
- */
- private EdmEntityType getLocalEdmEntityType() {
- EdmEntityType edmEntityType = EasyMock.createMock(EdmEntityType.class);
- try {
- EasyMock.expect(edmEntityType.getKeyProperties()).andStubReturn(new ArrayList<EdmProperty>());
- EasyMock.expect(edmEntityType.getPropertyNames()).andStubReturn(getLocalPropertyNames());
- EasyMock.expect(edmEntityType.getProperty(SO_ID)).andStubReturn(getEdmTypedMockedObj(SALES_ORDER));
- EasyMock.expect(edmEntityType.getKind()).andStubReturn(EdmTypeKind.SIMPLE);
- EasyMock.expect(edmEntityType.getNamespace()).andStubReturn(SALES_ORDER_HEADERS);
- EasyMock.expect(edmEntityType.getName()).andStubReturn(SALES_ORDER_HEADERS);
- EasyMock.expect(edmEntityType.hasStream()).andStubReturn(false);
- EasyMock.expect(edmEntityType.getNavigationPropertyNames()).andStubReturn(new ArrayList<String>());
- EasyMock.expect(edmEntityType.getKeyPropertyNames()).andStubReturn(new ArrayList<String>());
- EasyMock.expect(edmEntityType.getMapping()).andStubReturn(getEdmMappingMockedObj(SALES_ORDER));// ID vs Salesorder
- // ID
- EasyMock.replay(edmEntityType);
- } catch (EdmException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
- return edmEntityType;
- }
-
- private InlineCount getInlineCount() {
- return InlineCount.NONE;
- }
-
- private FilterExpression getFilter() {
- return null;
- }
-
- private Integer getSkip() {
- return null;
- }
-
- private Integer getTop() {
- return null;
- }
-
- private OrderByExpression getOrderByExpression() {
- return null;
- }
-
- private ODataJPAContext getLocalmockODataJPAContext() {
- ODataJPAContext odataJPAContext = EasyMock.createMock(ODataJPAContext.class);
- EasyMock.expect(odataJPAContext.getPersistenceUnitName()).andStubReturn("salesorderprocessing");
- EasyMock.expect(odataJPAContext.getEntityManagerFactory()).andStubReturn(mockEntityManagerFactory());
- EasyMock.expect(odataJPAContext.getODataContext()).andStubReturn(getLocalODataContext());
- EasyMock.expect(odataJPAContext.getEntityManager()).andStubReturn(getLocalEntityManager());
- EasyMock.replay(odataJPAContext);
- return odataJPAContext;
- }
-
- private EntityManagerFactory mockEntityManagerFactory() {
- EntityManagerFactory emf = EasyMock.createMock(EntityManagerFactory.class);
- EasyMock.expect(emf.getMetamodel()).andStubReturn(mockMetaModel());
- EasyMock.expect(emf.createEntityManager()).andStubReturn(getLocalEntityManager());
- EasyMock.replay(emf);
- return emf;
- }
-
- private EntityManagerFactory mockEntityManagerFactory2() {// For create, to avoid stackoverflow
- EntityManagerFactory emf = EasyMock.createMock(EntityManagerFactory.class);
- EasyMock.expect(emf.getMetamodel()).andStubReturn(mockMetaModel());
- EasyMock.replay(emf);
- return emf;
- }
-
- private EntityManager getLocalEntityManager() {
- EntityManager em = EasyMock.createMock(EntityManager.class);
- EasyMock.expect(em.createQuery("SELECT E1 FROM SalesOrderHeaders E1")).andStubReturn(getQuery());
- EasyMock.expect(em.createQuery("SELECT COUNT ( E1 ) FROM SalesOrderHeaders E1")).andStubReturn(
- getQueryForSelectCount());
- EasyMock.expect(em.getEntityManagerFactory()).andStubReturn(mockEntityManagerFactory2());// For create
- EasyMock.expect(em.getTransaction()).andStubReturn(getLocalTransaction()); // For Delete
- Address obj = new Address();
- em.remove(obj);// testing void method
- em.flush();
- EasyMock.replay(em);
- return em;
- }
-
- private EntityTransaction getLocalTransaction() {
- EntityTransaction entityTransaction = EasyMock.createMock(EntityTransaction.class);
- entityTransaction.begin(); // testing void method
- entityTransaction.commit();// testing void method
- entityTransaction.rollback();// testing void method
- EasyMock.replay(entityTransaction);
- return entityTransaction;
- }
-
- private Query getQuery() {
- Query query = EasyMock.createMock(Query.class);
- EasyMock.expect(query.getResultList()).andStubReturn(getResultList());
- EasyMock.replay(query);
- return query;
- }
-
- private Query getQueryForSelectCount() {
- Query query = EasyMock.createMock(Query.class);
- EasyMock.expect(query.getResultList()).andStubReturn(getResultListForSelectCount());
- EasyMock.replay(query);
- return query;
- }
-
- private List<?> getResultList() {
- List<Object> list = new ArrayList<Object>();
- list.add(new Address());
- return list;
- }
-
- private List<?> getResultListForSelectCount() {
- List<Object> list = new ArrayList<Object>();
- list.add(new Long(11));
- return list;
- }
-
- class Address {
- private String soId = "12";
-
- public String getSoId() {
- return soId;
- }
-
- @Override
- public boolean equals(final Object obj) {
- boolean isEqual = false;
- if (obj instanceof Address) {
- isEqual = getSoId().equalsIgnoreCase(((Address) obj).getSoId());//
- }
- return isEqual;
- }
- }
-
- private Metamodel mockMetaModel() {
- Metamodel metaModel = EasyMock.createMock(Metamodel.class);
- EasyMock.expect(metaModel.getEntities()).andStubReturn(getLocalEntities());
- EasyMock.replay(metaModel);
- return metaModel;
- }
-
- private Set<EntityType<?>> getLocalEntities() {
- Set<EntityType<?>> entityTypeSet = new HashSet<EntityType<?>>();
- entityTypeSet.add(getLocalJPAEntityType());
- return entityTypeSet;
- }
-
- @SuppressWarnings("rawtypes")
- private EntityType<EntityType> getLocalJPAEntityType() {
- @SuppressWarnings("unchecked")
- EntityType<EntityType> entityType = EasyMock.createMock(EntityType.class);
- EasyMock.expect(entityType.getJavaType()).andStubReturn(EntityType.class);
- EasyMock.replay(entityType);
- return entityType;
- }
-
- private GetEntityUriInfo getEntityUriInfo() {
- GetEntityUriInfo getEntityView = EasyMock.createMock(GetEntityUriInfo.class);
- EdmEntitySet edmEntitySet = EasyMock.createMock(EdmEntitySet.class);
- EdmEntityType edmEntityType = EasyMock.createMock(EdmEntityType.class);
- try {
- EasyMock.expect(getEntityView.getExpand()).andStubReturn(null);
- EasyMock.expect(edmEntityType.getKeyProperties()).andStubReturn(new ArrayList<EdmProperty>());
- EasyMock.expect(edmEntitySet.getEntityType()).andStubReturn(edmEntityType);
- EasyMock.expect(edmEntitySet.getName()).andStubReturn(SALES_ORDER_HEADERS);
-
- EasyMock.expect(getEntityView.getSelect()).andStubReturn(null);
- EasyMock.expect(getEntityView.getTargetEntitySet()).andStubReturn(edmEntitySet);
- EasyMock.expect(edmEntityType.getPropertyNames()).andStubReturn(getLocalPropertyNames());
- EasyMock.expect(edmEntityType.getProperty(SO_ID)).andStubReturn(getEdmTypedMockedObj(SO_ID));
-
- EasyMock.expect(edmEntityType.getMapping()).andStubReturn(getEdmMappingMockedObj(SALES_ORDER));
-
- EasyMock.expect(edmEntityType.getKind()).andStubReturn(EdmTypeKind.SIMPLE);
- EasyMock.expect(edmEntityType.getNamespace()).andStubReturn(SALES_ORDER_HEADERS);
- EasyMock.expect(edmEntityType.getName()).andStubReturn(SALES_ORDER_HEADERS);
- EasyMock.expect(edmEntityType.hasStream()).andStubReturn(false);
- EasyMock.expect(edmEntityType.getNavigationPropertyNames()).andStubReturn(new ArrayList<String>());
- EasyMock.expect(edmEntityType.getKeyPropertyNames()).andStubReturn(new ArrayList<String>());
-
- EasyMock.expect(edmEntitySet.getEntityContainer()).andStubReturn(getLocalEdmEntityContainer());
-
- EasyMock.replay(edmEntityType, edmEntitySet);
- EasyMock.expect(getEntityView.getKeyPredicates()).andStubReturn(new ArrayList<KeyPredicate>());
- List<NavigationSegment> navigationSegments = new ArrayList<NavigationSegment>();
- EasyMock.expect(getEntityView.getNavigationSegments()).andReturn(navigationSegments);
- EasyMock.expect(getEntityView.getStartEntitySet()).andReturn(edmEntitySet);
-
- EasyMock.replay(getEntityView);
- } catch (EdmException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
- return getEntityView;
- }
-
- private EdmEntityContainer getLocalEdmEntityContainer() {
- EdmEntityContainer edmEntityContainer = EasyMock.createMock(EdmEntityContainer.class);
- EasyMock.expect(edmEntityContainer.isDefaultEntityContainer()).andStubReturn(true);
- try {
- EasyMock.expect(edmEntityContainer.getName()).andStubReturn(SALESORDERPROCESSING_CONTAINER);
- } catch (EdmException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
-
- EasyMock.replay(edmEntityContainer);
- return edmEntityContainer;
- }
-
- private EdmTyped getEdmTypedMockedObj(final String propertyName) {
- EdmProperty mockedEdmProperty = EasyMock.createMock(EdmProperty.class);
- try {
- EasyMock.expect(mockedEdmProperty.getMapping()).andStubReturn(getEdmMappingMockedObj(propertyName));
- EdmType edmType = EasyMock.createMock(EdmType.class);
- EasyMock.expect(edmType.getKind()).andStubReturn(EdmTypeKind.SIMPLE);
- EasyMock.replay(edmType);
- EasyMock.expect(mockedEdmProperty.getName()).andStubReturn("identifier");
- EasyMock.expect(mockedEdmProperty.getType()).andStubReturn(edmType);
- EasyMock.expect(mockedEdmProperty.getFacets()).andStubReturn(getEdmFacetsMockedObj());
-
- EasyMock.replay(mockedEdmProperty);
- } catch (EdmException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
- return mockedEdmProperty;
- }
-
- private EdmFacets getEdmFacetsMockedObj() {
- EdmFacets facets = EasyMock.createMock(EdmFacets.class);
- EasyMock.expect(facets.getConcurrencyMode()).andStubReturn(EdmConcurrencyMode.Fixed);
-
- EasyMock.replay(facets);
- return facets;
- }
-
- private EdmMapping getEdmMappingMockedObj(final String propertyName) {
- EdmMapping mockedEdmMapping = EasyMock.createMock(EdmMapping.class);
- if (propertyName.equalsIgnoreCase(SALES_ORDER)) {
- EasyMock.expect(mockedEdmMapping.getInternalName()).andStubReturn(SALES_ORDER_HEADERS);
- } else {
- EasyMock.expect(mockedEdmMapping.getInternalName()).andStubReturn(propertyName);
- }
- EasyMock.replay(mockedEdmMapping);
- return mockedEdmMapping;
- }
-
- private List<String> getLocalPropertyNames() {
- List<String> list = new ArrayList<String>();
- list.add(SO_ID);
- return list;
- }
-
- private ODataContext getLocalODataContext() {
- ODataContext objODataContext = EasyMock.createMock(ODataContext.class);
- try {
- EasyMock.expect(objODataContext.getPathInfo()).andStubReturn(getLocalPathInfo());
- } catch (ODataException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
- EasyMock.replay(objODataContext);
- return objODataContext;
- }
-
- private PathInfo getLocalPathInfo() {
- PathInfo pathInfo = EasyMock.createMock(PathInfo.class);
- EasyMock.expect(pathInfo.getServiceRoot()).andStubReturn(getLocalURI());
- EasyMock.replay(pathInfo);
- return pathInfo;
- }
-
- private URI getLocalURI() {
- URI uri = null;
- try {
- uri = new URI(STR_LOCAL_URI);
- } catch (URISyntaxException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
- return uri;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/ODataJPAResponseBuilderTest.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/ODataJPAResponseBuilderTest.java b/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/ODataJPAResponseBuilderTest.java
deleted file mode 100644
index 426f236..0000000
--- a/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/ODataJPAResponseBuilderTest.java
+++ /dev/null
@@ -1,566 +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;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.olingo.odata2.api.commons.InlineCount;
-import org.apache.olingo.odata2.api.edm.EdmEntityContainer;
-import org.apache.olingo.odata2.api.edm.EdmEntitySet;
-import org.apache.olingo.odata2.api.edm.EdmEntityType;
-import org.apache.olingo.odata2.api.edm.EdmException;
-import org.apache.olingo.odata2.api.edm.EdmLiteralKind;
-import org.apache.olingo.odata2.api.edm.EdmMapping;
-import org.apache.olingo.odata2.api.edm.EdmNavigationProperty;
-import org.apache.olingo.odata2.api.edm.EdmProperty;
-import org.apache.olingo.odata2.api.edm.EdmSimpleType;
-import org.apache.olingo.odata2.api.edm.EdmSimpleTypeException;
-import org.apache.olingo.odata2.api.edm.EdmType;
-import org.apache.olingo.odata2.api.edm.EdmTypeKind;
-import org.apache.olingo.odata2.api.edm.provider.EntityType;
-import org.apache.olingo.odata2.api.edm.provider.Facets;
-import org.apache.olingo.odata2.api.ep.EntityProviderWriteProperties;
-import org.apache.olingo.odata2.api.exception.ODataException;
-import org.apache.olingo.odata2.api.exception.ODataNotFoundException;
-import org.apache.olingo.odata2.api.processor.ODataContext;
-import org.apache.olingo.odata2.api.processor.ODataResponse;
-import org.apache.olingo.odata2.api.uri.NavigationPropertySegment;
-import org.apache.olingo.odata2.api.uri.PathInfo;
-import org.apache.olingo.odata2.api.uri.SelectItem;
-import org.apache.olingo.odata2.api.uri.info.GetEntitySetUriInfo;
-import org.apache.olingo.odata2.api.uri.info.GetEntityUriInfo;
-import org.apache.olingo.odata2.processor.api.jpa.ODataJPAContext;
-import org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPARuntimeException;
-import org.apache.olingo.odata2.processor.core.jpa.common.ODataJPATestConstants;
-import org.apache.olingo.odata2.processor.core.jpa.model.JPAEdmTestModelView;
-import org.easymock.EasyMock;
-import org.junit.Test;
-
-public class ODataJPAResponseBuilderTest extends JPAEdmTestModelView {
-
- /*
- * This Unit is supposed to test the building of Entity Provider Properties for query with $expand
- */
- @Test
- public void testGetEntityProviderPropertiesQuery() {
- GetEntitySetUriInfo getEntitySetUriInfo = mockEntitySetUriInfoForExpand();
- ODataJPAContext oDataJPAContext = getODataJPAContext();
- // Building the edm entity
- List<Map<String, Object>> edmEntityList = new ArrayList<Map<String, Object>>();
- Map<String, Object> edmEntity = new HashMap<String, Object>();
- edmEntity.put("ID", 1);
- edmEntityList.add(edmEntity);
- // Invoking the private static method using reflection
- Class<?> clazz = ODataJPAResponseBuilder.class;
- Object[] actualParameters = { oDataJPAContext, getEntitySetUriInfo, edmEntityList };
- Class<?>[] formalParameters = { ODataJPAContext.class, GetEntitySetUriInfo.class, List.class };
- EntityProviderWriteProperties providerProperties = null;
- try {
- ODataJPAResponseBuilder responseBuilder = (ODataJPAResponseBuilder) clazz.newInstance();
- Method method = clazz.getDeclaredMethod("getEntityProviderProperties", formalParameters);
- method.setAccessible(true);
- providerProperties = (EntityProviderWriteProperties) method.invoke(responseBuilder, actualParameters);
- assertEquals(1, providerProperties.getExpandSelectTree().getLinks().size());
- } catch (SecurityException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- } catch (NoSuchMethodException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- } catch (IllegalArgumentException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- } catch (IllegalAccessException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- } catch (InvocationTargetException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- } catch (InstantiationException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
- }
-
- /*
- * This Unit is supposed to test the building of Entity Provider Properties for read with $expand
- */
- @Test
- public void testGetEntityProviderPropertiesRead() {
-
- // Getting the EntityUriInfo
- GetEntityUriInfo getEntityUriInfo = mockEntityUriInfoForExpand();
- ODataJPAContext oDataJPAContext = getODataJPAContext();
- Class<?> clazz = ODataJPAResponseBuilder.class;
- Object[] actualParameters = { oDataJPAContext, getEntityUriInfo };
- Class<?>[] formalParameters = { ODataJPAContext.class, GetEntityUriInfo.class };
- EntityProviderWriteProperties providerProperties = null;
- try {
- ODataJPAResponseBuilder responseBuilder = (ODataJPAResponseBuilder) clazz.newInstance();
- Method method = clazz.getDeclaredMethod("getEntityProviderProperties", formalParameters);
- method.setAccessible(true);
- providerProperties = (EntityProviderWriteProperties) method.invoke(responseBuilder, actualParameters);
- assertEquals(1, providerProperties.getExpandSelectTree().getLinks().size());
- } catch (SecurityException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- } catch (NoSuchMethodException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- } catch (IllegalArgumentException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- } catch (IllegalAccessException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- } catch (InvocationTargetException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- } catch (InstantiationException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
-
- }
-
- @SuppressWarnings("unchecked")
- @Test
- public void testConstructListofNavProperty() {
- List<ArrayList<NavigationPropertySegment>> expand = new ArrayList<ArrayList<NavigationPropertySegment>>();
- ArrayList<NavigationPropertySegment> navPropList1 = new ArrayList<NavigationPropertySegment>();
- navPropList1.add(getNavigationPropertySegment("DemoNavigationProperties11"));
- navPropList1.add(getNavigationPropertySegment("DemoNavigationProperties12"));
- expand.add(navPropList1);
- ArrayList<NavigationPropertySegment> navPropList2 = new ArrayList<NavigationPropertySegment>();
- navPropList2.add(getNavigationPropertySegment("DemoNavigationProperties21"));
- navPropList2.add(getNavigationPropertySegment("DemoNavigationProperties22"));
- expand.add(navPropList2);
- Class<?> clazz = ODataJPAResponseBuilder.class;
- Object[] actualParameters = { expand };
- Class<?>[] formalParameters = { List.class };
- List<EdmNavigationProperty> navigationProperties = null;
- try {
- ODataJPAResponseBuilder responseBuilder = (ODataJPAResponseBuilder) clazz.newInstance();
- Method method = clazz.getDeclaredMethod("constructListofNavProperty", formalParameters);
- method.setAccessible(true);
- navigationProperties = (List<EdmNavigationProperty>) method.invoke(responseBuilder, actualParameters);
- assertEquals("DemoNavigationProperties21", navigationProperties.get(1).getName());
- assertEquals("DemoNavigationProperties11", navigationProperties.get(0).getName());
- } catch (SecurityException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- } catch (NoSuchMethodException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- } catch (IllegalArgumentException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- } catch (IllegalAccessException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- } catch (InvocationTargetException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- } catch (InstantiationException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- } catch (EdmException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
-
- }
-
- @Test
- public void testBuildListOfTGetEntitySetUriInfoStringODataJPAContext() {
- try {
- assertNotNull(ODataJPAResponseBuilder.build(getJPAEntities(), getResultsView(), "application/xml",
- getODataJPAContext()));
- } catch (ODataJPARuntimeException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
-
- }
-
- @Test
- public void testBuildNegatives() {// Bad content type
- try {
- EntityType entity = new EntityType();
- entity.setName("SalesOrderHeader");
- try {
- assertNotNull(ODataJPAResponseBuilder.build(getEntity(), getLocalGetURIInfo(), "xml", getODataJPAContext()));
- } catch (ODataNotFoundException e) {
- assertTrue(true);
- }
- } catch (ODataJPARuntimeException e) {
- assertTrue(true);// Nothing to do, Expected.
- }
- try {// Bad content type
- assertNotNull(ODataJPAResponseBuilder.build(getJPAEntities(), getResultsView(), "xml", getODataJPAContext()));
- } catch (ODataJPARuntimeException e) {
- assertTrue(true);// Nothing to do, Expected.
- }
-
- }
-
- @Test
- public void testBuildObjectGetEntityUriInfoStringODataJPAContext() throws ODataNotFoundException {
- try {
- assertNotNull(ODataJPAResponseBuilder.build(new SalesOrderHeader(2, 10), getLocalGetURIInfo(), "application/xml",
- getODataJPAContext()));
- } catch (ODataJPARuntimeException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
- }
-
- @Test
- public void testBuildNullSelects() {// Bad content type
- try {
- ODataJPAResponseBuilder.build(getJPAEntities(), getResultsViewWithNullSelects(), "xml", getODataJPAContext());
- } catch (ODataJPARuntimeException e) {
- assertTrue(true);// Nothing to do, Expected.
- } catch (Exception e) {
- assertTrue(true);
- }
- }
-
- @Test
- public void testBuildGetCount() {
- ODataResponse objODataResponse = null;
- try {
- objODataResponse = ODataJPAResponseBuilder.build(1, getODataJPAContext());
- } catch (ODataJPARuntimeException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
- assertNotNull(objODataResponse);
- }
-
- private ODataJPAContext getODataJPAContext() {
- ODataJPAContext objODataJPAContext = EasyMock.createMock(ODataJPAContext.class);
- EasyMock.expect(objODataJPAContext.getODataContext()).andStubReturn(getLocalODataContext());
- EasyMock.replay(objODataJPAContext);
- return objODataJPAContext;
- }
-
- private ODataContext getLocalODataContext() {
- ODataContext objODataContext = EasyMock.createMock(ODataContext.class);
- try {
- EasyMock.expect(objODataContext.getPathInfo()).andStubReturn(getLocalPathInfo());
- } catch (ODataException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
- EasyMock.replay(objODataContext);
- return objODataContext;
- }
-
- private PathInfo getLocalPathInfo() {
- PathInfo pathInfo = EasyMock.createMock(PathInfo.class);
- EasyMock.expect(pathInfo.getServiceRoot()).andStubReturn(getLocalURI());
- EasyMock.replay(pathInfo);
- return pathInfo;
- }
-
- private URI getLocalURI() {
- URI uri = null;
- try {
- uri = new URI("http://localhost:8080/org.apache.olingo.odata2.processor.ref.web/");
- } catch (URISyntaxException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
- return uri;
- }
-
- private GetEntitySetUriInfo getResultsView() {
- GetEntitySetUriInfo objGetEntitySetUriInfo = EasyMock.createMock(GetEntitySetUriInfo.class);
- EasyMock.expect(objGetEntitySetUriInfo.getInlineCount()).andStubReturn(getLocalInlineCount());
- EasyMock.expect(objGetEntitySetUriInfo.getTargetEntitySet()).andStubReturn(getLocalTargetEntitySet());
- EasyMock.expect(objGetEntitySetUriInfo.getSelect()).andStubReturn(getSelectItemList());
- EasyMock.expect(objGetEntitySetUriInfo.getExpand()).andStubReturn(getExpandList());
- EasyMock.expect(objGetEntitySetUriInfo.getSkip()).andStubReturn(new Integer(1));
- EasyMock.replay(objGetEntitySetUriInfo);
- return objGetEntitySetUriInfo;
- }
-
- private List<ArrayList<NavigationPropertySegment>> getExpandList() {
- List<ArrayList<NavigationPropertySegment>> expandList = new ArrayList<ArrayList<NavigationPropertySegment>>();
- return expandList;
- }
-
- private GetEntitySetUriInfo getResultsViewWithNullSelects() {
- GetEntitySetUriInfo objGetEntitySetUriInfo = EasyMock.createMock(GetEntitySetUriInfo.class);
- EasyMock.expect(objGetEntitySetUriInfo.getInlineCount()).andStubReturn(getLocalInlineCount());
- EasyMock.expect(objGetEntitySetUriInfo.getTargetEntitySet()).andStubReturn(getLocalTargetEntitySet());
- EasyMock.expect(objGetEntitySetUriInfo.getSelect()).andStubReturn(null);
- EasyMock.expect(objGetEntitySetUriInfo.getExpand()).andStubReturn(null);
- EasyMock.expect(objGetEntitySetUriInfo.getSkip()).andStubReturn(new Integer(1));
-
- EasyMock.replay(objGetEntitySetUriInfo);
- return objGetEntitySetUriInfo;
- }
-
- private GetEntityUriInfo getLocalGetURIInfo() {
- GetEntityUriInfo objGetEntityUriInfo = EasyMock.createMock(GetEntityUriInfo.class);
- EasyMock.expect(objGetEntityUriInfo.getSelect()).andStubReturn(getSelectItemList());
- EasyMock.expect(objGetEntityUriInfo.getTargetEntitySet()).andStubReturn(getLocalTargetEntitySet());
- EasyMock.expect(objGetEntityUriInfo.getExpand()).andStubReturn(getExpandList());
- EasyMock.replay(objGetEntityUriInfo);
- return objGetEntityUriInfo;
- }
-
- private List<SelectItem> getSelectItemList() {
- List<SelectItem> selectItems = new ArrayList<SelectItem>();
- selectItems.add(getSelectItem());
- return selectItems;
- }
-
- private SelectItem getSelectItem() {
- SelectItem selectItem = EasyMock.createMock(SelectItem.class);
- EasyMock.expect(selectItem.getProperty()).andStubReturn(getEdmPropertyForSelect());
- List<NavigationPropertySegment> navigationSegmentList = new ArrayList<NavigationPropertySegment>();
- EasyMock.expect(selectItem.getNavigationPropertySegments()).andStubReturn(navigationSegmentList);
- EasyMock.replay(selectItem);
- return selectItem;
- }
-
- private EdmProperty getEdmPropertyForSelect() {
- EdmSimpleType edmType = EasyMock.createMock(EdmSimpleType.class);
- EasyMock.expect(edmType.getKind()).andStubReturn(EdmTypeKind.SIMPLE);
- Facets facets = new Facets().setNullable(false);
- try {
- EasyMock.expect(edmType.valueToString(new Integer(2), EdmLiteralKind.URI, facets)).andStubReturn("2");
- EasyMock.expect(edmType.valueToString(new Integer(2), EdmLiteralKind.DEFAULT, facets)).andStubReturn("2");
- } catch (EdmSimpleTypeException e1) {
- fail("There is an exception in mocking EdmType object " + e1.getMessage());
- }
- EasyMock.replay(edmType);
- EdmProperty edmProperty = EasyMock.createMock(EdmProperty.class);
- EdmMapping edmMapping = EasyMock.createMock(EdmMapping.class);
- EasyMock.expect(edmMapping.getInternalName()).andStubReturn("soId");
- EasyMock.expect(edmMapping.getMimeType()).andReturn(null);
- EasyMock.replay(edmMapping);
- try {
- EasyMock.expect(edmProperty.getName()).andStubReturn("ID");
- EasyMock.expect(edmProperty.getType()).andStubReturn(edmType);
- EasyMock.expect(edmProperty.getMapping()).andStubReturn(edmMapping);
- EasyMock.expect(edmProperty.getFacets()).andStubReturn(facets);
- EasyMock.expect(edmProperty.getCustomizableFeedMappings()).andStubReturn(null);
- EasyMock.expect(edmProperty.getMimeType()).andStubReturn(null);
- EasyMock.replay(edmProperty);
-
- } catch (EdmException e) {
- fail("There is an exception in mocking some object " + e.getMessage());
- }
-
- return edmProperty;
-
- }
-
- private EdmEntitySet getLocalTargetEntitySet() {
- EdmEntitySet objEdmEntitySet = EasyMock.createMock(EdmEntitySet.class);
- try {
- EasyMock.expect(objEdmEntitySet.getEntityType()).andStubReturn(getLocalEdmEntityType());
- EasyMock.expect(objEdmEntitySet.getName()).andStubReturn("SalesOderHeaders");
- EasyMock.expect(objEdmEntitySet.getEntityContainer()).andStubReturn(getLocalEdmEntityContainer());
- } catch (EdmException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
-
- EasyMock.replay(objEdmEntitySet);
- return objEdmEntitySet;
- }
-
- private EdmEntityContainer getLocalEdmEntityContainer() {
- EdmEntityContainer edmEntityContainer = EasyMock.createMock(EdmEntityContainer.class);
- EasyMock.expect(edmEntityContainer.isDefaultEntityContainer()).andStubReturn(true);
- try {
- EasyMock.expect(edmEntityContainer.getName()).andStubReturn("salesorderprocessingContainer");
- } catch (EdmException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
-
- EasyMock.replay(edmEntityContainer);
- return edmEntityContainer;
- }
-
- private EdmEntityType getLocalEdmEntityType() {
- EdmEntityType objEdmEntityType = EasyMock.createMock(EdmEntityType.class);
- try {
- EasyMock.expect(objEdmEntityType.getName()).andStubReturn("SalesOderHeaders");
- EasyMock.expect(objEdmEntityType.getNamespace()).andStubReturn("SalesOderHeaders");
- EasyMock.expect(objEdmEntityType.hasStream()).andStubReturn(false);
- EasyMock.expect(objEdmEntityType.hasStream()).andStubReturn(false);
- ArrayList<String> propertyNames = new ArrayList<String>();
- propertyNames.add("ID");
- EasyMock.expect(objEdmEntityType.getProperty("ID")).andStubReturn(getEdmPropertyForSelect());
- EasyMock.expect(objEdmEntityType.getPropertyNames()).andStubReturn(propertyNames);
- EasyMock.expect(objEdmEntityType.getNavigationPropertyNames()).andStubReturn(new ArrayList<String>());
- EasyMock.expect(objEdmEntityType.getKeyPropertyNames()).andStubReturn(propertyNames);
- EasyMock.expect(objEdmEntityType.getKeyProperties()).andStubReturn(getKeyProperties());
- } catch (EdmException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
- EasyMock.replay(objEdmEntityType);
- return objEdmEntityType;
- }
-
- private List<EdmProperty> getKeyProperties() {
- List<EdmProperty> edmProperties = new ArrayList<EdmProperty>();
- EdmType edmType = EasyMock.createMock(EdmType.class);
- EasyMock.expect(edmType.getKind()).andStubReturn(EdmTypeKind.SIMPLE);
- EasyMock.replay(edmType);
- EdmProperty edmProperty = EasyMock.createMock(EdmProperty.class);
- EdmMapping edmMapping = EasyMock.createMock(EdmMapping.class);
- EasyMock.expect(edmMapping.getInternalName()).andStubReturn("soId");
- EasyMock.replay(edmMapping);
- try {
- EasyMock.expect(edmProperty.getName()).andStubReturn("ID");
- EasyMock.expect(edmProperty.getType()).andStubReturn(edmType);
- EasyMock.expect(edmProperty.getMapping()).andStubReturn(edmMapping);
- EasyMock.replay(edmProperty);
- } catch (EdmException e) {
- fail("There is an exception is mocking some object " + e.getMessage());
- }
-
- edmProperties.add(edmProperty);
- return edmProperties;
- }
-
- private InlineCount getLocalInlineCount() {
- return InlineCount.NONE;
- }
-
- class SalesOrderHeader {
- private int soId;
- private int Field1;
-
- public SalesOrderHeader(final int soId, final int field) {
- this.soId = soId;
- Field1 = field;
- }
-
- public int getField1() {
- return Field1;
- }
-
- public void setField1(final int field1) {
- Field1 = field1;
- }
-
- public int getSoId() {
- return soId;
- }
-
- public void setSoId(final int soId) {
- this.soId = soId;
- }
-
- }
-
- private List<Object> getJPAEntities() {
- List<Object> listJPAEntities = new ArrayList<Object>();
- SalesOrderHeader entity;
- entity = new SalesOrderHeader(2, 10);
- listJPAEntities.add(entity);
- return listJPAEntities;
- }
-
- private Object getEntity() {
- SalesOrderHeader sHeader = new SalesOrderHeader(10, 34);
- return sHeader;
- }
-
- private GetEntityUriInfo mockEntityUriInfoForExpand() {
-
- List<SelectItem> selectItemList = new ArrayList<SelectItem>();
- List<ArrayList<NavigationPropertySegment>> expandList = new ArrayList<ArrayList<NavigationPropertySegment>>();
- ArrayList<NavigationPropertySegment> navigationPropertyList = new ArrayList<NavigationPropertySegment>();
- // Mocking the navigation property
- EdmNavigationProperty navigationProperty = EasyMock.createMock(EdmNavigationProperty.class);
- try {
- EasyMock.expect(navigationProperty.getName()).andStubReturn("SalesOrderItemDetails");
- } catch (EdmException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
- EasyMock.replay(navigationProperty);
- // Mocking the navigation property segments and adding to expand list
- NavigationPropertySegment navigationPropertySegment = EasyMock.createMock(NavigationPropertySegment.class);
- EasyMock.expect(navigationPropertySegment.getNavigationProperty()).andStubReturn(navigationProperty);
- EasyMock.expect(navigationPropertySegment.getTargetEntitySet()).andStubReturn(getTargetEntitySetForExpand());
- EasyMock.replay(navigationPropertySegment);
- navigationPropertyList.add(navigationPropertySegment);
- expandList.add(navigationPropertyList);
- // Mocking EntityUriInfo
- GetEntityUriInfo entityUriInfo = EasyMock.createMock(GetEntityUriInfo.class);
- EasyMock.expect(entityUriInfo.getSelect()).andStubReturn(selectItemList);
- EasyMock.expect(entityUriInfo.getExpand()).andStubReturn(expandList);
- EasyMock.replay(entityUriInfo);
- return entityUriInfo;
- }
-
- private GetEntitySetUriInfo mockEntitySetUriInfoForExpand() {
-
- List<SelectItem> selectItemList = new ArrayList<SelectItem>();
- List<ArrayList<NavigationPropertySegment>> expandList = new ArrayList<ArrayList<NavigationPropertySegment>>();
- ArrayList<NavigationPropertySegment> navigationPropertyList = new ArrayList<NavigationPropertySegment>();
- // Mocking the navigation property
- EdmNavigationProperty navigationProperty = EasyMock.createMock(EdmNavigationProperty.class);
- try {
- EasyMock.expect(navigationProperty.getName()).andStubReturn("SalesOrderItemDetails");
- } catch (EdmException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
- EasyMock.replay(navigationProperty);
- // Mocking the navigation property segments and adding to expand list
- NavigationPropertySegment navigationPropertySegment = EasyMock.createMock(NavigationPropertySegment.class);
- EasyMock.expect(navigationPropertySegment.getNavigationProperty()).andStubReturn(navigationProperty);
- EasyMock.expect(navigationPropertySegment.getTargetEntitySet()).andStubReturn(getTargetEntitySetForExpand());
- EasyMock.replay(navigationPropertySegment);
- navigationPropertyList.add(navigationPropertySegment);
- expandList.add(navigationPropertyList);
- // Mocking EntityUriInfo
- GetEntitySetUriInfo entitySetUriInfo = EasyMock.createMock(GetEntitySetUriInfo.class);
- EasyMock.expect(entitySetUriInfo.getSelect()).andStubReturn(selectItemList);
- EasyMock.expect(entitySetUriInfo.getExpand()).andStubReturn(expandList);
- EasyMock.expect(entitySetUriInfo.getInlineCount()).andStubReturn(InlineCount.ALLPAGES);
- EasyMock.expect(entitySetUriInfo.getSkip()).andStubReturn(new Integer(1));
- EasyMock.expect(entitySetUriInfo.getTop()).andStubReturn(new Integer(2));
- EasyMock.replay(entitySetUriInfo);
- return entitySetUriInfo;
- }
-
- private EdmEntitySet getTargetEntitySetForExpand() {
- EdmEntitySet entitySet = EasyMock.createMock(EdmEntitySet.class);
- try {
- EasyMock.expect(entitySet.getName()).andStubReturn("SalesOrderHeaders");
- EasyMock.expect(entitySet.getEntityType()).andStubReturn(null);
- } catch (EdmException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
- EasyMock.replay(entitySet);
- return entitySet;
- }
-
- private NavigationPropertySegment getNavigationPropertySegment(final String navPropertyName) {
- EdmNavigationProperty navigationProperty = EasyMock.createMock(EdmNavigationProperty.class);
- try {
- EasyMock.expect(navigationProperty.getName()).andStubReturn(navPropertyName);
- } catch (EdmException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
- EasyMock.replay(navigationProperty);
- NavigationPropertySegment navPropertySegment = EasyMock.createMock(NavigationPropertySegment.class);
- EasyMock.expect(navPropertySegment.getNavigationProperty()).andStubReturn(navigationProperty);
- EasyMock.replay(navPropertySegment);
- return navPropertySegment;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/access/data/JPAEntityParserTest.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/access/data/JPAEntityParserTest.java b/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/access/data/JPAEntityParserTest.java
deleted file mode 100644
index 55511ca..0000000
--- a/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/access/data/JPAEntityParserTest.java
+++ /dev/null
@@ -1,599 +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.access.data;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.olingo.odata2.api.edm.EdmException;
-import org.apache.olingo.odata2.api.edm.EdmMapping;
-import org.apache.olingo.odata2.api.edm.EdmNavigationProperty;
-import org.apache.olingo.odata2.api.edm.EdmProperty;
-import org.apache.olingo.odata2.api.edm.EdmStructuralType;
-import org.apache.olingo.odata2.api.edm.EdmType;
-import org.apache.olingo.odata2.api.edm.EdmTypeKind;
-import org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPARuntimeException;
-import org.apache.olingo.odata2.processor.core.jpa.common.ODataJPATestConstants;
-import org.easymock.EasyMock;
-import org.junit.Test;
-
-public class JPAEntityParserTest {
- /*
- * TestCase - JPAResultParser is a singleton class Check if the same
- * instance is returned when create method is called
- */
- @Test
- public void testCreate() {
- JPAEntityParser resultParser1 = new JPAEntityParser();
- JPAEntityParser resultParser2 = new JPAEntityParser();
-
- if (resultParser1.equals(resultParser2)) {
- fail();
- }
- }
-
- @Test
- public void testparse2EdmPropertyValueMap() {
- JPAEntityParser resultParser = new JPAEntityParser();
- Object jpaEntity = new demoItem("abc", 10);
- EdmStructuralType structuralType = EasyMock.createMock(EdmStructuralType.class);
- EdmProperty edmTyped = EasyMock.createMock(EdmProperty.class);
- EdmType edmType = EasyMock.createMock(EdmType.class);
- EdmProperty edmTyped01 = EasyMock.createMock(EdmProperty.class);
- EdmType edmType01 = EasyMock.createMock(EdmType.class);
- EdmMapping edmMapping = EasyMock.createMock(EdmMapping.class);
- EdmMapping edmMapping01 = EasyMock.createMock(EdmMapping.class);
-
- try {
- EasyMock.expect(edmType.getKind()).andStubReturn(EdmTypeKind.SIMPLE);
- EasyMock.expect(edmTyped.getName()).andStubReturn("identifier");
- EasyMock.replay(edmType);
- EasyMock.expect(edmMapping.getInternalName()).andStubReturn("id");
- EasyMock.replay(edmMapping);
- EasyMock.expect(edmTyped.getType()).andStubReturn(edmType);
- EasyMock.expect(edmTyped.getMapping()).andStubReturn(edmMapping);
- EasyMock.replay(edmTyped);
- EasyMock.expect(structuralType.getProperty("identifier")).andStubReturn(edmTyped);
-
- EasyMock.expect(edmType01.getKind()).andStubReturn(EdmTypeKind.SIMPLE);
- EasyMock.expect(edmTyped01.getName()).andStubReturn("Value");
- EasyMock.replay(edmType01);
- EasyMock.expect(edmMapping01.getInternalName()).andStubReturn("value");
- EasyMock.replay(edmMapping01);
- EasyMock.expect(edmTyped01.getType()).andStubReturn(edmType01);
- EasyMock.expect(edmTyped01.getMapping()).andStubReturn(edmMapping01);
- EasyMock.replay(edmTyped01);
- EasyMock.expect(structuralType.getProperty("value")).andStubReturn(edmTyped01);
-
- List<String> propNames = new ArrayList<String>();
- propNames.add("identifier");
- propNames.add("value");
- EasyMock.expect(structuralType.getPropertyNames()).andReturn(propNames);
- EasyMock.replay(structuralType);
-
- } catch (EdmException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
-
- try {
- Map<String, Object> result = resultParser.parse2EdmPropertyValueMap(jpaEntity, structuralType);
- assertEquals(2, result.size());
- } catch (ODataJPARuntimeException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
-
- }
-
- @Test
- public void testparse2EdmPropertyValueMapEdmExcep() {
- JPAEntityParser resultParser = new JPAEntityParser();
- Object jpaEntity = new demoItem("abc", 10);
- EdmStructuralType structuralType = EasyMock
- .createMock(EdmStructuralType.class);
- EdmProperty edmTyped = EasyMock.createMock(EdmProperty.class);
- EdmType edmType = EasyMock.createMock(EdmType.class);
- EdmProperty edmTyped01 = EasyMock.createMock(EdmProperty.class);
- EdmType edmType01 = EasyMock.createMock(EdmType.class);
- EdmMapping edmMapping = EasyMock.createMock(EdmMapping.class);
- EdmMapping edmMapping01 = EasyMock.createMock(EdmMapping.class);
-
- try {
- EasyMock.expect(edmType.getKind())
- .andStubReturn(EdmTypeKind.SIMPLE);
- EasyMock.expect(edmType.getName()).andReturn("identifier");
- EasyMock.replay(edmType);
- EasyMock.expect(edmMapping.getInternalName()).andStubReturn("id");
- EasyMock.replay(edmMapping);
- EasyMock.expect(edmTyped.getType()).andStubThrow(
- new EdmException(null));
- EasyMock.expect(edmTyped.getMapping()).andStubReturn(edmMapping);
- EasyMock.expect(edmTyped.getName()).andReturn("identifier");
- EasyMock.replay(edmTyped);
- EasyMock.expect(structuralType.getProperty("identifier"))
- .andStubReturn(edmTyped);
-
- EasyMock.expect(edmType01.getKind()).andStubReturn(
- EdmTypeKind.SIMPLE);
- EasyMock.expect(edmType01.getName()).andStubReturn("value");
- EasyMock.replay(edmType01);
- EasyMock.expect(edmMapping01.getInternalName()).andStubReturn(
- "value");
- EasyMock.replay(edmMapping01);
- EasyMock.expect(edmTyped01.getName()).andReturn("value");
- EasyMock.expect(edmTyped01.getType()).andStubReturn(edmType01);
- EasyMock.expect(edmTyped01.getMapping())
- .andStubReturn(edmMapping01);
- EasyMock.replay(edmTyped01);
- EasyMock.expect(structuralType.getProperty("value")).andStubReturn(
- edmTyped01);
-
- List<String> propNames = new ArrayList<String>();
- propNames.add("identifier");
- propNames.add("value");
- EasyMock.expect(structuralType.getPropertyNames()).andReturn(
- propNames);
- EasyMock.replay(structuralType);
-
- } catch (EdmException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage()
- + ODataJPATestConstants.EXCEPTION_MSG_PART_2); // assertTrue(false);
- }
-
- try {
- resultParser.parse2EdmPropertyValueMap(jpaEntity, structuralType);
- } catch (ODataJPARuntimeException e) {
- assertTrue(true);
- }
-
- }
-
- @Test
- public void testparse2EdmPropertyListMap() {
- JPAEntityParser resultParser = new JPAEntityParser();
- Map<String, Object> edmEntity = new HashMap<String, Object>();
- edmEntity.put("SoId", 1);
- DemoRelatedEntity relatedEntity = new DemoRelatedEntity("NewOrder");
- demoItem jpaEntity = new demoItem("laptop", 1);
- jpaEntity.setRelatedEntity(relatedEntity);
- List<EdmNavigationProperty> navigationPropertyList = new ArrayList<EdmNavigationProperty>();
- // Mocking a navigation property and its mapping object
- EdmNavigationProperty navigationProperty = EasyMock.createMock(EdmNavigationProperty.class);
- EdmMapping edmMapping = EasyMock.createMock(EdmMapping.class);
- try {
- EasyMock.expect(edmMapping.getInternalName()).andStubReturn("relatedEntity");
- EasyMock.replay(edmMapping);
- EasyMock.expect(navigationProperty.getName()).andStubReturn("RelatedEntities");
- EasyMock.expect(navigationProperty.getMapping()).andStubReturn(edmMapping);
- EasyMock.replay(navigationProperty);
- } catch (EdmException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
-
- navigationPropertyList.add(navigationProperty);
- try {
- HashMap<String, Object> result = resultParser.parse2EdmNavigationValueMap(jpaEntity, navigationPropertyList);
- assertEquals(relatedEntity, result.get("RelatedEntities"));
-
- } catch (ODataJPARuntimeException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
- }
-
- @Test
- public void testparse2EdmPropertyValueMapFromList() {
- JPAEntityParser resultParser = new JPAEntityParser();
- demoItem jpaEntity = new demoItem("laptop", 1);
- DemoRelatedEntity relatedEntity = new DemoRelatedEntity("DemoOrder");
- jpaEntity.setRelatedEntity(relatedEntity);
- List<EdmProperty> selectPropertyList = new ArrayList<EdmProperty>();
- // Mocking EdmProperties
- EdmProperty edmProperty1 = EasyMock.createMock(EdmProperty.class);
- EdmProperty edmProperty2 = EasyMock.createMock(EdmProperty.class);
- EdmType edmType1 = EasyMock.createMock(EdmType.class);
- EdmType edmType2 = EasyMock.createMock(EdmType.class);
- EdmMapping mapping1 = EasyMock.createMock(EdmMapping.class);
- EdmMapping mapping2 = EasyMock.createMock(EdmMapping.class);
- try {
- EasyMock.expect(edmType1.getKind()).andStubReturn(EdmTypeKind.SIMPLE);
- EasyMock.replay(edmType1);
- EasyMock.expect(mapping1.getInternalName()).andStubReturn("id");
- EasyMock.replay(mapping1);
- EasyMock.expect(edmProperty1.getName()).andStubReturn("Id");
- EasyMock.expect(edmProperty1.getMapping()).andStubReturn(mapping1);
- EasyMock.expect(edmProperty1.getType()).andStubReturn(edmType1);
- EasyMock.replay(edmProperty1);
- EasyMock.expect(edmType2.getKind()).andStubReturn(EdmTypeKind.COMPLEX);
- EasyMock.replay(edmType2);
- EasyMock.expect(mapping2.getInternalName()).andStubReturn("relatedEntity.order");
- EasyMock.replay(mapping2);
- EasyMock.expect(edmProperty2.getName()).andStubReturn("Order");
- EasyMock.expect(edmProperty2.getMapping()).andStubReturn(mapping2);
- EasyMock.expect(edmProperty2.getType()).andStubReturn(edmType2);
- EasyMock.replay(edmProperty2);
-
- } catch (EdmException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
- selectPropertyList.add(edmProperty1);
- selectPropertyList.add(edmProperty2);
- try {
- Map<String, Object> result = resultParser.parse2EdmPropertyValueMap(jpaEntity, selectPropertyList);
- assertEquals("DemoOrder", result.get("Order"));
- } catch (ODataJPARuntimeException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
-
- }
-
- // This unit tests when there is a complex type in the select list
- @SuppressWarnings("unchecked")
- @Test
- public void testparse2EdmPropertyValueMapFromListComplex() {
- JPAEntityParser resultParser = new JPAEntityParser();
- demoItem jpaEntity = new demoItem("laptop", 1);
- DemoRelatedEntity relatedEntity = new DemoRelatedEntity("DemoOrder");
- jpaEntity.setRelatedEntity(relatedEntity);
- List<EdmProperty> selectPropertyList = new ArrayList<EdmProperty>();
- // Mocking EdmProperties
- EdmProperty edmProperty1 = EasyMock.createMock(EdmProperty.class);
- EdmProperty edmProperty2 = EasyMock.createMock(EdmProperty.class);
- EdmProperty edmComplexProperty = EasyMock.createMock(EdmProperty.class);
- EdmType edmType1 = EasyMock.createMock(EdmType.class);
- EdmStructuralType edmType2 = EasyMock.createMock(EdmStructuralType.class);
- EdmType edmComplexType = EasyMock.createMock(EdmType.class);
- EdmMapping mapping1 = EasyMock.createMock(EdmMapping.class);
- EdmMapping mapping2 = EasyMock.createMock(EdmMapping.class);
- EdmMapping complexMapping = EasyMock.createMock(EdmMapping.class);
- try {
- EasyMock.expect(edmType1.getKind()).andStubReturn(EdmTypeKind.SIMPLE);
- EasyMock.replay(edmType1);
- EasyMock.expect(mapping1.getInternalName()).andStubReturn("id");
- EasyMock.replay(mapping1);
- EasyMock.expect(edmProperty1.getName()).andStubReturn("Id");
- EasyMock.expect(edmProperty1.getMapping()).andStubReturn(mapping1);
- EasyMock.expect(edmProperty1.getType()).andStubReturn(edmType1);
- EasyMock.replay(edmProperty1);
- // Mocking the complex properties
- EasyMock.expect(edmComplexType.getKind()).andStubReturn(EdmTypeKind.SIMPLE);
- EasyMock.replay(edmComplexType);
- EasyMock.expect(complexMapping.getInternalName()).andStubReturn("order");
- EasyMock.replay(complexMapping);
- EasyMock.expect(edmComplexProperty.getName()).andStubReturn("OrderName");
- EasyMock.expect(edmComplexProperty.getMapping()).andStubReturn(complexMapping);
- EasyMock.expect(edmComplexProperty.getType()).andStubReturn(edmComplexType);
- EasyMock.replay(edmComplexProperty);
- EasyMock.expect(edmType2.getKind()).andStubReturn(EdmTypeKind.COMPLEX);
- EasyMock.expect(edmType2.getProperty("OrderName")).andStubReturn(edmComplexProperty);
- List<String> propertyNames = new ArrayList<String>();
- propertyNames.add("OrderName");
- EasyMock.expect(edmType2.getPropertyNames()).andStubReturn(propertyNames);
- EasyMock.replay(edmType2);
- EasyMock.expect(mapping2.getInternalName()).andStubReturn("relatedEntity");
- EasyMock.replay(mapping2);
- EasyMock.expect(edmProperty2.getName()).andStubReturn("Order");
- EasyMock.expect(edmProperty2.getMapping()).andStubReturn(mapping2);
- EasyMock.expect(edmProperty2.getType()).andStubReturn(edmType2);
- EasyMock.replay(edmProperty2);
-
- } catch (EdmException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage()
- + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
- selectPropertyList.add(edmProperty1);
- selectPropertyList.add(edmProperty2);
- try {
- Map<String, Object> result = resultParser.parse2EdmPropertyValueMap(jpaEntity, selectPropertyList);
- assertEquals(1, ((HashMap<String, Object>) result.get("Order")).size());
- } catch (ODataJPARuntimeException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage()
- + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
-
- }
-
- /*
- * TestCase - getGetterName is a private method in JPAResultParser. The
- * method is uses reflection to derive the property access methods from
- * EdmProperty
- */
- @Test
- public void testGetGettersWithOutMapping() {
- JPAEntityParser resultParser = new JPAEntityParser();
- try {
-
- /*
- * Case 1 - Property having No mapping
- */
- Class<?>[] pars = { String.class, EdmMapping.class, String.class };
- Object[] params = { "Field1", null, "get" };
- Method getGetterName = resultParser.getClass().getDeclaredMethod("getAccessModifierName", pars);
- getGetterName.setAccessible(true);
- String name = (String) getGetterName.invoke(resultParser, params);
-
- assertEquals("getField1", name);
-
- } catch (IllegalAccessException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- } catch (IllegalArgumentException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- } catch (InvocationTargetException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- } catch (NoSuchMethodException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- } catch (SecurityException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
-
- }
- }
-
- @Test
- public void testGetGettersWithNullPropname() {
- JPAEntityParser resultParser = new JPAEntityParser();
- try {
-
- /*
- * Case 1 - Property having No mapping and no name
- */
- Class<?>[] pars = { String.class, EdmMapping.class, String.class };
- Object[] params = { null, null, null };
- Method getGetterName = resultParser.getClass().getDeclaredMethod("getAccessModifierName", pars);
- getGetterName.setAccessible(true);
-
- String name = (String) getGetterName.invoke(resultParser, params);
- assertNull(name);
-
- } catch (IllegalAccessException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- } catch (IllegalArgumentException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- } catch (InvocationTargetException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- } catch (NoSuchMethodException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- } catch (SecurityException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
-
- }
- }
-
- /*
- * TestCase - getGetterName is a private method in JPAResultParser. The
- * method is uses reflection to derive the property access methods from
- * EdmProperty
- *
- * EdmProperty name could have been modified. Then mapping object of
- * EdmProperty should be used for deriving the name
- */
- @Test
- public void testGetGettersWithMapping() {
- JPAEntityParser resultParser = new JPAEntityParser();
- EdmMapping edmMapping = EasyMock.createMock(EdmMapping.class);
- EasyMock.expect(edmMapping.getInternalName()).andStubReturn("field1");
- EasyMock.replay(edmMapping);
- try {
-
- Class<?>[] pars = { String.class, EdmMapping.class, String.class };
- Object[] params = { "myField", edmMapping, "get" };
- Method getGetterName = resultParser.getClass().getDeclaredMethod("getAccessModifierName", pars);
- getGetterName.setAccessible(true);
-
- String name = (String) getGetterName.invoke(resultParser, params);
- assertEquals("getField1", name);
-
- } catch (IllegalAccessException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- } catch (IllegalArgumentException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- } catch (InvocationTargetException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- } catch (NoSuchMethodException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- } catch (SecurityException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
-
- }
- }
-
- @Test
- public void testGetGettersNoSuchMethodException() {
- JPAEntityParser resultParser = new JPAEntityParser();
- try {
-
- Method getGetterName = resultParser.getClass().getDeclaredMethod("getGetterName1", EdmProperty.class);
- getGetterName.setAccessible(true);
-
- } catch (NoSuchMethodException e) {
- assertEquals(
- "org.apache.olingo.odata2.processor.core.jpa.access.data.JPAEntityParser.getGetterName1" +
- "(org.apache.olingo.odata2.api.edm.EdmProperty)",
- e.getMessage());
- } catch (SecurityException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
-
- }
- }
-
- @Test
- public void testParse2EdmPropertyValueMap() {
- JPAEntityParser resultParser = new JPAEntityParser();
- Object jpaEntity = new DemoItem2("abc");
- try {
- resultParser.parse2EdmPropertyValueMap(jpaEntity, getEdmPropertyList());
- } catch (ODataJPARuntimeException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
- }
-
- @Test
- public void testGetGetterEdmException() {
- JPAEntityParser resultParser = new JPAEntityParser();
- Object jpaEntity = new demoItem("abc", 10);
- EdmStructuralType structuralType = EasyMock.createMock(EdmStructuralType.class);
- try {
- EasyMock.expect(structuralType.getPropertyNames()).andStubThrow(new EdmException(null));
- EasyMock.replay(structuralType);
- Method getGetters =
- resultParser.getClass().getDeclaredMethod("getGetters", Object.class, EdmStructuralType.class);
- getGetters.setAccessible(true);
- try {
- getGetters.invoke(resultParser, jpaEntity, structuralType);
- } catch (IllegalAccessException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- } catch (IllegalArgumentException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- } catch (InvocationTargetException e) {
- assertTrue(true);
- }
- } catch (NoSuchMethodException e) {
- assertEquals(
- "org.apache.olingo.odata2.processor.core.jpa.access.data.JPAEntityParser.getGetters(java.lang.Object, " +
- "org.apache.olingo.odata2.api.edm.EdmStructuralType)",
- e.getMessage());
- } catch (SecurityException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- } catch (EdmException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
- }
-
- @Test
- public void testForNullJPAEntity() {
- JPAEntityParser resultParser = new JPAEntityParser();
- EdmStructuralType structuralType = EasyMock.createMock(EdmStructuralType.class);
- Object map;
- try {
- map = resultParser.parse2EdmPropertyValueMap(null, structuralType);
- assertNull(map);
- } catch (ODataJPARuntimeException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
- }
-
- class demoItem {
- private String id;
- private int value;
- private DemoRelatedEntity relatedEntity;
-
- public String getId() {
- return id;
- }
-
- public void setId(final String id) {
- this.id = id;
- }
-
- public DemoRelatedEntity getRelatedEntity() {
- return relatedEntity;
- }
-
- public void setRelatedEntity(final DemoRelatedEntity relatedEntity) {
- this.relatedEntity = relatedEntity;
- }
-
- public int getValue() {
- return value;
- }
-
- public void setValue(final int value) {
- this.value = value;
- }
-
- demoItem(final String id, final int value) {
- this.id = id;
- this.value = value;
- }
-
- }
-
- class DemoRelatedEntity {
- String order;
-
- public String getOrder() {
- return order;
- }
-
- public void setOrder(final String order) {
- this.order = order;
- }
-
- public DemoRelatedEntity(final String order) {
- super();
- this.order = order;
- }
-
- }
-
- private List<EdmProperty> getEdmPropertyList() {
- List<EdmProperty> properties = new ArrayList<EdmProperty>();
- properties.add(getEdmProperty());
- return properties;
- }
-
- class DemoItem2 {
- private String field1;
-
- public String getField1() {
- return field1;
- }
-
- public void setField1(final String field) {
- field1 = field;
- }
-
- public DemoItem2(final String field) {
- field1 = field;
- }
-
- }
-
- private EdmProperty getEdmProperty() {
- EdmProperty edmTyped = EasyMock.createMock(EdmProperty.class);
-
- EdmMapping edmMapping = EasyMock.createMock(EdmMapping.class);
- EasyMock.expect(edmMapping.getInternalName()).andStubReturn("Field1");
- EasyMock.replay(edmMapping);
-
- EdmType edmType = EasyMock.createMock(EdmType.class);
-
- try {
- EasyMock.expect(edmType.getKind()).andStubReturn(EdmTypeKind.SIMPLE);
- EasyMock.expect(edmType.getName()).andStubReturn("identifier");
- EasyMock.expect(edmTyped.getName()).andStubReturn("SalesOrderHeader");
- EasyMock.expect(edmTyped.getMapping()).andStubReturn(edmMapping);
-
- EasyMock.expect(edmTyped.getType()).andStubReturn(edmType);
- EasyMock.expect(edmTyped.getMapping()).andStubReturn(edmMapping);
-
- } catch (EdmException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
- EasyMock.replay(edmType);
- EasyMock.replay(edmTyped);
- return edmTyped;
- }
-}
[22/37] [OLINGO-82] Renamed the project folder name to
odata2-jpa-processor
Posted by ch...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmModelTest.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmModelTest.java b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmModelTest.java
new file mode 100644
index 0000000..4192c2b
--- /dev/null
+++ b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmModelTest.java
@@ -0,0 +1,145 @@
+/*******************************************************************************
+ * 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.assertNotNull;
+import static org.junit.Assert.fail;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.persistence.metamodel.Attribute;
+import javax.persistence.metamodel.EmbeddableType;
+import javax.persistence.metamodel.Metamodel;
+
+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.core.jpa.common.ODataJPATestConstants;
+import org.apache.olingo.odata2.processor.core.jpa.mock.model.JPAEmbeddableMock;
+import org.apache.olingo.odata2.processor.core.jpa.mock.model.JPAMetaModelMock;
+import org.apache.olingo.odata2.processor.core.jpa.mock.model.JPASingularAttributeMock;
+import org.junit.Before;
+import org.junit.Test;
+
+public class JPAEdmModelTest extends JPAEdmTestModelView {
+
+ private JPAEdmModel objJPAEdmModel;
+
+ @Before
+ public void setUp() {
+ objJPAEdmModel = new JPAEdmModel(getJPAMetaModel(), "salesorderprocessing");
+ try {
+ objJPAEdmModel.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);
+ }
+ }
+
+ @Test
+ public void testGetEdmSchemaView() {
+ assertNotNull(objJPAEdmModel.getEdmSchemaView());
+ }
+
+ @Test
+ public void testGetBuilder() {
+ assertNotNull(objJPAEdmModel.getBuilder());
+ }
+
+ @Override
+ public Metamodel getJPAMetaModel() {
+ return new JPAEdmMetaModel();
+ }
+
+ private class JPAEdmMetaModel extends JPAMetaModelMock {
+ Set<EmbeddableType<?>> embeddableSet;
+
+ public JPAEdmMetaModel() {
+ embeddableSet = new HashSet<EmbeddableType<?>>();
+ }
+
+ @Override
+ public Set<EmbeddableType<?>> getEmbeddables() {
+ embeddableSet.add(new JPAEdmEmbeddable<String>());
+ return embeddableSet;
+ }
+
+ }
+
+ @SuppressWarnings("hiding")
+ private class JPAEdmEmbeddable<String> extends JPAEmbeddableMock<String> {
+
+ Set<Attribute<? super String, ?>> attributeSet = new HashSet<Attribute<? super String, ?>>();
+
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ private void setValuesToSet() {
+ attributeSet.add((Attribute<? super String, String>) new JPAEdmAttribute(java.lang.String.class, "SOID"));
+ attributeSet.add((Attribute<? super String, String>) new JPAEdmAttribute(java.lang.String.class, "SONAME"));
+ }
+
+ @Override
+ public Set<Attribute<? super String, ?>> getAttributes() {
+ setValuesToSet();
+ return attributeSet;
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public Class<String> getJavaType() {
+ return (Class<String>) java.lang.String.class;
+ }
+
+ }
+
+ @SuppressWarnings("hiding")
+ private class JPAEdmAttribute<Object, String> extends JPASingularAttributeMock<Object, String> {
+
+ @Override
+ public PersistentAttributeType getPersistentAttributeType() {
+ return PersistentAttributeType.BASIC;
+ }
+
+ Class<String> clazz;
+ java.lang.String attributeName;
+
+ public JPAEdmAttribute(final Class<String> javaType, final java.lang.String name) {
+ this.clazz = javaType;
+ this.attributeName = name;
+
+ }
+
+ @Override
+ public Class<String> getJavaType() {
+ return clazz;
+ }
+
+ @Override
+ public java.lang.String getName() {
+ return this.attributeName;
+ }
+
+ @Override
+ public boolean isId() {
+ return false;
+ }
+
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmNavigationPropertyTest.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmNavigationPropertyTest.java b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmNavigationPropertyTest.java
new file mode 100644
index 0000000..8912bf8
--- /dev/null
+++ b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmNavigationPropertyTest.java
@@ -0,0 +1,218 @@
+/*******************************************************************************
+ * 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.assertTrue;
+import static org.junit.Assert.fail;
+
+import javax.persistence.metamodel.Attribute;
+import javax.persistence.metamodel.EntityType;
+import javax.persistence.metamodel.Type;
+
+import org.apache.olingo.odata2.api.edm.FullQualifiedName;
+import org.apache.olingo.odata2.api.edm.provider.Association;
+import org.apache.olingo.odata2.api.edm.provider.AssociationEnd;
+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.JPAEdmEntityTypeView;
+import org.apache.olingo.odata2.processor.core.jpa.common.ODataJPATestConstants;
+import org.apache.olingo.odata2.processor.core.jpa.mock.model.JPAEntityTypeMock;
+import org.apache.olingo.odata2.processor.core.jpa.mock.model.JPAPluralAttributeMock;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class JPAEdmNavigationPropertyTest extends JPAEdmTestModelView {
+
+ private static JPAEdmNavigationProperty objNavigationProperty;
+ private static JPAEdmNavigationPropertyTest navPropView;
+
+ @BeforeClass
+ public static void setup() {
+ JPAEdmNavigationPropertyTest localView = new JPAEdmNavigationPropertyTest();
+ navPropView = new JPAEdmNavigationPropertyTest();
+ objNavigationProperty = new JPAEdmNavigationProperty(localView,
+ localView, 1);
+ try {
+ objNavigationProperty.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);
+ }
+ }
+
+ @Override
+ public String getpUnitName() {
+ return "salesorderprocessing";
+ }
+
+ @Override
+ public JPAEdmEntityTypeView getJPAEdmEntityTypeView() {
+ return this;
+ }
+
+ @Override
+ public EntityType<?> getJPAEntityType() {
+ return new JPAEdmEntityType();
+ }
+
+ private Attribute<?, ?> getJPAAttributeLocal() {
+ AttributeMock<Object, String> attr = new AttributeMock<Object, String>();
+ return attr;
+ }
+
+ @Override
+ public Attribute<?, ?> getJPAAttribute() {
+ return getJPAAttributeLocal();
+ }
+
+ @Override
+ public Association getEdmAssociation() {
+
+ Association association = new Association();
+ association.setName("Assoc_SalesOrderHeader_SalesOrderItem");
+ association.setEnd1(new AssociationEnd().setType(
+ new FullQualifiedName("salesorderprocessing", "String"))
+ .setRole("SalesOrderHeader"));
+ association.setEnd2(new AssociationEnd()
+ .setType(
+ new FullQualifiedName("salesorderprocessing",
+ "SalesOrderItem")).setRole("SalesOrderItem"));
+ return association;
+ }
+
+ @Test
+ public void testGetBuilder() {
+ assertNotNull(objNavigationProperty.getBuilder());
+
+ }
+
+ @Test
+ public void testGetBuilderIdempotent() {
+ JPAEdmBuilder builder1 = objNavigationProperty.getBuilder();
+ JPAEdmBuilder builder2 = objNavigationProperty.getBuilder();
+
+ assertEquals(builder1.hashCode(), builder2.hashCode());
+ }
+
+ @Test
+ public void testGetEdmNavigationProperty() {
+ if (objNavigationProperty == null || objNavigationProperty.getEdmNavigationProperty() == null) {
+ JPAEdmNavigationPropertyTest localView = new JPAEdmNavigationPropertyTest();
+ navPropView = new JPAEdmNavigationPropertyTest();
+ objNavigationProperty = new JPAEdmNavigationProperty(localView,
+ localView, 1);
+ try {
+ objNavigationProperty.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);
+ }
+ }
+ assertEquals(
+ objNavigationProperty.getEdmNavigationProperty().getName(),
+ "StringDetails");
+ }
+
+ @Test
+ public void testGetConsistentEdmNavigationProperties() {
+ assertTrue(objNavigationProperty.getConsistentEdmNavigationProperties()
+ .size() > 0);
+ }
+
+ @Test
+ public void testAddJPAEdmNavigationPropertyView() {
+ JPAEdmNavigationPropertyTest localView = new JPAEdmNavigationPropertyTest();
+ navPropView = new JPAEdmNavigationPropertyTest();
+ objNavigationProperty = new JPAEdmNavigationProperty(localView,
+ localView, 1);
+ try {
+ objNavigationProperty.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);
+ }
+ objNavigationProperty.addJPAEdmNavigationPropertyView(navPropView);
+ assertTrue(objNavigationProperty.getConsistentEdmNavigationProperties()
+ .size() > 1);
+ }
+
+ @Override
+ public boolean isConsistent() {
+ return true;
+ }
+
+ @Test
+ public void testBuildNavigationProperty() {
+
+ try {
+ objNavigationProperty.getBuilder().build();
+ } catch (ODataJPARuntimeException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ } catch (ODataJPAModelException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+ assertEquals(objNavigationProperty.getEdmNavigationProperty()
+ .getFromRole(), "SalesOrderItem");
+ assertEquals(objNavigationProperty.getEdmNavigationProperty()
+ .getToRole(), "SalesOrderHeader");
+
+ }
+
+ @SuppressWarnings("hiding")
+ private class AttributeMock<Object, String> extends
+ JPAPluralAttributeMock {
+
+ @Override
+ public boolean isCollection() {
+ return true;
+ }
+
+ @Override
+ public Type<java.lang.String> getElementType() {
+ return new ElementType();
+ }
+ }
+
+ private class JPAEdmEntityType extends JPAEntityTypeMock<String> {
+ @Override
+ public String getName() {
+ return "SalesOrderHeader";
+ }
+ }
+
+ private class ElementType implements Type<String> {
+
+ @Override
+ public javax.persistence.metamodel.Type.PersistenceType getPersistenceType() {
+ return PersistenceType.BASIC;
+ }
+
+ @Override
+ public Class<String> getJavaType() {
+ return String.class;
+ }
+
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmPropertyTest.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmPropertyTest.java b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmPropertyTest.java
new file mode 100644
index 0000000..633459f
--- /dev/null
+++ b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmPropertyTest.java
@@ -0,0 +1,440 @@
+/*******************************************************************************
+ * 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.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import javax.persistence.metamodel.Attribute;
+import javax.persistence.metamodel.Attribute.PersistentAttributeType;
+import javax.persistence.metamodel.EmbeddableType;
+import javax.persistence.metamodel.EntityType;
+import javax.persistence.metamodel.Metamodel;
+import javax.persistence.metamodel.Type;
+
+import org.apache.olingo.odata2.api.edm.FullQualifiedName;
+import org.apache.olingo.odata2.api.edm.provider.Association;
+import org.apache.olingo.odata2.api.edm.provider.AssociationEnd;
+import org.apache.olingo.odata2.api.edm.provider.Schema;
+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.JPAEdmAssociationView;
+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.core.jpa.common.ODataJPATestConstants;
+import org.apache.olingo.odata2.processor.core.jpa.mock.model.JPAEdmMockData.ComplexType;
+import org.apache.olingo.odata2.processor.core.jpa.mock.model.JPAEdmMockData.SimpleType;
+import org.apache.olingo.odata2.processor.core.jpa.mock.model.JPAEmbeddableTypeMock;
+import org.apache.olingo.odata2.processor.core.jpa.mock.model.JPAEntityTypeMock;
+import org.apache.olingo.odata2.processor.core.jpa.mock.model.JPAMetaModelMock;
+import org.apache.olingo.odata2.processor.core.jpa.mock.model.JPAPluralAttributeMock;
+import org.apache.olingo.odata2.processor.core.jpa.mock.model.JPASingularAttributeMock;
+import org.junit.Test;
+
+public class JPAEdmPropertyTest extends JPAEdmTestModelView {
+
+ private JPAEdmPropertyTest objJPAEdmPropertyTest;
+ private JPAEdmProperty objJPAEdmProperty;
+
+ private static PersistentAttributeType ATTRIBUTE_TYPE = PersistentAttributeType.BASIC;
+
+ public void setUp() {
+ ATTRIBUTE_TYPE = PersistentAttributeType.BASIC;
+ objJPAEdmPropertyTest = new JPAEdmPropertyTest();
+ objJPAEdmProperty = new JPAEdmProperty(objJPAEdmPropertyTest);
+ try {
+ objJPAEdmProperty.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);
+ }
+
+ }
+
+ @Test
+ public void testGetBuilder() {
+ setUp();
+ assertNotNull(objJPAEdmProperty.getBuilder());
+ }
+
+ @Test
+ public void testGetBuilderIdempotent() {
+ setUp();
+ JPAEdmBuilder builder1 = objJPAEdmProperty.getBuilder();
+ JPAEdmBuilder builder2 = objJPAEdmProperty.getBuilder();
+
+ assertEquals(builder1.hashCode(), builder2.hashCode());
+ }
+
+ @Test
+ public void testGetPropertyList() {
+ setUp();
+ assertNotNull(objJPAEdmProperty.getEdmPropertyList());
+ assertTrue(objJPAEdmProperty.getEdmPropertyList().size() > 0);
+ }
+
+ @Test
+ public void testGetJPAEdmKeyView() {
+ setUp();
+ assertNotNull(objJPAEdmProperty.getJPAEdmKeyView());
+ }
+
+ @Test
+ public void testGetSimpleProperty() {
+ setUp();
+ assertNotNull(objJPAEdmProperty.getEdmSimpleProperty());
+ }
+
+ @Test
+ public void testGetJPAAttribute() {
+ setUp();
+ assertNotNull(objJPAEdmProperty.getJPAAttribute());
+ }
+
+ @Test
+ public void testGetEdmComplexProperty() {
+
+ // builder for complex type
+ ATTRIBUTE_TYPE = PersistentAttributeType.EMBEDDED;
+ objJPAEdmPropertyTest = new JPAEdmPropertyTest();
+ objJPAEdmProperty = new JPAEdmProperty(objJPAEdmPropertyTest, objJPAEdmPropertyTest);
+ try {
+ objJPAEdmProperty.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);
+ }
+
+ assertNotNull(objJPAEdmProperty.getEdmComplexProperty());
+ }
+
+ @Test
+ public void testGetJPAEdmNavigationPropertyView() {
+ setUp();
+ assertNotNull(objJPAEdmProperty.getJPAEdmNavigationPropertyView());
+ }
+
+ @Test
+ public void testIsConsistent() {
+ setUp();
+ assertNotNull(objJPAEdmProperty.isConsistent());
+ }
+
+ @Test
+ public void testClean() {
+ setUp();
+ objJPAEdmProperty.clean();
+ assertFalse(objJPAEdmProperty.isConsistent());
+ }
+
+ @Test
+ public void testBuildManyToOne() {
+ ATTRIBUTE_TYPE = PersistentAttributeType.MANY_TO_ONE;
+ objJPAEdmPropertyTest = new JPAEdmPropertyTest();
+ objJPAEdmProperty = new JPAEdmProperty(objJPAEdmPropertyTest);
+ try {
+ objJPAEdmProperty.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);
+ }
+
+ assertNotNull(objJPAEdmProperty.getJPAEdmNavigationPropertyView().getEdmNavigationProperty());
+ }
+
+ @Override
+ public Metamodel getJPAMetaModel() {
+ return new JPAEdmMetaModel();
+ }
+
+ @Override
+ public List<String> getNonKeyComplexTypeList() {
+ return new ArrayList<String>();
+ }
+
+ @Override
+ public Schema getEdmSchema() {
+ Schema schema = new Schema();
+ schema.setNamespace(getpUnitName());
+ return schema;
+ }
+
+ @Override
+ public org.apache.olingo.odata2.api.edm.provider.ComplexType searchEdmComplexType(final String arg0) {
+ org.apache.olingo.odata2.api.edm.provider.ComplexType complexType =
+ new org.apache.olingo.odata2.api.edm.provider.ComplexType();
+ complexType.setName("ComplexTypeA");
+ return complexType;
+ }
+
+ @Override
+ public JPAEdmEntitySetView getJPAEdmEntitySetView() {
+ return this;
+ }
+
+ @Override
+ public JPAEdmEntityContainerView getJPAEdmEntityContainerView() {
+ return this;
+ }
+
+ @Override
+ public EntityType<?> getJPAEntityType() {
+ return new JPAEdmEntityType<String>();
+ }
+
+ @Override
+ public JPAEdmEntityTypeView getJPAEdmEntityTypeView() {
+ return this;
+ }
+
+ @Override
+ public org.apache.olingo.odata2.api.edm.provider.EntityType getEdmEntityType() {
+ org.apache.olingo.odata2.api.edm.provider.EntityType entityType =
+ new org.apache.olingo.odata2.api.edm.provider.EntityType();
+ entityType.setName("SalesOrderHeader");
+
+ return entityType;
+ }
+
+ @Override
+ public Association getEdmAssociation() {
+ Association association = new Association();
+ association
+ .setEnd1(new AssociationEnd().setType(new FullQualifiedName("salesorderprocessing", "SalesOrderHeader")));
+ association.setEnd2(new AssociationEnd().setType(new FullQualifiedName("salesorderprocessing", "String")));
+
+ return association;
+ }
+
+ @Override
+ public String getpUnitName() {
+ return "salesorderprocessing";
+ }
+
+ @Override
+ public JPAEdmAssociationView getJPAEdmAssociationView() {
+ return this;
+ }
+
+ @Override
+ public EmbeddableType<?> getJPAEmbeddableType() {
+ return new JPAEdmEmbeddable<java.lang.String>();
+ }
+
+ @Override
+ public JPAEdmComplexTypeView getJPAEdmComplexTypeView() {
+ return this;
+ }
+
+ private class JPAEdmMetaModel extends JPAMetaModelMock {
+ Set<EntityType<?>> entities;
+ Set<EmbeddableType<?>> embeddableSet;
+
+ public JPAEdmMetaModel() {
+ entities = new HashSet<EntityType<?>>();
+ embeddableSet = new HashSet<EmbeddableType<?>>();
+ }
+
+ @Override
+ public Set<EntityType<?>> getEntities() {
+ entities.add(new JPAEdmEntityType());
+ return entities;
+ }
+
+ @Override
+ public Set<EmbeddableType<?>> getEmbeddables() {
+ embeddableSet.add(new JPAEdmEmbeddable<String>());
+ return embeddableSet;
+ }
+
+ private class JPAEdmEntityType extends JPAEntityTypeMock<String> {
+ @Override
+ public String getName() {
+ return "SalesOrderHeader";
+ }
+ }
+ }
+
+ @SuppressWarnings("hiding")
+ private class JPAEdmEntityType<String> extends JPAEntityTypeMock<String> {
+ Set<Attribute<? super String, ?>> attributeSet = new HashSet<Attribute<? super String, ?>>();
+
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ private void setValuesToSet() {
+ if (JPAEdmPropertyTest.ATTRIBUTE_TYPE.equals(PersistentAttributeType.BASIC)) {
+ attributeSet.add((Attribute<? super String, String>) new JPAEdmAttribute(java.lang.String.class, "SOID"));
+ attributeSet.add((Attribute<? super String, String>) new JPAEdmAttribute(java.lang.String.class, "SONAME"));
+ } else if (JPAEdmPropertyTest.ATTRIBUTE_TYPE.equals(PersistentAttributeType.EMBEDDED)) {
+ attributeSet.add(new JPAEdmAttribute(JPAEdmEmbeddable.class, ComplexType.ComplexTypeA.clazz.getName()));
+ } else if (JPAEdmPropertyTest.ATTRIBUTE_TYPE.equals(PersistentAttributeType.MANY_TO_ONE)) {
+ attributeSet.add(new JPAEdmPluralAttribute());
+ }
+ }
+
+ @Override
+ public Set<Attribute<? super String, ?>> getAttributes() {
+ setValuesToSet();
+ return attributeSet;
+ }
+
+ private class JPAEdmPluralAttribute extends JPAPluralAttributeMock {
+ @Override
+ public java.lang.String getName() {
+ return "salesorderheaderdetails";
+ }
+
+ @Override
+ public javax.persistence.metamodel.Attribute.PersistentAttributeType getPersistentAttributeType() {
+ return ATTRIBUTE_TYPE;
+ }
+
+ @Override
+ public boolean isCollection() {
+ return true;
+ }
+
+ @Override
+ public Type<java.lang.String> getElementType() {
+ return new Type<java.lang.String>() {
+
+ @Override
+ public Class<java.lang.String> getJavaType() {
+ return java.lang.String.class;
+ }
+
+ @Override
+ public javax.persistence.metamodel.Type.PersistenceType getPersistenceType() {
+ return null;
+ }
+
+ };
+ }
+ }
+
+ private class JPAEdmAttribute<Object, String> extends JPASingularAttributeMock<Object, String> {
+
+ @Override
+ public PersistentAttributeType getPersistentAttributeType() {
+ return ATTRIBUTE_TYPE;
+ }
+
+ Class<String> clazz;
+ java.lang.String attributeName;
+
+ public JPAEdmAttribute(final Class<String> javaType, final java.lang.String name) {
+ this.clazz = javaType;
+ this.attributeName = name;
+
+ }
+
+ @Override
+ public Class<String> getJavaType() {
+ return clazz;
+ }
+
+ @Override
+ public java.lang.String getName() {
+ return this.attributeName;
+ }
+
+ @Override
+ public boolean isId() {
+ return true;
+ }
+ }
+ }
+
+ @SuppressWarnings("hiding")
+ private class JPAEdmEmbeddable<String> extends JPAEmbeddableTypeMock<String> {
+
+ Set<Attribute<? super String, ?>> attributeSet = new HashSet<Attribute<? super String, ?>>();
+
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ private void setValuesToSet() {
+ attributeSet.add((Attribute<? super String, String>) new JPAEdmAttribute(java.lang.String.class, "SOID"));
+ attributeSet.add((Attribute<? super String, String>) new JPAEdmAttribute(java.lang.String.class, "SONAME"));
+ }
+
+ @Override
+ public Set<Attribute<? super String, ?>> getAttributes() {
+ setValuesToSet();
+ return attributeSet;
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public Class<String> getJavaType() {
+ Class<?> clazz = null;
+ if (ATTRIBUTE_TYPE.equals(PersistentAttributeType.BASIC)) {
+ clazz = (Class<java.lang.String>) SimpleType.SimpleTypeA.clazz;
+ } else {
+ clazz = (Class<?>) ComplexType.ComplexTypeA.clazz;
+ }
+ return (Class<String>) clazz;
+ }
+
+ private class JPAEdmAttribute<Object, String> extends JPASingularAttributeMock<Object, String> {
+
+ @Override
+ public PersistentAttributeType getPersistentAttributeType() {
+ return ATTRIBUTE_TYPE;
+ }
+
+ Class<String> clazz;
+ java.lang.String attributeName;
+
+ public JPAEdmAttribute(final Class<String> javaType, final java.lang.String name) {
+ this.clazz = javaType;
+ this.attributeName = name;
+
+ }
+
+ @Override
+ public Class<String> getJavaType() {
+ return clazz;
+ }
+
+ @Override
+ public java.lang.String getName() {
+ return this.attributeName;
+ }
+
+ @Override
+ public boolean isId() {
+ return true;
+ }
+ }
+
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmReferentialConstraintRoleTest.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmReferentialConstraintRoleTest.java b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmReferentialConstraintRoleTest.java
new file mode 100644
index 0000000..6c8c5eb
--- /dev/null
+++ b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmReferentialConstraintRoleTest.java
@@ -0,0 +1,233 @@
+/*******************************************************************************
+ * 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.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Member;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.persistence.JoinColumn;
+import javax.persistence.metamodel.Attribute;
+import javax.persistence.metamodel.ManagedType;
+
+import org.apache.olingo.odata2.api.edm.FullQualifiedName;
+import org.apache.olingo.odata2.api.edm.provider.Association;
+import org.apache.olingo.odata2.api.edm.provider.AssociationEnd;
+import org.apache.olingo.odata2.api.edm.provider.EntityType;
+import org.apache.olingo.odata2.api.edm.provider.Mapping;
+import org.apache.olingo.odata2.api.edm.provider.Property;
+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.JPAEdmReferentialConstraintRoleView.RoleType;
+import org.apache.olingo.odata2.processor.core.jpa.common.ODataJPATestConstants;
+import org.apache.olingo.odata2.processor.core.jpa.mock.model.JPAAttributeMock;
+import org.apache.olingo.odata2.processor.core.jpa.mock.model.JPAJavaMemberMock;
+import org.apache.olingo.odata2.processor.core.jpa.mock.model.JPAManagedTypeMock;
+import org.easymock.EasyMock;
+import org.junit.Before;
+import org.junit.Test;
+
+public class JPAEdmReferentialConstraintRoleTest extends JPAEdmTestModelView {
+
+ private static JPAEdmReferentialConstraintRole objJPAEdmReferentialConstraintRole = null;
+ private static JPAEdmReferentialConstraintRoleTest objJPAEdmReferentialConstraintRoleTest = null;
+
+ @Before
+ public void setUp() {
+ objJPAEdmReferentialConstraintRoleTest = new JPAEdmReferentialConstraintRoleTest();
+
+ objJPAEdmReferentialConstraintRole =
+ new JPAEdmReferentialConstraintRole(RoleType.PRINCIPAL, objJPAEdmReferentialConstraintRoleTest,
+ objJPAEdmReferentialConstraintRoleTest, objJPAEdmReferentialConstraintRoleTest);
+
+ try {
+ objJPAEdmReferentialConstraintRole.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);
+ }
+ }
+
+ @Test
+ public void testIsExists() {
+ assertTrue(objJPAEdmReferentialConstraintRole.isExists());// Default
+ }
+
+ @Test
+ public void testGetBuilder() {
+ assertNotNull(objJPAEdmReferentialConstraintRole.getBuilder());
+ }
+
+ @Test
+ public void testGetBuilderIdempotent() {
+ JPAEdmBuilder builder1 = objJPAEdmReferentialConstraintRole.getBuilder();
+ JPAEdmBuilder builder2 = objJPAEdmReferentialConstraintRole.getBuilder();
+
+ assertEquals(builder1.hashCode(), builder2.hashCode());
+ }
+
+ @Test
+ public void testGetRoleTypePrincipal() {
+ assertEquals(objJPAEdmReferentialConstraintRole.getRoleType(), RoleType.PRINCIPAL);
+ }
+
+ @Test
+ public void testGetRoleTypeDependent() {
+ objJPAEdmReferentialConstraintRoleTest = new JPAEdmReferentialConstraintRoleTest();
+ objJPAEdmReferentialConstraintRole =
+ new JPAEdmReferentialConstraintRole(RoleType.DEPENDENT, objJPAEdmReferentialConstraintRoleTest,
+ objJPAEdmReferentialConstraintRoleTest, objJPAEdmReferentialConstraintRoleTest);
+
+ try {
+ objJPAEdmReferentialConstraintRole.getBuilder().build();
+ objJPAEdmReferentialConstraintRole.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);
+ }
+ assertEquals(objJPAEdmReferentialConstraintRole.getRoleType(), RoleType.DEPENDENT);
+ }
+
+ @Test
+ public void testGetEdmReferentialConstraintRole() {
+ try {
+ objJPAEdmReferentialConstraintRole.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);
+ }
+ assertNotNull(objJPAEdmReferentialConstraintRole.getEdmReferentialConstraintRole());
+ }
+
+ @Test
+ public void testGetJPAColumnName() {
+ assertNull(objJPAEdmReferentialConstraintRole.getJPAColumnName());
+ }
+
+ @Test
+ public void testGetEdmEntityTypeName() {
+ assertNull(objJPAEdmReferentialConstraintRole.getEdmEntityTypeName());
+ }
+
+ @Test
+ public void testGetEdmAssociationName() {
+ assertNull(objJPAEdmReferentialConstraintRole.getEdmAssociationName());
+ }
+
+ @Override
+ public Attribute<?, ?> getJPAAttribute() {
+ return getJPAAttributeLocal();
+ }
+
+ @Override
+ public Association getEdmAssociation() {
+ Association association = new Association();
+ association.setName("Assoc_SalesOrderHeader_SalesOrderItem");
+ association.setEnd1(new AssociationEnd().setType(new FullQualifiedName("salesorderprocessing", "String")).setRole(
+ "SalesOrderHeader"));
+ association.setEnd2(new AssociationEnd().setType(new FullQualifiedName("salesorderprocessing", "SalesOrderItem"))
+ .setRole("SalesOrderItem"));
+ return association;
+ }
+
+ @Override
+ public EntityType searchEdmEntityType(final String arg0) {
+
+ EntityType entityType = new EntityType();
+
+ JPAEdmMappingImpl mapping = new JPAEdmMappingImpl();
+ mapping.setJPAColumnName("SOID");
+
+ List<Property> propList = new ArrayList<Property>();
+
+ Property property = new Property() {};
+ property.setMapping((Mapping) mapping);
+ property.setName("SOID");
+ propList.add(property);
+
+ entityType.setProperties(propList);
+
+ return entityType;
+ }
+
+ private Attribute<?, ?> getJPAAttributeLocal() {
+ AttributeMock<Object, String> attr = new AttributeMock<Object, String>();
+ return attr;
+ }
+
+ @SuppressWarnings("hiding")
+ private class AttributeMock<Object, String> extends JPAAttributeMock<Object, String> {
+
+ @Override
+ public Member getJavaMember() {
+ return new JavaMemberMock();
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public Class<String> getJavaType() {
+ return (Class<String>) java.lang.String.class;
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public ManagedType<Object> getDeclaringType() {
+ return (ManagedType<Object>) getManagedTypeLocal();
+ }
+
+ private ManagedType<?> getManagedTypeLocal() {
+ ManagedTypeMock<String> managedTypeMock = new ManagedTypeMock<String>();
+ return managedTypeMock;
+ }
+ }
+
+ @SuppressWarnings("hiding")
+ private class ManagedTypeMock<String> extends JPAManagedTypeMock<String> {
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public Class<String> getJavaType() {
+ return (Class<String>) java.lang.String.class;
+ }
+ }
+
+ private class JavaMemberMock extends JPAJavaMemberMock {
+ @SuppressWarnings("unchecked")
+ @Override
+ public <T extends Annotation> T getAnnotation(final Class<T> annotationClass) {
+ JoinColumn joinColumn = EasyMock.createMock(JoinColumn.class);
+ EasyMock.expect(joinColumn.referencedColumnName()).andReturn("SOID");
+ EasyMock.expect(joinColumn.name()).andReturn("SOID");
+
+ EasyMock.replay(joinColumn);
+ return (T) joinColumn;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmReferentialConstraintTest.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmReferentialConstraintTest.java b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmReferentialConstraintTest.java
new file mode 100644
index 0000000..84b7ad4
--- /dev/null
+++ b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmReferentialConstraintTest.java
@@ -0,0 +1,177 @@
+/*******************************************************************************
+ * 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.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Member;
+
+import javax.persistence.JoinColumn;
+import javax.persistence.metamodel.Attribute;
+import javax.persistence.metamodel.ManagedType;
+
+import org.apache.olingo.odata2.api.edm.FullQualifiedName;
+import org.apache.olingo.odata2.api.edm.provider.Association;
+import org.apache.olingo.odata2.api.edm.provider.AssociationEnd;
+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.core.jpa.common.ODataJPATestConstants;
+import org.apache.olingo.odata2.processor.core.jpa.mock.model.JPAAttributeMock;
+import org.apache.olingo.odata2.processor.core.jpa.mock.model.JPAJavaMemberMock;
+import org.apache.olingo.odata2.processor.core.jpa.mock.model.JPAManagedTypeMock;
+import org.easymock.EasyMock;
+import org.junit.Before;
+import org.junit.Test;
+
+public class JPAEdmReferentialConstraintTest extends JPAEdmTestModelView {
+
+ private static JPAEdmReferentialConstraint objJPAEdmReferentialConstraint = null;
+ private static JPAEdmReferentialConstraintTest objJPAEdmReferentialConstraintTest = null;
+
+ @Before
+ public void setUp() {
+ objJPAEdmReferentialConstraintTest = new JPAEdmReferentialConstraintTest();
+ objJPAEdmReferentialConstraint =
+ new JPAEdmReferentialConstraint(objJPAEdmReferentialConstraintTest, objJPAEdmReferentialConstraintTest,
+ objJPAEdmReferentialConstraintTest);
+ try {
+ objJPAEdmReferentialConstraint.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);
+ }
+ }
+
+ @Test
+ public void testGetBuilder() {
+ assertNotNull(objJPAEdmReferentialConstraint.getBuilder());
+ }
+
+ @Test
+ public void testGetBuilderIdempotent() {
+ JPAEdmBuilder builder1 = objJPAEdmReferentialConstraint.getBuilder();
+ JPAEdmBuilder builder2 = objJPAEdmReferentialConstraint.getBuilder();
+
+ assertEquals(builder1.hashCode(), builder2.hashCode());
+ }
+
+ @Test
+ public void testGetEdmReferentialConstraint() {
+ assertNotNull(objJPAEdmReferentialConstraint.getEdmReferentialConstraint());
+ }
+
+ @Test
+ public void testIsExistsTrue() {
+ objJPAEdmReferentialConstraintTest = new JPAEdmReferentialConstraintTest();
+ objJPAEdmReferentialConstraint =
+ new JPAEdmReferentialConstraint(objJPAEdmReferentialConstraintTest, objJPAEdmReferentialConstraintTest,
+ objJPAEdmReferentialConstraintTest);
+ try {
+ objJPAEdmReferentialConstraint.getBuilder().build();
+ objJPAEdmReferentialConstraint.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);
+ }
+ assertTrue(objJPAEdmReferentialConstraint.isExists());
+ }
+
+ @Test
+ public void testGetRelationShipName() {
+ assertEquals("Assoc_SalesOrderHeader_SalesOrderItem", objJPAEdmReferentialConstraint.getEdmRelationShipName());
+ }
+
+ @Override
+ public Association getEdmAssociation() {
+ Association association = new Association();
+ association.setName("Assoc_SalesOrderHeader_SalesOrderItem");
+ association.setEnd1(new AssociationEnd().setType(new FullQualifiedName("salesorderprocessing", "String")).setRole(
+ "SalesOrderHeader"));
+ association.setEnd2(new AssociationEnd().setType(new FullQualifiedName("salesorderprocessing", "SalesOrderItem"))
+ .setRole("SalesOrderItem"));
+ return association;
+ }
+
+ private Attribute<?, ?> getJPAAttributeLocal() {
+ AttributeMock<Object, String> attr = new AttributeMock<Object, String>();
+ return attr;
+ }
+
+ @Override
+ public Attribute<?, ?> getJPAAttribute() {
+ return getJPAAttributeLocal();
+ }
+
+ @SuppressWarnings("hiding")
+ private class AttributeMock<Object, String> extends JPAAttributeMock<Object, String> {
+
+ @Override
+ public Member getJavaMember() {
+ return new JavaMemberMock();
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public Class<String> getJavaType() {
+ return (Class<String>) java.lang.String.class;
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public ManagedType<Object> getDeclaringType() {
+ return (ManagedType<Object>) getManagedTypeLocal();
+ }
+
+ private ManagedType<?> getManagedTypeLocal() {
+ ManagedTypeMock<String> managedTypeMock = new ManagedTypeMock<String>();
+ return managedTypeMock;
+ }
+ }
+
+ @SuppressWarnings("hiding")
+ private class ManagedTypeMock<String> extends JPAManagedTypeMock<String> {
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public Class<String> getJavaType() {
+ return (Class<String>) java.lang.String.class;
+ }
+ }
+
+ private class JavaMemberMock extends JPAJavaMemberMock {
+ @SuppressWarnings("unchecked")
+ @Override
+ public <T extends Annotation> T getAnnotation(final Class<T> annotationClass) {
+ JoinColumn joinColumn = EasyMock.createMock(JoinColumn.class);
+ EasyMock.expect(joinColumn.referencedColumnName()).andReturn("SOID");
+ EasyMock.expect(joinColumn.name()).andReturn("SOID");
+
+ EasyMock.replay(joinColumn);
+ return (T) joinColumn;
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmSchemaTest.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmSchemaTest.java b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmSchemaTest.java
new file mode 100644
index 0000000..9d6848a
--- /dev/null
+++ b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmSchemaTest.java
@@ -0,0 +1,103 @@
+/*******************************************************************************
+ * 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.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+import javax.persistence.metamodel.Metamodel;
+
+import org.apache.olingo.odata2.processor.api.jpa.access.JPAEdmBuilder;
+import org.apache.olingo.odata2.processor.core.jpa.mock.model.JPAMetaModelMock;
+import org.junit.Before;
+import org.junit.Test;
+
+public class JPAEdmSchemaTest extends JPAEdmTestModelView {
+ private JPAEdmSchemaTest objJPAEdmSchemaTest;
+ private JPAEdmSchema objJPAEdmSchema;
+
+ @Before
+ public void setUp() {
+ objJPAEdmSchemaTest = new JPAEdmSchemaTest();
+ objJPAEdmSchema = new JPAEdmSchema(objJPAEdmSchemaTest);
+ // building schema is not required as downstream structure already tested
+
+ }
+
+ @Test
+ public void testClean() {
+ assertTrue(objJPAEdmSchema.isConsistent());
+ objJPAEdmSchema.clean();
+ assertFalse(objJPAEdmSchema.isConsistent());
+ }
+
+ @Test
+ public void testGetEdmSchema() {
+ assertNull(objJPAEdmSchema.getEdmSchema());
+ }
+
+ @Test
+ public void testGetJPAEdmEntityContainerView() {
+ assertNull(objJPAEdmSchema.getJPAEdmEntityContainerView());
+ }
+
+ @Test
+ public void testGetJPAEdmComplexTypeView() {
+ assertNull(objJPAEdmSchema.getJPAEdmComplexTypeView());
+ }
+
+ @Test
+ public void testGetBuilder() {
+ assertNotNull(objJPAEdmSchema.getBuilder());
+ }
+
+ @Test
+ public void testGetBuilderIdempotent() {
+ JPAEdmBuilder builder1 = objJPAEdmSchema.getBuilder();
+ JPAEdmBuilder builder2 = objJPAEdmSchema.getBuilder();
+
+ assertEquals(builder1.hashCode(), builder2.hashCode());
+ }
+
+ @Test
+ public void testGetJPAEdmAssociationView() {
+ assertNull(objJPAEdmSchema.getJPAEdmAssociationView());
+ }
+
+ @Test
+ public void testIsConsistent() {
+ assertTrue(objJPAEdmSchema.isConsistent());
+ objJPAEdmSchema.clean();
+ assertFalse(objJPAEdmSchema.isConsistent());
+ }
+
+ @Override
+ public Metamodel getJPAMetaModel() {
+ return new JPAMetaModelMock();
+ }
+
+ @Override
+ public String getpUnitName() {
+ return "salesorderprocessing";
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmTestModelView.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmTestModelView.java b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmTestModelView.java
new file mode 100644
index 0000000..cf96ac7
--- /dev/null
+++ b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmTestModelView.java
@@ -0,0 +1,396 @@
+/*******************************************************************************
+ * 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.util.HashMap;
+import java.util.List;
+
+import javax.persistence.metamodel.Attribute;
+import javax.persistence.metamodel.EmbeddableType;
+import javax.persistence.metamodel.Metamodel;
+
+import org.apache.olingo.odata2.api.edm.FullQualifiedName;
+import org.apache.olingo.odata2.api.edm.provider.Association;
+import org.apache.olingo.odata2.api.edm.provider.AssociationEnd;
+import org.apache.olingo.odata2.api.edm.provider.AssociationSet;
+import org.apache.olingo.odata2.api.edm.provider.ComplexProperty;
+import org.apache.olingo.odata2.api.edm.provider.ComplexType;
+import org.apache.olingo.odata2.api.edm.provider.EntityContainer;
+import org.apache.olingo.odata2.api.edm.provider.EntitySet;
+import org.apache.olingo.odata2.api.edm.provider.EntityType;
+import org.apache.olingo.odata2.api.edm.provider.Key;
+import org.apache.olingo.odata2.api.edm.provider.NavigationProperty;
+import org.apache.olingo.odata2.api.edm.provider.Property;
+import org.apache.olingo.odata2.api.edm.provider.ReferentialConstraint;
+import org.apache.olingo.odata2.api.edm.provider.Schema;
+import org.apache.olingo.odata2.api.edm.provider.SimpleProperty;
+import org.apache.olingo.odata2.processor.api.jpa.access.JPAEdmBuilder;
+import org.apache.olingo.odata2.processor.api.jpa.access.JPAEdmMappingModelAccess;
+import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmAssociationEndView;
+import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmAssociationSetView;
+import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmAssociationView;
+import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmBaseView;
+import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmComplexPropertyView;
+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.JPAEdmExtension;
+import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmKeyView;
+import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmModelView;
+import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmNavigationPropertyView;
+import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmPropertyView;
+import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmReferentialConstraintView;
+import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmSchemaView;
+
+public class JPAEdmTestModelView implements JPAEdmAssociationEndView, JPAEdmAssociationSetView, JPAEdmAssociationView,
+ JPAEdmBaseView, JPAEdmComplexPropertyView, JPAEdmComplexTypeView, JPAEdmEntityContainerView, JPAEdmEntitySetView,
+ JPAEdmEntityTypeView, JPAEdmKeyView, JPAEdmModelView, JPAEdmNavigationPropertyView, JPAEdmPropertyView,
+ JPAEdmReferentialConstraintView, JPAEdmSchemaView {
+
+ protected JPAEdmMappingModelAccess mappingModelAccess;
+
+ @Override
+ public Schema getEdmSchema() {
+ return null;
+ }
+
+ @Override
+ public JPAEdmAssociationView getJPAEdmAssociationView() {
+ return null;
+ }
+
+ @Override
+ public JPAEdmComplexTypeView getJPAEdmComplexTypeView() {
+ return null;
+ }
+
+ @Override
+ public JPAEdmEntityContainerView getJPAEdmEntityContainerView() {
+ return null;
+ }
+
+ @Override
+ public Attribute<?, ?> getJPAAttribute() {
+ return null;
+ }
+
+ @Override
+ public JPAEdmKeyView getJPAEdmKeyView() {
+ return null;
+ }
+
+ @Override
+ public List<Property> getEdmPropertyList() {
+ return null;
+ }
+
+ @Override
+ public SimpleProperty getEdmSimpleProperty() {
+ return null;
+ }
+
+ @Override
+ public JPAEdmSchemaView getEdmSchemaView() {
+ return null;
+ }
+
+ @Override
+ public Key getEdmKey() {
+ return null;
+ }
+
+ @Override
+ public List<EntityType> getConsistentEdmEntityTypes() {
+ return null;
+ }
+
+ @Override
+ public EntityType getEdmEntityType() {
+ return null;
+ }
+
+ @Override
+ public javax.persistence.metamodel.EntityType<?> getJPAEntityType() {
+ return null;
+ }
+
+ @Override
+ public List<EntitySet> getConsistentEdmEntitySetList() {
+ return null;
+ }
+
+ @Override
+ public EntitySet getEdmEntitySet() {
+ return null;
+ }
+
+ @Override
+ public JPAEdmEntityTypeView getJPAEdmEntityTypeView() {
+ return null;
+ }
+
+ @Override
+ public List<EntityContainer> getConsistentEdmEntityContainerList() {
+ return null;
+ }
+
+ @Override
+ public JPAEdmAssociationSetView getEdmAssociationSetView() {
+ return null;
+ }
+
+ @Override
+ public EntityContainer getEdmEntityContainer() {
+ return null;
+ }
+
+ @Override
+ public JPAEdmEntitySetView getJPAEdmEntitySetView() {
+ return null;
+ }
+
+ @Override
+ public void addJPAEdmCompleTypeView(final JPAEdmComplexTypeView arg0) {
+
+ }
+
+ @Override
+ public List<ComplexType> getConsistentEdmComplexTypes() {
+ return null;
+ }
+
+ @Override
+ public ComplexType getEdmComplexType() {
+ return null;
+ }
+
+ @Override
+ public EmbeddableType<?> getJPAEmbeddableType() {
+ return null;
+ }
+
+ @Override
+ public ComplexType searchEdmComplexType(final String arg0) {
+ return null;
+ }
+
+ @Override
+ public ComplexType searchEdmComplexType(final FullQualifiedName arg0) {
+ return null;
+ }
+
+ @Override
+ public ComplexProperty getEdmComplexProperty() {
+ return null;
+ }
+
+ @Override
+ public void clean() {
+
+ }
+
+ @Override
+ public JPAEdmBuilder getBuilder() {
+ return null;
+ }
+
+ @Override
+ public Metamodel getJPAMetaModel() {
+ return null;
+ }
+
+ @Override
+ public String getpUnitName() {
+ return null;
+ }
+
+ @Override
+ public boolean isConsistent() {
+ return false;
+ }
+
+ @Override
+ public void addJPAEdmRefConstraintView(final JPAEdmReferentialConstraintView arg0) {
+
+ }
+
+ @Override
+ public ReferentialConstraint getEdmReferentialConstraint() {
+ return null;
+ }
+
+ @Override
+ public String getEdmRelationShipName() {
+ return null;
+ }
+
+ @Override
+ public boolean isExists() {
+ return false;
+ }
+
+ @Override
+ public EntityType searchEdmEntityType(final String arg0) {
+ return null;
+ }
+
+ @Override
+ public JPAEdmReferentialConstraintView getJPAEdmReferentialConstraintView() {
+ return null;
+ }
+
+ @Override
+ public List<Association> getConsistentEdmAssociationList() {
+ return null;
+ }
+
+ @Override
+ public Association searchAssociation(final JPAEdmAssociationEndView arg0) {
+ return null;
+ }
+
+ @Override
+ public List<AssociationSet> getConsistentEdmAssociationSetList() {
+ return null;
+ }
+
+ @Override
+ public Association getEdmAssociation() {
+ return null;
+ }
+
+ @Override
+ public AssociationSet getEdmAssociationSet() {
+ return null;
+ }
+
+ @Override
+ public boolean compare(final AssociationEnd arg0, final AssociationEnd arg1) {
+ return false;
+ }
+
+ @Override
+ public AssociationEnd getEdmAssociationEnd1() {
+ return null;
+ }
+
+ @Override
+ public AssociationEnd getEdmAssociationEnd2() {
+ return null;
+ }
+
+ @Override
+ public JPAEdmNavigationPropertyView getJPAEdmNavigationPropertyView() {
+ return null;
+ }
+
+ @Override
+ public void addJPAEdmNavigationPropertyView(final JPAEdmNavigationPropertyView view) {
+
+ }
+
+ @Override
+ public List<NavigationProperty> getConsistentEdmNavigationProperties() {
+ return null;
+ }
+
+ @Override
+ public NavigationProperty getEdmNavigationProperty() {
+ return null;
+ }
+
+ @Override
+ public void expandEdmComplexType(final ComplexType complexType, final List<Property> expandedPropertyList,
+ final String embeddablePropertyName) {
+
+ }
+
+ @Override
+ public List<String> getNonKeyComplexTypeList() {
+ return null;
+ }
+
+ @Override
+ public void addNonKeyComplexName(final String complexTypeName) {}
+
+ @Override
+ public JPAEdmMappingModelAccess getJPAEdmMappingModelAccess() {
+ return null;
+ }
+
+ @Override
+ public void registerOperations(final Class<?> customClass, final String[] methodNames) {
+ // Do nothing
+ }
+
+ @Override
+ public HashMap<Class<?>, String[]> getRegisteredOperations() {
+ return null;
+ }
+
+ @Override
+ public JPAEdmExtension getJPAEdmExtension() {
+ return null;
+ }
+
+ @Override
+ public void addJPAEdmAssociationView(final JPAEdmAssociationView associationView,
+ final JPAEdmAssociationEndView associationEndView) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public int getNumberOfAssociationsWithSimilarEndPoints(final JPAEdmAssociationEndView view) {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public String getJoinColumnName() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public String getJoinColumnReferenceColumnName() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public String getMappedByName() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public String getOwningPropertyName() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public boolean isDefaultNamingSkipped() {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/_JPAEdmFunctionImportTest.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/_JPAEdmFunctionImportTest.java b/odata2-jpa-processor/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-jpa-processor/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/1b479e6c/odata2-jpa-processor/jpa-core/src/test/resources/SalesOrderProcessingMappingModels.xml
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-core/src/test/resources/SalesOrderProcessingMappingModels.xml b/odata2-jpa-processor/jpa-core/src/test/resources/SalesOrderProcessingMappingModels.xml
new file mode 100644
index 0000000..d81cae9
--- /dev/null
+++ b/odata2-jpa-processor/jpa-core/src/test/resources/SalesOrderProcessingMappingModels.xml
@@ -0,0 +1,62 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+<JPAEDMMappingModel
+ xmlns="http://www.apache.org/olingo/odata2/processor/api/jpa/model/mapping">
+ <PersistenceUnit name="salesorderprocessing">
+ <EDMSchemaNamespace>SalesOrderProcessing</EDMSchemaNamespace>
+ <JPAEntityTypes>
+ <JPAEntityType name="SalesOrderHeader">
+ <EDMEntityType>SalesOrder</EDMEntityType>
+ <EDMEntitySet>SalesOrders</EDMEntitySet>
+ <JPAAttributes>
+ <JPAAttribute name="soId"></JPAAttribute>
+ <JPAAttribute name="netAmount">NetAmount</JPAAttribute>
+ <JPAAttribute name="buyerAddress">BuyerAddressInfo</JPAAttribute>
+ </JPAAttributes>
+ <JPARelationships>
+ <JPARelationship name="salesOrderItems">SalesOrderItemDetails</JPARelationship>
+ <JPARelationship name="notes">NoteDetails</JPARelationship>
+ </JPARelationships>
+ </JPAEntityType>
+ <JPAEntityType name="SalesOrderItem">
+ <EDMEntityType>SalesOrderItem</EDMEntityType>
+ <EDMEntitySet>SalesOrderItems</EDMEntitySet>
+ <JPAAttributes>
+ <JPAAttribute name="liId">ID</JPAAttribute>
+ <JPAAttribute name="soId">SalesOrderID</JPAAttribute>
+ </JPAAttributes>
+ <JPARelationships>
+ <JPARelationship name="salesOrderHeader">SalesOrderHeaderDetails</JPARelationship>
+ <JPARelationship name="materials">MaterialDetails
+ </JPARelationship>
+ </JPARelationships>
+ </JPAEntityType>
+ </JPAEntityTypes>
+ <JPAEmbeddableTypes>
+ <JPAEmbeddableType name="SalesOrderItemKey">
+ <EDMComplexType>SalesOrderLineItemKey</EDMComplexType>
+ <JPAAttributes>
+ <JPAAttribute name="liId">ID</JPAAttribute>
+ <JPAAttribute name="soId">SalesOrderID</JPAAttribute>
+ </JPAAttributes>
+ </JPAEmbeddableType>
+ </JPAEmbeddableTypes>
+ </PersistenceUnit>
+</JPAEDMMappingModel>
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-ref/.gitignore
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-ref/.gitignore b/odata2-jpa-processor/jpa-ref/.gitignore
new file mode 100644
index 0000000..fe5d89b
--- /dev/null
+++ b/odata2-jpa-processor/jpa-ref/.gitignore
@@ -0,0 +1,8 @@
+.project
+.classpath
+.settings
+target
+bin
+*.bak
+classes
+.DS_Store
\ No newline at end of file
[08/37] [OLINGO-82] Renamed the project folder name to
odata2-jpa-processor
Posted by ch...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/edm/ODataJPAEdmProviderNegativeTest.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/edm/ODataJPAEdmProviderNegativeTest.java b/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/edm/ODataJPAEdmProviderNegativeTest.java
deleted file mode 100644
index f00cc61..0000000
--- a/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/edm/ODataJPAEdmProviderNegativeTest.java
+++ /dev/null
@@ -1,191 +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.edm;
-
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.fail;
-
-import java.lang.reflect.Field;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.olingo.odata2.api.edm.FullQualifiedName;
-import org.apache.olingo.odata2.api.edm.provider.Association;
-import org.apache.olingo.odata2.api.edm.provider.EntityContainer;
-import org.apache.olingo.odata2.api.edm.provider.EntityContainerInfo;
-import org.apache.olingo.odata2.api.edm.provider.Schema;
-import org.apache.olingo.odata2.api.exception.ODataException;
-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.model.JPAEdmModel;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-public class ODataJPAEdmProviderNegativeTest {
-
- private static ODataJPAEdmProvider edmProvider;
-
- @BeforeClass
- public static void setup() {
-
- edmProvider = new ODataJPAEdmProvider();
- try {
- Class<? extends ODataJPAEdmProvider> clazz = edmProvider.getClass();
- Field field = clazz.getDeclaredField("schemas");
- field.setAccessible(true);
- List<Schema> schemas = new ArrayList<Schema>();
- schemas.add(new Schema().setNamespace("salesorderprocessing")); // Empty Schema
- field.set(edmProvider, schemas);
- field = clazz.getDeclaredField("oDataJPAContext");
- field.setAccessible(true);
- field.set(edmProvider, ODataJPAContextMock.mockODataJPAContext());
- field = clazz.getDeclaredField("jpaEdmModel");
- field.setAccessible(true);
- field.set(edmProvider, new JPAEdmModel(null, null));
- } catch (IllegalArgumentException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- } catch (IllegalAccessException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- } catch (NoSuchFieldException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- } catch (SecurityException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
-
- }
-
- @Test
- public void testNullGetEntityContainerInfo() {
- EntityContainerInfo entityContainer = null;
- try {
- entityContainer = edmProvider.getEntityContainerInfo("salesorderprocessingContainer");
- } catch (ODataException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
- assertNull(entityContainer);
- }
-
- @Test
- public void testNullGetEntityType() {
- FullQualifiedName entityTypeName = new FullQualifiedName("salesorderprocessing", "SalesOrderHeader");
- try {
- assertNull(edmProvider.getEntityType(entityTypeName));
- } catch (ODataException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
- }
-
- @Test
- public void testNullGetComplexType() {
- FullQualifiedName complexTypeName = new FullQualifiedName("salesorderprocessing", "Address");
- try {
- assertNull(edmProvider.getComplexType(complexTypeName));
- } catch (ODataException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
- }
-
- @Test
- public void testGetAssociationFullQualifiedName() {
- Association association = null;
- try {
- association =
- edmProvider.getAssociation(new FullQualifiedName("salesorderprocessing", "SalesOrderHeader_SalesOrderItem"));
- } catch (ODataException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
- assertNull(association);
- }
-
- @Test
- public void testGetEntitySet() {
- try {
- assertNull(edmProvider.getEntitySet("salesorderprocessingContainer", "SalesOrderHeaders"));
- } catch (ODataException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
- }
-
- @Test
- public void testGetAssociationSet() {
- try {
- assertNull(edmProvider.getAssociationSet("salesorderprocessingContainer", new FullQualifiedName(
- "salesorderprocessing", "SalesOrderHeader_SalesOrderItem"), "SalesOrderHeaders", "SalesOrderHeader"));
- } catch (ODataException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
-
- }
-
- @Test
- public void testNullGetFunctionImport() {
-
- try {
- assertNull(edmProvider.getFunctionImport("salesorderprocessingContainer", "SalesOrder_FunctionImport1"));
- } catch (ODataException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
-
- }
-
- @Test
- public void testNullGetFunctionImport2() {
-
- try {
- ODataJPAEdmProvider provider = new ODataJPAEdmProvider();
- try {
- Class<? extends ODataJPAEdmProvider> clazz = provider.getClass();
- Field field = clazz.getDeclaredField("schemas");
- field.setAccessible(true);
- List<Schema> schemas = new ArrayList<Schema>();
- Schema schema = new Schema().setNamespace("salesorderprocessing");
- EntityContainer container = new EntityContainer().setName("salesorderprocessingContainer");
- List<EntityContainer> containerList = new ArrayList<EntityContainer>();
- containerList.add(container); // Empty Container
- schema.setEntityContainers(containerList);
- schemas.add(schema); // Empty Schema
- field.set(provider, schemas);
- } catch (IllegalArgumentException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- } catch (IllegalAccessException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- } catch (NoSuchFieldException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- } catch (SecurityException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
-
- assertNull(provider.getFunctionImport("salesorderprocessingContainer", "SalesOrder_FunctionImport1"));
- } catch (ODataException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
-
- }
-
- @Test
- public void testGetSchemas() {
- try {
- assertNotNull(edmProvider.getSchemas());
- } catch (ODataException 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/1b479e6c/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/edm/ODataJPAEdmProviderTest.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/edm/ODataJPAEdmProviderTest.java b/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/edm/ODataJPAEdmProviderTest.java
deleted file mode 100644
index 8dbd9da..0000000
--- a/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/edm/ODataJPAEdmProviderTest.java
+++ /dev/null
@@ -1,385 +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.edm;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import java.lang.reflect.Field;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-
-import org.apache.olingo.odata2.api.edm.FullQualifiedName;
-import org.apache.olingo.odata2.api.edm.provider.Association;
-import org.apache.olingo.odata2.api.edm.provider.AssociationSet;
-import org.apache.olingo.odata2.api.edm.provider.ComplexType;
-import org.apache.olingo.odata2.api.edm.provider.EntityContainerInfo;
-import org.apache.olingo.odata2.api.edm.provider.Schema;
-import org.apache.olingo.odata2.api.exception.ODataException;
-import org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPAModelException;
-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.EdmSchemaMock;
-import org.apache.olingo.odata2.processor.core.jpa.model.JPAEdmModel;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-public class ODataJPAEdmProviderTest {
-
- private static ODataJPAEdmProvider edmProvider;
-
- @BeforeClass
- public static void setup() {
-
- edmProvider = new ODataJPAEdmProvider();
- try {
- Class<? extends ODataJPAEdmProvider> clazz = edmProvider.getClass();
- Field field = clazz.getDeclaredField("schemas");
- field.setAccessible(true);
- List<Schema> schemas = new ArrayList<Schema>();
- schemas.add(EdmSchemaMock.createMockEdmSchema());
- field.set(edmProvider, schemas);
- field = clazz.getDeclaredField("oDataJPAContext");
- field.setAccessible(true);
- field.set(edmProvider, ODataJPAContextMock.mockODataJPAContext());
- field = clazz.getDeclaredField("jpaEdmModel");
- field.setAccessible(true);
- field.set(edmProvider, new JPAEdmModel(null, null));
- } catch (IllegalArgumentException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- } catch (IllegalAccessException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- } catch (NoSuchFieldException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- } catch (SecurityException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
-
- }
-
- @Test
- public void testConstructor() {
- try {
- ODataJPAEdmProvider edmProv = new ODataJPAEdmProvider(ODataJPAContextMock.mockODataJPAContext());
- edmProv.getClass();
- } catch (Exception e) {
- e.printStackTrace();
- assertTrue(true);
- }
- }
-
- @Test
- public void testGetODataJPAContext() {
- String pUnitName = edmProvider.getODataJPAContext().getPersistenceUnitName();
- assertEquals("salesorderprocessing", pUnitName);
- }
-
- @Test
- public void testGetEntityContainerInfo() {
- String entityContainerName = null;
- EntityContainerInfo entityContainer = null;
- try {
- entityContainer = edmProvider.getEntityContainerInfo("salesorderprocessingContainer");
- entityContainerName = entityContainer.getName();
- } catch (ODataException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
-
- assertEquals("salesorderprocessingContainer", entityContainerName);
- assertNotNull(entityContainer);
- }
-
- @Test
- public void testDefaultGetEntityContainerInfo() {
- String entityContainerName = null;
- EntityContainerInfo entityContainer = null;
- try {
- entityContainer = edmProvider.getEntityContainerInfo(null);
- entityContainerName = entityContainer.getName();
- } catch (ODataException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
-
- assertEquals("salesorderprocessingContainer", entityContainerName);
- assertNotNull(entityContainer);
- }
-
- @Test
- public void testGetEntityType() {
- FullQualifiedName entityTypeName = new FullQualifiedName("salesorderprocessing", "SalesOrderHeader");
- String entityName = null;
- try {
- entityName = edmProvider.getEntityType(entityTypeName).getName();
- } catch (ODataException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
- assertEquals("SalesOrderHeader", entityName);
- try {
- edmProvider.getEntityType(new FullQualifiedName("salesorder", "abc"));
- } catch (ODataException e) {
- assertTrue(true);
- }
-
- }
-
- @Test
- public void testGetComplexType() {
- FullQualifiedName complexTypeName = new FullQualifiedName("salesorderprocessing", "Address");
- String nameStr = null;
- try {
- nameStr = edmProvider.getComplexType(complexTypeName).getName();
- } catch (ODataException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
- assertEquals("Address", nameStr);
- }
-
- @Test
- public void testGetAssociationFullQualifiedName() {
- Association association = null;
- try {
- association =
- edmProvider.getAssociation(new FullQualifiedName("salesorderprocessing", "SalesOrderHeader_SalesOrderItem"));
- } catch (ODataException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
- assertNotNull(association);
- assertEquals("SalesOrderHeader_SalesOrderItem", association.getName());
- }
-
- @Test
- public void testGetEntitySet() {
- String entitySetName = null;
- try {
- entitySetName = edmProvider.getEntitySet("salesorderprocessingContainer", "SalesOrderHeaders").getName();
- } catch (ODataException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
- assertEquals("SalesOrderHeaders", entitySetName);
- try {
- assertNull(edmProvider.getEntitySet("salesorderprocessing", "SalesOrderHeaders"));
- } catch (ODataException e) {
- assertTrue(true);
- }
- }
-
- @Test
- public void testGetAssociationSet() {
- AssociationSet associationSet = null;
-
- try {
- associationSet =
- edmProvider.getAssociationSet("salesorderprocessingContainer", new FullQualifiedName("salesorderprocessing",
- "SalesOrderHeader_SalesOrderItem"), "SalesOrderHeaders", "SalesOrderHeader");
- } catch (ODataException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
- assertNotNull(associationSet);
- assertEquals("SalesOrderHeader_SalesOrderItemSet", associationSet.getName());
- try {
- associationSet =
- edmProvider.getAssociationSet("salesorderprocessingContainer", new FullQualifiedName("salesorderprocessing",
- "SalesOrderHeader_SalesOrderItem"), "SalesOrderItems", "SalesOrderItem");
- } catch (ODataException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
- assertNotNull(associationSet);
- try {
- associationSet =
- edmProvider.getAssociationSet("salesorderproceContainer", new FullQualifiedName("salesorderprocessing",
- "SalesOrderHeader_SalesOrderItem"), "SalesOrderItems", "SalesOrderItem");
- } catch (ODataException e) {
- assertTrue(true);
- }
- }
-
- @Test
- public void testGetFunctionImport() {
- String functionImportName = null;
- try {
- functionImportName =
- edmProvider.getFunctionImport("salesorderprocessingContainer", "SalesOrder_FunctionImport1").getName();
- } catch (ODataException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
- assertEquals("SalesOrder_FunctionImport1", functionImportName);
- try {
- functionImportName =
- edmProvider.getFunctionImport("salesorderprocessingContainer", "SalesOrder_FunctionImport1").getName();
- } catch (ODataException e) {
- assertTrue(true);
- }
- try {
- assertNotNull(edmProvider.getFunctionImport("salesorderprocessingContainer", "SalesOrder_FunctionImport1"));
- } catch (ODataException e) {
- e.printStackTrace();
- }
- }
-
- @Test
- public void testGetSchemas() {
- try {
- assertNotNull(edmProvider.getSchemas());
- } catch (ODataException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
- }
-
- @Test
- public void testgetComplexTypeWithBuffer() {
- HashMap<String, ComplexType> compTypes = new HashMap<String, ComplexType>();
- ComplexType comp = new ComplexType();
- comp.setName("Address");
- compTypes.put("salesorderprocessing" + "." + "Address", comp);
- ODataJPAEdmProvider jpaEdmProv = new ODataJPAEdmProvider();
- Class<?> claz = jpaEdmProv.getClass();
- Field f;
- try {
- f = claz.getDeclaredField("complexTypes");
- f.setAccessible(true);
- f.set(jpaEdmProv, compTypes);
- } catch (NoSuchFieldException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- } catch (SecurityException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- } catch (IllegalArgumentException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- } catch (IllegalAccessException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
-
- try {
- assertEquals(comp, jpaEdmProv.getComplexType(new FullQualifiedName("salesorderprocessing", "Address")));
- } catch (ODataException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
- try {
- jpaEdmProv.getComplexType(new FullQualifiedName("salesorderessing", "abc"));
- } catch (ODataJPAModelException e) {
- assertTrue(true);
- } catch (ODataException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
- }
-
- @Test
- public void testGetEntityContainerInfoWithBuffer() {
- HashMap<String, EntityContainerInfo> entityContainerInfos = new HashMap<String, EntityContainerInfo>();
- EntityContainerInfo entityContainer = new EntityContainerInfo();
- entityContainer.setName("salesorderprocessingContainer");
- entityContainerInfos.put("salesorderprocessingContainer", entityContainer);
- ODataJPAEdmProvider jpaEdmProv = new ODataJPAEdmProvider();
- Class<?> claz = jpaEdmProv.getClass();
- try {
- Field f = claz.getDeclaredField("entityContainerInfos");
- f.setAccessible(true);
- f.set(jpaEdmProv, entityContainerInfos);
- assertEquals(entityContainer, jpaEdmProv.getEntityContainerInfo("salesorderprocessingContainer"));
- jpaEdmProv.getEntityContainerInfo("abc");
- } catch (ODataJPAModelException e) {
- assertTrue(true);
- } catch (NoSuchFieldException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- } catch (SecurityException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- } catch (IllegalArgumentException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- } catch (IllegalAccessException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- } catch (ODataException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
- }
-
- @Test
- public void testGetEntityTypeWithBuffer() {
- HashMap<String, org.apache.olingo.odata2.api.edm.provider.EntityType> entityTypes =
- new HashMap<String, org.apache.olingo.odata2.api.edm.provider.EntityType>();
- org.apache.olingo.odata2.api.edm.provider.EntityType entity =
- new org.apache.olingo.odata2.api.edm.provider.EntityType();
- entity.setName("SalesOrderHeader");
- entityTypes.put("salesorderprocessing" + "." + "SalesorderHeader", entity);
- ODataJPAEdmProvider jpaEdmProv = new ODataJPAEdmProvider();
- Class<?> claz = jpaEdmProv.getClass();
- Field f;
- try {
- f = claz.getDeclaredField("entityTypes");
- f.setAccessible(true);
- f.set(jpaEdmProv, entityTypes);
- assertEquals(entity, jpaEdmProv.getEntityType(new FullQualifiedName("salesorderprocessing", "SalesorderHeader")));
- } catch (NoSuchFieldException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- } catch (SecurityException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- } catch (IllegalArgumentException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- } catch (IllegalAccessException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- } catch (ODataException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
- try {
- jpaEdmProv.getEntityType(new FullQualifiedName("salesoprocessing", "abc"));
- } catch (ODataJPAModelException e) {
- assertTrue(true);
- } catch (ODataException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
- }
-
- @Test
- public void testGetAssociationWithBuffer() {
- HashMap<String, Association> associations = new HashMap<String, Association>();
- Association association = new Association();
- association.setName("SalesOrderHeader_SalesOrderItem");
- associations.put("salesorderprocessing" + "." + "SalesOrderHeader_SalesOrderItem", association);
- ODataJPAEdmProvider jpaEdmProv = new ODataJPAEdmProvider();
- Class<?> claz = jpaEdmProv.getClass();
- Field f;
- try {
- f = claz.getDeclaredField("associations");
- f.setAccessible(true);
- f.set(jpaEdmProv, associations);
- assertEquals(association, jpaEdmProv.getAssociation(new FullQualifiedName("salesorderprocessing",
- "SalesOrderHeader_SalesOrderItem")));
- } catch (NoSuchFieldException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- } catch (SecurityException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- } catch (IllegalArgumentException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- } catch (IllegalAccessException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- } catch (ODataException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
- try {
- jpaEdmProv.getAssociation(new FullQualifiedName("salesorderprocessing", "abc"));
- } catch (ODataJPAModelException e) {
- assertTrue(true);
- } catch (ODataException 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/1b479e6c/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLBuilderFactoryTest.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLBuilderFactoryTest.java b/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLBuilderFactoryTest.java
deleted file mode 100644
index 7da02d8..0000000
--- a/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLBuilderFactoryTest.java
+++ /dev/null
@@ -1,377 +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.jpql;
-
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import java.lang.reflect.Field;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-
-import javax.persistence.Cache;
-import javax.persistence.EntityManager;
-import javax.persistence.EntityManagerFactory;
-import javax.persistence.PersistenceUnitUtil;
-import javax.persistence.criteria.CriteriaBuilder;
-import javax.persistence.metamodel.Metamodel;
-
-import org.apache.olingo.odata2.api.edm.EdmEntitySet;
-import org.apache.olingo.odata2.api.edm.EdmEntityType;
-import org.apache.olingo.odata2.api.edm.EdmException;
-import org.apache.olingo.odata2.api.edm.EdmMapping;
-import org.apache.olingo.odata2.api.edm.EdmProperty;
-import org.apache.olingo.odata2.api.edm.EdmSimpleType;
-import org.apache.olingo.odata2.api.exception.ODataException;
-import org.apache.olingo.odata2.api.uri.KeyPredicate;
-import org.apache.olingo.odata2.api.uri.NavigationSegment;
-import org.apache.olingo.odata2.api.uri.expression.OrderByExpression;
-import org.apache.olingo.odata2.api.uri.info.GetEntitySetUriInfo;
-import org.apache.olingo.odata2.api.uri.info.GetEntityUriInfo;
-import org.apache.olingo.odata2.processor.api.jpa.factory.JPAAccessFactory;
-import org.apache.olingo.odata2.processor.api.jpa.factory.ODataJPAAccessFactory;
-import org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLContext;
-import org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLContext.JPQLContextBuilder;
-import org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLContextType;
-import org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLStatement.JPQLStatementBuilder;
-import org.apache.olingo.odata2.processor.core.jpa.ODataJPAContextImpl;
-import org.apache.olingo.odata2.processor.core.jpa.access.data.JPAProcessorImplTest;
-import org.apache.olingo.odata2.processor.core.jpa.common.ODataJPATestConstants;
-import org.apache.olingo.odata2.processor.core.jpa.factory.ODataJPAFactoryImpl;
-import org.apache.olingo.odata2.processor.core.jpa.jpql.JPQLSelectContext.JPQLSelectContextBuilder;
-import org.apache.olingo.odata2.processor.core.jpa.jpql.JPQLSelectSingleContext.JPQLSelectSingleContextBuilder;
-import org.easymock.EasyMock;
-import org.junit.Test;
-
-public class JPQLBuilderFactoryTest {
-
- @Test
- public void testGetStatementBuilderFactoryforSelect() throws ODataException {
-
- GetEntitySetUriInfo getEntitySetView = getUriInfo();
-
- // Build JPQL Context
- JPQLContext selectContext = JPQLContext.createBuilder(JPQLContextType.SELECT, getEntitySetView).build();
- JPQLStatementBuilder statementBuilder =
- new ODataJPAFactoryImpl().getJPQLBuilderFactory().getStatementBuilder(selectContext);
-
- assertTrue(statementBuilder instanceof JPQLSelectStatementBuilder);
-
- }
-
- @Test
- public void testGetStatementBuilderFactoryforSelectSingle() throws ODataException {
-
- GetEntityUriInfo getEntityView = getEntityUriInfo();
-
- // Build JPQL Context
- JPQLContext selectContext = JPQLContext.createBuilder(JPQLContextType.SELECT_SINGLE, getEntityView).build();
- JPQLStatementBuilder statementBuilder =
- new ODataJPAFactoryImpl().getJPQLBuilderFactory().getStatementBuilder(selectContext);
-
- assertTrue(statementBuilder instanceof JPQLSelectSingleStatementBuilder);
-
- }
-
- @Test
- public void testGetStatementBuilderFactoryforJoinSelect() throws ODataException {
-
- GetEntitySetUriInfo getEntitySetView = getUriInfo();
-
- // Build JPQL Context
- JPQLContext selectContext = JPQLContext.createBuilder(JPQLContextType.JOIN, getEntitySetView).build();
- JPQLStatementBuilder statementBuilder =
- new ODataJPAFactoryImpl().getJPQLBuilderFactory().getStatementBuilder(selectContext);
-
- assertTrue(statementBuilder instanceof JPQLJoinStatementBuilder);
-
- }
-
- @Test
- public void testGetStatementBuilderFactoryforJoinSelectSingle() throws ODataException {
-
- GetEntityUriInfo getEntityView = getEntityUriInfo();
-
- // Build JPQL Context
- JPQLContext selectContext = JPQLContext.createBuilder(JPQLContextType.JOIN_SINGLE, getEntityView).build();
- JPQLStatementBuilder statementBuilder =
- new ODataJPAFactoryImpl().getJPQLBuilderFactory().getStatementBuilder(selectContext);
-
- assertTrue(statementBuilder instanceof JPQLJoinSelectSingleStatementBuilder);
-
- }
-
- @Test
- public void testGetContextBuilderforDelete() throws ODataException {
-
- // Build JPQL ContextBuilder
- JPQLContextBuilder contextBuilder =
- new ODataJPAFactoryImpl().getJPQLBuilderFactory().getContextBuilder(JPQLContextType.DELETE);
-
- assertNull(contextBuilder);
-
- }
-
- @Test
- public void testGetContextBuilderforSelect() throws ODataException {
-
- // Build JPQL ContextBuilder
- JPQLContextBuilder contextBuilder =
- new ODataJPAFactoryImpl().getJPQLBuilderFactory().getContextBuilder(JPQLContextType.SELECT);
-
- assertNotNull(contextBuilder);
- assertTrue(contextBuilder instanceof JPQLSelectContextBuilder);
-
- }
-
- @Test
- public void testGetContextBuilderforSelectSingle() throws ODataException {
-
- // Build JPQL ContextBuilder
- JPQLContextBuilder contextBuilder =
- new ODataJPAFactoryImpl().getJPQLBuilderFactory().getContextBuilder(JPQLContextType.SELECT_SINGLE);
-
- assertNotNull(contextBuilder);
- assertTrue(contextBuilder instanceof JPQLSelectSingleContextBuilder);
-
- }
-
- private GetEntitySetUriInfo getUriInfo() throws EdmException {
- GetEntitySetUriInfo getEntitySetView = EasyMock.createMock(GetEntitySetUriInfo.class);
- EdmEntitySet edmEntitySet = EasyMock.createMock(EdmEntitySet.class);
- EdmEntityType edmEntityType = EasyMock.createMock(EdmEntityType.class);
- EasyMock.expect(edmEntityType.getMapping()).andStubReturn(null);
- EasyMock.expect(edmEntityType.getName()).andStubReturn("SOItem");
- EasyMock.replay(edmEntityType);
- OrderByExpression orderByExpression = EasyMock.createMock(OrderByExpression.class);
- EasyMock.expect(getEntitySetView.getTargetEntitySet()).andStubReturn(edmEntitySet);
- EdmEntitySet startEdmEntitySet = EasyMock.createMock(EdmEntitySet.class);
- EdmEntityType startEdmEntityType = EasyMock.createMock(EdmEntityType.class);
- EasyMock.expect(startEdmEntityType.getMapping()).andStubReturn(null);
- EasyMock.expect(startEdmEntityType.getName()).andStubReturn("SOHeader");
- EasyMock.expect(startEdmEntitySet.getEntityType()).andStubReturn(startEdmEntityType);
- EasyMock.expect(getEntitySetView.getStartEntitySet()).andStubReturn(startEdmEntitySet);
- EasyMock.replay(startEdmEntityType, startEdmEntitySet);
- EasyMock.expect(getEntitySetView.getOrderBy()).andStubReturn(orderByExpression);
- EasyMock.expect(getEntitySetView.getSelect()).andStubReturn(null);
- EasyMock.expect(getEntitySetView.getFilter()).andStubReturn(null);
- List<NavigationSegment> navigationSegments = new ArrayList<NavigationSegment>();
- EasyMock.expect(getEntitySetView.getNavigationSegments()).andStubReturn(navigationSegments);
- KeyPredicate keyPredicate = EasyMock.createMock(KeyPredicate.class);
- EdmProperty kpProperty = EasyMock.createMock(EdmProperty.class);
- EdmSimpleType edmType = EasyMock.createMock(EdmSimpleType.class);
- EdmMapping edmMapping = EasyMock.createMock(EdmMapping.class);
- EasyMock.expect(edmMapping.getInternalName()).andStubReturn("Field1");
- EasyMock.expect(keyPredicate.getLiteral()).andStubReturn("1");
- try {
- EasyMock.expect(kpProperty.getName()).andStubReturn("Field1");
- EasyMock.expect(kpProperty.getType()).andStubReturn(edmType);
-
- EasyMock.expect(kpProperty.getMapping()).andStubReturn(edmMapping);
-
- } catch (EdmException e2) {
- fail("this should not happen");
- }
- EasyMock.expect(keyPredicate.getProperty()).andStubReturn(kpProperty);
- EasyMock.replay(edmMapping, edmType, kpProperty, keyPredicate);
- List<KeyPredicate> keyPredicates = new ArrayList<KeyPredicate>();
- keyPredicates.add(keyPredicate);
- EasyMock.expect(getEntitySetView.getKeyPredicates()).andStubReturn(keyPredicates);
- EasyMock.replay(getEntitySetView);
- EasyMock.expect(edmEntitySet.getEntityType()).andStubReturn(edmEntityType);
- EasyMock.replay(edmEntitySet);
- return getEntitySetView;
- }
-
- private GetEntityUriInfo getEntityUriInfo() throws EdmException {
- GetEntityUriInfo getEntityView = EasyMock.createMock(GetEntityUriInfo.class);
- EdmEntitySet edmEntitySet = EasyMock.createMock(EdmEntitySet.class);
- EdmEntityType edmEntityType = EasyMock.createMock(EdmEntityType.class);
- EasyMock.expect(edmEntityType.getKeyProperties()).andStubReturn(new ArrayList<EdmProperty>());
- EasyMock.expect(edmEntityType.getMapping()).andStubReturn(null);
- EasyMock.expect(edmEntityType.getName()).andStubReturn("");
- EasyMock.expect(edmEntitySet.getEntityType()).andStubReturn(edmEntityType);
- EasyMock.expect(getEntityView.getSelect()).andStubReturn(null);
- EasyMock.expect(getEntityView.getTargetEntitySet()).andStubReturn(edmEntitySet);
- EdmEntitySet startEdmEntitySet = EasyMock.createMock(EdmEntitySet.class);
- EdmEntityType startEdmEntityType = EasyMock.createMock(EdmEntityType.class);
- EasyMock.expect(startEdmEntityType.getMapping()).andStubReturn(null);
- EasyMock.expect(startEdmEntityType.getName()).andStubReturn("SOHeader");
- EasyMock.expect(startEdmEntitySet.getEntityType()).andStubReturn(startEdmEntityType);
- EasyMock.expect(getEntityView.getStartEntitySet()).andStubReturn(startEdmEntitySet);
- EasyMock.replay(startEdmEntityType, startEdmEntitySet);
- EasyMock.replay(edmEntityType, edmEntitySet);
- EasyMock.expect(getEntityView.getKeyPredicates()).andStubReturn(new ArrayList<KeyPredicate>());
- List<NavigationSegment> navigationSegments = new ArrayList<NavigationSegment>();
- EasyMock.expect(getEntityView.getNavigationSegments()).andStubReturn(navigationSegments);
- EasyMock.replay(getEntityView);
- return getEntityView;
- }
-
- @Test
- public void testJPAAccessFactory() {
- ODataJPAFactoryImpl oDataJPAFactoryImpl = new ODataJPAFactoryImpl();
- JPAAccessFactory jpaAccessFactory = oDataJPAFactoryImpl.getJPAAccessFactory();
- ODataJPAContextImpl oDataJPAContextImpl = new ODataJPAContextImpl();
- Class<?> clazz = oDataJPAContextImpl.getClass();
- try {
- Field field = clazz.getDeclaredField("em");
- field.setAccessible(true);
- field.set(oDataJPAContextImpl, new JPAProcessorImplTest().getLocalEntityManager());
- } catch (SecurityException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- } catch (NoSuchFieldException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- } catch (IllegalArgumentException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- } catch (IllegalAccessException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
- EntityManagerFactory emf = new EntityManagerFactory() {
-
- @Override
- public boolean isOpen() {
- return false;
- }
-
- @Override
- public Map<String, Object> getProperties() {
- return null;
- }
-
- @Override
- public PersistenceUnitUtil getPersistenceUnitUtil() {
- return null;
- }
-
- @Override
- public Metamodel getMetamodel() {
- return null;
- }
-
- @Override
- public CriteriaBuilder getCriteriaBuilder() {
- return null;
- }
-
- @Override
- public Cache getCache() {
- return null;
- }
-
- @SuppressWarnings("rawtypes")
- @Override
- public EntityManager createEntityManager(final Map arg0) {
- return null;
- }
-
- @Override
- public EntityManager createEntityManager() {
- return null;
- }
-
- @Override
- public void close() {}
- };
- oDataJPAContextImpl.setEntityManagerFactory(emf);
- oDataJPAContextImpl.setPersistenceUnitName("pUnit");
-
- assertNotNull(jpaAccessFactory.getJPAProcessor(oDataJPAContextImpl));
- assertNotNull(jpaAccessFactory.getJPAEdmModelView(oDataJPAContextImpl));
-
- }
-
- @Test
- public void testOdataJpaAccessFactory() {
-
- ODataJPAFactoryImpl oDataJPAFactoryImpl = new ODataJPAFactoryImpl();
- ODataJPAAccessFactory jpaAccessFactory = oDataJPAFactoryImpl.getODataJPAAccessFactory();
- ODataJPAContextImpl oDataJPAContextImpl = new ODataJPAContextImpl();
-
- EntityManagerFactory emf = new EntityManagerFactory() {
-
- @Override
- public boolean isOpen() {
- // TODO Auto-generated method stub
- return false;
- }
-
- @Override
- public Map<String, Object> getProperties() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public PersistenceUnitUtil getPersistenceUnitUtil() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public Metamodel getMetamodel() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public CriteriaBuilder getCriteriaBuilder() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public Cache getCache() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @SuppressWarnings("rawtypes")
- @Override
- public EntityManager createEntityManager(final Map arg0) {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public EntityManager createEntityManager() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public void close() {
- // TODO Auto-generated method stub
-
- }
- };
- oDataJPAContextImpl.setEntityManagerFactory(emf);
- oDataJPAContextImpl.setPersistenceUnitName("pUnit");
-
- assertNotNull(jpaAccessFactory.getODataJPAMessageService(new Locale("en")));
- assertNotNull(jpaAccessFactory.createODataJPAContext());
- assertNotNull(jpaAccessFactory.createJPAEdmProvider(oDataJPAContextImpl));
- assertNotNull(jpaAccessFactory.createODataProcessor(oDataJPAContextImpl));
-
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLJoinContextTest.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLJoinContextTest.java b/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLJoinContextTest.java
deleted file mode 100644
index 509591f..0000000
--- a/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLJoinContextTest.java
+++ /dev/null
@@ -1,198 +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.jpql;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.olingo.odata2.api.edm.EdmAssociation;
-import org.apache.olingo.odata2.api.edm.EdmAssociationEnd;
-import org.apache.olingo.odata2.api.edm.EdmEntitySet;
-import org.apache.olingo.odata2.api.edm.EdmEntityType;
-import org.apache.olingo.odata2.api.edm.EdmException;
-import org.apache.olingo.odata2.api.edm.EdmMapping;
-import org.apache.olingo.odata2.api.edm.EdmMultiplicity;
-import org.apache.olingo.odata2.api.edm.EdmNavigationProperty;
-import org.apache.olingo.odata2.api.edm.EdmProperty;
-import org.apache.olingo.odata2.api.edm.EdmSimpleType;
-import org.apache.olingo.odata2.api.uri.KeyPredicate;
-import org.apache.olingo.odata2.api.uri.NavigationSegment;
-import org.apache.olingo.odata2.api.uri.info.GetEntitySetUriInfo;
-import org.apache.olingo.odata2.processor.api.jpa.access.JPAJoinClause;
-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.core.jpa.jpql.JPQLJoinSelectContext.JPQLJoinContextBuilder;
-import org.easymock.EasyMock;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-public class JPQLJoinContextTest {
-
- GetEntitySetUriInfo entitySetUriInfo;
-
- @BeforeClass
- public static void setUpBeforeClass() throws Exception {}
-
- @AfterClass
- public static void tearDownAfterClass() throws Exception {}
-
- @Before
- public void setUp() throws Exception {
- entitySetUriInfo = EasyMock.createMock(GetEntitySetUriInfo.class);
- EdmEntitySet edmEntitySet = EasyMock.createMock(EdmEntitySet.class);
- EdmEntityType edmEntityType = EasyMock.createMock(EdmEntityType.class);
- List<NavigationSegment> navigationSegments = new ArrayList<NavigationSegment>();
- final EdmNavigationProperty navigationProperty = createNavigationProperty("a");
- final EdmNavigationProperty navigationProperty1 = createNavigationProperty("b");
- final List<KeyPredicate> keyPredicates = createKeyPredicates();
- NavigationSegment navigationSegment = new NavigationSegment() {
-
- @Override
- public EdmNavigationProperty getNavigationProperty() {
- return navigationProperty;
- }
-
- @Override
- public List<KeyPredicate> getKeyPredicates() {
- return keyPredicates;
- }
-
- @Override
- public EdmEntitySet getEntitySet() {
- // TODO Auto-generated method stub
- return null;
- }
- };
- NavigationSegment navigationSegment1 = new NavigationSegment() {
-
- @Override
- public EdmNavigationProperty getNavigationProperty() {
- return navigationProperty1;
- }
-
- @Override
- public List<KeyPredicate> getKeyPredicates() {
- return keyPredicates;
- }
-
- @Override
- public EdmEntitySet getEntitySet() {
- // TODO Auto-generated method stub
- return null;
- }
- };
- navigationSegments.add(navigationSegment);
- navigationSegments.add(navigationSegment1);
- EasyMock.expect(entitySetUriInfo.getNavigationSegments()).andStubReturn(navigationSegments);
- EasyMock.expect(entitySetUriInfo.getOrderBy()).andStubReturn(null);
- EasyMock.expect(entitySetUriInfo.getTop()).andStubReturn(null);
- EasyMock.expect(entitySetUriInfo.getSkip()).andStubReturn(null);
- EasyMock.expect(entitySetUriInfo.getSelect()).andStubReturn(null);
- EasyMock.expect(entitySetUriInfo.getFilter()).andStubReturn(null);
- EasyMock.expect(entitySetUriInfo.getKeyPredicates()).andStubReturn(keyPredicates);
- EasyMock.expect(entitySetUriInfo.getTargetEntitySet()).andStubReturn(edmEntitySet);
- EdmEntitySet startEdmEntitySet = EasyMock.createMock(EdmEntitySet.class);
- EdmEntityType startEdmEntityType = EasyMock.createMock(EdmEntityType.class);
- EasyMock.expect(startEdmEntityType.getMapping()).andStubReturn(null);
- EasyMock.expect(startEdmEntityType.getName()).andStubReturn("SOHeader");
- EasyMock.expect(startEdmEntitySet.getEntityType()).andStubReturn(startEdmEntityType);
- EasyMock.expect(entitySetUriInfo.getStartEntitySet()).andStubReturn(startEdmEntitySet);
- EasyMock.replay(startEdmEntityType, startEdmEntitySet);
- EasyMock.expect(edmEntitySet.getEntityType()).andStubReturn(edmEntityType);
- EasyMock.expect(edmEntityType.getMapping()).andStubReturn(null);
- EasyMock.expect(edmEntityType.getName()).andStubReturn("SOHeader");
- EasyMock.replay(edmEntityType, edmEntitySet, entitySetUriInfo);
-
- }
-
- @After
- public void tearDown() throws Exception {}
-
- @Test
- public void testGetJPAOuterJoinClauses() {
- JPQLJoinSelectContext joinContext = new JPQLJoinSelectContext(false);
- JPQLJoinContextBuilder joinContextBuilder = joinContext.new JPQLJoinContextBuilder();
- try {
- joinContextBuilder.entitySetView = entitySetUriInfo;
- joinContextBuilder.build();
- } catch (ODataJPAModelException e) {
- fail("Should not come here");
- } catch (ODataJPARuntimeException e) {
- fail("Should not come here");
- }
- List<JPAJoinClause> joinClauses = joinContext.getJPAJoinClauses();
- assertNotNull(joinClauses);
- assertTrue(joinClauses.size() > 0);
- assertEquals("E1", joinClauses.get(0).getEntityAlias());
- assertEquals("SOHeader", joinClauses.get(0).getEntityName());
- assertEquals("s_Itema", joinClauses.get(1).getEntityRelationShip());
- assertEquals("R1", joinClauses.get(1).getEntityRelationShipAlias());
- }
-
- private EdmNavigationProperty createNavigationProperty(final String z) throws EdmException {
- EdmNavigationProperty navigationProperty = EasyMock.createMock(EdmNavigationProperty.class);
- EdmAssociation association = EasyMock.createMock(EdmAssociation.class);
- EdmAssociationEnd associationEnd = EasyMock.createMock(EdmAssociationEnd.class);
- EasyMock.expect(navigationProperty.getFromRole()).andStubReturn("roleA" + z);
- EasyMock.expect(navigationProperty.getToRole()).andStubReturn("roleB" + z);
- EasyMock.expect(navigationProperty.getName()).andStubReturn("navP" + z);
- EasyMock.expect(navigationProperty.getName()).andStubReturn("navP" + z);
- EasyMock.expect(navigationProperty.getMultiplicity()).andStubReturn(EdmMultiplicity.ONE);
- EdmEntityType edmEntityType = EasyMock.createMock(EdmEntityType.class);
- EdmMapping edmMapping = EasyMock.createMock(EdmMapping.class);
- EasyMock.expect(edmMapping.getInternalName()).andStubReturn("sItem" + z);
- EasyMock.expect(edmEntityType.getMapping()).andStubReturn(edmMapping);
- EasyMock.expect(edmEntityType.getName()).andStubReturn("soItem" + z);
- EasyMock.expect(associationEnd.getEntityType()).andStubReturn(edmEntityType);
- EasyMock.expect(association.getEnd("roleA" + z)).andStubReturn(associationEnd);
- EasyMock.expect(navigationProperty.getRelationship()).andStubReturn(association);
- EdmMapping edmMapping1 = EasyMock.createMock(EdmMapping.class);
- EasyMock.expect(edmMapping1.getInternalName()).andStubReturn("s_Item" + z);
- EasyMock.expect(navigationProperty.getMapping()).andStubReturn(edmMapping1);
- EasyMock.replay(edmMapping, edmMapping1, edmEntityType, associationEnd, association, navigationProperty);
- return navigationProperty;
- }
-
- private List<KeyPredicate> createKeyPredicates() throws EdmException {
- KeyPredicate keyPredicate = EasyMock.createMock(KeyPredicate.class);
- EasyMock.expect(keyPredicate.getLiteral()).andStubReturn("1");
- EdmProperty edmProperty = EasyMock.createMock(EdmProperty.class);
- EdmMapping edmMapping = EasyMock.createMock(EdmMapping.class);
- EasyMock.expect(edmMapping.getInternalName()).andStubReturn("soid");
- EasyMock.expect(edmProperty.getMapping()).andStubReturn(edmMapping);
- EasyMock.expect(edmProperty.getName()).andStubReturn("soid");
- EdmSimpleType edmType = EasyMock.createMock(EdmSimpleType.class);
- EasyMock.expect(edmProperty.getType()).andStubReturn(edmType);
- EasyMock.expect(keyPredicate.getProperty()).andStubReturn(edmProperty);
-
- EasyMock.replay(edmType, edmMapping, edmProperty, keyPredicate);
- List<KeyPredicate> keyPredicates = new ArrayList<KeyPredicate>();
- keyPredicates.add(keyPredicate);
- return keyPredicates;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLJoinSelectSingleContextTest.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLJoinSelectSingleContextTest.java b/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLJoinSelectSingleContextTest.java
deleted file mode 100644
index b7c9c7d..0000000
--- a/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLJoinSelectSingleContextTest.java
+++ /dev/null
@@ -1,215 +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.jpql;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.olingo.odata2.api.edm.EdmAssociation;
-import org.apache.olingo.odata2.api.edm.EdmAssociationEnd;
-import org.apache.olingo.odata2.api.edm.EdmEntitySet;
-import org.apache.olingo.odata2.api.edm.EdmEntityType;
-import org.apache.olingo.odata2.api.edm.EdmException;
-import org.apache.olingo.odata2.api.edm.EdmMapping;
-import org.apache.olingo.odata2.api.edm.EdmMultiplicity;
-import org.apache.olingo.odata2.api.edm.EdmNavigationProperty;
-import org.apache.olingo.odata2.api.edm.EdmProperty;
-import org.apache.olingo.odata2.api.edm.EdmSimpleType;
-import org.apache.olingo.odata2.api.uri.KeyPredicate;
-import org.apache.olingo.odata2.api.uri.NavigationSegment;
-import org.apache.olingo.odata2.api.uri.info.GetEntityUriInfo;
-import org.apache.olingo.odata2.processor.api.jpa.access.JPAJoinClause;
-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.core.jpa.jpql.JPQLJoinSelectSingleContext.JPQLJoinSelectSingleContextBuilder;
-import org.easymock.EasyMock;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-public class JPQLJoinSelectSingleContextTest {
-
- GetEntityUriInfo entityUriInfo;
-
- @BeforeClass
- public static void setUpBeforeClass() throws Exception {}
-
- @AfterClass
- public static void tearDownAfterClass() throws Exception {}
-
- public void setUp(final boolean toThrowException) throws Exception {
- entityUriInfo = EasyMock.createMock(GetEntityUriInfo.class);
- EdmEntitySet edmEntitySet = EasyMock.createMock(EdmEntitySet.class);
- EdmEntityType edmEntityType = EasyMock.createMock(EdmEntityType.class);
- List<NavigationSegment> navigationSegments = new ArrayList<NavigationSegment>();
- final EdmNavigationProperty navigationProperty = createNavigationProperty("a");
- final EdmNavigationProperty navigationProperty1 = createNavigationProperty("b");
- final List<KeyPredicate> keyPredicates = createKeyPredicates(toThrowException);
- NavigationSegment navigationSegment = new NavigationSegment() {
-
- @Override
- public EdmNavigationProperty getNavigationProperty() {
- return navigationProperty;
- }
-
- @Override
- public List<KeyPredicate> getKeyPredicates() {
- return keyPredicates;
- }
-
- @Override
- public EdmEntitySet getEntitySet() {
- // TODO Auto-generated method stub
- return null;
- }
- };
- NavigationSegment navigationSegment1 = new NavigationSegment() {
-
- @Override
- public EdmNavigationProperty getNavigationProperty() {
- return navigationProperty1;
- }
-
- @Override
- public List<KeyPredicate> getKeyPredicates() {
- return keyPredicates;
- }
-
- @Override
- public EdmEntitySet getEntitySet() {
- // TODO Auto-generated method stub
- return null;
- }
- };
- navigationSegments.add(navigationSegment);
- navigationSegments.add(navigationSegment1);
- EasyMock.expect(entityUriInfo.getNavigationSegments()).andStubReturn(navigationSegments);
- EasyMock.expect(entityUriInfo.getSelect()).andStubReturn(null);
- EasyMock.expect(entityUriInfo.getFilter()).andStubReturn(null);
- EasyMock.expect(entityUriInfo.getKeyPredicates()).andStubReturn(createKeyPredicates(toThrowException));
- EasyMock.expect(entityUriInfo.getTargetEntitySet()).andStubReturn(edmEntitySet);
- EdmEntitySet startEdmEntitySet = EasyMock.createMock(EdmEntitySet.class);
- EdmEntityType startEdmEntityType = EasyMock.createMock(EdmEntityType.class);
- EasyMock.expect(startEdmEntityType.getMapping()).andStubReturn(null);
- EasyMock.expect(startEdmEntityType.getName()).andStubReturn("SOHeader");
- EasyMock.expect(startEdmEntitySet.getEntityType()).andStubReturn(startEdmEntityType);
- EasyMock.expect(entityUriInfo.getStartEntitySet()).andStubReturn(startEdmEntitySet);
- EasyMock.replay(startEdmEntityType, startEdmEntitySet);
- EasyMock.expect(edmEntitySet.getEntityType()).andStubReturn(edmEntityType);
- EasyMock.expect(edmEntityType.getMapping()).andStubReturn(null);
- EasyMock.expect(edmEntityType.getName()).andStubReturn("SOHeader");
- EasyMock.replay(edmEntityType, edmEntitySet, entityUriInfo);
-
- }
-
- @After
- public void tearDown() throws Exception {}
-
- @Test
- public void testGetJPAOuterJoinClauses() throws Exception {
- setUp(false);
-
- JPQLJoinSelectSingleContext joinContext = new JPQLJoinSelectSingleContext();
- JPQLJoinSelectSingleContextBuilder joinContextBuilder = joinContext.new JPQLJoinSelectSingleContextBuilder();
- try {
- joinContextBuilder.entityView = entityUriInfo;
- joinContextBuilder.build();
- } catch (ODataJPAModelException e) {
- fail("Should not come here");
- } catch (ODataJPARuntimeException e) {
- fail("Should not come here");
- }
- List<JPAJoinClause> joinClauses = joinContext.getJPAJoinClauses();
- assertNotNull(joinClauses);
- assertTrue(joinClauses.size() > 0);
- assertEquals("E1", joinClauses.get(0).getEntityAlias());
- assertEquals("SOHeader", joinClauses.get(0).getEntityName());
- assertEquals("s_Itema", joinClauses.get(1).getEntityRelationShip());
- assertEquals("R1", joinClauses.get(1).getEntityRelationShipAlias());
- }
-
- @Test
- public void testExceptionThrown() throws Exception {
- setUp(true);
- JPQLJoinSelectSingleContext joinContext = new JPQLJoinSelectSingleContext();
- JPQLJoinSelectSingleContextBuilder joinContextBuilder = joinContext.new JPQLJoinSelectSingleContextBuilder();
- try {
- joinContextBuilder.entityView = entityUriInfo;
- joinContextBuilder.build();
- fail("Should not come here");
- } catch (ODataJPAModelException e) {
- fail("Should not come here");
- } catch (ODataJPARuntimeException e) {
- assertTrue(true);
- }
- }
-
- private EdmNavigationProperty createNavigationProperty(final String z) throws EdmException {
- EdmNavigationProperty navigationProperty = EasyMock.createMock(EdmNavigationProperty.class);
- EdmAssociation association = EasyMock.createMock(EdmAssociation.class);
- EdmAssociationEnd associationEnd = EasyMock.createMock(EdmAssociationEnd.class);
- EasyMock.expect(navigationProperty.getFromRole()).andStubReturn("roleA" + z);
- EasyMock.expect(navigationProperty.getToRole()).andStubReturn("roleB" + z);
- EasyMock.expect(navigationProperty.getName()).andStubReturn("navP" + z);
- EasyMock.expect(navigationProperty.getName()).andStubReturn("navP" + z);
- EasyMock.expect(navigationProperty.getMultiplicity()).andStubReturn(EdmMultiplicity.ONE);
- EdmEntityType edmEntityType = EasyMock.createMock(EdmEntityType.class);
- EdmMapping edmMapping = EasyMock.createMock(EdmMapping.class);
- EasyMock.expect(edmMapping.getInternalName()).andStubReturn("sItem" + z);
- EasyMock.expect(edmEntityType.getMapping()).andStubReturn(edmMapping);
- EasyMock.expect(edmEntityType.getName()).andStubReturn("soItem" + z);
- EasyMock.expect(associationEnd.getEntityType()).andStubReturn(edmEntityType);
- EasyMock.expect(association.getEnd("roleA" + z)).andStubReturn(associationEnd);
- EasyMock.expect(navigationProperty.getRelationship()).andStubReturn(association);
- EdmMapping edmMapping1 = EasyMock.createMock(EdmMapping.class);
- EasyMock.expect(edmMapping1.getInternalName()).andStubReturn("s_Item" + z);
- EasyMock.expect(navigationProperty.getMapping()).andStubReturn(edmMapping1);
- EasyMock.replay(edmMapping, edmMapping1, edmEntityType, associationEnd, association, navigationProperty);
- return navigationProperty;
- }
-
- private List<KeyPredicate> createKeyPredicates(final boolean toThrowException) throws EdmException {
- KeyPredicate keyPredicate = EasyMock.createMock(KeyPredicate.class);
- EasyMock.expect(keyPredicate.getLiteral()).andStubReturn("1");
- EdmProperty edmProperty = EasyMock.createMock(EdmProperty.class);
- EdmMapping edmMapping = EasyMock.createMock(EdmMapping.class);
- EasyMock.expect(edmMapping.getInternalName()).andStubReturn("soid");
- EasyMock.expect(edmProperty.getMapping()).andStubReturn(edmMapping);
- EasyMock.expect(edmProperty.getName()).andStubReturn("soid");
- EdmSimpleType edmType = EasyMock.createMock(EdmSimpleType.class);
- if (toThrowException) {
- EasyMock.expect(edmProperty.getType()).andStubThrow(new EdmException(null));
- } else {
- EasyMock.expect(edmProperty.getType()).andStubReturn(edmType);
- }
- EasyMock.expect(keyPredicate.getProperty()).andStubReturn(edmProperty);
-
- EasyMock.replay(edmType, edmMapping, edmProperty, keyPredicate);
- List<KeyPredicate> keyPredicates = new ArrayList<KeyPredicate>();
- keyPredicates.add(keyPredicate);
- return keyPredicates;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLJoinSelectSingleStatementBuilderTest.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLJoinSelectSingleStatementBuilderTest.java b/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLJoinSelectSingleStatementBuilderTest.java
deleted file mode 100644
index c7df74b..0000000
--- a/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLJoinSelectSingleStatementBuilderTest.java
+++ /dev/null
@@ -1,142 +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.jpql;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.olingo.odata2.api.edm.EdmException;
-import org.apache.olingo.odata2.api.edm.EdmMapping;
-import org.apache.olingo.odata2.api.edm.EdmProperty;
-import org.apache.olingo.odata2.api.edm.EdmSimpleType;
-import org.apache.olingo.odata2.api.uri.KeyPredicate;
-import org.apache.olingo.odata2.processor.api.jpa.access.JPAJoinClause;
-import org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPARuntimeException;
-import org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLContextType;
-import org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLJoinSelectSingleContextView;
-import org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLStatement;
-import org.easymock.EasyMock;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-public class JPQLJoinSelectSingleStatementBuilderTest {
- JPQLJoinSelectSingleContextView context = null;
-
- @BeforeClass
- public static void setUpBeforeClass() throws Exception {}
-
- @AfterClass
- public static void tearDownAfterClass() throws Exception {}
-
- public void setUp(final List<JPAJoinClause> joinClauseList) throws Exception {
- context = EasyMock.createMock(JPQLJoinSelectSingleContextView.class);
- EasyMock.expect(context.getJPAEntityAlias()).andStubReturn("gt1");
- EasyMock.expect(context.getJPAEntityName()).andStubReturn("SOHeader");
- EasyMock.expect(context.getType()).andStubReturn(JPQLContextType.SELECT);
- EasyMock.expect(context.getKeyPredicates()).andStubReturn(createKeyPredicates());
- EasyMock.expect(context.getSelectExpression()).andStubReturn("gt1");
- EasyMock.expect(context.getJPAJoinClauses()).andStubReturn(joinClauseList);
- EasyMock.replay(context);
- }
-
- private List<JPAJoinClause> getJoinClauseList() {
- List<JPAJoinClause> joinClauseList = new ArrayList<JPAJoinClause>();
- JPAJoinClause jpaOuterJoinClause =
- new JPAJoinClause("SOHeader", "soh", null, null, "soh.soId = 1", JPAJoinClause.JOIN.LEFT);
- joinClauseList.add(jpaOuterJoinClause);
- jpaOuterJoinClause =
- new JPAJoinClause("SOHeader", "soh", "soItem", "soi", "soi.shId = soh.soId", JPAJoinClause.JOIN.LEFT);
- joinClauseList.add(jpaOuterJoinClause);
- jpaOuterJoinClause =
- new JPAJoinClause("SOItem", "si", "material", "mat", "mat.id = 'abc'", JPAJoinClause.JOIN.LEFT);
- joinClauseList.add(jpaOuterJoinClause);
- return joinClauseList;
- }
-
- @After
- public void tearDown() throws Exception {}
-
- @Test
- public void testBuild() throws Exception {
- setUp(getJoinClauseList());
- JPQLJoinSelectSingleStatementBuilder jpqlJoinSelectsingleStatementBuilder =
- new JPQLJoinSelectSingleStatementBuilder(context);
- try {
- JPQLStatement jpqlStatement = jpqlJoinSelectsingleStatementBuilder.build();
- assertEquals(
- "SELECT gt1 FROM SOHeader soh JOIN soh.soItem soi JOIN soi.material mat WHERE soh.soId = 1 AND " +
- "soi.shId = soh.soId AND mat.id = 'abc'",
- jpqlStatement.toString());
- } catch (ODataJPARuntimeException e) {
- fail("Should not have come here");
- }
-
- }
-
- private List<KeyPredicate> createKeyPredicates() throws EdmException {
- KeyPredicate keyPredicate = EasyMock.createMock(KeyPredicate.class);
- EasyMock.expect(keyPredicate.getLiteral()).andStubReturn("1");
- EdmProperty edmProperty = EasyMock.createMock(EdmProperty.class);
- EdmMapping edmMapping = EasyMock.createMock(EdmMapping.class);
- EasyMock.expect(edmMapping.getInternalName()).andStubReturn("soid");
- EasyMock.expect(edmProperty.getMapping()).andStubReturn(edmMapping);
- EdmSimpleType edmType = EasyMock.createMock(EdmSimpleType.class);
- EasyMock.expect(edmProperty.getType()).andStubReturn(edmType);
- EasyMock.expect(keyPredicate.getProperty()).andStubReturn(edmProperty);
-
- EasyMock.replay(edmType, edmMapping, edmProperty, keyPredicate);
- List<KeyPredicate> keyPredicates = new ArrayList<KeyPredicate>();
- keyPredicates.add(keyPredicate);
- return keyPredicates;
- }
-
- @Test
- public void testJoinClauseAsNull() throws Exception {
- setUp(null);
- JPQLJoinSelectSingleStatementBuilder jpqlJoinSelectsingleStatementBuilder =
- new JPQLJoinSelectSingleStatementBuilder(context);
- try {
- jpqlJoinSelectsingleStatementBuilder.build();
- fail("Should not have come here");
- } catch (ODataJPARuntimeException e) {
- assertTrue(true);
- }
- }
-
- @Test
- public void testJoinClauseListAsEmpty() throws Exception {
- List<JPAJoinClause> joinClauseList = new ArrayList<JPAJoinClause>();
- setUp(joinClauseList);
- JPQLJoinSelectSingleStatementBuilder jpqlJoinSelectsingleStatementBuilder =
- new JPQLJoinSelectSingleStatementBuilder(context);
- try {
- jpqlJoinSelectsingleStatementBuilder.build();
- fail("Should not have come here");
- } catch (ODataJPARuntimeException e) {
- assertTrue(true);
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLJoinStatementBuilderTest.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLJoinStatementBuilderTest.java b/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLJoinStatementBuilderTest.java
deleted file mode 100644
index dad45e3..0000000
--- a/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLJoinStatementBuilderTest.java
+++ /dev/null
@@ -1,124 +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.jpql;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-
-import org.apache.olingo.odata2.processor.api.jpa.access.JPAJoinClause;
-import org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPARuntimeException;
-import org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLContextType;
-import org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLJoinContextView;
-import org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLStatement;
-import org.easymock.EasyMock;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-public class JPQLJoinStatementBuilderTest {
- JPQLJoinContextView context = null;
-
- @BeforeClass
- public static void setUpBeforeClass() throws Exception {}
-
- @AfterClass
- public static void tearDownAfterClass() throws Exception {}
-
- public void setUp(final List<JPAJoinClause> joinClauseList) throws Exception {
- context = EasyMock.createMock(JPQLJoinContextView.class);
- EasyMock.expect(context.getJPAEntityAlias()).andStubReturn("mat");
- EasyMock.expect(context.getJPAEntityName()).andStubReturn("SOHeader");
- EasyMock.expect(context.getType()).andStubReturn(JPQLContextType.SELECT);
- EasyMock.expect(context.getSelectExpression()).andStubReturn("mat");
- EasyMock.expect(context.getWhereExpression()).andStubReturn("soh.buyerId = 2");
- HashMap<String, String> orderByMap = new HashMap<String, String>();
- orderByMap.put("mat.buyerId", "asc");
- orderByMap.put("mat.city", "desc");
- EasyMock.expect(context.getOrderByCollection()).andStubReturn(orderByMap);
- EasyMock.expect(context.getJPAJoinClauses()).andStubReturn(joinClauseList);
- EasyMock.replay(context);
- }
-
- private List<JPAJoinClause> getJoinClauseList() {
- List<JPAJoinClause> joinClauseList = new ArrayList<JPAJoinClause>();
- JPAJoinClause jpaOuterJoinClause =
- new JPAJoinClause("SOHeader", "soh", null, null, "soh.createdBy = 'Peter'", JPAJoinClause.JOIN.LEFT);
- joinClauseList.add(jpaOuterJoinClause);
- jpaOuterJoinClause =
- new JPAJoinClause("SOHeader", "soh", "soItem", "soi", "soi.shId = soh.soId", JPAJoinClause.JOIN.LEFT);
- joinClauseList.add(jpaOuterJoinClause);
- jpaOuterJoinClause =
- new JPAJoinClause("SOItem", "si", "material", "mat", "mat.id = 'abc'", JPAJoinClause.JOIN.LEFT);
- joinClauseList.add(jpaOuterJoinClause);
- return joinClauseList;
- }
-
- @After
- public void tearDown() throws Exception {}
-
- @Test
- public void testBuild() throws Exception {
- setUp(getJoinClauseList());
- JPQLJoinStatementBuilder jpqlJoinStatementBuilder = new JPQLJoinStatementBuilder(context);
- try {
- JPQLStatement jpqlStatement = jpqlJoinStatementBuilder.build();
- assertEquals(
- "SELECT mat FROM SOHeader soh JOIN soh.soItem soi JOIN soi.material mat WHERE soh.buyerId = 2 AND "
- +
- "soh.createdBy = 'Peter' AND soi.shId = soh.soId AND mat.id = 'abc' "
- +
- "ORDER BY mat.buyerId asc , mat.city desc",
- jpqlStatement.toString());
- } catch (ODataJPARuntimeException e) {
- fail("Should not have come here");
- }
-
- }
-
- @Test
- public void testJoinClauseAsNull() throws Exception {
- setUp(null);
- JPQLJoinStatementBuilder jpqlJoinStatementBuilder = new JPQLJoinStatementBuilder(context);
- try {
- jpqlJoinStatementBuilder.build();
- fail("Should not have come here");
- } catch (ODataJPARuntimeException e) {
- assertTrue(true);
- }
- }
-
- @Test
- public void testJoinClauseListAsEmpty() throws Exception {
- setUp(new ArrayList<JPAJoinClause>());
- JPQLJoinStatementBuilder jpqlJoinStatementBuilder = new JPQLJoinStatementBuilder(context);
- try {
- jpqlJoinStatementBuilder.build();
- fail("Should not have come here");
- } catch (ODataJPARuntimeException e) {
- assertTrue(true);
- }
- }
-
-}
[25/37] [OLINGO-82] Renamed the project folder name to
odata2-jpa-processor
Posted by ch...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLSelectContextImplTest.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLSelectContextImplTest.java b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLSelectContextImplTest.java
new file mode 100644
index 0000000..817d8d3
--- /dev/null
+++ b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLSelectContextImplTest.java
@@ -0,0 +1,385 @@
+/*******************************************************************************
+ * 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.jpql;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.olingo.odata2.api.edm.EdmEntitySet;
+import org.apache.olingo.odata2.api.edm.EdmEntityType;
+import org.apache.olingo.odata2.api.edm.EdmException;
+import org.apache.olingo.odata2.api.edm.EdmMapping;
+import org.apache.olingo.odata2.api.edm.EdmProperty;
+import org.apache.olingo.odata2.api.edm.EdmType;
+import org.apache.olingo.odata2.api.uri.KeyPredicate;
+import org.apache.olingo.odata2.api.uri.SelectItem;
+import org.apache.olingo.odata2.api.uri.expression.ExpressionKind;
+import org.apache.olingo.odata2.api.uri.expression.FilterExpression;
+import org.apache.olingo.odata2.api.uri.expression.OrderByExpression;
+import org.apache.olingo.odata2.api.uri.expression.OrderExpression;
+import org.apache.olingo.odata2.api.uri.expression.PropertyExpression;
+import org.apache.olingo.odata2.api.uri.expression.SortOrder;
+import org.apache.olingo.odata2.api.uri.info.GetEntitySetUriInfo;
+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.jpql.JPQLContext;
+import org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLContextType;
+import org.apache.olingo.odata2.processor.core.jpa.common.ODataJPATestConstants;
+import org.apache.olingo.odata2.processor.core.jpa.jpql.JPQLSelectContext.JPQLSelectContextBuilder;
+import org.easymock.EasyMock;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class JPQLSelectContextImplTest {
+
+ private static String entityTypeName = "MockEntity";
+ private static String[] fields = { "Field1", "Field2" };
+ private static List<KeyPredicate> keyPredicates;
+ private static SortOrder[] orderType = { SortOrder.asc, SortOrder.desc };
+
+ private static JPQLSelectContextBuilder builder;
+ private static JPQLSelectContext selectContext;
+
+ @BeforeClass
+ public static void setup() {
+
+ }
+
+ private void buildSelectContext(final boolean orderByIsNull, final boolean selectFieldsIsNull,
+ final boolean filterIsNull, final boolean isTopNull, final boolean isSkipNull) {
+ builder = null;
+ selectContext = null;
+ keyPredicates = new ArrayList<KeyPredicate>();
+ GetEntitySetUriInfo resultsView = EasyMock.createMock(GetEntitySetUriInfo.class);
+
+ EdmEntitySet entitySet = EasyMock.createMock(EdmEntitySet.class);
+ EdmEntityType entityType = EasyMock.createMock(EdmEntityType.class);
+ KeyPredicate keyPredicate = EasyMock.createMock(KeyPredicate.class);
+ EdmProperty kpProperty = EasyMock.createMock(EdmProperty.class);
+ EdmType edmType1 = EasyMock.createMock(EdmType.class);
+ EdmMapping mapping = EasyMock.createMock(EdmMapping.class);
+ EasyMock.expect(keyPredicate.getLiteral()).andStubReturn("1");
+ try {
+ EasyMock.expect(mapping.getInternalName()).andStubReturn("Field1");
+ EasyMock.expect(kpProperty.getMapping()).andStubReturn(mapping);
+ EasyMock.expect(kpProperty.getType()).andStubReturn(edmType1);
+
+ } catch (EdmException e2) {
+ fail("this should not happen");
+ }
+ EasyMock.expect(keyPredicate.getProperty()).andStubReturn(kpProperty);
+ EasyMock.replay(mapping, edmType1, kpProperty, keyPredicate);
+ keyPredicates.add(keyPredicate);
+ int i = 0;
+ List<OrderExpression> orderList = new ArrayList<OrderExpression>(2);
+ do {
+
+ EdmType edmType = EasyMock.createMock(EdmType.class);
+ try {
+ EasyMock.expect(edmType.getName()).andStubReturn(fields[i]);
+ EasyMock.replay(edmType);
+ } catch (EdmException e2) {
+ fail("Exception not Expected");
+ }
+
+ PropertyExpression commonExpression = EasyMock.createMock(PropertyExpression.class);
+ EasyMock.expect(commonExpression.getEdmType()).andStubReturn(edmType);
+
+ EdmProperty edmTyped = EasyMock.createMock(EdmProperty.class);
+ EdmMapping edmMapping = EasyMock.createMock(EdmMapping.class);
+ EasyMock.expect(edmMapping.getInternalName()).andStubReturn(fields[i]);
+ try {
+ EasyMock.expect(edmTyped.getMapping()).andStubReturn(edmMapping);
+ } catch (EdmException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ EasyMock.expect(commonExpression.getEdmProperty()).andStubReturn(edmTyped);
+ OrderExpression order = EasyMock.createMock(OrderExpression.class);
+ EasyMock.expect(order.getExpression()).andStubReturn(commonExpression);
+ EasyMock.expect(order.getSortOrder()).andStubReturn(orderType[i]);
+ EasyMock.replay(edmMapping, edmTyped, commonExpression);
+ EasyMock.replay(order);
+
+ orderList.add(order);
+
+ } while (++i < 2);
+
+ OrderByExpression orderBy = EasyMock.createMock(OrderByExpression.class);
+ EasyMock.expect(orderBy.getOrders()).andStubReturn(orderList);
+ EasyMock.replay(orderBy);
+
+ try {
+ i = 0;
+ List<SelectItem> selectItemList = new ArrayList<SelectItem>(2);
+ do {
+ EdmMapping edmMapping = EasyMock.createMock(EdmMapping.class);
+ EasyMock.expect(edmMapping.getInternalName()).andStubReturn(fields[i]);
+ EdmProperty edmProperty = EasyMock.createMock(EdmProperty.class);
+ EasyMock.expect(edmProperty.getMapping()).andStubReturn(edmMapping);
+ EasyMock.replay(edmMapping, edmProperty);
+
+ SelectItem selectItem = EasyMock.createMock(SelectItem.class);
+ EasyMock.expect(selectItem.getProperty()).andStubReturn(edmProperty);
+ EasyMock.replay(selectItem);
+
+ selectItemList.add(selectItem);
+
+ } while (++i < 2);
+ EasyMock.expect(entityType.getMapping()).andStubReturn(null);
+ EasyMock.expect(entityType.getName()).andStubReturn(entityTypeName);
+ EasyMock.expect(entityType.getKeyProperties()).andStubReturn(getLocalKeyProperties());
+
+ EasyMock.replay(entityType);
+ EasyMock.expect(entitySet.getEntityType()).andStubReturn(entityType);
+ EasyMock.replay(entitySet);
+
+ EasyMock.expect(resultsView.getTargetEntitySet()).andStubReturn(entitySet);
+ if (orderByIsNull) {
+ EasyMock.expect(resultsView.getOrderBy()).andStubReturn(null);
+ } else {
+ EasyMock.expect(resultsView.getOrderBy()).andStubReturn(orderBy);
+ }
+ if (selectFieldsIsNull) {
+ EasyMock.expect(resultsView.getSelect()).andStubReturn(null);
+ } else {
+ EasyMock.expect(resultsView.getSelect()).andStubReturn(selectItemList);
+ }
+ // FilterExpression filterExpression =
+ // EasyMock.createMock(FilterExpression.class);
+ // EasyMock.expect(filterExpression.g)
+ if (filterIsNull) {
+ EasyMock.expect(resultsView.getFilter()).andStubReturn(null);
+ } else {
+ EasyMock.expect(resultsView.getFilter()).andStubReturn(
+ getFilterExpressionMockedObj(ExpressionKind.PROPERTY, "SalesOrder"));
+ }
+ if (isTopNull) {
+ EasyMock.expect(resultsView.getTop()).andStubReturn(null);
+ } else {
+ EasyMock.expect(resultsView.getTop()).andStubReturn(10);
+ }
+ if (isSkipNull) {
+ EasyMock.expect(resultsView.getSkip()).andStubReturn(null);
+ } else {
+ EasyMock.expect(resultsView.getSkip()).andStubReturn(0);
+ }
+ EasyMock.expect(resultsView.getKeyPredicates()).andStubReturn(keyPredicates);
+ EasyMock.replay(resultsView);
+
+ } catch (EdmException e1) {
+ fail("Exception not Expected");
+ }
+ try {
+ builder = (JPQLSelectContextBuilder) JPQLContext.createBuilder(JPQLContextType.SELECT, resultsView);
+
+ selectContext = (JPQLSelectContext) builder.build();
+ } catch (ODataJPAModelException e) {
+ fail("Exception not Expected");
+ } catch (ODataJPARuntimeException e) {
+ fail("Runtime Exception thrown");
+ }
+ }
+
+ private List<EdmProperty> getLocalKeyProperties() {
+ List<EdmProperty> propertyList = new ArrayList<EdmProperty>();
+ EdmProperty edmProperty = EasyMock.createMock(EdmProperty.class);
+ try {
+ EasyMock.expect(edmProperty.getName()).andStubReturn("Field1");
+ EasyMock.expect(edmProperty.getMapping()).andStubReturn(null);
+ } catch (EdmException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+ EasyMock.replay(edmProperty);
+ propertyList.add(edmProperty);
+ return propertyList;
+ }
+
+ @Test
+ public void testEntityNameThrowingException() {
+ // buildSelectContext(false, false, false);
+ GetEntitySetUriInfo resultsView = EasyMock.createMock(GetEntitySetUriInfo.class);
+
+ EdmEntitySet entitySet = EasyMock.createMock(EdmEntitySet.class);
+ EdmEntityType entityType = EasyMock.createMock(EdmEntityType.class);
+
+ try {
+ EasyMock.expect(entityType.getName()).andStubThrow(new EdmException(null));
+ EasyMock.expect(entitySet.getEntityType()).andStubThrow(new EdmException(null));
+ } catch (EdmException e1) {
+ // throw new ODataException();
+ }
+
+ EasyMock.replay(entityType);
+ EasyMock.replay(entitySet);
+
+ EasyMock.expect(resultsView.getTargetEntitySet()).andStubReturn(entitySet);
+ EasyMock.expect(resultsView.getOrderBy()).andStubReturn(null);
+ EasyMock.expect(resultsView.getSelect()).andStubReturn(null);
+ EasyMock.expect(resultsView.getFilter()).andStubReturn(null);
+ EasyMock.replay(resultsView);
+ try {
+ JPQLSelectContextBuilder builder1 =
+ (JPQLSelectContextBuilder) JPQLContext.createBuilder(JPQLContextType.SELECT, resultsView);
+
+ builder1.build();
+ fail("Should not come here");
+ } catch (ODataJPAModelException e) {
+ fail();
+ } catch (ODataJPARuntimeException e) {
+ assertTrue(true);
+ }
+ }
+
+ @Test
+ public void testSelectFieldsAsNull() {
+ buildSelectContext(false, true, true, true, true);
+
+ try {
+ selectContext = (JPQLSelectContext) builder.build();
+ assertEquals("E2", selectContext.getSelectExpression());
+ } catch (ODataJPAModelException e) {
+ fail();
+ } catch (ODataJPARuntimeException e) {
+ fail();
+ }
+ }
+
+ @Test
+ public void testGetOrderByCollection() {
+ buildSelectContext(false, false, true, true, true);
+ assertEquals(true, selectContext.getOrderByCollection().containsKey("E1." + JPQLSelectContextImplTest.fields[0]));
+ assertEquals("", selectContext.getOrderByCollection().get("E1." + JPQLSelectContextImplTest.fields[0]));
+
+ assertEquals(true, selectContext.getOrderByCollection().containsKey("E1." + JPQLSelectContextImplTest.fields[1]));
+ assertEquals("DESC", selectContext.getOrderByCollection().get("E1." + JPQLSelectContextImplTest.fields[1]));
+ }
+
+ @Test
+ public void testGetWhereExpression() {
+ buildSelectContext(false, false, true, true, true);
+ // fail("Not yet implemented");
+ }
+
+ @Test
+ public void testGetJPAEntityName() {
+ buildSelectContext(false, false, true, true, true);
+ assertEquals(JPQLSelectContextImplTest.entityTypeName, selectContext.getJPAEntityName());
+ }
+
+ @Test
+ public void testGetType() {
+ buildSelectContext(false, false, true, true, true);
+ assertEquals(JPQLContextType.SELECT, selectContext.getType());
+ }
+
+ @Test
+ public void testCreateBuilder() {
+ buildSelectContext(false, false, true, true, true);
+ assertEquals(JPQLSelectContextBuilder.class.toString(), builder.getClass().toString());
+ }
+
+ @Test
+ public void testEntitySetAsNull() {
+ buildSelectContext(false, false, true, true, true);
+ try {
+ JPQLSelectContextBuilder builder =
+ (JPQLSelectContextBuilder) JPQLContext.createBuilder(JPQLContextType.SELECT, null);
+
+ JPQLSelectContext selectContext1 = (JPQLSelectContext) builder.build();
+ assertNull(selectContext1.getJPAEntityAlias());
+ assertNull(selectContext1.getJPAEntityName());
+ assertNull(selectContext1.getOrderByCollection());
+ assertNull(selectContext1.getSelectExpression());
+ assertNull(selectContext1.getType());
+ assertNull(selectContext1.getWhereExpression());
+ } catch (ODataJPAModelException e) {
+ fail("Exception not Expected");
+ } catch (ODataJPARuntimeException e) {
+ fail("Runtime Exception thrown");
+ }
+ }
+
+ @Test
+ public void testOrderingWithSkip() {
+ buildSelectContext(true, false, true, true, false);
+ assertEquals(true, selectContext.getOrderByCollection().containsKey("E1." + JPQLSelectContextImplTest.fields[0]));
+ assertEquals("", selectContext.getOrderByCollection().get("E1." + JPQLSelectContextImplTest.fields[0]));
+
+ assertEquals(false, selectContext.getOrderByCollection().containsKey("E1." + JPQLSelectContextImplTest.fields[1]));
+
+ }
+
+ @Test
+ public void testOrderingWithTop() {
+ buildSelectContext(true, false, true, false, true);
+ assertEquals(true, selectContext.getOrderByCollection().containsKey("E1." + JPQLSelectContextImplTest.fields[0]));
+ assertEquals("", selectContext.getOrderByCollection().get("E1." + JPQLSelectContextImplTest.fields[0]));
+
+ assertEquals(false, selectContext.getOrderByCollection().containsKey("E1." + JPQLSelectContextImplTest.fields[1]));
+
+ }
+
+ @Test
+ public void testOrderByTopSkipAsNull() {
+ buildSelectContext(true, true, true, true, true);
+ assertNull(selectContext.getOrderByCollection());
+ }
+
+ @Test
+ public void testFilter() {
+ buildSelectContext(true, false, false, false, false);
+ assertEquals("E1.field", selectContext.whereCondition);
+
+ }
+
+ private FilterExpression getFilterExpressionMockedObj(final ExpressionKind leftOperandExpKind,
+ final String propertyName) throws EdmException {
+ FilterExpression filterExpression = EasyMock.createMock(FilterExpression.class);
+ EasyMock.expect(filterExpression.getKind()).andStubReturn(ExpressionKind.FILTER);
+ EasyMock.expect(filterExpression.getExpression()).andStubReturn(
+ getPropertyExpressionMockedObj(leftOperandExpKind, propertyName));
+ EasyMock.replay(filterExpression);
+ return filterExpression;
+ }
+
+ private PropertyExpression getPropertyExpressionMockedObj(final ExpressionKind expKind, final String propertyName) {
+ PropertyExpression leftOperandPropertyExpresion = EasyMock.createMock(PropertyExpression.class);
+ EasyMock.expect(leftOperandPropertyExpresion.getKind()).andReturn(ExpressionKind.PROPERTY);
+ EasyMock.expect(leftOperandPropertyExpresion.getPropertyName()).andReturn(propertyName);
+ EdmProperty edmtTyped = EasyMock.createMock(EdmProperty.class);
+ EdmMapping mapping = EasyMock.createMock(EdmMapping.class);
+ EasyMock.expect(mapping.getInternalName()).andStubReturn("field");
+ try {
+ EasyMock.expect(edmtTyped.getMapping()).andStubReturn(mapping);
+ } catch (EdmException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ EasyMock.expect(leftOperandPropertyExpresion.getEdmProperty()).andReturn(edmtTyped);
+ EasyMock.replay(mapping, edmtTyped, leftOperandPropertyExpresion);
+ return leftOperandPropertyExpresion;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLSelectSingleContextImplTest.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLSelectSingleContextImplTest.java b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLSelectSingleContextImplTest.java
new file mode 100644
index 0000000..841ff5a
--- /dev/null
+++ b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLSelectSingleContextImplTest.java
@@ -0,0 +1,198 @@
+/*******************************************************************************
+ * 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.jpql;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.olingo.odata2.api.edm.EdmEntitySet;
+import org.apache.olingo.odata2.api.edm.EdmEntityType;
+import org.apache.olingo.odata2.api.edm.EdmException;
+import org.apache.olingo.odata2.api.edm.EdmMapping;
+import org.apache.olingo.odata2.api.edm.EdmProperty;
+import org.apache.olingo.odata2.api.edm.EdmType;
+import org.apache.olingo.odata2.api.uri.KeyPredicate;
+import org.apache.olingo.odata2.api.uri.SelectItem;
+import org.apache.olingo.odata2.api.uri.info.GetEntityUriInfo;
+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.jpql.JPQLContext;
+import org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLContextType;
+import org.apache.olingo.odata2.processor.core.jpa.jpql.JPQLSelectSingleContext.JPQLSelectSingleContextBuilder;
+import org.easymock.EasyMock;
+import org.junit.Test;
+
+public class JPQLSelectSingleContextImplTest {
+
+ private static String entityTypeName = "MockEntity";
+ private static String[] fields = { "Field1", "Field2" };
+ private static List<KeyPredicate> keyPredicates;
+
+ private static JPQLSelectSingleContextBuilder builder;
+ private static JPQLSelectSingleContext selectContext;
+
+ private void buildContextBuilder(final boolean isSelectNull) {
+ builder = null;
+ selectContext = null;
+ keyPredicates = new ArrayList<KeyPredicate>();
+ GetEntityUriInfo resultsView = EasyMock.createMock(GetEntityUriInfo.class);
+
+ EdmEntitySet entitySet = EasyMock.createMock(EdmEntitySet.class);
+ EdmEntityType entityType = EasyMock.createMock(EdmEntityType.class);
+
+ KeyPredicate keyPredicate = EasyMock.createMock(KeyPredicate.class);
+ EdmProperty kpProperty = EasyMock.createMock(EdmProperty.class);
+ EdmType edmType = EasyMock.createMock(EdmType.class);
+ EasyMock.expect(keyPredicate.getLiteral()).andStubReturn("1");
+ try {
+ EasyMock.expect(kpProperty.getName()).andStubReturn("Field1");
+ EasyMock.expect(kpProperty.getType()).andStubReturn(edmType);
+
+ } catch (EdmException e2) {
+ fail("this should not happen");
+ }
+ EasyMock.expect(keyPredicate.getProperty()).andStubReturn(kpProperty);
+ EasyMock.replay(edmType, kpProperty, keyPredicate);
+ keyPredicates.add(keyPredicate);
+ int i = 0;
+ try {
+
+ List<SelectItem> selectItemList = new ArrayList<SelectItem>(2);
+ do {
+ EdmMapping edmMapping = EasyMock.createMock(EdmMapping.class);
+ EasyMock.expect(edmMapping.getInternalName()).andStubReturn(fields[i]);
+ EdmProperty edmProperty = EasyMock.createMock(EdmProperty.class);
+ EasyMock.expect(edmProperty.getMapping()).andStubReturn(edmMapping);
+ EasyMock.replay(edmMapping, edmProperty);
+
+ SelectItem selectItem = EasyMock.createMock(SelectItem.class);
+ EasyMock.expect(selectItem.getProperty()).andStubReturn(edmProperty);
+ EasyMock.replay(selectItem);
+
+ selectItemList.add(selectItem);
+
+ } while (++i < 2);
+
+ EasyMock.expect(entityType.getMapping()).andStubReturn(null);
+ EasyMock.expect(entityType.getName()).andStubReturn(entityTypeName);
+ EasyMock.replay(entityType);
+ EasyMock.expect(entitySet.getEntityType()).andStubReturn(entityType);
+ EasyMock.replay(entitySet);
+
+ EasyMock.expect(resultsView.getTargetEntitySet()).andStubReturn(entitySet);
+ if (isSelectNull) {
+ selectItemList = null;
+ }
+ EasyMock.expect(resultsView.getSelect()).andStubReturn(selectItemList);
+ ArrayList<KeyPredicate> arrayList = new ArrayList<KeyPredicate>();
+ arrayList.add(keyPredicate);
+ EasyMock.expect(resultsView.getKeyPredicates()).andStubReturn(arrayList);
+ EasyMock.replay(resultsView);
+
+ } catch (EdmException e1) {
+ fail("Exception not Expected");
+ }
+ try {
+ builder = (JPQLSelectSingleContextBuilder) JPQLContext.createBuilder(JPQLContextType.SELECT_SINGLE, resultsView);
+
+ selectContext = (JPQLSelectSingleContext) builder.build();
+ } catch (ODataJPAModelException e) {
+ fail("Exception not Expected");
+ } catch (ODataJPARuntimeException e) {
+ fail("Runtime Exception thrown");
+ }
+ }
+
+ @Test
+ public void testEntityNameThrowingException() {
+ // buildSelectContext(false, false, false);
+ GetEntityUriInfo resultsView = EasyMock.createMock(GetEntityUriInfo.class);
+
+ EdmEntitySet entitySet = EasyMock.createMock(EdmEntitySet.class);
+ EdmEntityType entityType = EasyMock.createMock(EdmEntityType.class);
+
+ try {
+ EasyMock.expect(entityType.getName()).andStubThrow(new EdmException(null));
+ EasyMock.expect(entitySet.getEntityType()).andStubThrow(new EdmException(null));
+ } catch (EdmException e1) {
+ // throw new ODataException();
+ }
+
+ EasyMock.replay(entityType);
+ EasyMock.replay(entitySet);
+
+ EasyMock.expect(resultsView.getTargetEntitySet()).andStubReturn(entitySet);
+ EasyMock.expect(resultsView.getSelect()).andStubReturn(null);
+ EasyMock.expect(resultsView.getFilter()).andStubReturn(null);
+ EasyMock.replay(resultsView);
+ try {
+ JPQLSelectSingleContextBuilder builder1 =
+ (JPQLSelectSingleContextBuilder) JPQLContext.createBuilder(JPQLContextType.SELECT_SINGLE, resultsView);
+ builder1.build();
+ fail("Should not come here");
+ } catch (ODataJPAModelException e) {
+ fail();
+ } catch (ODataJPARuntimeException e) {
+ assertTrue(true);
+ }
+ }
+
+ @Test
+ public void testSlectedFieldsAsNull() {
+ buildContextBuilder(true);
+ try {
+ selectContext = (JPQLSelectSingleContext) builder.build();
+ assertEquals("E2", selectContext.getSelectExpression());
+ } catch (ODataJPAModelException e) {
+ fail();
+ } catch (ODataJPARuntimeException e) {
+ fail();
+ }
+ }
+
+ @Test
+ public void getKeyPredicates() {
+ buildContextBuilder(false);
+ assertEquals(keyPredicates.size(), selectContext.getKeyPredicates().size());
+ assertEquals(keyPredicates, selectContext.getKeyPredicates());
+ }
+
+ @Test
+ public void testGetJPAEntityName() {
+ buildContextBuilder(false);
+ assertEquals(JPQLSelectSingleContextImplTest.entityTypeName, selectContext.getJPAEntityName());
+ }
+
+ @Test
+ public void testGetType() {
+ buildContextBuilder(false);
+ assertEquals(JPQLContextType.SELECT_SINGLE, selectContext.getType());
+ }
+
+ @Test
+ public void testCreateBuilder() {
+ buildContextBuilder(false);
+ assertEquals(JPQLSelectSingleContextBuilder.class.toString(), builder.getClass().toString());
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLSelectSingleStatementBuilderTest.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLSelectSingleStatementBuilderTest.java b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLSelectSingleStatementBuilderTest.java
new file mode 100644
index 0000000..c5d5f95
--- /dev/null
+++ b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLSelectSingleStatementBuilderTest.java
@@ -0,0 +1,123 @@
+/*******************************************************************************
+ * 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.jpql;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.olingo.odata2.api.edm.EdmEntitySet;
+import org.apache.olingo.odata2.api.edm.EdmEntityType;
+import org.apache.olingo.odata2.api.edm.EdmException;
+import org.apache.olingo.odata2.api.edm.EdmMapping;
+import org.apache.olingo.odata2.api.edm.EdmProperty;
+import org.apache.olingo.odata2.api.edm.EdmSimpleType;
+import org.apache.olingo.odata2.api.uri.KeyPredicate;
+import org.apache.olingo.odata2.api.uri.SelectItem;
+import org.apache.olingo.odata2.api.uri.info.GetEntityUriInfo;
+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.jpql.JPQLContext;
+import org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLContext.JPQLContextBuilder;
+import org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLContextType;
+import org.easymock.EasyMock;
+import org.junit.Before;
+import org.junit.Test;
+
+public class JPQLSelectSingleStatementBuilderTest {
+
+ /**
+ * @throws java.lang.Exception
+ */
+ private JPQLSelectSingleStatementBuilder JPQLSelectSingleStatementBuilder;
+
+ @Before
+ public void setUp() throws Exception {
+
+ }
+
+ private JPQLSelectSingleContext createSelectContext() throws ODataJPARuntimeException, EdmException {
+ // Object Instantiation
+
+ JPQLSelectSingleContext JPQLSelectSingleContextImpl = null;// new JPQLSelectSingleContextImpl();
+ GetEntityUriInfo getEntityView = EasyMock.createMock(GetEntityUriInfo.class);
+
+ EdmEntitySet edmEntitySet = EasyMock.createMock(EdmEntitySet.class);
+ EdmEntityType edmEntityType = EasyMock.createMock(EdmEntityType.class);
+ List<SelectItem> selectItemList = null;
+
+ // Setting up the expected value
+ KeyPredicate keyPredicate = EasyMock.createMock(KeyPredicate.class);
+ EdmProperty kpProperty = EasyMock.createMock(EdmProperty.class);
+ EdmSimpleType edmType = EasyMock.createMock(EdmSimpleType.class);
+ EdmMapping edmMapping = EasyMock.createMock(EdmMapping.class);
+ EasyMock.expect(edmMapping.getInternalName()).andStubReturn("Field1");
+ EasyMock.expect(keyPredicate.getLiteral()).andStubReturn("1");
+ try {
+ EasyMock.expect(kpProperty.getName()).andStubReturn("Field1");
+ EasyMock.expect(kpProperty.getType()).andStubReturn(edmType);
+
+ EasyMock.expect(kpProperty.getMapping()).andStubReturn(edmMapping);
+
+ } catch (EdmException e2) {
+ fail("this should not happen");
+ }
+ EasyMock.expect(keyPredicate.getProperty()).andStubReturn(kpProperty);
+ EasyMock.replay(edmMapping, edmType, kpProperty, keyPredicate);
+ EasyMock.expect(getEntityView.getTargetEntitySet()).andStubReturn(edmEntitySet);
+ EasyMock.expect(getEntityView.getSelect()).andStubReturn(selectItemList);
+
+ EasyMock.expect(edmEntitySet.getEntityType()).andStubReturn(edmEntityType);
+ EasyMock.replay(edmEntitySet);
+ EasyMock.expect(edmEntityType.getMapping()).andStubReturn(null);
+ EasyMock.expect(edmEntityType.getName()).andStubReturn("SalesOrderHeader");
+ EasyMock.replay(edmEntityType);
+ ArrayList<KeyPredicate> arrayList = new ArrayList<KeyPredicate>();
+ arrayList.add(keyPredicate);
+ EasyMock.expect(getEntityView.getKeyPredicates()).andStubReturn(arrayList);
+ EasyMock.replay(getEntityView);
+
+ JPQLContextBuilder contextBuilder1 = JPQLContext.createBuilder(JPQLContextType.SELECT_SINGLE, getEntityView);
+ try {
+ JPQLSelectSingleContextImpl = (JPQLSelectSingleContext) contextBuilder1.build();
+ } catch (ODataJPAModelException e) {
+ fail("Model Exception thrown");
+ }
+
+ return JPQLSelectSingleContextImpl;
+ }
+
+ /**
+ * Test method for {@link org.apache.olingo.odata2.processor.jpa.jpql.JPQLSelectSingleStatementBuilder#build)}.
+ * @throws EdmException
+ * @throws ODataJPARuntimeException
+ */
+
+ @Test
+ public void testBuildSimpleQuery() throws EdmException, ODataJPARuntimeException {
+ JPQLSelectSingleContext JPQLSelectSingleContextImpl = createSelectContext();
+ JPQLSelectSingleStatementBuilder = new JPQLSelectSingleStatementBuilder(JPQLSelectSingleContextImpl);
+
+ assertEquals("SELECT E1 FROM SalesOrderHeader E1 WHERE E1.Field1 = 1", JPQLSelectSingleStatementBuilder.build()
+ .toString());
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLSelectStatementBuilderTest.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLSelectStatementBuilderTest.java b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLSelectStatementBuilderTest.java
new file mode 100644
index 0000000..2434809
--- /dev/null
+++ b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLSelectStatementBuilderTest.java
@@ -0,0 +1,135 @@
+/*******************************************************************************
+ * 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.jpql;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
+import java.util.HashMap;
+import java.util.List;
+
+import org.apache.olingo.odata2.api.edm.EdmEntitySet;
+import org.apache.olingo.odata2.api.edm.EdmEntityType;
+import org.apache.olingo.odata2.api.edm.EdmException;
+import org.apache.olingo.odata2.api.uri.SelectItem;
+import org.apache.olingo.odata2.api.uri.expression.FilterExpression;
+import org.apache.olingo.odata2.api.uri.expression.OrderByExpression;
+import org.apache.olingo.odata2.api.uri.info.GetEntitySetUriInfo;
+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.jpql.JPQLContext;
+import org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLContext.JPQLContextBuilder;
+import org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLContextType;
+import org.easymock.EasyMock;
+import org.junit.Before;
+import org.junit.Test;
+
+public class JPQLSelectStatementBuilderTest {
+
+ /**
+ * @throws java.lang.Exception
+ */
+ private JPQLSelectStatementBuilder jpqlSelectStatementBuilder;
+
+ @Before
+ public void setUp() throws Exception {
+
+ }
+
+ private JPQLSelectContext createSelectContext(final OrderByExpression orderByExpression,
+ final FilterExpression filterExpression) throws ODataJPARuntimeException, EdmException {
+ // Object Instantiation
+
+ JPQLSelectContext jpqlSelectContextImpl = null;
+ GetEntitySetUriInfo getEntitySetView = EasyMock.createMock(GetEntitySetUriInfo.class);
+
+ EdmEntitySet edmEntitySet = EasyMock.createMock(EdmEntitySet.class);
+ EdmEntityType edmEntityType = EasyMock.createMock(EdmEntityType.class);
+ List<SelectItem> selectItemList = null;
+
+ // Setting up the expected value
+
+ EasyMock.expect(getEntitySetView.getTargetEntitySet()).andStubReturn(edmEntitySet);
+ EasyMock.expect(getEntitySetView.getOrderBy()).andStubReturn(orderByExpression);
+ EasyMock.expect(getEntitySetView.getSelect()).andStubReturn(selectItemList);
+ EasyMock.expect(getEntitySetView.getFilter()).andStubReturn(filterExpression);
+ EasyMock.replay(getEntitySetView);
+ EasyMock.expect(edmEntitySet.getEntityType()).andStubReturn(edmEntityType);
+ EasyMock.replay(edmEntitySet);
+ EasyMock.expect(edmEntityType.getMapping()).andStubReturn(null);
+ EasyMock.expect(edmEntityType.getName()).andStubReturn("SalesOrderHeader");
+ EasyMock.replay(edmEntityType);
+
+ JPQLContextBuilder contextBuilder1 = JPQLContext.createBuilder(JPQLContextType.SELECT, getEntitySetView);
+ try {
+ jpqlSelectContextImpl = (JPQLSelectContext) contextBuilder1.build();
+ } catch (ODataJPAModelException e) {
+ fail("Model Exception thrown");
+ }
+
+ return jpqlSelectContextImpl;
+ }
+
+ /**
+ * Test method for {@link org.apache.olingo.odata2.processor.jpa.jpql.JPQLSelectStatementBuilder#build)}.
+ * @throws EdmException
+ * @throws ODataJPARuntimeException
+ */
+
+ @Test
+ public void testBuildSimpleQuery() throws EdmException, ODataJPARuntimeException {
+ OrderByExpression orderByExpression = EasyMock.createMock(OrderByExpression.class);
+ JPQLSelectContext jpqlSelectContextImpl = createSelectContext(orderByExpression, null);
+ jpqlSelectStatementBuilder = new JPQLSelectStatementBuilder(jpqlSelectContextImpl);
+
+ assertEquals("SELECT E1 FROM SalesOrderHeader E1", jpqlSelectStatementBuilder.build().toString());
+ }
+
+ @Test
+ public void testBuildQueryWithOrderBy() throws EdmException, ODataJPARuntimeException {
+ OrderByExpression orderByExpression = EasyMock.createMock(OrderByExpression.class);
+
+ JPQLSelectContext jpqlSelectContextImpl = createSelectContext(orderByExpression, null);
+ HashMap<String, String> orderByCollection = new HashMap<String, String>();
+ orderByCollection.put("E1.soID", "ASC");
+ orderByCollection.put("E1.buyerId", "DESC");
+ jpqlSelectContextImpl.setOrderByCollection(orderByCollection);
+ jpqlSelectStatementBuilder = new JPQLSelectStatementBuilder(jpqlSelectContextImpl);
+
+ assertEquals("SELECT E1 FROM SalesOrderHeader E1 ORDER BY E1.soID ASC , E1.buyerId DESC",
+ jpqlSelectStatementBuilder.build().toString());
+ }
+
+ @Test
+ public void testBuildQueryWithFilter() throws EdmException, ODataJPARuntimeException {
+ OrderByExpression orderByExpression = EasyMock.createMock(OrderByExpression.class);
+ FilterExpression filterExpression = null;// getFilterExpressionMockedObj();
+ JPQLSelectContext jpqlSelectContextImpl = createSelectContext(orderByExpression, filterExpression);
+ jpqlSelectContextImpl.setWhereExpression("E1.soID >= 1234");
+
+ jpqlSelectStatementBuilder = new JPQLSelectStatementBuilder(jpqlSelectContextImpl);
+
+ assertEquals("SELECT E1 FROM SalesOrderHeader E1 WHERE E1.soID >= 1234", jpqlSelectStatementBuilder.build()
+ .toString());
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/ODataJPAContextMock.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/ODataJPAContextMock.java b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/ODataJPAContextMock.java
new file mode 100644
index 0000000..7fc3a6d
--- /dev/null
+++ b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/ODataJPAContextMock.java
@@ -0,0 +1,57 @@
+/*******************************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ ******************************************************************************/
+package org.apache.olingo.odata2.processor.core.jpa.mock;
+
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.metamodel.Metamodel;
+
+import org.apache.olingo.odata2.processor.api.jpa.ODataJPAContext;
+import org.easymock.EasyMock;
+
+public abstract class ODataJPAContextMock {
+
+ public static final String NAMESPACE = "salesorderprocessing";
+ public static final String MAPPING_MODEL = "SalesOrderProcessingMappingModel";
+ public static final String PERSISTENCE_UNIT_NAME = "salesorderprocessing";
+
+ public static ODataJPAContext mockODataJPAContext() {
+ ODataJPAContext odataJPAContext = EasyMock.createMock(ODataJPAContext.class);
+ EasyMock.expect(odataJPAContext.getPersistenceUnitName()).andStubReturn(NAMESPACE);
+ EasyMock.expect(odataJPAContext.getEntityManagerFactory()).andReturn(mockEntityManagerFactory());
+ EasyMock.expect(odataJPAContext.getJPAEdmMappingModel()).andReturn(MAPPING_MODEL);
+ EasyMock.expect(odataJPAContext.getJPAEdmExtension()).andReturn(null);
+ EasyMock.expect(odataJPAContext.getDefaultNaming()).andReturn(true);
+ EasyMock.replay(odataJPAContext);
+ return odataJPAContext;
+ }
+
+ private static EntityManagerFactory mockEntityManagerFactory() {
+ EntityManagerFactory emf = EasyMock.createMock(EntityManagerFactory.class);
+ EasyMock.expect(emf.getMetamodel()).andReturn(mockMetaModel());
+ EasyMock.replay(emf);
+ return emf;
+ }
+
+ private static Metamodel mockMetaModel() {
+ Metamodel metaModel = EasyMock.createMock(Metamodel.class);
+ EasyMock.replay(metaModel);
+ return metaModel;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/data/EdmMockUtil.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/data/EdmMockUtil.java b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/data/EdmMockUtil.java
new file mode 100644
index 0000000..57866e3
--- /dev/null
+++ b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/data/EdmMockUtil.java
@@ -0,0 +1,337 @@
+/*******************************************************************************
+ * 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.data;
+
+import static org.junit.Assert.fail;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.olingo.odata2.api.edm.EdmEntitySet;
+import org.apache.olingo.odata2.api.edm.EdmEntityType;
+import org.apache.olingo.odata2.api.edm.EdmException;
+import org.apache.olingo.odata2.api.edm.EdmMapping;
+import org.apache.olingo.odata2.api.edm.EdmMultiplicity;
+import org.apache.olingo.odata2.api.edm.EdmNavigationProperty;
+import org.apache.olingo.odata2.api.edm.EdmProperty;
+import org.apache.olingo.odata2.api.edm.EdmType;
+import org.apache.olingo.odata2.api.edm.EdmTypeKind;
+import org.apache.olingo.odata2.api.edm.EdmTyped;
+import org.apache.olingo.odata2.api.ep.callback.WriteEntryCallbackContext;
+import org.apache.olingo.odata2.api.ep.callback.WriteFeedCallbackContext;
+import org.apache.olingo.odata2.api.uri.ExpandSelectTreeNode;
+import org.apache.olingo.odata2.api.uri.NavigationPropertySegment;
+import org.apache.olingo.odata2.processor.core.jpa.common.ODataJPATestConstants;
+import org.easymock.EasyMock;
+
+public class EdmMockUtil {
+
+ public static ExpandSelectTreeNode mockExpandSelectTreeNode() {
+ ExpandSelectTreeNode nextExpandNode = EasyMock.createMock(ExpandSelectTreeNode.class);
+ Map<String, ExpandSelectTreeNode> nextLink = null;
+ EasyMock.expect(nextExpandNode.getLinks()).andStubReturn(nextLink);
+ EasyMock.replay(nextExpandNode);
+ ExpandSelectTreeNode expandNode = EasyMock.createMock(ExpandSelectTreeNode.class);
+ Map<String, ExpandSelectTreeNode> links = new HashMap<String, ExpandSelectTreeNode>();
+ links.put("SalesOrderLineItemDetails", nextExpandNode);
+ EasyMock.expect(expandNode.getLinks()).andStubReturn(links);
+ EasyMock.replay(expandNode);
+ return expandNode;
+ }
+
+ public static ExpandSelectTreeNode mockCurrentExpandSelectTreeNode() {
+ ExpandSelectTreeNode expandNode = EasyMock.createMock(ExpandSelectTreeNode.class);
+ Map<String, ExpandSelectTreeNode> links = new HashMap<String, ExpandSelectTreeNode>();
+ EasyMock.expect(expandNode.getLinks()).andStubReturn(links);
+ EasyMock.replay(expandNode);
+ return expandNode;
+ }
+
+ public static List<ArrayList<NavigationPropertySegment>> getExpandList() {
+ List<ArrayList<NavigationPropertySegment>> expandList = new ArrayList<ArrayList<NavigationPropertySegment>>();
+ ArrayList<NavigationPropertySegment> expands = new ArrayList<NavigationPropertySegment>();
+ expands.add(mockNavigationPropertySegment());
+ expandList.add(expands);
+ return expandList;
+ }
+
+ public static WriteFeedCallbackContext getWriteFeedCallBackContext() {
+ URI selfLink = null;
+ WriteFeedCallbackContext writeContext = new WriteFeedCallbackContext();
+ try {
+ selfLink = new URI("SalesOrders(2L)/SalesOrderLineItemDetails");
+ writeContext.setSelfLink(selfLink);
+ writeContext.setCurrentExpandSelectTreeNode(mockCurrentExpandSelectTreeNode());
+ writeContext.setNavigationProperty(mockNavigationProperty());
+ writeContext.setSourceEntitySet(mockSourceEntitySet());
+ writeContext.setEntryData(getFeedData());
+
+ } catch (URISyntaxException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+
+ return writeContext;
+ }
+
+ public static WriteEntryCallbackContext getWriteEntryCallBackContext() {
+ WriteEntryCallbackContext writeContext = new WriteEntryCallbackContext();
+ writeContext.setCurrentExpandSelectTreeNode(mockCurrentExpandSelectTreeNode());
+ writeContext.setNavigationProperty(mockNavigationProperty());
+ writeContext.setSourceEntitySet(mockSourceEntitySet());
+ writeContext.setEntryData(getEntryData());
+ return writeContext;
+ }
+
+ private static EdmEntitySet mockSourceEntitySet() {
+ EdmEntitySet entitySet = EasyMock.createMock(EdmEntitySet.class);
+ try {
+ EasyMock.expect(entitySet.getEntityType()).andStubReturn(mockSourceEdmEntityType());
+ } catch (EdmException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+ EasyMock.replay(entitySet);
+ return entitySet;
+ }
+
+ public static EdmEntityType mockSourceEdmEntityType() {
+ EdmEntityType entityType = EasyMock.createMock(EdmEntityType.class);
+ EdmMapping mapping = EasyMock.createMock(EdmMapping.class);
+ List<String> navigationPropertyNames = new ArrayList<String>();
+ List<String> propertyNames = new ArrayList<String>();
+ propertyNames.add("id");
+ propertyNames.add("description");
+ navigationPropertyNames.add("SalesOrderLineItemDetails");
+ try {
+ EasyMock.expect(mapping.getInternalName()).andStubReturn("SalesOrderHeader");
+ EasyMock.replay(mapping);
+ EasyMock.expect(entityType.getName()).andStubReturn("SalesOrderHeader");
+ EasyMock.expect(entityType.getMapping()).andStubReturn(mapping);
+ EasyMock.expect(entityType.getNavigationPropertyNames()).andStubReturn(navigationPropertyNames);
+ EasyMock.expect(entityType.getProperty("SalesOrderLineItemDetails")).andStubReturn(mockNavigationProperty());
+ EdmProperty property1 = mockEdmPropertyOfSource1();
+ EasyMock.expect(entityType.getProperty("id")).andStubReturn(property1);
+ EasyMock.expect(entityType.getProperty("description")).andStubReturn(mockEdmPropertyOfSource2());
+ EasyMock.expect(entityType.getPropertyNames()).andStubReturn(propertyNames);
+
+ } catch (EdmException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+ EasyMock.replay(entityType);
+ return entityType;
+ }
+
+ private static EdmTyped mockEdmPropertyOfSource2() {
+ EdmProperty edmProperty = EasyMock.createMock(EdmProperty.class);
+ EdmType type = EasyMock.createMock(EdmType.class);
+ EasyMock.expect(type.getKind()).andStubReturn(EdmTypeKind.SIMPLE);
+ EasyMock.replay(type);
+ EdmMapping mapping = EasyMock.createMock(EdmMapping.class);
+ EasyMock.expect(mapping.getInternalName()).andStubReturn("description");
+ EasyMock.replay(mapping);
+ try {
+ EasyMock.expect(edmProperty.getName()).andStubReturn("description");
+ EasyMock.expect(edmProperty.getType()).andStubReturn(type);
+ EasyMock.expect(edmProperty.getMapping()).andStubReturn(mapping);
+ } catch (EdmException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+ EasyMock.replay(edmProperty);
+ return edmProperty;
+ }
+
+ private static EdmProperty mockEdmPropertyOfSource1() {
+ EdmProperty edmProperty = EasyMock.createMock(EdmProperty.class);
+ EdmType type = EasyMock.createMock(EdmType.class);
+ EasyMock.expect(type.getKind()).andStubReturn(EdmTypeKind.SIMPLE);
+ EasyMock.replay(type);
+ EdmMapping mapping = EasyMock.createMock(EdmMapping.class);
+ EasyMock.expect(mapping.getInternalName()).andStubReturn("id");
+ EasyMock.replay(mapping);
+ try {
+ EasyMock.expect(edmProperty.getName()).andStubReturn("id");
+ EasyMock.expect(edmProperty.getType()).andStubReturn(type);
+ EasyMock.expect(edmProperty.getMapping()).andStubReturn(mapping);
+ } catch (EdmException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+ EasyMock.replay(edmProperty);
+ return edmProperty;
+ }
+
+ private static Map<String, Object> getFeedData() {
+ Map<String, Object> entryData = new HashMap<String, Object>();
+ entryData.put("id", 1);
+ entryData.put("description", "laptop");
+ List<SalesOrderLineItem> salesOrderLineItems = new ArrayList<SalesOrderLineItem>();
+ salesOrderLineItems.add(new SalesOrderLineItem(23));
+ salesOrderLineItems.add(new SalesOrderLineItem(45));
+ entryData.put("SalesOrderLineItemDetails", salesOrderLineItems);
+ return entryData;
+ }
+
+ private static Map<String, Object> getEntryData() {
+ Map<String, Object> entryData = new HashMap<String, Object>();
+ entryData.put("id", 1);
+ entryData.put("description", "laptop");
+ entryData.put("SalesOrderLineItemDetails", new SalesOrderLineItem(23));
+ return entryData;
+ }
+
+ private static NavigationPropertySegment mockNavigationPropertySegment() {
+ NavigationPropertySegment navigationPropSegment = EasyMock.createMock(NavigationPropertySegment.class);
+ EasyMock.expect(navigationPropSegment.getNavigationProperty()).andStubReturn(mockNavigationProperty());
+ EasyMock.expect(navigationPropSegment.getTargetEntitySet()).andStubReturn(mockTargetEntitySet());
+ EasyMock.replay(navigationPropSegment);
+ return navigationPropSegment;
+ }
+
+ public static NavigationPropertySegment mockThirdNavigationPropertySegment() {
+ NavigationPropertySegment navigationPropSegment = EasyMock.createMock(NavigationPropertySegment.class);
+ EasyMock.expect(navigationPropSegment.getNavigationProperty()).andStubReturn(mockSecondNavigationProperty());
+ EasyMock.expect(navigationPropSegment.getTargetEntitySet()).andStubReturn(mockThirdEntitySet());
+ EasyMock.replay(navigationPropSegment);
+ return navigationPropSegment;
+ }
+
+ public static EdmNavigationProperty mockSecondNavigationProperty() {
+ EdmNavigationProperty navigationProperty = EasyMock.createMock(EdmNavigationProperty.class);
+ EdmMapping mapping = EasyMock.createMock(EdmMapping.class);
+ EasyMock.expect(mapping.getInternalName()).andStubReturn("materials");
+ EasyMock.replay(mapping);
+ try {
+ EasyMock.expect(navigationProperty.getMultiplicity()).andStubReturn(EdmMultiplicity.ONE);
+ EasyMock.expect(navigationProperty.getMapping()).andStubReturn(mapping);
+ EasyMock.expect(navigationProperty.getName()).andStubReturn("MaterialDetails");
+ EasyMock.expect(navigationProperty.getFromRole()).andStubReturn("SalesOrderLineItem");
+ } catch (EdmException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+ EasyMock.replay(navigationProperty);
+ return navigationProperty;
+ }
+
+ public static EdmEntitySet mockTargetEntitySet() {
+ EdmEntitySet entitySet = EasyMock.createMock(EdmEntitySet.class);
+ try {
+ EasyMock.expect(entitySet.getEntityType()).andStubReturn(mockTargetEdmEntityType());
+ } catch (EdmException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+ EasyMock.replay(entitySet);
+ return entitySet;
+ }
+
+ public static EdmEntitySet mockThirdEntitySet() {
+ EdmEntitySet entitySet = EasyMock.createMock(EdmEntitySet.class);
+ try {
+ EasyMock.expect(entitySet.getEntityType()).andStubReturn(mockThirdEdmEntityType());
+ } catch (EdmException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+ EasyMock.replay(entitySet);
+ return entitySet;
+
+ }
+
+ private static EdmEntityType mockThirdEdmEntityType() {
+ EdmEntityType entityType = EasyMock.createMock(EdmEntityType.class);
+ EdmMapping mapping = EasyMock.createMock(EdmMapping.class);
+
+ List<String> propertyNames = new ArrayList<String>();
+ propertyNames.add("price");
+ try {
+ EasyMock.expect(mapping.getInternalName()).andStubReturn("Material");
+ EasyMock.replay(mapping);
+ EasyMock.expect(entityType.getName()).andStubReturn("Material");
+ EasyMock.expect(entityType.getMapping()).andStubReturn(mapping);
+ EdmProperty property = mockEdmPropertyOfTarget();
+ EasyMock.expect(entityType.getProperty("price")).andStubReturn(property);
+ EasyMock.expect(entityType.getPropertyNames()).andStubReturn(propertyNames);
+
+ } catch (EdmException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+ EasyMock.replay(entityType);
+ return entityType;
+ }
+
+ public static EdmEntityType mockTargetEdmEntityType() {
+ EdmEntityType entityType = EasyMock.createMock(EdmEntityType.class);
+ EdmMapping mapping = EasyMock.createMock(EdmMapping.class);
+
+ List<String> propertyNames = new ArrayList<String>();
+ propertyNames.add("price");
+ try {
+ EasyMock.expect(mapping.getInternalName()).andStubReturn("SalesOrderLineItem");
+ EasyMock.replay(mapping);
+ EasyMock.expect(entityType.getName()).andStubReturn("SalesOrderLineItem");
+ EasyMock.expect(entityType.getMapping()).andStubReturn(mapping);
+ EdmProperty property = mockEdmPropertyOfTarget();
+ EasyMock.expect(entityType.getProperty("price")).andStubReturn(property);
+ EasyMock.expect(entityType.getPropertyNames()).andStubReturn(propertyNames);
+
+ } catch (EdmException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+ EasyMock.replay(entityType);
+ return entityType;
+ }
+
+ private static EdmProperty mockEdmPropertyOfTarget() {
+ EdmProperty edmProperty = EasyMock.createMock(EdmProperty.class);
+
+ EdmType type = EasyMock.createMock(EdmType.class);
+ EasyMock.expect(type.getKind()).andStubReturn(EdmTypeKind.SIMPLE);
+ EasyMock.replay(type);
+ EdmMapping mapping = EasyMock.createMock(EdmMapping.class);
+ EasyMock.expect(mapping.getInternalName()).andStubReturn("price");
+ EasyMock.replay(mapping);
+ try {
+ EasyMock.expect(edmProperty.getName()).andStubReturn("price");
+ EasyMock.expect(edmProperty.getType()).andStubReturn(type);
+ EasyMock.expect(edmProperty.getMapping()).andStubReturn(mapping);
+ } catch (EdmException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+ EasyMock.replay(edmProperty);
+ return edmProperty;
+ }
+
+ public static EdmNavigationProperty mockNavigationProperty() {
+ EdmNavigationProperty navigationProperty = EasyMock.createMock(EdmNavigationProperty.class);
+ EdmMapping mapping = EasyMock.createMock(EdmMapping.class);
+ EasyMock.expect(mapping.getInternalName()).andStubReturn("salesOrderLineItems");
+ EasyMock.replay(mapping);
+ try {
+ EasyMock.expect(navigationProperty.getMultiplicity()).andStubReturn(EdmMultiplicity.MANY);
+ EasyMock.expect(navigationProperty.getMapping()).andStubReturn(mapping);
+ EasyMock.expect(navigationProperty.getName()).andStubReturn("SalesOrderLineItemDetails");
+ EasyMock.expect(navigationProperty.getFromRole()).andStubReturn("SalesOrderHeader");
+ } catch (EdmException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+ EasyMock.replay(navigationProperty);
+ return navigationProperty;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/data/EdmMockUtilV2.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/data/EdmMockUtilV2.java b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/data/EdmMockUtilV2.java
new file mode 100644
index 0000000..6611fb1
--- /dev/null
+++ b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/data/EdmMockUtilV2.java
@@ -0,0 +1,324 @@
+/*******************************************************************************
+ * 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.data;
+
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.List;
+import java.util.UUID;
+
+import org.apache.olingo.odata2.api.edm.EdmAssociation;
+import org.apache.olingo.odata2.api.edm.EdmAssociationEnd;
+import org.apache.olingo.odata2.api.edm.EdmComplexType;
+import org.apache.olingo.odata2.api.edm.EdmEntitySet;
+import org.apache.olingo.odata2.api.edm.EdmEntityType;
+import org.apache.olingo.odata2.api.edm.EdmException;
+import org.apache.olingo.odata2.api.edm.EdmMapping;
+import org.apache.olingo.odata2.api.edm.EdmMultiplicity;
+import org.apache.olingo.odata2.api.edm.EdmNavigationProperty;
+import org.apache.olingo.odata2.api.edm.EdmProperty;
+import org.apache.olingo.odata2.api.edm.EdmType;
+import org.apache.olingo.odata2.api.edm.EdmTypeKind;
+import org.apache.olingo.odata2.api.edm.provider.Mapping;
+import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmMapping;
+import org.apache.olingo.odata2.processor.core.jpa.mock.data.JPATypeMock.JPARelatedTypeMock;
+import org.apache.olingo.odata2.processor.core.jpa.mock.data.JPATypeMock.JPATypeEmbeddableMock;
+import org.apache.olingo.odata2.processor.core.jpa.mock.data.JPATypeMock.JPATypeEmbeddableMock2;
+import org.apache.olingo.odata2.processor.core.jpa.model.JPAEdmMappingImpl;
+import org.easymock.EasyMock;
+
+public class EdmMockUtilV2 {
+
+ public static interface JPAEdmMappingMock extends JPAEdmMapping, EdmMapping {
+
+ }
+
+ public static EdmEntityType mockEdmEntityType(final String entityName, final boolean withComplexType)
+ throws EdmException {
+
+ EdmEntityType entityType = EasyMock.createMock(EdmEntityType.class);
+ EasyMock.expect(entityType.getName()).andReturn(entityName).anyTimes();
+ EasyMock.expect(entityType.getKeyPropertyNames()).andReturn(mockSimpleKeyPropertyNames(entityName));
+ if (withComplexType == false) {
+ EasyMock.expect(entityType.getPropertyNames()).andReturn(mockPropertyNames(entityName)).anyTimes();
+ } else {
+ EasyMock.expect(entityType.getPropertyNames()).andReturn(mockPropertyNamesWithComplexType(entityName)).anyTimes();
+ }
+
+ EasyMock.expect(entityType.getNavigationPropertyNames()).andReturn(mockNavigationPropertyNames(entityName));
+ EasyMock.expect(entityType.getKind()).andReturn(EdmTypeKind.ENTITY);
+ EasyMock.expect(entityType.getMapping()).andReturn((EdmMapping) mockEdmMapping(entityName, null, null));
+ if (entityName.equals(JPATypeMock.ENTITY_NAME)) {
+ EasyMock.expect(entityType.getProperty(JPATypeMock.PROPERTY_NAME_MINT)).andReturn(
+ mockEdmProperty(entityName, JPATypeMock.PROPERTY_NAME_MINT)).anyTimes();
+ EasyMock.expect(entityType.getProperty(JPATypeMock.PROPERTY_NAME_MSTRING)).andReturn(
+ mockEdmProperty(entityName, JPATypeMock.PROPERTY_NAME_MSTRING)).anyTimes();
+ EasyMock.expect(entityType.getProperty(JPATypeMock.PROPERTY_NAME_MDATETIME)).andReturn(
+ mockEdmProperty(entityName, JPATypeMock.PROPERTY_NAME_MDATETIME)).anyTimes();
+ EasyMock.expect(entityType.getProperty(JPATypeMock.PROPERTY_NAME_MCOMPLEXTYPE)).andReturn(
+ mockEdmProperty(entityName, JPATypeMock.PROPERTY_NAME_MCOMPLEXTYPE)).anyTimes();
+ EasyMock.expect(entityType.getProperty(JPATypeMock.NAVIGATION_PROPERTY_X)).andReturn(
+ mockEdmNavigationProperty(JPATypeMock.NAVIGATION_PROPERTY_X, EdmMultiplicity.ONE)).anyTimes();
+ } else if (entityName.equals(JPARelatedTypeMock.ENTITY_NAME)) {
+ EasyMock.expect(entityType.getProperty(JPARelatedTypeMock.PROPERTY_NAME_MLONG)).andReturn(
+ mockEdmProperty(entityName, JPARelatedTypeMock.PROPERTY_NAME_MLONG)).anyTimes();
+ EasyMock.expect(entityType.getProperty(JPARelatedTypeMock.PROPERTY_NAME_MBYTE)).andReturn(
+ mockEdmProperty(entityName, JPARelatedTypeMock.PROPERTY_NAME_MBYTE)).anyTimes();
+ EasyMock.expect(entityType.getProperty(JPARelatedTypeMock.PROPERTY_NAME_MBYTEARRAY)).andReturn(
+ mockEdmProperty(entityName, JPARelatedTypeMock.PROPERTY_NAME_MBYTEARRAY)).anyTimes();
+ EasyMock.expect(entityType.getProperty(JPARelatedTypeMock.PROPERTY_NAME_MDOUBLE)).andReturn(
+ mockEdmProperty(entityName, JPARelatedTypeMock.PROPERTY_NAME_MDOUBLE)).anyTimes();
+ }
+ EasyMock.replay(entityType);
+ return entityType;
+ }
+
+ public static List<String> mockNavigationPropertyNames(final String entityName) {
+ List<String> propertyNames = new ArrayList<String>();
+ propertyNames.add(JPATypeMock.NAVIGATION_PROPERTY_X);
+ propertyNames.add(JPATypeMock.NAVIGATION_PROPERTY_XS);
+ return propertyNames;
+ }
+
+ public static List<String> mockSimpleKeyPropertyNames(final String entityName) {
+ List<String> keyPropertyNames = new ArrayList<String>();
+ if (entityName.equals(JPATypeMock.ENTITY_NAME)) {
+ keyPropertyNames.add(JPATypeMock.PROPERTY_NAME_MINT);
+ } else if (entityName.equals(JPARelatedTypeMock.ENTITY_NAME)) {
+ keyPropertyNames.add(JPARelatedTypeMock.PROPERTY_NAME_MLONG);
+ }
+
+ return keyPropertyNames;
+ }
+
+ public static List<String> mockPropertyNames(final String entityName) {
+ List<String> propertyNames = new ArrayList<String>();
+
+ if (entityName.equals(JPATypeMock.ENTITY_NAME)) {
+ propertyNames.add(JPATypeMock.PROPERTY_NAME_MINT);
+ propertyNames.add(JPATypeMock.PROPERTY_NAME_MDATETIME);
+ propertyNames.add(JPATypeMock.PROPERTY_NAME_MSTRING);
+ } else if (entityName.equals(JPARelatedTypeMock.ENTITY_NAME)) {
+ propertyNames.add(JPARelatedTypeMock.PROPERTY_NAME_MLONG);
+ propertyNames.add(JPARelatedTypeMock.PROPERTY_NAME_MBYTE);
+ propertyNames.add(JPARelatedTypeMock.PROPERTY_NAME_MBYTEARRAY);
+ propertyNames.add(JPARelatedTypeMock.PROPERTY_NAME_MDOUBLE);
+ } else if (entityName.equals(JPATypeEmbeddableMock.ENTITY_NAME)) {
+ propertyNames.add(JPATypeMock.JPATypeEmbeddableMock.PROPERTY_NAME_MSHORT);
+ propertyNames.add(JPATypeMock.JPATypeEmbeddableMock.PROPERTY_NAME_MEMBEDDABLE);
+ } else if (entityName.equals(JPATypeEmbeddableMock2.ENTITY_NAME)) {
+ propertyNames.add(JPATypeMock.JPATypeEmbeddableMock2.PROPERTY_NAME_MFLOAT);
+ propertyNames.add(JPATypeMock.JPATypeEmbeddableMock2.PROPERTY_NAME_MUUID);
+ }
+
+ return propertyNames;
+ }
+
+ public static List<String> mockPropertyNamesWithComplexType(final String entityName) {
+ List<String> propertyNames = mockPropertyNames(entityName);
+ propertyNames.add(JPATypeMock.PROPERTY_NAME_MCOMPLEXTYPE);
+
+ return propertyNames;
+
+ }
+
+ public static EdmAssociationEnd mockEdmAssociatioEnd(final String navigationPropertyName, final String role)
+ throws EdmException {
+ EdmAssociationEnd associationEnd = EasyMock.createMock(EdmAssociationEnd.class);
+ EasyMock.expect(associationEnd.getMultiplicity()).andReturn(EdmMultiplicity.ONE);
+ EdmEntityType entityType = EasyMock.createMock(EdmEntityType.class);
+ EasyMock.expect(entityType.getMapping()).andReturn((EdmMapping) mockEdmMapping("JPARelatedTypeMock", null, null));
+ EasyMock.replay(entityType);
+
+ EasyMock.expect(associationEnd.getEntityType()).andReturn(entityType);
+ EasyMock.replay(associationEnd);
+ return associationEnd;
+ }
+
+ public static EdmAssociation mockEdmAssociation(final String navigationPropertyName) throws EdmException {
+ EdmAssociation edmAssociation = EasyMock.createMock(EdmAssociation.class);
+ EasyMock.expect(edmAssociation.getEnd("TO")).andReturn(mockEdmAssociatioEnd(navigationPropertyName, "TO"));
+ EasyMock.expect(edmAssociation.getEnd("FROM")).andReturn(mockEdmAssociatioEnd(navigationPropertyName, "FROM"));
+ EasyMock.replay(edmAssociation);
+ return edmAssociation;
+ }
+
+ public static EdmEntitySet mockEdmEntitySet(final String entityName, final boolean withComplexType)
+ throws EdmException {
+ EdmEntitySet entitySet = null;
+ if (entityName.equals(JPATypeMock.ENTITY_NAME)) {
+ entitySet = EasyMock.createMock(EdmEntitySet.class);
+ EasyMock.expect(entitySet.getEntityType()).andReturn(mockEdmEntityType(entityName, withComplexType)).anyTimes();
+ EasyMock.expect(entitySet.getRelatedEntitySet(EasyMock.isA(EdmNavigationProperty.class))).andReturn(
+ mockEdmEntitySet(JPARelatedTypeMock.ENTITY_NAME, false)).anyTimes();
+ } else if (entityName.equals(JPARelatedTypeMock.ENTITY_NAME)) {
+ entitySet = EasyMock.createMock(EdmEntitySet.class);
+ EasyMock.expect(entitySet.getEntityType()).andReturn(mockEdmEntityType(entityName, withComplexType)).anyTimes();
+ }
+
+ EasyMock.replay(entitySet);
+ return entitySet;
+ }
+
+ public static EdmNavigationProperty mockEdmNavigationProperty(final String navigationPropertyName,
+ final EdmMultiplicity multiplicity) throws EdmException {
+
+ EdmEntityType edmEntityType = mockEdmEntityType(JPARelatedTypeMock.ENTITY_NAME, false);
+
+ EdmNavigationProperty navigationProperty = EasyMock.createMock(EdmNavigationProperty.class);
+ EasyMock.expect(navigationProperty.getType()).andReturn(edmEntityType).anyTimes();
+ EasyMock.expect(navigationProperty.getMultiplicity()).andReturn(multiplicity);
+ EasyMock.expect(navigationProperty.getMapping()).andReturn(
+ (EdmMapping) mockEdmMapping(null, null, navigationPropertyName)).anyTimes();
+ EasyMock.expect(navigationProperty.getToRole()).andReturn("TO");
+ EasyMock.expect(navigationProperty.getRelationship()).andReturn(mockEdmAssociation(navigationPropertyName));
+ if (multiplicity.equals(EdmMultiplicity.ONE)) {
+ EasyMock.expect(navigationProperty.getName()).andReturn(JPATypeMock.NAVIGATION_PROPERTY_X).anyTimes();
+ }
+
+ EasyMock.replay(navigationProperty);
+
+ return navigationProperty;
+ }
+
+ public static EdmProperty mockEdmProperty(final String entityName, final String propertyName) throws EdmException {
+ EdmProperty edmProperty = EasyMock.createMock(EdmProperty.class);
+
+ if (propertyName.equals(JPATypeMock.PROPERTY_NAME_MINT) ||
+ propertyName.equals(JPATypeMock.PROPERTY_NAME_MSTRING) ||
+ propertyName.equals(JPATypeMock.PROPERTY_NAME_MDATETIME) ||
+ propertyName.equals(JPATypeMock.JPATypeEmbeddableMock.PROPERTY_NAME_MSHORT) ||
+ propertyName.equals(JPATypeMock.JPATypeEmbeddableMock2.PROPERTY_NAME_MFLOAT) ||
+ propertyName.equals(JPATypeMock.JPATypeEmbeddableMock2.PROPERTY_NAME_MUUID) ||
+ propertyName.equals(JPARelatedTypeMock.PROPERTY_NAME_MLONG) ||
+ propertyName.equals(JPARelatedTypeMock.PROPERTY_NAME_MBYTE) ||
+ propertyName.equals(JPARelatedTypeMock.PROPERTY_NAME_MDOUBLE) ||
+ propertyName.equals(JPARelatedTypeMock.PROPERTY_NAME_MBYTEARRAY)) {
+
+ EdmType edmType = EasyMock.createMock(EdmType.class);
+ EasyMock.expect(edmProperty.getType()).andReturn(edmType).anyTimes();
+ EasyMock.expect(edmType.getKind()).andReturn(EdmTypeKind.SIMPLE).anyTimes();
+ EasyMock.replay(edmType);
+ EasyMock.expect(edmProperty.getName()).andReturn(propertyName).anyTimes();
+ EasyMock.expect(edmProperty.getMapping()).andReturn((EdmMapping) mockEdmMapping(entityName, propertyName, null))
+ .anyTimes();
+
+ } else if (propertyName.equals(JPATypeMock.JPATypeEmbeddableMock.PROPERTY_NAME_MEMBEDDABLE) ||
+ propertyName.equals(JPATypeMock.PROPERTY_NAME_MCOMPLEXTYPE)) {
+ EdmComplexType complexType = mockComplexType(propertyName);
+
+ EasyMock.expect(edmProperty.getType()).andReturn(complexType).anyTimes();
+ EasyMock.expect(edmProperty.getName()).andReturn(propertyName).anyTimes();
+ EasyMock.expect(edmProperty.getMapping()).andReturn((EdmMapping) mockEdmMapping(null, propertyName, null))
+ .anyTimes();
+
+ }
+
+ EasyMock.replay(edmProperty);
+ return edmProperty;
+ }
+
+ public static EdmComplexType mockComplexType(final String complexPropertyName) throws EdmException {
+
+ String complexTypeName = null;
+ if (complexPropertyName.equals(JPATypeEmbeddableMock.PROPERTY_NAME_MEMBEDDABLE)) {
+ complexTypeName = JPATypeEmbeddableMock2.ENTITY_NAME;
+ } else if (complexPropertyName.equals(JPATypeMock.PROPERTY_NAME_MCOMPLEXTYPE)) {
+ complexTypeName = JPATypeEmbeddableMock.ENTITY_NAME;
+ }
+
+ EdmComplexType edmComplexType = EasyMock.createMock(EdmComplexType.class);
+ EasyMock.expect(edmComplexType.getKind()).andReturn(EdmTypeKind.COMPLEX);
+ EasyMock.expect(edmComplexType.getPropertyNames()).andReturn(mockPropertyNames(complexTypeName)).anyTimes();
+ EasyMock.expect(edmComplexType.getMapping()).andReturn((EdmMapping) mockEdmMapping(complexTypeName, null, null));
+
+ if (complexTypeName.equals(JPATypeEmbeddableMock.ENTITY_NAME)) {
+ EasyMock.expect(edmComplexType.getProperty(JPATypeEmbeddableMock.PROPERTY_NAME_MSHORT)).andReturn(
+ mockEdmProperty(complexTypeName, JPATypeEmbeddableMock.PROPERTY_NAME_MSHORT)).anyTimes();
+ EasyMock.expect(edmComplexType.getProperty(JPATypeEmbeddableMock.PROPERTY_NAME_MEMBEDDABLE)).andReturn(
+ mockEdmProperty(complexTypeName, JPATypeEmbeddableMock.PROPERTY_NAME_MEMBEDDABLE)).anyTimes();
+ } else if (complexTypeName.equals(JPATypeEmbeddableMock2.ENTITY_NAME)) {
+ EasyMock.expect(edmComplexType.getProperty(JPATypeEmbeddableMock2.PROPERTY_NAME_MFLOAT)).andReturn(
+ mockEdmProperty(complexTypeName, JPATypeEmbeddableMock2.PROPERTY_NAME_MFLOAT)).anyTimes();
+ EasyMock.expect(edmComplexType.getProperty(JPATypeEmbeddableMock2.PROPERTY_NAME_MUUID)).andReturn(
+ mockEdmProperty(complexTypeName, JPATypeEmbeddableMock2.PROPERTY_NAME_MUUID)).anyTimes();
+ }
+
+ EasyMock.replay(edmComplexType);
+ return edmComplexType;
+ }
+
+ public static JPAEdmMapping mockEdmMapping(final String entityName, final String propertyName,
+ final String navigationPropertyName) {
+ JPAEdmMapping mapping = new JPAEdmMappingImpl();
+
+ if (propertyName == null && entityName != null) {
+ if (entityName.equals(JPATypeMock.ENTITY_NAME)) {
+ mapping.setJPAType(JPATypeMock.class);
+ } else if (entityName.equals(JPARelatedTypeMock.ENTITY_NAME)) {
+ mapping.setJPAType(JPARelatedTypeMock.class);
+ } else if (entityName.equals(JPATypeEmbeddableMock.ENTITY_NAME)) {
+ mapping.setJPAType(JPATypeEmbeddableMock.class);
+ } else if (entityName.equals(JPATypeEmbeddableMock2.ENTITY_NAME)) {
+ mapping.setJPAType(JPATypeEmbeddableMock2.class);
+ }
+ } else if (entityName == null && navigationPropertyName != null) {
+ mapping.setJPAType(JPARelatedTypeMock.class);
+ mapping.setJPAColumnName(JPATypeMock.NAVIGATION_PROPERTY_X);
+ } else if (propertyName.equals(JPATypeMock.PROPERTY_NAME_MINT)) {
+ mapping.setJPAType(int.class);
+ ((Mapping) mapping).setInternalName(JPATypeMock.PROPERTY_NAME_MINT);
+ } else if (propertyName.equals(JPATypeMock.PROPERTY_NAME_MSTRING)) {
+ mapping.setJPAType(String.class);
+ ((Mapping) mapping).setInternalName(JPATypeMock.PROPERTY_NAME_MSTRING);
+ } else if (propertyName.equals(JPATypeMock.PROPERTY_NAME_MDATETIME)) {
+ mapping.setJPAType(Calendar.class);
+ ((Mapping) mapping).setInternalName(JPATypeMock.PROPERTY_NAME_MDATETIME);
+ } else if (propertyName.equals(JPARelatedTypeMock.PROPERTY_NAME_MLONG)) {
+ mapping.setJPAType(long.class);
+ ((Mapping) mapping).setInternalName(JPARelatedTypeMock.PROPERTY_NAME_MLONG);
+ } else if (propertyName.equals(JPARelatedTypeMock.PROPERTY_NAME_MDOUBLE)) {
+ mapping.setJPAType(double.class);
+ ((Mapping) mapping).setInternalName(JPARelatedTypeMock.PROPERTY_NAME_MDOUBLE);
+ } else if (propertyName.equals(JPARelatedTypeMock.PROPERTY_NAME_MBYTE)) {
+ mapping.setJPAType(byte.class);
+ ((Mapping) mapping).setInternalName(JPARelatedTypeMock.PROPERTY_NAME_MBYTE);
+ } else if (propertyName.equals(JPARelatedTypeMock.PROPERTY_NAME_MBYTEARRAY)) {
+ mapping.setJPAType(byte[].class);
+ ((Mapping) mapping).setInternalName(JPARelatedTypeMock.PROPERTY_NAME_MBYTEARRAY);
+ } else if (propertyName.equals(JPATypeMock.JPATypeEmbeddableMock.PROPERTY_NAME_MSHORT)) {
+ mapping.setJPAType(Short.TYPE);
+ ((Mapping) mapping).setInternalName(JPATypeMock.JPATypeEmbeddableMock.PROPERTY_NAME_MSHORT);
+ } else if (propertyName.equals(JPATypeMock.JPATypeEmbeddableMock2.PROPERTY_NAME_MFLOAT)) {
+ mapping.setJPAType(Float.TYPE);
+ ((Mapping) mapping).setInternalName(JPATypeMock.JPATypeEmbeddableMock2.PROPERTY_NAME_MFLOAT);
+ } else if (propertyName.equals(JPATypeMock.JPATypeEmbeddableMock2.PROPERTY_NAME_MUUID)) {
+ mapping.setJPAType(UUID.class);
+ ((Mapping) mapping).setInternalName(JPATypeMock.JPATypeEmbeddableMock2.PROPERTY_NAME_MUUID);
+ } else if (propertyName.equals(JPATypeMock.JPATypeEmbeddableMock.PROPERTY_NAME_MEMBEDDABLE)) {
+ mapping.setJPAType(JPATypeEmbeddableMock2.class);
+ ((Mapping) mapping).setInternalName(JPATypeMock.JPATypeEmbeddableMock.PROPERTY_NAME_MEMBEDDABLE);
+ } else if (propertyName.equals(JPATypeMock.PROPERTY_NAME_MCOMPLEXTYPE)) {
+ mapping.setJPAType(JPATypeEmbeddableMock.class);
+ ((Mapping) mapping).setInternalName(JPATypeMock.PROPERTY_NAME_MCOMPLEXTYPE);
+ }
+ return mapping;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/data/JPATypeMock.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/data/JPATypeMock.java b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/data/JPATypeMock.java
new file mode 100644
index 0000000..d7bb703
--- /dev/null
+++ b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/data/JPATypeMock.java
@@ -0,0 +1,205 @@
+/*******************************************************************************
+ * 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.data;
+
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.List;
+import java.util.UUID;
+
+/* ========================================================================= */
+public class JPATypeMock {
+
+ public static final String ENTITY_NAME = "JPATypeMock";
+ public static final String PROPERTY_NAME_MINT = "mInt";
+ public static final String PROPERTY_NAME_MSTRING = "mString";
+ public static final String PROPERTY_NAME_MDATETIME = "mDateTime";
+ public static final String PROPERTY_NAME_MKEY = "key";
+ public static final String PROPERTY_NAME_MCOMPLEXTYPE = "complexType";
+
+ public static final String NAVIGATION_PROPERTY_X = "mRelatedEntity";
+ public static final String NAVIGATION_PROPERTY_XS = "mRelatedEntities";
+
+ private JPATypeEmbeddableMock key;
+ private JPATypeEmbeddableMock complexType;
+ private int mInt;
+ private String mString;
+ private Calendar mDateTime;
+ private JPARelatedTypeMock mRelatedEntity;
+ private List<JPARelatedTypeMock> mRelatedEntities = new ArrayList<JPATypeMock.JPARelatedTypeMock>();
+
+ public String getMString() {
+ return mString;
+ }
+
+ public void setMString(final String mString) {
+ this.mString = mString;
+ }
+
+ public JPATypeEmbeddableMock getKey() {
+ return key;
+ }
+
+ public void setKey(final JPATypeEmbeddableMock key) {
+ this.key = key;
+ }
+
+ public int getMInt() {
+ return mInt;
+ }
+
+ public void setMInt(final int mInt) {
+ this.mInt = mInt;
+ }
+
+ public Calendar getMDateTime() {
+ return mDateTime;
+ }
+
+ public void setMDateTime(final Calendar mDateTime) {
+ this.mDateTime = mDateTime;
+ }
+
+ public JPARelatedTypeMock getMRelatedEntity() {
+ return mRelatedEntity;
+ }
+
+ public void setMRelatedEntity(final JPARelatedTypeMock mRelatedEntity) {
+ this.mRelatedEntity = mRelatedEntity;
+ }
+
+ public List<JPARelatedTypeMock> getMRelatedEntities() {
+ return mRelatedEntities;
+ }
+
+ public void setMRelatedEntities(final List<JPARelatedTypeMock> mRelatedEntities) {
+ this.mRelatedEntities = mRelatedEntities;
+ }
+
+ public JPATypeEmbeddableMock getComplexType() {
+ return complexType;
+ }
+
+ public void setComplexType(final JPATypeEmbeddableMock complexType) {
+ this.complexType = complexType;
+ }
+
+ /* ========================================================================= */
+ public static class JPATypeEmbeddableMock {
+
+ public static final String ENTITY_NAME = "JPATypeEmbeddableMock";
+ public static final String PROPERTY_NAME_MSHORT = "mShort";
+ public static final String PROPERTY_NAME_MEMBEDDABLE = "mEmbeddable";
+
+ private short mShort;
+ private JPATypeEmbeddableMock2 mEmbeddable;
+
+ public short getMShort() {
+ return mShort;
+ }
+
+ public void setMShort(final short mShort) {
+ this.mShort = mShort;
+ }
+
+ public JPATypeEmbeddableMock2 getMEmbeddable() {
+ return mEmbeddable;
+ }
+
+ public void setMEmbeddable(final JPATypeEmbeddableMock2 mEmbeddable) {
+ this.mEmbeddable = mEmbeddable;
+ }
+
+ }
+
+ /* ========================================================================= */
+ public static class JPATypeEmbeddableMock2 {
+
+ public static final String ENTITY_NAME = "JPATypeEmbeddableMock2";
+ public static final String PROPERTY_NAME_MUUID = "mUUID";
+ public static final String PROPERTY_NAME_MFLOAT = "mFloat";
+
+ private UUID mUUID;
+ private float mFloat;
+
+ public UUID getMUUID() {
+ return mUUID;
+ }
+
+ public void setMUUID(final UUID mUUID) {
+ this.mUUID = mUUID;
+ }
+
+ public float getMFloat() {
+ return mFloat;
+ }
+
+ public void setMFloat(final float mFloat) {
+ this.mFloat = mFloat;
+ }
+
+ }
+
+ /* ========================================================================= */
+ public static final class JPARelatedTypeMock {
+ public static final String ENTITY_NAME = "JPARelatedTypeMock";
+ public static final String PROPERTY_NAME_MLONG = "mLong";
+ public static final String PROPERTY_NAME_MDOUBLE = "mDouble";
+ public static final String PROPERTY_NAME_MBYTE = "mByte";
+ public static final String PROPERTY_NAME_MBYTEARRAY = "mByteArray";
+
+ private long mLong;
+ private double mDouble;
+ private byte mByte;
+ private byte mByteArray[];
+
+ public long getMLong() {
+ return mLong;
+ }
+
+ public void setMLong(final long key) {
+ mLong = key;
+ }
+
+ public double getMDouble() {
+ return mDouble;
+ }
+
+ public void setMDouble(final double mDouble) {
+ this.mDouble = mDouble;
+ }
+
+ public byte getMByte() {
+ return mByte;
+ }
+
+ public void setMByte(final byte mByte) {
+ this.mByte = mByte;
+ }
+
+ public byte[] getMByteArray() {
+ return mByteArray;
+ }
+
+ public void setMByteArray(final byte mByteArray[]) {
+ this.mByteArray = mByteArray;
+ }
+
+ }
+}
[07/37] [OLINGO-82] Renamed the project folder name to
odata2-jpa-processor
Posted by ch...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLSelectContextImplTest.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLSelectContextImplTest.java b/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLSelectContextImplTest.java
deleted file mode 100644
index 817d8d3..0000000
--- a/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLSelectContextImplTest.java
+++ /dev/null
@@ -1,385 +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.jpql;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.olingo.odata2.api.edm.EdmEntitySet;
-import org.apache.olingo.odata2.api.edm.EdmEntityType;
-import org.apache.olingo.odata2.api.edm.EdmException;
-import org.apache.olingo.odata2.api.edm.EdmMapping;
-import org.apache.olingo.odata2.api.edm.EdmProperty;
-import org.apache.olingo.odata2.api.edm.EdmType;
-import org.apache.olingo.odata2.api.uri.KeyPredicate;
-import org.apache.olingo.odata2.api.uri.SelectItem;
-import org.apache.olingo.odata2.api.uri.expression.ExpressionKind;
-import org.apache.olingo.odata2.api.uri.expression.FilterExpression;
-import org.apache.olingo.odata2.api.uri.expression.OrderByExpression;
-import org.apache.olingo.odata2.api.uri.expression.OrderExpression;
-import org.apache.olingo.odata2.api.uri.expression.PropertyExpression;
-import org.apache.olingo.odata2.api.uri.expression.SortOrder;
-import org.apache.olingo.odata2.api.uri.info.GetEntitySetUriInfo;
-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.jpql.JPQLContext;
-import org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLContextType;
-import org.apache.olingo.odata2.processor.core.jpa.common.ODataJPATestConstants;
-import org.apache.olingo.odata2.processor.core.jpa.jpql.JPQLSelectContext.JPQLSelectContextBuilder;
-import org.easymock.EasyMock;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-public class JPQLSelectContextImplTest {
-
- private static String entityTypeName = "MockEntity";
- private static String[] fields = { "Field1", "Field2" };
- private static List<KeyPredicate> keyPredicates;
- private static SortOrder[] orderType = { SortOrder.asc, SortOrder.desc };
-
- private static JPQLSelectContextBuilder builder;
- private static JPQLSelectContext selectContext;
-
- @BeforeClass
- public static void setup() {
-
- }
-
- private void buildSelectContext(final boolean orderByIsNull, final boolean selectFieldsIsNull,
- final boolean filterIsNull, final boolean isTopNull, final boolean isSkipNull) {
- builder = null;
- selectContext = null;
- keyPredicates = new ArrayList<KeyPredicate>();
- GetEntitySetUriInfo resultsView = EasyMock.createMock(GetEntitySetUriInfo.class);
-
- EdmEntitySet entitySet = EasyMock.createMock(EdmEntitySet.class);
- EdmEntityType entityType = EasyMock.createMock(EdmEntityType.class);
- KeyPredicate keyPredicate = EasyMock.createMock(KeyPredicate.class);
- EdmProperty kpProperty = EasyMock.createMock(EdmProperty.class);
- EdmType edmType1 = EasyMock.createMock(EdmType.class);
- EdmMapping mapping = EasyMock.createMock(EdmMapping.class);
- EasyMock.expect(keyPredicate.getLiteral()).andStubReturn("1");
- try {
- EasyMock.expect(mapping.getInternalName()).andStubReturn("Field1");
- EasyMock.expect(kpProperty.getMapping()).andStubReturn(mapping);
- EasyMock.expect(kpProperty.getType()).andStubReturn(edmType1);
-
- } catch (EdmException e2) {
- fail("this should not happen");
- }
- EasyMock.expect(keyPredicate.getProperty()).andStubReturn(kpProperty);
- EasyMock.replay(mapping, edmType1, kpProperty, keyPredicate);
- keyPredicates.add(keyPredicate);
- int i = 0;
- List<OrderExpression> orderList = new ArrayList<OrderExpression>(2);
- do {
-
- EdmType edmType = EasyMock.createMock(EdmType.class);
- try {
- EasyMock.expect(edmType.getName()).andStubReturn(fields[i]);
- EasyMock.replay(edmType);
- } catch (EdmException e2) {
- fail("Exception not Expected");
- }
-
- PropertyExpression commonExpression = EasyMock.createMock(PropertyExpression.class);
- EasyMock.expect(commonExpression.getEdmType()).andStubReturn(edmType);
-
- EdmProperty edmTyped = EasyMock.createMock(EdmProperty.class);
- EdmMapping edmMapping = EasyMock.createMock(EdmMapping.class);
- EasyMock.expect(edmMapping.getInternalName()).andStubReturn(fields[i]);
- try {
- EasyMock.expect(edmTyped.getMapping()).andStubReturn(edmMapping);
- } catch (EdmException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- EasyMock.expect(commonExpression.getEdmProperty()).andStubReturn(edmTyped);
- OrderExpression order = EasyMock.createMock(OrderExpression.class);
- EasyMock.expect(order.getExpression()).andStubReturn(commonExpression);
- EasyMock.expect(order.getSortOrder()).andStubReturn(orderType[i]);
- EasyMock.replay(edmMapping, edmTyped, commonExpression);
- EasyMock.replay(order);
-
- orderList.add(order);
-
- } while (++i < 2);
-
- OrderByExpression orderBy = EasyMock.createMock(OrderByExpression.class);
- EasyMock.expect(orderBy.getOrders()).andStubReturn(orderList);
- EasyMock.replay(orderBy);
-
- try {
- i = 0;
- List<SelectItem> selectItemList = new ArrayList<SelectItem>(2);
- do {
- EdmMapping edmMapping = EasyMock.createMock(EdmMapping.class);
- EasyMock.expect(edmMapping.getInternalName()).andStubReturn(fields[i]);
- EdmProperty edmProperty = EasyMock.createMock(EdmProperty.class);
- EasyMock.expect(edmProperty.getMapping()).andStubReturn(edmMapping);
- EasyMock.replay(edmMapping, edmProperty);
-
- SelectItem selectItem = EasyMock.createMock(SelectItem.class);
- EasyMock.expect(selectItem.getProperty()).andStubReturn(edmProperty);
- EasyMock.replay(selectItem);
-
- selectItemList.add(selectItem);
-
- } while (++i < 2);
- EasyMock.expect(entityType.getMapping()).andStubReturn(null);
- EasyMock.expect(entityType.getName()).andStubReturn(entityTypeName);
- EasyMock.expect(entityType.getKeyProperties()).andStubReturn(getLocalKeyProperties());
-
- EasyMock.replay(entityType);
- EasyMock.expect(entitySet.getEntityType()).andStubReturn(entityType);
- EasyMock.replay(entitySet);
-
- EasyMock.expect(resultsView.getTargetEntitySet()).andStubReturn(entitySet);
- if (orderByIsNull) {
- EasyMock.expect(resultsView.getOrderBy()).andStubReturn(null);
- } else {
- EasyMock.expect(resultsView.getOrderBy()).andStubReturn(orderBy);
- }
- if (selectFieldsIsNull) {
- EasyMock.expect(resultsView.getSelect()).andStubReturn(null);
- } else {
- EasyMock.expect(resultsView.getSelect()).andStubReturn(selectItemList);
- }
- // FilterExpression filterExpression =
- // EasyMock.createMock(FilterExpression.class);
- // EasyMock.expect(filterExpression.g)
- if (filterIsNull) {
- EasyMock.expect(resultsView.getFilter()).andStubReturn(null);
- } else {
- EasyMock.expect(resultsView.getFilter()).andStubReturn(
- getFilterExpressionMockedObj(ExpressionKind.PROPERTY, "SalesOrder"));
- }
- if (isTopNull) {
- EasyMock.expect(resultsView.getTop()).andStubReturn(null);
- } else {
- EasyMock.expect(resultsView.getTop()).andStubReturn(10);
- }
- if (isSkipNull) {
- EasyMock.expect(resultsView.getSkip()).andStubReturn(null);
- } else {
- EasyMock.expect(resultsView.getSkip()).andStubReturn(0);
- }
- EasyMock.expect(resultsView.getKeyPredicates()).andStubReturn(keyPredicates);
- EasyMock.replay(resultsView);
-
- } catch (EdmException e1) {
- fail("Exception not Expected");
- }
- try {
- builder = (JPQLSelectContextBuilder) JPQLContext.createBuilder(JPQLContextType.SELECT, resultsView);
-
- selectContext = (JPQLSelectContext) builder.build();
- } catch (ODataJPAModelException e) {
- fail("Exception not Expected");
- } catch (ODataJPARuntimeException e) {
- fail("Runtime Exception thrown");
- }
- }
-
- private List<EdmProperty> getLocalKeyProperties() {
- List<EdmProperty> propertyList = new ArrayList<EdmProperty>();
- EdmProperty edmProperty = EasyMock.createMock(EdmProperty.class);
- try {
- EasyMock.expect(edmProperty.getName()).andStubReturn("Field1");
- EasyMock.expect(edmProperty.getMapping()).andStubReturn(null);
- } catch (EdmException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
- EasyMock.replay(edmProperty);
- propertyList.add(edmProperty);
- return propertyList;
- }
-
- @Test
- public void testEntityNameThrowingException() {
- // buildSelectContext(false, false, false);
- GetEntitySetUriInfo resultsView = EasyMock.createMock(GetEntitySetUriInfo.class);
-
- EdmEntitySet entitySet = EasyMock.createMock(EdmEntitySet.class);
- EdmEntityType entityType = EasyMock.createMock(EdmEntityType.class);
-
- try {
- EasyMock.expect(entityType.getName()).andStubThrow(new EdmException(null));
- EasyMock.expect(entitySet.getEntityType()).andStubThrow(new EdmException(null));
- } catch (EdmException e1) {
- // throw new ODataException();
- }
-
- EasyMock.replay(entityType);
- EasyMock.replay(entitySet);
-
- EasyMock.expect(resultsView.getTargetEntitySet()).andStubReturn(entitySet);
- EasyMock.expect(resultsView.getOrderBy()).andStubReturn(null);
- EasyMock.expect(resultsView.getSelect()).andStubReturn(null);
- EasyMock.expect(resultsView.getFilter()).andStubReturn(null);
- EasyMock.replay(resultsView);
- try {
- JPQLSelectContextBuilder builder1 =
- (JPQLSelectContextBuilder) JPQLContext.createBuilder(JPQLContextType.SELECT, resultsView);
-
- builder1.build();
- fail("Should not come here");
- } catch (ODataJPAModelException e) {
- fail();
- } catch (ODataJPARuntimeException e) {
- assertTrue(true);
- }
- }
-
- @Test
- public void testSelectFieldsAsNull() {
- buildSelectContext(false, true, true, true, true);
-
- try {
- selectContext = (JPQLSelectContext) builder.build();
- assertEquals("E2", selectContext.getSelectExpression());
- } catch (ODataJPAModelException e) {
- fail();
- } catch (ODataJPARuntimeException e) {
- fail();
- }
- }
-
- @Test
- public void testGetOrderByCollection() {
- buildSelectContext(false, false, true, true, true);
- assertEquals(true, selectContext.getOrderByCollection().containsKey("E1." + JPQLSelectContextImplTest.fields[0]));
- assertEquals("", selectContext.getOrderByCollection().get("E1." + JPQLSelectContextImplTest.fields[0]));
-
- assertEquals(true, selectContext.getOrderByCollection().containsKey("E1." + JPQLSelectContextImplTest.fields[1]));
- assertEquals("DESC", selectContext.getOrderByCollection().get("E1." + JPQLSelectContextImplTest.fields[1]));
- }
-
- @Test
- public void testGetWhereExpression() {
- buildSelectContext(false, false, true, true, true);
- // fail("Not yet implemented");
- }
-
- @Test
- public void testGetJPAEntityName() {
- buildSelectContext(false, false, true, true, true);
- assertEquals(JPQLSelectContextImplTest.entityTypeName, selectContext.getJPAEntityName());
- }
-
- @Test
- public void testGetType() {
- buildSelectContext(false, false, true, true, true);
- assertEquals(JPQLContextType.SELECT, selectContext.getType());
- }
-
- @Test
- public void testCreateBuilder() {
- buildSelectContext(false, false, true, true, true);
- assertEquals(JPQLSelectContextBuilder.class.toString(), builder.getClass().toString());
- }
-
- @Test
- public void testEntitySetAsNull() {
- buildSelectContext(false, false, true, true, true);
- try {
- JPQLSelectContextBuilder builder =
- (JPQLSelectContextBuilder) JPQLContext.createBuilder(JPQLContextType.SELECT, null);
-
- JPQLSelectContext selectContext1 = (JPQLSelectContext) builder.build();
- assertNull(selectContext1.getJPAEntityAlias());
- assertNull(selectContext1.getJPAEntityName());
- assertNull(selectContext1.getOrderByCollection());
- assertNull(selectContext1.getSelectExpression());
- assertNull(selectContext1.getType());
- assertNull(selectContext1.getWhereExpression());
- } catch (ODataJPAModelException e) {
- fail("Exception not Expected");
- } catch (ODataJPARuntimeException e) {
- fail("Runtime Exception thrown");
- }
- }
-
- @Test
- public void testOrderingWithSkip() {
- buildSelectContext(true, false, true, true, false);
- assertEquals(true, selectContext.getOrderByCollection().containsKey("E1." + JPQLSelectContextImplTest.fields[0]));
- assertEquals("", selectContext.getOrderByCollection().get("E1." + JPQLSelectContextImplTest.fields[0]));
-
- assertEquals(false, selectContext.getOrderByCollection().containsKey("E1." + JPQLSelectContextImplTest.fields[1]));
-
- }
-
- @Test
- public void testOrderingWithTop() {
- buildSelectContext(true, false, true, false, true);
- assertEquals(true, selectContext.getOrderByCollection().containsKey("E1." + JPQLSelectContextImplTest.fields[0]));
- assertEquals("", selectContext.getOrderByCollection().get("E1." + JPQLSelectContextImplTest.fields[0]));
-
- assertEquals(false, selectContext.getOrderByCollection().containsKey("E1." + JPQLSelectContextImplTest.fields[1]));
-
- }
-
- @Test
- public void testOrderByTopSkipAsNull() {
- buildSelectContext(true, true, true, true, true);
- assertNull(selectContext.getOrderByCollection());
- }
-
- @Test
- public void testFilter() {
- buildSelectContext(true, false, false, false, false);
- assertEquals("E1.field", selectContext.whereCondition);
-
- }
-
- private FilterExpression getFilterExpressionMockedObj(final ExpressionKind leftOperandExpKind,
- final String propertyName) throws EdmException {
- FilterExpression filterExpression = EasyMock.createMock(FilterExpression.class);
- EasyMock.expect(filterExpression.getKind()).andStubReturn(ExpressionKind.FILTER);
- EasyMock.expect(filterExpression.getExpression()).andStubReturn(
- getPropertyExpressionMockedObj(leftOperandExpKind, propertyName));
- EasyMock.replay(filterExpression);
- return filterExpression;
- }
-
- private PropertyExpression getPropertyExpressionMockedObj(final ExpressionKind expKind, final String propertyName) {
- PropertyExpression leftOperandPropertyExpresion = EasyMock.createMock(PropertyExpression.class);
- EasyMock.expect(leftOperandPropertyExpresion.getKind()).andReturn(ExpressionKind.PROPERTY);
- EasyMock.expect(leftOperandPropertyExpresion.getPropertyName()).andReturn(propertyName);
- EdmProperty edmtTyped = EasyMock.createMock(EdmProperty.class);
- EdmMapping mapping = EasyMock.createMock(EdmMapping.class);
- EasyMock.expect(mapping.getInternalName()).andStubReturn("field");
- try {
- EasyMock.expect(edmtTyped.getMapping()).andStubReturn(mapping);
- } catch (EdmException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- EasyMock.expect(leftOperandPropertyExpresion.getEdmProperty()).andReturn(edmtTyped);
- EasyMock.replay(mapping, edmtTyped, leftOperandPropertyExpresion);
- return leftOperandPropertyExpresion;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLSelectSingleContextImplTest.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLSelectSingleContextImplTest.java b/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLSelectSingleContextImplTest.java
deleted file mode 100644
index 841ff5a..0000000
--- a/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLSelectSingleContextImplTest.java
+++ /dev/null
@@ -1,198 +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.jpql;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.olingo.odata2.api.edm.EdmEntitySet;
-import org.apache.olingo.odata2.api.edm.EdmEntityType;
-import org.apache.olingo.odata2.api.edm.EdmException;
-import org.apache.olingo.odata2.api.edm.EdmMapping;
-import org.apache.olingo.odata2.api.edm.EdmProperty;
-import org.apache.olingo.odata2.api.edm.EdmType;
-import org.apache.olingo.odata2.api.uri.KeyPredicate;
-import org.apache.olingo.odata2.api.uri.SelectItem;
-import org.apache.olingo.odata2.api.uri.info.GetEntityUriInfo;
-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.jpql.JPQLContext;
-import org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLContextType;
-import org.apache.olingo.odata2.processor.core.jpa.jpql.JPQLSelectSingleContext.JPQLSelectSingleContextBuilder;
-import org.easymock.EasyMock;
-import org.junit.Test;
-
-public class JPQLSelectSingleContextImplTest {
-
- private static String entityTypeName = "MockEntity";
- private static String[] fields = { "Field1", "Field2" };
- private static List<KeyPredicate> keyPredicates;
-
- private static JPQLSelectSingleContextBuilder builder;
- private static JPQLSelectSingleContext selectContext;
-
- private void buildContextBuilder(final boolean isSelectNull) {
- builder = null;
- selectContext = null;
- keyPredicates = new ArrayList<KeyPredicate>();
- GetEntityUriInfo resultsView = EasyMock.createMock(GetEntityUriInfo.class);
-
- EdmEntitySet entitySet = EasyMock.createMock(EdmEntitySet.class);
- EdmEntityType entityType = EasyMock.createMock(EdmEntityType.class);
-
- KeyPredicate keyPredicate = EasyMock.createMock(KeyPredicate.class);
- EdmProperty kpProperty = EasyMock.createMock(EdmProperty.class);
- EdmType edmType = EasyMock.createMock(EdmType.class);
- EasyMock.expect(keyPredicate.getLiteral()).andStubReturn("1");
- try {
- EasyMock.expect(kpProperty.getName()).andStubReturn("Field1");
- EasyMock.expect(kpProperty.getType()).andStubReturn(edmType);
-
- } catch (EdmException e2) {
- fail("this should not happen");
- }
- EasyMock.expect(keyPredicate.getProperty()).andStubReturn(kpProperty);
- EasyMock.replay(edmType, kpProperty, keyPredicate);
- keyPredicates.add(keyPredicate);
- int i = 0;
- try {
-
- List<SelectItem> selectItemList = new ArrayList<SelectItem>(2);
- do {
- EdmMapping edmMapping = EasyMock.createMock(EdmMapping.class);
- EasyMock.expect(edmMapping.getInternalName()).andStubReturn(fields[i]);
- EdmProperty edmProperty = EasyMock.createMock(EdmProperty.class);
- EasyMock.expect(edmProperty.getMapping()).andStubReturn(edmMapping);
- EasyMock.replay(edmMapping, edmProperty);
-
- SelectItem selectItem = EasyMock.createMock(SelectItem.class);
- EasyMock.expect(selectItem.getProperty()).andStubReturn(edmProperty);
- EasyMock.replay(selectItem);
-
- selectItemList.add(selectItem);
-
- } while (++i < 2);
-
- EasyMock.expect(entityType.getMapping()).andStubReturn(null);
- EasyMock.expect(entityType.getName()).andStubReturn(entityTypeName);
- EasyMock.replay(entityType);
- EasyMock.expect(entitySet.getEntityType()).andStubReturn(entityType);
- EasyMock.replay(entitySet);
-
- EasyMock.expect(resultsView.getTargetEntitySet()).andStubReturn(entitySet);
- if (isSelectNull) {
- selectItemList = null;
- }
- EasyMock.expect(resultsView.getSelect()).andStubReturn(selectItemList);
- ArrayList<KeyPredicate> arrayList = new ArrayList<KeyPredicate>();
- arrayList.add(keyPredicate);
- EasyMock.expect(resultsView.getKeyPredicates()).andStubReturn(arrayList);
- EasyMock.replay(resultsView);
-
- } catch (EdmException e1) {
- fail("Exception not Expected");
- }
- try {
- builder = (JPQLSelectSingleContextBuilder) JPQLContext.createBuilder(JPQLContextType.SELECT_SINGLE, resultsView);
-
- selectContext = (JPQLSelectSingleContext) builder.build();
- } catch (ODataJPAModelException e) {
- fail("Exception not Expected");
- } catch (ODataJPARuntimeException e) {
- fail("Runtime Exception thrown");
- }
- }
-
- @Test
- public void testEntityNameThrowingException() {
- // buildSelectContext(false, false, false);
- GetEntityUriInfo resultsView = EasyMock.createMock(GetEntityUriInfo.class);
-
- EdmEntitySet entitySet = EasyMock.createMock(EdmEntitySet.class);
- EdmEntityType entityType = EasyMock.createMock(EdmEntityType.class);
-
- try {
- EasyMock.expect(entityType.getName()).andStubThrow(new EdmException(null));
- EasyMock.expect(entitySet.getEntityType()).andStubThrow(new EdmException(null));
- } catch (EdmException e1) {
- // throw new ODataException();
- }
-
- EasyMock.replay(entityType);
- EasyMock.replay(entitySet);
-
- EasyMock.expect(resultsView.getTargetEntitySet()).andStubReturn(entitySet);
- EasyMock.expect(resultsView.getSelect()).andStubReturn(null);
- EasyMock.expect(resultsView.getFilter()).andStubReturn(null);
- EasyMock.replay(resultsView);
- try {
- JPQLSelectSingleContextBuilder builder1 =
- (JPQLSelectSingleContextBuilder) JPQLContext.createBuilder(JPQLContextType.SELECT_SINGLE, resultsView);
- builder1.build();
- fail("Should not come here");
- } catch (ODataJPAModelException e) {
- fail();
- } catch (ODataJPARuntimeException e) {
- assertTrue(true);
- }
- }
-
- @Test
- public void testSlectedFieldsAsNull() {
- buildContextBuilder(true);
- try {
- selectContext = (JPQLSelectSingleContext) builder.build();
- assertEquals("E2", selectContext.getSelectExpression());
- } catch (ODataJPAModelException e) {
- fail();
- } catch (ODataJPARuntimeException e) {
- fail();
- }
- }
-
- @Test
- public void getKeyPredicates() {
- buildContextBuilder(false);
- assertEquals(keyPredicates.size(), selectContext.getKeyPredicates().size());
- assertEquals(keyPredicates, selectContext.getKeyPredicates());
- }
-
- @Test
- public void testGetJPAEntityName() {
- buildContextBuilder(false);
- assertEquals(JPQLSelectSingleContextImplTest.entityTypeName, selectContext.getJPAEntityName());
- }
-
- @Test
- public void testGetType() {
- buildContextBuilder(false);
- assertEquals(JPQLContextType.SELECT_SINGLE, selectContext.getType());
- }
-
- @Test
- public void testCreateBuilder() {
- buildContextBuilder(false);
- assertEquals(JPQLSelectSingleContextBuilder.class.toString(), builder.getClass().toString());
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLSelectSingleStatementBuilderTest.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLSelectSingleStatementBuilderTest.java b/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLSelectSingleStatementBuilderTest.java
deleted file mode 100644
index c5d5f95..0000000
--- a/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLSelectSingleStatementBuilderTest.java
+++ /dev/null
@@ -1,123 +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.jpql;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.olingo.odata2.api.edm.EdmEntitySet;
-import org.apache.olingo.odata2.api.edm.EdmEntityType;
-import org.apache.olingo.odata2.api.edm.EdmException;
-import org.apache.olingo.odata2.api.edm.EdmMapping;
-import org.apache.olingo.odata2.api.edm.EdmProperty;
-import org.apache.olingo.odata2.api.edm.EdmSimpleType;
-import org.apache.olingo.odata2.api.uri.KeyPredicate;
-import org.apache.olingo.odata2.api.uri.SelectItem;
-import org.apache.olingo.odata2.api.uri.info.GetEntityUriInfo;
-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.jpql.JPQLContext;
-import org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLContext.JPQLContextBuilder;
-import org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLContextType;
-import org.easymock.EasyMock;
-import org.junit.Before;
-import org.junit.Test;
-
-public class JPQLSelectSingleStatementBuilderTest {
-
- /**
- * @throws java.lang.Exception
- */
- private JPQLSelectSingleStatementBuilder JPQLSelectSingleStatementBuilder;
-
- @Before
- public void setUp() throws Exception {
-
- }
-
- private JPQLSelectSingleContext createSelectContext() throws ODataJPARuntimeException, EdmException {
- // Object Instantiation
-
- JPQLSelectSingleContext JPQLSelectSingleContextImpl = null;// new JPQLSelectSingleContextImpl();
- GetEntityUriInfo getEntityView = EasyMock.createMock(GetEntityUriInfo.class);
-
- EdmEntitySet edmEntitySet = EasyMock.createMock(EdmEntitySet.class);
- EdmEntityType edmEntityType = EasyMock.createMock(EdmEntityType.class);
- List<SelectItem> selectItemList = null;
-
- // Setting up the expected value
- KeyPredicate keyPredicate = EasyMock.createMock(KeyPredicate.class);
- EdmProperty kpProperty = EasyMock.createMock(EdmProperty.class);
- EdmSimpleType edmType = EasyMock.createMock(EdmSimpleType.class);
- EdmMapping edmMapping = EasyMock.createMock(EdmMapping.class);
- EasyMock.expect(edmMapping.getInternalName()).andStubReturn("Field1");
- EasyMock.expect(keyPredicate.getLiteral()).andStubReturn("1");
- try {
- EasyMock.expect(kpProperty.getName()).andStubReturn("Field1");
- EasyMock.expect(kpProperty.getType()).andStubReturn(edmType);
-
- EasyMock.expect(kpProperty.getMapping()).andStubReturn(edmMapping);
-
- } catch (EdmException e2) {
- fail("this should not happen");
- }
- EasyMock.expect(keyPredicate.getProperty()).andStubReturn(kpProperty);
- EasyMock.replay(edmMapping, edmType, kpProperty, keyPredicate);
- EasyMock.expect(getEntityView.getTargetEntitySet()).andStubReturn(edmEntitySet);
- EasyMock.expect(getEntityView.getSelect()).andStubReturn(selectItemList);
-
- EasyMock.expect(edmEntitySet.getEntityType()).andStubReturn(edmEntityType);
- EasyMock.replay(edmEntitySet);
- EasyMock.expect(edmEntityType.getMapping()).andStubReturn(null);
- EasyMock.expect(edmEntityType.getName()).andStubReturn("SalesOrderHeader");
- EasyMock.replay(edmEntityType);
- ArrayList<KeyPredicate> arrayList = new ArrayList<KeyPredicate>();
- arrayList.add(keyPredicate);
- EasyMock.expect(getEntityView.getKeyPredicates()).andStubReturn(arrayList);
- EasyMock.replay(getEntityView);
-
- JPQLContextBuilder contextBuilder1 = JPQLContext.createBuilder(JPQLContextType.SELECT_SINGLE, getEntityView);
- try {
- JPQLSelectSingleContextImpl = (JPQLSelectSingleContext) contextBuilder1.build();
- } catch (ODataJPAModelException e) {
- fail("Model Exception thrown");
- }
-
- return JPQLSelectSingleContextImpl;
- }
-
- /**
- * Test method for {@link org.apache.olingo.odata2.processor.jpa.jpql.JPQLSelectSingleStatementBuilder#build)}.
- * @throws EdmException
- * @throws ODataJPARuntimeException
- */
-
- @Test
- public void testBuildSimpleQuery() throws EdmException, ODataJPARuntimeException {
- JPQLSelectSingleContext JPQLSelectSingleContextImpl = createSelectContext();
- JPQLSelectSingleStatementBuilder = new JPQLSelectSingleStatementBuilder(JPQLSelectSingleContextImpl);
-
- assertEquals("SELECT E1 FROM SalesOrderHeader E1 WHERE E1.Field1 = 1", JPQLSelectSingleStatementBuilder.build()
- .toString());
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLSelectStatementBuilderTest.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLSelectStatementBuilderTest.java b/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLSelectStatementBuilderTest.java
deleted file mode 100644
index 2434809..0000000
--- a/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLSelectStatementBuilderTest.java
+++ /dev/null
@@ -1,135 +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.jpql;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
-
-import java.util.HashMap;
-import java.util.List;
-
-import org.apache.olingo.odata2.api.edm.EdmEntitySet;
-import org.apache.olingo.odata2.api.edm.EdmEntityType;
-import org.apache.olingo.odata2.api.edm.EdmException;
-import org.apache.olingo.odata2.api.uri.SelectItem;
-import org.apache.olingo.odata2.api.uri.expression.FilterExpression;
-import org.apache.olingo.odata2.api.uri.expression.OrderByExpression;
-import org.apache.olingo.odata2.api.uri.info.GetEntitySetUriInfo;
-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.jpql.JPQLContext;
-import org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLContext.JPQLContextBuilder;
-import org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLContextType;
-import org.easymock.EasyMock;
-import org.junit.Before;
-import org.junit.Test;
-
-public class JPQLSelectStatementBuilderTest {
-
- /**
- * @throws java.lang.Exception
- */
- private JPQLSelectStatementBuilder jpqlSelectStatementBuilder;
-
- @Before
- public void setUp() throws Exception {
-
- }
-
- private JPQLSelectContext createSelectContext(final OrderByExpression orderByExpression,
- final FilterExpression filterExpression) throws ODataJPARuntimeException, EdmException {
- // Object Instantiation
-
- JPQLSelectContext jpqlSelectContextImpl = null;
- GetEntitySetUriInfo getEntitySetView = EasyMock.createMock(GetEntitySetUriInfo.class);
-
- EdmEntitySet edmEntitySet = EasyMock.createMock(EdmEntitySet.class);
- EdmEntityType edmEntityType = EasyMock.createMock(EdmEntityType.class);
- List<SelectItem> selectItemList = null;
-
- // Setting up the expected value
-
- EasyMock.expect(getEntitySetView.getTargetEntitySet()).andStubReturn(edmEntitySet);
- EasyMock.expect(getEntitySetView.getOrderBy()).andStubReturn(orderByExpression);
- EasyMock.expect(getEntitySetView.getSelect()).andStubReturn(selectItemList);
- EasyMock.expect(getEntitySetView.getFilter()).andStubReturn(filterExpression);
- EasyMock.replay(getEntitySetView);
- EasyMock.expect(edmEntitySet.getEntityType()).andStubReturn(edmEntityType);
- EasyMock.replay(edmEntitySet);
- EasyMock.expect(edmEntityType.getMapping()).andStubReturn(null);
- EasyMock.expect(edmEntityType.getName()).andStubReturn("SalesOrderHeader");
- EasyMock.replay(edmEntityType);
-
- JPQLContextBuilder contextBuilder1 = JPQLContext.createBuilder(JPQLContextType.SELECT, getEntitySetView);
- try {
- jpqlSelectContextImpl = (JPQLSelectContext) contextBuilder1.build();
- } catch (ODataJPAModelException e) {
- fail("Model Exception thrown");
- }
-
- return jpqlSelectContextImpl;
- }
-
- /**
- * Test method for {@link org.apache.olingo.odata2.processor.jpa.jpql.JPQLSelectStatementBuilder#build)}.
- * @throws EdmException
- * @throws ODataJPARuntimeException
- */
-
- @Test
- public void testBuildSimpleQuery() throws EdmException, ODataJPARuntimeException {
- OrderByExpression orderByExpression = EasyMock.createMock(OrderByExpression.class);
- JPQLSelectContext jpqlSelectContextImpl = createSelectContext(orderByExpression, null);
- jpqlSelectStatementBuilder = new JPQLSelectStatementBuilder(jpqlSelectContextImpl);
-
- assertEquals("SELECT E1 FROM SalesOrderHeader E1", jpqlSelectStatementBuilder.build().toString());
- }
-
- @Test
- public void testBuildQueryWithOrderBy() throws EdmException, ODataJPARuntimeException {
- OrderByExpression orderByExpression = EasyMock.createMock(OrderByExpression.class);
-
- JPQLSelectContext jpqlSelectContextImpl = createSelectContext(orderByExpression, null);
- HashMap<String, String> orderByCollection = new HashMap<String, String>();
- orderByCollection.put("E1.soID", "ASC");
- orderByCollection.put("E1.buyerId", "DESC");
- jpqlSelectContextImpl.setOrderByCollection(orderByCollection);
- jpqlSelectStatementBuilder = new JPQLSelectStatementBuilder(jpqlSelectContextImpl);
-
- assertEquals("SELECT E1 FROM SalesOrderHeader E1 ORDER BY E1.soID ASC , E1.buyerId DESC",
- jpqlSelectStatementBuilder.build().toString());
- }
-
- @Test
- public void testBuildQueryWithFilter() throws EdmException, ODataJPARuntimeException {
- OrderByExpression orderByExpression = EasyMock.createMock(OrderByExpression.class);
- FilterExpression filterExpression = null;// getFilterExpressionMockedObj();
- JPQLSelectContext jpqlSelectContextImpl = createSelectContext(orderByExpression, filterExpression);
- jpqlSelectContextImpl.setWhereExpression("E1.soID >= 1234");
-
- jpqlSelectStatementBuilder = new JPQLSelectStatementBuilder(jpqlSelectContextImpl);
-
- assertEquals("SELECT E1 FROM SalesOrderHeader E1 WHERE E1.soID >= 1234", jpqlSelectStatementBuilder.build()
- .toString());
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/ODataJPAContextMock.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/ODataJPAContextMock.java b/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/ODataJPAContextMock.java
deleted file mode 100644
index 7fc3a6d..0000000
--- a/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/ODataJPAContextMock.java
+++ /dev/null
@@ -1,57 +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;
-
-import javax.persistence.EntityManagerFactory;
-import javax.persistence.metamodel.Metamodel;
-
-import org.apache.olingo.odata2.processor.api.jpa.ODataJPAContext;
-import org.easymock.EasyMock;
-
-public abstract class ODataJPAContextMock {
-
- public static final String NAMESPACE = "salesorderprocessing";
- public static final String MAPPING_MODEL = "SalesOrderProcessingMappingModel";
- public static final String PERSISTENCE_UNIT_NAME = "salesorderprocessing";
-
- public static ODataJPAContext mockODataJPAContext() {
- ODataJPAContext odataJPAContext = EasyMock.createMock(ODataJPAContext.class);
- EasyMock.expect(odataJPAContext.getPersistenceUnitName()).andStubReturn(NAMESPACE);
- EasyMock.expect(odataJPAContext.getEntityManagerFactory()).andReturn(mockEntityManagerFactory());
- EasyMock.expect(odataJPAContext.getJPAEdmMappingModel()).andReturn(MAPPING_MODEL);
- EasyMock.expect(odataJPAContext.getJPAEdmExtension()).andReturn(null);
- EasyMock.expect(odataJPAContext.getDefaultNaming()).andReturn(true);
- EasyMock.replay(odataJPAContext);
- return odataJPAContext;
- }
-
- private static EntityManagerFactory mockEntityManagerFactory() {
- EntityManagerFactory emf = EasyMock.createMock(EntityManagerFactory.class);
- EasyMock.expect(emf.getMetamodel()).andReturn(mockMetaModel());
- EasyMock.replay(emf);
- return emf;
- }
-
- private static Metamodel mockMetaModel() {
- Metamodel metaModel = EasyMock.createMock(Metamodel.class);
- EasyMock.replay(metaModel);
- return metaModel;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/data/EdmMockUtil.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/data/EdmMockUtil.java b/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/data/EdmMockUtil.java
deleted file mode 100644
index 57866e3..0000000
--- a/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/data/EdmMockUtil.java
+++ /dev/null
@@ -1,337 +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.data;
-
-import static org.junit.Assert.fail;
-
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.olingo.odata2.api.edm.EdmEntitySet;
-import org.apache.olingo.odata2.api.edm.EdmEntityType;
-import org.apache.olingo.odata2.api.edm.EdmException;
-import org.apache.olingo.odata2.api.edm.EdmMapping;
-import org.apache.olingo.odata2.api.edm.EdmMultiplicity;
-import org.apache.olingo.odata2.api.edm.EdmNavigationProperty;
-import org.apache.olingo.odata2.api.edm.EdmProperty;
-import org.apache.olingo.odata2.api.edm.EdmType;
-import org.apache.olingo.odata2.api.edm.EdmTypeKind;
-import org.apache.olingo.odata2.api.edm.EdmTyped;
-import org.apache.olingo.odata2.api.ep.callback.WriteEntryCallbackContext;
-import org.apache.olingo.odata2.api.ep.callback.WriteFeedCallbackContext;
-import org.apache.olingo.odata2.api.uri.ExpandSelectTreeNode;
-import org.apache.olingo.odata2.api.uri.NavigationPropertySegment;
-import org.apache.olingo.odata2.processor.core.jpa.common.ODataJPATestConstants;
-import org.easymock.EasyMock;
-
-public class EdmMockUtil {
-
- public static ExpandSelectTreeNode mockExpandSelectTreeNode() {
- ExpandSelectTreeNode nextExpandNode = EasyMock.createMock(ExpandSelectTreeNode.class);
- Map<String, ExpandSelectTreeNode> nextLink = null;
- EasyMock.expect(nextExpandNode.getLinks()).andStubReturn(nextLink);
- EasyMock.replay(nextExpandNode);
- ExpandSelectTreeNode expandNode = EasyMock.createMock(ExpandSelectTreeNode.class);
- Map<String, ExpandSelectTreeNode> links = new HashMap<String, ExpandSelectTreeNode>();
- links.put("SalesOrderLineItemDetails", nextExpandNode);
- EasyMock.expect(expandNode.getLinks()).andStubReturn(links);
- EasyMock.replay(expandNode);
- return expandNode;
- }
-
- public static ExpandSelectTreeNode mockCurrentExpandSelectTreeNode() {
- ExpandSelectTreeNode expandNode = EasyMock.createMock(ExpandSelectTreeNode.class);
- Map<String, ExpandSelectTreeNode> links = new HashMap<String, ExpandSelectTreeNode>();
- EasyMock.expect(expandNode.getLinks()).andStubReturn(links);
- EasyMock.replay(expandNode);
- return expandNode;
- }
-
- public static List<ArrayList<NavigationPropertySegment>> getExpandList() {
- List<ArrayList<NavigationPropertySegment>> expandList = new ArrayList<ArrayList<NavigationPropertySegment>>();
- ArrayList<NavigationPropertySegment> expands = new ArrayList<NavigationPropertySegment>();
- expands.add(mockNavigationPropertySegment());
- expandList.add(expands);
- return expandList;
- }
-
- public static WriteFeedCallbackContext getWriteFeedCallBackContext() {
- URI selfLink = null;
- WriteFeedCallbackContext writeContext = new WriteFeedCallbackContext();
- try {
- selfLink = new URI("SalesOrders(2L)/SalesOrderLineItemDetails");
- writeContext.setSelfLink(selfLink);
- writeContext.setCurrentExpandSelectTreeNode(mockCurrentExpandSelectTreeNode());
- writeContext.setNavigationProperty(mockNavigationProperty());
- writeContext.setSourceEntitySet(mockSourceEntitySet());
- writeContext.setEntryData(getFeedData());
-
- } catch (URISyntaxException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
-
- return writeContext;
- }
-
- public static WriteEntryCallbackContext getWriteEntryCallBackContext() {
- WriteEntryCallbackContext writeContext = new WriteEntryCallbackContext();
- writeContext.setCurrentExpandSelectTreeNode(mockCurrentExpandSelectTreeNode());
- writeContext.setNavigationProperty(mockNavigationProperty());
- writeContext.setSourceEntitySet(mockSourceEntitySet());
- writeContext.setEntryData(getEntryData());
- return writeContext;
- }
-
- private static EdmEntitySet mockSourceEntitySet() {
- EdmEntitySet entitySet = EasyMock.createMock(EdmEntitySet.class);
- try {
- EasyMock.expect(entitySet.getEntityType()).andStubReturn(mockSourceEdmEntityType());
- } catch (EdmException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
- EasyMock.replay(entitySet);
- return entitySet;
- }
-
- public static EdmEntityType mockSourceEdmEntityType() {
- EdmEntityType entityType = EasyMock.createMock(EdmEntityType.class);
- EdmMapping mapping = EasyMock.createMock(EdmMapping.class);
- List<String> navigationPropertyNames = new ArrayList<String>();
- List<String> propertyNames = new ArrayList<String>();
- propertyNames.add("id");
- propertyNames.add("description");
- navigationPropertyNames.add("SalesOrderLineItemDetails");
- try {
- EasyMock.expect(mapping.getInternalName()).andStubReturn("SalesOrderHeader");
- EasyMock.replay(mapping);
- EasyMock.expect(entityType.getName()).andStubReturn("SalesOrderHeader");
- EasyMock.expect(entityType.getMapping()).andStubReturn(mapping);
- EasyMock.expect(entityType.getNavigationPropertyNames()).andStubReturn(navigationPropertyNames);
- EasyMock.expect(entityType.getProperty("SalesOrderLineItemDetails")).andStubReturn(mockNavigationProperty());
- EdmProperty property1 = mockEdmPropertyOfSource1();
- EasyMock.expect(entityType.getProperty("id")).andStubReturn(property1);
- EasyMock.expect(entityType.getProperty("description")).andStubReturn(mockEdmPropertyOfSource2());
- EasyMock.expect(entityType.getPropertyNames()).andStubReturn(propertyNames);
-
- } catch (EdmException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
- EasyMock.replay(entityType);
- return entityType;
- }
-
- private static EdmTyped mockEdmPropertyOfSource2() {
- EdmProperty edmProperty = EasyMock.createMock(EdmProperty.class);
- EdmType type = EasyMock.createMock(EdmType.class);
- EasyMock.expect(type.getKind()).andStubReturn(EdmTypeKind.SIMPLE);
- EasyMock.replay(type);
- EdmMapping mapping = EasyMock.createMock(EdmMapping.class);
- EasyMock.expect(mapping.getInternalName()).andStubReturn("description");
- EasyMock.replay(mapping);
- try {
- EasyMock.expect(edmProperty.getName()).andStubReturn("description");
- EasyMock.expect(edmProperty.getType()).andStubReturn(type);
- EasyMock.expect(edmProperty.getMapping()).andStubReturn(mapping);
- } catch (EdmException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
- EasyMock.replay(edmProperty);
- return edmProperty;
- }
-
- private static EdmProperty mockEdmPropertyOfSource1() {
- EdmProperty edmProperty = EasyMock.createMock(EdmProperty.class);
- EdmType type = EasyMock.createMock(EdmType.class);
- EasyMock.expect(type.getKind()).andStubReturn(EdmTypeKind.SIMPLE);
- EasyMock.replay(type);
- EdmMapping mapping = EasyMock.createMock(EdmMapping.class);
- EasyMock.expect(mapping.getInternalName()).andStubReturn("id");
- EasyMock.replay(mapping);
- try {
- EasyMock.expect(edmProperty.getName()).andStubReturn("id");
- EasyMock.expect(edmProperty.getType()).andStubReturn(type);
- EasyMock.expect(edmProperty.getMapping()).andStubReturn(mapping);
- } catch (EdmException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
- EasyMock.replay(edmProperty);
- return edmProperty;
- }
-
- private static Map<String, Object> getFeedData() {
- Map<String, Object> entryData = new HashMap<String, Object>();
- entryData.put("id", 1);
- entryData.put("description", "laptop");
- List<SalesOrderLineItem> salesOrderLineItems = new ArrayList<SalesOrderLineItem>();
- salesOrderLineItems.add(new SalesOrderLineItem(23));
- salesOrderLineItems.add(new SalesOrderLineItem(45));
- entryData.put("SalesOrderLineItemDetails", salesOrderLineItems);
- return entryData;
- }
-
- private static Map<String, Object> getEntryData() {
- Map<String, Object> entryData = new HashMap<String, Object>();
- entryData.put("id", 1);
- entryData.put("description", "laptop");
- entryData.put("SalesOrderLineItemDetails", new SalesOrderLineItem(23));
- return entryData;
- }
-
- private static NavigationPropertySegment mockNavigationPropertySegment() {
- NavigationPropertySegment navigationPropSegment = EasyMock.createMock(NavigationPropertySegment.class);
- EasyMock.expect(navigationPropSegment.getNavigationProperty()).andStubReturn(mockNavigationProperty());
- EasyMock.expect(navigationPropSegment.getTargetEntitySet()).andStubReturn(mockTargetEntitySet());
- EasyMock.replay(navigationPropSegment);
- return navigationPropSegment;
- }
-
- public static NavigationPropertySegment mockThirdNavigationPropertySegment() {
- NavigationPropertySegment navigationPropSegment = EasyMock.createMock(NavigationPropertySegment.class);
- EasyMock.expect(navigationPropSegment.getNavigationProperty()).andStubReturn(mockSecondNavigationProperty());
- EasyMock.expect(navigationPropSegment.getTargetEntitySet()).andStubReturn(mockThirdEntitySet());
- EasyMock.replay(navigationPropSegment);
- return navigationPropSegment;
- }
-
- public static EdmNavigationProperty mockSecondNavigationProperty() {
- EdmNavigationProperty navigationProperty = EasyMock.createMock(EdmNavigationProperty.class);
- EdmMapping mapping = EasyMock.createMock(EdmMapping.class);
- EasyMock.expect(mapping.getInternalName()).andStubReturn("materials");
- EasyMock.replay(mapping);
- try {
- EasyMock.expect(navigationProperty.getMultiplicity()).andStubReturn(EdmMultiplicity.ONE);
- EasyMock.expect(navigationProperty.getMapping()).andStubReturn(mapping);
- EasyMock.expect(navigationProperty.getName()).andStubReturn("MaterialDetails");
- EasyMock.expect(navigationProperty.getFromRole()).andStubReturn("SalesOrderLineItem");
- } catch (EdmException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
- EasyMock.replay(navigationProperty);
- return navigationProperty;
- }
-
- public static EdmEntitySet mockTargetEntitySet() {
- EdmEntitySet entitySet = EasyMock.createMock(EdmEntitySet.class);
- try {
- EasyMock.expect(entitySet.getEntityType()).andStubReturn(mockTargetEdmEntityType());
- } catch (EdmException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
- EasyMock.replay(entitySet);
- return entitySet;
- }
-
- public static EdmEntitySet mockThirdEntitySet() {
- EdmEntitySet entitySet = EasyMock.createMock(EdmEntitySet.class);
- try {
- EasyMock.expect(entitySet.getEntityType()).andStubReturn(mockThirdEdmEntityType());
- } catch (EdmException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
- EasyMock.replay(entitySet);
- return entitySet;
-
- }
-
- private static EdmEntityType mockThirdEdmEntityType() {
- EdmEntityType entityType = EasyMock.createMock(EdmEntityType.class);
- EdmMapping mapping = EasyMock.createMock(EdmMapping.class);
-
- List<String> propertyNames = new ArrayList<String>();
- propertyNames.add("price");
- try {
- EasyMock.expect(mapping.getInternalName()).andStubReturn("Material");
- EasyMock.replay(mapping);
- EasyMock.expect(entityType.getName()).andStubReturn("Material");
- EasyMock.expect(entityType.getMapping()).andStubReturn(mapping);
- EdmProperty property = mockEdmPropertyOfTarget();
- EasyMock.expect(entityType.getProperty("price")).andStubReturn(property);
- EasyMock.expect(entityType.getPropertyNames()).andStubReturn(propertyNames);
-
- } catch (EdmException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
- EasyMock.replay(entityType);
- return entityType;
- }
-
- public static EdmEntityType mockTargetEdmEntityType() {
- EdmEntityType entityType = EasyMock.createMock(EdmEntityType.class);
- EdmMapping mapping = EasyMock.createMock(EdmMapping.class);
-
- List<String> propertyNames = new ArrayList<String>();
- propertyNames.add("price");
- try {
- EasyMock.expect(mapping.getInternalName()).andStubReturn("SalesOrderLineItem");
- EasyMock.replay(mapping);
- EasyMock.expect(entityType.getName()).andStubReturn("SalesOrderLineItem");
- EasyMock.expect(entityType.getMapping()).andStubReturn(mapping);
- EdmProperty property = mockEdmPropertyOfTarget();
- EasyMock.expect(entityType.getProperty("price")).andStubReturn(property);
- EasyMock.expect(entityType.getPropertyNames()).andStubReturn(propertyNames);
-
- } catch (EdmException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
- EasyMock.replay(entityType);
- return entityType;
- }
-
- private static EdmProperty mockEdmPropertyOfTarget() {
- EdmProperty edmProperty = EasyMock.createMock(EdmProperty.class);
-
- EdmType type = EasyMock.createMock(EdmType.class);
- EasyMock.expect(type.getKind()).andStubReturn(EdmTypeKind.SIMPLE);
- EasyMock.replay(type);
- EdmMapping mapping = EasyMock.createMock(EdmMapping.class);
- EasyMock.expect(mapping.getInternalName()).andStubReturn("price");
- EasyMock.replay(mapping);
- try {
- EasyMock.expect(edmProperty.getName()).andStubReturn("price");
- EasyMock.expect(edmProperty.getType()).andStubReturn(type);
- EasyMock.expect(edmProperty.getMapping()).andStubReturn(mapping);
- } catch (EdmException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
- EasyMock.replay(edmProperty);
- return edmProperty;
- }
-
- public static EdmNavigationProperty mockNavigationProperty() {
- EdmNavigationProperty navigationProperty = EasyMock.createMock(EdmNavigationProperty.class);
- EdmMapping mapping = EasyMock.createMock(EdmMapping.class);
- EasyMock.expect(mapping.getInternalName()).andStubReturn("salesOrderLineItems");
- EasyMock.replay(mapping);
- try {
- EasyMock.expect(navigationProperty.getMultiplicity()).andStubReturn(EdmMultiplicity.MANY);
- EasyMock.expect(navigationProperty.getMapping()).andStubReturn(mapping);
- EasyMock.expect(navigationProperty.getName()).andStubReturn("SalesOrderLineItemDetails");
- EasyMock.expect(navigationProperty.getFromRole()).andStubReturn("SalesOrderHeader");
- } catch (EdmException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
- EasyMock.replay(navigationProperty);
- return navigationProperty;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/data/EdmMockUtilV2.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/data/EdmMockUtilV2.java b/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/data/EdmMockUtilV2.java
deleted file mode 100644
index 6611fb1..0000000
--- a/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/data/EdmMockUtilV2.java
+++ /dev/null
@@ -1,324 +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.data;
-
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.List;
-import java.util.UUID;
-
-import org.apache.olingo.odata2.api.edm.EdmAssociation;
-import org.apache.olingo.odata2.api.edm.EdmAssociationEnd;
-import org.apache.olingo.odata2.api.edm.EdmComplexType;
-import org.apache.olingo.odata2.api.edm.EdmEntitySet;
-import org.apache.olingo.odata2.api.edm.EdmEntityType;
-import org.apache.olingo.odata2.api.edm.EdmException;
-import org.apache.olingo.odata2.api.edm.EdmMapping;
-import org.apache.olingo.odata2.api.edm.EdmMultiplicity;
-import org.apache.olingo.odata2.api.edm.EdmNavigationProperty;
-import org.apache.olingo.odata2.api.edm.EdmProperty;
-import org.apache.olingo.odata2.api.edm.EdmType;
-import org.apache.olingo.odata2.api.edm.EdmTypeKind;
-import org.apache.olingo.odata2.api.edm.provider.Mapping;
-import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmMapping;
-import org.apache.olingo.odata2.processor.core.jpa.mock.data.JPATypeMock.JPARelatedTypeMock;
-import org.apache.olingo.odata2.processor.core.jpa.mock.data.JPATypeMock.JPATypeEmbeddableMock;
-import org.apache.olingo.odata2.processor.core.jpa.mock.data.JPATypeMock.JPATypeEmbeddableMock2;
-import org.apache.olingo.odata2.processor.core.jpa.model.JPAEdmMappingImpl;
-import org.easymock.EasyMock;
-
-public class EdmMockUtilV2 {
-
- public static interface JPAEdmMappingMock extends JPAEdmMapping, EdmMapping {
-
- }
-
- public static EdmEntityType mockEdmEntityType(final String entityName, final boolean withComplexType)
- throws EdmException {
-
- EdmEntityType entityType = EasyMock.createMock(EdmEntityType.class);
- EasyMock.expect(entityType.getName()).andReturn(entityName).anyTimes();
- EasyMock.expect(entityType.getKeyPropertyNames()).andReturn(mockSimpleKeyPropertyNames(entityName));
- if (withComplexType == false) {
- EasyMock.expect(entityType.getPropertyNames()).andReturn(mockPropertyNames(entityName)).anyTimes();
- } else {
- EasyMock.expect(entityType.getPropertyNames()).andReturn(mockPropertyNamesWithComplexType(entityName)).anyTimes();
- }
-
- EasyMock.expect(entityType.getNavigationPropertyNames()).andReturn(mockNavigationPropertyNames(entityName));
- EasyMock.expect(entityType.getKind()).andReturn(EdmTypeKind.ENTITY);
- EasyMock.expect(entityType.getMapping()).andReturn((EdmMapping) mockEdmMapping(entityName, null, null));
- if (entityName.equals(JPATypeMock.ENTITY_NAME)) {
- EasyMock.expect(entityType.getProperty(JPATypeMock.PROPERTY_NAME_MINT)).andReturn(
- mockEdmProperty(entityName, JPATypeMock.PROPERTY_NAME_MINT)).anyTimes();
- EasyMock.expect(entityType.getProperty(JPATypeMock.PROPERTY_NAME_MSTRING)).andReturn(
- mockEdmProperty(entityName, JPATypeMock.PROPERTY_NAME_MSTRING)).anyTimes();
- EasyMock.expect(entityType.getProperty(JPATypeMock.PROPERTY_NAME_MDATETIME)).andReturn(
- mockEdmProperty(entityName, JPATypeMock.PROPERTY_NAME_MDATETIME)).anyTimes();
- EasyMock.expect(entityType.getProperty(JPATypeMock.PROPERTY_NAME_MCOMPLEXTYPE)).andReturn(
- mockEdmProperty(entityName, JPATypeMock.PROPERTY_NAME_MCOMPLEXTYPE)).anyTimes();
- EasyMock.expect(entityType.getProperty(JPATypeMock.NAVIGATION_PROPERTY_X)).andReturn(
- mockEdmNavigationProperty(JPATypeMock.NAVIGATION_PROPERTY_X, EdmMultiplicity.ONE)).anyTimes();
- } else if (entityName.equals(JPARelatedTypeMock.ENTITY_NAME)) {
- EasyMock.expect(entityType.getProperty(JPARelatedTypeMock.PROPERTY_NAME_MLONG)).andReturn(
- mockEdmProperty(entityName, JPARelatedTypeMock.PROPERTY_NAME_MLONG)).anyTimes();
- EasyMock.expect(entityType.getProperty(JPARelatedTypeMock.PROPERTY_NAME_MBYTE)).andReturn(
- mockEdmProperty(entityName, JPARelatedTypeMock.PROPERTY_NAME_MBYTE)).anyTimes();
- EasyMock.expect(entityType.getProperty(JPARelatedTypeMock.PROPERTY_NAME_MBYTEARRAY)).andReturn(
- mockEdmProperty(entityName, JPARelatedTypeMock.PROPERTY_NAME_MBYTEARRAY)).anyTimes();
- EasyMock.expect(entityType.getProperty(JPARelatedTypeMock.PROPERTY_NAME_MDOUBLE)).andReturn(
- mockEdmProperty(entityName, JPARelatedTypeMock.PROPERTY_NAME_MDOUBLE)).anyTimes();
- }
- EasyMock.replay(entityType);
- return entityType;
- }
-
- public static List<String> mockNavigationPropertyNames(final String entityName) {
- List<String> propertyNames = new ArrayList<String>();
- propertyNames.add(JPATypeMock.NAVIGATION_PROPERTY_X);
- propertyNames.add(JPATypeMock.NAVIGATION_PROPERTY_XS);
- return propertyNames;
- }
-
- public static List<String> mockSimpleKeyPropertyNames(final String entityName) {
- List<String> keyPropertyNames = new ArrayList<String>();
- if (entityName.equals(JPATypeMock.ENTITY_NAME)) {
- keyPropertyNames.add(JPATypeMock.PROPERTY_NAME_MINT);
- } else if (entityName.equals(JPARelatedTypeMock.ENTITY_NAME)) {
- keyPropertyNames.add(JPARelatedTypeMock.PROPERTY_NAME_MLONG);
- }
-
- return keyPropertyNames;
- }
-
- public static List<String> mockPropertyNames(final String entityName) {
- List<String> propertyNames = new ArrayList<String>();
-
- if (entityName.equals(JPATypeMock.ENTITY_NAME)) {
- propertyNames.add(JPATypeMock.PROPERTY_NAME_MINT);
- propertyNames.add(JPATypeMock.PROPERTY_NAME_MDATETIME);
- propertyNames.add(JPATypeMock.PROPERTY_NAME_MSTRING);
- } else if (entityName.equals(JPARelatedTypeMock.ENTITY_NAME)) {
- propertyNames.add(JPARelatedTypeMock.PROPERTY_NAME_MLONG);
- propertyNames.add(JPARelatedTypeMock.PROPERTY_NAME_MBYTE);
- propertyNames.add(JPARelatedTypeMock.PROPERTY_NAME_MBYTEARRAY);
- propertyNames.add(JPARelatedTypeMock.PROPERTY_NAME_MDOUBLE);
- } else if (entityName.equals(JPATypeEmbeddableMock.ENTITY_NAME)) {
- propertyNames.add(JPATypeMock.JPATypeEmbeddableMock.PROPERTY_NAME_MSHORT);
- propertyNames.add(JPATypeMock.JPATypeEmbeddableMock.PROPERTY_NAME_MEMBEDDABLE);
- } else if (entityName.equals(JPATypeEmbeddableMock2.ENTITY_NAME)) {
- propertyNames.add(JPATypeMock.JPATypeEmbeddableMock2.PROPERTY_NAME_MFLOAT);
- propertyNames.add(JPATypeMock.JPATypeEmbeddableMock2.PROPERTY_NAME_MUUID);
- }
-
- return propertyNames;
- }
-
- public static List<String> mockPropertyNamesWithComplexType(final String entityName) {
- List<String> propertyNames = mockPropertyNames(entityName);
- propertyNames.add(JPATypeMock.PROPERTY_NAME_MCOMPLEXTYPE);
-
- return propertyNames;
-
- }
-
- public static EdmAssociationEnd mockEdmAssociatioEnd(final String navigationPropertyName, final String role)
- throws EdmException {
- EdmAssociationEnd associationEnd = EasyMock.createMock(EdmAssociationEnd.class);
- EasyMock.expect(associationEnd.getMultiplicity()).andReturn(EdmMultiplicity.ONE);
- EdmEntityType entityType = EasyMock.createMock(EdmEntityType.class);
- EasyMock.expect(entityType.getMapping()).andReturn((EdmMapping) mockEdmMapping("JPARelatedTypeMock", null, null));
- EasyMock.replay(entityType);
-
- EasyMock.expect(associationEnd.getEntityType()).andReturn(entityType);
- EasyMock.replay(associationEnd);
- return associationEnd;
- }
-
- public static EdmAssociation mockEdmAssociation(final String navigationPropertyName) throws EdmException {
- EdmAssociation edmAssociation = EasyMock.createMock(EdmAssociation.class);
- EasyMock.expect(edmAssociation.getEnd("TO")).andReturn(mockEdmAssociatioEnd(navigationPropertyName, "TO"));
- EasyMock.expect(edmAssociation.getEnd("FROM")).andReturn(mockEdmAssociatioEnd(navigationPropertyName, "FROM"));
- EasyMock.replay(edmAssociation);
- return edmAssociation;
- }
-
- public static EdmEntitySet mockEdmEntitySet(final String entityName, final boolean withComplexType)
- throws EdmException {
- EdmEntitySet entitySet = null;
- if (entityName.equals(JPATypeMock.ENTITY_NAME)) {
- entitySet = EasyMock.createMock(EdmEntitySet.class);
- EasyMock.expect(entitySet.getEntityType()).andReturn(mockEdmEntityType(entityName, withComplexType)).anyTimes();
- EasyMock.expect(entitySet.getRelatedEntitySet(EasyMock.isA(EdmNavigationProperty.class))).andReturn(
- mockEdmEntitySet(JPARelatedTypeMock.ENTITY_NAME, false)).anyTimes();
- } else if (entityName.equals(JPARelatedTypeMock.ENTITY_NAME)) {
- entitySet = EasyMock.createMock(EdmEntitySet.class);
- EasyMock.expect(entitySet.getEntityType()).andReturn(mockEdmEntityType(entityName, withComplexType)).anyTimes();
- }
-
- EasyMock.replay(entitySet);
- return entitySet;
- }
-
- public static EdmNavigationProperty mockEdmNavigationProperty(final String navigationPropertyName,
- final EdmMultiplicity multiplicity) throws EdmException {
-
- EdmEntityType edmEntityType = mockEdmEntityType(JPARelatedTypeMock.ENTITY_NAME, false);
-
- EdmNavigationProperty navigationProperty = EasyMock.createMock(EdmNavigationProperty.class);
- EasyMock.expect(navigationProperty.getType()).andReturn(edmEntityType).anyTimes();
- EasyMock.expect(navigationProperty.getMultiplicity()).andReturn(multiplicity);
- EasyMock.expect(navigationProperty.getMapping()).andReturn(
- (EdmMapping) mockEdmMapping(null, null, navigationPropertyName)).anyTimes();
- EasyMock.expect(navigationProperty.getToRole()).andReturn("TO");
- EasyMock.expect(navigationProperty.getRelationship()).andReturn(mockEdmAssociation(navigationPropertyName));
- if (multiplicity.equals(EdmMultiplicity.ONE)) {
- EasyMock.expect(navigationProperty.getName()).andReturn(JPATypeMock.NAVIGATION_PROPERTY_X).anyTimes();
- }
-
- EasyMock.replay(navigationProperty);
-
- return navigationProperty;
- }
-
- public static EdmProperty mockEdmProperty(final String entityName, final String propertyName) throws EdmException {
- EdmProperty edmProperty = EasyMock.createMock(EdmProperty.class);
-
- if (propertyName.equals(JPATypeMock.PROPERTY_NAME_MINT) ||
- propertyName.equals(JPATypeMock.PROPERTY_NAME_MSTRING) ||
- propertyName.equals(JPATypeMock.PROPERTY_NAME_MDATETIME) ||
- propertyName.equals(JPATypeMock.JPATypeEmbeddableMock.PROPERTY_NAME_MSHORT) ||
- propertyName.equals(JPATypeMock.JPATypeEmbeddableMock2.PROPERTY_NAME_MFLOAT) ||
- propertyName.equals(JPATypeMock.JPATypeEmbeddableMock2.PROPERTY_NAME_MUUID) ||
- propertyName.equals(JPARelatedTypeMock.PROPERTY_NAME_MLONG) ||
- propertyName.equals(JPARelatedTypeMock.PROPERTY_NAME_MBYTE) ||
- propertyName.equals(JPARelatedTypeMock.PROPERTY_NAME_MDOUBLE) ||
- propertyName.equals(JPARelatedTypeMock.PROPERTY_NAME_MBYTEARRAY)) {
-
- EdmType edmType = EasyMock.createMock(EdmType.class);
- EasyMock.expect(edmProperty.getType()).andReturn(edmType).anyTimes();
- EasyMock.expect(edmType.getKind()).andReturn(EdmTypeKind.SIMPLE).anyTimes();
- EasyMock.replay(edmType);
- EasyMock.expect(edmProperty.getName()).andReturn(propertyName).anyTimes();
- EasyMock.expect(edmProperty.getMapping()).andReturn((EdmMapping) mockEdmMapping(entityName, propertyName, null))
- .anyTimes();
-
- } else if (propertyName.equals(JPATypeMock.JPATypeEmbeddableMock.PROPERTY_NAME_MEMBEDDABLE) ||
- propertyName.equals(JPATypeMock.PROPERTY_NAME_MCOMPLEXTYPE)) {
- EdmComplexType complexType = mockComplexType(propertyName);
-
- EasyMock.expect(edmProperty.getType()).andReturn(complexType).anyTimes();
- EasyMock.expect(edmProperty.getName()).andReturn(propertyName).anyTimes();
- EasyMock.expect(edmProperty.getMapping()).andReturn((EdmMapping) mockEdmMapping(null, propertyName, null))
- .anyTimes();
-
- }
-
- EasyMock.replay(edmProperty);
- return edmProperty;
- }
-
- public static EdmComplexType mockComplexType(final String complexPropertyName) throws EdmException {
-
- String complexTypeName = null;
- if (complexPropertyName.equals(JPATypeEmbeddableMock.PROPERTY_NAME_MEMBEDDABLE)) {
- complexTypeName = JPATypeEmbeddableMock2.ENTITY_NAME;
- } else if (complexPropertyName.equals(JPATypeMock.PROPERTY_NAME_MCOMPLEXTYPE)) {
- complexTypeName = JPATypeEmbeddableMock.ENTITY_NAME;
- }
-
- EdmComplexType edmComplexType = EasyMock.createMock(EdmComplexType.class);
- EasyMock.expect(edmComplexType.getKind()).andReturn(EdmTypeKind.COMPLEX);
- EasyMock.expect(edmComplexType.getPropertyNames()).andReturn(mockPropertyNames(complexTypeName)).anyTimes();
- EasyMock.expect(edmComplexType.getMapping()).andReturn((EdmMapping) mockEdmMapping(complexTypeName, null, null));
-
- if (complexTypeName.equals(JPATypeEmbeddableMock.ENTITY_NAME)) {
- EasyMock.expect(edmComplexType.getProperty(JPATypeEmbeddableMock.PROPERTY_NAME_MSHORT)).andReturn(
- mockEdmProperty(complexTypeName, JPATypeEmbeddableMock.PROPERTY_NAME_MSHORT)).anyTimes();
- EasyMock.expect(edmComplexType.getProperty(JPATypeEmbeddableMock.PROPERTY_NAME_MEMBEDDABLE)).andReturn(
- mockEdmProperty(complexTypeName, JPATypeEmbeddableMock.PROPERTY_NAME_MEMBEDDABLE)).anyTimes();
- } else if (complexTypeName.equals(JPATypeEmbeddableMock2.ENTITY_NAME)) {
- EasyMock.expect(edmComplexType.getProperty(JPATypeEmbeddableMock2.PROPERTY_NAME_MFLOAT)).andReturn(
- mockEdmProperty(complexTypeName, JPATypeEmbeddableMock2.PROPERTY_NAME_MFLOAT)).anyTimes();
- EasyMock.expect(edmComplexType.getProperty(JPATypeEmbeddableMock2.PROPERTY_NAME_MUUID)).andReturn(
- mockEdmProperty(complexTypeName, JPATypeEmbeddableMock2.PROPERTY_NAME_MUUID)).anyTimes();
- }
-
- EasyMock.replay(edmComplexType);
- return edmComplexType;
- }
-
- public static JPAEdmMapping mockEdmMapping(final String entityName, final String propertyName,
- final String navigationPropertyName) {
- JPAEdmMapping mapping = new JPAEdmMappingImpl();
-
- if (propertyName == null && entityName != null) {
- if (entityName.equals(JPATypeMock.ENTITY_NAME)) {
- mapping.setJPAType(JPATypeMock.class);
- } else if (entityName.equals(JPARelatedTypeMock.ENTITY_NAME)) {
- mapping.setJPAType(JPARelatedTypeMock.class);
- } else if (entityName.equals(JPATypeEmbeddableMock.ENTITY_NAME)) {
- mapping.setJPAType(JPATypeEmbeddableMock.class);
- } else if (entityName.equals(JPATypeEmbeddableMock2.ENTITY_NAME)) {
- mapping.setJPAType(JPATypeEmbeddableMock2.class);
- }
- } else if (entityName == null && navigationPropertyName != null) {
- mapping.setJPAType(JPARelatedTypeMock.class);
- mapping.setJPAColumnName(JPATypeMock.NAVIGATION_PROPERTY_X);
- } else if (propertyName.equals(JPATypeMock.PROPERTY_NAME_MINT)) {
- mapping.setJPAType(int.class);
- ((Mapping) mapping).setInternalName(JPATypeMock.PROPERTY_NAME_MINT);
- } else if (propertyName.equals(JPATypeMock.PROPERTY_NAME_MSTRING)) {
- mapping.setJPAType(String.class);
- ((Mapping) mapping).setInternalName(JPATypeMock.PROPERTY_NAME_MSTRING);
- } else if (propertyName.equals(JPATypeMock.PROPERTY_NAME_MDATETIME)) {
- mapping.setJPAType(Calendar.class);
- ((Mapping) mapping).setInternalName(JPATypeMock.PROPERTY_NAME_MDATETIME);
- } else if (propertyName.equals(JPARelatedTypeMock.PROPERTY_NAME_MLONG)) {
- mapping.setJPAType(long.class);
- ((Mapping) mapping).setInternalName(JPARelatedTypeMock.PROPERTY_NAME_MLONG);
- } else if (propertyName.equals(JPARelatedTypeMock.PROPERTY_NAME_MDOUBLE)) {
- mapping.setJPAType(double.class);
- ((Mapping) mapping).setInternalName(JPARelatedTypeMock.PROPERTY_NAME_MDOUBLE);
- } else if (propertyName.equals(JPARelatedTypeMock.PROPERTY_NAME_MBYTE)) {
- mapping.setJPAType(byte.class);
- ((Mapping) mapping).setInternalName(JPARelatedTypeMock.PROPERTY_NAME_MBYTE);
- } else if (propertyName.equals(JPARelatedTypeMock.PROPERTY_NAME_MBYTEARRAY)) {
- mapping.setJPAType(byte[].class);
- ((Mapping) mapping).setInternalName(JPARelatedTypeMock.PROPERTY_NAME_MBYTEARRAY);
- } else if (propertyName.equals(JPATypeMock.JPATypeEmbeddableMock.PROPERTY_NAME_MSHORT)) {
- mapping.setJPAType(Short.TYPE);
- ((Mapping) mapping).setInternalName(JPATypeMock.JPATypeEmbeddableMock.PROPERTY_NAME_MSHORT);
- } else if (propertyName.equals(JPATypeMock.JPATypeEmbeddableMock2.PROPERTY_NAME_MFLOAT)) {
- mapping.setJPAType(Float.TYPE);
- ((Mapping) mapping).setInternalName(JPATypeMock.JPATypeEmbeddableMock2.PROPERTY_NAME_MFLOAT);
- } else if (propertyName.equals(JPATypeMock.JPATypeEmbeddableMock2.PROPERTY_NAME_MUUID)) {
- mapping.setJPAType(UUID.class);
- ((Mapping) mapping).setInternalName(JPATypeMock.JPATypeEmbeddableMock2.PROPERTY_NAME_MUUID);
- } else if (propertyName.equals(JPATypeMock.JPATypeEmbeddableMock.PROPERTY_NAME_MEMBEDDABLE)) {
- mapping.setJPAType(JPATypeEmbeddableMock2.class);
- ((Mapping) mapping).setInternalName(JPATypeMock.JPATypeEmbeddableMock.PROPERTY_NAME_MEMBEDDABLE);
- } else if (propertyName.equals(JPATypeMock.PROPERTY_NAME_MCOMPLEXTYPE)) {
- mapping.setJPAType(JPATypeEmbeddableMock.class);
- ((Mapping) mapping).setInternalName(JPATypeMock.PROPERTY_NAME_MCOMPLEXTYPE);
- }
- return mapping;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/data/JPATypeMock.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/data/JPATypeMock.java b/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/data/JPATypeMock.java
deleted file mode 100644
index d7bb703..0000000
--- a/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/data/JPATypeMock.java
+++ /dev/null
@@ -1,205 +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.data;
-
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.List;
-import java.util.UUID;
-
-/* ========================================================================= */
-public class JPATypeMock {
-
- public static final String ENTITY_NAME = "JPATypeMock";
- public static final String PROPERTY_NAME_MINT = "mInt";
- public static final String PROPERTY_NAME_MSTRING = "mString";
- public static final String PROPERTY_NAME_MDATETIME = "mDateTime";
- public static final String PROPERTY_NAME_MKEY = "key";
- public static final String PROPERTY_NAME_MCOMPLEXTYPE = "complexType";
-
- public static final String NAVIGATION_PROPERTY_X = "mRelatedEntity";
- public static final String NAVIGATION_PROPERTY_XS = "mRelatedEntities";
-
- private JPATypeEmbeddableMock key;
- private JPATypeEmbeddableMock complexType;
- private int mInt;
- private String mString;
- private Calendar mDateTime;
- private JPARelatedTypeMock mRelatedEntity;
- private List<JPARelatedTypeMock> mRelatedEntities = new ArrayList<JPATypeMock.JPARelatedTypeMock>();
-
- public String getMString() {
- return mString;
- }
-
- public void setMString(final String mString) {
- this.mString = mString;
- }
-
- public JPATypeEmbeddableMock getKey() {
- return key;
- }
-
- public void setKey(final JPATypeEmbeddableMock key) {
- this.key = key;
- }
-
- public int getMInt() {
- return mInt;
- }
-
- public void setMInt(final int mInt) {
- this.mInt = mInt;
- }
-
- public Calendar getMDateTime() {
- return mDateTime;
- }
-
- public void setMDateTime(final Calendar mDateTime) {
- this.mDateTime = mDateTime;
- }
-
- public JPARelatedTypeMock getMRelatedEntity() {
- return mRelatedEntity;
- }
-
- public void setMRelatedEntity(final JPARelatedTypeMock mRelatedEntity) {
- this.mRelatedEntity = mRelatedEntity;
- }
-
- public List<JPARelatedTypeMock> getMRelatedEntities() {
- return mRelatedEntities;
- }
-
- public void setMRelatedEntities(final List<JPARelatedTypeMock> mRelatedEntities) {
- this.mRelatedEntities = mRelatedEntities;
- }
-
- public JPATypeEmbeddableMock getComplexType() {
- return complexType;
- }
-
- public void setComplexType(final JPATypeEmbeddableMock complexType) {
- this.complexType = complexType;
- }
-
- /* ========================================================================= */
- public static class JPATypeEmbeddableMock {
-
- public static final String ENTITY_NAME = "JPATypeEmbeddableMock";
- public static final String PROPERTY_NAME_MSHORT = "mShort";
- public static final String PROPERTY_NAME_MEMBEDDABLE = "mEmbeddable";
-
- private short mShort;
- private JPATypeEmbeddableMock2 mEmbeddable;
-
- public short getMShort() {
- return mShort;
- }
-
- public void setMShort(final short mShort) {
- this.mShort = mShort;
- }
-
- public JPATypeEmbeddableMock2 getMEmbeddable() {
- return mEmbeddable;
- }
-
- public void setMEmbeddable(final JPATypeEmbeddableMock2 mEmbeddable) {
- this.mEmbeddable = mEmbeddable;
- }
-
- }
-
- /* ========================================================================= */
- public static class JPATypeEmbeddableMock2 {
-
- public static final String ENTITY_NAME = "JPATypeEmbeddableMock2";
- public static final String PROPERTY_NAME_MUUID = "mUUID";
- public static final String PROPERTY_NAME_MFLOAT = "mFloat";
-
- private UUID mUUID;
- private float mFloat;
-
- public UUID getMUUID() {
- return mUUID;
- }
-
- public void setMUUID(final UUID mUUID) {
- this.mUUID = mUUID;
- }
-
- public float getMFloat() {
- return mFloat;
- }
-
- public void setMFloat(final float mFloat) {
- this.mFloat = mFloat;
- }
-
- }
-
- /* ========================================================================= */
- public static final class JPARelatedTypeMock {
- public static final String ENTITY_NAME = "JPARelatedTypeMock";
- public static final String PROPERTY_NAME_MLONG = "mLong";
- public static final String PROPERTY_NAME_MDOUBLE = "mDouble";
- public static final String PROPERTY_NAME_MBYTE = "mByte";
- public static final String PROPERTY_NAME_MBYTEARRAY = "mByteArray";
-
- private long mLong;
- private double mDouble;
- private byte mByte;
- private byte mByteArray[];
-
- public long getMLong() {
- return mLong;
- }
-
- public void setMLong(final long key) {
- mLong = key;
- }
-
- public double getMDouble() {
- return mDouble;
- }
-
- public void setMDouble(final double mDouble) {
- this.mDouble = mDouble;
- }
-
- public byte getMByte() {
- return mByte;
- }
-
- public void setMByte(final byte mByte) {
- this.mByte = mByte;
- }
-
- public byte[] getMByteArray() {
- return mByteArray;
- }
-
- public void setMByteArray(final byte mByteArray[]) {
- this.mByteArray = mByteArray;
- }
-
- }
-}
[15/37] [OLINGO-82] Renamed the project folder name to
odata2-jpa-processor
Posted by ch...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/ODataJPAResponseBuilder.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/ODataJPAResponseBuilder.java b/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/ODataJPAResponseBuilder.java
deleted file mode 100644
index 8f3487e..0000000
--- a/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/ODataJPAResponseBuilder.java
+++ /dev/null
@@ -1,629 +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;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.olingo.odata2.api.commons.HttpStatusCodes;
-import org.apache.olingo.odata2.api.commons.InlineCount;
-import org.apache.olingo.odata2.api.edm.EdmEntitySet;
-import org.apache.olingo.odata2.api.edm.EdmEntityType;
-import org.apache.olingo.odata2.api.edm.EdmException;
-import org.apache.olingo.odata2.api.edm.EdmFunctionImport;
-import org.apache.olingo.odata2.api.edm.EdmLiteralKind;
-import org.apache.olingo.odata2.api.edm.EdmMultiplicity;
-import org.apache.olingo.odata2.api.edm.EdmNavigationProperty;
-import org.apache.olingo.odata2.api.edm.EdmProperty;
-import org.apache.olingo.odata2.api.edm.EdmSimpleType;
-import org.apache.olingo.odata2.api.edm.EdmStructuralType;
-import org.apache.olingo.odata2.api.edm.EdmType;
-import org.apache.olingo.odata2.api.edm.EdmTypeKind;
-import org.apache.olingo.odata2.api.ep.EntityProvider;
-import org.apache.olingo.odata2.api.ep.EntityProviderException;
-import org.apache.olingo.odata2.api.ep.EntityProviderWriteProperties;
-import org.apache.olingo.odata2.api.ep.EntityProviderWriteProperties.ODataEntityProviderPropertiesBuilder;
-import org.apache.olingo.odata2.api.exception.ODataException;
-import org.apache.olingo.odata2.api.exception.ODataHttpException;
-import org.apache.olingo.odata2.api.exception.ODataNotFoundException;
-import org.apache.olingo.odata2.api.processor.ODataContext;
-import org.apache.olingo.odata2.api.processor.ODataResponse;
-import org.apache.olingo.odata2.api.uri.ExpandSelectTreeNode;
-import org.apache.olingo.odata2.api.uri.NavigationPropertySegment;
-import org.apache.olingo.odata2.api.uri.SelectItem;
-import org.apache.olingo.odata2.api.uri.UriParser;
-import org.apache.olingo.odata2.api.uri.info.DeleteUriInfo;
-import org.apache.olingo.odata2.api.uri.info.GetEntityLinkUriInfo;
-import org.apache.olingo.odata2.api.uri.info.GetEntitySetLinksUriInfo;
-import org.apache.olingo.odata2.api.uri.info.GetEntitySetUriInfo;
-import org.apache.olingo.odata2.api.uri.info.GetEntityUriInfo;
-import org.apache.olingo.odata2.api.uri.info.GetFunctionImportUriInfo;
-import org.apache.olingo.odata2.api.uri.info.PostUriInfo;
-import org.apache.olingo.odata2.api.uri.info.PutMergePatchUriInfo;
-import org.apache.olingo.odata2.processor.api.jpa.ODataJPAContext;
-import org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPARuntimeException;
-import org.apache.olingo.odata2.processor.core.jpa.access.data.JPAEntityParser;
-import org.apache.olingo.odata2.processor.core.jpa.access.data.JPAExpandCallBack;
-
-public final class ODataJPAResponseBuilder {
-
- /* Response for Read Entity Set */
- public static <T> ODataResponse build(final List<T> jpaEntities, final GetEntitySetUriInfo resultsView,
- final String contentType, final ODataJPAContext odataJPAContext) throws ODataJPARuntimeException {
-
- EdmEntityType edmEntityType = null;
- ODataResponse odataResponse = null;
- List<ArrayList<NavigationPropertySegment>> expandList = null;
-
- try {
- edmEntityType = resultsView.getTargetEntitySet().getEntityType();
- List<Map<String, Object>> edmEntityList = new ArrayList<Map<String, Object>>();
- Map<String, Object> edmPropertyValueMap = null;
- JPAEntityParser jpaResultParser = new JPAEntityParser();
- final List<SelectItem> selectedItems = resultsView.getSelect();
- if (selectedItems != null && selectedItems.size() > 0) {
- for (Object jpaEntity : jpaEntities) {
- edmPropertyValueMap =
- jpaResultParser.parse2EdmPropertyValueMap(jpaEntity, buildSelectItemList(selectedItems, edmEntityType));
- edmEntityList.add(edmPropertyValueMap);
- }
- } else {
- for (Object jpaEntity : jpaEntities) {
- edmPropertyValueMap = jpaResultParser.parse2EdmPropertyValueMap(jpaEntity, edmEntityType);
- edmEntityList.add(edmPropertyValueMap);
- }
- }
- expandList = resultsView.getExpand();
- if (expandList != null && expandList.size() != 0) {
- int count = 0;
- List<EdmNavigationProperty> edmNavPropertyList = constructListofNavProperty(expandList);
- for (Object jpaEntity : jpaEntities) {
- Map<String, Object> relationShipMap = edmEntityList.get(count);
- HashMap<String, Object> navigationMap =
- jpaResultParser.parse2EdmNavigationValueMap(jpaEntity, edmNavPropertyList);
- relationShipMap.putAll(navigationMap);
- count++;
- }
- }
-
- EntityProviderWriteProperties feedProperties = null;
-
- feedProperties = getEntityProviderProperties(odataJPAContext, resultsView, edmEntityList);
- odataResponse =
- EntityProvider.writeFeed(contentType, resultsView.getTargetEntitySet(), edmEntityList, feedProperties);
- odataResponse = ODataResponse.fromResponse(odataResponse).status(HttpStatusCodes.OK).build();
-
- } catch (EntityProviderException e) {
- throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e);
- } catch (EdmException e) {
- throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e);
- }
-
- return odataResponse;
- }
-
- /* Response for Read Entity */
- public static ODataResponse build(final Object jpaEntity, final GetEntityUriInfo resultsView,
- final String contentType, final ODataJPAContext oDataJPAContext) throws ODataJPARuntimeException,
- ODataNotFoundException {
-
- List<ArrayList<NavigationPropertySegment>> expandList = null;
- if (jpaEntity == null) {
- throw new ODataNotFoundException(ODataNotFoundException.ENTITY);
- }
- EdmEntityType edmEntityType = null;
- ODataResponse odataResponse = null;
-
- try {
-
- edmEntityType = resultsView.getTargetEntitySet().getEntityType();
- Map<String, Object> edmPropertyValueMap = null;
-
- JPAEntityParser jpaResultParser = new JPAEntityParser();
- final List<SelectItem> selectedItems = resultsView.getSelect();
- if (selectedItems != null && selectedItems.size() > 0) {
- edmPropertyValueMap =
- jpaResultParser.parse2EdmPropertyValueMap(jpaEntity, buildSelectItemList(selectedItems, resultsView
- .getTargetEntitySet().getEntityType()));
- } else {
- edmPropertyValueMap = jpaResultParser.parse2EdmPropertyValueMap(jpaEntity, edmEntityType);
- }
-
- expandList = resultsView.getExpand();
- if (expandList != null && expandList.size() != 0) {
- HashMap<String, Object> navigationMap =
- jpaResultParser.parse2EdmNavigationValueMap(jpaEntity, constructListofNavProperty(expandList));
- edmPropertyValueMap.putAll(navigationMap);
- }
- EntityProviderWriteProperties feedProperties = null;
- feedProperties = getEntityProviderProperties(oDataJPAContext, resultsView);
- odataResponse =
- EntityProvider.writeEntry(contentType, resultsView.getTargetEntitySet(), edmPropertyValueMap, feedProperties);
-
- odataResponse = ODataResponse.fromResponse(odataResponse).status(HttpStatusCodes.OK).build();
-
- } catch (EntityProviderException e) {
- throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e);
- } catch (EdmException e) {
- throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e);
- }
-
- return odataResponse;
- }
-
- /* Response for $count */
- public static ODataResponse build(final long jpaEntityCount, final ODataJPAContext oDataJPAContext)
- throws ODataJPARuntimeException {
-
- ODataResponse odataResponse = null;
- try {
- odataResponse = EntityProvider.writeText(String.valueOf(jpaEntityCount));
- odataResponse = ODataResponse.fromResponse(odataResponse).build();
- } catch (EntityProviderException e) {
- throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e);
- }
- return odataResponse;
- }
-
- /* Response for Create Entity */
- @SuppressWarnings("unchecked")
- public static ODataResponse build(final List<Object> createdObjectList, final PostUriInfo uriInfo,
- final String contentType, final ODataJPAContext oDataJPAContext) throws ODataJPARuntimeException,
- ODataNotFoundException {
-
- if (createdObjectList == null || createdObjectList.size() == 0 || createdObjectList.get(0) == null) {
- throw new ODataNotFoundException(ODataNotFoundException.ENTITY);
- }
-
- EdmEntityType edmEntityType = null;
- ODataResponse odataResponse = null;
-
- try {
-
- edmEntityType = uriInfo.getTargetEntitySet().getEntityType();
- Map<String, Object> edmPropertyValueMap = null;
-
- JPAEntityParser jpaResultParser = new JPAEntityParser();
- edmPropertyValueMap = jpaResultParser.parse2EdmPropertyValueMap(createdObjectList.get(0), edmEntityType);
-
- List<ArrayList<NavigationPropertySegment>> expandList = null;
- if (createdObjectList.get(1) != null
- && ((Map<EdmNavigationProperty, EdmEntitySet>) createdObjectList.get(1)).size() > 0) {
- expandList = getExpandList((Map<EdmNavigationProperty, EdmEntitySet>) createdObjectList.get(1));
- HashMap<String, Object> navigationMap =
- jpaResultParser.parse2EdmNavigationValueMap(createdObjectList.get(0),
- constructListofNavProperty(expandList));
- edmPropertyValueMap.putAll(navigationMap);
- }
- EntityProviderWriteProperties feedProperties = null;
- try {
- feedProperties = getEntityProviderPropertiesforPost(oDataJPAContext, uriInfo, expandList);
- } catch (ODataException e) {
- throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.INNER_EXCEPTION, e);
- }
-
- odataResponse =
- EntityProvider.writeEntry(contentType, uriInfo.getTargetEntitySet(), edmPropertyValueMap, feedProperties);
-
- odataResponse = ODataResponse.fromResponse(odataResponse).status(HttpStatusCodes.CREATED).build();
-
- } catch (EntityProviderException e) {
- throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e);
- } catch (EdmException e) {
- throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e);
- }
-
- return odataResponse;
- }
-
- /* Response for Update Entity */
- public static ODataResponse build(final Object updatedObject, final PutMergePatchUriInfo putUriInfo)
- throws ODataJPARuntimeException, ODataNotFoundException {
- if (updatedObject == null) {
- throw new ODataNotFoundException(ODataNotFoundException.ENTITY);
- }
- return ODataResponse.status(HttpStatusCodes.NO_CONTENT).build();
- }
-
- /* Response for Delete Entity */
- public static ODataResponse build(final Object deletedObject, final DeleteUriInfo deleteUriInfo)
- throws ODataJPARuntimeException, ODataNotFoundException {
-
- if (deletedObject == null) {
- throw new ODataNotFoundException(ODataNotFoundException.ENTITY);
- }
- return ODataResponse.status(HttpStatusCodes.NO_CONTENT).build();
- }
-
- /* Response for Function Import Single Result */
- public static ODataResponse build(final Object result, final GetFunctionImportUriInfo resultsView)
- throws ODataJPARuntimeException {
-
- try {
- final EdmFunctionImport functionImport = resultsView.getFunctionImport();
- final EdmSimpleType type = (EdmSimpleType) functionImport.getReturnType().getType();
-
- if (result != null) {
- ODataResponse response = null;
-
- final String value = type.valueToString(result, EdmLiteralKind.DEFAULT, null);
- response = EntityProvider.writeText(value);
-
- return ODataResponse.fromResponse(response).build();
- } else {
- throw new ODataNotFoundException(ODataHttpException.COMMON);
- }
- } catch (EdmException e) {
- throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e);
- } catch (EntityProviderException e) {
- throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e);
- } catch (ODataException e) {
- throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.INNER_EXCEPTION, e);
- }
- }
-
- /* Response for Function Import Multiple Result */
- public static ODataResponse build(final List<Object> resultList, final GetFunctionImportUriInfo resultsView,
- final String contentType, final ODataJPAContext oDataJPAContext) throws ODataJPARuntimeException,
- ODataNotFoundException {
-
- ODataResponse odataResponse = null;
-
- if (resultList != null && !resultList.isEmpty()) {
- JPAEntityParser jpaResultParser = new JPAEntityParser();
- EdmType edmType = null;
- EdmFunctionImport functionImport = null;
- Map<String, Object> edmPropertyValueMap = null;
- List<Map<String, Object>> edmEntityList = null;
- Object result = null;
- try {
- EntityProviderWriteProperties feedProperties = null;
-
- feedProperties =
- EntityProviderWriteProperties.serviceRoot(oDataJPAContext.getODataContext().getPathInfo().getServiceRoot())
- .build();
-
- functionImport = resultsView.getFunctionImport();
- edmType = functionImport.getReturnType().getType();
-
- if (edmType.getKind().equals(EdmTypeKind.ENTITY) || edmType.getKind().equals(EdmTypeKind.COMPLEX)) {
- if (functionImport.getReturnType().getMultiplicity().equals(EdmMultiplicity.MANY)) {
- edmEntityList = new ArrayList<Map<String, Object>>();
- for (Object jpaEntity : resultList) {
- edmPropertyValueMap = jpaResultParser.parse2EdmPropertyValueMap(jpaEntity, (EdmStructuralType) edmType);
- edmEntityList.add(edmPropertyValueMap);
- }
- result = edmEntityList;
- } else {
-
- Object resultObject = resultList.get(0);
- edmPropertyValueMap = jpaResultParser.parse2EdmPropertyValueMap(resultObject, (EdmStructuralType) edmType);
-
- result = edmPropertyValueMap;
- }
-
- } else if (edmType.getKind().equals(EdmTypeKind.SIMPLE)) {
- result = resultList.get(0);
- }
-
- odataResponse =
- EntityProvider.writeFunctionImport(contentType, resultsView.getFunctionImport(), result, feedProperties);
- odataResponse = ODataResponse.fromResponse(odataResponse).status(HttpStatusCodes.OK).build();
-
- } catch (EdmException e) {
- throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e);
- } catch (EntityProviderException e) {
- throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e);
- } catch (ODataException e) {
- throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.INNER_EXCEPTION, e);
- }
-
- } else {
- throw new ODataNotFoundException(ODataHttpException.COMMON);
- }
-
- return odataResponse;
- }
-
- /* Response for Read Entity Link */
- public static ODataResponse build(final Object jpaEntity, final GetEntityLinkUriInfo resultsView,
- final String contentType, final ODataJPAContext oDataJPAContext) throws ODataNotFoundException,
- ODataJPARuntimeException {
-
- if (jpaEntity == null) {
- throw new ODataNotFoundException(ODataNotFoundException.ENTITY);
- }
- EdmEntityType edmEntityType = null;
- ODataResponse odataResponse = null;
-
- try {
-
- EdmEntitySet entitySet = resultsView.getTargetEntitySet();
- edmEntityType = entitySet.getEntityType();
- Map<String, Object> edmPropertyValueMap = null;
-
- JPAEntityParser jpaResultParser = new JPAEntityParser();
- edmPropertyValueMap = jpaResultParser.parse2EdmPropertyValueMap(jpaEntity, edmEntityType.getKeyProperties());
-
- EntityProviderWriteProperties entryProperties =
- EntityProviderWriteProperties.serviceRoot(oDataJPAContext.getODataContext().getPathInfo().getServiceRoot())
- .build();
-
- ODataResponse response = EntityProvider.writeLink(contentType, entitySet, edmPropertyValueMap, entryProperties);
-
- odataResponse = ODataResponse.fromResponse(response).build();
-
- } catch (ODataException e) {
- throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.INNER_EXCEPTION, e);
-
- }
-
- return odataResponse;
- }
-
- /* Response for Read Entity Links */
- public static <T> ODataResponse build(final List<T> jpaEntities, final GetEntitySetLinksUriInfo resultsView,
- final String contentType, final ODataJPAContext oDataJPAContext) throws ODataJPARuntimeException {
- EdmEntityType edmEntityType = null;
- ODataResponse odataResponse = null;
-
- try {
-
- EdmEntitySet entitySet = resultsView.getTargetEntitySet();
- edmEntityType = entitySet.getEntityType();
- List<EdmProperty> keyProperties = edmEntityType.getKeyProperties();
-
- List<Map<String, Object>> edmEntityList = new ArrayList<Map<String, Object>>();
- Map<String, Object> edmPropertyValueMap = null;
- JPAEntityParser jpaResultParser = new JPAEntityParser();
-
- for (Object jpaEntity : jpaEntities) {
- edmPropertyValueMap = jpaResultParser.parse2EdmPropertyValueMap(jpaEntity, keyProperties);
- edmEntityList.add(edmPropertyValueMap);
- }
-
- Integer count = null;
- if (resultsView.getInlineCount() != null) {
- if ((resultsView.getSkip() != null || resultsView.getTop() != null)) {
- // when $skip and/or $top is present with $inlinecount
- count = getInlineCountForNonFilterQueryLinks(edmEntityList, resultsView);
- } else {
- // In all other cases
- count = resultsView.getInlineCount() == InlineCount.ALLPAGES ? edmEntityList.size() : null;
- }
- }
-
- ODataContext context = oDataJPAContext.getODataContext();
- EntityProviderWriteProperties entryProperties =
- EntityProviderWriteProperties.serviceRoot(context.getPathInfo().getServiceRoot()).inlineCountType(
- resultsView.getInlineCount()).inlineCount(count).build();
-
- odataResponse = EntityProvider.writeLinks(contentType, entitySet, edmEntityList, entryProperties);
-
- odataResponse = ODataResponse.fromResponse(odataResponse).build();
-
- } catch (ODataException e) {
- throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e);
- }
-
- return odataResponse;
-
- }
-
- /*
- * This method handles $inlinecount request. It also modifies the list of results in case of
- * $inlinecount and $top/$skip combinations. Specific to LinksUriInfo.
- *
- * @param edmEntityList
- *
- * @param resultsView
- *
- * @return
- */
- private static Integer getInlineCountForNonFilterQueryLinks(final List<Map<String, Object>> edmEntityList,
- final GetEntitySetLinksUriInfo resultsView) {
- // when $skip and/or $top is present with $inlinecount, first get the total count
- Integer count = null;
- if (resultsView.getInlineCount() == InlineCount.ALLPAGES) {
- if (resultsView.getSkip() != null || resultsView.getTop() != null) {
- count = edmEntityList.size();
- // Now update the list
- if (resultsView.getSkip() != null) {
- // Index checks to avoid IndexOutOfBoundsException
- if (resultsView.getSkip() > edmEntityList.size()) {
- edmEntityList.clear();
- return count;
- }
- edmEntityList.subList(0, resultsView.getSkip()).clear();
- }
- if (resultsView.getTop() != null && resultsView.getTop() >= 0 && resultsView.getTop() < edmEntityList.size()) {
- edmEntityList.subList(0, resultsView.getTop());
- }
- }
- }// Inlinecount of None is handled by default - null
- return count;
- }
-
- /*
- * Method to build the entity provider Property.Callbacks for $expand would
- * be registered here
- */
- private static EntityProviderWriteProperties getEntityProviderProperties(final ODataJPAContext odataJPAContext,
- final GetEntitySetUriInfo resultsView, final List<Map<String, Object>> edmEntityList)
- throws ODataJPARuntimeException {
- ODataEntityProviderPropertiesBuilder entityFeedPropertiesBuilder = null;
-
- Integer count = null;
- if (resultsView.getInlineCount() != null) {
- if ((resultsView.getSkip() != null || resultsView.getTop() != null)) {
- // when $skip and/or $top is present with $inlinecount
- count = getInlineCountForNonFilterQueryEntitySet(edmEntityList, resultsView);
- } else {
- // In all other cases
- count = resultsView.getInlineCount() == InlineCount.ALLPAGES ? edmEntityList.size() : null;
- }
- }
-
- try {
- entityFeedPropertiesBuilder =
- EntityProviderWriteProperties.serviceRoot(odataJPAContext.getODataContext().getPathInfo().getServiceRoot());
- entityFeedPropertiesBuilder.inlineCount(count);
- entityFeedPropertiesBuilder.inlineCountType(resultsView.getInlineCount());
- ExpandSelectTreeNode expandSelectTree =
- UriParser.createExpandSelectTree(resultsView.getSelect(), resultsView.getExpand());
- entityFeedPropertiesBuilder.callbacks(JPAExpandCallBack.getCallbacks(odataJPAContext.getODataContext()
- .getPathInfo().getServiceRoot(), expandSelectTree, resultsView.getExpand()));
- entityFeedPropertiesBuilder.expandSelectTree(expandSelectTree);
-
- } catch (ODataException e) {
- throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.INNER_EXCEPTION, e);
- }
-
- return entityFeedPropertiesBuilder.build();
- }
-
- /*
- * This method handles $inlinecount request. It also modifies the list of results in case of
- * $inlinecount and $top/$skip combinations. Specific to Entity Set.
- */
- private static Integer getInlineCountForNonFilterQueryEntitySet(final List<Map<String, Object>> edmEntityList,
- final GetEntitySetUriInfo resultsView) {
- // when $skip and/or $top is present with $inlinecount, first get the total count
- Integer count = null;
- if (resultsView.getInlineCount() == InlineCount.ALLPAGES) {
- if (resultsView.getSkip() != null || resultsView.getTop() != null) {
- count = edmEntityList.size();
- // Now update the list
- if (resultsView.getSkip() != null) {
- // Index checks to avoid IndexOutOfBoundsException
- if (resultsView.getSkip() > edmEntityList.size()) {
- edmEntityList.clear();
- return count;
- }
- edmEntityList.subList(0, resultsView.getSkip()).clear();
- }
- if (resultsView.getTop() != null && resultsView.getTop() >= 0 && resultsView.getTop() < edmEntityList.size()) {
- edmEntityList.retainAll(edmEntityList.subList(0, resultsView.getTop()));
- }
- }
- }// Inlinecount of None is handled by default - null
- return count;
- }
-
- private static EntityProviderWriteProperties getEntityProviderProperties(final ODataJPAContext odataJPAContext,
- final GetEntityUriInfo resultsView) throws ODataJPARuntimeException {
- ODataEntityProviderPropertiesBuilder entityFeedPropertiesBuilder = null;
- ExpandSelectTreeNode expandSelectTree = null;
- try {
- entityFeedPropertiesBuilder =
- EntityProviderWriteProperties.serviceRoot(odataJPAContext.getODataContext().getPathInfo().getServiceRoot());
- expandSelectTree = UriParser.createExpandSelectTree(resultsView.getSelect(), resultsView.getExpand());
- entityFeedPropertiesBuilder.expandSelectTree(expandSelectTree);
- entityFeedPropertiesBuilder.callbacks(JPAExpandCallBack.getCallbacks(odataJPAContext.getODataContext()
- .getPathInfo().getServiceRoot(), expandSelectTree, resultsView.getExpand()));
- } catch (ODataException e) {
- throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.INNER_EXCEPTION, e);
- }
-
- return entityFeedPropertiesBuilder.build();
- }
-
- private static EntityProviderWriteProperties getEntityProviderPropertiesforPost(
- final ODataJPAContext odataJPAContext, final PostUriInfo resultsView,
- final List<ArrayList<NavigationPropertySegment>> expandList) throws ODataJPARuntimeException {
- ODataEntityProviderPropertiesBuilder entityFeedPropertiesBuilder = null;
- ExpandSelectTreeNode expandSelectTree = null;
- try {
- entityFeedPropertiesBuilder =
- EntityProviderWriteProperties.serviceRoot(odataJPAContext.getODataContext().getPathInfo().getServiceRoot());
- expandSelectTree = UriParser.createExpandSelectTree(null, expandList);
- entityFeedPropertiesBuilder.expandSelectTree(expandSelectTree);
- entityFeedPropertiesBuilder.callbacks(JPAExpandCallBack.getCallbacks(odataJPAContext.getODataContext()
- .getPathInfo().getServiceRoot(), expandSelectTree, expandList));
- } catch (ODataException e) {
- throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.INNER_EXCEPTION, e);
- }
-
- return entityFeedPropertiesBuilder.build();
- }
-
- private static List<ArrayList<NavigationPropertySegment>> getExpandList(
- final Map<EdmNavigationProperty, EdmEntitySet> navPropEntitySetMap) {
- List<ArrayList<NavigationPropertySegment>> expandList = new ArrayList<ArrayList<NavigationPropertySegment>>();
- ArrayList<NavigationPropertySegment> navigationPropertySegmentList = new ArrayList<NavigationPropertySegment>();
- for (Map.Entry<EdmNavigationProperty, EdmEntitySet> entry : navPropEntitySetMap.entrySet()) {
- final EdmNavigationProperty edmNavigationProperty = entry.getKey();
- final EdmEntitySet edmEntitySet = entry.getValue();
- NavigationPropertySegment navigationPropertySegment = new NavigationPropertySegment() {
-
- @Override
- public EdmEntitySet getTargetEntitySet() {
- return edmEntitySet;
- }
-
- @Override
- public EdmNavigationProperty getNavigationProperty() {
- return edmNavigationProperty;
- }
- };
- navigationPropertySegmentList.add(navigationPropertySegment);
- }
- expandList.add(navigationPropertySegmentList);
- return expandList;
- }
-
- private static List<EdmProperty> buildSelectItemList(final List<SelectItem> selectItems, final EdmEntityType entity)
- throws ODataJPARuntimeException {
- boolean flag = false;
- List<EdmProperty> selectPropertyList = new ArrayList<EdmProperty>();
- try {
- for (SelectItem selectItem : selectItems) {
- selectPropertyList.add(selectItem.getProperty());
- }
- for (EdmProperty keyProperty : entity.getKeyProperties()) {
- flag = true;
- for (SelectItem selectedItem : selectItems) {
- if (selectedItem.getProperty().equals(keyProperty)) {
- flag = false;
- break;
- }
- }
- if (flag == true) {
- selectPropertyList.add(keyProperty);
- }
- }
-
- } catch (EdmException e) {
- throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e);
- }
- return selectPropertyList;
- }
-
- private static List<EdmNavigationProperty> constructListofNavProperty(
- final List<ArrayList<NavigationPropertySegment>> expandList) {
- List<EdmNavigationProperty> navigationPropertyList = new ArrayList<EdmNavigationProperty>();
- for (ArrayList<NavigationPropertySegment> navpropSegment : expandList) {
- navigationPropertyList.add(navpropSegment.get(0).getNavigationProperty());
- }
- return navigationPropertyList;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/access/data/JPAEntity.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/access/data/JPAEntity.java b/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/access/data/JPAEntity.java
deleted file mode 100644
index 7c2ad29..0000000
--- a/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/access/data/JPAEntity.java
+++ /dev/null
@@ -1,355 +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.access.data;
-
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.apache.olingo.odata2.api.edm.EdmEntitySet;
-import org.apache.olingo.odata2.api.edm.EdmEntityType;
-import org.apache.olingo.odata2.api.edm.EdmException;
-import org.apache.olingo.odata2.api.edm.EdmNavigationProperty;
-import org.apache.olingo.odata2.api.edm.EdmProperty;
-import org.apache.olingo.odata2.api.edm.EdmStructuralType;
-import org.apache.olingo.odata2.api.edm.EdmTypeKind;
-import org.apache.olingo.odata2.api.edm.EdmTyped;
-import org.apache.olingo.odata2.api.ep.entry.ODataEntry;
-import org.apache.olingo.odata2.api.ep.feed.ODataFeed;
-import org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPARuntimeException;
-import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmMapping;
-
-public class JPAEntity {
-
- private Object jpaEntity = null;
- private EdmEntityType oDataEntityType = null;
- private EdmEntitySet oDataEntitySet = null;
- private Class<?> jpaType = null;
- private HashMap<String, Method> accessModifiersWrite = null;
- private JPAEntityParser jpaEntityParser = null;
- public HashMap<EdmNavigationProperty, EdmEntitySet> inlinedEntities = null;
-
- public JPAEntity(final EdmEntityType oDataEntityType, final EdmEntitySet oDataEntitySet) {
- this.oDataEntityType = oDataEntityType;
- this.oDataEntitySet = oDataEntitySet;
- try {
- JPAEdmMapping mapping = (JPAEdmMapping) oDataEntityType.getMapping();
- jpaType = mapping.getJPAType();
- } catch (EdmException e) {
- return;
- }
- jpaEntityParser = new JPAEntityParser();
- }
-
- public void setAccessModifersWrite(final HashMap<String, Method> accessModifiersWrite) {
- this.accessModifiersWrite = accessModifiersWrite;
- }
-
- public Object getJPAEntity() {
- return jpaEntity;
- }
-
- @SuppressWarnings("unchecked")
- private void write(final Map<String, Object> oDataEntryProperties, final boolean isCreate)
- throws ODataJPARuntimeException {
- try {
-
- EdmStructuralType structuralType = null;
- final List<String> keyNames = oDataEntityType.getKeyPropertyNames();
-
- if (isCreate) {
- jpaEntity = instantiateJPAEntity();
- } else if (jpaEntity == null) {
- throw ODataJPARuntimeException
- .throwException(ODataJPARuntimeException.RESOURCE_NOT_FOUND, null);
- }
-
- if (accessModifiersWrite == null) {
- accessModifiersWrite =
- jpaEntityParser.getAccessModifiers(jpaEntity, oDataEntityType, JPAEntityParser.ACCESS_MODIFIER_SET);
- }
-
- if (oDataEntityType == null || oDataEntryProperties == null) {
- throw ODataJPARuntimeException
- .throwException(ODataJPARuntimeException.GENERAL, null);
- }
-
- final HashMap<String, String> embeddableKeys =
- jpaEntityParser.getJPAEmbeddableKeyMap(jpaEntity.getClass().getName());
- Set<String> propertyNames = null;
- if (embeddableKeys != null) {
- setEmbeddableKeyProperty(embeddableKeys, oDataEntityType.getKeyProperties(), oDataEntryProperties, jpaEntity);
- propertyNames = new HashSet<String>();
- propertyNames.addAll(oDataEntryProperties.keySet());
- for (String propertyName : oDataEntityType.getKeyPropertyNames()) {
- propertyNames.remove(propertyName);
- }
- } else {
- propertyNames = oDataEntryProperties.keySet();
- }
-
- for (String propertyName : propertyNames) {
- EdmTyped edmTyped = (EdmTyped) oDataEntityType.getProperty(propertyName);
-
- Method accessModifier = null;
-
- switch (edmTyped.getType().getKind()) {
- case SIMPLE:
- if (isCreate == false) {
- if (keyNames.contains(edmTyped.getName())) {
- continue;
- }
- }
- accessModifier = accessModifiersWrite.get(propertyName);
- setProperty(accessModifier, jpaEntity, oDataEntryProperties.get(propertyName));
- break;
- case COMPLEX:
- structuralType = (EdmStructuralType) edmTyped.getType();
- accessModifier = accessModifiersWrite.get(propertyName);
- setComplexProperty(accessModifier, jpaEntity,
- structuralType,
- (HashMap<String, Object>) oDataEntryProperties.get(propertyName));
- break;
- case NAVIGATION:
- case ENTITY:
- structuralType = (EdmStructuralType) edmTyped.getType();
- EdmNavigationProperty navProperty = (EdmNavigationProperty) edmTyped;
- accessModifier =
- jpaEntityParser.getAccessModifier(jpaEntity, navProperty,
- JPAEntityParser.ACCESS_MODIFIER_SET);
- EdmEntitySet edmRelatedEntitySet = oDataEntitySet.getRelatedEntitySet(navProperty);
- List<ODataEntry> relatedEntries = (List<ODataEntry>) oDataEntryProperties.get(propertyName);
- Collection<Object> relatedJPAEntites = instantiateRelatedJPAEntities(jpaEntity, navProperty);
- JPAEntity relatedEntity = new JPAEntity((EdmEntityType) structuralType, edmRelatedEntitySet);
- for (ODataEntry oDataEntry : relatedEntries) {
- relatedEntity.create(oDataEntry);
- relatedJPAEntites.add(relatedEntity.getJPAEntity());
- }
-
- switch (navProperty.getMultiplicity()) {
- case MANY:
- accessModifier.invoke(jpaEntity, relatedJPAEntites);
- break;
- case ONE:
- case ZERO_TO_ONE:
- accessModifier.invoke(jpaEntity, relatedJPAEntites.iterator().next());
- break;
- }
-
- if (inlinedEntities == null) {
- inlinedEntities = new HashMap<EdmNavigationProperty, EdmEntitySet>();
- }
-
- inlinedEntities.put((EdmNavigationProperty) edmTyped, edmRelatedEntitySet);
- default:
- continue;
- }
- }
- } catch (Exception e) {
- throw ODataJPARuntimeException
- .throwException(ODataJPARuntimeException.GENERAL
- .addContent(e.getMessage()), e);
- }
- }
-
- @SuppressWarnings("unchecked")
- private Collection<Object> instantiateRelatedJPAEntities(final Object jpaEntity,
- final EdmNavigationProperty navProperty)
- throws InstantiationException,
- IllegalAccessException, EdmException, ODataJPARuntimeException, IllegalArgumentException,
- InvocationTargetException {
- Method accessModifier =
- jpaEntityParser.getAccessModifier(jpaEntity, navProperty, JPAEntityParser.ACCESS_MODIFIER_GET);
- Collection<Object> relatedJPAEntities = (Collection<Object>) accessModifier.invoke(jpaEntity);
- if (relatedJPAEntities == null) {
- relatedJPAEntities = new ArrayList<Object>();
- }
- return relatedJPAEntities;
- }
-
- public void create(final ODataEntry oDataEntry) throws ODataJPARuntimeException {
- if (oDataEntry == null) {
- throw ODataJPARuntimeException
- .throwException(ODataJPARuntimeException.GENERAL, null);
- }
- Map<String, Object> oDataEntryProperties = oDataEntry.getProperties();
- if (oDataEntry.containsInlineEntry()) {
- normalizeInlineEntries(oDataEntryProperties);
- }
- write(oDataEntryProperties, true);
- }
-
- public void create(final Map<String, Object> oDataEntryProperties) throws ODataJPARuntimeException {
- normalizeInlineEntries(oDataEntryProperties);
- write(oDataEntryProperties, true);
- }
-
- public void update(final ODataEntry oDataEntry) throws ODataJPARuntimeException {
- if (oDataEntry == null) {
- throw ODataJPARuntimeException
- .throwException(ODataJPARuntimeException.GENERAL, null);
- }
- Map<String, Object> oDataEntryProperties = oDataEntry.getProperties();
- write(oDataEntryProperties, false);
- }
-
- public void update(final Map<String, Object> oDataEntryProperties) throws ODataJPARuntimeException {
- write(oDataEntryProperties, false);
- }
-
- public HashMap<EdmNavigationProperty, EdmEntitySet> getInlineJPAEntities() {
- return inlinedEntities;
- }
-
- public void setJPAEntity(final Object jpaEntity) {
- this.jpaEntity = jpaEntity;
- }
-
- @SuppressWarnings("unchecked")
- protected void setComplexProperty(Method accessModifier, final Object jpaEntity,
- final EdmStructuralType edmComplexType, final HashMap<String, Object> propertyValue)
- throws EdmException, IllegalAccessException, IllegalArgumentException, InvocationTargetException,
- InstantiationException, ODataJPARuntimeException {
-
- JPAEdmMapping mapping = (JPAEdmMapping) edmComplexType.getMapping();
- Object embeddableObject = mapping.getJPAType().newInstance();
- accessModifier.invoke(jpaEntity, embeddableObject);
-
- HashMap<String, Method> accessModifiers =
- jpaEntityParser.getAccessModifiers(embeddableObject, edmComplexType, JPAEntityParser.ACCESS_MODIFIER_SET);
-
- for (String edmPropertyName : edmComplexType.getPropertyNames()) {
- EdmTyped edmTyped = (EdmTyped) edmComplexType.getProperty(edmPropertyName);
- accessModifier = accessModifiers.get(edmPropertyName);
- if (edmTyped.getType().getKind().toString().equals(EdmTypeKind.COMPLEX.toString())) {
- EdmStructuralType structualType = (EdmStructuralType) edmTyped.getType();
- setComplexProperty(accessModifier, embeddableObject, structualType, (HashMap<String, Object>) propertyValue
- .get(edmPropertyName));
- } else {
- setProperty(accessModifier, embeddableObject, propertyValue.get(edmPropertyName));
- }
- }
- }
-
- protected void setProperty(final Method method, final Object entity, final Object entityPropertyValue) throws
- IllegalAccessException, IllegalArgumentException, InvocationTargetException {
- if (entityPropertyValue != null) {
- Class<?> parameterType = method.getParameterTypes()[0];
- if (parameterType.equals(char[].class)) {
- char[] characters = ((String) entityPropertyValue).toCharArray();
- method.invoke(entity, characters);
- } else if (parameterType.equals(char.class)) {
- char c = ((String) entityPropertyValue).charAt(0);
- method.invoke(entity, c);
- } else if (parameterType.equals(Character[].class)) {
- Character[] characters = JPAEntityParser.toCharacterArray((String) entityPropertyValue);
- method.invoke(entity, (Object) characters);
- } else if (parameterType.equals(Character.class)) {
- Character c = Character.valueOf(((String) entityPropertyValue).charAt(0));
- method.invoke(entity, c);
- } else {
- method.invoke(entity, entityPropertyValue);
- }
- }
- }
-
- protected void setEmbeddableKeyProperty(final HashMap<String, String> embeddableKeys,
- final List<EdmProperty> oDataEntryKeyProperties,
- final Map<String, Object> oDataEntryProperties, final Object entity)
- throws ODataJPARuntimeException, EdmException, IllegalAccessException, IllegalArgumentException,
- InvocationTargetException, InstantiationException {
-
- HashMap<String, Object> embeddableObjMap = new HashMap<String, Object>();
- List<EdmProperty> leftODataEntryKeyProperties = new ArrayList<EdmProperty>();
- HashMap<String, String> leftEmbeddableKeys = new HashMap<String, String>();
-
- for (EdmProperty edmProperty : oDataEntryKeyProperties) {
- if (oDataEntryProperties.containsKey(edmProperty.getName()) == false) {
- continue;
- }
-
- String edmPropertyName = edmProperty.getName();
- String embeddableKeyNameComposite = embeddableKeys.get(edmPropertyName);
- String embeddableKeyNameSplit[] = embeddableKeyNameComposite.split("\\.");
- String methodPartName = null;
- Method method = null;
- Object embeddableObj = null;
-
- if (embeddableObjMap.containsKey(embeddableKeyNameSplit[0]) == false) {
- methodPartName = embeddableKeyNameSplit[0];
- method = jpaEntityParser.getAccessModifierSet(entity, methodPartName);
- embeddableObj = method.getParameterTypes()[0].newInstance();
- method.invoke(entity, embeddableObj);
- embeddableObjMap.put(embeddableKeyNameSplit[0], embeddableObj);
- } else {
- embeddableObj = embeddableObjMap.get(embeddableKeyNameSplit[0]);
- }
-
- if (embeddableKeyNameSplit.length == 2) {
- methodPartName = embeddableKeyNameSplit[1];
- method = jpaEntityParser.getAccessModifierSet(embeddableObj, methodPartName);
- Object simpleObj = oDataEntryProperties.get(edmProperty.getName());
- method.invoke(embeddableObj, simpleObj);
- } else if (embeddableKeyNameSplit.length > 2) { // Deeply nested
- leftODataEntryKeyProperties.add(edmProperty);
- leftEmbeddableKeys
- .put(edmPropertyName, embeddableKeyNameComposite.split(embeddableKeyNameSplit[0] + ".", 2)[1]);
- setEmbeddableKeyProperty(leftEmbeddableKeys, leftODataEntryKeyProperties, oDataEntryProperties, embeddableObj);
- }
-
- }
- }
-
- protected Object instantiateJPAEntity() throws InstantiationException, IllegalAccessException {
- if (jpaType == null) {
- throw new InstantiationException();
- }
-
- return jpaType.newInstance();
- }
-
- private void normalizeInlineEntries(final Map<String, Object> oDataEntryProperties) throws ODataJPARuntimeException {
- List<ODataEntry> entries = null;
- try {
- for (String navigationPropertyName : oDataEntityType.getNavigationPropertyNames()) {
- Object inline = oDataEntryProperties.get(navigationPropertyName);
- if (inline instanceof ODataFeed) {
- entries = ((ODataFeed) inline).getEntries();
- } else if (inline instanceof ODataEntry) {
- entries = new ArrayList<ODataEntry>();
- entries.add((ODataEntry) inline);
- }
- if (entries != null) {
- oDataEntryProperties.put(navigationPropertyName, entries);
- entries = null;
- }
- }
- } catch (EdmException e) {
- throw ODataJPARuntimeException
- .throwException(ODataJPARuntimeException.GENERAL
- .addContent(e.getMessage()), e);
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/access/data/JPAEntityParser.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/access/data/JPAEntityParser.java b/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/access/data/JPAEntityParser.java
deleted file mode 100644
index 756e1ca..0000000
--- a/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/access/data/JPAEntityParser.java
+++ /dev/null
@@ -1,453 +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.access.data;
-
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.util.HashMap;
-import java.util.List;
-
-import org.apache.olingo.odata2.api.edm.EdmAssociationEnd;
-import org.apache.olingo.odata2.api.edm.EdmException;
-import org.apache.olingo.odata2.api.edm.EdmMapping;
-import org.apache.olingo.odata2.api.edm.EdmNavigationProperty;
-import org.apache.olingo.odata2.api.edm.EdmProperty;
-import org.apache.olingo.odata2.api.edm.EdmStructuralType;
-import org.apache.olingo.odata2.api.edm.EdmTypeKind;
-import org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPARuntimeException;
-import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmMapping;
-
-public final class JPAEntityParser {
-
- /*
- * List of buffers used by the Parser
- */
- private static short MAX_SIZE = 10;
- public static final String ACCESS_MODIFIER_GET = "get";
- public static final String ACCESS_MODIFIER_SET = "set";
-
- private HashMap<String, HashMap<String, Method>> jpaEntityAccessMap = null;
- private HashMap<String, HashMap<String, String>> jpaEmbeddableKeyMap = null;
-
- public JPAEntityParser() {
- jpaEntityAccessMap = new HashMap<String, HashMap<String, Method>>(
- MAX_SIZE);
- jpaEmbeddableKeyMap = new HashMap<String, HashMap<String, String>>();
- };
-
- public HashMap<String, Method> getJPAEntityAccessMap(final String jpaEntityName) {
- return jpaEntityAccessMap.get(jpaEntityName);
- }
-
- public HashMap<String, String> getJPAEmbeddableKeyMap(final String jpaEntityName) {
- return jpaEmbeddableKeyMap.get(jpaEntityName);
- }
-
- /**
- * The method returns a Hash Map of Properties and values for selected
- * properties of an EdmEntity Type
- *
- * @param jpaEntity
- * @param selectedItems
- * @return a Hash Map of Properties and values for given selected properties
- * of an EdmEntity Type
- * @throws ODataJPARuntimeException
- */
-
- public final HashMap<String, Object> parse2EdmPropertyValueMap(
- final Object jpaEntity, final List<EdmProperty> selectPropertyList)
- throws ODataJPARuntimeException {
- HashMap<String, Object> edmEntity = new HashMap<String, Object>();
- String methodName = null;
- Method method = null;
- for (int i = 0; i < selectPropertyList.size(); i++) {
- String key = null;
- Object propertyValue = null;
- EdmProperty property = null;
- property = selectPropertyList.get(i);
-
- try {
- methodName = getAccessModifierName(property.getName(),
- property.getMapping(), ACCESS_MODIFIER_GET);
- String[] nameParts = methodName.split("\\.");
- if (nameParts.length > 1) {
- Object propertyVal = new Object();
- propertyVal = jpaEntity;
- for (String namePart : nameParts) {
- method = propertyVal.getClass().getMethod(
- namePart, (Class<?>[]) null);
- method.setAccessible(true);
- propertyVal = getProperty(method, propertyVal);
- }
- edmEntity.put(property.getName(), propertyVal);
- } else {
- method = jpaEntity.getClass().getMethod(methodName,
- (Class<?>[]) null);
- method.setAccessible(true);
- propertyValue = getProperty(method, jpaEntity);
- key = property.getName();
- if (property.getType().getKind()
- .equals(EdmTypeKind.COMPLEX)) {
- try {
- propertyValue = parse2EdmPropertyValueMap(
- propertyValue,
- (EdmStructuralType) property.getType());
- } catch (ODataJPARuntimeException e) {
- throw e;
- }
- }
- edmEntity.put(key, propertyValue);
- }
- } catch (EdmException e) {
- throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.INNER_EXCEPTION, e);
- } catch (SecurityException e) {
- throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.INNER_EXCEPTION, e);
- } catch (NoSuchMethodException e) {
- throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.INNER_EXCEPTION, e);
- } catch (IllegalArgumentException e) {
- throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.INNER_EXCEPTION, e);
- }
- }
-
- return edmEntity;
- }
-
- /**
- * The method returns a Hash Map of Properties and values for an EdmEntity
- * Type The method uses reflection on object jpaEntity to get the list of
- * accessModifier method. Then uses the accessModifier method to extract the value from
- * JPAEntity.
- *
- * @param jpaEntity
- * @param structuralType
- * @return a Hash Map of Properties and values for given EdmEntity Type
- * @throws ODataJPARuntimeException
- */
- public final HashMap<String, Object> parse2EdmPropertyValueMap(
- final Object jpaEntity, final EdmStructuralType structuralType)
- throws ODataJPARuntimeException {
-
- if (jpaEntity == null || structuralType == null) {
- return null;
- }
-
- String jpaEntityAccessKey = jpaEntity.getClass().getName();
-
- if (!jpaEntityAccessMap.containsKey(jpaEntityAccessKey)) {
- jpaEntityAccessMap.put(jpaEntityAccessKey,
- getAccessModifiers(jpaEntity, structuralType, ACCESS_MODIFIER_GET));
- }
-
- HashMap<String, Object> edmEntity = new HashMap<String, Object>();
- HashMap<String, Method> getters = jpaEntityAccessMap
- .get(jpaEntityAccessKey);
- HashMap<String, String> embeddableKeys = jpaEmbeddableKeyMap
- .get(jpaEntityAccessKey);
-
- try {
- for (String key : getters.keySet()) {
-
- EdmProperty property = (EdmProperty) structuralType
- .getProperty(key);
-
- Method method = getters.get(key);
- Object propertyValue = null;
-
- if (method != null) {
- getters.get(key).setAccessible(true);
- propertyValue = getProperty(method, jpaEntity);
- }
- if (property.getType().getKind().equals(EdmTypeKind.COMPLEX)) {
- propertyValue = parse2EdmPropertyValueMap(propertyValue,
- (EdmStructuralType) property.getType());
- }
-
- edmEntity.put(key, propertyValue);
-
- }
-
- if (embeddableKeys != null) {
- for (String key : embeddableKeys.keySet()) {
- String name = embeddableKeys.get(key);
- String[] nameParts = name.split("\\.");
- Object propertyValue = jpaEntity;
- Method method = null;
- for (String namePart : nameParts) {
- method = propertyValue.getClass().getMethod(
- namePart, (Class<?>[]) null);
- method.setAccessible(true);
- propertyValue = getProperty(method, propertyValue);
- }
- edmEntity.put(key, propertyValue);
- }
- }
- } catch (EdmException e) {
- throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.INNER_EXCEPTION, e);
- } catch (SecurityException e) {
- throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.INNER_EXCEPTION, e);
- } catch (NoSuchMethodException e) {
- throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.INNER_EXCEPTION, e);
- } catch (IllegalArgumentException e) {
- throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.INNER_EXCEPTION, e);
- }
- return edmEntity;
- }
-
- // This method appends the associated entities as a java list to an expanded
- // map of a source entity
- public final HashMap<String, Object> parse2EdmNavigationValueMap(
- final Object jpaEntity, final List<EdmNavigationProperty> navigationPropertyList)
- throws ODataJPARuntimeException {
- Object result = null;
- String methodName = null;
- HashMap<String, Object> navigationMap = new HashMap<String, Object>();
- if (navigationPropertyList != null
- && navigationPropertyList.size() != 0) {
-
- try {
- for (EdmNavigationProperty navigationProperty : navigationPropertyList) {
- methodName = getAccessModifierName(navigationProperty.getName(),
- navigationProperty.getMapping(), ACCESS_MODIFIER_GET);
- Method getterMethod = jpaEntity.getClass()
- .getDeclaredMethod(methodName, (Class<?>[]) null);
- getterMethod.setAccessible(true);
- result = getProperty(getterMethod, jpaEntity);
- navigationMap.put(navigationProperty.getName(), result);
- }
- } catch (IllegalArgumentException e) {
- throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.INNER_EXCEPTION, e);
- } catch (EdmException e) {
- throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.INNER_EXCEPTION, e);
- } catch (SecurityException e) {
- throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.INNER_EXCEPTION, e);
- } catch (NoSuchMethodException e) {
- throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.INNER_EXCEPTION, e);
- }
- }
- return navigationMap;
- }
-
- public Method getAccessModifierSet(final Object jpaEntity, final String methodName) throws ODataJPARuntimeException {
- Class<?> jpaType = jpaEntity.getClass();
- String methodNameGet = ACCESS_MODIFIER_GET + methodName.substring(3);
- Method method = null;
-
- try {
- method = jpaType.getMethod(methodNameGet, (Class<?>[]) null);
- Class<?> parameterType = method.getReturnType();
- method = jpaType.getMethod(methodName, new Class<?>[] { parameterType });
- } catch (NoSuchMethodException e) {
- throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.INNER_EXCEPTION, e);
- } catch (SecurityException e) {
- throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.INNER_EXCEPTION, e);
- }
-
- return method;
- }
-
- public HashMap<String, Method> getAccessModifiers(final Object jpaEntity,
- final EdmStructuralType structuralType, final String accessModifier) throws ODataJPARuntimeException {
-
- HashMap<String, Method> accessModifierMap = new HashMap<String, Method>();
- HashMap<String, String> embeddableKey = new HashMap<String, String>();
- try {
- for (String propertyName : structuralType.getPropertyNames()) {
-
- EdmProperty property = (EdmProperty) structuralType
- .getProperty(propertyName);
-
- String name = getAccessModifierName(property.getName(),
- property.getMapping(), accessModifier);
- String[] nameParts = name.split("\\.");
- if (nameParts.length > 1) {
- embeddableKey.put(propertyName, name);
- } else {
- if (accessModifier.equals(ACCESS_MODIFIER_SET)) {
- JPAEdmMapping jpaEdmMapping = (JPAEdmMapping) property.getMapping();
- accessModifierMap.put(
- propertyName,
- jpaEntity.getClass().getMethod(name, new Class<?>[] { jpaEdmMapping.getJPAType() }));
- } else {
- accessModifierMap.put(
- propertyName,
- jpaEntity.getClass().getMethod(name,
- (Class<?>[]) null));
- }
- }
- }
- } catch (NoSuchMethodException e) {
- throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.INNER_EXCEPTION, e);
- } catch (SecurityException e) {
- throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.INNER_EXCEPTION, e);
- } catch (EdmException e) {
- throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.INNER_EXCEPTION, e);
- }
-
- if (!embeddableKey.isEmpty()) {
- jpaEmbeddableKeyMap.put(jpaEntity.getClass().getName(),
- embeddableKey);
- }
- return accessModifierMap;
- }
-
- public static Object getProperty(final Method method, final Object entity) throws ODataJPARuntimeException {
- Object propertyValue = null;
- try {
- Class<?> returnType = method.getReturnType();
-
- if (returnType.equals(char[].class)) {
- char[] ch = (char[]) method.invoke(entity);
- if (ch != null) {
- propertyValue = (String) String.valueOf((char[]) method.invoke(entity));
- }
- } else if (returnType.equals(Character[].class)) {
- propertyValue = (String) toString((Character[]) method.invoke(entity));
- } else if (returnType.equals(char.class)) {
- char c = (Character) method.invoke(entity);
- if (c != '\u0000') {
- propertyValue = (String) String.valueOf(c);
- }
- } else if (returnType.equals(Character.class)) {
- Character c = (Character) method.invoke(entity);
- if (c != null) {
- propertyValue = toString(new Character[] { c });
- }
- } else {
- propertyValue = method.invoke(entity);
- }
- } catch (IllegalAccessException e) {
- throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.INNER_EXCEPTION, e);
- } catch (IllegalArgumentException e) {
- throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.INNER_EXCEPTION, e);
- } catch (InvocationTargetException e) {
- throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.INNER_EXCEPTION, e);
- }
- return propertyValue;
- }
-
- public static String toString(final Character[] input) {
- if (input == null) {
- return null;
- }
-
- StringBuilder builder = new StringBuilder();
- for (Character element : input) {
- if (element == null) {
- continue;
- }
- builder.append(element.charValue());
- }
- return builder.toString();
-
- }
-
- public static Character[] toCharacterArray(final String input) {
- if (input == null) {
- return null;
- }
-
- Character[] characters = new Character[input.length()];
- char[] chars = ((String) input).toCharArray();
- for (int i = 0; i < input.length(); i++) {
- characters[i] = new Character(chars[i]);
- }
-
- return characters;
- }
-
- public static String getAccessModifierName(final String propertyName, final EdmMapping mapping,
- final String accessModifier)
- throws ODataJPARuntimeException {
- String name = null;
- StringBuilder builder = new StringBuilder();
- String[] nameParts = {};
- if (mapping == null || mapping.getInternalName() == null) {
- name = propertyName;
- } else {
- name = mapping.getInternalName();
- }
- if (name != null) {
- nameParts = name.split("\\.");
- }
- if (nameParts.length == 1) {
- if (name != null) {
- char c = Character.toUpperCase(name.charAt(0));
-
- builder.append(accessModifier).append(c).append(name.substring(1))
- .toString();
- }
- } else if (nameParts.length > 1) {
-
- for (int i = 0; i < nameParts.length; i++) {
- name = nameParts[i];
- char c = Character.toUpperCase(name.charAt(0));
- if (i == 0) {
- builder.append(accessModifier).append(c).append(name.substring(1));
- } else {
- builder.append(".").append(accessModifier).append(c)
- .append(name.substring(1));
- }
- }
- } else {
- return null;
- }
-
- if (builder.length() > 0) {
- return builder.toString();
- } else {
- return null;
- }
-
- }
-
- public Method getAccessModifier(final Object jpaEntity, final EdmNavigationProperty navigationProperty,
- final String accessModifier)
- throws ODataJPARuntimeException {
-
- try {
-
- JPAEdmMapping navPropMapping = (JPAEdmMapping) navigationProperty.getMapping();
- String name = getAccessModifierName(navigationProperty.getName(), (EdmMapping) navPropMapping, accessModifier);
-
- Class<?>[] params = null;
- if (accessModifier.equals(ACCESS_MODIFIER_SET)) {
- EdmAssociationEnd end = navigationProperty.getRelationship().getEnd(navigationProperty.getToRole());
- switch (end.getMultiplicity()) {
- case MANY:
- params = new Class<?>[] { navPropMapping.getJPAType() };
- break;
- case ONE:
- params = new Class<?>[] { ((JPAEdmMapping) end.getEntityType().getMapping()).getJPAType() };
- default:
- break;
- }
- }
- return jpaEntity.getClass().getMethod(name,
- params);
-
- } catch (NoSuchMethodException e) {
- throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.INNER_EXCEPTION, e);
- } catch (SecurityException e) {
- throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.INNER_EXCEPTION, e);
- } catch (EdmException e) {
- throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.INNER_EXCEPTION, e);
- }
-
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/access/data/JPAExpandCallBack.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/access/data/JPAExpandCallBack.java b/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/access/data/JPAExpandCallBack.java
deleted file mode 100644
index 78a9ea5..0000000
--- a/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/access/data/JPAExpandCallBack.java
+++ /dev/null
@@ -1,180 +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.access.data;
-
-import java.net.URI;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.olingo.odata2.api.ODataCallback;
-import org.apache.olingo.odata2.api.edm.EdmEntitySet;
-import org.apache.olingo.odata2.api.edm.EdmEntityType;
-import org.apache.olingo.odata2.api.edm.EdmException;
-import org.apache.olingo.odata2.api.edm.EdmNavigationProperty;
-import org.apache.olingo.odata2.api.ep.EntityProviderWriteProperties;
-import org.apache.olingo.odata2.api.ep.EntityProviderWriteProperties.ODataEntityProviderPropertiesBuilder;
-import org.apache.olingo.odata2.api.ep.callback.OnWriteEntryContent;
-import org.apache.olingo.odata2.api.ep.callback.OnWriteFeedContent;
-import org.apache.olingo.odata2.api.ep.callback.WriteCallbackContext;
-import org.apache.olingo.odata2.api.ep.callback.WriteEntryCallbackContext;
-import org.apache.olingo.odata2.api.ep.callback.WriteEntryCallbackResult;
-import org.apache.olingo.odata2.api.ep.callback.WriteFeedCallbackContext;
-import org.apache.olingo.odata2.api.ep.callback.WriteFeedCallbackResult;
-import org.apache.olingo.odata2.api.uri.ExpandSelectTreeNode;
-import org.apache.olingo.odata2.api.uri.NavigationPropertySegment;
-import org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPARuntimeException;
-
-public class JPAExpandCallBack implements OnWriteFeedContent, OnWriteEntryContent, ODataCallback {
-
- private URI baseUri;
- private List<ArrayList<NavigationPropertySegment>> expandList;
- private EdmEntitySet nextEntitySet = null;
-
- private JPAExpandCallBack(final URI baseUri, final List<ArrayList<NavigationPropertySegment>> expandList) {
- super();
- this.baseUri = baseUri;
- this.expandList = expandList;
- }
-
- @Override
- public WriteEntryCallbackResult retrieveEntryResult(final WriteEntryCallbackContext context) {
- WriteEntryCallbackResult result = new WriteEntryCallbackResult();
- Map<String, Object> entry = context.getEntryData();
- Map<String, Object> edmPropertyValueMap = null;
- List<EdmNavigationProperty> currentNavPropertyList = null;
- Map<String, ExpandSelectTreeNode> navigationLinks = null;
- JPAEntityParser jpaResultParser = new JPAEntityParser();
- EdmNavigationProperty currentNavigationProperty = context.getNavigationProperty();
- try {
- Object inlinedEntry = entry.get(currentNavigationProperty.getName());
- if (nextEntitySet == null) {
- nextEntitySet = context.getSourceEntitySet().getRelatedEntitySet(currentNavigationProperty);
- }
- edmPropertyValueMap = jpaResultParser.parse2EdmPropertyValueMap(inlinedEntry, nextEntitySet.getEntityType());
- result.setEntryData(edmPropertyValueMap);
- navigationLinks = context.getCurrentExpandSelectTreeNode().getLinks();
- if (navigationLinks.size() > 0) {
- currentNavPropertyList = new ArrayList<EdmNavigationProperty>();
- EdmNavigationProperty nextNavProperty =
- getNextNavigationProperty(context.getSourceEntitySet().getEntityType(), context.getNavigationProperty());
- if (nextNavProperty != null) {
- currentNavPropertyList.add(nextNavProperty);
- }
- HashMap<String, Object> navigationMap =
- jpaResultParser.parse2EdmNavigationValueMap(inlinedEntry, currentNavPropertyList);
- edmPropertyValueMap.putAll(navigationMap);
- result.setEntryData(edmPropertyValueMap);
- }
- result.setInlineProperties(getInlineEntityProviderProperties(context));
- } catch (EdmException e) {
-
- } catch (ODataJPARuntimeException e) {
-
- }
-
- return result;
- }
-
- @Override
- public WriteFeedCallbackResult retrieveFeedResult(final WriteFeedCallbackContext context) {
- WriteFeedCallbackResult result = new WriteFeedCallbackResult();
- HashMap<String, Object> inlinedEntry = (HashMap<String, Object>) context.getEntryData();
- List<Map<String, Object>> edmEntityList = new ArrayList<Map<String, Object>>();
- Map<String, Object> edmPropertyValueMap = null;
- JPAEntityParser jpaResultParser = new JPAEntityParser();
- List<EdmNavigationProperty> currentNavPropertyList = null;
- EdmNavigationProperty currentNavigationProperty = context.getNavigationProperty();
- try {
- @SuppressWarnings({ "unchecked" })
- Collection<Object> listOfItems = (Collection<Object>) inlinedEntry.get(context.getNavigationProperty().getName());
- if (nextEntitySet == null) {
- nextEntitySet = context.getSourceEntitySet().getRelatedEntitySet(currentNavigationProperty);
- }
- for (Object object : listOfItems) {
- edmPropertyValueMap = jpaResultParser.parse2EdmPropertyValueMap(object, nextEntitySet.getEntityType());
- edmEntityList.add(edmPropertyValueMap);
- }
- result.setFeedData(edmEntityList);
- if (context.getCurrentExpandSelectTreeNode().getLinks().size() > 0) {
- currentNavPropertyList = new ArrayList<EdmNavigationProperty>();
- EdmNavigationProperty nextNavProperty =
- getNextNavigationProperty(context.getSourceEntitySet().getEntityType(), context.getNavigationProperty());
- if (nextNavProperty != null) {
- currentNavPropertyList.add(nextNavProperty);
- }
- int count = 0;
- for (Object object : listOfItems) {
- HashMap<String, Object> navigationMap =
- jpaResultParser.parse2EdmNavigationValueMap(object, currentNavPropertyList);
- edmEntityList.get(count).putAll(navigationMap);
- count++;
- }
- result.setFeedData(edmEntityList);
- }
- result.setInlineProperties(getInlineEntityProviderProperties(context));
- } catch (EdmException e) {
-
- } catch (ODataJPARuntimeException e) {
-
- }
- return result;
- }
-
- private EdmNavigationProperty getNextNavigationProperty(final EdmEntityType sourceEntityType,
- final EdmNavigationProperty navigationProperty) throws EdmException {
- for (ArrayList<NavigationPropertySegment> navPropSegments : expandList) {
- int size = navPropSegments.size();
- for (int i = 0; i < size; i++) {
- EdmNavigationProperty navProperty = navPropSegments.get(i).getNavigationProperty();
- if (navProperty.getFromRole().equalsIgnoreCase(sourceEntityType.getName())
- && navProperty.getName().equals(navigationProperty.getName())) {
- if (i < size - 1) {
- return navPropSegments.get(i + 1).getNavigationProperty();
- }
- }
- }
- }
- return null;
- }
-
- public static <T> Map<String, ODataCallback> getCallbacks(final URI baseUri,
- final ExpandSelectTreeNode expandSelectTreeNode, final List<ArrayList<NavigationPropertySegment>> expandList)
- throws EdmException {
- Map<String, ODataCallback> callbacks = new HashMap<String, ODataCallback>();
-
- for (String navigationPropertyName : expandSelectTreeNode.getLinks().keySet()) {
- callbacks.put(navigationPropertyName, new JPAExpandCallBack(baseUri, expandList));
- }
-
- return callbacks;
-
- }
-
- private EntityProviderWriteProperties getInlineEntityProviderProperties(final WriteCallbackContext context)
- throws EdmException {
- ODataEntityProviderPropertiesBuilder propertiesBuilder = EntityProviderWriteProperties.serviceRoot(baseUri);
- propertiesBuilder.callbacks(getCallbacks(baseUri, context.getCurrentExpandSelectTreeNode(), expandList));
- propertiesBuilder.expandSelectTree(context.getCurrentExpandSelectTreeNode());
- return propertiesBuilder.build();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/access/data/JPAFunctionContext.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/access/data/JPAFunctionContext.java b/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/access/data/JPAFunctionContext.java
deleted file mode 100644
index 8f79c92..0000000
--- a/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/access/data/JPAFunctionContext.java
+++ /dev/null
@@ -1,170 +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.access.data;
-
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.lang.reflect.Type;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.olingo.odata2.api.edm.EdmException;
-import org.apache.olingo.odata2.api.edm.EdmFacets;
-import org.apache.olingo.odata2.api.edm.EdmFunctionImport;
-import org.apache.olingo.odata2.api.edm.EdmLiteral;
-import org.apache.olingo.odata2.api.edm.EdmLiteralKind;
-import org.apache.olingo.odata2.api.edm.EdmMapping;
-import org.apache.olingo.odata2.api.edm.EdmParameter;
-import org.apache.olingo.odata2.api.edm.EdmSimpleType;
-import org.apache.olingo.odata2.api.edm.EdmSimpleTypeException;
-import org.apache.olingo.odata2.api.uri.info.GetFunctionImportUriInfo;
-import org.apache.olingo.odata2.processor.api.jpa.access.JPAFunction;
-import org.apache.olingo.odata2.processor.api.jpa.access.JPAMethodContext;
-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.JPAEdmMapping;
-
-public class JPAFunctionContext extends JPAMethodContext {
-
- public class JPAFunctionContextBuilder extends JPAMethodContextBuilder {
-
- protected GetFunctionImportUriInfo functiontView;
- private EdmFunctionImport functionImport;
- private EdmMapping mapping;
-
- @Override
- public JPAMethodContext build() throws ODataJPAModelException, ODataJPARuntimeException {
- if (functiontView != null) {
-
- functionImport = functiontView.getFunctionImport();
- try {
- mapping = functionImport.getMapping();
-
- List<JPAFunction> jpaFunctionList = new ArrayList<JPAFunction>();
- jpaFunctionList.add(generateJPAFunction());
- setJpaFunction(jpaFunctionList);
- setEnclosingObject(generateEnclosingObject());
- } catch (EdmException e) {
- throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e);
- } catch (InstantiationException e) {
- throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e);
- } catch (IllegalAccessException e) {
- throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e);
- } catch (IllegalArgumentException e) {
- throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e);
- } catch (InvocationTargetException e) {
- throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e);
- } catch (NoSuchMethodException e) {
- throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e);
- } catch (SecurityException e) {
- throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e);
- }
- }
-
- return JPAFunctionContext.this;
- }
-
- private JPAFunction generateJPAFunction() throws EdmException, NoSuchMethodException, SecurityException,
- ODataJPAModelException, ODataJPARuntimeException {
-
- Class<?>[] parameterTypes = getParameterTypes();
- Method method = getMethod(parameterTypes);
- Type returnType = getReturnType();
- Object[] args = getAruguments();
-
- JPAFunction jpafunction = new JPAFunction(method, parameterTypes, returnType, args);
-
- return jpafunction;
- }
-
- private Object[] getAruguments() throws EdmException {
- Map<String, EdmLiteral> edmArguements = functiontView.getFunctionImportParameters();
-
- if (edmArguements == null) {
- return null;
- } else {
- Object[] args = new Object[edmArguements.size()];
- int i = 0;
- for (String paramName : functionImport.getParameterNames()) {
- EdmLiteral literal = edmArguements.get(paramName);
- EdmParameter parameter = functionImport.getParameter(paramName);
- JPAEdmMapping mapping = (JPAEdmMapping) parameter.getMapping();
- args[i] = convertArguement(literal, parameter.getFacets(), mapping.getJPAType());
- i++;
- }
- return args;
- }
-
- }
-
- private Object convertArguement(final EdmLiteral edmLiteral, final EdmFacets facets, final Class<?> targetType)
- throws EdmSimpleTypeException {
- EdmSimpleType edmType = edmLiteral.getType();
- Object value = edmType.valueOfString(edmLiteral.getLiteral(), EdmLiteralKind.DEFAULT, facets, targetType);
-
- return value;
- }
-
- private Class<?>[] getParameterTypes() throws EdmException {
-
- Class<?>[] parameterTypes = new Class<?>[functionImport.getParameterNames().size()];
- int i = 0;
- for (String parameterName : functionImport.getParameterNames()) {
- EdmParameter parameter = functionImport.getParameter(parameterName);
- parameterTypes[i] = ((JPAEdmMapping) parameter.getMapping()).getJPAType();
- i++;
- }
-
- return parameterTypes;
- }
-
- private Method getMethod(final Class<?>[] parameterTypes) throws NoSuchMethodException, SecurityException {
-
- Class<?> type = ((JPAEdmMapping) mapping).getJPAType();
- Method method;
- method = type.getMethod(mapping.getInternalName(), parameterTypes);
-
- return method;
- }
-
- private Type getReturnType() throws ODataJPAModelException, ODataJPARuntimeException, EdmException {
- return null;
- }
-
- private Object generateEnclosingObject() throws InstantiationException, IllegalAccessException,
- IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException {
-
- Class<?> type = ((JPAEdmMapping) mapping).getJPAType();
- Object[] params = null;
-
- return type.getConstructor((Class<?>[]) params).newInstance(params);
-
- }
-
- @Override
- protected void setResultsView(final Object resultsView) {
- if (resultsView instanceof GetFunctionImportUriInfo) {
- functiontView = (GetFunctionImportUriInfo) resultsView;
- }
-
- }
-
- }
-}
[03/37] [OLINGO-82] Renamed the project folder name to
odata2-jpa-processor
Posted by ch...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-ref/pom.xml
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-ref/pom.xml b/odata2-processor-jpa/jpa-ref/pom.xml
deleted file mode 100644
index bdf3ee6..0000000
--- a/odata2-processor-jpa/jpa-ref/pom.xml
+++ /dev/null
@@ -1,109 +0,0 @@
-<?xml version="1.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.
--->
-<project
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
- xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.apache.olingo</groupId>
- <artifactId>olingo-odata2-jpa-processor-incubating</artifactId>
- <version>1.1.0-SNAPSHOT</version>
- <relativePath>..</relativePath>
- </parent>
-
- <artifactId>olingo-odata2-jpa-processor-ref-incubating</artifactId>
- <packaging>jar</packaging>
- <name>${project.artifactId}</name>
-
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-jar-plugin</artifactId>
- <configuration>
- <archive>
- <manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
- </archive>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <extensions>true</extensions>
- <executions>
- <execution>
- <id>bundle-manifest</id>
- <phase>process-classes</phase>
- <goals>
- <goal>manifest</goal>
- </goals>
- </execution>
- </executions>
- <configuration>
- <instructions>
- <Import-Package>
- *
- </Import-Package>
- <Export-Package>
- org.apache.olingo.odata2.jpa.processor.ref.factory;version=${project.version},
- </Export-Package>
- <Bundle-DocURL>${project.url}</Bundle-DocURL>
- <Bundle-ActivationPolicy>lazy</Bundle-ActivationPolicy>
- <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
- </instructions>
- </configuration>
- </plugin>
- </plugins>
- </build>
-
- <dependencies>
- <!-- JPA Support -->
- <dependency>
- <groupId>org.eclipse.persistence</groupId>
- <artifactId>eclipselink</artifactId>
- <version>${version.eclipselink}</version>
- </dependency>
- <dependency>
- <groupId>org.eclipse.persistence</groupId>
- <artifactId>javax.persistence</artifactId>
- <version>2.0.5</version>
- </dependency>
- <dependency>
- <groupId>org.hsqldb</groupId>
- <artifactId>hsqldb</artifactId>
- <version>1.8.0.10</version>
- </dependency>
-
- <!-- OData Annotation Support -->
- <dependency>
- <groupId>org.apache.olingo</groupId>
- <artifactId>olingo-odata2-api-annotation-incubating</artifactId>
- <version>${project.version}</version>
- </dependency>
-
- <!-- JUnits -->
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>3.8.1</version>
- <scope>test</scope>
- </dependency>
- </dependencies>
-</project>
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-ref/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/factory/JPAEntityManagerFactory.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-ref/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/factory/JPAEntityManagerFactory.java b/odata2-processor-jpa/jpa-ref/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/factory/JPAEntityManagerFactory.java
deleted file mode 100644
index 1f4a7a8..0000000
--- a/odata2-processor-jpa/jpa-ref/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/factory/JPAEntityManagerFactory.java
+++ /dev/null
@@ -1,46 +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.jpa.processor.ref.factory;
-
-import java.util.HashMap;
-
-import javax.persistence.EntityManagerFactory;
-import javax.persistence.Persistence;
-
-public class JPAEntityManagerFactory {
- private static HashMap<String, EntityManagerFactory> emfMap;
-
- public static EntityManagerFactory getEntityManagerFactory(final String pUnit) {
- if (pUnit == null) {
- return null;
- }
- if (emfMap == null) {
- emfMap = new HashMap<String, EntityManagerFactory>();
- }
-
- if (emfMap.containsKey(pUnit)) {
- return emfMap.get(pUnit);
- } else {
- EntityManagerFactory emf = Persistence.createEntityManagerFactory(pUnit);
- emfMap.put(pUnit, emf);
- return emf;
- }
-
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-ref/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/model/Address.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-ref/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/model/Address.java b/odata2-processor-jpa/jpa-ref/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/model/Address.java
deleted file mode 100644
index a0aabcb..0000000
--- a/odata2-processor-jpa/jpa-ref/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/model/Address.java
+++ /dev/null
@@ -1,83 +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.jpa.processor.ref.model;
-
-import javax.persistence.Column;
-import javax.persistence.Embeddable;
-
-@Embeddable
-public class Address {
-
- public Address() {
- super();
- }
-
- public Address(final short houseNumber, final String streetName, final String city,
- final String country) {
- this();
- this.houseNumber = houseNumber;
- this.streetName = streetName;
- this.city = city;
- this.country = country;
- }
-
- @Column(name = "HOUSE_NUMBER")
- private short houseNumber;
-
- @Column(name = "STREET_NAME")
- private String streetName;
-
- @Column(name = "CITY")
- private String city;
-
- @Column(name = "COUNTRY")
- private String country;
-
- public short getHouseNumber() {
- return houseNumber;
- }
-
- public void setHouseNumber(final short houseNumber) {
- this.houseNumber = houseNumber;
- }
-
- public String getStreetName() {
- return streetName;
- }
-
- public void setStreetName(final String streetName) {
- this.streetName = streetName;
- }
-
- public String getCity() {
- return city;
- }
-
- public void setCity(final String city) {
- this.city = city;
- }
-
- public String getCountry() {
- return country;
- }
-
- public void setCountry(final String country) {
- this.country = country;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-ref/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/model/Material.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-ref/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/model/Material.java b/odata2-processor-jpa/jpa-ref/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/model/Material.java
deleted file mode 100644
index 6f08119..0000000
--- a/odata2-processor-jpa/jpa-ref/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/model/Material.java
+++ /dev/null
@@ -1,116 +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.jpa.processor.ref.model;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.Id;
-import javax.persistence.ManyToMany;
-import javax.persistence.Table;
-
-@Entity
-@Table(name = "T_MATERIAL")
-public class Material {
-
- public Material() {}
-
- public Material(final String materialName, final String typeCode, final double price,
- final String measurementUnit) {
- super();
- this.materialName = materialName;
- this.typeCode = typeCode;
- this.price = price;
- this.measurementUnit = measurementUnit;
- }
-
- @Id
- @Column(name = "MATERIAL_ID")
- private long materialId;
-
- @Column(name = "MATERIAL_NAME")
- private String materialName;
-
- @Column(name = "TYPE_CODE")
- private String typeCode;
-
- @Column(name = "PRICE")
- private double price;
-
- @Column(name = "MEASUREMENT_UNIT")
- private String measurementUnit;
-
- @ManyToMany
- private List<Store> stores = new ArrayList<Store>();
-
- public long getMaterialId() {
- return materialId;
- }
-
- public void setMaterialId(final long materialId) {
- this.materialId = materialId;
- }
-
- public String getMaterialName() {
- return materialName;
- }
-
- public void setMaterialName(final String materialName) {
- this.materialName = materialName;
- }
-
- public String getTypeCode() {
- return typeCode;
- }
-
- public void setTypeCode(final String typeCode) {
- this.typeCode = typeCode;
- }
-
- public double getPrice() {
- return price;
- }
-
- public void setPrice(final double price) {
- this.price = price;
- }
-
- public String getMeasurementUnit() {
- return measurementUnit;
- }
-
- public void setMeasurementUnit(final String measurementUnit) {
- this.measurementUnit = measurementUnit;
- }
-
- public List<Store> getStores() {
- return stores;
- }
-
- public void setStores(final List<Store> stores) {
- this.stores = stores;
- Iterator<Store> itr = stores.iterator();
- while (itr.hasNext()) {
- itr.next().getMaterials().add(this);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-ref/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/model/Note.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-ref/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/model/Note.java b/odata2-processor-jpa/jpa-ref/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/model/Note.java
deleted file mode 100644
index 4a93509..0000000
--- a/odata2-processor-jpa/jpa-ref/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/model/Note.java
+++ /dev/null
@@ -1,116 +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.jpa.processor.ref.model;
-
-import java.util.Calendar;
-
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.Id;
-import javax.persistence.JoinColumn;
-import javax.persistence.ManyToOne;
-import javax.persistence.Table;
-import javax.persistence.Temporal;
-import javax.persistence.TemporalType;
-
-@Entity
-@Table(name = "T_NOTE")
-public class Note {
-
- public Note() {}
-
- public Note(final Calendar creationTime, final Calendar creationDate, final String createdBy,
- final String text) {
- super();
- this.creationTime = creationTime;
- this.creationDate = creationDate;
- this.createdBy = createdBy;
- this.text = text;
- }
-
- @Id
- @Temporal(TemporalType.TIME)
- private Calendar creationTime;
-
- @Id
- @Temporal(TemporalType.DATE)
- private Calendar creationDate;
-
- @Id
- private String createdBy;
-
- @Column
- private String text;
-
- @Column(name = "SO_ID")
- private long soId;
-
- @JoinColumn(name = "SO_ID", referencedColumnName = "SO_ID", insertable = false, updatable = false)
- @ManyToOne
- private SalesOrderHeader salesOrderHeader;
-
- public Calendar getCreationTime() {
- return creationTime;
- }
-
- public void setCreationTime(final Calendar creationTime) {
- this.creationTime = creationTime;
- }
-
- public Calendar getCreationDate() {
- return creationDate;
- }
-
- public void setCreationDate(final Calendar creationDate) {
- this.creationDate = creationDate;
- }
-
- public String getCreatedBy() {
- return createdBy;
- }
-
- public void setCreatedBy(final String createdBy) {
- this.createdBy = createdBy;
- }
-
- public String getText() {
- return text;
- }
-
- public void setText(final String text) {
- this.text = text;
- }
-
- public long getSoId() {
- return soId;
- }
-
- public void setSoId(final long soId) {
- this.soId = soId;
- }
-
- public SalesOrderHeader getSalesOrderHeader() {
- return salesOrderHeader;
- }
-
- public void setSalesOrderHeader(final SalesOrderHeader salesOrderHeader) {
- this.salesOrderHeader = salesOrderHeader;
- this.salesOrderHeader.getNotes().add(this);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-ref/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/model/SalesOrderHeader.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-ref/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/model/SalesOrderHeader.java b/odata2-processor-jpa/jpa-ref/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/model/SalesOrderHeader.java
deleted file mode 100644
index 9af23f3..0000000
--- a/odata2-processor-jpa/jpa-ref/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/model/SalesOrderHeader.java
+++ /dev/null
@@ -1,236 +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.jpa.processor.ref.model;
-
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-import java.util.TimeZone;
-
-import javax.persistence.CascadeType;
-import javax.persistence.Column;
-import javax.persistence.Embedded;
-import javax.persistence.Entity;
-import javax.persistence.Id;
-import javax.persistence.OneToMany;
-import javax.persistence.PostPersist;
-import javax.persistence.Table;
-import javax.persistence.Temporal;
-import javax.persistence.TemporalType;
-
-@Entity
-@Table(name = "T_SALESORDERHEADER")
-public class SalesOrderHeader {
-
- public SalesOrderHeader() {}
-
- public SalesOrderHeader(final Calendar creationDate, final int buyerId, final String buyerName,
- final Address buyerAddress, final String currencyCode, final double netAmount,
- final String deliveryStatus, final char[] shortText, final Character[] longText) {
- super();
- this.creationDate = creationDate;
- this.buyerId = buyerId;
- this.buyerName = buyerName;
- this.buyerAddress = buyerAddress;
- this.currencyCode = currencyCode;
- this.deliveryStatus = deliveryStatus;
- this.shortText = shortText;
- this.longText = longText;
- }
-
- @Id
- @Column(name = "SO_ID")
- private long soId;
-
- @Temporal(TemporalType.TIMESTAMP)
- private Calendar creationDate;
-
- @Column
- private Character status;
-
- public Character getStatus() {
- return status;
- }
-
- public void setStatus(final Character status) {
- this.status = status;
- }
-
- @Column(name = "SHORT_TEXT", length = 20)
- private char[] shortText;
-
- @Column(name = "LONG_TEXT", length = 40)
- private Character[] longText;
-
- @Column(name = "BUYER_ID")
- private int buyerId;
-
- @Column(name = "BUYER_NAME", length = 255)
- private String buyerName;
-
- @Embedded
- private Address buyerAddress;
-
- @Column(name = "CURRENCY_CODE", length = 3)
- private String currencyCode;
-
- @Column(name = "DELIVERY_STATUS", length = 2)
- private String deliveryStatus;
-
- @Column(precision = 5)
- private double grossAmount;
-
- @Column(precision = 8)
- private double netAmount;
-
- @OneToMany(mappedBy = "salesOrderHeader", cascade = CascadeType.ALL)
- private Set<SalesOrderItem> salesOrderItem = new HashSet<SalesOrderItem>();
-
- @OneToMany(mappedBy = "salesOrderHeader", cascade = CascadeType.ALL)
- private List<Note> notes = new ArrayList<Note>();
-
- public long getSoId() {
- return soId;
- }
-
- public void setSoId(final long soId) {
- this.soId = soId;
- }
-
- public Date getCreationDate() {
- if (creationDate == null) {
- return null;
- }
- long dbTime = creationDate.getTime().getTime();
- Date originalDate = new Date(dbTime + TimeZone.getDefault().getOffset(dbTime));
- return originalDate;
- }
-
- public void setCreationDate(final Calendar creationDate) {
- long originalTime;
- if (creationDate != null) {
- originalTime = creationDate.getTime().getTime();
- } else {
- originalTime = Calendar.getInstance(TimeZone.getDefault()).getTime().getTime();
- }
- Date newDate = new Date(originalTime - TimeZone.getDefault().getOffset(originalTime));
- Calendar newCalendar = Calendar.getInstance();
- newCalendar.setTime(newDate);
- this.creationDate = newCalendar;
- }
-
- public int getBuyerId() {
- return buyerId;
- }
-
- public void setBuyerId(final int buyerId) {
- this.buyerId = buyerId;
- }
-
- public String getBuyerName() {
- return buyerName;
- }
-
- public void setBuyerName(final String buyerName) {
- this.buyerName = buyerName;
- }
-
- public Address getBuyerAddress() {
- return buyerAddress;
- }
-
- public void setBuyerAddress(final Address buyerAddress) {
- this.buyerAddress = buyerAddress;
- }
-
- public String getCurrencyCode() {
- return currencyCode;
- }
-
- public void setCurrencyCode(final String currencyCode) {
- this.currencyCode = currencyCode;
- }
-
- public String getDeliveryStatus() {
- return deliveryStatus;
- }
-
- public void setDeliveryStatus(final String deliveryStatus) {
- this.deliveryStatus = deliveryStatus;
- }
-
- public double getGrossAmount() {
- return grossAmount;
- }
-
- public void setGrossAmount(final double grossAmount) {
- this.grossAmount = grossAmount;
- }
-
- public double getNetAmount() {
- return netAmount;
- }
-
- public void setNetAmount(final double netAmount) {
- this.netAmount = netAmount;
- }
-
- public Set<SalesOrderItem> getSalesOrderItem() {
- return salesOrderItem;
- }
-
- public void setSalesOrderItem(final Set<SalesOrderItem> salesOrderItem) {
- this.salesOrderItem = salesOrderItem;
- }
-
- public List<Note> getNotes() {
- return notes;
- }
-
- public void setNotes(final List<Note> notes) {
- this.notes = notes;
- }
-
- public char[] getShortText() {
- return shortText;
- }
-
- public void setShortText(final char[] shortText) {
- this.shortText = shortText;
- }
-
- public Character[] getLongText() {
- return longText;
- }
-
- public void setLongText(final Character[] longText) {
- this.longText = longText;
- }
-
- @PostPersist
- public void defaultValues() {
- if (creationDate == null) {
- setCreationDate(creationDate);
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-ref/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/model/SalesOrderItem.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-ref/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/model/SalesOrderItem.java b/odata2-processor-jpa/jpa-ref/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/model/SalesOrderItem.java
deleted file mode 100644
index fa20b47..0000000
--- a/odata2-processor-jpa/jpa-ref/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/model/SalesOrderItem.java
+++ /dev/null
@@ -1,133 +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.jpa.processor.ref.model;
-
-import javax.persistence.Column;
-import javax.persistence.EmbeddedId;
-import javax.persistence.Entity;
-import javax.persistence.JoinColumn;
-import javax.persistence.ManyToOne;
-import javax.persistence.Table;
-import javax.persistence.Transient;
-
-@Entity
-@Table(name = "T_SALESORDERITEM")
-public class SalesOrderItem {
-
- public SalesOrderItem() {}
-
- public SalesOrderItem(final int quantity, final double amount, final double discount,
- final Material material) {
- super();
- this.quantity = quantity;
- this.amount = amount;
- this.discount = discount;
- this.material = material;
- }
-
- @EmbeddedId
- private SalesOrderItemKey salesOrderItemKey;
-
- @Column(name = "Material_Id", nullable = false)
- private long matId;
-
- @Column
- private int quantity;
-
- @Column
- private double amount;
-
- @Column
- private double discount;
-
- @Transient
- private double netAmount;
-
- @JoinColumn(name = "Material_Id", referencedColumnName = "MATERIAL_ID", insertable = false, updatable = false)
- @ManyToOne
- private Material material;
-
- @JoinColumn(name = "Sales_Order_Id", referencedColumnName = "SO_ID", insertable = false, updatable = false)
- @ManyToOne
- private SalesOrderHeader salesOrderHeader;
-
- public SalesOrderItemKey getSalesOrderItemKey() {
- return salesOrderItemKey;
- }
-
- public void setSalesOrderItemKey(final SalesOrderItemKey salesOrderItemKey) {
- this.salesOrderItemKey = salesOrderItemKey;
- }
-
- public long getMatId() {
- return matId;
- }
-
- public void setMatId(final long matId) {
- this.matId = matId;
- }
-
- public int getQuantity() {
- return quantity;
- }
-
- public void setQuantity(final int quantity) {
- this.quantity = quantity;
- }
-
- public double getAmount() {
- return amount;
- }
-
- public void setAmount(final double amount) {
- this.amount = amount;
- }
-
- public double getDiscount() {
- return discount;
- }
-
- public void setDiscount(final double discount) {
- this.discount = discount;
- }
-
- public double getNetAmount() {
- return netAmount;
- }
-
- public void setNetAmount(final double netAmount) {
- this.netAmount = netAmount;
- }
-
- public Material getMaterial() {
- return material;
- }
-
- public void setMaterial(final Material material) {
- this.material = material;
- }
-
- public SalesOrderHeader getSalesOrderHeader() {
- return salesOrderHeader;
- }
-
- public void setSalesOrderHeader(final SalesOrderHeader salesOrderHeader) {
- this.salesOrderHeader = salesOrderHeader;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-ref/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/model/SalesOrderItemKey.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-ref/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/model/SalesOrderItemKey.java b/odata2-processor-jpa/jpa-ref/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/model/SalesOrderItemKey.java
deleted file mode 100644
index efc09d2..0000000
--- a/odata2-processor-jpa/jpa-ref/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/model/SalesOrderItemKey.java
+++ /dev/null
@@ -1,89 +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.jpa.processor.ref.model;
-
-import java.io.Serializable;
-
-import javax.persistence.Column;
-import javax.persistence.Embeddable;
-
-@Embeddable
-public class SalesOrderItemKey implements Serializable {
-
- private static final long serialVersionUID = 1L;
-
- public SalesOrderItemKey() {}
-
- public SalesOrderItemKey(final long liId) {
- super();
- this.liId = liId;
- }
-
- @Column(name = "Sales_Order_Id", nullable = false)
- private long soId;
-
- @Column(name = "Sales_Order_Item_Id", unique = true)
- private long liId;
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + (int) (liId ^ (liId >>> 32));
- result = prime * result + (int) (soId ^ (soId >>> 32));
- return result;
- }
-
- @Override
- public boolean equals(final Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj == null) {
- return false;
- }
- if (getClass() != obj.getClass()) {
- return false;
- }
- SalesOrderItemKey other = (SalesOrderItemKey) obj;
- if (liId != other.liId) {
- return false;
- }
- if (soId != other.soId) {
- return false;
- }
- return true;
- }
-
- public long getSoId() {
- return soId;
- }
-
- public void setSoId(final long soId) {
- this.soId = soId;
- }
-
- public long getLiId() {
- return liId;
- }
-
- public void setLiId(final long liId) {
- this.liId = liId;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-ref/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/model/Store.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-ref/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/model/Store.java b/odata2-processor-jpa/jpa-ref/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/model/Store.java
deleted file mode 100644
index b88bc3a..0000000
--- a/odata2-processor-jpa/jpa-ref/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/model/Store.java
+++ /dev/null
@@ -1,92 +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.jpa.processor.ref.model;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import javax.persistence.Column;
-import javax.persistence.Embedded;
-import javax.persistence.Entity;
-import javax.persistence.Id;
-import javax.persistence.ManyToMany;
-import javax.persistence.Table;
-
-@Entity
-@Table(name = "T_STORE")
-public class Store {
-
- public Store() {}
-
- public Store(final String storeName, final Address storeAddress) {
- super();
- this.storeName = storeName;
- this.storeAddress = storeAddress;
- }
-
- @Id
- @Column(name = "STORE_ID")
- private long storeId;
-
- @Column(name = "STORE_NAME", unique = true)
- private String storeName;
-
- @Embedded
- private Address storeAddress;
-
- @ManyToMany(mappedBy = "stores")
- private List<Material> materials = new ArrayList<Material>();
-
- public long getStoreId() {
- return storeId;
- }
-
- public void setStoreId(final long storeId) {
- this.storeId = storeId;
- }
-
- public String getStoreName() {
- return storeName;
- }
-
- public void setStoreName(final String storeName) {
- this.storeName = storeName;
- }
-
- public Address getStoreAddress() {
- return storeAddress;
- }
-
- public void setStoreAddress(final Address storeAddress) {
- this.storeAddress = storeAddress;
- }
-
- public List<Material> getMaterials() {
- return materials;
- }
-
- public void setMaterials(final List<Material> materials) {
- this.materials = materials;
- Iterator<Material> itr = materials.iterator();
- while (itr.hasNext()) {
- itr.next().getStores().add(this);
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-ref/src/main/resources/META-INF/persistence.xml
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-ref/src/main/resources/META-INF/persistence.xml b/odata2-processor-jpa/jpa-ref/src/main/resources/META-INF/persistence.xml
deleted file mode 100644
index f1a102f..0000000
--- a/odata2-processor-jpa/jpa-ref/src/main/resources/META-INF/persistence.xml
+++ /dev/null
@@ -1,46 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- 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.
--->
-<persistence version="2.0"
- xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
- <persistence-unit name="salesorderprocessing"
- transaction-type="RESOURCE_LOCAL">
- <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
- <class>org.apache.olingo.odata2.jpa.processor.ref.model.SalesOrderHeader</class>
- <class>org.apache.olingo.odata2.jpa.processor.ref.model.SalesOrderItem</class>
- <class>org.apache.olingo.odata2.jpa.processor.ref.model.Note</class>
- <class>org.apache.olingo.odata2.jpa.processor.ref.model.Material</class>
- <class>org.apache.olingo.odata2.jpa.processor.ref.model.Store</class>
- <properties>
- <property name="javax.persistence.jdbc.driver" value="org.hsqldb.jdbcDriver" />
- <property name="javax.persistence.jdbc.url"
- value="jdbc:hsqldb:mem:org.apache.olingo.jpa.sample" />
- <property name="javax.persistence.jdbc.user" value="sa" />
- <property name="javax.persistence.jdbc.password" value="" />
- <property name="eclipselink.target-database"
- value="org.eclipse.persistence.platform.database.HSQLPlatform" />
- <property name="eclipselink.logging.level" value="ALL" />
- <property name="eclipselink.orm.throw.exceptions" value="true" />
- <property name="eclipselink.ddl-generation" value="create-tables" />
- <property name="eclipselink.ddl-generation.output-mode"
- value="database" />
- </properties>
- </persistence-unit>
-</persistence>
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-web/.gitignore
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-web/.gitignore b/odata2-processor-jpa/jpa-web/.gitignore
deleted file mode 100644
index fe5d89b..0000000
--- a/odata2-processor-jpa/jpa-web/.gitignore
+++ /dev/null
@@ -1,8 +0,0 @@
-.project
-.classpath
-.settings
-target
-bin
-*.bak
-classes
-.DS_Store
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-web/pom.xml
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-web/pom.xml b/odata2-processor-jpa/jpa-web/pom.xml
deleted file mode 100644
index 18302cb..0000000
--- a/odata2-processor-jpa/jpa-web/pom.xml
+++ /dev/null
@@ -1,123 +0,0 @@
-<?xml version="1.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. -->
-<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
- xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
- <modelVersion>4.0.0</modelVersion>
-
- <artifactId>olingo-odata2-jpa-processor-ref-web-incubating</artifactId>
- <packaging>war</packaging>
- <name>${project.artifactId}</name>
-
- <parent>
- <groupId>org.apache.olingo</groupId>
- <artifactId>olingo-odata2-jpa-processor-incubating</artifactId>
- <version>1.1.0-SNAPSHOT</version>
- <relativePath>..</relativePath>
- </parent>
-
- <build>
- <resources>
- <resource>
- <directory>src/main/version</directory>
- <filtering>true</filtering>
- <targetPath>../${project.build.finalName}/gen</targetPath>
- </resource>
- <resource>
- <directory>src/main/resources</directory>
- <filtering>true</filtering>
- </resource>
- </resources>
-
- <pluginManagement>
- <plugins>
- <plugin>
- <groupId>com.sap.research</groupId>
- <artifactId>nwcloud-maven-plugin</artifactId>
- <version>1.0.0.RELEASE</version>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-deploy-plugin</artifactId>
- <configuration>
- <skip>true</skip>
- </configuration>
- </plugin>
- </plugins>
- </pluginManagement>
-
- </build>
-
- <dependencies>
- <dependency>
- <!-- required because of auto detection of web facet 2.5 -->
- <groupId>javax.servlet</groupId>
- <artifactId>servlet-api</artifactId>
- <version>2.5</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.cxf</groupId>
- <artifactId>cxf-rt-frontend-jaxrs</artifactId>
- <version>${cxf.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.olingo</groupId>
- <artifactId>olingo-odata2-core-incubating</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.olingo</groupId>
- <artifactId>olingo-odata2-api-incubating</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.olingo</groupId>
- <artifactId>olingo-odata2-jpa-processor-api-incubating</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.olingo</groupId>
- <artifactId>olingo-odata2-jpa-processor-core-incubating</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.olingo</groupId>
- <artifactId>olingo-odata2-jpa-processor-ref-incubating</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-log4j12</artifactId>
- <version>1.7.1</version>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>3.8.1</version>
- <scope>test</scope>
- </dependency>
- </dependencies>
-
- <profiles>
- <profile>
- <id>dev</id>
- <build>
- <defaultGoal>cargo:run</defaultGoal>
-
- <plugins>
- <plugin>
- <groupId>org.codehaus.cargo</groupId>
- <artifactId>cargo-maven2-plugin</artifactId>
- <version>1.4.2</version>
- </plugin>
- </plugins>
- </build>
- </profile>
- </profiles>
-</project>
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/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
deleted file mode 100644
index 0ff659b..0000000
--- a/odata2-processor-jpa/jpa-web/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/extension/SalesOrderHeaderProcessor.java
+++ /dev/null
@@ -1,115 +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.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/1b479e6c/odata2-processor-jpa/jpa-web/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/extension/SalesOrderProcessingExtension.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-web/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/extension/SalesOrderProcessingExtension.java b/odata2-processor-jpa/jpa-web/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/extension/SalesOrderProcessingExtension.java
deleted file mode 100644
index 6b82899..0000000
--- a/odata2-processor-jpa/jpa-web/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/extension/SalesOrderProcessingExtension.java
+++ /dev/null
@@ -1,38 +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.jpa.processor.ref.extension;
-
-import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmExtension;
-import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmSchemaView;
-
-public class SalesOrderProcessingExtension implements JPAEdmExtension {
-
- @Override
- public void extendJPAEdmSchema(final JPAEdmSchemaView arg0) {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public void extendWithOperation(final JPAEdmSchemaView view) {
- view.registerOperations(SalesOrderHeaderProcessor.class, null);
-
- }
-
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/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
deleted file mode 100644
index 4bc0a29..0000000
--- a/odata2-processor-jpa/jpa-web/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/extension/_SalesOrderHeaderProcessor.java
+++ /dev/null
@@ -1,127 +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.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;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-web/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/util/DataGenerator.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-web/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/util/DataGenerator.java b/odata2-processor-jpa/jpa-web/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/util/DataGenerator.java
deleted file mode 100644
index 55eb876..0000000
--- a/odata2-processor-jpa/jpa-web/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/util/DataGenerator.java
+++ /dev/null
@@ -1,158 +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.jpa.processor.ref.util;
-
-import java.util.Arrays;
-import java.util.List;
-import java.util.ResourceBundle;
-import java.util.Set;
-
-import javax.persistence.EntityManager;
-import javax.persistence.Query;
-
-import org.apache.olingo.odata2.jpa.processor.ref.model.Material;
-import org.apache.olingo.odata2.jpa.processor.ref.model.Store;
-import org.eclipse.persistence.internal.jpa.EntityManagerImpl;
-import org.eclipse.persistence.queries.DataModifyQuery;
-import org.eclipse.persistence.queries.SQLCall;
-import org.eclipse.persistence.sessions.Session;
-
-/**
- * This is a utility class for generating and cleaning data. The generated data would be used by the application.
- *
- *
- */
-public class DataGenerator {
-
- private EntityManager entityManager;
-
- /**
- * This is configuration property to hold comma separated names of Insert Files
- */
- private static final String SQL_INSERT_CONFIG = "SQLInsertConfig";
-
- /**
- * This is key which will be used to fetch file names from SQL Insert Config File.
- */
- private static final String SQL_INSERT_FILE_NAMES_KEY = "insert_file_names";
-
- private static final String SQL_DELETE_CONFIG = "DataDeleteSQLs";
- private static final String SQL_DELETE_STATEMENTS_KEY = "delete_queries";
-
- public DataGenerator(final EntityManager entityManager) {
- this.entityManager = entityManager;
- }
-
- /**
- * This method generates data to be used in the application. It does so by
- * reading properties file. Currently it iterates through comma separated
- * file names in file SQLInsertConfig and gets the insert statements from
- * those files in the order provided in the file.
- */
- public void generate() {
- String[] resourceSQLPropFileNames = getSQLInsertFileNames();
- if (resourceSQLPropFileNames.length > 0) { // If configuration is proper with at least one file
- Session session = ((EntityManagerImpl) entityManager).getActiveSession();
- ResourceBundle[] resourceBundleArr = new ResourceBundle[resourceSQLPropFileNames.length];
- entityManager.getTransaction().begin();
-
- for (int i = 0; i < resourceSQLPropFileNames.length; i++) { // For each Entity SQL property file,
- System.out.println("Reading from File - " + resourceSQLPropFileNames[i]);
- resourceBundleArr[i] = ResourceBundle.getBundle(resourceSQLPropFileNames[i]);// Get SQL statements as properties
-
- Set<String> keySet = resourceBundleArr[i].keySet();
-
- for (String string : keySet) {
- String currentSQL = (String) string;
- String sqlQuery = resourceBundleArr[i].getString(currentSQL);
- System.out.println("Executing Query - " + sqlQuery);
- SQLCall sqlCall = new SQLCall(sqlQuery);
-
- DataModifyQuery query = new DataModifyQuery();
- query.setCall(sqlCall);
- session.executeQuery(query);
- }
- }
- setMaterialInStore();
- entityManager.flush();
- entityManager.getTransaction().commit();
- }
-
- }
-
- @SuppressWarnings("unchecked")
- private void setMaterialInStore() {
- Query query = entityManager.createQuery("SELECT e FROM Material e");
- List<Material> materials = (List<Material>) query.getResultList();
-
- query = entityManager.createQuery("SELECT e FROM Store e");
- List<Store> stores = (List<Store>) query.getResultList();
-
- int storeSize = stores.size();
- int i = 0;
- for (Material material : materials) {
- List<Store> storesA = Arrays.asList(stores.get(i), stores.get(i + 1));
- material.setStores(storesA);
- i++;
- if (i > storeSize - 2) {
- i = 0;
- }
- entityManager.persist(material);
- }
- entityManager.flush();
- }
-
- private String[] getSQLInsertFileNames() {
- ResourceBundle resourceBundle = ResourceBundle.getBundle(SQL_INSERT_CONFIG);// File names from properties
- String namesStr = resourceBundle.getString(SQL_INSERT_FILE_NAMES_KEY);
- return namesStr.split(",");
- }
-
- private String[] getSQLDeleteStatements() {
- ResourceBundle resourceBundle = ResourceBundle.getBundle(SQL_DELETE_CONFIG);// File names from properties
- String deleteStatements = resourceBundle.getString(SQL_DELETE_STATEMENTS_KEY);
- return deleteStatements.split(",");
- }
-
- /**
- * This method deletes data from JPA tables created. This method reads comma
- * separated SQL delete statements from DataDeleteSQLs properties files and
- * executes them in order.
- */
- public void clean() {
- // Delete using SQLs
- String[] deleteStatements = getSQLDeleteStatements();
- if (deleteStatements.length > 0) { // If configuration is proper with at least one delete Statements
- Session session = ((EntityManagerImpl) entityManager).getActiveSession();
- entityManager.getTransaction().begin();
- for (String deleteStatement : deleteStatements) {
- System.out.println("Cleaning - " + deleteStatement);
- SQLCall sqlCall = new SQLCall(deleteStatement);
-
- DataModifyQuery query = new DataModifyQuery();
- query.setCall(sqlCall);
- session.executeQuery(query);
- }
- entityManager.getTransaction().commit();
- } else {
- System.err.println("Delete configuration file doesn't have any delete statements.");
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-web/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/web/JPAReferenceServiceFactory.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-web/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/web/JPAReferenceServiceFactory.java b/odata2-processor-jpa/jpa-web/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/web/JPAReferenceServiceFactory.java
deleted file mode 100644
index fe4e618..0000000
--- a/odata2-processor-jpa/jpa-web/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/web/JPAReferenceServiceFactory.java
+++ /dev/null
@@ -1,56 +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.jpa.processor.ref.web;
-
-import java.util.ResourceBundle;
-
-import org.apache.olingo.odata2.jpa.processor.ref.extension.SalesOrderProcessingExtension;
-import org.apache.olingo.odata2.jpa.processor.ref.factory.JPAEntityManagerFactory;
-import org.apache.olingo.odata2.processor.api.jpa.ODataJPAContext;
-import org.apache.olingo.odata2.processor.api.jpa.ODataJPAServiceFactory;
-import org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPARuntimeException;
-import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmExtension;
-
-public class JPAReferenceServiceFactory extends ODataJPAServiceFactory {
- private static final String PUNIT_NAME = "salesorderprocessing";
- private static final String MAPPING_MODEL = "SalesOrderProcessingMappingModel.xml";
- private static final String CONFIG = "serviceConfig";
- private static final String SHOW_DETAIL_ERROR = "showDetailError";
-
- @Override
- public ODataJPAContext initializeODataJPAContext()
- throws ODataJPARuntimeException {
- ODataJPAContext oDataJPAContext = getODataJPAContext();
- oDataJPAContext.setEntityManagerFactory(JPAEntityManagerFactory.getEntityManagerFactory(PUNIT_NAME));
- oDataJPAContext.setPersistenceUnitName(PUNIT_NAME);
- oDataJPAContext.setJPAEdmMappingModel(MAPPING_MODEL);
- oDataJPAContext
- .setJPAEdmExtension((JPAEdmExtension) new SalesOrderProcessingExtension());
-
- setErrorLevel();
-
- return oDataJPAContext;
- }
-
- private void setErrorLevel() {
- ResourceBundle config = ResourceBundle.getBundle(CONFIG);
- boolean error = Boolean.parseBoolean((String) config.getObject(SHOW_DETAIL_ERROR));
- setDetailErrors(error);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-web/src/main/resources/DataDeleteSQLs.properties
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-web/src/main/resources/DataDeleteSQLs.properties b/odata2-processor-jpa/jpa-web/src/main/resources/DataDeleteSQLs.properties
deleted file mode 100644
index 19f859d..0000000
--- a/odata2-processor-jpa/jpa-web/src/main/resources/DataDeleteSQLs.properties
+++ /dev/null
@@ -1,22 +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.
-#-------------------------------------------------------------------------------
-
-#Config file for deleting the entities. They are deleted in the order provided in the below comma-separated string.
-#It is mandatory due to referential constaints.
-delete_queries = DELETE FROM T_NOTE,DELETE FROM T_SALESORDERITEM,DELETE FROM T_MATERIAL_T_STORE,DELETE FROM T_MATERIAL,DELETE FROM T_STORE,DELETE FROM T_SALESORDERHEADER
\ No newline at end of file
[17/37] [OLINGO-82] Renamed the project folder name to
odata2-jpa-processor
Posted by ch...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmComplexTypeView.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmComplexTypeView.java b/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmComplexTypeView.java
deleted file mode 100644
index bbee5e4..0000000
--- a/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmComplexTypeView.java
+++ /dev/null
@@ -1,116 +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.api.jpa.model;
-
-import java.util.List;
-
-import org.apache.olingo.odata2.api.edm.FullQualifiedName;
-import org.apache.olingo.odata2.api.edm.provider.ComplexType;
-import org.apache.olingo.odata2.api.edm.provider.Property;
-
-/**
- * A view on Java Persistence embeddable types and EDM complex types. Java
- * persistence embeddable types are converted into EDM entity types. Only those
- * embeddable types that are
- * <ol>
- * <li>used in a java persistence Entity type</li>
- * <li>used as non embeddable id of a java persistence entity type</li>
- * </ol>
- * are converted into EDM complex types.
- * <p>
- * The implementation of the view provides access to EDM complex types for the
- * given JPA EDM model. The view acts as a container for consistent list of EDM
- * complex types. An EDM complex type is said to be consistent only if it used
- * in at least one of the EDM entity type.
- *
- *
- * <p>
- * @org.apache.olingo.odata2.DoNotImplement
- * @see org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmComplexPropertyView
- *
- */
-public interface JPAEdmComplexTypeView extends JPAEdmBaseView {
-
- /**
- * The method returns an EDM complex type that is currently being processed.
- *
- * @return an instance of type {@link org.apache.olingo.odata2.api.edm.provider.ComplexType}
- */
- public ComplexType getEdmComplexType();
-
- /**
- * The method returns an JPA embeddable type that is currently being
- * processed.
- *
- * @return an instance of type {@link javax.persistence.metamodel.EmbeddableType}
- */
- public javax.persistence.metamodel.EmbeddableType<?> getJPAEmbeddableType();
-
- /**
- * The method returns a consistent list of EDM complex types.
- *
- * @return a list of {@link org.apache.olingo.odata2.api.edm.provider.ComplexType}
- */
- public List<ComplexType> getConsistentEdmComplexTypes();
-
- /**
- * The method searches for the EDM complex type with in the container for
- * the given JPA embeddable type name.
- *
- * @param embeddableTypeName
- * is the name of JPA embeddable type
- * @return a reference to EDM complex type if found else null
- */
- public ComplexType searchEdmComplexType(String embeddableTypeName);
-
- /**
- * The method add a JPA EDM complex type view to the container.
- *
- * @param view
- * is an instance of type {@link org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmComplexTypeView}
- */
- public void addJPAEdmCompleTypeView(JPAEdmComplexTypeView view);
-
- /**
- * The method searches for the EDM complex type with in the container for
- * the given EDM complex type's fully qualified name.
- *
- * @param type
- * is the fully qualified name of EDM complex type
- * @return a reference to EDM complex type if found else null
- */
- public ComplexType searchEdmComplexType(FullQualifiedName type);
-
- /**
- * The method expands the given EDM complex type into a list of EDM simple
- * properties.
- *
- * @param complexType
- * is the EDM complex type to expand
- * @param expandedPropertyList
- * is the list to be populated with expanded EDM simple
- * properties
- * @param embeddablePropertyName
- * is the name of the complex property. The name is used as the
- * qualifier for the expanded simple property names.
- */
- public void expandEdmComplexType(ComplexType complexType, List<Property> expandedPropertyList,
- String embeddablePropertyName);
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmEntityContainerView.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmEntityContainerView.java b/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmEntityContainerView.java
deleted file mode 100644
index 82ccaf9..0000000
--- a/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmEntityContainerView.java
+++ /dev/null
@@ -1,72 +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.api.jpa.model;
-
-import java.util.List;
-
-import org.apache.olingo.odata2.api.edm.provider.EntityContainer;
-
-/**
- * A view on JPA EDM entity container. JPA EDM entity container is built from
- * consistent JPA EDM entity set and consistent JPA EDM association set views.
- *
- * <p>
- * The implementation of the view provides access to EDM entity containers. The
- * view acts as container for JPA EDM entity containers. A JPA EDM entity
- * container is said to be consistent only if the JPA EDM association set and
- * JPA EDM Entity Set view are consistent.
- *
- *
- * @org.apache.olingo.odata2.DoNotImplement
- * @see org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmEntitySetView
- * @see org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmAssociationSetView
- *
- */
-public interface JPAEdmEntityContainerView extends JPAEdmBaseView {
- /**
- * The method returns the EDM entity container that is currently being
- * processed.
- *
- * @return an instance of type {@link org.apache.olingo.odata2.api.edm.provider.EntityContainer}
- */
- public EntityContainer getEdmEntityContainer();
-
- /**
- * The method returns a list of consistent EDM entity containers
- *
- * @return a list of consistent EDM entity containers
- */
- public List<EntityContainer> getConsistentEdmEntityContainerList();
-
- /**
- * The method returns the JPA EDM entity set view that is currently being
- * processed.
- *
- * @return an instance of type {@link org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmEntitySetView}
- */
- public JPAEdmEntitySetView getJPAEdmEntitySetView();
-
- /**
- * The method returns the JPA EDM association set view that is currently
- * being processed.
- *
- * @return an instance of type {@link org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmAssociationSetView}
- */
- public JPAEdmAssociationSetView getEdmAssociationSetView();
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmEntitySetView.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmEntitySetView.java b/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmEntitySetView.java
deleted file mode 100644
index 87019f6..0000000
--- a/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmEntitySetView.java
+++ /dev/null
@@ -1,64 +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.api.jpa.model;
-
-import java.util.List;
-
-import org.apache.olingo.odata2.api.edm.provider.EntitySet;
-
-/**
- * A view on Java Persistence entity type and EDM entity sets. Java persistence
- * entity types are converted into EDM entity types and EDM entity sets.
- * <p>
- * The implementation of the view provides access to EDM entity sets for the
- * given JPA EDM entity type. The view acts as a container for consistent list
- * of EDM entity sets. An EDM entity set is said to be consistent only if it has
- * consistent EDM entity types.
- *
- *
- * <p>
- * @org.apache.olingo.odata2.DoNotImplement
- * @see org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmEntityTypeView
- *
- */
-public interface JPAEdmEntitySetView extends JPAEdmBaseView {
- /**
- * The method returns an EDM entity set that is currently being processed.
- *
- * @return an instance of type {@link org.apache.olingo.odata2.api.edm.provider.EntitySet}
- */
- public EntitySet getEdmEntitySet();
-
- /**
- * The method returns a list of consistent EDM entity sets.
- *
- * @return a list of EDM entity sets
- */
- public List<EntitySet> getConsistentEdmEntitySetList();
-
- /**
- * The method returns a JPA EDM entity type view that is currently being
- * processed. JPA EDM entity set view is built from JPA EDM entity type
- * view.
- *
- * @return an instance of type {@link org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmEntityTypeView}
- */
- public JPAEdmEntityTypeView getJPAEdmEntityTypeView();
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmEntityTypeView.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmEntityTypeView.java b/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmEntityTypeView.java
deleted file mode 100644
index 54965d8..0000000
--- a/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmEntityTypeView.java
+++ /dev/null
@@ -1,76 +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.api.jpa.model;
-
-import java.util.List;
-
-import org.apache.olingo.odata2.api.edm.provider.EntityType;
-
-/**
- * A view on Java Persistence entity types and EDM entity types. Java
- * persistence entity types are converted into EDM entity types.
- * <p>
- * The implementation of the view provides access to EDM entity types for the
- * given JPA EDM model. The view acts as a container for consistent list of EDM
- * entity types. An EDM entity type is said to be consistent only if it has at
- * least one consistent EDM property and at least one consistent EDM key.
- *
- *
- * <p>
- * @org.apache.olingo.odata2.DoNotImplement
- * @see org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmPropertyView
- * @see org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmKeyView
- * @see org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmNavigationPropertyView
- *
- */
-public interface JPAEdmEntityTypeView extends JPAEdmBaseView {
- /**
- * The method returns an EDM entity currently being processed.
- *
- * @return an instance of type {@link org.apache.olingo.odata2.api.edm.provider.EntityType}
- */
- public EntityType getEdmEntityType();
-
- /**
- * The method returns java persistence Entity type currently being
- * processed.
- *
- * @return an instance of type {@link javax.persistence.metamodel.EntityType}
- */
- public javax.persistence.metamodel.EntityType<?> getJPAEntityType();
-
- /**
- * The method returns a consistent list of EDM entity types for a given java
- * persistence meta model.
- *
- * @return a list of {@link org.apache.olingo.odata2.api.edm.provider.EntityType}
- */
- public List<EntityType> getConsistentEdmEntityTypes();
-
- /**
- * The method searches in the consistent list of EDM entity types for the
- * given EDM entity type's name.
- *
- * @param jpaEntityTypeName
- * is the name of EDM entity type
- * @return a reference to EDM entity type if found else null
- */
- public EntityType searchEdmEntityType(String jpaEntityTypeName);
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmExtension.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmExtension.java b/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmExtension.java
deleted file mode 100644
index 1345106..0000000
--- a/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmExtension.java
+++ /dev/null
@@ -1,50 +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.api.jpa.model;
-
-/**
- * The interface provides methods to extend JPA EDM containers.
- *
- *
- *
- */
-public interface JPAEdmExtension {
-
- /**
- * The method is used to extend the JPA EDM schema view with custom operations. Use this method to
- * register custom operations.
- *
- * @param view
- * is the schema view
- * @see org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmSchemaView#registerOperations(Class, String[])
- *
- */
- public void extendWithOperation(JPAEdmSchemaView view);
-
- /**
- * The method is used to extend the JPA EDM schema view with Entities, Entity Sets, Navigation Property and
- * Association.
- *
- * @param view
- * is the schema view
- *
- */
- public void extendJPAEdmSchema(JPAEdmSchemaView view);
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmFunctionImportView.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmFunctionImportView.java b/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmFunctionImportView.java
deleted file mode 100644
index be19742..0000000
--- a/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmFunctionImportView.java
+++ /dev/null
@@ -1,51 +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.api.jpa.model;
-
-import java.util.List;
-
-import org.apache.olingo.odata2.api.edm.provider.FunctionImport;
-
-/**
- * <p>
- * A view on EDM Function Imports. EDM function imports are derived from Java
- * class methods annotated with EDM Annotations.
- * </p>
- * <p>
- * The implementation of the view provides access to EDM Function Import created
- * from Java class methods. The implementation act as a container for list of
- * function imports that are consistent.
- * </p>
- *
- *
- * <p>
- * @org.apache.olingo.odata2.DoNotImplement
- *
- */
-public interface JPAEdmFunctionImportView extends JPAEdmBaseView {
-
- /**
- * The method returns a list of consistent Function Imports. A function
- * import is said to be consistent only if it adheres to the rules defined
- * in CSDL.
- *
- * @return a list of type {@link org.apache.olingo.odata2.api.edm.provider.FunctionImport}
- */
- List<FunctionImport> getConsistentFunctionImportList();
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmKeyView.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmKeyView.java b/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmKeyView.java
deleted file mode 100644
index a684126..0000000
--- a/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmKeyView.java
+++ /dev/null
@@ -1,51 +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.api.jpa.model;
-
-import org.apache.olingo.odata2.api.edm.provider.Key;
-
-/**
- * A view on Java Persistence Entity Key Attributes and EDM Key properties. Java
- * Persistence Key Attributes of type
- * <ol>
- * <li>embedded ID</li>
- * <li>ID</li>
- * </ol>
- * are converted into EDM keys. Embedded IDs are expanded into simple EDM
- * properties.
- * <p>
- * The implementation of the view provides access to EDM key properties for a
- * given JPA EDM entity type. The view acts as a container for consistent EDM
- * key property of an EDM entity type.
- *
- *
- * <p>
- * @org.apache.olingo.odata2.DoNotImplement
- * @see org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmPropertyView
- *
- */
-public interface JPAEdmKeyView extends JPAEdmBaseView {
- /**
- * The method returns an instance of EDM key for the given JPA EDM Entity
- * type.
- *
- * @return an instance of type {@link org.apache.olingo.odata2.api.edm.provider.Key}
- */
- public Key getEdmKey();
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmMapping.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmMapping.java b/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmMapping.java
deleted file mode 100644
index 4c44083..0000000
--- a/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmMapping.java
+++ /dev/null
@@ -1,63 +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.api.jpa.model;
-
-/**
- * The interface acts a container for storing Java persistence column name. The
- * JPA EDM mapping instance can be associated with any EDM simple, EDM complex
- * property to denote the properties Java persistence column name.
- *
- *
- *
- */
-public interface JPAEdmMapping {
- /**
- * The method sets the Java persistence column name into the mapping
- * container.
- *
- * @param name
- * is the Java persistence column name
- */
- public void setJPAColumnName(String name);
-
- /**
- * The method gets the Java persistence column name from the mapping
- * container.
- *
- * @return a String representing the Java persistence column name set into
- * the container
- */
- public String getJPAColumnName();
-
- /**
- * The method sets the Java persistence entity/property type.
- *
- * @param type
- * is an instance of type Class<?>
- */
- public void setJPAType(Class<?> type);
-
- /**
- * The method returns the Java persistence entity/property type.
- *
- * @return type
- */
- public Class<?> getJPAType();
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmModelView.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmModelView.java b/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmModelView.java
deleted file mode 100644
index 4c9a777..0000000
--- a/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmModelView.java
+++ /dev/null
@@ -1,43 +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.api.jpa.model;
-
-/**
- * A view on JPA meta model and EDM meta model. The view acts as the base for
- * the construction of EDM meta model from a JPA meta model.
- * <p>
- * The implementation of the view acts as the container for JPA meta model and
- * EDM meta model. The instance of JPA EDM meta model can be created using
- * {@link org.apache.olingo.odata2.processor.api.jpa.factory.JPAAccessFactory}. The
- * instance thus obtained can be used for constructing other elements of the
- * meta model using {@link org.apache.olingo.odata2.processor.api.jpa.access.JPAEdmBuilder}.
- *
- *
- * @org.apache.olingo.odata2.DoNotImplement
- * @see org.apache.olingo.odata2.processor.api.jpa.factory.JPAAccessFactory
- */
-public interface JPAEdmModelView extends JPAEdmBaseView {
- /**
- * The method returns a consistent JPA EDM schema view created from the JPA
- * meta model.
- *
- * @return an instance of type {@link org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmSchemaView}
- */
- public JPAEdmSchemaView getEdmSchemaView();
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmNavigationPropertyView.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmNavigationPropertyView.java b/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmNavigationPropertyView.java
deleted file mode 100644
index e1b0d3d..0000000
--- a/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmNavigationPropertyView.java
+++ /dev/null
@@ -1,72 +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.api.jpa.model;
-
-import java.util.List;
-
-import org.apache.olingo.odata2.api.edm.provider.NavigationProperty;
-
-/**
- * A view on Java persistence entity relationship and EDM navigation property.
- * Java persistence entity relationships annotated as
- * <ol>
- * <li>Many To Many</li>
- * <li>One To Many</li>
- * <li>One To One</li>
- * <li>Many To One</li>
- * </ol>
- * are transformed into navigation properties.
- * <p>
- * The implementation of the view provides access to EDM navigation properties
- * for a given JPA EDM entity type. The view acts as a container for consistent
- * list of EDM navigation properties of an EDM entity type. EDM navigation
- * property is consistent only if there exists a consistent EDM association.
- *
- *
- * @org.apache.olingo.odata2.DoNotImplement
- * @see org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmAssociationView
- *
- */
-public interface JPAEdmNavigationPropertyView extends JPAEdmBaseView {
- /**
- * The method adds a navigation property view to its container.
- *
- * @param view
- * is an instance of type {@link org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmNavigationPropertyView}
- */
- void addJPAEdmNavigationPropertyView(JPAEdmNavigationPropertyView view);
-
- /**
- * The method returns a consistent list of EDM navigation property. A
- * navigation property is consistent only if all its mandatory properties
- * can be built with no errors from Java persistence entity relationship.
- *
- * @return a list of consistent EDM navigation property for the Entity
- */
- List<NavigationProperty> getConsistentEdmNavigationProperties();
-
- /**
- * The method returns the navigation property that is currently being
- * processed.
- *
- * @return an instance of type {@link org.apache.olingo.odata2.api.edm.provider.NavigationProperty}
- */
- NavigationProperty getEdmNavigationProperty();
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmPropertyView.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmPropertyView.java b/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmPropertyView.java
deleted file mode 100644
index 742d5c8..0000000
--- a/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmPropertyView.java
+++ /dev/null
@@ -1,104 +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.api.jpa.model;
-
-import java.util.List;
-
-import javax.persistence.metamodel.Attribute;
-
-import org.apache.olingo.odata2.api.edm.provider.Property;
-import org.apache.olingo.odata2.api.edm.provider.SimpleProperty;
-
-/**
- * A view on Java Persistence Entity Attributes and EDM properties. Java
- * Persistence Attributes of type
- * <ol>
- * <li>embedded ID - are converted into EDM keys</li>
- * <li>ID - are converted into EDM keys</li>
- * <li>attributes - are converted into EDM properties</li>
- * <li>embeddable type - are converted into EDM complex properties</li>
- * <li>relationships - are converted into Associations/Navigation properties</li>
- * </ol>
- * <p>
- * The implementation of the view provides access to EDM properties for a given
- * JPA EDM entity type. The view acts as a container for consistent list of EDM
- * properties of an EDM entity type. EDM property is consistent only if there
- * exists at least one property in the entity type and there is at least one key
- * property.
- *
- *
- * <p>
- * @org.apache.olingo.odata2.DoNotImplement
- * @see org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmKeyView
- * @see org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmNavigationPropertyView
- *
- */
-public interface JPAEdmPropertyView extends JPAEdmBaseView {
- /**
- * The method returns a simple EDM property.
- *
- * @return an instance of type {@link org.apache.olingo.odata2.api.edm.provider.SimpleProperty}
- */
- SimpleProperty getEdmSimpleProperty();
-
- /**
- * The method returns a JPA EDM key view.
- *
- * @return an instance of type {@link org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmKeyView}
- */
- JPAEdmKeyView getJPAEdmKeyView();
-
- /**
- * The method returns a list of Properties for the given Entity Type.
- *
- * @return a list of {@link org.apache.olingo.odata2.api.edm.provider.Property}
- */
- List<Property> getEdmPropertyList();
-
- /**
- * The method returns a JPA Attribute for the given JPA entity type.
- *
- * @return an instance of type {@link javax.persistence.metamodel.Attribute
- * <?, ?>}
- */
- Attribute<?, ?> getJPAAttribute();
-
- /**
- * The method returns a JPA EDM navigation property view.
- *
- * @return an instance of type {@link org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmNavigationPropertyView}
- */
- JPAEdmNavigationPropertyView getJPAEdmNavigationPropertyView();
-
- /**
- * The method returns a JPA EDM Entity Type view that holds the property
- * view.
- *
- * @return an instance of type {@link org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmEntityTypeView}
- */
- JPAEdmEntityTypeView getJPAEdmEntityTypeView();
-
- /**
- * The method returns a JPA EDM Complex Type view that holds the property
- * view.
- *
- * @return an instance of type {@link org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmComplexTypeView}
- */
- JPAEdmComplexTypeView getJPAEdmComplexTypeView();
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmReferentialConstraintRoleView.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmReferentialConstraintRoleView.java b/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmReferentialConstraintRoleView.java
deleted file mode 100644
index ebf945c..0000000
--- a/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmReferentialConstraintRoleView.java
+++ /dev/null
@@ -1,101 +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.api.jpa.model;
-
-import org.apache.olingo.odata2.api.edm.provider.ReferentialConstraintRole;
-
-/**
- * <p>
- * A view on Java Persistence Entity Join Column's "name" and
- * "referenced column name" attributes and Entity Data Model Referential
- * Constraint's dependent and principal roles respectively. Each java
- * persistence entity with properties annotated with Join Columns are
- * transformed into Referential constraints and Referential constraint roles.
- * </p>
- * <p>
- * The implementation of the view provides access to EDM referential constraint
- * roles created from Java Persistence Entity Join Columns. The implementation
- * acts as a container for EDM referential constraint roles. A referential
- * constraint role is consistent only if the principal role and dependent roles
- * can be created from JPA Entity relationships.
- * </p>
- *
- *
- * <p>
- * @org.apache.olingo.odata2.DoNotImplement
- * @see org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmReferentialConstraintView
- *
- */
-public interface JPAEdmReferentialConstraintRoleView extends JPAEdmBaseView {
- /**
- * Two types of EDM roles of a referential constraint.
- */
- public enum RoleType {
- PRINCIPAL, DEPENDENT
- }
-
- /**
- * The method returns the role type (PRINCIPAL or DEPENDENT)
- *
- * @return a {@link org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmReferentialConstraintRoleView.RoleType}
- */
- RoleType getRoleType();
-
- /**
- * The method returns the Referential constraint role that is currently
- * being processed.
- *
- * @return an instance of type {@link org.apache.olingo.odata2.api.edm.provider.ReferentialConstraintRole}
- */
- ReferentialConstraintRole getEdmReferentialConstraintRole();
-
- /**
- * The method returns the name of JPA attribute's column name (annotated
- * with @Column). The returned Column Name acts as the PRINCIPAL entity
- * type.
- *
- * @return name of JPA Column name
- */
- String getJPAColumnName();
-
- /**
- * The method returns the EDM entity type name that holds the
- * relationship/referential constraint. The entity type that acts as a
- * DEPENDENT entity type.
- *
- * @return name of EDM entity type
- */
- String getEdmEntityTypeName();
-
- /**
- * The method returns the EDM association name.
- *
- * @return name of EDM association
- */
- String getEdmAssociationName();
-
- /**
- * The method tells if there exists a valid referential constraint for a
- * given association.
- *
- * @return true - if valid referential constraint exits else false
- */
- boolean isExists();
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmReferentialConstraintView.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmReferentialConstraintView.java b/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmReferentialConstraintView.java
deleted file mode 100644
index 4b90edb..0000000
--- a/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmReferentialConstraintView.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.api.jpa.model;
-
-import org.apache.olingo.odata2.api.edm.provider.ReferentialConstraint;
-
-/**
- * <p>
- * A view on Java Persistence Entity Join Columns and Entity Data Model
- * Referential Constraint. Each java persistence entity with properties
- * annotated with Join Columns are transformed into Referential constraints.
- * </p>
- * <p>
- * The implementation of the view provides access to EDM referential constraint
- * created from Java Persistence Entity Join Columns. The implementation acts as
- * a container for EDM referential constraint. A referential constraint is said
- * to be consistent only if referential constraint role is consistent.
- * </p>
- *
- * <br>
- * @org.apache.olingo.odata2.DoNotImplement
- * <br>
- * @see org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmReferentialConstraintRoleView
- *
- */
-public interface JPAEdmReferentialConstraintView extends JPAEdmBaseView {
-
- /**
- * The method returns EDM referential constraint created from Java
- * persistence Entity Join Columns.
- *
- * @return an instance of type {@link org.apache.olingo.odata2.api.edm.provider.ReferentialConstraint}
- */
- public ReferentialConstraint getEdmReferentialConstraint();
-
- /**
- * The method returns if a valid referential constraint exists for a given
- * EDM association. If there exists a JPA entity relationship with join
- * column having a valid "Name" and "ReferenceColumnName", that can be
- * mapped to EDM properties in dependent and source EDM entities
- * respectively then a valid EDM referential constraint exists.
- *
- * @return true if there exists a valid referential constraint else false.
- */
- public boolean isExists();
-
- /**
- * The method returns the name of EDM Association.
- *
- * @return name of an EDM association
- */
- public String getEdmRelationShipName();
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmSchemaView.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmSchemaView.java b/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmSchemaView.java
deleted file mode 100644
index d52d9a3..0000000
--- a/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmSchemaView.java
+++ /dev/null
@@ -1,116 +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.api.jpa.model;
-
-import java.util.HashMap;
-import java.util.List;
-
-import org.apache.olingo.odata2.api.edm.provider.Schema;
-
-/**
- * <p>
- * A view on Java Persistence Model and Entity Data Model Schema. Each java
- * persistence unit corresponds to a one EDM schema.
- * </p>
- * <p>
- * The implementation of the view provides access to EDM schema created from
- * Java Persistence unit. The implementation acts as a container for schema. The
- * schema is consistent only if following elements are consistent
- * <ol>
- * <li>{@link org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmAssociationView}</li>
- * <li> {@link org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmEntityContainerView}</li>
- * <li>{@link org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmComplexTypeView}</li>
- * </ol>
- * </p>
- *
- *
- * <p>
- * @org.apache.olingo.odata2.DoNotImplement
- * @see org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmAssociationView
- * @see org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmEntityContainerView
- * @see org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmComplexTypeView
- *
- */
-public interface JPAEdmSchemaView extends JPAEdmBaseView {
- /**
- * The method returns the EDM schema present in the container.
- *
- * @return an instance EDM schema of type {@link org.apache.olingo.odata2.api.edm.provider.Schema}
- */
- public Schema getEdmSchema();
-
- /**
- * The method returns JPA EDM container view. The JPA EDM container view can
- * be used to access EDM Entity Container elements.
- *
- * @return an instance of type {@link org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmEntityContainerView}
- */
- public JPAEdmEntityContainerView getJPAEdmEntityContainerView();
-
- /**
- * The method returns JPA EDM complex view. The JPA EDM complex view can be
- * used to access EDM complex types and JPA Embeddable Types.
- *
- * @return an instance of type {@link org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmComplexTypeView}
- */
- public JPAEdmComplexTypeView getJPAEdmComplexTypeView();
-
- /**
- * The method returns JPA EDM association view. The JPA EDM association view
- * can be used to access EDM associations and JPA Relationships.
- *
- * @return an instance of type {@link org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmAssociationView}
- */
- public JPAEdmAssociationView getJPAEdmAssociationView();
-
- /**
- * The method registers custom operations that shall be represented as Edm
- * Function Imports. Custom operations are created using Edm Annotation
- * {@link org.apache.olingo.odata2.api.annotation.edm.FunctionImport}.
- * <p>
- * Custom Operations can be part of JPA Entity or can be created in a class
- * other than JPA Entity. Such custom operations can be registered using
- * this method.
- * <p>
- * The method is a callback.
- *
- * @param customClass
- * is the class that contains custom operations
- * @param methodNames
- * is the name of the method that needs to be transformed into
- * Function Imports. It is an optional parameter. If null is
- * passed then all annotated methods are transformed into
- * Function Imports.
- *
- */
- public void registerOperations(Class<?> customClass, String methodNames[]);
-
- /**
- * The method returns an Hash Map containing the registered custom
- * operations.
- *
- * @return a HashMap of Class and the methods in the class
- */
- public HashMap<Class<?>, String[]> getRegisteredOperations();
-
- public List<String> getNonKeyComplexTypeList();
-
- public void addNonKeyComplexName(String complexTypeName);
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/mapping/JPAAttributeMapType.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/mapping/JPAAttributeMapType.java b/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/mapping/JPAAttributeMapType.java
deleted file mode 100644
index 7c9278f..0000000
--- a/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/mapping/JPAAttributeMapType.java
+++ /dev/null
@@ -1,202 +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.api.jpa.model.mapping;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.xml.bind.annotation.XmlAccessType;
-import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlAttribute;
-import javax.xml.bind.annotation.XmlElement;
-import javax.xml.bind.annotation.XmlType;
-import javax.xml.bind.annotation.XmlValue;
-
-/**
- *
- * The default name for EDM
- * property is derived from JPA attribute name. This can be overriden
- * using
- * JPAAttributeMapType.
- *
- *
- * <p>Java class for JPAAttributeMapType complex type.
- *
- * <p>The following schema fragment specifies the expected content contained within this class.
- *
- * <pre>
- * <complexType name="JPAAttributeMapType">
- * <complexContent>
- * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- * <sequence>
- * <element name="JPAAttribute" maxOccurs="unbounded" minOccurs="0">
- * <complexType>
- * <simpleContent>
- * <extension base="<http://www.w3.org/2001/XMLSchema>string">
- * <attribute name="name" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
- * <attribute name="exclude" type="{http://www.w3.org/2001/XMLSchema}boolean" default="false" />
- * </extension>
- * </simpleContent>
- * </complexType>
- * </element>
- * </sequence>
- * </restriction>
- * </complexContent>
- * </complexType>
- * </pre>
- *
- *
- */
-@XmlAccessorType(XmlAccessType.FIELD)
-@XmlType(name = "JPAAttributeMapType", propOrder = { "jpaAttribute" })
-public class JPAAttributeMapType {
-
- @XmlElement(name = "JPAAttribute")
- protected List<JPAAttributeMapType.JPAAttribute> jpaAttribute;
-
- /**
- * Gets the value of the jpaAttribute property.
- *
- * <p>
- * This accessor method returns a reference to the live list,
- * not a snapshot. Therefore any modification you make to the
- * returned list will be present inside the JAXB object.
- * This is why there is not a <CODE>set</CODE> method for the jpaAttribute property.
- *
- * <p>
- * For example, to add a new item, do as follows:
- * <pre>
- * getJPAAttribute().add(newItem);
- * </pre>
- *
- *
- * <p>
- * Objects of the following type(s) are allowed in the list {@link JPAAttributeMapType.JPAAttribute }
- *
- *
- */
- public List<JPAAttributeMapType.JPAAttribute> getJPAAttribute() {
- if (jpaAttribute == null) {
- jpaAttribute = new ArrayList<JPAAttributeMapType.JPAAttribute>();
- }
- return jpaAttribute;
- }
-
- /**
- * <p>Java class for anonymous complex type.
- *
- * <p>The following schema fragment specifies the expected content contained within this class.
- *
- * <pre>
- * <complexType>
- * <simpleContent>
- * <extension base="<http://www.w3.org/2001/XMLSchema>string">
- * <attribute name="name" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
- * <attribute name="exclude" type="{http://www.w3.org/2001/XMLSchema}boolean" default="false" />
- * </extension>
- * </simpleContent>
- * </complexType>
- * </pre>
- *
- *
- */
- @XmlAccessorType(XmlAccessType.FIELD)
- @XmlType(name = "", propOrder = { "value" })
- public static class JPAAttribute {
-
- @XmlValue
- protected String value;
- @XmlAttribute(name = "name", required = true)
- protected String name;
- @XmlAttribute(name = "exclude")
- protected Boolean exclude;
-
- /**
- * Gets the value of the value property.
- *
- * @return
- * possible object is {@link String }
- *
- */
- public String getValue() {
- return value;
- }
-
- /**
- * Sets the value of the value property.
- *
- * @param value
- * allowed object is {@link String }
- *
- */
- public void setValue(final String value) {
- this.value = value;
- }
-
- /**
- * Gets the value of the name property.
- *
- * @return
- * possible object is {@link String }
- *
- */
- public String getName() {
- return name;
- }
-
- /**
- * Sets the value of the name property.
- *
- * @param value
- * allowed object is {@link String }
- *
- */
- public void setName(final String value) {
- name = value;
- }
-
- /**
- * Gets the value of the exclude property.
- *
- * @return
- * possible object is {@link Boolean }
- *
- */
- public boolean isExclude() {
- if (exclude == null) {
- return false;
- } else {
- return exclude;
- }
- }
-
- /**
- * Sets the value of the exclude property.
- *
- * @param value
- * allowed object is {@link Boolean }
- *
- */
- public void setExclude(final Boolean value) {
- exclude = value;
- }
-
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/mapping/JPAEdmMappingModel.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/mapping/JPAEdmMappingModel.java b/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/mapping/JPAEdmMappingModel.java
deleted file mode 100644
index a91f12a..0000000
--- a/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/mapping/JPAEdmMappingModel.java
+++ /dev/null
@@ -1,79 +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.api.jpa.model.mapping;
-
-import javax.xml.bind.annotation.XmlAccessType;
-import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlElement;
-import javax.xml.bind.annotation.XmlRootElement;
-import javax.xml.bind.annotation.XmlType;
-
-/**
- * <p>
- * Java class for anonymous complex type.
- *
- * <p>
- * The following schema fragment specifies the expected content contained within
- * this class.
- *
- * <pre>
- * <complexType>
- * <complexContent>
- * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- * <sequence>
- * <element name="PersistenceUnit"
- * type="{http://www.apache.org/olingo/odata2/processor/api/jpa/model/mapping}JPAPersistenceUnitMapType"/>
- * </sequence>
- * </restriction>
- * </complexContent>
- * </complexType>
- * </pre>
- *
- *
- */
-@XmlAccessorType(XmlAccessType.FIELD)
-@XmlType(name = "", propOrder = { "persistenceUnit" })
-@XmlRootElement(name = "JPAEDMMappingModel")
-public class JPAEdmMappingModel {
-
- @XmlElement(name = "PersistenceUnit", required = true)
- protected JPAPersistenceUnitMapType persistenceUnit;
-
- /**
- * Gets the value of the persistenceUnit property.
- *
- * @return possible object is {@link JPAPersistenceUnitMapType }
- *
- */
- public JPAPersistenceUnitMapType getPersistenceUnit() {
- return persistenceUnit;
- }
-
- /**
- * Sets the value of the persistenceUnit property.
- *
- * @param value
- * allowed object is {@link JPAPersistenceUnitMapType }
- *
- */
- public void setPersistenceUnit(final JPAPersistenceUnitMapType value) {
- persistenceUnit = value;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/mapping/JPAEdmMappingModelFactory.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/mapping/JPAEdmMappingModelFactory.java b/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/mapping/JPAEdmMappingModelFactory.java
deleted file mode 100644
index f0e9787..0000000
--- a/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/mapping/JPAEdmMappingModelFactory.java
+++ /dev/null
@@ -1,85 +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.api.jpa.model.mapping;
-
-import javax.xml.bind.annotation.XmlRegistry;
-
-/**
- * This object contains factory methods for each Java content interface and Java
- * element interface generated in the
- * org.apache.olingo.odata2.processor.api.jpa.model.mapping package.
- * <p>
- * An ObjectFactory allows you to programatically construct new instances of the
- * Java representation for XML content. The Java representation of XML content
- * can consist of schema derived interfaces and classes representing the binding
- * of schema type definitions, element declarations and model groups. Factory
- * methods for each of these are provided in this class.
- *
- */
-@XmlRegistry
-public class JPAEdmMappingModelFactory {
-
- /**
- * Create a new ObjectFactory that can be used to create new instances of
- * schema derived classes for package:
- * org.apache.olingo.odata2.processor.api.jpa.model.mapping
- *
- */
- public JPAEdmMappingModelFactory() {}
-
- /**
- * Create an instance of {@link org.apache.olingo.odata2.processor.api.jpa.model.mapping.JPARelationshipMapType }
- *
- */
- public JPARelationshipMapType createJPARelationshipMapType() {
- return new JPARelationshipMapType();
- }
-
- /**
- * Create an instance of {@link org.apache.olingo.odata2.processor.api.jpa.model.mapping.JPAAttributeMapType }
- *
- */
- public JPAAttributeMapType createJPAAttributeMapType() {
- return new JPAAttributeMapType();
- }
-
- /**
- * Create an instance of {@link org.apache.olingo.odata2.processor.api.jpa.model.mapping.JPAEdmMappingModel }
- *
- */
- public JPAEdmMappingModel createJPAEDMMappingModel() {
- return new JPAEdmMappingModel();
- }
-
- /**
- * Create an instance of {@link org.apache.olingo.odata2.processor.api.jpa.model.mapping.JPAPersistenceUnitMapType }
- *
- */
- public JPAPersistenceUnitMapType createJPAPersistenceUnitMapType() {
- return new JPAPersistenceUnitMapType();
- }
-
- /**
- * Create an instance of {@link org.apache.olingo.odata2.processor.api.jpa.model.mapping.JPAEmbeddableTypeMapType }
- *
- */
- public JPAEmbeddableTypeMapType createJPAEmbeddableTypeMapType() {
- return new JPAEmbeddableTypeMapType();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/mapping/JPAEmbeddableTypeMapType.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/mapping/JPAEmbeddableTypeMapType.java b/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/mapping/JPAEmbeddableTypeMapType.java
deleted file mode 100644
index f462a96..0000000
--- a/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/mapping/JPAEmbeddableTypeMapType.java
+++ /dev/null
@@ -1,161 +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.api.jpa.model.mapping;
-
-import javax.xml.bind.annotation.XmlAccessType;
-import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlAttribute;
-import javax.xml.bind.annotation.XmlElement;
-import javax.xml.bind.annotation.XmlType;
-
-/**
- *
- * The default name for EDM
- * complex type is derived from JPA Embeddable type name. This can be
- * overriden using JPAEmbeddableTypeMapType.
- *
- *
- * <p>Java class for JPAEmbeddableTypeMapType complex type.
- *
- * <p>The following schema fragment specifies the expected content contained within this class.
- *
- * <pre>
- * <complexType name="JPAEmbeddableTypeMapType">
- * <complexContent>
- * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- * <sequence>
- * <element name="EDMComplexType" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
- * <element name="JPAAttributes"
- * type="{http://www.apache.org/olingo/odata2/processor/api/jpa/model/mapping}JPAAttributeMapType"/>
- * </sequence>
- * <attribute name="name" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
- * <attribute name="exclude" type="{http://www.w3.org/2001/XMLSchema}boolean" default="false" />
- * </restriction>
- * </complexContent>
- * </complexType>
- * </pre>
- *
- *
- */
-@XmlAccessorType(XmlAccessType.FIELD)
-@XmlType(name = "JPAEmbeddableTypeMapType", propOrder = { "edmComplexType", "jpaAttributes" })
-public class JPAEmbeddableTypeMapType {
-
- @XmlElement(name = "EDMComplexType")
- protected String edmComplexType;
- @XmlElement(name = "JPAAttributes", required = true)
- protected JPAAttributeMapType jpaAttributes;
- @XmlAttribute(name = "name", required = true)
- protected String name;
- @XmlAttribute(name = "exclude")
- protected Boolean exclude;
-
- /**
- * Gets the value of the edmComplexType property.
- *
- * @return
- * possible object is {@link String }
- *
- */
- public String getEDMComplexType() {
- return edmComplexType;
- }
-
- /**
- * Sets the value of the edmComplexType property.
- *
- * @param value
- * allowed object is {@link String }
- *
- */
- public void setEDMComplexType(final String value) {
- edmComplexType = value;
- }
-
- /**
- * Gets the value of the jpaAttributes property.
- *
- * @return
- * possible object is {@link JPAAttributeMapType }
- *
- */
- public JPAAttributeMapType getJPAAttributes() {
- return jpaAttributes;
- }
-
- /**
- * Sets the value of the jpaAttributes property.
- *
- * @param value
- * allowed object is {@link JPAAttributeMapType }
- *
- */
- public void setJPAAttributes(final JPAAttributeMapType value) {
- jpaAttributes = value;
- }
-
- /**
- * Gets the value of the name property.
- *
- * @return
- * possible object is {@link String }
- *
- */
- public String getName() {
- return name;
- }
-
- /**
- * Sets the value of the name property.
- *
- * @param value
- * allowed object is {@link String }
- *
- */
- public void setName(final String value) {
- name = value;
- }
-
- /**
- * Gets the value of the exclude property.
- *
- * @return
- * possible object is {@link Boolean }
- *
- */
- public boolean isExclude() {
- if (exclude == null) {
- return false;
- } else {
- return exclude;
- }
- }
-
- /**
- * Sets the value of the exclude property.
- *
- * @param value
- * allowed object is {@link Boolean }
- *
- */
- public void setExclude(final Boolean value) {
- exclude = value;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/mapping/JPAEmbeddableTypesMapType.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/mapping/JPAEmbeddableTypesMapType.java b/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/mapping/JPAEmbeddableTypesMapType.java
deleted file mode 100644
index 131e738..0000000
--- a/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/mapping/JPAEmbeddableTypesMapType.java
+++ /dev/null
@@ -1,89 +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.api.jpa.model.mapping;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.xml.bind.annotation.XmlAccessType;
-import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlElement;
-import javax.xml.bind.annotation.XmlType;
-
-/**
- * <p>
- * Java class for JPAEmbeddableTypesMapType complex type.
- *
- * <p>
- * The following schema fragment specifies the expected content contained within
- * this class.
- *
- * <pre>
- * <complexType name="JPAEmbeddableTypesMapType">
- * <complexContent>
- * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- * <sequence>
- * <element name="JPAEmbeddableType"
- * type="{http://www.apache.org/olingo/odata2/processor/api/jpa/model/mapping}JPAEmbeddableTypeMapType"
- * maxOccurs="unbounded" minOccurs="0"/>
- * </sequence>
- * </restriction>
- * </complexContent>
- * </complexType>
- * </pre>
- *
- *
- */
-@XmlAccessorType(XmlAccessType.FIELD)
-@XmlType(name = "JPAEmbeddableTypesMapType", propOrder = { "jpaEmbeddableType" })
-public class JPAEmbeddableTypesMapType {
-
- @XmlElement(name = "JPAEmbeddableType")
- protected List<JPAEmbeddableTypeMapType> jpaEmbeddableType;
-
- /**
- * Gets the value of the jpaEmbeddableType property.
- *
- * <p>
- * This accessor method returns a reference to the live list, not a
- * snapshot. Therefore any modification you make to the returned list will
- * be present inside the JAXB object. This is why there is not a
- * <CODE>set</CODE> method for the jpaEmbeddableType property.
- *
- * <p>
- * For example, to add a new item, do as follows:
- *
- * <pre>
- * getJPAEmbeddableType().add(newItem);
- * </pre>
- *
- *
- * <p>
- * Objects of the following type(s) are allowed in the list {@link JPAEmbeddableTypeMapType }
- *
- *
- */
- public List<JPAEmbeddableTypeMapType> getJPAEmbeddableType() {
- if (jpaEmbeddableType == null) {
- jpaEmbeddableType = new ArrayList<JPAEmbeddableTypeMapType>();
- }
- return jpaEmbeddableType;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/mapping/JPAEntityTypeMapType.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/mapping/JPAEntityTypeMapType.java b/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/mapping/JPAEntityTypeMapType.java
deleted file mode 100644
index 2f4526c..0000000
--- a/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/mapping/JPAEntityTypeMapType.java
+++ /dev/null
@@ -1,213 +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.api.jpa.model.mapping;
-
-import javax.xml.bind.annotation.XmlAccessType;
-import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlAttribute;
-import javax.xml.bind.annotation.XmlElement;
-import javax.xml.bind.annotation.XmlType;
-
-/**
- *
- * The default name for EDM
- * entity type is derived from JPA entity type name. This can be
- * overriden using JPAEntityTypeMapType.
- *
- *
- * <p>Java class for JPAEntityTypeMapType complex type.
- *
- * <p>The following schema fragment specifies the expected content contained within this class.
- *
- * <pre>
- * <complexType name="JPAEntityTypeMapType">
- * <complexContent>
- * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- * <sequence>
- * <element name="EDMEntityType" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
- * <element name="EDMEntitySet" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
- * <element name="JPAAttributes"
- * type="{http://www.apache.org/olingo/odata2/processor/api/jpa/model/mapping}JPAAttributeMapType"/>
- * <element name="JPARelationships"
- * type="{http://www.apache.org/olingo/odata2/processor/api/jpa/model/mapping}JPARelationshipMapType"/>
- * </sequence>
- * <attribute name="name" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
- * <attribute name="exclude" type="{http://www.w3.org/2001/XMLSchema}boolean" default="false" />
- * </restriction>
- * </complexContent>
- * </complexType>
- * </pre>
- *
- *
- */
-@XmlAccessorType(XmlAccessType.FIELD)
-@XmlType(name = "JPAEntityTypeMapType", propOrder = { "edmEntityType", "edmEntitySet", "jpaAttributes",
- "jpaRelationships" })
-public class JPAEntityTypeMapType {
-
- @XmlElement(name = "EDMEntityType")
- protected String edmEntityType;
- @XmlElement(name = "EDMEntitySet")
- protected String edmEntitySet;
- @XmlElement(name = "JPAAttributes", required = true)
- protected JPAAttributeMapType jpaAttributes;
- @XmlElement(name = "JPARelationships", required = true)
- protected JPARelationshipMapType jpaRelationships;
- @XmlAttribute(name = "name", required = true)
- protected String name;
- @XmlAttribute(name = "exclude")
- protected Boolean exclude;
-
- /**
- * Gets the value of the edmEntityType property.
- *
- * @return
- * possible object is {@link String }
- *
- */
- public String getEDMEntityType() {
- return edmEntityType;
- }
-
- /**
- * Sets the value of the edmEntityType property.
- *
- * @param value
- * allowed object is {@link String }
- *
- */
- public void setEDMEntityType(final String value) {
- edmEntityType = value;
- }
-
- /**
- * Gets the value of the edmEntitySet property.
- *
- * @return
- * possible object is {@link String }
- *
- */
- public String getEDMEntitySet() {
- return edmEntitySet;
- }
-
- /**
- * Sets the value of the edmEntitySet property.
- *
- * @param value
- * allowed object is {@link String }
- *
- */
- public void setEDMEntitySet(final String value) {
- edmEntitySet = value;
- }
-
- /**
- * Gets the value of the jpaAttributes property.
- *
- * @return
- * possible object is {@link JPAAttributeMapType }
- *
- */
- public JPAAttributeMapType getJPAAttributes() {
- return jpaAttributes;
- }
-
- /**
- * Sets the value of the jpaAttributes property.
- *
- * @param value
- * allowed object is {@link JPAAttributeMapType }
- *
- */
- public void setJPAAttributes(final JPAAttributeMapType value) {
- jpaAttributes = value;
- }
-
- /**
- * Gets the value of the jpaRelationships property.
- *
- * @return
- * possible object is {@link JPARelationshipMapType }
- *
- */
- public JPARelationshipMapType getJPARelationships() {
- return jpaRelationships;
- }
-
- /**
- * Sets the value of the jpaRelationships property.
- *
- * @param value
- * allowed object is {@link JPARelationshipMapType }
- *
- */
- public void setJPARelationships(final JPARelationshipMapType value) {
- jpaRelationships = value;
- }
-
- /**
- * Gets the value of the name property.
- *
- * @return
- * possible object is {@link String }
- *
- */
- public String getName() {
- return name;
- }
-
- /**
- * Sets the value of the name property.
- *
- * @param value
- * allowed object is {@link String }
- *
- */
- public void setName(final String value) {
- name = value;
- }
-
- /**
- * Gets the value of the exclude property.
- *
- * @return
- * possible object is {@link Boolean }
- *
- */
- public boolean isExclude() {
- if (exclude == null) {
- return false;
- } else {
- return exclude;
- }
- }
-
- /**
- * Sets the value of the exclude property.
- *
- * @param value
- * allowed object is {@link Boolean }
- *
- */
- public void setExclude(final Boolean value) {
- exclude = value;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/mapping/JPAEntityTypesMapType.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/mapping/JPAEntityTypesMapType.java b/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/mapping/JPAEntityTypesMapType.java
deleted file mode 100644
index cd2a6de..0000000
--- a/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/mapping/JPAEntityTypesMapType.java
+++ /dev/null
@@ -1,89 +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.api.jpa.model.mapping;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.xml.bind.annotation.XmlAccessType;
-import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlElement;
-import javax.xml.bind.annotation.XmlType;
-
-/**
- * <p>
- * Java class for JPAEntityTypesMapType complex type.
- *
- * <p>
- * The following schema fragment specifies the expected content contained within
- * this class.
- *
- * <pre>
- * <complexType name="JPAEntityTypesMapType">
- * <complexContent>
- * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- * <sequence>
- * <element name="JPAEntityType"
- * type="{http://www.apache.org/olingo/odata2/processor/api/jpa/model/mapping}JPAEntityTypeMapType"
- * maxOccurs="unbounded" minOccurs="0"/>
- * </sequence>
- * </restriction>
- * </complexContent>
- * </complexType>
- * </pre>
- *
- *
- */
-@XmlAccessorType(XmlAccessType.FIELD)
-@XmlType(name = "JPAEntityTypesMapType", propOrder = { "jpaEntityType" })
-public class JPAEntityTypesMapType {
-
- @XmlElement(name = "JPAEntityType")
- protected List<JPAEntityTypeMapType> jpaEntityType;
-
- /**
- * Gets the value of the jpaEntityType property.
- *
- * <p>
- * This accessor method returns a reference to the live list, not a
- * snapshot. Therefore any modification you make to the returned list will
- * be present inside the JAXB object. This is why there is not a
- * <CODE>set</CODE> method for the jpaEntityType property.
- *
- * <p>
- * For example, to add a new item, do as follows:
- *
- * <pre>
- * getJPAEntityType().add(newItem);
- * </pre>
- *
- *
- * <p>
- * Objects of the following type(s) are allowed in the list {@link JPAEntityTypeMapType }
- *
- *
- */
- public List<JPAEntityTypeMapType> getJPAEntityType() {
- if (jpaEntityType == null) {
- jpaEntityType = new ArrayList<JPAEntityTypeMapType>();
- }
- return jpaEntityType;
- }
-
-}
[16/37] [OLINGO-82] Renamed the project folder name to
odata2-jpa-processor
Posted by ch...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/mapping/JPAPersistenceUnitMapType.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/mapping/JPAPersistenceUnitMapType.java b/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/mapping/JPAPersistenceUnitMapType.java
deleted file mode 100644
index a9d34b2..0000000
--- a/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/mapping/JPAPersistenceUnitMapType.java
+++ /dev/null
@@ -1,157 +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.api.jpa.model.mapping;
-
-import javax.xml.bind.annotation.XmlAccessType;
-import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlAttribute;
-import javax.xml.bind.annotation.XmlElement;
-import javax.xml.bind.annotation.XmlType;
-
-/**
- *
- * By default Java Persistence Unit name is taken as EDM schema name. This can
- * be overriden using JPAPersistenceUnitMapType.
- *
- *
- * <p>
- * Java class for JPAPersistenceUnitMapType complex type.
- *
- * <p>
- * The following schema fragment specifies the expected content contained within
- * this class.
- *
- * <pre>
- * <complexType name="JPAPersistenceUnitMapType">
- * <complexContent>
- * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- * <sequence>
- * <element name="EDMSchemaNamespace" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
- * <element name="JPAEntityTypes"
- * type="{http://www.apache.org/olingo/odata2/processor/api/jpa/model/mapping}JPAEntityTypesMapType"/>
- * <element name="JPAEmbeddableTypes"
- * type="{http://www.apache.org/olingo/odata2/processor/api/jpa/model/mapping}JPAEmbeddableTypesMapType"/>
- * </sequence>
- * <attribute name="name" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
- * </restriction>
- * </complexContent>
- * </complexType>
- * </pre>
- *
- *
- */
-@XmlAccessorType(XmlAccessType.FIELD)
-@XmlType(name = "JPAPersistenceUnitMapType",
- propOrder = { "edmSchemaNamespace", "jpaEntityTypes", "jpaEmbeddableTypes" })
-public class JPAPersistenceUnitMapType {
-
- @XmlElement(name = "EDMSchemaNamespace")
- protected String edmSchemaNamespace;
- @XmlElement(name = "JPAEntityTypes", required = true)
- protected JPAEntityTypesMapType jpaEntityTypes;
- @XmlElement(name = "JPAEmbeddableTypes", required = true)
- protected JPAEmbeddableTypesMapType jpaEmbeddableTypes;
- @XmlAttribute(name = "name", required = true)
- protected String name;
-
- /**
- * Gets the value of the edmSchemaNamespace property.
- *
- * @return possible object is {@link String }
- *
- */
- public String getEDMSchemaNamespace() {
- return edmSchemaNamespace;
- }
-
- /**
- * Sets the value of the edmSchemaNamespace property.
- *
- * @param value
- * allowed object is {@link String }
- *
- */
- public void setEDMSchemaNamespace(final String value) {
- edmSchemaNamespace = value;
- }
-
- /**
- * Gets the value of the jpaEntityTypes property.
- *
- * @return possible object is {@link JPAEntityTypesMapType }
- *
- */
- public JPAEntityTypesMapType getJPAEntityTypes() {
- return jpaEntityTypes;
- }
-
- /**
- * Sets the value of the jpaEntityTypes property.
- *
- * @param value
- * allowed object is {@link JPAEntityTypesMapType }
- *
- */
- public void setJPAEntityTypes(final JPAEntityTypesMapType value) {
- jpaEntityTypes = value;
- }
-
- /**
- * Gets the value of the jpaEmbeddableTypes property.
- *
- * @return possible object is {@link JPAEmbeddableTypesMapType }
- *
- */
- public JPAEmbeddableTypesMapType getJPAEmbeddableTypes() {
- return jpaEmbeddableTypes;
- }
-
- /**
- * Sets the value of the jpaEmbeddableTypes property.
- *
- * @param value
- * allowed object is {@link JPAEmbeddableTypesMapType }
- *
- */
- public void setJPAEmbeddableTypes(final JPAEmbeddableTypesMapType value) {
- jpaEmbeddableTypes = value;
- }
-
- /**
- * Gets the value of the name property.
- *
- * @return possible object is {@link String }
- *
- */
- public String getName() {
- return name;
- }
-
- /**
- * Sets the value of the name property.
- *
- * @param value
- * allowed object is {@link String }
- *
- */
- public void setName(final String value) {
- name = value;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/mapping/JPARelationshipMapType.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/mapping/JPARelationshipMapType.java b/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/mapping/JPARelationshipMapType.java
deleted file mode 100644
index 986c187..0000000
--- a/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/mapping/JPARelationshipMapType.java
+++ /dev/null
@@ -1,175 +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.api.jpa.model.mapping;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.xml.bind.annotation.XmlAccessType;
-import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlAttribute;
-import javax.xml.bind.annotation.XmlElement;
-import javax.xml.bind.annotation.XmlType;
-import javax.xml.bind.annotation.XmlValue;
-
-/**
- *
- * The default name for EDM navigation property is derived from JPA relationship
- * name. This can be overriden using JPARelationshipMapType.
- *
- *
- * <p>
- * Java class for JPARelationshipMapType complex type.
- *
- * <p>
- * The following schema fragment specifies the expected content contained within
- * this class.
- *
- * <pre>
- * <complexType name="JPARelationshipMapType">
- * <complexContent>
- * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- * <sequence>
- * <element name="JPARelationship" maxOccurs="unbounded" minOccurs="0">
- * <complexType>
- * <simpleContent>
- * <extension base="<http://www.w3.org/2001/XMLSchema>string">
- * <attribute name="name" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
- * </extension>
- * </simpleContent>
- * </complexType>
- * </element>
- * </sequence>
- * </restriction>
- * </complexContent>
- * </complexType>
- * </pre>
- *
- *
- */
-@XmlAccessorType(XmlAccessType.FIELD)
-@XmlType(name = "JPARelationshipMapType", propOrder = { "jpaRelationship" })
-public class JPARelationshipMapType {
-
- @XmlElement(name = "JPARelationship")
- protected List<JPARelationshipMapType.JPARelationship> jpaRelationship;
-
- /**
- * Gets the value of the jpaRelationship property.
- *
- * <p>
- * This accessor method returns a reference to the live list, not a
- * snapshot. Therefore any modification you make to the returned list will
- * be present inside the JAXB object. This is why there is not a
- * <CODE>set</CODE> method for the jpaRelationship property.
- *
- * <p>
- * For example, to add a new item, do as follows:
- *
- * <pre>
- * getJPARelationship().add(newItem);
- * </pre>
- *
- *
- * <p>
- * Objects of the following type(s) are allowed in the list {@link JPARelationshipMapType.JPARelationship }
- *
- *
- */
- public List<JPARelationshipMapType.JPARelationship> getJPARelationship() {
- if (jpaRelationship == null) {
- jpaRelationship = new ArrayList<JPARelationshipMapType.JPARelationship>();
- }
- return jpaRelationship;
- }
-
- /**
- * <p>
- * Java class for anonymous complex type.
- *
- * <p>
- * The following schema fragment specifies the expected content contained
- * within this class.
- *
- * <pre>
- * <complexType>
- * <simpleContent>
- * <extension base="<http://www.w3.org/2001/XMLSchema>string">
- * <attribute name="name" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
- * </extension>
- * </simpleContent>
- * </complexType>
- * </pre>
- *
- *
- */
- @XmlAccessorType(XmlAccessType.FIELD)
- @XmlType(name = "", propOrder = { "value" })
- public static class JPARelationship {
-
- @XmlValue
- protected String value;
- @XmlAttribute(name = "name", required = true)
- protected String name;
-
- /**
- * Gets the value of the value property.
- *
- * @return possible object is {@link String }
- *
- */
- public String getValue() {
- return value;
- }
-
- /**
- * Sets the value of the value property.
- *
- * @param value
- * allowed object is {@link String }
- *
- */
- public void setValue(final String value) {
- this.value = value;
- }
-
- /**
- * Gets the value of the name property.
- *
- * @return possible object is {@link String }
- *
- */
- public String getName() {
- return name;
- }
-
- /**
- * Sets the value of the name property.
- *
- * @param value
- * allowed object is {@link String }
- *
- */
- public void setName(final String value) {
- name = value;
- }
-
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/mapping/package-info.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/mapping/package-info.java b/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/mapping/package-info.java
deleted file mode 100644
index 4593031..0000000
--- a/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/mapping/package-info.java
+++ /dev/null
@@ -1,28 +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.
- ******************************************************************************/
-/**
- * <h3>OData JPA Processor API Library - Mapping Model</h3>
- * The JPA EDM Mapping model (XML document) is represented as JAXB annotated Java Classes.
- *
- *
- */
-@javax.xml.bind.annotation.XmlSchema(namespace = "http://www.apache.org/olingo/odata2/processor/api/jpa/model/mapping",
- elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED)
-package org.apache.olingo.odata2.processor.api.jpa.model.mapping;
-
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/package-info.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/package-info.java b/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/package-info.java
deleted file mode 100644
index b2cf90a..0000000
--- a/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/package-info.java
+++ /dev/null
@@ -1,27 +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.
- ******************************************************************************/
-/**
- * <h3>OData JPA Processor API Library - JPA EDM Model</h3>
- * The library provides a set of views over the JPA/EDM element containers.
- * The views can used to access the elements that form EDM.
- *
- *
- */
-package org.apache.olingo.odata2.processor.api.jpa.model;
-
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/package-info.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/package-info.java b/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/package-info.java
deleted file mode 100644
index 89f4974..0000000
--- a/odata2-processor-jpa/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/package-info.java
+++ /dev/null
@@ -1,33 +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.
- ******************************************************************************/
-/**
- * <h3>OData JPA Processor API Library</h3>
- * The library provides a way for the developers to create an OData Service from a Java Persistence Model.
- * The library supports Java Persistence 2.0 and is dependent on OData library.
- *
- * To create an OData service from JPA models
- * <ol><li>extend the service factory class {@link org.apache.olingo.odata2.processor.api.jpa.ODataJPAServiceFactory}
- * and implement the methods</li>
- * <li>define a JAX-RS servlet in web.xml and configure the service factory as servlet init parameter.
- * <p><b>See Also:</b>{@link org.apache.olingo.odata2.processor.api.jpa.ODataJPAServiceFactory}</li></ol>
- *
- *
- */
-package org.apache.olingo.odata2.processor.api.jpa;
-
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-api/src/main/resources/JPAEDMMappingModel.xsd
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-api/src/main/resources/JPAEDMMappingModel.xsd b/odata2-processor-jpa/jpa-api/src/main/resources/JPAEDMMappingModel.xsd
deleted file mode 100644
index 07abdbf..0000000
--- a/odata2-processor-jpa/jpa-api/src/main/resources/JPAEDMMappingModel.xsd
+++ /dev/null
@@ -1,165 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- 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.
--->
-<xs:schema attributeFormDefault="unqualified"
- elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema"
- targetNamespace="http://www.apache.org/olingo/odata2/processor/api/jpa/model/mapping"
- xmlns:tns="http://www.apache.org/olingo/odata2/processor/api/jpa/model/mapping">
-
- <xs:element name="JPAEDMMappingModel">
- <xs:annotation>
- <xs:documentation xml:lang="en">
- Java Persistence (JPA) -
- Entity Data Model (EDM) Mapping schema. The schema defines a mapping
- model to describe EDM names for entity types, entity sets, entity
- properties, entity navigation properties. By default the names of
- Java Persistence entity types, entity attributes and entity
- relationships are transformed into their corresponding EDM names. To
- override the default names the mapping model is defined. Note:-
- Define the mapping model for only those default names that needs to
- be overriden.
- </xs:documentation>
- </xs:annotation>
- <xs:complexType>
- <xs:sequence>
- <xs:element name="PersistenceUnit" type="tns:JPAPersistenceUnitMapType"
- maxOccurs="1" minOccurs="1" />
- </xs:sequence>
- </xs:complexType>
- </xs:element>
-
- <xs:complexType name="JPAAttributeMapType">
- <xs:annotation>
- <xs:documentation xml:lang="en">
- The default name for EDM
- property is derived from JPA attribute name. This can be overriden
- using
- JPAAttributeMapType.
- </xs:documentation>
- </xs:annotation>
- <xs:sequence>
- <xs:element name="JPAAttribute" maxOccurs="unbounded"
- minOccurs="0">
- <xs:complexType>
- <xs:simpleContent>
- <xs:extension base="xs:string">
- <xs:attribute type="xs:string" name="name" use="required" />
- <xs:attribute type="xs:boolean" name="exclude" use="optional"
- default="false" />
- </xs:extension>
- </xs:simpleContent>
- </xs:complexType>
- </xs:element>
- </xs:sequence>
- </xs:complexType>
-
- <xs:complexType name="JPARelationshipMapType">
- <xs:annotation>
- <xs:documentation xml:lang="en">
- The default name for EDM
- navigation property is derived from JPA relationship name.
- This can
- be overriden using JPARelationshipMapType.
- </xs:documentation>
- </xs:annotation>
- <xs:sequence>
- <xs:element name="JPARelationship" maxOccurs="unbounded"
- minOccurs="0">
- <xs:complexType>
- <xs:simpleContent>
- <xs:extension base="xs:string">
- <xs:attribute type="xs:string" name="name" use="required" />
- </xs:extension>
- </xs:simpleContent>
- </xs:complexType>
- </xs:element>
- </xs:sequence>
- </xs:complexType>
-
- <xs:complexType name="JPAEntityTypeMapType">
- <xs:annotation>
- <xs:documentation xml:lang="en">
- The default name for EDM
- entity type is derived from JPA entity type name. This can be
- overriden using JPAEntityTypeMapType.
- </xs:documentation>
- </xs:annotation>
- <xs:sequence>
- <xs:element type="xs:string" name="EDMEntityType"
- maxOccurs="1" minOccurs="0" />
- <xs:element type="xs:string" name="EDMEntitySet"
- maxOccurs="1" minOccurs="0" />
- <xs:element name="JPAAttributes" type="tns:JPAAttributeMapType" />
- <xs:element name="JPARelationships" type="tns:JPARelationshipMapType" />
- </xs:sequence>
- <xs:attribute type="xs:string" name="name" use="required" />
- <xs:attribute type="xs:boolean" name="exclude" use="optional"
- default="false" />
- </xs:complexType>
-
- <xs:complexType name="JPAEntityTypesMapType">
- <xs:sequence>
- <xs:element name="JPAEntityType" type="tns:JPAEntityTypeMapType"
- maxOccurs="unbounded" minOccurs="0" />
- </xs:sequence>
- </xs:complexType>
- <xs:complexType name="JPAEmbeddableTypeMapType">
- <xs:annotation>
- <xs:documentation xml:lang="en">
- The default name for EDM
- complex type is derived from JPA Embeddable type name. This can be
- overriden using JPAEmbeddableTypeMapType.
- </xs:documentation>
- </xs:annotation>
- <xs:sequence>
- <xs:element type="xs:string" name="EDMComplexType"
- maxOccurs="1" minOccurs="0" />
- <xs:element name="JPAAttributes" type="tns:JPAAttributeMapType" />
- </xs:sequence>
- <xs:attribute type="xs:string" name="name" use="required" />
- <xs:attribute type="xs:boolean" name="exclude" use="optional"
- default="false" />
- </xs:complexType>
-
- <xs:complexType name="JPAEmbeddableTypesMapType">
- <xs:sequence>
- <xs:element name="JPAEmbeddableType" type="tns:JPAEmbeddableTypeMapType"
- maxOccurs="unbounded" minOccurs="0" />
- </xs:sequence>
- </xs:complexType>
-
- <xs:complexType name="JPAPersistenceUnitMapType">
- <xs:annotation>
- <xs:documentation xml:lang="en">
- By default Java
- Persistence Unit name is taken as EDM schema name. This can be
- overriden using JPAPersistenceUnitMapType.
- </xs:documentation>
- </xs:annotation>
- <xs:sequence>
- <xs:element type="xs:string" name="EDMSchemaNamespace"
- maxOccurs="1" minOccurs="0" />
- <xs:element name="JPAEntityTypes" type="tns:JPAEntityTypesMapType" />
- <xs:element name="JPAEmbeddableTypes" type="tns:JPAEmbeddableTypesMapType" />
- </xs:sequence>
- <xs:attribute type="xs:string" name="name" use="required" />
- </xs:complexType>
-
-
-</xs:schema>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-core/.gitignore
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-core/.gitignore b/odata2-processor-jpa/jpa-core/.gitignore
deleted file mode 100644
index fe5d89b..0000000
--- a/odata2-processor-jpa/jpa-core/.gitignore
+++ /dev/null
@@ -1,8 +0,0 @@
-.project
-.classpath
-.settings
-target
-bin
-*.bak
-classes
-.DS_Store
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-core/pom.xml
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-core/pom.xml b/odata2-processor-jpa/jpa-core/pom.xml
deleted file mode 100644
index 7cc8b0a..0000000
--- a/odata2-processor-jpa/jpa-core/pom.xml
+++ /dev/null
@@ -1,146 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- 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.
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.apache.olingo</groupId>
- <artifactId>olingo-odata2-jpa-processor-incubating</artifactId>
- <version>1.1.0-SNAPSHOT</version>
- <relativePath>../</relativePath>
- </parent>
-
- <artifactId>olingo-odata2-jpa-processor-core-incubating</artifactId>
- <packaging>jar</packaging>
- <name>${project.artifactId}</name>
-
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-jar-plugin</artifactId>
- <configuration>
- <archive>
- <manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
- </archive>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <extensions>true</extensions>
- <executions>
- <execution>
- <id>bundle-manifest</id>
- <phase>process-classes</phase>
- <goals>
- <goal>manifest</goal>
- </goals>
- </execution>
- </executions>
- <configuration>
- <instructions>
- <Import-Package>*</Import-Package>
- <Export-Package>org.apache.olingo.odata2.processor.core.jpa.factory;version=${project.version}</Export-Package>
- <Bundle-DocURL>${project.url}</Bundle-DocURL>
- <Bundle-ActivationPolicy>lazy</Bundle-ActivationPolicy>
- <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
- </instructions>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <version>2.3.2</version>
- <configuration>
- <source>1.6</source>
- <target>1.6</target>
- </configuration>
- </plugin>
- </plugins>
- </build>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.olingo</groupId>
- <artifactId>olingo-odata2-api-annotation-incubating</artifactId>
- <version>${project.version}</version>
- </dependency>
-
- <!-- ########################## -->
- <!-- Java Persistence API -->
- <!-- ########################## -->
- <dependency>
- <groupId>org.eclipse.persistence</groupId>
- <artifactId>javax.persistence</artifactId>
- <version>${version.javax.persistence}</version>
- </dependency>
-
- <!-- ########################## -->
- <!-- OData Java Library Support -->
- <!-- ########################## -->
- <dependency>
- <groupId>org.apache.olingo</groupId>
- <artifactId>olingo-odata2-api-incubating</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.olingo</groupId>
- <artifactId>olingo-odata2-core-incubating</artifactId>
- <version>${project.version}</version>
- </dependency>
-
- <!-- ########################## -->
- <!-- OData Java JPA API -->
- <!-- ########################## -->
- <dependency>
- <groupId>org.apache.olingo</groupId>
- <artifactId>olingo-odata2-jpa-processor-api-incubating</artifactId>
- <version>${project.version}</version>
- </dependency>
-
- <!-- ########################## -->
- <!-- For Testing -->
- <!-- ########################## -->
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>4.9</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.easymock</groupId>
- <artifactId>easymock</artifactId>
- <version>3.1</version>
- <scope>test</scope>
- </dependency>
-
- <!-- ########################## -->
- <!-- Supportability Tools -->
- <!-- ########################## -->
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
- <version>1.7.2</version>
- <scope>test</scope>
- </dependency>
- </dependencies>
-
-</project>
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-core/src/main/java/META-INF/MANIFEST.MF
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-core/src/main/java/META-INF/MANIFEST.MF b/odata2-processor-jpa/jpa-core/src/main/java/META-INF/MANIFEST.MF
deleted file mode 100644
index 5e94951..0000000
--- a/odata2-processor-jpa/jpa-core/src/main/java/META-INF/MANIFEST.MF
+++ /dev/null
@@ -1,3 +0,0 @@
-Manifest-Version: 1.0
-Class-Path:
-
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/ODataEntityParser.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/ODataEntityParser.java b/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/ODataEntityParser.java
deleted file mode 100644
index ee54290..0000000
--- a/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/ODataEntityParser.java
+++ /dev/null
@@ -1,163 +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;
-
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.olingo.odata2.api.edm.Edm;
-import org.apache.olingo.odata2.api.edm.EdmEntitySet;
-import org.apache.olingo.odata2.api.ep.EntityProvider;
-import org.apache.olingo.odata2.api.ep.EntityProviderException;
-import org.apache.olingo.odata2.api.ep.EntityProviderReadProperties;
-import org.apache.olingo.odata2.api.ep.entry.ODataEntry;
-import org.apache.olingo.odata2.api.exception.ODataBadRequestException;
-import org.apache.olingo.odata2.api.exception.ODataException;
-import org.apache.olingo.odata2.api.processor.ODataContext;
-import org.apache.olingo.odata2.api.uri.PathSegment;
-import org.apache.olingo.odata2.api.uri.UriInfo;
-import org.apache.olingo.odata2.api.uri.UriParser;
-import org.apache.olingo.odata2.processor.api.jpa.ODataJPAContext;
-import org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPARuntimeException;
-
-public final class ODataEntityParser {
-
- private ODataJPAContext context;
-
- public ODataEntityParser(final ODataJPAContext context) {
- this.context = context;
- }
-
- public final ODataEntry parseEntry(final EdmEntitySet entitySet,
- final InputStream content, final String requestContentType, final boolean merge)
- throws ODataBadRequestException {
- ODataEntry entryValues;
- try {
- EntityProviderReadProperties entityProviderProperties =
- EntityProviderReadProperties.init().mergeSemantic(merge).build();
- entryValues = EntityProvider.readEntry(requestContentType, entitySet, content, entityProviderProperties);
- } catch (EntityProviderException e) {
- throw new ODataBadRequestException(ODataBadRequestException.BODY, e);
- }
- return entryValues;
-
- }
-
- public final UriInfo parseLinkURI() throws ODataJPARuntimeException {
- UriInfo uriInfo = null;
-
- Edm edm;
- try {
- edm = context.getODataContext().getService().getEntityDataModel();
-
- List<PathSegment> pathSegments = context.getODataContext().getPathInfo().getODataSegments();
- List<PathSegment> subPathSegments = pathSegments.subList(0, pathSegments.size() - 2);
-
- uriInfo = UriParser.parse(edm, subPathSegments, Collections.<String, String> emptyMap());
- } catch (ODataException e) {
- throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e);
- }
-
- return uriInfo;
- }
-
- public final UriInfo parseLink(final EdmEntitySet entitySet, final InputStream content, final String contentType)
- throws ODataJPARuntimeException {
-
- String uriString = null;
- UriInfo uri = null;
-
- try {
- uriString = EntityProvider.readLink(contentType, entitySet, content);
- ODataContext odataContext = context.getODataContext();
- final String serviceRoot = odataContext.getPathInfo().getServiceRoot().toString();
-
- final String path =
- uriString.startsWith(serviceRoot.toString()) ? uriString.substring(serviceRoot.length()) : uriString;
-
- final PathSegment pathSegment = new PathSegment() {
- @Override
- public String getPath() {
- return path;
- }
-
- @Override
- public Map<String, List<String>> getMatrixParameters() {
- return null;
- }
- };
-
- final Edm edm = odataContext.getService().getEntityDataModel();
-
- uri = UriParser.parse(edm, Arrays.asList(pathSegment), Collections.<String, String> emptyMap());
-
- } catch (ODataException e) {
- throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e);
- }
-
- return uri;
-
- }
-
- public List<UriInfo> parseLinks(final EdmEntitySet entitySet, final InputStream content, final String contentType)
- throws ODataJPARuntimeException {
-
- List<String> uriList = new ArrayList<String>();
- List<UriInfo> uriInfoList = new ArrayList<UriInfo>();
-
- try {
-
- uriList = EntityProvider.readLinks(contentType, entitySet, content);
- ODataContext odataContext = context.getODataContext();
- final String serviceRoot = odataContext.getPathInfo().getServiceRoot().toString();
- final int length = serviceRoot.length();
- final Edm edm = odataContext.getService().getEntityDataModel();
-
- for (String uriString : uriList) {
- final String path = uriString.startsWith(serviceRoot) ? uriString.substring(length) : uriString;
-
- final PathSegment pathSegment = new PathSegment() {
- @Override
- public String getPath() {
- return path;
- }
-
- @Override
- public Map<String, List<String>> getMatrixParameters() {
- return null;
- }
- };
-
- UriInfo uriInfo = UriParser.parse(edm, Arrays.asList(pathSegment), Collections.<String, String> emptyMap());
- uriInfoList.add(uriInfo);
- }
- } catch (EntityProviderException e) {
- return null;
- } catch (ODataException e) {
- throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e);
- }
-
- return uriInfoList;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/ODataExpressionParser.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/ODataExpressionParser.java b/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/ODataExpressionParser.java
deleted file mode 100644
index 2993221..0000000
--- a/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/ODataExpressionParser.java
+++ /dev/null
@@ -1,381 +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;
-
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-
-import org.apache.olingo.odata2.api.edm.EdmException;
-import org.apache.olingo.odata2.api.edm.EdmLiteralKind;
-import org.apache.olingo.odata2.api.edm.EdmMapping;
-import org.apache.olingo.odata2.api.edm.EdmProperty;
-import org.apache.olingo.odata2.api.edm.EdmSimpleType;
-import org.apache.olingo.odata2.api.edm.EdmSimpleTypeException;
-import org.apache.olingo.odata2.api.edm.EdmSimpleTypeKind;
-import org.apache.olingo.odata2.api.exception.ODataException;
-import org.apache.olingo.odata2.api.exception.ODataNotImplementedException;
-import org.apache.olingo.odata2.api.uri.KeyPredicate;
-import org.apache.olingo.odata2.api.uri.expression.BinaryExpression;
-import org.apache.olingo.odata2.api.uri.expression.BinaryOperator;
-import org.apache.olingo.odata2.api.uri.expression.CommonExpression;
-import org.apache.olingo.odata2.api.uri.expression.ExpressionKind;
-import org.apache.olingo.odata2.api.uri.expression.FilterExpression;
-import org.apache.olingo.odata2.api.uri.expression.LiteralExpression;
-import org.apache.olingo.odata2.api.uri.expression.MemberExpression;
-import org.apache.olingo.odata2.api.uri.expression.MethodExpression;
-import org.apache.olingo.odata2.api.uri.expression.MethodOperator;
-import org.apache.olingo.odata2.api.uri.expression.OrderByExpression;
-import org.apache.olingo.odata2.api.uri.expression.OrderExpression;
-import org.apache.olingo.odata2.api.uri.expression.PropertyExpression;
-import org.apache.olingo.odata2.api.uri.expression.SortOrder;
-import org.apache.olingo.odata2.api.uri.expression.UnaryExpression;
-import org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPARuntimeException;
-import org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLStatement;
-
-/**
- * This class contains utility methods for parsing the filter expressions built by core library from user OData Query.
- *
- *
- *
- */
-public class ODataExpressionParser {
-
- public static final String EMPTY = ""; //$NON-NLS-1$
- public static Integer methodFlag = 0;
-
- /**
- * This method returns the parsed where condition corresponding to the filter input in the user query.
- *
- * @param whereExpression
- *
- * @return Parsed where condition String
- * @throws ODataException
- */
-
- public static String parseToJPAWhereExpression(final CommonExpression whereExpression, final String tableAlias)
- throws ODataException {
- switch (whereExpression.getKind()) {
- case UNARY:
- final UnaryExpression unaryExpression = (UnaryExpression) whereExpression;
- final String operand = parseToJPAWhereExpression(unaryExpression.getOperand(), tableAlias);
-
- switch (unaryExpression.getOperator()) {
- case NOT:
- return JPQLStatement.Operator.NOT + "(" + operand + ")"; //$NON-NLS-1$ //$NON-NLS-2$
- case MINUS:
- if (operand.startsWith("-")) {
- return operand.substring(1);
- } else {
- return "-" + operand; //$NON-NLS-1$
- }
- default:
- throw new ODataNotImplementedException();
- }
-
- case FILTER:
- return parseToJPAWhereExpression(((FilterExpression) whereExpression).getExpression(), tableAlias);
- case BINARY:
- final BinaryExpression binaryExpression = (BinaryExpression) whereExpression;
- if ((binaryExpression.getLeftOperand().getKind() == ExpressionKind.METHOD)
- && ((binaryExpression.getOperator() == BinaryOperator.EQ) ||
- (binaryExpression.getOperator() == BinaryOperator.NE))
- && (((MethodExpression) binaryExpression.getLeftOperand()).getMethod() == MethodOperator.SUBSTRINGOF)) {
- methodFlag = 1;
- }
- final String left = parseToJPAWhereExpression(binaryExpression.getLeftOperand(), tableAlias);
- final String right = parseToJPAWhereExpression(binaryExpression.getRightOperand(), tableAlias);
-
- switch (binaryExpression.getOperator()) {
- case AND:
- return left + JPQLStatement.DELIMITER.SPACE + JPQLStatement.Operator.AND + JPQLStatement.DELIMITER.SPACE
- + right;
- case OR:
- return left + JPQLStatement.DELIMITER.SPACE + JPQLStatement.Operator.OR + JPQLStatement.DELIMITER.SPACE + right;
- case EQ:
- return left + JPQLStatement.DELIMITER.SPACE + JPQLStatement.Operator.EQ + JPQLStatement.DELIMITER.SPACE + right;
- case NE:
- return left + JPQLStatement.DELIMITER.SPACE + JPQLStatement.Operator.NE + JPQLStatement.DELIMITER.SPACE + right;
- case LT:
- return left + JPQLStatement.DELIMITER.SPACE + JPQLStatement.Operator.LT + JPQLStatement.DELIMITER.SPACE + right;
- case LE:
- return left + JPQLStatement.DELIMITER.SPACE + JPQLStatement.Operator.LE + JPQLStatement.DELIMITER.SPACE + right;
- case GT:
- return left + JPQLStatement.DELIMITER.SPACE + JPQLStatement.Operator.GT + JPQLStatement.DELIMITER.SPACE + right;
- case GE:
- return left + JPQLStatement.DELIMITER.SPACE + JPQLStatement.Operator.GE + JPQLStatement.DELIMITER.SPACE + right;
- case PROPERTY_ACCESS:
- throw new ODataNotImplementedException();
- default:
- throw new ODataNotImplementedException();
- }
-
- case PROPERTY:
- String returnStr =
- tableAlias + JPQLStatement.DELIMITER.PERIOD
- + ((EdmProperty) ((PropertyExpression) whereExpression).getEdmProperty()).getMapping().getInternalName();
- return returnStr;
-
- case MEMBER:
- String memberExpStr = EMPTY;
- int i = 0;
- MemberExpression member = null;
- CommonExpression tempExp = whereExpression;
- while (tempExp != null && tempExp.getKind() == ExpressionKind.MEMBER) {
- member = (MemberExpression) tempExp;
- if (i > 0) {
- memberExpStr = JPQLStatement.DELIMITER.PERIOD + memberExpStr;
- }
- i++;
- memberExpStr =
- ((EdmProperty) ((PropertyExpression) member.getProperty()).getEdmProperty()).getMapping().getInternalName()
- + memberExpStr;
- tempExp = member.getPath();
- }
- memberExpStr =
- ((EdmProperty) ((PropertyExpression) tempExp).getEdmProperty()).getMapping().getInternalName()
- + JPQLStatement.DELIMITER.PERIOD + memberExpStr;
- return tableAlias + JPQLStatement.DELIMITER.PERIOD + memberExpStr;
-
- case LITERAL:
- final LiteralExpression literal = (LiteralExpression) whereExpression;
- final EdmSimpleType literalType = (EdmSimpleType) literal.getEdmType();
- String value =
- literalType.valueToString(literalType.valueOfString(literal.getUriLiteral(), EdmLiteralKind.URI, null,
- literalType.getDefaultType()), EdmLiteralKind.DEFAULT, null);
- return evaluateComparingExpression(value, literalType);
-
- case METHOD:
- final MethodExpression methodExpression = (MethodExpression) whereExpression;
- String first = parseToJPAWhereExpression(methodExpression.getParameters().get(0), tableAlias);
- final String second =
- methodExpression.getParameterCount() > 1 ? parseToJPAWhereExpression(methodExpression.getParameters().get(1),
- tableAlias) : null;
- String third =
- methodExpression.getParameterCount() > 2 ? parseToJPAWhereExpression(methodExpression.getParameters().get(2),
- tableAlias) : null;
-
- switch (methodExpression.getMethod()) {
- case SUBSTRING:
- third = third != null ? ", " + third : "";
- return String.format("SUBSTRING(%s, %s + 1 %s)", first, second, third);
- case SUBSTRINGOF:
- first = first.substring(1, first.length() - 1);
- if (methodFlag == 1) {
- methodFlag = 0;
- return String.format("(CASE WHEN (%s LIKE '%%%s%%') THEN TRUE ELSE FALSE END)", second, first);
- } else {
- return String.format("(CASE WHEN (%s LIKE '%%%s%%') THEN TRUE ELSE FALSE END) = true", second, first);
- }
- case TOLOWER:
- return String.format("LOWER(%s)", first);
- default:
- throw new ODataNotImplementedException();
- }
-
- default:
- throw new ODataNotImplementedException();
- }
- }
-
- /**
- * This method parses the select clause
- *
- * @param tableAlias
- * @param selectedFields
- * @return a select expression
- */
- public static String parseToJPASelectExpression(final String tableAlias, final ArrayList<String> selectedFields) {
-
- if ((selectedFields == null) || (selectedFields.size() == 0)) {
- return tableAlias;
- }
-
- String selectClause = EMPTY;
- Iterator<String> itr = selectedFields.iterator();
- int count = 0;
-
- while (itr.hasNext()) {
- selectClause = selectClause + tableAlias + JPQLStatement.DELIMITER.PERIOD + itr.next();
- count++;
-
- if (count < selectedFields.size()) {
- selectClause = selectClause + JPQLStatement.DELIMITER.COMMA + JPQLStatement.DELIMITER.SPACE;
- }
- }
- return selectClause;
- }
-
- /**
- * This method parses the order by condition in the query.
- *
- * @param orderByExpression
- * @return a map of JPA attributes and their sort order
- * @throws ODataJPARuntimeException
- */
- public static HashMap<String, String> parseToJPAOrderByExpression(final OrderByExpression orderByExpression,
- final String tableAlias) throws ODataJPARuntimeException {
- HashMap<String, String> orderByMap = new HashMap<String, String>();
- if (orderByExpression != null && orderByExpression.getOrders() != null) {
- List<OrderExpression> orderBys = orderByExpression.getOrders();
- String orderByField = null;
- String orderByDirection = null;
- for (OrderExpression orderBy : orderBys) {
-
- try {
- orderByField =
- ((EdmProperty) ((PropertyExpression) orderBy.getExpression()).getEdmProperty()).getMapping()
- .getInternalName();
- orderByDirection = (orderBy.getSortOrder() == SortOrder.asc) ? EMPTY : "DESC"; //$NON-NLS-1$
- orderByMap.put(tableAlias + JPQLStatement.DELIMITER.PERIOD + orderByField, orderByDirection);
- } catch (EdmException e) {
- throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e);
- }
- }
- }
- return orderByMap;
- }
-
- /**
- * This method evaluated the where expression for read of an entity based on the keys specified in the query.
- *
- * @param keyPredicates
- * @return the evaluated where expression
- */
-
- public static String parseKeyPredicates(final List<KeyPredicate> keyPredicates, final String tableAlias)
- throws ODataJPARuntimeException {
- String literal = null;
- String propertyName = null;
- EdmSimpleType edmSimpleType = null;
- StringBuilder keyFilters = new StringBuilder();
- int i = 0;
- for (KeyPredicate keyPredicate : keyPredicates) {
- if (i > 0) {
- keyFilters.append(JPQLStatement.DELIMITER.SPACE + JPQLStatement.Operator.AND + JPQLStatement.DELIMITER.SPACE);
- }
- i++;
- literal = keyPredicate.getLiteral();
- try {
- propertyName = keyPredicate.getProperty().getMapping().getInternalName();
- edmSimpleType = (EdmSimpleType) keyPredicate.getProperty().getType();
- } catch (EdmException e) {
- throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e);
- }
-
- literal = evaluateComparingExpression(literal, edmSimpleType);
-
- if (edmSimpleType == EdmSimpleTypeKind.DateTime.getEdmSimpleTypeInstance()
- || edmSimpleType == EdmSimpleTypeKind.DateTimeOffset.getEdmSimpleTypeInstance()) {
- literal = literal.substring(literal.indexOf('\''), literal.indexOf('}'));
- }
-
- keyFilters.append(tableAlias + JPQLStatement.DELIMITER.PERIOD + propertyName + JPQLStatement.DELIMITER.SPACE
- + JPQLStatement.Operator.EQ + JPQLStatement.DELIMITER.SPACE + literal);
- }
- if (keyFilters.length() > 0) {
- return keyFilters.toString();
- } else {
- return null;
- }
- }
-
- /**
- * This method evaluates the expression based on the type instance. Used for adding escape characters where necessary.
- *
- * @param value
- * @param edmSimpleType
- * @return the evaluated expression
- * @throws ODataJPARuntimeException
- */
- private static String evaluateComparingExpression(String value, final EdmSimpleType edmSimpleType)
- throws ODataJPARuntimeException {
-
- if (edmSimpleType == EdmSimpleTypeKind.String.getEdmSimpleTypeInstance()
- || edmSimpleType == EdmSimpleTypeKind.Guid.getEdmSimpleTypeInstance()) {
- value = "\'" + value + "\'"; //$NON-NLS-1$ //$NON-NLS-2$
- } else if (edmSimpleType == EdmSimpleTypeKind.DateTime.getEdmSimpleTypeInstance()
- || edmSimpleType == EdmSimpleTypeKind.DateTimeOffset.getEdmSimpleTypeInstance()) {
- try {
- Calendar datetime =
- (Calendar) edmSimpleType.valueOfString(value, EdmLiteralKind.DEFAULT, null, edmSimpleType.getDefaultType());
-
- String year = String.format("%04d", datetime.get(Calendar.YEAR));
- String month = String.format("%02d", datetime.get(Calendar.MONTH) + 1);
- String day = String.format("%02d", datetime.get(Calendar.DAY_OF_MONTH));
- String hour = String.format("%02d", datetime.get(Calendar.HOUR_OF_DAY));
- String min = String.format("%02d", datetime.get(Calendar.MINUTE));
- String sec = String.format("%02d", datetime.get(Calendar.SECOND));
-
- value =
- JPQLStatement.DELIMITER.LEFT_BRACE + JPQLStatement.KEYWORD.TIMESTAMP + JPQLStatement.DELIMITER.SPACE + "\'"
- + year + JPQLStatement.DELIMITER.HYPHEN + month + JPQLStatement.DELIMITER.HYPHEN + day
- + JPQLStatement.DELIMITER.SPACE + hour + JPQLStatement.DELIMITER.COLON + min
- + JPQLStatement.DELIMITER.COLON + sec + JPQLStatement.KEYWORD.OFFSET + "\'"
- + JPQLStatement.DELIMITER.RIGHT_BRACE;
-
- } catch (EdmSimpleTypeException e) {
- throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e);
- }
-
- } else if (edmSimpleType == EdmSimpleTypeKind.Time.getEdmSimpleTypeInstance()) {
- try {
- Calendar time =
- (Calendar) edmSimpleType.valueOfString(value, EdmLiteralKind.DEFAULT, null, edmSimpleType.getDefaultType());
-
- String hourValue = String.format("%02d", time.get(Calendar.HOUR_OF_DAY));
- String minValue = String.format("%02d", time.get(Calendar.MINUTE));
- String secValue = String.format("%02d", time.get(Calendar.SECOND));
-
- value =
- "\'" + hourValue + JPQLStatement.DELIMITER.COLON + minValue + JPQLStatement.DELIMITER.COLON + secValue
- + "\'";
- } catch (EdmSimpleTypeException e) {
- throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e);
- }
-
- } else if (edmSimpleType == EdmSimpleTypeKind.Int64.getEdmSimpleTypeInstance()) {
- value = value + JPQLStatement.DELIMITER.LONG; //$NON-NLS-1$
- }
- return value;
- }
-
- public static HashMap<String, String> parseKeyPropertiesToJPAOrderByExpression(
- final List<EdmProperty> edmPropertylist, final String tableAlias) throws ODataJPARuntimeException {
- HashMap<String, String> orderByMap = new HashMap<String, String>();
- String propertyName = null;
- for (EdmProperty edmProperty : edmPropertylist) {
- try {
- EdmMapping mapping = edmProperty.getMapping();
- if (mapping != null && mapping.getInternalName() != null) {
- propertyName = mapping.getInternalName();// For embedded/complex keys
- } else {
- propertyName = edmProperty.getName();
- }
- } catch (EdmException e) {
- throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e);
- }
- orderByMap.put(tableAlias + JPQLStatement.DELIMITER.PERIOD + propertyName, EMPTY);
- }
- return orderByMap;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/ODataJPAContextImpl.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/ODataJPAContextImpl.java b/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/ODataJPAContextImpl.java
deleted file mode 100644
index 5529d2c..0000000
--- a/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/ODataJPAContextImpl.java
+++ /dev/null
@@ -1,146 +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;
-
-import javax.persistence.EntityManager;
-import javax.persistence.EntityManagerFactory;
-
-import org.apache.olingo.odata2.api.edm.provider.EdmProvider;
-import org.apache.olingo.odata2.api.processor.ODataContext;
-import org.apache.olingo.odata2.api.processor.ODataProcessor;
-import org.apache.olingo.odata2.processor.api.jpa.ODataJPAContext;
-import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmExtension;
-
-public class ODataJPAContextImpl implements ODataJPAContext {
-
- private String pUnitName;
- private EntityManagerFactory emf;
- private EntityManager em;
- private ODataContext odataContext;
- private ODataProcessor processor;
- private EdmProvider edmProvider;
- private String jpaEdmMappingModelName;
- private JPAEdmExtension jpaEdmExtension;
- private static final ThreadLocal<ODataContext> oDataContextThreadLocal = new ThreadLocal<ODataContext>();
- private boolean defaultNaming = true;
-
- @Override
- public String getPersistenceUnitName() {
- return pUnitName;
- }
-
- @Override
- public void setPersistenceUnitName(final String pUnitName) {
- this.pUnitName = pUnitName;
- }
-
- @Override
- public EntityManagerFactory getEntityManagerFactory() {
- return emf;
- }
-
- @Override
- public void setEntityManagerFactory(final EntityManagerFactory emf) {
- this.emf = emf;
- }
-
- @Override
- public void setODataContext(final ODataContext ctx) {
- odataContext = ctx;
- setContextInThreadLocal(odataContext);
- }
-
- @Override
- public ODataContext getODataContext() {
- return odataContext;
- }
-
- @Override
- public void setODataProcessor(final ODataProcessor processor) {
- this.processor = processor;
- }
-
- @Override
- public ODataProcessor getODataProcessor() {
- return processor;
- }
-
- @Override
- public void setEdmProvider(final EdmProvider edmProvider) {
- this.edmProvider = edmProvider;
- }
-
- @Override
- public EdmProvider getEdmProvider() {
- return edmProvider;
- }
-
- @Override
- public void setJPAEdmMappingModel(final String name) {
- jpaEdmMappingModelName = name;
-
- }
-
- @Override
- public String getJPAEdmMappingModel() {
- return jpaEdmMappingModelName;
- }
-
- public static void setContextInThreadLocal(final ODataContext ctx) {
- oDataContextThreadLocal.set(ctx);
- }
-
- public static void unsetContextInThreadLocal() {
- oDataContextThreadLocal.remove();
- }
-
- public static ODataContext getContextInThreadLocal() {
- return (ODataContext) oDataContextThreadLocal.get();
- }
-
- @Override
- public EntityManager getEntityManager() {
- if (em == null) {
- em = emf.createEntityManager();
- }
-
- return em;
- }
-
- @Override
- public void setJPAEdmExtension(final JPAEdmExtension jpaEdmExtension) {
- this.jpaEdmExtension = jpaEdmExtension;
-
- }
-
- @Override
- public JPAEdmExtension getJPAEdmExtension() {
- return jpaEdmExtension;
- }
-
- @Override
- public void setDefaultNaming(final boolean defaultNaming) {
- this.defaultNaming = defaultNaming;
- }
-
- @Override
- public boolean getDefaultNaming() {
- return defaultNaming;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/ODataJPAProcessorDefault.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/ODataJPAProcessorDefault.java b/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/ODataJPAProcessorDefault.java
deleted file mode 100644
index 1d5929d..0000000
--- a/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/ODataJPAProcessorDefault.java
+++ /dev/null
@@ -1,194 +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;
-
-import java.io.InputStream;
-import java.util.List;
-
-import org.apache.olingo.odata2.api.exception.ODataException;
-import org.apache.olingo.odata2.api.processor.ODataResponse;
-import org.apache.olingo.odata2.api.uri.info.DeleteUriInfo;
-import org.apache.olingo.odata2.api.uri.info.GetEntityCountUriInfo;
-import org.apache.olingo.odata2.api.uri.info.GetEntityLinkUriInfo;
-import org.apache.olingo.odata2.api.uri.info.GetEntitySetCountUriInfo;
-import org.apache.olingo.odata2.api.uri.info.GetEntitySetLinksUriInfo;
-import org.apache.olingo.odata2.api.uri.info.GetEntitySetUriInfo;
-import org.apache.olingo.odata2.api.uri.info.GetEntityUriInfo;
-import org.apache.olingo.odata2.api.uri.info.GetFunctionImportUriInfo;
-import org.apache.olingo.odata2.api.uri.info.PostUriInfo;
-import org.apache.olingo.odata2.api.uri.info.PutMergePatchUriInfo;
-import org.apache.olingo.odata2.processor.api.jpa.ODataJPAContext;
-import org.apache.olingo.odata2.processor.api.jpa.ODataJPAProcessor;
-import org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPAException;
-
-public class ODataJPAProcessorDefault extends ODataJPAProcessor {
-
- public ODataJPAProcessorDefault(final ODataJPAContext oDataJPAContext) {
- super(oDataJPAContext);
- if (oDataJPAContext == null) {
- throw new IllegalArgumentException(ODataJPAException.ODATA_JPACTX_NULL);
- }
- }
-
- @Override
- public ODataResponse readEntitySet(final GetEntitySetUriInfo uriParserResultView, final String contentType)
- throws ODataException {
-
- List<?> jpaEntities = jpaProcessor.process(uriParserResultView);
-
- ODataResponse oDataResponse =
- ODataJPAResponseBuilder.build(jpaEntities, uriParserResultView, contentType, oDataJPAContext);
-
- return oDataResponse;
- }
-
- @Override
- public ODataResponse readEntity(final GetEntityUriInfo uriParserResultView, final String contentType)
- throws ODataException {
-
- Object jpaEntity = jpaProcessor.process(uriParserResultView);
-
- ODataResponse oDataResponse =
- ODataJPAResponseBuilder.build(jpaEntity, uriParserResultView, contentType, oDataJPAContext);
-
- return oDataResponse;
- }
-
- @Override
- public ODataResponse countEntitySet(final GetEntitySetCountUriInfo uriParserResultView, final String contentType)
- throws ODataException {
-
- long jpaEntityCount = jpaProcessor.process(uriParserResultView);
-
- ODataResponse oDataResponse = ODataJPAResponseBuilder.build(jpaEntityCount, oDataJPAContext);
-
- return oDataResponse;
- }
-
- @Override
- public ODataResponse existsEntity(final GetEntityCountUriInfo uriInfo, final String contentType)
- throws ODataException {
-
- long jpaEntityCount = jpaProcessor.process(uriInfo);
-
- ODataResponse oDataResponse = ODataJPAResponseBuilder.build(jpaEntityCount, oDataJPAContext);
-
- return oDataResponse;
- }
-
- @Override
- public ODataResponse createEntity(final PostUriInfo uriParserResultView, final InputStream content,
- final String requestContentType, final String contentType) throws ODataException {
-
- List<Object> createdJpaEntityList = jpaProcessor.process(uriParserResultView, content, requestContentType);
-
- ODataResponse oDataResponse =
- ODataJPAResponseBuilder.build(createdJpaEntityList, uriParserResultView, contentType, oDataJPAContext);
-
- return oDataResponse;
- }
-
- @Override
- public ODataResponse updateEntity(final PutMergePatchUriInfo uriParserResultView, final InputStream content,
- final String requestContentType, final boolean merge, final String contentType) throws ODataException {
-
- Object jpaEntity = jpaProcessor.process(uriParserResultView, content, requestContentType);
-
- ODataResponse oDataResponse = ODataJPAResponseBuilder.build(jpaEntity, uriParserResultView);
-
- return oDataResponse;
- }
-
- @Override
- public ODataResponse deleteEntity(final DeleteUriInfo uriParserResultView, final String contentType)
- throws ODataException {
-
- Object deletedObj = jpaProcessor.process(uriParserResultView, contentType);
-
- ODataResponse oDataResponse = ODataJPAResponseBuilder.build(deletedObj, uriParserResultView);
- return oDataResponse;
- }
-
- @Override
- public ODataResponse executeFunctionImport(final GetFunctionImportUriInfo uriParserResultView,
- final String contentType) throws ODataException {
-
- List<Object> resultEntity = jpaProcessor.process(uriParserResultView);
-
- ODataResponse oDataResponse =
- ODataJPAResponseBuilder.build(resultEntity, uriParserResultView, contentType, oDataJPAContext);
-
- return oDataResponse;
- }
-
- @Override
- public ODataResponse executeFunctionImportValue(final GetFunctionImportUriInfo uriParserResultView,
- final String contentType) throws ODataException {
-
- List<Object> result = jpaProcessor.process(uriParserResultView);
-
- ODataResponse oDataResponse =
- ODataJPAResponseBuilder.build(result, uriParserResultView, contentType, oDataJPAContext);
-
- return oDataResponse;
- }
-
- @Override
- public ODataResponse readEntityLink(final GetEntityLinkUriInfo uriParserResultView, final String contentType)
- throws ODataException {
-
- Object jpaEntity = jpaProcessor.process(uriParserResultView);
-
- ODataResponse oDataResponse =
- ODataJPAResponseBuilder.build(jpaEntity, uriParserResultView, contentType, oDataJPAContext);
-
- return oDataResponse;
- }
-
- @Override
- public ODataResponse readEntityLinks(final GetEntitySetLinksUriInfo uriParserResultView, final String contentType)
- throws ODataException {
-
- List<Object> jpaEntity = jpaProcessor.process(uriParserResultView);
-
- ODataResponse oDataResponse =
- ODataJPAResponseBuilder.build(jpaEntity, uriParserResultView, contentType, oDataJPAContext);
-
- return oDataResponse;
- }
-
- @Override
- public ODataResponse createEntityLink(final PostUriInfo uriParserResultView, final InputStream content,
- final String requestContentType, final String contentType) throws ODataException {
-
- jpaProcessor.process(uriParserResultView, content, requestContentType, contentType);
-
- return ODataResponse.newBuilder().build();
- }
-
- @Override
- public ODataResponse updateEntityLink(final PutMergePatchUriInfo uriParserResultView, final InputStream content,
- final String requestContentType, final String contentType) throws ODataException {
-
- jpaProcessor.process(uriParserResultView, content, requestContentType, contentType);
-
- return ODataResponse.newBuilder().build();
- }
-
-}
[14/37] [OLINGO-82] Renamed the project folder name to
odata2-jpa-processor
Posted by ch...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/access/data/JPALink.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/access/data/JPALink.java b/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/access/data/JPALink.java
deleted file mode 100644
index 872a99b..0000000
--- a/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/access/data/JPALink.java
+++ /dev/null
@@ -1,225 +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.access.data;
-
-import java.io.InputStream;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.persistence.EntityManager;
-import javax.persistence.EntityTransaction;
-
-import org.apache.olingo.odata2.api.edm.EdmEntitySet;
-import org.apache.olingo.odata2.api.edm.EdmException;
-import org.apache.olingo.odata2.api.edm.EdmNavigationProperty;
-import org.apache.olingo.odata2.api.uri.UriInfo;
-import org.apache.olingo.odata2.api.uri.info.GetEntityUriInfo;
-import org.apache.olingo.odata2.api.uri.info.PostUriInfo;
-import org.apache.olingo.odata2.api.uri.info.PutMergePatchUriInfo;
-import org.apache.olingo.odata2.processor.api.jpa.ODataJPAContext;
-import org.apache.olingo.odata2.processor.api.jpa.access.JPAProcessor;
-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.factory.ODataJPAFactory;
-import org.apache.olingo.odata2.processor.core.jpa.ODataEntityParser;
-
-public class JPALink {
-
- private ODataJPAContext context;
- private JPAProcessor jpaProcessor;
- private ODataEntityParser parser;
- private Object targetJPAEntity;
- private Object sourceJPAEntity;
-
- public JPALink(final ODataJPAContext context) {
- this.context = context;
- jpaProcessor = ODataJPAFactory.createFactory().getJPAAccessFactory().getJPAProcessor(this.context);
- parser = new ODataEntityParser(this.context);
- }
-
- public void setSourceJPAEntity(final Object jpaEntity) {
- sourceJPAEntity = jpaEntity;
- }
-
- public void create(final PostUriInfo uriInfo, final InputStream content, final String requestContentType,
- final String contentType) throws ODataJPARuntimeException, ODataJPAModelException {
-
- EdmEntitySet targetEntitySet = uriInfo.getTargetEntitySet();
- String targerEntitySetName;
- EdmNavigationProperty navigationProperty = null;
- try {
- targerEntitySetName = targetEntitySet.getName();
- } catch (EdmException e) {
- throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e);
- }
-
- List<UriInfo> uriInfoList = new ArrayList<UriInfo>();
-
- if (((UriInfo) uriInfo).isLinks()) {
- UriInfo getUriInfo = parser.parseLink(targetEntitySet, content, requestContentType);
- uriInfoList = new ArrayList<UriInfo>();
- uriInfoList.add(getUriInfo);
- navigationProperty = uriInfo.getNavigationSegments().get(0).getNavigationProperty();
- } else {
- uriInfoList = parser.parseLinks(targetEntitySet, content, contentType);
- }
-
- if (uriInfoList == null) {
- return;
- }
- try {
- for (UriInfo getUriInfo : uriInfoList) {
-
- if (!getUriInfo.getTargetEntitySet().getName().equals(targerEntitySetName)) {
- throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.RELATIONSHIP_INVALID, null);
- }
- if (!((UriInfo) uriInfo).isLinks()) {
- navigationProperty = getUriInfo.getNavigationSegments().get(0).getNavigationProperty();
- }
-
- targetJPAEntity = jpaProcessor.process((GetEntityUriInfo) getUriInfo);
- if (targetJPAEntity != null && ((UriInfo) uriInfo).isLinks()) {
- getUriInfo = parser.parseLinkURI();
- sourceJPAEntity = jpaProcessor.process((GetEntityUriInfo) getUriInfo);
- if (sourceJPAEntity == null) {
- throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.RESOURCE_X_NOT_FOUND
- .addContent(getUriInfo.getTargetEntitySet().getName()), null);
- }
- }
-
- JPAEntityParser entityParser = new JPAEntityParser();
- Method setMethod =
- entityParser.getAccessModifier(sourceJPAEntity, navigationProperty, JPAEntityParser.ACCESS_MODIFIER_SET);
-
- Method getMethod =
- entityParser.getAccessModifier(sourceJPAEntity, navigationProperty, JPAEntityParser.ACCESS_MODIFIER_GET);
-
- if (getMethod.getReturnType().getTypeParameters() != null) {
- @SuppressWarnings("unchecked")
- List<Object> relatedEntities = (List<Object>) getMethod.invoke(sourceJPAEntity);
- relatedEntities.add(targetJPAEntity);
- setMethod.invoke(sourceJPAEntity, relatedEntities);
- } else {
- setMethod.invoke(sourceJPAEntity, targetJPAEntity);
- }
- }
- } catch (IllegalAccessException e) {
- throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e);
- } catch (IllegalArgumentException e) {
- throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e);
- } catch (InvocationTargetException e) {
- throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e);
- } catch (EdmException e) {
- throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e);
- }
- }
-
- public void delete() {}
-
- public void save() {
- EntityManager em = context.getEntityManager();
- EntityTransaction tx = em.getTransaction();
-
- if (!tx.isActive()) {
- em.getTransaction().begin();
- em.persist(sourceJPAEntity);
- em.getTransaction().commit();
- }
-
- }
-
- public void update(final PutMergePatchUriInfo putUriInfo, final InputStream content, final String requestContentType,
- final String contentType) throws ODataJPARuntimeException, ODataJPAModelException {
- UriInfo uriInfo = (UriInfo) putUriInfo;
-
- EdmEntitySet targetEntitySet = uriInfo.getTargetEntitySet();
- String targerEntitySetName;
- EdmNavigationProperty navigationProperty = null;
- try {
- targerEntitySetName = targetEntitySet.getName();
- } catch (EdmException e) {
- throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e);
- }
-
- List<UriInfo> uriInfoList = new ArrayList<UriInfo>();
-
- if (((UriInfo) uriInfo).isLinks()) {
- UriInfo getUriInfo = parser.parseLink(targetEntitySet, content, requestContentType);
- uriInfoList = new ArrayList<UriInfo>();
- uriInfoList.add(getUriInfo);
- navigationProperty = uriInfo.getNavigationSegments().get(0).getNavigationProperty();
- } else {
- uriInfoList = parser.parseLinks(targetEntitySet, content, contentType);
- }
-
- if (uriInfoList == null) {
- return;
- }
- try {
- for (UriInfo getUriInfo : uriInfoList) {
-
- if (!getUriInfo.getTargetEntitySet().getName().equals(targerEntitySetName)) {
- throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.RELATIONSHIP_INVALID, null);
- }
- if (!((UriInfo) uriInfo).isLinks()) {
- navigationProperty = getUriInfo.getNavigationSegments().get(0).getNavigationProperty();
- }
-
- targetJPAEntity = jpaProcessor.process((GetEntityUriInfo) getUriInfo);
- if (targetJPAEntity != null && ((UriInfo) uriInfo).isLinks()) {
- getUriInfo = parser.parseLinkURI();
- sourceJPAEntity = jpaProcessor.process((GetEntityUriInfo) getUriInfo);
- if (sourceJPAEntity == null) {
- throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.RESOURCE_X_NOT_FOUND
- .addContent(getUriInfo.getTargetEntitySet().getName()), null);
- }
- }
-
- JPAEntityParser entityParser = new JPAEntityParser();
- Method setMethod =
- entityParser.getAccessModifier(sourceJPAEntity, navigationProperty, JPAEntityParser.ACCESS_MODIFIER_SET);
-
- Method getMethod =
- entityParser.getAccessModifier(sourceJPAEntity, navigationProperty, JPAEntityParser.ACCESS_MODIFIER_GET);
-
- if (getMethod.getReturnType().getTypeParameters() != null
- && getMethod.getReturnType().getTypeParameters().length != 0) {
- @SuppressWarnings("unchecked")
- List<Object> relatedEntities = (List<Object>) getMethod.invoke(sourceJPAEntity);
- relatedEntities.add(targetJPAEntity);
- setMethod.invoke(sourceJPAEntity, relatedEntities);
- } else {
- setMethod.invoke(sourceJPAEntity, targetJPAEntity);
- }
- }
- } catch (IllegalAccessException e) {
- throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e);
- } catch (IllegalArgumentException e) {
- throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e);
- } catch (InvocationTargetException e) {
- throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e);
- } catch (EdmException e) {
- throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e);
- }
-
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/access/data/JPAProcessorImpl.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/access/data/JPAProcessorImpl.java b/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/access/data/JPAProcessorImpl.java
deleted file mode 100644
index 8501b77..0000000
--- a/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/access/data/JPAProcessorImpl.java
+++ /dev/null
@@ -1,491 +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.access.data;
-
-import java.io.InputStream;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-import javax.persistence.EntityManager;
-import javax.persistence.Query;
-
-import org.apache.olingo.odata2.api.edm.EdmEntitySet;
-import org.apache.olingo.odata2.api.edm.EdmEntityType;
-import org.apache.olingo.odata2.api.edm.EdmException;
-import org.apache.olingo.odata2.api.edm.EdmMultiplicity;
-import org.apache.olingo.odata2.api.ep.entry.ODataEntry;
-import org.apache.olingo.odata2.api.uri.info.DeleteUriInfo;
-import org.apache.olingo.odata2.api.uri.info.GetEntityCountUriInfo;
-import org.apache.olingo.odata2.api.uri.info.GetEntityLinkUriInfo;
-import org.apache.olingo.odata2.api.uri.info.GetEntitySetCountUriInfo;
-import org.apache.olingo.odata2.api.uri.info.GetEntitySetLinksUriInfo;
-import org.apache.olingo.odata2.api.uri.info.GetEntitySetUriInfo;
-import org.apache.olingo.odata2.api.uri.info.GetEntityUriInfo;
-import org.apache.olingo.odata2.api.uri.info.GetFunctionImportUriInfo;
-import org.apache.olingo.odata2.api.uri.info.PostUriInfo;
-import org.apache.olingo.odata2.api.uri.info.PutMergePatchUriInfo;
-import org.apache.olingo.odata2.processor.api.jpa.ODataJPAContext;
-import org.apache.olingo.odata2.processor.api.jpa.access.JPAFunction;
-import org.apache.olingo.odata2.processor.api.jpa.access.JPAMethodContext;
-import org.apache.olingo.odata2.processor.api.jpa.access.JPAProcessor;
-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.jpql.JPQLContext;
-import org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLContextType;
-import org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLStatement;
-import org.apache.olingo.odata2.processor.core.jpa.ODataEntityParser;
-
-public class JPAProcessorImpl implements JPAProcessor {
-
- ODataJPAContext oDataJPAContext;
- EntityManager em;
-
- public JPAProcessorImpl(final ODataJPAContext oDataJPAContext) {
- this.oDataJPAContext = oDataJPAContext;
- em = oDataJPAContext.getEntityManager();
- }
-
- /* Process Function Import Request */
- @SuppressWarnings("unchecked")
- @Override
- public List<Object> process(final GetFunctionImportUriInfo uriParserResultView)
- throws ODataJPAModelException, ODataJPARuntimeException {
-
- JPAMethodContext jpaMethodContext = JPAMethodContext.createBuilder(
- JPQLContextType.FUNCTION, uriParserResultView).build();
-
- List<Object> resultObj = null;
-
- try {
-
- JPAFunction jpaFunction = jpaMethodContext.getJPAFunctionList()
- .get(0);
- Method method = jpaFunction.getFunction();
- Object[] args = jpaFunction.getArguments();
-
- if (uriParserResultView.getFunctionImport().getReturnType()
- .getMultiplicity().equals(EdmMultiplicity.MANY)) {
-
- resultObj = (List<Object>) method.invoke(
- jpaMethodContext.getEnclosingObject(), args);
- } else {
- resultObj = new ArrayList<Object>();
- Object result = method.invoke(
- jpaMethodContext.getEnclosingObject(), args);
- resultObj.add(result);
- }
-
- } catch (EdmException e) {
- throw ODataJPARuntimeException
- .throwException(ODataJPARuntimeException.GENERAL
- .addContent(e.getMessage()), e);
- } catch (IllegalAccessException e) {
- throw ODataJPARuntimeException
- .throwException(ODataJPARuntimeException.GENERAL
- .addContent(e.getMessage()), e);
- } catch (IllegalArgumentException e) {
- throw ODataJPARuntimeException
- .throwException(ODataJPARuntimeException.GENERAL
- .addContent(e.getMessage()), e);
- } catch (InvocationTargetException e) {
- throw ODataJPARuntimeException
- .throwException(ODataJPARuntimeException.GENERAL
- .addContent(e.getTargetException().getMessage()), e.getTargetException());
- }
-
- return resultObj;
- }
-
- /* Process Get Entity Set Request (Query) */
- @SuppressWarnings("unchecked")
- @Override
- public <T> List<T> process(final GetEntitySetUriInfo uriParserResultView)
- throws ODataJPAModelException, ODataJPARuntimeException {
-
- if (uriParserResultView.getFunctionImport() != null) {
- return (List<T>) process((GetFunctionImportUriInfo) uriParserResultView);
- }
- JPQLContextType contextType = null;
- try {
- if (!uriParserResultView.getStartEntitySet().getName()
- .equals(uriParserResultView.getTargetEntitySet().getName())) {
- contextType = JPQLContextType.JOIN;
- } else {
- contextType = JPQLContextType.SELECT;
- }
-
- } catch (EdmException e) {
- ODataJPARuntimeException.throwException(
- ODataJPARuntimeException.GENERAL, e);
- }
-
- JPQLContext jpqlContext = JPQLContext.createBuilder(contextType,
- uriParserResultView).build();
-
- JPQLStatement jpqlStatement = JPQLStatement.createBuilder(jpqlContext)
- .build();
- Query query = null;
- try {
- query = em.createQuery(jpqlStatement.toString());
- // $top/$skip with $inlinecount case handled in response builder to avoid multiple DB call
- if (uriParserResultView.getSkip() != null && uriParserResultView.getInlineCount() == null) {
- query.setFirstResult(uriParserResultView.getSkip());
- }
-
- if (uriParserResultView.getTop() != null && uriParserResultView.getInlineCount() == null) {
- if (uriParserResultView.getTop() == 0) {
- List<T> resultList = new ArrayList<T>();
- return resultList;
- } else {
- query.setMaxResults(uriParserResultView.getTop());
- }
- }
- return query.getResultList();
- } catch (Exception e) {
- throw ODataJPARuntimeException.throwException(
- ODataJPARuntimeException.ERROR_JPQL_QUERY_CREATE, e);
-
- }
- }
-
- /* Process Get Entity Request (Read) */
- @Override
- public <T> Object process(GetEntityUriInfo uriParserResultView)
- throws ODataJPAModelException, ODataJPARuntimeException {
-
- JPQLContextType contextType = null;
- try {
- if (uriParserResultView instanceof GetEntityUriInfo) {
- uriParserResultView = ((GetEntityUriInfo) uriParserResultView);
- if (!((GetEntityUriInfo) uriParserResultView).getStartEntitySet().getName()
- .equals(((GetEntityUriInfo) uriParserResultView).getTargetEntitySet().getName())) {
- contextType = JPQLContextType.JOIN_SINGLE;
- } else {
- contextType = JPQLContextType.SELECT_SINGLE;
- }
- }
- } catch (EdmException e) {
- ODataJPARuntimeException.throwException(
- ODataJPARuntimeException.GENERAL, e);
- }
-
- return readEntity(uriParserResultView, contextType);
- }
-
- /* Process $count for Get Entity Set Request */
- @Override
- public long process(final GetEntitySetCountUriInfo resultsView)
- throws ODataJPAModelException, ODataJPARuntimeException {
-
- JPQLContextType contextType = null;
- try {
- if (!resultsView.getStartEntitySet().getName()
- .equals(resultsView.getTargetEntitySet().getName())) {
- contextType = JPQLContextType.JOIN_COUNT;
- } else {
- contextType = JPQLContextType.SELECT_COUNT;
- }
- } catch (EdmException e) {
- ODataJPARuntimeException.throwException(
- ODataJPARuntimeException.GENERAL, e);
- }
-
- JPQLContext jpqlContext = JPQLContext.createBuilder(contextType,
- resultsView).build();
-
- JPQLStatement jpqlStatement = JPQLStatement.createBuilder(jpqlContext)
- .build();
- Query query = null;
- try {
-
- query = em.createQuery(jpqlStatement.toString());
- List<?> resultList = query.getResultList();
- if (resultList != null && resultList.size() == 1) {
- return Long.valueOf(resultList.get(0).toString());
- }
- } catch (IllegalArgumentException e) {
- throw ODataJPARuntimeException.throwException(
- ODataJPARuntimeException.ERROR_JPQL_QUERY_CREATE, e);
- }
- return 0;
- }
-
- /* Process $count for Get Entity Request */
- @Override
- public long process(final GetEntityCountUriInfo resultsView) throws ODataJPAModelException, ODataJPARuntimeException {
-
- JPQLContextType contextType = null;
- try {
- if (!resultsView.getStartEntitySet().getName()
- .equals(resultsView.getTargetEntitySet().getName())) {
- contextType = JPQLContextType.JOIN_COUNT;
- } else {
- contextType = JPQLContextType.SELECT_COUNT;
- }
- } catch (EdmException e) {
- ODataJPARuntimeException.throwException(
- ODataJPARuntimeException.GENERAL, e);
- }
-
- JPQLContext jpqlContext = JPQLContext.createBuilder(contextType,
- resultsView).build();
-
- JPQLStatement jpqlStatement = JPQLStatement.createBuilder(jpqlContext)
- .build();
- Query query = null;
- try {
-
- query = em.createQuery(jpqlStatement.toString());
- List<?> resultList = query.getResultList();
- if (resultList != null && resultList.size() == 1) {
- return Long.valueOf(resultList.get(0).toString());
- }
- } catch (IllegalArgumentException e) {
- throw ODataJPARuntimeException.throwException(
- ODataJPARuntimeException.ERROR_JPQL_QUERY_CREATE, e);
- }
-
- return 0;
- }
-
- /* Process Create Entity Request */
- @Override
- public <T> List<T> process(final PostUriInfo createView, final InputStream content,
- final String requestedContentType) throws ODataJPAModelException,
- ODataJPARuntimeException {
- return processCreate(createView, content, null, requestedContentType);
- }
-
- @Override
- public <T> List<T> process(final PostUriInfo createView, final Map<String, Object> content)
- throws ODataJPAModelException, ODataJPARuntimeException {
- return processCreate(createView, null, content, null);
- }
-
- /* Process Update Entity Request */
- @Override
- public <T> Object process(final PutMergePatchUriInfo updateView,
- final InputStream content, final String requestContentType)
- throws ODataJPAModelException, ODataJPARuntimeException {
- return processUpdate(updateView, content, null, requestContentType);
- }
-
- @Override
- public <T> Object process(final PutMergePatchUriInfo updateView, final Map<String, Object> content)
- throws ODataJPAModelException, ODataJPARuntimeException {
- return processUpdate(updateView, null, content, null);
- }
-
- @SuppressWarnings("unchecked")
- private <T> List<T> processCreate(final PostUriInfo createView, final InputStream content,
- final Map<String, Object> properties,
- final String requestedContentType) throws ODataJPAModelException,
- ODataJPARuntimeException {
- try {
-
- final EdmEntitySet oDataEntitySet = createView.getTargetEntitySet();
- final EdmEntityType oDataEntityType = oDataEntitySet.getEntityType();
- final JPAEntity virtualJPAEntity = new JPAEntity(oDataEntityType, oDataEntitySet);
- final List<Object> createList = new ArrayList<Object>();
- Object jpaEntity = null;
-
- if (content != null) {
- final ODataEntityParser oDataEntityParser = new ODataEntityParser(oDataJPAContext);
- final ODataEntry oDataEntry =
- oDataEntityParser.parseEntry(oDataEntitySet, content, requestedContentType, false);
- virtualJPAEntity.create(oDataEntry);
- JPALink link = new JPALink(oDataJPAContext);
- link.setSourceJPAEntity(jpaEntity);
- link.create(createView, content, requestedContentType, requestedContentType);
- } else if (properties != null) {
- virtualJPAEntity.create(properties);
- } else {
- return null;
- }
-
- em.getTransaction().begin();
- jpaEntity = virtualJPAEntity.getJPAEntity();
-
- em.persist(jpaEntity);
- if (em.contains(jpaEntity)) {
- em.getTransaction().commit();
-
- createList.add(virtualJPAEntity.getJPAEntity());
- createList.add(virtualJPAEntity.getInlineJPAEntities());
-
- return (List<T>) createList;
- }
- } catch (Exception e) {
- throw ODataJPARuntimeException.throwException(
- ODataJPARuntimeException.ERROR_JPQL_CREATE_REQUEST, e);
- }
- return null;
- }
-
- public <T> Object processUpdate(PutMergePatchUriInfo updateView,
- final InputStream content, final Map<String, Object> properties, final String requestContentType)
- throws ODataJPAModelException, ODataJPARuntimeException {
- JPQLContextType contextType = null;
- Object jpaEntity = null;
- try {
- em.getTransaction().begin();
- if (updateView instanceof PutMergePatchUriInfo) {
- updateView = ((PutMergePatchUriInfo) updateView);
- if (!((PutMergePatchUriInfo) updateView).getStartEntitySet().getName()
- .equals(((PutMergePatchUriInfo) updateView).getTargetEntitySet().getName())) {
- contextType = JPQLContextType.JOIN_SINGLE;
- } else {
- contextType = JPQLContextType.SELECT_SINGLE;
- }
- }
-
- jpaEntity = readEntity(updateView, contextType);
-
- if (jpaEntity == null) {
- throw ODataJPARuntimeException
- .throwException(ODataJPARuntimeException.RESOURCE_NOT_FOUND, null);
- }
-
- final EdmEntitySet oDataEntitySet = updateView.getTargetEntitySet();
- final EdmEntityType oDataEntityType = oDataEntitySet.getEntityType();
- final JPAEntity virtualJPAEntity = new JPAEntity(oDataEntityType, oDataEntitySet);
- virtualJPAEntity.setJPAEntity(jpaEntity);
-
- if (content != null) {
- final ODataEntityParser oDataEntityParser = new ODataEntityParser(oDataJPAContext);
- final ODataEntry oDataEntry = oDataEntityParser.parseEntry(oDataEntitySet, content, requestContentType, false);
- virtualJPAEntity.update(oDataEntry);
- } else if (properties != null) {
- virtualJPAEntity.update(properties);
- } else {
- return null;
- }
- em.flush();
- em.getTransaction().commit();
- } catch (Exception e) {
- throw ODataJPARuntimeException.throwException(
- ODataJPARuntimeException.ERROR_JPQL_UPDATE_REQUEST, e);
- }
-
- return jpaEntity;
- }
-
- /* Process Delete Entity Request */
- @Override
- public Object process(DeleteUriInfo uriParserResultView, final String contentType)
- throws ODataJPAModelException, ODataJPARuntimeException {
- JPQLContextType contextType = null;
- try {
- if (uriParserResultView instanceof DeleteUriInfo) {
- uriParserResultView = ((DeleteUriInfo) uriParserResultView);
- if (!((DeleteUriInfo) uriParserResultView).getStartEntitySet().getName()
- .equals(((DeleteUriInfo) uriParserResultView).getTargetEntitySet().getName())) {
- contextType = JPQLContextType.JOIN_SINGLE;
- } else {
- contextType = JPQLContextType.SELECT_SINGLE;
- }
- }
- } catch (EdmException e) {
- ODataJPARuntimeException.throwException(
- ODataJPARuntimeException.GENERAL, e);
- }
-
- // First read the entity with read operation.
- Object selectedObject = readEntity(uriParserResultView, contextType);
- // Read operation done. This object would be passed on to entity manager for delete
- if (selectedObject != null) {
- try {
- em.getTransaction().begin();
- em.remove(selectedObject);
- em.flush();
- em.getTransaction().commit();
- } catch (Exception e) {
- throw ODataJPARuntimeException.throwException(
- ODataJPARuntimeException.ERROR_JPQL_DELETE_REQUEST, e);
- }
- }
- return selectedObject;
- }
-
- /* Process Get Entity Link Request */
- @Override
- public Object process(final GetEntityLinkUriInfo uriParserResultView)
- throws ODataJPAModelException, ODataJPARuntimeException {
-
- return this.process((GetEntityUriInfo) uriParserResultView);
- }
-
- /* Process Get Entity Set Link Request */
- @Override
- public <T> List<T> process(final GetEntitySetLinksUriInfo uriParserResultView)
- throws ODataJPAModelException, ODataJPARuntimeException {
- return this.process((GetEntitySetUriInfo) uriParserResultView);
- }
-
- @Override
- public void process(final PostUriInfo uriInfo,
- final InputStream content, final String requestContentType, final String contentType)
- throws ODataJPARuntimeException, ODataJPAModelException {
- JPALink link = new JPALink(oDataJPAContext);
- link.create(uriInfo, content, requestContentType, contentType);
- link.save();
- }
-
- /* Common method for Read and Delete */
- private Object readEntity(final Object uriParserResultView, final JPQLContextType contextType)
- throws ODataJPAModelException, ODataJPARuntimeException {
-
- Object selectedObject = null;
-
- if (uriParserResultView instanceof DeleteUriInfo || uriParserResultView instanceof GetEntityUriInfo
- || uriParserResultView instanceof PutMergePatchUriInfo) {
-
- JPQLContext selectJPQLContext = JPQLContext.createBuilder(
- contextType, uriParserResultView).build();
-
- JPQLStatement selectJPQLStatement = JPQLStatement.createBuilder(
- selectJPQLContext).build();
- Query query = null;
- try {
- query = em.createQuery(selectJPQLStatement.toString());
- if (!query.getResultList().isEmpty()) {
- selectedObject = query.getResultList().get(0);
- }
- } catch (IllegalArgumentException e) {
- throw ODataJPARuntimeException.throwException(
- ODataJPARuntimeException.ERROR_JPQL_QUERY_CREATE, e);
- }
- }
- return selectedObject;
- }
-
- @Override
- public void process(final PutMergePatchUriInfo putUriInfo,
- final InputStream content, final String requestContentType, final String contentType)
- throws ODataJPARuntimeException, ODataJPAModelException {
-
- JPALink link = new JPALink(oDataJPAContext);
- link.update(putUriInfo, content, requestContentType, contentType);
- link.save();
-
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/access/model/EdmTypeConvertor.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/access/model/EdmTypeConvertor.java b/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/access/model/EdmTypeConvertor.java
deleted file mode 100644
index f3c3e88..0000000
--- a/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/access/model/EdmTypeConvertor.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.access.model;
-
-import java.math.BigDecimal;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.UUID;
-
-import org.apache.olingo.odata2.api.edm.EdmSimpleType;
-import org.apache.olingo.odata2.api.edm.EdmSimpleTypeKind;
-import org.apache.olingo.odata2.api.edm.EdmType;
-import org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPAModelException;
-import org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPARuntimeException;
-
-public class EdmTypeConvertor {
-
- public static Class<?> convertToJavaType(final EdmType edmType) throws ODataJPAModelException,
- ODataJPARuntimeException {
- if (edmType instanceof EdmSimpleType) {
- EdmSimpleType edmSimpleType = (EdmSimpleType) edmType;
- if (edmSimpleType == EdmSimpleTypeKind.String.getEdmSimpleTypeInstance()) {
- return String.class;
- } else if (edmSimpleType == EdmSimpleTypeKind.Int64.getEdmSimpleTypeInstance()) {
- return Long.TYPE;
- } else if (edmSimpleType == EdmSimpleTypeKind.Int16.getEdmSimpleTypeInstance()) {
- return Short.TYPE;
- } else if (edmSimpleType == EdmSimpleTypeKind.Int32.getEdmSimpleTypeInstance()) {
- return Integer.TYPE;
- } else if (edmSimpleType == EdmSimpleTypeKind.Double.getEdmSimpleTypeInstance()) {
- return Double.TYPE;
- } else if (edmSimpleType == EdmSimpleTypeKind.Single.getEdmSimpleTypeInstance()) {
- return Float.TYPE;
- } else if (edmSimpleType == EdmSimpleTypeKind.Decimal.getEdmSimpleTypeInstance()) {
- return BigDecimal.class;
- } else if (edmSimpleType == EdmSimpleTypeKind.Binary.getEdmSimpleTypeInstance()) {
- return byte[].class;
- } else if (edmSimpleType == EdmSimpleTypeKind.Byte.getEdmSimpleTypeInstance()) {
- return Byte.TYPE;
- } else if (edmSimpleType == EdmSimpleTypeKind.Boolean.getEdmSimpleTypeInstance()) {
- return Boolean.TYPE;
- } else if (edmSimpleType == EdmSimpleTypeKind.DateTime.getEdmSimpleTypeInstance()) {
- return Date.class;
- } else if (edmSimpleType == EdmSimpleTypeKind.DateTimeOffset.getEdmSimpleTypeInstance()) {
- return Calendar.class;
- } else if (edmSimpleType == EdmSimpleTypeKind.Guid.getEdmSimpleTypeInstance()) {
- return UUID.class;
- }
- }
- throw ODataJPAModelException.throwException(ODataJPAModelException.TYPE_NOT_SUPPORTED
- .addContent(edmType.toString()), null);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/access/model/JPAEdmMappingModelService.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/access/model/JPAEdmMappingModelService.java b/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/access/model/JPAEdmMappingModelService.java
deleted file mode 100644
index d00638e..0000000
--- a/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/access/model/JPAEdmMappingModelService.java
+++ /dev/null
@@ -1,247 +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.access.model;
-
-import java.io.InputStream;
-
-import javax.xml.bind.JAXBContext;
-import javax.xml.bind.JAXBException;
-import javax.xml.bind.Unmarshaller;
-
-import org.apache.olingo.odata2.processor.api.jpa.ODataJPAContext;
-import org.apache.olingo.odata2.processor.api.jpa.access.JPAEdmMappingModelAccess;
-import org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPAModelException;
-import org.apache.olingo.odata2.processor.api.jpa.model.mapping.JPAAttributeMapType.JPAAttribute;
-import org.apache.olingo.odata2.processor.api.jpa.model.mapping.JPAEdmMappingModel;
-import org.apache.olingo.odata2.processor.api.jpa.model.mapping.JPAEmbeddableTypeMapType;
-import org.apache.olingo.odata2.processor.api.jpa.model.mapping.JPAEntityTypeMapType;
-import org.apache.olingo.odata2.processor.api.jpa.model.mapping.JPAPersistenceUnitMapType;
-import org.apache.olingo.odata2.processor.api.jpa.model.mapping.JPARelationshipMapType.JPARelationship;
-
-public class JPAEdmMappingModelService implements JPAEdmMappingModelAccess {
-
- boolean mappingModelExists = true;
- private JPAEdmMappingModel mappingModel;
- private String mappingModelName;
-
- public JPAEdmMappingModelService(final ODataJPAContext ctx) {
- mappingModelName = ctx.getJPAEdmMappingModel();
- if (mappingModelName == null) {
- mappingModelExists = false;
- }
- }
-
- @Override
- public void loadMappingModel() {
-
- if (mappingModelExists) {
- JAXBContext context;
- try {
- context = JAXBContext.newInstance(JPAEdmMappingModel.class);
-
- Unmarshaller unmarshaller = context.createUnmarshaller();
- InputStream is = loadMappingModelInputStream();
- if (is == null) {
- mappingModelExists = false;
- return;
- }
-
- mappingModel = (JPAEdmMappingModel) unmarshaller.unmarshal(is);
-
- if (mappingModel != null) {
- mappingModelExists = true;
- }
-
- } catch (JAXBException e) {
- mappingModelExists = false;
- ODataJPAModelException.throwException(ODataJPAModelException.GENERAL, e);
- }
- }
- }
-
- @Override
- public boolean isMappingModelExists() {
- return mappingModelExists;
- }
-
- @Override
- public JPAEdmMappingModel getJPAEdmMappingModel() {
- return mappingModel;
- }
-
- @Override
- public String mapJPAPersistenceUnit(final String persistenceUnitName) {
-
- JPAPersistenceUnitMapType persistenceUnit = mappingModel.getPersistenceUnit();
- if (persistenceUnit.getName().equals(persistenceUnitName)) {
- return persistenceUnit.getEDMSchemaNamespace();
- }
-
- return null;
- }
-
- @Override
- public String mapJPAEntityType(final String jpaEntityTypeName) {
-
- JPAEntityTypeMapType jpaEntityTypeMap = searchJPAEntityTypeMapType(jpaEntityTypeName);
- if (jpaEntityTypeMap != null) {
- return jpaEntityTypeMap.getEDMEntityType();
- } else {
- return null;
- }
- }
-
- @Override
- public String mapJPAEntitySet(final String jpaEntityTypeName) {
- JPAEntityTypeMapType jpaEntityTypeMap = searchJPAEntityTypeMapType(jpaEntityTypeName);
- if (jpaEntityTypeMap != null) {
- return jpaEntityTypeMap.getEDMEntitySet();
- } else {
- return null;
- }
- }
-
- @Override
- public String mapJPAAttribute(final String jpaEntityTypeName, final String jpaAttributeName) {
- JPAEntityTypeMapType jpaEntityTypeMap = searchJPAEntityTypeMapType(jpaEntityTypeName);
- if (jpaEntityTypeMap != null && jpaEntityTypeMap.getJPAAttributes() != null) {
- // fixing attributes
- // removal issue
- // from mapping
- for (JPAAttribute jpaAttribute : jpaEntityTypeMap.getJPAAttributes().getJPAAttribute()) {
- if (jpaAttribute.getName().equals(jpaAttributeName)) {
- return jpaAttribute.getValue();
- }
- }
- }
-
- return null;
- }
-
- @Override
- public String mapJPARelationship(final String jpaEntityTypeName, final String jpaRelationshipName) {
- JPAEntityTypeMapType jpaEntityTypeMap = searchJPAEntityTypeMapType(jpaEntityTypeName);
- if (jpaEntityTypeMap != null && jpaEntityTypeMap.getJPARelationships() != null) {
- for (JPARelationship jpaRealtionship : jpaEntityTypeMap.getJPARelationships().getJPARelationship()) {
- if (jpaRealtionship.getName().equals(jpaRelationshipName)) {
- return jpaRealtionship.getValue();
- }
- }
- }
-
- return null;
- }
-
- @Override
- public String mapJPAEmbeddableType(final String jpaEmbeddableTypeName) {
- JPAEmbeddableTypeMapType jpaEmbeddableType = searchJPAEmbeddableTypeMapType(jpaEmbeddableTypeName);
- if (jpaEmbeddableType != null) {
- return jpaEmbeddableType.getEDMComplexType();
- } else {
- return null;
- }
- }
-
- @Override
- public String mapJPAEmbeddableTypeAttribute(final String jpaEmbeddableTypeName, final String jpaAttributeName) {
- JPAEmbeddableTypeMapType jpaEmbeddableType = searchJPAEmbeddableTypeMapType(jpaEmbeddableTypeName);
- if (jpaEmbeddableType != null && jpaEmbeddableType.getJPAAttributes() != null) {
- for (JPAAttribute jpaAttribute : jpaEmbeddableType.getJPAAttributes().getJPAAttribute()) {
- if (jpaAttribute.getName().equals(jpaAttributeName)) {
- return jpaAttribute.getValue();
- }
- }
- }
- return null;
- }
-
- private JPAEntityTypeMapType searchJPAEntityTypeMapType(final String jpaEntityTypeName) {
- for (JPAEntityTypeMapType jpaEntityType : mappingModel.getPersistenceUnit().getJPAEntityTypes()
- .getJPAEntityType()) {
- if (jpaEntityType.getName().equals(jpaEntityTypeName)) {
- return jpaEntityType;
- }
- }
-
- return null;
- }
-
- private JPAEmbeddableTypeMapType searchJPAEmbeddableTypeMapType(final String jpaEmbeddableTypeName) {
- for (JPAEmbeddableTypeMapType jpaEmbeddableType : mappingModel.getPersistenceUnit().getJPAEmbeddableTypes()
- .getJPAEmbeddableType()) {
- if (jpaEmbeddableType.getName().equals(jpaEmbeddableTypeName)) {
- return jpaEmbeddableType;
- }
- }
-
- return null;
- }
-
- protected InputStream loadMappingModelInputStream() {
- InputStream is = JPAEdmMappingModelService.class.getClassLoader().getResourceAsStream("../../" + mappingModelName);
-
- return is;
-
- }
-
- @Override
- public boolean checkExclusionOfJPAEntityType(final String jpaEntityTypeName) {
- JPAEntityTypeMapType type = searchJPAEntityTypeMapType(jpaEntityTypeName);
- if (type != null) {
- return type.isExclude();
- }
- return false;
- }
-
- @Override
- public boolean checkExclusionOfJPAAttributeType(final String jpaEntityTypeName, final String jpaAttributeName) {
- JPAEntityTypeMapType type = searchJPAEntityTypeMapType(jpaEntityTypeName);
- if (type != null && type.getJPAAttributes() != null) {
- for (JPAAttribute jpaAttribute : type.getJPAAttributes().getJPAAttribute()) {
- if (jpaAttribute.getName().equals(jpaAttributeName)) {
- return jpaAttribute.isExclude();
- }
- }
- }
- return false;
- }
-
- @Override
- public boolean checkExclusionOfJPAEmbeddableType(final String jpaEmbeddableTypeName) {
- JPAEmbeddableTypeMapType type = searchJPAEmbeddableTypeMapType(jpaEmbeddableTypeName);
- if (type != null) {
- return type.isExclude();
- }
- return false;
- }
-
- @Override
- public boolean checkExclusionOfJPAEmbeddableAttributeType(final String jpaEmbeddableTypeName,
- final String jpaAttributeName) {
- JPAEmbeddableTypeMapType type = searchJPAEmbeddableTypeMapType(jpaEmbeddableTypeName);
- if (type != null && type.getJPAAttributes() != null) {
- for (JPAAttribute jpaAttribute : type.getJPAAttributes().getJPAAttribute()) {
- if (jpaAttribute.getName().equals(jpaAttributeName)) {
- return jpaAttribute.isExclude();
- }
- }
- }
- return false;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/access/model/JPAEdmNameBuilder.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/access/model/JPAEdmNameBuilder.java b/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/access/model/JPAEdmNameBuilder.java
deleted file mode 100644
index 2a96ac9..0000000
--- a/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/access/model/JPAEdmNameBuilder.java
+++ /dev/null
@@ -1,499 +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.access.model;
-
-import java.lang.reflect.AnnotatedElement;
-import java.lang.reflect.Field;
-
-import javax.persistence.Column;
-import javax.persistence.metamodel.Attribute;
-import javax.persistence.metamodel.ManagedType;
-import javax.persistence.metamodel.PluralAttribute;
-
-import org.apache.olingo.odata2.api.edm.FullQualifiedName;
-import org.apache.olingo.odata2.api.edm.provider.Association;
-import org.apache.olingo.odata2.api.edm.provider.AssociationSet;
-import org.apache.olingo.odata2.api.edm.provider.ComplexProperty;
-import org.apache.olingo.odata2.api.edm.provider.ComplexType;
-import org.apache.olingo.odata2.api.edm.provider.EntityType;
-import org.apache.olingo.odata2.api.edm.provider.Mapping;
-import org.apache.olingo.odata2.api.edm.provider.NavigationProperty;
-import org.apache.olingo.odata2.processor.api.jpa.access.JPAEdmMappingModelAccess;
-import org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPAModelException;
-import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmAssociationEndView;
-import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmAssociationSetView;
-import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmAssociationView;
-import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmBaseView;
-import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmComplexPropertyView;
-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.api.jpa.model.JPAEdmNavigationPropertyView;
-import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmPropertyView;
-import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmSchemaView;
-import org.apache.olingo.odata2.processor.core.jpa.model.JPAEdmComplexType;
-import org.apache.olingo.odata2.processor.core.jpa.model.JPAEdmMappingImpl;
-
-public class JPAEdmNameBuilder {
- private static final String ENTITY_CONTAINER_SUFFIX = "Container";
- private static final String ENTITY_SET_SUFFIX = "s";
- private static final String ASSOCIATIONSET_SUFFIX = "Set";
- private static final String NAVIGATION_NAME = "Details";
- private static final String UNDERSCORE = "_";
-
- public static FullQualifiedName build(final JPAEdmBaseView view, final String name) {
- FullQualifiedName fqName = new FullQualifiedName(buildNamespace(view), name);
- return fqName;
- }
-
- /*
- * ************************************************************************
- * EDM EntityType Name - RULES
- * ************************************************************************
- * EDM Entity Type Name = JPA Entity Name EDM Entity Type Internal Name =
- * JPA Entity Name
- * ************************************************************************
- * EDM Entity Type Name - RULES
- * ************************************************************************
- */
- public static void build(final JPAEdmEntityTypeView view) {
-
- EntityType edmEntityType = view.getEdmEntityType();
- String jpaEntityName = view.getJPAEntityType().getName();
- JPAEdmMappingModelAccess mappingModelAccess = view.getJPAEdmMappingModelAccess();
- String edmEntityTypeName = null;
- if (mappingModelAccess != null && mappingModelAccess.isMappingModelExists()) {
- edmEntityTypeName = mappingModelAccess.mapJPAEntityType(jpaEntityName);
- }
-
- JPAEdmMapping mapping = new JPAEdmMappingImpl();
- mapping.setJPAType(view.getJPAEntityType().getJavaType());
-
- if (edmEntityTypeName == null) {
- edmEntityTypeName = jpaEntityName;
- }
- // Setting the mapping object
- edmEntityType.setMapping(((Mapping) mapping).setInternalName(jpaEntityName));
-
- edmEntityType.setName(edmEntityTypeName);
-
- }
-
- /*
- * ************************************************************************
- * EDM Schema Name - RULES
- * ************************************************************************
- * Java Persistence Unit name is set as Schema's Namespace
- * ************************************************************************
- * EDM Schema Name - RULES
- * ************************************************************************
- */
- public static void build(final JPAEdmSchemaView view) throws ODataJPAModelException {
- view.getEdmSchema().setNamespace(buildNamespace(view));
- }
-
- /*
- * ************************************************************************
- * EDM Property Name - RULES
- * ************************************************************************
- * OData Property Names are represented in Camel Case. The first character
- * of JPA Attribute Name is converted to an UpperCase Character and set as
- * OData Property Name. JPA Attribute Name is set as Internal Name for OData
- * Property. The Column name (annotated as @Column(name="x")) is set as
- * column name in the mapping object.
- * ************************************************************************
- * EDM Property Name - RULES
- * ************************************************************************
- */
- public static void build(final JPAEdmPropertyView view, final boolean isComplexMode,
- final boolean skipDefaultNaming) {
- Attribute<?, ?> jpaAttribute = view.getJPAAttribute();
- String jpaAttributeName = jpaAttribute.getName();
- String propertyName = null;
-
- JPAEdmMappingModelAccess mappingModelAccess = view.getJPAEdmMappingModelAccess();
- if (mappingModelAccess != null && mappingModelAccess.isMappingModelExists()) {
- if (isComplexMode) {
- propertyName =
- mappingModelAccess.mapJPAEmbeddableTypeAttribute(view.getJPAEdmComplexTypeView().getJPAEmbeddableType()
- .getJavaType().getSimpleName(), jpaAttributeName);
- } else {
- propertyName =
- mappingModelAccess.mapJPAAttribute(view.getJPAEdmEntityTypeView().getJPAEntityType().getName(),
- jpaAttributeName);
- }
- }
- if (skipDefaultNaming == false && propertyName == null) {
- propertyName = Character.toUpperCase(jpaAttributeName.charAt(0)) + jpaAttributeName.substring(1);
- } else if (propertyName == null) {
- propertyName = jpaAttributeName;
- }
-
- view.getEdmSimpleProperty().setName(propertyName);
-
- JPAEdmMapping mapping = new JPAEdmMappingImpl();
- ((Mapping) mapping).setInternalName(jpaAttributeName);
- mapping.setJPAType(jpaAttribute.getJavaType());
-
- AnnotatedElement annotatedElement = (AnnotatedElement) jpaAttribute.getJavaMember();
- if (annotatedElement != null) {
- Column column = annotatedElement.getAnnotation(Column.class);
- if (column != null) {
- mapping.setJPAColumnName(column.name());
- }
- } else {
- ManagedType<?> managedType = jpaAttribute.getDeclaringType();
- if (managedType != null) {
- Class<?> clazz = managedType.getJavaType();
- try {
- Field field = clazz.getField(jpaAttributeName);
- Column column = field.getAnnotation(Column.class);
- if (column != null) {
- mapping.setJPAColumnName(column.name());
- }
- } catch (SecurityException e) {
-
- } catch (NoSuchFieldException e) {
-
- }
- }
-
- }
- view.getEdmSimpleProperty().setMapping((Mapping) mapping);
- }
-
- /*
- * ************************************************************************
- * EDM EntityContainer Name - RULES
- * ************************************************************************
- * Entity Container Name = EDM Namespace + Literal "Container"
- * ************************************************************************
- * EDM EntityContainer Name - RULES
- * ************************************************************************
- */
- public static void build(final JPAEdmEntityContainerView view) {
- view.getEdmEntityContainer().setName(buildNamespace(view) + ENTITY_CONTAINER_SUFFIX);
- }
-
- /*
- * ************************************************************************
- * EDM EntitySet Name - RULES
- * ************************************************************************
- * Entity Set Name = JPA Entity Type Name + Literal "s"
- * ************************************************************************
- * EDM EntitySet Name - RULES
- * ************************************************************************
- */
- public static void build(final JPAEdmEntitySetView view, final JPAEdmEntityTypeView entityTypeView) {
- FullQualifiedName fQname = view.getEdmEntitySet().getEntityType();
- JPAEdmMappingModelAccess mappingModelAccess = view.getJPAEdmMappingModelAccess();
- String entitySetName = null;
- if (mappingModelAccess != null && mappingModelAccess.isMappingModelExists()) {
- Mapping mapping = entityTypeView.getEdmEntityType().getMapping();
- if (mapping != null) {
- entitySetName = mappingModelAccess.mapJPAEntitySet(mapping.getInternalName());
- }
- }
-
- if (entitySetName == null) {
- entitySetName = fQname.getName() + ENTITY_SET_SUFFIX;
- }
-
- view.getEdmEntitySet().setName(entitySetName);
- }
-
- /*
- * ************************************************************************
- * EDM Complex Type Name - RULES
- * ************************************************************************
- * Complex Type Name = JPA Embeddable Type Simple Name.
- * ************************************************************************
- * EDM Complex Type Name - RULES
- * ************************************************************************
- */
- public static void build(final JPAEdmComplexType view) {
-
- JPAEdmMappingModelAccess mappingModelAccess = view.getJPAEdmMappingModelAccess();
- String jpaEmbeddableTypeName = view.getJPAEmbeddableType().getJavaType().getSimpleName();
- String edmComplexTypeName = null;
- if (mappingModelAccess != null && mappingModelAccess.isMappingModelExists()) {
- edmComplexTypeName = mappingModelAccess.mapJPAEmbeddableType(jpaEmbeddableTypeName);
- }
-
- if (edmComplexTypeName == null) {
- edmComplexTypeName = jpaEmbeddableTypeName;
- }
-
- view.getEdmComplexType().setName(edmComplexTypeName);
- ComplexType complexType = view.getEdmComplexType();
- complexType.setName(edmComplexTypeName);
- JPAEdmMapping mapping = new JPAEdmMappingImpl();
- mapping.setJPAType(view.getJPAEmbeddableType().getJavaType());
- complexType.setMapping((Mapping) mapping);
-
- }
-
- /*
- * ************************************************************************
- * EDM Complex Property Name - RULES
- * ************************************************************************
- * The first character of JPA complex attribute name is converted to
- * uppercase. The modified JPA complex attribute name is assigned as EDM
- * complex property name. The unmodified JPA complex attribute name is
- * assigned as internal name.
- * ************************************************************************
- * EDM Complex Property Name - RULES
- * ************************************************************************
- */
- public static void build(final JPAEdmComplexPropertyView complexView,
- final JPAEdmPropertyView propertyView, final boolean skipDefaultNaming) {
-
- ComplexProperty complexProperty = complexView.getEdmComplexProperty();
-
- String jpaAttributeName = propertyView.getJPAAttribute().getName();
- String jpaEntityTypeName = propertyView.getJPAEdmEntityTypeView().getJPAEntityType().getName();
-
- JPAEdmMappingModelAccess mappingModelAccess = complexView.getJPAEdmMappingModelAccess();
- String propertyName = null;
-
- if (mappingModelAccess != null && mappingModelAccess.isMappingModelExists()) {
- propertyName = mappingModelAccess.mapJPAAttribute(jpaEntityTypeName, jpaAttributeName);
- }
-
- if (skipDefaultNaming == false && propertyName == null) {
- propertyName = Character.toUpperCase(jpaAttributeName.charAt(0)) + jpaAttributeName.substring(1);
- } else if (propertyName == null) {
- propertyName = jpaAttributeName;
- }
-
- // change for navigation property issue
- JPAEdmMapping mapping = new JPAEdmMappingImpl();
- ((Mapping) mapping).setInternalName(jpaAttributeName);
- mapping.setJPAType(propertyView.getJPAAttribute().getJavaType());
- complexProperty.setMapping((Mapping) mapping);
-
- complexProperty.setName(propertyName);
-
- }
-
- public static void build(final JPAEdmComplexPropertyView complexView,
- final String parentComplexTypeName, final boolean skipDefaultNaming) {
- ComplexProperty complexProperty = complexView.getEdmComplexProperty();
-
- JPAEdmMappingModelAccess mappingModelAccess = complexView.getJPAEdmMappingModelAccess();
- JPAEdmPropertyView propertyView = ((JPAEdmPropertyView) complexView);
- String jpaAttributeName = propertyView.getJPAAttribute().getName();
- String propertyName = null;
- if (mappingModelAccess != null && mappingModelAccess.isMappingModelExists()) {
- propertyName = mappingModelAccess.mapJPAEmbeddableTypeAttribute(parentComplexTypeName, jpaAttributeName);
- }
- if (skipDefaultNaming == false && propertyName == null) {
- propertyName = Character.toUpperCase(jpaAttributeName.charAt(0)) + jpaAttributeName.substring(1);
- } else if (propertyName == null) {
- propertyName = jpaAttributeName;
- }
-
- JPAEdmMapping mapping = new JPAEdmMappingImpl();
- ((Mapping) mapping).setInternalName(jpaAttributeName);
- mapping.setJPAType(propertyView.getJPAAttribute().getJavaType());
- complexProperty.setMapping((Mapping) mapping);
- complexProperty.setName(propertyName);
-
- }
-
- /*
- * ************************************************************************
- * EDM Association End Name - RULES
- * ************************************************************************
- * Association End name = Namespace + Entity Type Name
- * ************************************************************************
- * EDM Association End Name - RULES
- * ************************************************************************
- */
- public static void build(final JPAEdmAssociationEndView assocaitionEndView,
- final JPAEdmEntityTypeView entityTypeView, final JPAEdmPropertyView propertyView) {
-
- String namespace = buildNamespace(assocaitionEndView);
-
- String name = entityTypeView.getEdmEntityType().getName();
- FullQualifiedName fQName = new FullQualifiedName(namespace, name);
- assocaitionEndView.getEdmAssociationEnd1().setType(fQName);
-
- name = null;
- String jpaEntityTypeName = null;
- Attribute<?, ?> jpaAttribute = propertyView.getJPAAttribute();
- if (jpaAttribute.isCollection()) {
- jpaEntityTypeName = ((PluralAttribute<?, ?, ?>) jpaAttribute).getElementType().getJavaType()
- .getSimpleName();
- } else {
- jpaEntityTypeName = propertyView.getJPAAttribute().getJavaType()
- .getSimpleName();
- }
-
- JPAEdmMappingModelAccess mappingModelAccess = assocaitionEndView.getJPAEdmMappingModelAccess();
-
- if (mappingModelAccess != null && mappingModelAccess.isMappingModelExists()) {
- name = mappingModelAccess.mapJPAEntityType(jpaEntityTypeName);
- }
-
- if (name == null) {
- name = jpaEntityTypeName;
- }
-
- fQName = new FullQualifiedName(namespace, name);
- assocaitionEndView.getEdmAssociationEnd2().setType(fQName);
-
- }
-
- private static String buildNamespace(final JPAEdmBaseView view) {
- JPAEdmMappingModelAccess mappingModelAccess = view.getJPAEdmMappingModelAccess();
- String namespace = null;
- if (mappingModelAccess != null && mappingModelAccess.isMappingModelExists()) {
- namespace = mappingModelAccess.mapJPAPersistenceUnit(view.getpUnitName());
- }
- if (namespace == null) {
- namespace = view.getpUnitName();
- }
-
- return namespace;
- }
-
- /*
- * ************************************************************************
- * EDM Association Name - RULES
- * ************************************************************************
- * Association name = Association + End1 Name + End2 Name
- * ************************************************************************
- * EDM Association Name - RULES
- * ************************************************************************
- */
-
- public static void build(final JPAEdmAssociationView view, final int count) {
- Association association = view.getEdmAssociation();
- String associationName = null;
- String end1Name = association.getEnd1().getType().getName();
- String end2Name = association.getEnd2().getType().getName();
-
- if (end1Name.compareToIgnoreCase(end2Name) > 0) {
- associationName = end2Name + UNDERSCORE + end1Name;
- } else {
- associationName = end1Name + UNDERSCORE + end2Name;
- }
- if (count > 1) {
- associationName = associationName + Integer.toString(count - 1);
- }
- association.setName(associationName);
-
- }
-
- /*
- * ************************************************************************
- * EDM Association Set Name - RULES
- * ************************************************************************
- * Association Set name = Association Name + "Set"
- * ************************************************************************
- * EDM Association Set Name - RULES
- * ************************************************************************
- */
- public static void build(final JPAEdmAssociationSetView view) {
- AssociationSet associationSet = view.getEdmAssociationSet();
-
- String name = view.getEdmAssociation().getName();
- associationSet.setName(name + ASSOCIATIONSET_SUFFIX);
-
- }
-
- public static void build(final JPAEdmAssociationView associationView,
- final JPAEdmPropertyView propertyView,
- final JPAEdmNavigationPropertyView navPropertyView, final boolean skipDefaultNaming, final int count) {
-
- String toName = null;
- String fromName = null;
- String navPropName = null;
- NavigationProperty navProp = navPropertyView.getEdmNavigationProperty();
- String namespace = buildNamespace(associationView);
-
- Association association = associationView.getEdmAssociation();
- navProp.setRelationship(new FullQualifiedName(namespace, association
- .getName()));
-
- FullQualifiedName associationEndTypeOne = association.getEnd1()
- .getType();
- FullQualifiedName associationEndTypeTwo = association.getEnd2()
- .getType();
-
- Attribute<?, ?> jpaAttribute = propertyView.getJPAAttribute();
- JPAEdmMapping mapping = new JPAEdmMappingImpl();
- ((Mapping) mapping).setInternalName(jpaAttribute.getName());
- mapping.setJPAType(jpaAttribute.getJavaType());
- navProp.setMapping((Mapping) mapping);
-
- String jpaEntityTypeName = propertyView.getJPAEdmEntityTypeView()
- .getJPAEntityType().getName();
- JPAEdmMappingModelAccess mappingModelAccess = navPropertyView
- .getJPAEdmMappingModelAccess();
-
- String targetEntityTypeName = null;
- if (jpaAttribute.isCollection()) {
- targetEntityTypeName = ((PluralAttribute<?, ?, ?>) jpaAttribute).getElementType().getJavaType().getSimpleName();
- } else {
- targetEntityTypeName = jpaAttribute.getJavaType().getSimpleName();
- }
-
- if (mappingModelAccess != null
- && mappingModelAccess.isMappingModelExists()) {
- navPropName = mappingModelAccess.mapJPARelationship(
- jpaEntityTypeName, jpaAttribute.getName());
- toName = mappingModelAccess.mapJPAEntityType(targetEntityTypeName);
- fromName = mappingModelAccess
- .mapJPAEntityType(jpaEntityTypeName);
- }
- if (toName == null) {
- toName = targetEntityTypeName;
- }
-
- if (fromName == null) {
- fromName = jpaEntityTypeName;
- }
-
- if (skipDefaultNaming == false) {
- if (navPropName == null) {
- navPropName = toName.concat(NAVIGATION_NAME);
- }
- if (count > 1) {
- navPropName = navPropName + Integer.toString(count - 1);
- }
- } else if (navPropName == null) {
- navPropName = jpaAttribute.getName();
- }
-
- navProp.setName(navPropName);
-
- if (toName.equals(associationEndTypeOne.getName())) {
- navProp.setFromRole(association.getEnd2().getRole());
- navProp.setToRole(association.getEnd1().getRole());
- } else if (toName.equals(associationEndTypeTwo.getName())) {
-
- navProp.setToRole(association.getEnd2().getRole());
- navProp.setFromRole(association.getEnd1().getRole());
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/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
deleted file mode 100644
index e7b8a6e..0000000
--- a/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/access/model/JPATypeConvertor.java
+++ /dev/null
@@ -1,119 +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.access.model;
-
-import java.lang.reflect.Field;
-import java.math.BigDecimal;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.UUID;
-
-import javax.persistence.Temporal;
-import javax.persistence.TemporalType;
-import javax.persistence.metamodel.Attribute;
-
-import org.apache.olingo.odata2.api.edm.EdmSimpleTypeKind;
-import org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPAModelException;
-
-/**
- * This class holds utility methods for Type conversions between JPA and OData Types.
- *
- *
- *
- */
-public class JPATypeConvertor {
-
- /**
- * This utility method converts a given jpa Type to equivalent
- * EdmSimpleTypeKind for maintaining compatibility between Java and OData
- * Types.
- *
- * @param jpaType
- * The JPA Type input.
- * @return The corresponding EdmSimpleTypeKind.
- * @throws ODataJPAModelException
- * @throws org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPARuntimeException
- *
- * @see EdmSimpleTypeKind
- */
-
- private static final String OBJECT_TYPE = "java.lang.Object";
-
- public static EdmSimpleTypeKind
- convertToEdmSimpleType(final Class<?> jpaType, final Attribute<?, ?> currentAttribute)
- throws ODataJPAModelException {
- if (jpaType.equals(String.class) || jpaType.equals(Character.class) || jpaType.equals(char.class)
- || jpaType.equals(char[].class) ||
- jpaType.equals(Character[].class)) {
- return EdmSimpleTypeKind.String;
- } else if (jpaType.equals(Long.class) || jpaType.equals(long.class)) {
- return EdmSimpleTypeKind.Int64;
- } else if (jpaType.equals(Short.class) || jpaType.equals(short.class)) {
- return EdmSimpleTypeKind.Int16;
- } else if (jpaType.equals(Integer.class) || jpaType.equals(int.class)) {
- return EdmSimpleTypeKind.Int32;
- } else if (jpaType.equals(Double.class) || jpaType.equals(double.class)) {
- return EdmSimpleTypeKind.Double;
- } else if (jpaType.equals(Float.class) || jpaType.equals(float.class)) {
- return EdmSimpleTypeKind.Single;
- } else if (jpaType.equals(BigDecimal.class)) {
- return EdmSimpleTypeKind.Decimal;
- } else if (jpaType.equals(byte[].class)) {
- return EdmSimpleTypeKind.Binary;
- } else if (jpaType.equals(Byte.class) || jpaType.equals(byte.class)) {
- return EdmSimpleTypeKind.Byte;
- } else if (jpaType.equals(Byte[].class)) {
- return EdmSimpleTypeKind.Binary;
- } else if (jpaType.equals(Boolean.class) || jpaType.equals(boolean.class)) {
- return EdmSimpleTypeKind.Boolean;
- } else if ((jpaType.equals(Date.class)) || (jpaType.equals(Calendar.class))) {
- try {
- if ((currentAttribute != null)
- && (determineTemporalType(currentAttribute.getDeclaringType().getJavaType(), currentAttribute.getName())
- == TemporalType.TIME)) {
- return EdmSimpleTypeKind.Time;
- } else {
- return EdmSimpleTypeKind.DateTime;
- }
- } catch (SecurityException e) {
- throw ODataJPAModelException.throwException(ODataJPAModelException.GENERAL.addContent(e.getMessage()), e);
- }
- } else if (jpaType.equals(UUID.class)) {
- return EdmSimpleTypeKind.Guid;
- }
- throw ODataJPAModelException.throwException(ODataJPAModelException.TYPE_NOT_SUPPORTED
- .addContent(jpaType.toString()), null);
- }
-
- private static TemporalType determineTemporalType(final Class<?> type, final String fieldName)
- throws ODataJPAModelException {
- if (type != null && !type.getName().equals(OBJECT_TYPE)) {
- try {
- Field field = type.getField(fieldName);
- return field.getAnnotation(Temporal.class).value();
- } catch (NoSuchFieldException e) {
- determineTemporalType(type.getSuperclass(), fieldName);
- } catch (SecurityException e) {
- throw ODataJPAModelException.throwException(ODataJPAModelException.GENERAL.addContent(e.getMessage()), e);
- }
- }
- return null;
-
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/edm/ODataJPAEdmProvider.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/edm/ODataJPAEdmProvider.java b/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/edm/ODataJPAEdmProvider.java
deleted file mode 100644
index e0014e5..0000000
--- a/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/edm/ODataJPAEdmProvider.java
+++ /dev/null
@@ -1,295 +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.edm;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-
-import org.apache.olingo.odata2.api.edm.FullQualifiedName;
-import org.apache.olingo.odata2.api.edm.provider.Association;
-import org.apache.olingo.odata2.api.edm.provider.AssociationSet;
-import org.apache.olingo.odata2.api.edm.provider.AssociationSetEnd;
-import org.apache.olingo.odata2.api.edm.provider.ComplexType;
-import org.apache.olingo.odata2.api.edm.provider.EdmProvider;
-import org.apache.olingo.odata2.api.edm.provider.EntityContainer;
-import org.apache.olingo.odata2.api.edm.provider.EntityContainerInfo;
-import org.apache.olingo.odata2.api.edm.provider.EntitySet;
-import org.apache.olingo.odata2.api.edm.provider.EntityType;
-import org.apache.olingo.odata2.api.edm.provider.FunctionImport;
-import org.apache.olingo.odata2.api.edm.provider.Schema;
-import org.apache.olingo.odata2.api.exception.ODataException;
-import org.apache.olingo.odata2.processor.api.jpa.ODataJPAContext;
-import org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPAException;
-import org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPAModelException;
-import org.apache.olingo.odata2.processor.api.jpa.factory.ODataJPAFactory;
-import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmModelView;
-
-public class ODataJPAEdmProvider extends EdmProvider {
-
- private ODataJPAContext oDataJPAContext;
- private JPAEdmModelView jpaEdmModel;
-
- private List<Schema> schemas;
- private HashMap<String, EntityType> entityTypes;
- private HashMap<String, EntityContainerInfo> entityContainerInfos;
- private HashMap<String, ComplexType> complexTypes;
- private HashMap<String, Association> associations;
- private HashMap<String, FunctionImport> functionImports;
-
- public ODataJPAEdmProvider() {
- entityTypes = new HashMap<String, EntityType>();
- entityContainerInfos = new HashMap<String, EntityContainerInfo>();
- complexTypes = new HashMap<String, ComplexType>();
- associations = new HashMap<String, Association>();
- functionImports = new HashMap<String, FunctionImport>();
- }
-
- public ODataJPAEdmProvider(final ODataJPAContext oDataJPAContext) {
- if (oDataJPAContext == null) {
- throw new IllegalArgumentException(ODataJPAException.ODATA_JPACTX_NULL);
- }
- entityTypes = new HashMap<String, EntityType>();
- entityContainerInfos = new HashMap<String, EntityContainerInfo>();
- complexTypes = new HashMap<String, ComplexType>();
- associations = new HashMap<String, Association>();
- functionImports = new HashMap<String, FunctionImport>();
- jpaEdmModel = ODataJPAFactory.createFactory().getJPAAccessFactory().getJPAEdmModelView(oDataJPAContext);
- }
-
- public ODataJPAContext getODataJPAContext() {
- return oDataJPAContext;
- }
-
- public void setODataJPAContext(final ODataJPAContext jpaContext) {
- oDataJPAContext = jpaContext;
- }
-
- @Override
- public EntityContainerInfo getEntityContainerInfo(final String name) throws ODataException {
-
- if (entityContainerInfos.containsKey(name)) {
- return entityContainerInfos.get(name);
- } else {
-
- if (schemas == null) {
- getSchemas();
- }
- List<EntityContainer> containerList = schemas.get(0).getEntityContainers();
- if (containerList == null) {
- return null;
- }
- for (EntityContainer container : containerList) {
- if (name == null && container.isDefaultEntityContainer()) {
- entityContainerInfos.put(name, container);
- return container;
- } else if (name != null && name.equals(container.getName())) {
- return container;
- }
- }
- }
- return null;
- }
-
- @Override
- public EntityType getEntityType(final FullQualifiedName edmFQName) throws ODataException {
-
- String strEdmFQName = edmFQName.toString();
-
- if (edmFQName != null) {
- if (entityTypes.containsKey(strEdmFQName)) {
- return entityTypes.get(strEdmFQName);
- } else if (schemas == null) {
- getSchemas();
- }
-
- String entityTypeNamespace = edmFQName.getNamespace();
- String entityTypeName = edmFQName.getName();
-
- for (Schema schema : schemas) {
- String schemaNamespace = schema.getNamespace();
- if (schemaNamespace.equals(entityTypeNamespace)) {
- if (schema.getEntityTypes() == null) {
- return null;
- }
- for (EntityType et : schema.getEntityTypes()) {
- if (et.getName().equals(entityTypeName)) {
- entityTypes.put(strEdmFQName, et);
- return et;
- }
- }
- }
- }
- }
-
- return null;
- }
-
- @Override
- public ComplexType getComplexType(final FullQualifiedName edmFQName) throws ODataException {
-
- if (edmFQName != null) {
- if (complexTypes.containsKey(edmFQName.toString())) {
- return complexTypes.get(edmFQName.toString());
- } else if (schemas == null) {
- getSchemas();
- }
-
- for (Schema schema : schemas) {
- if (schema.getNamespace().equals(edmFQName.getNamespace())) {
- if (schema.getComplexTypes() == null) {
- return null;
- }
- for (ComplexType ct : schema.getComplexTypes()) {
- if (ct.getName().equals(edmFQName.getName())) {
- complexTypes.put(edmFQName.toString(), ct);
- return ct;
- }
- }
- }
- }
- }
-
- return null;
- }
-
- @Override
- public Association getAssociation(final FullQualifiedName edmFQName) throws ODataException {
- if (edmFQName != null) {
- if (associations.containsKey(edmFQName.toString())) {
- return associations.get(edmFQName.toString());
- } else if (schemas == null) {
- getSchemas();
- }
-
- for (Schema schema : schemas) {
- if (schema.getNamespace().equals(edmFQName.getNamespace())) {
- if (schema.getAssociations() == null) {
- return null;
- }
- for (Association association : schema.getAssociations()) {
- if (association.getName().equals(edmFQName.getName())) {
- associations.put(edmFQName.toString(), association);
- return association;
- }
- }
- }
- }
-
- }
- return null;
- }
-
- @Override
- public EntitySet getEntitySet(final String entityContainer, final String name) throws ODataException {
-
- EntitySet returnedSet = null;
- EntityContainer container = null;
- if (!entityContainerInfos.containsKey(entityContainer)) {
- container = (EntityContainer) getEntityContainerInfo(entityContainer);
- } else {
- container = (EntityContainer) entityContainerInfos.get(entityContainer);
- }
-
- if (container != null && name != null) {
- for (EntitySet es : container.getEntitySets()) {
- if (name.equals(es.getName())) {
- returnedSet = es;
- break;
- }
- }
- }
-
- return returnedSet;
- }
-
- @Override
- public AssociationSet getAssociationSet(final String entityContainer, final FullQualifiedName association,
- final String sourceEntitySetName, final String sourceEntitySetRole) throws ODataException {
-
- EntityContainer container = null;
- if (!entityContainerInfos.containsKey(entityContainer)) {
- container = (EntityContainer) getEntityContainerInfo(entityContainer);
- } else {
- container = (EntityContainer) entityContainerInfos.get(entityContainer);
- }
-
- if (container != null && association != null && container.getAssociationSets() != null) {
- for (AssociationSet as : container.getAssociationSets()) {
- if (association.equals(as.getAssociation())) {
- AssociationSetEnd end = as.getEnd1();
- if (sourceEntitySetName.equals(end.getEntitySet()) && sourceEntitySetRole.equals(end.getRole())) {
- return as;
- } else {
- end = as.getEnd2();
- if (sourceEntitySetName.equals(end.getEntitySet()) && sourceEntitySetRole.equals(end.getRole())) {
- return as;
- }
- }
- }
- }
- }
- return null;
- }
-
- @Override
- public FunctionImport getFunctionImport(final String entityContainer, final String name) throws ODataException {
-
- if (functionImports.containsKey(name)) {
- return functionImports.get(name);
- }
-
- EntityContainer container = null;
- if (!entityContainerInfos.containsKey(entityContainer)) {
- container = (EntityContainer) getEntityContainerInfo(entityContainer);
- } else {
- container = (EntityContainer) entityContainerInfos.get(entityContainer);
- }
-
- if (container != null && name != null) {
- if (container.getFunctionImports() == null) {
- return null;
- }
- for (FunctionImport fi : container.getFunctionImports()) {
- if (name.equals(fi.getName())) {
- functionImports.put(name, fi);
- return fi;
- }
- }
- }
- return null;
- }
-
- @Override
- public List<Schema> getSchemas() throws ODataException {
- if (schemas == null && jpaEdmModel != null) {
- jpaEdmModel.getBuilder().build();
- schemas = new ArrayList<Schema>();
- schemas.add(jpaEdmModel.getEdmSchemaView().getEdmSchema());
- }
- if (jpaEdmModel == null) {
-
- throw ODataJPAModelException.throwException(ODataJPAModelException.BUILDER_NULL, null);
- }
-
- return schemas;
-
- }
-
-}
[26/37] [OLINGO-82] Renamed the project folder name to
odata2-jpa-processor
Posted by ch...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/edm/ODataJPAEdmProviderNegativeTest.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/edm/ODataJPAEdmProviderNegativeTest.java b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/edm/ODataJPAEdmProviderNegativeTest.java
new file mode 100644
index 0000000..f00cc61
--- /dev/null
+++ b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/edm/ODataJPAEdmProviderNegativeTest.java
@@ -0,0 +1,191 @@
+/*******************************************************************************
+ * 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.edm;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.fail;
+
+import java.lang.reflect.Field;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.olingo.odata2.api.edm.FullQualifiedName;
+import org.apache.olingo.odata2.api.edm.provider.Association;
+import org.apache.olingo.odata2.api.edm.provider.EntityContainer;
+import org.apache.olingo.odata2.api.edm.provider.EntityContainerInfo;
+import org.apache.olingo.odata2.api.edm.provider.Schema;
+import org.apache.olingo.odata2.api.exception.ODataException;
+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.model.JPAEdmModel;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class ODataJPAEdmProviderNegativeTest {
+
+ private static ODataJPAEdmProvider edmProvider;
+
+ @BeforeClass
+ public static void setup() {
+
+ edmProvider = new ODataJPAEdmProvider();
+ try {
+ Class<? extends ODataJPAEdmProvider> clazz = edmProvider.getClass();
+ Field field = clazz.getDeclaredField("schemas");
+ field.setAccessible(true);
+ List<Schema> schemas = new ArrayList<Schema>();
+ schemas.add(new Schema().setNamespace("salesorderprocessing")); // Empty Schema
+ field.set(edmProvider, schemas);
+ field = clazz.getDeclaredField("oDataJPAContext");
+ field.setAccessible(true);
+ field.set(edmProvider, ODataJPAContextMock.mockODataJPAContext());
+ field = clazz.getDeclaredField("jpaEdmModel");
+ field.setAccessible(true);
+ field.set(edmProvider, new JPAEdmModel(null, null));
+ } catch (IllegalArgumentException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ } catch (IllegalAccessException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ } catch (NoSuchFieldException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ } catch (SecurityException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+
+ }
+
+ @Test
+ public void testNullGetEntityContainerInfo() {
+ EntityContainerInfo entityContainer = null;
+ try {
+ entityContainer = edmProvider.getEntityContainerInfo("salesorderprocessingContainer");
+ } catch (ODataException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+ assertNull(entityContainer);
+ }
+
+ @Test
+ public void testNullGetEntityType() {
+ FullQualifiedName entityTypeName = new FullQualifiedName("salesorderprocessing", "SalesOrderHeader");
+ try {
+ assertNull(edmProvider.getEntityType(entityTypeName));
+ } catch (ODataException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+ }
+
+ @Test
+ public void testNullGetComplexType() {
+ FullQualifiedName complexTypeName = new FullQualifiedName("salesorderprocessing", "Address");
+ try {
+ assertNull(edmProvider.getComplexType(complexTypeName));
+ } catch (ODataException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+ }
+
+ @Test
+ public void testGetAssociationFullQualifiedName() {
+ Association association = null;
+ try {
+ association =
+ edmProvider.getAssociation(new FullQualifiedName("salesorderprocessing", "SalesOrderHeader_SalesOrderItem"));
+ } catch (ODataException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+ assertNull(association);
+ }
+
+ @Test
+ public void testGetEntitySet() {
+ try {
+ assertNull(edmProvider.getEntitySet("salesorderprocessingContainer", "SalesOrderHeaders"));
+ } catch (ODataException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+ }
+
+ @Test
+ public void testGetAssociationSet() {
+ try {
+ assertNull(edmProvider.getAssociationSet("salesorderprocessingContainer", new FullQualifiedName(
+ "salesorderprocessing", "SalesOrderHeader_SalesOrderItem"), "SalesOrderHeaders", "SalesOrderHeader"));
+ } catch (ODataException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+
+ }
+
+ @Test
+ public void testNullGetFunctionImport() {
+
+ try {
+ assertNull(edmProvider.getFunctionImport("salesorderprocessingContainer", "SalesOrder_FunctionImport1"));
+ } catch (ODataException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+
+ }
+
+ @Test
+ public void testNullGetFunctionImport2() {
+
+ try {
+ ODataJPAEdmProvider provider = new ODataJPAEdmProvider();
+ try {
+ Class<? extends ODataJPAEdmProvider> clazz = provider.getClass();
+ Field field = clazz.getDeclaredField("schemas");
+ field.setAccessible(true);
+ List<Schema> schemas = new ArrayList<Schema>();
+ Schema schema = new Schema().setNamespace("salesorderprocessing");
+ EntityContainer container = new EntityContainer().setName("salesorderprocessingContainer");
+ List<EntityContainer> containerList = new ArrayList<EntityContainer>();
+ containerList.add(container); // Empty Container
+ schema.setEntityContainers(containerList);
+ schemas.add(schema); // Empty Schema
+ field.set(provider, schemas);
+ } catch (IllegalArgumentException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ } catch (IllegalAccessException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ } catch (NoSuchFieldException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ } catch (SecurityException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+
+ assertNull(provider.getFunctionImport("salesorderprocessingContainer", "SalesOrder_FunctionImport1"));
+ } catch (ODataException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+
+ }
+
+ @Test
+ public void testGetSchemas() {
+ try {
+ assertNotNull(edmProvider.getSchemas());
+ } catch (ODataException 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/1b479e6c/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/edm/ODataJPAEdmProviderTest.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/edm/ODataJPAEdmProviderTest.java b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/edm/ODataJPAEdmProviderTest.java
new file mode 100644
index 0000000..8dbd9da
--- /dev/null
+++ b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/edm/ODataJPAEdmProviderTest.java
@@ -0,0 +1,385 @@
+/*******************************************************************************
+ * 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.edm;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.lang.reflect.Field;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+
+import org.apache.olingo.odata2.api.edm.FullQualifiedName;
+import org.apache.olingo.odata2.api.edm.provider.Association;
+import org.apache.olingo.odata2.api.edm.provider.AssociationSet;
+import org.apache.olingo.odata2.api.edm.provider.ComplexType;
+import org.apache.olingo.odata2.api.edm.provider.EntityContainerInfo;
+import org.apache.olingo.odata2.api.edm.provider.Schema;
+import org.apache.olingo.odata2.api.exception.ODataException;
+import org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPAModelException;
+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.EdmSchemaMock;
+import org.apache.olingo.odata2.processor.core.jpa.model.JPAEdmModel;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class ODataJPAEdmProviderTest {
+
+ private static ODataJPAEdmProvider edmProvider;
+
+ @BeforeClass
+ public static void setup() {
+
+ edmProvider = new ODataJPAEdmProvider();
+ try {
+ Class<? extends ODataJPAEdmProvider> clazz = edmProvider.getClass();
+ Field field = clazz.getDeclaredField("schemas");
+ field.setAccessible(true);
+ List<Schema> schemas = new ArrayList<Schema>();
+ schemas.add(EdmSchemaMock.createMockEdmSchema());
+ field.set(edmProvider, schemas);
+ field = clazz.getDeclaredField("oDataJPAContext");
+ field.setAccessible(true);
+ field.set(edmProvider, ODataJPAContextMock.mockODataJPAContext());
+ field = clazz.getDeclaredField("jpaEdmModel");
+ field.setAccessible(true);
+ field.set(edmProvider, new JPAEdmModel(null, null));
+ } catch (IllegalArgumentException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ } catch (IllegalAccessException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ } catch (NoSuchFieldException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ } catch (SecurityException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+
+ }
+
+ @Test
+ public void testConstructor() {
+ try {
+ ODataJPAEdmProvider edmProv = new ODataJPAEdmProvider(ODataJPAContextMock.mockODataJPAContext());
+ edmProv.getClass();
+ } catch (Exception e) {
+ e.printStackTrace();
+ assertTrue(true);
+ }
+ }
+
+ @Test
+ public void testGetODataJPAContext() {
+ String pUnitName = edmProvider.getODataJPAContext().getPersistenceUnitName();
+ assertEquals("salesorderprocessing", pUnitName);
+ }
+
+ @Test
+ public void testGetEntityContainerInfo() {
+ String entityContainerName = null;
+ EntityContainerInfo entityContainer = null;
+ try {
+ entityContainer = edmProvider.getEntityContainerInfo("salesorderprocessingContainer");
+ entityContainerName = entityContainer.getName();
+ } catch (ODataException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+
+ assertEquals("salesorderprocessingContainer", entityContainerName);
+ assertNotNull(entityContainer);
+ }
+
+ @Test
+ public void testDefaultGetEntityContainerInfo() {
+ String entityContainerName = null;
+ EntityContainerInfo entityContainer = null;
+ try {
+ entityContainer = edmProvider.getEntityContainerInfo(null);
+ entityContainerName = entityContainer.getName();
+ } catch (ODataException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+
+ assertEquals("salesorderprocessingContainer", entityContainerName);
+ assertNotNull(entityContainer);
+ }
+
+ @Test
+ public void testGetEntityType() {
+ FullQualifiedName entityTypeName = new FullQualifiedName("salesorderprocessing", "SalesOrderHeader");
+ String entityName = null;
+ try {
+ entityName = edmProvider.getEntityType(entityTypeName).getName();
+ } catch (ODataException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+ assertEquals("SalesOrderHeader", entityName);
+ try {
+ edmProvider.getEntityType(new FullQualifiedName("salesorder", "abc"));
+ } catch (ODataException e) {
+ assertTrue(true);
+ }
+
+ }
+
+ @Test
+ public void testGetComplexType() {
+ FullQualifiedName complexTypeName = new FullQualifiedName("salesorderprocessing", "Address");
+ String nameStr = null;
+ try {
+ nameStr = edmProvider.getComplexType(complexTypeName).getName();
+ } catch (ODataException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+ assertEquals("Address", nameStr);
+ }
+
+ @Test
+ public void testGetAssociationFullQualifiedName() {
+ Association association = null;
+ try {
+ association =
+ edmProvider.getAssociation(new FullQualifiedName("salesorderprocessing", "SalesOrderHeader_SalesOrderItem"));
+ } catch (ODataException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+ assertNotNull(association);
+ assertEquals("SalesOrderHeader_SalesOrderItem", association.getName());
+ }
+
+ @Test
+ public void testGetEntitySet() {
+ String entitySetName = null;
+ try {
+ entitySetName = edmProvider.getEntitySet("salesorderprocessingContainer", "SalesOrderHeaders").getName();
+ } catch (ODataException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+ assertEquals("SalesOrderHeaders", entitySetName);
+ try {
+ assertNull(edmProvider.getEntitySet("salesorderprocessing", "SalesOrderHeaders"));
+ } catch (ODataException e) {
+ assertTrue(true);
+ }
+ }
+
+ @Test
+ public void testGetAssociationSet() {
+ AssociationSet associationSet = null;
+
+ try {
+ associationSet =
+ edmProvider.getAssociationSet("salesorderprocessingContainer", new FullQualifiedName("salesorderprocessing",
+ "SalesOrderHeader_SalesOrderItem"), "SalesOrderHeaders", "SalesOrderHeader");
+ } catch (ODataException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+ assertNotNull(associationSet);
+ assertEquals("SalesOrderHeader_SalesOrderItemSet", associationSet.getName());
+ try {
+ associationSet =
+ edmProvider.getAssociationSet("salesorderprocessingContainer", new FullQualifiedName("salesorderprocessing",
+ "SalesOrderHeader_SalesOrderItem"), "SalesOrderItems", "SalesOrderItem");
+ } catch (ODataException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+ assertNotNull(associationSet);
+ try {
+ associationSet =
+ edmProvider.getAssociationSet("salesorderproceContainer", new FullQualifiedName("salesorderprocessing",
+ "SalesOrderHeader_SalesOrderItem"), "SalesOrderItems", "SalesOrderItem");
+ } catch (ODataException e) {
+ assertTrue(true);
+ }
+ }
+
+ @Test
+ public void testGetFunctionImport() {
+ String functionImportName = null;
+ try {
+ functionImportName =
+ edmProvider.getFunctionImport("salesorderprocessingContainer", "SalesOrder_FunctionImport1").getName();
+ } catch (ODataException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+ assertEquals("SalesOrder_FunctionImport1", functionImportName);
+ try {
+ functionImportName =
+ edmProvider.getFunctionImport("salesorderprocessingContainer", "SalesOrder_FunctionImport1").getName();
+ } catch (ODataException e) {
+ assertTrue(true);
+ }
+ try {
+ assertNotNull(edmProvider.getFunctionImport("salesorderprocessingContainer", "SalesOrder_FunctionImport1"));
+ } catch (ODataException e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testGetSchemas() {
+ try {
+ assertNotNull(edmProvider.getSchemas());
+ } catch (ODataException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+ }
+
+ @Test
+ public void testgetComplexTypeWithBuffer() {
+ HashMap<String, ComplexType> compTypes = new HashMap<String, ComplexType>();
+ ComplexType comp = new ComplexType();
+ comp.setName("Address");
+ compTypes.put("salesorderprocessing" + "." + "Address", comp);
+ ODataJPAEdmProvider jpaEdmProv = new ODataJPAEdmProvider();
+ Class<?> claz = jpaEdmProv.getClass();
+ Field f;
+ try {
+ f = claz.getDeclaredField("complexTypes");
+ f.setAccessible(true);
+ f.set(jpaEdmProv, compTypes);
+ } catch (NoSuchFieldException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ } catch (SecurityException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ } catch (IllegalArgumentException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ } catch (IllegalAccessException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+
+ try {
+ assertEquals(comp, jpaEdmProv.getComplexType(new FullQualifiedName("salesorderprocessing", "Address")));
+ } catch (ODataException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+ try {
+ jpaEdmProv.getComplexType(new FullQualifiedName("salesorderessing", "abc"));
+ } catch (ODataJPAModelException e) {
+ assertTrue(true);
+ } catch (ODataException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+ }
+
+ @Test
+ public void testGetEntityContainerInfoWithBuffer() {
+ HashMap<String, EntityContainerInfo> entityContainerInfos = new HashMap<String, EntityContainerInfo>();
+ EntityContainerInfo entityContainer = new EntityContainerInfo();
+ entityContainer.setName("salesorderprocessingContainer");
+ entityContainerInfos.put("salesorderprocessingContainer", entityContainer);
+ ODataJPAEdmProvider jpaEdmProv = new ODataJPAEdmProvider();
+ Class<?> claz = jpaEdmProv.getClass();
+ try {
+ Field f = claz.getDeclaredField("entityContainerInfos");
+ f.setAccessible(true);
+ f.set(jpaEdmProv, entityContainerInfos);
+ assertEquals(entityContainer, jpaEdmProv.getEntityContainerInfo("salesorderprocessingContainer"));
+ jpaEdmProv.getEntityContainerInfo("abc");
+ } catch (ODataJPAModelException e) {
+ assertTrue(true);
+ } catch (NoSuchFieldException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ } catch (SecurityException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ } catch (IllegalArgumentException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ } catch (IllegalAccessException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ } catch (ODataException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+ }
+
+ @Test
+ public void testGetEntityTypeWithBuffer() {
+ HashMap<String, org.apache.olingo.odata2.api.edm.provider.EntityType> entityTypes =
+ new HashMap<String, org.apache.olingo.odata2.api.edm.provider.EntityType>();
+ org.apache.olingo.odata2.api.edm.provider.EntityType entity =
+ new org.apache.olingo.odata2.api.edm.provider.EntityType();
+ entity.setName("SalesOrderHeader");
+ entityTypes.put("salesorderprocessing" + "." + "SalesorderHeader", entity);
+ ODataJPAEdmProvider jpaEdmProv = new ODataJPAEdmProvider();
+ Class<?> claz = jpaEdmProv.getClass();
+ Field f;
+ try {
+ f = claz.getDeclaredField("entityTypes");
+ f.setAccessible(true);
+ f.set(jpaEdmProv, entityTypes);
+ assertEquals(entity, jpaEdmProv.getEntityType(new FullQualifiedName("salesorderprocessing", "SalesorderHeader")));
+ } catch (NoSuchFieldException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ } catch (SecurityException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ } catch (IllegalArgumentException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ } catch (IllegalAccessException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ } catch (ODataException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+ try {
+ jpaEdmProv.getEntityType(new FullQualifiedName("salesoprocessing", "abc"));
+ } catch (ODataJPAModelException e) {
+ assertTrue(true);
+ } catch (ODataException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+ }
+
+ @Test
+ public void testGetAssociationWithBuffer() {
+ HashMap<String, Association> associations = new HashMap<String, Association>();
+ Association association = new Association();
+ association.setName("SalesOrderHeader_SalesOrderItem");
+ associations.put("salesorderprocessing" + "." + "SalesOrderHeader_SalesOrderItem", association);
+ ODataJPAEdmProvider jpaEdmProv = new ODataJPAEdmProvider();
+ Class<?> claz = jpaEdmProv.getClass();
+ Field f;
+ try {
+ f = claz.getDeclaredField("associations");
+ f.setAccessible(true);
+ f.set(jpaEdmProv, associations);
+ assertEquals(association, jpaEdmProv.getAssociation(new FullQualifiedName("salesorderprocessing",
+ "SalesOrderHeader_SalesOrderItem")));
+ } catch (NoSuchFieldException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ } catch (SecurityException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ } catch (IllegalArgumentException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ } catch (IllegalAccessException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ } catch (ODataException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+ try {
+ jpaEdmProv.getAssociation(new FullQualifiedName("salesorderprocessing", "abc"));
+ } catch (ODataJPAModelException e) {
+ assertTrue(true);
+ } catch (ODataException 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/1b479e6c/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLBuilderFactoryTest.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLBuilderFactoryTest.java b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLBuilderFactoryTest.java
new file mode 100644
index 0000000..7da02d8
--- /dev/null
+++ b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLBuilderFactoryTest.java
@@ -0,0 +1,377 @@
+/*******************************************************************************
+ * 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.jpql;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.lang.reflect.Field;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+
+import javax.persistence.Cache;
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.PersistenceUnitUtil;
+import javax.persistence.criteria.CriteriaBuilder;
+import javax.persistence.metamodel.Metamodel;
+
+import org.apache.olingo.odata2.api.edm.EdmEntitySet;
+import org.apache.olingo.odata2.api.edm.EdmEntityType;
+import org.apache.olingo.odata2.api.edm.EdmException;
+import org.apache.olingo.odata2.api.edm.EdmMapping;
+import org.apache.olingo.odata2.api.edm.EdmProperty;
+import org.apache.olingo.odata2.api.edm.EdmSimpleType;
+import org.apache.olingo.odata2.api.exception.ODataException;
+import org.apache.olingo.odata2.api.uri.KeyPredicate;
+import org.apache.olingo.odata2.api.uri.NavigationSegment;
+import org.apache.olingo.odata2.api.uri.expression.OrderByExpression;
+import org.apache.olingo.odata2.api.uri.info.GetEntitySetUriInfo;
+import org.apache.olingo.odata2.api.uri.info.GetEntityUriInfo;
+import org.apache.olingo.odata2.processor.api.jpa.factory.JPAAccessFactory;
+import org.apache.olingo.odata2.processor.api.jpa.factory.ODataJPAAccessFactory;
+import org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLContext;
+import org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLContext.JPQLContextBuilder;
+import org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLContextType;
+import org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLStatement.JPQLStatementBuilder;
+import org.apache.olingo.odata2.processor.core.jpa.ODataJPAContextImpl;
+import org.apache.olingo.odata2.processor.core.jpa.access.data.JPAProcessorImplTest;
+import org.apache.olingo.odata2.processor.core.jpa.common.ODataJPATestConstants;
+import org.apache.olingo.odata2.processor.core.jpa.factory.ODataJPAFactoryImpl;
+import org.apache.olingo.odata2.processor.core.jpa.jpql.JPQLSelectContext.JPQLSelectContextBuilder;
+import org.apache.olingo.odata2.processor.core.jpa.jpql.JPQLSelectSingleContext.JPQLSelectSingleContextBuilder;
+import org.easymock.EasyMock;
+import org.junit.Test;
+
+public class JPQLBuilderFactoryTest {
+
+ @Test
+ public void testGetStatementBuilderFactoryforSelect() throws ODataException {
+
+ GetEntitySetUriInfo getEntitySetView = getUriInfo();
+
+ // Build JPQL Context
+ JPQLContext selectContext = JPQLContext.createBuilder(JPQLContextType.SELECT, getEntitySetView).build();
+ JPQLStatementBuilder statementBuilder =
+ new ODataJPAFactoryImpl().getJPQLBuilderFactory().getStatementBuilder(selectContext);
+
+ assertTrue(statementBuilder instanceof JPQLSelectStatementBuilder);
+
+ }
+
+ @Test
+ public void testGetStatementBuilderFactoryforSelectSingle() throws ODataException {
+
+ GetEntityUriInfo getEntityView = getEntityUriInfo();
+
+ // Build JPQL Context
+ JPQLContext selectContext = JPQLContext.createBuilder(JPQLContextType.SELECT_SINGLE, getEntityView).build();
+ JPQLStatementBuilder statementBuilder =
+ new ODataJPAFactoryImpl().getJPQLBuilderFactory().getStatementBuilder(selectContext);
+
+ assertTrue(statementBuilder instanceof JPQLSelectSingleStatementBuilder);
+
+ }
+
+ @Test
+ public void testGetStatementBuilderFactoryforJoinSelect() throws ODataException {
+
+ GetEntitySetUriInfo getEntitySetView = getUriInfo();
+
+ // Build JPQL Context
+ JPQLContext selectContext = JPQLContext.createBuilder(JPQLContextType.JOIN, getEntitySetView).build();
+ JPQLStatementBuilder statementBuilder =
+ new ODataJPAFactoryImpl().getJPQLBuilderFactory().getStatementBuilder(selectContext);
+
+ assertTrue(statementBuilder instanceof JPQLJoinStatementBuilder);
+
+ }
+
+ @Test
+ public void testGetStatementBuilderFactoryforJoinSelectSingle() throws ODataException {
+
+ GetEntityUriInfo getEntityView = getEntityUriInfo();
+
+ // Build JPQL Context
+ JPQLContext selectContext = JPQLContext.createBuilder(JPQLContextType.JOIN_SINGLE, getEntityView).build();
+ JPQLStatementBuilder statementBuilder =
+ new ODataJPAFactoryImpl().getJPQLBuilderFactory().getStatementBuilder(selectContext);
+
+ assertTrue(statementBuilder instanceof JPQLJoinSelectSingleStatementBuilder);
+
+ }
+
+ @Test
+ public void testGetContextBuilderforDelete() throws ODataException {
+
+ // Build JPQL ContextBuilder
+ JPQLContextBuilder contextBuilder =
+ new ODataJPAFactoryImpl().getJPQLBuilderFactory().getContextBuilder(JPQLContextType.DELETE);
+
+ assertNull(contextBuilder);
+
+ }
+
+ @Test
+ public void testGetContextBuilderforSelect() throws ODataException {
+
+ // Build JPQL ContextBuilder
+ JPQLContextBuilder contextBuilder =
+ new ODataJPAFactoryImpl().getJPQLBuilderFactory().getContextBuilder(JPQLContextType.SELECT);
+
+ assertNotNull(contextBuilder);
+ assertTrue(contextBuilder instanceof JPQLSelectContextBuilder);
+
+ }
+
+ @Test
+ public void testGetContextBuilderforSelectSingle() throws ODataException {
+
+ // Build JPQL ContextBuilder
+ JPQLContextBuilder contextBuilder =
+ new ODataJPAFactoryImpl().getJPQLBuilderFactory().getContextBuilder(JPQLContextType.SELECT_SINGLE);
+
+ assertNotNull(contextBuilder);
+ assertTrue(contextBuilder instanceof JPQLSelectSingleContextBuilder);
+
+ }
+
+ private GetEntitySetUriInfo getUriInfo() throws EdmException {
+ GetEntitySetUriInfo getEntitySetView = EasyMock.createMock(GetEntitySetUriInfo.class);
+ EdmEntitySet edmEntitySet = EasyMock.createMock(EdmEntitySet.class);
+ EdmEntityType edmEntityType = EasyMock.createMock(EdmEntityType.class);
+ EasyMock.expect(edmEntityType.getMapping()).andStubReturn(null);
+ EasyMock.expect(edmEntityType.getName()).andStubReturn("SOItem");
+ EasyMock.replay(edmEntityType);
+ OrderByExpression orderByExpression = EasyMock.createMock(OrderByExpression.class);
+ EasyMock.expect(getEntitySetView.getTargetEntitySet()).andStubReturn(edmEntitySet);
+ EdmEntitySet startEdmEntitySet = EasyMock.createMock(EdmEntitySet.class);
+ EdmEntityType startEdmEntityType = EasyMock.createMock(EdmEntityType.class);
+ EasyMock.expect(startEdmEntityType.getMapping()).andStubReturn(null);
+ EasyMock.expect(startEdmEntityType.getName()).andStubReturn("SOHeader");
+ EasyMock.expect(startEdmEntitySet.getEntityType()).andStubReturn(startEdmEntityType);
+ EasyMock.expect(getEntitySetView.getStartEntitySet()).andStubReturn(startEdmEntitySet);
+ EasyMock.replay(startEdmEntityType, startEdmEntitySet);
+ EasyMock.expect(getEntitySetView.getOrderBy()).andStubReturn(orderByExpression);
+ EasyMock.expect(getEntitySetView.getSelect()).andStubReturn(null);
+ EasyMock.expect(getEntitySetView.getFilter()).andStubReturn(null);
+ List<NavigationSegment> navigationSegments = new ArrayList<NavigationSegment>();
+ EasyMock.expect(getEntitySetView.getNavigationSegments()).andStubReturn(navigationSegments);
+ KeyPredicate keyPredicate = EasyMock.createMock(KeyPredicate.class);
+ EdmProperty kpProperty = EasyMock.createMock(EdmProperty.class);
+ EdmSimpleType edmType = EasyMock.createMock(EdmSimpleType.class);
+ EdmMapping edmMapping = EasyMock.createMock(EdmMapping.class);
+ EasyMock.expect(edmMapping.getInternalName()).andStubReturn("Field1");
+ EasyMock.expect(keyPredicate.getLiteral()).andStubReturn("1");
+ try {
+ EasyMock.expect(kpProperty.getName()).andStubReturn("Field1");
+ EasyMock.expect(kpProperty.getType()).andStubReturn(edmType);
+
+ EasyMock.expect(kpProperty.getMapping()).andStubReturn(edmMapping);
+
+ } catch (EdmException e2) {
+ fail("this should not happen");
+ }
+ EasyMock.expect(keyPredicate.getProperty()).andStubReturn(kpProperty);
+ EasyMock.replay(edmMapping, edmType, kpProperty, keyPredicate);
+ List<KeyPredicate> keyPredicates = new ArrayList<KeyPredicate>();
+ keyPredicates.add(keyPredicate);
+ EasyMock.expect(getEntitySetView.getKeyPredicates()).andStubReturn(keyPredicates);
+ EasyMock.replay(getEntitySetView);
+ EasyMock.expect(edmEntitySet.getEntityType()).andStubReturn(edmEntityType);
+ EasyMock.replay(edmEntitySet);
+ return getEntitySetView;
+ }
+
+ private GetEntityUriInfo getEntityUriInfo() throws EdmException {
+ GetEntityUriInfo getEntityView = EasyMock.createMock(GetEntityUriInfo.class);
+ EdmEntitySet edmEntitySet = EasyMock.createMock(EdmEntitySet.class);
+ EdmEntityType edmEntityType = EasyMock.createMock(EdmEntityType.class);
+ EasyMock.expect(edmEntityType.getKeyProperties()).andStubReturn(new ArrayList<EdmProperty>());
+ EasyMock.expect(edmEntityType.getMapping()).andStubReturn(null);
+ EasyMock.expect(edmEntityType.getName()).andStubReturn("");
+ EasyMock.expect(edmEntitySet.getEntityType()).andStubReturn(edmEntityType);
+ EasyMock.expect(getEntityView.getSelect()).andStubReturn(null);
+ EasyMock.expect(getEntityView.getTargetEntitySet()).andStubReturn(edmEntitySet);
+ EdmEntitySet startEdmEntitySet = EasyMock.createMock(EdmEntitySet.class);
+ EdmEntityType startEdmEntityType = EasyMock.createMock(EdmEntityType.class);
+ EasyMock.expect(startEdmEntityType.getMapping()).andStubReturn(null);
+ EasyMock.expect(startEdmEntityType.getName()).andStubReturn("SOHeader");
+ EasyMock.expect(startEdmEntitySet.getEntityType()).andStubReturn(startEdmEntityType);
+ EasyMock.expect(getEntityView.getStartEntitySet()).andStubReturn(startEdmEntitySet);
+ EasyMock.replay(startEdmEntityType, startEdmEntitySet);
+ EasyMock.replay(edmEntityType, edmEntitySet);
+ EasyMock.expect(getEntityView.getKeyPredicates()).andStubReturn(new ArrayList<KeyPredicate>());
+ List<NavigationSegment> navigationSegments = new ArrayList<NavigationSegment>();
+ EasyMock.expect(getEntityView.getNavigationSegments()).andStubReturn(navigationSegments);
+ EasyMock.replay(getEntityView);
+ return getEntityView;
+ }
+
+ @Test
+ public void testJPAAccessFactory() {
+ ODataJPAFactoryImpl oDataJPAFactoryImpl = new ODataJPAFactoryImpl();
+ JPAAccessFactory jpaAccessFactory = oDataJPAFactoryImpl.getJPAAccessFactory();
+ ODataJPAContextImpl oDataJPAContextImpl = new ODataJPAContextImpl();
+ Class<?> clazz = oDataJPAContextImpl.getClass();
+ try {
+ Field field = clazz.getDeclaredField("em");
+ field.setAccessible(true);
+ field.set(oDataJPAContextImpl, new JPAProcessorImplTest().getLocalEntityManager());
+ } catch (SecurityException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ } catch (NoSuchFieldException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ } catch (IllegalArgumentException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ } catch (IllegalAccessException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+ EntityManagerFactory emf = new EntityManagerFactory() {
+
+ @Override
+ public boolean isOpen() {
+ return false;
+ }
+
+ @Override
+ public Map<String, Object> getProperties() {
+ return null;
+ }
+
+ @Override
+ public PersistenceUnitUtil getPersistenceUnitUtil() {
+ return null;
+ }
+
+ @Override
+ public Metamodel getMetamodel() {
+ return null;
+ }
+
+ @Override
+ public CriteriaBuilder getCriteriaBuilder() {
+ return null;
+ }
+
+ @Override
+ public Cache getCache() {
+ return null;
+ }
+
+ @SuppressWarnings("rawtypes")
+ @Override
+ public EntityManager createEntityManager(final Map arg0) {
+ return null;
+ }
+
+ @Override
+ public EntityManager createEntityManager() {
+ return null;
+ }
+
+ @Override
+ public void close() {}
+ };
+ oDataJPAContextImpl.setEntityManagerFactory(emf);
+ oDataJPAContextImpl.setPersistenceUnitName("pUnit");
+
+ assertNotNull(jpaAccessFactory.getJPAProcessor(oDataJPAContextImpl));
+ assertNotNull(jpaAccessFactory.getJPAEdmModelView(oDataJPAContextImpl));
+
+ }
+
+ @Test
+ public void testOdataJpaAccessFactory() {
+
+ ODataJPAFactoryImpl oDataJPAFactoryImpl = new ODataJPAFactoryImpl();
+ ODataJPAAccessFactory jpaAccessFactory = oDataJPAFactoryImpl.getODataJPAAccessFactory();
+ ODataJPAContextImpl oDataJPAContextImpl = new ODataJPAContextImpl();
+
+ EntityManagerFactory emf = new EntityManagerFactory() {
+
+ @Override
+ public boolean isOpen() {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public Map<String, Object> getProperties() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public PersistenceUnitUtil getPersistenceUnitUtil() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Metamodel getMetamodel() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public CriteriaBuilder getCriteriaBuilder() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Cache getCache() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @SuppressWarnings("rawtypes")
+ @Override
+ public EntityManager createEntityManager(final Map arg0) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public EntityManager createEntityManager() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public void close() {
+ // TODO Auto-generated method stub
+
+ }
+ };
+ oDataJPAContextImpl.setEntityManagerFactory(emf);
+ oDataJPAContextImpl.setPersistenceUnitName("pUnit");
+
+ assertNotNull(jpaAccessFactory.getODataJPAMessageService(new Locale("en")));
+ assertNotNull(jpaAccessFactory.createODataJPAContext());
+ assertNotNull(jpaAccessFactory.createJPAEdmProvider(oDataJPAContextImpl));
+ assertNotNull(jpaAccessFactory.createODataProcessor(oDataJPAContextImpl));
+
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLJoinContextTest.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLJoinContextTest.java b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLJoinContextTest.java
new file mode 100644
index 0000000..509591f
--- /dev/null
+++ b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLJoinContextTest.java
@@ -0,0 +1,198 @@
+/*******************************************************************************
+ * 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.jpql;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.olingo.odata2.api.edm.EdmAssociation;
+import org.apache.olingo.odata2.api.edm.EdmAssociationEnd;
+import org.apache.olingo.odata2.api.edm.EdmEntitySet;
+import org.apache.olingo.odata2.api.edm.EdmEntityType;
+import org.apache.olingo.odata2.api.edm.EdmException;
+import org.apache.olingo.odata2.api.edm.EdmMapping;
+import org.apache.olingo.odata2.api.edm.EdmMultiplicity;
+import org.apache.olingo.odata2.api.edm.EdmNavigationProperty;
+import org.apache.olingo.odata2.api.edm.EdmProperty;
+import org.apache.olingo.odata2.api.edm.EdmSimpleType;
+import org.apache.olingo.odata2.api.uri.KeyPredicate;
+import org.apache.olingo.odata2.api.uri.NavigationSegment;
+import org.apache.olingo.odata2.api.uri.info.GetEntitySetUriInfo;
+import org.apache.olingo.odata2.processor.api.jpa.access.JPAJoinClause;
+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.core.jpa.jpql.JPQLJoinSelectContext.JPQLJoinContextBuilder;
+import org.easymock.EasyMock;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class JPQLJoinContextTest {
+
+ GetEntitySetUriInfo entitySetUriInfo;
+
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {}
+
+ @AfterClass
+ public static void tearDownAfterClass() throws Exception {}
+
+ @Before
+ public void setUp() throws Exception {
+ entitySetUriInfo = EasyMock.createMock(GetEntitySetUriInfo.class);
+ EdmEntitySet edmEntitySet = EasyMock.createMock(EdmEntitySet.class);
+ EdmEntityType edmEntityType = EasyMock.createMock(EdmEntityType.class);
+ List<NavigationSegment> navigationSegments = new ArrayList<NavigationSegment>();
+ final EdmNavigationProperty navigationProperty = createNavigationProperty("a");
+ final EdmNavigationProperty navigationProperty1 = createNavigationProperty("b");
+ final List<KeyPredicate> keyPredicates = createKeyPredicates();
+ NavigationSegment navigationSegment = new NavigationSegment() {
+
+ @Override
+ public EdmNavigationProperty getNavigationProperty() {
+ return navigationProperty;
+ }
+
+ @Override
+ public List<KeyPredicate> getKeyPredicates() {
+ return keyPredicates;
+ }
+
+ @Override
+ public EdmEntitySet getEntitySet() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+ };
+ NavigationSegment navigationSegment1 = new NavigationSegment() {
+
+ @Override
+ public EdmNavigationProperty getNavigationProperty() {
+ return navigationProperty1;
+ }
+
+ @Override
+ public List<KeyPredicate> getKeyPredicates() {
+ return keyPredicates;
+ }
+
+ @Override
+ public EdmEntitySet getEntitySet() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+ };
+ navigationSegments.add(navigationSegment);
+ navigationSegments.add(navigationSegment1);
+ EasyMock.expect(entitySetUriInfo.getNavigationSegments()).andStubReturn(navigationSegments);
+ EasyMock.expect(entitySetUriInfo.getOrderBy()).andStubReturn(null);
+ EasyMock.expect(entitySetUriInfo.getTop()).andStubReturn(null);
+ EasyMock.expect(entitySetUriInfo.getSkip()).andStubReturn(null);
+ EasyMock.expect(entitySetUriInfo.getSelect()).andStubReturn(null);
+ EasyMock.expect(entitySetUriInfo.getFilter()).andStubReturn(null);
+ EasyMock.expect(entitySetUriInfo.getKeyPredicates()).andStubReturn(keyPredicates);
+ EasyMock.expect(entitySetUriInfo.getTargetEntitySet()).andStubReturn(edmEntitySet);
+ EdmEntitySet startEdmEntitySet = EasyMock.createMock(EdmEntitySet.class);
+ EdmEntityType startEdmEntityType = EasyMock.createMock(EdmEntityType.class);
+ EasyMock.expect(startEdmEntityType.getMapping()).andStubReturn(null);
+ EasyMock.expect(startEdmEntityType.getName()).andStubReturn("SOHeader");
+ EasyMock.expect(startEdmEntitySet.getEntityType()).andStubReturn(startEdmEntityType);
+ EasyMock.expect(entitySetUriInfo.getStartEntitySet()).andStubReturn(startEdmEntitySet);
+ EasyMock.replay(startEdmEntityType, startEdmEntitySet);
+ EasyMock.expect(edmEntitySet.getEntityType()).andStubReturn(edmEntityType);
+ EasyMock.expect(edmEntityType.getMapping()).andStubReturn(null);
+ EasyMock.expect(edmEntityType.getName()).andStubReturn("SOHeader");
+ EasyMock.replay(edmEntityType, edmEntitySet, entitySetUriInfo);
+
+ }
+
+ @After
+ public void tearDown() throws Exception {}
+
+ @Test
+ public void testGetJPAOuterJoinClauses() {
+ JPQLJoinSelectContext joinContext = new JPQLJoinSelectContext(false);
+ JPQLJoinContextBuilder joinContextBuilder = joinContext.new JPQLJoinContextBuilder();
+ try {
+ joinContextBuilder.entitySetView = entitySetUriInfo;
+ joinContextBuilder.build();
+ } catch (ODataJPAModelException e) {
+ fail("Should not come here");
+ } catch (ODataJPARuntimeException e) {
+ fail("Should not come here");
+ }
+ List<JPAJoinClause> joinClauses = joinContext.getJPAJoinClauses();
+ assertNotNull(joinClauses);
+ assertTrue(joinClauses.size() > 0);
+ assertEquals("E1", joinClauses.get(0).getEntityAlias());
+ assertEquals("SOHeader", joinClauses.get(0).getEntityName());
+ assertEquals("s_Itema", joinClauses.get(1).getEntityRelationShip());
+ assertEquals("R1", joinClauses.get(1).getEntityRelationShipAlias());
+ }
+
+ private EdmNavigationProperty createNavigationProperty(final String z) throws EdmException {
+ EdmNavigationProperty navigationProperty = EasyMock.createMock(EdmNavigationProperty.class);
+ EdmAssociation association = EasyMock.createMock(EdmAssociation.class);
+ EdmAssociationEnd associationEnd = EasyMock.createMock(EdmAssociationEnd.class);
+ EasyMock.expect(navigationProperty.getFromRole()).andStubReturn("roleA" + z);
+ EasyMock.expect(navigationProperty.getToRole()).andStubReturn("roleB" + z);
+ EasyMock.expect(navigationProperty.getName()).andStubReturn("navP" + z);
+ EasyMock.expect(navigationProperty.getName()).andStubReturn("navP" + z);
+ EasyMock.expect(navigationProperty.getMultiplicity()).andStubReturn(EdmMultiplicity.ONE);
+ EdmEntityType edmEntityType = EasyMock.createMock(EdmEntityType.class);
+ EdmMapping edmMapping = EasyMock.createMock(EdmMapping.class);
+ EasyMock.expect(edmMapping.getInternalName()).andStubReturn("sItem" + z);
+ EasyMock.expect(edmEntityType.getMapping()).andStubReturn(edmMapping);
+ EasyMock.expect(edmEntityType.getName()).andStubReturn("soItem" + z);
+ EasyMock.expect(associationEnd.getEntityType()).andStubReturn(edmEntityType);
+ EasyMock.expect(association.getEnd("roleA" + z)).andStubReturn(associationEnd);
+ EasyMock.expect(navigationProperty.getRelationship()).andStubReturn(association);
+ EdmMapping edmMapping1 = EasyMock.createMock(EdmMapping.class);
+ EasyMock.expect(edmMapping1.getInternalName()).andStubReturn("s_Item" + z);
+ EasyMock.expect(navigationProperty.getMapping()).andStubReturn(edmMapping1);
+ EasyMock.replay(edmMapping, edmMapping1, edmEntityType, associationEnd, association, navigationProperty);
+ return navigationProperty;
+ }
+
+ private List<KeyPredicate> createKeyPredicates() throws EdmException {
+ KeyPredicate keyPredicate = EasyMock.createMock(KeyPredicate.class);
+ EasyMock.expect(keyPredicate.getLiteral()).andStubReturn("1");
+ EdmProperty edmProperty = EasyMock.createMock(EdmProperty.class);
+ EdmMapping edmMapping = EasyMock.createMock(EdmMapping.class);
+ EasyMock.expect(edmMapping.getInternalName()).andStubReturn("soid");
+ EasyMock.expect(edmProperty.getMapping()).andStubReturn(edmMapping);
+ EasyMock.expect(edmProperty.getName()).andStubReturn("soid");
+ EdmSimpleType edmType = EasyMock.createMock(EdmSimpleType.class);
+ EasyMock.expect(edmProperty.getType()).andStubReturn(edmType);
+ EasyMock.expect(keyPredicate.getProperty()).andStubReturn(edmProperty);
+
+ EasyMock.replay(edmType, edmMapping, edmProperty, keyPredicate);
+ List<KeyPredicate> keyPredicates = new ArrayList<KeyPredicate>();
+ keyPredicates.add(keyPredicate);
+ return keyPredicates;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLJoinSelectSingleContextTest.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLJoinSelectSingleContextTest.java b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLJoinSelectSingleContextTest.java
new file mode 100644
index 0000000..b7c9c7d
--- /dev/null
+++ b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLJoinSelectSingleContextTest.java
@@ -0,0 +1,215 @@
+/*******************************************************************************
+ * 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.jpql;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.olingo.odata2.api.edm.EdmAssociation;
+import org.apache.olingo.odata2.api.edm.EdmAssociationEnd;
+import org.apache.olingo.odata2.api.edm.EdmEntitySet;
+import org.apache.olingo.odata2.api.edm.EdmEntityType;
+import org.apache.olingo.odata2.api.edm.EdmException;
+import org.apache.olingo.odata2.api.edm.EdmMapping;
+import org.apache.olingo.odata2.api.edm.EdmMultiplicity;
+import org.apache.olingo.odata2.api.edm.EdmNavigationProperty;
+import org.apache.olingo.odata2.api.edm.EdmProperty;
+import org.apache.olingo.odata2.api.edm.EdmSimpleType;
+import org.apache.olingo.odata2.api.uri.KeyPredicate;
+import org.apache.olingo.odata2.api.uri.NavigationSegment;
+import org.apache.olingo.odata2.api.uri.info.GetEntityUriInfo;
+import org.apache.olingo.odata2.processor.api.jpa.access.JPAJoinClause;
+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.core.jpa.jpql.JPQLJoinSelectSingleContext.JPQLJoinSelectSingleContextBuilder;
+import org.easymock.EasyMock;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class JPQLJoinSelectSingleContextTest {
+
+ GetEntityUriInfo entityUriInfo;
+
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {}
+
+ @AfterClass
+ public static void tearDownAfterClass() throws Exception {}
+
+ public void setUp(final boolean toThrowException) throws Exception {
+ entityUriInfo = EasyMock.createMock(GetEntityUriInfo.class);
+ EdmEntitySet edmEntitySet = EasyMock.createMock(EdmEntitySet.class);
+ EdmEntityType edmEntityType = EasyMock.createMock(EdmEntityType.class);
+ List<NavigationSegment> navigationSegments = new ArrayList<NavigationSegment>();
+ final EdmNavigationProperty navigationProperty = createNavigationProperty("a");
+ final EdmNavigationProperty navigationProperty1 = createNavigationProperty("b");
+ final List<KeyPredicate> keyPredicates = createKeyPredicates(toThrowException);
+ NavigationSegment navigationSegment = new NavigationSegment() {
+
+ @Override
+ public EdmNavigationProperty getNavigationProperty() {
+ return navigationProperty;
+ }
+
+ @Override
+ public List<KeyPredicate> getKeyPredicates() {
+ return keyPredicates;
+ }
+
+ @Override
+ public EdmEntitySet getEntitySet() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+ };
+ NavigationSegment navigationSegment1 = new NavigationSegment() {
+
+ @Override
+ public EdmNavigationProperty getNavigationProperty() {
+ return navigationProperty1;
+ }
+
+ @Override
+ public List<KeyPredicate> getKeyPredicates() {
+ return keyPredicates;
+ }
+
+ @Override
+ public EdmEntitySet getEntitySet() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+ };
+ navigationSegments.add(navigationSegment);
+ navigationSegments.add(navigationSegment1);
+ EasyMock.expect(entityUriInfo.getNavigationSegments()).andStubReturn(navigationSegments);
+ EasyMock.expect(entityUriInfo.getSelect()).andStubReturn(null);
+ EasyMock.expect(entityUriInfo.getFilter()).andStubReturn(null);
+ EasyMock.expect(entityUriInfo.getKeyPredicates()).andStubReturn(createKeyPredicates(toThrowException));
+ EasyMock.expect(entityUriInfo.getTargetEntitySet()).andStubReturn(edmEntitySet);
+ EdmEntitySet startEdmEntitySet = EasyMock.createMock(EdmEntitySet.class);
+ EdmEntityType startEdmEntityType = EasyMock.createMock(EdmEntityType.class);
+ EasyMock.expect(startEdmEntityType.getMapping()).andStubReturn(null);
+ EasyMock.expect(startEdmEntityType.getName()).andStubReturn("SOHeader");
+ EasyMock.expect(startEdmEntitySet.getEntityType()).andStubReturn(startEdmEntityType);
+ EasyMock.expect(entityUriInfo.getStartEntitySet()).andStubReturn(startEdmEntitySet);
+ EasyMock.replay(startEdmEntityType, startEdmEntitySet);
+ EasyMock.expect(edmEntitySet.getEntityType()).andStubReturn(edmEntityType);
+ EasyMock.expect(edmEntityType.getMapping()).andStubReturn(null);
+ EasyMock.expect(edmEntityType.getName()).andStubReturn("SOHeader");
+ EasyMock.replay(edmEntityType, edmEntitySet, entityUriInfo);
+
+ }
+
+ @After
+ public void tearDown() throws Exception {}
+
+ @Test
+ public void testGetJPAOuterJoinClauses() throws Exception {
+ setUp(false);
+
+ JPQLJoinSelectSingleContext joinContext = new JPQLJoinSelectSingleContext();
+ JPQLJoinSelectSingleContextBuilder joinContextBuilder = joinContext.new JPQLJoinSelectSingleContextBuilder();
+ try {
+ joinContextBuilder.entityView = entityUriInfo;
+ joinContextBuilder.build();
+ } catch (ODataJPAModelException e) {
+ fail("Should not come here");
+ } catch (ODataJPARuntimeException e) {
+ fail("Should not come here");
+ }
+ List<JPAJoinClause> joinClauses = joinContext.getJPAJoinClauses();
+ assertNotNull(joinClauses);
+ assertTrue(joinClauses.size() > 0);
+ assertEquals("E1", joinClauses.get(0).getEntityAlias());
+ assertEquals("SOHeader", joinClauses.get(0).getEntityName());
+ assertEquals("s_Itema", joinClauses.get(1).getEntityRelationShip());
+ assertEquals("R1", joinClauses.get(1).getEntityRelationShipAlias());
+ }
+
+ @Test
+ public void testExceptionThrown() throws Exception {
+ setUp(true);
+ JPQLJoinSelectSingleContext joinContext = new JPQLJoinSelectSingleContext();
+ JPQLJoinSelectSingleContextBuilder joinContextBuilder = joinContext.new JPQLJoinSelectSingleContextBuilder();
+ try {
+ joinContextBuilder.entityView = entityUriInfo;
+ joinContextBuilder.build();
+ fail("Should not come here");
+ } catch (ODataJPAModelException e) {
+ fail("Should not come here");
+ } catch (ODataJPARuntimeException e) {
+ assertTrue(true);
+ }
+ }
+
+ private EdmNavigationProperty createNavigationProperty(final String z) throws EdmException {
+ EdmNavigationProperty navigationProperty = EasyMock.createMock(EdmNavigationProperty.class);
+ EdmAssociation association = EasyMock.createMock(EdmAssociation.class);
+ EdmAssociationEnd associationEnd = EasyMock.createMock(EdmAssociationEnd.class);
+ EasyMock.expect(navigationProperty.getFromRole()).andStubReturn("roleA" + z);
+ EasyMock.expect(navigationProperty.getToRole()).andStubReturn("roleB" + z);
+ EasyMock.expect(navigationProperty.getName()).andStubReturn("navP" + z);
+ EasyMock.expect(navigationProperty.getName()).andStubReturn("navP" + z);
+ EasyMock.expect(navigationProperty.getMultiplicity()).andStubReturn(EdmMultiplicity.ONE);
+ EdmEntityType edmEntityType = EasyMock.createMock(EdmEntityType.class);
+ EdmMapping edmMapping = EasyMock.createMock(EdmMapping.class);
+ EasyMock.expect(edmMapping.getInternalName()).andStubReturn("sItem" + z);
+ EasyMock.expect(edmEntityType.getMapping()).andStubReturn(edmMapping);
+ EasyMock.expect(edmEntityType.getName()).andStubReturn("soItem" + z);
+ EasyMock.expect(associationEnd.getEntityType()).andStubReturn(edmEntityType);
+ EasyMock.expect(association.getEnd("roleA" + z)).andStubReturn(associationEnd);
+ EasyMock.expect(navigationProperty.getRelationship()).andStubReturn(association);
+ EdmMapping edmMapping1 = EasyMock.createMock(EdmMapping.class);
+ EasyMock.expect(edmMapping1.getInternalName()).andStubReturn("s_Item" + z);
+ EasyMock.expect(navigationProperty.getMapping()).andStubReturn(edmMapping1);
+ EasyMock.replay(edmMapping, edmMapping1, edmEntityType, associationEnd, association, navigationProperty);
+ return navigationProperty;
+ }
+
+ private List<KeyPredicate> createKeyPredicates(final boolean toThrowException) throws EdmException {
+ KeyPredicate keyPredicate = EasyMock.createMock(KeyPredicate.class);
+ EasyMock.expect(keyPredicate.getLiteral()).andStubReturn("1");
+ EdmProperty edmProperty = EasyMock.createMock(EdmProperty.class);
+ EdmMapping edmMapping = EasyMock.createMock(EdmMapping.class);
+ EasyMock.expect(edmMapping.getInternalName()).andStubReturn("soid");
+ EasyMock.expect(edmProperty.getMapping()).andStubReturn(edmMapping);
+ EasyMock.expect(edmProperty.getName()).andStubReturn("soid");
+ EdmSimpleType edmType = EasyMock.createMock(EdmSimpleType.class);
+ if (toThrowException) {
+ EasyMock.expect(edmProperty.getType()).andStubThrow(new EdmException(null));
+ } else {
+ EasyMock.expect(edmProperty.getType()).andStubReturn(edmType);
+ }
+ EasyMock.expect(keyPredicate.getProperty()).andStubReturn(edmProperty);
+
+ EasyMock.replay(edmType, edmMapping, edmProperty, keyPredicate);
+ List<KeyPredicate> keyPredicates = new ArrayList<KeyPredicate>();
+ keyPredicates.add(keyPredicate);
+ return keyPredicates;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLJoinSelectSingleStatementBuilderTest.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLJoinSelectSingleStatementBuilderTest.java b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLJoinSelectSingleStatementBuilderTest.java
new file mode 100644
index 0000000..c7df74b
--- /dev/null
+++ b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLJoinSelectSingleStatementBuilderTest.java
@@ -0,0 +1,142 @@
+/*******************************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ ******************************************************************************/
+package org.apache.olingo.odata2.processor.core.jpa.jpql;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.olingo.odata2.api.edm.EdmException;
+import org.apache.olingo.odata2.api.edm.EdmMapping;
+import org.apache.olingo.odata2.api.edm.EdmProperty;
+import org.apache.olingo.odata2.api.edm.EdmSimpleType;
+import org.apache.olingo.odata2.api.uri.KeyPredicate;
+import org.apache.olingo.odata2.processor.api.jpa.access.JPAJoinClause;
+import org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPARuntimeException;
+import org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLContextType;
+import org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLJoinSelectSingleContextView;
+import org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLStatement;
+import org.easymock.EasyMock;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class JPQLJoinSelectSingleStatementBuilderTest {
+ JPQLJoinSelectSingleContextView context = null;
+
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {}
+
+ @AfterClass
+ public static void tearDownAfterClass() throws Exception {}
+
+ public void setUp(final List<JPAJoinClause> joinClauseList) throws Exception {
+ context = EasyMock.createMock(JPQLJoinSelectSingleContextView.class);
+ EasyMock.expect(context.getJPAEntityAlias()).andStubReturn("gt1");
+ EasyMock.expect(context.getJPAEntityName()).andStubReturn("SOHeader");
+ EasyMock.expect(context.getType()).andStubReturn(JPQLContextType.SELECT);
+ EasyMock.expect(context.getKeyPredicates()).andStubReturn(createKeyPredicates());
+ EasyMock.expect(context.getSelectExpression()).andStubReturn("gt1");
+ EasyMock.expect(context.getJPAJoinClauses()).andStubReturn(joinClauseList);
+ EasyMock.replay(context);
+ }
+
+ private List<JPAJoinClause> getJoinClauseList() {
+ List<JPAJoinClause> joinClauseList = new ArrayList<JPAJoinClause>();
+ JPAJoinClause jpaOuterJoinClause =
+ new JPAJoinClause("SOHeader", "soh", null, null, "soh.soId = 1", JPAJoinClause.JOIN.LEFT);
+ joinClauseList.add(jpaOuterJoinClause);
+ jpaOuterJoinClause =
+ new JPAJoinClause("SOHeader", "soh", "soItem", "soi", "soi.shId = soh.soId", JPAJoinClause.JOIN.LEFT);
+ joinClauseList.add(jpaOuterJoinClause);
+ jpaOuterJoinClause =
+ new JPAJoinClause("SOItem", "si", "material", "mat", "mat.id = 'abc'", JPAJoinClause.JOIN.LEFT);
+ joinClauseList.add(jpaOuterJoinClause);
+ return joinClauseList;
+ }
+
+ @After
+ public void tearDown() throws Exception {}
+
+ @Test
+ public void testBuild() throws Exception {
+ setUp(getJoinClauseList());
+ JPQLJoinSelectSingleStatementBuilder jpqlJoinSelectsingleStatementBuilder =
+ new JPQLJoinSelectSingleStatementBuilder(context);
+ try {
+ JPQLStatement jpqlStatement = jpqlJoinSelectsingleStatementBuilder.build();
+ assertEquals(
+ "SELECT gt1 FROM SOHeader soh JOIN soh.soItem soi JOIN soi.material mat WHERE soh.soId = 1 AND " +
+ "soi.shId = soh.soId AND mat.id = 'abc'",
+ jpqlStatement.toString());
+ } catch (ODataJPARuntimeException e) {
+ fail("Should not have come here");
+ }
+
+ }
+
+ private List<KeyPredicate> createKeyPredicates() throws EdmException {
+ KeyPredicate keyPredicate = EasyMock.createMock(KeyPredicate.class);
+ EasyMock.expect(keyPredicate.getLiteral()).andStubReturn("1");
+ EdmProperty edmProperty = EasyMock.createMock(EdmProperty.class);
+ EdmMapping edmMapping = EasyMock.createMock(EdmMapping.class);
+ EasyMock.expect(edmMapping.getInternalName()).andStubReturn("soid");
+ EasyMock.expect(edmProperty.getMapping()).andStubReturn(edmMapping);
+ EdmSimpleType edmType = EasyMock.createMock(EdmSimpleType.class);
+ EasyMock.expect(edmProperty.getType()).andStubReturn(edmType);
+ EasyMock.expect(keyPredicate.getProperty()).andStubReturn(edmProperty);
+
+ EasyMock.replay(edmType, edmMapping, edmProperty, keyPredicate);
+ List<KeyPredicate> keyPredicates = new ArrayList<KeyPredicate>();
+ keyPredicates.add(keyPredicate);
+ return keyPredicates;
+ }
+
+ @Test
+ public void testJoinClauseAsNull() throws Exception {
+ setUp(null);
+ JPQLJoinSelectSingleStatementBuilder jpqlJoinSelectsingleStatementBuilder =
+ new JPQLJoinSelectSingleStatementBuilder(context);
+ try {
+ jpqlJoinSelectsingleStatementBuilder.build();
+ fail("Should not have come here");
+ } catch (ODataJPARuntimeException e) {
+ assertTrue(true);
+ }
+ }
+
+ @Test
+ public void testJoinClauseListAsEmpty() throws Exception {
+ List<JPAJoinClause> joinClauseList = new ArrayList<JPAJoinClause>();
+ setUp(joinClauseList);
+ JPQLJoinSelectSingleStatementBuilder jpqlJoinSelectsingleStatementBuilder =
+ new JPQLJoinSelectSingleStatementBuilder(context);
+ try {
+ jpqlJoinSelectsingleStatementBuilder.build();
+ fail("Should not have come here");
+ } catch (ODataJPARuntimeException e) {
+ assertTrue(true);
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLJoinStatementBuilderTest.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLJoinStatementBuilderTest.java b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLJoinStatementBuilderTest.java
new file mode 100644
index 0000000..dad45e3
--- /dev/null
+++ b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLJoinStatementBuilderTest.java
@@ -0,0 +1,124 @@
+/*******************************************************************************
+ * 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.jpql;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+
+import org.apache.olingo.odata2.processor.api.jpa.access.JPAJoinClause;
+import org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPARuntimeException;
+import org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLContextType;
+import org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLJoinContextView;
+import org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLStatement;
+import org.easymock.EasyMock;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class JPQLJoinStatementBuilderTest {
+ JPQLJoinContextView context = null;
+
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {}
+
+ @AfterClass
+ public static void tearDownAfterClass() throws Exception {}
+
+ public void setUp(final List<JPAJoinClause> joinClauseList) throws Exception {
+ context = EasyMock.createMock(JPQLJoinContextView.class);
+ EasyMock.expect(context.getJPAEntityAlias()).andStubReturn("mat");
+ EasyMock.expect(context.getJPAEntityName()).andStubReturn("SOHeader");
+ EasyMock.expect(context.getType()).andStubReturn(JPQLContextType.SELECT);
+ EasyMock.expect(context.getSelectExpression()).andStubReturn("mat");
+ EasyMock.expect(context.getWhereExpression()).andStubReturn("soh.buyerId = 2");
+ HashMap<String, String> orderByMap = new HashMap<String, String>();
+ orderByMap.put("mat.buyerId", "asc");
+ orderByMap.put("mat.city", "desc");
+ EasyMock.expect(context.getOrderByCollection()).andStubReturn(orderByMap);
+ EasyMock.expect(context.getJPAJoinClauses()).andStubReturn(joinClauseList);
+ EasyMock.replay(context);
+ }
+
+ private List<JPAJoinClause> getJoinClauseList() {
+ List<JPAJoinClause> joinClauseList = new ArrayList<JPAJoinClause>();
+ JPAJoinClause jpaOuterJoinClause =
+ new JPAJoinClause("SOHeader", "soh", null, null, "soh.createdBy = 'Peter'", JPAJoinClause.JOIN.LEFT);
+ joinClauseList.add(jpaOuterJoinClause);
+ jpaOuterJoinClause =
+ new JPAJoinClause("SOHeader", "soh", "soItem", "soi", "soi.shId = soh.soId", JPAJoinClause.JOIN.LEFT);
+ joinClauseList.add(jpaOuterJoinClause);
+ jpaOuterJoinClause =
+ new JPAJoinClause("SOItem", "si", "material", "mat", "mat.id = 'abc'", JPAJoinClause.JOIN.LEFT);
+ joinClauseList.add(jpaOuterJoinClause);
+ return joinClauseList;
+ }
+
+ @After
+ public void tearDown() throws Exception {}
+
+ @Test
+ public void testBuild() throws Exception {
+ setUp(getJoinClauseList());
+ JPQLJoinStatementBuilder jpqlJoinStatementBuilder = new JPQLJoinStatementBuilder(context);
+ try {
+ JPQLStatement jpqlStatement = jpqlJoinStatementBuilder.build();
+ assertEquals(
+ "SELECT mat FROM SOHeader soh JOIN soh.soItem soi JOIN soi.material mat WHERE soh.buyerId = 2 AND "
+ +
+ "soh.createdBy = 'Peter' AND soi.shId = soh.soId AND mat.id = 'abc' "
+ +
+ "ORDER BY mat.buyerId asc , mat.city desc",
+ jpqlStatement.toString());
+ } catch (ODataJPARuntimeException e) {
+ fail("Should not have come here");
+ }
+
+ }
+
+ @Test
+ public void testJoinClauseAsNull() throws Exception {
+ setUp(null);
+ JPQLJoinStatementBuilder jpqlJoinStatementBuilder = new JPQLJoinStatementBuilder(context);
+ try {
+ jpqlJoinStatementBuilder.build();
+ fail("Should not have come here");
+ } catch (ODataJPARuntimeException e) {
+ assertTrue(true);
+ }
+ }
+
+ @Test
+ public void testJoinClauseListAsEmpty() throws Exception {
+ setUp(new ArrayList<JPAJoinClause>());
+ JPQLJoinStatementBuilder jpqlJoinStatementBuilder = new JPQLJoinStatementBuilder(context);
+ try {
+ jpqlJoinStatementBuilder.build();
+ fail("Should not have come here");
+ } catch (ODataJPARuntimeException e) {
+ assertTrue(true);
+ }
+ }
+
+}
[11/37] [OLINGO-82] Renamed the project folder name to
odata2-jpa-processor
Posted by ch...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmReferentialConstraint.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmReferentialConstraint.java b/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmReferentialConstraint.java
deleted file mode 100644
index 2888a9a..0000000
--- a/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmReferentialConstraint.java
+++ /dev/null
@@ -1,147 +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.model;
-
-import org.apache.olingo.odata2.api.edm.provider.ReferentialConstraint;
-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.JPAEdmAssociationView;
-import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmEntityTypeView;
-import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmPropertyView;
-import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmReferentialConstraintRoleView;
-import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmReferentialConstraintRoleView.RoleType;
-import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmReferentialConstraintView;
-
-public class JPAEdmReferentialConstraint extends JPAEdmBaseViewImpl implements JPAEdmReferentialConstraintView {
-
- private JPAEdmRefConstraintBuilder builder = null;
-
- private boolean exists = false;
- private boolean firstBuild = true;
-
- private JPAEdmAssociationView associationView;
- private JPAEdmPropertyView propertyView;
- private JPAEdmEntityTypeView entityTypeView;
-
- private ReferentialConstraint referentialConstraint;
-
- private JPAEdmReferentialConstraintRoleView principalRoleView;
- private JPAEdmReferentialConstraintRoleView dependentRoleView;
-
- private String relationShipName;
-
- public JPAEdmReferentialConstraint(final JPAEdmAssociationView associationView,
- final JPAEdmEntityTypeView entityTypeView, final JPAEdmPropertyView propertyView) {
- super(associationView);
- this.associationView = associationView;
- this.propertyView = propertyView;
- this.entityTypeView = entityTypeView;
-
- relationShipName = associationView.getEdmAssociation().getName();
- }
-
- @Override
- public JPAEdmBuilder getBuilder() {
- if (builder == null) {
- builder = new JPAEdmRefConstraintBuilder();
- }
-
- return builder;
- }
-
- @Override
- public ReferentialConstraint getEdmReferentialConstraint() {
- return referentialConstraint;
- }
-
- @Override
- public boolean isExists() {
- return exists;
- }
-
- @Override
- public String getEdmRelationShipName() {
- return relationShipName;
- }
-
- private class JPAEdmRefConstraintBuilder implements JPAEdmBuilder {
- /*
- * Check if Ref Constraint was already Built. If Ref constraint was
- * already built consistently then do not build referential constraint.
- *
- * For Ref Constraint to be consistently built Principal and Dependent
- * roles must be consistently built. If Principal or Dependent roles are
- * not consistently built then try building them again.
- *
- * The Principal and Dependent roles could be have been built
- * inconsistently if the required EDM Entity Types or EDM properties are
- * yet to be built. In such cases rebuilding these roles would make them
- * consistent.
- */
- @Override
- public void build() throws ODataJPAModelException, ODataJPARuntimeException {
-
- if (firstBuild) {
- firstBuild();
- } else {
- if (exists && !firstBuild && principalRoleView.isConsistent() == false) {
- principalRoleView.getBuilder().build();
- }
-
- if (exists && !firstBuild && dependentRoleView.isConsistent() == false) {
- dependentRoleView.getBuilder().build();
- }
- }
-
- if (principalRoleView.isConsistent()) {
- referentialConstraint.setPrincipal(principalRoleView.getEdmReferentialConstraintRole());
- }
-
- if (dependentRoleView.isConsistent()) {
- referentialConstraint.setDependent(dependentRoleView.getEdmReferentialConstraintRole());
- }
-
- exists = principalRoleView.isExists() & dependentRoleView.isExists();
-
- isConsistent = principalRoleView.isConsistent() & dependentRoleView.isConsistent();
-
- }
-
- private void firstBuild() throws ODataJPAModelException, ODataJPARuntimeException {
- firstBuild = false;
- if (principalRoleView == null && dependentRoleView == null) {
-
- principalRoleView =
- new JPAEdmReferentialConstraintRole(RoleType.PRINCIPAL, entityTypeView, propertyView, associationView);
- principalRoleView.getBuilder().build();
-
- dependentRoleView =
- new JPAEdmReferentialConstraintRole(RoleType.DEPENDENT, entityTypeView, propertyView, associationView);
- dependentRoleView.getBuilder().build();
-
- if (referentialConstraint == null) {
- referentialConstraint = new ReferentialConstraint();
- }
- }
-
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmReferentialConstraintRole.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmReferentialConstraintRole.java b/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmReferentialConstraintRole.java
deleted file mode 100644
index 3761d4b..0000000
--- a/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmReferentialConstraintRole.java
+++ /dev/null
@@ -1,258 +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.model;
-
-import java.lang.reflect.AnnotatedElement;
-import java.lang.reflect.ParameterizedType;
-import java.lang.reflect.Type;
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.persistence.JoinColumn;
-import javax.persistence.JoinColumns;
-import javax.persistence.metamodel.Attribute;
-
-import org.apache.olingo.odata2.api.edm.provider.Association;
-import org.apache.olingo.odata2.api.edm.provider.AssociationEnd;
-import org.apache.olingo.odata2.api.edm.provider.EntityType;
-import org.apache.olingo.odata2.api.edm.provider.Property;
-import org.apache.olingo.odata2.api.edm.provider.PropertyRef;
-import org.apache.olingo.odata2.api.edm.provider.ReferentialConstraintRole;
-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.model.JPAEdmAssociationView;
-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.JPAEdmPropertyView;
-import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmReferentialConstraintRoleView;
-
-public class JPAEdmReferentialConstraintRole extends JPAEdmBaseViewImpl implements JPAEdmReferentialConstraintRoleView {
- /*
- * Static Buffer
- */
- private static Attribute<?, ?> bufferedJPAAttribute = null;
- private static ArrayList<JoinColumn> bufferedJoinColumns = new ArrayList<JoinColumn>();
- /*
- * Static Buffer
- */
-
- private boolean firstBuild = true;
-
- private JPAEdmEntityTypeView entityTypeView;
- private JPAEdmReferentialConstraintRoleView.RoleType roleType;
-
- private Attribute<?, ?> jpaAttribute;
- private ArrayList<String> jpaColumnNames;
- private Association association;
-
- private boolean roleExists = false;
-
- private JPAEdmRefConstraintRoleBuilder builder;
- private ReferentialConstraintRole currentRole;
-
- public JPAEdmReferentialConstraintRole(final JPAEdmReferentialConstraintRoleView.RoleType roleType,
- final JPAEdmEntityTypeView entityTypeView, final JPAEdmPropertyView propertyView,
- final JPAEdmAssociationView associationView) {
-
- super(entityTypeView);
- this.entityTypeView = entityTypeView;
- this.roleType = roleType;
-
- jpaAttribute = propertyView.getJPAAttribute();
- association = associationView.getEdmAssociation();
-
- }
-
- @Override
- public boolean isExists() {
- return roleExists;
-
- }
-
- @Override
- public JPAEdmBuilder getBuilder() {
- if (builder == null) {
- builder = new JPAEdmRefConstraintRoleBuilder();
- }
-
- return builder;
- }
-
- @Override
- public RoleType getRoleType() {
- return roleType;
- }
-
- @Override
- public ReferentialConstraintRole getEdmReferentialConstraintRole() {
- return currentRole;
- }
-
- @Override
- public String getJPAColumnName() {
- return null;
- }
-
- @Override
- public String getEdmEntityTypeName() {
- return null;
- }
-
- @Override
- public String getEdmAssociationName() {
- return null;
- }
-
- private class JPAEdmRefConstraintRoleBuilder implements JPAEdmBuilder {
-
- @Override
- public void build() throws ODataJPAModelException {
- if (firstBuild) {
- firstBuild();
- } else if (roleExists) {
- try {
- buildRole();
- } catch (SecurityException e) {
- throw ODataJPAModelException.throwException(ODataJPAModelException.GENERAL.addContent(e.getMessage()), e);
- } catch (NoSuchFieldException e) {
- throw ODataJPAModelException.throwException(ODataJPAModelException.GENERAL.addContent(e.getMessage()), e);
- }
- }
-
- }
-
- private void firstBuild() {
- firstBuild = false;
- isConsistent = false;
-
- extractJoinColumns();
-
- if (!roleExists) {
- return;
- }
-
- jpaColumnNames = new ArrayList<String>();
-
- for (JoinColumn joinColumn : bufferedJoinColumns) {
- if (roleType == RoleType.PRINCIPAL) {
- jpaColumnNames.add(joinColumn.referencedColumnName());
- } else if (roleType == RoleType.DEPENDENT) {
- jpaColumnNames.add(joinColumn.name());
- }
- }
-
- }
-
- private void buildRole() throws SecurityException, NoSuchFieldException {
-
- if (currentRole == null) {
- currentRole = new ReferentialConstraintRole();
- String jpaAttributeType = null;
- EntityType edmEntityType = null;
-
- if (roleType == RoleType.PRINCIPAL) {
- jpaAttributeType = jpaAttribute.getJavaType().getSimpleName();
- if (jpaAttributeType.equals("List")) {
- Type type =
- ((ParameterizedType) jpaAttribute.getJavaMember().getDeclaringClass().getDeclaredField(
- jpaAttribute.getName()).getGenericType()).getActualTypeArguments()[0];
- int lastIndexOfDot = type.toString().lastIndexOf(".");
- jpaAttributeType = type.toString().substring(lastIndexOfDot + 1);
- }
- edmEntityType = entityTypeView.searchEdmEntityType(jpaAttributeType);
- } else if (roleType == RoleType.DEPENDENT) {
- edmEntityType =
- entityTypeView.searchEdmEntityType(jpaAttribute.getDeclaringType().getJavaType().getSimpleName());
- }
-
- List<PropertyRef> propertyRefs = new ArrayList<PropertyRef>();
- if (edmEntityType != null) {
- for (String columnName : jpaColumnNames) {
- for (Property property : edmEntityType.getProperties()) {
- if (columnName.equals(((JPAEdmMapping) property.getMapping()).getJPAColumnName())) {
- PropertyRef propertyRef = new PropertyRef();
- propertyRef.setName(property.getName());
- propertyRefs.add(propertyRef);
- break;
- }
- }
- }
- currentRole.setPropertyRefs(propertyRefs);
- if (propertyRefs.isEmpty()) {
- isConsistent = false;
- return;
- }
- AssociationEnd end = association.getEnd1();
- if (end.getType().getName().equals(edmEntityType.getName())) {
- currentRole.setRole(end.getRole());
- isConsistent = true;
- } else {
- end = association.getEnd2();
- if (end.getType().getName().equals(edmEntityType.getName())) {
- currentRole.setRole(end.getRole());
- isConsistent = true;
- }
- }
- }
-
- }
- }
-
- private void extractJoinColumns() {
- /*
- * Check against Static Buffer whether the join column was already
- * extracted.
- */
- if (!jpaAttribute.equals(bufferedJPAAttribute)) {
- bufferedJPAAttribute = jpaAttribute;
- bufferedJoinColumns.clear();
- } else if (bufferedJoinColumns.isEmpty()) {
- roleExists = false;
- return;
- } else {
- roleExists = true;
- return;
- }
-
- AnnotatedElement annotatedElement = (AnnotatedElement) jpaAttribute.getJavaMember();
-
- if (annotatedElement == null) {
- return;
- }
-
- JoinColumn joinColumn = annotatedElement.getAnnotation(JoinColumn.class);
- if (joinColumn == null) {
- JoinColumns joinColumns = annotatedElement.getAnnotation(JoinColumns.class);
-
- if (joinColumns != null) {
- JoinColumn[] joinColumnArray = joinColumns.value();
-
- for (JoinColumn element : joinColumnArray) {
- bufferedJoinColumns.add(element);
- }
- } else {
- return;
- }
- } else {
- bufferedJoinColumns.add(joinColumn);
- }
- roleExists = true;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmSchema.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmSchema.java b/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmSchema.java
deleted file mode 100644
index b9ded8b..0000000
--- a/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmSchema.java
+++ /dev/null
@@ -1,216 +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.model;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-
-import org.apache.olingo.odata2.api.edm.provider.Association;
-import org.apache.olingo.odata2.api.edm.provider.ComplexType;
-import org.apache.olingo.odata2.api.edm.provider.EntityType;
-import org.apache.olingo.odata2.api.edm.provider.NavigationProperty;
-import org.apache.olingo.odata2.api.edm.provider.Schema;
-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.JPAEdmAssociationView;
-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.JPAEdmModelView;
-import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmSchemaView;
-import org.apache.olingo.odata2.processor.core.jpa.access.model.JPAEdmNameBuilder;
-
-public class JPAEdmSchema extends JPAEdmBaseViewImpl implements JPAEdmSchemaView {
-
- private Schema schema;
- private JPAEdmComplexTypeView complexTypeView;
- private JPAEdmEntityContainerView entityContainerView;
- private JPAEdmAssociationView associationView = null;
- private List<String> nonKeyComplexList = null;
- private HashMap<Class<?>, String[]> customOperations = null;
-
- public JPAEdmSchema(final JPAEdmModelView modelView) {
- super(modelView);
- if (nonKeyComplexList == null) {
- nonKeyComplexList = new ArrayList<String>();
- }
- }
-
- @Override
- public List<String> getNonKeyComplexTypeList() {
- return nonKeyComplexList;
- }
-
- @Override
- public void addNonKeyComplexName(final String complexTypeName) {
- nonKeyComplexList.add(complexTypeName);
- }
-
- @Override
- public Schema getEdmSchema() {
- return schema;
- }
-
- @Override
- public JPAEdmEntityContainerView getJPAEdmEntityContainerView() {
- return entityContainerView;
- }
-
- @Override
- public JPAEdmComplexTypeView getJPAEdmComplexTypeView() {
- return complexTypeView;
- }
-
- @Override
- public JPAEdmBuilder getBuilder() {
- if (builder == null) {
- builder = new JPAEdmSchemaBuilder();
- }
-
- return builder;
- }
-
- @Override
- public void clean() {
- super.clean();
- schema = null;
- }
-
- private class JPAEdmSchemaBuilder implements JPAEdmBuilder {
- /*
- *
- * Each call to build method creates a new EDM Schema. The newly created
- * schema is built with Entity Containers, associations, Complex Types
- * and Entity Types.
- *
- * ************************************************************ Build
- * EDM Schema - STEPS
- * ************************************************************ 1) Build
- * Name for EDM Schema 2) Build EDM Complex Types from JPA Embeddable
- * Types 3) Add EDM Complex Types to EDM Schema 4) Build EDM Entity
- * Container 5) Add EDM Entity Container to EDM Schema 6) Fetch Built
- * EDM Entity Types from EDM Entity Container 7) Add EDM Entity Types to
- * EDM Schema 8) Fetch Built EDM Association Sets from EDM Entity
- * Container 9) Fetch Built EDM Associations from EDM Association Set
- * 10) Add EDM Association to EDM Schema
- * ************************************************************ Build
- * EDM Schema - STEPS
- * ************************************************************
- */
- @Override
- public void build() throws ODataJPAModelException, ODataJPARuntimeException {
-
- schema = new Schema();
- JPAEdmNameBuilder.build(JPAEdmSchema.this);
-
- associationView = new JPAEdmAssociation(JPAEdmSchema.this);
-
- complexTypeView = new JPAEdmComplexType(JPAEdmSchema.this);
- complexTypeView.getBuilder().build();
-
- if (getJPAEdmExtension() != null) {
- getJPAEdmExtension().extendWithOperation(JPAEdmSchema.this);
- }
-
- entityContainerView = new JPAEdmEntityContainer(JPAEdmSchema.this);
- entityContainerView.getBuilder().build();
- schema.setEntityContainers(entityContainerView.getConsistentEdmEntityContainerList());
-
- JPAEdmEntitySetView entitySetView = entityContainerView.getJPAEdmEntitySetView();
- if (entitySetView.isConsistent() && entitySetView.getJPAEdmEntityTypeView() != null) {
- JPAEdmEntityTypeView entityTypeView = entitySetView.getJPAEdmEntityTypeView();
- if (entityTypeView.isConsistent() && !entityTypeView.getConsistentEdmEntityTypes().isEmpty()) {
- schema.setEntityTypes(entityTypeView.getConsistentEdmEntityTypes());
- }
- }
- if (complexTypeView.isConsistent()) {
- List<ComplexType> complexTypes = complexTypeView.getConsistentEdmComplexTypes();
- List<ComplexType> existingComplexTypes = new ArrayList<ComplexType>();
- for (ComplexType complexType : complexTypes) {
- if (complexType != null && nonKeyComplexList.contains(complexType.getName())) {// null check for exclude
- existingComplexTypes.add(complexType);
- }
- }
- if (!existingComplexTypes.isEmpty()) {
- schema.setComplexTypes(existingComplexTypes);
- }
- }
-
- List<String> existingAssociationList = new ArrayList<String>();
- if (associationView.isConsistent() && !associationView.getConsistentEdmAssociationList().isEmpty()) {
-
- List<Association> consistentAssociationList = associationView.getConsistentEdmAssociationList();
- schema.setAssociations(consistentAssociationList);
- for (Association association : consistentAssociationList) {
- existingAssociationList.add(association.getName());
- }
-
- }
- List<EntityType> entityTypes =
- entityContainerView.getJPAEdmEntitySetView().getJPAEdmEntityTypeView().getConsistentEdmEntityTypes();
- List<NavigationProperty> navigationProperties;
- if (entityTypes != null && !entityTypes.isEmpty()) {
- for (EntityType entityType : entityTypes) {
-
- List<NavigationProperty> consistentNavigationProperties = null;
- navigationProperties = entityType.getNavigationProperties();
- if (navigationProperties != null) {
- consistentNavigationProperties = new ArrayList<NavigationProperty>();
- for (NavigationProperty navigationProperty : navigationProperties) {
- if (existingAssociationList.contains(navigationProperty.getRelationship().getName())) {
- consistentNavigationProperties.add(navigationProperty);
- }
- }
- if (consistentNavigationProperties.isEmpty()) {
- entityType.setNavigationProperties(null);
- } else {
- entityType.setNavigationProperties(consistentNavigationProperties);
- }
- }
-
- }
- }
-
- }
-
- }
-
- @Override
- public final JPAEdmAssociationView getJPAEdmAssociationView() {
- return associationView;
- }
-
- @Override
- public void registerOperations(final Class<?> customClass, final String[] methodNames) {
- if (customOperations == null) {
- customOperations = new HashMap<Class<?>, String[]>();
- }
-
- customOperations.put(customClass, methodNames);
-
- }
-
- @Override
- public HashMap<Class<?>, String[]> getRegisteredOperations() {
- return customOperations;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/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
deleted file mode 100644
index da8054c..0000000
--- a/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/_JPAEdmFunctionImportBuilder.java
+++ /dev/null
@@ -1,237 +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.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/1b479e6c/odata2-processor-jpa/jpa-core/src/main/resources/jpaprocessor_msg.properties
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-core/src/main/resources/jpaprocessor_msg.properties b/odata2-processor-jpa/jpa-core/src/main/resources/jpaprocessor_msg.properties
deleted file mode 100644
index 5eb96fb..0000000
--- a/odata2-processor-jpa/jpa-core/src/main/resources/jpaprocessor_msg.properties
+++ /dev/null
@@ -1,61 +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.
-#-------------------------------------------------------------------------------
-# Fall Back translations
-#
-
-#JPA EDM Provider Errors
-org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPAModelException.GENERAL="OData - JPA Metadata: Internal error [%1$s]"
-org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPAModelException.INNER_EXCEPTION="%1$s: %2$s.\n"
-org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPAModelException.INVALID_ENTITY_TYPE="OData - JPA Model Processor: Invalid Entity Type [%1$s]"
-org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPAModelException.INVALID_COMPLEX_TYPE="OData - JPA Model Processor: Invalid Complex Type [%1$s]"
-org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPAModelException.INVALID_ASSOCIATION ="OData - JPA Model Processor: Invalid Association [%1$s]"
-org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPAModelException.INVALID_ENTITYSET="OData - JPA Model Processor: Invalid Entity set [%1$s]"
-org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPAModelException.INVALID_ENTITYCONTAINER="OData - JPA Model Processor: Invalid Entity Container [%1$s]"
-org.apache.olingo.odata2.processor.jap.exception.ODataJPAModelException.INVALID_ASSOCIATION_SET="OData - JPA Model Processor: Invalid Association Set [%1$s]"
-org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPAModelException.INVALID_FUNC_IMPORT="OData - JPA Model Processor: Invalid Function Import [%1$s]"
-org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPAModelException.BUILDER_NULL="OData - JPA Model Processor: JPA Builder not initialized"
-org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPAModelException.FUNC_ENTITYSET_EXP="OData - JPA Model Processor: Entity Set expected for Function Import with return type as Entity Type with Multiplicity Many"
-org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPAModelException.FUNC_RETURN_TYPE_EXP="OData - JPA Model Processor: Return type expected. Class: [%1$s], Method: [%2$s]"
-org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPAModelException.FUNC_RETURN_TYPE_ENTITY_NOT_FOUND="OData - JPA Model Processor: Return type not found. Class: [%1$s], Method: [%2$s], Type: [%3$s]"
-org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPAModelException.FUNC_PARAM_NAME_EXP="OData - JPA Model Processor: Parameter Name for function import expected. Class: [%1$s]", Method: [%2$s]"
-
-#JPA Type converter Errors
-org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPAModelException.TYPE_NOT_SUPPORTED="OData - JPA Type Converter: Type [%1$s] not supported"
-
-#JPA Runtime Errors
-org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPARuntimeException.ENTITY_MANAGER_NOT_INITIALIZED="OData - JPA Service Factory: Java Persistence Entity Manager not initialized"
-org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPARuntimeException.GENERAL="OData - JPA Runtime: Internal error [%1$s]"
-org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPARuntimeException.INNER_EXCEPTION="%1$s: %2$s.\n"
-org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPARuntimeException.JOIN_CLAUSE_EXPECTED="OData - JPA Runtime: Join Clause expected"
-org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPARuntimeException.RESOURCE_NOT_FOUND="OData - JPA Runtime: Resource not found"
-org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPARuntimeException.ERROR_ODATA_FILTER_CONDITION="OData - JPA Runtime: Filter condition not correct"
-org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPARuntimeException.ERROR_JPQL_QUERY_CREATE="OData - JPA Runtime: JPA query syntax is not correct"
-org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPARuntimeException.ERROR_JPQL_CREATE_REQUEST="OData - JPA Runtime: JPA create request is not correct"
-org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPARuntimeException.ERROR_JPQL_UPDATE_REQUEST="OData - JPA Runtime: JPA update request is not correct"
-org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPARuntimeException.ERROR_JPQL_DELETE_REQUEST="OData - JPA Runtime: JPA delete URL is not correct"
-org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPARuntimeException.ERROR_JPQL_KEY_VALUE="Key parameter value is not correct for [%1$s]"
-org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPARuntimeException.ERROR_JPQL_PARAM_VALUE="Parameter value is not correct for [%1$s]"
-org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPARuntimeException.ERROR_JPQL_UNIQUE_CONSTRAINT="Violation of unique constraint"
-org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPARuntimeException.ERROR_JPQL_INTEGRITY_CONSTRAINT="Integrity constraint violation"
-org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPARuntimeException.RELATIONSHIP_INVALID="OData - JPA Runtime: Invalid link"
-org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPARuntimeException.RESOURCE_X_NOT_FOUND="OData - JPA Runtime: Resource [%1$s] not found"
-
-#JPA Common Errors
-org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPAException.ODATA_JPACTX_NULL="OData JPA: OData JPA Context cannot be null"
-org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPARuntimeException.ERROR_JPQLCTXBLDR_CREATE="OData JPA: Error creating JPQL Context Builder"
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-core/src/test/java/META-INF/MANIFEST.MF
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-core/src/test/java/META-INF/MANIFEST.MF b/odata2-processor-jpa/jpa-core/src/test/java/META-INF/MANIFEST.MF
deleted file mode 100644
index 5e94951..0000000
--- a/odata2-processor-jpa/jpa-core/src/test/java/META-INF/MANIFEST.MF
+++ /dev/null
@@ -1,3 +0,0 @@
-Manifest-Version: 1.0
-Class-Path:
-
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/ODataExpressionParserTest.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/ODataExpressionParserTest.java b/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/ODataExpressionParserTest.java
deleted file mode 100644
index 390c7fe..0000000
--- a/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/ODataExpressionParserTest.java
+++ /dev/null
@@ -1,515 +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;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.olingo.odata2.api.edm.EdmException;
-import org.apache.olingo.odata2.api.edm.EdmFacets;
-import org.apache.olingo.odata2.api.edm.EdmLiteralKind;
-import org.apache.olingo.odata2.api.edm.EdmMapping;
-import org.apache.olingo.odata2.api.edm.EdmProperty;
-import org.apache.olingo.odata2.api.edm.EdmSimpleType;
-import org.apache.olingo.odata2.api.edm.EdmSimpleTypeKind;
-import org.apache.olingo.odata2.api.edm.EdmTypeKind;
-import org.apache.olingo.odata2.api.edm.EdmTyped;
-import org.apache.olingo.odata2.api.exception.ODataException;
-import org.apache.olingo.odata2.api.uri.KeyPredicate;
-import org.apache.olingo.odata2.api.uri.expression.BinaryExpression;
-import org.apache.olingo.odata2.api.uri.expression.BinaryOperator;
-import org.apache.olingo.odata2.api.uri.expression.CommonExpression;
-import org.apache.olingo.odata2.api.uri.expression.ExpressionKind;
-import org.apache.olingo.odata2.api.uri.expression.FilterExpression;
-import org.apache.olingo.odata2.api.uri.expression.LiteralExpression;
-import org.apache.olingo.odata2.api.uri.expression.MemberExpression;
-import org.apache.olingo.odata2.api.uri.expression.MethodExpression;
-import org.apache.olingo.odata2.api.uri.expression.MethodOperator;
-import org.apache.olingo.odata2.api.uri.expression.PropertyExpression;
-import org.apache.olingo.odata2.api.uri.expression.UnaryExpression;
-import org.apache.olingo.odata2.api.uri.expression.UnaryOperator;
-import org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPARuntimeException;
-import org.apache.olingo.odata2.processor.core.jpa.common.ODataJPATestConstants;
-import org.easymock.EasyMock;
-import org.junit.Test;
-
-public class ODataExpressionParserTest {
-
- private static final String EXPECTED_STR_1 = "gwt1.SalesOrder = 1234";
- private static final String EXPECTED_STR_2 = "gwt1.SalesOrder >= 1234 AND gwt1.SalesABC <> XYZ";
- private static final String EXPECTED_STR_3 = "gwt1.SalesOrder >= 1234 OR gwt1.SalesABC <> XYZ";
- private static final String EXPECTED_STR_4 = "gwt1.SalesOrder < 1234 AND gwt1.SalesABC <= XYZ";
- private static final String EXPECTED_STR_5 = "gwt1.LineItems > 2345 AND gwt1.SalesOrder >= Amazon";
- private static final String EXPECTED_STR_6 = "gwt1.Address.city = \'City_3\'";
- private static final String EXPECTED_STR_7 = "gwt1.Address.city.area = \'BTM\'";
- private static final String EXPECTED_STR_8 = "gwt1.field1 = 1 AND gwt1.field2 = 'abc'";
- private static final String EXPECTED_STR_9 = "gwt1.BuyerAddress, gwt1.BuyerName, gwt1.BuyerId";
- private static final String EXPECTED_STR_10 = "gwt1.SalesOrder";
- private static final String EXPECTED_STR_11 = "NOT(gwt1.deliveryStatus)";
- private static final String EXPECTED_STR_12 =
- "(CASE WHEN (gwt1.currencyCode LIKE '%Ru%') THEN TRUE ELSE FALSE END) = true";
- private static final String EXPECTED_STR_13 = "SUBSTRING(gwt1.currencyCode, 1 + 1 , 2) = 'NR'";
- private static final String EXPECTED_STR_14 = "LOWER(gwt1.currencyCode) = 'inr rupees'";
- private static final String EXPECTED_STR_15 =
- "(CASE WHEN (LOWER(gwt1.currencyCode) LIKE '%nr rupees%') THEN TRUE ELSE FALSE END) = true";
- private static final String EXPECTED_STR_16 =
- "(CASE WHEN (gwt1.currencyCode LIKE '%INR%') THEN TRUE ELSE FALSE END) = true";
- private static final String EXPECTED_STR_17 =
- "(CASE WHEN (LOWER(gwt1.currencyCode) LIKE '%nr rupees%') THEN TRUE ELSE FALSE END) = true";
-
- private static final String ADDRESS = "Address";
- private static final String CITY = "city";
- private static final String AREA = "area";
- private static final String SALES_ORDER = "SalesOrder";
- private static final String SALES_ABC = "SalesABC";
- private static final String SAMPLE_DATA_1 = "1234";
- private static final String SAMPLE_DATA_2 = "2345";
- private static final String SAMPLE_DATA_XYZ = "XYZ";
- private static final String SAMPLE_DATA_BTM = "\'BTM\'";
- private static final String SAMPLE_DATA_CITY_3 = "\'City_3\'";
- private static final String SAMPLE_DATA_LINE_ITEMS = "LineItems";
- private static final String SAMPLE_DATA_AMAZON = "Amazon";
- private static final String SAMPLE_DATA_FIELD1 = "field1";
- private static final String SAMPLE_DATA_FIELD2 = "field2";
-
- private static final String TABLE_ALIAS = "gwt1"; //$NON-NLS-1$
-
- @Test
- public void testParseWhereExpression() {
- try {
- String parsedStr = ODataJPATestConstants.EMPTY_STRING;
- // Simple Binary query -
- parsedStr =
- ODataExpressionParser.parseToJPAWhereExpression(getBinaryExpressionMockedObj(BinaryOperator.EQ,
- ExpressionKind.PROPERTY, SALES_ORDER, SAMPLE_DATA_1), TABLE_ALIAS);
-
- assertEquals(EXPECTED_STR_1, parsedStr);
- // complex query -
- parsedStr = ODataJPATestConstants.EMPTY_STRING;
-
- CommonExpression exp1 =
- getBinaryExpressionMockedObj(BinaryOperator.GE, ExpressionKind.PROPERTY, SALES_ORDER, SAMPLE_DATA_1);
- CommonExpression exp2 =
- getBinaryExpressionMockedObj(BinaryOperator.NE, ExpressionKind.PROPERTY, SALES_ABC, SAMPLE_DATA_XYZ);
- parsedStr =
- ODataExpressionParser.parseToJPAWhereExpression(getBinaryExpression(exp1, BinaryOperator.AND, exp2),
- TABLE_ALIAS);
- assertEquals(EXPECTED_STR_2, parsedStr);
- } catch (EdmException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- } catch (ODataException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
- }
-
- @Test
- public void testMoreThanOneBinaryExpression() {
- // complex query -
- String parsedStr = ODataJPATestConstants.EMPTY_STRING;
- CommonExpression exp1 =
- getBinaryExpressionMockedObj(BinaryOperator.GE, ExpressionKind.PROPERTY, SALES_ORDER, SAMPLE_DATA_1);
- CommonExpression exp2 =
- getBinaryExpressionMockedObj(BinaryOperator.NE, ExpressionKind.PROPERTY, SALES_ABC, SAMPLE_DATA_XYZ);
- try {
- parsedStr =
- ODataExpressionParser.parseToJPAWhereExpression(getBinaryExpression(exp1, BinaryOperator.AND, exp2),
- TABLE_ALIAS);
- assertEquals(EXPECTED_STR_2, parsedStr);
- parsedStr =
- ODataExpressionParser.parseToJPAWhereExpression(getBinaryExpression(exp1, BinaryOperator.OR, exp2),
- TABLE_ALIAS);
- } catch (ODataException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
- assertEquals(EXPECTED_STR_3, parsedStr);
- }
-
- @Test
- public void testParseFilterExpression() {
- try {
- assertEquals(EXPECTED_STR_10, ODataExpressionParser.parseToJPAWhereExpression(getFilterExpressionMockedObj(
- ExpressionKind.PROPERTY, SALES_ORDER), TABLE_ALIAS));
- } catch (ODataException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
- }
-
- @Test
- public void testAllBinaryOperators() { // Test for all Binary Operators
- // complex query -
- String parsedStr1 = ODataJPATestConstants.EMPTY_STRING;
- String parsedStr2 = ODataJPATestConstants.EMPTY_STRING;
-
- CommonExpression exp1 =
- getBinaryExpressionMockedObj(BinaryOperator.LT, ExpressionKind.PROPERTY, SALES_ORDER, SAMPLE_DATA_1);
- CommonExpression exp2 =
- getBinaryExpressionMockedObj(BinaryOperator.LE, ExpressionKind.PROPERTY, SALES_ABC, SAMPLE_DATA_XYZ);
-
- try {
- parsedStr1 =
- ODataExpressionParser.parseToJPAWhereExpression((BinaryExpression) getBinaryExpression(exp1,
- BinaryOperator.AND, exp2), TABLE_ALIAS);
- assertEquals(EXPECTED_STR_4, parsedStr1);
-
- CommonExpression exp3 =
- getBinaryExpressionMockedObj(BinaryOperator.GT, ExpressionKind.PROPERTY, SAMPLE_DATA_LINE_ITEMS,
- SAMPLE_DATA_2);
- CommonExpression exp4 =
- getBinaryExpressionMockedObj(BinaryOperator.GE, ExpressionKind.PROPERTY, SALES_ORDER, SAMPLE_DATA_AMAZON);
-
- parsedStr2 =
- ODataExpressionParser.parseToJPAWhereExpression(getBinaryExpression(exp3, BinaryOperator.AND, exp4),
- TABLE_ALIAS);
-
- } catch (ODataException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
- assertEquals(EXPECTED_STR_5, parsedStr2);
- }
-
- @Test
- public void testParseMemberExpression() {
- try {
- assertEquals(EXPECTED_STR_6, ODataExpressionParser.parseToJPAWhereExpression(getBinaryExpression(
- getMemberExpressionMockedObj(ADDRESS, CITY), BinaryOperator.EQ,
- getLiteralExpressionMockedObj(SAMPLE_DATA_CITY_3)), TABLE_ALIAS));
- assertEquals(EXPECTED_STR_7, ODataExpressionParser.parseToJPAWhereExpression(getBinaryExpression(
- getMultipleMemberExpressionMockedObj(ADDRESS, CITY, AREA), BinaryOperator.EQ,
- getLiteralExpressionMockedObj(SAMPLE_DATA_BTM)), TABLE_ALIAS));
- } catch (ODataException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
- }
-
- @Test
- public void testParseMethodExpression() {
- try {
- assertEquals(EXPECTED_STR_12, ODataExpressionParser.parseToJPAWhereExpression(getBinaryExpression(
- getMethodExpressionMockedObj(MethodOperator.SUBSTRINGOF, "'Ru'", "currencyCode", null, 2), BinaryOperator.EQ,
- getLiteralExpressionMockedObj("true")), TABLE_ALIAS));
- assertEquals(EXPECTED_STR_13, ODataExpressionParser.parseToJPAWhereExpression(getBinaryExpression(
- getMethodExpressionMockedObj(MethodOperator.SUBSTRING, "currencyCode", "1", "2", 3), BinaryOperator.EQ,
- getLiteralExpressionMockedObj("'NR'")), TABLE_ALIAS));
- assertEquals(EXPECTED_STR_14, ODataExpressionParser.parseToJPAWhereExpression(getBinaryExpression(
- getMethodExpressionMockedObj(MethodOperator.TOLOWER, "currencyCode", null, null, 1), BinaryOperator.EQ,
- getLiteralExpressionMockedObj("'inr rupees'")), TABLE_ALIAS));
- assertEquals(EXPECTED_STR_15, ODataExpressionParser.parseToJPAWhereExpression(getBinaryExpression(
- getMultipleMethodExpressionMockedObj(MethodOperator.SUBSTRINGOF, "'nr rupees'", MethodOperator.TOLOWER,
- "currencyCode", 2, 1), BinaryOperator.EQ, getLiteralExpressionMockedObj("true")), TABLE_ALIAS));
- assertEquals(EXPECTED_STR_16, ODataExpressionParser.parseToJPAWhereExpression(
- getFilterExpressionForFunctionsMockedObj(MethodOperator.SUBSTRINGOF, "'INR'", null, "currencyCode", 2, null)
- /*
- * getBinaryExpression(
- * getMemberExpressionMockedObj(ADDRESS,
- * CITY),
- * BinaryOperator.EQ,
- * getLiteralExpressionMockedObj(SAMPLE_DATA_CITY_3))
- */, TABLE_ALIAS));
- assertEquals(EXPECTED_STR_17, ODataExpressionParser.parseToJPAWhereExpression(
- getFilterExpressionForFunctionsMockedObj(MethodOperator.SUBSTRINGOF, "'nr rupees'", MethodOperator.TOLOWER,
- "currencyCode", 2, 1)
- /*
- * getBinaryExpression(
- * getMemberExpressionMockedObj(ADDRESS,
- * CITY),
- * BinaryOperator.EQ,
- * getLiteralExpressionMockedObj(SAMPLE_DATA_CITY_3))
- */, TABLE_ALIAS));
-
- } catch (ODataException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
- }
-
- private CommonExpression getMethodExpressionMockedObj(final MethodOperator methodOperator, final String firstName,
- final String secondName, final String thirdName, final Integer parameterCount) {
-
- List<CommonExpression> parameters = new ArrayList<CommonExpression>();
-
- if (methodOperator == MethodOperator.SUBSTRINGOF) {
- parameters.add(getLiteralExpressionMockedObj(firstName));
- parameters.add(getPropertyExpressionMockedObj(ExpressionKind.PROPERTY, secondName));
- } else if (methodOperator == MethodOperator.SUBSTRING) {
- parameters.add(getPropertyExpressionMockedObj(ExpressionKind.PROPERTY, firstName));
- parameters.add(getLiteralExpressionMockedObj(secondName));
- parameters.add(getLiteralExpressionMockedObj(thirdName));
- } else if (methodOperator == MethodOperator.TOLOWER) {
- parameters.add(getPropertyExpressionMockedObj(ExpressionKind.PROPERTY, firstName));
- }
-
- MethodExpression methodExpression = EasyMock.createMock(MethodExpression.class);
-
- EasyMock.expect(methodExpression.getKind()).andStubReturn(ExpressionKind.METHOD);
- EasyMock.expect(methodExpression.getMethod()).andStubReturn(methodOperator);
- EasyMock.expect(methodExpression.getParameterCount()).andStubReturn(parameterCount);
- EasyMock.expect(methodExpression.getParameters()).andStubReturn(parameters);
- EasyMock.replay(methodExpression);
-
- return methodExpression;
- }
-
- private CommonExpression getMultipleMethodExpressionMockedObj(final MethodOperator methodOperator1,
- final String firstName, final MethodOperator methodOperator2, final String secondName,
- final Integer parameterCount1, final Integer parameterCount2) {
-
- // complex query
- List<CommonExpression> parameters = new ArrayList<CommonExpression>();
-
- parameters.add(getLiteralExpressionMockedObj(firstName));
- parameters.add(getMethodExpressionMockedObj(methodOperator2, secondName, null, null, 1));
-
- MethodExpression methodExpression = EasyMock.createMock(MethodExpression.class);
-
- EasyMock.expect(methodExpression.getKind()).andStubReturn(ExpressionKind.METHOD);
- EasyMock.expect(methodExpression.getMethod()).andStubReturn(methodOperator1);
- EasyMock.expect(methodExpression.getParameterCount()).andStubReturn(parameterCount1);
- EasyMock.expect(methodExpression.getParameters()).andStubReturn(parameters);
- EasyMock.replay(methodExpression);
-
- return methodExpression;
- }
-
- private CommonExpression getMultipleMemberExpressionMockedObj(final String string1, final String string2,
- final String string3) {
-
- MemberExpression memberExpression = EasyMock.createMock(MemberExpression.class);
-
- EasyMock.expect(memberExpression.getPath()).andStubReturn(getMemberExpressionMockedObj(string1, string2));
- EasyMock.expect(memberExpression.getProperty()).andStubReturn(
- getPropertyExpressionMockedObj(ExpressionKind.PROPERTY, string3));
- EasyMock.expect(memberExpression.getKind()).andStubReturn(ExpressionKind.MEMBER);
- EasyMock.replay(memberExpression);
-
- return memberExpression;
- }
-
- @Test
- public void testParseUnaryExpression() {
-
- UnaryExpression unaryExpression =
- getUnaryExpressionMockedObj(getPropertyExpressionMockedObj(ExpressionKind.PROPERTY, "deliveryStatus"),
- org.apache.olingo.odata2.api.uri.expression.UnaryOperator.NOT);
- try {
- assertEquals(EXPECTED_STR_11, ODataExpressionParser.parseToJPAWhereExpression(unaryExpression, TABLE_ALIAS));
- } catch (ODataException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
-
- }
-
- private UnaryExpression
- getUnaryExpressionMockedObj(final CommonExpression operand, final UnaryOperator unaryOperator) {
- UnaryExpression unaryExpression = EasyMock.createMock(UnaryExpression.class);
- EasyMock.expect(unaryExpression.getKind()).andStubReturn(ExpressionKind.UNARY);
- EasyMock.expect(unaryExpression.getOperand()).andStubReturn(operand);
- EasyMock.expect(unaryExpression.getOperator()).andStubReturn(unaryOperator);
-
- EasyMock.replay(unaryExpression);
- return unaryExpression;
- }
-
- private CommonExpression getMemberExpressionMockedObj(final String pathUriLiteral, final String propertyUriLiteral) {
- MemberExpression memberExpression = EasyMock.createMock(MemberExpression.class);
- EasyMock.expect(memberExpression.getPath()).andStubReturn(
- getPropertyExpressionMockedObj(ExpressionKind.PROPERTY, pathUriLiteral));
- EasyMock.expect(memberExpression.getProperty()).andStubReturn(
- getPropertyExpressionMockedObj(ExpressionKind.PROPERTY, propertyUriLiteral));
- EasyMock.expect(memberExpression.getKind()).andStubReturn(ExpressionKind.MEMBER);
-
- EasyMock.replay(memberExpression);
- return memberExpression;
- }
-
- private LiteralExpression getLiteralExpressionMockedObj(final String uriLiteral) {
- LiteralExpression rightOperandLiteralExpresion = EasyMock.createMock(LiteralExpression.class);
- EasyMock.expect(rightOperandLiteralExpresion.getKind()).andStubReturn(ExpressionKind.LITERAL);
- EasyMock.expect(rightOperandLiteralExpresion.getUriLiteral()).andStubReturn(uriLiteral);// SAMPLE_DATA
- EasyMock.expect(rightOperandLiteralExpresion.getEdmType()).andStubReturn(getEdmSimpleTypeMockedObj(uriLiteral));
- EasyMock.replay(rightOperandLiteralExpresion);
- return rightOperandLiteralExpresion;
-
- }
-
- private EdmSimpleType getEdmSimpleTypeMockedObj(final String value) {
- EdmSimpleType edmSimpleType = EasyMock.createMock(EdmSimpleType.class);
- try {
- EasyMock.expect(edmSimpleType.getName()).andReturn(value);
- EasyMock.expect(edmSimpleType.getKind()).andStubReturn(EdmTypeKind.SIMPLE);
- EasyMock.expect(edmSimpleType.valueOfString(value, EdmLiteralKind.URI, getEdmFacetsMockedObj(), null))
- .andStubReturn(value);
- EasyMock.expect(edmSimpleType.valueOfString(value, EdmLiteralKind.URI, null, null)).andStubReturn(value);
- EasyMock.expect(edmSimpleType.valueToString(value, EdmLiteralKind.DEFAULT, getEdmFacetsMockedObj()))
- .andStubReturn(value);
- EasyMock.expect(edmSimpleType.valueToString(value, EdmLiteralKind.DEFAULT, null)).andStubReturn(value);
- } catch (EdmException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
- EasyMock.expect(edmSimpleType.getDefaultType()).andStubReturn(null);
- EasyMock.replay(edmSimpleType);
- return edmSimpleType;
- }
-
- private EdmFacets getEdmFacetsMockedObj() {
- EdmFacets facets = EasyMock.createMock(EdmFacets.class);
-
- EasyMock.replay(facets);
- return facets;
- }
-
- private PropertyExpression getPropertyExpressionMockedObj(final ExpressionKind expKind, final String propertyName) {
- PropertyExpression leftOperandPropertyExpresion = EasyMock.createMock(PropertyExpression.class);
- EasyMock.expect(leftOperandPropertyExpresion.getKind()).andStubReturn(ExpressionKind.PROPERTY);
- EasyMock.expect(leftOperandPropertyExpresion.getPropertyName()).andStubReturn(propertyName);
- EasyMock.expect(leftOperandPropertyExpresion.getEdmProperty()).andStubReturn(getEdmTypedMockedObj(propertyName));
- EasyMock.replay(leftOperandPropertyExpresion);
- return leftOperandPropertyExpresion;
- }
-
- private EdmTyped getEdmTypedMockedObj(final String propertyName) {
- EdmProperty mockedEdmProperty = EasyMock.createMock(EdmProperty.class);
- try {
- EasyMock.expect(mockedEdmProperty.getMapping()).andStubReturn(getEdmMappingMockedObj(propertyName));
- EasyMock.replay(mockedEdmProperty);
- } catch (EdmException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
- return mockedEdmProperty;
- }
-
- private EdmMapping getEdmMappingMockedObj(final String propertyName) {
- EdmMapping mockedEdmMapping = EasyMock.createMock(EdmMapping.class);
- EasyMock.expect(mockedEdmMapping.getInternalName()).andStubReturn(propertyName);
- EasyMock.replay(mockedEdmMapping);
- return mockedEdmMapping;
- }
-
- private BinaryExpression getBinaryExpressionMockedObj(final BinaryOperator operator,
- final ExpressionKind leftOperandExpKind, final String propertyName, final String literalStr) {
- BinaryExpression binaryExpression = EasyMock.createMock(BinaryExpression.class);
- EasyMock.expect(binaryExpression.getKind()).andStubReturn(ExpressionKind.BINARY);
- EasyMock.expect(binaryExpression.getLeftOperand()).andStubReturn(
- getPropertyExpressionMockedObj(leftOperandExpKind, propertyName));
- EasyMock.expect(binaryExpression.getOperator()).andStubReturn(operator);
- EasyMock.expect(binaryExpression.getRightOperand()).andStubReturn(getLiteralExpressionMockedObj(literalStr));
-
- EasyMock.replay(binaryExpression);
- return binaryExpression;
- }
-
- private FilterExpression getFilterExpressionMockedObj(final ExpressionKind leftOperandExpKind,
- final String propertyName) {
- FilterExpression filterExpression = EasyMock.createMock(FilterExpression.class);
- EasyMock.expect(filterExpression.getKind()).andStubReturn(ExpressionKind.FILTER);
- EasyMock.expect(filterExpression.getExpression()).andStubReturn(
- getPropertyExpressionMockedObj(leftOperandExpKind, propertyName));
-
- EasyMock.replay(filterExpression);
- return filterExpression;
- }
-
- private FilterExpression getFilterExpressionForFunctionsMockedObj(final MethodOperator methodOperator1,
- final String firstName, final MethodOperator methodOperator2, final String secondName,
- final Integer parameterCount1, final Integer parameterCount2) {
- // default value handling of SUBSTRINGOF
- FilterExpression filterExpression = EasyMock.createMock(FilterExpression.class);
- EasyMock.expect(filterExpression.getKind()).andStubReturn(ExpressionKind.FILTER);
- if ((methodOperator2 != null) && (parameterCount2 != null)) {
- EasyMock.expect(filterExpression.getExpression()).andStubReturn(
- getMultipleMethodExpressionMockedObj(methodOperator1, firstName, methodOperator2, secondName,
- parameterCount1, parameterCount2));
- } else {
- EasyMock.expect(filterExpression.getExpression()).andStubReturn(
- getMethodExpressionMockedObj(methodOperator1, firstName, secondName, null, parameterCount1));
- }
-
- EasyMock.replay(filterExpression);
- return filterExpression;
- }
-
- private CommonExpression getBinaryExpression(final CommonExpression leftOperand, final BinaryOperator operator,
- final CommonExpression rightOperand) {
- BinaryExpression binaryExpression = EasyMock.createMock(BinaryExpression.class);
- EasyMock.expect(binaryExpression.getKind()).andStubReturn(ExpressionKind.BINARY);
- EasyMock.expect(binaryExpression.getLeftOperand()).andStubReturn(leftOperand);
- EasyMock.expect(binaryExpression.getRightOperand()).andStubReturn(rightOperand);
- EasyMock.expect(binaryExpression.getOperator()).andStubReturn(operator);
-
- EasyMock.replay(binaryExpression);
- return binaryExpression;
- }
-
- @Test
- public void testParseKeyPredicates() {
- // Setting up the expected value
- KeyPredicate keyPredicate1 = EasyMock.createMock(KeyPredicate.class);
- EdmProperty kpProperty1 = EasyMock.createMock(EdmProperty.class);
- EasyMock.expect(keyPredicate1.getLiteral()).andStubReturn("1");
- KeyPredicate keyPredicate2 = EasyMock.createMock(KeyPredicate.class);
- EdmProperty kpProperty2 = EasyMock.createMock(EdmProperty.class);
- EasyMock.expect(keyPredicate2.getLiteral()).andStubReturn("abc");
- EdmMapping edmMapping = EasyMock.createMock(EdmMapping.class);
- try {
- EasyMock.expect(kpProperty1.getName()).andStubReturn(SAMPLE_DATA_FIELD1);
- EasyMock.expect(kpProperty1.getType()).andStubReturn(EdmSimpleTypeKind.Int32.getEdmSimpleTypeInstance());
- EasyMock.expect(kpProperty2.getName()).andStubReturn(SAMPLE_DATA_FIELD2);
- EasyMock.expect(kpProperty2.getType()).andStubReturn(EdmSimpleTypeKind.String.getEdmSimpleTypeInstance());
- EasyMock.expect(keyPredicate1.getProperty()).andStubReturn(kpProperty1);
- EasyMock.expect(kpProperty1.getMapping()).andReturn(edmMapping);
- EasyMock.expect(edmMapping.getInternalName()).andReturn(SAMPLE_DATA_FIELD1);
- EasyMock.expect(keyPredicate2.getProperty()).andStubReturn(kpProperty2);
- EasyMock.expect(kpProperty2.getMapping()).andReturn(edmMapping);
- } catch (EdmException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
- EasyMock.expect(edmMapping.getInternalName()).andReturn(SAMPLE_DATA_FIELD2);
- EasyMock.replay(edmMapping);
- EasyMock.replay(kpProperty1, keyPredicate1, kpProperty2, keyPredicate2);
-
- ArrayList<KeyPredicate> keyPredicates = new ArrayList<KeyPredicate>();
- keyPredicates.add(keyPredicate1);
- keyPredicates.add(keyPredicate2);
- String str = null;
-
- try {
- str = ODataExpressionParser.parseKeyPredicates(keyPredicates, TABLE_ALIAS);
- } catch (ODataJPARuntimeException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
-
- assertEquals(EXPECTED_STR_8, str);
- }
-
- @Test
- public void testParseToJPASelectExpression() {
-
- ArrayList<String> selectedFields = new ArrayList<String>();
- selectedFields.add("BuyerAddress");
- selectedFields.add("BuyerName");
- selectedFields.add("BuyerId");
-
- assertEquals(EXPECTED_STR_9, ODataExpressionParser.parseToJPASelectExpression(TABLE_ALIAS, selectedFields));
- assertEquals(TABLE_ALIAS, ODataExpressionParser.parseToJPASelectExpression(TABLE_ALIAS, null));
-
- selectedFields.clear();
- assertEquals(TABLE_ALIAS, ODataExpressionParser.parseToJPASelectExpression(TABLE_ALIAS, selectedFields));
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/ODataJPAContextImplTest.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/ODataJPAContextImplTest.java b/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/ODataJPAContextImplTest.java
deleted file mode 100644
index 10e65c0..0000000
--- a/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/ODataJPAContextImplTest.java
+++ /dev/null
@@ -1,98 +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;
-
-import static org.junit.Assert.assertEquals;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Locale;
-
-import javax.persistence.EntityManager;
-import javax.persistence.EntityManagerFactory;
-
-import org.apache.olingo.odata2.api.edm.provider.EdmProvider;
-import org.apache.olingo.odata2.api.processor.ODataContext;
-import org.apache.olingo.odata2.api.processor.ODataProcessor;
-import org.apache.olingo.odata2.processor.api.jpa.ODataJPAContext;
-import org.apache.olingo.odata2.processor.core.jpa.edm.ODataJPAEdmProvider;
-import org.apache.olingo.odata2.processor.core.jpa.mock.ODataJPAContextMock;
-import org.easymock.EasyMock;
-import org.junit.Before;
-import org.junit.Test;
-
-public class ODataJPAContextImplTest {
-
- private ODataContext odataContext = null;
- private ODataJPAContext odataJPAContext = null;
- private EdmProvider edmProvider = null;
- private EntityManagerFactory emf = null;
- private EntityManager em = null;
- private ODataProcessor processor = null;
-
- @Before
- public void setup() {
-
- edmProvider = new ODataJPAEdmProvider();
- emf = EasyMock.createMock(EntityManagerFactory.class);
- em = EasyMock.createMock(EntityManager.class);
- EasyMock.replay(em);
-
- EasyMock.expect(emf.createEntityManager()).andStubReturn(em);
- EasyMock.replay(emf);
-
- odataContext = EasyMock.createMock(ODataContext.class);
- List<Locale> listLocale = new ArrayList<Locale>();
- listLocale.add(Locale.ENGLISH);
- listLocale.add(Locale.GERMAN);
-
- EasyMock.expect(odataContext.getAcceptableLanguages()).andStubReturn(listLocale);
- EasyMock.replay(odataContext);
-
- processor = EasyMock.createMock(ODataProcessor.class);
- EasyMock.replay(processor);
-
- odataJPAContext = new ODataJPAContextImpl();
- odataJPAContext.setEdmProvider(edmProvider);
- odataJPAContext.setEntityManagerFactory(emf);
- odataJPAContext.setODataContext(odataContext);
- odataJPAContext.setODataProcessor(processor);
- odataJPAContext.setPersistenceUnitName(ODataJPAContextMock.PERSISTENCE_UNIT_NAME);
- odataJPAContext.setJPAEdmMappingModel(ODataJPAContextMock.MAPPING_MODEL);
- }
-
- @Test
- public void testgetMethodsOfODataJPAContext() {
-
- assertEquals(odataJPAContext.getEdmProvider().hashCode(), edmProvider.hashCode());
- assertEquals(odataJPAContext.getEntityManagerFactory().hashCode(), emf.hashCode());
- assertEquals(odataJPAContext.getODataContext().hashCode(), odataContext.hashCode());
- assertEquals(odataJPAContext.getODataProcessor().hashCode(), processor.hashCode());
- assertEquals(odataJPAContext.getPersistenceUnitName(), ODataJPAContextMock.PERSISTENCE_UNIT_NAME);
- assertEquals(odataJPAContext.getJPAEdmMappingModel(), ODataJPAContextMock.MAPPING_MODEL);
-
- EntityManager em1 = odataJPAContext.getEntityManager();
- EntityManager em2 = odataJPAContext.getEntityManager();
- if (em1 != null && em2 != null) {
- assertEquals(em1.hashCode(), em2.hashCode());
- }
-
- }
-
-}
[21/37] [OLINGO-82] Renamed the project folder name to
odata2-jpa-processor
Posted by ch...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-ref/pom.xml
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-ref/pom.xml b/odata2-jpa-processor/jpa-ref/pom.xml
new file mode 100644
index 0000000..bdf3ee6
--- /dev/null
+++ b/odata2-jpa-processor/jpa-ref/pom.xml
@@ -0,0 +1,109 @@
+<?xml version="1.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.
+-->
+<project
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
+ xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.olingo</groupId>
+ <artifactId>olingo-odata2-jpa-processor-incubating</artifactId>
+ <version>1.1.0-SNAPSHOT</version>
+ <relativePath>..</relativePath>
+ </parent>
+
+ <artifactId>olingo-odata2-jpa-processor-ref-incubating</artifactId>
+ <packaging>jar</packaging>
+ <name>${project.artifactId}</name>
+
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-jar-plugin</artifactId>
+ <configuration>
+ <archive>
+ <manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
+ </archive>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <extensions>true</extensions>
+ <executions>
+ <execution>
+ <id>bundle-manifest</id>
+ <phase>process-classes</phase>
+ <goals>
+ <goal>manifest</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <instructions>
+ <Import-Package>
+ *
+ </Import-Package>
+ <Export-Package>
+ org.apache.olingo.odata2.jpa.processor.ref.factory;version=${project.version},
+ </Export-Package>
+ <Bundle-DocURL>${project.url}</Bundle-DocURL>
+ <Bundle-ActivationPolicy>lazy</Bundle-ActivationPolicy>
+ <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
+ </instructions>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+ <dependencies>
+ <!-- JPA Support -->
+ <dependency>
+ <groupId>org.eclipse.persistence</groupId>
+ <artifactId>eclipselink</artifactId>
+ <version>${version.eclipselink}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.persistence</groupId>
+ <artifactId>javax.persistence</artifactId>
+ <version>2.0.5</version>
+ </dependency>
+ <dependency>
+ <groupId>org.hsqldb</groupId>
+ <artifactId>hsqldb</artifactId>
+ <version>1.8.0.10</version>
+ </dependency>
+
+ <!-- OData Annotation Support -->
+ <dependency>
+ <groupId>org.apache.olingo</groupId>
+ <artifactId>olingo-odata2-api-annotation-incubating</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <!-- JUnits -->
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>3.8.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+</project>
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-ref/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/exception/InvalidPartyRoleException.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-ref/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/exception/InvalidPartyRoleException.java b/odata2-jpa-processor/jpa-ref/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/exception/InvalidPartyRoleException.java
new file mode 100644
index 0000000..3eb7d5a
--- /dev/null
+++ b/odata2-jpa-processor/jpa-ref/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/exception/InvalidPartyRoleException.java
@@ -0,0 +1,10 @@
+package org.apache.olingo.odata2.jpa.processor.ref.exception;
+
+public class InvalidPartyRoleException extends Exception {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-ref/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/factory/JPAEntityManagerFactory.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-ref/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/factory/JPAEntityManagerFactory.java b/odata2-jpa-processor/jpa-ref/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/factory/JPAEntityManagerFactory.java
new file mode 100644
index 0000000..1f4a7a8
--- /dev/null
+++ b/odata2-jpa-processor/jpa-ref/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/factory/JPAEntityManagerFactory.java
@@ -0,0 +1,46 @@
+/*******************************************************************************
+ * 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.factory;
+
+import java.util.HashMap;
+
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.Persistence;
+
+public class JPAEntityManagerFactory {
+ private static HashMap<String, EntityManagerFactory> emfMap;
+
+ public static EntityManagerFactory getEntityManagerFactory(final String pUnit) {
+ if (pUnit == null) {
+ return null;
+ }
+ if (emfMap == null) {
+ emfMap = new HashMap<String, EntityManagerFactory>();
+ }
+
+ if (emfMap.containsKey(pUnit)) {
+ return emfMap.get(pUnit);
+ } else {
+ EntityManagerFactory emf = Persistence.createEntityManagerFactory(pUnit);
+ emfMap.put(pUnit, emf);
+ return emf;
+ }
+
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-ref/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/model/Activity.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-ref/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/model/Activity.java b/odata2-jpa-processor/jpa-ref/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/model/Activity.java
new file mode 100644
index 0000000..c20e5b8
--- /dev/null
+++ b/odata2-jpa-processor/jpa-ref/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/model/Activity.java
@@ -0,0 +1,59 @@
+package org.apache.olingo.odata2.jpa.processor.ref.model;
+
+import java.util.Calendar;
+
+import javax.persistence.Column;
+import javax.persistence.Id;
+import javax.persistence.MappedSuperclass;
+import javax.persistence.Temporal;
+import javax.persistence.TemporalType;
+
+@MappedSuperclass
+public abstract class Activity {
+
+ @Column(name = "ACTIVITY_ID")
+ @Id
+ protected long id;
+
+ @Column
+ protected String subject;
+
+ @Temporal(TemporalType.TIMESTAMP)
+ protected Calendar creationDate;
+
+ @Column
+ protected String note;
+
+ public Calendar getCreationDate() {
+ return creationDate;
+ }
+
+ public void setCreationDate(final Calendar creationDate) {
+ this.creationDate = creationDate;
+ }
+
+ public String getNote() {
+ return note;
+ }
+
+ public void setNote(final String note) {
+ this.note = note;
+ }
+
+ public long getId() {
+ return id;
+ }
+
+ public void setId(final long id) {
+ this.id = id;
+ }
+
+ public String getSubject() {
+ return subject;
+ }
+
+ public void setSubject(final String subject) {
+ this.subject = subject;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-ref/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/model/ActivityParty.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-ref/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/model/ActivityParty.java b/odata2-jpa-processor/jpa-ref/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/model/ActivityParty.java
new file mode 100644
index 0000000..c92908c
--- /dev/null
+++ b/odata2-jpa-processor/jpa-ref/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/model/ActivityParty.java
@@ -0,0 +1,46 @@
+package org.apache.olingo.odata2.jpa.processor.ref.model;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+
+@Entity
+public class ActivityParty {
+
+ @Id
+ @Column(name = "PARTY_ID")
+ private long id;
+
+ @Column(name = "ACTIVITY_ID")
+ private long activityId;
+
+ @Column
+ private String name;
+ @Column
+ private short role;
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(final String name) {
+ this.name = name;
+ }
+
+ public short getRole() {
+ return role;
+ }
+
+ public void setRole(final short role) {
+ this.role = role;
+ }
+
+ public long getId() {
+ return id;
+ }
+
+ public void setId(final long id) {
+ this.id = id;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-ref/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/model/Address.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-ref/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/model/Address.java b/odata2-jpa-processor/jpa-ref/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/model/Address.java
new file mode 100644
index 0000000..a0aabcb
--- /dev/null
+++ b/odata2-jpa-processor/jpa-ref/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/model/Address.java
@@ -0,0 +1,83 @@
+/*******************************************************************************
+ * 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.model;
+
+import javax.persistence.Column;
+import javax.persistence.Embeddable;
+
+@Embeddable
+public class Address {
+
+ public Address() {
+ super();
+ }
+
+ public Address(final short houseNumber, final String streetName, final String city,
+ final String country) {
+ this();
+ this.houseNumber = houseNumber;
+ this.streetName = streetName;
+ this.city = city;
+ this.country = country;
+ }
+
+ @Column(name = "HOUSE_NUMBER")
+ private short houseNumber;
+
+ @Column(name = "STREET_NAME")
+ private String streetName;
+
+ @Column(name = "CITY")
+ private String city;
+
+ @Column(name = "COUNTRY")
+ private String country;
+
+ public short getHouseNumber() {
+ return houseNumber;
+ }
+
+ public void setHouseNumber(final short houseNumber) {
+ this.houseNumber = houseNumber;
+ }
+
+ public String getStreetName() {
+ return streetName;
+ }
+
+ public void setStreetName(final String streetName) {
+ this.streetName = streetName;
+ }
+
+ public String getCity() {
+ return city;
+ }
+
+ public void setCity(final String city) {
+ this.city = city;
+ }
+
+ public String getCountry() {
+ return country;
+ }
+
+ public void setCountry(final String country) {
+ this.country = country;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-ref/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/model/AppointmentActivity.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-ref/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/model/AppointmentActivity.java b/odata2-jpa-processor/jpa-ref/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/model/AppointmentActivity.java
new file mode 100644
index 0000000..aafedb2
--- /dev/null
+++ b/odata2-jpa-processor/jpa-ref/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/model/AppointmentActivity.java
@@ -0,0 +1,44 @@
+package org.apache.olingo.odata2.jpa.processor.ref.model;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.persistence.CascadeType;
+import javax.persistence.Entity;
+import javax.persistence.OneToMany;
+import javax.persistence.PrePersist;
+
+import org.apache.olingo.odata2.jpa.processor.ref.exception.InvalidPartyRoleException;
+
+@Entity
+public class AppointmentActivity extends Activity {
+
+ @OneToMany(cascade = CascadeType.ALL)
+ private List<ActivityParty> parties = new ArrayList<ActivityParty>();
+
+ public List<ActivityParty> getParties() {
+ return parties;
+ }
+
+ public void setParties(final List<ActivityParty> parties) {
+ this.parties = parties;
+ }
+
+ @PrePersist
+ public void validatePartyRoles() throws InvalidPartyRoleException {
+ boolean maxOrganizer = false;
+ for (ActivityParty party : getParties()) {
+ Short role = party.getRole();
+ if (role != PartyRole.ATTENDEE.ordinal() ||
+ role != PartyRole.ORGANIZER.ordinal()) {
+ throw new InvalidPartyRoleException();
+ }
+ if (role == PartyRole.ORGANIZER.ordinal() && maxOrganizer == false) {
+ maxOrganizer = true;
+ } else if (role == PartyRole.ORGANIZER.ordinal() && maxOrganizer == true) {
+ throw new InvalidPartyRoleException();
+ }
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-ref/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/model/EmailActivity.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-ref/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/model/EmailActivity.java b/odata2-jpa-processor/jpa-ref/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/model/EmailActivity.java
new file mode 100644
index 0000000..521d124
--- /dev/null
+++ b/odata2-jpa-processor/jpa-ref/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/model/EmailActivity.java
@@ -0,0 +1,46 @@
+package org.apache.olingo.odata2.jpa.processor.ref.model;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.persistence.CascadeType;
+import javax.persistence.Entity;
+import javax.persistence.OneToMany;
+import javax.persistence.PrePersist;
+
+import org.apache.olingo.odata2.jpa.processor.ref.exception.InvalidPartyRoleException;
+
+@Entity
+public class EmailActivity extends Activity {
+
+ @OneToMany(cascade = CascadeType.ALL)
+ private List<ActivityParty> parties = new ArrayList<ActivityParty>();
+
+ public List<ActivityParty> getParties() {
+ return parties;
+ }
+
+ public void setParties(final List<ActivityParty> parties) {
+ this.parties = parties;
+ }
+
+ @PrePersist
+ public void validatePartyRoles() throws InvalidPartyRoleException {
+ boolean maxFrom = false;
+ for (ActivityParty party : getParties()) {
+ Short role = party.getRole();
+ if (role != PartyRole.FROM.ordinal() ||
+ role != PartyRole.TO.ordinal() ||
+ role != PartyRole.CC.ordinal() ||
+ role != PartyRole.BCC.ordinal()) {
+ throw new InvalidPartyRoleException();
+ }
+ if (role == PartyRole.FROM.ordinal() && maxFrom == false) {
+ maxFrom = true;
+ } else if (role == PartyRole.FROM.ordinal() && maxFrom == true) {
+ throw new InvalidPartyRoleException();
+ }
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-ref/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/model/Material.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-ref/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/model/Material.java b/odata2-jpa-processor/jpa-ref/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/model/Material.java
new file mode 100644
index 0000000..6f08119
--- /dev/null
+++ b/odata2-jpa-processor/jpa-ref/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/model/Material.java
@@ -0,0 +1,116 @@
+/*******************************************************************************
+ * 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.model;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.ManyToMany;
+import javax.persistence.Table;
+
+@Entity
+@Table(name = "T_MATERIAL")
+public class Material {
+
+ public Material() {}
+
+ public Material(final String materialName, final String typeCode, final double price,
+ final String measurementUnit) {
+ super();
+ this.materialName = materialName;
+ this.typeCode = typeCode;
+ this.price = price;
+ this.measurementUnit = measurementUnit;
+ }
+
+ @Id
+ @Column(name = "MATERIAL_ID")
+ private long materialId;
+
+ @Column(name = "MATERIAL_NAME")
+ private String materialName;
+
+ @Column(name = "TYPE_CODE")
+ private String typeCode;
+
+ @Column(name = "PRICE")
+ private double price;
+
+ @Column(name = "MEASUREMENT_UNIT")
+ private String measurementUnit;
+
+ @ManyToMany
+ private List<Store> stores = new ArrayList<Store>();
+
+ public long getMaterialId() {
+ return materialId;
+ }
+
+ public void setMaterialId(final long materialId) {
+ this.materialId = materialId;
+ }
+
+ public String getMaterialName() {
+ return materialName;
+ }
+
+ public void setMaterialName(final String materialName) {
+ this.materialName = materialName;
+ }
+
+ public String getTypeCode() {
+ return typeCode;
+ }
+
+ public void setTypeCode(final String typeCode) {
+ this.typeCode = typeCode;
+ }
+
+ public double getPrice() {
+ return price;
+ }
+
+ public void setPrice(final double price) {
+ this.price = price;
+ }
+
+ public String getMeasurementUnit() {
+ return measurementUnit;
+ }
+
+ public void setMeasurementUnit(final String measurementUnit) {
+ this.measurementUnit = measurementUnit;
+ }
+
+ public List<Store> getStores() {
+ return stores;
+ }
+
+ public void setStores(final List<Store> stores) {
+ this.stores = stores;
+ Iterator<Store> itr = stores.iterator();
+ while (itr.hasNext()) {
+ itr.next().getMaterials().add(this);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-ref/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/model/Note.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-ref/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/model/Note.java b/odata2-jpa-processor/jpa-ref/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/model/Note.java
new file mode 100644
index 0000000..4a93509
--- /dev/null
+++ b/odata2-jpa-processor/jpa-ref/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/model/Note.java
@@ -0,0 +1,116 @@
+/*******************************************************************************
+ * 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.model;
+
+import java.util.Calendar;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+import javax.persistence.Table;
+import javax.persistence.Temporal;
+import javax.persistence.TemporalType;
+
+@Entity
+@Table(name = "T_NOTE")
+public class Note {
+
+ public Note() {}
+
+ public Note(final Calendar creationTime, final Calendar creationDate, final String createdBy,
+ final String text) {
+ super();
+ this.creationTime = creationTime;
+ this.creationDate = creationDate;
+ this.createdBy = createdBy;
+ this.text = text;
+ }
+
+ @Id
+ @Temporal(TemporalType.TIME)
+ private Calendar creationTime;
+
+ @Id
+ @Temporal(TemporalType.DATE)
+ private Calendar creationDate;
+
+ @Id
+ private String createdBy;
+
+ @Column
+ private String text;
+
+ @Column(name = "SO_ID")
+ private long soId;
+
+ @JoinColumn(name = "SO_ID", referencedColumnName = "SO_ID", insertable = false, updatable = false)
+ @ManyToOne
+ private SalesOrderHeader salesOrderHeader;
+
+ public Calendar getCreationTime() {
+ return creationTime;
+ }
+
+ public void setCreationTime(final Calendar creationTime) {
+ this.creationTime = creationTime;
+ }
+
+ public Calendar getCreationDate() {
+ return creationDate;
+ }
+
+ public void setCreationDate(final Calendar creationDate) {
+ this.creationDate = creationDate;
+ }
+
+ public String getCreatedBy() {
+ return createdBy;
+ }
+
+ public void setCreatedBy(final String createdBy) {
+ this.createdBy = createdBy;
+ }
+
+ public String getText() {
+ return text;
+ }
+
+ public void setText(final String text) {
+ this.text = text;
+ }
+
+ public long getSoId() {
+ return soId;
+ }
+
+ public void setSoId(final long soId) {
+ this.soId = soId;
+ }
+
+ public SalesOrderHeader getSalesOrderHeader() {
+ return salesOrderHeader;
+ }
+
+ public void setSalesOrderHeader(final SalesOrderHeader salesOrderHeader) {
+ this.salesOrderHeader = salesOrderHeader;
+ this.salesOrderHeader.getNotes().add(this);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-ref/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/model/PartyRole.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-ref/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/model/PartyRole.java b/odata2-jpa-processor/jpa-ref/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/model/PartyRole.java
new file mode 100644
index 0000000..c1adaf9
--- /dev/null
+++ b/odata2-jpa-processor/jpa-ref/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/model/PartyRole.java
@@ -0,0 +1,5 @@
+package org.apache.olingo.odata2.jpa.processor.ref.model;
+
+public enum PartyRole {
+ FROM, TO, CC, BCC, ORGANIZER, ATTENDEE
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-ref/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/model/SalesOrderHeader.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-ref/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/model/SalesOrderHeader.java b/odata2-jpa-processor/jpa-ref/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/model/SalesOrderHeader.java
new file mode 100644
index 0000000..9af23f3
--- /dev/null
+++ b/odata2-jpa-processor/jpa-ref/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/model/SalesOrderHeader.java
@@ -0,0 +1,236 @@
+/*******************************************************************************
+ * 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.model;
+
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.TimeZone;
+
+import javax.persistence.CascadeType;
+import javax.persistence.Column;
+import javax.persistence.Embedded;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.OneToMany;
+import javax.persistence.PostPersist;
+import javax.persistence.Table;
+import javax.persistence.Temporal;
+import javax.persistence.TemporalType;
+
+@Entity
+@Table(name = "T_SALESORDERHEADER")
+public class SalesOrderHeader {
+
+ public SalesOrderHeader() {}
+
+ public SalesOrderHeader(final Calendar creationDate, final int buyerId, final String buyerName,
+ final Address buyerAddress, final String currencyCode, final double netAmount,
+ final String deliveryStatus, final char[] shortText, final Character[] longText) {
+ super();
+ this.creationDate = creationDate;
+ this.buyerId = buyerId;
+ this.buyerName = buyerName;
+ this.buyerAddress = buyerAddress;
+ this.currencyCode = currencyCode;
+ this.deliveryStatus = deliveryStatus;
+ this.shortText = shortText;
+ this.longText = longText;
+ }
+
+ @Id
+ @Column(name = "SO_ID")
+ private long soId;
+
+ @Temporal(TemporalType.TIMESTAMP)
+ private Calendar creationDate;
+
+ @Column
+ private Character status;
+
+ public Character getStatus() {
+ return status;
+ }
+
+ public void setStatus(final Character status) {
+ this.status = status;
+ }
+
+ @Column(name = "SHORT_TEXT", length = 20)
+ private char[] shortText;
+
+ @Column(name = "LONG_TEXT", length = 40)
+ private Character[] longText;
+
+ @Column(name = "BUYER_ID")
+ private int buyerId;
+
+ @Column(name = "BUYER_NAME", length = 255)
+ private String buyerName;
+
+ @Embedded
+ private Address buyerAddress;
+
+ @Column(name = "CURRENCY_CODE", length = 3)
+ private String currencyCode;
+
+ @Column(name = "DELIVERY_STATUS", length = 2)
+ private String deliveryStatus;
+
+ @Column(precision = 5)
+ private double grossAmount;
+
+ @Column(precision = 8)
+ private double netAmount;
+
+ @OneToMany(mappedBy = "salesOrderHeader", cascade = CascadeType.ALL)
+ private Set<SalesOrderItem> salesOrderItem = new HashSet<SalesOrderItem>();
+
+ @OneToMany(mappedBy = "salesOrderHeader", cascade = CascadeType.ALL)
+ private List<Note> notes = new ArrayList<Note>();
+
+ public long getSoId() {
+ return soId;
+ }
+
+ public void setSoId(final long soId) {
+ this.soId = soId;
+ }
+
+ public Date getCreationDate() {
+ if (creationDate == null) {
+ return null;
+ }
+ long dbTime = creationDate.getTime().getTime();
+ Date originalDate = new Date(dbTime + TimeZone.getDefault().getOffset(dbTime));
+ return originalDate;
+ }
+
+ public void setCreationDate(final Calendar creationDate) {
+ long originalTime;
+ if (creationDate != null) {
+ originalTime = creationDate.getTime().getTime();
+ } else {
+ originalTime = Calendar.getInstance(TimeZone.getDefault()).getTime().getTime();
+ }
+ Date newDate = new Date(originalTime - TimeZone.getDefault().getOffset(originalTime));
+ Calendar newCalendar = Calendar.getInstance();
+ newCalendar.setTime(newDate);
+ this.creationDate = newCalendar;
+ }
+
+ public int getBuyerId() {
+ return buyerId;
+ }
+
+ public void setBuyerId(final int buyerId) {
+ this.buyerId = buyerId;
+ }
+
+ public String getBuyerName() {
+ return buyerName;
+ }
+
+ public void setBuyerName(final String buyerName) {
+ this.buyerName = buyerName;
+ }
+
+ public Address getBuyerAddress() {
+ return buyerAddress;
+ }
+
+ public void setBuyerAddress(final Address buyerAddress) {
+ this.buyerAddress = buyerAddress;
+ }
+
+ public String getCurrencyCode() {
+ return currencyCode;
+ }
+
+ public void setCurrencyCode(final String currencyCode) {
+ this.currencyCode = currencyCode;
+ }
+
+ public String getDeliveryStatus() {
+ return deliveryStatus;
+ }
+
+ public void setDeliveryStatus(final String deliveryStatus) {
+ this.deliveryStatus = deliveryStatus;
+ }
+
+ public double getGrossAmount() {
+ return grossAmount;
+ }
+
+ public void setGrossAmount(final double grossAmount) {
+ this.grossAmount = grossAmount;
+ }
+
+ public double getNetAmount() {
+ return netAmount;
+ }
+
+ public void setNetAmount(final double netAmount) {
+ this.netAmount = netAmount;
+ }
+
+ public Set<SalesOrderItem> getSalesOrderItem() {
+ return salesOrderItem;
+ }
+
+ public void setSalesOrderItem(final Set<SalesOrderItem> salesOrderItem) {
+ this.salesOrderItem = salesOrderItem;
+ }
+
+ public List<Note> getNotes() {
+ return notes;
+ }
+
+ public void setNotes(final List<Note> notes) {
+ this.notes = notes;
+ }
+
+ public char[] getShortText() {
+ return shortText;
+ }
+
+ public void setShortText(final char[] shortText) {
+ this.shortText = shortText;
+ }
+
+ public Character[] getLongText() {
+ return longText;
+ }
+
+ public void setLongText(final Character[] longText) {
+ this.longText = longText;
+ }
+
+ @PostPersist
+ public void defaultValues() {
+ if (creationDate == null) {
+ setCreationDate(creationDate);
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-ref/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/model/SalesOrderItem.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-ref/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/model/SalesOrderItem.java b/odata2-jpa-processor/jpa-ref/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/model/SalesOrderItem.java
new file mode 100644
index 0000000..fa20b47
--- /dev/null
+++ b/odata2-jpa-processor/jpa-ref/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/model/SalesOrderItem.java
@@ -0,0 +1,133 @@
+/*******************************************************************************
+ * 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.model;
+
+import javax.persistence.Column;
+import javax.persistence.EmbeddedId;
+import javax.persistence.Entity;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+import javax.persistence.Table;
+import javax.persistence.Transient;
+
+@Entity
+@Table(name = "T_SALESORDERITEM")
+public class SalesOrderItem {
+
+ public SalesOrderItem() {}
+
+ public SalesOrderItem(final int quantity, final double amount, final double discount,
+ final Material material) {
+ super();
+ this.quantity = quantity;
+ this.amount = amount;
+ this.discount = discount;
+ this.material = material;
+ }
+
+ @EmbeddedId
+ private SalesOrderItemKey salesOrderItemKey;
+
+ @Column(name = "Material_Id", nullable = false)
+ private long matId;
+
+ @Column
+ private int quantity;
+
+ @Column
+ private double amount;
+
+ @Column
+ private double discount;
+
+ @Transient
+ private double netAmount;
+
+ @JoinColumn(name = "Material_Id", referencedColumnName = "MATERIAL_ID", insertable = false, updatable = false)
+ @ManyToOne
+ private Material material;
+
+ @JoinColumn(name = "Sales_Order_Id", referencedColumnName = "SO_ID", insertable = false, updatable = false)
+ @ManyToOne
+ private SalesOrderHeader salesOrderHeader;
+
+ public SalesOrderItemKey getSalesOrderItemKey() {
+ return salesOrderItemKey;
+ }
+
+ public void setSalesOrderItemKey(final SalesOrderItemKey salesOrderItemKey) {
+ this.salesOrderItemKey = salesOrderItemKey;
+ }
+
+ public long getMatId() {
+ return matId;
+ }
+
+ public void setMatId(final long matId) {
+ this.matId = matId;
+ }
+
+ public int getQuantity() {
+ return quantity;
+ }
+
+ public void setQuantity(final int quantity) {
+ this.quantity = quantity;
+ }
+
+ public double getAmount() {
+ return amount;
+ }
+
+ public void setAmount(final double amount) {
+ this.amount = amount;
+ }
+
+ public double getDiscount() {
+ return discount;
+ }
+
+ public void setDiscount(final double discount) {
+ this.discount = discount;
+ }
+
+ public double getNetAmount() {
+ return netAmount;
+ }
+
+ public void setNetAmount(final double netAmount) {
+ this.netAmount = netAmount;
+ }
+
+ public Material getMaterial() {
+ return material;
+ }
+
+ public void setMaterial(final Material material) {
+ this.material = material;
+ }
+
+ public SalesOrderHeader getSalesOrderHeader() {
+ return salesOrderHeader;
+ }
+
+ public void setSalesOrderHeader(final SalesOrderHeader salesOrderHeader) {
+ this.salesOrderHeader = salesOrderHeader;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-ref/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/model/SalesOrderItemKey.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-ref/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/model/SalesOrderItemKey.java b/odata2-jpa-processor/jpa-ref/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/model/SalesOrderItemKey.java
new file mode 100644
index 0000000..efc09d2
--- /dev/null
+++ b/odata2-jpa-processor/jpa-ref/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/model/SalesOrderItemKey.java
@@ -0,0 +1,89 @@
+/*******************************************************************************
+ * 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.model;
+
+import java.io.Serializable;
+
+import javax.persistence.Column;
+import javax.persistence.Embeddable;
+
+@Embeddable
+public class SalesOrderItemKey implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ public SalesOrderItemKey() {}
+
+ public SalesOrderItemKey(final long liId) {
+ super();
+ this.liId = liId;
+ }
+
+ @Column(name = "Sales_Order_Id", nullable = false)
+ private long soId;
+
+ @Column(name = "Sales_Order_Item_Id", unique = true)
+ private long liId;
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + (int) (liId ^ (liId >>> 32));
+ result = prime * result + (int) (soId ^ (soId >>> 32));
+ return result;
+ }
+
+ @Override
+ public boolean equals(final Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ SalesOrderItemKey other = (SalesOrderItemKey) obj;
+ if (liId != other.liId) {
+ return false;
+ }
+ if (soId != other.soId) {
+ return false;
+ }
+ return true;
+ }
+
+ public long getSoId() {
+ return soId;
+ }
+
+ public void setSoId(final long soId) {
+ this.soId = soId;
+ }
+
+ public long getLiId() {
+ return liId;
+ }
+
+ public void setLiId(final long liId) {
+ this.liId = liId;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-ref/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/model/Store.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-ref/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/model/Store.java b/odata2-jpa-processor/jpa-ref/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/model/Store.java
new file mode 100644
index 0000000..b88bc3a
--- /dev/null
+++ b/odata2-jpa-processor/jpa-ref/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/model/Store.java
@@ -0,0 +1,92 @@
+/*******************************************************************************
+ * 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.model;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.persistence.Column;
+import javax.persistence.Embedded;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.ManyToMany;
+import javax.persistence.Table;
+
+@Entity
+@Table(name = "T_STORE")
+public class Store {
+
+ public Store() {}
+
+ public Store(final String storeName, final Address storeAddress) {
+ super();
+ this.storeName = storeName;
+ this.storeAddress = storeAddress;
+ }
+
+ @Id
+ @Column(name = "STORE_ID")
+ private long storeId;
+
+ @Column(name = "STORE_NAME", unique = true)
+ private String storeName;
+
+ @Embedded
+ private Address storeAddress;
+
+ @ManyToMany(mappedBy = "stores")
+ private List<Material> materials = new ArrayList<Material>();
+
+ public long getStoreId() {
+ return storeId;
+ }
+
+ public void setStoreId(final long storeId) {
+ this.storeId = storeId;
+ }
+
+ public String getStoreName() {
+ return storeName;
+ }
+
+ public void setStoreName(final String storeName) {
+ this.storeName = storeName;
+ }
+
+ public Address getStoreAddress() {
+ return storeAddress;
+ }
+
+ public void setStoreAddress(final Address storeAddress) {
+ this.storeAddress = storeAddress;
+ }
+
+ public List<Material> getMaterials() {
+ return materials;
+ }
+
+ public void setMaterials(final List<Material> materials) {
+ this.materials = materials;
+ Iterator<Material> itr = materials.iterator();
+ while (itr.hasNext()) {
+ itr.next().getStores().add(this);
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-ref/src/main/resources/META-INF/persistence.xml
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-ref/src/main/resources/META-INF/persistence.xml b/odata2-jpa-processor/jpa-ref/src/main/resources/META-INF/persistence.xml
new file mode 100644
index 0000000..d85fa46
--- /dev/null
+++ b/odata2-jpa-processor/jpa-ref/src/main/resources/META-INF/persistence.xml
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- 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. -->
+<persistence version="2.0"
+ xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
+ <persistence-unit name="salesorderprocessing"
+ transaction-type="RESOURCE_LOCAL">
+ <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
+ <class>org.apache.olingo.odata2.jpa.processor.ref.model.SalesOrderHeader</class>
+ <class>org.apache.olingo.odata2.jpa.processor.ref.model.SalesOrderItem</class>
+ <class>org.apache.olingo.odata2.jpa.processor.ref.model.Note</class>
+ <class>org.apache.olingo.odata2.jpa.processor.ref.model.Material</class>
+ <class>org.apache.olingo.odata2.jpa.processor.ref.model.Store</class>
+ <class>org.apache.olingo.odata2.jpa.processor.ref.model.EmailActivity</class>
+ <class>org.apache.olingo.odata2.jpa.processor.ref.model.ActivityParty</class>
+ <class>org.apache.olingo.odata2.jpa.processor.ref.model.AppointmentActivity</class>
+ <properties>
+ <property name="javax.persistence.jdbc.driver" value="org.hsqldb.jdbcDriver" />
+ <property name="javax.persistence.jdbc.url"
+ value="jdbc:hsqldb:mem:org.apache.olingo.jpa.sample" />
+ <property name="javax.persistence.jdbc.user" value="sa" />
+ <property name="javax.persistence.jdbc.password" value="" />
+ <property name="eclipselink.target-database"
+ value="org.eclipse.persistence.platform.database.HSQLPlatform" />
+ <property name="eclipselink.logging.level" value="ALL" />
+ <property name="eclipselink.orm.throw.exceptions" value="true" />
+ <property name="eclipselink.ddl-generation" value="create-tables" />
+ <property name="eclipselink.ddl-generation.output-mode"
+ value="database" />
+ </properties>
+ </persistence-unit>
+</persistence>
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-web/.gitignore
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-web/.gitignore b/odata2-jpa-processor/jpa-web/.gitignore
new file mode 100644
index 0000000..fe5d89b
--- /dev/null
+++ b/odata2-jpa-processor/jpa-web/.gitignore
@@ -0,0 +1,8 @@
+.project
+.classpath
+.settings
+target
+bin
+*.bak
+classes
+.DS_Store
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-web/pom.xml
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-web/pom.xml b/odata2-jpa-processor/jpa-web/pom.xml
new file mode 100644
index 0000000..18302cb
--- /dev/null
+++ b/odata2-jpa-processor/jpa-web/pom.xml
@@ -0,0 +1,123 @@
+<?xml version="1.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. -->
+<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
+ xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <modelVersion>4.0.0</modelVersion>
+
+ <artifactId>olingo-odata2-jpa-processor-ref-web-incubating</artifactId>
+ <packaging>war</packaging>
+ <name>${project.artifactId}</name>
+
+ <parent>
+ <groupId>org.apache.olingo</groupId>
+ <artifactId>olingo-odata2-jpa-processor-incubating</artifactId>
+ <version>1.1.0-SNAPSHOT</version>
+ <relativePath>..</relativePath>
+ </parent>
+
+ <build>
+ <resources>
+ <resource>
+ <directory>src/main/version</directory>
+ <filtering>true</filtering>
+ <targetPath>../${project.build.finalName}/gen</targetPath>
+ </resource>
+ <resource>
+ <directory>src/main/resources</directory>
+ <filtering>true</filtering>
+ </resource>
+ </resources>
+
+ <pluginManagement>
+ <plugins>
+ <plugin>
+ <groupId>com.sap.research</groupId>
+ <artifactId>nwcloud-maven-plugin</artifactId>
+ <version>1.0.0.RELEASE</version>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-deploy-plugin</artifactId>
+ <configuration>
+ <skip>true</skip>
+ </configuration>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+
+ </build>
+
+ <dependencies>
+ <dependency>
+ <!-- required because of auto detection of web facet 2.5 -->
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <version>2.5</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-rt-frontend-jaxrs</artifactId>
+ <version>${cxf.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.olingo</groupId>
+ <artifactId>olingo-odata2-core-incubating</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.olingo</groupId>
+ <artifactId>olingo-odata2-api-incubating</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.olingo</groupId>
+ <artifactId>olingo-odata2-jpa-processor-api-incubating</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.olingo</groupId>
+ <artifactId>olingo-odata2-jpa-processor-core-incubating</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.olingo</groupId>
+ <artifactId>olingo-odata2-jpa-processor-ref-incubating</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ <version>1.7.1</version>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>3.8.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <profiles>
+ <profile>
+ <id>dev</id>
+ <build>
+ <defaultGoal>cargo:run</defaultGoal>
+
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.cargo</groupId>
+ <artifactId>cargo-maven2-plugin</artifactId>
+ <version>1.4.2</version>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
+</project>
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-web/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/extension/SalesOrderHeaderProcessor.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-web/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/extension/SalesOrderHeaderProcessor.java b/odata2-jpa-processor/jpa-web/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/extension/SalesOrderHeaderProcessor.java
new file mode 100644
index 0000000..0ff659b
--- /dev/null
+++ b/odata2-jpa-processor/jpa-web/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/extension/SalesOrderHeaderProcessor.java
@@ -0,0 +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.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/1b479e6c/odata2-jpa-processor/jpa-web/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/extension/SalesOrderProcessingExtension.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-web/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/extension/SalesOrderProcessingExtension.java b/odata2-jpa-processor/jpa-web/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/extension/SalesOrderProcessingExtension.java
new file mode 100644
index 0000000..6b82899
--- /dev/null
+++ b/odata2-jpa-processor/jpa-web/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/extension/SalesOrderProcessingExtension.java
@@ -0,0 +1,38 @@
+/*******************************************************************************
+ * 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 org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmExtension;
+import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmSchemaView;
+
+public class SalesOrderProcessingExtension implements JPAEdmExtension {
+
+ @Override
+ public void extendJPAEdmSchema(final JPAEdmSchemaView arg0) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void extendWithOperation(final JPAEdmSchemaView view) {
+ view.registerOperations(SalesOrderHeaderProcessor.class, null);
+
+ }
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-web/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/extension/_SalesOrderHeaderProcessor.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-web/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/extension/_SalesOrderHeaderProcessor.java b/odata2-jpa-processor/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-jpa-processor/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;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-web/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/util/DataGenerator.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-web/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/util/DataGenerator.java b/odata2-jpa-processor/jpa-web/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/util/DataGenerator.java
new file mode 100644
index 0000000..55eb876
--- /dev/null
+++ b/odata2-jpa-processor/jpa-web/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/util/DataGenerator.java
@@ -0,0 +1,158 @@
+/*******************************************************************************
+ * 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.util;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.ResourceBundle;
+import java.util.Set;
+
+import javax.persistence.EntityManager;
+import javax.persistence.Query;
+
+import org.apache.olingo.odata2.jpa.processor.ref.model.Material;
+import org.apache.olingo.odata2.jpa.processor.ref.model.Store;
+import org.eclipse.persistence.internal.jpa.EntityManagerImpl;
+import org.eclipse.persistence.queries.DataModifyQuery;
+import org.eclipse.persistence.queries.SQLCall;
+import org.eclipse.persistence.sessions.Session;
+
+/**
+ * This is a utility class for generating and cleaning data. The generated data would be used by the application.
+ *
+ *
+ */
+public class DataGenerator {
+
+ private EntityManager entityManager;
+
+ /**
+ * This is configuration property to hold comma separated names of Insert Files
+ */
+ private static final String SQL_INSERT_CONFIG = "SQLInsertConfig";
+
+ /**
+ * This is key which will be used to fetch file names from SQL Insert Config File.
+ */
+ private static final String SQL_INSERT_FILE_NAMES_KEY = "insert_file_names";
+
+ private static final String SQL_DELETE_CONFIG = "DataDeleteSQLs";
+ private static final String SQL_DELETE_STATEMENTS_KEY = "delete_queries";
+
+ public DataGenerator(final EntityManager entityManager) {
+ this.entityManager = entityManager;
+ }
+
+ /**
+ * This method generates data to be used in the application. It does so by
+ * reading properties file. Currently it iterates through comma separated
+ * file names in file SQLInsertConfig and gets the insert statements from
+ * those files in the order provided in the file.
+ */
+ public void generate() {
+ String[] resourceSQLPropFileNames = getSQLInsertFileNames();
+ if (resourceSQLPropFileNames.length > 0) { // If configuration is proper with at least one file
+ Session session = ((EntityManagerImpl) entityManager).getActiveSession();
+ ResourceBundle[] resourceBundleArr = new ResourceBundle[resourceSQLPropFileNames.length];
+ entityManager.getTransaction().begin();
+
+ for (int i = 0; i < resourceSQLPropFileNames.length; i++) { // For each Entity SQL property file,
+ System.out.println("Reading from File - " + resourceSQLPropFileNames[i]);
+ resourceBundleArr[i] = ResourceBundle.getBundle(resourceSQLPropFileNames[i]);// Get SQL statements as properties
+
+ Set<String> keySet = resourceBundleArr[i].keySet();
+
+ for (String string : keySet) {
+ String currentSQL = (String) string;
+ String sqlQuery = resourceBundleArr[i].getString(currentSQL);
+ System.out.println("Executing Query - " + sqlQuery);
+ SQLCall sqlCall = new SQLCall(sqlQuery);
+
+ DataModifyQuery query = new DataModifyQuery();
+ query.setCall(sqlCall);
+ session.executeQuery(query);
+ }
+ }
+ setMaterialInStore();
+ entityManager.flush();
+ entityManager.getTransaction().commit();
+ }
+
+ }
+
+ @SuppressWarnings("unchecked")
+ private void setMaterialInStore() {
+ Query query = entityManager.createQuery("SELECT e FROM Material e");
+ List<Material> materials = (List<Material>) query.getResultList();
+
+ query = entityManager.createQuery("SELECT e FROM Store e");
+ List<Store> stores = (List<Store>) query.getResultList();
+
+ int storeSize = stores.size();
+ int i = 0;
+ for (Material material : materials) {
+ List<Store> storesA = Arrays.asList(stores.get(i), stores.get(i + 1));
+ material.setStores(storesA);
+ i++;
+ if (i > storeSize - 2) {
+ i = 0;
+ }
+ entityManager.persist(material);
+ }
+ entityManager.flush();
+ }
+
+ private String[] getSQLInsertFileNames() {
+ ResourceBundle resourceBundle = ResourceBundle.getBundle(SQL_INSERT_CONFIG);// File names from properties
+ String namesStr = resourceBundle.getString(SQL_INSERT_FILE_NAMES_KEY);
+ return namesStr.split(",");
+ }
+
+ private String[] getSQLDeleteStatements() {
+ ResourceBundle resourceBundle = ResourceBundle.getBundle(SQL_DELETE_CONFIG);// File names from properties
+ String deleteStatements = resourceBundle.getString(SQL_DELETE_STATEMENTS_KEY);
+ return deleteStatements.split(",");
+ }
+
+ /**
+ * This method deletes data from JPA tables created. This method reads comma
+ * separated SQL delete statements from DataDeleteSQLs properties files and
+ * executes them in order.
+ */
+ public void clean() {
+ // Delete using SQLs
+ String[] deleteStatements = getSQLDeleteStatements();
+ if (deleteStatements.length > 0) { // If configuration is proper with at least one delete Statements
+ Session session = ((EntityManagerImpl) entityManager).getActiveSession();
+ entityManager.getTransaction().begin();
+ for (String deleteStatement : deleteStatements) {
+ System.out.println("Cleaning - " + deleteStatement);
+ SQLCall sqlCall = new SQLCall(deleteStatement);
+
+ DataModifyQuery query = new DataModifyQuery();
+ query.setCall(sqlCall);
+ session.executeQuery(query);
+ }
+ entityManager.getTransaction().commit();
+ } else {
+ System.err.println("Delete configuration file doesn't have any delete statements.");
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-web/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/web/JPAReferenceServiceFactory.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-web/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/web/JPAReferenceServiceFactory.java b/odata2-jpa-processor/jpa-web/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/web/JPAReferenceServiceFactory.java
new file mode 100644
index 0000000..fe4e618
--- /dev/null
+++ b/odata2-jpa-processor/jpa-web/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/web/JPAReferenceServiceFactory.java
@@ -0,0 +1,56 @@
+/*******************************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ ******************************************************************************/
+package org.apache.olingo.odata2.jpa.processor.ref.web;
+
+import java.util.ResourceBundle;
+
+import org.apache.olingo.odata2.jpa.processor.ref.extension.SalesOrderProcessingExtension;
+import org.apache.olingo.odata2.jpa.processor.ref.factory.JPAEntityManagerFactory;
+import org.apache.olingo.odata2.processor.api.jpa.ODataJPAContext;
+import org.apache.olingo.odata2.processor.api.jpa.ODataJPAServiceFactory;
+import org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPARuntimeException;
+import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmExtension;
+
+public class JPAReferenceServiceFactory extends ODataJPAServiceFactory {
+ private static final String PUNIT_NAME = "salesorderprocessing";
+ private static final String MAPPING_MODEL = "SalesOrderProcessingMappingModel.xml";
+ private static final String CONFIG = "serviceConfig";
+ private static final String SHOW_DETAIL_ERROR = "showDetailError";
+
+ @Override
+ public ODataJPAContext initializeODataJPAContext()
+ throws ODataJPARuntimeException {
+ ODataJPAContext oDataJPAContext = getODataJPAContext();
+ oDataJPAContext.setEntityManagerFactory(JPAEntityManagerFactory.getEntityManagerFactory(PUNIT_NAME));
+ oDataJPAContext.setPersistenceUnitName(PUNIT_NAME);
+ oDataJPAContext.setJPAEdmMappingModel(MAPPING_MODEL);
+ oDataJPAContext
+ .setJPAEdmExtension((JPAEdmExtension) new SalesOrderProcessingExtension());
+
+ setErrorLevel();
+
+ return oDataJPAContext;
+ }
+
+ private void setErrorLevel() {
+ ResourceBundle config = ResourceBundle.getBundle(CONFIG);
+ boolean error = Boolean.parseBoolean((String) config.getObject(SHOW_DETAIL_ERROR));
+ setDetailErrors(error);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-web/src/main/resources/DataDeleteSQLs.properties
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-web/src/main/resources/DataDeleteSQLs.properties b/odata2-jpa-processor/jpa-web/src/main/resources/DataDeleteSQLs.properties
new file mode 100644
index 0000000..19f859d
--- /dev/null
+++ b/odata2-jpa-processor/jpa-web/src/main/resources/DataDeleteSQLs.properties
@@ -0,0 +1,22 @@
+#-------------------------------------------------------------------------------
+# 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.
+#-------------------------------------------------------------------------------
+
+#Config file for deleting the entities. They are deleted in the order provided in the below comma-separated string.
+#It is mandatory due to referential constaints.
+delete_queries = DELETE FROM T_NOTE,DELETE FROM T_SALESORDERITEM,DELETE FROM T_MATERIAL_T_STORE,DELETE FROM T_MATERIAL,DELETE FROM T_STORE,DELETE FROM T_SALESORDERHEADER
\ No newline at end of file
[06/37] [OLINGO-82] Renamed the project folder name to
odata2-jpa-processor
Posted by ch...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/data/ODataEntryMockUtil.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/data/ODataEntryMockUtil.java b/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/data/ODataEntryMockUtil.java
deleted file mode 100644
index 609017b..0000000
--- a/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/data/ODataEntryMockUtil.java
+++ /dev/null
@@ -1,127 +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.data;
-
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.TimeZone;
-import java.util.UUID;
-
-import org.apache.olingo.odata2.api.ep.entry.ODataEntry;
-import org.apache.olingo.odata2.api.ep.feed.ODataFeed;
-import org.apache.olingo.odata2.processor.core.jpa.mock.data.JPATypeMock.JPARelatedTypeMock;
-import org.apache.olingo.odata2.processor.core.jpa.mock.data.JPATypeMock.JPATypeEmbeddableMock;
-import org.apache.olingo.odata2.processor.core.jpa.mock.data.JPATypeMock.JPATypeEmbeddableMock2;
-import org.easymock.EasyMock;
-
-public class ODataEntryMockUtil {
-
- public static final int VALUE_MINT = 20;
- public static Calendar VALUE_DATE_TIME = null;
- public static final String VALUE_MSTRING = "Mock";
- public static final long VALUE_MLONG = 1234567890L;
- public static final double VALUE_MDOUBLE = 20.12;
- public static final byte VALUE_MBYTE = 0XA;
- public static final byte[] VALUE_MBYTEARRAY = { 0XA, 0XB };
- public static final float VALUE_MFLOAT = 2.00F;
- public static final UUID VALUE_UUID = UUID.fromString("38400000-8cf0-11bd-b23e-10b96e4ef00d");
- public static final short VALUE_SHORT = 2;
-
- public static ODataEntry mockODataEntry(final String entityName) {
- ODataEntry oDataEntry = EasyMock.createMock(ODataEntry.class);
- EasyMock.expect(oDataEntry.getProperties()).andReturn(mockODataEntryProperties(entityName)).anyTimes();
-
- EasyMock.expect(oDataEntry.containsInlineEntry()).andReturn(false);
- EasyMock.replay(oDataEntry);
- return oDataEntry;
- }
-
- public static ODataEntry mockODataEntryWithComplexType(final String entityName) {
- ODataEntry oDataEntry = EasyMock.createMock(ODataEntry.class);
- EasyMock.expect(oDataEntry.getProperties()).andReturn(mockODataEntryPropertiesWithComplexType(entityName))
- .anyTimes();
-
- EasyMock.expect(oDataEntry.containsInlineEntry()).andReturn(false);
- EasyMock.replay(oDataEntry);
- return oDataEntry;
- }
-
- public static Map<String, Object> mockODataEntryProperties(final String entityName) {
- Map<String, Object> propertyMap = new HashMap<String, Object>();
-
- if (entityName.equals(JPATypeMock.ENTITY_NAME)) {
- propertyMap.put(JPATypeMock.PROPERTY_NAME_MINT, VALUE_MINT);
-
- VALUE_DATE_TIME = Calendar.getInstance(TimeZone.getDefault());
- VALUE_DATE_TIME.set(2013, 1, 1, 1, 1, 1);
- propertyMap.put(JPATypeMock.PROPERTY_NAME_MDATETIME, VALUE_DATE_TIME);
-
- propertyMap.put(JPATypeMock.PROPERTY_NAME_MSTRING, VALUE_MSTRING);
- } else if (entityName.equals(JPARelatedTypeMock.ENTITY_NAME)) {
- propertyMap.put(JPARelatedTypeMock.PROPERTY_NAME_MLONG, VALUE_MLONG);
- propertyMap.put(JPARelatedTypeMock.PROPERTY_NAME_MDOUBLE, VALUE_MDOUBLE);
- propertyMap.put(JPARelatedTypeMock.PROPERTY_NAME_MBYTE, VALUE_MBYTE);
- propertyMap.put(JPARelatedTypeMock.PROPERTY_NAME_MBYTEARRAY, VALUE_MBYTEARRAY);
- } else if (entityName.equals(JPATypeEmbeddableMock.ENTITY_NAME)) {
- propertyMap.put(JPATypeEmbeddableMock.PROPERTY_NAME_MSHORT, VALUE_SHORT);
- propertyMap.put(JPATypeEmbeddableMock.PROPERTY_NAME_MEMBEDDABLE,
- mockODataEntryProperties(JPATypeEmbeddableMock2.ENTITY_NAME));
- } else if (entityName.equals(JPATypeEmbeddableMock2.ENTITY_NAME)) {
- propertyMap.put(JPATypeEmbeddableMock2.PROPERTY_NAME_MFLOAT, VALUE_MFLOAT);
- propertyMap.put(JPATypeEmbeddableMock2.PROPERTY_NAME_MUUID, VALUE_UUID);
- }
-
- return propertyMap;
- }
-
- public static Map<String, Object> mockODataEntryPropertiesWithComplexType(final String entityName) {
- Map<String, Object> propertyMap = mockODataEntryProperties(entityName);
- propertyMap
- .put(JPATypeMock.PROPERTY_NAME_MCOMPLEXTYPE, mockODataEntryProperties(JPATypeEmbeddableMock.ENTITY_NAME));
- return propertyMap;
- }
-
- public static Map<String, Object> mockODataEntryPropertiesWithInline(final String entityName) {
- Map<String, Object> propertyMap = mockODataEntryProperties(entityName);
- List<ODataEntry> relatedEntries = new ArrayList<ODataEntry>();
- relatedEntries.add(mockODataEntry(JPARelatedTypeMock.ENTITY_NAME));
- ODataFeed feed = EasyMock.createMock(ODataFeed.class);
- EasyMock.expect(feed.getEntries()).andReturn(relatedEntries);
- EasyMock.replay(feed);
- propertyMap.put(JPATypeMock.NAVIGATION_PROPERTY_X, feed);
-
- return propertyMap;
-
- }
-
- public static ODataEntry mockODataEntryWithInline(final String entityName) {
- ODataEntry oDataEntry = EasyMock.createMock(ODataEntry.class);
- EasyMock.expect(oDataEntry.getProperties()).andReturn(mockODataEntryPropertiesWithInline(entityName)).anyTimes();
- if (entityName.equals(JPATypeMock.ENTITY_NAME)) {
- EasyMock.expect(oDataEntry.containsInlineEntry()).andReturn(true);
- } else {
- EasyMock.expect(oDataEntry.containsInlineEntry()).andReturn(false);
- }
- EasyMock.replay(oDataEntry);
- return oDataEntry;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/data/SalesOrderHeader.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/data/SalesOrderHeader.java b/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/data/SalesOrderHeader.java
deleted file mode 100644
index c54411e..0000000
--- a/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/data/SalesOrderHeader.java
+++ /dev/null
@@ -1,63 +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.data;
-
-import java.util.ArrayList;
-import java.util.List;
-
-public class SalesOrderHeader {
-
- private int id;
- private String description;
-
- public SalesOrderHeader() {}
-
- public SalesOrderHeader(final int id, final String description) {
- super();
- this.id = id;
- this.description = description;
- }
-
- private List<SalesOrderLineItem> salesOrderLineItems = new ArrayList<SalesOrderLineItem>();
-
- public String getDescription() {
- return description;
- }
-
- public void setDescription(final String description) {
- this.description = description;
- }
-
- public int getId() {
- return id;
- }
-
- public void setId(final int id) {
- this.id = id;
- }
-
- public List<SalesOrderLineItem> getSalesOrderLineItems() {
- return salesOrderLineItems;
- }
-
- public void setSalesOrderLineItems(final List<SalesOrderLineItem> salesOrderLineItems) {
- this.salesOrderLineItems = salesOrderLineItems;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/data/SalesOrderLineItem.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/data/SalesOrderLineItem.java b/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/data/SalesOrderLineItem.java
deleted file mode 100644
index ba9c09a..0000000
--- a/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/data/SalesOrderLineItem.java
+++ /dev/null
@@ -1,38 +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.data;
-
-public class SalesOrderLineItem {
-
- private int price;
-
- public SalesOrderLineItem(final int price) {
- super();
- this.price = price;
- }
-
- public int getPrice() {
- return price;
- }
-
- public void setPrice(final int price) {
- this.price = price;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/data/SalesOrderLineItemKey.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/data/SalesOrderLineItemKey.java b/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/data/SalesOrderLineItemKey.java
deleted file mode 100644
index d8b7ee3..0000000
--- a/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/data/SalesOrderLineItemKey.java
+++ /dev/null
@@ -1,52 +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.data;
-
-public class SalesOrderLineItemKey {
-
- private int soId;
- private int liId;
-
- public SalesOrderLineItemKey() {
-
- }
-
- public SalesOrderLineItemKey(final int soId, final int liId) {
- super();
- this.soId = soId;
- this.liId = liId;
- }
-
- public int getSoId() {
- return soId;
- }
-
- public void setSoId(final int soId) {
- this.soId = soId;
- }
-
- public int getLiId() {
- return liId;
- }
-
- public void setLiId(final int liId) {
- this.liId = liId;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/EdmSchemaMock.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/EdmSchemaMock.java b/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/EdmSchemaMock.java
deleted file mode 100644
index 879c2c2..0000000
--- a/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/EdmSchemaMock.java
+++ /dev/null
@@ -1,213 +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.ArrayList;
-import java.util.List;
-
-import org.apache.olingo.odata2.api.edm.EdmMultiplicity;
-import org.apache.olingo.odata2.api.edm.EdmSimpleTypeKind;
-import org.apache.olingo.odata2.api.edm.FullQualifiedName;
-import org.apache.olingo.odata2.api.edm.provider.Association;
-import org.apache.olingo.odata2.api.edm.provider.AssociationEnd;
-import org.apache.olingo.odata2.api.edm.provider.AssociationSet;
-import org.apache.olingo.odata2.api.edm.provider.AssociationSetEnd;
-import org.apache.olingo.odata2.api.edm.provider.ComplexType;
-import org.apache.olingo.odata2.api.edm.provider.EntityContainer;
-import org.apache.olingo.odata2.api.edm.provider.EntitySet;
-import org.apache.olingo.odata2.api.edm.provider.EntityType;
-import org.apache.olingo.odata2.api.edm.provider.FunctionImport;
-import org.apache.olingo.odata2.api.edm.provider.Key;
-import org.apache.olingo.odata2.api.edm.provider.Mapping;
-import org.apache.olingo.odata2.api.edm.provider.Property;
-import org.apache.olingo.odata2.api.edm.provider.PropertyRef;
-import org.apache.olingo.odata2.api.edm.provider.Schema;
-import org.apache.olingo.odata2.api.edm.provider.SimpleProperty;
-import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmMapping;
-import org.apache.olingo.odata2.processor.core.jpa.model.JPAEdmMappingImpl;
-
-public class EdmSchemaMock {
-
- private static final String ASSOCIATION_ROLE_NAME_ONE = "SalesOrderHeader";
- private static final String ASSOCIATION_NAME = "SalesOrderHeader_SalesOrderItem";
- private static final String ASSOCIATION_SET_NAME = "SalesOrderHeader_SalesOrderItemSet";
- private static final String ASSOCIATION_ROLE_NAME_TWO = "SalesOrderItem";
- private static final String NAMESPACE = "salesorderprocessing";
- private static final String ENTITY_CONTAINER_NAME = "salesorderprocessingContainer";
- private static final String ENTITY_NAME_ONE = "SalesOrderHeader";
- private static final String ENTITY_NAME_TWO = "SalesOrderItem";
- private static final String ENTITY_SET_NAME_ONE = "SalesOrderHeaders";
- private static final String FUNCTION_IMPORT_NAME_ONE = "SalesOrder_FunctionImport1";
- private static final String FUNCTION_IMPORT_NAME_TWO = "SalesOrder_FunctionImport2";
- private static final String ENTITY_SET_NAME_TWO = "SalesOrderItems";
- private static final String COMPLEX_TYPE_NAME_ONE = "Address";
- private static final String COMPLEX_TYPE_NAME_TWO = "SalesOrderItemKey";
-
- public static Schema createMockEdmSchema() {
- Schema schema = new Schema();
- schema.setNamespace(NAMESPACE);
- schema.setComplexTypes(createComplexTypes());
- schema.setEntityContainers(createEntityContainer());
- schema.setEntityTypes(createEntityTypes());
- schema.setAssociations(createAssociations());
- return schema;
- }
-
- private static List<EntityContainer> createEntityContainer() {
- List<EntityContainer> entityContainers = new ArrayList<EntityContainer>();
- EntityContainer entityContainer = new EntityContainer();
- entityContainer.setDefaultEntityContainer(true);
- entityContainer.setName(ENTITY_CONTAINER_NAME);
- entityContainer.setEntitySets(createEntitySets());
- entityContainer.setAssociationSets(createAssociationSets());
- entityContainer.setFunctionImports(createFunctionImports());
- entityContainers.add(entityContainer);
- return entityContainers;
- }
-
- private static List<AssociationSet> createAssociationSets() {
- List<AssociationSet> associationSets = new ArrayList<AssociationSet>();
- AssociationSet associationSet = new AssociationSet();
- associationSet.setName(ASSOCIATION_SET_NAME);
- associationSet.setAssociation(new FullQualifiedName(NAMESPACE, ASSOCIATION_NAME));
- associationSet
- .setEnd1(new AssociationSetEnd().setEntitySet(ENTITY_SET_NAME_ONE).setRole(ASSOCIATION_ROLE_NAME_ONE));
- associationSet
- .setEnd2(new AssociationSetEnd().setEntitySet(ENTITY_SET_NAME_TWO).setRole(ASSOCIATION_ROLE_NAME_TWO));
- associationSets.add(associationSet);
- return associationSets;
- }
-
- private static List<EntitySet> createEntitySets() {
- List<EntitySet> entitySets = new ArrayList<EntitySet>();
- EntitySet entitySet = new EntitySet();
- entitySet.setName(ENTITY_SET_NAME_ONE);
- entitySet.setEntityType(new FullQualifiedName(NAMESPACE, ENTITY_NAME_ONE));
- entitySets.add(entitySet);
- entitySet = new EntitySet();
- entitySet.setName(ENTITY_SET_NAME_TWO);
- entitySet.setEntityType(new FullQualifiedName(NAMESPACE, ENTITY_NAME_TWO));
- entitySets.add(entitySet);
- return entitySets;
- }
-
- private static List<FunctionImport> createFunctionImports() {
- List<FunctionImport> functionImports = new ArrayList<FunctionImport>();
- FunctionImport functionImport = new FunctionImport();
- functionImport.setName(FUNCTION_IMPORT_NAME_ONE);
- functionImports.add(functionImport);
- functionImport = new FunctionImport();
- functionImport.setName(FUNCTION_IMPORT_NAME_TWO);
- functionImports.add(functionImport);
- return functionImports;
- }
-
- private static List<Association> createAssociations() {
- List<Association> associations = new ArrayList<Association>();
- Association association = new Association();
- association.setName(ASSOCIATION_NAME);
- association.setEnd1(new AssociationEnd().setMultiplicity(EdmMultiplicity.ONE).setRole(ASSOCIATION_ROLE_NAME_ONE)
- .setType(new FullQualifiedName(NAMESPACE, ENTITY_NAME_ONE)));
- association.setEnd2(new AssociationEnd().setMultiplicity(EdmMultiplicity.MANY).setRole(ASSOCIATION_ROLE_NAME_TWO)
- .setType(new FullQualifiedName(NAMESPACE, ENTITY_NAME_TWO)));
- associations.add(association);
- return associations;
- }
-
- private static List<EntityType> createEntityTypes() {
- List<EntityType> entityTypes = new ArrayList<EntityType>();
- EntityType entityType = new EntityType();
- entityType.setName(ENTITY_NAME_ONE);
- String[] keyNamesOne = { "SoId" };
- entityType.setKey(createKey(keyNamesOne));
- entityTypes.add(entityType);
-
- entityType = new EntityType();
- entityType.setName(ENTITY_NAME_TWO);
- String[] keyNamesTwo = { "SoId", "LiId" };
- entityType.setKey(createKey(keyNamesTwo));
- entityTypes.add(entityType);
- return entityTypes;
-
- }
-
- private static Key createKey(final String[] keyNames) {
- Key key = new Key();
- List<PropertyRef> keys = new ArrayList<PropertyRef>();
- for (String keyName : keyNames) {
- keys.add(new PropertyRef().setName(keyName));
- }
- key.setKeys(keys);
- return null;
- }
-
- private static List<ComplexType> createComplexTypes() {
- List<ComplexType> complexTypes = new ArrayList<ComplexType>();
- ComplexType complexTypeOne = new ComplexType();
- complexTypeOne.setName(COMPLEX_TYPE_NAME_ONE);
- complexTypeOne.setProperties(createComplexTypePropertiesOne());
- complexTypes.add(complexTypeOne);
- ComplexType complexTypeTwo = new ComplexType();
- complexTypeTwo.setName(COMPLEX_TYPE_NAME_TWO);
- complexTypeTwo.setProperties(createComplexTypePropertiesTwo());
- complexTypes.add(complexTypeTwo);
- return complexTypes;
- }
-
- private static List<Property> createComplexTypePropertiesTwo() {
- List<Property> properties = new ArrayList<Property>();
- SimpleProperty property = new SimpleProperty();
- property.setName("SoId");
- property.setType(EdmSimpleTypeKind.Int64);
- JPAEdmMapping mapping = new JPAEdmMappingImpl();
- mapping.setJPAColumnName("Sales_Order_Id");
- ((Mapping) mapping).setInternalName("SalesOrderItemKey.SoId");
- property.setMapping((Mapping) mapping);
- properties.add(property);
- property = new SimpleProperty();
- property.setName("LiId");
- property.setType(EdmSimpleTypeKind.Int64);
- mapping = new JPAEdmMappingImpl();
- mapping.setJPAColumnName("Sales_Order_Item_Id");
- property.setMapping((Mapping) mapping);
- properties.add(property);
- return properties;
-
- }
-
- private static List<Property> createComplexTypePropertiesOne() {
- List<Property> properties = new ArrayList<Property>();
- SimpleProperty property = new SimpleProperty();
- property.setName("StreetName");
- property.setType(EdmSimpleTypeKind.String);
- JPAEdmMapping mapping = new JPAEdmMappingImpl();
- mapping.setJPAColumnName("STREET_NAME");
- property.setMapping((Mapping) mapping);
- properties.add(property);
- property = new SimpleProperty();
- property.setName("City");
- property.setType(EdmSimpleTypeKind.String);
- mapping = new JPAEdmMappingImpl();
- mapping.setJPAColumnName("CITY");
- property.setMapping((Mapping) mapping);
- properties.add(property);
- return properties;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/JPAAttributeMock.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/JPAAttributeMock.java b/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/JPAAttributeMock.java
deleted file mode 100644
index 9d6bad1..0000000
--- a/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/JPAAttributeMock.java
+++ /dev/null
@@ -1,63 +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.lang.reflect.Member;
-
-import javax.persistence.metamodel.Attribute;
-import javax.persistence.metamodel.ManagedType;
-
-public abstract class JPAAttributeMock<X, Y> implements Attribute<X, Y> {
-
- @Override
- public ManagedType<X> getDeclaringType() {
- return null;
- }
-
- @Override
- public Member getJavaMember() {
- return null;
- }
-
- @Override
- public Class<Y> getJavaType() {
- return null;
- }
-
- @Override
- public String getName() {
- return null;
- }
-
- @Override
- public javax.persistence.metamodel.Attribute.PersistentAttributeType getPersistentAttributeType() {
- return null;
- }
-
- @Override
- public boolean isAssociation() {
- return false;
- }
-
- @Override
- public boolean isCollection() {
- return false;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/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
deleted file mode 100644
index 54a6871..0000000
--- a/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/JPACustomProcessorMock.java
+++ /dev/null
@@ -1,74 +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.ArrayList;
-import java.util.List;
-
-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";
-
- @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>();
- }
-
- @EdmFunctionImport(name = "Method2", entitySet = "MockSet", returnType = @ReturnType(type = Type.ENTITY,
- isCollection = true))
- public List<JPACustomProcessorMock> method2(
- @EdmFunctionImportParameter(facets = @EdmFacets(maxLength = 2), name = "Param2") final String param2) {
- return new ArrayList<JPACustomProcessorMock>();
- }
-
- @EdmFunctionImport(returnType = @ReturnType(type = Type.SIMPLE))
- public int method3(@EdmFunctionImportParameter(name = "Param3") final String param3) {
- return 0;
- }
-
- @EdmFunctionImport(returnType = @ReturnType(type = Type.ENTITY,
- isCollection = false), entitySet = "MockSet")
- public JPACustomProcessorMock method7() {
- return null;
- }
-
- @EdmFunctionImport(returnType = @ReturnType(type = Type.COMPLEX,
- isCollection = false))
- public JPACustomProcessorMock method9() {
- return null;
- }
-
- @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/1b479e6c/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/JPAEdmMockData.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/JPAEdmMockData.java b/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/JPAEdmMockData.java
deleted file mode 100644
index 9b25115..0000000
--- a/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/JPAEdmMockData.java
+++ /dev/null
@@ -1,72 +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 org.apache.olingo.odata2.processor.core.jpa.mock.model.JPAEdmMockData.EntityType.EntityTypeA;
-
-public interface JPAEdmMockData {
- /*
- * Edm Complex Type Mock Data
- */
- public interface ComplexType {
-
- public interface ComplexTypeA {
- public static final String name = "ComplexTypeA";
- public static final Class<ComplexTypeA> clazz = ComplexTypeA.class;
-
- public interface Property {
- public static final String PROPERTY_A = "A";
- public static final String PROPERTY_B = "B";
- public static final String PROPERTY_C = "C";
- }
-
- }
-
- public interface ComplexTypeB {
- public static final String name = "ComplexTypeB";
-
- public interface Property {
- public static final String PROPERTY_D = "D";
- public static final String PROPERTY_E = "E";
- }
-
- }
- }
-
- public interface EntityType {
- public interface EntityTypeA {
- public static final String name = "SalesOrderHeader";
- public static final Class<EntityTypeA> entityClazz = EntityTypeA.class;
-
- public interface Property {
- public static final String PROPERTY_A = SimpleType.SimpleTypeA.NAME;
-
- }
-
- }
- }
-
- public interface SimpleType {
- public interface SimpleTypeA {
- public static final String NAME = "SOID";
- public static final Class<String> clazz = String.class;
- public static final Class<EntityTypeA> declaringClazz = EntityType.EntityTypeA.class;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/JPAEmbeddableMock.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/JPAEmbeddableMock.java b/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/JPAEmbeddableMock.java
deleted file mode 100644
index 397f971..0000000
--- a/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/JPAEmbeddableMock.java
+++ /dev/null
@@ -1,184 +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.Set;
-
-import javax.persistence.metamodel.Attribute;
-import javax.persistence.metamodel.CollectionAttribute;
-import javax.persistence.metamodel.EmbeddableType;
-import javax.persistence.metamodel.ListAttribute;
-import javax.persistence.metamodel.MapAttribute;
-import javax.persistence.metamodel.PluralAttribute;
-import javax.persistence.metamodel.SetAttribute;
-import javax.persistence.metamodel.SingularAttribute;
-
-public class JPAEmbeddableMock<X> implements EmbeddableType<X> {
-
- @Override
- public Attribute<? super X, ?> getAttribute(final String arg0) {
- return null;
- }
-
- @Override
- public Set<Attribute<? super X, ?>> getAttributes() {
- return null;
- }
-
- @Override
- public CollectionAttribute<? super X, ?> getCollection(final String arg0) {
- return null;
- }
-
- @Override
- public <E> CollectionAttribute<? super X, E> getCollection(final String arg0, final Class<E> arg1) {
- return null;
- }
-
- @Override
- public Attribute<X, ?> getDeclaredAttribute(final String arg0) {
- return null;
- }
-
- @Override
- public Set<Attribute<X, ?>> getDeclaredAttributes() {
- return null;
- }
-
- @Override
- public CollectionAttribute<X, ?> getDeclaredCollection(final String arg0) {
- return null;
- }
-
- @Override
- public <E> CollectionAttribute<X, E> getDeclaredCollection(final String arg0, final Class<E> arg1) {
- return null;
- }
-
- @Override
- public ListAttribute<X, ?> getDeclaredList(final String arg0) {
- return null;
- }
-
- @Override
- public <E> ListAttribute<X, E> getDeclaredList(final String arg0, final Class<E> arg1) {
- return null;
- }
-
- @Override
- public MapAttribute<X, ?, ?> getDeclaredMap(final String arg0) {
- return null;
- }
-
- @Override
- public <K, V> MapAttribute<X, K, V> getDeclaredMap(final String arg0, final Class<K> arg1, final Class<V> arg2) {
- return null;
- }
-
- @Override
- public Set<PluralAttribute<X, ?, ?>> getDeclaredPluralAttributes() {
- return null;
- }
-
- @Override
- public SetAttribute<X, ?> getDeclaredSet(final String arg0) {
- return null;
- }
-
- @Override
- public <E> SetAttribute<X, E> getDeclaredSet(final String arg0, final Class<E> arg1) {
- return null;
- }
-
- @Override
- public SingularAttribute<X, ?> getDeclaredSingularAttribute(final String arg0) {
- return null;
- }
-
- @Override
- public <Y> SingularAttribute<X, Y> getDeclaredSingularAttribute(final String arg0, final Class<Y> arg1) {
- return null;
- }
-
- @Override
- public Set<SingularAttribute<X, ?>> getDeclaredSingularAttributes() {
- return null;
- }
-
- @Override
- public ListAttribute<? super X, ?> getList(final String arg0) {
- return null;
- }
-
- @Override
- public <E> ListAttribute<? super X, E> getList(final String arg0, final Class<E> arg1) {
- return null;
- }
-
- @Override
- public MapAttribute<? super X, ?, ?> getMap(final String arg0) {
- return null;
- }
-
- @Override
- public <K, V> MapAttribute<? super X, K, V> getMap(final String arg0, final Class<K> arg1, final Class<V> arg2) {
- return null;
- }
-
- @Override
- public Set<PluralAttribute<? super X, ?, ?>> getPluralAttributes() {
- return null;
- }
-
- @Override
- public SetAttribute<? super X, ?> getSet(final String arg0) {
- return null;
- }
-
- @Override
- public <E> SetAttribute<? super X, E> getSet(final String arg0, final Class<E> arg1) {
- return null;
- }
-
- @Override
- public SingularAttribute<? super X, ?> getSingularAttribute(final String arg0) {
- return null;
- }
-
- @Override
- public <Y> SingularAttribute<? super X, Y> getSingularAttribute(final String arg0, final Class<Y> arg1) {
- return null;
- }
-
- @Override
- public Set<SingularAttribute<? super X, ?>> getSingularAttributes() {
- return null;
- }
-
- @Override
- public Class<X> getJavaType() {
- return null;
- }
-
- @Override
- public javax.persistence.metamodel.Type.PersistenceType getPersistenceType() {
- return null;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/JPAEmbeddableTypeMock.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/JPAEmbeddableTypeMock.java b/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/JPAEmbeddableTypeMock.java
deleted file mode 100644
index 7f6adc8..0000000
--- a/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/JPAEmbeddableTypeMock.java
+++ /dev/null
@@ -1,184 +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.Set;
-
-import javax.persistence.metamodel.Attribute;
-import javax.persistence.metamodel.CollectionAttribute;
-import javax.persistence.metamodel.EmbeddableType;
-import javax.persistence.metamodel.ListAttribute;
-import javax.persistence.metamodel.MapAttribute;
-import javax.persistence.metamodel.PluralAttribute;
-import javax.persistence.metamodel.SetAttribute;
-import javax.persistence.metamodel.SingularAttribute;
-
-public class JPAEmbeddableTypeMock<X> implements EmbeddableType<X> {
-
- @Override
- public Attribute<? super X, ?> getAttribute(final String arg0) {
- return null;
- }
-
- @Override
- public Set<Attribute<? super X, ?>> getAttributes() {
- return null;
- }
-
- @Override
- public CollectionAttribute<? super X, ?> getCollection(final String arg0) {
- return null;
- }
-
- @Override
- public <E> CollectionAttribute<? super X, E> getCollection(final String arg0, final Class<E> arg1) {
- return null;
- }
-
- @Override
- public Attribute<X, ?> getDeclaredAttribute(final String arg0) {
- return null;
- }
-
- @Override
- public Set<Attribute<X, ?>> getDeclaredAttributes() {
- return null;
- }
-
- @Override
- public CollectionAttribute<X, ?> getDeclaredCollection(final String arg0) {
- return null;
- }
-
- @Override
- public <E> CollectionAttribute<X, E> getDeclaredCollection(final String arg0, final Class<E> arg1) {
- return null;
- }
-
- @Override
- public ListAttribute<X, ?> getDeclaredList(final String arg0) {
- return null;
- }
-
- @Override
- public <E> ListAttribute<X, E> getDeclaredList(final String arg0, final Class<E> arg1) {
- return null;
- }
-
- @Override
- public MapAttribute<X, ?, ?> getDeclaredMap(final String arg0) {
- return null;
- }
-
- @Override
- public <K, V> MapAttribute<X, K, V> getDeclaredMap(final String arg0, final Class<K> arg1, final Class<V> arg2) {
- return null;
- }
-
- @Override
- public Set<PluralAttribute<X, ?, ?>> getDeclaredPluralAttributes() {
- return null;
- }
-
- @Override
- public SetAttribute<X, ?> getDeclaredSet(final String arg0) {
- return null;
- }
-
- @Override
- public <E> SetAttribute<X, E> getDeclaredSet(final String arg0, final Class<E> arg1) {
- return null;
- }
-
- @Override
- public SingularAttribute<X, ?> getDeclaredSingularAttribute(final String arg0) {
- return null;
- }
-
- @Override
- public <Y> SingularAttribute<X, Y> getDeclaredSingularAttribute(final String arg0, final Class<Y> arg1) {
- return null;
- }
-
- @Override
- public Set<SingularAttribute<X, ?>> getDeclaredSingularAttributes() {
- return null;
- }
-
- @Override
- public ListAttribute<? super X, ?> getList(final String arg0) {
- return null;
- }
-
- @Override
- public <E> ListAttribute<? super X, E> getList(final String arg0, final Class<E> arg1) {
- return null;
- }
-
- @Override
- public MapAttribute<? super X, ?, ?> getMap(final String arg0) {
- return null;
- }
-
- @Override
- public <K, V> MapAttribute<? super X, K, V> getMap(final String arg0, final Class<K> arg1, final Class<V> arg2) {
- return null;
- }
-
- @Override
- public Set<PluralAttribute<? super X, ?, ?>> getPluralAttributes() {
- return null;
- }
-
- @Override
- public SetAttribute<? super X, ?> getSet(final String arg0) {
- return null;
- }
-
- @Override
- public <E> SetAttribute<? super X, E> getSet(final String arg0, final Class<E> arg1) {
- return null;
- }
-
- @Override
- public SingularAttribute<? super X, ?> getSingularAttribute(final String arg0) {
- return null;
- }
-
- @Override
- public <Y> SingularAttribute<? super X, Y> getSingularAttribute(final String arg0, final Class<Y> arg1) {
- return null;
- }
-
- @Override
- public Set<SingularAttribute<? super X, ?>> getSingularAttributes() {
- return null;
- }
-
- @Override
- public Class<X> getJavaType() {
- return null;
- }
-
- @Override
- public javax.persistence.metamodel.Type.PersistenceType getPersistenceType() {
- return null;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/JPAEntityTypeMock.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/JPAEntityTypeMock.java b/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/JPAEntityTypeMock.java
deleted file mode 100644
index 602d430..0000000
--- a/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/JPAEntityTypeMock.java
+++ /dev/null
@@ -1,246 +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.Set;
-
-import javax.persistence.metamodel.Attribute;
-import javax.persistence.metamodel.CollectionAttribute;
-import javax.persistence.metamodel.EntityType;
-import javax.persistence.metamodel.IdentifiableType;
-import javax.persistence.metamodel.ListAttribute;
-import javax.persistence.metamodel.MapAttribute;
-import javax.persistence.metamodel.PluralAttribute;
-import javax.persistence.metamodel.SetAttribute;
-import javax.persistence.metamodel.SingularAttribute;
-import javax.persistence.metamodel.Type;
-
-public abstract class JPAEntityTypeMock<X> implements EntityType<X> {
-
- @Override
- public <Y> SingularAttribute<X, Y> getDeclaredId(final Class<Y> arg0) {
- return null;
- }
-
- @Override
- public <Y> SingularAttribute<X, Y> getDeclaredVersion(final Class<Y> arg0) {
- return null;
- }
-
- @Override
- public <Y> SingularAttribute<? super X, Y> getId(final Class<Y> arg0) {
- return null;
- }
-
- @Override
- public Set<SingularAttribute<? super X, ?>> getIdClassAttributes() {
- return null;
- }
-
- @Override
- public Type<?> getIdType() {
- return null;
- }
-
- @Override
- public IdentifiableType<? super X> getSupertype() {
- return null;
- }
-
- @Override
- public <Y> SingularAttribute<? super X, Y> getVersion(final Class<Y> arg0) {
- return null;
- }
-
- @Override
- public boolean hasSingleIdAttribute() {
- return false;
- }
-
- @Override
- public boolean hasVersionAttribute() {
- return false;
- }
-
- @Override
- public Attribute<? super X, ?> getAttribute(final String arg0) {
- return null;
- }
-
- @Override
- public Set<Attribute<? super X, ?>> getAttributes() {
- return null;
- }
-
- @Override
- public CollectionAttribute<? super X, ?> getCollection(final String arg0) {
- return null;
- }
-
- @Override
- public <E> CollectionAttribute<? super X, E> getCollection(final String arg0, final Class<E> arg1) {
- return null;
- }
-
- @Override
- public Attribute<X, ?> getDeclaredAttribute(final String arg0) {
- return null;
- }
-
- @Override
- public Set<Attribute<X, ?>> getDeclaredAttributes() {
- return null;
- }
-
- @Override
- public CollectionAttribute<X, ?> getDeclaredCollection(final String arg0) {
- return null;
- }
-
- @Override
- public <E> CollectionAttribute<X, E> getDeclaredCollection(final String arg0, final Class<E> arg1) {
- return null;
- }
-
- @Override
- public ListAttribute<X, ?> getDeclaredList(final String arg0) {
- return null;
- }
-
- @Override
- public <E> ListAttribute<X, E> getDeclaredList(final String arg0, final Class<E> arg1) {
- return null;
- }
-
- @Override
- public MapAttribute<X, ?, ?> getDeclaredMap(final String arg0) {
- return null;
- }
-
- @Override
- public <K, V> MapAttribute<X, K, V> getDeclaredMap(final String arg0, final Class<K> arg1, final Class<V> arg2) {
- return null;
- }
-
- @Override
- public Set<PluralAttribute<X, ?, ?>> getDeclaredPluralAttributes() {
- return null;
- }
-
- @Override
- public SetAttribute<X, ?> getDeclaredSet(final String arg0) {
- return null;
- }
-
- @Override
- public <E> SetAttribute<X, E> getDeclaredSet(final String arg0, final Class<E> arg1) {
- return null;
- }
-
- @Override
- public SingularAttribute<X, ?> getDeclaredSingularAttribute(final String arg0) {
- return null;
- }
-
- @Override
- public <Y> SingularAttribute<X, Y> getDeclaredSingularAttribute(final String arg0, final Class<Y> arg1) {
- return null;
- }
-
- @Override
- public Set<SingularAttribute<X, ?>> getDeclaredSingularAttributes() {
- return null;
- }
-
- @Override
- public ListAttribute<? super X, ?> getList(final String arg0) {
- return null;
- }
-
- @Override
- public <E> ListAttribute<? super X, E> getList(final String arg0, final Class<E> arg1) {
- return null;
- }
-
- @Override
- public MapAttribute<? super X, ?, ?> getMap(final String arg0) {
- return null;
- }
-
- @Override
- public <K, V> MapAttribute<? super X, K, V> getMap(final String arg0, final Class<K> arg1, final Class<V> arg2) {
- return null;
- }
-
- @Override
- public Set<PluralAttribute<? super X, ?, ?>> getPluralAttributes() {
- return null;
- }
-
- @Override
- public SetAttribute<? super X, ?> getSet(final String arg0) {
- return null;
- }
-
- @Override
- public <E> SetAttribute<? super X, E> getSet(final String arg0, final Class<E> arg1) {
- return null;
- }
-
- @Override
- public SingularAttribute<? super X, ?> getSingularAttribute(final String arg0) {
- return null;
- }
-
- @Override
- public <Y> SingularAttribute<? super X, Y> getSingularAttribute(final String arg0, final Class<Y> arg1) {
- return null;
- }
-
- @Override
- public Set<SingularAttribute<? super X, ?>> getSingularAttributes() {
- return null;
- }
-
- @Override
- public Class<X> getJavaType() {
- return null;
- }
-
- @Override
- public javax.persistence.metamodel.Type.PersistenceType getPersistenceType() {
- return null;
- }
-
- @Override
- public Class<X> getBindableJavaType() {
- return null;
- }
-
- @Override
- public javax.persistence.metamodel.Bindable.BindableType getBindableType() {
- return null;
- }
-
- @Override
- public String getName() {
- return null;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/JPAJavaMemberMock.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/JPAJavaMemberMock.java b/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/JPAJavaMemberMock.java
deleted file mode 100644
index 740a2ec..0000000
--- a/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/JPAJavaMemberMock.java
+++ /dev/null
@@ -1,74 +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.lang.annotation.Annotation;
-import java.lang.reflect.AnnotatedElement;
-import java.lang.reflect.Member;
-
-import javax.persistence.JoinColumns;
-
-public class JPAJavaMemberMock implements Member, AnnotatedElement, Annotation {
-
- @Override
- public Class<?> getDeclaringClass() {
- return null;
- }
-
- @Override
- public String getName() {
- return null;
- }
-
- @Override
- public int getModifiers() {
- return 0;
- }
-
- @Override
- public boolean isSynthetic() {
- return false;
- }
-
- @Override
- public boolean isAnnotationPresent(final Class<? extends Annotation> annotationClass) {
- return false;
- }
-
- @Override
- public Annotation[] getAnnotations() {
- return null;
- }
-
- @Override
- public Annotation[] getDeclaredAnnotations() {
- return null;
- }
-
- @Override
- public Class<? extends Annotation> annotationType() {
- return JoinColumns.class;
- }
-
- @Override
- public <T extends Annotation> T getAnnotation(final Class<T> annotationClass) {
- return null;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/JPAManagedTypeMock.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/JPAManagedTypeMock.java b/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/JPAManagedTypeMock.java
deleted file mode 100644
index 915c562..0000000
--- a/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/JPAManagedTypeMock.java
+++ /dev/null
@@ -1,184 +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.Set;
-
-import javax.persistence.metamodel.Attribute;
-import javax.persistence.metamodel.CollectionAttribute;
-import javax.persistence.metamodel.ListAttribute;
-import javax.persistence.metamodel.ManagedType;
-import javax.persistence.metamodel.MapAttribute;
-import javax.persistence.metamodel.PluralAttribute;
-import javax.persistence.metamodel.SetAttribute;
-import javax.persistence.metamodel.SingularAttribute;
-
-public class JPAManagedTypeMock<X> implements ManagedType<X> {
-
- @Override
- public Class<X> getJavaType() {
- return null;
- }
-
- @Override
- public javax.persistence.metamodel.Type.PersistenceType getPersistenceType() {
- return null;
- }
-
- @Override
- public Attribute<? super X, ?> getAttribute(final String arg0) {
- return null;
- }
-
- @Override
- public Set<Attribute<? super X, ?>> getAttributes() {
- return null;
- }
-
- @Override
- public CollectionAttribute<? super X, ?> getCollection(final String arg0) {
- return null;
- }
-
- @Override
- public <E> CollectionAttribute<? super X, E> getCollection(final String arg0, final Class<E> arg1) {
- return null;
- }
-
- @Override
- public Attribute<X, ?> getDeclaredAttribute(final String arg0) {
- return null;
- }
-
- @Override
- public Set<Attribute<X, ?>> getDeclaredAttributes() {
- return null;
- }
-
- @Override
- public CollectionAttribute<X, ?> getDeclaredCollection(final String arg0) {
- return null;
- }
-
- @Override
- public <E> CollectionAttribute<X, E> getDeclaredCollection(final String arg0, final Class<E> arg1) {
- return null;
- }
-
- @Override
- public ListAttribute<X, ?> getDeclaredList(final String arg0) {
- return null;
- }
-
- @Override
- public <E> ListAttribute<X, E> getDeclaredList(final String arg0, final Class<E> arg1) {
- return null;
- }
-
- @Override
- public MapAttribute<X, ?, ?> getDeclaredMap(final String arg0) {
- return null;
- }
-
- @Override
- public <K, V> MapAttribute<X, K, V> getDeclaredMap(final String arg0, final Class<K> arg1, final Class<V> arg2) {
- return null;
- }
-
- @Override
- public Set<PluralAttribute<X, ?, ?>> getDeclaredPluralAttributes() {
- return null;
- }
-
- @Override
- public SetAttribute<X, ?> getDeclaredSet(final String arg0) {
- return null;
- }
-
- @Override
- public <E> SetAttribute<X, E> getDeclaredSet(final String arg0, final Class<E> arg1) {
- return null;
- }
-
- @Override
- public SingularAttribute<X, ?> getDeclaredSingularAttribute(final String arg0) {
- return null;
- }
-
- @Override
- public <Y> SingularAttribute<X, Y> getDeclaredSingularAttribute(final String arg0, final Class<Y> arg1) {
- return null;
- }
-
- @Override
- public Set<SingularAttribute<X, ?>> getDeclaredSingularAttributes() {
- return null;
- }
-
- @Override
- public ListAttribute<? super X, ?> getList(final String arg0) {
- return null;
- }
-
- @Override
- public <E> ListAttribute<? super X, E> getList(final String arg0, final Class<E> arg1) {
- return null;
- }
-
- @Override
- public MapAttribute<? super X, ?, ?> getMap(final String arg0) {
- return null;
- }
-
- @Override
- public <K, V> MapAttribute<? super X, K, V> getMap(final String arg0, final Class<K> arg1, final Class<V> arg2) {
- return null;
- }
-
- @Override
- public Set<PluralAttribute<? super X, ?, ?>> getPluralAttributes() {
- return null;
- }
-
- @Override
- public SetAttribute<? super X, ?> getSet(final String arg0) {
- return null;
- }
-
- @Override
- public <E> SetAttribute<? super X, E> getSet(final String arg0, final Class<E> arg1) {
- return null;
- }
-
- @Override
- public SingularAttribute<? super X, ?> getSingularAttribute(final String arg0) {
- return null;
- }
-
- @Override
- public <Y> SingularAttribute<? super X, Y> getSingularAttribute(final String arg0, final Class<Y> arg1) {
- return null;
- }
-
- @Override
- public Set<SingularAttribute<? super X, ?>> getSingularAttributes() {
- return null;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/JPAMetaModelMock.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/JPAMetaModelMock.java b/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/JPAMetaModelMock.java
deleted file mode 100644
index 8e528b2..0000000
--- a/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/JPAMetaModelMock.java
+++ /dev/null
@@ -1,60 +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.Set;
-
-import javax.persistence.metamodel.EmbeddableType;
-import javax.persistence.metamodel.EntityType;
-import javax.persistence.metamodel.ManagedType;
-import javax.persistence.metamodel.Metamodel;
-
-public class JPAMetaModelMock implements Metamodel {
-
- @Override
- public <X> EmbeddableType<X> embeddable(final Class<X> arg0) {
- return null;
- }
-
- @Override
- public <X> EntityType<X> entity(final Class<X> arg0) {
- return null;
- }
-
- @Override
- public Set<EmbeddableType<?>> getEmbeddables() {
- return null;
- }
-
- @Override
- public Set<EntityType<?>> getEntities() {
- return null;
- }
-
- @Override
- public Set<ManagedType<?>> getManagedTypes() {
- return null;
- }
-
- @Override
- public <X> ManagedType<X> managedType(final Class<X> arg0) {
- return null;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/JPAPluralAttributeMock.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/JPAPluralAttributeMock.java b/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/JPAPluralAttributeMock.java
deleted file mode 100644
index a4aa2b5..0000000
--- a/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/JPAPluralAttributeMock.java
+++ /dev/null
@@ -1,95 +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.lang.reflect.Member;
-import java.util.ArrayList;
-
-import javax.persistence.metamodel.ManagedType;
-import javax.persistence.metamodel.PluralAttribute;
-import javax.persistence.metamodel.Type;
-
-public class JPAPluralAttributeMock implements PluralAttribute<Object, ArrayList<String>, String> {
-
- @Override
- public String getName() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public javax.persistence.metamodel.Attribute.PersistentAttributeType getPersistentAttributeType() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public ManagedType<Object> getDeclaringType() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public Class<ArrayList<String>> getJavaType() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public Member getJavaMember() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public boolean isAssociation() {
- // TODO Auto-generated method stub
- return false;
- }
-
- @Override
- public boolean isCollection() {
- return false;
- }
-
- @Override
- public javax.persistence.metamodel.Bindable.BindableType getBindableType() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public Class<String> getBindableJavaType() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public javax.persistence.metamodel.PluralAttribute.CollectionType getCollectionType() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public Type<String> getElementType() {
- // TODO Auto-generated method stub
- return null;
- }
-
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/JPASingularAttributeMock.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/JPASingularAttributeMock.java b/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/JPASingularAttributeMock.java
deleted file mode 100644
index 41124fe..0000000
--- a/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/JPASingularAttributeMock.java
+++ /dev/null
@@ -1,94 +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.lang.reflect.Member;
-
-import javax.persistence.metamodel.ManagedType;
-import javax.persistence.metamodel.SingularAttribute;
-import javax.persistence.metamodel.Type;
-
-public class JPASingularAttributeMock<X, T> implements SingularAttribute<X, T> {
-
- @Override
- public ManagedType<X> getDeclaringType() {
- return null;
- }
-
- @Override
- public Member getJavaMember() {
- return null;
- }
-
- @Override
- public Class<T> getJavaType() {
- return null;
- }
-
- @Override
- public String getName() {
- return null;
- }
-
- @Override
- public javax.persistence.metamodel.Attribute.PersistentAttributeType getPersistentAttributeType() {
- return null;
- }
-
- @Override
- public boolean isAssociation() {
- return false;
- }
-
- @Override
- public boolean isCollection() {
- return false;
- }
-
- @Override
- public Class<T> getBindableJavaType() {
- return null;
- }
-
- @Override
- public javax.persistence.metamodel.Bindable.BindableType getBindableType() {
- return null;
- }
-
- @Override
- public Type<T> getType() {
- return null;
- }
-
- @Override
- public boolean isId() {
- return false;
- }
-
- @Override
- public boolean isOptional() {
- return false;
- }
-
- @Override
- public boolean isVersion() {
- return false;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/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
deleted file mode 100644
index dbc6d7a..0000000
--- a/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/_JPACustomProcessorMock.java
+++ /dev/null
@@ -1,77 +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.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/1b479e6c/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 6799949..0000000
--- a/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/mock/model/_JPACustomProcessorNegativeMock.java
+++ /dev/null
@@ -1,70 +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;
-
-@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/1b479e6c/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmAssociationEndTest.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmAssociationEndTest.java b/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmAssociationEndTest.java
deleted file mode 100644
index 05db5ab..0000000
--- a/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmAssociationEndTest.java
+++ /dev/null
@@ -1,177 +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.model;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import javax.persistence.metamodel.Attribute;
-
-import org.apache.olingo.odata2.api.edm.EdmMultiplicity;
-import org.apache.olingo.odata2.api.edm.FullQualifiedName;
-import org.apache.olingo.odata2.api.edm.provider.AssociationEnd;
-import org.apache.olingo.odata2.api.edm.provider.EntityType;
-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.core.jpa.common.ODataJPATestConstants;
-import org.apache.olingo.odata2.processor.core.jpa.mock.model.JPAAttributeMock;
-import org.apache.olingo.odata2.processor.core.jpa.mock.model.JPAEdmMockData.SimpleType;
-import org.apache.olingo.odata2.processor.core.jpa.mock.model.JPAEdmMockData.SimpleType.SimpleTypeA;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-public class JPAEdmAssociationEndTest extends JPAEdmTestModelView {
-
- private final static int VARIANT1 = 1;
- private final static int VARIANT2 = 2;
- private final static int VARIANT3 = 3;
-
- private static int variant;
-
- private static final String PUNIT_NAME = "salesorderprocessing";
- private static JPAEdmAssociationEnd objJPAEdmAssociationEnd = null;
- private static JPAEdmAssociationEndTest objJPAEdmAssociationEndTest = null;
-
- @BeforeClass
- public static void setup() {
- objJPAEdmAssociationEndTest = new JPAEdmAssociationEndTest();
- objJPAEdmAssociationEnd = new JPAEdmAssociationEnd(objJPAEdmAssociationEndTest, objJPAEdmAssociationEndTest);
- try {
- objJPAEdmAssociationEnd.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);
- }
- }
-
- @Test
- public void testGetBuilder() {
- JPAEdmBuilder builder = objJPAEdmAssociationEnd.getBuilder();
- assertNotNull(builder);
-
- }
-
- @Test
- public void testGetBuilderIdempotent() {
- JPAEdmBuilder builder1 = objJPAEdmAssociationEnd.getBuilder();
- JPAEdmBuilder builder2 = objJPAEdmAssociationEnd.getBuilder();
-
- assertEquals(builder1.hashCode(), builder2.hashCode());
- }
-
- @Test
- public void testGetAssociationEnd1() {
- AssociationEnd associationEnd = objJPAEdmAssociationEnd.getEdmAssociationEnd1();
- assertEquals(associationEnd.getType().getName(), "SOID");
- }
-
- @Test
- public void testGetAssociationEnd2() {
- AssociationEnd associationEnd = objJPAEdmAssociationEnd.getEdmAssociationEnd2();
- assertEquals(associationEnd.getType().getName(), "String");
- }
-
- @Test
- public void testCompare() {
- assertTrue(objJPAEdmAssociationEnd.compare(getAssociationEnd("SOID", 1), getAssociationEnd("String", 1)));
- assertFalse(objJPAEdmAssociationEnd.compare(getAssociationEnd("String", 2), getAssociationEnd("SOID", 1)));
- }
-
- @Test
- public void testBuildAssociationEnd() {
- assertEquals("SOID", objJPAEdmAssociationEnd.getEdmAssociationEnd1().getType().getName());
- assertEquals(new FullQualifiedName("salesorderprocessing", "SOID"), objJPAEdmAssociationEnd.getEdmAssociationEnd1()
- .getType());
- assertTrue(objJPAEdmAssociationEnd.isConsistent());
-
- }
-
- private AssociationEnd getAssociationEnd(final String typeName, final int variant) {
- AssociationEnd associationEnd = new AssociationEnd();
- associationEnd.setType(getFullQualifiedName(typeName));
- if (variant == VARIANT1) {
- associationEnd.setMultiplicity(EdmMultiplicity.MANY);
- } else if (variant == VARIANT2) {
- associationEnd.setMultiplicity(EdmMultiplicity.ONE);
- } else if (variant == VARIANT3) {
- associationEnd.setMultiplicity(EdmMultiplicity.ZERO_TO_ONE);
- } else {
- associationEnd.setMultiplicity(EdmMultiplicity.MANY);//
- }
- return associationEnd;
- }
-
- private FullQualifiedName getFullQualifiedName(final String typeName) {
- FullQualifiedName fullQualifiedName = new FullQualifiedName(PUNIT_NAME, typeName);
- return fullQualifiedName;
- }
-
- private Attribute<?, ?> getJPAAttributeLocal() {
- AttributeMock<Object, String> attr = new AttributeMock<Object, String>();
- return attr;
- }
-
- @Override
- public Attribute<?, ?> getJPAAttribute() {
- return getJPAAttributeLocal();
- }
-
- @Override
- public String getpUnitName() {
- return PUNIT_NAME;
- }
-
- @Override
- public EntityType getEdmEntityType() {
- EntityType entityType = new EntityType();
- entityType.setName(SimpleTypeA.NAME);
- return entityType;
- }
-
- // The inner class which gives us an replica of the jpa attribute
- @SuppressWarnings("hiding")
- public class AttributeMock<Object, String> extends JPAAttributeMock<Object, String> {
-
- @SuppressWarnings("unchecked")
- @Override
- public Class<String> getJavaType() {
- return (Class<String>) SimpleType.SimpleTypeA.clazz;
- }
-
- @Override
- public PersistentAttributeType getPersistentAttributeType() {
- if (variant == VARIANT1) {
- return PersistentAttributeType.ONE_TO_MANY;
- } else if (variant == VARIANT2) {
- return PersistentAttributeType.ONE_TO_ONE;
- } else if (variant == VARIANT3) {
- return PersistentAttributeType.MANY_TO_ONE;
- } else {
- return PersistentAttributeType.MANY_TO_MANY;
- }
-
- }
- }
-
-}
[37/37] git commit: [OLINGO-82] Renamed the project folder name to
odata2-jpa-processor
Posted by ch...@apache.org.
[OLINGO-82] Renamed the project folder name to odata2-jpa-processor
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/1b479e6c
Tree: http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/tree/1b479e6c
Diff: http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/diff/1b479e6c
Branch: refs/heads/master
Commit: 1b479e6c0c5b48cf843654a6668abb0827b95a10
Parents: 33c4701
Author: Chandan V A <ch...@sap.com>
Authored: Wed Dec 18 14:36:55 2013 +0530
Committer: Chandan V A <ch...@sap.com>
Committed: Wed Dec 18 14:36:55 2013 +0530
----------------------------------------------------------------------
odata2-jpa-processor/jpa-api/.gitignore | 8 +
odata2-jpa-processor/jpa-api/pom.xml | 91 ++
.../processor/api/jpa/ODataJPAContext.java | 206 +++
.../processor/api/jpa/ODataJPAProcessor.java | 69 +
.../api/jpa/ODataJPAServiceFactory.java | 190 +++
.../processor/api/jpa/access/JPAEdmBuilder.java | 57 +
.../jpa/access/JPAEdmMappingModelAccess.java | 191 +++
.../processor/api/jpa/access/JPAFunction.java | 85 ++
.../processor/api/jpa/access/JPAJoinClause.java | 148 +++
.../api/jpa/access/JPAMethodContext.java | 130 ++
.../api/jpa/access/JPAMethodContextView.java | 46 +
.../processor/api/jpa/access/JPAProcessor.java | 260 ++++
.../processor/api/jpa/access/package-info.java | 26 +
.../jpa/exception/ODataJPAErrorCallback.java | 45 +
.../api/jpa/exception/ODataJPAException.java | 68 +
.../jpa/exception/ODataJPAMessageService.java | 49 +
.../jpa/exception/ODataJPAModelException.java | 92 ++
.../jpa/exception/ODataJPARuntimeException.java | 97 ++
.../api/jpa/exception/package-info.java | 31 +
.../api/jpa/factory/JPAAccessFactory.java | 69 +
.../api/jpa/factory/JPQLBuilderFactory.java | 77 ++
.../api/jpa/factory/ODataJPAAccessFactory.java | 82 ++
.../api/jpa/factory/ODataJPAFactory.java | 105 ++
.../processor/api/jpa/factory/package-info.java | 33 +
.../processor/api/jpa/jpql/JPQLContext.java | 204 +++
.../processor/api/jpa/jpql/JPQLContextType.java | 73 +
.../processor/api/jpa/jpql/JPQLContextView.java | 53 +
.../api/jpa/jpql/JPQLJoinContextView.java | 44 +
.../jpql/JPQLJoinSelectSingleContextView.java | 45 +
.../api/jpa/jpql/JPQLSelectContextView.java | 62 +
.../jpa/jpql/JPQLSelectSingleContextView.java | 53 +
.../processor/api/jpa/jpql/JPQLStatement.java | 148 +++
.../processor/api/jpa/jpql/package-info.java | 27 +
.../api/jpa/model/JPAEdmAssociationEndView.java | 91 ++
.../api/jpa/model/JPAEdmAssociationSetView.java | 69 +
.../api/jpa/model/JPAEdmAssociationView.java | 128 ++
.../processor/api/jpa/model/JPAEdmBaseView.java | 101 ++
.../jpa/model/JPAEdmComplexPropertyView.java | 45 +
.../api/jpa/model/JPAEdmComplexTypeView.java | 116 ++
.../jpa/model/JPAEdmEntityContainerView.java | 72 +
.../api/jpa/model/JPAEdmEntitySetView.java | 64 +
.../api/jpa/model/JPAEdmEntityTypeView.java | 76 ++
.../api/jpa/model/JPAEdmExtension.java | 50 +
.../api/jpa/model/JPAEdmFunctionImportView.java | 51 +
.../processor/api/jpa/model/JPAEdmKeyView.java | 51 +
.../processor/api/jpa/model/JPAEdmMapping.java | 63 +
.../api/jpa/model/JPAEdmModelView.java | 43 +
.../jpa/model/JPAEdmNavigationPropertyView.java | 72 +
.../api/jpa/model/JPAEdmPropertyView.java | 104 ++
.../JPAEdmReferentialConstraintRoleView.java | 101 ++
.../model/JPAEdmReferentialConstraintView.java | 69 +
.../api/jpa/model/JPAEdmSchemaView.java | 116 ++
.../jpa/model/mapping/JPAAttributeMapType.java | 202 +++
.../jpa/model/mapping/JPAEdmMappingModel.java | 79 ++
.../mapping/JPAEdmMappingModelFactory.java | 85 ++
.../model/mapping/JPAEmbeddableTypeMapType.java | 161 +++
.../mapping/JPAEmbeddableTypesMapType.java | 89 ++
.../jpa/model/mapping/JPAEntityTypeMapType.java | 213 +++
.../model/mapping/JPAEntityTypesMapType.java | 89 ++
.../mapping/JPAPersistenceUnitMapType.java | 157 +++
.../model/mapping/JPARelationshipMapType.java | 175 +++
.../api/jpa/model/mapping/package-info.java | 28 +
.../processor/api/jpa/model/package-info.java | 27 +
.../odata2/processor/api/jpa/package-info.java | 33 +
.../src/main/resources/JPAEDMMappingModel.xsd | 165 +++
odata2-jpa-processor/jpa-core/.gitignore | 8 +
odata2-jpa-processor/jpa-core/pom.xml | 146 ++
.../processor/core/jpa/ODataEntityParser.java | 163 +++
.../core/jpa/ODataExpressionParser.java | 381 ++++++
.../processor/core/jpa/ODataJPAContextImpl.java | 146 ++
.../core/jpa/ODataJPAProcessorDefault.java | 194 +++
.../core/jpa/ODataJPAResponseBuilder.java | 629 +++++++++
.../core/jpa/access/data/JPAEntity.java | 355 +++++
.../core/jpa/access/data/JPAEntityParser.java | 453 +++++++
.../core/jpa/access/data/JPAExpandCallBack.java | 180 +++
.../jpa/access/data/JPAFunctionContext.java | 170 +++
.../processor/core/jpa/access/data/JPALink.java | 225 ++++
.../core/jpa/access/data/JPAProcessorImpl.java | 491 +++++++
.../core/jpa/access/model/EdmTypeConvertor.java | 69 +
.../access/model/JPAEdmMappingModelService.java | 247 ++++
.../jpa/access/model/JPAEdmNameBuilder.java | 499 +++++++
.../core/jpa/access/model/JPATypeConvertor.java | 119 ++
.../core/jpa/edm/ODataJPAEdmProvider.java | 295 +++++
.../ODataJPAMessageServiceDefault.java | 122 ++
.../core/jpa/factory/ODataJPAFactoryImpl.java | 237 ++++
.../core/jpa/jpql/JPQLJoinSelectContext.java | 171 +++
.../jpa/jpql/JPQLJoinSelectSingleContext.java | 158 +++
.../JPQLJoinSelectSingleStatementBuilder.java | 106 ++
.../core/jpa/jpql/JPQLJoinStatementBuilder.java | 145 ++
.../core/jpa/jpql/JPQLSelectContext.java | 159 +++
.../core/jpa/jpql/JPQLSelectSingleContext.java | 109 ++
.../jpql/JPQLSelectSingleStatementBuilder.java | 66 +
.../jpa/jpql/JPQLSelectStatementBuilder.java | 98 ++
.../core/jpa/model/JPAEdmAssociation.java | 237 ++++
.../core/jpa/model/JPAEdmAssociationEnd.java | 183 +++
.../core/jpa/model/JPAEdmAssociationSet.java | 131 ++
.../core/jpa/model/JPAEdmBaseViewImpl.java | 101 ++
.../core/jpa/model/JPAEdmComplexType.java | 254 ++++
.../core/jpa/model/JPAEdmEntityContainer.java | 154 +++
.../core/jpa/model/JPAEdmEntitySet.java | 112 ++
.../core/jpa/model/JPAEdmEntityType.java | 230 ++++
.../processor/core/jpa/model/JPAEdmFacets.java | 94 ++
.../core/jpa/model/JPAEdmFunctionImport.java | 331 +++++
.../processor/core/jpa/model/JPAEdmKey.java | 129 ++
.../core/jpa/model/JPAEdmMappingImpl.java | 51 +
.../processor/core/jpa/model/JPAEdmModel.java | 65 +
.../jpa/model/JPAEdmNavigationProperty.java | 98 ++
.../core/jpa/model/JPAEdmProperty.java | 378 ++++++
.../jpa/model/JPAEdmReferentialConstraint.java | 147 ++
.../model/JPAEdmReferentialConstraintRole.java | 258 ++++
.../processor/core/jpa/model/JPAEdmSchema.java | 216 +++
.../jpa/model/_JPAEdmFunctionImportBuilder.java | 237 ++++
.../main/resources/jpaprocessor_msg.properties | 61 +
.../core/jpa/ODataExpressionParserTest.java | 515 +++++++
.../core/jpa/ODataJPAContextImplTest.java | 98 ++
.../core/jpa/ODataJPAProcessorDefaultTest.java | 554 ++++++++
.../core/jpa/ODataJPAResponseBuilderTest.java | 566 ++++++++
.../jpa/access/data/JPAEntityParserTest.java | 599 +++++++++
.../JPAEntityParserTestForStaticMethods.java | 251 ++++
.../core/jpa/access/data/JPAEntityTest.java | 187 +++
.../jpa/access/data/JPAExpandCallBackTest.java | 160 +++
.../jpa/access/data/JPAFunctionContextTest.java | 143 ++
.../jpa/access/data/JPAProcessorImplTest.java | 447 +++++++
.../model/JPAEdmMappingModelServiceTest.java | 213 +++
.../jpa/access/model/JPAEdmNameBuilderTest.java | 151 +++
.../jpa/access/model/JPATypeConvertorTest.java | 94 ++
.../core/jpa/common/ODataJPATestConstants.java | 27 +
.../edm/ODataJPAEdmProviderNegativeTest.java | 191 +++
.../core/jpa/edm/ODataJPAEdmProviderTest.java | 385 ++++++
.../core/jpa/jpql/JPQLBuilderFactoryTest.java | 377 ++++++
.../core/jpa/jpql/JPQLJoinContextTest.java | 198 +++
.../jpql/JPQLJoinSelectSingleContextTest.java | 215 +++
...PQLJoinSelectSingleStatementBuilderTest.java | 142 ++
.../jpa/jpql/JPQLJoinStatementBuilderTest.java | 124 ++
.../jpa/jpql/JPQLSelectContextImplTest.java | 385 ++++++
.../jpql/JPQLSelectSingleContextImplTest.java | 198 +++
.../JPQLSelectSingleStatementBuilderTest.java | 123 ++
.../jpql/JPQLSelectStatementBuilderTest.java | 135 ++
.../core/jpa/mock/ODataJPAContextMock.java | 57 +
.../core/jpa/mock/data/EdmMockUtil.java | 337 +++++
.../core/jpa/mock/data/EdmMockUtilV2.java | 324 +++++
.../core/jpa/mock/data/JPATypeMock.java | 205 +++
.../core/jpa/mock/data/ODataEntryMockUtil.java | 127 ++
.../core/jpa/mock/data/SalesOrderHeader.java | 63 +
.../core/jpa/mock/data/SalesOrderLineItem.java | 38 +
.../jpa/mock/data/SalesOrderLineItemKey.java | 52 +
.../core/jpa/mock/model/EdmSchemaMock.java | 213 +++
.../core/jpa/mock/model/JPAAttributeMock.java | 63 +
.../jpa/mock/model/JPACustomProcessorMock.java | 74 ++
.../core/jpa/mock/model/JPAEdmMockData.java | 72 +
.../core/jpa/mock/model/JPAEmbeddableMock.java | 184 +++
.../jpa/mock/model/JPAEmbeddableTypeMock.java | 184 +++
.../core/jpa/mock/model/JPAEntityTypeMock.java | 246 ++++
.../core/jpa/mock/model/JPAJavaMemberMock.java | 74 ++
.../core/jpa/mock/model/JPAManagedTypeMock.java | 184 +++
.../core/jpa/mock/model/JPAMetaModelMock.java | 60 +
.../jpa/mock/model/JPAPluralAttributeMock.java | 95 ++
.../mock/model/JPASingularAttributeMock.java | 94 ++
.../jpa/mock/model/_JPACustomProcessorMock.java | 77 ++
.../model/_JPACustomProcessorNegativeMock.java | 70 +
.../jpa/model/JPAEdmAssociationEndTest.java | 177 +++
.../jpa/model/JPAEdmAssociationSetTest.java | 184 +++
.../core/jpa/model/JPAEdmAssociationTest.java | 423 ++++++
.../core/jpa/model/JPAEdmBaseViewImplTest.java | 89 ++
.../core/jpa/model/JPAEdmComplexTypeTest.java | 268 ++++
.../jpa/model/JPAEdmEntityContainerTest.java | 234 ++++
.../core/jpa/model/JPAEdmEntitySetTest.java | 224 ++++
.../core/jpa/model/JPAEdmEntityTypeTest.java | 198 +++
.../jpa/model/JPAEdmFunctionImportTest.java | 566 ++++++++
.../processor/core/jpa/model/JPAEdmKeyTest.java | 176 +++
.../core/jpa/model/JPAEdmModelTest.java | 145 ++
.../jpa/model/JPAEdmNavigationPropertyTest.java | 218 +++
.../core/jpa/model/JPAEdmPropertyTest.java | 440 ++++++
.../JPAEdmReferentialConstraintRoleTest.java | 233 ++++
.../model/JPAEdmReferentialConstraintTest.java | 177 +++
.../core/jpa/model/JPAEdmSchemaTest.java | 103 ++
.../core/jpa/model/JPAEdmTestModelView.java | 396 ++++++
.../jpa/model/_JPAEdmFunctionImportTest.java | 570 ++++++++
.../SalesOrderProcessingMappingModels.xml | 62 +
odata2-jpa-processor/jpa-ref/.gitignore | 8 +
odata2-jpa-processor/jpa-ref/pom.xml | 109 ++
.../exception/InvalidPartyRoleException.java | 10 +
.../ref/factory/JPAEntityManagerFactory.java | 46 +
.../jpa/processor/ref/model/Activity.java | 59 +
.../jpa/processor/ref/model/ActivityParty.java | 46 +
.../odata2/jpa/processor/ref/model/Address.java | 83 ++
.../ref/model/AppointmentActivity.java | 44 +
.../jpa/processor/ref/model/EmailActivity.java | 46 +
.../jpa/processor/ref/model/Material.java | 116 ++
.../odata2/jpa/processor/ref/model/Note.java | 116 ++
.../jpa/processor/ref/model/PartyRole.java | 5 +
.../processor/ref/model/SalesOrderHeader.java | 236 ++++
.../jpa/processor/ref/model/SalesOrderItem.java | 133 ++
.../processor/ref/model/SalesOrderItemKey.java | 89 ++
.../odata2/jpa/processor/ref/model/Store.java | 92 ++
.../src/main/resources/META-INF/persistence.xml | 41 +
odata2-jpa-processor/jpa-web/.gitignore | 8 +
odata2-jpa-processor/jpa-web/pom.xml | 123 ++
.../extension/SalesOrderHeaderProcessor.java | 115 ++
.../SalesOrderProcessingExtension.java | 38 +
.../extension/_SalesOrderHeaderProcessor.java | 127 ++
.../jpa/processor/ref/util/DataGenerator.java | 158 +++
.../ref/web/JPAReferenceServiceFactory.java | 56 +
.../main/resources/DataDeleteSQLs.properties | 22 +
.../jpa-web/src/main/resources/META-INF/LICENSE | 1252 ++++++++++++++++++
.../src/main/resources/MaterialSQLs.properties | 30 +
.../src/main/resources/NoteSQLs.properties | 20 +
.../main/resources/SQLInsertConfig.properties | 22 +
.../resources/SalesOrderHeaderSQLs.properties | 30 +
.../resources/SalesOrderItemSQLs.properties | 30 +
.../src/main/resources/StoreSQLs.properties | 30 +
.../src/main/resources/serviceConfig.properties | 19 +
.../webapp/SalesOrderProcessingMappingModel.xml | 61 +
.../jpa-web/src/main/webapp/WEB-INF/web.xml | 47 +
.../jpa-web/src/main/webapp/index.jsp | 312 +++++
odata2-jpa-processor/pom.xml | 31 +
odata2-processor-jpa/jpa-api/.gitignore | 8 -
odata2-processor-jpa/jpa-api/pom.xml | 91 --
.../jpa-api/src/main/java/META-INF/MANIFEST.MF | 3 -
.../processor/api/jpa/ODataJPAContext.java | 206 ---
.../processor/api/jpa/ODataJPAProcessor.java | 69 -
.../api/jpa/ODataJPAServiceFactory.java | 190 ---
.../processor/api/jpa/access/JPAEdmBuilder.java | 57 -
.../jpa/access/JPAEdmMappingModelAccess.java | 191 ---
.../processor/api/jpa/access/JPAFunction.java | 85 --
.../processor/api/jpa/access/JPAJoinClause.java | 148 ---
.../api/jpa/access/JPAMethodContext.java | 130 --
.../api/jpa/access/JPAMethodContextView.java | 46 -
.../processor/api/jpa/access/JPAProcessor.java | 260 ----
.../processor/api/jpa/access/package-info.java | 26 -
.../jpa/exception/ODataJPAErrorCallback.java | 45 -
.../api/jpa/exception/ODataJPAException.java | 68 -
.../jpa/exception/ODataJPAMessageService.java | 49 -
.../jpa/exception/ODataJPAModelException.java | 92 --
.../jpa/exception/ODataJPARuntimeException.java | 97 --
.../api/jpa/exception/package-info.java | 31 -
.../api/jpa/factory/JPAAccessFactory.java | 69 -
.../api/jpa/factory/JPQLBuilderFactory.java | 77 --
.../api/jpa/factory/ODataJPAAccessFactory.java | 82 --
.../api/jpa/factory/ODataJPAFactory.java | 105 --
.../processor/api/jpa/factory/package-info.java | 33 -
.../processor/api/jpa/jpql/JPQLContext.java | 204 ---
.../processor/api/jpa/jpql/JPQLContextType.java | 73 -
.../processor/api/jpa/jpql/JPQLContextView.java | 53 -
.../api/jpa/jpql/JPQLJoinContextView.java | 44 -
.../jpql/JPQLJoinSelectSingleContextView.java | 45 -
.../api/jpa/jpql/JPQLSelectContextView.java | 62 -
.../jpa/jpql/JPQLSelectSingleContextView.java | 53 -
.../processor/api/jpa/jpql/JPQLStatement.java | 148 ---
.../processor/api/jpa/jpql/package-info.java | 27 -
.../api/jpa/model/JPAEdmAssociationEndView.java | 91 --
.../api/jpa/model/JPAEdmAssociationSetView.java | 69 -
.../api/jpa/model/JPAEdmAssociationView.java | 128 --
.../processor/api/jpa/model/JPAEdmBaseView.java | 101 --
.../jpa/model/JPAEdmComplexPropertyView.java | 45 -
.../api/jpa/model/JPAEdmComplexTypeView.java | 116 --
.../jpa/model/JPAEdmEntityContainerView.java | 72 -
.../api/jpa/model/JPAEdmEntitySetView.java | 64 -
.../api/jpa/model/JPAEdmEntityTypeView.java | 76 --
.../api/jpa/model/JPAEdmExtension.java | 50 -
.../api/jpa/model/JPAEdmFunctionImportView.java | 51 -
.../processor/api/jpa/model/JPAEdmKeyView.java | 51 -
.../processor/api/jpa/model/JPAEdmMapping.java | 63 -
.../api/jpa/model/JPAEdmModelView.java | 43 -
.../jpa/model/JPAEdmNavigationPropertyView.java | 72 -
.../api/jpa/model/JPAEdmPropertyView.java | 104 --
.../JPAEdmReferentialConstraintRoleView.java | 101 --
.../model/JPAEdmReferentialConstraintView.java | 69 -
.../api/jpa/model/JPAEdmSchemaView.java | 116 --
.../jpa/model/mapping/JPAAttributeMapType.java | 202 ---
.../jpa/model/mapping/JPAEdmMappingModel.java | 79 --
.../mapping/JPAEdmMappingModelFactory.java | 85 --
.../model/mapping/JPAEmbeddableTypeMapType.java | 161 ---
.../mapping/JPAEmbeddableTypesMapType.java | 89 --
.../jpa/model/mapping/JPAEntityTypeMapType.java | 213 ---
.../model/mapping/JPAEntityTypesMapType.java | 89 --
.../mapping/JPAPersistenceUnitMapType.java | 157 ---
.../model/mapping/JPARelationshipMapType.java | 175 ---
.../api/jpa/model/mapping/package-info.java | 28 -
.../processor/api/jpa/model/package-info.java | 27 -
.../odata2/processor/api/jpa/package-info.java | 33 -
.../src/main/resources/JPAEDMMappingModel.xsd | 165 ---
odata2-processor-jpa/jpa-core/.gitignore | 8 -
odata2-processor-jpa/jpa-core/pom.xml | 146 --
.../jpa-core/src/main/java/META-INF/MANIFEST.MF | 3 -
.../processor/core/jpa/ODataEntityParser.java | 163 ---
.../core/jpa/ODataExpressionParser.java | 381 ------
.../processor/core/jpa/ODataJPAContextImpl.java | 146 --
.../core/jpa/ODataJPAProcessorDefault.java | 194 ---
.../core/jpa/ODataJPAResponseBuilder.java | 629 ---------
.../core/jpa/access/data/JPAEntity.java | 355 -----
.../core/jpa/access/data/JPAEntityParser.java | 453 -------
.../core/jpa/access/data/JPAExpandCallBack.java | 180 ---
.../jpa/access/data/JPAFunctionContext.java | 170 ---
.../processor/core/jpa/access/data/JPALink.java | 225 ----
.../core/jpa/access/data/JPAProcessorImpl.java | 491 -------
.../core/jpa/access/model/EdmTypeConvertor.java | 69 -
.../access/model/JPAEdmMappingModelService.java | 247 ----
.../jpa/access/model/JPAEdmNameBuilder.java | 499 -------
.../core/jpa/access/model/JPATypeConvertor.java | 119 --
.../core/jpa/edm/ODataJPAEdmProvider.java | 295 -----
.../ODataJPAMessageServiceDefault.java | 122 --
.../core/jpa/factory/ODataJPAFactoryImpl.java | 237 ----
.../core/jpa/jpql/JPQLJoinSelectContext.java | 171 ---
.../jpa/jpql/JPQLJoinSelectSingleContext.java | 158 ---
.../JPQLJoinSelectSingleStatementBuilder.java | 106 --
.../core/jpa/jpql/JPQLJoinStatementBuilder.java | 145 --
.../core/jpa/jpql/JPQLSelectContext.java | 159 ---
.../core/jpa/jpql/JPQLSelectSingleContext.java | 109 --
.../jpql/JPQLSelectSingleStatementBuilder.java | 66 -
.../jpa/jpql/JPQLSelectStatementBuilder.java | 98 --
.../core/jpa/model/JPAEdmAssociation.java | 237 ----
.../core/jpa/model/JPAEdmAssociationEnd.java | 183 ---
.../core/jpa/model/JPAEdmAssociationSet.java | 131 --
.../core/jpa/model/JPAEdmBaseViewImpl.java | 101 --
.../core/jpa/model/JPAEdmComplexType.java | 254 ----
.../core/jpa/model/JPAEdmEntityContainer.java | 154 ---
.../core/jpa/model/JPAEdmEntitySet.java | 112 --
.../core/jpa/model/JPAEdmEntityType.java | 230 ----
.../processor/core/jpa/model/JPAEdmFacets.java | 94 --
.../core/jpa/model/JPAEdmFunctionImport.java | 331 -----
.../processor/core/jpa/model/JPAEdmKey.java | 129 --
.../core/jpa/model/JPAEdmMappingImpl.java | 51 -
.../processor/core/jpa/model/JPAEdmModel.java | 65 -
.../jpa/model/JPAEdmNavigationProperty.java | 98 --
.../core/jpa/model/JPAEdmProperty.java | 378 ------
.../jpa/model/JPAEdmReferentialConstraint.java | 147 --
.../model/JPAEdmReferentialConstraintRole.java | 258 ----
.../processor/core/jpa/model/JPAEdmSchema.java | 216 ---
.../jpa/model/_JPAEdmFunctionImportBuilder.java | 237 ----
.../main/resources/jpaprocessor_msg.properties | 61 -
.../jpa-core/src/test/java/META-INF/MANIFEST.MF | 3 -
.../core/jpa/ODataExpressionParserTest.java | 515 -------
.../core/jpa/ODataJPAContextImplTest.java | 98 --
.../core/jpa/ODataJPAProcessorDefaultTest.java | 554 --------
.../core/jpa/ODataJPAResponseBuilderTest.java | 566 --------
.../jpa/access/data/JPAEntityParserTest.java | 599 ---------
.../JPAEntityParserTestForStaticMethods.java | 251 ----
.../core/jpa/access/data/JPAEntityTest.java | 187 ---
.../jpa/access/data/JPAExpandCallBackTest.java | 160 ---
.../jpa/access/data/JPAFunctionContextTest.java | 143 --
.../jpa/access/data/JPAProcessorImplTest.java | 447 -------
.../model/JPAEdmMappingModelServiceTest.java | 213 ---
.../jpa/access/model/JPAEdmNameBuilderTest.java | 151 ---
.../jpa/access/model/JPATypeConvertorTest.java | 94 --
.../core/jpa/common/ODataJPATestConstants.java | 27 -
.../edm/ODataJPAEdmProviderNegativeTest.java | 191 ---
.../core/jpa/edm/ODataJPAEdmProviderTest.java | 385 ------
.../core/jpa/jpql/JPQLBuilderFactoryTest.java | 377 ------
.../core/jpa/jpql/JPQLJoinContextTest.java | 198 ---
.../jpql/JPQLJoinSelectSingleContextTest.java | 215 ---
...PQLJoinSelectSingleStatementBuilderTest.java | 142 --
.../jpa/jpql/JPQLJoinStatementBuilderTest.java | 124 --
.../jpa/jpql/JPQLSelectContextImplTest.java | 385 ------
.../jpql/JPQLSelectSingleContextImplTest.java | 198 ---
.../JPQLSelectSingleStatementBuilderTest.java | 123 --
.../jpql/JPQLSelectStatementBuilderTest.java | 135 --
.../core/jpa/mock/ODataJPAContextMock.java | 57 -
.../core/jpa/mock/data/EdmMockUtil.java | 337 -----
.../core/jpa/mock/data/EdmMockUtilV2.java | 324 -----
.../core/jpa/mock/data/JPATypeMock.java | 205 ---
.../core/jpa/mock/data/ODataEntryMockUtil.java | 127 --
.../core/jpa/mock/data/SalesOrderHeader.java | 63 -
.../core/jpa/mock/data/SalesOrderLineItem.java | 38 -
.../jpa/mock/data/SalesOrderLineItemKey.java | 52 -
.../core/jpa/mock/model/EdmSchemaMock.java | 213 ---
.../core/jpa/mock/model/JPAAttributeMock.java | 63 -
.../jpa/mock/model/JPACustomProcessorMock.java | 74 --
.../core/jpa/mock/model/JPAEdmMockData.java | 72 -
.../core/jpa/mock/model/JPAEmbeddableMock.java | 184 ---
.../jpa/mock/model/JPAEmbeddableTypeMock.java | 184 ---
.../core/jpa/mock/model/JPAEntityTypeMock.java | 246 ----
.../core/jpa/mock/model/JPAJavaMemberMock.java | 74 --
.../core/jpa/mock/model/JPAManagedTypeMock.java | 184 ---
.../core/jpa/mock/model/JPAMetaModelMock.java | 60 -
.../jpa/mock/model/JPAPluralAttributeMock.java | 95 --
.../mock/model/JPASingularAttributeMock.java | 94 --
.../jpa/mock/model/_JPACustomProcessorMock.java | 77 --
.../model/_JPACustomProcessorNegativeMock.java | 70 -
.../jpa/model/JPAEdmAssociationEndTest.java | 177 ---
.../jpa/model/JPAEdmAssociationSetTest.java | 184 ---
.../core/jpa/model/JPAEdmAssociationTest.java | 422 ------
.../core/jpa/model/JPAEdmBaseViewImplTest.java | 89 --
.../core/jpa/model/JPAEdmComplexTypeTest.java | 268 ----
.../jpa/model/JPAEdmEntityContainerTest.java | 234 ----
.../core/jpa/model/JPAEdmEntitySetTest.java | 224 ----
.../core/jpa/model/JPAEdmEntityTypeTest.java | 198 ---
.../jpa/model/JPAEdmFunctionImportTest.java | 566 --------
.../processor/core/jpa/model/JPAEdmKeyTest.java | 176 ---
.../core/jpa/model/JPAEdmModelTest.java | 145 --
.../jpa/model/JPAEdmNavigationPropertyTest.java | 218 ---
.../core/jpa/model/JPAEdmPropertyTest.java | 440 ------
.../JPAEdmReferentialConstraintRoleTest.java | 233 ----
.../model/JPAEdmReferentialConstraintTest.java | 177 ---
.../core/jpa/model/JPAEdmSchemaTest.java | 103 --
.../core/jpa/model/JPAEdmTestModelView.java | 396 ------
.../jpa/model/_JPAEdmFunctionImportTest.java | 570 --------
.../SalesOrderProcessingMappingModels.xml | 62 -
odata2-processor-jpa/jpa-ref/.gitignore | 8 -
odata2-processor-jpa/jpa-ref/pom.xml | 109 --
.../ref/factory/JPAEntityManagerFactory.java | 46 -
.../odata2/jpa/processor/ref/model/Address.java | 83 --
.../jpa/processor/ref/model/Material.java | 116 --
.../odata2/jpa/processor/ref/model/Note.java | 116 --
.../processor/ref/model/SalesOrderHeader.java | 236 ----
.../jpa/processor/ref/model/SalesOrderItem.java | 133 --
.../processor/ref/model/SalesOrderItemKey.java | 89 --
.../odata2/jpa/processor/ref/model/Store.java | 92 --
.../src/main/resources/META-INF/persistence.xml | 46 -
odata2-processor-jpa/jpa-web/.gitignore | 8 -
odata2-processor-jpa/jpa-web/pom.xml | 123 --
.../extension/SalesOrderHeaderProcessor.java | 115 --
.../SalesOrderProcessingExtension.java | 38 -
.../extension/_SalesOrderHeaderProcessor.java | 127 --
.../jpa/processor/ref/util/DataGenerator.java | 158 ---
.../ref/web/JPAReferenceServiceFactory.java | 56 -
.../main/resources/DataDeleteSQLs.properties | 22 -
.../jpa-web/src/main/resources/META-INF/LICENSE | 1252 ------------------
.../src/main/resources/MaterialSQLs.properties | 30 -
.../src/main/resources/NoteSQLs.properties | 20 -
.../main/resources/SQLInsertConfig.properties | 22 -
.../resources/SalesOrderHeaderSQLs.properties | 30 -
.../resources/SalesOrderItemSQLs.properties | 30 -
.../src/main/resources/StoreSQLs.properties | 30 -
.../src/main/resources/serviceConfig.properties | 19 -
.../webapp/SalesOrderProcessingMappingModel.xml | 62 -
.../jpa-web/src/main/webapp/WEB-INF/web.xml | 47 -
.../jpa-web/src/main/webapp/index.jsp | 312 -----
odata2-processor-jpa/pom.xml | 31 -
pom.xml | 2 +-
430 files changed, 33622 insertions(+), 33426 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-api/.gitignore
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-api/.gitignore b/odata2-jpa-processor/jpa-api/.gitignore
new file mode 100644
index 0000000..fe5d89b
--- /dev/null
+++ b/odata2-jpa-processor/jpa-api/.gitignore
@@ -0,0 +1,8 @@
+.project
+.classpath
+.settings
+target
+bin
+*.bak
+classes
+.DS_Store
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-api/pom.xml
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-api/pom.xml b/odata2-jpa-processor/jpa-api/pom.xml
new file mode 100644
index 0000000..d0c8e0b
--- /dev/null
+++ b/odata2-jpa-processor/jpa-api/pom.xml
@@ -0,0 +1,91 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.olingo</groupId>
+ <artifactId>olingo-odata2-jpa-processor-incubating</artifactId>
+ <version>1.1.0-SNAPSHOT</version>
+ <relativePath>../</relativePath>
+ </parent>
+
+ <artifactId>olingo-odata2-jpa-processor-api-incubating</artifactId>
+ <packaging>jar</packaging>
+ <name>${project.artifactId}</name>
+
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-jar-plugin</artifactId>
+ <configuration>
+ <archive>
+ <manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
+ </archive>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <extensions>true</extensions>
+ <executions>
+ <execution>
+ <id>bundle-manifest</id>
+ <phase>process-classes</phase>
+ <goals>
+ <goal>manifest</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <instructions>
+ <Import-Package>
+ org.apache.olingo.odata2.processor.core.jpa.factory;resolution:=optional,
+ *
+ </Import-Package>
+ <Export-Package>
+ org.apache.olingo.odata2.processor.api.*;version=${project.version}
+ </Export-Package>
+ <Bundle-DocURL>${project.url}</Bundle-DocURL>
+ <Bundle-ActivationPolicy>lazy</Bundle-ActivationPolicy>
+ <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
+ </instructions>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+ <dependencies>
+ <!-- JPA Support -->
+ <dependency>
+ <groupId>org.eclipse.persistence</groupId>
+ <artifactId>javax.persistence</artifactId>
+ <version>${version.javax.persistence}</version>
+ </dependency>
+
+ <!-- OData Java Library -->
+ <dependency>
+ <groupId>org.apache.olingo</groupId>
+ <artifactId>olingo-odata2-api-incubating</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+</project>
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/ODataJPAContext.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/ODataJPAContext.java b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/ODataJPAContext.java
new file mode 100644
index 0000000..9974434
--- /dev/null
+++ b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/ODataJPAContext.java
@@ -0,0 +1,206 @@
+/*******************************************************************************
+ * 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.api.jpa;
+
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+
+import org.apache.olingo.odata2.api.edm.provider.EdmProvider;
+import org.apache.olingo.odata2.api.processor.ODataContext;
+import org.apache.olingo.odata2.api.processor.ODataProcessor;
+import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmExtension;
+
+/**
+ * This class does the compilation of context objects required for OData JPA
+ * Runtime. The context object should be properly initialized with values else
+ * the behavior of processor and EDM provider can result in exception.
+ *
+ * Following are the mandatory parameter to be set into the context object
+ * <ol>
+ * <li>Persistence Unit Name</li>
+ * <li>An instance of Java Persistence Entity Manager Factory</li>
+ * </ol>
+ *
+ * <br>
+ * @org.apache.olingo.odata2.DoNotImplement
+ * @see org.apache.olingo.odata2.processor.api.jpa.factory.ODataJPAFactory
+ * @see org.apache.olingo.odata2.processor.api.jpa.factory.ODataJPAAccessFactory
+ *
+ */
+public interface ODataJPAContext {
+
+ /**
+ * The method gets the Java Persistence Unit Name set into the context.
+ *
+ * @return Java Persistence Unit Name
+ */
+ public String getPersistenceUnitName();
+
+ /**
+ * The method sets the Java Persistence Unit Name into the context.
+ *
+ * @param pUnitName
+ * is the Java Persistence Unit Name.
+ *
+ */
+ public void setPersistenceUnitName(String pUnitName);
+
+ /**
+ * The method gets the OData Processor for JPA from the context.
+ *
+ * @return OData JPA Processor
+ */
+ public ODataProcessor getODataProcessor();
+
+ /**
+ * The method sets the OData Processor for JPA into the context.
+ *
+ * @param processor
+ * is the specific implementation of {@link org.apache.olingo.odata2.processor.api.jpa.ODataJPAProcessor} for
+ * processing OData service requests.
+ */
+ public void setODataProcessor(ODataProcessor processor);
+
+ /**
+ * The method gets the EDM provider for JPA from the context.
+ *
+ * @return EDM provider
+ */
+ public EdmProvider getEdmProvider();
+
+ /**
+ * The method sets EDM provider into the context
+ *
+ * @param edmProvider
+ * is the specific implementation of {@link org.apache.olingo.odata2.api.edm.provider.EdmProvider} for
+ * transforming Java persistence models to Entity Data Model
+ *
+ */
+ public void setEdmProvider(EdmProvider edmProvider);
+
+ /**
+ * The method gets the Java Persistence Entity Manager factory from the
+ * context. <br>
+ * <b>CAUTION:-</b> Don't use the Entity Manager Factory to instantiate
+ * Entity Managers. Instead get reference to Entity Manager using
+ * {@link org.apache.olingo.odata2.processor.api.jpa.ODataJPAContext#getEntityManager()}
+ *
+ * @return an instance of Java Persistence Entity Manager Factory
+ */
+ public EntityManagerFactory getEntityManagerFactory();
+
+ /**
+ * The method sets the Java Persistence Entity Manager factory into the
+ * context.
+ *
+ * @param emf
+ * is of type {@link javax.persistence.EntityManagerFactory}
+ *
+ */
+ public void setEntityManagerFactory(EntityManagerFactory emf);
+
+ /**
+ * The method gets OData Context into the context.
+ *
+ * @return OData Context
+ */
+ public ODataContext getODataContext();
+
+ /**
+ * The method sets OData context into the context.
+ *
+ * @param ctx
+ * is an OData context of type {@link org.apache.olingo.odata2.api.processor.ODataContext}
+ */
+ public void setODataContext(ODataContext ctx);
+
+ /**
+ * The method sets the JPA EDM mapping model name into the context. JPA EDM
+ * mapping model is an XML document based on JPAEDMMappingModel.xsd
+ *
+ * @param name
+ * is the name of JPA EDM mapping model
+ */
+ public void setJPAEdmMappingModel(String name);
+
+ /**
+ * The method gets the JPA EDM mapping model name from the context.
+ *
+ * @return name of JPA EDM mapping model
+ */
+ public String getJPAEdmMappingModel();
+
+ /**
+ * The method returns an instance of type entity manager. The entity manager
+ * thus returns a single persistence context for the current OData request.
+ * Hence all entities that are accessed within JPA processor are managed by
+ * single entity manager.
+ *
+ * @return an instance of type {@link javax.persistence.EntityManager}
+ */
+ public EntityManager getEntityManager();
+
+ /**
+ * The method sets the JPA Edm Extension instance into the context. There
+ * can be at most only one extension for a context. Invoking the method
+ * several times overwrites already set extension instance in the context.
+ *
+ * @param jpaEdmExtension
+ * is an instance of type {@link org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmExtension}
+ *
+ */
+ public void setJPAEdmExtension(JPAEdmExtension jpaEdmExtension);
+
+ /**
+ * The method returns the JPA Edm Extension instance set into the context.
+ *
+ * @return an instance of type
+ * {@link org.apache.olingo.odata2.processor.api.jpa.model.mapping.JPAEmbeddableTypeMapType}
+ */
+ public JPAEdmExtension getJPAEdmExtension();
+
+ /**
+ * The method sets into the context whether the library should consider default naming for
+ * <ul><li>EdmProperty</li>
+ * <li>EdmComplexProperty</li>
+ * <li>EdmNavigationProperty</li></ul>
+ *
+ * @param defaultNaming is a boolean value that indicates if set to
+ * <ul><li>true - default naming is considered in case no mapping is provided.</li>
+ * <li>false - default naming is not considered in case no mapping is provided. The
+ * name provided in JPA Entity Model is considered.</li>
+ * </ul>
+ */
+ public void setDefaultNaming(boolean defaultNaming);
+
+ /**
+ * The method returns whether the library should consider default naming for
+ * <ul><li>EdmProperty</li>
+ * <li>EdmComplexProperty</li>
+ * <li>EdmNavigationProperty</li></ul>
+ *
+ * @return
+ * <ul><li>true - default naming is considered in case no mapping is provided.</li>
+ * <li>false - default naming is not considered in case no mapping is provided. The
+ * name provided in JPA Entity Model is considered.</li>
+ * </ul>
+ */
+ public boolean getDefaultNaming();
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/ODataJPAProcessor.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/ODataJPAProcessor.java b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/ODataJPAProcessor.java
new file mode 100644
index 0000000..441d38e
--- /dev/null
+++ b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/ODataJPAProcessor.java
@@ -0,0 +1,69 @@
+/*******************************************************************************
+ * 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.api.jpa;
+
+import org.apache.olingo.odata2.api.processor.ODataSingleProcessor;
+import org.apache.olingo.odata2.processor.api.jpa.access.JPAProcessor;
+import org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPAException;
+import org.apache.olingo.odata2.processor.api.jpa.factory.ODataJPAFactory;
+
+/**
+ * Extend this class and implement an OData JPA processor if the default
+ * behavior of OData JPA Processor library has to be overwritten.
+ *
+ *
+ *
+ *
+ */
+public abstract class ODataJPAProcessor extends ODataSingleProcessor {
+
+ /**
+ * An instance of {@link org.apache.olingo.odata2.processor.api.jpa.ODataJPAContext} object
+ */
+ protected ODataJPAContext oDataJPAContext;
+
+ /**
+ * An instance of {@link org.apache.olingo.odata2.processor.api.jpa.access.JPAProcessor}. The
+ * instance is created using {@link org.apache.olingo.odata2.processor.api.jpa.factory.JPAAccessFactory}.
+ */
+ protected JPAProcessor jpaProcessor;
+
+ public ODataJPAContext getOdataJPAContext() {
+ return oDataJPAContext;
+ }
+
+ public void setOdataJPAContext(final ODataJPAContext odataJPAContext) {
+ oDataJPAContext = odataJPAContext;
+ }
+
+ /**
+ * Constructor
+ *
+ * @param oDataJPAContext
+ * non null OData JPA Context object
+ */
+ public ODataJPAProcessor(final ODataJPAContext oDataJPAContext) {
+ if (oDataJPAContext == null) {
+ throw new IllegalArgumentException(ODataJPAException.ODATA_JPACTX_NULL);
+ }
+ this.oDataJPAContext = oDataJPAContext;
+ jpaProcessor = ODataJPAFactory.createFactory().getJPAAccessFactory().getJPAProcessor(this.oDataJPAContext);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/ODataJPAServiceFactory.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/ODataJPAServiceFactory.java b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/ODataJPAServiceFactory.java
new file mode 100644
index 0000000..4968107
--- /dev/null
+++ b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/ODataJPAServiceFactory.java
@@ -0,0 +1,190 @@
+/*******************************************************************************
+ * 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.api.jpa;
+
+import org.apache.olingo.odata2.api.ODataCallback;
+import org.apache.olingo.odata2.api.ODataService;
+import org.apache.olingo.odata2.api.ODataServiceFactory;
+import org.apache.olingo.odata2.api.edm.provider.EdmProvider;
+import org.apache.olingo.odata2.api.exception.ODataException;
+import org.apache.olingo.odata2.api.processor.ODataContext;
+import org.apache.olingo.odata2.api.processor.ODataErrorCallback;
+import org.apache.olingo.odata2.api.processor.ODataSingleProcessor;
+import org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPAErrorCallback;
+import org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPARuntimeException;
+import org.apache.olingo.odata2.processor.api.jpa.factory.ODataJPAAccessFactory;
+import org.apache.olingo.odata2.processor.api.jpa.factory.ODataJPAFactory;
+
+/**
+ * <p>
+ * Extend this factory class and create own instance of {@link org.apache.olingo.odata2.api.ODataService} that
+ * transforms Java Persistence
+ * Models into an OData Service. The factory class instantiates instances of
+ * type {@link org.apache.olingo.odata2.api.edm.provider.EdmProvider} and
+ * {@link org.apache.olingo.odata2.api.processor.ODataSingleProcessor}. The OData
+ * JPA Processor library provides a default implementation for EdmProvider and
+ * OData Single Processor.
+ * </p>
+ * <p>
+ * The factory implementation is passed as servlet init parameter to a JAX-RS
+ * runtime which will instantiate a {@link org.apache.olingo.odata2.api.ODataService} implementation using this factory.
+ * </p>
+ *
+ * <p>
+ * <b>Mandatory:</b> Implement the abstract method initializeODataJPAContext. Fill
+ * {@link org.apache.olingo.odata2.processor.api.jpa.ODataJPAContext} with context
+ * values.
+ * </p>
+ *
+ * <b>Sample Configuration:</b>
+ *
+ * <pre> {@code
+ * <servlet>
+ * <servlet-name>ReferenceScenarioServlet</servlet-name>
+ * <servlet-class>org.apache.cxf.jaxrs.servlet.CXFNonSpringJaxrsServlet</servlet-class>
+ * <init-param>
+ * <param-name>javax.ws.rs.Application</param-name>
+ * <param-value>org.apache.olingo.odata2.core.rest.ODataApplication</param-value>
+ * </init-param>
+ * <init-param>
+ * <param-name>org.apache.olingo.odata2.processor.factory</param-name>
+ * <param-value>foo.bar.sample.processor.SampleProcessorFactory</param-value>
+ * </init-param>
+ * <init-param>
+ * <param-name>org.apache.olingo.odata2.path.split</param-name>
+ * <param-value>2</param-value>
+ * </init-param>
+ * <load-on-startup>1</load-on-startup>
+ * </servlet>
+ * } </pre>
+ */
+
+public abstract class ODataJPAServiceFactory extends ODataServiceFactory {
+
+ private ODataJPAContext oDataJPAContext;
+ private ODataContext oDataContext;
+ private boolean setDetailErrors = false;
+
+ /**
+ * Creates an OData Service based on the values set in
+ * {@link org.apache.olingo.odata2.processor.api.jpa.ODataJPAContext} and
+ * {@link org.apache.olingo.odata2.api.processor.ODataContext}.
+ */
+ @Override
+ public final ODataService createService(final ODataContext ctx) throws ODataException {
+
+ oDataContext = ctx;
+
+ // Initialize OData JPA Context
+ oDataJPAContext = initializeODataJPAContext();
+
+ validatePreConditions();
+
+ ODataJPAFactory factory = ODataJPAFactory.createFactory();
+ ODataJPAAccessFactory accessFactory = factory.getODataJPAAccessFactory();
+
+ // OData JPA Processor
+ if (oDataJPAContext.getODataContext() == null) {
+ oDataJPAContext.setODataContext(ctx);
+ }
+
+ ODataSingleProcessor odataJPAProcessor = accessFactory.createODataProcessor(oDataJPAContext);
+
+ // OData Entity Data Model Provider based on JPA
+ EdmProvider edmProvider = accessFactory.createJPAEdmProvider(oDataJPAContext);
+
+ return createODataSingleProcessorService(edmProvider, odataJPAProcessor);
+ }
+
+ private void validatePreConditions() throws ODataJPARuntimeException {
+
+ if (oDataJPAContext.getEntityManagerFactory() == null) {
+ throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.ENTITY_MANAGER_NOT_INITIALIZED, null);
+ }
+
+ }
+
+ /**
+ * Implement this method and initialize OData JPA Context. It is mandatory
+ * to set an instance of type {@link javax.persistence.EntityManagerFactory} into the context. An exception of type
+ * {@link org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPARuntimeException} is thrown if
+ * EntityManagerFactory is not initialized. <br>
+ * <br>
+ * <b>Sample Code:</b> <code>
+ * <p>public class JPAReferenceServiceFactory extends ODataJPAServiceFactory{</p>
+ *
+ * <blockquote>private static final String PUNIT_NAME = "punit";
+ * <br>
+ * public ODataJPAContext initializeODataJPAContext() {
+ * <blockquote>ODataJPAContext oDataJPAContext = this.getODataJPAContext();
+ * <br>
+ * EntityManagerFactory emf = Persistence.createEntityManagerFactory(PUNIT_NAME);
+ * <br>
+ * oDataJPAContext.setEntityManagerFactory(emf);
+ * oDataJPAContext.setPersistenceUnitName(PUNIT_NAME);
+ * <br> return oDataJPAContext;</blockquote>
+ * }</blockquote>
+ * } </code>
+ * <p>
+ *
+ * @return an instance of type {@link org.apache.olingo.odata2.processor.api.jpa.ODataJPAContext}
+ * @throws ODataJPARuntimeException
+ */
+ public abstract ODataJPAContext initializeODataJPAContext() throws ODataJPARuntimeException;
+
+ /**
+ * @return an instance of type {@link ODataJPAContext}
+ * @throws ODataJPARuntimeException
+ */
+ public final ODataJPAContext getODataJPAContext() throws ODataJPARuntimeException {
+ if (oDataJPAContext == null) {
+ oDataJPAContext = ODataJPAFactory.createFactory().getODataJPAAccessFactory().createODataJPAContext();
+ }
+ if (oDataContext != null) {
+ oDataJPAContext.setODataContext(oDataContext);
+ }
+ return oDataJPAContext;
+
+ }
+
+ /**
+ * The method sets the context whether a detail error message should be thrown
+ * or a less detail error message should be thrown by the library.
+ * @param setDetailErrors takes
+ * <ul><li>true - to indicate that library should throw a detailed error message</li>
+ * <li>false - to indicate that library should not throw a detailed error message</li>
+ * </ul>
+ *
+ */
+ protected void setDetailErrors(final boolean setDetailErrors) {
+ this.setDetailErrors = setDetailErrors;
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public <T extends ODataCallback> T getCallback(final Class<? extends ODataCallback> callbackInterface) {
+ if (setDetailErrors == true) {
+ if (callbackInterface.isAssignableFrom(ODataErrorCallback.class)) {
+ return (T) new ODataJPAErrorCallback();
+ }
+ }
+ return null;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/access/JPAEdmBuilder.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/access/JPAEdmBuilder.java b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/access/JPAEdmBuilder.java
new file mode 100644
index 0000000..110a1f1
--- /dev/null
+++ b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/access/JPAEdmBuilder.java
@@ -0,0 +1,57 @@
+/*******************************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ ******************************************************************************/
+package org.apache.olingo.odata2.processor.api.jpa.access;
+
+import org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPAModelException;
+import org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPARuntimeException;
+
+/**
+ * JPAEdmBuilder interface provides methods for building elements of an Entity Data Model (EDM) from
+ * a Java Persistence Model.
+ *
+ *
+ *
+ */
+public interface JPAEdmBuilder {
+ /**
+ * The Method builds EDM Elements by transforming JPA MetaModel. The method
+ * processes EDM JPA Containers which could be accessed using the following
+ * views,
+ * <ul>
+ * <li> {@link org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmAssociationSetView} </li>
+ * <li> {@link org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmAssociationView}</li>
+ * <li> {@link org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmBaseView}</li>
+ * <li> {@link org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmComplexPropertyView} </li>
+ * <li> {@link org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmComplexTypeView}</li>
+ * <li> {@link org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmEntityContainerView} </li>
+ * <li> {@link org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmEntitySetView}</li>
+ * <li> {@link org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmEntityTypeView}</li>
+ * <li> {@link org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmKeyView}</li>
+ * <li> {@link org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmModelView}</li>
+ * <li> {@link org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmNavigationPropertyView} </li>
+ * <li> {@link org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmPropertyView}</li>
+ * <li> {@link org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmReferentialConstraintRoleView} </li>
+ * <li> {@link org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmReferentialConstraintView} </li>
+ * <li> {@link org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmSchemaView}</li>
+ * </ul>
+ *
+ * @throws ODataJPARuntimeException
+ **/
+ public void build() throws ODataJPAModelException, ODataJPARuntimeException;
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/access/JPAEdmMappingModelAccess.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/access/JPAEdmMappingModelAccess.java b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/access/JPAEdmMappingModelAccess.java
new file mode 100644
index 0000000..216db55
--- /dev/null
+++ b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/access/JPAEdmMappingModelAccess.java
@@ -0,0 +1,191 @@
+/*******************************************************************************
+ * 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.api.jpa.access;
+
+import org.apache.olingo.odata2.processor.api.jpa.model.mapping.JPAEdmMappingModel;
+
+/**
+ * Interface provides methods to access JPA EDM mapping model.
+ *
+ *
+ * @see JPAEdmMappingModel
+ *
+ */
+public interface JPAEdmMappingModelAccess {
+
+ /**
+ * The method searches and loads the mapping model stored in <file>.xml
+ * file into the java object {@link org.apache.olingo.odata2.processor.api.jpa.model.mapping.JPAEdmMappingModel} . The
+ * name of the file is set into ODataJPAContext method.
+ *
+ * @see org.apache.olingo.odata2.processor.api.jpa.ODataJPAContext#setJPAEdmMappingModel(String)
+ */
+ public void loadMappingModel();
+
+ /**
+ * The method returns if there exists a mapping model.
+ *
+ * @return true - if there exists a mapping model for the OData service else
+ * false
+ */
+ public boolean isMappingModelExists();
+
+ /**
+ * The method returns a JPA EDM mapping model Java object. The mapping model
+ * in XML files is un-marshaled into the Java object.
+ *
+ * @return an instance of type {@link org.apache.olingo.odata2.processor.api.jpa.model.mapping.JPAEdmMappingModel}
+ */
+ public JPAEdmMappingModel getJPAEdmMappingModel();
+
+ /**
+ * The method returns EDM Schema namespace for the persistence unit name
+ *
+ * @param persistenceUnitName
+ * is the Java persistence unit name
+ * @return EDM schema name space mapped to Java persistence unit name or
+ * null if no mapping is available
+ */
+ public String mapJPAPersistenceUnit(String persistenceUnitName);
+
+ /**
+ * The method returns EDM entity type name for the Java persistence entity
+ * type name
+ *
+ * @param jpaEntityTypeName
+ * is the Java persistence entity type name
+ * @return EDM entity type name mapped to Java persistence entity type name
+ * or null if no mapping is available
+ */
+ public String mapJPAEntityType(String jpaEntityTypeName);
+
+ /**
+ * The method returns EDM entity set name for the Java persistence entity
+ * type name
+ *
+ * @param jpaEntityTypeName
+ * is the Java persistence entity type name
+ * @return EDM entity set name mapped to Java persistence entity type name
+ * or null if no mapping is available
+ */
+ public String mapJPAEntitySet(String jpaEntityTypeName);
+
+ /**
+ * The method returns EDM property name for the Java persistence entity
+ * attribute name.
+ *
+ * @param jpaEntityTypeName
+ * is the Java persistence entity type name
+ * @param jpaAttributeName
+ * is the Java persistence attribute name
+ * @return EDM property name mapped to Java persistence attribute name or
+ * null if no mapping is available
+ */
+ public String mapJPAAttribute(String jpaEntityTypeName, String jpaAttributeName);
+
+ /**
+ * The method returns EDM navigation property name for the Java persistence
+ * entity relationship name.
+ *
+ * @param jpaEntityTypeName
+ * is the Java persistence entity type name
+ * @param jpaRelationshipName
+ * is the Java persistence relationship name
+ * @return EDM navigation property name mapped to Java persistence entity
+ * relationship name or null if no mapping is available
+ */
+ public String mapJPARelationship(String jpaEntityTypeName, String jpaRelationshipName);
+
+ /**
+ * The method returns EDM complex type name for the Java embeddable type
+ * name.
+ *
+ * @param jpaEmbeddableTypeName
+ * is the Java persistence embeddable type name
+ * @return EDM complex type name mapped to Java persistence entity
+ * relationship name or null if no mapping is available
+ */
+ public String mapJPAEmbeddableType(String jpaEmbeddableTypeName);
+
+ /**
+ * The method returns EDM property name for the Java persistence embeddable
+ * type's attribute name.
+ *
+ * @param jpaEmbeddableTypeName
+ * is the Java persistence
+ * @param jpaAttributeName
+ * is the Java persistence attribute name
+ * @return EDM property name mapped to Java persistence attribute name or
+ * null if no mapping is available
+ */
+ public String mapJPAEmbeddableTypeAttribute(String jpaEmbeddableTypeName, String jpaAttributeName);
+
+ /**
+ * The method returns whether the JPA Entity should be excluded from EDM
+ * model
+ *
+ * @param jpaEntityTypeName
+ * is the name of JPA Entity Type
+ * @return <b>true</b> - if JPA Entity should be excluded<br>
+ * <b>false</b> - if JPA Entity should be not be excluded
+ *
+ */
+ public boolean checkExclusionOfJPAEntityType(String jpaEntityTypeName);
+
+ /**
+ * The method returns whether the JPA Attribute should be excluded from EDM
+ * Entity Type
+ *
+ * @param jpaEntityTypeName
+ * is the name of JPA Entity Type
+ * @param jpaAttributeName
+ * is the name of JPA attribute
+ * @return <b>true</b> - if JPA attribute should be excluded<br>
+ * <b>false</b> - if JPA attribute should be not be excluded
+ *
+ */
+ public boolean checkExclusionOfJPAAttributeType(String jpaEntityTypeName, String jpaAttributeName);
+
+ /**
+ * The method returns whether the JPA Embeddable Type should be excluded
+ * from EDM model
+ *
+ * @param jpaEmbeddableTypeName
+ * is the name of JPA Embeddable Type
+ * @return <b>true</b> - if JPA Embeddable Type should be excluded<br>
+ * <b>false</b> - if JPA Embeddable Type should be not be excluded
+ *
+ */
+ public boolean checkExclusionOfJPAEmbeddableType(String jpaEmbeddableTypeName);
+
+ /**
+ * The method returns whether the JPA Embeddable Attribute Type should be
+ * excluded from EDM model
+ *
+ * @param jpaEmbeddableTypeName
+ * is the name of JPA Embeddable Attribute Type
+ * @param jpaAttributeName
+ * is the name of JPA Attribute name
+ * @return <b>true</b> - if JPA Embeddable Attribute Type should be excluded<br>
+ * <b>false</b> - if JPA Embeddable Attribute Type should be not be
+ * excluded
+ *
+ */
+ public boolean checkExclusionOfJPAEmbeddableAttributeType(String jpaEmbeddableTypeName, String jpaAttributeName);
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/access/JPAFunction.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/access/JPAFunction.java b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/access/JPAFunction.java
new file mode 100644
index 0000000..648a09c
--- /dev/null
+++ b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/access/JPAFunction.java
@@ -0,0 +1,85 @@
+/*******************************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ ******************************************************************************/
+package org.apache.olingo.odata2.processor.api.jpa.access;
+
+import java.lang.reflect.Method;
+import java.lang.reflect.Type;
+
+/**
+ * A container for JPA Functions. A JPA function can be
+ * <ol>
+ * <li>Property Access method</li>
+ * <li>Custom Operation (Annotated with EDM Annotation FunctionImport)</li>
+ * </ol>
+ *
+ *
+ *
+ */
+public class JPAFunction {
+
+ private Method function;
+ private Class<?>[] parameterTypes;
+ private Type returnType;
+ private Object[] args;
+
+ public JPAFunction(final Method function, final Class<?>[] parameterTypes, final Type returnType,
+ final Object[] args) {
+ this.function = function;
+ this.parameterTypes = parameterTypes;
+ this.returnType = returnType;
+ this.args = args;
+ }
+
+ /**
+ * The method returns the Java method.
+ *
+ * @return an instance of {@link java.lang.reflect.Method}
+ */
+ public Method getFunction() {
+ return function;
+ }
+
+ /**
+ * The method returns the parameter types for the Java method.
+ *
+ * @return an array of type {@link java.lang.Class}
+ */
+ public Class<?>[] getParameterTypes() {
+ return parameterTypes;
+ }
+
+ /**
+ * The method returns the return type for the Java method.
+ *
+ * @return an instance of {@link java.lang.reflect.Type}
+ */
+ public Type getReturnType() {
+ return returnType;
+ }
+
+ /**
+ * The method returns an array of arguments for invoking the Java method.
+ *
+ * @return an array of Objects
+ */
+ public Object[] getArguments() {
+ return args;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/access/JPAJoinClause.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/access/JPAJoinClause.java b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/access/JPAJoinClause.java
new file mode 100644
index 0000000..f0a4c8d
--- /dev/null
+++ b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/access/JPAJoinClause.java
@@ -0,0 +1,148 @@
+/*******************************************************************************
+ * 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.api.jpa.access;
+
+/**
+ * A container for Java Persistence Join Clause that can be used for building
+ * JPQL statements. The container has two main elements <b>
+ * <ol>
+ * <li>Java Persistence Entity -</li> is the source entity participating in the
+ * join. <br>
+ * <li>Java Persistence Entity Relationship -</li> is the entity relationship of
+ * the source entity participating in the join.
+ * </ol>
+ * </b>
+ *
+ *
+ *
+ */
+public class JPAJoinClause {
+
+ /**
+ * Enumerated list of possible Joins in JPQL
+ * <ol>
+ * <li>LEFT - left outer join</li>
+ * <li>FETCH - enable fetching of an association as a side effect of the
+ * execution of a query</li>
+ * <li>INNER - inner join
+ * </ol>
+ *
+ *
+ *
+ */
+ public enum JOIN {
+ LEFT, FETCH, INNER
+ }
+
+ private String entityName;
+ private String entityAlias;
+ private String entityRelationShip;
+ private String entityRelationShipAlias;
+ private JOIN joinType;
+ private String joinCondition;
+
+ /**
+ * The method returns Java Persistence Entity participating in the join.
+ *
+ * @return an entity name
+ */
+ public String getEntityName() {
+ return entityName;
+ }
+
+ /**
+ * The method returns Java Persistence Entity alias name participating in
+ * the join.
+ *
+ * @return a entity alias name
+ */
+ public String getEntityAlias() {
+ return entityAlias;
+ }
+
+ /**
+ * The method returns Java Persistence Entity Relationship name
+ * participating in the join.
+ *
+ * @return entity alias relationship
+ */
+ public String getEntityRelationShip() {
+ return entityRelationShip;
+ }
+
+ /**
+ * The method returns Java Persistence Entity Relationship Alias name
+ * participating in the join.
+ *
+ * @return entity entity relationship alias
+ */
+ public String getEntityRelationShipAlias() {
+ return entityRelationShipAlias;
+ }
+
+ /**
+ * Constructor for creating elements of JPA Join Clause container.
+ *
+ * @param entityName
+ * is the name of the JPA entity participating in the join
+ * @param entityAlias
+ * is the alias for the JPA entity participating in the join
+ * @param entityRelationShip
+ * is the name of the JPA entity relationship participating in
+ * the join
+ * @param entityRelationShipAlias
+ * is the alias name of the JPA entity relationship participating
+ * in the join
+ * @param joinCondition
+ * is the condition on which the joins should occur
+ * @param joinType
+ * is the type of join {@link org.apache.olingo.odata2.processor.api.jpa.access.JPAJoinClause.JOIN} to execute
+ */
+ public JPAJoinClause(final String entityName, final String entityAlias, final String entityRelationShip,
+ final String entityRelationShipAlias, final String joinCondition, final JOIN joinType) {
+
+ this.entityName = entityName;
+ this.entityAlias = entityAlias;
+ this.entityRelationShip = entityRelationShip;
+ this.entityRelationShipAlias = entityRelationShipAlias;
+ this.joinCondition = joinCondition;
+ this.joinType = joinType;
+ }
+
+ /**
+ * The method returns a join condition that can be used for building JPQL
+ * join statements.
+ *
+ * @return a join condition
+ */
+ public String getJoinCondition() {
+ return joinCondition;
+ }
+
+ /**
+ * The method returns the type of {@link org.apache.olingo.odata2.processor.api.jpa.access.JPAJoinClause.JOIN} that
+ * can be used for building JPQL join statements.
+ *
+ * @return join type
+ */
+ public JOIN getJoinType() {
+ return joinType;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/access/JPAMethodContext.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/access/JPAMethodContext.java b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/access/JPAMethodContext.java
new file mode 100644
index 0000000..fd44200
--- /dev/null
+++ b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/access/JPAMethodContext.java
@@ -0,0 +1,130 @@
+/*******************************************************************************
+ * 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.api.jpa.access;
+
+import java.util.ArrayList;
+import java.util.List;
+
+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.factory.ODataJPAFactory;
+import org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLContextType;
+
+/**
+ * The abstract class is a compilation of objects required for building specific
+ * instances of JPA Method Context. Extend this class to implement specific
+ * implementations of JPQL context types (Create,Update,Function). A JPA method
+ * Context is constructed from an OData request. Depending on OData
+ * CUD/FunctionImport operation performed on an Entity, a corresponding JPA
+ * method context object is built. The object thus built can be used for
+ * executing operations on JPA Entity/Custom processor objects. <br>
+ * A default implementation is provided by the library.
+ *
+ *
+ * @see org.apache.olingo.odata2.processor.api.jpa.access.JPAMethodContextView
+ * @see org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLContextType
+ *
+ */
+
+public abstract class JPAMethodContext implements JPAMethodContextView {
+
+ protected Object enclosingObject;
+ protected ArrayList<JPAFunction> jpaFunction;
+
+ @Override
+ /**
+ * The method returns list of JPA functions that can be executed on the
+ * enclosing object.
+ *
+ * @return an instance of list of JPA Function
+ */
+ public Object getEnclosingObject() {
+ return enclosingObject;
+ }
+
+ @Override
+ /**
+ * The method returns list of JPA functions that can be executed on the
+ * enclosing object.
+ *
+ * @return an instance of list of JPA Function
+ */
+ public List<JPAFunction> getJPAFunctionList() {
+ return jpaFunction;
+ }
+
+ protected void setEnclosingObject(final Object enclosingObject) {
+ this.enclosingObject = enclosingObject;
+ }
+
+ protected void setJpaFunction(final List<JPAFunction> jpaFunctionList) {
+ jpaFunction = (ArrayList<JPAFunction>) jpaFunctionList;
+ }
+
+ /**
+ * the method instantiates an instance of type JPAMethodContextBuilder.
+ *
+ * @param contextType
+ * indicates the type of JPQLContextBuilder to instantiate.
+ * @param resultsView
+ * is the OData request view
+ * @return {@link org.apache.olingo.odata2.processor.api.jpa.access.JPAMethodContext.JPAMethodContextBuilder}
+ *
+ * @throws ODataJPARuntimeException
+ */
+ public final static JPAMethodContextBuilder
+ createBuilder(final JPQLContextType contextType, final Object resultsView) throws ODataJPARuntimeException {
+ return JPAMethodContextBuilder.create(contextType, resultsView);
+ }
+
+ /**
+ * The abstract class is extended by specific JPA Method Context Builder to
+ * build JPA Method Context types.
+ *
+ *
+ *
+ */
+ public static abstract class JPAMethodContextBuilder {
+
+ /**
+ * Implement this method to build JPAMethodContext
+ *
+ * @return an instance of type JPAMethodContext
+ * @throws ODataJPAModelException
+ * @throws ODataJPARuntimeException
+ */
+ public abstract JPAMethodContext build() throws ODataJPAModelException, ODataJPARuntimeException;
+
+ protected JPAMethodContextBuilder() {}
+
+ private static JPAMethodContextBuilder create(final JPQLContextType contextType, final Object resultsView)
+ throws ODataJPARuntimeException {
+ JPAMethodContextBuilder contextBuilder =
+ ODataJPAFactory.createFactory().getJPQLBuilderFactory().getJPAMethodContextBuilder(contextType);
+
+ if (contextBuilder == null) {
+ throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.ERROR_JPQLCTXBLDR_CREATE, null);
+ }
+ contextBuilder.setResultsView(resultsView);
+ return contextBuilder;
+ }
+
+ protected abstract void setResultsView(Object resultsView);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/access/JPAMethodContextView.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/access/JPAMethodContextView.java b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/access/JPAMethodContextView.java
new file mode 100644
index 0000000..fb057a0
--- /dev/null
+++ b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/access/JPAMethodContextView.java
@@ -0,0 +1,46 @@
+/*******************************************************************************
+ * 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.api.jpa.access;
+
+import java.util.List;
+
+/**
+ * The interface provides view on JPA Method Context. JPA Method context can be
+ * used to access custom operations or JPA Entity property access methods.
+ *
+ *
+ *
+ */
+public interface JPAMethodContextView {
+ /**
+ * The method returns an instance of Object on which the methods/custom
+ * operations can be executed.
+ *
+ * @return instance of enclosing object for the method
+ */
+ public Object getEnclosingObject();
+
+ /**
+ * The method returns list of JPA functions that can be executed on the
+ * enclosing object.
+ *
+ * @return an instance of list of JPA Function
+ */
+ public List<JPAFunction> getJPAFunctionList();
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/access/JPAProcessor.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/access/JPAProcessor.java b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/access/JPAProcessor.java
new file mode 100644
index 0000000..af9b77d
--- /dev/null
+++ b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/access/JPAProcessor.java
@@ -0,0 +1,260 @@
+/*******************************************************************************
+ * 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.api.jpa.access;
+
+import java.io.InputStream;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.olingo.odata2.api.uri.info.DeleteUriInfo;
+import org.apache.olingo.odata2.api.uri.info.GetEntityCountUriInfo;
+import org.apache.olingo.odata2.api.uri.info.GetEntityLinkUriInfo;
+import org.apache.olingo.odata2.api.uri.info.GetEntitySetCountUriInfo;
+import org.apache.olingo.odata2.api.uri.info.GetEntitySetLinksUriInfo;
+import org.apache.olingo.odata2.api.uri.info.GetEntitySetUriInfo;
+import org.apache.olingo.odata2.api.uri.info.GetEntityUriInfo;
+import org.apache.olingo.odata2.api.uri.info.GetFunctionImportUriInfo;
+import org.apache.olingo.odata2.api.uri.info.PostUriInfo;
+import org.apache.olingo.odata2.api.uri.info.PutMergePatchUriInfo;
+import org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPAModelException;
+import org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPARuntimeException;
+
+/**
+ * The interface provides methods for processing OData Requests for Create, Read, Update, Delete operations.
+ * Pass the OData request or parsed OData request (Map of properties) as request.
+ * A JPA entity is returned as a response.
+ *
+ */
+public interface JPAProcessor {
+ /**
+ * Processes OData request for querying an Entity Set. The method returns
+ * list of Objects of type representing JPA Entity Types.
+ *
+ * @param <T>
+ * Template parameter representing Java Persistence Entity Type.
+ * <p>
+ * <b>Note:-</b> Default parameter is Object.
+ * </p>
+ *
+ * @param requestView
+ * is an OData request for querying an entity set
+ * <p>
+ * @return list of objects representing JPA entity types
+ **/
+ public <T> List<T> process(GetEntitySetUriInfo requestView)
+ throws ODataJPAModelException, ODataJPARuntimeException;
+
+ /**
+ * Processes OData request for reading an Entity. The method returns an
+ * Object of type representing JPA Entity Type.
+ *
+ * @param <T>
+ * Template parameter representing Java Persistence Entity Type.
+ * <p>
+ * <b>Note:-</b> Default parameter is Object.
+ * </p>
+ *
+ * @param requestView
+ * OData request for reading an entity
+ *
+ * <p>
+ * @return object representing JPA entity type
+ **/
+ public <T> Object process(GetEntityUriInfo requestView)
+ throws ODataJPAModelException, ODataJPARuntimeException;
+
+ /**
+ * Processes OData request for fetching Entity count. The method returns JPA Entity count
+ *
+ * @param requestView
+ * OData request for counting an entity set
+ * @return long value representing count of JPA entity set
+ *
+ * @throws ODataJPAModelException
+ * @throws ODataJPARuntimeException
+ */
+
+ public long process(GetEntitySetCountUriInfo requestView)
+ throws ODataJPAModelException, ODataJPARuntimeException;
+
+ /**
+ * Processes OData request for fetching Entity count. The method returns count of target entity.
+ * This is specific to situation where cardinality is 1:1
+ *
+ * @param resultsView
+ * OData request for counting target entity.
+ * @return long value representing count of JPA entity
+ *
+ * @throws ODataJPAModelException
+ * @throws ODataJPARuntimeException
+ */
+ public long process(GetEntityCountUriInfo resultsView)
+ throws ODataJPAModelException, ODataJPARuntimeException;
+
+ /**
+ * Processes OData request for executing custom operations. The method
+ * returns a List of Object. The list contains one entry if the the custom
+ * operations return type has multiplicity of ONE.
+ *
+ * @param requestView
+ * OData request for executing function import
+ * @return result of executing function import
+ * @throws ODataJPAModelException
+ * @throws ODataJPARuntimeException
+ */
+ public List<Object> process(GetFunctionImportUriInfo requestView)
+ throws ODataJPAModelException, ODataJPARuntimeException;
+
+ /**
+ * Processes OData request for executing $links OData command for N:1 relation.
+ * The method returns an Object of type representing OData entity.
+ *
+ * @param uriParserResultView
+ * OData request for Entity Link URI
+ * @return an object representing JPA entity
+ * @throws ODataJPAModelException
+ * @throws ODataJPARuntimeException
+ */
+ public Object process(GetEntityLinkUriInfo uriParserResultView)
+ throws ODataJPAModelException, ODataJPARuntimeException;
+
+ /**
+ * Processes OData request for executing $links OData command for N:1 relation.
+ * The method returns an Object of type representing OData entity.
+ *
+ * @param uriParserResultView
+ * OData request for Entity Set Link URI
+ * @return a list of object representing JPA entities
+ * @throws ODataJPAModelException
+ * @throws ODataJPARuntimeException
+ */
+ public <T> List<T> process(GetEntitySetLinksUriInfo uriParserResultView)
+ throws ODataJPAModelException, ODataJPARuntimeException;
+
+ /**
+ * Processes OData request for creating Entity. The method returns an Object
+ * which is created. A Null reference implies object was not created.
+ *
+ * @param createView
+ * @param content
+ * @param requestContentType
+ * @return Created Object
+ *
+ * @throws ODataJPAModelException
+ * @throws ODataJPARuntimeException
+ */
+
+ public <T> List<T> process(PostUriInfo createView, InputStream content,
+ String requestContentType) throws ODataJPAModelException,
+ ODataJPARuntimeException;
+
+ /**
+ * Processes OData request for creating Entity. The method expects a parsed OData request which is a Map of
+ * properties.
+ * The method returns an Object that is created. A Null reference implies object was not created.
+ *
+ * @param createView
+ * @param content
+ * @return Created Object
+ *
+ * @throws ODataJPAModelException
+ * @throws ODataJPARuntimeException
+ */
+
+ public <T> List<T> process(PostUriInfo createView, Map<String, Object> content) throws ODataJPAModelException,
+ ODataJPARuntimeException;
+
+ /**
+ * Processes OData request for updating Entity. The method returns an Object
+ * which is updated. A Null reference implies object was not created.
+ *
+ * @param updateView
+ * @param content
+ * @param requestContentType
+ * @return Deleted Object
+ *
+ * @throws ODataJPAModelException
+ * @throws ODataJPARuntimeException
+ */
+ public <T> Object process(PutMergePatchUriInfo updateView,
+ InputStream content, String requestContentType)
+ throws ODataJPAModelException, ODataJPARuntimeException;
+
+ /**
+ * Processes OData request for updating Entity. The method returns an Object
+ * which is updated. A Null reference implies object was not created.
+ *
+ * @param updateView
+ * @param content
+ * @return Deleted Object
+ *
+ * @throws ODataJPAModelException
+ * @throws ODataJPARuntimeException
+ */
+ public <T> Object process(PutMergePatchUriInfo updateView, Map<String, Object> content)
+ throws ODataJPAModelException, ODataJPARuntimeException;
+
+ /**
+ * Processes OData request for deleting Entity. The method returns an Object
+ * which is deleted. A Null reference implies object was not created.
+ *
+ * @param deleteuriInfo
+ * @param contentType
+ * @return Deleted Object
+ *
+ * @throws ODataJPAModelException
+ * @throws ODataJPARuntimeException
+ */
+ public Object process(DeleteUriInfo deleteuriInfo, String contentType)
+ throws ODataJPAModelException, ODataJPARuntimeException;
+
+ /**
+ * Process OData request for creating Links. The OData request should contain
+ * $links OData command.
+ *
+ * @param uriParserResultView
+ * OData request for creating Links
+ * @param content
+ * @param requestContentType
+ * @param contentType
+ *
+ * @throws ODataJPARuntimeException
+ * @throws ODataJPAModelException
+ */
+ public void process(PostUriInfo uriParserResultView,
+ InputStream content, String requestContentType, String contentType)
+ throws ODataJPARuntimeException, ODataJPAModelException;
+
+ /**
+ * Process OData request for updating Links. The OData request should contain
+ * $links OData command.
+ *
+ * @param uriParserResultView
+ * OData request for updating Links
+ * @param content
+ * @param requestContentType
+ * @param contentType
+ *
+ * @throws ODataJPARuntimeException
+ * @throws ODataJPAModelException
+ */
+ public void process(PutMergePatchUriInfo uriParserResultView,
+ InputStream content, String requestContentType, String contentType)
+ throws ODataJPARuntimeException, ODataJPAModelException;
+}
[12/37] [OLINGO-82] Renamed the project folder name to
odata2-jpa-processor
Posted by ch...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmBaseViewImpl.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmBaseViewImpl.java b/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmBaseViewImpl.java
deleted file mode 100644
index 0798487..0000000
--- a/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmBaseViewImpl.java
+++ /dev/null
@@ -1,101 +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.model;
-
-import javax.persistence.metamodel.Metamodel;
-
-import org.apache.olingo.odata2.processor.api.jpa.ODataJPAContext;
-import org.apache.olingo.odata2.processor.api.jpa.access.JPAEdmBuilder;
-import org.apache.olingo.odata2.processor.api.jpa.access.JPAEdmMappingModelAccess;
-import org.apache.olingo.odata2.processor.api.jpa.factory.ODataJPAFactory;
-import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmBaseView;
-import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmExtension;
-
-public abstract class JPAEdmBaseViewImpl implements JPAEdmBaseView {
-
- protected boolean skipDefaultNaming = false;
- protected String pUnitName = null;
- protected Metamodel metaModel = null;
- protected boolean isConsistent = true;
- protected JPAEdmBuilder builder = null;
- protected JPAEdmExtension jpaEdmExtension = null;
- private JPAEdmMappingModelAccess jpaEdmMappingModelAccess = null;
-
- public JPAEdmBaseViewImpl(final JPAEdmBaseView view) {
- pUnitName = view.getpUnitName();
- metaModel = view.getJPAMetaModel();
- jpaEdmMappingModelAccess = view.getJPAEdmMappingModelAccess();
- jpaEdmExtension = view.getJPAEdmExtension();
- skipDefaultNaming = view.isDefaultNamingSkipped();
- }
-
- public JPAEdmBaseViewImpl(final ODataJPAContext context) {
- pUnitName = context.getPersistenceUnitName();
- metaModel = context.getEntityManagerFactory().getMetamodel();
- jpaEdmMappingModelAccess =
- ODataJPAFactory.createFactory().getJPAAccessFactory().getJPAEdmMappingModelAccess(context);
- jpaEdmExtension = context.getJPAEdmExtension();
- jpaEdmMappingModelAccess.loadMappingModel();
- skipDefaultNaming = !context.getDefaultNaming();
- }
-
- public JPAEdmBaseViewImpl(final Metamodel metaModel, final String pUnitName) {
- this.metaModel = metaModel;
- this.pUnitName = pUnitName;
- }
-
- @Override
- public String getpUnitName() {
- return pUnitName;
- }
-
- @Override
- public Metamodel getJPAMetaModel() {
- return metaModel;
- }
-
- @Override
- public boolean isConsistent() {
- return isConsistent;
- }
-
- @Override
- public void clean() {
- pUnitName = null;
- metaModel = null;
- isConsistent = false;
- }
-
- @Override
- public JPAEdmMappingModelAccess getJPAEdmMappingModelAccess() {
- return jpaEdmMappingModelAccess;
-
- }
-
- @Override
- public JPAEdmExtension getJPAEdmExtension() {
- return jpaEdmExtension;
- }
-
- @Override
- public boolean isDefaultNamingSkipped() {
- return skipDefaultNaming;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmComplexType.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmComplexType.java b/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmComplexType.java
deleted file mode 100644
index ad25a1b..0000000
--- a/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmComplexType.java
+++ /dev/null
@@ -1,254 +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.model;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import javax.persistence.metamodel.Attribute;
-import javax.persistence.metamodel.EmbeddableType;
-
-import org.apache.olingo.odata2.api.edm.FullQualifiedName;
-import org.apache.olingo.odata2.api.edm.provider.ComplexProperty;
-import org.apache.olingo.odata2.api.edm.provider.ComplexType;
-import org.apache.olingo.odata2.api.edm.provider.Mapping;
-import org.apache.olingo.odata2.api.edm.provider.Property;
-import org.apache.olingo.odata2.api.edm.provider.SimpleProperty;
-import org.apache.olingo.odata2.processor.api.jpa.access.JPAEdmBuilder;
-import org.apache.olingo.odata2.processor.api.jpa.access.JPAEdmMappingModelAccess;
-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.JPAEdmMapping;
-import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmPropertyView;
-import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmSchemaView;
-import org.apache.olingo.odata2.processor.core.jpa.access.model.JPAEdmNameBuilder;
-
-public class JPAEdmComplexType extends JPAEdmBaseViewImpl implements JPAEdmComplexTypeView {
-
- private JPAEdmSchemaView schemaView;
- private ComplexType currentComplexType = null;
- private EmbeddableType<?> currentEmbeddableType = null;
- private HashMap<String, ComplexType> searchMap = null;
- private List<ComplexType> consistentComplextTypes = null;
- private boolean directBuild;
- private EmbeddableType<?> nestedComplexType = null;
-
- public JPAEdmComplexType(final JPAEdmSchemaView view) {
- super(view);
- schemaView = view;
- directBuild = true;
- }
-
- public JPAEdmComplexType(final JPAEdmSchemaView view, final Attribute<?, ?> complexAttribute) {
- super(view);
- schemaView = view;
- for (EmbeddableType<?> jpaEmbeddable : schemaView.getJPAMetaModel().getEmbeddables()) {
- if (jpaEmbeddable.getJavaType().getName().equals(complexAttribute.getJavaType().getName())) {
- nestedComplexType = jpaEmbeddable;
- break;
- }
- }
- directBuild = false;
- }
-
- @Override
- public JPAEdmBuilder getBuilder() {
- if (builder == null) {
- builder = new JPAEdmComplexTypeBuilder();
- }
-
- return builder;
- }
-
- @Override
- public ComplexType getEdmComplexType() {
- return currentComplexType;
- }
-
- @Override
- public ComplexType searchEdmComplexType(final String embeddableTypeName) {
- return searchMap.get(embeddableTypeName);
- }
-
- @Override
- public EmbeddableType<?> getJPAEmbeddableType() {
- return currentEmbeddableType;
- }
-
- @Override
- public List<ComplexType> getConsistentEdmComplexTypes() {
- return consistentComplextTypes;
- }
-
- @Override
- public ComplexType searchEdmComplexType(final FullQualifiedName type) {
- String name = type.getName();
- return searchComplexTypeByName(name);
-
- }
-
- private ComplexType searchComplexTypeByName(final String name) {
- for (ComplexType complexType : consistentComplextTypes) {
- if (null != complexType && null != complexType.getName() && complexType.getName().equals(name)) {
- return complexType;
- }
- }
-
- return null;
- }
-
- @Override
- public void addJPAEdmCompleTypeView(final JPAEdmComplexTypeView view) {
- String searchKey = view.getJPAEmbeddableType().getJavaType().getName();
-
- if (!searchMap.containsKey(searchKey)) {
- consistentComplextTypes.add(view.getEdmComplexType());
- searchMap.put(searchKey, view.getEdmComplexType());
- }
- }
-
- @Override
- public void expandEdmComplexType(final ComplexType complexType, List<Property> expandedList,
- final String embeddablePropertyName) {
-
- if (expandedList == null) {
- expandedList = new ArrayList<Property>();
- }
- for (Property property : complexType.getProperties()) {
- try {
- SimpleProperty newSimpleProperty = new SimpleProperty();
- SimpleProperty oldSimpleProperty = (SimpleProperty) property;
- newSimpleProperty.setAnnotationAttributes(oldSimpleProperty.getAnnotationAttributes());
- newSimpleProperty.setAnnotationElements(oldSimpleProperty.getAnnotationElements());
- newSimpleProperty.setCustomizableFeedMappings(oldSimpleProperty.getCustomizableFeedMappings());
- newSimpleProperty.setDocumentation(oldSimpleProperty.getDocumentation());
- newSimpleProperty.setFacets(oldSimpleProperty.getFacets());
- newSimpleProperty.setMimeType(oldSimpleProperty.getMimeType());
- newSimpleProperty.setName(oldSimpleProperty.getName());
- newSimpleProperty.setType(oldSimpleProperty.getType());
- JPAEdmMappingImpl newMapping = new JPAEdmMappingImpl();
- Mapping mapping = oldSimpleProperty.getMapping();
- JPAEdmMapping oldMapping = (JPAEdmMapping) mapping;
- newMapping.setJPAColumnName(oldMapping.getJPAColumnName());
- newMapping.setInternalName(embeddablePropertyName + "." + mapping.getInternalName());
- newMapping.setMimeType(mapping.getMimeType());
- newMapping.setObject(mapping.getObject());
- newMapping.setJPAType(oldMapping.getJPAType());
- newSimpleProperty.setMapping(newMapping);
- expandedList.add(newSimpleProperty);
- } catch (ClassCastException e) {
- ComplexProperty complexProperty = (ComplexProperty) property;
- String name = embeddablePropertyName + "." + complexProperty.getMapping().getInternalName();
- expandEdmComplexType(searchComplexTypeByName(complexProperty.getName()), expandedList, name);
- }
- }
-
- }
-
- private class JPAEdmComplexTypeBuilder implements JPAEdmBuilder {
- /*
- *
- * Each call to build method creates a new Complex Type.
- * The Complex Type is created only if it is not created
- * earlier. A local buffer is maintained to track the list
- * of complex types created.
- *
- * ************************************************************
- * Build EDM Complex Type - STEPS
- * ************************************************************
- * 1) Fetch list of embeddable types from JPA Model
- * 2) Search local buffer if there exists already a Complex
- * type for the embeddable type.
- * 3) If the complex type was already been built continue with
- * the next embeddable type, else create new EDM Complex Type.
- * 4) Create a Property view with Complex Type
- * 5) Get Property Builder and build the Property with Complex
- * type.
- * 6) Set EDM complex type with list of properties built by
- * the property view
- * 7) Provide name for EDM complex type.
- *
- * ************************************************************
- * Build EDM Complex Type - STEPS
- * ************************************************************
- */
- @Override
- public void build() throws ODataJPAModelException, ODataJPARuntimeException {
- Set<EmbeddableType<?>> embeddables = new HashSet<EmbeddableType<?>>();
-
- if (consistentComplextTypes == null) {
- consistentComplextTypes = new ArrayList<ComplexType>();
- }
-
- if (searchMap == null) {
- searchMap = new HashMap<String, ComplexType>();
- }
-
- if (directBuild) {
- embeddables = schemaView.getJPAMetaModel().getEmbeddables();
- } else {
- embeddables.add(nestedComplexType);
- }
-
- for (EmbeddableType<?> embeddableType : embeddables) {
-
- currentEmbeddableType = embeddableType;
- String searchKey = embeddableType.getJavaType().getName();
-
- if (searchMap.containsKey(searchKey)) {
- continue;
- }
-
- // Check for need to Exclude
- if (isExcluded(JPAEdmComplexType.this)) {
- continue;
- }
-
- JPAEdmPropertyView propertyView = new JPAEdmProperty(schemaView, JPAEdmComplexType.this);
- propertyView.getBuilder().build();
-
- currentComplexType = new ComplexType();
- currentComplexType.setProperties(propertyView.getEdmPropertyList());
- JPAEdmNameBuilder.build(JPAEdmComplexType.this);
-
- searchMap.put(searchKey, currentComplexType);
- consistentComplextTypes.add(currentComplexType);
-
- }
-
- }
-
- private boolean isExcluded(final JPAEdmComplexType jpaEdmComplexType) {
-
- JPAEdmMappingModelAccess mappingModelAccess = jpaEdmComplexType.getJPAEdmMappingModelAccess();
- if (mappingModelAccess != null
- && mappingModelAccess.isMappingModelExists()
- && mappingModelAccess.checkExclusionOfJPAEmbeddableType(jpaEdmComplexType.getJPAEmbeddableType()
- .getJavaType().getSimpleName())) {
- return true;
- }
- return false;
- }
-
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmEntityContainer.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmEntityContainer.java b/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmEntityContainer.java
deleted file mode 100644
index fee40c2..0000000
--- a/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmEntityContainer.java
+++ /dev/null
@@ -1,154 +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.model;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.olingo.odata2.api.edm.provider.EntityContainer;
-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.JPAEdmAssociationSetView;
-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.JPAEdmFunctionImportView;
-import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmSchemaView;
-import org.apache.olingo.odata2.processor.core.jpa.access.model.JPAEdmNameBuilder;
-
-public class JPAEdmEntityContainer extends JPAEdmBaseViewImpl implements JPAEdmEntityContainerView {
-
- private JPAEdmEntitySetView entitySetView;
- private JPAEdmSchemaView schemaView;
- private JPAEdmAssociationSetView associationSetView;
-
- private EntityContainer currentEntityContainer;
- private List<EntityContainer> consistentEntityContainerList;
-
- public JPAEdmEntityContainer(final JPAEdmSchemaView view) {
- super(view);
- schemaView = view;
- }
-
- @Override
- public JPAEdmBuilder getBuilder() {
- if (builder == null) {
- builder = new JPAEdmEntityContainerBuilder();
- }
-
- return builder;
- }
-
- @Override
- public EntityContainer getEdmEntityContainer() {
- return currentEntityContainer;
- }
-
- @Override
- public List<EntityContainer> getConsistentEdmEntityContainerList() {
- return consistentEntityContainerList;
- }
-
- @Override
- public JPAEdmEntitySetView getJPAEdmEntitySetView() {
- return entitySetView;
- }
-
- @Override
- public JPAEdmAssociationSetView getEdmAssociationSetView() {
- return associationSetView;
- }
-
- @Override
- public void clean() {
- super.clean();
- entitySetView = null;
- associationSetView = null;
- currentEntityContainer = null;
- consistentEntityContainerList = null;
- }
-
- private class JPAEdmEntityContainerBuilder implements JPAEdmBuilder {
- /*
- *
- * Each call to build method creates a new Entity Container and builds
- * the entity container with Association Sets and Entity Sets. The newly
- * created and built entity container is added to the exiting Entity
- * Container List.
- *
- * ************************************************************ Build
- * EDM Entity Container - STEPS
- * ************************************************************ 1)
- * Instantiate New EDM Entity Container 2) Build Name for EDM Entity
- * Container 2) Create Entity Container List (if does not exists) 3)
- * Build EDM Entity Set 4) Add EDM Entity Set to EDM Entity Container 6)
- * Build EDM Association Set 7) Add EDM Association Set to EDM Entity
- * Container 8) Add EDM Entity Container to the Container List
- * ************************************************************ Build
- * EDM Entity Container - STEPS
- * ************************************************************
- */
- @Override
- public void build() throws ODataJPAModelException, ODataJPARuntimeException {
-
- currentEntityContainer = new EntityContainer();
-
- if (consistentEntityContainerList == null) {
- currentEntityContainer.setDefaultEntityContainer(true);
- consistentEntityContainerList = new ArrayList<EntityContainer>();
- }
-
- entitySetView = new JPAEdmEntitySet(schemaView);
- entitySetView.getBuilder().build();
- if (entitySetView.isConsistent()) {
- currentEntityContainer.setEntitySets(entitySetView.getConsistentEdmEntitySetList());
- } else {
- isConsistent = false;
- return;
- }
-
- if (!schemaView.getJPAEdmAssociationView().isConsistent()) {
- schemaView.getJPAEdmAssociationView().getBuilder().build();
- }
-
- associationSetView = new JPAEdmAssociationSet(schemaView);
- associationSetView.getBuilder().build();
- if (associationSetView.isConsistent()) {
- currentEntityContainer.setAssociationSets(associationSetView.getConsistentEdmAssociationSetList());
- } else {
- isConsistent = false;
- return;
- }
-
- JPAEdmNameBuilder.build(JPAEdmEntityContainer.this);
- if (schemaView.getJPAEdmExtension() != null) {
- JPAEdmFunctionImportView functionImportView = new JPAEdmFunctionImport(schemaView);
- functionImportView.getBuilder().build();
- if (functionImportView.getConsistentFunctionImportList() != null) {
- currentEntityContainer.setFunctionImports(functionImportView.getConsistentFunctionImportList());
- }
- }
-
- consistentEntityContainerList.add(currentEntityContainer);
- isConsistent = true;
-
- }
-
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmEntitySet.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmEntitySet.java b/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmEntitySet.java
deleted file mode 100644
index 9e5248f..0000000
--- a/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmEntitySet.java
+++ /dev/null
@@ -1,112 +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.model;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.olingo.odata2.api.edm.FullQualifiedName;
-import org.apache.olingo.odata2.api.edm.provider.EntitySet;
-import org.apache.olingo.odata2.api.edm.provider.EntityType;
-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.JPAEdmEntitySetView;
-import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmEntityTypeView;
-import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmSchemaView;
-import org.apache.olingo.odata2.processor.core.jpa.access.model.JPAEdmNameBuilder;
-
-public class JPAEdmEntitySet extends JPAEdmBaseViewImpl implements JPAEdmEntitySetView {
-
- private EntitySet currentEntitySet = null;
- private List<EntitySet> consistentEntitySetList = null;
- private JPAEdmEntityTypeView entityTypeView = null;
- private JPAEdmSchemaView schemaView;
-
- public JPAEdmEntitySet(final JPAEdmSchemaView view) {
- super(view);
- schemaView = view;
- }
-
- @Override
- public JPAEdmBuilder getBuilder() {
- if (builder == null) {
- builder = new JPAEdmEntitySetBuilder();
- }
-
- return builder;
- }
-
- @Override
- public EntitySet getEdmEntitySet() {
- return currentEntitySet;
- }
-
- @Override
- public List<EntitySet> getConsistentEdmEntitySetList() {
- return consistentEntitySetList;
- }
-
- @Override
- public JPAEdmEntityTypeView getJPAEdmEntityTypeView() {
- return entityTypeView;
- }
-
- @Override
- public void clean() {
- currentEntitySet = null;
- consistentEntitySetList = null;
- entityTypeView = null;
- isConsistent = false;
- }
-
- private class JPAEdmEntitySetBuilder implements JPAEdmBuilder {
-
- @Override
- public void build() throws ODataJPAModelException, ODataJPARuntimeException {
-
- if (consistentEntitySetList == null) {
- consistentEntitySetList = new ArrayList<EntitySet>();
- }
-
- entityTypeView = new JPAEdmEntityType(schemaView);
- entityTypeView.getBuilder().build();
-
- if (entityTypeView.isConsistent() && entityTypeView.getConsistentEdmEntityTypes() != null) {
-
- String nameSpace = schemaView.getEdmSchema().getNamespace();
- for (EntityType entityType : entityTypeView.getConsistentEdmEntityTypes()) {
-
- currentEntitySet = new EntitySet();
- currentEntitySet.setEntityType(new FullQualifiedName(nameSpace, entityType.getName()));
- JPAEdmNameBuilder.build(JPAEdmEntitySet.this, entityTypeView);
- consistentEntitySetList.add(currentEntitySet);
-
- }
- isConsistent = true;
- } else {
- isConsistent = false;
- return;
- }
-
- }
-
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmEntityType.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmEntityType.java b/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmEntityType.java
deleted file mode 100644
index 5864a1c..0000000
--- a/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmEntityType.java
+++ /dev/null
@@ -1,230 +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.model;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.ListIterator;
-import java.util.Set;
-
-import org.apache.olingo.odata2.api.edm.provider.EntityType;
-import org.apache.olingo.odata2.processor.api.jpa.access.JPAEdmBuilder;
-import org.apache.olingo.odata2.processor.api.jpa.access.JPAEdmMappingModelAccess;
-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.JPAEdmEntityTypeView;
-import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmKeyView;
-import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmNavigationPropertyView;
-import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmPropertyView;
-import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmSchemaView;
-import org.apache.olingo.odata2.processor.core.jpa.access.model.JPAEdmNameBuilder;
-
-public class JPAEdmEntityType extends JPAEdmBaseViewImpl implements JPAEdmEntityTypeView {
-
- private JPAEdmSchemaView schemaView = null;
- private EntityType currentEdmEntityType = null;
- private javax.persistence.metamodel.EntityType<?> currentJPAEntityType = null;
- private EntityTypeList<EntityType> consistentEntityTypes = null;
-
- private HashMap<String, EntityType> consistentEntityTypeMap;
-
- public JPAEdmEntityType(final JPAEdmSchemaView view) {
- super(view);
- schemaView = view;
- consistentEntityTypeMap = new HashMap<String, EntityType>();
- }
-
- @Override
- public JPAEdmBuilder getBuilder() {
- if (builder == null) {
- builder = new JPAEdmEntityTypeBuilder();
- }
-
- return builder;
- }
-
- @Override
- public EntityType getEdmEntityType() {
- return currentEdmEntityType;
- }
-
- @Override
- public javax.persistence.metamodel.EntityType<?> getJPAEntityType() {
- return currentJPAEntityType;
- }
-
- @Override
- public List<EntityType> getConsistentEdmEntityTypes() {
- return consistentEntityTypes;
- }
-
- @Override
- public EntityType searchEdmEntityType(final String jpaEntityTypeName) {
- return consistentEntityTypeMap.get(jpaEntityTypeName);
- }
-
- private class JPAEdmEntityTypeBuilder implements JPAEdmBuilder {
-
- @Override
- public void build() throws ODataJPAModelException, ODataJPARuntimeException {
-
- Set<javax.persistence.metamodel.EntityType<?>> jpaEntityTypes = metaModel.getEntities();
-
- if (jpaEntityTypes == null || jpaEntityTypes.isEmpty() == true) {
- return;
- } else if (consistentEntityTypes == null) {
- consistentEntityTypes = new EntityTypeList<EntityType>();
-
- }
-
- for (javax.persistence.metamodel.EntityType<?> jpaEntityType : jpaEntityTypes) {
- currentEdmEntityType = new EntityType();
- currentJPAEntityType = jpaEntityType;
-
- // Check for need to Exclude
- if (isExcluded(JPAEdmEntityType.this)) {
- continue;
- }
-
- JPAEdmNameBuilder.build(JPAEdmEntityType.this);
-
- JPAEdmPropertyView propertyView = new JPAEdmProperty(schemaView);
- propertyView.getBuilder().build();
-
- currentEdmEntityType.setProperties(propertyView.getEdmPropertyList());
- if (propertyView.getJPAEdmNavigationPropertyView() != null) {
- JPAEdmNavigationPropertyView navPropView = propertyView.getJPAEdmNavigationPropertyView();
- if (navPropView.getConsistentEdmNavigationProperties() != null
- && !navPropView.getConsistentEdmNavigationProperties().isEmpty()) {
- currentEdmEntityType.setNavigationProperties(navPropView.getConsistentEdmNavigationProperties());
- }
- }
- JPAEdmKeyView keyView = propertyView.getJPAEdmKeyView();
- currentEdmEntityType.setKey(keyView.getEdmKey());
-
- consistentEntityTypes.add(currentEdmEntityType);
- consistentEntityTypeMap.put(currentJPAEntityType.getName(), currentEdmEntityType);
- }
-
- }
-
- private boolean isExcluded(final JPAEdmEntityType jpaEdmEntityType) {
- JPAEdmMappingModelAccess mappingModelAccess = jpaEdmEntityType.getJPAEdmMappingModelAccess();
- if (mappingModelAccess != null && mappingModelAccess.isMappingModelExists()
- && mappingModelAccess.checkExclusionOfJPAEntityType(jpaEdmEntityType.getJPAEntityType().getName())) {
- return true;
- }
- return false;
- }
-
- }
-
- private class EntityTypeList<X> extends ArrayList<EntityType> {
-
- /**
- *
- */
- private static final long serialVersionUID = 719079109608251592L;
-
- @Override
- public Iterator<EntityType> iterator() {
- return new EntityTypeListIterator<X>(size());
- }
-
- }
-
- private class EntityTypeListIterator<E> implements ListIterator<EntityType> {
-
- private int size = 0;
- private int pos = 0;
-
- public EntityTypeListIterator(final int listSize) {
- this.size = listSize;
- }
-
- @Override
- public void add(final EntityType e) {
- consistentEntityTypes.add(e);
- size++;
- }
-
- @Override
- public boolean hasNext() {
- if (pos < size) {
- return true;
- }
-
- return false;
- }
-
- @Override
- public boolean hasPrevious() {
- if (pos > 0) {
- return true;
- }
- return false;
- }
-
- @Override
- public EntityType next() {
- if (pos < size) {
- currentEdmEntityType = consistentEntityTypes.get(pos++);
- return currentEdmEntityType;
- }
-
- return null;
- }
-
- @Override
- public int nextIndex() {
- return pos;
- }
-
- @Override
- public EntityType previous() {
- if (pos > 0 && pos < size) {
- currentEdmEntityType = consistentEntityTypes.get(--pos);
- return currentEdmEntityType;
- }
- return null;
- }
-
- @Override
- public int previousIndex() {
- if (pos > 0) {
- return pos - 1;
- }
-
- return 0;
- }
-
- @Override
- public void remove() {
- consistentEntityTypes.remove(pos);
- }
-
- @Override
- public void set(final EntityType e) {
- consistentEntityTypes.set(pos, e);
- }
-
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmFacets.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmFacets.java b/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmFacets.java
deleted file mode 100644
index 61f984f..0000000
--- a/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmFacets.java
+++ /dev/null
@@ -1,94 +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.model;
-
-import java.lang.reflect.AnnotatedElement;
-
-import javax.persistence.Column;
-import javax.persistence.metamodel.Attribute;
-
-import org.apache.olingo.odata2.api.edm.EdmSimpleTypeKind;
-import org.apache.olingo.odata2.api.edm.provider.Facets;
-import org.apache.olingo.odata2.api.edm.provider.SimpleProperty;
-
-public class JPAEdmFacets {
- public static void setFacets(final Attribute<?, ?> jpaAttribute, final SimpleProperty edmProperty) {
- EdmSimpleTypeKind edmTypeKind = edmProperty.getType();
- Facets facets = new Facets();
- edmProperty.setFacets(facets);
-
- Column column = null;
- if (jpaAttribute.getJavaMember() instanceof AnnotatedElement) {
- column = ((AnnotatedElement) jpaAttribute
- .getJavaMember()).getAnnotation(Column.class);
- }
-
- if (column == null) {
- return;
- }
-
- setNullable(column, edmProperty);
-
- switch (edmTypeKind) {
- case Binary:
- setMaxLength(column, edmProperty);
- break;
- case DateTime:
- setPrecision(column, edmProperty);
- break;
- case DateTimeOffset:
- setPrecision(column, edmProperty);
- break;
- case Time:
- setPrecision(column, edmProperty);
- break;
- case Decimal:
- setPrecision(column, edmProperty);
- setScale(column, edmProperty);
- break;
- case String:
- setMaxLength(column, edmProperty);
- break;
- default:
- break;
- }
- }
-
- private static void setNullable(final Column column, final SimpleProperty edmProperty) {
- ((Facets) edmProperty.getFacets()).setNullable(column.nullable());
- }
-
- private static void setMaxLength(final Column column, final SimpleProperty edmProperty) {
- if (column.length() > 0) {
- ((Facets) edmProperty.getFacets()).setMaxLength(column.length());
- }
- }
-
- private static void setPrecision(final Column column, final SimpleProperty edmProperty) {
- if (column.precision() > 0) {
- ((Facets) edmProperty.getFacets()).setPrecision(column.precision());
- }
- }
-
- private static void setScale(final Column column, final SimpleProperty edmProperty) {
- if (column.scale() > 0) {
- ((Facets) edmProperty.getFacets()).setScale(column.scale());
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/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
deleted file mode 100644
index b64f61c..0000000
--- a/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmFunctionImport.java
+++ /dev/null
@@ -1,331 +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.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.HashMap;
-import java.util.List;
-
-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;
-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.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.JPAEdmEntityTypeView;
-import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmFunctionImportView;
-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;
-
-public class JPAEdmFunctionImport extends JPAEdmBaseViewImpl implements JPAEdmFunctionImportView {
-
- private List<FunctionImport> consistentFunctionImportList = new ArrayList<FunctionImport>();
- private JPAEdmBuilder builder = null;
- private JPAEdmSchemaView schemaView;
-
- public JPAEdmFunctionImport(final JPAEdmSchemaView view) {
- super(view);
- schemaView = view;
- }
-
- @Override
- public JPAEdmBuilder getBuilder() {
- if (builder == null) {
- builder = new JPAEdmFunctionImportBuilder();
- }
- return builder;
- }
-
- @Override
- public List<FunctionImport> getConsistentFunctionImportList() {
- return consistentFunctionImportList;
- }
-
- protected class JPAEdmFunctionImportBuilder implements JPAEdmBuilder {
-
- private JPAEdmEntityTypeView jpaEdmEntityTypeView = null;
- private JPAEdmComplexTypeView jpaEdmComplexTypeView = null;
- @SuppressWarnings("deprecation")
- private _JPAEdmFunctionImportBuilder builderDeprecated = new _JPAEdmFunctionImportBuilder();
-
- @SuppressWarnings("deprecation")
- @Override
- public void build() throws ODataJPAModelException, ODataJPARuntimeException {
-
- HashMap<Class<?>, String[]> customOperations = schemaView.getRegisteredOperations();
-
- jpaEdmEntityTypeView =
- schemaView.getJPAEdmEntityContainerView().getJPAEdmEntitySetView().getJPAEdmEntityTypeView();
- jpaEdmComplexTypeView = schemaView.getJPAEdmComplexTypeView();
-
- if (customOperations != null) {
- // Initialize deprecated Builder
- builderDeprecated.setJPAEdmComplexTypeView(jpaEdmComplexTypeView);
- builderDeprecated.setJPAEdmEntityTypeView(jpaEdmEntityTypeView);
- builderDeprecated.setSchemaView(schemaView);
-
- for (Class<?> clazz : customOperations.keySet()) {
-
- String[] operationNames = customOperations.get(clazz);
- Method[] methods = clazz.getMethods();
- Method method = null;
-
- int length = 0;
- if (operationNames != null) {
- length = operationNames.length;
- } else {
- length = methods.length;
- }
-
- boolean found = false;
- for (int i = 0; i < length; i++) {
-
- try {
- if (operationNames != null) {
- for (Method method2 : methods) {
- if (method2.getName().equals(operationNames[i])) {
- found = true;
- method = method2;
- break;
- }
- }
- if (found == true) {
- found = false;
- } else {
- continue;
- }
- } else {
- method = methods[i];
- }
-
- FunctionImport functionImport = buildFunctionImport(method);
- if (functionImport != null) {
- consistentFunctionImportList.add(functionImport);
- }
-
- } catch (SecurityException e) {
- throw ODataJPAModelException.throwException(ODataJPAModelException.GENERAL, e);
- }
- }
- }
- }
- }
-
- @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) {
- 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 (edmAnnotationFunctionImport.name().equals("")) {
- functionImport.setName(method.getName());
- } else {
- functionImport.setName(edmAnnotationFunctionImport.name());
- }
-
- JPAEdmMapping mapping = new JPAEdmMappingImpl();
- ((Mapping) mapping).setInternalName(method.getName());
- mapping.setJPAType(method.getDeclaringClass());
- functionImport.setMapping((Mapping) mapping);
-
- functionImport.setHttpMethod(edmAnnotationFunctionImport.httpMethod().name().toString());
-
- buildEdmReturnType(functionImport, method, edmAnnotationFunctionImport);
- buildEdmParameter(functionImport, method);
-
- return functionImport;
- }
- return null;
- }
-
- 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>();
- JPAEdmMapping mapping = null;
- int j = 0;
- for (Annotation[] annotationArr : annotations) {
- Class<?> parameterType = parameterTypes[j++];
-
- for (Annotation element : annotationArr) {
- 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
- .getDeclaringClass().getName(), method.getName()), null);
- } else {
- functionImportParameter.setName(annotation.name());
- }
-
- functionImportParameter.setType(JPATypeConvertor.convertToEdmSimpleType(parameterType, null));
-
- 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 buildEdmReturnType(final FunctionImport functionImport, final Method method,
- final EdmFunctionImport edmAnnotationFunctionImport) throws ODataJPAModelException {
- ReturnType returnType = edmAnnotationFunctionImport.returnType();
-
- if (returnType != null) {
- org.apache.olingo.odata2.api.edm.provider.ReturnType functionReturnType =
- new org.apache.olingo.odata2.api.edm.provider.ReturnType();
-
- if (returnType.isCollection()) {
- functionReturnType.setMultiplicity(EdmMultiplicity.MANY);
- } else {
- functionReturnType.setMultiplicity(EdmMultiplicity.ONE);
- }
-
- if (returnType.type() == ReturnType.Type.ENTITY) {
- String entitySet = edmAnnotationFunctionImport.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.type()) {
- case ENTITY:
- EntityType edmEntityType = null;
- if (returnType.isCollection() == false) {
- edmEntityType = jpaEdmEntityTypeView.searchEdmEntityType(methodReturnType.getSimpleName());
- } else {
- 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 SIMPLE:
- EdmSimpleTypeKind edmSimpleTypeKind = JPATypeConvertor.convertToEdmSimpleType(methodReturnType, null);
- functionReturnType.setTypeName(edmSimpleTypeKind.getFullQualifiedName());
-
- break;
- case COMPLEX:
- ComplexType complexType = null;
- if (returnType.isCollection() == false) {
- complexType = jpaEdmComplexTypeView.searchEdmComplexType(methodReturnType.getName());
- } else {
- 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/1b479e6c/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmKey.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmKey.java b/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmKey.java
deleted file mode 100644
index 15cd26e..0000000
--- a/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmKey.java
+++ /dev/null
@@ -1,129 +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.model;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.olingo.odata2.api.edm.provider.ComplexProperty;
-import org.apache.olingo.odata2.api.edm.provider.ComplexType;
-import org.apache.olingo.odata2.api.edm.provider.Facets;
-import org.apache.olingo.odata2.api.edm.provider.Key;
-import org.apache.olingo.odata2.api.edm.provider.Property;
-import org.apache.olingo.odata2.api.edm.provider.PropertyRef;
-import org.apache.olingo.odata2.api.edm.provider.SimpleProperty;
-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.model.JPAEdmComplexTypeView;
-import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmKeyView;
-import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmPropertyView;
-
-public class JPAEdmKey extends JPAEdmBaseViewImpl implements JPAEdmKeyView {
-
- private JPAEdmPropertyView propertyView;
- private JPAEdmComplexTypeView complexTypeView = null;
- private boolean isBuildModeComplexType = false;
- private Key key;
-
- public JPAEdmKey(final JPAEdmProperty view) {
- super(view);
- propertyView = view;
- }
-
- public JPAEdmKey(final JPAEdmComplexTypeView complexTypeView, final JPAEdmPropertyView propertyView) {
- super(complexTypeView);
- this.propertyView = propertyView;
- this.complexTypeView = complexTypeView;
- isBuildModeComplexType = true;
- }
-
- @Override
- public JPAEdmBuilder getBuilder() {
- if (builder == null) {
- builder = new JPAEdmKeyBuider();
- }
-
- return builder;
- }
-
- @Override
- public Key getEdmKey() {
- return key;
- }
-
- private class JPAEdmKeyBuider implements JPAEdmBuilder {
-
- @Override
- public void build() throws ODataJPAModelException {
-
- List<PropertyRef> propertyRefList = null;
- if (key == null) {
- key = new Key();
- }
-
- if (key.getKeys() == null) {
- propertyRefList = new ArrayList<PropertyRef>();
- key.setKeys(propertyRefList);
- } else {
- propertyRefList = key.getKeys();
- }
-
- if (isBuildModeComplexType) {
- ComplexType complexType =
- complexTypeView.searchEdmComplexType(propertyView.getJPAAttribute().getJavaType().getName());
- normalizeComplexKey(complexType, propertyRefList);
- } else {
- PropertyRef propertyRef = new PropertyRef();
- propertyRef.setName(propertyView.getEdmSimpleProperty().getName());
- Facets facets = (Facets) propertyView.getEdmSimpleProperty().getFacets();
- if (facets == null) {
- propertyView.getEdmSimpleProperty().setFacets(new Facets().setNullable(false));
- } else {
- facets.setNullable(false);
- }
- propertyRefList.add(propertyRef);
- }
-
- }
-
- // TODO think how to stop the recursion if A includes B and B includes A!!!!!!
- public void normalizeComplexKey(final ComplexType complexType, final List<PropertyRef> propertyRefList) {
- for (Property property : complexType.getProperties()) {
- try {
-
- SimpleProperty simpleProperty = (SimpleProperty) property;
- Facets facets = (Facets) simpleProperty.getFacets();
- if (facets == null) {
- simpleProperty.setFacets(new Facets().setNullable(false));
- } else {
- facets.setNullable(false);
- }
- PropertyRef propertyRef = new PropertyRef();
- propertyRef.setName(simpleProperty.getName());
- propertyRefList.add(propertyRef);
-
- } catch (ClassCastException e) {
- ComplexProperty complexProperty = (ComplexProperty) property;
- normalizeComplexKey(complexTypeView.searchEdmComplexType(complexProperty.getType()), propertyRefList);
- }
-
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmMappingImpl.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmMappingImpl.java b/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmMappingImpl.java
deleted file mode 100644
index 99d9f5f..0000000
--- a/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmMappingImpl.java
+++ /dev/null
@@ -1,51 +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.model;
-
-import org.apache.olingo.odata2.api.edm.provider.Mapping;
-import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmMapping;
-
-public class JPAEdmMappingImpl extends Mapping implements JPAEdmMapping {
-
- private String columnName = null;
- private Class<?> type = null;
-
- @Override
- public void setJPAColumnName(final String name) {
- columnName = name;
-
- }
-
- @Override
- public String getJPAColumnName() {
- return columnName;
- }
-
- @Override
- public void setJPAType(final Class<?> type) {
- this.type = type;
-
- }
-
- @Override
- public Class<?> getJPAType() {
- return type;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmModel.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmModel.java b/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmModel.java
deleted file mode 100644
index fac5614..0000000
--- a/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmModel.java
+++ /dev/null
@@ -1,65 +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.model;
-
-import javax.persistence.metamodel.Metamodel;
-
-import org.apache.olingo.odata2.processor.api.jpa.ODataJPAContext;
-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.JPAEdmModelView;
-import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmSchemaView;
-
-public class JPAEdmModel extends JPAEdmBaseViewImpl implements JPAEdmModelView {
-
- protected JPAEdmSchemaView schemaView;
-
- public JPAEdmModel(final Metamodel metaModel, final String pUnitName) {
- super(metaModel, pUnitName);
- }
-
- public JPAEdmModel(final ODataJPAContext ctx) {
- super(ctx);
- }
-
- @Override
- public JPAEdmSchemaView getEdmSchemaView() {
- return schemaView;
- }
-
- @Override
- public JPAEdmBuilder getBuilder() {
- if (builder == null) {
- builder = new JPAEdmModelBuilder();
- }
-
- return builder;
- }
-
- private class JPAEdmModelBuilder implements JPAEdmBuilder {
-
- @Override
- public void build() throws ODataJPAModelException, ODataJPARuntimeException {
- schemaView = new JPAEdmSchema(JPAEdmModel.this);
- schemaView.getBuilder().build();
- }
-
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmNavigationProperty.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmNavigationProperty.java b/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmNavigationProperty.java
deleted file mode 100644
index 4757c9a..0000000
--- a/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmNavigationProperty.java
+++ /dev/null
@@ -1,98 +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.model;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.olingo.odata2.api.edm.provider.NavigationProperty;
-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.model.JPAEdmAssociationView;
-import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmNavigationPropertyView;
-import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmPropertyView;
-import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmSchemaView;
-import org.apache.olingo.odata2.processor.core.jpa.access.model.JPAEdmNameBuilder;
-
-public class JPAEdmNavigationProperty extends JPAEdmBaseViewImpl implements JPAEdmNavigationPropertyView {
-
- private JPAEdmAssociationView associationView = null;
- private NavigationProperty currentNavigationProperty = null;
- private JPAEdmPropertyView propertyView = null;
- private List<NavigationProperty> consistentNavigationProperties = null;
- private int count;
-
- public JPAEdmNavigationProperty(final JPAEdmAssociationView associationView, final JPAEdmPropertyView propertyView,
- final int countNumber) {
- super(associationView);
- this.associationView = associationView;
- this.propertyView = propertyView;
- count = countNumber;
- if (consistentNavigationProperties == null) {
- consistentNavigationProperties = new ArrayList<NavigationProperty>();
- }
- }
-
- public JPAEdmNavigationProperty(final JPAEdmSchemaView schemaView) {
- super(schemaView);
- consistentNavigationProperties = new ArrayList<NavigationProperty>();
-
- }
-
- @Override
- public JPAEdmBuilder getBuilder() {
- if (builder == null) {
- builder = new JPAEdmNavigationPropertyBuilder();
- }
-
- return builder;
- }
-
- private class JPAEdmNavigationPropertyBuilder implements JPAEdmBuilder {
-
- @Override
- public void build() throws ODataJPAModelException {
-
- currentNavigationProperty = new NavigationProperty();
- JPAEdmNameBuilder.build(associationView, propertyView, JPAEdmNavigationProperty.this, skipDefaultNaming, count);
- consistentNavigationProperties.add(currentNavigationProperty);
- }
-
- }
-
- @Override
- public NavigationProperty getEdmNavigationProperty() {
- return currentNavigationProperty;
- }
-
- @Override
- public List<NavigationProperty> getConsistentEdmNavigationProperties() {
- return consistentNavigationProperties;
- }
-
- @Override
- public void addJPAEdmNavigationPropertyView(final JPAEdmNavigationPropertyView view) {
- if (view != null && view.isConsistent()) {
- currentNavigationProperty = view.getEdmNavigationProperty();
- consistentNavigationProperties.add(currentNavigationProperty);
-
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmProperty.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmProperty.java b/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmProperty.java
deleted file mode 100644
index b34a71d..0000000
--- a/odata2-processor-jpa/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmProperty.java
+++ /dev/null
@@ -1,378 +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.model;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import javax.persistence.metamodel.Attribute;
-import javax.persistence.metamodel.Attribute.PersistentAttributeType;
-import javax.persistence.metamodel.PluralAttribute;
-import javax.persistence.metamodel.SingularAttribute;
-
-import org.apache.olingo.odata2.api.edm.EdmSimpleTypeKind;
-import org.apache.olingo.odata2.api.edm.FullQualifiedName;
-import org.apache.olingo.odata2.api.edm.provider.ComplexProperty;
-import org.apache.olingo.odata2.api.edm.provider.ComplexType;
-import org.apache.olingo.odata2.api.edm.provider.Property;
-import org.apache.olingo.odata2.api.edm.provider.SimpleProperty;
-import org.apache.olingo.odata2.processor.api.jpa.access.JPAEdmBuilder;
-import org.apache.olingo.odata2.processor.api.jpa.access.JPAEdmMappingModelAccess;
-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.JPAEdmAssociationEndView;
-import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmAssociationView;
-import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmComplexPropertyView;
-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.JPAEdmKeyView;
-import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmNavigationPropertyView;
-import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmPropertyView;
-import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmReferentialConstraintView;
-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;
-
-public class JPAEdmProperty extends JPAEdmBaseViewImpl implements
- JPAEdmPropertyView, JPAEdmComplexPropertyView {
-
- private JPAEdmSchemaView schemaView;
- private JPAEdmEntityTypeView entityTypeView;
- private JPAEdmComplexTypeView complexTypeView;
- private JPAEdmNavigationPropertyView navigationPropertyView = null;
-
- private JPAEdmKeyView keyView;
- private List<Property> properties;
- private SimpleProperty currentSimpleProperty = null;
- private ComplexProperty currentComplexProperty = null;
- private Attribute<?, ?> currentAttribute;
- private boolean isBuildModeComplexType;
- private Map<String, Integer> associationCount;
-
- public JPAEdmProperty(final JPAEdmSchemaView view) {
- super(view);
- schemaView = view;
- entityTypeView = schemaView.getJPAEdmEntityContainerView()
- .getJPAEdmEntitySetView().getJPAEdmEntityTypeView();
- complexTypeView = schemaView.getJPAEdmComplexTypeView();
- navigationPropertyView = new JPAEdmNavigationProperty(schemaView);
- isBuildModeComplexType = false;
- associationCount = new HashMap<String, Integer>();
- }
-
- public JPAEdmProperty(final JPAEdmSchemaView schemaView,
- final JPAEdmComplexTypeView view) {
- super(view);
- this.schemaView = schemaView;
- complexTypeView = view;
- isBuildModeComplexType = true;
- }
-
- @Override
- public JPAEdmBuilder getBuilder() {
- if (builder == null) {
- builder = new JPAEdmPropertyBuilder();
- }
-
- return builder;
- }
-
- @Override
- public List<Property> getEdmPropertyList() {
- return properties;
- }
-
- @Override
- public JPAEdmKeyView getJPAEdmKeyView() {
- return keyView;
- }
-
- @Override
- public SimpleProperty getEdmSimpleProperty() {
- return currentSimpleProperty;
- }
-
- @Override
- public Attribute<?, ?> getJPAAttribute() {
- return currentAttribute;
- }
-
- @Override
- public ComplexProperty getEdmComplexProperty() {
- return currentComplexProperty;
- }
-
- @Override
- public JPAEdmNavigationPropertyView getJPAEdmNavigationPropertyView() {
- return navigationPropertyView;
- }
-
- private class JPAEdmPropertyBuilder implements JPAEdmBuilder {
- /*
- *
- * Each call to build method creates a new EDM Property List.
- * The Property List can be created either by an Entity type or
- * ComplexType. The flag isBuildModeComplexType tells if the
- * Properties are built for complex type or for Entity Type.
- *
- * While Building Properties Associations are built. However
- * the associations thus built does not contain Referential
- * constraint. Associations thus built only contains
- * information about Referential constraints. Adding of
- * referential constraints to Associations is the taken care
- * by Schema.
- *
- * Building Properties is divided into four parts
- * A) Building Simple Properties
- * B) Building Complex Properties
- * C) Building Associations
- * D) Building Navigation Properties
- *
- * ************************************************************
- * Build EDM Schema - STEPS
- * ************************************************************
- * A) Building Simple Properties:
- *
- * 1) Fetch JPA Attribute List from
- * A) Complex Type
- * B) Entity Type
- * depending on isBuildModeComplexType.
- * B) Building Complex Properties
- * C) Building Associations
- * D) Building Navigation Properties
- *
- * ************************************************************
- * Build EDM Schema - STEPS
- * ************************************************************
- */
- @Override
- public void build() throws ODataJPAModelException, ODataJPARuntimeException {
-
- JPAEdmBuilder keyViewBuilder = null;
-
- properties = new ArrayList<Property>();
-
- List<Attribute<?, ?>> jpaAttributes = null;
- String currentEntityName = null;
- String targetEntityName = null;
- String entityTypeName = null;
- if (isBuildModeComplexType) {
- jpaAttributes = sortInAscendingOrder(complexTypeView.getJPAEmbeddableType()
- .getAttributes());
- entityTypeName = complexTypeView.getJPAEmbeddableType().getJavaType()
- .getSimpleName();
- } else {
- jpaAttributes = sortInAscendingOrder(entityTypeView.getJPAEntityType()
- .getAttributes());
- entityTypeName = entityTypeView.getJPAEntityType().getName();
- }
-
- for (Object jpaAttribute : jpaAttributes) {
- currentAttribute = (Attribute<?, ?>) jpaAttribute;
-
- // Check for need to Exclude
- if (isExcluded((JPAEdmPropertyView) JPAEdmProperty.this, entityTypeName, currentAttribute.getName())) {
- continue;
- }
-
- PersistentAttributeType attributeType = currentAttribute
- .getPersistentAttributeType();
-
- switch (attributeType) {
- case BASIC:
-
- currentSimpleProperty = new SimpleProperty();
- JPAEdmNameBuilder
- .build((JPAEdmPropertyView) JPAEdmProperty.this, isBuildModeComplexType, skipDefaultNaming);
-
- EdmSimpleTypeKind simpleTypeKind = JPATypeConvertor
- .convertToEdmSimpleType(currentAttribute
- .getJavaType(), currentAttribute);
-
- currentSimpleProperty.setType(simpleTypeKind);
- JPAEdmFacets.setFacets(currentAttribute, currentSimpleProperty);
-
- properties.add(currentSimpleProperty);
-
- if (((SingularAttribute<?, ?>) currentAttribute).isId()) {
- if (keyView == null) {
- keyView = new JPAEdmKey(JPAEdmProperty.this);
- keyViewBuilder = keyView.getBuilder();
- }
-
- keyViewBuilder.build();
- }
-
- break;
- case EMBEDDED:
- ComplexType complexType = complexTypeView
- .searchEdmComplexType(currentAttribute.getJavaType().getName());
-
- if (complexType == null) {
- JPAEdmComplexTypeView complexTypeViewLocal = new JPAEdmComplexType(
- schemaView, currentAttribute);
- complexTypeViewLocal.getBuilder().build();
- complexType = complexTypeViewLocal.getEdmComplexType();
- complexTypeView.addJPAEdmCompleTypeView(complexTypeViewLocal);
-
- }
-
- if (isBuildModeComplexType == false
- && entityTypeView.getJPAEntityType().getIdType()
- .getJavaType()
- .equals(currentAttribute.getJavaType())) {
-
- if (keyView == null) {
- keyView = new JPAEdmKey(complexTypeView,
- JPAEdmProperty.this);
- }
- keyView.getBuilder().build();
- complexTypeView.expandEdmComplexType(complexType, properties, currentAttribute.getName());
- } else {
- currentComplexProperty = new ComplexProperty();
- if (isBuildModeComplexType) {
- JPAEdmNameBuilder
- .build((JPAEdmComplexPropertyView) JPAEdmProperty.this,
- complexTypeView.getJPAEmbeddableType().getJavaType().getSimpleName());
- } else {
- JPAEdmNameBuilder
- .build((JPAEdmComplexPropertyView) JPAEdmProperty.this,
- JPAEdmProperty.this, skipDefaultNaming);
- }
- currentComplexProperty.setType(new FullQualifiedName(
- schemaView.getEdmSchema().getNamespace(),
- complexType.getName()));
-
- properties.add(currentComplexProperty);
- List<String> nonKeyComplexTypes = schemaView.getNonKeyComplexTypeList();
- if (!nonKeyComplexTypes.contains(currentComplexProperty.getType().getName()))
- {
- schemaView.addNonKeyComplexName(currentComplexProperty.getType().getName());
- }
- }
-
- break;
- case MANY_TO_MANY:
- case ONE_TO_MANY:
- case ONE_TO_ONE:
- case MANY_TO_ONE:
-
- JPAEdmAssociationEndView associationEndView = new JPAEdmAssociationEnd(entityTypeView, JPAEdmProperty.this);
- associationEndView.getBuilder().build();
- JPAEdmAssociationView associationView = schemaView.getJPAEdmAssociationView();
- if (associationView.searchAssociation(associationEndView) == null) {
- int count = associationView.getNumberOfAssociationsWithSimilarEndPoints(associationEndView);
- JPAEdmAssociationView associationViewLocal =
- new JPAEdmAssociation(associationEndView, entityTypeView, JPAEdmProperty.this, count);
- associationViewLocal.getBuilder().build();
- associationView.addJPAEdmAssociationView(associationViewLocal, associationEndView);
- }
-
- JPAEdmReferentialConstraintView refConstraintView = new JPAEdmReferentialConstraint(
- associationView, entityTypeView, JPAEdmProperty.this);
- refConstraintView.getBuilder().build();
-
- if (refConstraintView.isExists()) {
- associationView.addJPAEdmRefConstraintView(refConstraintView);
- }
-
- if (navigationPropertyView == null) {
- navigationPropertyView = new JPAEdmNavigationProperty(schemaView);
- }
- currentEntityName = entityTypeView.getJPAEntityType().getName();
-
- if (currentAttribute.isCollection()) {
- targetEntityName = ((PluralAttribute<?, ?, ?>) currentAttribute).getElementType().getJavaType()
- .getSimpleName();
- } else {
- targetEntityName = currentAttribute.getJavaType().getSimpleName();
- }
- Integer sequenceNumber = associationCount.get(currentEntityName + targetEntityName);
- if (sequenceNumber == null) {
- sequenceNumber = new Integer(1);
- } else {
- sequenceNumber = new Integer(sequenceNumber.intValue() + 1);
- }
- associationCount.put(currentEntityName + targetEntityName, sequenceNumber);
- JPAEdmNavigationPropertyView localNavigationPropertyView =
- new JPAEdmNavigationProperty(associationView, JPAEdmProperty.this, sequenceNumber.intValue());
- localNavigationPropertyView.getBuilder().build();
- navigationPropertyView.addJPAEdmNavigationPropertyView(localNavigationPropertyView);
- break;
- default:
- break;
- }
- }
-
- }
-
- @SuppressWarnings("rawtypes")
- private List<Attribute<?, ?>> sortInAscendingOrder(final Set<?> jpaAttributes) {
- List<Attribute<?, ?>> jpaAttributeList = new ArrayList<Attribute<?, ?>>();
- Iterator itr = null;
- Attribute<?, ?> smallestJpaAttribute;
- Attribute<?, ?> currentJpaAttribute;
- while (!jpaAttributes.isEmpty()) {
- itr = jpaAttributes.iterator();
- smallestJpaAttribute = (Attribute<?, ?>) itr.next();
- while (itr.hasNext()) {
- currentJpaAttribute = (Attribute<?, ?>) itr.next();
- if (smallestJpaAttribute.getName().compareTo(currentJpaAttribute.getName()) > 0) {
- smallestJpaAttribute = currentJpaAttribute;
- }
- }
- jpaAttributeList.add(smallestJpaAttribute);
- jpaAttributes.remove(smallestJpaAttribute);
- }
- return jpaAttributeList;
- }
- }
-
- @Override
- public JPAEdmEntityTypeView getJPAEdmEntityTypeView() {
- return entityTypeView;
- }
-
- @Override
- public JPAEdmComplexTypeView getJPAEdmComplexTypeView() {
- return complexTypeView;
- }
-
- private boolean isExcluded(final JPAEdmPropertyView jpaEdmPropertyView, final String jpaEntityTypeName,
- final String jpaAttributeName) {
- JPAEdmMappingModelAccess mappingModelAccess = jpaEdmPropertyView
- .getJPAEdmMappingModelAccess();
- boolean isExcluded = false;
- if (mappingModelAccess != null && mappingModelAccess.isMappingModelExists()) {
- // Exclusion of a simple property in a complex type
- if (isBuildModeComplexType
- && mappingModelAccess.checkExclusionOfJPAEmbeddableAttributeType(jpaEntityTypeName, jpaAttributeName)
- // Exclusion of a simple property of an Entity Type
- || (!isBuildModeComplexType && mappingModelAccess.checkExclusionOfJPAAttributeType(jpaEntityTypeName,
- jpaAttributeName))) {
- isExcluded = true;
- }
- }
- return isExcluded;
- }
-}
[35/37] [OLINGO-82] Renamed the project folder name to
odata2-jpa-processor
Posted by ch...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmAssociationView.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmAssociationView.java b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmAssociationView.java
new file mode 100644
index 0000000..7cc7cda
--- /dev/null
+++ b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmAssociationView.java
@@ -0,0 +1,128 @@
+/*******************************************************************************
+ * 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.api.jpa.model;
+
+import java.util.List;
+
+import org.apache.olingo.odata2.api.edm.provider.Association;
+
+/**
+ * <p>
+ * A View on Java Persistence Entity Relationship and Entity Data Model
+ * Association.
+ * </p>
+ * <p>
+ * The implementation of the view provides access to EDM Association created
+ * from Java Persistence Entity Relationships. The implementation acts as a
+ * container for list of association that are consistent.
+ *
+ * An Association is said to be consistent only
+ * <ol>
+ * <li>If both the Ends of Association are consistent</li>
+ * <li>If referential constraint exists for the Association then it should be
+ * consistent</li>
+ * </ol>
+ * </p>
+ *
+ *
+ * <p>
+ * @org.apache.olingo.odata2.DoNotImplement
+ * @see org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmAssociationSetView
+ * @see org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmReferentialConstraintView
+ *
+ */
+public interface JPAEdmAssociationView extends JPAEdmBaseView {
+
+ /**
+ * The method returns an association which is currently being processed.
+ *
+ * @return an {@link org.apache.olingo.odata2.api.edm.provider.Association}
+ */
+ public Association getEdmAssociation();
+
+ /**
+ * The method returns a consistent list of associations. An association is
+ * set to be consistent only if all its mandatory properties can be
+ * completely built from a Java Persistence Relationship.
+ *
+ * @return a consistent list of {@link org.apache.olingo.odata2.api.edm.provider.Association}
+ *
+ */
+ public List<Association> getConsistentEdmAssociationList();
+
+ /**
+ * The method adds {@link org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmAssociationView} to its container
+ *
+ * @param associationView
+ * of type {@link org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmAssociationView}
+ */
+ public void addJPAEdmAssociationView(JPAEdmAssociationView associationView,
+ JPAEdmAssociationEndView associationEndView);
+
+ /**
+ * The method searches for an Association in its container against the
+ * search parameter <b>view</b> of type {@link org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmAssociationView}
+ * .
+ *
+ * The Association in the container <b>view</b> is searched against the
+ * consistent list of Association stored in this container.
+ *
+ * @param view
+ * of type {@link org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmAssociationView}
+ * @return {@link org.apache.olingo.odata2.api.edm.provider.Association} if found
+ * in the container
+ */
+ public Association searchAssociation(JPAEdmAssociationEndView view);
+
+ /**
+ * The method adds the referential constraint view to its container.
+ * <p>
+ * <b>Note: </b>The referential constraint view is added only if it exists.
+ * </p>
+ *
+ * @param refView
+ * of type {@link org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmReferentialConstraintView}
+ */
+ public void addJPAEdmRefConstraintView(JPAEdmReferentialConstraintView refView);
+
+ /**
+ * The method returns the referential constraint view that is currently
+ * being processed.
+ *
+ * @return an instance of type
+ * {@link org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmReferentialConstraintView}
+ */
+ public JPAEdmReferentialConstraintView getJPAEdmReferentialConstraintView();
+
+ /**
+ * The method searches for the number of associations with similar endpoints in its container against the
+ * search parameter <b>view</b> of type {@link org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmAssociationView}
+ * .
+ *
+ * The Association in the container <b>view</b> is searched against the
+ * consistent list of Association stored in this container.
+ *
+ * @param view
+ * of type {@link org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmAssociationView}
+ * @return {@link org.apache.olingo.odata2.api.edm.provider.Association} if found
+ * in the container
+ */
+ int getNumberOfAssociationsWithSimilarEndPoints(JPAEdmAssociationEndView view);
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmBaseView.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmBaseView.java b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmBaseView.java
new file mode 100644
index 0000000..765da7f
--- /dev/null
+++ b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmBaseView.java
@@ -0,0 +1,101 @@
+/*******************************************************************************
+ * 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.api.jpa.model;
+
+import javax.persistence.metamodel.Metamodel;
+
+import org.apache.olingo.odata2.processor.api.jpa.access.JPAEdmBuilder;
+import org.apache.olingo.odata2.processor.api.jpa.access.JPAEdmMappingModelAccess;
+
+/**
+ * <p>
+ * A base view on Java Persistence Model and Entity Data Model.
+ * </p>
+ * <p>
+ * The implementation of the view acts as a base container for containers of
+ * Java Persistence Model and Entity Data Model elements.
+ *
+ *
+ * <p>
+ * @org.apache.olingo.odata2.DoNotImplement
+ *
+ */
+public interface JPAEdmBaseView {
+ /**
+ *
+ * @return Java Persistence Unit Name
+ */
+ public String getpUnitName();
+
+ /**
+ * The method returns the Java Persistence MetaModel
+ *
+ * @return a meta model of type {@link javax.persistence.metamodel.Metamodel}
+ */
+ public Metamodel getJPAMetaModel();
+
+ /**
+ * The method returns a builder for building Entity Data Model elements from
+ * Java Persistence Model Elements
+ *
+ * @return a builder of type {@link org.apache.olingo.odata2.processor.api.jpa.access.JPAEdmBuilder}
+ */
+ public JPAEdmBuilder getBuilder();
+
+ /**
+ * The method returns the if the container is consistent without any errors
+ *
+ * @return <ul>
+ * <li>true - if the container is consistent without errors</li>
+ * <li>false - if the container is inconsistent with errors</li>
+ * </ul>
+ *
+ */
+ public boolean isConsistent();
+
+ /**
+ * The method cleans the container.
+ */
+ public void clean();
+
+ /**
+ * The method returns a reference to JPA EDM mapping model access.
+ *
+ * @return an instance to JPA EDM mapping model access
+ */
+ public JPAEdmMappingModelAccess getJPAEdmMappingModelAccess();
+
+ /**
+ * The method returns a reference to JPA EDM extension if available else
+ * null.
+ *
+ * @return an instance of JPA Edm Extension
+ */
+ public JPAEdmExtension getJPAEdmExtension();
+
+ /**
+ * The method returns whether the default naming logic is skipped for the
+ * current view.
+ *
+ * @return <ul><li>true - skip default naming logic</li>
+ * <li>false - do not skip default naming logic</li>
+ * </ul>
+ */
+ public boolean isDefaultNamingSkipped();
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmComplexPropertyView.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmComplexPropertyView.java b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmComplexPropertyView.java
new file mode 100644
index 0000000..172e5f4
--- /dev/null
+++ b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmComplexPropertyView.java
@@ -0,0 +1,45 @@
+/*******************************************************************************
+ * 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.api.jpa.model;
+
+import org.apache.olingo.odata2.api.edm.provider.ComplexProperty;
+
+/**
+ * <p>
+ * A view on properties of Java Persistence embeddable type and EDM complex
+ * type. Properties of JPA embeddable types are converted into EDM properties of
+ * EDM complex type.
+ * </p>
+ * <p>
+ * The implementation of the view provides access to properties of EDM complex
+ * type created for a given JPA EDM complex type. The implementation acts as a
+ * container for the properties of EDM complex type.
+ * </p>
+ *
+ * @org.apache.olingo.odata2.DoNotImplement
+ * @see org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmComplexTypeView
+ */
+public interface JPAEdmComplexPropertyView extends JPAEdmBaseView {
+ /**
+ * The method returns a complex property for a complex type.
+ *
+ * @return an instance of {@link org.apache.olingo.odata2.api.edm.provider.ComplexProperty}
+ */
+ ComplexProperty getEdmComplexProperty();
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmComplexTypeView.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmComplexTypeView.java b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmComplexTypeView.java
new file mode 100644
index 0000000..bbee5e4
--- /dev/null
+++ b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmComplexTypeView.java
@@ -0,0 +1,116 @@
+/*******************************************************************************
+ * 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.api.jpa.model;
+
+import java.util.List;
+
+import org.apache.olingo.odata2.api.edm.FullQualifiedName;
+import org.apache.olingo.odata2.api.edm.provider.ComplexType;
+import org.apache.olingo.odata2.api.edm.provider.Property;
+
+/**
+ * A view on Java Persistence embeddable types and EDM complex types. Java
+ * persistence embeddable types are converted into EDM entity types. Only those
+ * embeddable types that are
+ * <ol>
+ * <li>used in a java persistence Entity type</li>
+ * <li>used as non embeddable id of a java persistence entity type</li>
+ * </ol>
+ * are converted into EDM complex types.
+ * <p>
+ * The implementation of the view provides access to EDM complex types for the
+ * given JPA EDM model. The view acts as a container for consistent list of EDM
+ * complex types. An EDM complex type is said to be consistent only if it used
+ * in at least one of the EDM entity type.
+ *
+ *
+ * <p>
+ * @org.apache.olingo.odata2.DoNotImplement
+ * @see org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmComplexPropertyView
+ *
+ */
+public interface JPAEdmComplexTypeView extends JPAEdmBaseView {
+
+ /**
+ * The method returns an EDM complex type that is currently being processed.
+ *
+ * @return an instance of type {@link org.apache.olingo.odata2.api.edm.provider.ComplexType}
+ */
+ public ComplexType getEdmComplexType();
+
+ /**
+ * The method returns an JPA embeddable type that is currently being
+ * processed.
+ *
+ * @return an instance of type {@link javax.persistence.metamodel.EmbeddableType}
+ */
+ public javax.persistence.metamodel.EmbeddableType<?> getJPAEmbeddableType();
+
+ /**
+ * The method returns a consistent list of EDM complex types.
+ *
+ * @return a list of {@link org.apache.olingo.odata2.api.edm.provider.ComplexType}
+ */
+ public List<ComplexType> getConsistentEdmComplexTypes();
+
+ /**
+ * The method searches for the EDM complex type with in the container for
+ * the given JPA embeddable type name.
+ *
+ * @param embeddableTypeName
+ * is the name of JPA embeddable type
+ * @return a reference to EDM complex type if found else null
+ */
+ public ComplexType searchEdmComplexType(String embeddableTypeName);
+
+ /**
+ * The method add a JPA EDM complex type view to the container.
+ *
+ * @param view
+ * is an instance of type {@link org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmComplexTypeView}
+ */
+ public void addJPAEdmCompleTypeView(JPAEdmComplexTypeView view);
+
+ /**
+ * The method searches for the EDM complex type with in the container for
+ * the given EDM complex type's fully qualified name.
+ *
+ * @param type
+ * is the fully qualified name of EDM complex type
+ * @return a reference to EDM complex type if found else null
+ */
+ public ComplexType searchEdmComplexType(FullQualifiedName type);
+
+ /**
+ * The method expands the given EDM complex type into a list of EDM simple
+ * properties.
+ *
+ * @param complexType
+ * is the EDM complex type to expand
+ * @param expandedPropertyList
+ * is the list to be populated with expanded EDM simple
+ * properties
+ * @param embeddablePropertyName
+ * is the name of the complex property. The name is used as the
+ * qualifier for the expanded simple property names.
+ */
+ public void expandEdmComplexType(ComplexType complexType, List<Property> expandedPropertyList,
+ String embeddablePropertyName);
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmEntityContainerView.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmEntityContainerView.java b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmEntityContainerView.java
new file mode 100644
index 0000000..82ccaf9
--- /dev/null
+++ b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmEntityContainerView.java
@@ -0,0 +1,72 @@
+/*******************************************************************************
+ * 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.api.jpa.model;
+
+import java.util.List;
+
+import org.apache.olingo.odata2.api.edm.provider.EntityContainer;
+
+/**
+ * A view on JPA EDM entity container. JPA EDM entity container is built from
+ * consistent JPA EDM entity set and consistent JPA EDM association set views.
+ *
+ * <p>
+ * The implementation of the view provides access to EDM entity containers. The
+ * view acts as container for JPA EDM entity containers. A JPA EDM entity
+ * container is said to be consistent only if the JPA EDM association set and
+ * JPA EDM Entity Set view are consistent.
+ *
+ *
+ * @org.apache.olingo.odata2.DoNotImplement
+ * @see org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmEntitySetView
+ * @see org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmAssociationSetView
+ *
+ */
+public interface JPAEdmEntityContainerView extends JPAEdmBaseView {
+ /**
+ * The method returns the EDM entity container that is currently being
+ * processed.
+ *
+ * @return an instance of type {@link org.apache.olingo.odata2.api.edm.provider.EntityContainer}
+ */
+ public EntityContainer getEdmEntityContainer();
+
+ /**
+ * The method returns a list of consistent EDM entity containers
+ *
+ * @return a list of consistent EDM entity containers
+ */
+ public List<EntityContainer> getConsistentEdmEntityContainerList();
+
+ /**
+ * The method returns the JPA EDM entity set view that is currently being
+ * processed.
+ *
+ * @return an instance of type {@link org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmEntitySetView}
+ */
+ public JPAEdmEntitySetView getJPAEdmEntitySetView();
+
+ /**
+ * The method returns the JPA EDM association set view that is currently
+ * being processed.
+ *
+ * @return an instance of type {@link org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmAssociationSetView}
+ */
+ public JPAEdmAssociationSetView getEdmAssociationSetView();
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmEntitySetView.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmEntitySetView.java b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmEntitySetView.java
new file mode 100644
index 0000000..87019f6
--- /dev/null
+++ b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmEntitySetView.java
@@ -0,0 +1,64 @@
+/*******************************************************************************
+ * 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.api.jpa.model;
+
+import java.util.List;
+
+import org.apache.olingo.odata2.api.edm.provider.EntitySet;
+
+/**
+ * A view on Java Persistence entity type and EDM entity sets. Java persistence
+ * entity types are converted into EDM entity types and EDM entity sets.
+ * <p>
+ * The implementation of the view provides access to EDM entity sets for the
+ * given JPA EDM entity type. The view acts as a container for consistent list
+ * of EDM entity sets. An EDM entity set is said to be consistent only if it has
+ * consistent EDM entity types.
+ *
+ *
+ * <p>
+ * @org.apache.olingo.odata2.DoNotImplement
+ * @see org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmEntityTypeView
+ *
+ */
+public interface JPAEdmEntitySetView extends JPAEdmBaseView {
+ /**
+ * The method returns an EDM entity set that is currently being processed.
+ *
+ * @return an instance of type {@link org.apache.olingo.odata2.api.edm.provider.EntitySet}
+ */
+ public EntitySet getEdmEntitySet();
+
+ /**
+ * The method returns a list of consistent EDM entity sets.
+ *
+ * @return a list of EDM entity sets
+ */
+ public List<EntitySet> getConsistentEdmEntitySetList();
+
+ /**
+ * The method returns a JPA EDM entity type view that is currently being
+ * processed. JPA EDM entity set view is built from JPA EDM entity type
+ * view.
+ *
+ * @return an instance of type {@link org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmEntityTypeView}
+ */
+ public JPAEdmEntityTypeView getJPAEdmEntityTypeView();
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmEntityTypeView.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmEntityTypeView.java b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmEntityTypeView.java
new file mode 100644
index 0000000..54965d8
--- /dev/null
+++ b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmEntityTypeView.java
@@ -0,0 +1,76 @@
+/*******************************************************************************
+ * 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.api.jpa.model;
+
+import java.util.List;
+
+import org.apache.olingo.odata2.api.edm.provider.EntityType;
+
+/**
+ * A view on Java Persistence entity types and EDM entity types. Java
+ * persistence entity types are converted into EDM entity types.
+ * <p>
+ * The implementation of the view provides access to EDM entity types for the
+ * given JPA EDM model. The view acts as a container for consistent list of EDM
+ * entity types. An EDM entity type is said to be consistent only if it has at
+ * least one consistent EDM property and at least one consistent EDM key.
+ *
+ *
+ * <p>
+ * @org.apache.olingo.odata2.DoNotImplement
+ * @see org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmPropertyView
+ * @see org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmKeyView
+ * @see org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmNavigationPropertyView
+ *
+ */
+public interface JPAEdmEntityTypeView extends JPAEdmBaseView {
+ /**
+ * The method returns an EDM entity currently being processed.
+ *
+ * @return an instance of type {@link org.apache.olingo.odata2.api.edm.provider.EntityType}
+ */
+ public EntityType getEdmEntityType();
+
+ /**
+ * The method returns java persistence Entity type currently being
+ * processed.
+ *
+ * @return an instance of type {@link javax.persistence.metamodel.EntityType}
+ */
+ public javax.persistence.metamodel.EntityType<?> getJPAEntityType();
+
+ /**
+ * The method returns a consistent list of EDM entity types for a given java
+ * persistence meta model.
+ *
+ * @return a list of {@link org.apache.olingo.odata2.api.edm.provider.EntityType}
+ */
+ public List<EntityType> getConsistentEdmEntityTypes();
+
+ /**
+ * The method searches in the consistent list of EDM entity types for the
+ * given EDM entity type's name.
+ *
+ * @param jpaEntityTypeName
+ * is the name of EDM entity type
+ * @return a reference to EDM entity type if found else null
+ */
+ public EntityType searchEdmEntityType(String jpaEntityTypeName);
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmExtension.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmExtension.java b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmExtension.java
new file mode 100644
index 0000000..1345106
--- /dev/null
+++ b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmExtension.java
@@ -0,0 +1,50 @@
+/*******************************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ ******************************************************************************/
+package org.apache.olingo.odata2.processor.api.jpa.model;
+
+/**
+ * The interface provides methods to extend JPA EDM containers.
+ *
+ *
+ *
+ */
+public interface JPAEdmExtension {
+
+ /**
+ * The method is used to extend the JPA EDM schema view with custom operations. Use this method to
+ * register custom operations.
+ *
+ * @param view
+ * is the schema view
+ * @see org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmSchemaView#registerOperations(Class, String[])
+ *
+ */
+ public void extendWithOperation(JPAEdmSchemaView view);
+
+ /**
+ * The method is used to extend the JPA EDM schema view with Entities, Entity Sets, Navigation Property and
+ * Association.
+ *
+ * @param view
+ * is the schema view
+ *
+ */
+ public void extendJPAEdmSchema(JPAEdmSchemaView view);
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmFunctionImportView.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmFunctionImportView.java b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmFunctionImportView.java
new file mode 100644
index 0000000..be19742
--- /dev/null
+++ b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmFunctionImportView.java
@@ -0,0 +1,51 @@
+/*******************************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ ******************************************************************************/
+package org.apache.olingo.odata2.processor.api.jpa.model;
+
+import java.util.List;
+
+import org.apache.olingo.odata2.api.edm.provider.FunctionImport;
+
+/**
+ * <p>
+ * A view on EDM Function Imports. EDM function imports are derived from Java
+ * class methods annotated with EDM Annotations.
+ * </p>
+ * <p>
+ * The implementation of the view provides access to EDM Function Import created
+ * from Java class methods. The implementation act as a container for list of
+ * function imports that are consistent.
+ * </p>
+ *
+ *
+ * <p>
+ * @org.apache.olingo.odata2.DoNotImplement
+ *
+ */
+public interface JPAEdmFunctionImportView extends JPAEdmBaseView {
+
+ /**
+ * The method returns a list of consistent Function Imports. A function
+ * import is said to be consistent only if it adheres to the rules defined
+ * in CSDL.
+ *
+ * @return a list of type {@link org.apache.olingo.odata2.api.edm.provider.FunctionImport}
+ */
+ List<FunctionImport> getConsistentFunctionImportList();
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmKeyView.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmKeyView.java b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmKeyView.java
new file mode 100644
index 0000000..a684126
--- /dev/null
+++ b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmKeyView.java
@@ -0,0 +1,51 @@
+/*******************************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ ******************************************************************************/
+package org.apache.olingo.odata2.processor.api.jpa.model;
+
+import org.apache.olingo.odata2.api.edm.provider.Key;
+
+/**
+ * A view on Java Persistence Entity Key Attributes and EDM Key properties. Java
+ * Persistence Key Attributes of type
+ * <ol>
+ * <li>embedded ID</li>
+ * <li>ID</li>
+ * </ol>
+ * are converted into EDM keys. Embedded IDs are expanded into simple EDM
+ * properties.
+ * <p>
+ * The implementation of the view provides access to EDM key properties for a
+ * given JPA EDM entity type. The view acts as a container for consistent EDM
+ * key property of an EDM entity type.
+ *
+ *
+ * <p>
+ * @org.apache.olingo.odata2.DoNotImplement
+ * @see org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmPropertyView
+ *
+ */
+public interface JPAEdmKeyView extends JPAEdmBaseView {
+ /**
+ * The method returns an instance of EDM key for the given JPA EDM Entity
+ * type.
+ *
+ * @return an instance of type {@link org.apache.olingo.odata2.api.edm.provider.Key}
+ */
+ public Key getEdmKey();
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmMapping.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmMapping.java b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmMapping.java
new file mode 100644
index 0000000..4c44083
--- /dev/null
+++ b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmMapping.java
@@ -0,0 +1,63 @@
+/*******************************************************************************
+ * 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.api.jpa.model;
+
+/**
+ * The interface acts a container for storing Java persistence column name. The
+ * JPA EDM mapping instance can be associated with any EDM simple, EDM complex
+ * property to denote the properties Java persistence column name.
+ *
+ *
+ *
+ */
+public interface JPAEdmMapping {
+ /**
+ * The method sets the Java persistence column name into the mapping
+ * container.
+ *
+ * @param name
+ * is the Java persistence column name
+ */
+ public void setJPAColumnName(String name);
+
+ /**
+ * The method gets the Java persistence column name from the mapping
+ * container.
+ *
+ * @return a String representing the Java persistence column name set into
+ * the container
+ */
+ public String getJPAColumnName();
+
+ /**
+ * The method sets the Java persistence entity/property type.
+ *
+ * @param type
+ * is an instance of type Class<?>
+ */
+ public void setJPAType(Class<?> type);
+
+ /**
+ * The method returns the Java persistence entity/property type.
+ *
+ * @return type
+ */
+ public Class<?> getJPAType();
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmModelView.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmModelView.java b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmModelView.java
new file mode 100644
index 0000000..4c9a777
--- /dev/null
+++ b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmModelView.java
@@ -0,0 +1,43 @@
+/*******************************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ ******************************************************************************/
+package org.apache.olingo.odata2.processor.api.jpa.model;
+
+/**
+ * A view on JPA meta model and EDM meta model. The view acts as the base for
+ * the construction of EDM meta model from a JPA meta model.
+ * <p>
+ * The implementation of the view acts as the container for JPA meta model and
+ * EDM meta model. The instance of JPA EDM meta model can be created using
+ * {@link org.apache.olingo.odata2.processor.api.jpa.factory.JPAAccessFactory}. The
+ * instance thus obtained can be used for constructing other elements of the
+ * meta model using {@link org.apache.olingo.odata2.processor.api.jpa.access.JPAEdmBuilder}.
+ *
+ *
+ * @org.apache.olingo.odata2.DoNotImplement
+ * @see org.apache.olingo.odata2.processor.api.jpa.factory.JPAAccessFactory
+ */
+public interface JPAEdmModelView extends JPAEdmBaseView {
+ /**
+ * The method returns a consistent JPA EDM schema view created from the JPA
+ * meta model.
+ *
+ * @return an instance of type {@link org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmSchemaView}
+ */
+ public JPAEdmSchemaView getEdmSchemaView();
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmNavigationPropertyView.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmNavigationPropertyView.java b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmNavigationPropertyView.java
new file mode 100644
index 0000000..e1b0d3d
--- /dev/null
+++ b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmNavigationPropertyView.java
@@ -0,0 +1,72 @@
+/*******************************************************************************
+ * 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.api.jpa.model;
+
+import java.util.List;
+
+import org.apache.olingo.odata2.api.edm.provider.NavigationProperty;
+
+/**
+ * A view on Java persistence entity relationship and EDM navigation property.
+ * Java persistence entity relationships annotated as
+ * <ol>
+ * <li>Many To Many</li>
+ * <li>One To Many</li>
+ * <li>One To One</li>
+ * <li>Many To One</li>
+ * </ol>
+ * are transformed into navigation properties.
+ * <p>
+ * The implementation of the view provides access to EDM navigation properties
+ * for a given JPA EDM entity type. The view acts as a container for consistent
+ * list of EDM navigation properties of an EDM entity type. EDM navigation
+ * property is consistent only if there exists a consistent EDM association.
+ *
+ *
+ * @org.apache.olingo.odata2.DoNotImplement
+ * @see org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmAssociationView
+ *
+ */
+public interface JPAEdmNavigationPropertyView extends JPAEdmBaseView {
+ /**
+ * The method adds a navigation property view to its container.
+ *
+ * @param view
+ * is an instance of type {@link org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmNavigationPropertyView}
+ */
+ void addJPAEdmNavigationPropertyView(JPAEdmNavigationPropertyView view);
+
+ /**
+ * The method returns a consistent list of EDM navigation property. A
+ * navigation property is consistent only if all its mandatory properties
+ * can be built with no errors from Java persistence entity relationship.
+ *
+ * @return a list of consistent EDM navigation property for the Entity
+ */
+ List<NavigationProperty> getConsistentEdmNavigationProperties();
+
+ /**
+ * The method returns the navigation property that is currently being
+ * processed.
+ *
+ * @return an instance of type {@link org.apache.olingo.odata2.api.edm.provider.NavigationProperty}
+ */
+ NavigationProperty getEdmNavigationProperty();
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmPropertyView.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmPropertyView.java b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmPropertyView.java
new file mode 100644
index 0000000..742d5c8
--- /dev/null
+++ b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmPropertyView.java
@@ -0,0 +1,104 @@
+/*******************************************************************************
+ * 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.api.jpa.model;
+
+import java.util.List;
+
+import javax.persistence.metamodel.Attribute;
+
+import org.apache.olingo.odata2.api.edm.provider.Property;
+import org.apache.olingo.odata2.api.edm.provider.SimpleProperty;
+
+/**
+ * A view on Java Persistence Entity Attributes and EDM properties. Java
+ * Persistence Attributes of type
+ * <ol>
+ * <li>embedded ID - are converted into EDM keys</li>
+ * <li>ID - are converted into EDM keys</li>
+ * <li>attributes - are converted into EDM properties</li>
+ * <li>embeddable type - are converted into EDM complex properties</li>
+ * <li>relationships - are converted into Associations/Navigation properties</li>
+ * </ol>
+ * <p>
+ * The implementation of the view provides access to EDM properties for a given
+ * JPA EDM entity type. The view acts as a container for consistent list of EDM
+ * properties of an EDM entity type. EDM property is consistent only if there
+ * exists at least one property in the entity type and there is at least one key
+ * property.
+ *
+ *
+ * <p>
+ * @org.apache.olingo.odata2.DoNotImplement
+ * @see org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmKeyView
+ * @see org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmNavigationPropertyView
+ *
+ */
+public interface JPAEdmPropertyView extends JPAEdmBaseView {
+ /**
+ * The method returns a simple EDM property.
+ *
+ * @return an instance of type {@link org.apache.olingo.odata2.api.edm.provider.SimpleProperty}
+ */
+ SimpleProperty getEdmSimpleProperty();
+
+ /**
+ * The method returns a JPA EDM key view.
+ *
+ * @return an instance of type {@link org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmKeyView}
+ */
+ JPAEdmKeyView getJPAEdmKeyView();
+
+ /**
+ * The method returns a list of Properties for the given Entity Type.
+ *
+ * @return a list of {@link org.apache.olingo.odata2.api.edm.provider.Property}
+ */
+ List<Property> getEdmPropertyList();
+
+ /**
+ * The method returns a JPA Attribute for the given JPA entity type.
+ *
+ * @return an instance of type {@link javax.persistence.metamodel.Attribute
+ * <?, ?>}
+ */
+ Attribute<?, ?> getJPAAttribute();
+
+ /**
+ * The method returns a JPA EDM navigation property view.
+ *
+ * @return an instance of type {@link org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmNavigationPropertyView}
+ */
+ JPAEdmNavigationPropertyView getJPAEdmNavigationPropertyView();
+
+ /**
+ * The method returns a JPA EDM Entity Type view that holds the property
+ * view.
+ *
+ * @return an instance of type {@link org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmEntityTypeView}
+ */
+ JPAEdmEntityTypeView getJPAEdmEntityTypeView();
+
+ /**
+ * The method returns a JPA EDM Complex Type view that holds the property
+ * view.
+ *
+ * @return an instance of type {@link org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmComplexTypeView}
+ */
+ JPAEdmComplexTypeView getJPAEdmComplexTypeView();
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmReferentialConstraintRoleView.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmReferentialConstraintRoleView.java b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmReferentialConstraintRoleView.java
new file mode 100644
index 0000000..ebf945c
--- /dev/null
+++ b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmReferentialConstraintRoleView.java
@@ -0,0 +1,101 @@
+/*******************************************************************************
+ * 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.api.jpa.model;
+
+import org.apache.olingo.odata2.api.edm.provider.ReferentialConstraintRole;
+
+/**
+ * <p>
+ * A view on Java Persistence Entity Join Column's "name" and
+ * "referenced column name" attributes and Entity Data Model Referential
+ * Constraint's dependent and principal roles respectively. Each java
+ * persistence entity with properties annotated with Join Columns are
+ * transformed into Referential constraints and Referential constraint roles.
+ * </p>
+ * <p>
+ * The implementation of the view provides access to EDM referential constraint
+ * roles created from Java Persistence Entity Join Columns. The implementation
+ * acts as a container for EDM referential constraint roles. A referential
+ * constraint role is consistent only if the principal role and dependent roles
+ * can be created from JPA Entity relationships.
+ * </p>
+ *
+ *
+ * <p>
+ * @org.apache.olingo.odata2.DoNotImplement
+ * @see org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmReferentialConstraintView
+ *
+ */
+public interface JPAEdmReferentialConstraintRoleView extends JPAEdmBaseView {
+ /**
+ * Two types of EDM roles of a referential constraint.
+ */
+ public enum RoleType {
+ PRINCIPAL, DEPENDENT
+ }
+
+ /**
+ * The method returns the role type (PRINCIPAL or DEPENDENT)
+ *
+ * @return a {@link org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmReferentialConstraintRoleView.RoleType}
+ */
+ RoleType getRoleType();
+
+ /**
+ * The method returns the Referential constraint role that is currently
+ * being processed.
+ *
+ * @return an instance of type {@link org.apache.olingo.odata2.api.edm.provider.ReferentialConstraintRole}
+ */
+ ReferentialConstraintRole getEdmReferentialConstraintRole();
+
+ /**
+ * The method returns the name of JPA attribute's column name (annotated
+ * with @Column). The returned Column Name acts as the PRINCIPAL entity
+ * type.
+ *
+ * @return name of JPA Column name
+ */
+ String getJPAColumnName();
+
+ /**
+ * The method returns the EDM entity type name that holds the
+ * relationship/referential constraint. The entity type that acts as a
+ * DEPENDENT entity type.
+ *
+ * @return name of EDM entity type
+ */
+ String getEdmEntityTypeName();
+
+ /**
+ * The method returns the EDM association name.
+ *
+ * @return name of EDM association
+ */
+ String getEdmAssociationName();
+
+ /**
+ * The method tells if there exists a valid referential constraint for a
+ * given association.
+ *
+ * @return true - if valid referential constraint exits else false
+ */
+ boolean isExists();
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmReferentialConstraintView.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmReferentialConstraintView.java b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmReferentialConstraintView.java
new file mode 100644
index 0000000..4b90edb
--- /dev/null
+++ b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmReferentialConstraintView.java
@@ -0,0 +1,69 @@
+/*******************************************************************************
+ * 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.api.jpa.model;
+
+import org.apache.olingo.odata2.api.edm.provider.ReferentialConstraint;
+
+/**
+ * <p>
+ * A view on Java Persistence Entity Join Columns and Entity Data Model
+ * Referential Constraint. Each java persistence entity with properties
+ * annotated with Join Columns are transformed into Referential constraints.
+ * </p>
+ * <p>
+ * The implementation of the view provides access to EDM referential constraint
+ * created from Java Persistence Entity Join Columns. The implementation acts as
+ * a container for EDM referential constraint. A referential constraint is said
+ * to be consistent only if referential constraint role is consistent.
+ * </p>
+ *
+ * <br>
+ * @org.apache.olingo.odata2.DoNotImplement
+ * <br>
+ * @see org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmReferentialConstraintRoleView
+ *
+ */
+public interface JPAEdmReferentialConstraintView extends JPAEdmBaseView {
+
+ /**
+ * The method returns EDM referential constraint created from Java
+ * persistence Entity Join Columns.
+ *
+ * @return an instance of type {@link org.apache.olingo.odata2.api.edm.provider.ReferentialConstraint}
+ */
+ public ReferentialConstraint getEdmReferentialConstraint();
+
+ /**
+ * The method returns if a valid referential constraint exists for a given
+ * EDM association. If there exists a JPA entity relationship with join
+ * column having a valid "Name" and "ReferenceColumnName", that can be
+ * mapped to EDM properties in dependent and source EDM entities
+ * respectively then a valid EDM referential constraint exists.
+ *
+ * @return true if there exists a valid referential constraint else false.
+ */
+ public boolean isExists();
+
+ /**
+ * The method returns the name of EDM Association.
+ *
+ * @return name of an EDM association
+ */
+ public String getEdmRelationShipName();
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmSchemaView.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmSchemaView.java b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmSchemaView.java
new file mode 100644
index 0000000..d52d9a3
--- /dev/null
+++ b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmSchemaView.java
@@ -0,0 +1,116 @@
+/*******************************************************************************
+ * 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.api.jpa.model;
+
+import java.util.HashMap;
+import java.util.List;
+
+import org.apache.olingo.odata2.api.edm.provider.Schema;
+
+/**
+ * <p>
+ * A view on Java Persistence Model and Entity Data Model Schema. Each java
+ * persistence unit corresponds to a one EDM schema.
+ * </p>
+ * <p>
+ * The implementation of the view provides access to EDM schema created from
+ * Java Persistence unit. The implementation acts as a container for schema. The
+ * schema is consistent only if following elements are consistent
+ * <ol>
+ * <li>{@link org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmAssociationView}</li>
+ * <li> {@link org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmEntityContainerView}</li>
+ * <li>{@link org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmComplexTypeView}</li>
+ * </ol>
+ * </p>
+ *
+ *
+ * <p>
+ * @org.apache.olingo.odata2.DoNotImplement
+ * @see org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmAssociationView
+ * @see org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmEntityContainerView
+ * @see org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmComplexTypeView
+ *
+ */
+public interface JPAEdmSchemaView extends JPAEdmBaseView {
+ /**
+ * The method returns the EDM schema present in the container.
+ *
+ * @return an instance EDM schema of type {@link org.apache.olingo.odata2.api.edm.provider.Schema}
+ */
+ public Schema getEdmSchema();
+
+ /**
+ * The method returns JPA EDM container view. The JPA EDM container view can
+ * be used to access EDM Entity Container elements.
+ *
+ * @return an instance of type {@link org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmEntityContainerView}
+ */
+ public JPAEdmEntityContainerView getJPAEdmEntityContainerView();
+
+ /**
+ * The method returns JPA EDM complex view. The JPA EDM complex view can be
+ * used to access EDM complex types and JPA Embeddable Types.
+ *
+ * @return an instance of type {@link org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmComplexTypeView}
+ */
+ public JPAEdmComplexTypeView getJPAEdmComplexTypeView();
+
+ /**
+ * The method returns JPA EDM association view. The JPA EDM association view
+ * can be used to access EDM associations and JPA Relationships.
+ *
+ * @return an instance of type {@link org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmAssociationView}
+ */
+ public JPAEdmAssociationView getJPAEdmAssociationView();
+
+ /**
+ * The method registers custom operations that shall be represented as Edm
+ * Function Imports. Custom operations are created using Edm Annotation
+ * {@link org.apache.olingo.odata2.api.annotation.edm.FunctionImport}.
+ * <p>
+ * Custom Operations can be part of JPA Entity or can be created in a class
+ * other than JPA Entity. Such custom operations can be registered using
+ * this method.
+ * <p>
+ * The method is a callback.
+ *
+ * @param customClass
+ * is the class that contains custom operations
+ * @param methodNames
+ * is the name of the method that needs to be transformed into
+ * Function Imports. It is an optional parameter. If null is
+ * passed then all annotated methods are transformed into
+ * Function Imports.
+ *
+ */
+ public void registerOperations(Class<?> customClass, String methodNames[]);
+
+ /**
+ * The method returns an Hash Map containing the registered custom
+ * operations.
+ *
+ * @return a HashMap of Class and the methods in the class
+ */
+ public HashMap<Class<?>, String[]> getRegisteredOperations();
+
+ public List<String> getNonKeyComplexTypeList();
+
+ public void addNonKeyComplexName(String complexTypeName);
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/mapping/JPAAttributeMapType.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/mapping/JPAAttributeMapType.java b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/mapping/JPAAttributeMapType.java
new file mode 100644
index 0000000..7c9278f
--- /dev/null
+++ b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/mapping/JPAAttributeMapType.java
@@ -0,0 +1,202 @@
+/*******************************************************************************
+ * 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.api.jpa.model.mapping;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlType;
+import javax.xml.bind.annotation.XmlValue;
+
+/**
+ *
+ * The default name for EDM
+ * property is derived from JPA attribute name. This can be overriden
+ * using
+ * JPAAttributeMapType.
+ *
+ *
+ * <p>Java class for JPAAttributeMapType complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="JPAAttributeMapType">
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <sequence>
+ * <element name="JPAAttribute" maxOccurs="unbounded" minOccurs="0">
+ * <complexType>
+ * <simpleContent>
+ * <extension base="<http://www.w3.org/2001/XMLSchema>string">
+ * <attribute name="name" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
+ * <attribute name="exclude" type="{http://www.w3.org/2001/XMLSchema}boolean" default="false" />
+ * </extension>
+ * </simpleContent>
+ * </complexType>
+ * </element>
+ * </sequence>
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "JPAAttributeMapType", propOrder = { "jpaAttribute" })
+public class JPAAttributeMapType {
+
+ @XmlElement(name = "JPAAttribute")
+ protected List<JPAAttributeMapType.JPAAttribute> jpaAttribute;
+
+ /**
+ * Gets the value of the jpaAttribute property.
+ *
+ * <p>
+ * This accessor method returns a reference to the live list,
+ * not a snapshot. Therefore any modification you make to the
+ * returned list will be present inside the JAXB object.
+ * This is why there is not a <CODE>set</CODE> method for the jpaAttribute property.
+ *
+ * <p>
+ * For example, to add a new item, do as follows:
+ * <pre>
+ * getJPAAttribute().add(newItem);
+ * </pre>
+ *
+ *
+ * <p>
+ * Objects of the following type(s) are allowed in the list {@link JPAAttributeMapType.JPAAttribute }
+ *
+ *
+ */
+ public List<JPAAttributeMapType.JPAAttribute> getJPAAttribute() {
+ if (jpaAttribute == null) {
+ jpaAttribute = new ArrayList<JPAAttributeMapType.JPAAttribute>();
+ }
+ return jpaAttribute;
+ }
+
+ /**
+ * <p>Java class for anonymous complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType>
+ * <simpleContent>
+ * <extension base="<http://www.w3.org/2001/XMLSchema>string">
+ * <attribute name="name" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
+ * <attribute name="exclude" type="{http://www.w3.org/2001/XMLSchema}boolean" default="false" />
+ * </extension>
+ * </simpleContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+ @XmlAccessorType(XmlAccessType.FIELD)
+ @XmlType(name = "", propOrder = { "value" })
+ public static class JPAAttribute {
+
+ @XmlValue
+ protected String value;
+ @XmlAttribute(name = "name", required = true)
+ protected String name;
+ @XmlAttribute(name = "exclude")
+ protected Boolean exclude;
+
+ /**
+ * Gets the value of the value property.
+ *
+ * @return
+ * possible object is {@link String }
+ *
+ */
+ public String getValue() {
+ return value;
+ }
+
+ /**
+ * Sets the value of the value property.
+ *
+ * @param value
+ * allowed object is {@link String }
+ *
+ */
+ public void setValue(final String value) {
+ this.value = value;
+ }
+
+ /**
+ * Gets the value of the name property.
+ *
+ * @return
+ * possible object is {@link String }
+ *
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * Sets the value of the name property.
+ *
+ * @param value
+ * allowed object is {@link String }
+ *
+ */
+ public void setName(final String value) {
+ name = value;
+ }
+
+ /**
+ * Gets the value of the exclude property.
+ *
+ * @return
+ * possible object is {@link Boolean }
+ *
+ */
+ public boolean isExclude() {
+ if (exclude == null) {
+ return false;
+ } else {
+ return exclude;
+ }
+ }
+
+ /**
+ * Sets the value of the exclude property.
+ *
+ * @param value
+ * allowed object is {@link Boolean }
+ *
+ */
+ public void setExclude(final Boolean value) {
+ exclude = value;
+ }
+
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/mapping/JPAEdmMappingModel.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/mapping/JPAEdmMappingModel.java b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/mapping/JPAEdmMappingModel.java
new file mode 100644
index 0000000..a91f12a
--- /dev/null
+++ b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/mapping/JPAEdmMappingModel.java
@@ -0,0 +1,79 @@
+/*******************************************************************************
+ * 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.api.jpa.model.mapping;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlType;
+
+/**
+ * <p>
+ * Java class for anonymous complex type.
+ *
+ * <p>
+ * The following schema fragment specifies the expected content contained within
+ * this class.
+ *
+ * <pre>
+ * <complexType>
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <sequence>
+ * <element name="PersistenceUnit"
+ * type="{http://www.apache.org/olingo/odata2/processor/api/jpa/model/mapping}JPAPersistenceUnitMapType"/>
+ * </sequence>
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "", propOrder = { "persistenceUnit" })
+@XmlRootElement(name = "JPAEDMMappingModel")
+public class JPAEdmMappingModel {
+
+ @XmlElement(name = "PersistenceUnit", required = true)
+ protected JPAPersistenceUnitMapType persistenceUnit;
+
+ /**
+ * Gets the value of the persistenceUnit property.
+ *
+ * @return possible object is {@link JPAPersistenceUnitMapType }
+ *
+ */
+ public JPAPersistenceUnitMapType getPersistenceUnit() {
+ return persistenceUnit;
+ }
+
+ /**
+ * Sets the value of the persistenceUnit property.
+ *
+ * @param value
+ * allowed object is {@link JPAPersistenceUnitMapType }
+ *
+ */
+ public void setPersistenceUnit(final JPAPersistenceUnitMapType value) {
+ persistenceUnit = value;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/mapping/JPAEdmMappingModelFactory.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/mapping/JPAEdmMappingModelFactory.java b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/mapping/JPAEdmMappingModelFactory.java
new file mode 100644
index 0000000..f0e9787
--- /dev/null
+++ b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/mapping/JPAEdmMappingModelFactory.java
@@ -0,0 +1,85 @@
+/*******************************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ ******************************************************************************/
+package org.apache.olingo.odata2.processor.api.jpa.model.mapping;
+
+import javax.xml.bind.annotation.XmlRegistry;
+
+/**
+ * This object contains factory methods for each Java content interface and Java
+ * element interface generated in the
+ * org.apache.olingo.odata2.processor.api.jpa.model.mapping package.
+ * <p>
+ * An ObjectFactory allows you to programatically construct new instances of the
+ * Java representation for XML content. The Java representation of XML content
+ * can consist of schema derived interfaces and classes representing the binding
+ * of schema type definitions, element declarations and model groups. Factory
+ * methods for each of these are provided in this class.
+ *
+ */
+@XmlRegistry
+public class JPAEdmMappingModelFactory {
+
+ /**
+ * Create a new ObjectFactory that can be used to create new instances of
+ * schema derived classes for package:
+ * org.apache.olingo.odata2.processor.api.jpa.model.mapping
+ *
+ */
+ public JPAEdmMappingModelFactory() {}
+
+ /**
+ * Create an instance of {@link org.apache.olingo.odata2.processor.api.jpa.model.mapping.JPARelationshipMapType }
+ *
+ */
+ public JPARelationshipMapType createJPARelationshipMapType() {
+ return new JPARelationshipMapType();
+ }
+
+ /**
+ * Create an instance of {@link org.apache.olingo.odata2.processor.api.jpa.model.mapping.JPAAttributeMapType }
+ *
+ */
+ public JPAAttributeMapType createJPAAttributeMapType() {
+ return new JPAAttributeMapType();
+ }
+
+ /**
+ * Create an instance of {@link org.apache.olingo.odata2.processor.api.jpa.model.mapping.JPAEdmMappingModel }
+ *
+ */
+ public JPAEdmMappingModel createJPAEDMMappingModel() {
+ return new JPAEdmMappingModel();
+ }
+
+ /**
+ * Create an instance of {@link org.apache.olingo.odata2.processor.api.jpa.model.mapping.JPAPersistenceUnitMapType }
+ *
+ */
+ public JPAPersistenceUnitMapType createJPAPersistenceUnitMapType() {
+ return new JPAPersistenceUnitMapType();
+ }
+
+ /**
+ * Create an instance of {@link org.apache.olingo.odata2.processor.api.jpa.model.mapping.JPAEmbeddableTypeMapType }
+ *
+ */
+ public JPAEmbeddableTypeMapType createJPAEmbeddableTypeMapType() {
+ return new JPAEmbeddableTypeMapType();
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/mapping/JPAEmbeddableTypeMapType.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/mapping/JPAEmbeddableTypeMapType.java b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/mapping/JPAEmbeddableTypeMapType.java
new file mode 100644
index 0000000..f462a96
--- /dev/null
+++ b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/mapping/JPAEmbeddableTypeMapType.java
@@ -0,0 +1,161 @@
+/*******************************************************************************
+ * 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.api.jpa.model.mapping;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlType;
+
+/**
+ *
+ * The default name for EDM
+ * complex type is derived from JPA Embeddable type name. This can be
+ * overriden using JPAEmbeddableTypeMapType.
+ *
+ *
+ * <p>Java class for JPAEmbeddableTypeMapType complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="JPAEmbeddableTypeMapType">
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <sequence>
+ * <element name="EDMComplexType" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
+ * <element name="JPAAttributes"
+ * type="{http://www.apache.org/olingo/odata2/processor/api/jpa/model/mapping}JPAAttributeMapType"/>
+ * </sequence>
+ * <attribute name="name" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
+ * <attribute name="exclude" type="{http://www.w3.org/2001/XMLSchema}boolean" default="false" />
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "JPAEmbeddableTypeMapType", propOrder = { "edmComplexType", "jpaAttributes" })
+public class JPAEmbeddableTypeMapType {
+
+ @XmlElement(name = "EDMComplexType")
+ protected String edmComplexType;
+ @XmlElement(name = "JPAAttributes", required = true)
+ protected JPAAttributeMapType jpaAttributes;
+ @XmlAttribute(name = "name", required = true)
+ protected String name;
+ @XmlAttribute(name = "exclude")
+ protected Boolean exclude;
+
+ /**
+ * Gets the value of the edmComplexType property.
+ *
+ * @return
+ * possible object is {@link String }
+ *
+ */
+ public String getEDMComplexType() {
+ return edmComplexType;
+ }
+
+ /**
+ * Sets the value of the edmComplexType property.
+ *
+ * @param value
+ * allowed object is {@link String }
+ *
+ */
+ public void setEDMComplexType(final String value) {
+ edmComplexType = value;
+ }
+
+ /**
+ * Gets the value of the jpaAttributes property.
+ *
+ * @return
+ * possible object is {@link JPAAttributeMapType }
+ *
+ */
+ public JPAAttributeMapType getJPAAttributes() {
+ return jpaAttributes;
+ }
+
+ /**
+ * Sets the value of the jpaAttributes property.
+ *
+ * @param value
+ * allowed object is {@link JPAAttributeMapType }
+ *
+ */
+ public void setJPAAttributes(final JPAAttributeMapType value) {
+ jpaAttributes = value;
+ }
+
+ /**
+ * Gets the value of the name property.
+ *
+ * @return
+ * possible object is {@link String }
+ *
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * Sets the value of the name property.
+ *
+ * @param value
+ * allowed object is {@link String }
+ *
+ */
+ public void setName(final String value) {
+ name = value;
+ }
+
+ /**
+ * Gets the value of the exclude property.
+ *
+ * @return
+ * possible object is {@link Boolean }
+ *
+ */
+ public boolean isExclude() {
+ if (exclude == null) {
+ return false;
+ } else {
+ return exclude;
+ }
+ }
+
+ /**
+ * Sets the value of the exclude property.
+ *
+ * @param value
+ * allowed object is {@link Boolean }
+ *
+ */
+ public void setExclude(final Boolean value) {
+ exclude = value;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/mapping/JPAEmbeddableTypesMapType.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/mapping/JPAEmbeddableTypesMapType.java b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/mapping/JPAEmbeddableTypesMapType.java
new file mode 100644
index 0000000..131e738
--- /dev/null
+++ b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/mapping/JPAEmbeddableTypesMapType.java
@@ -0,0 +1,89 @@
+/*******************************************************************************
+ * 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.api.jpa.model.mapping;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlType;
+
+/**
+ * <p>
+ * Java class for JPAEmbeddableTypesMapType complex type.
+ *
+ * <p>
+ * The following schema fragment specifies the expected content contained within
+ * this class.
+ *
+ * <pre>
+ * <complexType name="JPAEmbeddableTypesMapType">
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <sequence>
+ * <element name="JPAEmbeddableType"
+ * type="{http://www.apache.org/olingo/odata2/processor/api/jpa/model/mapping}JPAEmbeddableTypeMapType"
+ * maxOccurs="unbounded" minOccurs="0"/>
+ * </sequence>
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "JPAEmbeddableTypesMapType", propOrder = { "jpaEmbeddableType" })
+public class JPAEmbeddableTypesMapType {
+
+ @XmlElement(name = "JPAEmbeddableType")
+ protected List<JPAEmbeddableTypeMapType> jpaEmbeddableType;
+
+ /**
+ * Gets the value of the jpaEmbeddableType property.
+ *
+ * <p>
+ * This accessor method returns a reference to the live list, not a
+ * snapshot. Therefore any modification you make to the returned list will
+ * be present inside the JAXB object. This is why there is not a
+ * <CODE>set</CODE> method for the jpaEmbeddableType property.
+ *
+ * <p>
+ * For example, to add a new item, do as follows:
+ *
+ * <pre>
+ * getJPAEmbeddableType().add(newItem);
+ * </pre>
+ *
+ *
+ * <p>
+ * Objects of the following type(s) are allowed in the list {@link JPAEmbeddableTypeMapType }
+ *
+ *
+ */
+ public List<JPAEmbeddableTypeMapType> getJPAEmbeddableType() {
+ if (jpaEmbeddableType == null) {
+ jpaEmbeddableType = new ArrayList<JPAEmbeddableTypeMapType>();
+ }
+ return jpaEmbeddableType;
+ }
+
+}
[02/37] [OLINGO-82] Renamed the project folder name to
odata2-jpa-processor
Posted by ch...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-web/src/main/resources/META-INF/LICENSE
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-web/src/main/resources/META-INF/LICENSE b/odata2-processor-jpa/jpa-web/src/main/resources/META-INF/LICENSE
deleted file mode 100644
index 325ef4a..0000000
--- a/odata2-processor-jpa/jpa-web/src/main/resources/META-INF/LICENSE
+++ /dev/null
@@ -1,1252 +0,0 @@
-
-
- Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
-
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
- 1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
- 2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
- 3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
- 4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
- 5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
- 6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
- 7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
- 8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
- 9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
- END OF TERMS AND CONDITIONS
-
- APPENDIX: How to apply the Apache License to your work.
-
- To apply the Apache License to your work, attach the following
- boilerplate notice, with the fields enclosed by brackets "[]"
- replaced with your own identifying information. (Don't include
- the brackets!) The text should be enclosed in the appropriate
- comment syntax for the file format. We also recommend that a
- file or class name and description of purpose be included on the
- same "printed page" as the copyright notice for easier
- identification within third-party archives.
-
- Copyright [yyyy] [name of copyright owner]
-
- Licensed 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.
-
-=====================================================================
- - WSDL4J (http://sf.net/projects/wsdl4j) wsdl4j:wsdl4j:jar:1.6.3
- License: CPL (http://www.opensource.org/licenses/cpl1.0.txt)
-=====================================================================
- Common Public License Version 1.0
-
- THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS
- COMMON PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR
- DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF
- THIS AGREEMENT.
-
- 1. DEFINITIONS
-
- "Contribution" means:
-
- a) in the case of the initial Contributor, the initial code and
- documentation distributed under this Agreement, and
-
- b) in the case of each subsequent Contributor:
-
- i) changes to the Program, and
-
- ii) additions to the Program;
-
- where such changes and/or additions to the Program originate from
- and are distributed by that particular Contributor. A
- Contribution 'originates' from a Contributor if it was added to
- the Program by such Contributor itself or anyone acting on such
- Contributor's behalf. Contributions do not include additions to
- the Program which: (i) are separate modules of software
- distributed in conjunction with the Program under their own
- license agreement, and (ii) are not derivative works of the
- Program.
-
- "Contributor" means any person or entity that distributes the
- Program.
-
- "Licensed Patents " mean patent claims licensable by a
- Contributor which are necessarily infringed by the use or sale of
- its Contribution alone or when combined with the Program.
-
- "Program" means the Contributions distributed in accordance with
- this Agreement.
-
- "Recipient" means anyone who receives the Program under this
- Agreement, including all Contributors.
-
- 2. GRANT OF RIGHTS
-
- a) Subject to the terms of this Agreement, each Contributor
- hereby grants Recipient a non-exclusive, worldwide, royalty-free
- copyright license to reproduce, prepare derivative works of,
- publicly display, publicly perform, distribute and sublicense the
- Contribution of such Contributor, if any, and such derivative
- works, in source code and object code form.
-
- b) Subject to the terms of this Agreement, each Contributor
- hereby grants Recipient a non-exclusive, worldwide, royalty-free
- patent license under Licensed Patents to make, use, sell, offer
- to sell, import and otherwise transfer the Contribution of such
- Contributor, if any, in source code and object code form. This
- patent license shall apply to the combination of the Contribution
- and the Program if, at the time the Contribution is added by the
- Contributor, such addition of the Contribution causes such
- combination to be covered by the Licensed Patents. The patent
- license shall not apply to any other combinations which include
- the Contribution. No hardware per se is licensed hereunder.
-
- c) Recipient understands that although each Contributor grants
- the licenses to its Contributions set forth herein, no assurances
- are provided by any Contributor that the Program does not
- infringe the patent or other intellectual property rights of any
- other entity. Each Contributor disclaims any liability to
- Recipient for claims brought by any other entity based on
- infringement of intellectual property rights or otherwise. As a
- condition to exercising the rights and licenses granted
- hereunder, each Recipient hereby assumes sole responsibility to
- secure any other intellectual property rights needed, if any. For
- example, if a third party patent license is required to allow
- Recipient to distribute the Program, it is Recipient's
- responsibility to acquire that license before distributing the
- Program.
-
- d) Each Contributor represents that to its knowledge it has
- sufficient copyright rights in its Contribution, if any, to grant
- the copyright license set forth in this Agreement.
-
- 3. REQUIREMENTS
-
- A Contributor may choose to distribute the Program in object code
- form under its own license agreement, provided that:
-
- a) it complies with the terms and conditions of this Agreement;
- and
-
- b) its license agreement:
-
- i) effectively disclaims on behalf of all Contributors all
- warranties and conditions, express and implied, including
- warranties or conditions of title and non-infringement, and
- implied warranties or conditions of merchantability and fitness
- for a particular purpose;
-
- ii) effectively excludes on behalf of all Contributors all
- liability for damages, including direct, indirect, special,
- incidental and consequential damages, such as lost profits;
-
- iii) states that any provisions which differ from this Agreement
- are offered by that Contributor alone and not by any other party;
- and
-
- iv) states that source code for the Program is available from
- such Contributor, and informs licensees how to obtain it in a
- reasonable manner on or through a medium customarily used for
- software exchange.
-
- When the Program is made available in source code form:
-
- a) it must be made available under this Agreement; and
-
- b) a copy of this Agreement must be included with each copy of
- the Program.
-
- Contributors may not remove or alter any copyright notices
- contained within the Program.
-
- Each Contributor must identify itself as the originator of its
- Contribution, if any, in a manner that reasonably allows
- subsequent Recipients to identify the originator of the
- Contribution.
-
- 4. COMMERCIAL DISTRIBUTION
-
- Commercial distributors of software may accept certain
- responsibilities with respect to end users, business partners and
- the like. While this license is intended to facilitate the
- commercial use of the Program, the Contributor who includes the
- Program in a commercial product offering should do so in a manner
- which does not create potential liability for other Contributors.
- Therefore, if a Contributor includes the Program in a commercial
- product offering, such Contributor ("Commercial Contributor")
- hereby agrees to defend and indemnify every other Contributor
- ("Indemnified Contributor") against any losses, damages and costs
- (collectively "Losses") arising from claims, lawsuits and other
- legal actions brought by a third party against the Indemnified
- Contributor to the extent caused by the acts or omissions of such
- Commercial Contributor in connection with its distribution of the
- Program in a commercial product offering. The obligations in this
- section do not apply to any claims or Losses relating to any
- actual or alleged intellectual property infringement. In order to
- qualify, an Indemnified Contributor must: a) promptly notify the
- Commercial Contributor in writing of such claim, and b) allow the
- Commercial Contributor to control, and cooperate with the
- Commercial Contributor in, the defense and any related settlement
- negotiations. The Indemnified Contributor may participate in any
- such claim at its own expense.
-
- For example, a Contributor might include the Program in a
- commercial product offering, Product X. That Contributor is then
- a Commercial Contributor. If that Commercial Contributor then
- makes performance claims, or offers warranties related to Product
- X, those performance claims and warranties are such Commercial
- Contributor's responsibility alone. Under this section, the
- Commercial Contributor would have to defend claims against the
- other Contributors related to those performance claims and
- warranties, and if a court requires any other Contributor to pay
- any damages as a result, the Commercial Contributor must pay
- those damages.
-
- 5. NO WARRANTY
-
- EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS
- PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
- ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT
- LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE,
- NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR
- PURPOSE. Each Recipient is solely responsible for determining the
- appropriateness of using and distributing the Program and assumes
- all risks associated with its exercise of rights under this
- Agreement, including but not limited to the risks and costs of
- program errors, compliance with applicable laws, damage to or
- loss of data, programs or equipment, and unavailability or
- interruption of operations.
-
- 6. DISCLAIMER OF LIABILITY
-
- EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER
- RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY
- DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST
- PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
- IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF
- THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN
- IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
-
- 7. GENERAL
-
- If any provision of this Agreement is invalid or unenforceable
- under applicable law, it shall not affect the validity or
- enforceability of the remainder of the terms of this Agreement,
- and without further action by the parties hereto, such provision
- shall be reformed to the minimum extent necessary to make such
- provision valid and enforceable.
-
- If Recipient institutes patent litigation against a Contributor
- with respect to a patent applicable to software (including a
- cross-claim or counterclaim in a lawsuit), then any patent
- licenses granted by that Contributor to such Recipient under this
- Agreement shall terminate as of the date such litigation is
- filed. In addition, if Recipient institutes patent litigation
- against any entity (including a cross-claim or counterclaim in a
- lawsuit) alleging that the Program itself (excluding combinations
- of the Program with other software or hardware) infringes such
- Recipient's patent(s), then such Recipient's rights granted under
- Section 2(b) shall terminate as of the date such litigation is
- filed.
-
- All Recipient's rights under this Agreement shall terminate if it
- fails to comply with any of the material terms or conditions of
- this Agreement and does not cure such failure in a reasonable
- period of time after becoming aware of such noncompliance. If all
- Recipient's rights under this Agreement terminate, Recipient
- agrees to cease use and distribution of the Program as soon as
- reasonably practicable. However, Recipient's obligations under
- this Agreement and any licenses granted by Recipient relating to
- the Program shall continue and survive.
-
- Everyone is permitted to copy and distribute copies of this
- Agreement, but in order to avoid inconsistency the Agreement is
- copyrighted and may only be modified in the following manner. The
- Agreement Steward reserves the right to publish new versions
- (including revisions) of this Agreement from time to time. No one
- other than the Agreement Steward has the right to modify this
- Agreement. IBM is the initial Agreement Steward. IBM may assign
- the responsibility to serve as the Agreement Steward to a
- suitable separate entity. Each new version of the Agreement will
- be given a distinguishing version number. The Program (including
- Contributions) may always be distributed subject to the version
- of the Agreement under which it was received. In addition, after
- a new version of the Agreement is published, Contributor may
- elect to distribute the Program (including its Contributions)
- under the new version. Except as expressly stated in Sections
- 2(a) and 2(b) above, Recipient receives no rights or licenses to
- the intellectual property of any Contributor under this
- Agreement, whether expressly, by implication, estoppel or
- otherwise. All rights in the Program not expressly granted under
- this Agreement are reserved.
-
- This Agreement is governed by the laws of the State of New York
- and the intellectual property laws of the United States of
- America. No party to this Agreement will bring a legal action
- under this Agreement more than one year after the cause of action
- arose. Each party waives its rights to a jury trial in any
- resulting litigation.
-
-=====================================================================
- - Stax2 API (http://woodstox.codehaus.org/StAX2)
- org.codehaus.woodstox:stax2-api:jar:3.1.1
- License: The BSD License
- (http://www.opensource.org/licenses/bsd-license.php)
-=====================================================================
- Copyright (c) 2004-2010, Woodstox Project
- (http://woodstox.codehaus.org/) All rights reserved.
-
- Redistribution and use in source and binary forms, with or
- without modification, are permitted provided that the following
- conditions are met:
-
- 1. Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer. 2.
- Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in
- the documentation and/or other materials provided with the
- distribution. 3. Neither the name of the Woodstox XML Processor
- nor the names of its contributors may be used to endorse or
- promote products derived from this software without specific
- prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
- CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
- INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
- BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- POSSIBILITY OF SUCH DAMAGE.
-
-
-=====================================================================
- - javax.ws.rs-api (http://jax-rs-spec.java.net)
- javax.ws.rs:javax.ws.rs-api:jar:2.0-m10
- - JAXB Reference Implementation (http://jaxb.java.net/)
- com.sun.xml.bind:jaxb-impl:jar:2.2.6
- License: CDDL 1.1 (https://glassfish.java.net/public/CDDL+GPL_1_1.html)
-=====================================================================
-
- COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL)Version 1.1
-
- 1. Definitions.
-
- 1.1. “Contributor” means each individual or entity that creates
- or contributes to the creation of Modifications.
-
- 1.2. “Contributor Version” means the combination of the Original
- Software, prior Modifications used by a Contributor (if any), and
- the Modifications made by that particular Contributor.
-
- 1.3. “Covered Software” means (a) the Original Software, or (b)
- Modifications, or (c) the combination of files containing
- Original Software with files containing Modifications, in each
- case including portions thereof.
-
- 1.4. “Executable” means the Covered Software in any form other
- than Source Code.
-
- 1.5. “Initial Developer” means the individual or entity that
- first makes Original Software available under this License.
-
- 1.6. “Larger Work” means a work which combines Covered Software
- or portions thereof with code not governed by the terms of this
- License.
-
- 1.7. “License” means this document.
-
- 1.8. “Licensable” means having the right to grant, to the maximum
- extent possible, whether at the time of the initial grant or
- subsequently acquired, any and all of the rights conveyed herein.
-
- 1.9. “Modifications” means the Source Code and Executable form of
- any of the following:
-
- A. Any file that results from an addition to, deletion from or
- modification of the contents of a file containing Original
- Software or previous Modifications;
-
- B. Any new file that contains any part of the Original Software
- or previous Modification; or
-
- C. Any new file that is contributed or otherwise made available
- under the terms of this License.
-
- 1.10. “Original Software” means the Source Code and Executable
- form of computer software code that is originally released under
- this License.
-
- 1.11. “Patent Claims” means any patent claim(s), now owned or
- hereafter acquired, including without limitation, method,
- process, and apparatus claims, in any patent Licensable by
- grantor.
-
- 1.12. “Source Code” means (a) the common form of computer
- software code in which modifications are made and (b) associated
- documentation included in or with such code.
-
- 1.13. “You” (or “Your”) means an individual or a legal entity
- exercising rights under, and complying with all of the terms of,
- this License. For legal entities, “You” includes any entity which
- controls, is controlled by, or is under common control with You.
- For purposes of this definition, “control” means (a) the power,
- direct or indirect, to cause the direction or management of such
- entity, whether by contract or otherwise, or (b) ownership of
- more than fifty percent (50%) of the outstanding shares or
- beneficial ownership of such entity.
-
- 2. License Grants.
-
- 2.1. The Initial Developer Grant.
-
- Conditioned upon Your compliance with Section 3.1 below and
- subject to third party intellectual property claims, the Initial
- Developer hereby grants You a world-wide, royalty-free,
- non-exclusive license:
-
- (a) under intellectual property rights (other than patent or
- trademark) Licensable by Initial Developer, to use, reproduce,
- modify, display, perform, sublicense and distribute the Original
- Software (or portions thereof), with or without Modifications,
- and/or as part of a Larger Work; and
-
- (b) under Patent Claims infringed by the making, using or selling
- of Original Software, to make, have made, use, practice, sell,
- and offer for sale, and/or otherwise dispose of the Original
- Software (or portions thereof).
-
- (c) The licenses granted in Sections 2.1(a) and (b) are effective
- on the date Initial Developer first distributes or otherwise
- makes the Original Software available to a third party under the
- terms of this License.
-
- (d) Notwithstanding Section 2.1(b) above, no patent license is
- granted: (1) for code that You delete from the Original Software,
- or (2) for infringements caused by: (i) the modification of the
- Original Software, or (ii) the combination of the Original
- Software with other software or devices.
-
- 2.2. Contributor Grant.
-
- Conditioned upon Your compliance with Section 3.1 below and
- subject to third party intellectual property claims, each
- Contributor hereby grants You a world-wide, royalty-free,
- non-exclusive license:
-
- (a) under intellectual property rights (other than patent or
- trademark) Licensable by Contributor to use, reproduce, modify,
- display, perform, sublicense and distribute the Modifications
- created by such Contributor (or portions thereof), either on an
- unmodified basis, with other Modifications, as Covered Software
- and/or as part of a Larger Work; and
-
- (b) under Patent Claims infringed by the making, using, or
- selling of Modifications made by that Contributor either alone
- and/or in combination with its Contributor Version (or portions
- of such combination), to make, use, sell, offer for sale, have
- made, and/or otherwise dispose of: (1) Modifications made by that
- Contributor (or portions thereof); and (2) the combination of
- Modifications made by that Contributor with its Contributor
- Version (or portions of such combination).
-
- (c) The licenses granted in Sections 2.2(a) and 2.2(b) are
- effective on the date Contributor first distributes or otherwise
- makes the Modifications available to a third party.
-
- (d) Notwithstanding Section 2.2(b) above, no patent license is
- granted: (1) for any code that Contributor has deleted from the
- Contributor Version; (2) for infringements caused by: (i) third
- party modifications of Contributor Version, or (ii) the
- combination of Modifications made by that Contributor with other
- software (except as part of the Contributor Version) or other
- devices; or (3) under Patent Claims infringed by Covered Software
- in the absence of Modifications made by that Contributor.
-
- 3. Distribution Obligations.
-
- 3.1. Availability of Source Code.
-
- Any Covered Software that You distribute or otherwise make
- available in Executable form must also be made available in
- Source Code form and that Source Code form must be distributed
- only under the terms of this License. You must include a copy of
- this License with every copy of the Source Code form of the
- Covered Software You distribute or otherwise make available. You
- must inform recipients of any such Covered Software in Executable
- form as to how they can obtain such Covered Software in Source
- Code form in a reasonable manner on or through a medium
- customarily used for software exchange.
-
- 3.2. Modifications.
-
- The Modifications that You create or to which You contribute are
- governed by the terms of this License. You represent that You
- believe Your Modifications are Your original creation(s) and/or
- You have sufficient rights to grant the rights conveyed by this
- License.
-
- 3.3. Required Notices.
-
- You must include a notice in each of Your Modifications that
- identifies You as the Contributor of the Modification. You may
- not remove or alter any copyright, patent or trademark notices
- contained within the Covered Software, or any notices of
- licensing or any descriptive text giving attribution to any
- Contributor or the Initial Developer.
-
- 3.4. Application of Additional Terms.
-
- You may not offer or impose any terms on any Covered Software in
- Source Code form that alters or restricts the applicable version
- of this License or the recipients' rights hereunder. You may
- choose to offer, and to charge a fee for, warranty, support,
- indemnity or liability obligations to one or more recipients of
- Covered Software. However, you may do so only on Your own behalf,
- and not on behalf of the Initial Developer or any Contributor.
- You must make it absolutely clear that any such warranty,
- support, indemnity or liability obligation is offered by You
- alone, and You hereby agree to indemnify the Initial Developer
- and every Contributor for any liability incurred by the Initial
- Developer or such Contributor as a result of warranty, support,
- indemnity or liability terms You offer.
-
- 3.5. Distribution of Executable Versions.
-
- You may distribute the Executable form of the Covered Software
- under the terms of this License or under the terms of a license
- of Your choice, which may contain terms different from this
- License, provided that You are in compliance with the terms of
- this License and that the license for the Executable form does
- not attempt to limit or alter the recipient's rights in the
- Source Code form from the rights set forth in this License. If
- You distribute the Covered Software in Executable form under a
- different license, You must make it absolutely clear that any
- terms which differ from this License are offered by You alone,
- not by the Initial Developer or Contributor. You hereby agree to
- indemnify the Initial Developer and every Contributor for any
- liability incurred by the Initial Developer or such Contributor
- as a result of any such terms You offer.
-
- 3.6. Larger Works.
-
- You may create a Larger Work by combining Covered Software with
- other code not governed by the terms of this License and
- distribute the Larger Work as a single product. In such a case,
- You must make sure the requirements of this License are fulfilled
- for the Covered Software.
-
- 4. Versions of the License.
-
- 4.1. New Versions.
-
- Oracle is the initial license steward and may publish revised
- and/or new versions of this License from time to time. Each
- version will be given a distinguishing version number. Except as
- provided in Section 4.3, no one other than the license steward
- has the right to modify this License.
-
- 4.2. Effect of New Versions.
-
- You may always continue to use, distribute or otherwise make the
- Covered Software available under the terms of the version of the
- License under which You originally received the Covered Software.
- If the Initial Developer includes a notice in the Original
- Software prohibiting it from being distributed or otherwise made
- available under any subsequent version of the License, You must
- distribute and make the Covered Software available under the
- terms of the version of the License under which You originally
- received the Covered Software. Otherwise, You may also choose to
- use, distribute or otherwise make the Covered Software available
- under the terms of any subsequent version of the License
- published by the license steward.
-
- 4.3. Modified Versions.
-
- When You are an Initial Developer and You want to create a new
- license for Your Original Software, You may create and use a
- modified version of this License if You: (a) rename the license
- and remove any references to the name of the license steward
- (except to note that the license differs from this License); and
- (b) otherwise make it clear that the license contains terms which
- differ from this License.
-
- 5. DISCLAIMER OF WARRANTY.
-
- COVERED SOFTWARE IS PROVIDED UNDER THIS LICENSE ON AN “AS IS”
- BASIS, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED,
- INCLUDING, WITHOUT LIMITATION, WARRANTIES THAT THE COVERED
- SOFTWARE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR
- PURPOSE OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND
- PERFORMANCE OF THE COVERED SOFTWARE IS WITH YOU. SHOULD ANY
- COVERED SOFTWARE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT THE
- INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF
- ANY NECESSARY SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF
- WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE. NO USE OF
- ANY COVERED SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER THIS
- DISCLAIMER.
-
- 6. TERMINATION.
-
- 6.1. This License and the rights granted hereunder will terminate
- automatically if You fail to comply with terms herein and fail to
- cure such breach within 30 days of becoming aware of the breach.
- Provisions which, by their nature, must remain in effect beyond
- the termination of this License shall survive.
-
- 6.2. If You assert a patent infringement claim (excluding
- declaratory judgment actions) against Initial Developer or a
- Contributor (the Initial Developer or Contributor against whom
- You assert such claim is referred to as “Participant”) alleging
- that the Participant Software (meaning the Contributor Version
- where the Participant is a Contributor or the Original Software
- where the Participant is the Initial Developer) directly or
- indirectly infringes any patent, then any and all rights granted
- directly or indirectly to You by such Participant, the Initial
- Developer (if the Initial Developer is not the Participant) and
- all Contributors under Sections 2.1 and/or 2.2 of this License
- shall, upon 60 days notice from Participant terminate
- prospectively and automatically at the expiration of such 60 day
- notice period, unless if within such 60 day period You withdraw
- Your claim with respect to the Participant Software against such
- Participant either unilaterally or pursuant to a written
- agreement with Participant.
-
- 6.3. If You assert a patent infringement claim against
- Participant alleging that the Participant Software directly or
- indirectly infringes any patent where such claim is resolved
- (such as by license or settlement) prior to the initiation of
- patent infringement litigation, then the reasonable value of the
- licenses granted by such Participant under Sections 2.1 or 2.2
- shall be taken into account in determining the amount or value of
- any payment or license.
-
- 6.4. In the event of termination under Sections 6.1 or 6.2 above,
- all end user licenses that have been validly granted by You or
- any distributor hereunder prior to termination (excluding
- licenses granted to You by any distributor) shall survive
- termination.
-
- 7. LIMITATION OF LIABILITY.
-
- UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, WHETHER TORT
- (INCLUDING NEGLIGENCE), CONTRACT, OR OTHERWISE, SHALL YOU, THE
- INITIAL DEVELOPER, ANY OTHER CONTRIBUTOR, OR ANY DISTRIBUTOR OF
- COVERED SOFTWARE, OR ANY SUPPLIER OF ANY OF SUCH PARTIES, BE
- LIABLE TO ANY PERSON FOR ANY INDIRECT, SPECIAL, INCIDENTAL, OR
- CONSEQUENTIAL DAMAGES OF ANY CHARACTER INCLUDING, WITHOUT
- LIMITATION, DAMAGES FOR LOSS OF GOODWILL, WORK STOPPAGE, COMPUTER
- FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER COMMERCIAL DAMAGES
- OR LOSSES, EVEN IF SUCH PARTY SHALL HAVE BEEN INFORMED OF THE
- POSSIBILITY OF SUCH DAMAGES. THIS LIMITATION OF LIABILITY SHALL
- NOT APPLY TO LIABILITY FOR DEATH OR PERSONAL INJURY RESULTING
- FROM SUCH PARTY'S NEGLIGENCE TO THE EXTENT APPLICABLE LAW
- PROHIBITS SUCH LIMITATION. SOME JURISDICTIONS DO NOT ALLOW THE
- EXCLUSION OR LIMITATION OF INCIDENTAL OR CONSEQUENTIAL DAMAGES,
- SO THIS EXCLUSION AND LIMITATION MAY NOT APPLY TO YOU.
-
- 8. U.S. GOVERNMENT END USERS.
-
- The Covered Software is a “commercial item,” as that term is
- defined in 48 C.F.R. 2.101 (Oct. 1995), consisting of “commercial
- computer software” (as that term is defined at 48 C.F.R. §
- 252.227-7014(a)(1)) and “commercial computer software
- documentation” as such terms are used in 48 C.F.R. 12.212 (Sept.
- 1995). Consistent with 48 C.F.R. 12.212 and 48 C.F.R. 227.7202-1
- through 227.7202-4 (June 1995), all U.S. Government End Users
- acquire Covered Software with only those rights set forth herein.
- This U.S. Government Rights clause is in lieu of, and supersedes,
- any other FAR, DFAR, or other clause or provision that addresses
- Government rights in computer software under this License.
-
- 9. MISCELLANEOUS.
-
- This License represents the complete agreement concerning subject
- matter hereof. If any provision of this License is held to be
- unenforceable, such provision shall be reformed only to the
- extent necessary to make it enforceable. This License shall be
- governed by the law of the jurisdiction specified in a notice
- contained within the Original Software (except to the extent
- applicable law, if any, provides otherwise), excluding such
- jurisdiction's conflict-of-law provisions. Any litigation
- relating to this License shall be subject to the jurisdiction of
- the courts located in the jurisdiction and venue specified in a
- notice contained within the Original Software, with the losing
- party responsible for costs, including, without limitation, court
- costs and reasonable attorneys' fees and expenses. The
- application of the United Nations Convention on Contracts for the
- International Sale of Goods is expressly excluded. Any law or
- regulation which provides that the language of a contract shall
- be construed against the drafter shall not apply to this License.
- You agree that You alone are responsible for compliance with the
- United States export administration regulations (and the export
- control laws and regulation of any other countries) when You use,
- distribute or otherwise make available any Covered Software.
-
- 10. RESPONSIBILITY FOR CLAIMS.
-
- As between Initial Developer and the Contributors, each party is
- responsible for claims and damages arising, directly or
- indirectly, out of its utilization of rights under this License
- and You agree to work with Initial Developer and Contributors to
- distribute such responsibility on an equitable basis. Nothing
- herein is intended or shall be deemed to constitute any admission
- of liability.
-
- NOTICE PURSUANT TO SECTION 9 OF THE COMMON DEVELOPMENT AND
- DISTRIBUTION LICENSE (CDDL)
-
- The code released under the CDDL shall be governed by the laws of
- the State of California (excluding conflict-of-law provisions).
- Any litigation relating to this License shall be subject to the
- jurisdiction of the Federal Courts of the Northern District of
- California and the state courts of the State of California, with
- venue lying in Santa Clara County, California.
-
-=====================================================================
- - SLF4J API Module (http://www.slf4j.org) org.slf4j:slf4j-api:jar:1.7.1
- - SLF4J LOG4J-12 Binding (http://www.slf4j.org) org.slf4j:slf4j-log4j12:jar:1.7.1
- License: MIT License (http://www.opensource.org/licenses/mit-license.php)
-=====================================================================
- Copyright (c) 2004-2013 QOS.ch All rights reserved.
-
- Permission is hereby granted, free of charge, to any person
- obtaining a copy of this software and associated documentation
- files (the "Software"), to deal in the Software without
- restriction, including without limitation the rights to use,
- copy, modify, merge, publish, distribute, sublicense, and/or sell
- copies of the Software, and to permit persons to whom the
- Software is furnished to do so, subject to the following
- conditions:
-
- The above copyright notice and this permission notice shall be
- included in all copies or substantial portions of the Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
- OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
- HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
- WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- OTHER DEALINGS IN THE SOFTWARE.
-
-=====================================================================
-
- - SDO API (http://www.eclipse.org/eclipselink)
- org.eclipse.persistence:commonj.sdo:jar:2.1.1
- - EclipseLink (non-OSGi) (http://www.eclipse.org/eclipselink)
- org.eclipse.persistence:eclipselink:jar:2.5.0
- - Javax Persistence (http://www.eclipse.org/eclipselink)
- org.eclipse.persistence:javax.persistence:jar:2.0.5
- License: Eclipse Public License v1.0 (http://www.eclipse.org/legal/epl-v10.html)
- License: Eclipse Distribution License v. 1.0
- (http://www.eclipse.org/org/documents/edl-v10.php)
-=====================================================================
-
- Eclipse Public License - v 1.0
-
- THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS
- ECLIPSE PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR
- DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF
- THIS AGREEMENT.
-
- 1. DEFINITIONS
-
- "Contribution" means:
-
- a) in the case of the initial Contributor, the initial code and
- documentation distributed under this Agreement, and
-
- b) in the case of each subsequent Contributor:
-
- i) changes to the Program, and
-
- ii) additions to the Program;
-
- where such changes and/or additions to the Program originate from
- and are distributed by that particular Contributor. A
- Contribution 'originates' from a Contributor if it was added to
- the Program by such Contributor itself or anyone acting on such
- Contributor's behalf. Contributions do not include additions to
- the Program which: (i) are separate modules of software
- distributed in conjunction with the Program under their own
- license agreement, and (ii) are not derivative works of the
- Program.
-
- "Contributor" means any person or entity that distributes the
- Program.
-
- "Licensed Patents" mean patent claims licensable by a Contributor
- which are necessarily infringed by the use or sale of its
- Contribution alone or when combined with the Program.
-
- "Program" means the Contributions distributed in accordance with
- this Agreement.
-
- "Recipient" means anyone who receives the Program under this
- Agreement, including all Contributors.
-
- 2. GRANT OF RIGHTS
-
- a) Subject to the terms of this Agreement, each Contributor
- hereby grants Recipient a non-exclusive, worldwide, royalty-free
- copyright license to reproduce, prepare derivative works of,
- publicly display, publicly perform, distribute and sublicense the
- Contribution of such Contributor, if any, and such derivative
- works, in source code and object code form.
-
- b) Subject to the terms of this Agreement, each Contributor
- hereby grants Recipient a non-exclusive, worldwide, royalty-free
- patent license under Licensed Patents to make, use, sell, offer
- to sell, import and otherwise transfer the Contribution of such
- Contributor, if any, in source code and object code form. This
- patent license shall apply to the combination of the Contribution
- and the Program if, at the time the Contribution is added by the
- Contributor, such addition of the Contribution causes such
- combination to be covered by the Licensed Patents. The patent
- license shall not apply to any other combinations which include
- the Contribution. No hardware per se is licensed hereunder.
-
- c) Recipient understands that although each Contributor grants
- the licenses to its Contributions set forth herein, no assurances
- are provided by any Contributor that the Program does not
- infringe the patent or other intellectual property rights of any
- other entity. Each Contributor disclaims any liability to
- Recipient for claims brought by any other entity based on
- infringement of intellectual property rights or otherwise. As a
- condition to exercising the rights and licenses granted
- hereunder, each Recipient hereby assumes sole responsibility to
- secure any other intellectual property rights needed, if any. For
- example, if a third party patent license is required to allow
- Recipient to distribute the Program, it is Recipient's
- responsibility to acquire that license before distributing the
- Program.
-
- d) Each Contributor represents that to its knowledge it has
- sufficient copyright rights in its Contribution, if any, to grant
- the copyright license set forth in this Agreement.
-
- 3. REQUIREMENTS
-
- A Contributor may choose to distribute the Program in object code
- form under its own license agreement, provided that:
-
- a) it complies with the terms and conditions of this Agreement;
- and
-
- b) its license agreement:
-
- i) effectively disclaims on behalf of all Contributors all
- warranties and conditions, express and implied, including
- warranties or conditions of title and non-infringement, and
- implied warranties or conditions of merchantability and fitness
- for a particular purpose;
-
- ii) effectively excludes on behalf of all Contributors all
- liability for damages, including direct, indirect, special,
- incidental and consequential damages, such as lost profits;
-
- iii) states that any provisions which differ from this Agreement
- are offered by that Contributor alone and not by any other party;
- and
-
- iv) states that source code for the Program is available from
- such Contributor, and informs licensees how to obtain it in a
- reasonable manner on or through a medium customarily used for
- software exchange.
-
- When the Program is made available in source code form:
-
- a) it must be made available under this Agreement; and
-
- b) a copy of this Agreement must be included with each copy of
- the Program.
-
- Contributors may not remove or alter any copyright notices
- contained within the Program.
-
- Each Contributor must identify itself as the originator of its
- Contribution, if any, in a manner that reasonably allows
- subsequent Recipients to identify the originator of the
- Contribution.
-
- 4. COMMERCIAL DISTRIBUTION
-
- Commercial distributors of software may accept certain
- responsibilities with respect to end users, business partners and
- the like. While this license is intended to facilitate the
- commercial use of the Program, the Contributor who includes the
- Program in a commercial product offering should do so in a manner
- which does not create potential liability for other Contributors.
- Therefore, if a Contributor includes the Program in a commercial
- product offering, such Contributor ("Commercial Contributor")
- hereby agrees to defend and indemnify every other Contributor
- ("Indemnified Contributor") against any losses, damages and costs
- (collectively "Losses") arising from claims, lawsuits and other
- legal actions brought by a third party against the Indemnified
- Contributor to the extent caused by the acts or omissions of such
- Commercial Contributor in connection with its distribution of the
- Program in a commercial product offering. The obligations in this
- section do not apply to any claims or Losses relating to any
- actual or alleged intellectual property infringement. In order to
- qualify, an Indemnified Contributor must: a) promptly notify the
- Commercial Contributor in writing of such claim, and b) allow the
- Commercial Contributor to control, and cooperate with the
- Commercial Contributor in, the defense and any related settlement
- negotiations. The Indemnified Contributor may participate in any
- such claim at its own expense.
-
- For example, a Contributor might include the Program in a
- commercial product offering, Product X. That Contributor is then
- a Commercial Contributor. If that Commercial Contributor then
- makes performance claims, or offers warranties related to Product
- X, those performance claims and warranties are such Commercial
- Contributor's responsibility alone. Under this section, the
- Commercial Contributor would have to defend claims against the
- other Contributors related to those performance claims and
- warranties, and if a court requires any other Contributor to pay
- any damages as a result, the Commercial Contributor must pay
- those damages.
-
- 5. NO WARRANTY
-
- EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS
- PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
- ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT
- LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE,
- NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR
- PURPOSE. Each Recipient is solely responsible for determining the
- appropriateness of using and distributing the Program and assumes
- all risks associated with its exercise of rights under this
- Agreement , including but not limited to the risks and costs of
- program errors, compliance with applicable laws, damage to or
- loss of data, programs or equipment, and unavailability or
- interruption of operations.
-
- 6. DISCLAIMER OF LIABILITY
-
- EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER
- RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY
- DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST
- PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
- IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF
- THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN
- IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
-
- 7. GENERAL
-
- If any provision of this Agreement is invalid or unenforceable
- under applicable law, it shall not affect the validity or
- enforceability of the remainder of the terms of this Agreement,
- and without further action by the parties hereto, such provision
- shall be reformed to the minimum extent necessary to make such
- provision valid and enforceable.
-
- If Recipient institutes patent litigation against any entity
- (including a cross-claim or counterclaim in a lawsuit) alleging
- that the Program itself (excluding combinations of the Program
- with other software or hardware) infringes such Recipient's
- patent(s), then such Recipient's rights granted under Section
- 2(b) shall terminate as of the date such litigation is filed.
-
- All Recipient's rights under this Agreement shall terminate if it
- fails to comply with any of the material terms or conditions of
- this Agreement and does not cure such failure in a reasonable
- period of time after becoming aware of such noncompliance. If all
- Recipient's rights under this Agreement terminate, Recipient
- agrees to cease use and distribution of the Program as soon as
- reasonably practicable. However, Recipient's obligations under
- this Agreement and any licenses granted by Recipient relating to
- the Program shall continue and survive.
-
- Everyone is permitted to copy and distribute copies of this
- Agreement, but in order to avoid inconsistency the Agreement is
- copyrighted and may only be modified in the following manner. The
- Agreement Steward reserves the right to publish new versions
- (including revisions) of this Agreement from time to time. No one
- other than the Agreement Steward has the right to modify this
- Agreement. The Eclipse Foundation is the initial Agreement
- Steward. The Eclipse Foundation may assign the responsibility to
- serve as the Agreement Steward to a suitable separate entity.
- Each new version of the Agreement will be given a distinguishing
- version number. The Program (including Contributions) may always
- be distributed subject to the version of the Agreement under
- which it was received. In addition, after a new version of the
- Agreement is published, Contributor may elect to distribute the
- Program (including its Contributions) under the new version.
- Except as expressly stated in Sections 2(a) and 2(b) above,
- Recipient receives no rights or licenses to the intellectual
- property of any Contributor under this Agreement, whether
- expressly, by implication, estoppel or otherwise. All rights in
- the Program not expressly granted under this Agreement are
- reserved.
-
- This Agreement is governed by the laws of the State of New York
- and the intellectual property laws of the United States of
- America. No party to this Agreement will bring a legal action
- under this Agreement more than one year after the cause of action
- arose. Each party waives its rights to a jury trial in any
- resulting litigation.
-
-=====================================================================
- - HSQLDB Database (http://hsqldb.org/) org.hsqldb:hsqldb:jar:1.8.0.10
- License: HSQLDB License, a BSD open source license
- (http://hsqldb.org/web/hsqlLicense.html)
-=====================================================================
- COPYRIGHTS AND LICENSES (based on BSD License)
-
- For work developed by the HSQL Development Group:
-
- Copyright (c) 2001-2010, The HSQL Development Group All rights
- reserved.
-
- Redistribution and use in source and binary forms, with or
- without modification, are permitted provided that the following
- conditions are met:
-
- Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
-
- Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in
- the documentation and/or other materials provided with the
- distribution.
-
- Neither the name of the HSQL Development Group nor the names of
- its contributors may be used to endorse or promote products
- derived from this software without specific prior written
- permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
- CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
- INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- DISCLAIMED. IN NO EVENT SHALL HSQL DEVELOPMENT GROUP, HSQLDB.ORG,
- OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- POSSIBILITY OF SUCH DAMAGE.
-
-
- For work originally developed by the Hypersonic SQL Group:
-
- Copyright (c) 1995-2000 by the Hypersonic SQL Group. All rights
- reserved.
-
- Redistribution and use in source and binary forms, with or
- without modification, are permitted provided that the following
- conditions are met:
-
- Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
-
- Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in
- the documentation and/or other materials provided with the
- distribution.
-
- Neither the name of the Hypersonic SQL Group nor the names of its
- contributors may be used to endorse or promote products derived
- from this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
- CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
- INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- DISCLAIMED. IN NO EVENT SHALL THE HYPERSONIC SQL GROUP, OR
- CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- POSSIBILITY OF SUCH DAMAGE.
-
- This software consists of voluntary contributions made by many
- individuals on behalf of the Hypersonic SQL Group.
-
-=====================================================================
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-web/src/main/resources/MaterialSQLs.properties
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-web/src/main/resources/MaterialSQLs.properties b/odata2-processor-jpa/jpa-web/src/main/resources/MaterialSQLs.properties
deleted file mode 100644
index 0faf9ce..0000000
--- a/odata2-processor-jpa/jpa-web/src/main/resources/MaterialSQLs.properties
+++ /dev/null
@@ -1,30 +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.
-#-------------------------------------------------------------------------------
-
-material_query_1 = insert into T_MATERIAL (MATERIAL_ID , MATERIAL_NAME, TYPE_CODE, PRICE, MEASUREMENT_UNIT) values(111, 'Test_Material_Name_1', 'Test_Type_Code_1', 111.1, 'Dollar');
-material_query_2 = insert into T_MATERIAL (MATERIAL_ID , MATERIAL_NAME, TYPE_CODE, PRICE, MEASUREMENT_UNIT) values(112, 'Test_Material_Name_2', 'Test_Type_Code_2', 112.1, 'Pound');
-material_query_3 = insert into T_MATERIAL (MATERIAL_ID , MATERIAL_NAME, TYPE_CODE, PRICE, MEASUREMENT_UNIT) values(113, 'Test_Material_Name_3', 'Test_Type_Code_3', 113.1, 'Yen');
-material_query_4 = insert into T_MATERIAL (MATERIAL_ID , MATERIAL_NAME, TYPE_CODE, PRICE, MEASUREMENT_UNIT) values(114, 'Test_Material_Name_4', 'Test_Type_Code_4', 114.1, 'Rupee');
-material_query_5 = insert into T_MATERIAL (MATERIAL_ID , MATERIAL_NAME, TYPE_CODE, PRICE, MEASUREMENT_UNIT) values(115, 'Test_Material_Name_5', 'Test_Type_Code_5', 115.1, 'Dollar');
-material_query_6 = insert into T_MATERIAL (MATERIAL_ID , MATERIAL_NAME, TYPE_CODE, PRICE, MEASUREMENT_UNIT) values(116, 'Test_Material_Name_6', 'Test_Type_Code_6', 116.1, 'Dollar');
-material_query_7 = insert into T_MATERIAL (MATERIAL_ID , MATERIAL_NAME, TYPE_CODE, PRICE, MEASUREMENT_UNIT) values(117, 'Test_Material_Name_7', 'Test_Type_Code_7', 117.1, 'Dollar');
-material_query_8 = insert into T_MATERIAL (MATERIAL_ID , MATERIAL_NAME, TYPE_CODE, PRICE, MEASUREMENT_UNIT) values(118, 'Test_Material_Name_8', 'Test_Type_Code_8', 118.1, 'Dollar');
-material_query_9 = insert into T_MATERIAL (MATERIAL_ID , MATERIAL_NAME, TYPE_CODE, PRICE, MEASUREMENT_UNIT) values(119, 'Test_Material_Name_9', 'Test_Type_Code_9', 119.1, 'Dollar');
-material_query_10 = insert into T_MATERIAL (MATERIAL_ID , MATERIAL_NAME, TYPE_CODE, PRICE, MEASUREMENT_UNIT) values(120, 'Test_Material_Name_10', 'Test_Type_Code_10', 120.1, 'Dollar');
-material_query_11 = insert into T_MATERIAL (MATERIAL_ID , MATERIAL_NAME, TYPE_CODE, PRICE, MEASUREMENT_UNIT) values(121, 'Test_Material_Name_11', 'Test_Type_Code_11', 121.1, 'Dollar');
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-web/src/main/resources/NoteSQLs.properties
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-web/src/main/resources/NoteSQLs.properties b/odata2-processor-jpa/jpa-web/src/main/resources/NoteSQLs.properties
deleted file mode 100644
index 347c37a..0000000
--- a/odata2-processor-jpa/jpa-web/src/main/resources/NoteSQLs.properties
+++ /dev/null
@@ -1,20 +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.
-#-------------------------------------------------------------------------------
-
-note_query_1 = insert into T_NOTE (SO_ID , text, createdBy, creationDate,creationTime) values(2, 'Test_Note_1', 'CreatedBy_1','2013-01-01 00:00:00','00:00:23');
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-web/src/main/resources/SQLInsertConfig.properties
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-web/src/main/resources/SQLInsertConfig.properties b/odata2-processor-jpa/jpa-web/src/main/resources/SQLInsertConfig.properties
deleted file mode 100644
index 915a8e8..0000000
--- a/odata2-processor-jpa/jpa-web/src/main/resources/SQLInsertConfig.properties
+++ /dev/null
@@ -1,22 +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.
-#-------------------------------------------------------------------------------
-
-#This file contains names of file which will contain the SQL statements to be executed by Data generator. Add a file name here and it will be picked up by Generator
-#You need to put the file names in order you want to get them called. First Entry will be inserted first.
-insert_file_names = SalesOrderHeaderSQLs,StoreSQLs,MaterialSQLs,SalesOrderItemSQLs,NoteSQLs
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-web/src/main/resources/SalesOrderHeaderSQLs.properties
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-web/src/main/resources/SalesOrderHeaderSQLs.properties b/odata2-processor-jpa/jpa-web/src/main/resources/SalesOrderHeaderSQLs.properties
deleted file mode 100644
index bc3e5a3..0000000
--- a/odata2-processor-jpa/jpa-web/src/main/resources/SalesOrderHeaderSQLs.properties
+++ /dev/null
@@ -1,30 +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.
-#-------------------------------------------------------------------------------
-
-query1 = insert into T_SALESORDERHEADER (SO_ID, BUYER_ID, BUYER_NAME, CURRENCY_CODE, DELIVERY_STATUS, creationDate, HOUSE_NUMBER, STREET_NAME, CITY, COUNTRY) values(20130320170725, 1, 'buyerName_1', 'INR', '01', '2012-11-01 00:01:00', 1, 'Test_Street_Name_1', 'Test_City_1', 'Test_Country_1');
-query2 = insert into T_SALESORDERHEADER (SO_ID, BUYER_ID, BUYER_NAME, CURRENCY_CODE, DELIVERY_STATUS, creationDate, HOUSE_NUMBER, STREET_NAME, CITY, COUNTRY) values(2, 2, 'buyerName_2', 'USD', '01', '2013-01-02 00:00:00', 2, 'Test_Street_Name_2', 'Test_City_2', 'Test_Country_2');
-query3 = insert into T_SALESORDERHEADER (SO_ID, BUYER_ID, BUYER_NAME, CURRENCY_CODE, DELIVERY_STATUS, creationDate, HOUSE_NUMBER, STREET_NAME, CITY, COUNTRY) values(3, 3, 'buyerName_3', 'USD', '02', '2013-01-01 14:00:00', 3, 'Test_Street_Name_3', 'Test_City_3', 'Test_Country_3');
-query4 = insert into T_SALESORDERHEADER (SO_ID, BUYER_ID, BUYER_NAME, CURRENCY_CODE, DELIVERY_STATUS, creationDate, HOUSE_NUMBER, STREET_NAME, CITY, COUNTRY) values(4, 4, 'buyerName_4', 'INR', '01', '2013-01-02 00:00:00', 4, 'Test_Street_Name_4', 'Test_City_4', 'Test_Country_4');
-query5 = insert into T_SALESORDERHEADER (SO_ID, BUYER_ID, BUYER_NAME, CURRENCY_CODE, DELIVERY_STATUS, creationDate, HOUSE_NUMBER, STREET_NAME, CITY, COUNTRY) values(5, 5, 'buyerName_5', 'INR', '02', '2013-01-01 14:14:14', 5, 'Test_Street_Name_5', 'Test_City_5', 'Test_Country_5');
-query6 = insert into T_SALESORDERHEADER (SO_ID, BUYER_ID, BUYER_NAME, CURRENCY_CODE, DELIVERY_STATUS, creationDate, HOUSE_NUMBER, STREET_NAME, CITY, COUNTRY) values(6, 6, 'buyerName_6', 'EUR', '01', '2013-01-02 00:00:00', 6, 'Test_Street_Name_6', 'Test_City_6', 'Test_Country_6');
-query7 = insert into T_SALESORDERHEADER (SO_ID, BUYER_ID, BUYER_NAME, CURRENCY_CODE, DELIVERY_STATUS, creationDate, HOUSE_NUMBER, STREET_NAME, CITY, COUNTRY) values(7, 7, 'buyerName_7', 'EUR', '02', '2013-01-01 14:14:00', 7, 'Test_Street_Name_7', 'Test_City_7', 'Test_Country_7');
-query8 = insert into T_SALESORDERHEADER (SO_ID, BUYER_ID, BUYER_NAME, CURRENCY_CODE, DELIVERY_STATUS, creationDate, HOUSE_NUMBER, STREET_NAME, CITY, COUNTRY) values(8, 8, 'buyerName_8', 'GBR', '01', '2013-01-02 00:00:00', 8, 'Test_Street_Name_8', 'Test_City_8', 'Test_Country_8');
-query9 = insert into T_SALESORDERHEADER (SO_ID, BUYER_ID, BUYER_NAME, CURRENCY_CODE, DELIVERY_STATUS, creationDate, HOUSE_NUMBER, STREET_NAME, CITY, COUNTRY) values(9, 9, 'buyerName_9', 'GBR', '02', '2013-01-01 00:00:00', 9, 'Test_Street_Name_9', 'Test_City_9', 'Test_Country_9');
-query10 = insert into T_SALESORDERHEADER (SO_ID, BUYER_ID, BUYER_NAME, CURRENCY_CODE, DELIVERY_STATUS, creationDate, HOUSE_NUMBER, STREET_NAME, CITY, COUNTRY) values(10, 10, 'buyerName_10', 'AUD', '01', '2013-01-01 00:00:00', 10, 'Test_Street_Name_10', 'Test_City_10', 'Test_Country_10');
-query11 = insert into T_SALESORDERHEADER (SO_ID, BUYER_ID, BUYER_NAME, CURRENCY_CODE, DELIVERY_STATUS, creationDate, HOUSE_NUMBER, STREET_NAME, CITY, COUNTRY) values(11, 11, 'buyerName_11', 'AUD', '02', '2013-01-02 00:00:00', 7, 'Test_Street_Name_11', 'Test_City_11', 'Test_Country_3');
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-web/src/main/resources/SalesOrderItemSQLs.properties
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-web/src/main/resources/SalesOrderItemSQLs.properties b/odata2-processor-jpa/jpa-web/src/main/resources/SalesOrderItemSQLs.properties
deleted file mode 100644
index 46c8655..0000000
--- a/odata2-processor-jpa/jpa-web/src/main/resources/SalesOrderItemSQLs.properties
+++ /dev/null
@@ -1,30 +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.
-#-------------------------------------------------------------------------------
-
-line_item_query1 = insert into T_SALESORDERITEM (Material_Id , quantity , amount , discount , Sales_Order_Id , Sales_Order_Item_Id ) values(111, 1, 1.1, 1.11, 3, 11);
-line_item_query2 = insert into T_SALESORDERITEM (Material_Id , quantity , amount , discount , Sales_Order_Id , Sales_Order_Item_Id ) values(112, 1, 1.1, 1.12, 2, 10);
-line_item_query3 = insert into T_SALESORDERITEM (Material_Id , quantity , amount , discount , Sales_Order_Id , Sales_Order_Item_Id ) values(113, 1, 1.1, 1.13, 3, 9);
-line_item_query4 = insert into T_SALESORDERITEM (Material_Id , quantity , amount , discount , Sales_Order_Id , Sales_Order_Item_Id ) values(114, 1, 1.1, 1.14, 4, 8);
-line_item_query5 = insert into T_SALESORDERITEM (Material_Id , quantity , amount , discount , Sales_Order_Id , Sales_Order_Item_Id ) values(115, 1, 1.1, 1.15, 5, 7);
-line_item_query6 = insert into T_SALESORDERITEM (Material_Id , quantity , amount , discount , Sales_Order_Id , Sales_Order_Item_Id ) values(116, 1, 1.1, 1.16, 6, 6);
-line_item_query7 = insert into T_SALESORDERITEM (Material_Id , quantity , amount , discount , Sales_Order_Id , Sales_Order_Item_Id ) values(117, 1, 1.1, 1.17, 7, 5);
-line_item_query8 = insert into T_SALESORDERITEM (Material_Id , quantity , amount , discount , Sales_Order_Id , Sales_Order_Item_Id ) values(118, 1, 1.1, 1.18, 8, 4);
-line_item_query9 = insert into T_SALESORDERITEM (Material_Id , quantity , amount , discount , Sales_Order_Id , Sales_Order_Item_Id ) values(119, 1, 1.1, 1.19, 9, 3);
-line_item_query10 = insert into T_SALESORDERITEM (Material_Id , quantity , amount , discount , Sales_Order_Id , Sales_Order_Item_Id ) values(120, 1, 1.1, 1.20, 10, 2);
-line_item_query11 = insert into T_SALESORDERITEM (Material_Id , quantity , amount , discount , Sales_Order_Id , Sales_Order_Item_Id ) values(121, 1, 1.1, 1.21, 3, 1);
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-web/src/main/resources/StoreSQLs.properties
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-web/src/main/resources/StoreSQLs.properties b/odata2-processor-jpa/jpa-web/src/main/resources/StoreSQLs.properties
deleted file mode 100644
index 69af954..0000000
--- a/odata2-processor-jpa/jpa-web/src/main/resources/StoreSQLs.properties
+++ /dev/null
@@ -1,30 +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.
-#-------------------------------------------------------------------------------
-
-store_query_1 = insert into T_STORE (STORE_ID , STORE_NAME, HOUSE_NUMBER, STREET_NAME, CITY, COUNTRY) values(131, 'Test_Store_1', 1, 'Test_Street_Name_1', 'Test_City_1', 'Test_Country_1');
-store_query_2 = insert into T_STORE (STORE_ID , STORE_NAME, HOUSE_NUMBER, STREET_NAME, CITY, COUNTRY) values(132, 'Test_Store_2', 1, 'Test_Street_Name_2', 'Test_City_2', 'Test_Country_2');
-store_query_3 = insert into T_STORE (STORE_ID , STORE_NAME, HOUSE_NUMBER, STREET_NAME, CITY, COUNTRY) values(133, 'Test_Store_3', 1, 'Test_Street_Name_3', 'Test_City_3', 'Test_Country_3');
-store_query_4 = insert into T_STORE (STORE_ID , STORE_NAME, HOUSE_NUMBER, STREET_NAME, CITY, COUNTRY) values(134, 'Test_Store_4', 1, 'Test_Street_Name_4', 'Test_City_4', 'Test_Country_4');
-store_query_5 = insert into T_STORE (STORE_ID , STORE_NAME, HOUSE_NUMBER, STREET_NAME, CITY, COUNTRY) values(135, 'Test_Store_5', 1, 'Test_Street_Name_5', 'Test_City_5', 'Test_Country_5');
-store_query_6 = insert into T_STORE (STORE_ID , STORE_NAME, HOUSE_NUMBER, STREET_NAME, CITY, COUNTRY) values(136, 'Test_Store_6', 1, 'Test_Street_Name_6', 'Test_City_6', 'Test_Country_6');
-store_query_7 = insert into T_STORE (STORE_ID , STORE_NAME, HOUSE_NUMBER, STREET_NAME, CITY, COUNTRY) values(137, 'Test_Store_7', 1, 'Test_Street_Name_7', 'Test_City_7', 'Test_Country_7');
-store_query_8 = insert into T_STORE (STORE_ID , STORE_NAME, HOUSE_NUMBER, STREET_NAME, CITY, COUNTRY) values(138, 'Test_Store_8', 1, 'Test_Street_Name_8', 'Test_City_8', 'Test_Country_8');
-store_query_9 = insert into T_STORE (STORE_ID , STORE_NAME, HOUSE_NUMBER, STREET_NAME, CITY, COUNTRY) values(139, 'Test_Store_9', 1, 'Test_Street_Name_9', 'Test_City_9', 'Test_Country_9');
-store_query_10 = insert into T_STORE (STORE_ID , STORE_NAME, HOUSE_NUMBER, STREET_NAME, CITY, COUNTRY) values(140, 'Test_Store_10', 1, 'Test_Street_Name_10', 'Test_City_10', 'Test_Country_10');
-store_query_11 = insert into T_STORE (STORE_ID , STORE_NAME, HOUSE_NUMBER, STREET_NAME, CITY, COUNTRY) values(141, 'Test_Store_11', 1, 'Test_Street_Name_11', 'Test_City_11', 'Test_Country_11');
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-web/src/main/resources/serviceConfig.properties
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-web/src/main/resources/serviceConfig.properties b/odata2-processor-jpa/jpa-web/src/main/resources/serviceConfig.properties
deleted file mode 100644
index 747277e..0000000
--- a/odata2-processor-jpa/jpa-web/src/main/resources/serviceConfig.properties
+++ /dev/null
@@ -1,19 +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.
-#-------------------------------------------------------------------------------
-showDetailError=true
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-web/src/main/webapp/SalesOrderProcessingMappingModel.xml
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-web/src/main/webapp/SalesOrderProcessingMappingModel.xml b/odata2-processor-jpa/jpa-web/src/main/webapp/SalesOrderProcessingMappingModel.xml
deleted file mode 100644
index 5e49189..0000000
--- a/odata2-processor-jpa/jpa-web/src/main/webapp/SalesOrderProcessingMappingModel.xml
+++ /dev/null
@@ -1,62 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- 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.
--->
-<JPAEDMMappingModel
- xmlns="http://www.apache.org/olingo/odata2/processor/api/jpa/model/mapping">
- <PersistenceUnit name="salesorderprocessing">
- <EDMSchemaNamespace>SalesOrderProcessing</EDMSchemaNamespace>
- <JPAEntityTypes>
- <JPAEntityType name="SalesOrderHeader">
- <EDMEntityType>SalesOrder</EDMEntityType>
- <EDMEntitySet>SalesOrders</EDMEntitySet>
- <JPAAttributes>
- <JPAAttribute name="soId">ID</JPAAttribute>
- <JPAAttribute name="netAmount">NetAmount</JPAAttribute>
- <JPAAttribute name="buyerAddress">BuyerAddressInfo</JPAAttribute>
- </JPAAttributes>
- <JPARelationships>
- <JPARelationship name="salesOrderItem">SalesOrderLineItemDetails</JPARelationship>
- <JPARelationship name="notes">NotesDetails</JPARelationship>
- </JPARelationships>
- </JPAEntityType>
- <JPAEntityType name="SalesOrderItem">
- <EDMEntityType>SalesOrderLineItem</EDMEntityType>
- <EDMEntitySet>SalesOrderLineItems</EDMEntitySet>
- <JPAAttributes>
- <JPAAttribute name="liId">ID</JPAAttribute>
- <JPAAttribute name="soId">SalesOrderID</JPAAttribute>
- </JPAAttributes>
- <JPARelationships>
- <JPARelationship name="salesOrderHeader">SalesOrderHeaderDetails</JPARelationship>
- <JPARelationship name="materials">MaterialDetails</JPARelationship>
- </JPARelationships>
- </JPAEntityType>
-
- </JPAEntityTypes>
- <JPAEmbeddableTypes>
- <JPAEmbeddableType name="Address">
- <EDMComplexType>AddressInfo</EDMComplexType>
- <JPAAttributes>
- <JPAAttribute name="houseNumber">Number</JPAAttribute>
- <JPAAttribute name="streetName">Street</JPAAttribute>
- </JPAAttributes>
- </JPAEmbeddableType>
- </JPAEmbeddableTypes>
- </PersistenceUnit>
-</JPAEDMMappingModel>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-web/src/main/webapp/WEB-INF/web.xml
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-web/src/main/webapp/WEB-INF/web.xml b/odata2-processor-jpa/jpa-web/src/main/webapp/WEB-INF/web.xml
deleted file mode 100644
index df2bba0..0000000
--- a/odata2-processor-jpa/jpa-web/src/main/webapp/WEB-INF/web.xml
+++ /dev/null
@@ -1,47 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- 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.
--->
-
-<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
- xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
- id="WebApp_ID" version="2.5">
- <display-name>OData - JPA Reference</display-name>
- <welcome-file-list>
- <welcome-file>index.jsp</welcome-file>
- </welcome-file-list>
-
- <servlet>
- <servlet-name>JPARefScenarioServlet</servlet-name>
- <servlet-class>org.apache.cxf.jaxrs.servlet.CXFNonSpringJaxrsServlet</servlet-class>
- <init-param>
- <param-name>javax.ws.rs.Application</param-name>
- <param-value>org.apache.olingo.odata2.core.rest.app.ODataApplication</param-value>
- </init-param>
- <init-param>
- <param-name>org.apache.olingo.odata2.service.factory</param-name>
- <param-value>org.apache.olingo.odata2.jpa.processor.ref.web.JPAReferenceServiceFactory</param-value>
- </init-param>
- <load-on-startup>1</load-on-startup>
- </servlet>
- <servlet-mapping>
- <servlet-name>JPARefScenarioServlet</servlet-name>
- <url-pattern>/SalesOrderProcessing.svc/*</url-pattern>
- </servlet-mapping>
-</web-app>
[28/37] [OLINGO-82] Renamed the project folder name to
odata2-jpa-processor
Posted by ch...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/ODataJPAProcessorDefaultTest.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/ODataJPAProcessorDefaultTest.java b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/ODataJPAProcessorDefaultTest.java
new file mode 100644
index 0000000..af20194
--- /dev/null
+++ b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/ODataJPAProcessorDefaultTest.java
@@ -0,0 +1,554 @@
+/*******************************************************************************
+ * 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;
+
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.nio.charset.Charset;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.EntityTransaction;
+import javax.persistence.Query;
+import javax.persistence.metamodel.EntityType;
+import javax.persistence.metamodel.Metamodel;
+
+import org.apache.olingo.odata2.api.commons.HttpContentType;
+import org.apache.olingo.odata2.api.commons.InlineCount;
+import org.apache.olingo.odata2.api.edm.EdmConcurrencyMode;
+import org.apache.olingo.odata2.api.edm.EdmEntityContainer;
+import org.apache.olingo.odata2.api.edm.EdmEntitySet;
+import org.apache.olingo.odata2.api.edm.EdmEntityType;
+import org.apache.olingo.odata2.api.edm.EdmException;
+import org.apache.olingo.odata2.api.edm.EdmFacets;
+import org.apache.olingo.odata2.api.edm.EdmMapping;
+import org.apache.olingo.odata2.api.edm.EdmProperty;
+import org.apache.olingo.odata2.api.edm.EdmType;
+import org.apache.olingo.odata2.api.edm.EdmTypeKind;
+import org.apache.olingo.odata2.api.edm.EdmTyped;
+import org.apache.olingo.odata2.api.exception.ODataException;
+import org.apache.olingo.odata2.api.processor.ODataContext;
+import org.apache.olingo.odata2.api.processor.ODataResponse;
+import org.apache.olingo.odata2.api.uri.KeyPredicate;
+import org.apache.olingo.odata2.api.uri.NavigationSegment;
+import org.apache.olingo.odata2.api.uri.PathInfo;
+import org.apache.olingo.odata2.api.uri.UriInfo;
+import org.apache.olingo.odata2.api.uri.expression.FilterExpression;
+import org.apache.olingo.odata2.api.uri.expression.OrderByExpression;
+import org.apache.olingo.odata2.api.uri.info.DeleteUriInfo;
+import org.apache.olingo.odata2.api.uri.info.GetEntityCountUriInfo;
+import org.apache.olingo.odata2.api.uri.info.GetEntitySetCountUriInfo;
+import org.apache.olingo.odata2.api.uri.info.GetEntityUriInfo;
+import org.apache.olingo.odata2.api.uri.info.PostUriInfo;
+import org.apache.olingo.odata2.api.uri.info.PutMergePatchUriInfo;
+import org.apache.olingo.odata2.processor.api.jpa.ODataJPAContext;
+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.core.jpa.common.ODataJPATestConstants;
+import org.apache.olingo.odata2.processor.core.jpa.model.JPAEdmTestModelView;
+import org.easymock.EasyMock;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+public class ODataJPAProcessorDefaultTest extends JPAEdmTestModelView {
+
+ ODataJPAProcessorDefault objODataJPAProcessorDefault;
+ ODataJPAProcessorDefaultTest objODataJPAProcessorDefaultTest;
+
+ private static final String STR_LOCAL_URI = "http://localhost:8080/org.apache.olingo.odata2.processor.ref.web/";
+ private static final String SALESORDERPROCESSING_CONTAINER = "salesorderprocessingContainer";
+ private static final String SO_ID = "SoId";
+ private static final String SALES_ORDER = "SalesOrder";
+ private static final String SALES_ORDER_HEADERS = "SalesOrderHeaders";
+ private static final String STR_CONTENT_TYPE = "Content-Type";
+
+ @Before
+ public void setUp() {
+ objODataJPAProcessorDefaultTest = new ODataJPAProcessorDefaultTest();
+ objODataJPAProcessorDefault = new ODataJPAProcessorDefault(getLocalmockODataJPAContext());
+ }
+
+ @Test
+ public void testReadEntitySetGetEntitySetUriInfoString() {
+ try {
+ GetEntityUriInfo getEntityView = getEntityUriInfo();
+ Assert.assertNotNull(objODataJPAProcessorDefault.readEntity(getEntityView, HttpContentType.APPLICATION_XML));
+ } catch (ODataJPAModelException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ } catch (ODataJPARuntimeException e1) {// Expected
+ assertTrue(true);
+ } catch (ODataException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+
+ }
+
+ @Test
+ public void testcountEntitySet() {
+ try {
+ ODataResponse countEntitySet =
+ objODataJPAProcessorDefault.countEntitySet(getEntitySetCountUriInfo(), HttpContentType.APPLICATION_XML);
+ Assert.assertNotNull(countEntitySet);
+ Object entity = countEntitySet.getEntity();
+ Assert.assertNotNull(entity);
+
+ byte[] b = new byte[2];
+ ((ByteArrayInputStream) entity).read(b);
+ Assert.assertEquals("11", new String(b, Charset.forName("utf-8")));
+ } catch (ODataException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ } catch (Exception e) {
+ assertTrue(true);
+ }
+ }
+
+ @Test
+ public void testExistsEntity() {
+ try {
+ Assert.assertNotNull(objODataJPAProcessorDefault.existsEntity(getEntityCountCountUriInfo(),
+ HttpContentType.APPLICATION_XML));
+ Assert.assertNull("ContentType MUST NOT set by entity provider", objODataJPAProcessorDefault.existsEntity(
+ getEntityCountCountUriInfo(), HttpContentType.APPLICATION_XML).getHeader(STR_CONTENT_TYPE));
+ } catch (ODataException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ } catch (Exception e) {
+ assertTrue(true);
+ }
+ }
+
+ @Test
+ public void testDeleteEntity() {
+ try {
+ Assert.assertNotNull(objODataJPAProcessorDefault.deleteEntity(getDeletetUriInfo(),
+ HttpContentType.APPLICATION_XML));
+ } catch (ODataException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+ }
+
+ @Test
+ public void testCreateEntity() {
+ try {
+ Assert.assertNotNull(objODataJPAProcessorDefault.createEntity(getPostUriInfo(), getMockedInputStreamContent(),
+ HttpContentType.APPLICATION_XML, HttpContentType.APPLICATION_XML));
+ } catch (ODataException e) {
+ Assert.assertTrue(true); // Expected TODO - need to revisit
+ }
+ }
+
+ @Test
+ public void testUpdateEntity() {
+ try {
+ Assert.assertNotNull(objODataJPAProcessorDefault.updateEntity(getPutUriInfo(), getMockedInputStreamContent(),
+ HttpContentType.APPLICATION_XML, false, HttpContentType.APPLICATION_XML));
+ } catch (ODataException e) {
+ Assert.assertTrue(true); // Expected TODO - need to revisit
+ }
+ }
+
+ private PutMergePatchUriInfo getPutUriInfo() {
+ return (PutMergePatchUriInfo) getDeletetUriInfo();
+ }
+
+ private PostUriInfo getPostUriInfo() {
+ return (PostUriInfo) getDeletetUriInfo();
+ }
+
+ private InputStream getMockedInputStreamContent() {
+ return new ByteArrayInputStream(getEntityBody().getBytes());
+ }
+
+ private String getEntityBody() {
+ return "<entry xmlns=\"http://www.w3.org/2005/Atom\" " +
+ "xmlns:m=\"http://schemas.microsoft.com/ado/2007/08/dataservices/metadata\" " +
+ "xmlns:d=\"http://schemas.microsoft.com/ado/2007/08/dataservices\" " +
+ "xml:base=\"http://localhost:8080/org.apache.olingo.odata2.processor.ref.web/SalesOrderProcessing.svc/\">"
+ + "<content type=\"application/xml\">"
+ + "<m:properties>"
+ + "<d:ID>2</d:ID>"
+ + "<d:CreationDate>2013-01-02T00:00:00</d:CreationDate>"
+ + "<d:CurrencyCode>Code_555</d:CurrencyCode>"
+ + "<d:BuyerAddressInfo m:type=\"SalesOrderProcessing.AddressInfo\">"
+ + "<d:Street>Test_Street_Name_055</d:Street>"
+ + "<d:Number>2</d:Number>"
+ + "<d:Country>Test_Country_2</d:Country>"
+ + "<d:City>Test_City_2</d:City>"
+ + "</d:BuyerAddressInfo>"
+ + "<d:GrossAmount>0.0</d:GrossAmount>"
+ + "<d:BuyerId>2</d:BuyerId>"
+ + "<d:DeliveryStatus>true</d:DeliveryStatus>"
+ + "<d:BuyerName>buyerName_2</d:BuyerName>"
+ + "<d:NetAmount>0.0</d:NetAmount>" + "</m:properties>" + "</content>" + "</entry>";
+ }
+
+ private GetEntitySetCountUriInfo getEntitySetCountUriInfo() {
+ return getLocalUriInfo();
+ }
+
+ private GetEntityCountUriInfo getEntityCountCountUriInfo() {
+ return getLocalUriInfo();
+ }
+
+ private DeleteUriInfo getDeletetUriInfo() {
+ UriInfo objUriInfo = EasyMock.createMock(UriInfo.class);
+ EasyMock.expect(objUriInfo.getStartEntitySet()).andStubReturn(getLocalEdmEntitySet());
+ EasyMock.expect(objUriInfo.getTargetEntitySet()).andStubReturn(getLocalEdmEntitySet());
+ EasyMock.expect(objUriInfo.getSelect()).andStubReturn(null);
+ EasyMock.expect(objUriInfo.getOrderBy()).andStubReturn(getOrderByExpression());
+ EasyMock.expect(objUriInfo.getTop()).andStubReturn(getTop());
+ EasyMock.expect(objUriInfo.getSkip()).andStubReturn(getSkip());
+ EasyMock.expect(objUriInfo.getInlineCount()).andStubReturn(getInlineCount());
+ EasyMock.expect(objUriInfo.getFilter()).andStubReturn(getFilter());
+ EasyMock.expect(objUriInfo.getKeyPredicates()).andStubReturn(getKeyPredicates());
+ EasyMock.replay(objUriInfo);
+ return objUriInfo;
+ }
+
+ private List<KeyPredicate> getKeyPredicates() {
+ List<KeyPredicate> keyPredicates = new ArrayList<KeyPredicate>();
+ return keyPredicates;
+ }
+
+ /**
+ * @return
+ */
+ private UriInfo getLocalUriInfo() {
+ UriInfo objUriInfo = EasyMock.createMock(UriInfo.class);
+ EasyMock.expect(objUriInfo.getStartEntitySet()).andStubReturn(getLocalEdmEntitySet());
+ EasyMock.expect(objUriInfo.getTargetEntitySet()).andStubReturn(getLocalEdmEntitySet());
+ EasyMock.expect(objUriInfo.getSelect()).andStubReturn(null);
+ EasyMock.expect(objUriInfo.getOrderBy()).andStubReturn(getOrderByExpression());
+ EasyMock.expect(objUriInfo.getTop()).andStubReturn(getTop());
+ EasyMock.expect(objUriInfo.getSkip()).andStubReturn(getSkip());
+ EasyMock.expect(objUriInfo.getInlineCount()).andStubReturn(getInlineCount());
+ EasyMock.expect(objUriInfo.getFilter()).andStubReturn(getFilter());
+ EasyMock.expect(objUriInfo.getFunctionImport()).andStubReturn(null);
+ EasyMock.replay(objUriInfo);
+ return objUriInfo;
+ }
+
+ /**
+ * @return
+ * @throws EdmException
+ */
+ private EdmEntitySet getLocalEdmEntitySet() {
+ EdmEntitySet edmEntitySet = EasyMock.createMock(EdmEntitySet.class);
+ try {
+ EasyMock.expect(edmEntitySet.getName()).andStubReturn(SALES_ORDER_HEADERS);
+ EasyMock.expect(edmEntitySet.getEntityContainer()).andStubReturn(getLocalEdmEntityContainer());
+ EasyMock.expect(edmEntitySet.getEntityType()).andStubReturn(getLocalEdmEntityType());
+ EasyMock.replay(edmEntitySet);
+ } catch (EdmException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+ return edmEntitySet;
+ }
+
+ /**
+ * @return
+ * @throws EdmException
+ */
+ private EdmEntityType getLocalEdmEntityType() {
+ EdmEntityType edmEntityType = EasyMock.createMock(EdmEntityType.class);
+ try {
+ EasyMock.expect(edmEntityType.getKeyProperties()).andStubReturn(new ArrayList<EdmProperty>());
+ EasyMock.expect(edmEntityType.getPropertyNames()).andStubReturn(getLocalPropertyNames());
+ EasyMock.expect(edmEntityType.getProperty(SO_ID)).andStubReturn(getEdmTypedMockedObj(SALES_ORDER));
+ EasyMock.expect(edmEntityType.getKind()).andStubReturn(EdmTypeKind.SIMPLE);
+ EasyMock.expect(edmEntityType.getNamespace()).andStubReturn(SALES_ORDER_HEADERS);
+ EasyMock.expect(edmEntityType.getName()).andStubReturn(SALES_ORDER_HEADERS);
+ EasyMock.expect(edmEntityType.hasStream()).andStubReturn(false);
+ EasyMock.expect(edmEntityType.getNavigationPropertyNames()).andStubReturn(new ArrayList<String>());
+ EasyMock.expect(edmEntityType.getKeyPropertyNames()).andStubReturn(new ArrayList<String>());
+ EasyMock.expect(edmEntityType.getMapping()).andStubReturn(getEdmMappingMockedObj(SALES_ORDER));// ID vs Salesorder
+ // ID
+ EasyMock.replay(edmEntityType);
+ } catch (EdmException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+ return edmEntityType;
+ }
+
+ private InlineCount getInlineCount() {
+ return InlineCount.NONE;
+ }
+
+ private FilterExpression getFilter() {
+ return null;
+ }
+
+ private Integer getSkip() {
+ return null;
+ }
+
+ private Integer getTop() {
+ return null;
+ }
+
+ private OrderByExpression getOrderByExpression() {
+ return null;
+ }
+
+ private ODataJPAContext getLocalmockODataJPAContext() {
+ ODataJPAContext odataJPAContext = EasyMock.createMock(ODataJPAContext.class);
+ EasyMock.expect(odataJPAContext.getPersistenceUnitName()).andStubReturn("salesorderprocessing");
+ EasyMock.expect(odataJPAContext.getEntityManagerFactory()).andStubReturn(mockEntityManagerFactory());
+ EasyMock.expect(odataJPAContext.getODataContext()).andStubReturn(getLocalODataContext());
+ EasyMock.expect(odataJPAContext.getEntityManager()).andStubReturn(getLocalEntityManager());
+ EasyMock.replay(odataJPAContext);
+ return odataJPAContext;
+ }
+
+ private EntityManagerFactory mockEntityManagerFactory() {
+ EntityManagerFactory emf = EasyMock.createMock(EntityManagerFactory.class);
+ EasyMock.expect(emf.getMetamodel()).andStubReturn(mockMetaModel());
+ EasyMock.expect(emf.createEntityManager()).andStubReturn(getLocalEntityManager());
+ EasyMock.replay(emf);
+ return emf;
+ }
+
+ private EntityManagerFactory mockEntityManagerFactory2() {// For create, to avoid stackoverflow
+ EntityManagerFactory emf = EasyMock.createMock(EntityManagerFactory.class);
+ EasyMock.expect(emf.getMetamodel()).andStubReturn(mockMetaModel());
+ EasyMock.replay(emf);
+ return emf;
+ }
+
+ private EntityManager getLocalEntityManager() {
+ EntityManager em = EasyMock.createMock(EntityManager.class);
+ EasyMock.expect(em.createQuery("SELECT E1 FROM SalesOrderHeaders E1")).andStubReturn(getQuery());
+ EasyMock.expect(em.createQuery("SELECT COUNT ( E1 ) FROM SalesOrderHeaders E1")).andStubReturn(
+ getQueryForSelectCount());
+ EasyMock.expect(em.getEntityManagerFactory()).andStubReturn(mockEntityManagerFactory2());// For create
+ EasyMock.expect(em.getTransaction()).andStubReturn(getLocalTransaction()); // For Delete
+ Address obj = new Address();
+ em.remove(obj);// testing void method
+ em.flush();
+ EasyMock.replay(em);
+ return em;
+ }
+
+ private EntityTransaction getLocalTransaction() {
+ EntityTransaction entityTransaction = EasyMock.createMock(EntityTransaction.class);
+ entityTransaction.begin(); // testing void method
+ entityTransaction.commit();// testing void method
+ entityTransaction.rollback();// testing void method
+ EasyMock.replay(entityTransaction);
+ return entityTransaction;
+ }
+
+ private Query getQuery() {
+ Query query = EasyMock.createMock(Query.class);
+ EasyMock.expect(query.getResultList()).andStubReturn(getResultList());
+ EasyMock.replay(query);
+ return query;
+ }
+
+ private Query getQueryForSelectCount() {
+ Query query = EasyMock.createMock(Query.class);
+ EasyMock.expect(query.getResultList()).andStubReturn(getResultListForSelectCount());
+ EasyMock.replay(query);
+ return query;
+ }
+
+ private List<?> getResultList() {
+ List<Object> list = new ArrayList<Object>();
+ list.add(new Address());
+ return list;
+ }
+
+ private List<?> getResultListForSelectCount() {
+ List<Object> list = new ArrayList<Object>();
+ list.add(new Long(11));
+ return list;
+ }
+
+ class Address {
+ private String soId = "12";
+
+ public String getSoId() {
+ return soId;
+ }
+
+ @Override
+ public boolean equals(final Object obj) {
+ boolean isEqual = false;
+ if (obj instanceof Address) {
+ isEqual = getSoId().equalsIgnoreCase(((Address) obj).getSoId());//
+ }
+ return isEqual;
+ }
+ }
+
+ private Metamodel mockMetaModel() {
+ Metamodel metaModel = EasyMock.createMock(Metamodel.class);
+ EasyMock.expect(metaModel.getEntities()).andStubReturn(getLocalEntities());
+ EasyMock.replay(metaModel);
+ return metaModel;
+ }
+
+ private Set<EntityType<?>> getLocalEntities() {
+ Set<EntityType<?>> entityTypeSet = new HashSet<EntityType<?>>();
+ entityTypeSet.add(getLocalJPAEntityType());
+ return entityTypeSet;
+ }
+
+ @SuppressWarnings("rawtypes")
+ private EntityType<EntityType> getLocalJPAEntityType() {
+ @SuppressWarnings("unchecked")
+ EntityType<EntityType> entityType = EasyMock.createMock(EntityType.class);
+ EasyMock.expect(entityType.getJavaType()).andStubReturn(EntityType.class);
+ EasyMock.replay(entityType);
+ return entityType;
+ }
+
+ private GetEntityUriInfo getEntityUriInfo() {
+ GetEntityUriInfo getEntityView = EasyMock.createMock(GetEntityUriInfo.class);
+ EdmEntitySet edmEntitySet = EasyMock.createMock(EdmEntitySet.class);
+ EdmEntityType edmEntityType = EasyMock.createMock(EdmEntityType.class);
+ try {
+ EasyMock.expect(getEntityView.getExpand()).andStubReturn(null);
+ EasyMock.expect(edmEntityType.getKeyProperties()).andStubReturn(new ArrayList<EdmProperty>());
+ EasyMock.expect(edmEntitySet.getEntityType()).andStubReturn(edmEntityType);
+ EasyMock.expect(edmEntitySet.getName()).andStubReturn(SALES_ORDER_HEADERS);
+
+ EasyMock.expect(getEntityView.getSelect()).andStubReturn(null);
+ EasyMock.expect(getEntityView.getTargetEntitySet()).andStubReturn(edmEntitySet);
+ EasyMock.expect(edmEntityType.getPropertyNames()).andStubReturn(getLocalPropertyNames());
+ EasyMock.expect(edmEntityType.getProperty(SO_ID)).andStubReturn(getEdmTypedMockedObj(SO_ID));
+
+ EasyMock.expect(edmEntityType.getMapping()).andStubReturn(getEdmMappingMockedObj(SALES_ORDER));
+
+ EasyMock.expect(edmEntityType.getKind()).andStubReturn(EdmTypeKind.SIMPLE);
+ EasyMock.expect(edmEntityType.getNamespace()).andStubReturn(SALES_ORDER_HEADERS);
+ EasyMock.expect(edmEntityType.getName()).andStubReturn(SALES_ORDER_HEADERS);
+ EasyMock.expect(edmEntityType.hasStream()).andStubReturn(false);
+ EasyMock.expect(edmEntityType.getNavigationPropertyNames()).andStubReturn(new ArrayList<String>());
+ EasyMock.expect(edmEntityType.getKeyPropertyNames()).andStubReturn(new ArrayList<String>());
+
+ EasyMock.expect(edmEntitySet.getEntityContainer()).andStubReturn(getLocalEdmEntityContainer());
+
+ EasyMock.replay(edmEntityType, edmEntitySet);
+ EasyMock.expect(getEntityView.getKeyPredicates()).andStubReturn(new ArrayList<KeyPredicate>());
+ List<NavigationSegment> navigationSegments = new ArrayList<NavigationSegment>();
+ EasyMock.expect(getEntityView.getNavigationSegments()).andReturn(navigationSegments);
+ EasyMock.expect(getEntityView.getStartEntitySet()).andReturn(edmEntitySet);
+
+ EasyMock.replay(getEntityView);
+ } catch (EdmException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+ return getEntityView;
+ }
+
+ private EdmEntityContainer getLocalEdmEntityContainer() {
+ EdmEntityContainer edmEntityContainer = EasyMock.createMock(EdmEntityContainer.class);
+ EasyMock.expect(edmEntityContainer.isDefaultEntityContainer()).andStubReturn(true);
+ try {
+ EasyMock.expect(edmEntityContainer.getName()).andStubReturn(SALESORDERPROCESSING_CONTAINER);
+ } catch (EdmException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+
+ EasyMock.replay(edmEntityContainer);
+ return edmEntityContainer;
+ }
+
+ private EdmTyped getEdmTypedMockedObj(final String propertyName) {
+ EdmProperty mockedEdmProperty = EasyMock.createMock(EdmProperty.class);
+ try {
+ EasyMock.expect(mockedEdmProperty.getMapping()).andStubReturn(getEdmMappingMockedObj(propertyName));
+ EdmType edmType = EasyMock.createMock(EdmType.class);
+ EasyMock.expect(edmType.getKind()).andStubReturn(EdmTypeKind.SIMPLE);
+ EasyMock.replay(edmType);
+ EasyMock.expect(mockedEdmProperty.getName()).andStubReturn("identifier");
+ EasyMock.expect(mockedEdmProperty.getType()).andStubReturn(edmType);
+ EasyMock.expect(mockedEdmProperty.getFacets()).andStubReturn(getEdmFacetsMockedObj());
+
+ EasyMock.replay(mockedEdmProperty);
+ } catch (EdmException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+ return mockedEdmProperty;
+ }
+
+ private EdmFacets getEdmFacetsMockedObj() {
+ EdmFacets facets = EasyMock.createMock(EdmFacets.class);
+ EasyMock.expect(facets.getConcurrencyMode()).andStubReturn(EdmConcurrencyMode.Fixed);
+
+ EasyMock.replay(facets);
+ return facets;
+ }
+
+ private EdmMapping getEdmMappingMockedObj(final String propertyName) {
+ EdmMapping mockedEdmMapping = EasyMock.createMock(EdmMapping.class);
+ if (propertyName.equalsIgnoreCase(SALES_ORDER)) {
+ EasyMock.expect(mockedEdmMapping.getInternalName()).andStubReturn(SALES_ORDER_HEADERS);
+ } else {
+ EasyMock.expect(mockedEdmMapping.getInternalName()).andStubReturn(propertyName);
+ }
+ EasyMock.replay(mockedEdmMapping);
+ return mockedEdmMapping;
+ }
+
+ private List<String> getLocalPropertyNames() {
+ List<String> list = new ArrayList<String>();
+ list.add(SO_ID);
+ return list;
+ }
+
+ private ODataContext getLocalODataContext() {
+ ODataContext objODataContext = EasyMock.createMock(ODataContext.class);
+ try {
+ EasyMock.expect(objODataContext.getPathInfo()).andStubReturn(getLocalPathInfo());
+ } catch (ODataException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+ EasyMock.replay(objODataContext);
+ return objODataContext;
+ }
+
+ private PathInfo getLocalPathInfo() {
+ PathInfo pathInfo = EasyMock.createMock(PathInfo.class);
+ EasyMock.expect(pathInfo.getServiceRoot()).andStubReturn(getLocalURI());
+ EasyMock.replay(pathInfo);
+ return pathInfo;
+ }
+
+ private URI getLocalURI() {
+ URI uri = null;
+ try {
+ uri = new URI(STR_LOCAL_URI);
+ } catch (URISyntaxException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+ return uri;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/ODataJPAResponseBuilderTest.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/ODataJPAResponseBuilderTest.java b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/ODataJPAResponseBuilderTest.java
new file mode 100644
index 0000000..426f236
--- /dev/null
+++ b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/ODataJPAResponseBuilderTest.java
@@ -0,0 +1,566 @@
+/*******************************************************************************
+ * 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;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.olingo.odata2.api.commons.InlineCount;
+import org.apache.olingo.odata2.api.edm.EdmEntityContainer;
+import org.apache.olingo.odata2.api.edm.EdmEntitySet;
+import org.apache.olingo.odata2.api.edm.EdmEntityType;
+import org.apache.olingo.odata2.api.edm.EdmException;
+import org.apache.olingo.odata2.api.edm.EdmLiteralKind;
+import org.apache.olingo.odata2.api.edm.EdmMapping;
+import org.apache.olingo.odata2.api.edm.EdmNavigationProperty;
+import org.apache.olingo.odata2.api.edm.EdmProperty;
+import org.apache.olingo.odata2.api.edm.EdmSimpleType;
+import org.apache.olingo.odata2.api.edm.EdmSimpleTypeException;
+import org.apache.olingo.odata2.api.edm.EdmType;
+import org.apache.olingo.odata2.api.edm.EdmTypeKind;
+import org.apache.olingo.odata2.api.edm.provider.EntityType;
+import org.apache.olingo.odata2.api.edm.provider.Facets;
+import org.apache.olingo.odata2.api.ep.EntityProviderWriteProperties;
+import org.apache.olingo.odata2.api.exception.ODataException;
+import org.apache.olingo.odata2.api.exception.ODataNotFoundException;
+import org.apache.olingo.odata2.api.processor.ODataContext;
+import org.apache.olingo.odata2.api.processor.ODataResponse;
+import org.apache.olingo.odata2.api.uri.NavigationPropertySegment;
+import org.apache.olingo.odata2.api.uri.PathInfo;
+import org.apache.olingo.odata2.api.uri.SelectItem;
+import org.apache.olingo.odata2.api.uri.info.GetEntitySetUriInfo;
+import org.apache.olingo.odata2.api.uri.info.GetEntityUriInfo;
+import org.apache.olingo.odata2.processor.api.jpa.ODataJPAContext;
+import org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPARuntimeException;
+import org.apache.olingo.odata2.processor.core.jpa.common.ODataJPATestConstants;
+import org.apache.olingo.odata2.processor.core.jpa.model.JPAEdmTestModelView;
+import org.easymock.EasyMock;
+import org.junit.Test;
+
+public class ODataJPAResponseBuilderTest extends JPAEdmTestModelView {
+
+ /*
+ * This Unit is supposed to test the building of Entity Provider Properties for query with $expand
+ */
+ @Test
+ public void testGetEntityProviderPropertiesQuery() {
+ GetEntitySetUriInfo getEntitySetUriInfo = mockEntitySetUriInfoForExpand();
+ ODataJPAContext oDataJPAContext = getODataJPAContext();
+ // Building the edm entity
+ List<Map<String, Object>> edmEntityList = new ArrayList<Map<String, Object>>();
+ Map<String, Object> edmEntity = new HashMap<String, Object>();
+ edmEntity.put("ID", 1);
+ edmEntityList.add(edmEntity);
+ // Invoking the private static method using reflection
+ Class<?> clazz = ODataJPAResponseBuilder.class;
+ Object[] actualParameters = { oDataJPAContext, getEntitySetUriInfo, edmEntityList };
+ Class<?>[] formalParameters = { ODataJPAContext.class, GetEntitySetUriInfo.class, List.class };
+ EntityProviderWriteProperties providerProperties = null;
+ try {
+ ODataJPAResponseBuilder responseBuilder = (ODataJPAResponseBuilder) clazz.newInstance();
+ Method method = clazz.getDeclaredMethod("getEntityProviderProperties", formalParameters);
+ method.setAccessible(true);
+ providerProperties = (EntityProviderWriteProperties) method.invoke(responseBuilder, actualParameters);
+ assertEquals(1, providerProperties.getExpandSelectTree().getLinks().size());
+ } catch (SecurityException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ } catch (NoSuchMethodException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ } catch (IllegalArgumentException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ } catch (IllegalAccessException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ } catch (InvocationTargetException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ } catch (InstantiationException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+ }
+
+ /*
+ * This Unit is supposed to test the building of Entity Provider Properties for read with $expand
+ */
+ @Test
+ public void testGetEntityProviderPropertiesRead() {
+
+ // Getting the EntityUriInfo
+ GetEntityUriInfo getEntityUriInfo = mockEntityUriInfoForExpand();
+ ODataJPAContext oDataJPAContext = getODataJPAContext();
+ Class<?> clazz = ODataJPAResponseBuilder.class;
+ Object[] actualParameters = { oDataJPAContext, getEntityUriInfo };
+ Class<?>[] formalParameters = { ODataJPAContext.class, GetEntityUriInfo.class };
+ EntityProviderWriteProperties providerProperties = null;
+ try {
+ ODataJPAResponseBuilder responseBuilder = (ODataJPAResponseBuilder) clazz.newInstance();
+ Method method = clazz.getDeclaredMethod("getEntityProviderProperties", formalParameters);
+ method.setAccessible(true);
+ providerProperties = (EntityProviderWriteProperties) method.invoke(responseBuilder, actualParameters);
+ assertEquals(1, providerProperties.getExpandSelectTree().getLinks().size());
+ } catch (SecurityException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ } catch (NoSuchMethodException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ } catch (IllegalArgumentException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ } catch (IllegalAccessException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ } catch (InvocationTargetException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ } catch (InstantiationException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+
+ }
+
+ @SuppressWarnings("unchecked")
+ @Test
+ public void testConstructListofNavProperty() {
+ List<ArrayList<NavigationPropertySegment>> expand = new ArrayList<ArrayList<NavigationPropertySegment>>();
+ ArrayList<NavigationPropertySegment> navPropList1 = new ArrayList<NavigationPropertySegment>();
+ navPropList1.add(getNavigationPropertySegment("DemoNavigationProperties11"));
+ navPropList1.add(getNavigationPropertySegment("DemoNavigationProperties12"));
+ expand.add(navPropList1);
+ ArrayList<NavigationPropertySegment> navPropList2 = new ArrayList<NavigationPropertySegment>();
+ navPropList2.add(getNavigationPropertySegment("DemoNavigationProperties21"));
+ navPropList2.add(getNavigationPropertySegment("DemoNavigationProperties22"));
+ expand.add(navPropList2);
+ Class<?> clazz = ODataJPAResponseBuilder.class;
+ Object[] actualParameters = { expand };
+ Class<?>[] formalParameters = { List.class };
+ List<EdmNavigationProperty> navigationProperties = null;
+ try {
+ ODataJPAResponseBuilder responseBuilder = (ODataJPAResponseBuilder) clazz.newInstance();
+ Method method = clazz.getDeclaredMethod("constructListofNavProperty", formalParameters);
+ method.setAccessible(true);
+ navigationProperties = (List<EdmNavigationProperty>) method.invoke(responseBuilder, actualParameters);
+ assertEquals("DemoNavigationProperties21", navigationProperties.get(1).getName());
+ assertEquals("DemoNavigationProperties11", navigationProperties.get(0).getName());
+ } catch (SecurityException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ } catch (NoSuchMethodException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ } catch (IllegalArgumentException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ } catch (IllegalAccessException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ } catch (InvocationTargetException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ } catch (InstantiationException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ } catch (EdmException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+
+ }
+
+ @Test
+ public void testBuildListOfTGetEntitySetUriInfoStringODataJPAContext() {
+ try {
+ assertNotNull(ODataJPAResponseBuilder.build(getJPAEntities(), getResultsView(), "application/xml",
+ getODataJPAContext()));
+ } catch (ODataJPARuntimeException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+
+ }
+
+ @Test
+ public void testBuildNegatives() {// Bad content type
+ try {
+ EntityType entity = new EntityType();
+ entity.setName("SalesOrderHeader");
+ try {
+ assertNotNull(ODataJPAResponseBuilder.build(getEntity(), getLocalGetURIInfo(), "xml", getODataJPAContext()));
+ } catch (ODataNotFoundException e) {
+ assertTrue(true);
+ }
+ } catch (ODataJPARuntimeException e) {
+ assertTrue(true);// Nothing to do, Expected.
+ }
+ try {// Bad content type
+ assertNotNull(ODataJPAResponseBuilder.build(getJPAEntities(), getResultsView(), "xml", getODataJPAContext()));
+ } catch (ODataJPARuntimeException e) {
+ assertTrue(true);// Nothing to do, Expected.
+ }
+
+ }
+
+ @Test
+ public void testBuildObjectGetEntityUriInfoStringODataJPAContext() throws ODataNotFoundException {
+ try {
+ assertNotNull(ODataJPAResponseBuilder.build(new SalesOrderHeader(2, 10), getLocalGetURIInfo(), "application/xml",
+ getODataJPAContext()));
+ } catch (ODataJPARuntimeException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+ }
+
+ @Test
+ public void testBuildNullSelects() {// Bad content type
+ try {
+ ODataJPAResponseBuilder.build(getJPAEntities(), getResultsViewWithNullSelects(), "xml", getODataJPAContext());
+ } catch (ODataJPARuntimeException e) {
+ assertTrue(true);// Nothing to do, Expected.
+ } catch (Exception e) {
+ assertTrue(true);
+ }
+ }
+
+ @Test
+ public void testBuildGetCount() {
+ ODataResponse objODataResponse = null;
+ try {
+ objODataResponse = ODataJPAResponseBuilder.build(1, getODataJPAContext());
+ } catch (ODataJPARuntimeException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+ assertNotNull(objODataResponse);
+ }
+
+ private ODataJPAContext getODataJPAContext() {
+ ODataJPAContext objODataJPAContext = EasyMock.createMock(ODataJPAContext.class);
+ EasyMock.expect(objODataJPAContext.getODataContext()).andStubReturn(getLocalODataContext());
+ EasyMock.replay(objODataJPAContext);
+ return objODataJPAContext;
+ }
+
+ private ODataContext getLocalODataContext() {
+ ODataContext objODataContext = EasyMock.createMock(ODataContext.class);
+ try {
+ EasyMock.expect(objODataContext.getPathInfo()).andStubReturn(getLocalPathInfo());
+ } catch (ODataException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+ EasyMock.replay(objODataContext);
+ return objODataContext;
+ }
+
+ private PathInfo getLocalPathInfo() {
+ PathInfo pathInfo = EasyMock.createMock(PathInfo.class);
+ EasyMock.expect(pathInfo.getServiceRoot()).andStubReturn(getLocalURI());
+ EasyMock.replay(pathInfo);
+ return pathInfo;
+ }
+
+ private URI getLocalURI() {
+ URI uri = null;
+ try {
+ uri = new URI("http://localhost:8080/org.apache.olingo.odata2.processor.ref.web/");
+ } catch (URISyntaxException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+ return uri;
+ }
+
+ private GetEntitySetUriInfo getResultsView() {
+ GetEntitySetUriInfo objGetEntitySetUriInfo = EasyMock.createMock(GetEntitySetUriInfo.class);
+ EasyMock.expect(objGetEntitySetUriInfo.getInlineCount()).andStubReturn(getLocalInlineCount());
+ EasyMock.expect(objGetEntitySetUriInfo.getTargetEntitySet()).andStubReturn(getLocalTargetEntitySet());
+ EasyMock.expect(objGetEntitySetUriInfo.getSelect()).andStubReturn(getSelectItemList());
+ EasyMock.expect(objGetEntitySetUriInfo.getExpand()).andStubReturn(getExpandList());
+ EasyMock.expect(objGetEntitySetUriInfo.getSkip()).andStubReturn(new Integer(1));
+ EasyMock.replay(objGetEntitySetUriInfo);
+ return objGetEntitySetUriInfo;
+ }
+
+ private List<ArrayList<NavigationPropertySegment>> getExpandList() {
+ List<ArrayList<NavigationPropertySegment>> expandList = new ArrayList<ArrayList<NavigationPropertySegment>>();
+ return expandList;
+ }
+
+ private GetEntitySetUriInfo getResultsViewWithNullSelects() {
+ GetEntitySetUriInfo objGetEntitySetUriInfo = EasyMock.createMock(GetEntitySetUriInfo.class);
+ EasyMock.expect(objGetEntitySetUriInfo.getInlineCount()).andStubReturn(getLocalInlineCount());
+ EasyMock.expect(objGetEntitySetUriInfo.getTargetEntitySet()).andStubReturn(getLocalTargetEntitySet());
+ EasyMock.expect(objGetEntitySetUriInfo.getSelect()).andStubReturn(null);
+ EasyMock.expect(objGetEntitySetUriInfo.getExpand()).andStubReturn(null);
+ EasyMock.expect(objGetEntitySetUriInfo.getSkip()).andStubReturn(new Integer(1));
+
+ EasyMock.replay(objGetEntitySetUriInfo);
+ return objGetEntitySetUriInfo;
+ }
+
+ private GetEntityUriInfo getLocalGetURIInfo() {
+ GetEntityUriInfo objGetEntityUriInfo = EasyMock.createMock(GetEntityUriInfo.class);
+ EasyMock.expect(objGetEntityUriInfo.getSelect()).andStubReturn(getSelectItemList());
+ EasyMock.expect(objGetEntityUriInfo.getTargetEntitySet()).andStubReturn(getLocalTargetEntitySet());
+ EasyMock.expect(objGetEntityUriInfo.getExpand()).andStubReturn(getExpandList());
+ EasyMock.replay(objGetEntityUriInfo);
+ return objGetEntityUriInfo;
+ }
+
+ private List<SelectItem> getSelectItemList() {
+ List<SelectItem> selectItems = new ArrayList<SelectItem>();
+ selectItems.add(getSelectItem());
+ return selectItems;
+ }
+
+ private SelectItem getSelectItem() {
+ SelectItem selectItem = EasyMock.createMock(SelectItem.class);
+ EasyMock.expect(selectItem.getProperty()).andStubReturn(getEdmPropertyForSelect());
+ List<NavigationPropertySegment> navigationSegmentList = new ArrayList<NavigationPropertySegment>();
+ EasyMock.expect(selectItem.getNavigationPropertySegments()).andStubReturn(navigationSegmentList);
+ EasyMock.replay(selectItem);
+ return selectItem;
+ }
+
+ private EdmProperty getEdmPropertyForSelect() {
+ EdmSimpleType edmType = EasyMock.createMock(EdmSimpleType.class);
+ EasyMock.expect(edmType.getKind()).andStubReturn(EdmTypeKind.SIMPLE);
+ Facets facets = new Facets().setNullable(false);
+ try {
+ EasyMock.expect(edmType.valueToString(new Integer(2), EdmLiteralKind.URI, facets)).andStubReturn("2");
+ EasyMock.expect(edmType.valueToString(new Integer(2), EdmLiteralKind.DEFAULT, facets)).andStubReturn("2");
+ } catch (EdmSimpleTypeException e1) {
+ fail("There is an exception in mocking EdmType object " + e1.getMessage());
+ }
+ EasyMock.replay(edmType);
+ EdmProperty edmProperty = EasyMock.createMock(EdmProperty.class);
+ EdmMapping edmMapping = EasyMock.createMock(EdmMapping.class);
+ EasyMock.expect(edmMapping.getInternalName()).andStubReturn("soId");
+ EasyMock.expect(edmMapping.getMimeType()).andReturn(null);
+ EasyMock.replay(edmMapping);
+ try {
+ EasyMock.expect(edmProperty.getName()).andStubReturn("ID");
+ EasyMock.expect(edmProperty.getType()).andStubReturn(edmType);
+ EasyMock.expect(edmProperty.getMapping()).andStubReturn(edmMapping);
+ EasyMock.expect(edmProperty.getFacets()).andStubReturn(facets);
+ EasyMock.expect(edmProperty.getCustomizableFeedMappings()).andStubReturn(null);
+ EasyMock.expect(edmProperty.getMimeType()).andStubReturn(null);
+ EasyMock.replay(edmProperty);
+
+ } catch (EdmException e) {
+ fail("There is an exception in mocking some object " + e.getMessage());
+ }
+
+ return edmProperty;
+
+ }
+
+ private EdmEntitySet getLocalTargetEntitySet() {
+ EdmEntitySet objEdmEntitySet = EasyMock.createMock(EdmEntitySet.class);
+ try {
+ EasyMock.expect(objEdmEntitySet.getEntityType()).andStubReturn(getLocalEdmEntityType());
+ EasyMock.expect(objEdmEntitySet.getName()).andStubReturn("SalesOderHeaders");
+ EasyMock.expect(objEdmEntitySet.getEntityContainer()).andStubReturn(getLocalEdmEntityContainer());
+ } catch (EdmException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+
+ EasyMock.replay(objEdmEntitySet);
+ return objEdmEntitySet;
+ }
+
+ private EdmEntityContainer getLocalEdmEntityContainer() {
+ EdmEntityContainer edmEntityContainer = EasyMock.createMock(EdmEntityContainer.class);
+ EasyMock.expect(edmEntityContainer.isDefaultEntityContainer()).andStubReturn(true);
+ try {
+ EasyMock.expect(edmEntityContainer.getName()).andStubReturn("salesorderprocessingContainer");
+ } catch (EdmException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+
+ EasyMock.replay(edmEntityContainer);
+ return edmEntityContainer;
+ }
+
+ private EdmEntityType getLocalEdmEntityType() {
+ EdmEntityType objEdmEntityType = EasyMock.createMock(EdmEntityType.class);
+ try {
+ EasyMock.expect(objEdmEntityType.getName()).andStubReturn("SalesOderHeaders");
+ EasyMock.expect(objEdmEntityType.getNamespace()).andStubReturn("SalesOderHeaders");
+ EasyMock.expect(objEdmEntityType.hasStream()).andStubReturn(false);
+ EasyMock.expect(objEdmEntityType.hasStream()).andStubReturn(false);
+ ArrayList<String> propertyNames = new ArrayList<String>();
+ propertyNames.add("ID");
+ EasyMock.expect(objEdmEntityType.getProperty("ID")).andStubReturn(getEdmPropertyForSelect());
+ EasyMock.expect(objEdmEntityType.getPropertyNames()).andStubReturn(propertyNames);
+ EasyMock.expect(objEdmEntityType.getNavigationPropertyNames()).andStubReturn(new ArrayList<String>());
+ EasyMock.expect(objEdmEntityType.getKeyPropertyNames()).andStubReturn(propertyNames);
+ EasyMock.expect(objEdmEntityType.getKeyProperties()).andStubReturn(getKeyProperties());
+ } catch (EdmException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+ EasyMock.replay(objEdmEntityType);
+ return objEdmEntityType;
+ }
+
+ private List<EdmProperty> getKeyProperties() {
+ List<EdmProperty> edmProperties = new ArrayList<EdmProperty>();
+ EdmType edmType = EasyMock.createMock(EdmType.class);
+ EasyMock.expect(edmType.getKind()).andStubReturn(EdmTypeKind.SIMPLE);
+ EasyMock.replay(edmType);
+ EdmProperty edmProperty = EasyMock.createMock(EdmProperty.class);
+ EdmMapping edmMapping = EasyMock.createMock(EdmMapping.class);
+ EasyMock.expect(edmMapping.getInternalName()).andStubReturn("soId");
+ EasyMock.replay(edmMapping);
+ try {
+ EasyMock.expect(edmProperty.getName()).andStubReturn("ID");
+ EasyMock.expect(edmProperty.getType()).andStubReturn(edmType);
+ EasyMock.expect(edmProperty.getMapping()).andStubReturn(edmMapping);
+ EasyMock.replay(edmProperty);
+ } catch (EdmException e) {
+ fail("There is an exception is mocking some object " + e.getMessage());
+ }
+
+ edmProperties.add(edmProperty);
+ return edmProperties;
+ }
+
+ private InlineCount getLocalInlineCount() {
+ return InlineCount.NONE;
+ }
+
+ class SalesOrderHeader {
+ private int soId;
+ private int Field1;
+
+ public SalesOrderHeader(final int soId, final int field) {
+ this.soId = soId;
+ Field1 = field;
+ }
+
+ public int getField1() {
+ return Field1;
+ }
+
+ public void setField1(final int field1) {
+ Field1 = field1;
+ }
+
+ public int getSoId() {
+ return soId;
+ }
+
+ public void setSoId(final int soId) {
+ this.soId = soId;
+ }
+
+ }
+
+ private List<Object> getJPAEntities() {
+ List<Object> listJPAEntities = new ArrayList<Object>();
+ SalesOrderHeader entity;
+ entity = new SalesOrderHeader(2, 10);
+ listJPAEntities.add(entity);
+ return listJPAEntities;
+ }
+
+ private Object getEntity() {
+ SalesOrderHeader sHeader = new SalesOrderHeader(10, 34);
+ return sHeader;
+ }
+
+ private GetEntityUriInfo mockEntityUriInfoForExpand() {
+
+ List<SelectItem> selectItemList = new ArrayList<SelectItem>();
+ List<ArrayList<NavigationPropertySegment>> expandList = new ArrayList<ArrayList<NavigationPropertySegment>>();
+ ArrayList<NavigationPropertySegment> navigationPropertyList = new ArrayList<NavigationPropertySegment>();
+ // Mocking the navigation property
+ EdmNavigationProperty navigationProperty = EasyMock.createMock(EdmNavigationProperty.class);
+ try {
+ EasyMock.expect(navigationProperty.getName()).andStubReturn("SalesOrderItemDetails");
+ } catch (EdmException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+ EasyMock.replay(navigationProperty);
+ // Mocking the navigation property segments and adding to expand list
+ NavigationPropertySegment navigationPropertySegment = EasyMock.createMock(NavigationPropertySegment.class);
+ EasyMock.expect(navigationPropertySegment.getNavigationProperty()).andStubReturn(navigationProperty);
+ EasyMock.expect(navigationPropertySegment.getTargetEntitySet()).andStubReturn(getTargetEntitySetForExpand());
+ EasyMock.replay(navigationPropertySegment);
+ navigationPropertyList.add(navigationPropertySegment);
+ expandList.add(navigationPropertyList);
+ // Mocking EntityUriInfo
+ GetEntityUriInfo entityUriInfo = EasyMock.createMock(GetEntityUriInfo.class);
+ EasyMock.expect(entityUriInfo.getSelect()).andStubReturn(selectItemList);
+ EasyMock.expect(entityUriInfo.getExpand()).andStubReturn(expandList);
+ EasyMock.replay(entityUriInfo);
+ return entityUriInfo;
+ }
+
+ private GetEntitySetUriInfo mockEntitySetUriInfoForExpand() {
+
+ List<SelectItem> selectItemList = new ArrayList<SelectItem>();
+ List<ArrayList<NavigationPropertySegment>> expandList = new ArrayList<ArrayList<NavigationPropertySegment>>();
+ ArrayList<NavigationPropertySegment> navigationPropertyList = new ArrayList<NavigationPropertySegment>();
+ // Mocking the navigation property
+ EdmNavigationProperty navigationProperty = EasyMock.createMock(EdmNavigationProperty.class);
+ try {
+ EasyMock.expect(navigationProperty.getName()).andStubReturn("SalesOrderItemDetails");
+ } catch (EdmException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+ EasyMock.replay(navigationProperty);
+ // Mocking the navigation property segments and adding to expand list
+ NavigationPropertySegment navigationPropertySegment = EasyMock.createMock(NavigationPropertySegment.class);
+ EasyMock.expect(navigationPropertySegment.getNavigationProperty()).andStubReturn(navigationProperty);
+ EasyMock.expect(navigationPropertySegment.getTargetEntitySet()).andStubReturn(getTargetEntitySetForExpand());
+ EasyMock.replay(navigationPropertySegment);
+ navigationPropertyList.add(navigationPropertySegment);
+ expandList.add(navigationPropertyList);
+ // Mocking EntityUriInfo
+ GetEntitySetUriInfo entitySetUriInfo = EasyMock.createMock(GetEntitySetUriInfo.class);
+ EasyMock.expect(entitySetUriInfo.getSelect()).andStubReturn(selectItemList);
+ EasyMock.expect(entitySetUriInfo.getExpand()).andStubReturn(expandList);
+ EasyMock.expect(entitySetUriInfo.getInlineCount()).andStubReturn(InlineCount.ALLPAGES);
+ EasyMock.expect(entitySetUriInfo.getSkip()).andStubReturn(new Integer(1));
+ EasyMock.expect(entitySetUriInfo.getTop()).andStubReturn(new Integer(2));
+ EasyMock.replay(entitySetUriInfo);
+ return entitySetUriInfo;
+ }
+
+ private EdmEntitySet getTargetEntitySetForExpand() {
+ EdmEntitySet entitySet = EasyMock.createMock(EdmEntitySet.class);
+ try {
+ EasyMock.expect(entitySet.getName()).andStubReturn("SalesOrderHeaders");
+ EasyMock.expect(entitySet.getEntityType()).andStubReturn(null);
+ } catch (EdmException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+ EasyMock.replay(entitySet);
+ return entitySet;
+ }
+
+ private NavigationPropertySegment getNavigationPropertySegment(final String navPropertyName) {
+ EdmNavigationProperty navigationProperty = EasyMock.createMock(EdmNavigationProperty.class);
+ try {
+ EasyMock.expect(navigationProperty.getName()).andStubReturn(navPropertyName);
+ } catch (EdmException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+ EasyMock.replay(navigationProperty);
+ NavigationPropertySegment navPropertySegment = EasyMock.createMock(NavigationPropertySegment.class);
+ EasyMock.expect(navPropertySegment.getNavigationProperty()).andStubReturn(navigationProperty);
+ EasyMock.replay(navPropertySegment);
+ return navPropertySegment;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/access/data/JPAEntityParserTest.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/access/data/JPAEntityParserTest.java b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/access/data/JPAEntityParserTest.java
new file mode 100644
index 0000000..55511ca
--- /dev/null
+++ b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/access/data/JPAEntityParserTest.java
@@ -0,0 +1,599 @@
+/*******************************************************************************
+ * 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.access.data;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.olingo.odata2.api.edm.EdmException;
+import org.apache.olingo.odata2.api.edm.EdmMapping;
+import org.apache.olingo.odata2.api.edm.EdmNavigationProperty;
+import org.apache.olingo.odata2.api.edm.EdmProperty;
+import org.apache.olingo.odata2.api.edm.EdmStructuralType;
+import org.apache.olingo.odata2.api.edm.EdmType;
+import org.apache.olingo.odata2.api.edm.EdmTypeKind;
+import org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPARuntimeException;
+import org.apache.olingo.odata2.processor.core.jpa.common.ODataJPATestConstants;
+import org.easymock.EasyMock;
+import org.junit.Test;
+
+public class JPAEntityParserTest {
+ /*
+ * TestCase - JPAResultParser is a singleton class Check if the same
+ * instance is returned when create method is called
+ */
+ @Test
+ public void testCreate() {
+ JPAEntityParser resultParser1 = new JPAEntityParser();
+ JPAEntityParser resultParser2 = new JPAEntityParser();
+
+ if (resultParser1.equals(resultParser2)) {
+ fail();
+ }
+ }
+
+ @Test
+ public void testparse2EdmPropertyValueMap() {
+ JPAEntityParser resultParser = new JPAEntityParser();
+ Object jpaEntity = new demoItem("abc", 10);
+ EdmStructuralType structuralType = EasyMock.createMock(EdmStructuralType.class);
+ EdmProperty edmTyped = EasyMock.createMock(EdmProperty.class);
+ EdmType edmType = EasyMock.createMock(EdmType.class);
+ EdmProperty edmTyped01 = EasyMock.createMock(EdmProperty.class);
+ EdmType edmType01 = EasyMock.createMock(EdmType.class);
+ EdmMapping edmMapping = EasyMock.createMock(EdmMapping.class);
+ EdmMapping edmMapping01 = EasyMock.createMock(EdmMapping.class);
+
+ try {
+ EasyMock.expect(edmType.getKind()).andStubReturn(EdmTypeKind.SIMPLE);
+ EasyMock.expect(edmTyped.getName()).andStubReturn("identifier");
+ EasyMock.replay(edmType);
+ EasyMock.expect(edmMapping.getInternalName()).andStubReturn("id");
+ EasyMock.replay(edmMapping);
+ EasyMock.expect(edmTyped.getType()).andStubReturn(edmType);
+ EasyMock.expect(edmTyped.getMapping()).andStubReturn(edmMapping);
+ EasyMock.replay(edmTyped);
+ EasyMock.expect(structuralType.getProperty("identifier")).andStubReturn(edmTyped);
+
+ EasyMock.expect(edmType01.getKind()).andStubReturn(EdmTypeKind.SIMPLE);
+ EasyMock.expect(edmTyped01.getName()).andStubReturn("Value");
+ EasyMock.replay(edmType01);
+ EasyMock.expect(edmMapping01.getInternalName()).andStubReturn("value");
+ EasyMock.replay(edmMapping01);
+ EasyMock.expect(edmTyped01.getType()).andStubReturn(edmType01);
+ EasyMock.expect(edmTyped01.getMapping()).andStubReturn(edmMapping01);
+ EasyMock.replay(edmTyped01);
+ EasyMock.expect(structuralType.getProperty("value")).andStubReturn(edmTyped01);
+
+ List<String> propNames = new ArrayList<String>();
+ propNames.add("identifier");
+ propNames.add("value");
+ EasyMock.expect(structuralType.getPropertyNames()).andReturn(propNames);
+ EasyMock.replay(structuralType);
+
+ } catch (EdmException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+
+ try {
+ Map<String, Object> result = resultParser.parse2EdmPropertyValueMap(jpaEntity, structuralType);
+ assertEquals(2, result.size());
+ } catch (ODataJPARuntimeException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+
+ }
+
+ @Test
+ public void testparse2EdmPropertyValueMapEdmExcep() {
+ JPAEntityParser resultParser = new JPAEntityParser();
+ Object jpaEntity = new demoItem("abc", 10);
+ EdmStructuralType structuralType = EasyMock
+ .createMock(EdmStructuralType.class);
+ EdmProperty edmTyped = EasyMock.createMock(EdmProperty.class);
+ EdmType edmType = EasyMock.createMock(EdmType.class);
+ EdmProperty edmTyped01 = EasyMock.createMock(EdmProperty.class);
+ EdmType edmType01 = EasyMock.createMock(EdmType.class);
+ EdmMapping edmMapping = EasyMock.createMock(EdmMapping.class);
+ EdmMapping edmMapping01 = EasyMock.createMock(EdmMapping.class);
+
+ try {
+ EasyMock.expect(edmType.getKind())
+ .andStubReturn(EdmTypeKind.SIMPLE);
+ EasyMock.expect(edmType.getName()).andReturn("identifier");
+ EasyMock.replay(edmType);
+ EasyMock.expect(edmMapping.getInternalName()).andStubReturn("id");
+ EasyMock.replay(edmMapping);
+ EasyMock.expect(edmTyped.getType()).andStubThrow(
+ new EdmException(null));
+ EasyMock.expect(edmTyped.getMapping()).andStubReturn(edmMapping);
+ EasyMock.expect(edmTyped.getName()).andReturn("identifier");
+ EasyMock.replay(edmTyped);
+ EasyMock.expect(structuralType.getProperty("identifier"))
+ .andStubReturn(edmTyped);
+
+ EasyMock.expect(edmType01.getKind()).andStubReturn(
+ EdmTypeKind.SIMPLE);
+ EasyMock.expect(edmType01.getName()).andStubReturn("value");
+ EasyMock.replay(edmType01);
+ EasyMock.expect(edmMapping01.getInternalName()).andStubReturn(
+ "value");
+ EasyMock.replay(edmMapping01);
+ EasyMock.expect(edmTyped01.getName()).andReturn("value");
+ EasyMock.expect(edmTyped01.getType()).andStubReturn(edmType01);
+ EasyMock.expect(edmTyped01.getMapping())
+ .andStubReturn(edmMapping01);
+ EasyMock.replay(edmTyped01);
+ EasyMock.expect(structuralType.getProperty("value")).andStubReturn(
+ edmTyped01);
+
+ List<String> propNames = new ArrayList<String>();
+ propNames.add("identifier");
+ propNames.add("value");
+ EasyMock.expect(structuralType.getPropertyNames()).andReturn(
+ propNames);
+ EasyMock.replay(structuralType);
+
+ } catch (EdmException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage()
+ + ODataJPATestConstants.EXCEPTION_MSG_PART_2); // assertTrue(false);
+ }
+
+ try {
+ resultParser.parse2EdmPropertyValueMap(jpaEntity, structuralType);
+ } catch (ODataJPARuntimeException e) {
+ assertTrue(true);
+ }
+
+ }
+
+ @Test
+ public void testparse2EdmPropertyListMap() {
+ JPAEntityParser resultParser = new JPAEntityParser();
+ Map<String, Object> edmEntity = new HashMap<String, Object>();
+ edmEntity.put("SoId", 1);
+ DemoRelatedEntity relatedEntity = new DemoRelatedEntity("NewOrder");
+ demoItem jpaEntity = new demoItem("laptop", 1);
+ jpaEntity.setRelatedEntity(relatedEntity);
+ List<EdmNavigationProperty> navigationPropertyList = new ArrayList<EdmNavigationProperty>();
+ // Mocking a navigation property and its mapping object
+ EdmNavigationProperty navigationProperty = EasyMock.createMock(EdmNavigationProperty.class);
+ EdmMapping edmMapping = EasyMock.createMock(EdmMapping.class);
+ try {
+ EasyMock.expect(edmMapping.getInternalName()).andStubReturn("relatedEntity");
+ EasyMock.replay(edmMapping);
+ EasyMock.expect(navigationProperty.getName()).andStubReturn("RelatedEntities");
+ EasyMock.expect(navigationProperty.getMapping()).andStubReturn(edmMapping);
+ EasyMock.replay(navigationProperty);
+ } catch (EdmException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+
+ navigationPropertyList.add(navigationProperty);
+ try {
+ HashMap<String, Object> result = resultParser.parse2EdmNavigationValueMap(jpaEntity, navigationPropertyList);
+ assertEquals(relatedEntity, result.get("RelatedEntities"));
+
+ } catch (ODataJPARuntimeException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+ }
+
+ @Test
+ public void testparse2EdmPropertyValueMapFromList() {
+ JPAEntityParser resultParser = new JPAEntityParser();
+ demoItem jpaEntity = new demoItem("laptop", 1);
+ DemoRelatedEntity relatedEntity = new DemoRelatedEntity("DemoOrder");
+ jpaEntity.setRelatedEntity(relatedEntity);
+ List<EdmProperty> selectPropertyList = new ArrayList<EdmProperty>();
+ // Mocking EdmProperties
+ EdmProperty edmProperty1 = EasyMock.createMock(EdmProperty.class);
+ EdmProperty edmProperty2 = EasyMock.createMock(EdmProperty.class);
+ EdmType edmType1 = EasyMock.createMock(EdmType.class);
+ EdmType edmType2 = EasyMock.createMock(EdmType.class);
+ EdmMapping mapping1 = EasyMock.createMock(EdmMapping.class);
+ EdmMapping mapping2 = EasyMock.createMock(EdmMapping.class);
+ try {
+ EasyMock.expect(edmType1.getKind()).andStubReturn(EdmTypeKind.SIMPLE);
+ EasyMock.replay(edmType1);
+ EasyMock.expect(mapping1.getInternalName()).andStubReturn("id");
+ EasyMock.replay(mapping1);
+ EasyMock.expect(edmProperty1.getName()).andStubReturn("Id");
+ EasyMock.expect(edmProperty1.getMapping()).andStubReturn(mapping1);
+ EasyMock.expect(edmProperty1.getType()).andStubReturn(edmType1);
+ EasyMock.replay(edmProperty1);
+ EasyMock.expect(edmType2.getKind()).andStubReturn(EdmTypeKind.COMPLEX);
+ EasyMock.replay(edmType2);
+ EasyMock.expect(mapping2.getInternalName()).andStubReturn("relatedEntity.order");
+ EasyMock.replay(mapping2);
+ EasyMock.expect(edmProperty2.getName()).andStubReturn("Order");
+ EasyMock.expect(edmProperty2.getMapping()).andStubReturn(mapping2);
+ EasyMock.expect(edmProperty2.getType()).andStubReturn(edmType2);
+ EasyMock.replay(edmProperty2);
+
+ } catch (EdmException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+ selectPropertyList.add(edmProperty1);
+ selectPropertyList.add(edmProperty2);
+ try {
+ Map<String, Object> result = resultParser.parse2EdmPropertyValueMap(jpaEntity, selectPropertyList);
+ assertEquals("DemoOrder", result.get("Order"));
+ } catch (ODataJPARuntimeException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+
+ }
+
+ // This unit tests when there is a complex type in the select list
+ @SuppressWarnings("unchecked")
+ @Test
+ public void testparse2EdmPropertyValueMapFromListComplex() {
+ JPAEntityParser resultParser = new JPAEntityParser();
+ demoItem jpaEntity = new demoItem("laptop", 1);
+ DemoRelatedEntity relatedEntity = new DemoRelatedEntity("DemoOrder");
+ jpaEntity.setRelatedEntity(relatedEntity);
+ List<EdmProperty> selectPropertyList = new ArrayList<EdmProperty>();
+ // Mocking EdmProperties
+ EdmProperty edmProperty1 = EasyMock.createMock(EdmProperty.class);
+ EdmProperty edmProperty2 = EasyMock.createMock(EdmProperty.class);
+ EdmProperty edmComplexProperty = EasyMock.createMock(EdmProperty.class);
+ EdmType edmType1 = EasyMock.createMock(EdmType.class);
+ EdmStructuralType edmType2 = EasyMock.createMock(EdmStructuralType.class);
+ EdmType edmComplexType = EasyMock.createMock(EdmType.class);
+ EdmMapping mapping1 = EasyMock.createMock(EdmMapping.class);
+ EdmMapping mapping2 = EasyMock.createMock(EdmMapping.class);
+ EdmMapping complexMapping = EasyMock.createMock(EdmMapping.class);
+ try {
+ EasyMock.expect(edmType1.getKind()).andStubReturn(EdmTypeKind.SIMPLE);
+ EasyMock.replay(edmType1);
+ EasyMock.expect(mapping1.getInternalName()).andStubReturn("id");
+ EasyMock.replay(mapping1);
+ EasyMock.expect(edmProperty1.getName()).andStubReturn("Id");
+ EasyMock.expect(edmProperty1.getMapping()).andStubReturn(mapping1);
+ EasyMock.expect(edmProperty1.getType()).andStubReturn(edmType1);
+ EasyMock.replay(edmProperty1);
+ // Mocking the complex properties
+ EasyMock.expect(edmComplexType.getKind()).andStubReturn(EdmTypeKind.SIMPLE);
+ EasyMock.replay(edmComplexType);
+ EasyMock.expect(complexMapping.getInternalName()).andStubReturn("order");
+ EasyMock.replay(complexMapping);
+ EasyMock.expect(edmComplexProperty.getName()).andStubReturn("OrderName");
+ EasyMock.expect(edmComplexProperty.getMapping()).andStubReturn(complexMapping);
+ EasyMock.expect(edmComplexProperty.getType()).andStubReturn(edmComplexType);
+ EasyMock.replay(edmComplexProperty);
+ EasyMock.expect(edmType2.getKind()).andStubReturn(EdmTypeKind.COMPLEX);
+ EasyMock.expect(edmType2.getProperty("OrderName")).andStubReturn(edmComplexProperty);
+ List<String> propertyNames = new ArrayList<String>();
+ propertyNames.add("OrderName");
+ EasyMock.expect(edmType2.getPropertyNames()).andStubReturn(propertyNames);
+ EasyMock.replay(edmType2);
+ EasyMock.expect(mapping2.getInternalName()).andStubReturn("relatedEntity");
+ EasyMock.replay(mapping2);
+ EasyMock.expect(edmProperty2.getName()).andStubReturn("Order");
+ EasyMock.expect(edmProperty2.getMapping()).andStubReturn(mapping2);
+ EasyMock.expect(edmProperty2.getType()).andStubReturn(edmType2);
+ EasyMock.replay(edmProperty2);
+
+ } catch (EdmException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage()
+ + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+ selectPropertyList.add(edmProperty1);
+ selectPropertyList.add(edmProperty2);
+ try {
+ Map<String, Object> result = resultParser.parse2EdmPropertyValueMap(jpaEntity, selectPropertyList);
+ assertEquals(1, ((HashMap<String, Object>) result.get("Order")).size());
+ } catch (ODataJPARuntimeException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage()
+ + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+
+ }
+
+ /*
+ * TestCase - getGetterName is a private method in JPAResultParser. The
+ * method is uses reflection to derive the property access methods from
+ * EdmProperty
+ */
+ @Test
+ public void testGetGettersWithOutMapping() {
+ JPAEntityParser resultParser = new JPAEntityParser();
+ try {
+
+ /*
+ * Case 1 - Property having No mapping
+ */
+ Class<?>[] pars = { String.class, EdmMapping.class, String.class };
+ Object[] params = { "Field1", null, "get" };
+ Method getGetterName = resultParser.getClass().getDeclaredMethod("getAccessModifierName", pars);
+ getGetterName.setAccessible(true);
+ String name = (String) getGetterName.invoke(resultParser, params);
+
+ assertEquals("getField1", name);
+
+ } catch (IllegalAccessException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ } catch (IllegalArgumentException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ } catch (InvocationTargetException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ } catch (NoSuchMethodException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ } catch (SecurityException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+
+ }
+ }
+
+ @Test
+ public void testGetGettersWithNullPropname() {
+ JPAEntityParser resultParser = new JPAEntityParser();
+ try {
+
+ /*
+ * Case 1 - Property having No mapping and no name
+ */
+ Class<?>[] pars = { String.class, EdmMapping.class, String.class };
+ Object[] params = { null, null, null };
+ Method getGetterName = resultParser.getClass().getDeclaredMethod("getAccessModifierName", pars);
+ getGetterName.setAccessible(true);
+
+ String name = (String) getGetterName.invoke(resultParser, params);
+ assertNull(name);
+
+ } catch (IllegalAccessException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ } catch (IllegalArgumentException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ } catch (InvocationTargetException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ } catch (NoSuchMethodException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ } catch (SecurityException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+
+ }
+ }
+
+ /*
+ * TestCase - getGetterName is a private method in JPAResultParser. The
+ * method is uses reflection to derive the property access methods from
+ * EdmProperty
+ *
+ * EdmProperty name could have been modified. Then mapping object of
+ * EdmProperty should be used for deriving the name
+ */
+ @Test
+ public void testGetGettersWithMapping() {
+ JPAEntityParser resultParser = new JPAEntityParser();
+ EdmMapping edmMapping = EasyMock.createMock(EdmMapping.class);
+ EasyMock.expect(edmMapping.getInternalName()).andStubReturn("field1");
+ EasyMock.replay(edmMapping);
+ try {
+
+ Class<?>[] pars = { String.class, EdmMapping.class, String.class };
+ Object[] params = { "myField", edmMapping, "get" };
+ Method getGetterName = resultParser.getClass().getDeclaredMethod("getAccessModifierName", pars);
+ getGetterName.setAccessible(true);
+
+ String name = (String) getGetterName.invoke(resultParser, params);
+ assertEquals("getField1", name);
+
+ } catch (IllegalAccessException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ } catch (IllegalArgumentException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ } catch (InvocationTargetException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ } catch (NoSuchMethodException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ } catch (SecurityException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+
+ }
+ }
+
+ @Test
+ public void testGetGettersNoSuchMethodException() {
+ JPAEntityParser resultParser = new JPAEntityParser();
+ try {
+
+ Method getGetterName = resultParser.getClass().getDeclaredMethod("getGetterName1", EdmProperty.class);
+ getGetterName.setAccessible(true);
+
+ } catch (NoSuchMethodException e) {
+ assertEquals(
+ "org.apache.olingo.odata2.processor.core.jpa.access.data.JPAEntityParser.getGetterName1" +
+ "(org.apache.olingo.odata2.api.edm.EdmProperty)",
+ e.getMessage());
+ } catch (SecurityException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+
+ }
+ }
+
+ @Test
+ public void testParse2EdmPropertyValueMap() {
+ JPAEntityParser resultParser = new JPAEntityParser();
+ Object jpaEntity = new DemoItem2("abc");
+ try {
+ resultParser.parse2EdmPropertyValueMap(jpaEntity, getEdmPropertyList());
+ } catch (ODataJPARuntimeException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+ }
+
+ @Test
+ public void testGetGetterEdmException() {
+ JPAEntityParser resultParser = new JPAEntityParser();
+ Object jpaEntity = new demoItem("abc", 10);
+ EdmStructuralType structuralType = EasyMock.createMock(EdmStructuralType.class);
+ try {
+ EasyMock.expect(structuralType.getPropertyNames()).andStubThrow(new EdmException(null));
+ EasyMock.replay(structuralType);
+ Method getGetters =
+ resultParser.getClass().getDeclaredMethod("getGetters", Object.class, EdmStructuralType.class);
+ getGetters.setAccessible(true);
+ try {
+ getGetters.invoke(resultParser, jpaEntity, structuralType);
+ } catch (IllegalAccessException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ } catch (IllegalArgumentException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ } catch (InvocationTargetException e) {
+ assertTrue(true);
+ }
+ } catch (NoSuchMethodException e) {
+ assertEquals(
+ "org.apache.olingo.odata2.processor.core.jpa.access.data.JPAEntityParser.getGetters(java.lang.Object, " +
+ "org.apache.olingo.odata2.api.edm.EdmStructuralType)",
+ e.getMessage());
+ } catch (SecurityException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ } catch (EdmException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+ }
+
+ @Test
+ public void testForNullJPAEntity() {
+ JPAEntityParser resultParser = new JPAEntityParser();
+ EdmStructuralType structuralType = EasyMock.createMock(EdmStructuralType.class);
+ Object map;
+ try {
+ map = resultParser.parse2EdmPropertyValueMap(null, structuralType);
+ assertNull(map);
+ } catch (ODataJPARuntimeException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+ }
+
+ class demoItem {
+ private String id;
+ private int value;
+ private DemoRelatedEntity relatedEntity;
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(final String id) {
+ this.id = id;
+ }
+
+ public DemoRelatedEntity getRelatedEntity() {
+ return relatedEntity;
+ }
+
+ public void setRelatedEntity(final DemoRelatedEntity relatedEntity) {
+ this.relatedEntity = relatedEntity;
+ }
+
+ public int getValue() {
+ return value;
+ }
+
+ public void setValue(final int value) {
+ this.value = value;
+ }
+
+ demoItem(final String id, final int value) {
+ this.id = id;
+ this.value = value;
+ }
+
+ }
+
+ class DemoRelatedEntity {
+ String order;
+
+ public String getOrder() {
+ return order;
+ }
+
+ public void setOrder(final String order) {
+ this.order = order;
+ }
+
+ public DemoRelatedEntity(final String order) {
+ super();
+ this.order = order;
+ }
+
+ }
+
+ private List<EdmProperty> getEdmPropertyList() {
+ List<EdmProperty> properties = new ArrayList<EdmProperty>();
+ properties.add(getEdmProperty());
+ return properties;
+ }
+
+ class DemoItem2 {
+ private String field1;
+
+ public String getField1() {
+ return field1;
+ }
+
+ public void setField1(final String field) {
+ field1 = field;
+ }
+
+ public DemoItem2(final String field) {
+ field1 = field;
+ }
+
+ }
+
+ private EdmProperty getEdmProperty() {
+ EdmProperty edmTyped = EasyMock.createMock(EdmProperty.class);
+
+ EdmMapping edmMapping = EasyMock.createMock(EdmMapping.class);
+ EasyMock.expect(edmMapping.getInternalName()).andStubReturn("Field1");
+ EasyMock.replay(edmMapping);
+
+ EdmType edmType = EasyMock.createMock(EdmType.class);
+
+ try {
+ EasyMock.expect(edmType.getKind()).andStubReturn(EdmTypeKind.SIMPLE);
+ EasyMock.expect(edmType.getName()).andStubReturn("identifier");
+ EasyMock.expect(edmTyped.getName()).andStubReturn("SalesOrderHeader");
+ EasyMock.expect(edmTyped.getMapping()).andStubReturn(edmMapping);
+
+ EasyMock.expect(edmTyped.getType()).andStubReturn(edmType);
+ EasyMock.expect(edmTyped.getMapping()).andStubReturn(edmMapping);
+
+ } catch (EdmException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+ EasyMock.replay(edmType);
+ EasyMock.replay(edmTyped);
+ return edmTyped;
+ }
+}
[34/37] [OLINGO-82] Renamed the project folder name to
odata2-jpa-processor
Posted by ch...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/mapping/JPAEntityTypeMapType.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/mapping/JPAEntityTypeMapType.java b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/mapping/JPAEntityTypeMapType.java
new file mode 100644
index 0000000..2f4526c
--- /dev/null
+++ b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/mapping/JPAEntityTypeMapType.java
@@ -0,0 +1,213 @@
+/*******************************************************************************
+ * 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.api.jpa.model.mapping;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlType;
+
+/**
+ *
+ * The default name for EDM
+ * entity type is derived from JPA entity type name. This can be
+ * overriden using JPAEntityTypeMapType.
+ *
+ *
+ * <p>Java class for JPAEntityTypeMapType complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="JPAEntityTypeMapType">
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <sequence>
+ * <element name="EDMEntityType" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
+ * <element name="EDMEntitySet" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
+ * <element name="JPAAttributes"
+ * type="{http://www.apache.org/olingo/odata2/processor/api/jpa/model/mapping}JPAAttributeMapType"/>
+ * <element name="JPARelationships"
+ * type="{http://www.apache.org/olingo/odata2/processor/api/jpa/model/mapping}JPARelationshipMapType"/>
+ * </sequence>
+ * <attribute name="name" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
+ * <attribute name="exclude" type="{http://www.w3.org/2001/XMLSchema}boolean" default="false" />
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "JPAEntityTypeMapType", propOrder = { "edmEntityType", "edmEntitySet", "jpaAttributes",
+ "jpaRelationships" })
+public class JPAEntityTypeMapType {
+
+ @XmlElement(name = "EDMEntityType")
+ protected String edmEntityType;
+ @XmlElement(name = "EDMEntitySet")
+ protected String edmEntitySet;
+ @XmlElement(name = "JPAAttributes", required = true)
+ protected JPAAttributeMapType jpaAttributes;
+ @XmlElement(name = "JPARelationships", required = true)
+ protected JPARelationshipMapType jpaRelationships;
+ @XmlAttribute(name = "name", required = true)
+ protected String name;
+ @XmlAttribute(name = "exclude")
+ protected Boolean exclude;
+
+ /**
+ * Gets the value of the edmEntityType property.
+ *
+ * @return
+ * possible object is {@link String }
+ *
+ */
+ public String getEDMEntityType() {
+ return edmEntityType;
+ }
+
+ /**
+ * Sets the value of the edmEntityType property.
+ *
+ * @param value
+ * allowed object is {@link String }
+ *
+ */
+ public void setEDMEntityType(final String value) {
+ edmEntityType = value;
+ }
+
+ /**
+ * Gets the value of the edmEntitySet property.
+ *
+ * @return
+ * possible object is {@link String }
+ *
+ */
+ public String getEDMEntitySet() {
+ return edmEntitySet;
+ }
+
+ /**
+ * Sets the value of the edmEntitySet property.
+ *
+ * @param value
+ * allowed object is {@link String }
+ *
+ */
+ public void setEDMEntitySet(final String value) {
+ edmEntitySet = value;
+ }
+
+ /**
+ * Gets the value of the jpaAttributes property.
+ *
+ * @return
+ * possible object is {@link JPAAttributeMapType }
+ *
+ */
+ public JPAAttributeMapType getJPAAttributes() {
+ return jpaAttributes;
+ }
+
+ /**
+ * Sets the value of the jpaAttributes property.
+ *
+ * @param value
+ * allowed object is {@link JPAAttributeMapType }
+ *
+ */
+ public void setJPAAttributes(final JPAAttributeMapType value) {
+ jpaAttributes = value;
+ }
+
+ /**
+ * Gets the value of the jpaRelationships property.
+ *
+ * @return
+ * possible object is {@link JPARelationshipMapType }
+ *
+ */
+ public JPARelationshipMapType getJPARelationships() {
+ return jpaRelationships;
+ }
+
+ /**
+ * Sets the value of the jpaRelationships property.
+ *
+ * @param value
+ * allowed object is {@link JPARelationshipMapType }
+ *
+ */
+ public void setJPARelationships(final JPARelationshipMapType value) {
+ jpaRelationships = value;
+ }
+
+ /**
+ * Gets the value of the name property.
+ *
+ * @return
+ * possible object is {@link String }
+ *
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * Sets the value of the name property.
+ *
+ * @param value
+ * allowed object is {@link String }
+ *
+ */
+ public void setName(final String value) {
+ name = value;
+ }
+
+ /**
+ * Gets the value of the exclude property.
+ *
+ * @return
+ * possible object is {@link Boolean }
+ *
+ */
+ public boolean isExclude() {
+ if (exclude == null) {
+ return false;
+ } else {
+ return exclude;
+ }
+ }
+
+ /**
+ * Sets the value of the exclude property.
+ *
+ * @param value
+ * allowed object is {@link Boolean }
+ *
+ */
+ public void setExclude(final Boolean value) {
+ exclude = value;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/mapping/JPAEntityTypesMapType.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/mapping/JPAEntityTypesMapType.java b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/mapping/JPAEntityTypesMapType.java
new file mode 100644
index 0000000..cd2a6de
--- /dev/null
+++ b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/mapping/JPAEntityTypesMapType.java
@@ -0,0 +1,89 @@
+/*******************************************************************************
+ * 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.api.jpa.model.mapping;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlType;
+
+/**
+ * <p>
+ * Java class for JPAEntityTypesMapType complex type.
+ *
+ * <p>
+ * The following schema fragment specifies the expected content contained within
+ * this class.
+ *
+ * <pre>
+ * <complexType name="JPAEntityTypesMapType">
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <sequence>
+ * <element name="JPAEntityType"
+ * type="{http://www.apache.org/olingo/odata2/processor/api/jpa/model/mapping}JPAEntityTypeMapType"
+ * maxOccurs="unbounded" minOccurs="0"/>
+ * </sequence>
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "JPAEntityTypesMapType", propOrder = { "jpaEntityType" })
+public class JPAEntityTypesMapType {
+
+ @XmlElement(name = "JPAEntityType")
+ protected List<JPAEntityTypeMapType> jpaEntityType;
+
+ /**
+ * Gets the value of the jpaEntityType property.
+ *
+ * <p>
+ * This accessor method returns a reference to the live list, not a
+ * snapshot. Therefore any modification you make to the returned list will
+ * be present inside the JAXB object. This is why there is not a
+ * <CODE>set</CODE> method for the jpaEntityType property.
+ *
+ * <p>
+ * For example, to add a new item, do as follows:
+ *
+ * <pre>
+ * getJPAEntityType().add(newItem);
+ * </pre>
+ *
+ *
+ * <p>
+ * Objects of the following type(s) are allowed in the list {@link JPAEntityTypeMapType }
+ *
+ *
+ */
+ public List<JPAEntityTypeMapType> getJPAEntityType() {
+ if (jpaEntityType == null) {
+ jpaEntityType = new ArrayList<JPAEntityTypeMapType>();
+ }
+ return jpaEntityType;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/mapping/JPAPersistenceUnitMapType.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/mapping/JPAPersistenceUnitMapType.java b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/mapping/JPAPersistenceUnitMapType.java
new file mode 100644
index 0000000..a9d34b2
--- /dev/null
+++ b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/mapping/JPAPersistenceUnitMapType.java
@@ -0,0 +1,157 @@
+/*******************************************************************************
+ * 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.api.jpa.model.mapping;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlType;
+
+/**
+ *
+ * By default Java Persistence Unit name is taken as EDM schema name. This can
+ * be overriden using JPAPersistenceUnitMapType.
+ *
+ *
+ * <p>
+ * Java class for JPAPersistenceUnitMapType complex type.
+ *
+ * <p>
+ * The following schema fragment specifies the expected content contained within
+ * this class.
+ *
+ * <pre>
+ * <complexType name="JPAPersistenceUnitMapType">
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <sequence>
+ * <element name="EDMSchemaNamespace" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
+ * <element name="JPAEntityTypes"
+ * type="{http://www.apache.org/olingo/odata2/processor/api/jpa/model/mapping}JPAEntityTypesMapType"/>
+ * <element name="JPAEmbeddableTypes"
+ * type="{http://www.apache.org/olingo/odata2/processor/api/jpa/model/mapping}JPAEmbeddableTypesMapType"/>
+ * </sequence>
+ * <attribute name="name" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "JPAPersistenceUnitMapType",
+ propOrder = { "edmSchemaNamespace", "jpaEntityTypes", "jpaEmbeddableTypes" })
+public class JPAPersistenceUnitMapType {
+
+ @XmlElement(name = "EDMSchemaNamespace")
+ protected String edmSchemaNamespace;
+ @XmlElement(name = "JPAEntityTypes", required = true)
+ protected JPAEntityTypesMapType jpaEntityTypes;
+ @XmlElement(name = "JPAEmbeddableTypes", required = true)
+ protected JPAEmbeddableTypesMapType jpaEmbeddableTypes;
+ @XmlAttribute(name = "name", required = true)
+ protected String name;
+
+ /**
+ * Gets the value of the edmSchemaNamespace property.
+ *
+ * @return possible object is {@link String }
+ *
+ */
+ public String getEDMSchemaNamespace() {
+ return edmSchemaNamespace;
+ }
+
+ /**
+ * Sets the value of the edmSchemaNamespace property.
+ *
+ * @param value
+ * allowed object is {@link String }
+ *
+ */
+ public void setEDMSchemaNamespace(final String value) {
+ edmSchemaNamespace = value;
+ }
+
+ /**
+ * Gets the value of the jpaEntityTypes property.
+ *
+ * @return possible object is {@link JPAEntityTypesMapType }
+ *
+ */
+ public JPAEntityTypesMapType getJPAEntityTypes() {
+ return jpaEntityTypes;
+ }
+
+ /**
+ * Sets the value of the jpaEntityTypes property.
+ *
+ * @param value
+ * allowed object is {@link JPAEntityTypesMapType }
+ *
+ */
+ public void setJPAEntityTypes(final JPAEntityTypesMapType value) {
+ jpaEntityTypes = value;
+ }
+
+ /**
+ * Gets the value of the jpaEmbeddableTypes property.
+ *
+ * @return possible object is {@link JPAEmbeddableTypesMapType }
+ *
+ */
+ public JPAEmbeddableTypesMapType getJPAEmbeddableTypes() {
+ return jpaEmbeddableTypes;
+ }
+
+ /**
+ * Sets the value of the jpaEmbeddableTypes property.
+ *
+ * @param value
+ * allowed object is {@link JPAEmbeddableTypesMapType }
+ *
+ */
+ public void setJPAEmbeddableTypes(final JPAEmbeddableTypesMapType value) {
+ jpaEmbeddableTypes = value;
+ }
+
+ /**
+ * Gets the value of the name property.
+ *
+ * @return possible object is {@link String }
+ *
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * Sets the value of the name property.
+ *
+ * @param value
+ * allowed object is {@link String }
+ *
+ */
+ public void setName(final String value) {
+ name = value;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/mapping/JPARelationshipMapType.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/mapping/JPARelationshipMapType.java b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/mapping/JPARelationshipMapType.java
new file mode 100644
index 0000000..986c187
--- /dev/null
+++ b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/mapping/JPARelationshipMapType.java
@@ -0,0 +1,175 @@
+/*******************************************************************************
+ * 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.api.jpa.model.mapping;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlType;
+import javax.xml.bind.annotation.XmlValue;
+
+/**
+ *
+ * The default name for EDM navigation property is derived from JPA relationship
+ * name. This can be overriden using JPARelationshipMapType.
+ *
+ *
+ * <p>
+ * Java class for JPARelationshipMapType complex type.
+ *
+ * <p>
+ * The following schema fragment specifies the expected content contained within
+ * this class.
+ *
+ * <pre>
+ * <complexType name="JPARelationshipMapType">
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <sequence>
+ * <element name="JPARelationship" maxOccurs="unbounded" minOccurs="0">
+ * <complexType>
+ * <simpleContent>
+ * <extension base="<http://www.w3.org/2001/XMLSchema>string">
+ * <attribute name="name" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
+ * </extension>
+ * </simpleContent>
+ * </complexType>
+ * </element>
+ * </sequence>
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "JPARelationshipMapType", propOrder = { "jpaRelationship" })
+public class JPARelationshipMapType {
+
+ @XmlElement(name = "JPARelationship")
+ protected List<JPARelationshipMapType.JPARelationship> jpaRelationship;
+
+ /**
+ * Gets the value of the jpaRelationship property.
+ *
+ * <p>
+ * This accessor method returns a reference to the live list, not a
+ * snapshot. Therefore any modification you make to the returned list will
+ * be present inside the JAXB object. This is why there is not a
+ * <CODE>set</CODE> method for the jpaRelationship property.
+ *
+ * <p>
+ * For example, to add a new item, do as follows:
+ *
+ * <pre>
+ * getJPARelationship().add(newItem);
+ * </pre>
+ *
+ *
+ * <p>
+ * Objects of the following type(s) are allowed in the list {@link JPARelationshipMapType.JPARelationship }
+ *
+ *
+ */
+ public List<JPARelationshipMapType.JPARelationship> getJPARelationship() {
+ if (jpaRelationship == null) {
+ jpaRelationship = new ArrayList<JPARelationshipMapType.JPARelationship>();
+ }
+ return jpaRelationship;
+ }
+
+ /**
+ * <p>
+ * Java class for anonymous complex type.
+ *
+ * <p>
+ * The following schema fragment specifies the expected content contained
+ * within this class.
+ *
+ * <pre>
+ * <complexType>
+ * <simpleContent>
+ * <extension base="<http://www.w3.org/2001/XMLSchema>string">
+ * <attribute name="name" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
+ * </extension>
+ * </simpleContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+ @XmlAccessorType(XmlAccessType.FIELD)
+ @XmlType(name = "", propOrder = { "value" })
+ public static class JPARelationship {
+
+ @XmlValue
+ protected String value;
+ @XmlAttribute(name = "name", required = true)
+ protected String name;
+
+ /**
+ * Gets the value of the value property.
+ *
+ * @return possible object is {@link String }
+ *
+ */
+ public String getValue() {
+ return value;
+ }
+
+ /**
+ * Sets the value of the value property.
+ *
+ * @param value
+ * allowed object is {@link String }
+ *
+ */
+ public void setValue(final String value) {
+ this.value = value;
+ }
+
+ /**
+ * Gets the value of the name property.
+ *
+ * @return possible object is {@link String }
+ *
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * Sets the value of the name property.
+ *
+ * @param value
+ * allowed object is {@link String }
+ *
+ */
+ public void setName(final String value) {
+ name = value;
+ }
+
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/mapping/package-info.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/mapping/package-info.java b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/mapping/package-info.java
new file mode 100644
index 0000000..4593031
--- /dev/null
+++ b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/mapping/package-info.java
@@ -0,0 +1,28 @@
+/*******************************************************************************
+ * 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.
+ ******************************************************************************/
+/**
+ * <h3>OData JPA Processor API Library - Mapping Model</h3>
+ * The JPA EDM Mapping model (XML document) is represented as JAXB annotated Java Classes.
+ *
+ *
+ */
+@javax.xml.bind.annotation.XmlSchema(namespace = "http://www.apache.org/olingo/odata2/processor/api/jpa/model/mapping",
+ elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED)
+package org.apache.olingo.odata2.processor.api.jpa.model.mapping;
+
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/package-info.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/package-info.java b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/package-info.java
new file mode 100644
index 0000000..b2cf90a
--- /dev/null
+++ b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/package-info.java
@@ -0,0 +1,27 @@
+/*******************************************************************************
+ * 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.
+ ******************************************************************************/
+/**
+ * <h3>OData JPA Processor API Library - JPA EDM Model</h3>
+ * The library provides a set of views over the JPA/EDM element containers.
+ * The views can used to access the elements that form EDM.
+ *
+ *
+ */
+package org.apache.olingo.odata2.processor.api.jpa.model;
+
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/package-info.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/package-info.java b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/package-info.java
new file mode 100644
index 0000000..89f4974
--- /dev/null
+++ b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/package-info.java
@@ -0,0 +1,33 @@
+/*******************************************************************************
+ * 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.
+ ******************************************************************************/
+/**
+ * <h3>OData JPA Processor API Library</h3>
+ * The library provides a way for the developers to create an OData Service from a Java Persistence Model.
+ * The library supports Java Persistence 2.0 and is dependent on OData library.
+ *
+ * To create an OData service from JPA models
+ * <ol><li>extend the service factory class {@link org.apache.olingo.odata2.processor.api.jpa.ODataJPAServiceFactory}
+ * and implement the methods</li>
+ * <li>define a JAX-RS servlet in web.xml and configure the service factory as servlet init parameter.
+ * <p><b>See Also:</b>{@link org.apache.olingo.odata2.processor.api.jpa.ODataJPAServiceFactory}</li></ol>
+ *
+ *
+ */
+package org.apache.olingo.odata2.processor.api.jpa;
+
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-api/src/main/resources/JPAEDMMappingModel.xsd
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-api/src/main/resources/JPAEDMMappingModel.xsd b/odata2-jpa-processor/jpa-api/src/main/resources/JPAEDMMappingModel.xsd
new file mode 100644
index 0000000..07abdbf
--- /dev/null
+++ b/odata2-jpa-processor/jpa-api/src/main/resources/JPAEDMMappingModel.xsd
@@ -0,0 +1,165 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+<xs:schema attributeFormDefault="unqualified"
+ elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://www.apache.org/olingo/odata2/processor/api/jpa/model/mapping"
+ xmlns:tns="http://www.apache.org/olingo/odata2/processor/api/jpa/model/mapping">
+
+ <xs:element name="JPAEDMMappingModel">
+ <xs:annotation>
+ <xs:documentation xml:lang="en">
+ Java Persistence (JPA) -
+ Entity Data Model (EDM) Mapping schema. The schema defines a mapping
+ model to describe EDM names for entity types, entity sets, entity
+ properties, entity navigation properties. By default the names of
+ Java Persistence entity types, entity attributes and entity
+ relationships are transformed into their corresponding EDM names. To
+ override the default names the mapping model is defined. Note:-
+ Define the mapping model for only those default names that needs to
+ be overriden.
+ </xs:documentation>
+ </xs:annotation>
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="PersistenceUnit" type="tns:JPAPersistenceUnitMapType"
+ maxOccurs="1" minOccurs="1" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+
+ <xs:complexType name="JPAAttributeMapType">
+ <xs:annotation>
+ <xs:documentation xml:lang="en">
+ The default name for EDM
+ property is derived from JPA attribute name. This can be overriden
+ using
+ JPAAttributeMapType.
+ </xs:documentation>
+ </xs:annotation>
+ <xs:sequence>
+ <xs:element name="JPAAttribute" maxOccurs="unbounded"
+ minOccurs="0">
+ <xs:complexType>
+ <xs:simpleContent>
+ <xs:extension base="xs:string">
+ <xs:attribute type="xs:string" name="name" use="required" />
+ <xs:attribute type="xs:boolean" name="exclude" use="optional"
+ default="false" />
+ </xs:extension>
+ </xs:simpleContent>
+ </xs:complexType>
+ </xs:element>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="JPARelationshipMapType">
+ <xs:annotation>
+ <xs:documentation xml:lang="en">
+ The default name for EDM
+ navigation property is derived from JPA relationship name.
+ This can
+ be overriden using JPARelationshipMapType.
+ </xs:documentation>
+ </xs:annotation>
+ <xs:sequence>
+ <xs:element name="JPARelationship" maxOccurs="unbounded"
+ minOccurs="0">
+ <xs:complexType>
+ <xs:simpleContent>
+ <xs:extension base="xs:string">
+ <xs:attribute type="xs:string" name="name" use="required" />
+ </xs:extension>
+ </xs:simpleContent>
+ </xs:complexType>
+ </xs:element>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="JPAEntityTypeMapType">
+ <xs:annotation>
+ <xs:documentation xml:lang="en">
+ The default name for EDM
+ entity type is derived from JPA entity type name. This can be
+ overriden using JPAEntityTypeMapType.
+ </xs:documentation>
+ </xs:annotation>
+ <xs:sequence>
+ <xs:element type="xs:string" name="EDMEntityType"
+ maxOccurs="1" minOccurs="0" />
+ <xs:element type="xs:string" name="EDMEntitySet"
+ maxOccurs="1" minOccurs="0" />
+ <xs:element name="JPAAttributes" type="tns:JPAAttributeMapType" />
+ <xs:element name="JPARelationships" type="tns:JPARelationshipMapType" />
+ </xs:sequence>
+ <xs:attribute type="xs:string" name="name" use="required" />
+ <xs:attribute type="xs:boolean" name="exclude" use="optional"
+ default="false" />
+ </xs:complexType>
+
+ <xs:complexType name="JPAEntityTypesMapType">
+ <xs:sequence>
+ <xs:element name="JPAEntityType" type="tns:JPAEntityTypeMapType"
+ maxOccurs="unbounded" minOccurs="0" />
+ </xs:sequence>
+ </xs:complexType>
+ <xs:complexType name="JPAEmbeddableTypeMapType">
+ <xs:annotation>
+ <xs:documentation xml:lang="en">
+ The default name for EDM
+ complex type is derived from JPA Embeddable type name. This can be
+ overriden using JPAEmbeddableTypeMapType.
+ </xs:documentation>
+ </xs:annotation>
+ <xs:sequence>
+ <xs:element type="xs:string" name="EDMComplexType"
+ maxOccurs="1" minOccurs="0" />
+ <xs:element name="JPAAttributes" type="tns:JPAAttributeMapType" />
+ </xs:sequence>
+ <xs:attribute type="xs:string" name="name" use="required" />
+ <xs:attribute type="xs:boolean" name="exclude" use="optional"
+ default="false" />
+ </xs:complexType>
+
+ <xs:complexType name="JPAEmbeddableTypesMapType">
+ <xs:sequence>
+ <xs:element name="JPAEmbeddableType" type="tns:JPAEmbeddableTypeMapType"
+ maxOccurs="unbounded" minOccurs="0" />
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="JPAPersistenceUnitMapType">
+ <xs:annotation>
+ <xs:documentation xml:lang="en">
+ By default Java
+ Persistence Unit name is taken as EDM schema name. This can be
+ overriden using JPAPersistenceUnitMapType.
+ </xs:documentation>
+ </xs:annotation>
+ <xs:sequence>
+ <xs:element type="xs:string" name="EDMSchemaNamespace"
+ maxOccurs="1" minOccurs="0" />
+ <xs:element name="JPAEntityTypes" type="tns:JPAEntityTypesMapType" />
+ <xs:element name="JPAEmbeddableTypes" type="tns:JPAEmbeddableTypesMapType" />
+ </xs:sequence>
+ <xs:attribute type="xs:string" name="name" use="required" />
+ </xs:complexType>
+
+
+</xs:schema>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-core/.gitignore
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-core/.gitignore b/odata2-jpa-processor/jpa-core/.gitignore
new file mode 100644
index 0000000..fe5d89b
--- /dev/null
+++ b/odata2-jpa-processor/jpa-core/.gitignore
@@ -0,0 +1,8 @@
+.project
+.classpath
+.settings
+target
+bin
+*.bak
+classes
+.DS_Store
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-core/pom.xml
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-core/pom.xml b/odata2-jpa-processor/jpa-core/pom.xml
new file mode 100644
index 0000000..7cc8b0a
--- /dev/null
+++ b/odata2-jpa-processor/jpa-core/pom.xml
@@ -0,0 +1,146 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.olingo</groupId>
+ <artifactId>olingo-odata2-jpa-processor-incubating</artifactId>
+ <version>1.1.0-SNAPSHOT</version>
+ <relativePath>../</relativePath>
+ </parent>
+
+ <artifactId>olingo-odata2-jpa-processor-core-incubating</artifactId>
+ <packaging>jar</packaging>
+ <name>${project.artifactId}</name>
+
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-jar-plugin</artifactId>
+ <configuration>
+ <archive>
+ <manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
+ </archive>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <extensions>true</extensions>
+ <executions>
+ <execution>
+ <id>bundle-manifest</id>
+ <phase>process-classes</phase>
+ <goals>
+ <goal>manifest</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <instructions>
+ <Import-Package>*</Import-Package>
+ <Export-Package>org.apache.olingo.odata2.processor.core.jpa.factory;version=${project.version}</Export-Package>
+ <Bundle-DocURL>${project.url}</Bundle-DocURL>
+ <Bundle-ActivationPolicy>lazy</Bundle-ActivationPolicy>
+ <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
+ </instructions>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>2.3.2</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.olingo</groupId>
+ <artifactId>olingo-odata2-api-annotation-incubating</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <!-- ########################## -->
+ <!-- Java Persistence API -->
+ <!-- ########################## -->
+ <dependency>
+ <groupId>org.eclipse.persistence</groupId>
+ <artifactId>javax.persistence</artifactId>
+ <version>${version.javax.persistence}</version>
+ </dependency>
+
+ <!-- ########################## -->
+ <!-- OData Java Library Support -->
+ <!-- ########################## -->
+ <dependency>
+ <groupId>org.apache.olingo</groupId>
+ <artifactId>olingo-odata2-api-incubating</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.olingo</groupId>
+ <artifactId>olingo-odata2-core-incubating</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <!-- ########################## -->
+ <!-- OData Java JPA API -->
+ <!-- ########################## -->
+ <dependency>
+ <groupId>org.apache.olingo</groupId>
+ <artifactId>olingo-odata2-jpa-processor-api-incubating</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <!-- ########################## -->
+ <!-- For Testing -->
+ <!-- ########################## -->
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.9</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.easymock</groupId>
+ <artifactId>easymock</artifactId>
+ <version>3.1</version>
+ <scope>test</scope>
+ </dependency>
+
+ <!-- ########################## -->
+ <!-- Supportability Tools -->
+ <!-- ########################## -->
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ <version>1.7.2</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+</project>
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/ODataEntityParser.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/ODataEntityParser.java b/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/ODataEntityParser.java
new file mode 100644
index 0000000..ee54290
--- /dev/null
+++ b/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/ODataEntityParser.java
@@ -0,0 +1,163 @@
+/*******************************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ ******************************************************************************/
+package org.apache.olingo.odata2.processor.core.jpa;
+
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.olingo.odata2.api.edm.Edm;
+import org.apache.olingo.odata2.api.edm.EdmEntitySet;
+import org.apache.olingo.odata2.api.ep.EntityProvider;
+import org.apache.olingo.odata2.api.ep.EntityProviderException;
+import org.apache.olingo.odata2.api.ep.EntityProviderReadProperties;
+import org.apache.olingo.odata2.api.ep.entry.ODataEntry;
+import org.apache.olingo.odata2.api.exception.ODataBadRequestException;
+import org.apache.olingo.odata2.api.exception.ODataException;
+import org.apache.olingo.odata2.api.processor.ODataContext;
+import org.apache.olingo.odata2.api.uri.PathSegment;
+import org.apache.olingo.odata2.api.uri.UriInfo;
+import org.apache.olingo.odata2.api.uri.UriParser;
+import org.apache.olingo.odata2.processor.api.jpa.ODataJPAContext;
+import org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPARuntimeException;
+
+public final class ODataEntityParser {
+
+ private ODataJPAContext context;
+
+ public ODataEntityParser(final ODataJPAContext context) {
+ this.context = context;
+ }
+
+ public final ODataEntry parseEntry(final EdmEntitySet entitySet,
+ final InputStream content, final String requestContentType, final boolean merge)
+ throws ODataBadRequestException {
+ ODataEntry entryValues;
+ try {
+ EntityProviderReadProperties entityProviderProperties =
+ EntityProviderReadProperties.init().mergeSemantic(merge).build();
+ entryValues = EntityProvider.readEntry(requestContentType, entitySet, content, entityProviderProperties);
+ } catch (EntityProviderException e) {
+ throw new ODataBadRequestException(ODataBadRequestException.BODY, e);
+ }
+ return entryValues;
+
+ }
+
+ public final UriInfo parseLinkURI() throws ODataJPARuntimeException {
+ UriInfo uriInfo = null;
+
+ Edm edm;
+ try {
+ edm = context.getODataContext().getService().getEntityDataModel();
+
+ List<PathSegment> pathSegments = context.getODataContext().getPathInfo().getODataSegments();
+ List<PathSegment> subPathSegments = pathSegments.subList(0, pathSegments.size() - 2);
+
+ uriInfo = UriParser.parse(edm, subPathSegments, Collections.<String, String> emptyMap());
+ } catch (ODataException e) {
+ throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e);
+ }
+
+ return uriInfo;
+ }
+
+ public final UriInfo parseLink(final EdmEntitySet entitySet, final InputStream content, final String contentType)
+ throws ODataJPARuntimeException {
+
+ String uriString = null;
+ UriInfo uri = null;
+
+ try {
+ uriString = EntityProvider.readLink(contentType, entitySet, content);
+ ODataContext odataContext = context.getODataContext();
+ final String serviceRoot = odataContext.getPathInfo().getServiceRoot().toString();
+
+ final String path =
+ uriString.startsWith(serviceRoot.toString()) ? uriString.substring(serviceRoot.length()) : uriString;
+
+ final PathSegment pathSegment = new PathSegment() {
+ @Override
+ public String getPath() {
+ return path;
+ }
+
+ @Override
+ public Map<String, List<String>> getMatrixParameters() {
+ return null;
+ }
+ };
+
+ final Edm edm = odataContext.getService().getEntityDataModel();
+
+ uri = UriParser.parse(edm, Arrays.asList(pathSegment), Collections.<String, String> emptyMap());
+
+ } catch (ODataException e) {
+ throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e);
+ }
+
+ return uri;
+
+ }
+
+ public List<UriInfo> parseLinks(final EdmEntitySet entitySet, final InputStream content, final String contentType)
+ throws ODataJPARuntimeException {
+
+ List<String> uriList = new ArrayList<String>();
+ List<UriInfo> uriInfoList = new ArrayList<UriInfo>();
+
+ try {
+
+ uriList = EntityProvider.readLinks(contentType, entitySet, content);
+ ODataContext odataContext = context.getODataContext();
+ final String serviceRoot = odataContext.getPathInfo().getServiceRoot().toString();
+ final int length = serviceRoot.length();
+ final Edm edm = odataContext.getService().getEntityDataModel();
+
+ for (String uriString : uriList) {
+ final String path = uriString.startsWith(serviceRoot) ? uriString.substring(length) : uriString;
+
+ final PathSegment pathSegment = new PathSegment() {
+ @Override
+ public String getPath() {
+ return path;
+ }
+
+ @Override
+ public Map<String, List<String>> getMatrixParameters() {
+ return null;
+ }
+ };
+
+ UriInfo uriInfo = UriParser.parse(edm, Arrays.asList(pathSegment), Collections.<String, String> emptyMap());
+ uriInfoList.add(uriInfo);
+ }
+ } catch (EntityProviderException e) {
+ return null;
+ } catch (ODataException e) {
+ throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e);
+ }
+
+ return uriInfoList;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/ODataExpressionParser.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/ODataExpressionParser.java b/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/ODataExpressionParser.java
new file mode 100644
index 0000000..2993221
--- /dev/null
+++ b/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/ODataExpressionParser.java
@@ -0,0 +1,381 @@
+/*******************************************************************************
+ * 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;
+
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.olingo.odata2.api.edm.EdmException;
+import org.apache.olingo.odata2.api.edm.EdmLiteralKind;
+import org.apache.olingo.odata2.api.edm.EdmMapping;
+import org.apache.olingo.odata2.api.edm.EdmProperty;
+import org.apache.olingo.odata2.api.edm.EdmSimpleType;
+import org.apache.olingo.odata2.api.edm.EdmSimpleTypeException;
+import org.apache.olingo.odata2.api.edm.EdmSimpleTypeKind;
+import org.apache.olingo.odata2.api.exception.ODataException;
+import org.apache.olingo.odata2.api.exception.ODataNotImplementedException;
+import org.apache.olingo.odata2.api.uri.KeyPredicate;
+import org.apache.olingo.odata2.api.uri.expression.BinaryExpression;
+import org.apache.olingo.odata2.api.uri.expression.BinaryOperator;
+import org.apache.olingo.odata2.api.uri.expression.CommonExpression;
+import org.apache.olingo.odata2.api.uri.expression.ExpressionKind;
+import org.apache.olingo.odata2.api.uri.expression.FilterExpression;
+import org.apache.olingo.odata2.api.uri.expression.LiteralExpression;
+import org.apache.olingo.odata2.api.uri.expression.MemberExpression;
+import org.apache.olingo.odata2.api.uri.expression.MethodExpression;
+import org.apache.olingo.odata2.api.uri.expression.MethodOperator;
+import org.apache.olingo.odata2.api.uri.expression.OrderByExpression;
+import org.apache.olingo.odata2.api.uri.expression.OrderExpression;
+import org.apache.olingo.odata2.api.uri.expression.PropertyExpression;
+import org.apache.olingo.odata2.api.uri.expression.SortOrder;
+import org.apache.olingo.odata2.api.uri.expression.UnaryExpression;
+import org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPARuntimeException;
+import org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLStatement;
+
+/**
+ * This class contains utility methods for parsing the filter expressions built by core library from user OData Query.
+ *
+ *
+ *
+ */
+public class ODataExpressionParser {
+
+ public static final String EMPTY = ""; //$NON-NLS-1$
+ public static Integer methodFlag = 0;
+
+ /**
+ * This method returns the parsed where condition corresponding to the filter input in the user query.
+ *
+ * @param whereExpression
+ *
+ * @return Parsed where condition String
+ * @throws ODataException
+ */
+
+ public static String parseToJPAWhereExpression(final CommonExpression whereExpression, final String tableAlias)
+ throws ODataException {
+ switch (whereExpression.getKind()) {
+ case UNARY:
+ final UnaryExpression unaryExpression = (UnaryExpression) whereExpression;
+ final String operand = parseToJPAWhereExpression(unaryExpression.getOperand(), tableAlias);
+
+ switch (unaryExpression.getOperator()) {
+ case NOT:
+ return JPQLStatement.Operator.NOT + "(" + operand + ")"; //$NON-NLS-1$ //$NON-NLS-2$
+ case MINUS:
+ if (operand.startsWith("-")) {
+ return operand.substring(1);
+ } else {
+ return "-" + operand; //$NON-NLS-1$
+ }
+ default:
+ throw new ODataNotImplementedException();
+ }
+
+ case FILTER:
+ return parseToJPAWhereExpression(((FilterExpression) whereExpression).getExpression(), tableAlias);
+ case BINARY:
+ final BinaryExpression binaryExpression = (BinaryExpression) whereExpression;
+ if ((binaryExpression.getLeftOperand().getKind() == ExpressionKind.METHOD)
+ && ((binaryExpression.getOperator() == BinaryOperator.EQ) ||
+ (binaryExpression.getOperator() == BinaryOperator.NE))
+ && (((MethodExpression) binaryExpression.getLeftOperand()).getMethod() == MethodOperator.SUBSTRINGOF)) {
+ methodFlag = 1;
+ }
+ final String left = parseToJPAWhereExpression(binaryExpression.getLeftOperand(), tableAlias);
+ final String right = parseToJPAWhereExpression(binaryExpression.getRightOperand(), tableAlias);
+
+ switch (binaryExpression.getOperator()) {
+ case AND:
+ return left + JPQLStatement.DELIMITER.SPACE + JPQLStatement.Operator.AND + JPQLStatement.DELIMITER.SPACE
+ + right;
+ case OR:
+ return left + JPQLStatement.DELIMITER.SPACE + JPQLStatement.Operator.OR + JPQLStatement.DELIMITER.SPACE + right;
+ case EQ:
+ return left + JPQLStatement.DELIMITER.SPACE + JPQLStatement.Operator.EQ + JPQLStatement.DELIMITER.SPACE + right;
+ case NE:
+ return left + JPQLStatement.DELIMITER.SPACE + JPQLStatement.Operator.NE + JPQLStatement.DELIMITER.SPACE + right;
+ case LT:
+ return left + JPQLStatement.DELIMITER.SPACE + JPQLStatement.Operator.LT + JPQLStatement.DELIMITER.SPACE + right;
+ case LE:
+ return left + JPQLStatement.DELIMITER.SPACE + JPQLStatement.Operator.LE + JPQLStatement.DELIMITER.SPACE + right;
+ case GT:
+ return left + JPQLStatement.DELIMITER.SPACE + JPQLStatement.Operator.GT + JPQLStatement.DELIMITER.SPACE + right;
+ case GE:
+ return left + JPQLStatement.DELIMITER.SPACE + JPQLStatement.Operator.GE + JPQLStatement.DELIMITER.SPACE + right;
+ case PROPERTY_ACCESS:
+ throw new ODataNotImplementedException();
+ default:
+ throw new ODataNotImplementedException();
+ }
+
+ case PROPERTY:
+ String returnStr =
+ tableAlias + JPQLStatement.DELIMITER.PERIOD
+ + ((EdmProperty) ((PropertyExpression) whereExpression).getEdmProperty()).getMapping().getInternalName();
+ return returnStr;
+
+ case MEMBER:
+ String memberExpStr = EMPTY;
+ int i = 0;
+ MemberExpression member = null;
+ CommonExpression tempExp = whereExpression;
+ while (tempExp != null && tempExp.getKind() == ExpressionKind.MEMBER) {
+ member = (MemberExpression) tempExp;
+ if (i > 0) {
+ memberExpStr = JPQLStatement.DELIMITER.PERIOD + memberExpStr;
+ }
+ i++;
+ memberExpStr =
+ ((EdmProperty) ((PropertyExpression) member.getProperty()).getEdmProperty()).getMapping().getInternalName()
+ + memberExpStr;
+ tempExp = member.getPath();
+ }
+ memberExpStr =
+ ((EdmProperty) ((PropertyExpression) tempExp).getEdmProperty()).getMapping().getInternalName()
+ + JPQLStatement.DELIMITER.PERIOD + memberExpStr;
+ return tableAlias + JPQLStatement.DELIMITER.PERIOD + memberExpStr;
+
+ case LITERAL:
+ final LiteralExpression literal = (LiteralExpression) whereExpression;
+ final EdmSimpleType literalType = (EdmSimpleType) literal.getEdmType();
+ String value =
+ literalType.valueToString(literalType.valueOfString(literal.getUriLiteral(), EdmLiteralKind.URI, null,
+ literalType.getDefaultType()), EdmLiteralKind.DEFAULT, null);
+ return evaluateComparingExpression(value, literalType);
+
+ case METHOD:
+ final MethodExpression methodExpression = (MethodExpression) whereExpression;
+ String first = parseToJPAWhereExpression(methodExpression.getParameters().get(0), tableAlias);
+ final String second =
+ methodExpression.getParameterCount() > 1 ? parseToJPAWhereExpression(methodExpression.getParameters().get(1),
+ tableAlias) : null;
+ String third =
+ methodExpression.getParameterCount() > 2 ? parseToJPAWhereExpression(methodExpression.getParameters().get(2),
+ tableAlias) : null;
+
+ switch (methodExpression.getMethod()) {
+ case SUBSTRING:
+ third = third != null ? ", " + third : "";
+ return String.format("SUBSTRING(%s, %s + 1 %s)", first, second, third);
+ case SUBSTRINGOF:
+ first = first.substring(1, first.length() - 1);
+ if (methodFlag == 1) {
+ methodFlag = 0;
+ return String.format("(CASE WHEN (%s LIKE '%%%s%%') THEN TRUE ELSE FALSE END)", second, first);
+ } else {
+ return String.format("(CASE WHEN (%s LIKE '%%%s%%') THEN TRUE ELSE FALSE END) = true", second, first);
+ }
+ case TOLOWER:
+ return String.format("LOWER(%s)", first);
+ default:
+ throw new ODataNotImplementedException();
+ }
+
+ default:
+ throw new ODataNotImplementedException();
+ }
+ }
+
+ /**
+ * This method parses the select clause
+ *
+ * @param tableAlias
+ * @param selectedFields
+ * @return a select expression
+ */
+ public static String parseToJPASelectExpression(final String tableAlias, final ArrayList<String> selectedFields) {
+
+ if ((selectedFields == null) || (selectedFields.size() == 0)) {
+ return tableAlias;
+ }
+
+ String selectClause = EMPTY;
+ Iterator<String> itr = selectedFields.iterator();
+ int count = 0;
+
+ while (itr.hasNext()) {
+ selectClause = selectClause + tableAlias + JPQLStatement.DELIMITER.PERIOD + itr.next();
+ count++;
+
+ if (count < selectedFields.size()) {
+ selectClause = selectClause + JPQLStatement.DELIMITER.COMMA + JPQLStatement.DELIMITER.SPACE;
+ }
+ }
+ return selectClause;
+ }
+
+ /**
+ * This method parses the order by condition in the query.
+ *
+ * @param orderByExpression
+ * @return a map of JPA attributes and their sort order
+ * @throws ODataJPARuntimeException
+ */
+ public static HashMap<String, String> parseToJPAOrderByExpression(final OrderByExpression orderByExpression,
+ final String tableAlias) throws ODataJPARuntimeException {
+ HashMap<String, String> orderByMap = new HashMap<String, String>();
+ if (orderByExpression != null && orderByExpression.getOrders() != null) {
+ List<OrderExpression> orderBys = orderByExpression.getOrders();
+ String orderByField = null;
+ String orderByDirection = null;
+ for (OrderExpression orderBy : orderBys) {
+
+ try {
+ orderByField =
+ ((EdmProperty) ((PropertyExpression) orderBy.getExpression()).getEdmProperty()).getMapping()
+ .getInternalName();
+ orderByDirection = (orderBy.getSortOrder() == SortOrder.asc) ? EMPTY : "DESC"; //$NON-NLS-1$
+ orderByMap.put(tableAlias + JPQLStatement.DELIMITER.PERIOD + orderByField, orderByDirection);
+ } catch (EdmException e) {
+ throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e);
+ }
+ }
+ }
+ return orderByMap;
+ }
+
+ /**
+ * This method evaluated the where expression for read of an entity based on the keys specified in the query.
+ *
+ * @param keyPredicates
+ * @return the evaluated where expression
+ */
+
+ public static String parseKeyPredicates(final List<KeyPredicate> keyPredicates, final String tableAlias)
+ throws ODataJPARuntimeException {
+ String literal = null;
+ String propertyName = null;
+ EdmSimpleType edmSimpleType = null;
+ StringBuilder keyFilters = new StringBuilder();
+ int i = 0;
+ for (KeyPredicate keyPredicate : keyPredicates) {
+ if (i > 0) {
+ keyFilters.append(JPQLStatement.DELIMITER.SPACE + JPQLStatement.Operator.AND + JPQLStatement.DELIMITER.SPACE);
+ }
+ i++;
+ literal = keyPredicate.getLiteral();
+ try {
+ propertyName = keyPredicate.getProperty().getMapping().getInternalName();
+ edmSimpleType = (EdmSimpleType) keyPredicate.getProperty().getType();
+ } catch (EdmException e) {
+ throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e);
+ }
+
+ literal = evaluateComparingExpression(literal, edmSimpleType);
+
+ if (edmSimpleType == EdmSimpleTypeKind.DateTime.getEdmSimpleTypeInstance()
+ || edmSimpleType == EdmSimpleTypeKind.DateTimeOffset.getEdmSimpleTypeInstance()) {
+ literal = literal.substring(literal.indexOf('\''), literal.indexOf('}'));
+ }
+
+ keyFilters.append(tableAlias + JPQLStatement.DELIMITER.PERIOD + propertyName + JPQLStatement.DELIMITER.SPACE
+ + JPQLStatement.Operator.EQ + JPQLStatement.DELIMITER.SPACE + literal);
+ }
+ if (keyFilters.length() > 0) {
+ return keyFilters.toString();
+ } else {
+ return null;
+ }
+ }
+
+ /**
+ * This method evaluates the expression based on the type instance. Used for adding escape characters where necessary.
+ *
+ * @param value
+ * @param edmSimpleType
+ * @return the evaluated expression
+ * @throws ODataJPARuntimeException
+ */
+ private static String evaluateComparingExpression(String value, final EdmSimpleType edmSimpleType)
+ throws ODataJPARuntimeException {
+
+ if (edmSimpleType == EdmSimpleTypeKind.String.getEdmSimpleTypeInstance()
+ || edmSimpleType == EdmSimpleTypeKind.Guid.getEdmSimpleTypeInstance()) {
+ value = "\'" + value + "\'"; //$NON-NLS-1$ //$NON-NLS-2$
+ } else if (edmSimpleType == EdmSimpleTypeKind.DateTime.getEdmSimpleTypeInstance()
+ || edmSimpleType == EdmSimpleTypeKind.DateTimeOffset.getEdmSimpleTypeInstance()) {
+ try {
+ Calendar datetime =
+ (Calendar) edmSimpleType.valueOfString(value, EdmLiteralKind.DEFAULT, null, edmSimpleType.getDefaultType());
+
+ String year = String.format("%04d", datetime.get(Calendar.YEAR));
+ String month = String.format("%02d", datetime.get(Calendar.MONTH) + 1);
+ String day = String.format("%02d", datetime.get(Calendar.DAY_OF_MONTH));
+ String hour = String.format("%02d", datetime.get(Calendar.HOUR_OF_DAY));
+ String min = String.format("%02d", datetime.get(Calendar.MINUTE));
+ String sec = String.format("%02d", datetime.get(Calendar.SECOND));
+
+ value =
+ JPQLStatement.DELIMITER.LEFT_BRACE + JPQLStatement.KEYWORD.TIMESTAMP + JPQLStatement.DELIMITER.SPACE + "\'"
+ + year + JPQLStatement.DELIMITER.HYPHEN + month + JPQLStatement.DELIMITER.HYPHEN + day
+ + JPQLStatement.DELIMITER.SPACE + hour + JPQLStatement.DELIMITER.COLON + min
+ + JPQLStatement.DELIMITER.COLON + sec + JPQLStatement.KEYWORD.OFFSET + "\'"
+ + JPQLStatement.DELIMITER.RIGHT_BRACE;
+
+ } catch (EdmSimpleTypeException e) {
+ throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e);
+ }
+
+ } else if (edmSimpleType == EdmSimpleTypeKind.Time.getEdmSimpleTypeInstance()) {
+ try {
+ Calendar time =
+ (Calendar) edmSimpleType.valueOfString(value, EdmLiteralKind.DEFAULT, null, edmSimpleType.getDefaultType());
+
+ String hourValue = String.format("%02d", time.get(Calendar.HOUR_OF_DAY));
+ String minValue = String.format("%02d", time.get(Calendar.MINUTE));
+ String secValue = String.format("%02d", time.get(Calendar.SECOND));
+
+ value =
+ "\'" + hourValue + JPQLStatement.DELIMITER.COLON + minValue + JPQLStatement.DELIMITER.COLON + secValue
+ + "\'";
+ } catch (EdmSimpleTypeException e) {
+ throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e);
+ }
+
+ } else if (edmSimpleType == EdmSimpleTypeKind.Int64.getEdmSimpleTypeInstance()) {
+ value = value + JPQLStatement.DELIMITER.LONG; //$NON-NLS-1$
+ }
+ return value;
+ }
+
+ public static HashMap<String, String> parseKeyPropertiesToJPAOrderByExpression(
+ final List<EdmProperty> edmPropertylist, final String tableAlias) throws ODataJPARuntimeException {
+ HashMap<String, String> orderByMap = new HashMap<String, String>();
+ String propertyName = null;
+ for (EdmProperty edmProperty : edmPropertylist) {
+ try {
+ EdmMapping mapping = edmProperty.getMapping();
+ if (mapping != null && mapping.getInternalName() != null) {
+ propertyName = mapping.getInternalName();// For embedded/complex keys
+ } else {
+ propertyName = edmProperty.getName();
+ }
+ } catch (EdmException e) {
+ throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e);
+ }
+ orderByMap.put(tableAlias + JPQLStatement.DELIMITER.PERIOD + propertyName, EMPTY);
+ }
+ return orderByMap;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/ODataJPAContextImpl.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/ODataJPAContextImpl.java b/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/ODataJPAContextImpl.java
new file mode 100644
index 0000000..5529d2c
--- /dev/null
+++ b/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/ODataJPAContextImpl.java
@@ -0,0 +1,146 @@
+/*******************************************************************************
+ * 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;
+
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+
+import org.apache.olingo.odata2.api.edm.provider.EdmProvider;
+import org.apache.olingo.odata2.api.processor.ODataContext;
+import org.apache.olingo.odata2.api.processor.ODataProcessor;
+import org.apache.olingo.odata2.processor.api.jpa.ODataJPAContext;
+import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmExtension;
+
+public class ODataJPAContextImpl implements ODataJPAContext {
+
+ private String pUnitName;
+ private EntityManagerFactory emf;
+ private EntityManager em;
+ private ODataContext odataContext;
+ private ODataProcessor processor;
+ private EdmProvider edmProvider;
+ private String jpaEdmMappingModelName;
+ private JPAEdmExtension jpaEdmExtension;
+ private static final ThreadLocal<ODataContext> oDataContextThreadLocal = new ThreadLocal<ODataContext>();
+ private boolean defaultNaming = true;
+
+ @Override
+ public String getPersistenceUnitName() {
+ return pUnitName;
+ }
+
+ @Override
+ public void setPersistenceUnitName(final String pUnitName) {
+ this.pUnitName = pUnitName;
+ }
+
+ @Override
+ public EntityManagerFactory getEntityManagerFactory() {
+ return emf;
+ }
+
+ @Override
+ public void setEntityManagerFactory(final EntityManagerFactory emf) {
+ this.emf = emf;
+ }
+
+ @Override
+ public void setODataContext(final ODataContext ctx) {
+ odataContext = ctx;
+ setContextInThreadLocal(odataContext);
+ }
+
+ @Override
+ public ODataContext getODataContext() {
+ return odataContext;
+ }
+
+ @Override
+ public void setODataProcessor(final ODataProcessor processor) {
+ this.processor = processor;
+ }
+
+ @Override
+ public ODataProcessor getODataProcessor() {
+ return processor;
+ }
+
+ @Override
+ public void setEdmProvider(final EdmProvider edmProvider) {
+ this.edmProvider = edmProvider;
+ }
+
+ @Override
+ public EdmProvider getEdmProvider() {
+ return edmProvider;
+ }
+
+ @Override
+ public void setJPAEdmMappingModel(final String name) {
+ jpaEdmMappingModelName = name;
+
+ }
+
+ @Override
+ public String getJPAEdmMappingModel() {
+ return jpaEdmMappingModelName;
+ }
+
+ public static void setContextInThreadLocal(final ODataContext ctx) {
+ oDataContextThreadLocal.set(ctx);
+ }
+
+ public static void unsetContextInThreadLocal() {
+ oDataContextThreadLocal.remove();
+ }
+
+ public static ODataContext getContextInThreadLocal() {
+ return (ODataContext) oDataContextThreadLocal.get();
+ }
+
+ @Override
+ public EntityManager getEntityManager() {
+ if (em == null) {
+ em = emf.createEntityManager();
+ }
+
+ return em;
+ }
+
+ @Override
+ public void setJPAEdmExtension(final JPAEdmExtension jpaEdmExtension) {
+ this.jpaEdmExtension = jpaEdmExtension;
+
+ }
+
+ @Override
+ public JPAEdmExtension getJPAEdmExtension() {
+ return jpaEdmExtension;
+ }
+
+ @Override
+ public void setDefaultNaming(final boolean defaultNaming) {
+ this.defaultNaming = defaultNaming;
+ }
+
+ @Override
+ public boolean getDefaultNaming() {
+ return defaultNaming;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/ODataJPAProcessorDefault.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/ODataJPAProcessorDefault.java b/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/ODataJPAProcessorDefault.java
new file mode 100644
index 0000000..1d5929d
--- /dev/null
+++ b/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/ODataJPAProcessorDefault.java
@@ -0,0 +1,194 @@
+/*******************************************************************************
+ * 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;
+
+import java.io.InputStream;
+import java.util.List;
+
+import org.apache.olingo.odata2.api.exception.ODataException;
+import org.apache.olingo.odata2.api.processor.ODataResponse;
+import org.apache.olingo.odata2.api.uri.info.DeleteUriInfo;
+import org.apache.olingo.odata2.api.uri.info.GetEntityCountUriInfo;
+import org.apache.olingo.odata2.api.uri.info.GetEntityLinkUriInfo;
+import org.apache.olingo.odata2.api.uri.info.GetEntitySetCountUriInfo;
+import org.apache.olingo.odata2.api.uri.info.GetEntitySetLinksUriInfo;
+import org.apache.olingo.odata2.api.uri.info.GetEntitySetUriInfo;
+import org.apache.olingo.odata2.api.uri.info.GetEntityUriInfo;
+import org.apache.olingo.odata2.api.uri.info.GetFunctionImportUriInfo;
+import org.apache.olingo.odata2.api.uri.info.PostUriInfo;
+import org.apache.olingo.odata2.api.uri.info.PutMergePatchUriInfo;
+import org.apache.olingo.odata2.processor.api.jpa.ODataJPAContext;
+import org.apache.olingo.odata2.processor.api.jpa.ODataJPAProcessor;
+import org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPAException;
+
+public class ODataJPAProcessorDefault extends ODataJPAProcessor {
+
+ public ODataJPAProcessorDefault(final ODataJPAContext oDataJPAContext) {
+ super(oDataJPAContext);
+ if (oDataJPAContext == null) {
+ throw new IllegalArgumentException(ODataJPAException.ODATA_JPACTX_NULL);
+ }
+ }
+
+ @Override
+ public ODataResponse readEntitySet(final GetEntitySetUriInfo uriParserResultView, final String contentType)
+ throws ODataException {
+
+ List<?> jpaEntities = jpaProcessor.process(uriParserResultView);
+
+ ODataResponse oDataResponse =
+ ODataJPAResponseBuilder.build(jpaEntities, uriParserResultView, contentType, oDataJPAContext);
+
+ return oDataResponse;
+ }
+
+ @Override
+ public ODataResponse readEntity(final GetEntityUriInfo uriParserResultView, final String contentType)
+ throws ODataException {
+
+ Object jpaEntity = jpaProcessor.process(uriParserResultView);
+
+ ODataResponse oDataResponse =
+ ODataJPAResponseBuilder.build(jpaEntity, uriParserResultView, contentType, oDataJPAContext);
+
+ return oDataResponse;
+ }
+
+ @Override
+ public ODataResponse countEntitySet(final GetEntitySetCountUriInfo uriParserResultView, final String contentType)
+ throws ODataException {
+
+ long jpaEntityCount = jpaProcessor.process(uriParserResultView);
+
+ ODataResponse oDataResponse = ODataJPAResponseBuilder.build(jpaEntityCount, oDataJPAContext);
+
+ return oDataResponse;
+ }
+
+ @Override
+ public ODataResponse existsEntity(final GetEntityCountUriInfo uriInfo, final String contentType)
+ throws ODataException {
+
+ long jpaEntityCount = jpaProcessor.process(uriInfo);
+
+ ODataResponse oDataResponse = ODataJPAResponseBuilder.build(jpaEntityCount, oDataJPAContext);
+
+ return oDataResponse;
+ }
+
+ @Override
+ public ODataResponse createEntity(final PostUriInfo uriParserResultView, final InputStream content,
+ final String requestContentType, final String contentType) throws ODataException {
+
+ List<Object> createdJpaEntityList = jpaProcessor.process(uriParserResultView, content, requestContentType);
+
+ ODataResponse oDataResponse =
+ ODataJPAResponseBuilder.build(createdJpaEntityList, uriParserResultView, contentType, oDataJPAContext);
+
+ return oDataResponse;
+ }
+
+ @Override
+ public ODataResponse updateEntity(final PutMergePatchUriInfo uriParserResultView, final InputStream content,
+ final String requestContentType, final boolean merge, final String contentType) throws ODataException {
+
+ Object jpaEntity = jpaProcessor.process(uriParserResultView, content, requestContentType);
+
+ ODataResponse oDataResponse = ODataJPAResponseBuilder.build(jpaEntity, uriParserResultView);
+
+ return oDataResponse;
+ }
+
+ @Override
+ public ODataResponse deleteEntity(final DeleteUriInfo uriParserResultView, final String contentType)
+ throws ODataException {
+
+ Object deletedObj = jpaProcessor.process(uriParserResultView, contentType);
+
+ ODataResponse oDataResponse = ODataJPAResponseBuilder.build(deletedObj, uriParserResultView);
+ return oDataResponse;
+ }
+
+ @Override
+ public ODataResponse executeFunctionImport(final GetFunctionImportUriInfo uriParserResultView,
+ final String contentType) throws ODataException {
+
+ List<Object> resultEntity = jpaProcessor.process(uriParserResultView);
+
+ ODataResponse oDataResponse =
+ ODataJPAResponseBuilder.build(resultEntity, uriParserResultView, contentType, oDataJPAContext);
+
+ return oDataResponse;
+ }
+
+ @Override
+ public ODataResponse executeFunctionImportValue(final GetFunctionImportUriInfo uriParserResultView,
+ final String contentType) throws ODataException {
+
+ List<Object> result = jpaProcessor.process(uriParserResultView);
+
+ ODataResponse oDataResponse =
+ ODataJPAResponseBuilder.build(result, uriParserResultView, contentType, oDataJPAContext);
+
+ return oDataResponse;
+ }
+
+ @Override
+ public ODataResponse readEntityLink(final GetEntityLinkUriInfo uriParserResultView, final String contentType)
+ throws ODataException {
+
+ Object jpaEntity = jpaProcessor.process(uriParserResultView);
+
+ ODataResponse oDataResponse =
+ ODataJPAResponseBuilder.build(jpaEntity, uriParserResultView, contentType, oDataJPAContext);
+
+ return oDataResponse;
+ }
+
+ @Override
+ public ODataResponse readEntityLinks(final GetEntitySetLinksUriInfo uriParserResultView, final String contentType)
+ throws ODataException {
+
+ List<Object> jpaEntity = jpaProcessor.process(uriParserResultView);
+
+ ODataResponse oDataResponse =
+ ODataJPAResponseBuilder.build(jpaEntity, uriParserResultView, contentType, oDataJPAContext);
+
+ return oDataResponse;
+ }
+
+ @Override
+ public ODataResponse createEntityLink(final PostUriInfo uriParserResultView, final InputStream content,
+ final String requestContentType, final String contentType) throws ODataException {
+
+ jpaProcessor.process(uriParserResultView, content, requestContentType, contentType);
+
+ return ODataResponse.newBuilder().build();
+ }
+
+ @Override
+ public ODataResponse updateEntityLink(final PutMergePatchUriInfo uriParserResultView, final InputStream content,
+ final String requestContentType, final String contentType) throws ODataException {
+
+ jpaProcessor.process(uriParserResultView, content, requestContentType, contentType);
+
+ return ODataResponse.newBuilder().build();
+ }
+
+}
[05/37] [OLINGO-82] Renamed the project folder name to
odata2-jpa-processor
Posted by ch...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmAssociationSetTest.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmAssociationSetTest.java b/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmAssociationSetTest.java
deleted file mode 100644
index 965d3d7..0000000
--- a/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmAssociationSetTest.java
+++ /dev/null
@@ -1,184 +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.model;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.olingo.odata2.api.edm.FullQualifiedName;
-import org.apache.olingo.odata2.api.edm.provider.Association;
-import org.apache.olingo.odata2.api.edm.provider.AssociationEnd;
-import org.apache.olingo.odata2.api.edm.provider.AssociationSet;
-import org.apache.olingo.odata2.api.edm.provider.AssociationSetEnd;
-import org.apache.olingo.odata2.api.edm.provider.EntitySet;
-import org.apache.olingo.odata2.api.edm.provider.Schema;
-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.JPAEdmAssociationView;
-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.core.jpa.common.ODataJPATestConstants;
-import org.junit.Before;
-import org.junit.Test;
-
-public class JPAEdmAssociationSetTest extends JPAEdmTestModelView {
-
- private JPAEdmAssociationSetTest objJPAEdmAssociationSetTest;
- private JPAEdmAssociationSet objJPAEdmAssociationSet;
-
- @Before
- public void setUp() {
- objJPAEdmAssociationSetTest = new JPAEdmAssociationSetTest();
- objJPAEdmAssociationSet = new JPAEdmAssociationSet(objJPAEdmAssociationSetTest);
- try {
- objJPAEdmAssociationSet.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);
- }
-
- }
-
- @Test
- public void testGetBuilder() {
- assertNotNull(objJPAEdmAssociationSet.getBuilder());
- }
-
- @Test
- public void testGetConsistentEdmAssociationSetList() {
- assertNotNull(objJPAEdmAssociationSet.getConsistentEdmAssociationSetList());
- }
-
- @Test
- public void testGetEdmAssociationSet() {
- assertNotNull(objJPAEdmAssociationSet.getEdmAssociationSet());
- }
-
- @Test
- public void testGetEdmAssociation() {
- assertNotNull(objJPAEdmAssociationSet.getEdmAssociation());
- }
-
- @Test
- public void testIsConsistent() {
- assertTrue(objJPAEdmAssociationSet.isConsistent());
- }
-
- @Test
- public void testGetBuilderIdempotent() {
- JPAEdmBuilder builder1 = objJPAEdmAssociationSet.getBuilder();
- JPAEdmBuilder builder2 = objJPAEdmAssociationSet.getBuilder();
-
- assertEquals(builder1.hashCode(), builder2.hashCode());
- }
-
- @Override
- public JPAEdmEntityContainerView getJPAEdmEntityContainerView() {
- return this;
- }
-
- @Override
- public JPAEdmEntitySetView getJPAEdmEntitySetView() {
- return this;
- }
-
- @Override
- public JPAEdmAssociationView getJPAEdmAssociationView() {
- return this;
- }
-
- @Override
- public AssociationSet getEdmAssociationSet() {
- AssociationSet associationSet = new AssociationSet();
- associationSet.setEnd1(new AssociationSetEnd());
- associationSet.setEnd2(new AssociationSetEnd());
-
- return associationSet;
- }
-
- @Override
- public List<Association> getConsistentEdmAssociationList() {
- return getEdmAssociationListLocal();
- }
-
- @Override
- public List<AssociationSet> getConsistentEdmAssociationSetList() {
-
- List<AssociationSet> associationSetList = new ArrayList<AssociationSet>();
- associationSetList.add(getEdmAssociationSet());
- associationSetList.add(getEdmAssociationSet());
-
- return associationSetList;
- }
-
- @Override
- public List<EntitySet> getConsistentEdmEntitySetList() {
- return getEntitySetListLocal();
- }
-
- @Override
- public boolean isConsistent() {
- return true;
- }
-
- @Override
- public Schema getEdmSchema() {
- Schema schema = new Schema();
- schema.setNamespace("salesordereprocessing");
- return schema;
- }
-
- private List<EntitySet> getEntitySetListLocal() {
- List<EntitySet> entitySetList = new ArrayList<EntitySet>();
-
- EntitySet entitySet = new EntitySet();
- entitySet.setName("SalesOrderHeader");
- entitySet.setEntityType(new FullQualifiedName("salesorderprocessing", "SOID"));
-
- EntitySet entitySet2 = new EntitySet();
- entitySet2.setName("SalesOrderItem");
- entitySet2.setEntityType(new FullQualifiedName("salesorderprocessing", "SOID"));
-
- entitySetList.add(entitySet);
- entitySetList.add(entitySet2);
- return entitySetList;
- }
-
- private List<Association> getEdmAssociationListLocal() {
- List<Association> associationList = new ArrayList<Association>();
-
- Association association = new Association();
- association.setName("Assoc_SalesOrderHeader_SalesOrderItem");
- association.setEnd1(new AssociationEnd().setType(new FullQualifiedName("salesorderprocessing", "String")).setRole(
- "SalesOrderHeader"));
- association.setEnd2(new AssociationEnd().setType(new FullQualifiedName("salesorderprocessing", "SalesOrderItem"))
- .setRole("SalesOrderItem"));
-
- associationList.add(association);
- return associationList;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmAssociationTest.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmAssociationTest.java b/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmAssociationTest.java
deleted file mode 100644
index f7c8f47..0000000
--- a/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmAssociationTest.java
+++ /dev/null
@@ -1,422 +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.model;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import java.lang.annotation.Annotation;
-import java.lang.reflect.AnnotatedElement;
-import java.lang.reflect.Field;
-import java.lang.reflect.Member;
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.persistence.JoinColumn;
-import javax.persistence.OneToMany;
-import javax.persistence.metamodel.Attribute;
-
-import org.apache.olingo.odata2.api.edm.EdmMultiplicity;
-import org.apache.olingo.odata2.api.edm.FullQualifiedName;
-import org.apache.olingo.odata2.api.edm.provider.Association;
-import org.apache.olingo.odata2.api.edm.provider.AssociationEnd;
-import org.apache.olingo.odata2.api.edm.provider.EntityType;
-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.JPAEdmAssociationEndView;
-import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmReferentialConstraintView;
-import org.apache.olingo.odata2.processor.core.jpa.common.ODataJPATestConstants;
-import org.apache.olingo.odata2.processor.core.jpa.mock.model.JPAAttributeMock;
-import org.apache.olingo.odata2.processor.core.jpa.mock.model.JPAEdmMockData.SimpleType;
-import org.apache.olingo.odata2.processor.core.jpa.mock.model.JPAEdmMockData.SimpleType.SimpleTypeA;
-import org.easymock.EasyMock;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-public class JPAEdmAssociationTest extends JPAEdmTestModelView {
-
- private static JPAEdmAssociation objAssociation = null;
- private static String ASSOCIATION_NAME = "SalesOrderHeader_String";
- private static JPAEdmAssociationTest localView = null;
- private static final String PUNIT_NAME = "salesorderprocessing";
- private int variant;
-
- @BeforeClass
- public static void setup() {
- localView = new JPAEdmAssociationTest();
- objAssociation = new JPAEdmAssociation(localView, localView, localView, 1);
- try {
- objAssociation.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);
- }
- }
-
- @Override
- public AssociationEnd getEdmAssociationEnd1() {
- AssociationEnd associationEnd = new AssociationEnd();
- associationEnd.setType(new FullQualifiedName("salesorderprocessing", "SalesOrderHeader"));
- associationEnd.setRole("SalesOrderHeader");
- associationEnd.setMultiplicity(EdmMultiplicity.ONE);
- return associationEnd;
- }
-
- @Override
- public AssociationEnd getEdmAssociationEnd2() {
- AssociationEnd associationEnd = new AssociationEnd();
- associationEnd.setType(new FullQualifiedName("salesorderprocessing", "String"));
- associationEnd.setRole("String");
- associationEnd.setMultiplicity(EdmMultiplicity.MANY);
- return associationEnd;
- }
-
- @Override
- public Association getEdmAssociation() {
- Association association = new Association();
- association
- .setEnd1(new AssociationEnd().setType(new FullQualifiedName("salesorderprocessing", "SalesOrderHeader")));
- association.setEnd2(new AssociationEnd().setType(new FullQualifiedName("salesorderprocessing", "String")));
-
- return association;
- }
-
- @Override
- public boolean isExists() {
- return true;
- }
-
- @Override
- public JPAEdmReferentialConstraintView getJPAEdmReferentialConstraintView() {
- JPAEdmReferentialConstraint refConstraintView = new JPAEdmReferentialConstraint(localView, localView, localView);
- return refConstraintView;
- }
-
- @Override
- public Attribute<?, ?> getJPAAttribute() {
- return getJPAAttributeLocal();
- }
-
- @Override
- public String getpUnitName() {
- return PUNIT_NAME;
- }
-
- @Override
- public EntityType getEdmEntityType() {
- EntityType entityType = new EntityType();
- entityType.setName(SimpleTypeA.NAME);
- return entityType;
- }
-
- // The inner class which gives us an replica of the jpa attribute
- @SuppressWarnings("hiding")
- private class AttributeMock<Object, String> extends JPAAttributeMock<Object, String> {
-
- @SuppressWarnings("unchecked")
- @Override
- public Class<String> getJavaType() {
- return (Class<String>) SimpleType.SimpleTypeA.clazz;
- }
-
- @Override
- public PersistentAttributeType getPersistentAttributeType() {
- if (variant == 1) {
- return PersistentAttributeType.ONE_TO_MANY;
- } else if (variant == 2) {
- return PersistentAttributeType.ONE_TO_ONE;
- } else if (variant == 2) {
- return PersistentAttributeType.MANY_TO_ONE;
- } else {
- return PersistentAttributeType.MANY_TO_MANY;
- }
-
- }
- }
-
- private Attribute<?, ?> getJPAAttributeLocal() {
- AttributeMock<Object, String> attr = new AttributeMock<Object, String>();
- return attr;
- }
-
- @Test
- public void testGetBuilder() {
- assertNotNull(objAssociation.getBuilder());
- }
-
- @Test
- public void testGetEdmAssociation() {
- assertNotNull(objAssociation.getEdmAssociation());
- assertEquals(objAssociation.getEdmAssociation().getName(), ASSOCIATION_NAME);
- }
-
- @Test
- public void testGetConsistentEdmAssociationList() {
- assertTrue(objAssociation.getConsistentEdmAssociationList().size() > 0);
- }
-
- @Override
- public String getEdmRelationShipName() {
- return "Association_SalesOrderHeader_String";
- }
-
- @Test
- public void testSearchAssociation1() {
- class TestAssociationEndView extends JPAEdmTestModelView {
- @Override
- public String getEdmRelationShipName() {
- return "SalesOrderHeader_String1";
- }
-
- private Attribute<?, ?> getJPAAttributeLocal() {
- AttributeMock<Object, String> attr = new AttributeMock<Object, String>();
- return attr;
- }
-
- @Override
- public Attribute<?, ?> getJPAAttribute() {
- return getJPAAttributeLocal();
- }
-
- @Override
- public String getJoinColumnName() {
- return "SO_ID";
- }
-
- @Override
- public String getJoinColumnReferenceColumnName() {
- return "DEMO_ID";
- }
-
- @Override
- public String getMappedByName() {
- return "demo";
- }
-
- @Override
- public String getOwningPropertyName() {
- return "salesOrder";
- }
-
- @Override
- public int getNumberOfAssociationsWithSimilarEndPoints(final JPAEdmAssociationEndView view) {
- return 1;
- }
-
- @Override
- public String getpUnitName() {
- return "salesorderprocessing";
- }
-
- @Override
- public EntityType getEdmEntityType() {
- EntityType entityType = new EntityType();
- entityType.setName("SalesOrderHeader");
- return entityType;
- }
-
- @SuppressWarnings("hiding")
- class AttributeMock<Object, String> extends JPAAttributeMock<Object, String> {
-
- @SuppressWarnings("unchecked")
- @Override
- public Class<String> getJavaType() {
- return (Class<String>) SimpleType.SimpleTypeA.clazz;
- }
-
- @Override
- public PersistentAttributeType getPersistentAttributeType() {
-
- return PersistentAttributeType.ONE_TO_MANY;
-
- }
-
- @Override
- public Member getJavaMember() {
- return new AnnotatedElementMock();
- }
-
- @Override
- public java.lang.String getName() {
- // TODO Auto-generated method stub
- return super.getName();
- }
-
- class AnnotatedElementMock implements AnnotatedElement, Member {
-
- @Override
- public boolean isAnnotationPresent(final Class<? extends Annotation> annotationClass) {
- return true;
- }
-
- @SuppressWarnings("unchecked")
- @Override
- public Annotation getAnnotation(@SuppressWarnings("rawtypes") final Class annotationClass) {
- if (annotationClass.equals(JoinColumn.class)) {
- JoinColumn joinColumn = EasyMock.createMock(JoinColumn.class);
- EasyMock.expect(joinColumn.name()).andStubReturn("SO_ID");
- EasyMock.expect(joinColumn.referencedColumnName()).andStubReturn("DEMO_ID");
- EasyMock.replay(joinColumn);
- return joinColumn;
- } else {
- OneToMany oneToMany = EasyMock.createMock(OneToMany.class);
- EasyMock.expect(oneToMany.mappedBy()).andStubReturn("demo");
- EasyMock.replay(oneToMany);
- return oneToMany;
- }
- }
-
- @Override
- public Annotation[] getAnnotations() {
- return null;
- }
-
- @Override
- public Annotation[] getDeclaredAnnotations() {
- return null;
- }
-
- @Override
- public Class<?> getDeclaringClass() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public java.lang.String getName() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public int getModifiers() {
- // TODO Auto-generated method stub
- return 0;
- }
-
- @Override
- public boolean isSynthetic() {
- // TODO Auto-generated method stub
- return false;
- }
-
- }
-
- }
- }
- TestAssociationEndView objJPAEdmAssociationEndTest = new TestAssociationEndView();
- JPAEdmAssociationEnd objJPAEdmAssociationEnd =
- new JPAEdmAssociationEnd(objJPAEdmAssociationEndTest, objJPAEdmAssociationEndTest);
- try {
- objJPAEdmAssociationEnd.getBuilder().build();
- Field field = objAssociation.getClass().getDeclaredField("associationEndMap");
- field.setAccessible(true);
- Map<String, JPAEdmAssociationEndView> associationEndMap = new HashMap<String, JPAEdmAssociationEndView>();
- associationEndMap.put("SalesOrderHeader_String", objJPAEdmAssociationEnd);
- field.set(objAssociation, associationEndMap);
- } catch (ODataJPARuntimeException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- } catch (ODataJPAModelException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- } catch (SecurityException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- } catch (NoSuchFieldException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- } catch (IllegalArgumentException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- } catch (IllegalAccessException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
-
- assertEquals("SalesOrderHeader_String", objAssociation.searchAssociation(objJPAEdmAssociationEnd).getName());
-
- }
-
- @Test
- public void testAddJPAEdmAssociationView() {
-
- class LocalJPAAssociationView extends JPAEdmTestModelView {
- @Override
- public AssociationEnd getEdmAssociationEnd1() {
- AssociationEnd associationEnd = new AssociationEnd();
- associationEnd.setType(new FullQualifiedName("salesorderprocessing", "SalesOrderHeader"));
- associationEnd.setRole("SalesOrderHeader");
- associationEnd.setMultiplicity(EdmMultiplicity.ONE);
- return associationEnd;
- }
-
- @Override
- public AssociationEnd getEdmAssociationEnd2() {
- AssociationEnd associationEnd = new AssociationEnd();
- associationEnd.setType(new FullQualifiedName("salesorderprocessing", "SalesOrderItem"));
- associationEnd.setRole("SalesOrderItem");
- associationEnd.setMultiplicity(EdmMultiplicity.MANY);
- return associationEnd;
- }
-
- @Override
- public Association getEdmAssociation() {
- Association association = new Association();
- association.setEnd1(new AssociationEnd().setType(new FullQualifiedName("salesorderprocessing",
- "SalesOrderHeader")));
- association.setEnd2(new AssociationEnd()
- .setType(new FullQualifiedName("salesorderprocessing", "SalesOrderItem")));
-
- return association;
- }
- }
- LocalJPAAssociationView assocViewObj = new LocalJPAAssociationView();
- JPAEdmAssociation objLocalAssociation = new JPAEdmAssociation(assocViewObj, assocViewObj, assocViewObj, 1);
- try {
- objLocalAssociation.getBuilder().build();
- } catch (ODataJPARuntimeException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- } catch (ODataJPAModelException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
-
- objAssociation.addJPAEdmAssociationView(objLocalAssociation, localView);
-
- }
-
- @Test
- public void testAddJPAEdmRefConstraintView() {
-
- localView = new JPAEdmAssociationTest();
- objAssociation = new JPAEdmAssociation(localView, localView, localView, 1);
- try {
- objAssociation.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);
- }
-
- objAssociation.addJPAEdmRefConstraintView(localView);
- assertTrue(objAssociation.getConsistentEdmAssociationList().size() > 0);
- }
-
- @Test
- public void testGetJPAEdmReferentialConstraintView() {
-
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmBaseViewImplTest.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmBaseViewImplTest.java b/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmBaseViewImplTest.java
deleted file mode 100644
index bdbf104..0000000
--- a/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmBaseViewImplTest.java
+++ /dev/null
@@ -1,89 +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.model;
-
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-import javax.persistence.metamodel.Metamodel;
-
-import org.apache.olingo.odata2.processor.api.jpa.access.JPAEdmBuilder;
-import org.apache.olingo.odata2.processor.core.jpa.mock.model.JPAMetaModelMock;
-import org.junit.Before;
-import org.junit.Test;
-
-public class JPAEdmBaseViewImplTest extends JPAEdmTestModelView {
-
- private JPAEdmBaseViewImplTest objJPAEdmBaseViewImplTest;
- private JPAEdmBaseViewImpl objJPAEdmBaseViewImpl;
-
- @Before
- public void setUp() {
- objJPAEdmBaseViewImplTest = new JPAEdmBaseViewImplTest();
- objJPAEdmBaseViewImpl = new JPAEdmBaseViewImpl(objJPAEdmBaseViewImplTest) {
-
- @Override
- public JPAEdmBuilder getBuilder() {
- return null;
- }
- };
-
- objJPAEdmBaseViewImpl = new JPAEdmBaseViewImpl(getJPAMetaModel(), getpUnitName()) {
-
- @Override
- public JPAEdmBuilder getBuilder() {
- return null;
- }
- };
-
- }
-
- @Test
- public void testGetpUnitName() {
- assertTrue(objJPAEdmBaseViewImpl.getpUnitName().equals("salesorderprocessing"));
- }
-
- @Test
- public void testGetJPAMetaModel() {
- assertNotNull(objJPAEdmBaseViewImpl.getJPAMetaModel());
- }
-
- @Test
- public void testIsConsistent() {
- assertTrue(objJPAEdmBaseViewImpl.isConsistent());
- }
-
- @Test
- public void testClean() {
- objJPAEdmBaseViewImpl.clean();
- assertFalse(objJPAEdmBaseViewImpl.isConsistent());
- }
-
- @Override
- public String getpUnitName() {
- return "salesorderprocessing";
- }
-
- @Override
- public Metamodel getJPAMetaModel() {
- return new JPAMetaModelMock();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmComplexTypeTest.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmComplexTypeTest.java b/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmComplexTypeTest.java
deleted file mode 100644
index 2fabe8c..0000000
--- a/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmComplexTypeTest.java
+++ /dev/null
@@ -1,268 +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.model;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import javax.persistence.metamodel.Attribute;
-import javax.persistence.metamodel.EmbeddableType;
-import javax.persistence.metamodel.Metamodel;
-
-import org.apache.olingo.odata2.api.edm.FullQualifiedName;
-import org.apache.olingo.odata2.api.edm.provider.ComplexType;
-import org.apache.olingo.odata2.api.edm.provider.Mapping;
-import org.apache.olingo.odata2.api.edm.provider.Property;
-import org.apache.olingo.odata2.api.edm.provider.SimpleProperty;
-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.JPAEdmMapping;
-import org.apache.olingo.odata2.processor.core.jpa.common.ODataJPATestConstants;
-import org.apache.olingo.odata2.processor.core.jpa.mock.model.JPAEmbeddableMock;
-import org.apache.olingo.odata2.processor.core.jpa.mock.model.JPAMetaModelMock;
-import org.apache.olingo.odata2.processor.core.jpa.mock.model.JPASingularAttributeMock;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-public class JPAEdmComplexTypeTest extends JPAEdmTestModelView {
-
- private static JPAEdmComplexType objComplexType = null;
- private static JPAEdmComplexTypeTest localView = null;
-
- @BeforeClass
- public static void setup() {
- localView = new JPAEdmComplexTypeTest();
- objComplexType = new JPAEdmComplexType(localView);
- try {
- objComplexType.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);
- }
- }
-
- @SuppressWarnings("rawtypes")
- @Override
- public EmbeddableType<?> getJPAEmbeddableType() {
- @SuppressWarnings("hiding")
- class JPAComplexAttribute<Long> extends JPAEmbeddableMock<Long> {
-
- @SuppressWarnings("unchecked")
- @Override
- public Class<Long> getJavaType() {
-
- return (Class<Long>) java.lang.Long.class;
- }
-
- }
- return new JPAComplexAttribute();
- }
-
- @Override
- public String getpUnitName() {
- return "salesorderprocessing";
- }
-
- @Override
- public Metamodel getJPAMetaModel() {
- return new JPAEdmMetaModel();
- }
-
- @Test
- public void testGetBuilder() {
-
- assertNotNull(objComplexType.getBuilder());
- }
-
- @Test
- public void testGetEdmComplexType() {
- assertEquals(objComplexType.getEdmComplexType().getName(), "String");
- }
-
- @Test
- public void testSearchComplexTypeString() {
- assertNotNull(objComplexType.searchEdmComplexType("java.lang.String"));
-
- }
-
- @Test
- public void testGetJPAEmbeddableType() {
- assertTrue(objComplexType.getJPAEmbeddableType().getAttributes().size() > 0);
-
- }
-
- @Test
- public void testGetConsistentEdmComplexTypes() {
- assertTrue(objComplexType.getConsistentEdmComplexTypes().size() > 0);
- }
-
- @Test
- public void testSearchComplexTypeFullQualifiedName() {
- assertNotNull(objComplexType.searchEdmComplexType(new FullQualifiedName("salesorderprocessing", "String")));
-
- }
-
- @Test
- public void testSearchComplexTypeFullQualifiedNameNegative() {
- assertNull(objComplexType.searchEdmComplexType(new FullQualifiedName("salesorderprocessing", "lang.String")));
- }
-
- @Test
- public void testGetBuilderIdempotent() {
- JPAEdmBuilder builder1 = objComplexType.getBuilder();
- JPAEdmBuilder builder2 = objComplexType.getBuilder();
-
- assertEquals(builder1.hashCode(), builder2.hashCode());
- }
-
- @Test
- public void testAddCompleTypeView() {
- localView = new JPAEdmComplexTypeTest();
- objComplexType = new JPAEdmComplexType(localView);
- try {
- objComplexType.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);
- }
-
- objComplexType.addJPAEdmCompleTypeView(localView);
- assertTrue(objComplexType.getConsistentEdmComplexTypes().size() > 1);
- }
-
- @Test
- public void testExpandEdmComplexType() {
- ComplexType complexType = new ComplexType();
- List<Property> properties = new ArrayList<Property>();
- JPAEdmMapping mapping1 = new JPAEdmMappingImpl();
- mapping1.setJPAColumnName("LINEITEMID");
- ((Mapping) mapping1).setInternalName("LineItemKey.LiId");
- JPAEdmMapping mapping2 = new JPAEdmMappingImpl();
- mapping2.setJPAColumnName("LINEITEMNAME");
- ((Mapping) mapping2).setInternalName("LineItemKey.LiName");
- properties.add(new SimpleProperty().setName("LIID").setMapping((Mapping) mapping1));
- properties.add(new SimpleProperty().setName("LINAME").setMapping((Mapping) mapping2));
- complexType.setProperties(properties);
- List<Property> expandedList = null;
- try {
- objComplexType.expandEdmComplexType(complexType, expandedList, "SalesOrderItemKey");
- } catch (ClassCastException e) {
- assertTrue(false);
- }
- assertTrue(true);
-
- }
-
- @Test
- public void testComplexTypeCreation() {
- try {
- objComplexType.getBuilder().build();
- } catch (ODataJPARuntimeException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- } catch (ODataJPAModelException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
- assertEquals(objComplexType.pUnitName, "salesorderprocessing");
- }
-
- private class JPAEdmMetaModel extends JPAMetaModelMock {
- Set<EmbeddableType<?>> embeddableSet;
-
- public JPAEdmMetaModel() {
- embeddableSet = new HashSet<EmbeddableType<?>>();
- }
-
- @Override
- public Set<EmbeddableType<?>> getEmbeddables() {
- embeddableSet.add(new JPAEdmEmbeddable<String>());
- return embeddableSet;
- }
-
- }
-
- @SuppressWarnings("hiding")
- private class JPAEdmEmbeddable<String> extends JPAEmbeddableMock<String> {
-
- Set<Attribute<? super String, ?>> attributeSet = new HashSet<Attribute<? super String, ?>>();
-
- @SuppressWarnings({ "unchecked", "rawtypes" })
- private void setValuesToSet() {
- attributeSet.add((Attribute<? super String, String>) new JPAEdmAttribute(java.lang.String.class, "SOID"));
- attributeSet.add((Attribute<? super String, String>) new JPAEdmAttribute(java.lang.String.class, "SONAME"));
- }
-
- @Override
- public Set<Attribute<? super String, ?>> getAttributes() {
- setValuesToSet();
- return attributeSet;
- }
-
- @SuppressWarnings("unchecked")
- @Override
- public Class<String> getJavaType() {
- return (Class<String>) java.lang.String.class;
- }
-
- }
-
- @SuppressWarnings("hiding")
- private class JPAEdmAttribute<Object, String> extends JPASingularAttributeMock<Object, String> {
-
- @Override
- public PersistentAttributeType getPersistentAttributeType() {
- return PersistentAttributeType.BASIC;
- }
-
- Class<String> clazz;
- java.lang.String attributeName;
-
- public JPAEdmAttribute(final Class<String> javaType, final java.lang.String name) {
- this.clazz = javaType;
- this.attributeName = name;
-
- }
-
- @Override
- public Class<String> getJavaType() {
- return clazz;
- }
-
- @Override
- public java.lang.String getName() {
- return this.attributeName;
- }
-
- @Override
- public boolean isId() {
- return false;
- }
-
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmEntityContainerTest.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmEntityContainerTest.java b/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmEntityContainerTest.java
deleted file mode 100644
index 4e9355b..0000000
--- a/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmEntityContainerTest.java
+++ /dev/null
@@ -1,234 +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.model;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import java.util.HashSet;
-import java.util.Set;
-
-import javax.persistence.metamodel.Attribute;
-import javax.persistence.metamodel.EntityType;
-import javax.persistence.metamodel.Metamodel;
-
-import org.apache.olingo.odata2.api.edm.provider.Schema;
-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.JPAEdmAssociationView;
-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.core.jpa.common.ODataJPATestConstants;
-import org.apache.olingo.odata2.processor.core.jpa.mock.model.JPAEntityTypeMock;
-import org.apache.olingo.odata2.processor.core.jpa.mock.model.JPAMetaModelMock;
-import org.apache.olingo.odata2.processor.core.jpa.mock.model.JPASingularAttributeMock;
-import org.junit.Before;
-import org.junit.Test;
-
-public class JPAEdmEntityContainerTest extends JPAEdmTestModelView {
-
- private JPAEdmEntityContainer objJPAEdmEntityContainer;
- private JPAEdmEntityContainerTest objJPAEdmEntityContainerTest;
-
- @Before
- public void setUp() {
- objJPAEdmEntityContainerTest = new JPAEdmEntityContainerTest();
- objJPAEdmEntityContainer = new JPAEdmEntityContainer(objJPAEdmEntityContainerTest);
- try {
- objJPAEdmEntityContainer.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);
- }
- }
-
- @Test
- public void testGetBuilder() {
- assertNotNull(objJPAEdmEntityContainer.getBuilder());
- }
-
- @Test
- public void testGetEdmEntityContainer() {
- assertNotNull(objJPAEdmEntityContainer.getEdmEntityContainer());
- assertTrue(objJPAEdmEntityContainer.getEdmEntityContainer().getEntitySets().size() > 0);
- }
-
- @Test
- public void testGetConsistentEdmEntityContainerList() {
- assertNotNull(objJPAEdmEntityContainer.getConsistentEdmEntityContainerList());
- assertTrue(objJPAEdmEntityContainer.getConsistentEdmEntityContainerList().size() > 0);
-
- }
-
- @Test
- public void testGetJPAEdmEntitySetView() {
- assertNotNull(objJPAEdmEntityContainer.getJPAEdmEntitySetView());
- assertEquals("salesorderprocessing", objJPAEdmEntityContainer.getJPAEdmEntitySetView().getpUnitName());
- }
-
- @Test
- public void testIsConsistent() {
- assertTrue(objJPAEdmEntityContainer.isConsistent());
- objJPAEdmEntityContainer.clean();
- assertFalse(objJPAEdmEntityContainer.isConsistent());
- }
-
- @Test
- public void testGetEdmAssociationSetView() {
- assertNotNull(objJPAEdmEntityContainer.getEdmAssociationSetView());
- }
-
- @Test
- public void testGetBuilderIdempotent() {
- JPAEdmBuilder builder1 = objJPAEdmEntityContainer.getBuilder();
- JPAEdmBuilder builder2 = objJPAEdmEntityContainer.getBuilder();
-
- assertEquals(builder1.hashCode(), builder2.hashCode());
- }
-
- @Override
- public Metamodel getJPAMetaModel() {
- return new JPAEdmMetaModel();
- }
-
- @Override
- public JPAEdmEntitySetView getJPAEdmEntitySetView() {
- return this;
- }
-
- @Override
- public JPAEdmEntityContainerView getJPAEdmEntityContainerView() {
- return this;
- }
-
- @Override
- public EntityType<?> getJPAEntityType() {
- return new JPAEdmEntityType<String>();
- }
-
- @Override
- public JPAEdmEntityTypeView getJPAEdmEntityTypeView() {
- return this;
- }
-
- @Override
- public Schema getEdmSchema() {
- Schema schema = new Schema();
- schema.setNamespace("salesordereprocessing");
- return schema;
- }
-
- @Override
- public String getpUnitName() {
- return "salesorderprocessing";
- }
-
- @Override
- public JPAEdmAssociationView getJPAEdmAssociationView() {
- return this;
- }
-
- @Override
- public JPAEdmBuilder getBuilder() {
- return new JPAEdmBuilder() {
-
- @Override
- public void build() {
- // Nothing to do?
- }
- };
- }
-
- private class JPAEdmMetaModel extends JPAMetaModelMock {
- Set<EntityType<?>> entities;
-
- public JPAEdmMetaModel() {
- entities = new HashSet<EntityType<?>>();
- }
-
- @Override
- public Set<EntityType<?>> getEntities() {
- entities.add(new JPAEdmEntityType());
- return entities;
- }
-
- private class JPAEdmEntityType extends JPAEntityTypeMock<String> {
- @Override
- public String getName() {
- return "SalesOrderHeader";
- }
- }
- }
-
- @SuppressWarnings("hiding")
- private class JPAEdmEntityType<String> extends JPAEntityTypeMock<String> {
- Set<Attribute<? super String, ?>> attributeSet = new HashSet<Attribute<? super String, ?>>();
-
- @SuppressWarnings({ "unchecked", "rawtypes" })
- private void setValuesToSet() {
- attributeSet.add((Attribute<? super String, String>) new JPAEdmAttribute(java.lang.String.class, "SOID"));
- attributeSet.add((Attribute<? super String, String>) new JPAEdmAttribute(java.lang.String.class, "SONAME"));
- }
-
- @Override
- public Set<Attribute<? super String, ?>> getAttributes() {
- setValuesToSet();
- return attributeSet;
- }
-
- private class JPAEdmAttribute<Object, String> extends JPASingularAttributeMock<Object, String> {
-
- @Override
- public PersistentAttributeType getPersistentAttributeType() {
- return PersistentAttributeType.BASIC;
- }
-
- Class<String> clazz;
- java.lang.String attributeName;
-
- public JPAEdmAttribute(final Class<String> javaType, final java.lang.String name) {
- this.clazz = javaType;
- this.attributeName = name;
-
- }
-
- @Override
- public Class<String> getJavaType() {
- return clazz;
- }
-
- @Override
- public java.lang.String getName() {
- return this.attributeName;
- }
-
- @Override
- public boolean isId() {
- return true;
- }
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmEntitySetTest.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmEntitySetTest.java b/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmEntitySetTest.java
deleted file mode 100644
index 74c203e..0000000
--- a/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmEntitySetTest.java
+++ /dev/null
@@ -1,224 +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.model;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import java.util.HashSet;
-import java.util.Set;
-
-import javax.persistence.metamodel.Attribute;
-import javax.persistence.metamodel.EntityType;
-import javax.persistence.metamodel.Metamodel;
-
-import org.apache.olingo.odata2.api.edm.provider.Schema;
-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.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.JPAEdmKeyView;
-import org.apache.olingo.odata2.processor.core.jpa.common.ODataJPATestConstants;
-import org.apache.olingo.odata2.processor.core.jpa.mock.model.JPAEntityTypeMock;
-import org.apache.olingo.odata2.processor.core.jpa.mock.model.JPAMetaModelMock;
-import org.apache.olingo.odata2.processor.core.jpa.mock.model.JPASingularAttributeMock;
-import org.junit.Before;
-import org.junit.Test;
-
-public class JPAEdmEntitySetTest extends JPAEdmTestModelView {
-
- private static JPAEdmEntitySet objJPAEdmEntitySet;
- private static JPAEdmEntitySetTest objJPAEdmEntitySetTest;
-
- @Before
- public void setUp() {
- objJPAEdmEntitySetTest = new JPAEdmEntitySetTest();
- objJPAEdmEntitySet = new JPAEdmEntitySet(objJPAEdmEntitySetTest);
- try {
- objJPAEdmEntitySet.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);
- }
- }
-
- @Test
- public void testGetBuilder() {
- assertNotNull(objJPAEdmEntitySet.getBuilder());
- }
-
- @Test
- public void testGetEdmEntitySet() {
- assertNotNull(objJPAEdmEntitySet.getEdmEntitySet());
- assertNotNull(objJPAEdmEntitySet.getEdmEntitySet().getEntityType());
- }
-
- @Test
- public void testGetConsistentEntitySetList() {
- assertTrue(objJPAEdmEntitySet.getConsistentEdmEntitySetList().size() > 0);
- }
-
- @Test
- public void testGetJPAEdmEntityTypeView() {
- assertNotNull(objJPAEdmEntitySet.getJPAEdmEntityTypeView());
- assertEquals("salesorderprocessing", objJPAEdmEntitySet.getJPAEdmEntityTypeView().getpUnitName());
- }
-
- @Test
- public void testIsConsistent() {
- assertTrue(objJPAEdmEntitySet.isConsistent());
-
- objJPAEdmEntitySet.getJPAEdmEntityTypeView().clean();
- assertFalse(objJPAEdmEntitySet.getJPAEdmEntityTypeView().isConsistent());
-
- objJPAEdmEntitySet.clean();
- assertFalse(objJPAEdmEntitySet.isConsistent());
- }
-
- @Test
- public void testGetBuilderIdempotent() {
- JPAEdmBuilder builder1 = objJPAEdmEntitySet.getBuilder();
- JPAEdmBuilder builder2 = objJPAEdmEntitySet.getBuilder();
-
- assertEquals(builder1.hashCode(), builder2.hashCode());
- }
-
- @Override
- public Metamodel getJPAMetaModel() {
- return new JPAEdmMetaModel();
- }
-
- @Override
- public JPAEdmEntityContainerView getJPAEdmEntityContainerView() {
- return this;
- }
-
- @Override
- public JPAEdmEntitySetView getJPAEdmEntitySetView() {
- return this;
- }
-
- @Override
- public JPAEdmEntityTypeView getJPAEdmEntityTypeView() {
- return this;
- }
-
- @Override
- public EntityType<?> getJPAEntityType() {
- return new JPAEdmEntityType<String>();
- }
-
- @Override
- public JPAEdmKeyView getJPAEdmKeyView() {
- return this;
- }
-
- @Override
- public Schema getEdmSchema() {
- Schema schema = new Schema();
- schema.setNamespace("salesordereprocessing");
- return schema;
- }
-
- @Override
- public String getpUnitName() {
- return "salesorderprocessing";
- }
-
- @SuppressWarnings("hiding")
- private class JPAEdmEntityType<String> extends JPAEntityTypeMock<String> {
- Set<Attribute<? super String, ?>> attributeSet = new HashSet<Attribute<? super String, ?>>();
-
- @SuppressWarnings({ "unchecked", "rawtypes" })
- private void setValuesToSet() {
- attributeSet.add((Attribute<? super String, String>) new JPAEdmAttribute(java.lang.String.class, "SOID"));
- attributeSet.add((Attribute<? super String, String>) new JPAEdmAttribute(java.lang.String.class, "SONAME"));
- }
-
- @Override
- public java.lang.String getName() {
- return "SalesOrderHeader";
- }
-
- @Override
- public Set<Attribute<? super String, ?>> getAttributes() {
- setValuesToSet();
- return attributeSet;
- }
-
- private class JPAEdmAttribute<Object, String> extends JPASingularAttributeMock<Object, String> {
-
- @Override
- public PersistentAttributeType getPersistentAttributeType() {
- return PersistentAttributeType.BASIC;
- }
-
- Class<String> clazz;
- java.lang.String attributeName;
-
- public JPAEdmAttribute(final Class<String> javaType, final java.lang.String name) {
- this.clazz = javaType;
- this.attributeName = name;
-
- }
-
- @Override
- public Class<String> getJavaType() {
- return clazz;
- }
-
- @Override
- public java.lang.String getName() {
- return this.attributeName;
- }
-
- @Override
- public boolean isId() {
- return true;
- }
- }
- }
-
- private class JPAEdmMetaModel extends JPAMetaModelMock {
- Set<EntityType<?>> entities;
-
- public JPAEdmMetaModel() {
- entities = new HashSet<EntityType<?>>();
- }
-
- @Override
- public Set<EntityType<?>> getEntities() {
- entities.add(new JPAEdmEntityType());
- return entities;
- }
-
- private class JPAEdmEntityType extends JPAEntityTypeMock<String> {
- @Override
- public String getName() {
- return "SalesOrderHeader";
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmEntityTypeTest.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmEntityTypeTest.java b/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmEntityTypeTest.java
deleted file mode 100644
index dfbe879..0000000
--- a/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmEntityTypeTest.java
+++ /dev/null
@@ -1,198 +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.model;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import java.util.HashSet;
-import java.util.Set;
-
-import javax.persistence.metamodel.Attribute;
-import javax.persistence.metamodel.EntityType;
-import javax.persistence.metamodel.Metamodel;
-
-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.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.core.jpa.common.ODataJPATestConstants;
-import org.apache.olingo.odata2.processor.core.jpa.mock.model.JPAEntityTypeMock;
-import org.apache.olingo.odata2.processor.core.jpa.mock.model.JPAMetaModelMock;
-import org.apache.olingo.odata2.processor.core.jpa.mock.model.JPASingularAttributeMock;
-import org.junit.Before;
-import org.junit.Test;
-
-public class JPAEdmEntityTypeTest extends JPAEdmTestModelView {
-
- private static JPAEdmEntityTypeTest objJPAEdmEntityTypeTest;
- private static JPAEdmEntityType objJPAEdmEntityType;
-
- @Before
- public void setUp() {
- objJPAEdmEntityTypeTest = new JPAEdmEntityTypeTest();
- objJPAEdmEntityType = new JPAEdmEntityType(objJPAEdmEntityTypeTest);
- try {
- objJPAEdmEntityType.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);
- }
- }
-
- @Test
- public void testGetBuilder() {
- assertNotNull(objJPAEdmEntityType.getBuilder());
- }
-
- @Test
- public void testGetBuilderIdempotent() {
- JPAEdmBuilder builder1 = objJPAEdmEntityType.getBuilder();
- JPAEdmBuilder builder2 = objJPAEdmEntityType.getBuilder();
-
- assertEquals(builder1.hashCode(), builder2.hashCode());
- }
-
- @Test
- public void testGetEdmEntityType() {
- assertNotNull(objJPAEdmEntityType.getEdmEntityType());
- assertNotNull(objJPAEdmEntityType.getEdmEntityType().getKey());
- }
-
- @Test
- public void testGetJPAEntityType() {
- assertNotNull(objJPAEdmEntityType.getJPAEntityType());
-
- }
-
- @Test
- public void testGetConsistentEdmEntityTypes() {
- assertTrue(objJPAEdmEntityType.getConsistentEdmEntityTypes().size() > 0);
- }
-
- @Test
- public void testSearchEdmEntityType() {
- assertNotNull(objJPAEdmEntityType.searchEdmEntityType("SalesOrderHeader"));
- }
-
- @Test
- public void testIsConsistent() {
- assertTrue(objJPAEdmEntityType.isConsistent());
- }
-
- @Override
- public Metamodel getJPAMetaModel() {
- return new JPAEdmMetaModel();
- }
-
- @Override
- public JPAEdmEntitySetView getJPAEdmEntitySetView() {
- return this;
- }
-
- @Override
- public JPAEdmEntityContainerView getJPAEdmEntityContainerView() {
- return this;
- }
-
- @Override
- public EntityType<?> getJPAEntityType() {
- return new JPAEdmEntityTypeLocal<String>();
- }
-
- @Override
- public JPAEdmEntityTypeView getJPAEdmEntityTypeView() {
- return this;
- }
-
- private class JPAEdmMetaModel extends JPAMetaModelMock {
- Set<EntityType<?>> entities;
-
- public JPAEdmMetaModel() {
- entities = new HashSet<EntityType<?>>();
- }
-
- @Override
- public Set<EntityType<?>> getEntities() {
- entities.add(new JPAEdmEntityType());
- return entities;
- }
-
- private class JPAEdmEntityType extends JPAEntityTypeMock<String> {
- @Override
- public String getName() {
- return "SalesOrderHeader";
- }
- }
- }
-
- @SuppressWarnings("hiding")
- private class JPAEdmEntityTypeLocal<String> extends JPAEntityTypeMock<String> {
- Set<Attribute<? super String, ?>> attributeSet = new HashSet<Attribute<? super String, ?>>();
-
- @SuppressWarnings({ "unchecked", "rawtypes" })
- private void setValuesToSet() {
- attributeSet.add((Attribute<? super String, String>) new JPAEdmAttribute(java.lang.String.class, "SOID"));
- attributeSet.add((Attribute<? super String, String>) new JPAEdmAttribute(java.lang.String.class, "SONAME"));
- }
-
- @Override
- public Set<Attribute<? super String, ?>> getAttributes() {
- setValuesToSet();
- return attributeSet;
- }
-
- private class JPAEdmAttribute<Object, String> extends JPASingularAttributeMock<Object, String> {
-
- @Override
- public PersistentAttributeType getPersistentAttributeType() {
- return PersistentAttributeType.BASIC;
- }
-
- Class<String> clazz;
- java.lang.String attributeName;
-
- public JPAEdmAttribute(final Class<String> javaType, final java.lang.String name) {
- this.clazz = javaType;
- this.attributeName = name;
-
- }
-
- @Override
- public Class<String> getJavaType() {
- return clazz;
- }
-
- @Override
- public java.lang.String getName() {
- return this.attributeName;
- }
-
- @Override
- public boolean isId() {
- return true;
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/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
deleted file mode 100644
index 94665d7..0000000
--- a/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmFunctionImportTest.java
+++ /dev/null
@@ -1,566 +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.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.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;
-
-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("Param3", funcImpList.get(1).getName());
- assertEquals(EdmSimpleTypeKind.Double, funcImpList.get(1).getType());
-
- }
-
- }
-
- /**
- * 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/1b479e6c/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmKeyTest.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmKeyTest.java b/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmKeyTest.java
deleted file mode 100644
index 0ec45df..0000000
--- a/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmKeyTest.java
+++ /dev/null
@@ -1,176 +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.model;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.persistence.metamodel.Attribute;
-
-import org.apache.olingo.odata2.api.edm.EdmSimpleTypeKind;
-import org.apache.olingo.odata2.api.edm.FullQualifiedName;
-import org.apache.olingo.odata2.api.edm.provider.ComplexProperty;
-import org.apache.olingo.odata2.api.edm.provider.ComplexType;
-import org.apache.olingo.odata2.api.edm.provider.Key;
-import org.apache.olingo.odata2.api.edm.provider.Property;
-import org.apache.olingo.odata2.api.edm.provider.SimpleProperty;
-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.JPAEdmKeyView;
-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.JPAAttributeMock;
-import org.apache.olingo.odata2.processor.core.jpa.mock.model.JPAEdmMockData;
-import org.apache.olingo.odata2.processor.core.jpa.mock.model.JPAEdmMockData.ComplexType.ComplexTypeA;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-public class JPAEdmKeyTest extends JPAEdmTestModelView {
-
- private static JPAEdmKeyView keyView;
- private static JPAEdmKeyTest objJpaEdmKeyTest;
-
- @BeforeClass
- public static void setup() {
- objJpaEdmKeyTest = new JPAEdmKeyTest();
- keyView = new JPAEdmKey(objJpaEdmKeyTest, objJpaEdmKeyTest);
- }
-
- @SuppressWarnings("hiding")
- private class JPAAttributeA<Object, ComplexTypeA> extends JPAAttributeMock<Object, ComplexTypeA> {
- @SuppressWarnings("unchecked")
- @Override
- public Class<ComplexTypeA> getJavaType() {
- return (Class<ComplexTypeA>) JPAEdmMockData.ComplexType.ComplexTypeA.class;
- }
- }
-
- @Test
- public void testBuildComplexKey() {
- try {
- keyView.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);
- }
-
- Key key = keyView.getEdmKey();
-
- assertEquals(JPAEdmMockData.ComplexType.ComplexTypeA.Property.PROPERTY_A, key.getKeys().get(0).getName());
- assertEquals(JPAEdmMockData.ComplexType.ComplexTypeA.Property.PROPERTY_B, key.getKeys().get(1).getName());
- assertEquals(JPAEdmMockData.ComplexType.ComplexTypeB.Property.PROPERTY_D, key.getKeys().get(2).getName());
- assertEquals(JPAEdmMockData.ComplexType.ComplexTypeB.Property.PROPERTY_E, key.getKeys().get(3).getName());
-
- }
-
- @Test
- public void testGetBuilderIdempotent() {
- JPAEdmBuilder builder1 = keyView.getBuilder();
- JPAEdmBuilder builder2 = keyView.getBuilder();
-
- assertEquals(builder1.hashCode(), builder2.hashCode());
- }
-
- @Override
- public Attribute<?, ?> getJPAAttribute() {
- return new JPAAttributeA<Object, ComplexTypeA>();
-
- }
-
- @Override
- public ComplexType searchEdmComplexType(final FullQualifiedName arg0) {
- return searchEdmComplexType(arg0.getName());
- }
-
- @Override
- public ComplexType searchEdmComplexType(final String arg0) {
- if (arg0.equals(JPAEdmMockData.ComplexType.ComplexTypeA.class.getName())) {
- return buildComplexTypeA();
- } else if (arg0.equals(JPAEdmMockData.ComplexType.ComplexTypeB.class.getSimpleName())) {
- return buildComplexTypeB();
- }
-
- return null;
-
- }
-
- private ComplexType buildComplexTypeB() {
- ComplexType complexType = new ComplexType();
- complexType.setProperties(buildPropertiesB());
-
- return complexType;
- }
-
- private List<Property> buildPropertiesB() {
- List<Property> propertyList = new ArrayList<Property>();
-
- SimpleProperty property = new SimpleProperty();
- property.setName(JPAEdmMockData.ComplexType.ComplexTypeB.Property.PROPERTY_D);
- property.setType(EdmSimpleTypeKind.Int16);
-
- propertyList.add(property);
-
- property = new SimpleProperty();
- property.setName(JPAEdmMockData.ComplexType.ComplexTypeB.Property.PROPERTY_E);
- property.setType(EdmSimpleTypeKind.Int16);
-
- propertyList.add(property);
-
- return propertyList;
- }
-
- private ComplexType buildComplexTypeA() {
- ComplexType complexType = new ComplexType();
- complexType.setProperties(buildPropertiesA());
-
- return complexType;
- }
-
- private List<Property> buildPropertiesA() {
-
- List<Property> propertyList = new ArrayList<Property>();
-
- SimpleProperty property = new SimpleProperty();
- property.setName(JPAEdmMockData.ComplexType.ComplexTypeA.Property.PROPERTY_A);
- property.setType(EdmSimpleTypeKind.Int16);
-
- propertyList.add(property);
-
- property = new SimpleProperty();
- property.setName(JPAEdmMockData.ComplexType.ComplexTypeA.Property.PROPERTY_B);
- property.setType(EdmSimpleTypeKind.Int16);
-
- propertyList.add(property);
-
- ComplexProperty complexProperty = new ComplexProperty();
- complexProperty.setName(JPAEdmMockData.ComplexType.ComplexTypeA.Property.PROPERTY_C);
- complexProperty.setType(new FullQualifiedName(ODataJPAContextMock.NAMESPACE,
- JPAEdmMockData.ComplexType.ComplexTypeB.name));
-
- propertyList.add(complexProperty);
- return propertyList;
-
- }
-
-}
[04/37] [OLINGO-82] Renamed the project folder name to
odata2-jpa-processor
Posted by ch...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmModelTest.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmModelTest.java b/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmModelTest.java
deleted file mode 100644
index 4192c2b..0000000
--- a/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmModelTest.java
+++ /dev/null
@@ -1,145 +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.model;
-
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.fail;
-
-import java.util.HashSet;
-import java.util.Set;
-
-import javax.persistence.metamodel.Attribute;
-import javax.persistence.metamodel.EmbeddableType;
-import javax.persistence.metamodel.Metamodel;
-
-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.core.jpa.common.ODataJPATestConstants;
-import org.apache.olingo.odata2.processor.core.jpa.mock.model.JPAEmbeddableMock;
-import org.apache.olingo.odata2.processor.core.jpa.mock.model.JPAMetaModelMock;
-import org.apache.olingo.odata2.processor.core.jpa.mock.model.JPASingularAttributeMock;
-import org.junit.Before;
-import org.junit.Test;
-
-public class JPAEdmModelTest extends JPAEdmTestModelView {
-
- private JPAEdmModel objJPAEdmModel;
-
- @Before
- public void setUp() {
- objJPAEdmModel = new JPAEdmModel(getJPAMetaModel(), "salesorderprocessing");
- try {
- objJPAEdmModel.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);
- }
- }
-
- @Test
- public void testGetEdmSchemaView() {
- assertNotNull(objJPAEdmModel.getEdmSchemaView());
- }
-
- @Test
- public void testGetBuilder() {
- assertNotNull(objJPAEdmModel.getBuilder());
- }
-
- @Override
- public Metamodel getJPAMetaModel() {
- return new JPAEdmMetaModel();
- }
-
- private class JPAEdmMetaModel extends JPAMetaModelMock {
- Set<EmbeddableType<?>> embeddableSet;
-
- public JPAEdmMetaModel() {
- embeddableSet = new HashSet<EmbeddableType<?>>();
- }
-
- @Override
- public Set<EmbeddableType<?>> getEmbeddables() {
- embeddableSet.add(new JPAEdmEmbeddable<String>());
- return embeddableSet;
- }
-
- }
-
- @SuppressWarnings("hiding")
- private class JPAEdmEmbeddable<String> extends JPAEmbeddableMock<String> {
-
- Set<Attribute<? super String, ?>> attributeSet = new HashSet<Attribute<? super String, ?>>();
-
- @SuppressWarnings({ "unchecked", "rawtypes" })
- private void setValuesToSet() {
- attributeSet.add((Attribute<? super String, String>) new JPAEdmAttribute(java.lang.String.class, "SOID"));
- attributeSet.add((Attribute<? super String, String>) new JPAEdmAttribute(java.lang.String.class, "SONAME"));
- }
-
- @Override
- public Set<Attribute<? super String, ?>> getAttributes() {
- setValuesToSet();
- return attributeSet;
- }
-
- @SuppressWarnings("unchecked")
- @Override
- public Class<String> getJavaType() {
- return (Class<String>) java.lang.String.class;
- }
-
- }
-
- @SuppressWarnings("hiding")
- private class JPAEdmAttribute<Object, String> extends JPASingularAttributeMock<Object, String> {
-
- @Override
- public PersistentAttributeType getPersistentAttributeType() {
- return PersistentAttributeType.BASIC;
- }
-
- Class<String> clazz;
- java.lang.String attributeName;
-
- public JPAEdmAttribute(final Class<String> javaType, final java.lang.String name) {
- this.clazz = javaType;
- this.attributeName = name;
-
- }
-
- @Override
- public Class<String> getJavaType() {
- return clazz;
- }
-
- @Override
- public java.lang.String getName() {
- return this.attributeName;
- }
-
- @Override
- public boolean isId() {
- return false;
- }
-
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmNavigationPropertyTest.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmNavigationPropertyTest.java b/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmNavigationPropertyTest.java
deleted file mode 100644
index 8912bf8..0000000
--- a/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmNavigationPropertyTest.java
+++ /dev/null
@@ -1,218 +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.model;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import javax.persistence.metamodel.Attribute;
-import javax.persistence.metamodel.EntityType;
-import javax.persistence.metamodel.Type;
-
-import org.apache.olingo.odata2.api.edm.FullQualifiedName;
-import org.apache.olingo.odata2.api.edm.provider.Association;
-import org.apache.olingo.odata2.api.edm.provider.AssociationEnd;
-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.JPAEdmEntityTypeView;
-import org.apache.olingo.odata2.processor.core.jpa.common.ODataJPATestConstants;
-import org.apache.olingo.odata2.processor.core.jpa.mock.model.JPAEntityTypeMock;
-import org.apache.olingo.odata2.processor.core.jpa.mock.model.JPAPluralAttributeMock;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-public class JPAEdmNavigationPropertyTest extends JPAEdmTestModelView {
-
- private static JPAEdmNavigationProperty objNavigationProperty;
- private static JPAEdmNavigationPropertyTest navPropView;
-
- @BeforeClass
- public static void setup() {
- JPAEdmNavigationPropertyTest localView = new JPAEdmNavigationPropertyTest();
- navPropView = new JPAEdmNavigationPropertyTest();
- objNavigationProperty = new JPAEdmNavigationProperty(localView,
- localView, 1);
- try {
- objNavigationProperty.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);
- }
- }
-
- @Override
- public String getpUnitName() {
- return "salesorderprocessing";
- }
-
- @Override
- public JPAEdmEntityTypeView getJPAEdmEntityTypeView() {
- return this;
- }
-
- @Override
- public EntityType<?> getJPAEntityType() {
- return new JPAEdmEntityType();
- }
-
- private Attribute<?, ?> getJPAAttributeLocal() {
- AttributeMock<Object, String> attr = new AttributeMock<Object, String>();
- return attr;
- }
-
- @Override
- public Attribute<?, ?> getJPAAttribute() {
- return getJPAAttributeLocal();
- }
-
- @Override
- public Association getEdmAssociation() {
-
- Association association = new Association();
- association.setName("Assoc_SalesOrderHeader_SalesOrderItem");
- association.setEnd1(new AssociationEnd().setType(
- new FullQualifiedName("salesorderprocessing", "String"))
- .setRole("SalesOrderHeader"));
- association.setEnd2(new AssociationEnd()
- .setType(
- new FullQualifiedName("salesorderprocessing",
- "SalesOrderItem")).setRole("SalesOrderItem"));
- return association;
- }
-
- @Test
- public void testGetBuilder() {
- assertNotNull(objNavigationProperty.getBuilder());
-
- }
-
- @Test
- public void testGetBuilderIdempotent() {
- JPAEdmBuilder builder1 = objNavigationProperty.getBuilder();
- JPAEdmBuilder builder2 = objNavigationProperty.getBuilder();
-
- assertEquals(builder1.hashCode(), builder2.hashCode());
- }
-
- @Test
- public void testGetEdmNavigationProperty() {
- if (objNavigationProperty == null || objNavigationProperty.getEdmNavigationProperty() == null) {
- JPAEdmNavigationPropertyTest localView = new JPAEdmNavigationPropertyTest();
- navPropView = new JPAEdmNavigationPropertyTest();
- objNavigationProperty = new JPAEdmNavigationProperty(localView,
- localView, 1);
- try {
- objNavigationProperty.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);
- }
- }
- assertEquals(
- objNavigationProperty.getEdmNavigationProperty().getName(),
- "StringDetails");
- }
-
- @Test
- public void testGetConsistentEdmNavigationProperties() {
- assertTrue(objNavigationProperty.getConsistentEdmNavigationProperties()
- .size() > 0);
- }
-
- @Test
- public void testAddJPAEdmNavigationPropertyView() {
- JPAEdmNavigationPropertyTest localView = new JPAEdmNavigationPropertyTest();
- navPropView = new JPAEdmNavigationPropertyTest();
- objNavigationProperty = new JPAEdmNavigationProperty(localView,
- localView, 1);
- try {
- objNavigationProperty.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);
- }
- objNavigationProperty.addJPAEdmNavigationPropertyView(navPropView);
- assertTrue(objNavigationProperty.getConsistentEdmNavigationProperties()
- .size() > 1);
- }
-
- @Override
- public boolean isConsistent() {
- return true;
- }
-
- @Test
- public void testBuildNavigationProperty() {
-
- try {
- objNavigationProperty.getBuilder().build();
- } catch (ODataJPARuntimeException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- } catch (ODataJPAModelException e) {
- fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
- }
- assertEquals(objNavigationProperty.getEdmNavigationProperty()
- .getFromRole(), "SalesOrderItem");
- assertEquals(objNavigationProperty.getEdmNavigationProperty()
- .getToRole(), "SalesOrderHeader");
-
- }
-
- @SuppressWarnings("hiding")
- private class AttributeMock<Object, String> extends
- JPAPluralAttributeMock {
-
- @Override
- public boolean isCollection() {
- return true;
- }
-
- @Override
- public Type<java.lang.String> getElementType() {
- return new ElementType();
- }
- }
-
- private class JPAEdmEntityType extends JPAEntityTypeMock<String> {
- @Override
- public String getName() {
- return "SalesOrderHeader";
- }
- }
-
- private class ElementType implements Type<String> {
-
- @Override
- public javax.persistence.metamodel.Type.PersistenceType getPersistenceType() {
- return PersistenceType.BASIC;
- }
-
- @Override
- public Class<String> getJavaType() {
- return String.class;
- }
-
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmPropertyTest.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmPropertyTest.java b/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmPropertyTest.java
deleted file mode 100644
index 633459f..0000000
--- a/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmPropertyTest.java
+++ /dev/null
@@ -1,440 +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.model;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import javax.persistence.metamodel.Attribute;
-import javax.persistence.metamodel.Attribute.PersistentAttributeType;
-import javax.persistence.metamodel.EmbeddableType;
-import javax.persistence.metamodel.EntityType;
-import javax.persistence.metamodel.Metamodel;
-import javax.persistence.metamodel.Type;
-
-import org.apache.olingo.odata2.api.edm.FullQualifiedName;
-import org.apache.olingo.odata2.api.edm.provider.Association;
-import org.apache.olingo.odata2.api.edm.provider.AssociationEnd;
-import org.apache.olingo.odata2.api.edm.provider.Schema;
-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.JPAEdmAssociationView;
-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.core.jpa.common.ODataJPATestConstants;
-import org.apache.olingo.odata2.processor.core.jpa.mock.model.JPAEdmMockData.ComplexType;
-import org.apache.olingo.odata2.processor.core.jpa.mock.model.JPAEdmMockData.SimpleType;
-import org.apache.olingo.odata2.processor.core.jpa.mock.model.JPAEmbeddableTypeMock;
-import org.apache.olingo.odata2.processor.core.jpa.mock.model.JPAEntityTypeMock;
-import org.apache.olingo.odata2.processor.core.jpa.mock.model.JPAMetaModelMock;
-import org.apache.olingo.odata2.processor.core.jpa.mock.model.JPAPluralAttributeMock;
-import org.apache.olingo.odata2.processor.core.jpa.mock.model.JPASingularAttributeMock;
-import org.junit.Test;
-
-public class JPAEdmPropertyTest extends JPAEdmTestModelView {
-
- private JPAEdmPropertyTest objJPAEdmPropertyTest;
- private JPAEdmProperty objJPAEdmProperty;
-
- private static PersistentAttributeType ATTRIBUTE_TYPE = PersistentAttributeType.BASIC;
-
- public void setUp() {
- ATTRIBUTE_TYPE = PersistentAttributeType.BASIC;
- objJPAEdmPropertyTest = new JPAEdmPropertyTest();
- objJPAEdmProperty = new JPAEdmProperty(objJPAEdmPropertyTest);
- try {
- objJPAEdmProperty.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);
- }
-
- }
-
- @Test
- public void testGetBuilder() {
- setUp();
- assertNotNull(objJPAEdmProperty.getBuilder());
- }
-
- @Test
- public void testGetBuilderIdempotent() {
- setUp();
- JPAEdmBuilder builder1 = objJPAEdmProperty.getBuilder();
- JPAEdmBuilder builder2 = objJPAEdmProperty.getBuilder();
-
- assertEquals(builder1.hashCode(), builder2.hashCode());
- }
-
- @Test
- public void testGetPropertyList() {
- setUp();
- assertNotNull(objJPAEdmProperty.getEdmPropertyList());
- assertTrue(objJPAEdmProperty.getEdmPropertyList().size() > 0);
- }
-
- @Test
- public void testGetJPAEdmKeyView() {
- setUp();
- assertNotNull(objJPAEdmProperty.getJPAEdmKeyView());
- }
-
- @Test
- public void testGetSimpleProperty() {
- setUp();
- assertNotNull(objJPAEdmProperty.getEdmSimpleProperty());
- }
-
- @Test
- public void testGetJPAAttribute() {
- setUp();
- assertNotNull(objJPAEdmProperty.getJPAAttribute());
- }
-
- @Test
- public void testGetEdmComplexProperty() {
-
- // builder for complex type
- ATTRIBUTE_TYPE = PersistentAttributeType.EMBEDDED;
- objJPAEdmPropertyTest = new JPAEdmPropertyTest();
- objJPAEdmProperty = new JPAEdmProperty(objJPAEdmPropertyTest, objJPAEdmPropertyTest);
- try {
- objJPAEdmProperty.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);
- }
-
- assertNotNull(objJPAEdmProperty.getEdmComplexProperty());
- }
-
- @Test
- public void testGetJPAEdmNavigationPropertyView() {
- setUp();
- assertNotNull(objJPAEdmProperty.getJPAEdmNavigationPropertyView());
- }
-
- @Test
- public void testIsConsistent() {
- setUp();
- assertNotNull(objJPAEdmProperty.isConsistent());
- }
-
- @Test
- public void testClean() {
- setUp();
- objJPAEdmProperty.clean();
- assertFalse(objJPAEdmProperty.isConsistent());
- }
-
- @Test
- public void testBuildManyToOne() {
- ATTRIBUTE_TYPE = PersistentAttributeType.MANY_TO_ONE;
- objJPAEdmPropertyTest = new JPAEdmPropertyTest();
- objJPAEdmProperty = new JPAEdmProperty(objJPAEdmPropertyTest);
- try {
- objJPAEdmProperty.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);
- }
-
- assertNotNull(objJPAEdmProperty.getJPAEdmNavigationPropertyView().getEdmNavigationProperty());
- }
-
- @Override
- public Metamodel getJPAMetaModel() {
- return new JPAEdmMetaModel();
- }
-
- @Override
- public List<String> getNonKeyComplexTypeList() {
- return new ArrayList<String>();
- }
-
- @Override
- public Schema getEdmSchema() {
- Schema schema = new Schema();
- schema.setNamespace(getpUnitName());
- return schema;
- }
-
- @Override
- public org.apache.olingo.odata2.api.edm.provider.ComplexType searchEdmComplexType(final String arg0) {
- org.apache.olingo.odata2.api.edm.provider.ComplexType complexType =
- new org.apache.olingo.odata2.api.edm.provider.ComplexType();
- complexType.setName("ComplexTypeA");
- return complexType;
- }
-
- @Override
- public JPAEdmEntitySetView getJPAEdmEntitySetView() {
- return this;
- }
-
- @Override
- public JPAEdmEntityContainerView getJPAEdmEntityContainerView() {
- return this;
- }
-
- @Override
- public EntityType<?> getJPAEntityType() {
- return new JPAEdmEntityType<String>();
- }
-
- @Override
- public JPAEdmEntityTypeView getJPAEdmEntityTypeView() {
- return this;
- }
-
- @Override
- public org.apache.olingo.odata2.api.edm.provider.EntityType getEdmEntityType() {
- org.apache.olingo.odata2.api.edm.provider.EntityType entityType =
- new org.apache.olingo.odata2.api.edm.provider.EntityType();
- entityType.setName("SalesOrderHeader");
-
- return entityType;
- }
-
- @Override
- public Association getEdmAssociation() {
- Association association = new Association();
- association
- .setEnd1(new AssociationEnd().setType(new FullQualifiedName("salesorderprocessing", "SalesOrderHeader")));
- association.setEnd2(new AssociationEnd().setType(new FullQualifiedName("salesorderprocessing", "String")));
-
- return association;
- }
-
- @Override
- public String getpUnitName() {
- return "salesorderprocessing";
- }
-
- @Override
- public JPAEdmAssociationView getJPAEdmAssociationView() {
- return this;
- }
-
- @Override
- public EmbeddableType<?> getJPAEmbeddableType() {
- return new JPAEdmEmbeddable<java.lang.String>();
- }
-
- @Override
- public JPAEdmComplexTypeView getJPAEdmComplexTypeView() {
- return this;
- }
-
- private class JPAEdmMetaModel extends JPAMetaModelMock {
- Set<EntityType<?>> entities;
- Set<EmbeddableType<?>> embeddableSet;
-
- public JPAEdmMetaModel() {
- entities = new HashSet<EntityType<?>>();
- embeddableSet = new HashSet<EmbeddableType<?>>();
- }
-
- @Override
- public Set<EntityType<?>> getEntities() {
- entities.add(new JPAEdmEntityType());
- return entities;
- }
-
- @Override
- public Set<EmbeddableType<?>> getEmbeddables() {
- embeddableSet.add(new JPAEdmEmbeddable<String>());
- return embeddableSet;
- }
-
- private class JPAEdmEntityType extends JPAEntityTypeMock<String> {
- @Override
- public String getName() {
- return "SalesOrderHeader";
- }
- }
- }
-
- @SuppressWarnings("hiding")
- private class JPAEdmEntityType<String> extends JPAEntityTypeMock<String> {
- Set<Attribute<? super String, ?>> attributeSet = new HashSet<Attribute<? super String, ?>>();
-
- @SuppressWarnings({ "unchecked", "rawtypes" })
- private void setValuesToSet() {
- if (JPAEdmPropertyTest.ATTRIBUTE_TYPE.equals(PersistentAttributeType.BASIC)) {
- attributeSet.add((Attribute<? super String, String>) new JPAEdmAttribute(java.lang.String.class, "SOID"));
- attributeSet.add((Attribute<? super String, String>) new JPAEdmAttribute(java.lang.String.class, "SONAME"));
- } else if (JPAEdmPropertyTest.ATTRIBUTE_TYPE.equals(PersistentAttributeType.EMBEDDED)) {
- attributeSet.add(new JPAEdmAttribute(JPAEdmEmbeddable.class, ComplexType.ComplexTypeA.clazz.getName()));
- } else if (JPAEdmPropertyTest.ATTRIBUTE_TYPE.equals(PersistentAttributeType.MANY_TO_ONE)) {
- attributeSet.add(new JPAEdmPluralAttribute());
- }
- }
-
- @Override
- public Set<Attribute<? super String, ?>> getAttributes() {
- setValuesToSet();
- return attributeSet;
- }
-
- private class JPAEdmPluralAttribute extends JPAPluralAttributeMock {
- @Override
- public java.lang.String getName() {
- return "salesorderheaderdetails";
- }
-
- @Override
- public javax.persistence.metamodel.Attribute.PersistentAttributeType getPersistentAttributeType() {
- return ATTRIBUTE_TYPE;
- }
-
- @Override
- public boolean isCollection() {
- return true;
- }
-
- @Override
- public Type<java.lang.String> getElementType() {
- return new Type<java.lang.String>() {
-
- @Override
- public Class<java.lang.String> getJavaType() {
- return java.lang.String.class;
- }
-
- @Override
- public javax.persistence.metamodel.Type.PersistenceType getPersistenceType() {
- return null;
- }
-
- };
- }
- }
-
- private class JPAEdmAttribute<Object, String> extends JPASingularAttributeMock<Object, String> {
-
- @Override
- public PersistentAttributeType getPersistentAttributeType() {
- return ATTRIBUTE_TYPE;
- }
-
- Class<String> clazz;
- java.lang.String attributeName;
-
- public JPAEdmAttribute(final Class<String> javaType, final java.lang.String name) {
- this.clazz = javaType;
- this.attributeName = name;
-
- }
-
- @Override
- public Class<String> getJavaType() {
- return clazz;
- }
-
- @Override
- public java.lang.String getName() {
- return this.attributeName;
- }
-
- @Override
- public boolean isId() {
- return true;
- }
- }
- }
-
- @SuppressWarnings("hiding")
- private class JPAEdmEmbeddable<String> extends JPAEmbeddableTypeMock<String> {
-
- Set<Attribute<? super String, ?>> attributeSet = new HashSet<Attribute<? super String, ?>>();
-
- @SuppressWarnings({ "unchecked", "rawtypes" })
- private void setValuesToSet() {
- attributeSet.add((Attribute<? super String, String>) new JPAEdmAttribute(java.lang.String.class, "SOID"));
- attributeSet.add((Attribute<? super String, String>) new JPAEdmAttribute(java.lang.String.class, "SONAME"));
- }
-
- @Override
- public Set<Attribute<? super String, ?>> getAttributes() {
- setValuesToSet();
- return attributeSet;
- }
-
- @SuppressWarnings("unchecked")
- @Override
- public Class<String> getJavaType() {
- Class<?> clazz = null;
- if (ATTRIBUTE_TYPE.equals(PersistentAttributeType.BASIC)) {
- clazz = (Class<java.lang.String>) SimpleType.SimpleTypeA.clazz;
- } else {
- clazz = (Class<?>) ComplexType.ComplexTypeA.clazz;
- }
- return (Class<String>) clazz;
- }
-
- private class JPAEdmAttribute<Object, String> extends JPASingularAttributeMock<Object, String> {
-
- @Override
- public PersistentAttributeType getPersistentAttributeType() {
- return ATTRIBUTE_TYPE;
- }
-
- Class<String> clazz;
- java.lang.String attributeName;
-
- public JPAEdmAttribute(final Class<String> javaType, final java.lang.String name) {
- this.clazz = javaType;
- this.attributeName = name;
-
- }
-
- @Override
- public Class<String> getJavaType() {
- return clazz;
- }
-
- @Override
- public java.lang.String getName() {
- return this.attributeName;
- }
-
- @Override
- public boolean isId() {
- return true;
- }
- }
-
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmReferentialConstraintRoleTest.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmReferentialConstraintRoleTest.java b/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmReferentialConstraintRoleTest.java
deleted file mode 100644
index 6c8c5eb..0000000
--- a/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmReferentialConstraintRoleTest.java
+++ /dev/null
@@ -1,233 +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.model;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Member;
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.persistence.JoinColumn;
-import javax.persistence.metamodel.Attribute;
-import javax.persistence.metamodel.ManagedType;
-
-import org.apache.olingo.odata2.api.edm.FullQualifiedName;
-import org.apache.olingo.odata2.api.edm.provider.Association;
-import org.apache.olingo.odata2.api.edm.provider.AssociationEnd;
-import org.apache.olingo.odata2.api.edm.provider.EntityType;
-import org.apache.olingo.odata2.api.edm.provider.Mapping;
-import org.apache.olingo.odata2.api.edm.provider.Property;
-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.JPAEdmReferentialConstraintRoleView.RoleType;
-import org.apache.olingo.odata2.processor.core.jpa.common.ODataJPATestConstants;
-import org.apache.olingo.odata2.processor.core.jpa.mock.model.JPAAttributeMock;
-import org.apache.olingo.odata2.processor.core.jpa.mock.model.JPAJavaMemberMock;
-import org.apache.olingo.odata2.processor.core.jpa.mock.model.JPAManagedTypeMock;
-import org.easymock.EasyMock;
-import org.junit.Before;
-import org.junit.Test;
-
-public class JPAEdmReferentialConstraintRoleTest extends JPAEdmTestModelView {
-
- private static JPAEdmReferentialConstraintRole objJPAEdmReferentialConstraintRole = null;
- private static JPAEdmReferentialConstraintRoleTest objJPAEdmReferentialConstraintRoleTest = null;
-
- @Before
- public void setUp() {
- objJPAEdmReferentialConstraintRoleTest = new JPAEdmReferentialConstraintRoleTest();
-
- objJPAEdmReferentialConstraintRole =
- new JPAEdmReferentialConstraintRole(RoleType.PRINCIPAL, objJPAEdmReferentialConstraintRoleTest,
- objJPAEdmReferentialConstraintRoleTest, objJPAEdmReferentialConstraintRoleTest);
-
- try {
- objJPAEdmReferentialConstraintRole.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);
- }
- }
-
- @Test
- public void testIsExists() {
- assertTrue(objJPAEdmReferentialConstraintRole.isExists());// Default
- }
-
- @Test
- public void testGetBuilder() {
- assertNotNull(objJPAEdmReferentialConstraintRole.getBuilder());
- }
-
- @Test
- public void testGetBuilderIdempotent() {
- JPAEdmBuilder builder1 = objJPAEdmReferentialConstraintRole.getBuilder();
- JPAEdmBuilder builder2 = objJPAEdmReferentialConstraintRole.getBuilder();
-
- assertEquals(builder1.hashCode(), builder2.hashCode());
- }
-
- @Test
- public void testGetRoleTypePrincipal() {
- assertEquals(objJPAEdmReferentialConstraintRole.getRoleType(), RoleType.PRINCIPAL);
- }
-
- @Test
- public void testGetRoleTypeDependent() {
- objJPAEdmReferentialConstraintRoleTest = new JPAEdmReferentialConstraintRoleTest();
- objJPAEdmReferentialConstraintRole =
- new JPAEdmReferentialConstraintRole(RoleType.DEPENDENT, objJPAEdmReferentialConstraintRoleTest,
- objJPAEdmReferentialConstraintRoleTest, objJPAEdmReferentialConstraintRoleTest);
-
- try {
- objJPAEdmReferentialConstraintRole.getBuilder().build();
- objJPAEdmReferentialConstraintRole.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);
- }
- assertEquals(objJPAEdmReferentialConstraintRole.getRoleType(), RoleType.DEPENDENT);
- }
-
- @Test
- public void testGetEdmReferentialConstraintRole() {
- try {
- objJPAEdmReferentialConstraintRole.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);
- }
- assertNotNull(objJPAEdmReferentialConstraintRole.getEdmReferentialConstraintRole());
- }
-
- @Test
- public void testGetJPAColumnName() {
- assertNull(objJPAEdmReferentialConstraintRole.getJPAColumnName());
- }
-
- @Test
- public void testGetEdmEntityTypeName() {
- assertNull(objJPAEdmReferentialConstraintRole.getEdmEntityTypeName());
- }
-
- @Test
- public void testGetEdmAssociationName() {
- assertNull(objJPAEdmReferentialConstraintRole.getEdmAssociationName());
- }
-
- @Override
- public Attribute<?, ?> getJPAAttribute() {
- return getJPAAttributeLocal();
- }
-
- @Override
- public Association getEdmAssociation() {
- Association association = new Association();
- association.setName("Assoc_SalesOrderHeader_SalesOrderItem");
- association.setEnd1(new AssociationEnd().setType(new FullQualifiedName("salesorderprocessing", "String")).setRole(
- "SalesOrderHeader"));
- association.setEnd2(new AssociationEnd().setType(new FullQualifiedName("salesorderprocessing", "SalesOrderItem"))
- .setRole("SalesOrderItem"));
- return association;
- }
-
- @Override
- public EntityType searchEdmEntityType(final String arg0) {
-
- EntityType entityType = new EntityType();
-
- JPAEdmMappingImpl mapping = new JPAEdmMappingImpl();
- mapping.setJPAColumnName("SOID");
-
- List<Property> propList = new ArrayList<Property>();
-
- Property property = new Property() {};
- property.setMapping((Mapping) mapping);
- property.setName("SOID");
- propList.add(property);
-
- entityType.setProperties(propList);
-
- return entityType;
- }
-
- private Attribute<?, ?> getJPAAttributeLocal() {
- AttributeMock<Object, String> attr = new AttributeMock<Object, String>();
- return attr;
- }
-
- @SuppressWarnings("hiding")
- private class AttributeMock<Object, String> extends JPAAttributeMock<Object, String> {
-
- @Override
- public Member getJavaMember() {
- return new JavaMemberMock();
- }
-
- @SuppressWarnings("unchecked")
- @Override
- public Class<String> getJavaType() {
- return (Class<String>) java.lang.String.class;
- }
-
- @SuppressWarnings("unchecked")
- @Override
- public ManagedType<Object> getDeclaringType() {
- return (ManagedType<Object>) getManagedTypeLocal();
- }
-
- private ManagedType<?> getManagedTypeLocal() {
- ManagedTypeMock<String> managedTypeMock = new ManagedTypeMock<String>();
- return managedTypeMock;
- }
- }
-
- @SuppressWarnings("hiding")
- private class ManagedTypeMock<String> extends JPAManagedTypeMock<String> {
-
- @SuppressWarnings("unchecked")
- @Override
- public Class<String> getJavaType() {
- return (Class<String>) java.lang.String.class;
- }
- }
-
- private class JavaMemberMock extends JPAJavaMemberMock {
- @SuppressWarnings("unchecked")
- @Override
- public <T extends Annotation> T getAnnotation(final Class<T> annotationClass) {
- JoinColumn joinColumn = EasyMock.createMock(JoinColumn.class);
- EasyMock.expect(joinColumn.referencedColumnName()).andReturn("SOID");
- EasyMock.expect(joinColumn.name()).andReturn("SOID");
-
- EasyMock.replay(joinColumn);
- return (T) joinColumn;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmReferentialConstraintTest.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmReferentialConstraintTest.java b/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmReferentialConstraintTest.java
deleted file mode 100644
index 84b7ad4..0000000
--- a/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmReferentialConstraintTest.java
+++ /dev/null
@@ -1,177 +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.model;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Member;
-
-import javax.persistence.JoinColumn;
-import javax.persistence.metamodel.Attribute;
-import javax.persistence.metamodel.ManagedType;
-
-import org.apache.olingo.odata2.api.edm.FullQualifiedName;
-import org.apache.olingo.odata2.api.edm.provider.Association;
-import org.apache.olingo.odata2.api.edm.provider.AssociationEnd;
-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.core.jpa.common.ODataJPATestConstants;
-import org.apache.olingo.odata2.processor.core.jpa.mock.model.JPAAttributeMock;
-import org.apache.olingo.odata2.processor.core.jpa.mock.model.JPAJavaMemberMock;
-import org.apache.olingo.odata2.processor.core.jpa.mock.model.JPAManagedTypeMock;
-import org.easymock.EasyMock;
-import org.junit.Before;
-import org.junit.Test;
-
-public class JPAEdmReferentialConstraintTest extends JPAEdmTestModelView {
-
- private static JPAEdmReferentialConstraint objJPAEdmReferentialConstraint = null;
- private static JPAEdmReferentialConstraintTest objJPAEdmReferentialConstraintTest = null;
-
- @Before
- public void setUp() {
- objJPAEdmReferentialConstraintTest = new JPAEdmReferentialConstraintTest();
- objJPAEdmReferentialConstraint =
- new JPAEdmReferentialConstraint(objJPAEdmReferentialConstraintTest, objJPAEdmReferentialConstraintTest,
- objJPAEdmReferentialConstraintTest);
- try {
- objJPAEdmReferentialConstraint.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);
- }
- }
-
- @Test
- public void testGetBuilder() {
- assertNotNull(objJPAEdmReferentialConstraint.getBuilder());
- }
-
- @Test
- public void testGetBuilderIdempotent() {
- JPAEdmBuilder builder1 = objJPAEdmReferentialConstraint.getBuilder();
- JPAEdmBuilder builder2 = objJPAEdmReferentialConstraint.getBuilder();
-
- assertEquals(builder1.hashCode(), builder2.hashCode());
- }
-
- @Test
- public void testGetEdmReferentialConstraint() {
- assertNotNull(objJPAEdmReferentialConstraint.getEdmReferentialConstraint());
- }
-
- @Test
- public void testIsExistsTrue() {
- objJPAEdmReferentialConstraintTest = new JPAEdmReferentialConstraintTest();
- objJPAEdmReferentialConstraint =
- new JPAEdmReferentialConstraint(objJPAEdmReferentialConstraintTest, objJPAEdmReferentialConstraintTest,
- objJPAEdmReferentialConstraintTest);
- try {
- objJPAEdmReferentialConstraint.getBuilder().build();
- objJPAEdmReferentialConstraint.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);
- }
- assertTrue(objJPAEdmReferentialConstraint.isExists());
- }
-
- @Test
- public void testGetRelationShipName() {
- assertEquals("Assoc_SalesOrderHeader_SalesOrderItem", objJPAEdmReferentialConstraint.getEdmRelationShipName());
- }
-
- @Override
- public Association getEdmAssociation() {
- Association association = new Association();
- association.setName("Assoc_SalesOrderHeader_SalesOrderItem");
- association.setEnd1(new AssociationEnd().setType(new FullQualifiedName("salesorderprocessing", "String")).setRole(
- "SalesOrderHeader"));
- association.setEnd2(new AssociationEnd().setType(new FullQualifiedName("salesorderprocessing", "SalesOrderItem"))
- .setRole("SalesOrderItem"));
- return association;
- }
-
- private Attribute<?, ?> getJPAAttributeLocal() {
- AttributeMock<Object, String> attr = new AttributeMock<Object, String>();
- return attr;
- }
-
- @Override
- public Attribute<?, ?> getJPAAttribute() {
- return getJPAAttributeLocal();
- }
-
- @SuppressWarnings("hiding")
- private class AttributeMock<Object, String> extends JPAAttributeMock<Object, String> {
-
- @Override
- public Member getJavaMember() {
- return new JavaMemberMock();
- }
-
- @SuppressWarnings("unchecked")
- @Override
- public Class<String> getJavaType() {
- return (Class<String>) java.lang.String.class;
- }
-
- @SuppressWarnings("unchecked")
- @Override
- public ManagedType<Object> getDeclaringType() {
- return (ManagedType<Object>) getManagedTypeLocal();
- }
-
- private ManagedType<?> getManagedTypeLocal() {
- ManagedTypeMock<String> managedTypeMock = new ManagedTypeMock<String>();
- return managedTypeMock;
- }
- }
-
- @SuppressWarnings("hiding")
- private class ManagedTypeMock<String> extends JPAManagedTypeMock<String> {
-
- @SuppressWarnings("unchecked")
- @Override
- public Class<String> getJavaType() {
- return (Class<String>) java.lang.String.class;
- }
- }
-
- private class JavaMemberMock extends JPAJavaMemberMock {
- @SuppressWarnings("unchecked")
- @Override
- public <T extends Annotation> T getAnnotation(final Class<T> annotationClass) {
- JoinColumn joinColumn = EasyMock.createMock(JoinColumn.class);
- EasyMock.expect(joinColumn.referencedColumnName()).andReturn("SOID");
- EasyMock.expect(joinColumn.name()).andReturn("SOID");
-
- EasyMock.replay(joinColumn);
- return (T) joinColumn;
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmSchemaTest.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmSchemaTest.java b/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmSchemaTest.java
deleted file mode 100644
index 9d6848a..0000000
--- a/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmSchemaTest.java
+++ /dev/null
@@ -1,103 +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.model;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-
-import javax.persistence.metamodel.Metamodel;
-
-import org.apache.olingo.odata2.processor.api.jpa.access.JPAEdmBuilder;
-import org.apache.olingo.odata2.processor.core.jpa.mock.model.JPAMetaModelMock;
-import org.junit.Before;
-import org.junit.Test;
-
-public class JPAEdmSchemaTest extends JPAEdmTestModelView {
- private JPAEdmSchemaTest objJPAEdmSchemaTest;
- private JPAEdmSchema objJPAEdmSchema;
-
- @Before
- public void setUp() {
- objJPAEdmSchemaTest = new JPAEdmSchemaTest();
- objJPAEdmSchema = new JPAEdmSchema(objJPAEdmSchemaTest);
- // building schema is not required as downstream structure already tested
-
- }
-
- @Test
- public void testClean() {
- assertTrue(objJPAEdmSchema.isConsistent());
- objJPAEdmSchema.clean();
- assertFalse(objJPAEdmSchema.isConsistent());
- }
-
- @Test
- public void testGetEdmSchema() {
- assertNull(objJPAEdmSchema.getEdmSchema());
- }
-
- @Test
- public void testGetJPAEdmEntityContainerView() {
- assertNull(objJPAEdmSchema.getJPAEdmEntityContainerView());
- }
-
- @Test
- public void testGetJPAEdmComplexTypeView() {
- assertNull(objJPAEdmSchema.getJPAEdmComplexTypeView());
- }
-
- @Test
- public void testGetBuilder() {
- assertNotNull(objJPAEdmSchema.getBuilder());
- }
-
- @Test
- public void testGetBuilderIdempotent() {
- JPAEdmBuilder builder1 = objJPAEdmSchema.getBuilder();
- JPAEdmBuilder builder2 = objJPAEdmSchema.getBuilder();
-
- assertEquals(builder1.hashCode(), builder2.hashCode());
- }
-
- @Test
- public void testGetJPAEdmAssociationView() {
- assertNull(objJPAEdmSchema.getJPAEdmAssociationView());
- }
-
- @Test
- public void testIsConsistent() {
- assertTrue(objJPAEdmSchema.isConsistent());
- objJPAEdmSchema.clean();
- assertFalse(objJPAEdmSchema.isConsistent());
- }
-
- @Override
- public Metamodel getJPAMetaModel() {
- return new JPAMetaModelMock();
- }
-
- @Override
- public String getpUnitName() {
- return "salesorderprocessing";
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmTestModelView.java
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmTestModelView.java b/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmTestModelView.java
deleted file mode 100644
index cf96ac7..0000000
--- a/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmTestModelView.java
+++ /dev/null
@@ -1,396 +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.model;
-
-import java.util.HashMap;
-import java.util.List;
-
-import javax.persistence.metamodel.Attribute;
-import javax.persistence.metamodel.EmbeddableType;
-import javax.persistence.metamodel.Metamodel;
-
-import org.apache.olingo.odata2.api.edm.FullQualifiedName;
-import org.apache.olingo.odata2.api.edm.provider.Association;
-import org.apache.olingo.odata2.api.edm.provider.AssociationEnd;
-import org.apache.olingo.odata2.api.edm.provider.AssociationSet;
-import org.apache.olingo.odata2.api.edm.provider.ComplexProperty;
-import org.apache.olingo.odata2.api.edm.provider.ComplexType;
-import org.apache.olingo.odata2.api.edm.provider.EntityContainer;
-import org.apache.olingo.odata2.api.edm.provider.EntitySet;
-import org.apache.olingo.odata2.api.edm.provider.EntityType;
-import org.apache.olingo.odata2.api.edm.provider.Key;
-import org.apache.olingo.odata2.api.edm.provider.NavigationProperty;
-import org.apache.olingo.odata2.api.edm.provider.Property;
-import org.apache.olingo.odata2.api.edm.provider.ReferentialConstraint;
-import org.apache.olingo.odata2.api.edm.provider.Schema;
-import org.apache.olingo.odata2.api.edm.provider.SimpleProperty;
-import org.apache.olingo.odata2.processor.api.jpa.access.JPAEdmBuilder;
-import org.apache.olingo.odata2.processor.api.jpa.access.JPAEdmMappingModelAccess;
-import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmAssociationEndView;
-import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmAssociationSetView;
-import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmAssociationView;
-import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmBaseView;
-import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmComplexPropertyView;
-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.JPAEdmExtension;
-import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmKeyView;
-import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmModelView;
-import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmNavigationPropertyView;
-import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmPropertyView;
-import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmReferentialConstraintView;
-import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmSchemaView;
-
-public class JPAEdmTestModelView implements JPAEdmAssociationEndView, JPAEdmAssociationSetView, JPAEdmAssociationView,
- JPAEdmBaseView, JPAEdmComplexPropertyView, JPAEdmComplexTypeView, JPAEdmEntityContainerView, JPAEdmEntitySetView,
- JPAEdmEntityTypeView, JPAEdmKeyView, JPAEdmModelView, JPAEdmNavigationPropertyView, JPAEdmPropertyView,
- JPAEdmReferentialConstraintView, JPAEdmSchemaView {
-
- protected JPAEdmMappingModelAccess mappingModelAccess;
-
- @Override
- public Schema getEdmSchema() {
- return null;
- }
-
- @Override
- public JPAEdmAssociationView getJPAEdmAssociationView() {
- return null;
- }
-
- @Override
- public JPAEdmComplexTypeView getJPAEdmComplexTypeView() {
- return null;
- }
-
- @Override
- public JPAEdmEntityContainerView getJPAEdmEntityContainerView() {
- return null;
- }
-
- @Override
- public Attribute<?, ?> getJPAAttribute() {
- return null;
- }
-
- @Override
- public JPAEdmKeyView getJPAEdmKeyView() {
- return null;
- }
-
- @Override
- public List<Property> getEdmPropertyList() {
- return null;
- }
-
- @Override
- public SimpleProperty getEdmSimpleProperty() {
- return null;
- }
-
- @Override
- public JPAEdmSchemaView getEdmSchemaView() {
- return null;
- }
-
- @Override
- public Key getEdmKey() {
- return null;
- }
-
- @Override
- public List<EntityType> getConsistentEdmEntityTypes() {
- return null;
- }
-
- @Override
- public EntityType getEdmEntityType() {
- return null;
- }
-
- @Override
- public javax.persistence.metamodel.EntityType<?> getJPAEntityType() {
- return null;
- }
-
- @Override
- public List<EntitySet> getConsistentEdmEntitySetList() {
- return null;
- }
-
- @Override
- public EntitySet getEdmEntitySet() {
- return null;
- }
-
- @Override
- public JPAEdmEntityTypeView getJPAEdmEntityTypeView() {
- return null;
- }
-
- @Override
- public List<EntityContainer> getConsistentEdmEntityContainerList() {
- return null;
- }
-
- @Override
- public JPAEdmAssociationSetView getEdmAssociationSetView() {
- return null;
- }
-
- @Override
- public EntityContainer getEdmEntityContainer() {
- return null;
- }
-
- @Override
- public JPAEdmEntitySetView getJPAEdmEntitySetView() {
- return null;
- }
-
- @Override
- public void addJPAEdmCompleTypeView(final JPAEdmComplexTypeView arg0) {
-
- }
-
- @Override
- public List<ComplexType> getConsistentEdmComplexTypes() {
- return null;
- }
-
- @Override
- public ComplexType getEdmComplexType() {
- return null;
- }
-
- @Override
- public EmbeddableType<?> getJPAEmbeddableType() {
- return null;
- }
-
- @Override
- public ComplexType searchEdmComplexType(final String arg0) {
- return null;
- }
-
- @Override
- public ComplexType searchEdmComplexType(final FullQualifiedName arg0) {
- return null;
- }
-
- @Override
- public ComplexProperty getEdmComplexProperty() {
- return null;
- }
-
- @Override
- public void clean() {
-
- }
-
- @Override
- public JPAEdmBuilder getBuilder() {
- return null;
- }
-
- @Override
- public Metamodel getJPAMetaModel() {
- return null;
- }
-
- @Override
- public String getpUnitName() {
- return null;
- }
-
- @Override
- public boolean isConsistent() {
- return false;
- }
-
- @Override
- public void addJPAEdmRefConstraintView(final JPAEdmReferentialConstraintView arg0) {
-
- }
-
- @Override
- public ReferentialConstraint getEdmReferentialConstraint() {
- return null;
- }
-
- @Override
- public String getEdmRelationShipName() {
- return null;
- }
-
- @Override
- public boolean isExists() {
- return false;
- }
-
- @Override
- public EntityType searchEdmEntityType(final String arg0) {
- return null;
- }
-
- @Override
- public JPAEdmReferentialConstraintView getJPAEdmReferentialConstraintView() {
- return null;
- }
-
- @Override
- public List<Association> getConsistentEdmAssociationList() {
- return null;
- }
-
- @Override
- public Association searchAssociation(final JPAEdmAssociationEndView arg0) {
- return null;
- }
-
- @Override
- public List<AssociationSet> getConsistentEdmAssociationSetList() {
- return null;
- }
-
- @Override
- public Association getEdmAssociation() {
- return null;
- }
-
- @Override
- public AssociationSet getEdmAssociationSet() {
- return null;
- }
-
- @Override
- public boolean compare(final AssociationEnd arg0, final AssociationEnd arg1) {
- return false;
- }
-
- @Override
- public AssociationEnd getEdmAssociationEnd1() {
- return null;
- }
-
- @Override
- public AssociationEnd getEdmAssociationEnd2() {
- return null;
- }
-
- @Override
- public JPAEdmNavigationPropertyView getJPAEdmNavigationPropertyView() {
- return null;
- }
-
- @Override
- public void addJPAEdmNavigationPropertyView(final JPAEdmNavigationPropertyView view) {
-
- }
-
- @Override
- public List<NavigationProperty> getConsistentEdmNavigationProperties() {
- return null;
- }
-
- @Override
- public NavigationProperty getEdmNavigationProperty() {
- return null;
- }
-
- @Override
- public void expandEdmComplexType(final ComplexType complexType, final List<Property> expandedPropertyList,
- final String embeddablePropertyName) {
-
- }
-
- @Override
- public List<String> getNonKeyComplexTypeList() {
- return null;
- }
-
- @Override
- public void addNonKeyComplexName(final String complexTypeName) {}
-
- @Override
- public JPAEdmMappingModelAccess getJPAEdmMappingModelAccess() {
- return null;
- }
-
- @Override
- public void registerOperations(final Class<?> customClass, final String[] methodNames) {
- // Do nothing
- }
-
- @Override
- public HashMap<Class<?>, String[]> getRegisteredOperations() {
- return null;
- }
-
- @Override
- public JPAEdmExtension getJPAEdmExtension() {
- return null;
- }
-
- @Override
- public void addJPAEdmAssociationView(final JPAEdmAssociationView associationView,
- final JPAEdmAssociationEndView associationEndView) {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public int getNumberOfAssociationsWithSimilarEndPoints(final JPAEdmAssociationEndView view) {
- // TODO Auto-generated method stub
- return 0;
- }
-
- @Override
- public String getJoinColumnName() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public String getJoinColumnReferenceColumnName() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public String getMappedByName() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public String getOwningPropertyName() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public boolean isDefaultNamingSkipped() {
- // TODO Auto-generated method stub
- return false;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/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
deleted file mode 100644
index d596e77..0000000
--- a/odata2-processor-jpa/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/model/_JPAEdmFunctionImportTest.java
+++ /dev/null
@@ -1,570 +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.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/1b479e6c/odata2-processor-jpa/jpa-core/src/test/resources/SalesOrderProcessingMappingModels.xml
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-core/src/test/resources/SalesOrderProcessingMappingModels.xml b/odata2-processor-jpa/jpa-core/src/test/resources/SalesOrderProcessingMappingModels.xml
deleted file mode 100644
index d81cae9..0000000
--- a/odata2-processor-jpa/jpa-core/src/test/resources/SalesOrderProcessingMappingModels.xml
+++ /dev/null
@@ -1,62 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- 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.
--->
-<JPAEDMMappingModel
- xmlns="http://www.apache.org/olingo/odata2/processor/api/jpa/model/mapping">
- <PersistenceUnit name="salesorderprocessing">
- <EDMSchemaNamespace>SalesOrderProcessing</EDMSchemaNamespace>
- <JPAEntityTypes>
- <JPAEntityType name="SalesOrderHeader">
- <EDMEntityType>SalesOrder</EDMEntityType>
- <EDMEntitySet>SalesOrders</EDMEntitySet>
- <JPAAttributes>
- <JPAAttribute name="soId"></JPAAttribute>
- <JPAAttribute name="netAmount">NetAmount</JPAAttribute>
- <JPAAttribute name="buyerAddress">BuyerAddressInfo</JPAAttribute>
- </JPAAttributes>
- <JPARelationships>
- <JPARelationship name="salesOrderItems">SalesOrderItemDetails</JPARelationship>
- <JPARelationship name="notes">NoteDetails</JPARelationship>
- </JPARelationships>
- </JPAEntityType>
- <JPAEntityType name="SalesOrderItem">
- <EDMEntityType>SalesOrderItem</EDMEntityType>
- <EDMEntitySet>SalesOrderItems</EDMEntitySet>
- <JPAAttributes>
- <JPAAttribute name="liId">ID</JPAAttribute>
- <JPAAttribute name="soId">SalesOrderID</JPAAttribute>
- </JPAAttributes>
- <JPARelationships>
- <JPARelationship name="salesOrderHeader">SalesOrderHeaderDetails</JPARelationship>
- <JPARelationship name="materials">MaterialDetails
- </JPARelationship>
- </JPARelationships>
- </JPAEntityType>
- </JPAEntityTypes>
- <JPAEmbeddableTypes>
- <JPAEmbeddableType name="SalesOrderItemKey">
- <EDMComplexType>SalesOrderLineItemKey</EDMComplexType>
- <JPAAttributes>
- <JPAAttribute name="liId">ID</JPAAttribute>
- <JPAAttribute name="soId">SalesOrderID</JPAAttribute>
- </JPAAttributes>
- </JPAEmbeddableType>
- </JPAEmbeddableTypes>
- </PersistenceUnit>
-</JPAEDMMappingModel>
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-processor-jpa/jpa-ref/.gitignore
----------------------------------------------------------------------
diff --git a/odata2-processor-jpa/jpa-ref/.gitignore b/odata2-processor-jpa/jpa-ref/.gitignore
deleted file mode 100644
index fe5d89b..0000000
--- a/odata2-processor-jpa/jpa-ref/.gitignore
+++ /dev/null
@@ -1,8 +0,0 @@
-.project
-.classpath
-.settings
-target
-bin
-*.bak
-classes
-.DS_Store
\ No newline at end of file
[36/37] [OLINGO-82] Renamed the project folder name to
odata2-jpa-processor
Posted by ch...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/access/package-info.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/access/package-info.java b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/access/package-info.java
new file mode 100644
index 0000000..38671c1
--- /dev/null
+++ b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/access/package-info.java
@@ -0,0 +1,26 @@
+/*******************************************************************************
+ * 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.
+ ******************************************************************************/
+/**
+ * <h3>OData JPA Processor API Library - Java Persistence Access</h3>
+ * The library provides a set of APIs to access Java Persistence Models and Data.
+ *
+ *
+ */
+package org.apache.olingo.odata2.processor.api.jpa.access;
+
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/exception/ODataJPAErrorCallback.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/exception/ODataJPAErrorCallback.java b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/exception/ODataJPAErrorCallback.java
new file mode 100644
index 0000000..9f78af0
--- /dev/null
+++ b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/exception/ODataJPAErrorCallback.java
@@ -0,0 +1,45 @@
+/*******************************************************************************
+ * 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.api.jpa.exception;
+
+import org.apache.olingo.odata2.api.ep.EntityProvider;
+import org.apache.olingo.odata2.api.exception.ODataApplicationException;
+import org.apache.olingo.odata2.api.processor.ODataErrorCallback;
+import org.apache.olingo.odata2.api.processor.ODataErrorContext;
+import org.apache.olingo.odata2.api.processor.ODataResponse;
+
+public class ODataJPAErrorCallback implements ODataErrorCallback {
+
+ @Override
+ public ODataResponse handleError(final ODataErrorContext context) throws ODataApplicationException {
+
+ final String SEPARATOR = " : ";
+
+ Throwable t = context.getException();
+ if (t instanceof ODataJPAException) {
+ StringBuilder errorBuilder = new StringBuilder();
+ errorBuilder.append(t.getCause().getClass().toString());
+ errorBuilder.append(SEPARATOR);
+ errorBuilder.append(t.getCause().getMessage());
+ context.setInnerError(errorBuilder.toString());
+ }
+ return EntityProvider.writeErrorDocument(context);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/exception/ODataJPAException.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/exception/ODataJPAException.java b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/exception/ODataJPAException.java
new file mode 100644
index 0000000..3347ee0
--- /dev/null
+++ b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/exception/ODataJPAException.java
@@ -0,0 +1,68 @@
+/*******************************************************************************
+ * 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.api.jpa.exception;
+
+import java.util.Locale;
+
+import org.apache.olingo.odata2.api.exception.MessageReference;
+import org.apache.olingo.odata2.api.exception.ODataException;
+
+/**
+ * The exception class is the base of OData JPA exceptions. The class also
+ * provides non localized error texts that can be used for raising OData JPA
+ * exceptions with non localized error texts.
+ *
+ *
+ *
+ */
+public abstract class ODataJPAException extends ODataException {
+
+ protected MessageReference messageReference;
+
+ public static final String ODATA_JPACTX_NULL = "OData JPA Context cannot be null";
+
+ private static final long serialVersionUID = -6884673558124441214L;
+ protected static final Locale DEFAULT_LOCALE = Locale.ENGLISH;
+
+ protected ODataJPAException(final String localizedMessage, final Throwable e, final MessageReference msgRef) {
+ super(localizedMessage, e);
+ messageReference = msgRef;
+ }
+
+ /**
+ * The method creates a Reference to Message Object {@link org.apache.olingo.odata2.api.exception.MessageReference} .
+ * The message
+ * text key is derived out of parameters clazz.messageReferenceKey.
+ *
+ * @param clazz
+ * is name of the class extending {@link org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPAException}
+ * @param messageReferenceKey
+ * is the key of the message
+ * @return an instance of type {@link org.apache.olingo.odata2.api.exception.MessageReference}
+ */
+ protected static MessageReference createMessageReference(final Class<? extends ODataJPAException> clazz,
+ final String messageReferenceKey) {
+ return MessageReference.create(clazz, messageReferenceKey);
+ }
+
+ public MessageReference getMessageReference() {
+ return messageReference;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/exception/ODataJPAMessageService.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/exception/ODataJPAMessageService.java b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/exception/ODataJPAMessageService.java
new file mode 100644
index 0000000..97dc1bf
--- /dev/null
+++ b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/exception/ODataJPAMessageService.java
@@ -0,0 +1,49 @@
+/*******************************************************************************
+ * 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.api.jpa.exception;
+
+import org.apache.olingo.odata2.api.exception.MessageReference;
+
+/**
+ * The interface is used to access language dependent message texts. Default
+ * language is "English - EN". <br>
+ * The default implementation of the interface shipped with the library loads
+ * message texts from language dependent property files. If the message text is
+ * not found for the given language then the default language -EN is used for
+ * the message texts.
+ *
+ *
+ * @see org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPAException
+ * @see org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPARuntimeException
+ * @see org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPAModelException
+ * @see org.apache.olingo.odata2.api.exception.MessageReference
+ */
+public interface ODataJPAMessageService {
+ /**
+ * The method returns a language dependent message texts for the given
+ * {@link org.apache.olingo.odata2.api.exception.MessageReference}.
+ *
+ * @param context
+ * is a Message Reference
+ * exception
+ * is a Throwable Exception
+ * @return a language dependent message text
+ */
+ public String getLocalizedMessage(MessageReference context, Throwable exception);
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/exception/ODataJPAModelException.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/exception/ODataJPAModelException.java b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/exception/ODataJPAModelException.java
new file mode 100644
index 0000000..7800b9e
--- /dev/null
+++ b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/exception/ODataJPAModelException.java
@@ -0,0 +1,92 @@
+/*******************************************************************************
+ * 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.api.jpa.exception;
+
+import org.apache.olingo.odata2.api.exception.MessageReference;
+import org.apache.olingo.odata2.processor.api.jpa.factory.ODataJPAFactory;
+
+/**
+ * The exception is thrown for any unexpected errors raising while
+ * accessing/transforming Java Persistence Models.
+ *
+ *
+ *
+ */
+public class ODataJPAModelException extends ODataJPAException {
+
+ public static final MessageReference INVALID_ENTITY_TYPE = createMessageReference(ODataJPAModelException.class,
+ "INVALID_ENTITY_TYPE");
+ public static final MessageReference INVALID_COMPLEX_TYPE = createMessageReference(ODataJPAModelException.class,
+ "INVLAID_COMPLEX_TYPE");
+ public static final MessageReference INVALID_ASSOCIATION = createMessageReference(ODataJPAModelException.class,
+ "INVALID_ASSOCIATION");
+ public static final MessageReference INVALID_ENTITYSET = createMessageReference(ODataJPAModelException.class,
+ "INVALID_ENTITYSET");
+ public static final MessageReference INVALID_ENTITYCONTAINER = createMessageReference(ODataJPAModelException.class,
+ "INVALID_ENTITYCONTAINER");
+ public static final MessageReference INVALID_ASSOCIATION_SET = createMessageReference(ODataJPAModelException.class,
+ "INVALID_ASSOCIATION_SET");
+ public static final MessageReference INVALID_FUNC_IMPORT = createMessageReference(ODataJPAModelException.class,
+ "INVALID_FUNC_IMPORT");
+
+ public static final MessageReference BUILDER_NULL = createMessageReference(ODataJPAModelException.class,
+ "BUILDER_NULL");
+ public static final MessageReference TYPE_NOT_SUPPORTED = createMessageReference(ODataJPAModelException.class,
+ "TYPE_NOT_SUPPORTED");
+ public static final MessageReference FUNC_ENTITYSET_EXP = createMessageReference(ODataJPAModelException.class,
+ "FUNC_ENTITYSET_EXP");
+ public static final MessageReference FUNC_RETURN_TYPE_EXP = createMessageReference(ODataJPAModelException.class,
+ "FUNC_RETURN_TYPE_EXP");
+ public static final MessageReference FUNC_RETURN_TYPE_ENTITY_NOT_FOUND = createMessageReference(
+ ODataJPAModelException.class, "FUNC_RETURN_TYPE_ENTITY_NOT_FOUND");
+ public static final MessageReference GENERAL = createMessageReference(ODataJPAModelException.class, "GENERAL");
+ public static final MessageReference INNER_EXCEPTION = createMessageReference(ODataJPAModelException.class,
+ "INNER_EXCEPTION");
+ public static final MessageReference FUNC_PARAM_NAME_EXP = createMessageReference(ODataJPAModelException.class,
+ "FUNC_PARAM_NAME_EXP");
+
+ private ODataJPAModelException(final String localizedMessage, final Throwable e, final MessageReference msgRef) {
+ super(localizedMessage, e, msgRef);
+ }
+
+ /**
+ * The method creates an exception object of type ODataJPAModelException
+ * with localized error texts.
+ *
+ * @param messageReference
+ * is a <b>mandatory</b> parameter referring to a literal that
+ * could be translated to localized error texts.
+ * @param e
+ * is an optional parameter representing the previous exception
+ * in the call stack
+ * @return an instance of ODataJPAModelException which can be then raised.
+ * @throws ODataJPARuntimeException
+ */
+ public static ODataJPAModelException throwException(final MessageReference messageReference, final Throwable e) {
+
+ ODataJPAMessageService messageService;
+ messageService =
+ ODataJPAFactory.createFactory().getODataJPAAccessFactory().getODataJPAMessageService(DEFAULT_LOCALE);
+ String message = messageService.getLocalizedMessage(messageReference, e);
+ return new ODataJPAModelException(message, e, messageReference);
+ }
+
+ private static final long serialVersionUID = 7940106375606950703L;
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/exception/ODataJPARuntimeException.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/exception/ODataJPARuntimeException.java b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/exception/ODataJPARuntimeException.java
new file mode 100644
index 0000000..b3195c3
--- /dev/null
+++ b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/exception/ODataJPARuntimeException.java
@@ -0,0 +1,97 @@
+/*******************************************************************************
+ * 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.api.jpa.exception;
+
+import org.apache.olingo.odata2.api.exception.MessageReference;
+import org.apache.olingo.odata2.processor.api.jpa.factory.ODataJPAFactory;
+
+/**
+ * The exception is thrown for any unexpected errors raising while accessing
+ * data from Java Persistence Models.
+ *
+ * The exception object is created with localized error texts provided error
+ * texts are maintained in localized languages.
+ *
+ *
+ *
+ */
+public class ODataJPARuntimeException extends ODataJPAException {
+
+ public static final MessageReference ENTITY_MANAGER_NOT_INITIALIZED = createMessageReference(
+ ODataJPARuntimeException.class, "ENTITY_MANAGER_NOT_INITIALIZED");
+ public static final MessageReference RESOURCE_NOT_FOUND = createMessageReference(ODataJPARuntimeException.class,
+ "RESOURCE_NOT_FOUND");
+ public static final MessageReference GENERAL = createMessageReference(ODataJPARuntimeException.class, "GENERAL");
+ public static final MessageReference INNER_EXCEPTION = createMessageReference(ODataJPARuntimeException.class,
+ "INNER_EXCEPTION");
+ public static final MessageReference JOIN_CLAUSE_EXPECTED = createMessageReference(ODataJPARuntimeException.class,
+ "JOIN_CLAUSE_EXPECTED");
+ public static final MessageReference ERROR_JPQLCTXBLDR_CREATE = createMessageReference(
+ ODataJPARuntimeException.class, "ERROR_JPQLCTXBLDR_CREATE");
+ public static final MessageReference ERROR_ODATA_FILTER_CONDITION = createMessageReference(
+ ODataJPARuntimeException.class, "ERROR_ODATA_FILTER_CONDITION");
+ public static final MessageReference ERROR_JPQL_QUERY_CREATE = createMessageReference(ODataJPARuntimeException.class,
+ "ERROR_JPQL_QUERY_CREATE");
+ public static final MessageReference ERROR_JPQL_CREATE_REQUEST = createMessageReference(
+ ODataJPARuntimeException.class, "ERROR_JPQL_CREATE_REQUEST");
+ public static final MessageReference ERROR_JPQL_UPDATE_REQUEST = createMessageReference(
+ ODataJPARuntimeException.class, "ERROR_JPQL_UPDATE_REQUEST");
+ public static final MessageReference ERROR_JPQL_DELETE_REQUEST = createMessageReference(
+ ODataJPARuntimeException.class, "ERROR_JPQL_DELETE_REQUEST");
+ public static final MessageReference ERROR_JPQL_KEY_VALUE = createMessageReference(ODataJPARuntimeException.class,
+ "ERROR_JPQL_KEY_VALUE");
+ public static final MessageReference ERROR_JPQL_PARAM_VALUE = createMessageReference(ODataJPARuntimeException.class,
+ "ERROR_JPQL_PARAM_VALUE");
+ public static final MessageReference ERROR_JPQL_UNIQUE_CONSTRAINT = createMessageReference(
+ ODataJPARuntimeException.class, "ERROR_JPQL_UNIQUE_CONSTRAINT");
+ public static final MessageReference ERROR_JPQL_INTEGRITY_CONSTRAINT = createMessageReference(
+ ODataJPARuntimeException.class, "ERROR_JPQL_INTEGRITY_CONSTRAINT");
+ public static final MessageReference RELATIONSHIP_INVALID = createMessageReference(ODataJPARuntimeException.class,
+ "RELATIONSHIP_INVALID");
+ public static final MessageReference RESOURCE_X_NOT_FOUND = createMessageReference(ODataJPARuntimeException.class,
+ "RESOURCE_X_NOT_FOUND");
+
+ private ODataJPARuntimeException(final String localizedMessage, final Throwable e, final MessageReference msgRef) {
+ super(localizedMessage, e, msgRef);
+ }
+
+ /**
+ * The method creates an exception object of type ODataJPARuntimeException
+ * with localized error texts.
+ *
+ * @param messageReference
+ * is a <b>mandatory</b> parameter referring to a literal that
+ * could be translated to localized error texts.
+ * @param e
+ * is an optional parameter representing the previous exception
+ * in the call stack
+ * @return an instance of ODataJPARuntimeException which can be then raised.
+ * @throws ODataJPARuntimeException
+ */
+ public static ODataJPARuntimeException throwException(final MessageReference messageReference, final Throwable e) {
+ ODataJPAMessageService messageService;
+ messageService =
+ ODataJPAFactory.createFactory().getODataJPAAccessFactory().getODataJPAMessageService(DEFAULT_LOCALE);
+ String message = messageService.getLocalizedMessage(messageReference, e);
+ return new ODataJPARuntimeException(message, e, messageReference);
+ }
+
+ private static final long serialVersionUID = -5230976355642443012L;
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/exception/package-info.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/exception/package-info.java b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/exception/package-info.java
new file mode 100644
index 0000000..5059bb4
--- /dev/null
+++ b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/exception/package-info.java
@@ -0,0 +1,31 @@
+/*******************************************************************************
+ * 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.
+ ******************************************************************************/
+/**
+ * <h3>OData JPA Processor API Library - Exceptions</h3>
+ * There are two main types of exceptions thrown from the library
+ * <ol><li>Model Exception</li>
+ * <li>Runtime Exception</li></ol>
+ * <br>
+ * The Model Exception is thrown while processing JPA metamodels and
+ * runtime exception is thrown while processing persistence data.
+ *
+ *
+ */
+package org.apache.olingo.odata2.processor.api.jpa.exception;
+
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/factory/JPAAccessFactory.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/factory/JPAAccessFactory.java b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/factory/JPAAccessFactory.java
new file mode 100644
index 0000000..02268de
--- /dev/null
+++ b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/factory/JPAAccessFactory.java
@@ -0,0 +1,69 @@
+/*******************************************************************************
+ * 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.api.jpa.factory;
+
+import org.apache.olingo.odata2.processor.api.jpa.ODataJPAContext;
+import org.apache.olingo.odata2.processor.api.jpa.access.JPAEdmMappingModelAccess;
+import org.apache.olingo.odata2.processor.api.jpa.access.JPAProcessor;
+import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmModelView;
+
+/**
+ * Factory interface for creating
+ * <ol>
+ * <li>JPA EDM Model view</li>
+ * <li>JPA Processor</li>
+ * </ol>
+ *
+ *
+ *
+ */
+public interface JPAAccessFactory {
+ /**
+ * The method returns an instance of JPA EDM model view based on OData JPA
+ * Context. The JPA EDM model view thus returned can be used for building
+ * EDM models from Java persistence models.
+ *
+ * @param oDataJPAContext
+ * a non null instance of {@link org.apache.olingo.odata2.processor.api.jpa.ODataJPAContext}
+ * @return an instance of type {@link org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmModelView}
+ */
+ public JPAEdmModelView getJPAEdmModelView(ODataJPAContext oDataJPAContext);
+
+ /**
+ * The method returns an instance of JPA processor based on OData JPA
+ * Context. The JPA Processor thus returned can be used for building and
+ * processing JPQL statements.
+ *
+ * @param oDataJPAContext
+ * a non null instance of {@link org.apache.olingo.odata2.processor.api.jpa.ODataJPAContext}
+ * @return an instance of type {@link org.apache.olingo.odata2.processor.api.jpa.access.JPAProcessor}
+ */
+ public JPAProcessor getJPAProcessor(ODataJPAContext oDataJPAContext);
+
+ /**
+ * The method returns an instance of JPA EDM mapping model access based on
+ * OData JPA context. The instance thus returned can be used for accessing
+ * the mapping details maintained for an OData service
+ *
+ * @param oDataJPAContext
+ * a non null instance of {@link org.apache.olingo.odata2.processor.api.jpa.ODataJPAContext}
+ * @return an instance of type {@link org.apache.olingo.odata2.processor.api.jpa.access.JPAEdmMappingModelAccess}
+ */
+ public JPAEdmMappingModelAccess getJPAEdmMappingModelAccess(ODataJPAContext oDataJPAContext);
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/factory/JPQLBuilderFactory.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/factory/JPQLBuilderFactory.java b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/factory/JPQLBuilderFactory.java
new file mode 100644
index 0000000..52d45ab
--- /dev/null
+++ b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/factory/JPQLBuilderFactory.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.api.jpa.factory;
+
+import org.apache.olingo.odata2.processor.api.jpa.access.JPAMethodContext.JPAMethodContextBuilder;
+import org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLContext.JPQLContextBuilder;
+import org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLContextType;
+import org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLContextView;
+import org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLStatement.JPQLStatementBuilder;
+
+/**
+ * Factory interface for creating following instances
+ *
+ * <p>
+ * <ul>
+ * <li>JPQL statement builders of type
+ * {@link org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLStatement.JPQLStatementBuilder} </li>
+ * <li>JPQL context builder of type
+ * {@link org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLContext.JPQLContextBuilder} </li>
+ * </ul>
+ * </p>
+ *
+ *
+ * @see org.apache.olingo.odata2.processor.api.jpa.factory.ODataJPAFactory
+ */
+public interface JPQLBuilderFactory {
+ /**
+ * The method returns JPQL statement builder for building JPQL statements.
+ *
+ * @param context
+ * is {@link org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLContext} that determines the type of JPQL statement
+ * builder. The
+ * parameter cannot be null.
+ * @return an instance of JPQLStatementBuilder
+ */
+ public JPQLStatementBuilder getStatementBuilder(JPQLContextView context);
+
+ /**
+ * The method returns a JPQL context builder for building JPQL Context
+ * object.
+ *
+ * @param contextType
+ * is {@link org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLContextType} that determines the type of JPQL context
+ * builder. The
+ * parameter cannot be null.
+ * @return an instance of JPQLContextBuilder
+ */
+ public JPQLContextBuilder getContextBuilder(JPQLContextType contextType);
+
+ /**
+ * The method returns a JPA method context builder for building JPA Method
+ * context object.
+ *
+ * @param contextType
+ * is {@link org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLContextType} that determines the type of JPQL context
+ * builder. The
+ * parameter cannot be null.
+ * @return an instance of JPAMethodContextBuilder
+ */
+ public JPAMethodContextBuilder getJPAMethodContextBuilder(JPQLContextType contextType);
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/factory/ODataJPAAccessFactory.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/factory/ODataJPAAccessFactory.java b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/factory/ODataJPAAccessFactory.java
new file mode 100644
index 0000000..3d8073e
--- /dev/null
+++ b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/factory/ODataJPAAccessFactory.java
@@ -0,0 +1,82 @@
+/*******************************************************************************
+ * 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.api.jpa.factory;
+
+import java.util.Locale;
+
+import org.apache.olingo.odata2.api.edm.provider.EdmProvider;
+import org.apache.olingo.odata2.api.processor.ODataSingleProcessor;
+import org.apache.olingo.odata2.processor.api.jpa.ODataJPAContext;
+import org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPAMessageService;
+
+/**
+ * Factory interface for creating following instances
+ *
+ * <p>
+ * <ul>
+ * <li>OData JPA Processor of type {@link org.apache.olingo.odata2.api.processor.ODataSingleProcessor}</li>
+ * <li>JPA EDM Provider of type {@link org.apache.olingo.odata2.api.edm.provider.EdmProvider}</li>
+ * <li>OData JPA Context {@link org.apache.olingo.odata2.processor.api.jpa.ODataJPAContext}</li>
+ * </ul>
+ * </p>
+ *
+ *
+ * @see org.apache.olingo.odata2.processor.api.jpa.factory.ODataJPAFactory
+ */
+public interface ODataJPAAccessFactory {
+ /**
+ * The method creates an OData JPA Processor. The processor handles runtime
+ * behavior of an OData service.
+ *
+ * @param oDataJPAContext
+ * an instance of type {@link org.apache.olingo.odata2.processor.api.jpa.ODataJPAContext}.
+ * The context should be initialized properly and cannot be null.
+ * @return An implementation of OData JPA Processor.
+ */
+ public ODataSingleProcessor createODataProcessor(ODataJPAContext oDataJPAContext);
+
+ /**
+ *
+ * @param oDataJPAContext
+ * an instance of type {@link org.apache.olingo.odata2.processor.api.jpa.ODataJPAContext}.
+ * The context should be initialized properly and cannot be null.
+ * @return An implementation of JPA EdmProvider. EdmProvider handles
+ * meta-data.
+ */
+ public EdmProvider createJPAEdmProvider(ODataJPAContext oDataJPAContext);
+
+ /**
+ * The method creates an instance of OData JPA Context. An empty instance is
+ * returned.
+ *
+ * @return an instance of type {@link org.apache.olingo.odata2.processor.api.jpa.ODataJPAContext}
+ */
+ public ODataJPAContext createODataJPAContext();
+
+ /**
+ * The method creates an instance of message service for loading language
+ * dependent message text.
+ *
+ * @param locale
+ * is the language in which the message service should load
+ * message texts.
+ * @return an instance of type {@link org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPAMessageService}
+ */
+ public ODataJPAMessageService getODataJPAMessageService(Locale locale);
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/factory/ODataJPAFactory.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/factory/ODataJPAFactory.java b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/factory/ODataJPAFactory.java
new file mode 100644
index 0000000..b421ce4
--- /dev/null
+++ b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/factory/ODataJPAFactory.java
@@ -0,0 +1,105 @@
+/*******************************************************************************
+ * 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.api.jpa.factory;
+
+/**
+ * The class is an abstract factory for creating default ODataJPAFactory. The
+ * class's actual implementation is responsible for creating other factory
+ * implementations.The class creates factories implementing interfaces
+ * <ul>
+ * <li>{@link org.apache.olingo.odata2.processor.api.jpa.factory.JPAAccessFactory}</li>
+ * <li>{@link org.apache.olingo.odata2.processor.api.jpa.factory.JPQLBuilderFactory}</li>
+ * <li>{@link org.apache.olingo.odata2.processor.api.jpa.factory.JPQLBuilderFactory}</li>
+ * </ul>
+ *
+ * <b>Note: </b>Extend this class only if you don't require library's default
+ * factory implementation.
+ * <p>
+ *
+ *
+ *
+ *
+ *
+ */
+public abstract class ODataJPAFactory {
+
+ private static final String IMPLEMENTATION =
+ "org.apache.olingo.odata2.processor.core.jpa.factory.ODataJPAFactoryImpl";
+ private static ODataJPAFactory factoryImpl;
+
+ /**
+ * Method creates a factory instance. The instance returned is singleton.
+ * The instance of this factory can be used for creating other factory
+ * implementations.
+ *
+ * @return instance of type {@link org.apache.olingo.odata2.processor.api.jpa.factory.ODataJPAFactory} .
+ */
+ public static ODataJPAFactory createFactory() {
+
+ if (factoryImpl != null) {
+ return factoryImpl;
+ } else {
+ try {
+ Class<?> clazz = Class.forName(ODataJPAFactory.IMPLEMENTATION);
+
+ Object object = clazz.newInstance();
+ factoryImpl = (ODataJPAFactory) object;
+
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+
+ return factoryImpl;
+ }
+ }
+
+ /**
+ * The method returns a null reference to JPQL Builder Factory. Override
+ * this method to return an implementation of JPQLBuilderFactory if default
+ * implementation from library is not required.
+ *
+ * @return instance of type {@link org.apache.olingo.odata2.processor.api.jpa.factory.JPQLBuilderFactory}
+ */
+ public JPQLBuilderFactory getJPQLBuilderFactory() {
+ return null;
+ };
+
+ /**
+ * The method returns a null reference to JPA Access Factory. Override this
+ * method to return an implementation of JPAAccessFactory if default
+ * implementation from library is not required.
+ *
+ * @return instance of type {@link org.apache.olingo.odata2.processor.api.jpa.factory.JPQLBuilderFactory}
+ */
+ public JPAAccessFactory getJPAAccessFactory() {
+ return null;
+ };
+
+ /**
+ * The method returns a null reference to OData JPA Access Factory. Override
+ * this method to return an implementation of ODataJPAAccessFactory if
+ * default implementation from library is not required.
+ *
+ * @return instance of type {@link org.apache.olingo.odata2.processor.api.jpa.factory.ODataJPAAccessFactory}
+ */
+ public ODataJPAAccessFactory getODataJPAAccessFactory() {
+ return null;
+ };
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/factory/package-info.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/factory/package-info.java b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/factory/package-info.java
new file mode 100644
index 0000000..de2b699
--- /dev/null
+++ b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/factory/package-info.java
@@ -0,0 +1,33 @@
+/*******************************************************************************
+ * 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.
+ ******************************************************************************/
+/**
+ * <h3>OData JPA Processor API Library - Factory</h3>
+ * The library provides different types of factories for creating instances for
+ * <ul>
+ * <li>Accessing Java Persistence Model/Data</li>
+ * <li>Building different types of JPQL statements</li>
+ * <li>Accessing OData EDM provider and processor</li>
+ * </ul>
+ *
+ * The instances of these factories can be obtained from an abstract ODataJPAFactory.
+ *
+ *
+ */
+package org.apache.olingo.odata2.processor.api.jpa.factory;
+
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/jpql/JPQLContext.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/jpql/JPQLContext.java b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/jpql/JPQLContext.java
new file mode 100644
index 0000000..ab24e67
--- /dev/null
+++ b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/jpql/JPQLContext.java
@@ -0,0 +1,204 @@
+/*******************************************************************************
+ * 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.api.jpa.jpql;
+
+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.factory.ODataJPAFactory;
+
+/**
+ * The abstract class is a compilation of objects required for building
+ * {@link org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLStatement}. Extend this
+ * class to implement specific implementations of JPQL context types (Select,
+ * Join). A JPQL Context is constructed from an OData
+ * request. Depending on OData CRUD operation performed on an Entity, a
+ * corresponding JPQL context object is built. The JPQL context object thus
+ * built can be used for constructing JPQL statements. <br>
+ * A default implementation is provided by the library.
+ *
+ *
+ * @see org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLStatement
+ * @see org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLContextType
+ * @see org.apache.olingo.odata2.processor.api.jpa.factory.JPQLBuilderFactory
+ *
+ */
+public abstract class JPQLContext implements JPQLContextView {
+
+ /**
+ * An alias for Java Persistence Entity
+ */
+ protected String jpaEntityAlias;
+ /**
+ * Java Persistence Entity name
+ */
+ protected String jpaEntityName;
+ /**
+ * The type of JPQL context. Based on the type JPQL statements can be built.
+ */
+ protected JPQLContextType type;
+
+ /**
+ * sets JPA Entity Name into the context
+ *
+ * @param jpaEntityName
+ * is the name of JPA Entity
+ */
+ protected final void setJPAEntityName(final String jpaEntityName) {
+ this.jpaEntityName = jpaEntityName;
+ }
+
+ /**
+ * sets JPA Entity alias name into the context
+ *
+ * @param jpaEntityAlias
+ * is the JPA entity alias name
+ */
+ protected final void setJPAEntityAlias(final String jpaEntityAlias) {
+ this.jpaEntityAlias = jpaEntityAlias;
+ }
+
+ /**
+ * gets the JPA entity alias name set into the context
+ */
+ @Override
+ public final String getJPAEntityAlias() {
+ return jpaEntityAlias;
+ }
+
+ /**
+ * sets the JPQL context type into the context
+ *
+ * @param type
+ * is JPQLContextType
+ */
+ protected final void setType(final JPQLContextType type) {
+ this.type = type;
+ }
+
+ /**
+ * gets the JPA entity name set into the context
+ */
+ @Override
+ public final String getJPAEntityName() {
+ return jpaEntityName;
+ }
+
+ /**
+ * gets the JPQL context type set into the context
+ */
+ @Override
+ public final JPQLContextType getType() {
+ return type;
+ }
+
+ /**
+ * the method returns an instance of type
+ * {@link org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLContext.JPQLContextBuilder} based on the
+ * JPQLContextType. The context builder can be used for
+ * building different JPQL contexts.
+ *
+ * @param contextType
+ * is the JPQLContextType
+ * @param resultsView
+ * is the OData request view
+ * @return an instance of type {@link org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLContext.JPQLContextBuilder}
+ * @throws ODataJPARuntimeException
+ */
+ public final static JPQLContextBuilder createBuilder(final JPQLContextType contextType, final Object resultsView)
+ throws ODataJPARuntimeException {
+ return JPQLContextBuilder.create(contextType, resultsView);
+ }
+
+ /**
+ * The abstract class is extended by specific JPQLContext builder for
+ * building JPQLContexts.
+ *
+ *
+ *
+ */
+ public static abstract class JPQLContextBuilder {
+ /**
+ * alias counter is an integer counter that is incremented by "1" for
+ * every new alias name generation. The value of counter is used in the
+ * generation of JPA entity alias names.
+ */
+ protected int aliasCounter = 0;
+
+ protected JPQLContextBuilder() {}
+
+ /**
+ * the method instantiates an instance of type JPQLContextBuilder.
+ *
+ * @param contextType
+ * indicates the type of JPQLContextBuilder to instantiate.
+ * @param resultsView
+ * is the OData request view
+ * @return an instance of type
+ * {@link org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLContext.JPQLContextBuilder}
+ * @throws ODataJPARuntimeException
+ */
+ private static JPQLContextBuilder create(final JPQLContextType contextType, final Object resultsView)
+ throws ODataJPARuntimeException {
+ JPQLContextBuilder contextBuilder =
+ ODataJPAFactory.createFactory().getJPQLBuilderFactory().getContextBuilder(contextType);
+ if (contextBuilder == null) {
+ throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.ERROR_JPQLCTXBLDR_CREATE, null);
+ }
+ contextBuilder.setResultsView(resultsView);
+ return contextBuilder;
+ }
+
+ /**
+ * The abstract method is implemented by specific JPQL context builders
+ * to build JPQL Contexts. The build method makes use of information set
+ * into the context to built JPQL Context Types.
+ *
+ * @return an instance of {@link org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLContext}
+ * @throws ODataJPAModelException
+ * @throws ODataJPARuntimeException
+ */
+ public abstract JPQLContext build() throws ODataJPAModelException, ODataJPARuntimeException;
+
+ /**
+ * The abstract method is implemented by specific JPQL context builder.
+ * The method sets the OData request view into the JPQL context.
+ *
+ * @param resultsView
+ * is an instance representing OData request.
+ */
+ protected abstract void setResultsView(Object resultsView);
+
+ /**
+ * The method resets the alias counter value to "0".
+ */
+ protected void resetAliasCounter() {
+ aliasCounter = 0;
+ }
+
+ /**
+ * The method returns a system generated alias name starting with prefix
+ * "E" and ending with suffix "aliasCounter".
+ *
+ * @return a String representing JPA entity alias name
+ */
+ protected String generateJPAEntityAlias() {
+ return new String("E" + ++aliasCounter);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/jpql/JPQLContextType.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/jpql/JPQLContextType.java b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/jpql/JPQLContextType.java
new file mode 100644
index 0000000..17df83a
--- /dev/null
+++ b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/jpql/JPQLContextType.java
@@ -0,0 +1,73 @@
+/*******************************************************************************
+ * 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.api.jpa.jpql;
+
+/**
+ * Enumerated list of JPQL context Types.
+ *
+ *
+ *
+ */
+public enum JPQLContextType {
+ /**
+ * indicates that the JPQL context can be used for building JPQL select
+ * statements
+ */
+ SELECT,
+ /**
+ * indicates that the JPQL context can be used for building JPQL modify
+ * statements
+ */
+ MODIFY,
+ /**
+ * indicates that the JPQL context can be used for building JPQL delete
+ * statements
+ */
+ DELETE,
+ /**
+ * indicates that the JPQL context can be used for building JPQL select
+ * statement that fetches single record
+ */
+ SELECT_SINGLE,
+ /**
+ * indicates that the JPQL context can be used for building JPQL join
+ * statement
+ */
+ JOIN,
+ /**
+ * indicates that the JPQL context can be used for building JPQL join
+ * statement that fetches single record
+ */
+ JOIN_SINGLE,
+ /**
+ * indicates that the JPQL context can be used for building JPQL select
+ * statement that fetches record counts
+ */
+ SELECT_COUNT,
+ /**
+ * indicates that the JPQL context can be used for building JPQL join
+ * statement that fetches single record
+ */
+ JOIN_COUNT,
+ /**
+ * indicates that the JPQL context can be used for building JPA Method
+ * context that can be used for invoking custom functions
+ */
+ FUNCTION
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/jpql/JPQLContextView.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/jpql/JPQLContextView.java b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/jpql/JPQLContextView.java
new file mode 100644
index 0000000..d1ac24f
--- /dev/null
+++ b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/jpql/JPQLContextView.java
@@ -0,0 +1,53 @@
+/*******************************************************************************
+ * 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.api.jpa.jpql;
+
+/**
+ * The interface provides a view on JPQL Context. The view can be used to access
+ * different JPQL context type implementations.
+ *
+ *
+ * @see org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLContextType
+ * @see org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLContextType
+ */
+public interface JPQLContextView {
+ /**
+ * The method returns a JPA entity name for which the JPQL context is
+ * relevant.
+ *
+ * @return JPA entity name
+ */
+ public String getJPAEntityName();
+
+ /**
+ * The method returns a JPA entity alias name for which the JPQL context is
+ * relevant.
+ *
+ * @return JPA entity alias name
+ */
+
+ public String getJPAEntityAlias();
+
+ /**
+ * The method returns a JPQL context type
+ *
+ * @return an instance of type {@link org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLContextType}
+ */
+ public JPQLContextType getType();
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/jpql/JPQLJoinContextView.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/jpql/JPQLJoinContextView.java b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/jpql/JPQLJoinContextView.java
new file mode 100644
index 0000000..4392015
--- /dev/null
+++ b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/jpql/JPQLJoinContextView.java
@@ -0,0 +1,44 @@
+/*******************************************************************************
+ * 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.api.jpa.jpql;
+
+import java.util.List;
+
+import org.apache.olingo.odata2.processor.api.jpa.access.JPAJoinClause;
+
+/**
+ * The interface provide a view on JPQL Join context.The interface provides
+ * methods for accessing the Join Clause which can be part of JPQL Select
+ * statement. The interface extends the JPQL Select Context to add JQPL Join
+ * clauses to the Select statement. The JPQL Join context view is built from
+ * OData read entity set with navigation request.
+ *
+ *
+ * @see org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLSelectContextView
+ *
+ */
+public interface JPQLJoinContextView extends JPQLSelectContextView {
+ /**
+ * The method returns a list of JPA Join Clauses. The returned list of
+ * values can be used for building JPQL Statements with Join clauses.
+ *
+ * @return a list of {@link org.apache.olingo.odata2.processor.api.jpa.access.JPAJoinClause}
+ */
+ public List<JPAJoinClause> getJPAJoinClauses();
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/jpql/JPQLJoinSelectSingleContextView.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/jpql/JPQLJoinSelectSingleContextView.java b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/jpql/JPQLJoinSelectSingleContextView.java
new file mode 100644
index 0000000..7d71dc3
--- /dev/null
+++ b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/jpql/JPQLJoinSelectSingleContextView.java
@@ -0,0 +1,45 @@
+/*******************************************************************************
+ * 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.api.jpa.jpql;
+
+import java.util.List;
+
+import org.apache.olingo.odata2.processor.api.jpa.access.JPAJoinClause;
+
+/**
+ * The interface provide a view on JPQL Join Clauses.The interface is an
+ * extension to JPQL select single context and provides methods for accessing
+ * JPQL Join clauses. The view can be used for building JPQL statements without
+ * any WHERE,ORDERBY clauses. The clauses are built from OData read entity
+ * request views.
+ *
+ *
+ * @see org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLSelectSingleContextView
+ *
+ */
+public interface JPQLJoinSelectSingleContextView extends JPQLSelectSingleContextView {
+
+ /**
+ * The method returns a list of JPA Join Clauses. The returned list of
+ * values can be used for building JPQL Statements with Join clauses.
+ *
+ * @return a list of {@link org.apache.olingo.odata2.processor.api.jpa.access.JPAJoinClause}
+ */
+ public abstract List<JPAJoinClause> getJPAJoinClauses();
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/jpql/JPQLSelectContextView.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/jpql/JPQLSelectContextView.java b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/jpql/JPQLSelectContextView.java
new file mode 100644
index 0000000..58f595e
--- /dev/null
+++ b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/jpql/JPQLSelectContextView.java
@@ -0,0 +1,62 @@
+/*******************************************************************************
+ * 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.api.jpa.jpql;
+
+import java.util.HashMap;
+
+/**
+ * The interface provide a view on JPQL select context.The interface provides
+ * methods for accessing the clauses of a JPQL SELECT statement like "SELECT",
+ * "ORDERBY", "WHERE". The clauses are built from OData read entity set request
+ * views. The clauses thus built can be used for building JPQL Statements.
+ *
+ *
+ * @see org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLStatement
+ *
+ */
+public interface JPQLSelectContextView extends JPQLContextView {
+ /**
+ * The method returns a JPQL SELECT clause. The SELECT clause is built from
+ * $select OData system Query option.
+ *
+ * @return a String representing a SELECT clause in JPQL
+ */
+ public String getSelectExpression();
+
+ /**
+ * The method returns a Hash Map of JPQL ORDERBY clause. The ORDERBY clause
+ * is built from $orderby OData system query option. The hash map contains
+ * <ol>
+ * <li>Key - JPA Entity Property name to be ordered</li>
+ * <li>Value - Sort Order in JPQL (desc,asc)</li>
+ * </ol>
+ *
+ * @return a hash map of (JPA Property Name,Sort Order)
+ */
+ public HashMap<String, String> getOrderByCollection();
+
+ /**
+ * The method returns a JPQL WHERE condition as string. The WHERE condition
+ * can be built from $filter OData System Query Option and/or Key predicates
+ * of an OData Request.
+ *
+ * @return a String representing a WHERE condition in JPQL
+ */
+ public String getWhereExpression();
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/jpql/JPQLSelectSingleContextView.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/jpql/JPQLSelectSingleContextView.java b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/jpql/JPQLSelectSingleContextView.java
new file mode 100644
index 0000000..5e492be
--- /dev/null
+++ b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/jpql/JPQLSelectSingleContextView.java
@@ -0,0 +1,53 @@
+/*******************************************************************************
+ * 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.api.jpa.jpql;
+
+import java.util.List;
+
+import org.apache.olingo.odata2.api.uri.KeyPredicate;
+
+/**
+ * The interface provide a view on JPQL select single context.The interface
+ * provides methods for accessing the clause of a JPQL SELECT statement like
+ * "SELECT". The view can be used for building JPQL statements without any
+ * WHERE,JOIN,ORDERBY clauses. The clauses are built from OData read entity
+ * request views.
+ *
+ *
+ * @see org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLStatement
+ *
+ */
+public interface JPQLSelectSingleContextView extends JPQLContextView {
+ /**
+ * The method returns a JPQL SELECT clause. The SELECT clause is built from
+ * $select OData system Query option.
+ *
+ * @return a String representing a SELECT clause in JPQL
+ */
+ public String getSelectExpression();
+
+ /**
+ * The method returns the list of key predicates that can be used for
+ * constructing the WHERE clause in JPQL statements. The OData entity key
+ * predicates are thus converted into JPA entity keys.
+ *
+ * @return a list of key predicates
+ */
+ public List<KeyPredicate> getKeyPredicates();
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/jpql/JPQLStatement.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/jpql/JPQLStatement.java b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/jpql/JPQLStatement.java
new file mode 100644
index 0000000..e68b4d4
--- /dev/null
+++ b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/jpql/JPQLStatement.java
@@ -0,0 +1,148 @@
+/*******************************************************************************
+ * 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.api.jpa.jpql;
+
+import org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPARuntimeException;
+import org.apache.olingo.odata2.processor.api.jpa.factory.ODataJPAFactory;
+
+/**
+ * The class represents a Java Persistence Query Language (JPQL) Statement.
+ * The JPQL statement is built using a builder namely
+ * {@link org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLStatement.JPQLStatementBuilder} . Based upon the JPQL
+ * Context types ( {@link org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLContextType} different
+ * kinds of JPQL statements are built.
+ * The JPQL statements thus generated can be executed using JPA Query APIs to fetch JPA entities.
+ *
+ *
+ * @see org.apache.olingo.odata2.processor.api.jpa.factory.JPQLBuilderFactory
+ * @see org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLContextView
+ */
+public class JPQLStatement {
+
+ protected String statement;
+
+ /**
+ * The method is used for creating an instance of JPQL Statement Builder for
+ * building JPQL statements. The JPQL Statement builder is created based
+ * upon the JPQL Context.
+ *
+ * @param context
+ * a non null value of {@link org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLContextView} . The context is
+ * expected to be set to be built with no
+ * errors.
+ * @return an instance of JPQL statement builder
+ * @throws ODataJPARuntimeException
+ */
+ public static JPQLStatementBuilder createBuilder(final JPQLContextView context) throws ODataJPARuntimeException {
+ return JPQLStatementBuilder.create(context);
+ }
+
+ private JPQLStatement(final String statement) {
+ this.statement = statement;
+ }
+
+ /**
+ * The method provides a String representation of JPQLStatement.
+ */
+ @Override
+ public String toString() {
+ return statement;
+ }
+
+ /**
+ * The abstract class is extended by specific JPQL statement builders for
+ * building JPQL statements like
+ * <ol>
+ * <li>Select statements</li>
+ * <li>Select single statements</li>
+ * <li>Select statements with Join</li>
+ * <li>Insert/Modify/Delete statements</li>
+ * </ol>
+ *
+ * A default statement builder for building each kind of JPQL statements is
+ * provided by the library.
+ *
+ *
+ *
+ */
+ public static abstract class JPQLStatementBuilder {
+
+ protected JPQLStatementBuilder() {}
+
+ private static final JPQLStatementBuilder create(final JPQLContextView context) throws ODataJPARuntimeException {
+ return ODataJPAFactory.createFactory().getJPQLBuilderFactory().getStatementBuilder(context);
+ }
+
+ protected final JPQLStatement createStatement(final String statement) {
+ return new JPQLStatement(statement);
+ }
+
+ /**
+ * The abstract method is implemented by specific statement builder for
+ * building JPQL Statement.
+ *
+ * @return an instance of {@link org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLStatement}
+ * @throws ODataJPARuntimeException
+ * in case there are errors building the statements
+ */
+ public abstract JPQLStatement build() throws ODataJPARuntimeException;
+
+ }
+
+ public static final class Operator {
+ public static final String EQ = "=";
+ public static final String NE = "<>";
+ public static final String LT = "<";
+ public static final String LE = "<=";
+ public static final String GT = ">";
+ public static final String GE = ">=";
+ public static final String AND = "AND";
+ public static final String NOT = "NOT";
+ public static final String OR = "OR";
+
+ }
+
+ public static final class KEYWORD {
+ public static final String SELECT = "SELECT";
+ public static final String FROM = "FROM";
+ public static final String WHERE = "WHERE";
+ public static final String LEFT_OUTER_JOIN = "LEFT OUTER JOIN";
+ public static final String OUTER = "OUTER";
+ public static final String JOIN = "JOIN";
+ public static final String ORDERBY = "ORDER BY";
+ public static final String COUNT = "COUNT";
+ public static final String OFFSET = ".000";
+ public static final String TIMESTAMP = "ts";
+
+ }
+
+ public static final class DELIMITER {
+ public static final char SPACE = ' ';
+ public static final char COMMA = ',';
+ public static final char PERIOD = '.';
+ public static final char PARENTHESIS_LEFT = '(';
+ public static final char PARENTHESIS_RIGHT = ')';
+ public static final char COLON = ':';
+ public static final char HYPHEN = '-';
+ public static final char LEFT_BRACE = '{';
+ public static final char RIGHT_BRACE = '}';
+ public static final char LONG = 'L';
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/jpql/package-info.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/jpql/package-info.java b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/jpql/package-info.java
new file mode 100644
index 0000000..dc02b90
--- /dev/null
+++ b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/jpql/package-info.java
@@ -0,0 +1,27 @@
+/*******************************************************************************
+ * 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.
+ ******************************************************************************/
+/**
+ * <h3>OData JPA Processor API Library - Java Persistence Query Language</h3>
+ * The library provides set of APIs for building JPQL contexts from OData Requests.
+ * The JPQL contexts thus built can be used for building JPQL Statements.
+ *
+ *
+ */
+package org.apache.olingo.odata2.processor.api.jpa.jpql;
+
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmAssociationEndView.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmAssociationEndView.java b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmAssociationEndView.java
new file mode 100644
index 0000000..9d3238d
--- /dev/null
+++ b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmAssociationEndView.java
@@ -0,0 +1,91 @@
+/*******************************************************************************
+ * 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.api.jpa.model;
+
+import org.apache.olingo.odata2.api.edm.provider.AssociationEnd;
+
+/**
+ * <p>
+ * A view on Java Persistence Entity Relationship and Entity Data Model
+ * Association End.
+ * </p>
+ * <p>
+ * The implementation of the view provides access to EDM Association Ends
+ * created from Java Persistence Entity Relationships. The implementation acts
+ * as a container for Association Ends.
+ * </p>
+ *
+ * @org.apache.olingo.odata2.DoNotImplement
+ * @see org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmAssociationView
+ *
+ */
+public interface JPAEdmAssociationEndView extends JPAEdmBaseView {
+
+ /**
+ * The method gets the one of the association ends present in the container.
+ *
+ * @return one of the {@link org.apache.olingo.odata2.api.edm.provider.AssociationEnd} for an
+ * {@link org.apache.olingo.odata2.api.edm.provider.Association}
+ */
+ AssociationEnd getEdmAssociationEnd2();
+
+ /**
+ * The method gets the other association end present in the container.
+ *
+ * @return one of the {@link org.apache.olingo.odata2.api.edm.provider.AssociationEnd} for an
+ * {@link org.apache.olingo.odata2.api.edm.provider.Association}
+ */
+ AssociationEnd getEdmAssociationEnd1();
+
+ /**
+ * The method compares two ends {<b>end1, end2</b>} of an
+ * {@link org.apache.olingo.odata2.api.edm.provider.AssociationEnd} against its
+ * two ends.
+ *
+ * The Method compares the following properties in each end for equality <i>
+ * <ul>
+ * <li>{@link org.apache.olingo.odata2.api.edm.FullQualifiedName} of End Type</li>
+ * <li>{@link org.apache.olingo.odata2.api.edm.EdmMultiplicity} of End</li>
+ * </ul>
+ * </i>
+ *
+ * @param end1
+ * one end of type {@link org.apache.olingo.odata2.api.edm.provider.AssociationEnd} of
+ * an {@link org.apache.olingo.odata2.api.edm.provider.Association}
+ * @param end2
+ * other end of type {@link org.apache.olingo.odata2.api.edm.provider.AssociationEnd} of
+ * an {@link org.apache.olingo.odata2.api.edm.provider.Association} <p>
+ * @return <ul>
+ * <li><i>true</i> - Only if the properties of <b>end1</b> matches
+ * with all the properties of any one end and only if the properties
+ * of <b>end2</b> matches with all the properties of the remaining
+ * end</li> <li><i>false</i> - Otherwise</li>
+ * </ul>
+ */
+ boolean compare(AssociationEnd end1, AssociationEnd end2);
+
+ String getJoinColumnName();
+
+ String getJoinColumnReferenceColumnName();
+
+ String getMappedByName();
+
+ String getOwningPropertyName();
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmAssociationSetView.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmAssociationSetView.java b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmAssociationSetView.java
new file mode 100644
index 0000000..911569d
--- /dev/null
+++ b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmAssociationSetView.java
@@ -0,0 +1,69 @@
+/*******************************************************************************
+ * 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.api.jpa.model;
+
+import java.util.List;
+
+import org.apache.olingo.odata2.api.edm.provider.Association;
+import org.apache.olingo.odata2.api.edm.provider.AssociationSet;
+
+/**
+ * <p>
+ * A view on Java Persistence Entity Relationship and Entity Data Model
+ * Association Set.
+ * </p>
+ * <p>
+ * The implementation of the view provides access to EDM Association Set created
+ * from Java Persistence Entity Relationship. The implementation act as a
+ * container for list of association sets that are consistent.
+ * </p>
+ *
+ *
+ * <p>
+ * @org.apache.olingo.odata2.DoNotImplement
+ * @see org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmAssociationView
+ */
+public interface JPAEdmAssociationSetView extends JPAEdmBaseView {
+
+ /**
+ * The method returns a consistent list of association sets. An association
+ * set is set to be consistent only if all its mandatory properties can be
+ * completely built from a Java Persistence Relationship.
+ *
+ * @return a consistent list of {@link org.apache.olingo.odata2.api.edm.provider.AssociationSet}
+ *
+ */
+ List<AssociationSet> getConsistentEdmAssociationSetList();
+
+ /**
+ * The method returns an association set that is currently being processed.
+ *
+ * @return an instance of type {@link org.apache.olingo.odata2.api.edm.provider.AssociationSet}
+ */
+ AssociationSet getEdmAssociationSet();
+
+ /**
+ * The method returns an association from which the association set is
+ * currently being processed.
+ *
+ * @return an instance of type {@link org.apache.olingo.odata2.api.edm.provider.Association}
+ */
+ Association getEdmAssociation();
+
+}
[29/37] [OLINGO-82] Renamed the project folder name to
odata2-jpa-processor
Posted by ch...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmReferentialConstraint.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmReferentialConstraint.java b/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmReferentialConstraint.java
new file mode 100644
index 0000000..2888a9a
--- /dev/null
+++ b/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmReferentialConstraint.java
@@ -0,0 +1,147 @@
+/*******************************************************************************
+ * 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 org.apache.olingo.odata2.api.edm.provider.ReferentialConstraint;
+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.JPAEdmAssociationView;
+import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmEntityTypeView;
+import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmPropertyView;
+import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmReferentialConstraintRoleView;
+import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmReferentialConstraintRoleView.RoleType;
+import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmReferentialConstraintView;
+
+public class JPAEdmReferentialConstraint extends JPAEdmBaseViewImpl implements JPAEdmReferentialConstraintView {
+
+ private JPAEdmRefConstraintBuilder builder = null;
+
+ private boolean exists = false;
+ private boolean firstBuild = true;
+
+ private JPAEdmAssociationView associationView;
+ private JPAEdmPropertyView propertyView;
+ private JPAEdmEntityTypeView entityTypeView;
+
+ private ReferentialConstraint referentialConstraint;
+
+ private JPAEdmReferentialConstraintRoleView principalRoleView;
+ private JPAEdmReferentialConstraintRoleView dependentRoleView;
+
+ private String relationShipName;
+
+ public JPAEdmReferentialConstraint(final JPAEdmAssociationView associationView,
+ final JPAEdmEntityTypeView entityTypeView, final JPAEdmPropertyView propertyView) {
+ super(associationView);
+ this.associationView = associationView;
+ this.propertyView = propertyView;
+ this.entityTypeView = entityTypeView;
+
+ relationShipName = associationView.getEdmAssociation().getName();
+ }
+
+ @Override
+ public JPAEdmBuilder getBuilder() {
+ if (builder == null) {
+ builder = new JPAEdmRefConstraintBuilder();
+ }
+
+ return builder;
+ }
+
+ @Override
+ public ReferentialConstraint getEdmReferentialConstraint() {
+ return referentialConstraint;
+ }
+
+ @Override
+ public boolean isExists() {
+ return exists;
+ }
+
+ @Override
+ public String getEdmRelationShipName() {
+ return relationShipName;
+ }
+
+ private class JPAEdmRefConstraintBuilder implements JPAEdmBuilder {
+ /*
+ * Check if Ref Constraint was already Built. If Ref constraint was
+ * already built consistently then do not build referential constraint.
+ *
+ * For Ref Constraint to be consistently built Principal and Dependent
+ * roles must be consistently built. If Principal or Dependent roles are
+ * not consistently built then try building them again.
+ *
+ * The Principal and Dependent roles could be have been built
+ * inconsistently if the required EDM Entity Types or EDM properties are
+ * yet to be built. In such cases rebuilding these roles would make them
+ * consistent.
+ */
+ @Override
+ public void build() throws ODataJPAModelException, ODataJPARuntimeException {
+
+ if (firstBuild) {
+ firstBuild();
+ } else {
+ if (exists && !firstBuild && principalRoleView.isConsistent() == false) {
+ principalRoleView.getBuilder().build();
+ }
+
+ if (exists && !firstBuild && dependentRoleView.isConsistent() == false) {
+ dependentRoleView.getBuilder().build();
+ }
+ }
+
+ if (principalRoleView.isConsistent()) {
+ referentialConstraint.setPrincipal(principalRoleView.getEdmReferentialConstraintRole());
+ }
+
+ if (dependentRoleView.isConsistent()) {
+ referentialConstraint.setDependent(dependentRoleView.getEdmReferentialConstraintRole());
+ }
+
+ exists = principalRoleView.isExists() & dependentRoleView.isExists();
+
+ isConsistent = principalRoleView.isConsistent() & dependentRoleView.isConsistent();
+
+ }
+
+ private void firstBuild() throws ODataJPAModelException, ODataJPARuntimeException {
+ firstBuild = false;
+ if (principalRoleView == null && dependentRoleView == null) {
+
+ principalRoleView =
+ new JPAEdmReferentialConstraintRole(RoleType.PRINCIPAL, entityTypeView, propertyView, associationView);
+ principalRoleView.getBuilder().build();
+
+ dependentRoleView =
+ new JPAEdmReferentialConstraintRole(RoleType.DEPENDENT, entityTypeView, propertyView, associationView);
+ dependentRoleView.getBuilder().build();
+
+ if (referentialConstraint == null) {
+ referentialConstraint = new ReferentialConstraint();
+ }
+ }
+
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmReferentialConstraintRole.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmReferentialConstraintRole.java b/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmReferentialConstraintRole.java
new file mode 100644
index 0000000..3761d4b
--- /dev/null
+++ b/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmReferentialConstraintRole.java
@@ -0,0 +1,258 @@
+/*******************************************************************************
+ * 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.reflect.AnnotatedElement;
+import java.lang.reflect.ParameterizedType;
+import java.lang.reflect.Type;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.persistence.JoinColumn;
+import javax.persistence.JoinColumns;
+import javax.persistence.metamodel.Attribute;
+
+import org.apache.olingo.odata2.api.edm.provider.Association;
+import org.apache.olingo.odata2.api.edm.provider.AssociationEnd;
+import org.apache.olingo.odata2.api.edm.provider.EntityType;
+import org.apache.olingo.odata2.api.edm.provider.Property;
+import org.apache.olingo.odata2.api.edm.provider.PropertyRef;
+import org.apache.olingo.odata2.api.edm.provider.ReferentialConstraintRole;
+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.model.JPAEdmAssociationView;
+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.JPAEdmPropertyView;
+import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmReferentialConstraintRoleView;
+
+public class JPAEdmReferentialConstraintRole extends JPAEdmBaseViewImpl implements JPAEdmReferentialConstraintRoleView {
+ /*
+ * Static Buffer
+ */
+ private static Attribute<?, ?> bufferedJPAAttribute = null;
+ private static ArrayList<JoinColumn> bufferedJoinColumns = new ArrayList<JoinColumn>();
+ /*
+ * Static Buffer
+ */
+
+ private boolean firstBuild = true;
+
+ private JPAEdmEntityTypeView entityTypeView;
+ private JPAEdmReferentialConstraintRoleView.RoleType roleType;
+
+ private Attribute<?, ?> jpaAttribute;
+ private ArrayList<String> jpaColumnNames;
+ private Association association;
+
+ private boolean roleExists = false;
+
+ private JPAEdmRefConstraintRoleBuilder builder;
+ private ReferentialConstraintRole currentRole;
+
+ public JPAEdmReferentialConstraintRole(final JPAEdmReferentialConstraintRoleView.RoleType roleType,
+ final JPAEdmEntityTypeView entityTypeView, final JPAEdmPropertyView propertyView,
+ final JPAEdmAssociationView associationView) {
+
+ super(entityTypeView);
+ this.entityTypeView = entityTypeView;
+ this.roleType = roleType;
+
+ jpaAttribute = propertyView.getJPAAttribute();
+ association = associationView.getEdmAssociation();
+
+ }
+
+ @Override
+ public boolean isExists() {
+ return roleExists;
+
+ }
+
+ @Override
+ public JPAEdmBuilder getBuilder() {
+ if (builder == null) {
+ builder = new JPAEdmRefConstraintRoleBuilder();
+ }
+
+ return builder;
+ }
+
+ @Override
+ public RoleType getRoleType() {
+ return roleType;
+ }
+
+ @Override
+ public ReferentialConstraintRole getEdmReferentialConstraintRole() {
+ return currentRole;
+ }
+
+ @Override
+ public String getJPAColumnName() {
+ return null;
+ }
+
+ @Override
+ public String getEdmEntityTypeName() {
+ return null;
+ }
+
+ @Override
+ public String getEdmAssociationName() {
+ return null;
+ }
+
+ private class JPAEdmRefConstraintRoleBuilder implements JPAEdmBuilder {
+
+ @Override
+ public void build() throws ODataJPAModelException {
+ if (firstBuild) {
+ firstBuild();
+ } else if (roleExists) {
+ try {
+ buildRole();
+ } catch (SecurityException e) {
+ throw ODataJPAModelException.throwException(ODataJPAModelException.GENERAL.addContent(e.getMessage()), e);
+ } catch (NoSuchFieldException e) {
+ throw ODataJPAModelException.throwException(ODataJPAModelException.GENERAL.addContent(e.getMessage()), e);
+ }
+ }
+
+ }
+
+ private void firstBuild() {
+ firstBuild = false;
+ isConsistent = false;
+
+ extractJoinColumns();
+
+ if (!roleExists) {
+ return;
+ }
+
+ jpaColumnNames = new ArrayList<String>();
+
+ for (JoinColumn joinColumn : bufferedJoinColumns) {
+ if (roleType == RoleType.PRINCIPAL) {
+ jpaColumnNames.add(joinColumn.referencedColumnName());
+ } else if (roleType == RoleType.DEPENDENT) {
+ jpaColumnNames.add(joinColumn.name());
+ }
+ }
+
+ }
+
+ private void buildRole() throws SecurityException, NoSuchFieldException {
+
+ if (currentRole == null) {
+ currentRole = new ReferentialConstraintRole();
+ String jpaAttributeType = null;
+ EntityType edmEntityType = null;
+
+ if (roleType == RoleType.PRINCIPAL) {
+ jpaAttributeType = jpaAttribute.getJavaType().getSimpleName();
+ if (jpaAttributeType.equals("List")) {
+ Type type =
+ ((ParameterizedType) jpaAttribute.getJavaMember().getDeclaringClass().getDeclaredField(
+ jpaAttribute.getName()).getGenericType()).getActualTypeArguments()[0];
+ int lastIndexOfDot = type.toString().lastIndexOf(".");
+ jpaAttributeType = type.toString().substring(lastIndexOfDot + 1);
+ }
+ edmEntityType = entityTypeView.searchEdmEntityType(jpaAttributeType);
+ } else if (roleType == RoleType.DEPENDENT) {
+ edmEntityType =
+ entityTypeView.searchEdmEntityType(jpaAttribute.getDeclaringType().getJavaType().getSimpleName());
+ }
+
+ List<PropertyRef> propertyRefs = new ArrayList<PropertyRef>();
+ if (edmEntityType != null) {
+ for (String columnName : jpaColumnNames) {
+ for (Property property : edmEntityType.getProperties()) {
+ if (columnName.equals(((JPAEdmMapping) property.getMapping()).getJPAColumnName())) {
+ PropertyRef propertyRef = new PropertyRef();
+ propertyRef.setName(property.getName());
+ propertyRefs.add(propertyRef);
+ break;
+ }
+ }
+ }
+ currentRole.setPropertyRefs(propertyRefs);
+ if (propertyRefs.isEmpty()) {
+ isConsistent = false;
+ return;
+ }
+ AssociationEnd end = association.getEnd1();
+ if (end.getType().getName().equals(edmEntityType.getName())) {
+ currentRole.setRole(end.getRole());
+ isConsistent = true;
+ } else {
+ end = association.getEnd2();
+ if (end.getType().getName().equals(edmEntityType.getName())) {
+ currentRole.setRole(end.getRole());
+ isConsistent = true;
+ }
+ }
+ }
+
+ }
+ }
+
+ private void extractJoinColumns() {
+ /*
+ * Check against Static Buffer whether the join column was already
+ * extracted.
+ */
+ if (!jpaAttribute.equals(bufferedJPAAttribute)) {
+ bufferedJPAAttribute = jpaAttribute;
+ bufferedJoinColumns.clear();
+ } else if (bufferedJoinColumns.isEmpty()) {
+ roleExists = false;
+ return;
+ } else {
+ roleExists = true;
+ return;
+ }
+
+ AnnotatedElement annotatedElement = (AnnotatedElement) jpaAttribute.getJavaMember();
+
+ if (annotatedElement == null) {
+ return;
+ }
+
+ JoinColumn joinColumn = annotatedElement.getAnnotation(JoinColumn.class);
+ if (joinColumn == null) {
+ JoinColumns joinColumns = annotatedElement.getAnnotation(JoinColumns.class);
+
+ if (joinColumns != null) {
+ JoinColumn[] joinColumnArray = joinColumns.value();
+
+ for (JoinColumn element : joinColumnArray) {
+ bufferedJoinColumns.add(element);
+ }
+ } else {
+ return;
+ }
+ } else {
+ bufferedJoinColumns.add(joinColumn);
+ }
+ roleExists = true;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmSchema.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmSchema.java b/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmSchema.java
new file mode 100644
index 0000000..b9ded8b
--- /dev/null
+++ b/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmSchema.java
@@ -0,0 +1,216 @@
+/*******************************************************************************
+ * 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.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+
+import org.apache.olingo.odata2.api.edm.provider.Association;
+import org.apache.olingo.odata2.api.edm.provider.ComplexType;
+import org.apache.olingo.odata2.api.edm.provider.EntityType;
+import org.apache.olingo.odata2.api.edm.provider.NavigationProperty;
+import org.apache.olingo.odata2.api.edm.provider.Schema;
+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.JPAEdmAssociationView;
+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.JPAEdmModelView;
+import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmSchemaView;
+import org.apache.olingo.odata2.processor.core.jpa.access.model.JPAEdmNameBuilder;
+
+public class JPAEdmSchema extends JPAEdmBaseViewImpl implements JPAEdmSchemaView {
+
+ private Schema schema;
+ private JPAEdmComplexTypeView complexTypeView;
+ private JPAEdmEntityContainerView entityContainerView;
+ private JPAEdmAssociationView associationView = null;
+ private List<String> nonKeyComplexList = null;
+ private HashMap<Class<?>, String[]> customOperations = null;
+
+ public JPAEdmSchema(final JPAEdmModelView modelView) {
+ super(modelView);
+ if (nonKeyComplexList == null) {
+ nonKeyComplexList = new ArrayList<String>();
+ }
+ }
+
+ @Override
+ public List<String> getNonKeyComplexTypeList() {
+ return nonKeyComplexList;
+ }
+
+ @Override
+ public void addNonKeyComplexName(final String complexTypeName) {
+ nonKeyComplexList.add(complexTypeName);
+ }
+
+ @Override
+ public Schema getEdmSchema() {
+ return schema;
+ }
+
+ @Override
+ public JPAEdmEntityContainerView getJPAEdmEntityContainerView() {
+ return entityContainerView;
+ }
+
+ @Override
+ public JPAEdmComplexTypeView getJPAEdmComplexTypeView() {
+ return complexTypeView;
+ }
+
+ @Override
+ public JPAEdmBuilder getBuilder() {
+ if (builder == null) {
+ builder = new JPAEdmSchemaBuilder();
+ }
+
+ return builder;
+ }
+
+ @Override
+ public void clean() {
+ super.clean();
+ schema = null;
+ }
+
+ private class JPAEdmSchemaBuilder implements JPAEdmBuilder {
+ /*
+ *
+ * Each call to build method creates a new EDM Schema. The newly created
+ * schema is built with Entity Containers, associations, Complex Types
+ * and Entity Types.
+ *
+ * ************************************************************ Build
+ * EDM Schema - STEPS
+ * ************************************************************ 1) Build
+ * Name for EDM Schema 2) Build EDM Complex Types from JPA Embeddable
+ * Types 3) Add EDM Complex Types to EDM Schema 4) Build EDM Entity
+ * Container 5) Add EDM Entity Container to EDM Schema 6) Fetch Built
+ * EDM Entity Types from EDM Entity Container 7) Add EDM Entity Types to
+ * EDM Schema 8) Fetch Built EDM Association Sets from EDM Entity
+ * Container 9) Fetch Built EDM Associations from EDM Association Set
+ * 10) Add EDM Association to EDM Schema
+ * ************************************************************ Build
+ * EDM Schema - STEPS
+ * ************************************************************
+ */
+ @Override
+ public void build() throws ODataJPAModelException, ODataJPARuntimeException {
+
+ schema = new Schema();
+ JPAEdmNameBuilder.build(JPAEdmSchema.this);
+
+ associationView = new JPAEdmAssociation(JPAEdmSchema.this);
+
+ complexTypeView = new JPAEdmComplexType(JPAEdmSchema.this);
+ complexTypeView.getBuilder().build();
+
+ if (getJPAEdmExtension() != null) {
+ getJPAEdmExtension().extendWithOperation(JPAEdmSchema.this);
+ }
+
+ entityContainerView = new JPAEdmEntityContainer(JPAEdmSchema.this);
+ entityContainerView.getBuilder().build();
+ schema.setEntityContainers(entityContainerView.getConsistentEdmEntityContainerList());
+
+ JPAEdmEntitySetView entitySetView = entityContainerView.getJPAEdmEntitySetView();
+ if (entitySetView.isConsistent() && entitySetView.getJPAEdmEntityTypeView() != null) {
+ JPAEdmEntityTypeView entityTypeView = entitySetView.getJPAEdmEntityTypeView();
+ if (entityTypeView.isConsistent() && !entityTypeView.getConsistentEdmEntityTypes().isEmpty()) {
+ schema.setEntityTypes(entityTypeView.getConsistentEdmEntityTypes());
+ }
+ }
+ if (complexTypeView.isConsistent()) {
+ List<ComplexType> complexTypes = complexTypeView.getConsistentEdmComplexTypes();
+ List<ComplexType> existingComplexTypes = new ArrayList<ComplexType>();
+ for (ComplexType complexType : complexTypes) {
+ if (complexType != null && nonKeyComplexList.contains(complexType.getName())) {// null check for exclude
+ existingComplexTypes.add(complexType);
+ }
+ }
+ if (!existingComplexTypes.isEmpty()) {
+ schema.setComplexTypes(existingComplexTypes);
+ }
+ }
+
+ List<String> existingAssociationList = new ArrayList<String>();
+ if (associationView.isConsistent() && !associationView.getConsistentEdmAssociationList().isEmpty()) {
+
+ List<Association> consistentAssociationList = associationView.getConsistentEdmAssociationList();
+ schema.setAssociations(consistentAssociationList);
+ for (Association association : consistentAssociationList) {
+ existingAssociationList.add(association.getName());
+ }
+
+ }
+ List<EntityType> entityTypes =
+ entityContainerView.getJPAEdmEntitySetView().getJPAEdmEntityTypeView().getConsistentEdmEntityTypes();
+ List<NavigationProperty> navigationProperties;
+ if (entityTypes != null && !entityTypes.isEmpty()) {
+ for (EntityType entityType : entityTypes) {
+
+ List<NavigationProperty> consistentNavigationProperties = null;
+ navigationProperties = entityType.getNavigationProperties();
+ if (navigationProperties != null) {
+ consistentNavigationProperties = new ArrayList<NavigationProperty>();
+ for (NavigationProperty navigationProperty : navigationProperties) {
+ if (existingAssociationList.contains(navigationProperty.getRelationship().getName())) {
+ consistentNavigationProperties.add(navigationProperty);
+ }
+ }
+ if (consistentNavigationProperties.isEmpty()) {
+ entityType.setNavigationProperties(null);
+ } else {
+ entityType.setNavigationProperties(consistentNavigationProperties);
+ }
+ }
+
+ }
+ }
+
+ }
+
+ }
+
+ @Override
+ public final JPAEdmAssociationView getJPAEdmAssociationView() {
+ return associationView;
+ }
+
+ @Override
+ public void registerOperations(final Class<?> customClass, final String[] methodNames) {
+ if (customOperations == null) {
+ customOperations = new HashMap<Class<?>, String[]>();
+ }
+
+ customOperations.put(customClass, methodNames);
+
+ }
+
+ @Override
+ public HashMap<Class<?>, String[]> getRegisteredOperations() {
+ return customOperations;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/_JPAEdmFunctionImportBuilder.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/_JPAEdmFunctionImportBuilder.java b/odata2-jpa-processor/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-jpa-processor/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/1b479e6c/odata2-jpa-processor/jpa-core/src/main/resources/jpaprocessor_msg.properties
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-core/src/main/resources/jpaprocessor_msg.properties b/odata2-jpa-processor/jpa-core/src/main/resources/jpaprocessor_msg.properties
new file mode 100644
index 0000000..5eb96fb
--- /dev/null
+++ b/odata2-jpa-processor/jpa-core/src/main/resources/jpaprocessor_msg.properties
@@ -0,0 +1,61 @@
+#-------------------------------------------------------------------------------
+# 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.
+#-------------------------------------------------------------------------------
+# Fall Back translations
+#
+
+#JPA EDM Provider Errors
+org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPAModelException.GENERAL="OData - JPA Metadata: Internal error [%1$s]"
+org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPAModelException.INNER_EXCEPTION="%1$s: %2$s.\n"
+org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPAModelException.INVALID_ENTITY_TYPE="OData - JPA Model Processor: Invalid Entity Type [%1$s]"
+org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPAModelException.INVALID_COMPLEX_TYPE="OData - JPA Model Processor: Invalid Complex Type [%1$s]"
+org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPAModelException.INVALID_ASSOCIATION ="OData - JPA Model Processor: Invalid Association [%1$s]"
+org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPAModelException.INVALID_ENTITYSET="OData - JPA Model Processor: Invalid Entity set [%1$s]"
+org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPAModelException.INVALID_ENTITYCONTAINER="OData - JPA Model Processor: Invalid Entity Container [%1$s]"
+org.apache.olingo.odata2.processor.jap.exception.ODataJPAModelException.INVALID_ASSOCIATION_SET="OData - JPA Model Processor: Invalid Association Set [%1$s]"
+org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPAModelException.INVALID_FUNC_IMPORT="OData - JPA Model Processor: Invalid Function Import [%1$s]"
+org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPAModelException.BUILDER_NULL="OData - JPA Model Processor: JPA Builder not initialized"
+org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPAModelException.FUNC_ENTITYSET_EXP="OData - JPA Model Processor: Entity Set expected for Function Import with return type as Entity Type with Multiplicity Many"
+org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPAModelException.FUNC_RETURN_TYPE_EXP="OData - JPA Model Processor: Return type expected. Class: [%1$s], Method: [%2$s]"
+org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPAModelException.FUNC_RETURN_TYPE_ENTITY_NOT_FOUND="OData - JPA Model Processor: Return type not found. Class: [%1$s], Method: [%2$s], Type: [%3$s]"
+org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPAModelException.FUNC_PARAM_NAME_EXP="OData - JPA Model Processor: Parameter Name for function import expected. Class: [%1$s]", Method: [%2$s]"
+
+#JPA Type converter Errors
+org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPAModelException.TYPE_NOT_SUPPORTED="OData - JPA Type Converter: Type [%1$s] not supported"
+
+#JPA Runtime Errors
+org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPARuntimeException.ENTITY_MANAGER_NOT_INITIALIZED="OData - JPA Service Factory: Java Persistence Entity Manager not initialized"
+org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPARuntimeException.GENERAL="OData - JPA Runtime: Internal error [%1$s]"
+org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPARuntimeException.INNER_EXCEPTION="%1$s: %2$s.\n"
+org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPARuntimeException.JOIN_CLAUSE_EXPECTED="OData - JPA Runtime: Join Clause expected"
+org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPARuntimeException.RESOURCE_NOT_FOUND="OData - JPA Runtime: Resource not found"
+org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPARuntimeException.ERROR_ODATA_FILTER_CONDITION="OData - JPA Runtime: Filter condition not correct"
+org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPARuntimeException.ERROR_JPQL_QUERY_CREATE="OData - JPA Runtime: JPA query syntax is not correct"
+org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPARuntimeException.ERROR_JPQL_CREATE_REQUEST="OData - JPA Runtime: JPA create request is not correct"
+org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPARuntimeException.ERROR_JPQL_UPDATE_REQUEST="OData - JPA Runtime: JPA update request is not correct"
+org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPARuntimeException.ERROR_JPQL_DELETE_REQUEST="OData - JPA Runtime: JPA delete URL is not correct"
+org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPARuntimeException.ERROR_JPQL_KEY_VALUE="Key parameter value is not correct for [%1$s]"
+org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPARuntimeException.ERROR_JPQL_PARAM_VALUE="Parameter value is not correct for [%1$s]"
+org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPARuntimeException.ERROR_JPQL_UNIQUE_CONSTRAINT="Violation of unique constraint"
+org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPARuntimeException.ERROR_JPQL_INTEGRITY_CONSTRAINT="Integrity constraint violation"
+org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPARuntimeException.RELATIONSHIP_INVALID="OData - JPA Runtime: Invalid link"
+org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPARuntimeException.RESOURCE_X_NOT_FOUND="OData - JPA Runtime: Resource [%1$s] not found"
+
+#JPA Common Errors
+org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPAException.ODATA_JPACTX_NULL="OData JPA: OData JPA Context cannot be null"
+org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPARuntimeException.ERROR_JPQLCTXBLDR_CREATE="OData JPA: Error creating JPQL Context Builder"
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/ODataExpressionParserTest.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/ODataExpressionParserTest.java b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/ODataExpressionParserTest.java
new file mode 100644
index 0000000..390c7fe
--- /dev/null
+++ b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/ODataExpressionParserTest.java
@@ -0,0 +1,515 @@
+/*******************************************************************************
+ * 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;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.olingo.odata2.api.edm.EdmException;
+import org.apache.olingo.odata2.api.edm.EdmFacets;
+import org.apache.olingo.odata2.api.edm.EdmLiteralKind;
+import org.apache.olingo.odata2.api.edm.EdmMapping;
+import org.apache.olingo.odata2.api.edm.EdmProperty;
+import org.apache.olingo.odata2.api.edm.EdmSimpleType;
+import org.apache.olingo.odata2.api.edm.EdmSimpleTypeKind;
+import org.apache.olingo.odata2.api.edm.EdmTypeKind;
+import org.apache.olingo.odata2.api.edm.EdmTyped;
+import org.apache.olingo.odata2.api.exception.ODataException;
+import org.apache.olingo.odata2.api.uri.KeyPredicate;
+import org.apache.olingo.odata2.api.uri.expression.BinaryExpression;
+import org.apache.olingo.odata2.api.uri.expression.BinaryOperator;
+import org.apache.olingo.odata2.api.uri.expression.CommonExpression;
+import org.apache.olingo.odata2.api.uri.expression.ExpressionKind;
+import org.apache.olingo.odata2.api.uri.expression.FilterExpression;
+import org.apache.olingo.odata2.api.uri.expression.LiteralExpression;
+import org.apache.olingo.odata2.api.uri.expression.MemberExpression;
+import org.apache.olingo.odata2.api.uri.expression.MethodExpression;
+import org.apache.olingo.odata2.api.uri.expression.MethodOperator;
+import org.apache.olingo.odata2.api.uri.expression.PropertyExpression;
+import org.apache.olingo.odata2.api.uri.expression.UnaryExpression;
+import org.apache.olingo.odata2.api.uri.expression.UnaryOperator;
+import org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPARuntimeException;
+import org.apache.olingo.odata2.processor.core.jpa.common.ODataJPATestConstants;
+import org.easymock.EasyMock;
+import org.junit.Test;
+
+public class ODataExpressionParserTest {
+
+ private static final String EXPECTED_STR_1 = "gwt1.SalesOrder = 1234";
+ private static final String EXPECTED_STR_2 = "gwt1.SalesOrder >= 1234 AND gwt1.SalesABC <> XYZ";
+ private static final String EXPECTED_STR_3 = "gwt1.SalesOrder >= 1234 OR gwt1.SalesABC <> XYZ";
+ private static final String EXPECTED_STR_4 = "gwt1.SalesOrder < 1234 AND gwt1.SalesABC <= XYZ";
+ private static final String EXPECTED_STR_5 = "gwt1.LineItems > 2345 AND gwt1.SalesOrder >= Amazon";
+ private static final String EXPECTED_STR_6 = "gwt1.Address.city = \'City_3\'";
+ private static final String EXPECTED_STR_7 = "gwt1.Address.city.area = \'BTM\'";
+ private static final String EXPECTED_STR_8 = "gwt1.field1 = 1 AND gwt1.field2 = 'abc'";
+ private static final String EXPECTED_STR_9 = "gwt1.BuyerAddress, gwt1.BuyerName, gwt1.BuyerId";
+ private static final String EXPECTED_STR_10 = "gwt1.SalesOrder";
+ private static final String EXPECTED_STR_11 = "NOT(gwt1.deliveryStatus)";
+ private static final String EXPECTED_STR_12 =
+ "(CASE WHEN (gwt1.currencyCode LIKE '%Ru%') THEN TRUE ELSE FALSE END) = true";
+ private static final String EXPECTED_STR_13 = "SUBSTRING(gwt1.currencyCode, 1 + 1 , 2) = 'NR'";
+ private static final String EXPECTED_STR_14 = "LOWER(gwt1.currencyCode) = 'inr rupees'";
+ private static final String EXPECTED_STR_15 =
+ "(CASE WHEN (LOWER(gwt1.currencyCode) LIKE '%nr rupees%') THEN TRUE ELSE FALSE END) = true";
+ private static final String EXPECTED_STR_16 =
+ "(CASE WHEN (gwt1.currencyCode LIKE '%INR%') THEN TRUE ELSE FALSE END) = true";
+ private static final String EXPECTED_STR_17 =
+ "(CASE WHEN (LOWER(gwt1.currencyCode) LIKE '%nr rupees%') THEN TRUE ELSE FALSE END) = true";
+
+ private static final String ADDRESS = "Address";
+ private static final String CITY = "city";
+ private static final String AREA = "area";
+ private static final String SALES_ORDER = "SalesOrder";
+ private static final String SALES_ABC = "SalesABC";
+ private static final String SAMPLE_DATA_1 = "1234";
+ private static final String SAMPLE_DATA_2 = "2345";
+ private static final String SAMPLE_DATA_XYZ = "XYZ";
+ private static final String SAMPLE_DATA_BTM = "\'BTM\'";
+ private static final String SAMPLE_DATA_CITY_3 = "\'City_3\'";
+ private static final String SAMPLE_DATA_LINE_ITEMS = "LineItems";
+ private static final String SAMPLE_DATA_AMAZON = "Amazon";
+ private static final String SAMPLE_DATA_FIELD1 = "field1";
+ private static final String SAMPLE_DATA_FIELD2 = "field2";
+
+ private static final String TABLE_ALIAS = "gwt1"; //$NON-NLS-1$
+
+ @Test
+ public void testParseWhereExpression() {
+ try {
+ String parsedStr = ODataJPATestConstants.EMPTY_STRING;
+ // Simple Binary query -
+ parsedStr =
+ ODataExpressionParser.parseToJPAWhereExpression(getBinaryExpressionMockedObj(BinaryOperator.EQ,
+ ExpressionKind.PROPERTY, SALES_ORDER, SAMPLE_DATA_1), TABLE_ALIAS);
+
+ assertEquals(EXPECTED_STR_1, parsedStr);
+ // complex query -
+ parsedStr = ODataJPATestConstants.EMPTY_STRING;
+
+ CommonExpression exp1 =
+ getBinaryExpressionMockedObj(BinaryOperator.GE, ExpressionKind.PROPERTY, SALES_ORDER, SAMPLE_DATA_1);
+ CommonExpression exp2 =
+ getBinaryExpressionMockedObj(BinaryOperator.NE, ExpressionKind.PROPERTY, SALES_ABC, SAMPLE_DATA_XYZ);
+ parsedStr =
+ ODataExpressionParser.parseToJPAWhereExpression(getBinaryExpression(exp1, BinaryOperator.AND, exp2),
+ TABLE_ALIAS);
+ assertEquals(EXPECTED_STR_2, parsedStr);
+ } catch (EdmException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ } catch (ODataException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+ }
+
+ @Test
+ public void testMoreThanOneBinaryExpression() {
+ // complex query -
+ String parsedStr = ODataJPATestConstants.EMPTY_STRING;
+ CommonExpression exp1 =
+ getBinaryExpressionMockedObj(BinaryOperator.GE, ExpressionKind.PROPERTY, SALES_ORDER, SAMPLE_DATA_1);
+ CommonExpression exp2 =
+ getBinaryExpressionMockedObj(BinaryOperator.NE, ExpressionKind.PROPERTY, SALES_ABC, SAMPLE_DATA_XYZ);
+ try {
+ parsedStr =
+ ODataExpressionParser.parseToJPAWhereExpression(getBinaryExpression(exp1, BinaryOperator.AND, exp2),
+ TABLE_ALIAS);
+ assertEquals(EXPECTED_STR_2, parsedStr);
+ parsedStr =
+ ODataExpressionParser.parseToJPAWhereExpression(getBinaryExpression(exp1, BinaryOperator.OR, exp2),
+ TABLE_ALIAS);
+ } catch (ODataException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+ assertEquals(EXPECTED_STR_3, parsedStr);
+ }
+
+ @Test
+ public void testParseFilterExpression() {
+ try {
+ assertEquals(EXPECTED_STR_10, ODataExpressionParser.parseToJPAWhereExpression(getFilterExpressionMockedObj(
+ ExpressionKind.PROPERTY, SALES_ORDER), TABLE_ALIAS));
+ } catch (ODataException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+ }
+
+ @Test
+ public void testAllBinaryOperators() { // Test for all Binary Operators
+ // complex query -
+ String parsedStr1 = ODataJPATestConstants.EMPTY_STRING;
+ String parsedStr2 = ODataJPATestConstants.EMPTY_STRING;
+
+ CommonExpression exp1 =
+ getBinaryExpressionMockedObj(BinaryOperator.LT, ExpressionKind.PROPERTY, SALES_ORDER, SAMPLE_DATA_1);
+ CommonExpression exp2 =
+ getBinaryExpressionMockedObj(BinaryOperator.LE, ExpressionKind.PROPERTY, SALES_ABC, SAMPLE_DATA_XYZ);
+
+ try {
+ parsedStr1 =
+ ODataExpressionParser.parseToJPAWhereExpression((BinaryExpression) getBinaryExpression(exp1,
+ BinaryOperator.AND, exp2), TABLE_ALIAS);
+ assertEquals(EXPECTED_STR_4, parsedStr1);
+
+ CommonExpression exp3 =
+ getBinaryExpressionMockedObj(BinaryOperator.GT, ExpressionKind.PROPERTY, SAMPLE_DATA_LINE_ITEMS,
+ SAMPLE_DATA_2);
+ CommonExpression exp4 =
+ getBinaryExpressionMockedObj(BinaryOperator.GE, ExpressionKind.PROPERTY, SALES_ORDER, SAMPLE_DATA_AMAZON);
+
+ parsedStr2 =
+ ODataExpressionParser.parseToJPAWhereExpression(getBinaryExpression(exp3, BinaryOperator.AND, exp4),
+ TABLE_ALIAS);
+
+ } catch (ODataException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+ assertEquals(EXPECTED_STR_5, parsedStr2);
+ }
+
+ @Test
+ public void testParseMemberExpression() {
+ try {
+ assertEquals(EXPECTED_STR_6, ODataExpressionParser.parseToJPAWhereExpression(getBinaryExpression(
+ getMemberExpressionMockedObj(ADDRESS, CITY), BinaryOperator.EQ,
+ getLiteralExpressionMockedObj(SAMPLE_DATA_CITY_3)), TABLE_ALIAS));
+ assertEquals(EXPECTED_STR_7, ODataExpressionParser.parseToJPAWhereExpression(getBinaryExpression(
+ getMultipleMemberExpressionMockedObj(ADDRESS, CITY, AREA), BinaryOperator.EQ,
+ getLiteralExpressionMockedObj(SAMPLE_DATA_BTM)), TABLE_ALIAS));
+ } catch (ODataException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+ }
+
+ @Test
+ public void testParseMethodExpression() {
+ try {
+ assertEquals(EXPECTED_STR_12, ODataExpressionParser.parseToJPAWhereExpression(getBinaryExpression(
+ getMethodExpressionMockedObj(MethodOperator.SUBSTRINGOF, "'Ru'", "currencyCode", null, 2), BinaryOperator.EQ,
+ getLiteralExpressionMockedObj("true")), TABLE_ALIAS));
+ assertEquals(EXPECTED_STR_13, ODataExpressionParser.parseToJPAWhereExpression(getBinaryExpression(
+ getMethodExpressionMockedObj(MethodOperator.SUBSTRING, "currencyCode", "1", "2", 3), BinaryOperator.EQ,
+ getLiteralExpressionMockedObj("'NR'")), TABLE_ALIAS));
+ assertEquals(EXPECTED_STR_14, ODataExpressionParser.parseToJPAWhereExpression(getBinaryExpression(
+ getMethodExpressionMockedObj(MethodOperator.TOLOWER, "currencyCode", null, null, 1), BinaryOperator.EQ,
+ getLiteralExpressionMockedObj("'inr rupees'")), TABLE_ALIAS));
+ assertEquals(EXPECTED_STR_15, ODataExpressionParser.parseToJPAWhereExpression(getBinaryExpression(
+ getMultipleMethodExpressionMockedObj(MethodOperator.SUBSTRINGOF, "'nr rupees'", MethodOperator.TOLOWER,
+ "currencyCode", 2, 1), BinaryOperator.EQ, getLiteralExpressionMockedObj("true")), TABLE_ALIAS));
+ assertEquals(EXPECTED_STR_16, ODataExpressionParser.parseToJPAWhereExpression(
+ getFilterExpressionForFunctionsMockedObj(MethodOperator.SUBSTRINGOF, "'INR'", null, "currencyCode", 2, null)
+ /*
+ * getBinaryExpression(
+ * getMemberExpressionMockedObj(ADDRESS,
+ * CITY),
+ * BinaryOperator.EQ,
+ * getLiteralExpressionMockedObj(SAMPLE_DATA_CITY_3))
+ */, TABLE_ALIAS));
+ assertEquals(EXPECTED_STR_17, ODataExpressionParser.parseToJPAWhereExpression(
+ getFilterExpressionForFunctionsMockedObj(MethodOperator.SUBSTRINGOF, "'nr rupees'", MethodOperator.TOLOWER,
+ "currencyCode", 2, 1)
+ /*
+ * getBinaryExpression(
+ * getMemberExpressionMockedObj(ADDRESS,
+ * CITY),
+ * BinaryOperator.EQ,
+ * getLiteralExpressionMockedObj(SAMPLE_DATA_CITY_3))
+ */, TABLE_ALIAS));
+
+ } catch (ODataException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+ }
+
+ private CommonExpression getMethodExpressionMockedObj(final MethodOperator methodOperator, final String firstName,
+ final String secondName, final String thirdName, final Integer parameterCount) {
+
+ List<CommonExpression> parameters = new ArrayList<CommonExpression>();
+
+ if (methodOperator == MethodOperator.SUBSTRINGOF) {
+ parameters.add(getLiteralExpressionMockedObj(firstName));
+ parameters.add(getPropertyExpressionMockedObj(ExpressionKind.PROPERTY, secondName));
+ } else if (methodOperator == MethodOperator.SUBSTRING) {
+ parameters.add(getPropertyExpressionMockedObj(ExpressionKind.PROPERTY, firstName));
+ parameters.add(getLiteralExpressionMockedObj(secondName));
+ parameters.add(getLiteralExpressionMockedObj(thirdName));
+ } else if (methodOperator == MethodOperator.TOLOWER) {
+ parameters.add(getPropertyExpressionMockedObj(ExpressionKind.PROPERTY, firstName));
+ }
+
+ MethodExpression methodExpression = EasyMock.createMock(MethodExpression.class);
+
+ EasyMock.expect(methodExpression.getKind()).andStubReturn(ExpressionKind.METHOD);
+ EasyMock.expect(methodExpression.getMethod()).andStubReturn(methodOperator);
+ EasyMock.expect(methodExpression.getParameterCount()).andStubReturn(parameterCount);
+ EasyMock.expect(methodExpression.getParameters()).andStubReturn(parameters);
+ EasyMock.replay(methodExpression);
+
+ return methodExpression;
+ }
+
+ private CommonExpression getMultipleMethodExpressionMockedObj(final MethodOperator methodOperator1,
+ final String firstName, final MethodOperator methodOperator2, final String secondName,
+ final Integer parameterCount1, final Integer parameterCount2) {
+
+ // complex query
+ List<CommonExpression> parameters = new ArrayList<CommonExpression>();
+
+ parameters.add(getLiteralExpressionMockedObj(firstName));
+ parameters.add(getMethodExpressionMockedObj(methodOperator2, secondName, null, null, 1));
+
+ MethodExpression methodExpression = EasyMock.createMock(MethodExpression.class);
+
+ EasyMock.expect(methodExpression.getKind()).andStubReturn(ExpressionKind.METHOD);
+ EasyMock.expect(methodExpression.getMethod()).andStubReturn(methodOperator1);
+ EasyMock.expect(methodExpression.getParameterCount()).andStubReturn(parameterCount1);
+ EasyMock.expect(methodExpression.getParameters()).andStubReturn(parameters);
+ EasyMock.replay(methodExpression);
+
+ return methodExpression;
+ }
+
+ private CommonExpression getMultipleMemberExpressionMockedObj(final String string1, final String string2,
+ final String string3) {
+
+ MemberExpression memberExpression = EasyMock.createMock(MemberExpression.class);
+
+ EasyMock.expect(memberExpression.getPath()).andStubReturn(getMemberExpressionMockedObj(string1, string2));
+ EasyMock.expect(memberExpression.getProperty()).andStubReturn(
+ getPropertyExpressionMockedObj(ExpressionKind.PROPERTY, string3));
+ EasyMock.expect(memberExpression.getKind()).andStubReturn(ExpressionKind.MEMBER);
+ EasyMock.replay(memberExpression);
+
+ return memberExpression;
+ }
+
+ @Test
+ public void testParseUnaryExpression() {
+
+ UnaryExpression unaryExpression =
+ getUnaryExpressionMockedObj(getPropertyExpressionMockedObj(ExpressionKind.PROPERTY, "deliveryStatus"),
+ org.apache.olingo.odata2.api.uri.expression.UnaryOperator.NOT);
+ try {
+ assertEquals(EXPECTED_STR_11, ODataExpressionParser.parseToJPAWhereExpression(unaryExpression, TABLE_ALIAS));
+ } catch (ODataException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+
+ }
+
+ private UnaryExpression
+ getUnaryExpressionMockedObj(final CommonExpression operand, final UnaryOperator unaryOperator) {
+ UnaryExpression unaryExpression = EasyMock.createMock(UnaryExpression.class);
+ EasyMock.expect(unaryExpression.getKind()).andStubReturn(ExpressionKind.UNARY);
+ EasyMock.expect(unaryExpression.getOperand()).andStubReturn(operand);
+ EasyMock.expect(unaryExpression.getOperator()).andStubReturn(unaryOperator);
+
+ EasyMock.replay(unaryExpression);
+ return unaryExpression;
+ }
+
+ private CommonExpression getMemberExpressionMockedObj(final String pathUriLiteral, final String propertyUriLiteral) {
+ MemberExpression memberExpression = EasyMock.createMock(MemberExpression.class);
+ EasyMock.expect(memberExpression.getPath()).andStubReturn(
+ getPropertyExpressionMockedObj(ExpressionKind.PROPERTY, pathUriLiteral));
+ EasyMock.expect(memberExpression.getProperty()).andStubReturn(
+ getPropertyExpressionMockedObj(ExpressionKind.PROPERTY, propertyUriLiteral));
+ EasyMock.expect(memberExpression.getKind()).andStubReturn(ExpressionKind.MEMBER);
+
+ EasyMock.replay(memberExpression);
+ return memberExpression;
+ }
+
+ private LiteralExpression getLiteralExpressionMockedObj(final String uriLiteral) {
+ LiteralExpression rightOperandLiteralExpresion = EasyMock.createMock(LiteralExpression.class);
+ EasyMock.expect(rightOperandLiteralExpresion.getKind()).andStubReturn(ExpressionKind.LITERAL);
+ EasyMock.expect(rightOperandLiteralExpresion.getUriLiteral()).andStubReturn(uriLiteral);// SAMPLE_DATA
+ EasyMock.expect(rightOperandLiteralExpresion.getEdmType()).andStubReturn(getEdmSimpleTypeMockedObj(uriLiteral));
+ EasyMock.replay(rightOperandLiteralExpresion);
+ return rightOperandLiteralExpresion;
+
+ }
+
+ private EdmSimpleType getEdmSimpleTypeMockedObj(final String value) {
+ EdmSimpleType edmSimpleType = EasyMock.createMock(EdmSimpleType.class);
+ try {
+ EasyMock.expect(edmSimpleType.getName()).andReturn(value);
+ EasyMock.expect(edmSimpleType.getKind()).andStubReturn(EdmTypeKind.SIMPLE);
+ EasyMock.expect(edmSimpleType.valueOfString(value, EdmLiteralKind.URI, getEdmFacetsMockedObj(), null))
+ .andStubReturn(value);
+ EasyMock.expect(edmSimpleType.valueOfString(value, EdmLiteralKind.URI, null, null)).andStubReturn(value);
+ EasyMock.expect(edmSimpleType.valueToString(value, EdmLiteralKind.DEFAULT, getEdmFacetsMockedObj()))
+ .andStubReturn(value);
+ EasyMock.expect(edmSimpleType.valueToString(value, EdmLiteralKind.DEFAULT, null)).andStubReturn(value);
+ } catch (EdmException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+ EasyMock.expect(edmSimpleType.getDefaultType()).andStubReturn(null);
+ EasyMock.replay(edmSimpleType);
+ return edmSimpleType;
+ }
+
+ private EdmFacets getEdmFacetsMockedObj() {
+ EdmFacets facets = EasyMock.createMock(EdmFacets.class);
+
+ EasyMock.replay(facets);
+ return facets;
+ }
+
+ private PropertyExpression getPropertyExpressionMockedObj(final ExpressionKind expKind, final String propertyName) {
+ PropertyExpression leftOperandPropertyExpresion = EasyMock.createMock(PropertyExpression.class);
+ EasyMock.expect(leftOperandPropertyExpresion.getKind()).andStubReturn(ExpressionKind.PROPERTY);
+ EasyMock.expect(leftOperandPropertyExpresion.getPropertyName()).andStubReturn(propertyName);
+ EasyMock.expect(leftOperandPropertyExpresion.getEdmProperty()).andStubReturn(getEdmTypedMockedObj(propertyName));
+ EasyMock.replay(leftOperandPropertyExpresion);
+ return leftOperandPropertyExpresion;
+ }
+
+ private EdmTyped getEdmTypedMockedObj(final String propertyName) {
+ EdmProperty mockedEdmProperty = EasyMock.createMock(EdmProperty.class);
+ try {
+ EasyMock.expect(mockedEdmProperty.getMapping()).andStubReturn(getEdmMappingMockedObj(propertyName));
+ EasyMock.replay(mockedEdmProperty);
+ } catch (EdmException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+ return mockedEdmProperty;
+ }
+
+ private EdmMapping getEdmMappingMockedObj(final String propertyName) {
+ EdmMapping mockedEdmMapping = EasyMock.createMock(EdmMapping.class);
+ EasyMock.expect(mockedEdmMapping.getInternalName()).andStubReturn(propertyName);
+ EasyMock.replay(mockedEdmMapping);
+ return mockedEdmMapping;
+ }
+
+ private BinaryExpression getBinaryExpressionMockedObj(final BinaryOperator operator,
+ final ExpressionKind leftOperandExpKind, final String propertyName, final String literalStr) {
+ BinaryExpression binaryExpression = EasyMock.createMock(BinaryExpression.class);
+ EasyMock.expect(binaryExpression.getKind()).andStubReturn(ExpressionKind.BINARY);
+ EasyMock.expect(binaryExpression.getLeftOperand()).andStubReturn(
+ getPropertyExpressionMockedObj(leftOperandExpKind, propertyName));
+ EasyMock.expect(binaryExpression.getOperator()).andStubReturn(operator);
+ EasyMock.expect(binaryExpression.getRightOperand()).andStubReturn(getLiteralExpressionMockedObj(literalStr));
+
+ EasyMock.replay(binaryExpression);
+ return binaryExpression;
+ }
+
+ private FilterExpression getFilterExpressionMockedObj(final ExpressionKind leftOperandExpKind,
+ final String propertyName) {
+ FilterExpression filterExpression = EasyMock.createMock(FilterExpression.class);
+ EasyMock.expect(filterExpression.getKind()).andStubReturn(ExpressionKind.FILTER);
+ EasyMock.expect(filterExpression.getExpression()).andStubReturn(
+ getPropertyExpressionMockedObj(leftOperandExpKind, propertyName));
+
+ EasyMock.replay(filterExpression);
+ return filterExpression;
+ }
+
+ private FilterExpression getFilterExpressionForFunctionsMockedObj(final MethodOperator methodOperator1,
+ final String firstName, final MethodOperator methodOperator2, final String secondName,
+ final Integer parameterCount1, final Integer parameterCount2) {
+ // default value handling of SUBSTRINGOF
+ FilterExpression filterExpression = EasyMock.createMock(FilterExpression.class);
+ EasyMock.expect(filterExpression.getKind()).andStubReturn(ExpressionKind.FILTER);
+ if ((methodOperator2 != null) && (parameterCount2 != null)) {
+ EasyMock.expect(filterExpression.getExpression()).andStubReturn(
+ getMultipleMethodExpressionMockedObj(methodOperator1, firstName, methodOperator2, secondName,
+ parameterCount1, parameterCount2));
+ } else {
+ EasyMock.expect(filterExpression.getExpression()).andStubReturn(
+ getMethodExpressionMockedObj(methodOperator1, firstName, secondName, null, parameterCount1));
+ }
+
+ EasyMock.replay(filterExpression);
+ return filterExpression;
+ }
+
+ private CommonExpression getBinaryExpression(final CommonExpression leftOperand, final BinaryOperator operator,
+ final CommonExpression rightOperand) {
+ BinaryExpression binaryExpression = EasyMock.createMock(BinaryExpression.class);
+ EasyMock.expect(binaryExpression.getKind()).andStubReturn(ExpressionKind.BINARY);
+ EasyMock.expect(binaryExpression.getLeftOperand()).andStubReturn(leftOperand);
+ EasyMock.expect(binaryExpression.getRightOperand()).andStubReturn(rightOperand);
+ EasyMock.expect(binaryExpression.getOperator()).andStubReturn(operator);
+
+ EasyMock.replay(binaryExpression);
+ return binaryExpression;
+ }
+
+ @Test
+ public void testParseKeyPredicates() {
+ // Setting up the expected value
+ KeyPredicate keyPredicate1 = EasyMock.createMock(KeyPredicate.class);
+ EdmProperty kpProperty1 = EasyMock.createMock(EdmProperty.class);
+ EasyMock.expect(keyPredicate1.getLiteral()).andStubReturn("1");
+ KeyPredicate keyPredicate2 = EasyMock.createMock(KeyPredicate.class);
+ EdmProperty kpProperty2 = EasyMock.createMock(EdmProperty.class);
+ EasyMock.expect(keyPredicate2.getLiteral()).andStubReturn("abc");
+ EdmMapping edmMapping = EasyMock.createMock(EdmMapping.class);
+ try {
+ EasyMock.expect(kpProperty1.getName()).andStubReturn(SAMPLE_DATA_FIELD1);
+ EasyMock.expect(kpProperty1.getType()).andStubReturn(EdmSimpleTypeKind.Int32.getEdmSimpleTypeInstance());
+ EasyMock.expect(kpProperty2.getName()).andStubReturn(SAMPLE_DATA_FIELD2);
+ EasyMock.expect(kpProperty2.getType()).andStubReturn(EdmSimpleTypeKind.String.getEdmSimpleTypeInstance());
+ EasyMock.expect(keyPredicate1.getProperty()).andStubReturn(kpProperty1);
+ EasyMock.expect(kpProperty1.getMapping()).andReturn(edmMapping);
+ EasyMock.expect(edmMapping.getInternalName()).andReturn(SAMPLE_DATA_FIELD1);
+ EasyMock.expect(keyPredicate2.getProperty()).andStubReturn(kpProperty2);
+ EasyMock.expect(kpProperty2.getMapping()).andReturn(edmMapping);
+ } catch (EdmException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+ EasyMock.expect(edmMapping.getInternalName()).andReturn(SAMPLE_DATA_FIELD2);
+ EasyMock.replay(edmMapping);
+ EasyMock.replay(kpProperty1, keyPredicate1, kpProperty2, keyPredicate2);
+
+ ArrayList<KeyPredicate> keyPredicates = new ArrayList<KeyPredicate>();
+ keyPredicates.add(keyPredicate1);
+ keyPredicates.add(keyPredicate2);
+ String str = null;
+
+ try {
+ str = ODataExpressionParser.parseKeyPredicates(keyPredicates, TABLE_ALIAS);
+ } catch (ODataJPARuntimeException e) {
+ fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+ }
+
+ assertEquals(EXPECTED_STR_8, str);
+ }
+
+ @Test
+ public void testParseToJPASelectExpression() {
+
+ ArrayList<String> selectedFields = new ArrayList<String>();
+ selectedFields.add("BuyerAddress");
+ selectedFields.add("BuyerName");
+ selectedFields.add("BuyerId");
+
+ assertEquals(EXPECTED_STR_9, ODataExpressionParser.parseToJPASelectExpression(TABLE_ALIAS, selectedFields));
+ assertEquals(TABLE_ALIAS, ODataExpressionParser.parseToJPASelectExpression(TABLE_ALIAS, null));
+
+ selectedFields.clear();
+ assertEquals(TABLE_ALIAS, ODataExpressionParser.parseToJPASelectExpression(TABLE_ALIAS, selectedFields));
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1b479e6c/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/ODataJPAContextImplTest.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/ODataJPAContextImplTest.java b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/ODataJPAContextImplTest.java
new file mode 100644
index 0000000..10e65c0
--- /dev/null
+++ b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/processor/core/jpa/ODataJPAContextImplTest.java
@@ -0,0 +1,98 @@
+/*******************************************************************************
+ * 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;
+
+import static org.junit.Assert.assertEquals;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Locale;
+
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+
+import org.apache.olingo.odata2.api.edm.provider.EdmProvider;
+import org.apache.olingo.odata2.api.processor.ODataContext;
+import org.apache.olingo.odata2.api.processor.ODataProcessor;
+import org.apache.olingo.odata2.processor.api.jpa.ODataJPAContext;
+import org.apache.olingo.odata2.processor.core.jpa.edm.ODataJPAEdmProvider;
+import org.apache.olingo.odata2.processor.core.jpa.mock.ODataJPAContextMock;
+import org.easymock.EasyMock;
+import org.junit.Before;
+import org.junit.Test;
+
+public class ODataJPAContextImplTest {
+
+ private ODataContext odataContext = null;
+ private ODataJPAContext odataJPAContext = null;
+ private EdmProvider edmProvider = null;
+ private EntityManagerFactory emf = null;
+ private EntityManager em = null;
+ private ODataProcessor processor = null;
+
+ @Before
+ public void setup() {
+
+ edmProvider = new ODataJPAEdmProvider();
+ emf = EasyMock.createMock(EntityManagerFactory.class);
+ em = EasyMock.createMock(EntityManager.class);
+ EasyMock.replay(em);
+
+ EasyMock.expect(emf.createEntityManager()).andStubReturn(em);
+ EasyMock.replay(emf);
+
+ odataContext = EasyMock.createMock(ODataContext.class);
+ List<Locale> listLocale = new ArrayList<Locale>();
+ listLocale.add(Locale.ENGLISH);
+ listLocale.add(Locale.GERMAN);
+
+ EasyMock.expect(odataContext.getAcceptableLanguages()).andStubReturn(listLocale);
+ EasyMock.replay(odataContext);
+
+ processor = EasyMock.createMock(ODataProcessor.class);
+ EasyMock.replay(processor);
+
+ odataJPAContext = new ODataJPAContextImpl();
+ odataJPAContext.setEdmProvider(edmProvider);
+ odataJPAContext.setEntityManagerFactory(emf);
+ odataJPAContext.setODataContext(odataContext);
+ odataJPAContext.setODataProcessor(processor);
+ odataJPAContext.setPersistenceUnitName(ODataJPAContextMock.PERSISTENCE_UNIT_NAME);
+ odataJPAContext.setJPAEdmMappingModel(ODataJPAContextMock.MAPPING_MODEL);
+ }
+
+ @Test
+ public void testgetMethodsOfODataJPAContext() {
+
+ assertEquals(odataJPAContext.getEdmProvider().hashCode(), edmProvider.hashCode());
+ assertEquals(odataJPAContext.getEntityManagerFactory().hashCode(), emf.hashCode());
+ assertEquals(odataJPAContext.getODataContext().hashCode(), odataContext.hashCode());
+ assertEquals(odataJPAContext.getODataProcessor().hashCode(), processor.hashCode());
+ assertEquals(odataJPAContext.getPersistenceUnitName(), ODataJPAContextMock.PERSISTENCE_UNIT_NAME);
+ assertEquals(odataJPAContext.getJPAEdmMappingModel(), ODataJPAContextMock.MAPPING_MODEL);
+
+ EntityManager em1 = odataJPAContext.getEntityManager();
+ EntityManager em2 = odataJPAContext.getEntityManager();
+ if (em1 != null && em2 != null) {
+ assertEquals(em1.hashCode(), em2.hashCode());
+ }
+
+ }
+
+}