You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@olingo.apache.org by ch...@apache.org on 2013/09/20 15:34:19 UTC
[57/59] [abbrv] git commit: cleanup jpa core
cleanup jpa core
Project: http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/commit/02a598bd
Tree: http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/tree/02a598bd
Diff: http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/diff/02a598bd
Branch: refs/heads/master
Commit: 02a598bdce717c6e6282012725315ac5141a80a6
Parents: da6d5ca
Author: Christian Amend <ch...@apache.org>
Authored: Fri Sep 20 15:24:28 2013 +0200
Committer: Christian Amend <ch...@apache.org>
Committed: Fri Sep 20 15:24:28 2013 +0200
----------------------------------------------------------------------
.../processor/core/jpa/ODataEntityParser.java | 38 ++--
.../core/jpa/ODataExpressionParser.java | 115 ++++++----
.../processor/core/jpa/ODataJPAContextImpl.java | 26 +--
.../core/jpa/ODataJPAProcessorDefault.java | 86 +++++---
.../core/jpa/ODataJPAResponseBuilder.java | 159 +++++++++-----
.../core/jpa/access/data/JPAEntity.java | 87 ++++----
.../core/jpa/access/data/JPAEntityParser.java | 83 ++++----
.../core/jpa/access/data/JPAExpandCallBack.java | 51 +++--
.../jpa/access/data/JPAFunctionContext.java | 35 +--
.../processor/core/jpa/access/data/JPALink.java | 53 +++--
.../core/jpa/access/data/JPAProcessorImpl.java | 58 ++---
.../core/jpa/access/model/EdmTypeConvertor.java | 32 +--
.../access/model/JPAEdmMappingModelService.java | 35 +--
.../jpa/access/model/JPAEdmNameBuilder.java | 49 +++--
.../core/jpa/access/model/JPATypeConvertor.java | 48 +++--
.../core/jpa/edm/ODataJPAEdmProvider.java | 29 +--
.../ODataJPAMessageServiceDefault.java | 35 +--
.../core/jpa/factory/ODataJPAFactoryImpl.java | 26 +--
.../core/jpa/jpql/JPQLJoinSelectContext.java | 36 ++--
.../jpa/jpql/JPQLJoinSelectSingleContext.java | 36 ++--
.../JPQLJoinSelectSingleStatementBuilder.java | 29 +--
.../core/jpa/jpql/JPQLJoinStatementBuilder.java | 42 ++--
.../core/jpa/jpql/JPQLSelectContext.java | 36 ++--
.../core/jpa/jpql/JPQLSelectSingleContext.java | 31 +--
.../jpql/JPQLSelectSingleStatementBuilder.java | 29 +--
.../jpa/jpql/JPQLSelectStatementBuilder.java | 33 +--
.../core/jpa/model/JPAEdmAssociation.java | 44 ++--
.../core/jpa/model/JPAEdmAssociationEnd.java | 35 +--
.../core/jpa/model/JPAEdmAssociationSet.java | 32 +--
.../core/jpa/model/JPAEdmBaseViewImpl.java | 29 +--
.../core/jpa/model/JPAEdmComplexType.java | 45 ++--
.../core/jpa/model/JPAEdmEntityContainer.java | 26 +--
.../core/jpa/model/JPAEdmEntitySet.java | 26 +--
.../core/jpa/model/JPAEdmEntityType.java | 32 +--
.../processor/core/jpa/model/JPAEdmFacets.java | 32 +--
.../core/jpa/model/JPAEdmFunctionImport.java | 53 +++--
.../processor/core/jpa/model/JPAEdmKey.java | 31 +--
.../core/jpa/model/JPAEdmMappingImpl.java | 26 +--
.../processor/core/jpa/model/JPAEdmModel.java | 26 +--
.../jpa/model/JPAEdmNavigationProperty.java | 29 +--
.../core/jpa/model/JPAEdmProperty.java | 86 ++++----
.../jpa/model/JPAEdmReferentialConstraint.java | 35 +--
.../model/JPAEdmReferentialConstraintRole.java | 41 ++--
.../processor/core/jpa/model/JPAEdmSchema.java | 31 +--
.../core/jpa/ODataExpressionParserTest.java | 212 ++++++++++++-------
.../core/jpa/ODataJPAContextImplTest.java | 26 +--
.../core/jpa/ODataJPAProcessorDefaultTest.java | 83 +++++---
.../core/jpa/ODataJPAResponseBuilderTest.java | 32 +--
.../jpa/access/data/JPAEntityParserTest.java | 40 ++--
.../JPAEntityParserTestForStaticMethods.java | 35 +--
.../core/jpa/access/data/JPAEntityTest.java | 30 +--
.../jpa/access/data/JPAExpandCallBackTest.java | 32 +--
.../jpa/access/data/JPAFunctionContextTest.java | 29 +--
.../jpa/access/data/JPAProcessorImplTest.java | 46 ++--
.../model/JPAEdmMappingModelServiceTest.java | 65 +++---
.../jpa/access/model/JPAEdmNameBuilderTest.java | 26 +--
.../jpa/access/model/JPATypeConvertorTest.java | 34 +--
.../core/jpa/common/ODataJPATestConstants.java | 26 +--
.../edm/ODataJPAEdmProviderNegativeTest.java | 36 ++--
.../core/jpa/edm/ODataJPAEdmProviderTest.java | 56 +++--
.../core/jpa/jpql/JPQLBuilderFactoryTest.java | 47 ++--
.../core/jpa/jpql/JPQLJoinContextTest.java | 26 +--
.../jpql/JPQLJoinSelectSingleContextTest.java | 26 +--
...PQLJoinSelectSingleStatementBuilderTest.java | 49 +++--
.../jpa/jpql/JPQLJoinStatementBuilderTest.java | 40 ++--
.../jpa/jpql/JPQLSelectContextImplTest.java | 44 ++--
.../jpql/JPQLSelectSingleContextImplTest.java | 29 +--
.../JPQLSelectSingleStatementBuilderTest.java | 41 ++--
.../jpql/JPQLSelectStatementBuilderTest.java | 45 ++--
.../core/jpa/mock/ODataJPAContextMock.java | 26 +--
.../core/jpa/mock/data/EdmMockUtil.java | 26 +--
.../core/jpa/mock/data/EdmMockUtilV2.java | 155 +++++++-------
.../core/jpa/mock/data/JPATypeMock.java | 34 +--
.../core/jpa/mock/data/ODataEntryMockUtil.java | 44 ++--
.../core/jpa/mock/data/SalesOrderHeader.java | 26 +--
.../core/jpa/mock/data/SalesOrderLineItem.java | 26 +--
.../jpa/mock/data/SalesOrderLineItemKey.java | 26 +--
.../core/jpa/mock/model/EdmSchemaMock.java | 38 ++--
.../core/jpa/mock/model/JPAAttributeMock.java | 26 +--
.../jpa/mock/model/JPACustomProcessorMock.java | 39 ++--
.../model/JPACustomProcessorNegativeMock.java | 26 +--
.../core/jpa/mock/model/JPAEdmMockData.java | 26 +--
.../core/jpa/mock/model/JPAEmbeddableMock.java | 26 +--
.../jpa/mock/model/JPAEmbeddableTypeMock.java | 26 +--
.../core/jpa/mock/model/JPAEntityTypeMock.java | 26 +--
.../core/jpa/mock/model/JPAJavaMemberMock.java | 26 +--
.../core/jpa/mock/model/JPAManagedTypeMock.java | 26 +--
.../core/jpa/mock/model/JPAMetaModelMock.java | 26 +--
.../jpa/mock/model/JPAPluralAttributeMock.java | 26 +--
.../mock/model/JPASingularAttributeMock.java | 26 +--
.../jpa/model/JPAEdmAssociationEndTest.java | 29 +--
.../jpa/model/JPAEdmAssociationSetTest.java | 32 +--
.../core/jpa/model/JPAEdmAssociationTest.java | 38 ++--
.../core/jpa/model/JPAEdmBaseViewImplTest.java | 26 +--
.../core/jpa/model/JPAEdmComplexTypeTest.java | 26 +--
.../jpa/model/JPAEdmEntityContainerTest.java | 28 +--
.../core/jpa/model/JPAEdmEntitySetTest.java | 26 +--
.../core/jpa/model/JPAEdmEntityTypeTest.java | 26 +--
.../jpa/model/JPAEdmFunctionImportTest.java | 35 +--
.../processor/core/jpa/model/JPAEdmKeyTest.java | 29 +--
.../core/jpa/model/JPAEdmModelTest.java | 26 +--
.../jpa/model/JPAEdmNavigationPropertyTest.java | 26 +--
.../core/jpa/model/JPAEdmPropertyTest.java | 41 ++--
.../JPAEdmReferentialConstraintRoleTest.java | 40 ++--
.../model/JPAEdmReferentialConstraintTest.java | 40 ++--
.../core/jpa/model/JPAEdmSchemaTest.java | 28 +--
.../core/jpa/model/JPAEdmTestModelView.java | 37 ++--
107 files changed, 2415 insertions(+), 1975 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/02a598bd/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/ODataEntityParser.java
----------------------------------------------------------------------
diff --git a/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/ODataEntityParser.java b/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/ODataEntityParser.java
index f4df2c5..ee54290 100644
--- a/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/ODataEntityParser.java
+++ b/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/ODataEntityParser.java
@@ -1,20 +1,20 @@
/*******************************************************************************
* Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, 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;
@@ -53,7 +53,8 @@ public final class ODataEntityParser {
throws ODataBadRequestException {
ODataEntry entryValues;
try {
- EntityProviderReadProperties entityProviderProperties = EntityProviderReadProperties.init().mergeSemantic(merge).build();
+ EntityProviderReadProperties entityProviderProperties =
+ EntityProviderReadProperties.init().mergeSemantic(merge).build();
entryValues = EntityProvider.readEntry(requestContentType, entitySet, content, entityProviderProperties);
} catch (EntityProviderException e) {
throw new ODataBadRequestException(ODataBadRequestException.BODY, e);
@@ -80,7 +81,8 @@ public final class ODataEntityParser {
return uriInfo;
}
- public final UriInfo parseLink(final EdmEntitySet entitySet, final InputStream content, final String contentType) throws ODataJPARuntimeException {
+ public final UriInfo parseLink(final EdmEntitySet entitySet, final InputStream content, final String contentType)
+ throws ODataJPARuntimeException {
String uriString = null;
UriInfo uri = null;
@@ -90,7 +92,8 @@ public final class ODataEntityParser {
ODataContext odataContext = context.getODataContext();
final String serviceRoot = odataContext.getPathInfo().getServiceRoot().toString();
- final String path = uriString.startsWith(serviceRoot.toString()) ? uriString.substring(serviceRoot.length()) : uriString;
+ final String path =
+ uriString.startsWith(serviceRoot.toString()) ? uriString.substring(serviceRoot.length()) : uriString;
final PathSegment pathSegment = new PathSegment() {
@Override
@@ -116,7 +119,8 @@ public final class ODataEntityParser {
}
- public List<UriInfo> parseLinks(final EdmEntitySet entitySet, final InputStream content, final String contentType) throws ODataJPARuntimeException {
+ public List<UriInfo> parseLinks(final EdmEntitySet entitySet, final InputStream content, final String contentType)
+ throws ODataJPARuntimeException {
List<String> uriList = new ArrayList<String>();
List<UriInfo> uriInfoList = new ArrayList<UriInfo>();
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/02a598bd/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/ODataExpressionParser.java
----------------------------------------------------------------------
diff --git a/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/ODataExpressionParser.java b/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/ODataExpressionParser.java
index 448138b..8c69634 100644
--- a/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/ODataExpressionParser.java
+++ b/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/ODataExpressionParser.java
@@ -1,20 +1,20 @@
/*******************************************************************************
* Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, 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;
@@ -54,8 +54,8 @@ import org.apache.olingo.odata2.processor.api.jpa.jpql.JPQLStatement;
/**
* This class contains utility methods for parsing the filter expressions built by core library from user OData Query.
*
- *
- *
+ *
+ *
*/
public class ODataExpressionParser {
@@ -71,7 +71,8 @@ public class ODataExpressionParser {
* @throws ODataException
*/
- public static String parseToJPAWhereExpression(final CommonExpression whereExpression, final String tableAlias) throws ODataException {
+ public static String parseToJPAWhereExpression(final CommonExpression whereExpression, final String tableAlias)
+ throws ODataException {
switch (whereExpression.getKind()) {
case UNARY:
final UnaryExpression unaryExpression = (UnaryExpression) whereExpression;
@@ -94,7 +95,10 @@ public class ODataExpressionParser {
return parseToJPAWhereExpression(((FilterExpression) whereExpression).getExpression(), tableAlias);
case BINARY:
final BinaryExpression binaryExpression = (BinaryExpression) whereExpression;
- if ((binaryExpression.getLeftOperand().getKind() == ExpressionKind.METHOD) && ((binaryExpression.getOperator() == BinaryOperator.EQ) || (binaryExpression.getOperator() == BinaryOperator.NE)) && (((MethodExpression) binaryExpression.getLeftOperand()).getMethod() == MethodOperator.SUBSTRINGOF)) {
+ if ((binaryExpression.getLeftOperand().getKind() == ExpressionKind.METHOD)
+ && ((binaryExpression.getOperator() == BinaryOperator.EQ) ||
+ (binaryExpression.getOperator() == BinaryOperator.NE))
+ && (((MethodExpression) binaryExpression.getLeftOperand()).getMethod() == MethodOperator.SUBSTRINGOF)) {
methodFlag = 1;
}
final String left = parseToJPAWhereExpression(binaryExpression.getLeftOperand(), tableAlias);
@@ -102,7 +106,8 @@ public class ODataExpressionParser {
switch (binaryExpression.getOperator()) {
case AND:
- return left + JPQLStatement.DELIMITER.SPACE + JPQLStatement.Operator.AND + JPQLStatement.DELIMITER.SPACE + right;
+ return left + JPQLStatement.DELIMITER.SPACE + JPQLStatement.Operator.AND + JPQLStatement.DELIMITER.SPACE
+ + right;
case OR:
return left + JPQLStatement.DELIMITER.SPACE + JPQLStatement.Operator.OR + JPQLStatement.DELIMITER.SPACE + right;
case EQ:
@@ -124,7 +129,9 @@ public class ODataExpressionParser {
}
case PROPERTY:
- String returnStr = tableAlias + JPQLStatement.DELIMITER.PERIOD + ((EdmProperty) ((PropertyExpression) whereExpression).getEdmProperty()).getMapping().getInternalName();
+ String returnStr =
+ tableAlias + JPQLStatement.DELIMITER.PERIOD
+ + ((EdmProperty) ((PropertyExpression) whereExpression).getEdmProperty()).getMapping().getInternalName();
return returnStr;
case MEMBER:
@@ -138,23 +145,33 @@ public class ODataExpressionParser {
memberExpStr = JPQLStatement.DELIMITER.PERIOD + memberExpStr;
}
i++;
- memberExpStr = ((EdmProperty) ((PropertyExpression) member.getProperty()).getEdmProperty()).getMapping().getInternalName() + memberExpStr;
+ memberExpStr =
+ ((EdmProperty) ((PropertyExpression) member.getProperty()).getEdmProperty()).getMapping().getInternalName()
+ + memberExpStr;
tempExp = member.getPath();
}
- memberExpStr = ((EdmProperty) ((PropertyExpression) tempExp).getEdmProperty()).getMapping().getInternalName() + JPQLStatement.DELIMITER.PERIOD + memberExpStr;
+ memberExpStr =
+ ((EdmProperty) ((PropertyExpression) tempExp).getEdmProperty()).getMapping().getInternalName()
+ + JPQLStatement.DELIMITER.PERIOD + memberExpStr;
return tableAlias + JPQLStatement.DELIMITER.PERIOD + memberExpStr;
case LITERAL:
final LiteralExpression literal = (LiteralExpression) whereExpression;
final EdmSimpleType literalType = (EdmSimpleType) literal.getEdmType();
- String value = literalType.valueToString(literalType.valueOfString(literal.getUriLiteral(), EdmLiteralKind.URI, null, literalType.getDefaultType()), EdmLiteralKind.DEFAULT, null);
+ String value =
+ literalType.valueToString(literalType.valueOfString(literal.getUriLiteral(), EdmLiteralKind.URI, null,
+ literalType.getDefaultType()), EdmLiteralKind.DEFAULT, null);
return evaluateComparingExpression(value, literalType);
case METHOD:
final MethodExpression methodExpression = (MethodExpression) whereExpression;
String first = parseToJPAWhereExpression(methodExpression.getParameters().get(0), tableAlias);
- final String second = methodExpression.getParameterCount() > 1 ? parseToJPAWhereExpression(methodExpression.getParameters().get(1), tableAlias) : null;
- String third = methodExpression.getParameterCount() > 2 ? parseToJPAWhereExpression(methodExpression.getParameters().get(2), tableAlias) : null;
+ final String second =
+ methodExpression.getParameterCount() > 1 ? parseToJPAWhereExpression(methodExpression.getParameters().get(1),
+ tableAlias) : null;
+ String third =
+ methodExpression.getParameterCount() > 2 ? parseToJPAWhereExpression(methodExpression.getParameters().get(2),
+ tableAlias) : null;
switch (methodExpression.getMethod()) {
case SUBSTRING:
@@ -165,8 +182,7 @@ public class ODataExpressionParser {
if (methodFlag == 1) {
methodFlag = 0;
return String.format("(CASE WHEN (%s LIKE '%%%s%%') THEN TRUE ELSE FALSE END)", second, first);
- }
- else {
+ } else {
return String.format("(CASE WHEN (%s LIKE '%%%s%%') THEN TRUE ELSE FALSE END) = true", second, first);
}
case TOLOWER:
@@ -215,7 +231,8 @@ public class ODataExpressionParser {
* @return a map of JPA attributes and their sort order
* @throws ODataJPARuntimeException
*/
- public static HashMap<String, String> parseToJPAOrderByExpression(final OrderByExpression orderByExpression, final String tableAlias) throws ODataJPARuntimeException {
+ public static HashMap<String, String> parseToJPAOrderByExpression(final OrderByExpression orderByExpression,
+ final String tableAlias) throws ODataJPARuntimeException {
HashMap<String, String> orderByMap = new HashMap<String, String>();
if (orderByExpression != null && orderByExpression.getOrders() != null) {
List<OrderExpression> orderBys = orderByExpression.getOrders();
@@ -224,7 +241,9 @@ public class ODataExpressionParser {
for (OrderExpression orderBy : orderBys) {
try {
- orderByField = ((EdmProperty) ((PropertyExpression) orderBy.getExpression()).getEdmProperty()).getMapping().getInternalName();
+ orderByField =
+ ((EdmProperty) ((PropertyExpression) orderBy.getExpression()).getEdmProperty()).getMapping()
+ .getInternalName();
orderByDirection = (orderBy.getSortOrder() == SortOrder.asc) ? EMPTY : "DESC"; //$NON-NLS-1$
orderByMap.put(tableAlias + JPQLStatement.DELIMITER.PERIOD + orderByField, orderByDirection);
} catch (EdmException e) {
@@ -242,7 +261,8 @@ public class ODataExpressionParser {
* @return the evaluated where expression
*/
- public static String parseKeyPredicates(final List<KeyPredicate> keyPredicates, final String tableAlias) throws ODataJPARuntimeException {
+ public static String parseKeyPredicates(final List<KeyPredicate> keyPredicates, final String tableAlias)
+ throws ODataJPARuntimeException {
String literal = null;
String propertyName = null;
EdmSimpleType edmSimpleType = null;
@@ -263,11 +283,13 @@ public class ODataExpressionParser {
literal = evaluateComparingExpression(literal, edmSimpleType);
- if (edmSimpleType == EdmSimpleTypeKind.DateTime.getEdmSimpleTypeInstance() || edmSimpleType == EdmSimpleTypeKind.DateTimeOffset.getEdmSimpleTypeInstance()) {
+ if (edmSimpleType == EdmSimpleTypeKind.DateTime.getEdmSimpleTypeInstance()
+ || edmSimpleType == EdmSimpleTypeKind.DateTimeOffset.getEdmSimpleTypeInstance()) {
literal = literal.substring(literal.indexOf('\''), literal.indexOf('}'));
}
- keyFilters.append(tableAlias + JPQLStatement.DELIMITER.PERIOD + propertyName + JPQLStatement.DELIMITER.SPACE + JPQLStatement.Operator.EQ + JPQLStatement.DELIMITER.SPACE + literal);
+ keyFilters.append(tableAlias + JPQLStatement.DELIMITER.PERIOD + propertyName + JPQLStatement.DELIMITER.SPACE
+ + JPQLStatement.Operator.EQ + JPQLStatement.DELIMITER.SPACE + literal);
}
if (keyFilters.length() > 0) {
return keyFilters.toString();
@@ -282,15 +304,19 @@ public class ODataExpressionParser {
* @param value
* @param edmSimpleType
* @return the evaluated expression
- * @throws ODataJPARuntimeException
+ * @throws ODataJPARuntimeException
*/
- private static String evaluateComparingExpression(String value, final EdmSimpleType edmSimpleType) throws ODataJPARuntimeException {
+ private static String evaluateComparingExpression(String value, final EdmSimpleType edmSimpleType)
+ throws ODataJPARuntimeException {
- if (edmSimpleType == EdmSimpleTypeKind.String.getEdmSimpleTypeInstance() || edmSimpleType == EdmSimpleTypeKind.Guid.getEdmSimpleTypeInstance()) {
+ if (edmSimpleType == EdmSimpleTypeKind.String.getEdmSimpleTypeInstance()
+ || edmSimpleType == EdmSimpleTypeKind.Guid.getEdmSimpleTypeInstance()) {
value = "\'" + value + "\'"; //$NON-NLS-1$ //$NON-NLS-2$
- } else if (edmSimpleType == EdmSimpleTypeKind.DateTime.getEdmSimpleTypeInstance() || edmSimpleType == EdmSimpleTypeKind.DateTimeOffset.getEdmSimpleTypeInstance()) {
+ } else if (edmSimpleType == EdmSimpleTypeKind.DateTime.getEdmSimpleTypeInstance()
+ || edmSimpleType == EdmSimpleTypeKind.DateTimeOffset.getEdmSimpleTypeInstance()) {
try {
- Calendar datetime = (Calendar) edmSimpleType.valueOfString(value, EdmLiteralKind.DEFAULT, null, edmSimpleType.getDefaultType());
+ Calendar datetime =
+ (Calendar) edmSimpleType.valueOfString(value, EdmLiteralKind.DEFAULT, null, edmSimpleType.getDefaultType());
String year = String.format("%04d", datetime.get(Calendar.YEAR));
String month = String.format("%02d", datetime.get(Calendar.MONTH) + 1);
@@ -299,7 +325,12 @@ public class ODataExpressionParser {
String min = String.format("%02d", datetime.get(Calendar.MINUTE));
String sec = String.format("%02d", datetime.get(Calendar.SECOND));
- value = JPQLStatement.DELIMITER.LEFT_BRACE + JPQLStatement.KEYWORD.TIMESTAMP + JPQLStatement.DELIMITER.SPACE + "\'" + year + JPQLStatement.DELIMITER.HYPHEN + month + JPQLStatement.DELIMITER.HYPHEN + day + JPQLStatement.DELIMITER.SPACE + hour + JPQLStatement.DELIMITER.COLON + min + JPQLStatement.DELIMITER.COLON + sec + JPQLStatement.KEYWORD.OFFSET + "\'" + JPQLStatement.DELIMITER.RIGHT_BRACE;
+ value =
+ JPQLStatement.DELIMITER.LEFT_BRACE + JPQLStatement.KEYWORD.TIMESTAMP + JPQLStatement.DELIMITER.SPACE + "\'"
+ + year + JPQLStatement.DELIMITER.HYPHEN + month + JPQLStatement.DELIMITER.HYPHEN + day
+ + JPQLStatement.DELIMITER.SPACE + hour + JPQLStatement.DELIMITER.COLON + min
+ + JPQLStatement.DELIMITER.COLON + sec + JPQLStatement.KEYWORD.OFFSET + "\'"
+ + JPQLStatement.DELIMITER.RIGHT_BRACE;
} catch (EdmSimpleTypeException e) {
throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e);
@@ -307,13 +338,16 @@ public class ODataExpressionParser {
} else if (edmSimpleType == EdmSimpleTypeKind.Time.getEdmSimpleTypeInstance()) {
try {
- Calendar time = (Calendar) edmSimpleType.valueOfString(value, EdmLiteralKind.DEFAULT, null, edmSimpleType.getDefaultType());
+ Calendar time =
+ (Calendar) edmSimpleType.valueOfString(value, EdmLiteralKind.DEFAULT, null, edmSimpleType.getDefaultType());
String hourValue = String.format("%02d", time.get(Calendar.HOUR_OF_DAY));
String minValue = String.format("%02d", time.get(Calendar.MINUTE));
String secValue = String.format("%02d", time.get(Calendar.SECOND));
- value = "\'" + hourValue + JPQLStatement.DELIMITER.COLON + minValue + JPQLStatement.DELIMITER.COLON + secValue + "\'";
+ value =
+ "\'" + hourValue + JPQLStatement.DELIMITER.COLON + minValue + JPQLStatement.DELIMITER.COLON + secValue
+ + "\'";
} catch (EdmSimpleTypeException e) {
throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e);
}
@@ -324,7 +358,8 @@ public class ODataExpressionParser {
return value;
}
- public static HashMap<String, String> parseKeyPropertiesToJPAOrderByExpression(final List<EdmProperty> edmPropertylist, final String tableAlias) throws ODataJPARuntimeException {
+ public static HashMap<String, String> parseKeyPropertiesToJPAOrderByExpression(
+ final List<EdmProperty> edmPropertylist, final String tableAlias) throws ODataJPARuntimeException {
HashMap<String, String> orderByMap = new HashMap<String, String>();
String propertyName = null;
for (EdmProperty edmProperty : edmPropertylist) {
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/02a598bd/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/ODataJPAContextImpl.java
----------------------------------------------------------------------
diff --git a/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/ODataJPAContextImpl.java b/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/ODataJPAContextImpl.java
index e7ad2f9..21c17b7 100644
--- a/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/ODataJPAContextImpl.java
+++ b/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/ODataJPAContextImpl.java
@@ -1,20 +1,20 @@
/*******************************************************************************
* Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, 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;
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/02a598bd/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/ODataJPAProcessorDefault.java
----------------------------------------------------------------------
diff --git a/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/ODataJPAProcessorDefault.java b/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/ODataJPAProcessorDefault.java
index fb76ca4..1d5929d 100644
--- a/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/ODataJPAProcessorDefault.java
+++ b/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/ODataJPAProcessorDefault.java
@@ -1,20 +1,20 @@
/*******************************************************************************
* Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, 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;
@@ -47,27 +47,32 @@ public class ODataJPAProcessorDefault extends ODataJPAProcessor {
}
@Override
- public ODataResponse readEntitySet(final GetEntitySetUriInfo uriParserResultView, final String contentType) throws ODataException {
+ public ODataResponse readEntitySet(final GetEntitySetUriInfo uriParserResultView, final String contentType)
+ throws ODataException {
List<?> jpaEntities = jpaProcessor.process(uriParserResultView);
- ODataResponse oDataResponse = ODataJPAResponseBuilder.build(jpaEntities, uriParserResultView, contentType, oDataJPAContext);
+ ODataResponse oDataResponse =
+ ODataJPAResponseBuilder.build(jpaEntities, uriParserResultView, contentType, oDataJPAContext);
return oDataResponse;
}
@Override
- public ODataResponse readEntity(final GetEntityUriInfo uriParserResultView, final String contentType) throws ODataException {
+ public ODataResponse readEntity(final GetEntityUriInfo uriParserResultView, final String contentType)
+ throws ODataException {
Object jpaEntity = jpaProcessor.process(uriParserResultView);
- ODataResponse oDataResponse = ODataJPAResponseBuilder.build(jpaEntity, uriParserResultView, contentType, oDataJPAContext);
+ ODataResponse oDataResponse =
+ ODataJPAResponseBuilder.build(jpaEntity, uriParserResultView, contentType, oDataJPAContext);
return oDataResponse;
}
@Override
- public ODataResponse countEntitySet(final GetEntitySetCountUriInfo uriParserResultView, final String contentType) throws ODataException {
+ public ODataResponse countEntitySet(final GetEntitySetCountUriInfo uriParserResultView, final String contentType)
+ throws ODataException {
long jpaEntityCount = jpaProcessor.process(uriParserResultView);
@@ -77,7 +82,8 @@ public class ODataJPAProcessorDefault extends ODataJPAProcessor {
}
@Override
- public ODataResponse existsEntity(final GetEntityCountUriInfo uriInfo, final String contentType) throws ODataException {
+ public ODataResponse existsEntity(final GetEntityCountUriInfo uriInfo, final String contentType)
+ throws ODataException {
long jpaEntityCount = jpaProcessor.process(uriInfo);
@@ -87,17 +93,20 @@ public class ODataJPAProcessorDefault extends ODataJPAProcessor {
}
@Override
- public ODataResponse createEntity(final PostUriInfo uriParserResultView, final InputStream content, final String requestContentType, final String contentType) throws ODataException {
+ public ODataResponse createEntity(final PostUriInfo uriParserResultView, final InputStream content,
+ final String requestContentType, final String contentType) throws ODataException {
List<Object> createdJpaEntityList = jpaProcessor.process(uriParserResultView, content, requestContentType);
- ODataResponse oDataResponse = ODataJPAResponseBuilder.build(createdJpaEntityList, uriParserResultView, contentType, oDataJPAContext);
+ ODataResponse oDataResponse =
+ ODataJPAResponseBuilder.build(createdJpaEntityList, uriParserResultView, contentType, oDataJPAContext);
return oDataResponse;
}
@Override
- public ODataResponse updateEntity(final PutMergePatchUriInfo uriParserResultView, final InputStream content, final String requestContentType, final boolean merge, final String contentType) throws ODataException {
+ public ODataResponse updateEntity(final PutMergePatchUriInfo uriParserResultView, final InputStream content,
+ final String requestContentType, final boolean merge, final String contentType) throws ODataException {
Object jpaEntity = jpaProcessor.process(uriParserResultView, content, requestContentType);
@@ -107,7 +116,8 @@ public class ODataJPAProcessorDefault extends ODataJPAProcessor {
}
@Override
- public ODataResponse deleteEntity(final DeleteUriInfo uriParserResultView, final String contentType) throws ODataException {
+ public ODataResponse deleteEntity(final DeleteUriInfo uriParserResultView, final String contentType)
+ throws ODataException {
Object deletedObj = jpaProcessor.process(uriParserResultView, contentType);
@@ -116,47 +126,56 @@ public class ODataJPAProcessorDefault extends ODataJPAProcessor {
}
@Override
- public ODataResponse executeFunctionImport(final GetFunctionImportUriInfo uriParserResultView, final String contentType) throws ODataException {
+ public ODataResponse executeFunctionImport(final GetFunctionImportUriInfo uriParserResultView,
+ final String contentType) throws ODataException {
List<Object> resultEntity = jpaProcessor.process(uriParserResultView);
- ODataResponse oDataResponse = ODataJPAResponseBuilder.build(resultEntity, uriParserResultView, contentType, oDataJPAContext);
+ ODataResponse oDataResponse =
+ ODataJPAResponseBuilder.build(resultEntity, uriParserResultView, contentType, oDataJPAContext);
return oDataResponse;
}
@Override
- public ODataResponse executeFunctionImportValue(final GetFunctionImportUriInfo uriParserResultView, final String contentType) throws ODataException {
+ public ODataResponse executeFunctionImportValue(final GetFunctionImportUriInfo uriParserResultView,
+ final String contentType) throws ODataException {
List<Object> result = jpaProcessor.process(uriParserResultView);
- ODataResponse oDataResponse = ODataJPAResponseBuilder.build(result, uriParserResultView, contentType, oDataJPAContext);
+ ODataResponse oDataResponse =
+ ODataJPAResponseBuilder.build(result, uriParserResultView, contentType, oDataJPAContext);
return oDataResponse;
}
@Override
- public ODataResponse readEntityLink(final GetEntityLinkUriInfo uriParserResultView, final String contentType) throws ODataException {
+ public ODataResponse readEntityLink(final GetEntityLinkUriInfo uriParserResultView, final String contentType)
+ throws ODataException {
Object jpaEntity = jpaProcessor.process(uriParserResultView);
- ODataResponse oDataResponse = ODataJPAResponseBuilder.build(jpaEntity, uriParserResultView, contentType, oDataJPAContext);
+ ODataResponse oDataResponse =
+ ODataJPAResponseBuilder.build(jpaEntity, uriParserResultView, contentType, oDataJPAContext);
return oDataResponse;
}
@Override
- public ODataResponse readEntityLinks(final GetEntitySetLinksUriInfo uriParserResultView, final String contentType) throws ODataException {
+ public ODataResponse readEntityLinks(final GetEntitySetLinksUriInfo uriParserResultView, final String contentType)
+ throws ODataException {
List<Object> jpaEntity = jpaProcessor.process(uriParserResultView);
- ODataResponse oDataResponse = ODataJPAResponseBuilder.build(jpaEntity, uriParserResultView, contentType, oDataJPAContext);
+ ODataResponse oDataResponse =
+ ODataJPAResponseBuilder.build(jpaEntity, uriParserResultView, contentType, oDataJPAContext);
return oDataResponse;
}
@Override
- public ODataResponse createEntityLink(final PostUriInfo uriParserResultView, final InputStream content, final String requestContentType, final String contentType) throws ODataException {
+ public ODataResponse createEntityLink(final PostUriInfo uriParserResultView, final InputStream content,
+ final String requestContentType, final String contentType) throws ODataException {
jpaProcessor.process(uriParserResultView, content, requestContentType, contentType);
@@ -164,7 +183,8 @@ public class ODataJPAProcessorDefault extends ODataJPAProcessor {
}
@Override
- public ODataResponse updateEntityLink(final PutMergePatchUriInfo uriParserResultView, final InputStream content, final String requestContentType, final String contentType) throws ODataException {
+ public ODataResponse updateEntityLink(final PutMergePatchUriInfo uriParserResultView, final InputStream content,
+ final String requestContentType, final String contentType) throws ODataException {
jpaProcessor.process(uriParserResultView, content, requestContentType, contentType);
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/02a598bd/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/ODataJPAResponseBuilder.java
----------------------------------------------------------------------
diff --git a/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/ODataJPAResponseBuilder.java b/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/ODataJPAResponseBuilder.java
index 65a26f6..f0d2923 100644
--- a/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/ODataJPAResponseBuilder.java
+++ b/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/ODataJPAResponseBuilder.java
@@ -1,20 +1,20 @@
/*******************************************************************************
* Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, 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;
@@ -66,7 +66,8 @@ import org.apache.olingo.odata2.processor.core.jpa.access.data.JPAExpandCallBack
public final class ODataJPAResponseBuilder {
/* Response for Read Entity Set */
- public static <T> ODataResponse build(final List<T> jpaEntities, final GetEntitySetUriInfo resultsView, final String contentType, final ODataJPAContext odataJPAContext) throws ODataJPARuntimeException {
+ public static <T> ODataResponse build(final List<T> jpaEntities, final GetEntitySetUriInfo resultsView,
+ final String contentType, final ODataJPAContext odataJPAContext) throws ODataJPARuntimeException {
EdmEntityType edmEntityType = null;
ODataResponse odataResponse = null;
@@ -80,7 +81,8 @@ public final class ODataJPAResponseBuilder {
final List<SelectItem> selectedItems = resultsView.getSelect();
if (selectedItems != null && selectedItems.size() > 0) {
for (Object jpaEntity : jpaEntities) {
- edmPropertyValueMap = jpaResultParser.parse2EdmPropertyValueMap(jpaEntity, buildSelectItemList(selectedItems, edmEntityType));
+ edmPropertyValueMap =
+ jpaResultParser.parse2EdmPropertyValueMap(jpaEntity, buildSelectItemList(selectedItems, edmEntityType));
edmEntityList.add(edmPropertyValueMap);
}
} else {
@@ -94,7 +96,8 @@ public final class ODataJPAResponseBuilder {
int count = 0;
for (Object jpaEntity : jpaEntities) {
Map<String, Object> relationShipMap = edmEntityList.get(count);
- HashMap<String, Object> navigationMap = jpaResultParser.parse2EdmNavigationValueMap(jpaEntity, constructListofNavProperty(expandList));
+ HashMap<String, Object> navigationMap =
+ jpaResultParser.parse2EdmNavigationValueMap(jpaEntity, constructListofNavProperty(expandList));
relationShipMap.putAll(navigationMap);
count++;
}
@@ -103,7 +106,8 @@ public final class ODataJPAResponseBuilder {
EntityProviderWriteProperties feedProperties = null;
feedProperties = getEntityProviderProperties(odataJPAContext, resultsView, edmEntityList);
- odataResponse = EntityProvider.writeFeed(contentType, resultsView.getTargetEntitySet(), edmEntityList, feedProperties);
+ odataResponse =
+ EntityProvider.writeFeed(contentType, resultsView.getTargetEntitySet(), edmEntityList, feedProperties);
odataResponse = ODataResponse.fromResponse(odataResponse).status(HttpStatusCodes.OK).build();
} catch (EntityProviderException e) {
@@ -116,7 +120,9 @@ public final class ODataJPAResponseBuilder {
}
/* Response for Read Entity */
- public static ODataResponse build(final Object jpaEntity, final GetEntityUriInfo resultsView, final String contentType, final ODataJPAContext oDataJPAContext) throws ODataJPARuntimeException, ODataNotFoundException {
+ public static ODataResponse build(final Object jpaEntity, final GetEntityUriInfo resultsView,
+ final String contentType, final ODataJPAContext oDataJPAContext) throws ODataJPARuntimeException,
+ ODataNotFoundException {
List<ArrayList<NavigationPropertySegment>> expandList = null;
if (jpaEntity == null) {
@@ -133,19 +139,23 @@ public final class ODataJPAResponseBuilder {
JPAEntityParser jpaResultParser = new JPAEntityParser();
final List<SelectItem> selectedItems = resultsView.getSelect();
if (selectedItems != null && selectedItems.size() > 0) {
- edmPropertyValueMap = jpaResultParser.parse2EdmPropertyValueMap(jpaEntity, buildSelectItemList(selectedItems, resultsView.getTargetEntitySet().getEntityType()));
+ edmPropertyValueMap =
+ jpaResultParser.parse2EdmPropertyValueMap(jpaEntity, buildSelectItemList(selectedItems, resultsView
+ .getTargetEntitySet().getEntityType()));
} else {
edmPropertyValueMap = jpaResultParser.parse2EdmPropertyValueMap(jpaEntity, edmEntityType);
}
expandList = resultsView.getExpand();
if (expandList != null && expandList.size() != 0) {
- HashMap<String, Object> navigationMap = jpaResultParser.parse2EdmNavigationValueMap(jpaEntity, constructListofNavProperty(expandList));
+ HashMap<String, Object> navigationMap =
+ jpaResultParser.parse2EdmNavigationValueMap(jpaEntity, constructListofNavProperty(expandList));
edmPropertyValueMap.putAll(navigationMap);
}
EntityProviderWriteProperties feedProperties = null;
feedProperties = getEntityProviderProperties(oDataJPAContext, resultsView);
- odataResponse = EntityProvider.writeEntry(contentType, resultsView.getTargetEntitySet(), edmPropertyValueMap, feedProperties);
+ odataResponse =
+ EntityProvider.writeEntry(contentType, resultsView.getTargetEntitySet(), edmPropertyValueMap, feedProperties);
odataResponse = ODataResponse.fromResponse(odataResponse).status(HttpStatusCodes.OK).build();
@@ -159,7 +169,8 @@ public final class ODataJPAResponseBuilder {
}
/* Response for $count */
- public static ODataResponse build(final long jpaEntityCount, final ODataJPAContext oDataJPAContext) throws ODataJPARuntimeException {
+ public static ODataResponse build(final long jpaEntityCount, final ODataJPAContext oDataJPAContext)
+ throws ODataJPARuntimeException {
ODataResponse odataResponse = null;
try {
@@ -173,7 +184,9 @@ public final class ODataJPAResponseBuilder {
/* Response for Create Entity */
@SuppressWarnings("unchecked")
- public static ODataResponse build(final List<Object> createdObjectList, final PostUriInfo uriInfo, final String contentType, final ODataJPAContext oDataJPAContext) throws ODataJPARuntimeException, ODataNotFoundException {
+ public static ODataResponse build(final List<Object> createdObjectList, final PostUriInfo uriInfo,
+ final String contentType, final ODataJPAContext oDataJPAContext) throws ODataJPARuntimeException,
+ ODataNotFoundException {
if (createdObjectList == null || createdObjectList.size() == 0 || createdObjectList.get(0) == null) {
throw new ODataNotFoundException(ODataNotFoundException.ENTITY);
@@ -191,9 +204,12 @@ public final class ODataJPAResponseBuilder {
edmPropertyValueMap = jpaResultParser.parse2EdmPropertyValueMap(createdObjectList.get(0), edmEntityType);
List<ArrayList<NavigationPropertySegment>> expandList = null;
- if (createdObjectList.get(1) != null && ((Map<EdmNavigationProperty, EdmEntitySet>) createdObjectList.get(1)).size() > 0) {
+ if (createdObjectList.get(1) != null
+ && ((Map<EdmNavigationProperty, EdmEntitySet>) createdObjectList.get(1)).size() > 0) {
expandList = getExpandList((Map<EdmNavigationProperty, EdmEntitySet>) createdObjectList.get(1));
- HashMap<String, Object> navigationMap = jpaResultParser.parse2EdmNavigationValueMap(createdObjectList.get(0), constructListofNavProperty(expandList));
+ HashMap<String, Object> navigationMap =
+ jpaResultParser.parse2EdmNavigationValueMap(createdObjectList.get(0),
+ constructListofNavProperty(expandList));
edmPropertyValueMap.putAll(navigationMap);
}
EntityProviderWriteProperties feedProperties = null;
@@ -203,7 +219,8 @@ public final class ODataJPAResponseBuilder {
throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.INNER_EXCEPTION, e);
}
- odataResponse = EntityProvider.writeEntry(contentType, uriInfo.getTargetEntitySet(), edmPropertyValueMap, feedProperties);
+ odataResponse =
+ EntityProvider.writeEntry(contentType, uriInfo.getTargetEntitySet(), edmPropertyValueMap, feedProperties);
odataResponse = ODataResponse.fromResponse(odataResponse).status(HttpStatusCodes.CREATED).build();
@@ -217,7 +234,8 @@ public final class ODataJPAResponseBuilder {
}
/* Response for Update Entity */
- public static ODataResponse build(final Object updatedObject, final PutMergePatchUriInfo putUriInfo) throws ODataJPARuntimeException, ODataNotFoundException {
+ public static ODataResponse build(final Object updatedObject, final PutMergePatchUriInfo putUriInfo)
+ throws ODataJPARuntimeException, ODataNotFoundException {
if (updatedObject == null) {
throw new ODataNotFoundException(ODataNotFoundException.ENTITY);
}
@@ -225,7 +243,8 @@ public final class ODataJPAResponseBuilder {
}
/* Response for Delete Entity */
- public static ODataResponse build(final Object deletedObject, final DeleteUriInfo deleteUriInfo) throws ODataJPARuntimeException, ODataNotFoundException {
+ public static ODataResponse build(final Object deletedObject, final DeleteUriInfo deleteUriInfo)
+ throws ODataJPARuntimeException, ODataNotFoundException {
if (deletedObject == null) {
throw new ODataNotFoundException(ODataNotFoundException.ENTITY);
@@ -234,7 +253,8 @@ public final class ODataJPAResponseBuilder {
}
/* Response for Function Import Single Result */
- public static ODataResponse build(final Object result, final GetFunctionImportUriInfo resultsView) throws ODataJPARuntimeException {
+ public static ODataResponse build(final Object result, final GetFunctionImportUriInfo resultsView)
+ throws ODataJPARuntimeException {
try {
final EdmFunctionImport functionImport = resultsView.getFunctionImport();
@@ -260,7 +280,9 @@ public final class ODataJPAResponseBuilder {
}
/* Response for Function Import Multiple Result */
- public static ODataResponse build(final List<Object> resultList, final GetFunctionImportUriInfo resultsView, final String contentType, final ODataJPAContext oDataJPAContext) throws ODataJPARuntimeException, ODataNotFoundException {
+ public static ODataResponse build(final List<Object> resultList, final GetFunctionImportUriInfo resultsView,
+ final String contentType, final ODataJPAContext oDataJPAContext) throws ODataJPARuntimeException,
+ ODataNotFoundException {
ODataResponse odataResponse = null;
@@ -274,7 +296,9 @@ public final class ODataJPAResponseBuilder {
try {
EntityProviderWriteProperties feedProperties = null;
- feedProperties = EntityProviderWriteProperties.serviceRoot(oDataJPAContext.getODataContext().getPathInfo().getServiceRoot()).build();
+ feedProperties =
+ EntityProviderWriteProperties.serviceRoot(oDataJPAContext.getODataContext().getPathInfo().getServiceRoot())
+ .build();
functionImport = resultsView.getFunctionImport();
edmType = functionImport.getReturnType().getType();
@@ -299,7 +323,8 @@ public final class ODataJPAResponseBuilder {
result = resultList.get(0);
}
- odataResponse = EntityProvider.writeFunctionImport(contentType, resultsView.getFunctionImport(), result, feedProperties);
+ odataResponse =
+ EntityProvider.writeFunctionImport(contentType, resultsView.getFunctionImport(), result, feedProperties);
odataResponse = ODataResponse.fromResponse(odataResponse).status(HttpStatusCodes.OK).build();
} catch (EdmException e) {
@@ -318,7 +343,9 @@ public final class ODataJPAResponseBuilder {
}
/* Response for Read Entity Link */
- public static ODataResponse build(final Object jpaEntity, final GetEntityLinkUriInfo resultsView, final String contentType, final ODataJPAContext oDataJPAContext) throws ODataNotFoundException, ODataJPARuntimeException {
+ public static ODataResponse build(final Object jpaEntity, final GetEntityLinkUriInfo resultsView,
+ final String contentType, final ODataJPAContext oDataJPAContext) throws ODataNotFoundException,
+ ODataJPARuntimeException {
if (jpaEntity == null) {
throw new ODataNotFoundException(ODataNotFoundException.ENTITY);
@@ -335,7 +362,9 @@ public final class ODataJPAResponseBuilder {
JPAEntityParser jpaResultParser = new JPAEntityParser();
edmPropertyValueMap = jpaResultParser.parse2EdmPropertyValueMap(jpaEntity, edmEntityType.getKeyProperties());
- EntityProviderWriteProperties entryProperties = EntityProviderWriteProperties.serviceRoot(oDataJPAContext.getODataContext().getPathInfo().getServiceRoot()).build();
+ EntityProviderWriteProperties entryProperties =
+ EntityProviderWriteProperties.serviceRoot(oDataJPAContext.getODataContext().getPathInfo().getServiceRoot())
+ .build();
ODataResponse response = EntityProvider.writeLink(contentType, entitySet, edmPropertyValueMap, entryProperties);
@@ -350,7 +379,8 @@ public final class ODataJPAResponseBuilder {
}
/* Response for Read Entity Links */
- public static <T> ODataResponse build(final List<T> jpaEntities, final GetEntitySetLinksUriInfo resultsView, final String contentType, final ODataJPAContext oDataJPAContext) throws ODataJPARuntimeException {
+ public static <T> ODataResponse build(final List<T> jpaEntities, final GetEntitySetLinksUriInfo resultsView,
+ final String contentType, final ODataJPAContext oDataJPAContext) throws ODataJPARuntimeException {
EdmEntityType edmEntityType = null;
ODataResponse odataResponse = null;
@@ -381,7 +411,9 @@ public final class ODataJPAResponseBuilder {
}
ODataContext context = oDataJPAContext.getODataContext();
- EntityProviderWriteProperties entryProperties = EntityProviderWriteProperties.serviceRoot(context.getPathInfo().getServiceRoot()).inlineCountType(resultsView.getInlineCount()).inlineCount(count).build();
+ EntityProviderWriteProperties entryProperties =
+ EntityProviderWriteProperties.serviceRoot(context.getPathInfo().getServiceRoot()).inlineCountType(
+ resultsView.getInlineCount()).inlineCount(count).build();
odataResponse = EntityProvider.writeLinks(contentType, entitySet, edmEntityList, entryProperties);
@@ -396,15 +428,17 @@ public final class ODataJPAResponseBuilder {
}
/*
- * This method handles $inlinecount request. It also modifies the list of results in case of
+ * This method handles $inlinecount request. It also modifies the list of results in case of
* $inlinecount and $top/$skip combinations. Specific to LinksUriInfo. //TODO
*
* @param edmEntityList
- * @param resultsView
+ *
+ * @param resultsView
*
* @return
*/
- private static Integer getInlineCountForNonFilterQueryLinks(final List<Map<String, Object>> edmEntityList, final GetEntitySetLinksUriInfo resultsView) {
+ private static Integer getInlineCountForNonFilterQueryLinks(final List<Map<String, Object>> edmEntityList,
+ final GetEntitySetLinksUriInfo resultsView) {
// when $skip and/or $top is present with $inlinecount, first get the total count
Integer count = null;
if (resultsView.getInlineCount() == InlineCount.ALLPAGES) {
@@ -431,7 +465,9 @@ public final class ODataJPAResponseBuilder {
* Method to build the entity provider Property.Callbacks for $expand would
* be registered here
*/
- private static EntityProviderWriteProperties getEntityProviderProperties(final ODataJPAContext odataJPAContext, final GetEntitySetUriInfo resultsView, final List<Map<String, Object>> edmEntityList) throws ODataJPARuntimeException {
+ private static EntityProviderWriteProperties getEntityProviderProperties(final ODataJPAContext odataJPAContext,
+ final GetEntitySetUriInfo resultsView, final List<Map<String, Object>> edmEntityList)
+ throws ODataJPARuntimeException {
ODataEntityProviderPropertiesBuilder entityFeedPropertiesBuilder = null;
Integer count = null;
@@ -446,11 +482,14 @@ public final class ODataJPAResponseBuilder {
}
try {
- entityFeedPropertiesBuilder = EntityProviderWriteProperties.serviceRoot(odataJPAContext.getODataContext().getPathInfo().getServiceRoot());
+ entityFeedPropertiesBuilder =
+ EntityProviderWriteProperties.serviceRoot(odataJPAContext.getODataContext().getPathInfo().getServiceRoot());
entityFeedPropertiesBuilder.inlineCount(count);
entityFeedPropertiesBuilder.inlineCountType(resultsView.getInlineCount());
- ExpandSelectTreeNode expandSelectTree = UriParser.createExpandSelectTree(resultsView.getSelect(), resultsView.getExpand());
- entityFeedPropertiesBuilder.callbacks(JPAExpandCallBack.getCallbacks(odataJPAContext.getODataContext().getPathInfo().getServiceRoot(), expandSelectTree, resultsView.getExpand()));
+ ExpandSelectTreeNode expandSelectTree =
+ UriParser.createExpandSelectTree(resultsView.getSelect(), resultsView.getExpand());
+ entityFeedPropertiesBuilder.callbacks(JPAExpandCallBack.getCallbacks(odataJPAContext.getODataContext()
+ .getPathInfo().getServiceRoot(), expandSelectTree, resultsView.getExpand()));
entityFeedPropertiesBuilder.expandSelectTree(expandSelectTree);
} catch (ODataException e) {
@@ -461,11 +500,11 @@ public final class ODataJPAResponseBuilder {
}
/*
- * This method handles $inlinecount request. It also modifies the list of results in case of
+ * This method handles $inlinecount request. It also modifies the list of results in case of
* $inlinecount and $top/$skip combinations. Specific to Entity Set. //TODO
- *
*/
- private static Integer getInlineCountForNonFilterQueryEntitySet(final List<Map<String, Object>> edmEntityList, final GetEntitySetUriInfo resultsView) {
+ private static Integer getInlineCountForNonFilterQueryEntitySet(final List<Map<String, Object>> edmEntityList,
+ final GetEntitySetUriInfo resultsView) {
// when $skip and/or $top is present with $inlinecount, first get the total count
Integer count = null;
if (resultsView.getInlineCount() == InlineCount.ALLPAGES) {
@@ -488,14 +527,17 @@ public final class ODataJPAResponseBuilder {
return count;
}
- private static EntityProviderWriteProperties getEntityProviderProperties(final ODataJPAContext odataJPAContext, final GetEntityUriInfo resultsView) throws ODataJPARuntimeException {
+ private static EntityProviderWriteProperties getEntityProviderProperties(final ODataJPAContext odataJPAContext,
+ final GetEntityUriInfo resultsView) throws ODataJPARuntimeException {
ODataEntityProviderPropertiesBuilder entityFeedPropertiesBuilder = null;
ExpandSelectTreeNode expandSelectTree = null;
try {
- entityFeedPropertiesBuilder = EntityProviderWriteProperties.serviceRoot(odataJPAContext.getODataContext().getPathInfo().getServiceRoot());
+ entityFeedPropertiesBuilder =
+ EntityProviderWriteProperties.serviceRoot(odataJPAContext.getODataContext().getPathInfo().getServiceRoot());
expandSelectTree = UriParser.createExpandSelectTree(resultsView.getSelect(), resultsView.getExpand());
entityFeedPropertiesBuilder.expandSelectTree(expandSelectTree);
- entityFeedPropertiesBuilder.callbacks(JPAExpandCallBack.getCallbacks(odataJPAContext.getODataContext().getPathInfo().getServiceRoot(), expandSelectTree, resultsView.getExpand()));
+ entityFeedPropertiesBuilder.callbacks(JPAExpandCallBack.getCallbacks(odataJPAContext.getODataContext()
+ .getPathInfo().getServiceRoot(), expandSelectTree, resultsView.getExpand()));
} catch (ODataException e) {
throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.INNER_EXCEPTION, e);
}
@@ -503,14 +545,18 @@ public final class ODataJPAResponseBuilder {
return entityFeedPropertiesBuilder.build();
}
- private static EntityProviderWriteProperties getEntityProviderPropertiesforPost(final ODataJPAContext odataJPAContext, final PostUriInfo resultsView, final List<ArrayList<NavigationPropertySegment>> expandList) throws ODataJPARuntimeException {
+ private static EntityProviderWriteProperties getEntityProviderPropertiesforPost(
+ final ODataJPAContext odataJPAContext, final PostUriInfo resultsView,
+ final List<ArrayList<NavigationPropertySegment>> expandList) throws ODataJPARuntimeException {
ODataEntityProviderPropertiesBuilder entityFeedPropertiesBuilder = null;
ExpandSelectTreeNode expandSelectTree = null;
try {
- entityFeedPropertiesBuilder = EntityProviderWriteProperties.serviceRoot(odataJPAContext.getODataContext().getPathInfo().getServiceRoot());
+ entityFeedPropertiesBuilder =
+ EntityProviderWriteProperties.serviceRoot(odataJPAContext.getODataContext().getPathInfo().getServiceRoot());
expandSelectTree = UriParser.createExpandSelectTree(null, expandList);
entityFeedPropertiesBuilder.expandSelectTree(expandSelectTree);
- entityFeedPropertiesBuilder.callbacks(JPAExpandCallBack.getCallbacks(odataJPAContext.getODataContext().getPathInfo().getServiceRoot(), expandSelectTree, expandList));
+ entityFeedPropertiesBuilder.callbacks(JPAExpandCallBack.getCallbacks(odataJPAContext.getODataContext()
+ .getPathInfo().getServiceRoot(), expandSelectTree, expandList));
} catch (ODataException e) {
throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.INNER_EXCEPTION, e);
}
@@ -518,7 +564,8 @@ public final class ODataJPAResponseBuilder {
return entityFeedPropertiesBuilder.build();
}
- private static List<ArrayList<NavigationPropertySegment>> getExpandList(final Map<EdmNavigationProperty, EdmEntitySet> navPropEntitySetMap) {
+ private static List<ArrayList<NavigationPropertySegment>> getExpandList(
+ final Map<EdmNavigationProperty, EdmEntitySet> navPropEntitySetMap) {
List<ArrayList<NavigationPropertySegment>> expandList = new ArrayList<ArrayList<NavigationPropertySegment>>();
ArrayList<NavigationPropertySegment> navigationPropertySegmentList = new ArrayList<NavigationPropertySegment>();
for (Map.Entry<EdmNavigationProperty, EdmEntitySet> entry : navPropEntitySetMap.entrySet()) {
@@ -542,7 +589,8 @@ public final class ODataJPAResponseBuilder {
return expandList;
}
- private static List<EdmProperty> buildSelectItemList(final List<SelectItem> selectItems, final EdmEntityType entity) throws ODataJPARuntimeException {
+ private static List<EdmProperty> buildSelectItemList(final List<SelectItem> selectItems, final EdmEntityType entity)
+ throws ODataJPARuntimeException {
boolean flag = false;
List<EdmProperty> selectPropertyList = new ArrayList<EdmProperty>();
try {
@@ -568,7 +616,8 @@ public final class ODataJPAResponseBuilder {
return selectPropertyList;
}
- private static List<EdmNavigationProperty> constructListofNavProperty(final List<ArrayList<NavigationPropertySegment>> expandList) {
+ private static List<EdmNavigationProperty> constructListofNavProperty(
+ final List<ArrayList<NavigationPropertySegment>> expandList) {
List<EdmNavigationProperty> navigationPropertyList = new ArrayList<EdmNavigationProperty>();
for (ArrayList<NavigationPropertySegment> navpropSegment : expandList) {
navigationPropertyList.add(navpropSegment.get(0).getNavigationProperty());
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/02a598bd/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/access/data/JPAEntity.java
----------------------------------------------------------------------
diff --git a/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/access/data/JPAEntity.java b/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/access/data/JPAEntity.java
index 2e03fbd..7045cd5 100644
--- a/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/access/data/JPAEntity.java
+++ b/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/access/data/JPAEntity.java
@@ -1,20 +1,20 @@
/*******************************************************************************
* Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
******************************************************************************/
package org.apache.olingo.odata2.processor.core.jpa.access.data;
@@ -71,7 +71,8 @@ public class JPAEntity {
}
@SuppressWarnings("unchecked")
- private void write(final Map<String, Object> oDataEntryProperties, final boolean isCreate) throws ODataJPARuntimeException {
+ private void write(final Map<String, Object> oDataEntryProperties, final boolean isCreate)
+ throws ODataJPARuntimeException {
try {
EdmStructuralType structuralType = null;
@@ -85,7 +86,8 @@ public class JPAEntity {
}
if (accessModifiersWrite == null) {
- accessModifiersWrite = jpaEntityParser.getAccessModifiers(jpaEntity, oDataEntityType, JPAEntityParser.ACCESS_MODIFIER_SET);
+ accessModifiersWrite =
+ jpaEntityParser.getAccessModifiers(jpaEntity, oDataEntityType, JPAEntityParser.ACCESS_MODIFIER_SET);
}
if (oDataEntityType == null || oDataEntryProperties == null) {
@@ -93,10 +95,10 @@ public class JPAEntity {
.throwException(ODataJPARuntimeException.GENERAL, null);
}
- final HashMap<String, String> embeddableKeys = jpaEntityParser.getJPAEmbeddableKeyMap(jpaEntity.getClass().getName());
+ final HashMap<String, String> embeddableKeys =
+ jpaEntityParser.getJPAEmbeddableKeyMap(jpaEntity.getClass().getName());
Set<String> propertyNames = null;
- if (embeddableKeys != null)
- {
+ if (embeddableKeys != null) {
setEmbeddableKeyProperty(embeddableKeys, oDataEntityType.getKeyProperties(), oDataEntryProperties, jpaEntity);
propertyNames = new HashSet<String>();
propertyNames.addAll(oDataEntryProperties.keySet());
@@ -132,7 +134,9 @@ public class JPAEntity {
case NAVIGATION:
case ENTITY:
structuralType = (EdmStructuralType) edmTyped.getType();
- accessModifier = jpaEntityParser.getAccessModifier(jpaEntity, (EdmNavigationProperty) edmTyped, JPAEntityParser.ACCESS_MODIFIER_SET);
+ accessModifier =
+ jpaEntityParser.getAccessModifier(jpaEntity, (EdmNavigationProperty) edmTyped,
+ JPAEntityParser.ACCESS_MODIFIER_SET);
EdmEntitySet edmRelatedEntitySet = oDataEntitySet.getRelatedEntitySet((EdmNavigationProperty) edmTyped);
List<ODataEntry> relatedEntries = (List<ODataEntry>) oDataEntryProperties.get(propertyName);
List<Object> relatedJPAEntites = new ArrayList<Object>();
@@ -222,21 +226,25 @@ public class JPAEntity {
}
@SuppressWarnings("unchecked")
- protected void setComplexProperty(Method accessModifier, final Object jpaEntity, final EdmStructuralType edmComplexType, final HashMap<String, Object> propertyValue)
- throws EdmException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, InstantiationException, ODataJPARuntimeException {
+ protected void setComplexProperty(Method accessModifier, final Object jpaEntity,
+ final EdmStructuralType edmComplexType, final HashMap<String, Object> propertyValue)
+ throws EdmException, IllegalAccessException, IllegalArgumentException, InvocationTargetException,
+ InstantiationException, ODataJPARuntimeException {
JPAEdmMapping mapping = (JPAEdmMapping) edmComplexType.getMapping();
Object embeddableObject = mapping.getJPAType().newInstance();
accessModifier.invoke(jpaEntity, embeddableObject);
- HashMap<String, Method> accessModifiers = jpaEntityParser.getAccessModifiers(embeddableObject, edmComplexType, JPAEntityParser.ACCESS_MODIFIER_SET);
+ HashMap<String, Method> accessModifiers =
+ jpaEntityParser.getAccessModifiers(embeddableObject, edmComplexType, JPAEntityParser.ACCESS_MODIFIER_SET);
for (String edmPropertyName : edmComplexType.getPropertyNames()) {
EdmTyped edmTyped = (EdmTyped) edmComplexType.getProperty(edmPropertyName);
accessModifier = accessModifiers.get(edmPropertyName);
if (edmTyped.getType().getKind().toString().equals(EdmTypeKind.COMPLEX.toString())) {
EdmStructuralType structualType = (EdmStructuralType) edmTyped.getType();
- setComplexProperty(accessModifier, embeddableObject, structualType, (HashMap<String, Object>) propertyValue.get(edmPropertyName));
+ setComplexProperty(accessModifier, embeddableObject, structualType, (HashMap<String, Object>) propertyValue
+ .get(edmPropertyName));
} else {
setProperty(accessModifier, embeddableObject, propertyValue.get(edmPropertyName));
}
@@ -247,39 +255,35 @@ public class JPAEntity {
IllegalAccessException, IllegalArgumentException, InvocationTargetException {
if (entityPropertyValue != null) {
Class<?> parameterType = method.getParameterTypes()[0];
- if (parameterType.equals(char[].class))
- {
+ if (parameterType.equals(char[].class)) {
char[] characters = ((String) entityPropertyValue).toCharArray();
method.invoke(entity, characters);
- }
- else if (parameterType.equals(char.class)) {
+ } else if (parameterType.equals(char.class)) {
char c = ((String) entityPropertyValue).charAt(0);
method.invoke(entity, c);
- }
- else if (parameterType.equals(Character[].class))
- {
+ } else if (parameterType.equals(Character[].class)) {
Character[] characters = JPAEntityParser.toCharacterArray((String) entityPropertyValue);
method.invoke(entity, (Object) characters);
- }
- else if (parameterType.equals(Character.class)) {
+ } else if (parameterType.equals(Character.class)) {
Character c = Character.valueOf(((String) entityPropertyValue).charAt(0));
method.invoke(entity, c);
- }
- else
+ } else {
method.invoke(entity, entityPropertyValue);
+ }
}
}
- protected void setEmbeddableKeyProperty(final HashMap<String, String> embeddableKeys, final List<EdmProperty> oDataEntryKeyProperties,
+ protected void setEmbeddableKeyProperty(final HashMap<String, String> embeddableKeys,
+ final List<EdmProperty> oDataEntryKeyProperties,
final Map<String, Object> oDataEntryProperties, final Object entity)
- throws ODataJPARuntimeException, EdmException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, InstantiationException {
+ throws ODataJPARuntimeException, EdmException, IllegalAccessException, IllegalArgumentException,
+ InvocationTargetException, InstantiationException {
HashMap<String, Object> embeddableObjMap = new HashMap<String, Object>();
List<EdmProperty> leftODataEntryKeyProperties = new ArrayList<EdmProperty>();
HashMap<String, String> leftEmbeddableKeys = new HashMap<String, String>();
- for (EdmProperty edmProperty : oDataEntryKeyProperties)
- {
+ for (EdmProperty edmProperty : oDataEntryKeyProperties) {
if (oDataEntryProperties.containsKey(edmProperty.getName()) == false) {
continue;
}
@@ -306,11 +310,10 @@ public class JPAEntity {
method = jpaEntityParser.getAccessModifierSet(embeddableObj, methodPartName);
Object simpleObj = oDataEntryProperties.get(edmProperty.getName());
method.invoke(embeddableObj, simpleObj);
- }
- else if (embeddableKeyNameSplit.length > 2) // Deeply nested
- {
+ } else if (embeddableKeyNameSplit.length > 2) { // Deeply nested
leftODataEntryKeyProperties.add(edmProperty);
- leftEmbeddableKeys.put(edmPropertyName, embeddableKeyNameComposite.split(embeddableKeyNameSplit[0] + ".", 2)[1]);
+ leftEmbeddableKeys
+ .put(edmPropertyName, embeddableKeyNameComposite.split(embeddableKeyNameSplit[0] + ".", 2)[1]);
setEmbeddableKeyProperty(leftEmbeddableKeys, leftODataEntryKeyProperties, oDataEntryProperties, embeddableObj);
}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/02a598bd/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/access/data/JPAEntityParser.java
----------------------------------------------------------------------
diff --git a/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/access/data/JPAEntityParser.java b/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/access/data/JPAEntityParser.java
index f424fa2..fad4b9b 100644
--- a/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/access/data/JPAEntityParser.java
+++ b/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/access/data/JPAEntityParser.java
@@ -1,20 +1,20 @@
/*******************************************************************************
* Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
******************************************************************************/
package org.apache.olingo.odata2.processor.core.jpa.access.data;
@@ -66,7 +66,7 @@ public final class JPAEntityParser {
* @param jpaEntity
* @param selectedItems
* @return a Hash Map of Properties and values for given selected properties
- * of an EdmEntity Type
+ * of an EdmEntity Type
* @throws ODataJPARuntimeException
*/
@@ -306,31 +306,31 @@ public final class JPAEntityParser {
return accessModifierMap;
}
- public static Object getProperty(Method method, Object entity) throws ODataJPARuntimeException {
+ public static Object getProperty(final Method method, final Object entity) throws ODataJPARuntimeException {
Object propertyValue = null;
try {
Class<?> returnType = method.getReturnType();
- if (returnType.equals(char[].class))
- {
+ if (returnType.equals(char[].class)) {
char[] ch = (char[]) method.invoke(entity);
- if (ch != null)
+ if (ch != null) {
propertyValue = (String) String.valueOf((char[]) method.invoke(entity));
- }
- else if (returnType.equals(Character[].class))
+ }
+ } else if (returnType.equals(Character[].class)) {
propertyValue = (String) toString((Character[]) method.invoke(entity));
- else if (returnType.equals(char.class)) {
+ } else if (returnType.equals(char.class)) {
char c = (Character) method.invoke(entity);
- if (c != '\u0000')
+ if (c != '\u0000') {
propertyValue = (String) String.valueOf(c);
- }
- else if (returnType.equals(Character.class)) {
+ }
+ } else if (returnType.equals(Character.class)) {
Character c = (Character) method.invoke(entity);
- if (c != null)
+ if (c != null) {
propertyValue = toString(new Character[] { c });
- }
- else
+ }
+ } else {
propertyValue = method.invoke(entity);
+ }
} catch (IllegalAccessException e) {
throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.INNER_EXCEPTION, e);
} catch (IllegalArgumentException e) {
@@ -341,30 +341,38 @@ public final class JPAEntityParser {
return propertyValue;
}
- public static String toString(Character[] input) {
- if (input == null) return null;
+ public static String toString(final Character[] input) {
+ if (input == null) {
+ return null;
+ }
StringBuilder builder = new StringBuilder();
- for (int i = 0; i < input.length; i++) {
- if (input[i] == null) continue;
- builder.append(input[i].charValue());
+ for (Character element : input) {
+ if (element == null) {
+ continue;
+ }
+ builder.append(element.charValue());
}
return builder.toString();
}
- public static Character[] toCharacterArray(String input) {
- if (input == null) return null;
+ public static Character[] toCharacterArray(final String input) {
+ if (input == null) {
+ return null;
+ }
Character[] characters = new Character[input.length()];
char[] chars = ((String) input).toCharArray();
- for (int i = 0; i < input.length(); i++)
+ for (int i = 0; i < input.length(); i++) {
characters[i] = new Character(chars[i]);
+ }
return characters;
}
- public static String getAccessModifierName(final String propertyName, final EdmMapping mapping, final String accessModifier)
+ public static String getAccessModifierName(final String propertyName, final EdmMapping mapping,
+ final String accessModifier)
throws ODataJPARuntimeException {
String name = null;
StringBuilder builder = new StringBuilder();
@@ -408,7 +416,8 @@ public final class JPAEntityParser {
}
- public Method getAccessModifier(final Object jpaEntity, final EdmNavigationProperty navigationProperty, final String accessModifier)
+ public Method getAccessModifier(final Object jpaEntity, final EdmNavigationProperty navigationProperty,
+ final String accessModifier)
throws ODataJPARuntimeException {
try {