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 2015/09/06 16:58:27 UTC
olingo-odata4 git commit: [OLINGO-619] - JPA CSdl Meta Data APIs -
Initial Version
Repository: olingo-odata4
Updated Branches:
refs/heads/OLINGO-549-ODataV4-JPA c42ca9222 -> 7edc5efaa
[OLINGO-619] - JPA CSdl Meta Data APIs - Initial Version
Signed-off-by: Chandan V A <ch...@sap.com>
Project: http://git-wip-us.apache.org/repos/asf/olingo-odata4/repo
Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata4/commit/7edc5efa
Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata4/tree/7edc5efa
Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata4/diff/7edc5efa
Branch: refs/heads/OLINGO-549-ODataV4-JPA
Commit: 7edc5efaad97ca1602bf3c29b5e8bfa2da23ef57
Parents: c42ca92
Author: Chandan V A <ch...@sap.com>
Authored: Sun Sep 6 20:28:13 2015 +0530
Committer: Chandan V A <ch...@sap.com>
Committed: Sun Sep 6 20:28:13 2015 +0530
----------------------------------------------------------------------
ext/odata-jpa/odata-jpa-api/pom.xml | 4 ++
.../jpa/api/ODataJPAAbstractEdmProvider.java | 11 +++++
.../apache/olingo/jpa/api/ODataJPAContext.java | 50 +++++++++++++++++++-
.../apache/olingo/jpa/api/ODataJPAServlet.java | 2 +-
.../extension/JPACsdlMetaModelExtension.java | 23 +++++++++
.../olingo/jpa/api/factory/ODataJPAFactory.java | 3 +-
.../olingo/jpa/api/model/JPACsdlBuilder.java | 35 ++++++++++++++
.../jpa/api/model/JPACsdlMetaModelAccessor.java | 27 +++++++++++
.../jpa/api/model/JPACsdlMetaModelContext.java | 31 ++++++++++++
.../jpa/api/model/JPACsdlSchemaAccessor.java | 35 ++++++++++++++
10 files changed, 218 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/7edc5efa/ext/odata-jpa/odata-jpa-api/pom.xml
----------------------------------------------------------------------
diff --git a/ext/odata-jpa/odata-jpa-api/pom.xml b/ext/odata-jpa/odata-jpa-api/pom.xml
index 0dd4a24..68f03be 100644
--- a/ext/odata-jpa/odata-jpa-api/pom.xml
+++ b/ext/odata-jpa/odata-jpa-api/pom.xml
@@ -45,5 +45,9 @@
<groupId>org.apache.olingo</groupId>
<artifactId>odata-server-api</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.eclipse.persistence</groupId>
+ <artifactId>javax.persistence</artifactId>
+ </dependency>
</dependencies>
</project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/7edc5efa/ext/odata-jpa/odata-jpa-api/src/main/java/org/apache/olingo/jpa/api/ODataJPAAbstractEdmProvider.java
----------------------------------------------------------------------
diff --git a/ext/odata-jpa/odata-jpa-api/src/main/java/org/apache/olingo/jpa/api/ODataJPAAbstractEdmProvider.java b/ext/odata-jpa/odata-jpa-api/src/main/java/org/apache/olingo/jpa/api/ODataJPAAbstractEdmProvider.java
index f2ec2d3..cc6710c 100644
--- a/ext/odata-jpa/odata-jpa-api/src/main/java/org/apache/olingo/jpa/api/ODataJPAAbstractEdmProvider.java
+++ b/ext/odata-jpa/odata-jpa-api/src/main/java/org/apache/olingo/jpa/api/ODataJPAAbstractEdmProvider.java
@@ -21,5 +21,16 @@ package org.apache.olingo.jpa.api;
import org.apache.olingo.commons.api.edm.provider.CsdlAbstractEdmProvider;
public abstract class ODataJPAAbstractEdmProvider extends CsdlAbstractEdmProvider {
+ private ODataJPAContext odataJPAContext = null;
+ public ODataJPAAbstractEdmProvider(ODataJPAContext context) {
+ if (context == null) {
+ throw new IllegalArgumentException();
+ }
+ this.odataJPAContext = context;
+ }
+
+ public ODataJPAContext getODataJPAContext() {
+ return odataJPAContext;
+ }
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/7edc5efa/ext/odata-jpa/odata-jpa-api/src/main/java/org/apache/olingo/jpa/api/ODataJPAContext.java
----------------------------------------------------------------------
diff --git a/ext/odata-jpa/odata-jpa-api/src/main/java/org/apache/olingo/jpa/api/ODataJPAContext.java b/ext/odata-jpa/odata-jpa-api/src/main/java/org/apache/olingo/jpa/api/ODataJPAContext.java
index 575b5de..82ad0f0 100644
--- a/ext/odata-jpa/odata-jpa-api/src/main/java/org/apache/olingo/jpa/api/ODataJPAContext.java
+++ b/ext/odata-jpa/odata-jpa-api/src/main/java/org/apache/olingo/jpa/api/ODataJPAContext.java
@@ -18,6 +18,10 @@
*/
package org.apache.olingo.jpa.api;
+import javax.persistence.EntityManagerFactory;
+
+import org.apache.olingo.jpa.api.extension.JPACsdlMetaModelExtension;
+
/**
* This class does the compilation of context objects required for OData JPA
* Runtime. The context object should be properly initialized with values else
@@ -32,8 +36,52 @@ package org.apache.olingo.jpa.api;
*/
public interface ODataJPAContext {
+ /**
+ * The method gets the Java Persistence Unit Name set into the context.
+ *
+ * @return Java Persistence Unit Name
+ */
String getPersistenceUnitName();
- void setPersistenceUnitName();
+ /**
+ * The method sets the Java Persistence Unit Name into the context.
+ *
+ * @param pUnitName
+ * is the Java Persistence Unit Name.
+ *
+ */
+ void setPersistenceUnitName(String pUnitName);
+
+ /**
+ * 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.jpa.api.ODataJPAContext#getEntityManager()}
+ *
+ * @return an instance of Java Persistence Entity Manager Factory
+ */
+ EntityManagerFactory getEntityManagerFactory();
+
+ /**
+ * The method sets the Java Persistence Entity Manager factory into the
+ * context.
+ *
+ * @param emf
+ * is of type {@link javax.persistence.EntityManagerFactory}
+ *
+ */
+ void setEntityManagerFactory(EntityManagerFactory emf);
+
+ /**
+ * The method returns the extension for JPA Csdl Meta Model.
+ * @return
+ */
+ JPACsdlMetaModelExtension getJPACsdlMetaModelExtension();
+ /**
+ * The method sets the extension for JPA Csdl Meta model
+ * @param extension
+ */
+ void setJPACsdlMetaModelExtension(JPACsdlMetaModelExtension extension);
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/7edc5efa/ext/odata-jpa/odata-jpa-api/src/main/java/org/apache/olingo/jpa/api/ODataJPAServlet.java
----------------------------------------------------------------------
diff --git a/ext/odata-jpa/odata-jpa-api/src/main/java/org/apache/olingo/jpa/api/ODataJPAServlet.java b/ext/odata-jpa/odata-jpa-api/src/main/java/org/apache/olingo/jpa/api/ODataJPAServlet.java
index ee25548..a56dbdc 100644
--- a/ext/odata-jpa/odata-jpa-api/src/main/java/org/apache/olingo/jpa/api/ODataJPAServlet.java
+++ b/ext/odata-jpa/odata-jpa-api/src/main/java/org/apache/olingo/jpa/api/ODataJPAServlet.java
@@ -93,7 +93,7 @@ public abstract class ODataJPAServlet extends HttpServlet {
odataJPAService = new ODataJPAService();
odataJPAContext = getODataJPAContext();
initializeODataJPAContext(odataJPAContext);
- odataJPAService.setODataJPAEdmProvider(odataJPAFactory.getODataJPAEdmProvider(persistenceUnitName));
+ odataJPAService.setODataJPAEdmProvider(odataJPAFactory.getODataJPAEdmProvider(odataJPAContext));
odataJPAService.setODataJPAProcessor(odataJPAFactory.getODataJPAProcessor(odataJPAContext));
return odataJPAService;
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/7edc5efa/ext/odata-jpa/odata-jpa-api/src/main/java/org/apache/olingo/jpa/api/extension/JPACsdlMetaModelExtension.java
----------------------------------------------------------------------
diff --git a/ext/odata-jpa/odata-jpa-api/src/main/java/org/apache/olingo/jpa/api/extension/JPACsdlMetaModelExtension.java b/ext/odata-jpa/odata-jpa-api/src/main/java/org/apache/olingo/jpa/api/extension/JPACsdlMetaModelExtension.java
new file mode 100644
index 0000000..b3e358c
--- /dev/null
+++ b/ext/odata-jpa/odata-jpa-api/src/main/java/org/apache/olingo/jpa/api/extension/JPACsdlMetaModelExtension.java
@@ -0,0 +1,23 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.olingo.jpa.api.extension;
+
+public interface JPACsdlMetaModelExtension {
+
+}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/7edc5efa/ext/odata-jpa/odata-jpa-api/src/main/java/org/apache/olingo/jpa/api/factory/ODataJPAFactory.java
----------------------------------------------------------------------
diff --git a/ext/odata-jpa/odata-jpa-api/src/main/java/org/apache/olingo/jpa/api/factory/ODataJPAFactory.java b/ext/odata-jpa/odata-jpa-api/src/main/java/org/apache/olingo/jpa/api/factory/ODataJPAFactory.java
index dd13b5d..9c99ff4 100644
--- a/ext/odata-jpa/odata-jpa-api/src/main/java/org/apache/olingo/jpa/api/factory/ODataJPAFactory.java
+++ b/ext/odata-jpa/odata-jpa-api/src/main/java/org/apache/olingo/jpa/api/factory/ODataJPAFactory.java
@@ -33,7 +33,8 @@ public abstract class ODataJPAFactory {
return odataJPAFactory;
}
- public abstract ODataJPAAbstractEdmProvider getODataJPAEdmProvider(String pUnitName) throws ODataJPAException;
+ public abstract ODataJPAAbstractEdmProvider getODataJPAEdmProvider(ODataJPAContext odataJPAContext)
+ throws ODataJPAException;
public abstract ODataJPAProcessor getODataJPAProcessor(ODataJPAContext odataJPAContext) throws ODataJPAException;
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/7edc5efa/ext/odata-jpa/odata-jpa-api/src/main/java/org/apache/olingo/jpa/api/model/JPACsdlBuilder.java
----------------------------------------------------------------------
diff --git a/ext/odata-jpa/odata-jpa-api/src/main/java/org/apache/olingo/jpa/api/model/JPACsdlBuilder.java b/ext/odata-jpa/odata-jpa-api/src/main/java/org/apache/olingo/jpa/api/model/JPACsdlBuilder.java
new file mode 100644
index 0000000..bb37fed
--- /dev/null
+++ b/ext/odata-jpa/odata-jpa-api/src/main/java/org/apache/olingo/jpa/api/model/JPACsdlBuilder.java
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.olingo.jpa.api.model;
+
+import org.apache.olingo.jpa.api.exception.ODataJPAException;
+
+/**
+ * JPAEdmBuilder interface provides methods for building elements of an Entity Data Model (EDM) from
+ * a Java Persistence Model.
+ */
+public interface JPACsdlBuilder {
+
+ /**
+ * the method builds an returns a reference to JPAEdm MetaModel accessor
+ * @return a reference to {@link org.apache.olingo.jpa.api.model.JPACsdlMetaModelAccessor}
+ * @throws ODataJPAException
+ */
+ JPACsdlMetaModelAccessor build() throws ODataJPAException;
+}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/7edc5efa/ext/odata-jpa/odata-jpa-api/src/main/java/org/apache/olingo/jpa/api/model/JPACsdlMetaModelAccessor.java
----------------------------------------------------------------------
diff --git a/ext/odata-jpa/odata-jpa-api/src/main/java/org/apache/olingo/jpa/api/model/JPACsdlMetaModelAccessor.java b/ext/odata-jpa/odata-jpa-api/src/main/java/org/apache/olingo/jpa/api/model/JPACsdlMetaModelAccessor.java
new file mode 100644
index 0000000..0fa316d
--- /dev/null
+++ b/ext/odata-jpa/odata-jpa-api/src/main/java/org/apache/olingo/jpa/api/model/JPACsdlMetaModelAccessor.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.jpa.api.model;
+
+/**
+ * The interface is a tag interface for Metadata/Model needed for transforming JPA entities into CSDL
+ * elements
+ */
+public interface JPACsdlMetaModelAccessor {
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/7edc5efa/ext/odata-jpa/odata-jpa-api/src/main/java/org/apache/olingo/jpa/api/model/JPACsdlMetaModelContext.java
----------------------------------------------------------------------
diff --git a/ext/odata-jpa/odata-jpa-api/src/main/java/org/apache/olingo/jpa/api/model/JPACsdlMetaModelContext.java b/ext/odata-jpa/odata-jpa-api/src/main/java/org/apache/olingo/jpa/api/model/JPACsdlMetaModelContext.java
new file mode 100644
index 0000000..bcf6696
--- /dev/null
+++ b/ext/odata-jpa/odata-jpa-api/src/main/java/org/apache/olingo/jpa/api/model/JPACsdlMetaModelContext.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.
+ */
+package org.apache.olingo.jpa.api.model;
+
+import javax.persistence.metamodel.Metamodel;
+
+import org.apache.olingo.jpa.api.extension.JPACsdlMetaModelExtension;
+
+public interface JPACsdlMetaModelContext {
+ String getPersistenceUnit();
+
+ Metamodel getJPAMetaModel();
+
+ JPACsdlMetaModelExtension getJPACsdlMetaModelExtension();
+}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/7edc5efa/ext/odata-jpa/odata-jpa-api/src/main/java/org/apache/olingo/jpa/api/model/JPACsdlSchemaAccessor.java
----------------------------------------------------------------------
diff --git a/ext/odata-jpa/odata-jpa-api/src/main/java/org/apache/olingo/jpa/api/model/JPACsdlSchemaAccessor.java b/ext/odata-jpa/odata-jpa-api/src/main/java/org/apache/olingo/jpa/api/model/JPACsdlSchemaAccessor.java
new file mode 100644
index 0000000..f95bc42
--- /dev/null
+++ b/ext/odata-jpa/odata-jpa-api/src/main/java/org/apache/olingo/jpa/api/model/JPACsdlSchemaAccessor.java
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.olingo.jpa.api.model;
+
+import org.apache.olingo.commons.api.edm.provider.CsdlSchema;
+
+/**
+ * The interface provides methods to access CSDL Schema generated from JPA Meta model.
+ */
+public interface JPACsdlSchemaAccessor extends JPACsdlMetaModelAccessor {
+ /**
+ * The method returns a CSDL Schema element built from JPA Meta Model.
+ * @return an instance of type {@link org.apache.olingo.commons.api.edm.provider.CsdlSchema}
+ */
+ CsdlSchema getCsdlSchema();
+
+ JPACsdlBuilder getJPACsdlBuilder();
+
+}