You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@olingo.apache.org by fm...@apache.org on 2013/07/26 13:22:54 UTC
[49/51] [partial] initial commit
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/ff2b0a0e/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/factory/JPQLBuilderFactory.java
----------------------------------------------------------------------
diff --git a/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/factory/JPQLBuilderFactory.java b/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/factory/JPQLBuilderFactory.java
new file mode 100644
index 0000000..5f664f6
--- /dev/null
+++ b/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/factory/JPQLBuilderFactory.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.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>
+ *
+ * @author SAP AG
+ * @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/ff2b0a0e/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/factory/ODataJPAAccessFactory.java
----------------------------------------------------------------------
diff --git a/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/factory/ODataJPAAccessFactory.java b/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/factory/ODataJPAAccessFactory.java
new file mode 100644
index 0000000..072a069
--- /dev/null
+++ b/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/factory/ODataJPAAccessFactory.java
@@ -0,0 +1,90 @@
+/*******************************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, 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>
+ *
+ * @author SAP AG
+ * @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/ff2b0a0e/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/factory/ODataJPAFactory.java
----------------------------------------------------------------------
diff --git a/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/factory/ODataJPAFactory.java b/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/factory/ODataJPAFactory.java
new file mode 100644
index 0000000..0f538c1
--- /dev/null
+++ b/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/factory/ODataJPAFactory.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.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>
+ *
+ * @author SAP AG
+ *
+ *
+ *
+ */
+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/ff2b0a0e/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/factory/package-info.java
----------------------------------------------------------------------
diff --git a/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/factory/package-info.java b/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/factory/package-info.java
new file mode 100644
index 0000000..6c785eb
--- /dev/null
+++ b/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.
+ *
+ * @author SAP AG
+ */
+package org.apache.olingo.odata2.processor.api.jpa.factory;
+
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/ff2b0a0e/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/jpql/JPQLContext.java
----------------------------------------------------------------------
diff --git a/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/jpql/JPQLContext.java b/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/jpql/JPQLContext.java
new file mode 100644
index 0000000..c227a86
--- /dev/null
+++ b/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/jpql/JPQLContext.java
@@ -0,0 +1,211 @@
+/*******************************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, 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.
+ *
+ * @author SAP AG
+ * @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.
+ *
+ * @author SAP AG
+ *
+ */
+ 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/ff2b0a0e/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/jpql/JPQLContextType.java
----------------------------------------------------------------------
diff --git a/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/jpql/JPQLContextType.java b/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/jpql/JPQLContextType.java
new file mode 100644
index 0000000..3a379b7
--- /dev/null
+++ b/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.
+ *
+ * @author SAP AG
+ *
+ */
+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/ff2b0a0e/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/jpql/JPQLContextView.java
----------------------------------------------------------------------
diff --git a/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/jpql/JPQLContextView.java b/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/jpql/JPQLContextView.java
new file mode 100644
index 0000000..0d907b0
--- /dev/null
+++ b/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/jpql/JPQLContextView.java
@@ -0,0 +1,54 @@
+/*******************************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, 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.
+ *
+ * @author SAP AG
+ * @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/ff2b0a0e/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/jpql/JPQLJoinContextView.java
----------------------------------------------------------------------
diff --git a/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/jpql/JPQLJoinContextView.java b/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/jpql/JPQLJoinContextView.java
new file mode 100644
index 0000000..7227da7
--- /dev/null
+++ b/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/jpql/JPQLJoinContextView.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 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.
+ *
+ * @author SAP AG
+ * @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/ff2b0a0e/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/jpql/JPQLJoinSelectSingleContextView.java
----------------------------------------------------------------------
diff --git a/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/jpql/JPQLJoinSelectSingleContextView.java b/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/jpql/JPQLJoinSelectSingleContextView.java
new file mode 100644
index 0000000..de923d0
--- /dev/null
+++ b/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/jpql/JPQLJoinSelectSingleContextView.java
@@ -0,0 +1,47 @@
+/*******************************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, 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.
+ *
+ * @author SAP AG
+ * @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/ff2b0a0e/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/jpql/JPQLSelectContextView.java
----------------------------------------------------------------------
diff --git a/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/jpql/JPQLSelectContextView.java b/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/jpql/JPQLSelectContextView.java
new file mode 100644
index 0000000..3958c9f
--- /dev/null
+++ b/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.
+ *
+ * @author SAP AG
+ * @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/ff2b0a0e/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/jpql/JPQLSelectSingleContextView.java
----------------------------------------------------------------------
diff --git a/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/jpql/JPQLSelectSingleContextView.java b/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/jpql/JPQLSelectSingleContextView.java
new file mode 100644
index 0000000..68c73ff
--- /dev/null
+++ b/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.
+ *
+ * @author SAP AG
+ * @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/ff2b0a0e/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/jpql/JPQLStatement.java
----------------------------------------------------------------------
diff --git a/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/jpql/JPQLStatement.java b/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/jpql/JPQLStatement.java
new file mode 100644
index 0000000..934fe02
--- /dev/null
+++ b/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/jpql/JPQLStatement.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.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.
+ *
+ * @author SAP AG
+ * @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.
+ *
+ * @author SAP AG
+ *
+ */
+ 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/ff2b0a0e/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/jpql/package-info.java
----------------------------------------------------------------------
diff --git a/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/jpql/package-info.java b/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/jpql/package-info.java
new file mode 100644
index 0000000..b03bd31
--- /dev/null
+++ b/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.
+ *
+ * @author SAP AG
+ */
+package org.apache.olingo.odata2.processor.api.jpa.jpql;
+
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/ff2b0a0e/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmAssociationEndView.java
----------------------------------------------------------------------
diff --git a/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmAssociationEndView.java b/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmAssociationEndView.java
new file mode 100644
index 0000000..e9b0d40
--- /dev/null
+++ b/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmAssociationEndView.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.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>
+ *
+ * @author SAP AG
+ * <p>
+ * @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/ff2b0a0e/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmAssociationSetView.java
----------------------------------------------------------------------
diff --git a/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmAssociationSetView.java b/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmAssociationSetView.java
new file mode 100644
index 0000000..86bf6fc
--- /dev/null
+++ b/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>
+ *
+ * @author SAP AG
+ * <p>
+ * @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/ff2b0a0e/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmAssociationView.java
----------------------------------------------------------------------
diff --git a/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmAssociationView.java b/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmAssociationView.java
new file mode 100644
index 0000000..07ab135
--- /dev/null
+++ b/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmAssociationView.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.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>
+ *
+ * @author SAP AG
+ * <p>
+ * @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/ff2b0a0e/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmBaseView.java
----------------------------------------------------------------------
diff --git a/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmBaseView.java b/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmBaseView.java
new file mode 100644
index 0000000..0a01c2d
--- /dev/null
+++ b/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmBaseView.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.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.
+ *
+ * @author SAP AG
+ * <p>
+ * @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>
+ *
+ */
+ 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();
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/ff2b0a0e/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmComplexPropertyView.java
----------------------------------------------------------------------
diff --git a/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmComplexPropertyView.java b/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmComplexPropertyView.java
new file mode 100644
index 0000000..27d8afe
--- /dev/null
+++ b/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmComplexPropertyView.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.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>
+ *
+ * @author SAP AG
+ * @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/ff2b0a0e/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmComplexTypeView.java
----------------------------------------------------------------------
diff --git a/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmComplexTypeView.java b/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmComplexTypeView.java
new file mode 100644
index 0000000..8ee0b25
--- /dev/null
+++ b/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmComplexTypeView.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.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.
+ *
+ * @author SAP AG
+ * <p>
+ * @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/ff2b0a0e/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmEntityContainerView.java
----------------------------------------------------------------------
diff --git a/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmEntityContainerView.java b/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmEntityContainerView.java
new file mode 100644
index 0000000..00f5eaf
--- /dev/null
+++ b/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmEntityContainerView.java
@@ -0,0 +1,75 @@
+/*******************************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, 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.
+ *
+ * @author SAP AG
+ * @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/ff2b0a0e/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmEntitySetView.java
----------------------------------------------------------------------
diff --git a/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmEntitySetView.java b/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmEntitySetView.java
new file mode 100644
index 0000000..25f4557
--- /dev/null
+++ b/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmEntitySetView.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.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.
+ *
+ * @author SAP AG
+ * <p>
+ * @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/ff2b0a0e/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmEntityTypeView.java
----------------------------------------------------------------------
diff --git a/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmEntityTypeView.java b/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmEntityTypeView.java
new file mode 100644
index 0000000..6a5219b
--- /dev/null
+++ b/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmEntityTypeView.java
@@ -0,0 +1,78 @@
+/*******************************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ ******************************************************************************/
+package org.apache.olingo.odata2.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.
+ *
+ * @author SAP AG
+ * <p>
+ * @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/ff2b0a0e/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmExtension.java
----------------------------------------------------------------------
diff --git a/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmExtension.java b/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmExtension.java
new file mode 100644
index 0000000..4294741
--- /dev/null
+++ b/jpa-api/src/main/java/org/apache/olingo/odata2/processor/api/jpa/model/JPAEdmExtension.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 provides methods to extend JPA EDM containers.
+ *
+ * @author SAP AG
+ *
+ */
+public interface JPAEdmExtension {
+ /**
+ * The method is used to extend the JPA EDM schema view. 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[])
+ * @deprecated Use {@link org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmExtension#extendWithOperations(JPAEdmSchemaView view)}
+ *
+ */
+ @Deprecated
+ public void extend(JPAEdmSchemaView view);
+
+ /**
+ * 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);
+
+}