You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@olingo.apache.org by mi...@apache.org on 2013/09/24 14:43:11 UTC
[44/51] [partial] Refactored project structure
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/57599da6/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLSelectContext.java
----------------------------------------------------------------------
diff --git a/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLSelectContext.java b/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLSelectContext.java
deleted file mode 100644
index ef588aa..0000000
--- a/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLSelectContext.java
+++ /dev/null
@@ -1,159 +0,0 @@
-/*******************************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- ******************************************************************************/
-package org.apache.olingo.odata2.processor.core.jpa.jpql;
-
-import java.util.HashMap;
-
-import org.apache.olingo.odata2.api.edm.EdmEntityType;
-import org.apache.olingo.odata2.api.edm.EdmException;
-import org.apache.olingo.odata2.api.edm.EdmMapping;
-import org.apache.olingo.odata2.api.exception.ODataException;
-import org.apache.olingo.odata2.api.uri.info.GetEntitySetUriInfo;
-import org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPAModelException;
-import org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPARuntimeException;
-import org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLContext;
-import org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLContextType;
-import org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLSelectContextView;
-import org.apache.olingo.odata2.processor.core.jpa.ODataExpressionParser;
-
-public class JPQLSelectContext extends JPQLContext implements JPQLSelectContextView {
-
- protected String selectExpression;
- protected HashMap<String, String> orderByCollection;
- protected String whereCondition;
-
- protected boolean isCountOnly = false;// Support for $count
-
- public JPQLSelectContext(final boolean isCountOnly) {
- this.isCountOnly = isCountOnly;
- }
-
- protected final void setOrderByCollection(final HashMap<String, String> orderByCollection) {
- this.orderByCollection = orderByCollection;
- }
-
- protected final void setWhereExpression(final String filterExpression) {
- whereCondition = filterExpression;
- }
-
- protected final void setSelectExpression(final String selectExpression) {
- this.selectExpression = selectExpression;
- }
-
- @Override
- public String getSelectExpression() {
- return selectExpression;
- }
-
- @Override
- public HashMap<String, String> getOrderByCollection() {
- return orderByCollection;
- }
-
- @Override
- public String getWhereExpression() {
- return whereCondition;
- }
-
- public class JPQLSelectContextBuilder extends
- org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLContext.JPQLContextBuilder {
-
- protected GetEntitySetUriInfo entitySetView;
-
- @Override
- public JPQLContext build() throws ODataJPAModelException, ODataJPARuntimeException {
- if (entitySetView != null) {
-
- try {
-
- if (isCountOnly) {
- setType(JPQLContextType.SELECT_COUNT);
- } else {
- setType(JPQLContextType.SELECT);
- }
- EdmEntityType entityType = entitySetView.getTargetEntitySet().getEntityType();
- EdmMapping mapping = entityType.getMapping();
- if (mapping != null) {
- setJPAEntityName(mapping.getInternalName());
- } else {
- setJPAEntityName(entityType.getName());
- }
-
- setJPAEntityAlias(generateJPAEntityAlias());
-
- setOrderByCollection(generateOrderByFileds());
-
- setSelectExpression(generateSelectExpression());
-
- setWhereExpression(generateWhereExpression());
- } catch (ODataException e) {
- throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.INNER_EXCEPTION, e);
- }
- }
-
- return JPQLSelectContext.this;
-
- }
-
- @Override
- protected void setResultsView(final Object resultsView) {
- if (resultsView instanceof GetEntitySetUriInfo) {
- entitySetView = (GetEntitySetUriInfo) resultsView;
- }
-
- }
-
- /*
- * Generate Select Clause
- */
- protected String generateSelectExpression() throws EdmException {
- return getJPAEntityAlias();
- }
-
- /*
- * Generate Order By Clause Fields
- */
- protected HashMap<String, String> generateOrderByFileds() throws ODataJPARuntimeException, EdmException {
-
- if (entitySetView.getOrderBy() != null) {
-
- return ODataExpressionParser.parseToJPAOrderByExpression(entitySetView.getOrderBy(), getJPAEntityAlias());
-
- } else if (entitySetView.getTop() != null || entitySetView.getSkip() != null) {
-
- return ODataExpressionParser.parseKeyPropertiesToJPAOrderByExpression(entitySetView.getTargetEntitySet()
- .getEntityType().getKeyProperties(), getJPAEntityAlias());
- } else {
- return null;
- }
-
- }
-
- /*
- * Generate Where Clause Expression
- */
- protected String generateWhereExpression() throws ODataException {
- if (entitySetView.getFilter() != null) {
- return ODataExpressionParser.parseToJPAWhereExpression(entitySetView.getFilter(), getJPAEntityAlias());
- }
- return null;
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/57599da6/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLSelectSingleContext.java
----------------------------------------------------------------------
diff --git a/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLSelectSingleContext.java b/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLSelectSingleContext.java
deleted file mode 100644
index 9d2884d..0000000
--- a/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLSelectSingleContext.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/*******************************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- ******************************************************************************/
-package org.apache.olingo.odata2.processor.core.jpa.jpql;
-
-import java.util.List;
-
-import org.apache.olingo.odata2.api.edm.EdmEntityType;
-import org.apache.olingo.odata2.api.edm.EdmException;
-import org.apache.olingo.odata2.api.edm.EdmMapping;
-import org.apache.olingo.odata2.api.uri.KeyPredicate;
-import org.apache.olingo.odata2.api.uri.info.GetEntityUriInfo;
-import org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPAModelException;
-import org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPARuntimeException;
-import org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLContext;
-import org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLContextType;
-import org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLSelectSingleContextView;
-
-public class JPQLSelectSingleContext extends JPQLContext implements JPQLSelectSingleContextView {
-
- private String selectExpression;
- private List<KeyPredicate> keyPredicates;
-
- protected void setKeyPredicates(final List<KeyPredicate> keyPredicates) {
- this.keyPredicates = keyPredicates;
- }
-
- @Override
- public List<KeyPredicate> getKeyPredicates() {
- return keyPredicates;
- }
-
- protected final void setSelectExpression(final String selectExpression) {
- this.selectExpression = selectExpression;
- }
-
- @Override
- public String getSelectExpression() {
- return selectExpression;
- }
-
- public class JPQLSelectSingleContextBuilder extends
- org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLContext.JPQLContextBuilder {
-
- protected GetEntityUriInfo entityView;
-
- @Override
- public JPQLContext build() throws ODataJPAModelException, ODataJPARuntimeException {
- if (entityView != null) {
-
- try {
-
- setType(JPQLContextType.SELECT_SINGLE);
-
- EdmEntityType entityType = entityView.getTargetEntitySet().getEntityType();
- EdmMapping mapping = entityType.getMapping();
- if (mapping != null) {
- setJPAEntityName(mapping.getInternalName());
- } else {
- setJPAEntityName(entityType.getName());
- }
-
- setJPAEntityAlias(generateJPAEntityAlias());
-
- setKeyPredicates(entityView.getKeyPredicates());
-
- setSelectExpression(generateSelectExpression());
-
- } catch (EdmException e) {
- throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e);
- }
-
- }
-
- return JPQLSelectSingleContext.this;
-
- }
-
- @Override
- protected void setResultsView(final Object resultsView) {
- if (resultsView instanceof GetEntityUriInfo) {
- entityView = (GetEntityUriInfo) resultsView;
- }
-
- }
-
- /*
- * Generate Select Clause
- */
- protected String generateSelectExpression() throws EdmException {
- return getJPAEntityAlias();
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/57599da6/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLSelectSingleStatementBuilder.java
----------------------------------------------------------------------
diff --git a/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLSelectSingleStatementBuilder.java b/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLSelectSingleStatementBuilder.java
deleted file mode 100644
index 06e2444..0000000
--- a/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLSelectSingleStatementBuilder.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*******************************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- ******************************************************************************/
-package org.apache.olingo.odata2.processor.core.jpa.jpql;
-
-import org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPARuntimeException;
-import org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLContextView;
-import org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLSelectSingleContextView;
-import org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLStatement;
-import org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLStatement.JPQLStatementBuilder;
-import org.apache.olingo.odata2.processor.core.jpa.ODataExpressionParser;
-
-public class JPQLSelectSingleStatementBuilder extends JPQLStatementBuilder {
-
- JPQLStatement jpqlStatement;
- private JPQLSelectSingleContextView context;
-
- public JPQLSelectSingleStatementBuilder(final JPQLContextView context) {
- this.context = (JPQLSelectSingleContextView) context;
- }
-
- @Override
- public JPQLStatement build() throws ODataJPARuntimeException {
- jpqlStatement = createStatement(createJPQLQuery());
- return jpqlStatement;
-
- }
-
- private String createJPQLQuery() throws ODataJPARuntimeException {
-
- StringBuilder jpqlQuery = new StringBuilder();
- String tableAlias = context.getJPAEntityAlias();
- String fromClause = context.getJPAEntityName() + JPQLStatement.DELIMITER.SPACE + tableAlias;
-
- jpqlQuery.append(JPQLStatement.KEYWORD.SELECT).append(JPQLStatement.DELIMITER.SPACE);
- jpqlQuery.append(context.getSelectExpression()).append(JPQLStatement.DELIMITER.SPACE);
- jpqlQuery.append(JPQLStatement.KEYWORD.FROM).append(JPQLStatement.DELIMITER.SPACE);
- jpqlQuery.append(fromClause);
-
- if (context.getKeyPredicates() != null && context.getKeyPredicates().size() > 0) {
- jpqlQuery.append(JPQLStatement.DELIMITER.SPACE);
- jpqlQuery.append(JPQLStatement.KEYWORD.WHERE).append(JPQLStatement.DELIMITER.SPACE);
- jpqlQuery.append(ODataExpressionParser
- .parseKeyPredicates(context.getKeyPredicates(), context.getJPAEntityAlias()));
- }
-
- return jpqlQuery.toString();
-
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/57599da6/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLSelectStatementBuilder.java
----------------------------------------------------------------------
diff --git a/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLSelectStatementBuilder.java b/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLSelectStatementBuilder.java
deleted file mode 100644
index 22059f1..0000000
--- a/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/jpql/JPQLSelectStatementBuilder.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*******************************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- ******************************************************************************/
-package org.apache.olingo.odata2.processor.core.jpa.jpql;
-
-import java.util.Iterator;
-import java.util.Map.Entry;
-
-import org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPARuntimeException;
-import org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLContextType;
-import org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLContextView;
-import org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLSelectContextView;
-import org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLStatement;
-import org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLStatement.JPQLStatementBuilder;
-
-public class JPQLSelectStatementBuilder extends JPQLStatementBuilder {
-
- JPQLStatement jpqlStatement;
- private JPQLSelectContextView context;
-
- public JPQLSelectStatementBuilder(final JPQLContextView context) {
- this.context = (JPQLSelectContextView) context;
- }
-
- @Override
- public JPQLStatement build() throws ODataJPARuntimeException {
- jpqlStatement = createStatement(createJPQLQuery());
- return jpqlStatement;
-
- }
-
- private String createJPQLQuery() throws ODataJPARuntimeException {
-
- StringBuilder jpqlQuery = new StringBuilder();
- String tableAlias = context.getJPAEntityAlias();
- String fromClause = context.getJPAEntityName() + JPQLStatement.DELIMITER.SPACE + tableAlias;
-
- jpqlQuery.append(JPQLStatement.KEYWORD.SELECT).append(JPQLStatement.DELIMITER.SPACE);
- if (context.getType().equals(JPQLContextType.SELECT_COUNT)) { // $COUNT
- jpqlQuery.append(JPQLStatement.KEYWORD.COUNT).append(JPQLStatement.DELIMITER.SPACE);
- jpqlQuery.append(JPQLStatement.DELIMITER.PARENTHESIS_LEFT).append(JPQLStatement.DELIMITER.SPACE);
- jpqlQuery.append(context.getSelectExpression()).append(JPQLStatement.DELIMITER.SPACE);
- jpqlQuery.append(JPQLStatement.DELIMITER.PARENTHESIS_RIGHT).append(JPQLStatement.DELIMITER.SPACE);
- } else {// Normal
- jpqlQuery.append(context.getSelectExpression()).append(JPQLStatement.DELIMITER.SPACE);
- }
-
- jpqlQuery.append(JPQLStatement.KEYWORD.FROM).append(JPQLStatement.DELIMITER.SPACE);
- jpqlQuery.append(fromClause);
-
- if (context.getWhereExpression() != null) {
- jpqlQuery.append(JPQLStatement.DELIMITER.SPACE);
- jpqlQuery.append(JPQLStatement.KEYWORD.WHERE).append(JPQLStatement.DELIMITER.SPACE);
- jpqlQuery.append(context.getWhereExpression());
- }
-
- if (context.getOrderByCollection() != null && context.getOrderByCollection().size() > 0) {
-
- StringBuilder orderByBuilder = new StringBuilder();
- Iterator<Entry<String, String>> orderItr = context.getOrderByCollection().entrySet().iterator();
-
- int i = 0;
-
- while (orderItr.hasNext()) {
- if (i != 0) {
- orderByBuilder.append(JPQLStatement.DELIMITER.SPACE).append(JPQLStatement.DELIMITER.COMMA).append(
- JPQLStatement.DELIMITER.SPACE);
- }
- Entry<String, String> entry = orderItr.next();
- orderByBuilder.append(entry.getKey()).append(JPQLStatement.DELIMITER.SPACE);
- orderByBuilder.append(entry.getValue());
- i++;
- }
- jpqlQuery.append(JPQLStatement.DELIMITER.SPACE);
- jpqlQuery.append(JPQLStatement.KEYWORD.ORDERBY).append(JPQLStatement.DELIMITER.SPACE);
- jpqlQuery.append(orderByBuilder);
- }
-
- return jpqlQuery.toString();
-
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/57599da6/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmAssociation.java
----------------------------------------------------------------------
diff --git a/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmAssociation.java b/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmAssociation.java
deleted file mode 100644
index 1675828..0000000
--- a/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmAssociation.java
+++ /dev/null
@@ -1,237 +0,0 @@
-/*******************************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- ******************************************************************************/
-package org.apache.olingo.odata2.processor.core.jpa.model;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.LinkedList;
-import java.util.List;
-
-import org.apache.olingo.odata2.api.edm.provider.Association;
-import org.apache.olingo.odata2.api.edm.provider.AssociationEnd;
-import org.apache.olingo.odata2.processor.api.jpa.access.JPAEdmBuilder;
-import org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPAModelException;
-import org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPARuntimeException;
-import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmAssociationEndView;
-import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmAssociationView;
-import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmEntityTypeView;
-import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmPropertyView;
-import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmReferentialConstraintView;
-import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmSchemaView;
-import org.apache.olingo.odata2.processor.core.jpa.access.model.JPAEdmNameBuilder;
-
-public class JPAEdmAssociation extends JPAEdmBaseViewImpl implements JPAEdmAssociationView {
-
- private JPAEdmAssociationEndView associationEndView;
-
- private Association currentAssociation;
- private List<Association> consistentAssociatonList;
- private HashMap<String, Association> associationMap;
- private HashMap<String, JPAEdmAssociationEndView> associationEndMap;
- private List<JPAEdmReferentialConstraintView> inconsistentRefConstraintViewList;
- private int numberOfSimilarEndPoints;
-
- public JPAEdmAssociation(final JPAEdmAssociationEndView associationEndview,
- final JPAEdmEntityTypeView entityTypeView, final JPAEdmPropertyView propertyView, final int value) {
- super(associationEndview);
- associationEndView = associationEndview;
- numberOfSimilarEndPoints = value;
- init();
- }
-
- public JPAEdmAssociation(final JPAEdmSchemaView view) {
- super(view);
- init();
- }
-
- private void init() {
- isConsistent = false;
- consistentAssociatonList = new ArrayList<Association>();
- inconsistentRefConstraintViewList = new LinkedList<JPAEdmReferentialConstraintView>();
- associationMap = new HashMap<String, Association>();
- associationEndMap = new HashMap<String, JPAEdmAssociationEndView>();
- }
-
- @Override
- public JPAEdmBuilder getBuilder() {
- if (builder == null) {
- builder = new JPAEdmAssociationBuilder();
- }
- return builder;
- }
-
- @Override
- public Association getEdmAssociation() {
- return currentAssociation;
- }
-
- @Override
- public List<Association> getConsistentEdmAssociationList() {
- return consistentAssociatonList;
- }
-
- @Override
- public Association searchAssociation(final JPAEdmAssociationEndView view) {
- if (view != null) {
- for (String key : associationMap.keySet()) {
- Association association = associationMap.get(key);
- if (association != null) {
- if (view.compare(association.getEnd1(), association.getEnd2())) {
- JPAEdmAssociationEndView associationEnd = associationEndMap.get(association.getName());
- if (associationEnd.getJoinColumnName() != null && associationEnd.getJoinColumnReferenceColumnName() != null
- && view.getJoinColumnName() != null && view.getJoinColumnReferenceColumnName() != null) {
- if (view.getJoinColumnName().equals(associationEnd.getJoinColumnName())
- && view.getJoinColumnReferenceColumnName()
- .equals(associationEnd.getJoinColumnReferenceColumnName())) {
- currentAssociation = association;
- return association;
- }
-
- }
- if (associationEnd.getMappedByName() != null) {
- if (associationEnd.getMappedByName().equals(view.getOwningPropertyName())) {
- currentAssociation = association;
- return association;
- }
- }
- if (associationEnd.getOwningPropertyName() != null) {
- if (associationEnd.getOwningPropertyName().equals(view.getMappedByName())) {
- currentAssociation = association;
- return association;
- }
- }
- }
- }
- }
- }
- return null;
- }
-
- @Override
- public void addJPAEdmAssociationView(final JPAEdmAssociationView associationView,
- final JPAEdmAssociationEndView associationEndView) {
- if (associationView != null) {
- currentAssociation = associationView.getEdmAssociation();
- associationMap.put(currentAssociation.getName(), currentAssociation);
- associationEndMap.put(currentAssociation.getName(), associationEndView);
- addJPAEdmRefConstraintView(associationView.getJPAEdmReferentialConstraintView());
- }
- }
-
- @Override
- public void addJPAEdmRefConstraintView(final JPAEdmReferentialConstraintView refView) {
- if (refView != null && refView.isExists()) {
- inconsistentRefConstraintViewList.add(refView);
- }
- }
-
- @Override
- public JPAEdmReferentialConstraintView getJPAEdmReferentialConstraintView() {
- if (inconsistentRefConstraintViewList.isEmpty()) {
- return null;
- }
- return inconsistentRefConstraintViewList.get(0);
- }
-
- private class JPAEdmAssociationBuilder implements JPAEdmBuilder {
-
- @Override
- public void build() throws ODataJPAModelException, ODataJPARuntimeException {
-
- if (associationEndView != null && searchAssociation(associationEndView) == null) {
- currentAssociation = new Association();
- currentAssociation.setEnd1(associationEndView.getEdmAssociationEnd1());
- currentAssociation.setEnd2(associationEndView.getEdmAssociationEnd2());
-
- JPAEdmNameBuilder.build(JPAEdmAssociation.this, numberOfSimilarEndPoints);
-
- associationMap.put(currentAssociation.getName(), currentAssociation);
-
- } else if (!inconsistentRefConstraintViewList.isEmpty()) {
- int inconsistentRefConstraintViewSize = inconsistentRefConstraintViewList.size();
- int index = 0;
- for (int i = 0; i < inconsistentRefConstraintViewSize; i++) {
- JPAEdmReferentialConstraintView view = inconsistentRefConstraintViewList.get(index);
-
- if (view.isExists() && !view.isConsistent()) {
- view.getBuilder().build();
- }
- if (view.isConsistent()) {
- Association newAssociation = new Association();
- copyAssociation(newAssociation, associationMap.get(view.getEdmRelationShipName()));
- newAssociation.setReferentialConstraint(view.getEdmReferentialConstraint());
- consistentAssociatonList.add(newAssociation);
- associationMap.put(view.getEdmRelationShipName(), newAssociation);
- inconsistentRefConstraintViewList.remove(index);
- } else {
- associationMap.remove(view.getEdmRelationShipName());
- index++;
- }
- }
- }
-
- if (associationMap.size() == consistentAssociatonList.size()) {
- isConsistent = true;
- } else {
- for (String key : associationMap.keySet()) {
- Association association = associationMap.get(key);
- if (!consistentAssociatonList.contains(association)) {
- consistentAssociatonList.add(association);
- }
- }
- isConsistent = true;
- }
-
- }
-
- private void copyAssociation(final Association copyToAssociation, final Association copyFromAssociation) {
- copyToAssociation.setEnd1(copyFromAssociation.getEnd1());
- copyToAssociation.setEnd2(copyFromAssociation.getEnd2());
- copyToAssociation.setName(copyFromAssociation.getName());
- copyToAssociation.setAnnotationAttributes(copyFromAssociation.getAnnotationAttributes());
- copyToAssociation.setAnnotationElements(copyFromAssociation.getAnnotationElements());
- copyToAssociation.setDocumentation(copyFromAssociation.getDocumentation());
-
- }
- }
-
- @Override
- public int getNumberOfAssociationsWithSimilarEndPoints(final JPAEdmAssociationEndView view) {
- int count = 0;
- AssociationEnd currentAssociationEnd1 = view.getEdmAssociationEnd1();
- AssociationEnd currentAssociationEnd2 = view.getEdmAssociationEnd2();
- AssociationEnd end1 = null;
- AssociationEnd end2 = null;
- for (String key : associationMap.keySet()) {
- Association association = associationMap.get(key);
- if (association != null) {
- end1 = association.getEnd1();
- end2 = association.getEnd2();
- if ((end1.getType().equals(currentAssociationEnd1.getType()) && end2.getType().equals(
- currentAssociationEnd2.getType()))
- || (end1.getType().equals(currentAssociationEnd2.getType()) && end2.getType().equals(
- currentAssociationEnd1.getType()))) {
- count++;
- }
- }
- }
- return count;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/57599da6/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmAssociationEnd.java
----------------------------------------------------------------------
diff --git a/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmAssociationEnd.java b/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmAssociationEnd.java
deleted file mode 100644
index 1b648ae..0000000
--- a/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmAssociationEnd.java
+++ /dev/null
@@ -1,183 +0,0 @@
-/*******************************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- ******************************************************************************/
-package org.apache.olingo.odata2.processor.core.jpa.model;
-
-import java.lang.reflect.AnnotatedElement;
-
-import javax.persistence.JoinColumn;
-import javax.persistence.ManyToMany;
-import javax.persistence.OneToMany;
-import javax.persistence.OneToOne;
-import javax.persistence.metamodel.Attribute.PersistentAttributeType;
-
-import org.apache.olingo.odata2.api.edm.EdmMultiplicity;
-import org.apache.olingo.odata2.api.edm.provider.AssociationEnd;
-import org.apache.olingo.odata2.processor.api.jpa.access.JPAEdmBuilder;
-import org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPAModelException;
-import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmAssociationEndView;
-import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmEntityTypeView;
-import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmPropertyView;
-import org.apache.olingo.odata2.processor.core.jpa.access.model.JPAEdmNameBuilder;
-
-public class JPAEdmAssociationEnd extends JPAEdmBaseViewImpl implements JPAEdmAssociationEndView {
-
- private JPAEdmEntityTypeView entityTypeView = null;
- private JPAEdmPropertyView propertyView = null;
- private AssociationEnd currentAssociationEnd1 = null;
- private AssociationEnd currentAssociationEnd2 = null;
- private String columnName;
- private String referencedColumnName;
- private String mappedBy;
- private String ownerPropertyName;
-
- public JPAEdmAssociationEnd(final JPAEdmEntityTypeView entityTypeView, final JPAEdmPropertyView propertyView) {
- super(entityTypeView);
- this.entityTypeView = entityTypeView;
- this.propertyView = propertyView;
- }
-
- @Override
- public JPAEdmBuilder getBuilder() {
- if (builder == null) {
- builder = new JPAEdmAssociationEndBuilder();
- }
-
- return builder;
- }
-
- @Override
- public AssociationEnd getEdmAssociationEnd1() {
- return currentAssociationEnd1;
- }
-
- @Override
- public AssociationEnd getEdmAssociationEnd2() {
- return currentAssociationEnd2;
- }
-
- private class JPAEdmAssociationEndBuilder implements JPAEdmBuilder {
-
- @Override
- public void build() throws ODataJPAModelException {
-
- JoinColumn joinColumn = null;
-
- currentAssociationEnd1 = new AssociationEnd();
- currentAssociationEnd2 = new AssociationEnd();
-
- JPAEdmNameBuilder.build(JPAEdmAssociationEnd.this, entityTypeView, propertyView);
-
- currentAssociationEnd1.setRole(currentAssociationEnd1.getType().getName());
- currentAssociationEnd2.setRole(currentAssociationEnd2.getType().getName());
-
- setEdmMultiplicity(propertyView.getJPAAttribute().getPersistentAttributeType());
-
- AnnotatedElement annotatedElement = (AnnotatedElement) propertyView.getJPAAttribute().getJavaMember();
- if (annotatedElement != null) {
- joinColumn = annotatedElement.getAnnotation(JoinColumn.class);
- if (joinColumn != null) {
- columnName = joinColumn.name();
- referencedColumnName = joinColumn.referencedColumnName();
- }
-
- }
- ownerPropertyName = propertyView.getJPAAttribute().getName();
-
- }
-
- private void setEdmMultiplicity(final PersistentAttributeType type) {
- AnnotatedElement annotatedElement = (AnnotatedElement) propertyView.getJPAAttribute().getJavaMember();
- switch (type) {
- case ONE_TO_MANY:
- currentAssociationEnd1.setMultiplicity(EdmMultiplicity.ONE);
- currentAssociationEnd2.setMultiplicity(EdmMultiplicity.MANY);
- if (annotatedElement != null) {
- OneToMany reln = annotatedElement.getAnnotation(OneToMany.class);
- if (reln != null) {
- mappedBy = reln.mappedBy();
- }
- }
- break;
- case MANY_TO_MANY:
- currentAssociationEnd1.setMultiplicity(EdmMultiplicity.MANY);
- currentAssociationEnd2.setMultiplicity(EdmMultiplicity.MANY);
- if (annotatedElement != null) {
- ManyToMany reln = annotatedElement.getAnnotation(ManyToMany.class);
- if (reln != null) {
- mappedBy = reln.mappedBy();
- }
- }
- break;
- case MANY_TO_ONE:
- currentAssociationEnd1.setMultiplicity(EdmMultiplicity.MANY);
- currentAssociationEnd2.setMultiplicity(EdmMultiplicity.ONE);
- break;
- case ONE_TO_ONE:
- currentAssociationEnd1.setMultiplicity(EdmMultiplicity.ONE);
- currentAssociationEnd2.setMultiplicity(EdmMultiplicity.ONE);
- if (annotatedElement != null) {
- OneToOne reln = annotatedElement.getAnnotation(OneToOne.class);
- if (reln != null) {
- mappedBy = reln.mappedBy();
- }
- }
- break;
- default:
- break;
- }
- }
- }
-
- @Override
- public boolean compare(final AssociationEnd end1, final AssociationEnd end2) {
- if ((end1.getType().equals(currentAssociationEnd1.getType())
- && end2.getType().equals(currentAssociationEnd2.getType())
- && end1.getMultiplicity().equals(currentAssociationEnd1.getMultiplicity()) && end2.getMultiplicity().equals(
- currentAssociationEnd2.getMultiplicity()))
- || (end1.getType().equals(currentAssociationEnd2.getType())
- && end2.getType().equals(currentAssociationEnd1.getType())
- && end1.getMultiplicity().equals(currentAssociationEnd2.getMultiplicity()) && end2.getMultiplicity()
- .equals(currentAssociationEnd1.getMultiplicity()))) {
- return true;
- }
-
- return false;
- }
-
- @Override
- public String getJoinColumnName() {
- return columnName;
- }
-
- @Override
- public String getJoinColumnReferenceColumnName() {
- return referencedColumnName;
- }
-
- @Override
- public String getMappedByName() {
- return mappedBy;
- }
-
- @Override
- public String getOwningPropertyName() {
- return ownerPropertyName;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/57599da6/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmAssociationSet.java
----------------------------------------------------------------------
diff --git a/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmAssociationSet.java b/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmAssociationSet.java
deleted file mode 100644
index 925a497..0000000
--- a/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmAssociationSet.java
+++ /dev/null
@@ -1,131 +0,0 @@
-/*******************************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- ******************************************************************************/
-package org.apache.olingo.odata2.processor.core.jpa.model;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.olingo.odata2.api.edm.FullQualifiedName;
-import org.apache.olingo.odata2.api.edm.provider.Association;
-import org.apache.olingo.odata2.api.edm.provider.AssociationSet;
-import org.apache.olingo.odata2.api.edm.provider.AssociationSetEnd;
-import org.apache.olingo.odata2.api.edm.provider.EntitySet;
-import org.apache.olingo.odata2.processor.api.jpa.access.JPAEdmBuilder;
-import org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPAModelException;
-import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmAssociationSetView;
-import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmAssociationView;
-import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmEntitySetView;
-import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmSchemaView;
-import org.apache.olingo.odata2.processor.core.jpa.access.model.JPAEdmNameBuilder;
-
-public class JPAEdmAssociationSet extends JPAEdmBaseViewImpl implements JPAEdmAssociationSetView {
-
- private JPAEdmSchemaView schemaView;
- private AssociationSet currentAssociationSet;
- private List<AssociationSet> associationSetList;
- private Association currentAssociation;
-
- public JPAEdmAssociationSet(final JPAEdmSchemaView view) {
- super(view);
- schemaView = view;
- }
-
- @Override
- public JPAEdmBuilder getBuilder() {
- if (builder == null) {
- builder = new JPAEdmAssociationSetBuilder();
- }
-
- return builder;
- }
-
- @Override
- public List<AssociationSet> getConsistentEdmAssociationSetList() {
- return associationSetList;
- }
-
- @Override
- public AssociationSet getEdmAssociationSet() {
- return currentAssociationSet;
- }
-
- @Override
- public Association getEdmAssociation() {
- return currentAssociation;
- }
-
- private class JPAEdmAssociationSetBuilder implements JPAEdmBuilder {
-
- @Override
- public void build() throws ODataJPAModelException {
-
- if (associationSetList == null) {
- associationSetList = new ArrayList<AssociationSet>();
- }
-
- JPAEdmAssociationView associationView = schemaView.getJPAEdmAssociationView();
- JPAEdmEntitySetView entitySetView = schemaView.getJPAEdmEntityContainerView().getJPAEdmEntitySetView();
-
- List<EntitySet> entitySetList = entitySetView.getConsistentEdmEntitySetList();
- if (associationView.isConsistent()) {
- for (Association association : associationView.getConsistentEdmAssociationList()) {
-
- currentAssociation = association;
-
- FullQualifiedName fQname =
- new FullQualifiedName(schemaView.getEdmSchema().getNamespace(), association.getName());
- currentAssociationSet = new AssociationSet();
- currentAssociationSet.setAssociation(fQname);
-
- int endCount = 0;
- short endFlag = 0;
- for (EntitySet entitySet : entitySetList) {
- fQname = entitySet.getEntityType();
- endFlag = 0;
- if (fQname.equals(association.getEnd1().getType()) || ++endFlag > 1
- || fQname.equals(association.getEnd2().getType())) {
-
- AssociationSetEnd end = new AssociationSetEnd();
- end.setEntitySet(entitySet.getName());
- if (endFlag == 0) {
- currentAssociationSet.setEnd1(end);
- end.setRole(association.getEnd1().getRole());
- endCount++;
- } else {
- endCount++;
- currentAssociationSet.setEnd2(end);
- end.setRole(association.getEnd2().getRole());
- }
-
- if (endCount == 2) {
- break;
- }
- }
- }
- if (endCount == 2) {
- JPAEdmNameBuilder.build(JPAEdmAssociationSet.this);
- associationSetList.add(currentAssociationSet);
- }
-
- }
-
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/57599da6/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmBaseViewImpl.java
----------------------------------------------------------------------
diff --git a/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmBaseViewImpl.java b/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmBaseViewImpl.java
deleted file mode 100644
index 0485bb1..0000000
--- a/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmBaseViewImpl.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*******************************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- ******************************************************************************/
-package org.apache.olingo.odata2.processor.core.jpa.model;
-
-import javax.persistence.metamodel.Metamodel;
-
-import org.apache.olingo.odata2.processor.api.jpa.ODataJPAContext;
-import org.apache.olingo.odata2.processor.api.jpa.access.JPAEdmBuilder;
-import org.apache.olingo.odata2.processor.api.jpa.access.JPAEdmMappingModelAccess;
-import org.apache.olingo.odata2.processor.api.jpa.factory.ODataJPAFactory;
-import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmBaseView;
-import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmExtension;
-
-public abstract class JPAEdmBaseViewImpl implements JPAEdmBaseView {
-
- protected String pUnitName = null;
- protected Metamodel metaModel = null;
- protected boolean isConsistent = true;
- protected JPAEdmBuilder builder = null;
- protected JPAEdmExtension jpaEdmExtension = null;
- private JPAEdmMappingModelAccess jpaEdmMappingModelAccess = null;
-
- public JPAEdmBaseViewImpl(final JPAEdmBaseView view) {
- pUnitName = view.getpUnitName();
- metaModel = view.getJPAMetaModel();
- jpaEdmMappingModelAccess = view.getJPAEdmMappingModelAccess();
- jpaEdmExtension = view.getJPAEdmExtension();
- }
-
- public JPAEdmBaseViewImpl(final ODataJPAContext context) {
- pUnitName = context.getPersistenceUnitName();
- metaModel = context.getEntityManagerFactory().getMetamodel();
- jpaEdmMappingModelAccess =
- ODataJPAFactory.createFactory().getJPAAccessFactory().getJPAEdmMappingModelAccess(context);
- jpaEdmExtension = context.getJPAEdmExtension();
- jpaEdmMappingModelAccess.loadMappingModel();
- }
-
- public JPAEdmBaseViewImpl(final Metamodel metaModel, final String pUnitName) {
- this.metaModel = metaModel;
- this.pUnitName = pUnitName;
- }
-
- @Override
- public String getpUnitName() {
- return pUnitName;
- }
-
- @Override
- public Metamodel getJPAMetaModel() {
- return metaModel;
- }
-
- @Override
- public boolean isConsistent() {
- return isConsistent;
- }
-
- @Override
- public void clean() {
- pUnitName = null;
- metaModel = null;
- isConsistent = false;
- }
-
- @Override
- public JPAEdmMappingModelAccess getJPAEdmMappingModelAccess() {
- return jpaEdmMappingModelAccess;
-
- }
-
- @Override
- public JPAEdmExtension getJPAEdmExtension() {
- return jpaEdmExtension;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/57599da6/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmComplexType.java
----------------------------------------------------------------------
diff --git a/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmComplexType.java b/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmComplexType.java
deleted file mode 100644
index ad25a1b..0000000
--- a/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmComplexType.java
+++ /dev/null
@@ -1,254 +0,0 @@
-/*******************************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- ******************************************************************************/
-package org.apache.olingo.odata2.processor.core.jpa.model;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import javax.persistence.metamodel.Attribute;
-import javax.persistence.metamodel.EmbeddableType;
-
-import org.apache.olingo.odata2.api.edm.FullQualifiedName;
-import org.apache.olingo.odata2.api.edm.provider.ComplexProperty;
-import org.apache.olingo.odata2.api.edm.provider.ComplexType;
-import org.apache.olingo.odata2.api.edm.provider.Mapping;
-import org.apache.olingo.odata2.api.edm.provider.Property;
-import org.apache.olingo.odata2.api.edm.provider.SimpleProperty;
-import org.apache.olingo.odata2.processor.api.jpa.access.JPAEdmBuilder;
-import org.apache.olingo.odata2.processor.api.jpa.access.JPAEdmMappingModelAccess;
-import org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPAModelException;
-import org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPARuntimeException;
-import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmComplexTypeView;
-import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmMapping;
-import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmPropertyView;
-import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmSchemaView;
-import org.apache.olingo.odata2.processor.core.jpa.access.model.JPAEdmNameBuilder;
-
-public class JPAEdmComplexType extends JPAEdmBaseViewImpl implements JPAEdmComplexTypeView {
-
- private JPAEdmSchemaView schemaView;
- private ComplexType currentComplexType = null;
- private EmbeddableType<?> currentEmbeddableType = null;
- private HashMap<String, ComplexType> searchMap = null;
- private List<ComplexType> consistentComplextTypes = null;
- private boolean directBuild;
- private EmbeddableType<?> nestedComplexType = null;
-
- public JPAEdmComplexType(final JPAEdmSchemaView view) {
- super(view);
- schemaView = view;
- directBuild = true;
- }
-
- public JPAEdmComplexType(final JPAEdmSchemaView view, final Attribute<?, ?> complexAttribute) {
- super(view);
- schemaView = view;
- for (EmbeddableType<?> jpaEmbeddable : schemaView.getJPAMetaModel().getEmbeddables()) {
- if (jpaEmbeddable.getJavaType().getName().equals(complexAttribute.getJavaType().getName())) {
- nestedComplexType = jpaEmbeddable;
- break;
- }
- }
- directBuild = false;
- }
-
- @Override
- public JPAEdmBuilder getBuilder() {
- if (builder == null) {
- builder = new JPAEdmComplexTypeBuilder();
- }
-
- return builder;
- }
-
- @Override
- public ComplexType getEdmComplexType() {
- return currentComplexType;
- }
-
- @Override
- public ComplexType searchEdmComplexType(final String embeddableTypeName) {
- return searchMap.get(embeddableTypeName);
- }
-
- @Override
- public EmbeddableType<?> getJPAEmbeddableType() {
- return currentEmbeddableType;
- }
-
- @Override
- public List<ComplexType> getConsistentEdmComplexTypes() {
- return consistentComplextTypes;
- }
-
- @Override
- public ComplexType searchEdmComplexType(final FullQualifiedName type) {
- String name = type.getName();
- return searchComplexTypeByName(name);
-
- }
-
- private ComplexType searchComplexTypeByName(final String name) {
- for (ComplexType complexType : consistentComplextTypes) {
- if (null != complexType && null != complexType.getName() && complexType.getName().equals(name)) {
- return complexType;
- }
- }
-
- return null;
- }
-
- @Override
- public void addJPAEdmCompleTypeView(final JPAEdmComplexTypeView view) {
- String searchKey = view.getJPAEmbeddableType().getJavaType().getName();
-
- if (!searchMap.containsKey(searchKey)) {
- consistentComplextTypes.add(view.getEdmComplexType());
- searchMap.put(searchKey, view.getEdmComplexType());
- }
- }
-
- @Override
- public void expandEdmComplexType(final ComplexType complexType, List<Property> expandedList,
- final String embeddablePropertyName) {
-
- if (expandedList == null) {
- expandedList = new ArrayList<Property>();
- }
- for (Property property : complexType.getProperties()) {
- try {
- SimpleProperty newSimpleProperty = new SimpleProperty();
- SimpleProperty oldSimpleProperty = (SimpleProperty) property;
- newSimpleProperty.setAnnotationAttributes(oldSimpleProperty.getAnnotationAttributes());
- newSimpleProperty.setAnnotationElements(oldSimpleProperty.getAnnotationElements());
- newSimpleProperty.setCustomizableFeedMappings(oldSimpleProperty.getCustomizableFeedMappings());
- newSimpleProperty.setDocumentation(oldSimpleProperty.getDocumentation());
- newSimpleProperty.setFacets(oldSimpleProperty.getFacets());
- newSimpleProperty.setMimeType(oldSimpleProperty.getMimeType());
- newSimpleProperty.setName(oldSimpleProperty.getName());
- newSimpleProperty.setType(oldSimpleProperty.getType());
- JPAEdmMappingImpl newMapping = new JPAEdmMappingImpl();
- Mapping mapping = oldSimpleProperty.getMapping();
- JPAEdmMapping oldMapping = (JPAEdmMapping) mapping;
- newMapping.setJPAColumnName(oldMapping.getJPAColumnName());
- newMapping.setInternalName(embeddablePropertyName + "." + mapping.getInternalName());
- newMapping.setMimeType(mapping.getMimeType());
- newMapping.setObject(mapping.getObject());
- newMapping.setJPAType(oldMapping.getJPAType());
- newSimpleProperty.setMapping(newMapping);
- expandedList.add(newSimpleProperty);
- } catch (ClassCastException e) {
- ComplexProperty complexProperty = (ComplexProperty) property;
- String name = embeddablePropertyName + "." + complexProperty.getMapping().getInternalName();
- expandEdmComplexType(searchComplexTypeByName(complexProperty.getName()), expandedList, name);
- }
- }
-
- }
-
- private class JPAEdmComplexTypeBuilder implements JPAEdmBuilder {
- /*
- *
- * Each call to build method creates a new Complex Type.
- * The Complex Type is created only if it is not created
- * earlier. A local buffer is maintained to track the list
- * of complex types created.
- *
- * ************************************************************
- * Build EDM Complex Type - STEPS
- * ************************************************************
- * 1) Fetch list of embeddable types from JPA Model
- * 2) Search local buffer if there exists already a Complex
- * type for the embeddable type.
- * 3) If the complex type was already been built continue with
- * the next embeddable type, else create new EDM Complex Type.
- * 4) Create a Property view with Complex Type
- * 5) Get Property Builder and build the Property with Complex
- * type.
- * 6) Set EDM complex type with list of properties built by
- * the property view
- * 7) Provide name for EDM complex type.
- *
- * ************************************************************
- * Build EDM Complex Type - STEPS
- * ************************************************************
- */
- @Override
- public void build() throws ODataJPAModelException, ODataJPARuntimeException {
- Set<EmbeddableType<?>> embeddables = new HashSet<EmbeddableType<?>>();
-
- if (consistentComplextTypes == null) {
- consistentComplextTypes = new ArrayList<ComplexType>();
- }
-
- if (searchMap == null) {
- searchMap = new HashMap<String, ComplexType>();
- }
-
- if (directBuild) {
- embeddables = schemaView.getJPAMetaModel().getEmbeddables();
- } else {
- embeddables.add(nestedComplexType);
- }
-
- for (EmbeddableType<?> embeddableType : embeddables) {
-
- currentEmbeddableType = embeddableType;
- String searchKey = embeddableType.getJavaType().getName();
-
- if (searchMap.containsKey(searchKey)) {
- continue;
- }
-
- // Check for need to Exclude
- if (isExcluded(JPAEdmComplexType.this)) {
- continue;
- }
-
- JPAEdmPropertyView propertyView = new JPAEdmProperty(schemaView, JPAEdmComplexType.this);
- propertyView.getBuilder().build();
-
- currentComplexType = new ComplexType();
- currentComplexType.setProperties(propertyView.getEdmPropertyList());
- JPAEdmNameBuilder.build(JPAEdmComplexType.this);
-
- searchMap.put(searchKey, currentComplexType);
- consistentComplextTypes.add(currentComplexType);
-
- }
-
- }
-
- private boolean isExcluded(final JPAEdmComplexType jpaEdmComplexType) {
-
- JPAEdmMappingModelAccess mappingModelAccess = jpaEdmComplexType.getJPAEdmMappingModelAccess();
- if (mappingModelAccess != null
- && mappingModelAccess.isMappingModelExists()
- && mappingModelAccess.checkExclusionOfJPAEmbeddableType(jpaEdmComplexType.getJPAEmbeddableType()
- .getJavaType().getSimpleName())) {
- return true;
- }
- return false;
- }
-
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/57599da6/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmEntityContainer.java
----------------------------------------------------------------------
diff --git a/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmEntityContainer.java b/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmEntityContainer.java
deleted file mode 100644
index fee40c2..0000000
--- a/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmEntityContainer.java
+++ /dev/null
@@ -1,154 +0,0 @@
-/*******************************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- ******************************************************************************/
-package org.apache.olingo.odata2.processor.core.jpa.model;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.olingo.odata2.api.edm.provider.EntityContainer;
-import org.apache.olingo.odata2.processor.api.jpa.access.JPAEdmBuilder;
-import org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPAModelException;
-import org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPARuntimeException;
-import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmAssociationSetView;
-import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmEntityContainerView;
-import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmEntitySetView;
-import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmFunctionImportView;
-import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmSchemaView;
-import org.apache.olingo.odata2.processor.core.jpa.access.model.JPAEdmNameBuilder;
-
-public class JPAEdmEntityContainer extends JPAEdmBaseViewImpl implements JPAEdmEntityContainerView {
-
- private JPAEdmEntitySetView entitySetView;
- private JPAEdmSchemaView schemaView;
- private JPAEdmAssociationSetView associationSetView;
-
- private EntityContainer currentEntityContainer;
- private List<EntityContainer> consistentEntityContainerList;
-
- public JPAEdmEntityContainer(final JPAEdmSchemaView view) {
- super(view);
- schemaView = view;
- }
-
- @Override
- public JPAEdmBuilder getBuilder() {
- if (builder == null) {
- builder = new JPAEdmEntityContainerBuilder();
- }
-
- return builder;
- }
-
- @Override
- public EntityContainer getEdmEntityContainer() {
- return currentEntityContainer;
- }
-
- @Override
- public List<EntityContainer> getConsistentEdmEntityContainerList() {
- return consistentEntityContainerList;
- }
-
- @Override
- public JPAEdmEntitySetView getJPAEdmEntitySetView() {
- return entitySetView;
- }
-
- @Override
- public JPAEdmAssociationSetView getEdmAssociationSetView() {
- return associationSetView;
- }
-
- @Override
- public void clean() {
- super.clean();
- entitySetView = null;
- associationSetView = null;
- currentEntityContainer = null;
- consistentEntityContainerList = null;
- }
-
- private class JPAEdmEntityContainerBuilder implements JPAEdmBuilder {
- /*
- *
- * Each call to build method creates a new Entity Container and builds
- * the entity container with Association Sets and Entity Sets. The newly
- * created and built entity container is added to the exiting Entity
- * Container List.
- *
- * ************************************************************ Build
- * EDM Entity Container - STEPS
- * ************************************************************ 1)
- * Instantiate New EDM Entity Container 2) Build Name for EDM Entity
- * Container 2) Create Entity Container List (if does not exists) 3)
- * Build EDM Entity Set 4) Add EDM Entity Set to EDM Entity Container 6)
- * Build EDM Association Set 7) Add EDM Association Set to EDM Entity
- * Container 8) Add EDM Entity Container to the Container List
- * ************************************************************ Build
- * EDM Entity Container - STEPS
- * ************************************************************
- */
- @Override
- public void build() throws ODataJPAModelException, ODataJPARuntimeException {
-
- currentEntityContainer = new EntityContainer();
-
- if (consistentEntityContainerList == null) {
- currentEntityContainer.setDefaultEntityContainer(true);
- consistentEntityContainerList = new ArrayList<EntityContainer>();
- }
-
- entitySetView = new JPAEdmEntitySet(schemaView);
- entitySetView.getBuilder().build();
- if (entitySetView.isConsistent()) {
- currentEntityContainer.setEntitySets(entitySetView.getConsistentEdmEntitySetList());
- } else {
- isConsistent = false;
- return;
- }
-
- if (!schemaView.getJPAEdmAssociationView().isConsistent()) {
- schemaView.getJPAEdmAssociationView().getBuilder().build();
- }
-
- associationSetView = new JPAEdmAssociationSet(schemaView);
- associationSetView.getBuilder().build();
- if (associationSetView.isConsistent()) {
- currentEntityContainer.setAssociationSets(associationSetView.getConsistentEdmAssociationSetList());
- } else {
- isConsistent = false;
- return;
- }
-
- JPAEdmNameBuilder.build(JPAEdmEntityContainer.this);
- if (schemaView.getJPAEdmExtension() != null) {
- JPAEdmFunctionImportView functionImportView = new JPAEdmFunctionImport(schemaView);
- functionImportView.getBuilder().build();
- if (functionImportView.getConsistentFunctionImportList() != null) {
- currentEntityContainer.setFunctionImports(functionImportView.getConsistentFunctionImportList());
- }
- }
-
- consistentEntityContainerList.add(currentEntityContainer);
- isConsistent = true;
-
- }
-
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/57599da6/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmEntitySet.java
----------------------------------------------------------------------
diff --git a/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmEntitySet.java b/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmEntitySet.java
deleted file mode 100644
index 9e5248f..0000000
--- a/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmEntitySet.java
+++ /dev/null
@@ -1,112 +0,0 @@
-/*******************************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- ******************************************************************************/
-package org.apache.olingo.odata2.processor.core.jpa.model;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.olingo.odata2.api.edm.FullQualifiedName;
-import org.apache.olingo.odata2.api.edm.provider.EntitySet;
-import org.apache.olingo.odata2.api.edm.provider.EntityType;
-import org.apache.olingo.odata2.processor.api.jpa.access.JPAEdmBuilder;
-import org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPAModelException;
-import org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPARuntimeException;
-import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmEntitySetView;
-import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmEntityTypeView;
-import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmSchemaView;
-import org.apache.olingo.odata2.processor.core.jpa.access.model.JPAEdmNameBuilder;
-
-public class JPAEdmEntitySet extends JPAEdmBaseViewImpl implements JPAEdmEntitySetView {
-
- private EntitySet currentEntitySet = null;
- private List<EntitySet> consistentEntitySetList = null;
- private JPAEdmEntityTypeView entityTypeView = null;
- private JPAEdmSchemaView schemaView;
-
- public JPAEdmEntitySet(final JPAEdmSchemaView view) {
- super(view);
- schemaView = view;
- }
-
- @Override
- public JPAEdmBuilder getBuilder() {
- if (builder == null) {
- builder = new JPAEdmEntitySetBuilder();
- }
-
- return builder;
- }
-
- @Override
- public EntitySet getEdmEntitySet() {
- return currentEntitySet;
- }
-
- @Override
- public List<EntitySet> getConsistentEdmEntitySetList() {
- return consistentEntitySetList;
- }
-
- @Override
- public JPAEdmEntityTypeView getJPAEdmEntityTypeView() {
- return entityTypeView;
- }
-
- @Override
- public void clean() {
- currentEntitySet = null;
- consistentEntitySetList = null;
- entityTypeView = null;
- isConsistent = false;
- }
-
- private class JPAEdmEntitySetBuilder implements JPAEdmBuilder {
-
- @Override
- public void build() throws ODataJPAModelException, ODataJPARuntimeException {
-
- if (consistentEntitySetList == null) {
- consistentEntitySetList = new ArrayList<EntitySet>();
- }
-
- entityTypeView = new JPAEdmEntityType(schemaView);
- entityTypeView.getBuilder().build();
-
- if (entityTypeView.isConsistent() && entityTypeView.getConsistentEdmEntityTypes() != null) {
-
- String nameSpace = schemaView.getEdmSchema().getNamespace();
- for (EntityType entityType : entityTypeView.getConsistentEdmEntityTypes()) {
-
- currentEntitySet = new EntitySet();
- currentEntitySet.setEntityType(new FullQualifiedName(nameSpace, entityType.getName()));
- JPAEdmNameBuilder.build(JPAEdmEntitySet.this, entityTypeView);
- consistentEntitySetList.add(currentEntitySet);
-
- }
- isConsistent = true;
- } else {
- isConsistent = false;
- return;
- }
-
- }
-
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/57599da6/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmEntityType.java
----------------------------------------------------------------------
diff --git a/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmEntityType.java b/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmEntityType.java
deleted file mode 100644
index 5864a1c..0000000
--- a/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmEntityType.java
+++ /dev/null
@@ -1,230 +0,0 @@
-/*******************************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- ******************************************************************************/
-package org.apache.olingo.odata2.processor.core.jpa.model;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.ListIterator;
-import java.util.Set;
-
-import org.apache.olingo.odata2.api.edm.provider.EntityType;
-import org.apache.olingo.odata2.processor.api.jpa.access.JPAEdmBuilder;
-import org.apache.olingo.odata2.processor.api.jpa.access.JPAEdmMappingModelAccess;
-import org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPAModelException;
-import org.apache.olingo.odata2.processor.api.jpa.exception.ODataJPARuntimeException;
-import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmEntityTypeView;
-import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmKeyView;
-import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmNavigationPropertyView;
-import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmPropertyView;
-import org.apache.olingo.odata2.processor.api.jpa.model.JPAEdmSchemaView;
-import org.apache.olingo.odata2.processor.core.jpa.access.model.JPAEdmNameBuilder;
-
-public class JPAEdmEntityType extends JPAEdmBaseViewImpl implements JPAEdmEntityTypeView {
-
- private JPAEdmSchemaView schemaView = null;
- private EntityType currentEdmEntityType = null;
- private javax.persistence.metamodel.EntityType<?> currentJPAEntityType = null;
- private EntityTypeList<EntityType> consistentEntityTypes = null;
-
- private HashMap<String, EntityType> consistentEntityTypeMap;
-
- public JPAEdmEntityType(final JPAEdmSchemaView view) {
- super(view);
- schemaView = view;
- consistentEntityTypeMap = new HashMap<String, EntityType>();
- }
-
- @Override
- public JPAEdmBuilder getBuilder() {
- if (builder == null) {
- builder = new JPAEdmEntityTypeBuilder();
- }
-
- return builder;
- }
-
- @Override
- public EntityType getEdmEntityType() {
- return currentEdmEntityType;
- }
-
- @Override
- public javax.persistence.metamodel.EntityType<?> getJPAEntityType() {
- return currentJPAEntityType;
- }
-
- @Override
- public List<EntityType> getConsistentEdmEntityTypes() {
- return consistentEntityTypes;
- }
-
- @Override
- public EntityType searchEdmEntityType(final String jpaEntityTypeName) {
- return consistentEntityTypeMap.get(jpaEntityTypeName);
- }
-
- private class JPAEdmEntityTypeBuilder implements JPAEdmBuilder {
-
- @Override
- public void build() throws ODataJPAModelException, ODataJPARuntimeException {
-
- Set<javax.persistence.metamodel.EntityType<?>> jpaEntityTypes = metaModel.getEntities();
-
- if (jpaEntityTypes == null || jpaEntityTypes.isEmpty() == true) {
- return;
- } else if (consistentEntityTypes == null) {
- consistentEntityTypes = new EntityTypeList<EntityType>();
-
- }
-
- for (javax.persistence.metamodel.EntityType<?> jpaEntityType : jpaEntityTypes) {
- currentEdmEntityType = new EntityType();
- currentJPAEntityType = jpaEntityType;
-
- // Check for need to Exclude
- if (isExcluded(JPAEdmEntityType.this)) {
- continue;
- }
-
- JPAEdmNameBuilder.build(JPAEdmEntityType.this);
-
- JPAEdmPropertyView propertyView = new JPAEdmProperty(schemaView);
- propertyView.getBuilder().build();
-
- currentEdmEntityType.setProperties(propertyView.getEdmPropertyList());
- if (propertyView.getJPAEdmNavigationPropertyView() != null) {
- JPAEdmNavigationPropertyView navPropView = propertyView.getJPAEdmNavigationPropertyView();
- if (navPropView.getConsistentEdmNavigationProperties() != null
- && !navPropView.getConsistentEdmNavigationProperties().isEmpty()) {
- currentEdmEntityType.setNavigationProperties(navPropView.getConsistentEdmNavigationProperties());
- }
- }
- JPAEdmKeyView keyView = propertyView.getJPAEdmKeyView();
- currentEdmEntityType.setKey(keyView.getEdmKey());
-
- consistentEntityTypes.add(currentEdmEntityType);
- consistentEntityTypeMap.put(currentJPAEntityType.getName(), currentEdmEntityType);
- }
-
- }
-
- private boolean isExcluded(final JPAEdmEntityType jpaEdmEntityType) {
- JPAEdmMappingModelAccess mappingModelAccess = jpaEdmEntityType.getJPAEdmMappingModelAccess();
- if (mappingModelAccess != null && mappingModelAccess.isMappingModelExists()
- && mappingModelAccess.checkExclusionOfJPAEntityType(jpaEdmEntityType.getJPAEntityType().getName())) {
- return true;
- }
- return false;
- }
-
- }
-
- private class EntityTypeList<X> extends ArrayList<EntityType> {
-
- /**
- *
- */
- private static final long serialVersionUID = 719079109608251592L;
-
- @Override
- public Iterator<EntityType> iterator() {
- return new EntityTypeListIterator<X>(size());
- }
-
- }
-
- private class EntityTypeListIterator<E> implements ListIterator<EntityType> {
-
- private int size = 0;
- private int pos = 0;
-
- public EntityTypeListIterator(final int listSize) {
- this.size = listSize;
- }
-
- @Override
- public void add(final EntityType e) {
- consistentEntityTypes.add(e);
- size++;
- }
-
- @Override
- public boolean hasNext() {
- if (pos < size) {
- return true;
- }
-
- return false;
- }
-
- @Override
- public boolean hasPrevious() {
- if (pos > 0) {
- return true;
- }
- return false;
- }
-
- @Override
- public EntityType next() {
- if (pos < size) {
- currentEdmEntityType = consistentEntityTypes.get(pos++);
- return currentEdmEntityType;
- }
-
- return null;
- }
-
- @Override
- public int nextIndex() {
- return pos;
- }
-
- @Override
- public EntityType previous() {
- if (pos > 0 && pos < size) {
- currentEdmEntityType = consistentEntityTypes.get(--pos);
- return currentEdmEntityType;
- }
- return null;
- }
-
- @Override
- public int previousIndex() {
- if (pos > 0) {
- return pos - 1;
- }
-
- return 0;
- }
-
- @Override
- public void remove() {
- consistentEntityTypes.remove(pos);
- }
-
- @Override
- public void set(final EntityType e) {
- consistentEntityTypes.set(pos, e);
- }
-
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/57599da6/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmFacets.java
----------------------------------------------------------------------
diff --git a/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmFacets.java b/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmFacets.java
deleted file mode 100644
index 61f984f..0000000
--- a/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/model/JPAEdmFacets.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*******************************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- ******************************************************************************/
-package org.apache.olingo.odata2.processor.core.jpa.model;
-
-import java.lang.reflect.AnnotatedElement;
-
-import javax.persistence.Column;
-import javax.persistence.metamodel.Attribute;
-
-import org.apache.olingo.odata2.api.edm.EdmSimpleTypeKind;
-import org.apache.olingo.odata2.api.edm.provider.Facets;
-import org.apache.olingo.odata2.api.edm.provider.SimpleProperty;
-
-public class JPAEdmFacets {
- public static void setFacets(final Attribute<?, ?> jpaAttribute, final SimpleProperty edmProperty) {
- EdmSimpleTypeKind edmTypeKind = edmProperty.getType();
- Facets facets = new Facets();
- edmProperty.setFacets(facets);
-
- Column column = null;
- if (jpaAttribute.getJavaMember() instanceof AnnotatedElement) {
- column = ((AnnotatedElement) jpaAttribute
- .getJavaMember()).getAnnotation(Column.class);
- }
-
- if (column == null) {
- return;
- }
-
- setNullable(column, edmProperty);
-
- switch (edmTypeKind) {
- case Binary:
- setMaxLength(column, edmProperty);
- break;
- case DateTime:
- setPrecision(column, edmProperty);
- break;
- case DateTimeOffset:
- setPrecision(column, edmProperty);
- break;
- case Time:
- setPrecision(column, edmProperty);
- break;
- case Decimal:
- setPrecision(column, edmProperty);
- setScale(column, edmProperty);
- break;
- case String:
- setMaxLength(column, edmProperty);
- break;
- default:
- break;
- }
- }
-
- private static void setNullable(final Column column, final SimpleProperty edmProperty) {
- ((Facets) edmProperty.getFacets()).setNullable(column.nullable());
- }
-
- private static void setMaxLength(final Column column, final SimpleProperty edmProperty) {
- if (column.length() > 0) {
- ((Facets) edmProperty.getFacets()).setMaxLength(column.length());
- }
- }
-
- private static void setPrecision(final Column column, final SimpleProperty edmProperty) {
- if (column.precision() > 0) {
- ((Facets) edmProperty.getFacets()).setPrecision(column.precision());
- }
- }
-
- private static void setScale(final Column column, final SimpleProperty edmProperty) {
- if (column.scale() > 0) {
- ((Facets) edmProperty.getFacets()).setScale(column.scale());
- }
- }
-}