You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@olingo.apache.org by sk...@apache.org on 2013/07/31 10:13:06 UTC
[21/22] eliminate checkstyle warnings
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1e5280b7/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 78e2e7d..69abe74 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
@@ -66,9 +66,7 @@ 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;
@@ -82,17 +80,12 @@ 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 {
for (Object jpaEntity : jpaEntities) {
- edmPropertyValueMap = jpaResultParser
- .parse2EdmPropertyValueMap(jpaEntity, edmEntityType);
+ edmPropertyValueMap = jpaResultParser.parse2EdmPropertyValueMap(jpaEntity, edmEntityType);
edmEntityList.add(edmPropertyValueMap);
}
}
@@ -101,8 +94,7 @@ 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++;
}
@@ -110,32 +102,21 @@ public final class ODataJPAResponseBuilder {
EntityProviderWriteProperties feedProperties = null;
- feedProperties = getEntityProviderProperties(odataJPAContext,
- resultsView, edmEntityList);
- odataResponse = EntityProvider.writeFeed(contentType,
- resultsView.getTargetEntitySet(), edmEntityList,
- feedProperties);
- odataResponse = ODataResponse.fromResponse(odataResponse)
- .status(HttpStatusCodes.OK).build();
+ feedProperties = getEntityProviderProperties(odataJPAContext, resultsView, edmEntityList);
+ odataResponse = EntityProvider.writeFeed(contentType, resultsView.getTargetEntitySet(), edmEntityList, feedProperties);
+ odataResponse = ODataResponse.fromResponse(odataResponse).status(HttpStatusCodes.OK).build();
} catch (EntityProviderException e) {
- throw ODataJPARuntimeException
- .throwException(ODataJPARuntimeException.GENERAL
- .addContent(e.getMessage()), e);
+ throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e);
} catch (EdmException e) {
- throw ODataJPARuntimeException
- .throwException(ODataJPARuntimeException.GENERAL
- .addContent(e.getMessage()), e);
+ throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e);
}
return odataResponse;
}
/* Response for Read Entity */
- public static ODataResponse build(final Object jpaEntity,
- final GetEntityUriInfo resultsView, final String contentType,
- final ODataJPAContext oDataJPAContext) throws ODataJPARuntimeException,
- ODataNotFoundException {
+ 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) {
@@ -152,69 +133,47 @@ public final class ODataJPAResponseBuilder {
JPAEntityParser jpaResultParser = JPAEntityParser.create();
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);
+ edmPropertyValueMap = jpaResultParser.parse2EdmPropertyValueMap(jpaEntity, edmEntityType);
}
expandList = resultsView.getExpand();
- if (expandList != null && expandList.size() != 0)
- {
- HashMap<String, Object> navigationMap = jpaResultParser.parse2EdmNavigationValueMap(
- jpaEntity, constructListofNavProperty(expandList));
+ if (expandList != null && expandList.size() != 0) {
+ HashMap<String, Object> navigationMap = jpaResultParser.parse2EdmNavigationValueMap(jpaEntity, constructListofNavProperty(expandList));
edmPropertyValueMap.putAll(navigationMap);
}
EntityProviderWriteProperties feedProperties = null;
- feedProperties = getEntityProviderProperties(oDataJPAContext,
- resultsView);
- odataResponse = EntityProvider.writeEntry(contentType,
- resultsView.getTargetEntitySet(), edmPropertyValueMap,
- feedProperties);
+ feedProperties = getEntityProviderProperties(oDataJPAContext, resultsView);
+ odataResponse = EntityProvider.writeEntry(contentType, resultsView.getTargetEntitySet(), edmPropertyValueMap, feedProperties);
- odataResponse = ODataResponse.fromResponse(odataResponse)
- .status(HttpStatusCodes.OK).build();
+ odataResponse = ODataResponse.fromResponse(odataResponse).status(HttpStatusCodes.OK).build();
} catch (EntityProviderException e) {
- throw ODataJPARuntimeException
- .throwException(ODataJPARuntimeException.GENERAL
- .addContent(e.getMessage()), e);
+ throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e);
} catch (EdmException e) {
- throw ODataJPARuntimeException
- .throwException(ODataJPARuntimeException.GENERAL
- .addContent(e.getMessage()), e);
+ throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e);
}
return odataResponse;
}
/* Response for $count */
- public static ODataResponse build(final long jpaEntityCount,
- final ODataJPAContext oDataJPAContext) throws ODataJPARuntimeException {
+ public static ODataResponse build(final long jpaEntityCount, final ODataJPAContext oDataJPAContext) throws ODataJPARuntimeException {
ODataResponse odataResponse = null;
try {
- odataResponse = EntityProvider.writeText(String
- .valueOf(jpaEntityCount));
+ odataResponse = EntityProvider.writeText(String.valueOf(jpaEntityCount));
odataResponse = ODataResponse.fromResponse(odataResponse).build();
} catch (EntityProviderException e) {
- throw ODataJPARuntimeException
- .throwException(ODataJPARuntimeException.GENERAL
- .addContent(e.getMessage()), e);
+ throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e);
}
return odataResponse;
}
/* Response for Create Entity */
@SuppressWarnings("unchecked")
- public static ODataResponse build(final List<Object> createdObjectList,
- final PostUriInfo uriInfo, final String contentType,
- final ODataJPAContext oDataJPAContext) throws ODataJPARuntimeException,
- ODataNotFoundException {
+ 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);
@@ -229,48 +188,36 @@ public final class ODataJPAResponseBuilder {
Map<String, Object> edmPropertyValueMap = null;
JPAEntityParser jpaResultParser = JPAEntityParser.create();
- edmPropertyValueMap = jpaResultParser.parse2EdmPropertyValueMap(
- createdObjectList.get(0), edmEntityType);
+ edmPropertyValueMap = jpaResultParser.parse2EdmPropertyValueMap(createdObjectList.get(0), edmEntityType);
List<ArrayList<NavigationPropertySegment>> expandList = null;
if (createdObjectList.get(1) != null && ((Map<EdmNavigationProperty, EdmEntitySet>) createdObjectList.get(1)).size() > 0) {
expandList = getExpandList((Map<EdmNavigationProperty, EdmEntitySet>) createdObjectList.get(1));
- HashMap<String, Object> navigationMap = jpaResultParser.parse2EdmNavigationValueMap(
- createdObjectList.get(0), constructListofNavProperty(expandList));
+ HashMap<String, Object> navigationMap = jpaResultParser.parse2EdmNavigationValueMap(createdObjectList.get(0), constructListofNavProperty(expandList));
edmPropertyValueMap.putAll(navigationMap);
}
EntityProviderWriteProperties feedProperties = null;
try {
feedProperties = getEntityProviderPropertiesforPost(oDataJPAContext, uriInfo, expandList);
} catch (ODataException e) {
- throw ODataJPARuntimeException.throwException(
- ODataJPARuntimeException.INNER_EXCEPTION, e);
+ 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();
+ odataResponse = ODataResponse.fromResponse(odataResponse).status(HttpStatusCodes.CREATED).build();
} catch (EntityProviderException e) {
- throw ODataJPARuntimeException
- .throwException(ODataJPARuntimeException.GENERAL
- .addContent(e.getMessage()), e);
+ throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e);
} catch (EdmException e) {
- throw ODataJPARuntimeException
- .throwException(ODataJPARuntimeException.GENERAL
- .addContent(e.getMessage()), e);
+ throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e);
}
return odataResponse;
}
/* Response for Update Entity */
- public static ODataResponse build(final Object updatedObject,
- final PutMergePatchUriInfo putUriInfo) throws ODataJPARuntimeException,
- ODataNotFoundException {
+ public static ODataResponse build(final Object updatedObject, final PutMergePatchUriInfo putUriInfo) throws ODataJPARuntimeException, ODataNotFoundException {
if (updatedObject == null) {
throw new ODataNotFoundException(ODataNotFoundException.ENTITY);
}
@@ -278,9 +225,7 @@ 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);
@@ -289,21 +234,16 @@ 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();
- final EdmSimpleType type = (EdmSimpleType) functionImport
- .getReturnType().getType();
+ final EdmFunctionImport functionImport = resultsView.getFunctionImport();
+ final EdmSimpleType type = (EdmSimpleType) functionImport.getReturnType().getType();
if (result != null) {
ODataResponse response = null;
- final String value = type.valueToString(result,
- EdmLiteralKind.DEFAULT, null);
+ final String value = type.valueToString(result, EdmLiteralKind.DEFAULT, null);
response = EntityProvider.writeText(value);
return ODataResponse.fromResponse(response).build();
@@ -311,24 +251,16 @@ public final class ODataJPAResponseBuilder {
throw new ODataNotFoundException(ODataHttpException.COMMON);
}
} catch (EdmException e) {
- throw ODataJPARuntimeException
- .throwException(ODataJPARuntimeException.GENERAL
- .addContent(e.getMessage()), e);
+ throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e);
} catch (EntityProviderException e) {
- throw ODataJPARuntimeException
- .throwException(ODataJPARuntimeException.GENERAL
- .addContent(e.getMessage()), e);
+ throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e);
} catch (ODataException e) {
- throw ODataJPARuntimeException.throwException(
- ODataJPARuntimeException.INNER_EXCEPTION, e);
+ throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.INNER_EXCEPTION, e);
}
}
/* Response for Function Import Multiple Result */
- public static ODataResponse build(final List<Object> resultList,
- final GetFunctionImportUriInfo resultsView, final String contentType,
- final ODataJPAContext oDataJPAContext) throws ODataJPARuntimeException,
- ODataNotFoundException {
+ public static ODataResponse build(final List<Object> resultList, final GetFunctionImportUriInfo resultsView, final String contentType, final ODataJPAContext oDataJPAContext) throws ODataJPARuntimeException, ODataNotFoundException {
ODataResponse odataResponse = null;
@@ -342,31 +274,23 @@ 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();
- if (edmType.getKind().equals(EdmTypeKind.ENTITY)
- || edmType.getKind().equals(EdmTypeKind.COMPLEX)) {
- if (functionImport.getReturnType().getMultiplicity()
- .equals(EdmMultiplicity.MANY)) {
+ if (edmType.getKind().equals(EdmTypeKind.ENTITY) || edmType.getKind().equals(EdmTypeKind.COMPLEX)) {
+ if (functionImport.getReturnType().getMultiplicity().equals(EdmMultiplicity.MANY)) {
edmEntityList = new ArrayList<Map<String, Object>>();
for (Object jpaEntity : resultList) {
- edmPropertyValueMap = jpaResultParser
- .parse2EdmPropertyValueMap(jpaEntity,
- (EdmStructuralType) edmType);
+ edmPropertyValueMap = jpaResultParser.parse2EdmPropertyValueMap(jpaEntity, (EdmStructuralType) edmType);
edmEntityList.add(edmPropertyValueMap);
}
result = edmEntityList;
} else {
Object resultObject = resultList.get(0);
- edmPropertyValueMap = jpaResultParser
- .parse2EdmPropertyValueMap(resultObject,
- (EdmStructuralType) edmType);
+ edmPropertyValueMap = jpaResultParser.parse2EdmPropertyValueMap(resultObject, (EdmStructuralType) edmType);
result = edmPropertyValueMap;
}
@@ -375,24 +299,15 @@ public final class ODataJPAResponseBuilder {
result = resultList.get(0);
}
- odataResponse = EntityProvider
- .writeFunctionImport(contentType,
- resultsView.getFunctionImport(), result,
- feedProperties);
- odataResponse = ODataResponse.fromResponse(odataResponse)
- .status(HttpStatusCodes.OK).build();
+ odataResponse = EntityProvider.writeFunctionImport(contentType, resultsView.getFunctionImport(), result, feedProperties);
+ odataResponse = ODataResponse.fromResponse(odataResponse).status(HttpStatusCodes.OK).build();
} catch (EdmException e) {
- throw ODataJPARuntimeException.throwException(
- ODataJPARuntimeException.GENERAL.addContent(e
- .getMessage()), e);
+ throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e);
} catch (EntityProviderException e) {
- throw ODataJPARuntimeException.throwException(
- ODataJPARuntimeException.GENERAL.addContent(e
- .getMessage()), e);
+ throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e);
} catch (ODataException e) {
- throw ODataJPARuntimeException.throwException(
- ODataJPARuntimeException.INNER_EXCEPTION, e);
+ throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.INNER_EXCEPTION, e);
}
} else {
@@ -403,9 +318,7 @@ 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);
@@ -420,22 +333,16 @@ public final class ODataJPAResponseBuilder {
Map<String, Object> edmPropertyValueMap = null;
JPAEntityParser jpaResultParser = JPAEntityParser.create();
- edmPropertyValueMap = jpaResultParser
- .parse2EdmPropertyValueMap(
- jpaEntity,
- edmEntityType.getKeyProperties());
+ 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);
odataResponse = ODataResponse.fromResponse(response).build();
} catch (ODataException e) {
- throw ODataJPARuntimeException.throwException(
- ODataJPARuntimeException.INNER_EXCEPTION, e);
+ throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.INNER_EXCEPTION, e);
}
@@ -443,10 +350,7 @@ 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;
@@ -461,10 +365,7 @@ public final class ODataJPAResponseBuilder {
JPAEntityParser jpaResultParser = JPAEntityParser.create();
for (Object jpaEntity : jpaEntities) {
- edmPropertyValueMap = jpaResultParser
- .parse2EdmPropertyValueMap(
- jpaEntity,
- keyProperties);
+ edmPropertyValueMap = jpaResultParser.parse2EdmPropertyValueMap(jpaEntity, keyProperties);
edmEntityList.add(edmPropertyValueMap);
}
@@ -475,26 +376,19 @@ public final class ODataJPAResponseBuilder {
count = getInlineCountForNonFilterQueryLinks(edmEntityList, resultsView);
} else {
// In all other cases
- count = resultsView.getInlineCount() == InlineCount.ALLPAGES ? edmEntityList
- .size() : null;
+ count = resultsView.getInlineCount() == InlineCount.ALLPAGES ? edmEntityList.size() : null;
}
}
ODataContext context = oDataJPAContext.getODataContext();
- EntityProviderWriteProperties entryProperties = EntityProviderWriteProperties
- .serviceRoot(context.getPathInfo().getServiceRoot())
- .inlineCountType(resultsView.getInlineCount())
- .inlineCount(count)
- .build();
+ EntityProviderWriteProperties entryProperties = EntityProviderWriteProperties.serviceRoot(context.getPathInfo().getServiceRoot()).inlineCountType(resultsView.getInlineCount()).inlineCount(count).build();
odataResponse = EntityProvider.writeLinks(contentType, entitySet, edmEntityList, entryProperties);
odataResponse = ODataResponse.fromResponse(odataResponse).build();
} catch (ODataException e) {
- throw ODataJPARuntimeException
- .throwException(ODataJPARuntimeException.GENERAL
- .addContent(e.getMessage()), e);
+ throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e);
}
return odataResponse;
@@ -537,10 +431,7 @@ 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;
@@ -550,30 +441,20 @@ public final class ODataJPAResponseBuilder {
count = getInlineCountForNonFilterQueryEntitySet(edmEntityList, resultsView);
} else {
// In all other cases
- count = resultsView.getInlineCount() == InlineCount.ALLPAGES ? edmEntityList
- .size() : null;
+ count = resultsView.getInlineCount() == InlineCount.ALLPAGES ? edmEntityList.size() : null;
}
}
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()));
+ entityFeedPropertiesBuilder.inlineCountType(resultsView.getInlineCount());
+ ExpandSelectTreeNode expandSelectTree = UriParser.createExpandSelectTree(resultsView.getSelect(), resultsView.getExpand());
+ entityFeedPropertiesBuilder.callbacks(JPAExpandCallBack.getCallbacks(odataJPAContext.getODataContext().getPathInfo().getServiceRoot(), expandSelectTree, resultsView.getExpand()));
entityFeedPropertiesBuilder.expandSelectTree(expandSelectTree);
} catch (ODataException e) {
- throw ODataJPARuntimeException.throwException(
- ODataJPARuntimeException.INNER_EXCEPTION, e);
+ throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.INNER_EXCEPTION, e);
}
return entityFeedPropertiesBuilder.build();
@@ -607,49 +488,31 @@ 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());
- expandSelectTree = UriParser.createExpandSelectTree(
- resultsView.getSelect(), resultsView.getExpand());
+ 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);
+ throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.INNER_EXCEPTION, e);
}
return entityFeedPropertiesBuilder.build();
}
- private static EntityProviderWriteProperties getEntityProviderPropertiesforPost(
- final ODataJPAContext odataJPAContext, final PostUriInfo resultsView, final List<ArrayList<NavigationPropertySegment>> expandList)
- throws ODataJPARuntimeException {
+ private static EntityProviderWriteProperties getEntityProviderPropertiesforPost(final ODataJPAContext odataJPAContext, final PostUriInfo resultsView, final List<ArrayList<NavigationPropertySegment>> expandList) throws ODataJPARuntimeException {
ODataEntityProviderPropertiesBuilder entityFeedPropertiesBuilder = null;
ExpandSelectTreeNode expandSelectTree = null;
try {
- entityFeedPropertiesBuilder = EntityProviderWriteProperties
- .serviceRoot(odataJPAContext.getODataContext()
- .getPathInfo().getServiceRoot());
- expandSelectTree = UriParser.createExpandSelectTree(
- null, expandList);
+ entityFeedPropertiesBuilder = 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);
+ throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.INNER_EXCEPTION, e);
}
return entityFeedPropertiesBuilder.build();
@@ -679,8 +542,7 @@ 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 {
@@ -701,19 +563,15 @@ public final class ODataJPAResponseBuilder {
}
} catch (EdmException e) {
- throw ODataJPARuntimeException
- .throwException(ODataJPARuntimeException.GENERAL
- .addContent(e.getMessage()), e);
+ throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e);
}
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());
+ navigationPropertyList.add(navpropSegment.get(0).getNavigationProperty());
}
return navigationPropertyList;
}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1e5280b7/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 72e81fa..532561e 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
@@ -48,8 +48,7 @@ public final class JPAEntityParser {
private static JPAEntityParser jpaEntityParser;
private JPAEntityParser() {
- jpaEntityAccessMap = new HashMap<String, HashMap<String, Method>>(
- MAX_SIZE);
+ jpaEntityAccessMap = new HashMap<String, HashMap<String, Method>>(MAX_SIZE);
jpaEmbeddableKeyMap = new HashMap<String, HashMap<String, String>>();
};
@@ -71,9 +70,7 @@ public final class JPAEntityParser {
* @throws ODataJPARuntimeException
*/
- public final HashMap<String, Object> parse2EdmPropertyValueMap(
- final Object jpaEntity, final List<EdmProperty> selectPropertyList)
- throws ODataJPARuntimeException {
+ public final HashMap<String, Object> parse2EdmPropertyValueMap(final Object jpaEntity, final List<EdmProperty> selectPropertyList) throws ODataJPARuntimeException {
HashMap<String, Object> edmEntity = new HashMap<String, Object>();
String methodName = null;
Method method = null;
@@ -84,31 +81,25 @@ public final class JPAEntityParser {
property = selectPropertyList.get(i);
try {
- methodName = getAccessModifierName(property.getName(),
- property.getMapping(), ACCESS_MODIFIER_GET);
+ methodName = getAccessModifierName(property.getName(), property.getMapping(), ACCESS_MODIFIER_GET);
String[] nameParts = methodName.split("\\.");
if (nameParts.length > 1) {
Object propertyVal = new Object();
propertyVal = jpaEntity;
for (String namePart : nameParts) {
- method = propertyVal.getClass().getMethod(
- namePart, (Class<?>[]) null);
+ method = propertyVal.getClass().getMethod(namePart, (Class<?>[]) null);
method.setAccessible(true);
propertyVal = method.invoke(propertyVal);
}
edmEntity.put(property.getName(), propertyVal);
} else {
- method = jpaEntity.getClass().getMethod(methodName,
- (Class<?>[]) null);
+ method = jpaEntity.getClass().getMethod(methodName, (Class<?>[]) null);
method.setAccessible(true);
propertyValue = method.invoke(jpaEntity);
key = property.getName();
- if (property.getType().getKind()
- .equals(EdmTypeKind.COMPLEX)) {
+ if (property.getType().getKind().equals(EdmTypeKind.COMPLEX)) {
try {
- propertyValue = parse2EdmPropertyValueMap(
- propertyValue,
- (EdmStructuralType) property.getType());
+ propertyValue = parse2EdmPropertyValueMap(propertyValue, (EdmStructuralType) property.getType());
} catch (ODataJPARuntimeException e) {
throw e;
}
@@ -116,29 +107,17 @@ public final class JPAEntityParser {
edmEntity.put(key, propertyValue);
}
} catch (EdmException e) {
- throw ODataJPARuntimeException.throwException(
- ODataJPARuntimeException.GENERAL.addContent(e
- .getMessage()), e);
+ throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e);
} catch (SecurityException e) {
- throw ODataJPARuntimeException.throwException(
- ODataJPARuntimeException.GENERAL.addContent(e
- .getMessage()), e);
+ throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e);
} catch (NoSuchMethodException e) {
- throw ODataJPARuntimeException.throwException(
- ODataJPARuntimeException.GENERAL.addContent(e
- .getMessage()), e);
+ throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e);
} catch (IllegalArgumentException e) {
- throw ODataJPARuntimeException.throwException(
- ODataJPARuntimeException.GENERAL.addContent(e
- .getMessage()), e);
+ throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e);
} catch (IllegalAccessException e) {
- throw ODataJPARuntimeException.throwException(
- ODataJPARuntimeException.GENERAL.addContent(e
- .getMessage()), e);
+ throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e);
} catch (InvocationTargetException e) {
- throw ODataJPARuntimeException.throwException(
- ODataJPARuntimeException.GENERAL.addContent(e
- .getMessage()), e);
+ throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e);
}
}
@@ -156,9 +135,7 @@ public final class JPAEntityParser {
* @return a Hash Map of Properties and values for given EdmEntity Type
* @throws ODataJPARuntimeException
*/
- public final HashMap<String, Object> parse2EdmPropertyValueMap(
- final Object jpaEntity, final EdmStructuralType structuralType)
- throws ODataJPARuntimeException {
+ public final HashMap<String, Object> parse2EdmPropertyValueMap(final Object jpaEntity, final EdmStructuralType structuralType) throws ODataJPARuntimeException {
if (jpaEntity == null || structuralType == null) {
return null;
@@ -167,21 +144,17 @@ public final class JPAEntityParser {
String jpaEntityAccessKey = jpaEntity.getClass().getName();
if (!jpaEntityAccessMap.containsKey(jpaEntityAccessKey)) {
- jpaEntityAccessMap.put(jpaEntityAccessKey,
- getAccessModifier(jpaEntity, structuralType, ACCESS_MODIFIER_GET));
+ jpaEntityAccessMap.put(jpaEntityAccessKey, getAccessModifier(jpaEntity, structuralType, ACCESS_MODIFIER_GET));
}
HashMap<String, Object> edmEntity = new HashMap<String, Object>();
- HashMap<String, Method> getters = jpaEntityAccessMap
- .get(jpaEntityAccessKey);
- HashMap<String, String> embeddableKeys = jpaEmbeddableKeyMap
- .get(jpaEntityAccessKey);
+ HashMap<String, Method> getters = jpaEntityAccessMap.get(jpaEntityAccessKey);
+ HashMap<String, String> embeddableKeys = jpaEmbeddableKeyMap.get(jpaEntityAccessKey);
try {
for (String key : getters.keySet()) {
- EdmProperty property = (EdmProperty) structuralType
- .getProperty(key);
+ EdmProperty property = (EdmProperty) structuralType.getProperty(key);
Method method = getters.get(key);
Object propertyValue = null;
@@ -192,8 +165,7 @@ public final class JPAEntityParser {
}
if (property.getType().getKind().equals(EdmTypeKind.COMPLEX)) {
- propertyValue = parse2EdmPropertyValueMap(propertyValue,
- (EdmStructuralType) property.getType());
+ propertyValue = parse2EdmPropertyValueMap(propertyValue, (EdmStructuralType) property.getType());
}
edmEntity.put(key, propertyValue);
@@ -207,8 +179,7 @@ public final class JPAEntityParser {
Object propertyValue = jpaEntity;
Method method = null;
for (String namePart : nameParts) {
- method = propertyValue.getClass().getMethod(
- namePart, (Class<?>[]) null);
+ method = propertyValue.getClass().getMethod(namePart, (Class<?>[]) null);
method.setAccessible(true);
propertyValue = method.invoke(propertyValue);
}
@@ -216,129 +187,86 @@ public final class JPAEntityParser {
}
}
} catch (EdmException e) {
- throw ODataJPARuntimeException
- .throwException(ODataJPARuntimeException.GENERAL
- .addContent(e.getMessage()), e);
+ throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e);
} catch (SecurityException e) {
- throw ODataJPARuntimeException
- .throwException(ODataJPARuntimeException.GENERAL
- .addContent(e.getMessage()), e);
+ throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e);
} catch (NoSuchMethodException e) {
- throw ODataJPARuntimeException
- .throwException(ODataJPARuntimeException.GENERAL
- .addContent(e.getMessage()), e);
+ throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e);
} catch (IllegalArgumentException e) {
- throw ODataJPARuntimeException
- .throwException(ODataJPARuntimeException.GENERAL
- .addContent(e.getMessage()), e);
+ throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e);
} catch (IllegalAccessException e) {
- throw ODataJPARuntimeException
- .throwException(ODataJPARuntimeException.GENERAL
- .addContent(e.getMessage()), e);
+ throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e);
} catch (InvocationTargetException e) {
- throw ODataJPARuntimeException
- .throwException(ODataJPARuntimeException.GENERAL
- .addContent(e.getMessage()), e);
+ throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e);
}
return edmEntity;
}
// This method appends the associated entities as a java list to an expanded
// map of a source entity
- public final HashMap<String, Object> parse2EdmNavigationValueMap(
- final Object jpaEntity, final List<EdmNavigationProperty> navigationPropertyList)
- throws ODataJPARuntimeException {
+ public final HashMap<String, Object> parse2EdmNavigationValueMap(final Object jpaEntity, final List<EdmNavigationProperty> navigationPropertyList) throws ODataJPARuntimeException {
Object result = null;
String methodName = null;
HashMap<String, Object> navigationMap = new HashMap<String, Object>();
- if (navigationPropertyList != null
- && navigationPropertyList.size() != 0) {
+ if (navigationPropertyList != null && navigationPropertyList.size() != 0) {
try {
for (EdmNavigationProperty navigationProperty : navigationPropertyList) {
- methodName = getAccessModifierName(navigationProperty.getName(),
- navigationProperty.getMapping(), ACCESS_MODIFIER_GET);
- Method getterMethod = jpaEntity.getClass()
- .getDeclaredMethod(methodName, (Class<?>[]) null);
+ methodName = getAccessModifierName(navigationProperty.getName(), navigationProperty.getMapping(), ACCESS_MODIFIER_GET);
+ Method getterMethod = jpaEntity.getClass().getDeclaredMethod(methodName, (Class<?>[]) null);
getterMethod.setAccessible(true);
result = getterMethod.invoke(jpaEntity);
navigationMap.put(navigationProperty.getName(), result);
}
} catch (IllegalArgumentException e) {
- throw ODataJPARuntimeException.throwException(
- ODataJPARuntimeException.GENERAL.addContent(e
- .getMessage()), e);
+ throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e);
} catch (IllegalAccessException e) {
- throw ODataJPARuntimeException.throwException(
- ODataJPARuntimeException.GENERAL.addContent(e
- .getMessage()), e);
+ throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e);
} catch (InvocationTargetException e) {
- throw ODataJPARuntimeException.throwException(
- ODataJPARuntimeException.GENERAL.addContent(e
- .getMessage()), e);
+ throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e);
} catch (EdmException e) {
- throw ODataJPARuntimeException.throwException(
- ODataJPARuntimeException.GENERAL.addContent(e
- .getMessage()), e);
+ throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e);
} catch (SecurityException e) {
- throw ODataJPARuntimeException.throwException(
- ODataJPARuntimeException.GENERAL.addContent(e
- .getMessage()), e);
+ throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e);
} catch (NoSuchMethodException e) {
- throw ODataJPARuntimeException.throwException(
- ODataJPARuntimeException.GENERAL.addContent(e
- .getMessage()), e);
+ throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e);
}
}
return navigationMap;
}
- public HashMap<String, Method> getAccessModifier(final Object jpaEntity,
- final EdmStructuralType structuralType, final String accessModifier) throws ODataJPARuntimeException {
+ public HashMap<String, Method> getAccessModifier(final Object jpaEntity, final EdmStructuralType structuralType, final String accessModifier) throws ODataJPARuntimeException {
HashMap<String, Method> accessModifierMap = new HashMap<String, Method>();
HashMap<String, String> embeddableKey = new HashMap<String, String>();
try {
for (String propertyName : structuralType.getPropertyNames()) {
- EdmProperty property = (EdmProperty) structuralType
- .getProperty(propertyName);
+ EdmProperty property = (EdmProperty) structuralType.getProperty(propertyName);
- String name = getAccessModifierName(property.getName(),
- property.getMapping(), accessModifier);
+ String name = getAccessModifierName(property.getName(), property.getMapping(), accessModifier);
String[] nameParts = name.split("\\.");
if (nameParts.length > 1) {
embeddableKey.put(propertyName, name);
} else {
- accessModifierMap.put(
- propertyName,
- jpaEntity.getClass().getMethod(name,
- (Class<?>[]) null));
+ accessModifierMap.put(propertyName, jpaEntity.getClass().getMethod(name, (Class<?>[]) null));
}
}
} catch (NoSuchMethodException e) {
- throw ODataJPARuntimeException
- .throwException(ODataJPARuntimeException.GENERAL
- .addContent(e.getMessage()), e);
+ throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e);
} catch (SecurityException e) {
- throw ODataJPARuntimeException
- .throwException(ODataJPARuntimeException.GENERAL
- .addContent(e.getMessage()), e);
+ throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e);
} catch (EdmException e) {
- throw ODataJPARuntimeException
- .throwException(ODataJPARuntimeException.GENERAL
- .addContent(e.getMessage()), e);
+ throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e);
}
if (!embeddableKey.isEmpty()) {
- jpaEmbeddableKeyMap.put(jpaEntity.getClass().getName(),
- embeddableKey);
+ jpaEmbeddableKeyMap.put(jpaEntity.getClass().getName(), embeddableKey);
}
return accessModifierMap;
}
- private static String getAccessModifierName(final String propertyName, final EdmMapping mapping, final String accessModifier)
- throws ODataJPARuntimeException {
+ private static String getAccessModifierName(final String propertyName, final EdmMapping mapping, final String accessModifier) throws ODataJPARuntimeException {
String name = null;
StringBuilder builder = new StringBuilder();
String[] nameParts = {};
@@ -354,8 +282,7 @@ public final class JPAEntityParser {
if (name != null) {
char c = Character.toUpperCase(name.charAt(0));
- builder.append(accessModifier).append(c).append(name.substring(1))
- .toString();
+ builder.append(accessModifier).append(c).append(name.substring(1)).toString();
}
} else if (nameParts.length > 1) {
@@ -365,8 +292,7 @@ public final class JPAEntityParser {
if (i == 0) {
builder.append(accessModifier).append(c).append(name.substring(1));
} else {
- builder.append(".").append(accessModifier).append(c)
- .append(name.substring(1));
+ builder.append(".").append(accessModifier).append(c).append(name.substring(1));
}
}
} else {
@@ -381,13 +307,11 @@ public final class JPAEntityParser {
}
- public Method getAccessModifier(final Object jpaEntity, final EdmNavigationProperty navigationProperty, final String accessModifier)
- throws ODataJPARuntimeException {
+ public Method getAccessModifier(final Object jpaEntity, final EdmNavigationProperty navigationProperty, final String accessModifier) throws ODataJPARuntimeException {
try {
- String name = getAccessModifierName(navigationProperty.getName(),
- navigationProperty.getMapping(), accessModifier);
+ String name = getAccessModifierName(navigationProperty.getName(), navigationProperty.getMapping(), accessModifier);
Class<?>[] params = null;
if (accessModifier.equals(ACCESS_MODIFIER_SET)) {
@@ -402,21 +326,14 @@ public final class JPAEntityParser {
break;
}
}
- return jpaEntity.getClass().getMethod(name,
- params);
+ return jpaEntity.getClass().getMethod(name, params);
} catch (NoSuchMethodException e) {
- throw ODataJPARuntimeException
- .throwException(ODataJPARuntimeException.GENERAL
- .addContent(e.getMessage()), e);
+ throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e);
} catch (SecurityException e) {
- throw ODataJPARuntimeException
- .throwException(ODataJPARuntimeException.GENERAL
- .addContent(e.getMessage()), e);
+ throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e);
} catch (EdmException e) {
- throw ODataJPARuntimeException
- .throwException(ODataJPARuntimeException.GENERAL
- .addContent(e.getMessage()), e);
+ throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e);
}
}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1e5280b7/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/access/data/JPAExpandCallBack.java
----------------------------------------------------------------------
diff --git a/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/access/data/JPAExpandCallBack.java b/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/access/data/JPAExpandCallBack.java
index eb875d8..52917e2 100644
--- a/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/access/data/JPAExpandCallBack.java
+++ b/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/access/data/JPAExpandCallBack.java
@@ -55,8 +55,7 @@ public class JPAExpandCallBack implements OnWriteFeedContent, OnWriteEntryConten
}
@Override
- public WriteEntryCallbackResult retrieveEntryResult(
- final WriteEntryCallbackContext context) {
+ public WriteEntryCallbackResult retrieveEntryResult(final WriteEntryCallbackContext context) {
WriteEntryCallbackResult result = new WriteEntryCallbackResult();
Map<String, Object> entry = context.getEntryData();
Map<String, Object> edmPropertyValueMap = null;
@@ -72,8 +71,7 @@ public class JPAExpandCallBack implements OnWriteFeedContent, OnWriteEntryConten
edmPropertyValueMap = jpaResultParser.parse2EdmPropertyValueMap(inlinedEntry, nextEntitySet.getEntityType());
result.setEntryData(edmPropertyValueMap);
navigationLinks = context.getCurrentExpandSelectTreeNode().getLinks();
- if (navigationLinks.size() > 0)
- {
+ if (navigationLinks.size() > 0) {
currentNavPropertyList = new ArrayList<EdmNavigationProperty>();
currentNavPropertyList.add(getNextNavigationProperty(context.getSourceEntitySet().getEntityType(), context.getNavigationProperty()));
HashMap<String, Object> navigationMap = jpaResultParser.parse2EdmNavigationValueMap(inlinedEntry, currentNavPropertyList);
@@ -91,8 +89,7 @@ public class JPAExpandCallBack implements OnWriteFeedContent, OnWriteEntryConten
}
@Override
- public WriteFeedCallbackResult retrieveFeedResult(
- final WriteFeedCallbackContext context) {
+ public WriteFeedCallbackResult retrieveFeedResult(final WriteFeedCallbackContext context) {
WriteFeedCallbackResult result = new WriteFeedCallbackResult();
HashMap<String, Object> inlinedEntry = (HashMap<String, Object>) context.getEntryData();
List<Map<String, Object>> edmEntityList = new ArrayList<Map<String, Object>>();
@@ -106,19 +103,16 @@ public class JPAExpandCallBack implements OnWriteFeedContent, OnWriteEntryConten
if (nextEntitySet == null) {
nextEntitySet = context.getSourceEntitySet().getRelatedEntitySet(currentNavigationProperty);
}
- for (Object object : listOfItems)
- {
+ for (Object object : listOfItems) {
edmPropertyValueMap = jpaResultParser.parse2EdmPropertyValueMap(object, nextEntitySet.getEntityType());
edmEntityList.add(edmPropertyValueMap);
}
result.setFeedData(edmEntityList);
- if (context.getCurrentExpandSelectTreeNode().getLinks().size() > 0)
- {
+ if (context.getCurrentExpandSelectTreeNode().getLinks().size() > 0) {
currentNavPropertyList = new ArrayList<EdmNavigationProperty>();
currentNavPropertyList.add(getNextNavigationProperty(context.getSourceEntitySet().getEntityType(), context.getNavigationProperty()));
int count = 0;
- for (Object object : listOfItems)
- {
+ for (Object object : listOfItems) {
HashMap<String, Object> navigationMap = jpaResultParser.parse2EdmNavigationValueMap(object, currentNavPropertyList);
edmEntityList.get(count).putAll(navigationMap);
count++;
@@ -134,14 +128,11 @@ public class JPAExpandCallBack implements OnWriteFeedContent, OnWriteEntryConten
return result;
}
- private EdmNavigationProperty getNextNavigationProperty(
- final EdmEntityType sourceEntityType, final EdmNavigationProperty navigationProperty) throws EdmException {
+ private EdmNavigationProperty getNextNavigationProperty(final EdmEntityType sourceEntityType, final EdmNavigationProperty navigationProperty) throws EdmException {
int count;
- for (ArrayList<NavigationPropertySegment> navPropSegments : expandList)
- {
+ for (ArrayList<NavigationPropertySegment> navPropSegments : expandList) {
count = 0;
- for (NavigationPropertySegment navPropSegment : navPropSegments)
- {
+ for (NavigationPropertySegment navPropSegment : navPropSegments) {
EdmNavigationProperty navProperty = navPropSegment.getNavigationProperty();
if (navProperty.getFromRole().equalsIgnoreCase(sourceEntityType.getName()) && navProperty.getName().equals(navigationProperty.getName())) {
return navPropSegments.get(count + 1).getNavigationProperty();
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1e5280b7/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/access/data/JPAFunctionContext.java
----------------------------------------------------------------------
diff --git a/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/access/data/JPAFunctionContext.java b/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/access/data/JPAFunctionContext.java
index ecebd48..000d018 100644
--- a/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/access/data/JPAFunctionContext.java
+++ b/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/access/data/JPAFunctionContext.java
@@ -50,8 +50,7 @@ public class JPAFunctionContext extends JPAMethodContext {
private EdmMapping mapping;
@Override
- public JPAMethodContext build() throws ODataJPAModelException,
- ODataJPARuntimeException {
+ public JPAMethodContext build() throws ODataJPAModelException, ODataJPARuntimeException {
if (functiontView != null) {
functionImport = functiontView.getFunctionImport();
@@ -63,57 +62,39 @@ public class JPAFunctionContext extends JPAMethodContext {
setJpaFunction(jpaFunctionList);
setEnclosingObject(generateEnclosingObject());
} catch (EdmException e) {
- throw ODataJPARuntimeException.throwException(
- ODataJPARuntimeException.GENERAL.addContent(e
- .getMessage()), e);
+ throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e);
} catch (InstantiationException e) {
- throw ODataJPARuntimeException.throwException(
- ODataJPARuntimeException.GENERAL.addContent(e
- .getMessage()), e);
+ throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e);
} catch (IllegalAccessException e) {
- throw ODataJPARuntimeException.throwException(
- ODataJPARuntimeException.GENERAL.addContent(e
- .getMessage()), e);
+ throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e);
} catch (IllegalArgumentException e) {
- throw ODataJPARuntimeException.throwException(
- ODataJPARuntimeException.GENERAL.addContent(e
- .getMessage()), e);
+ throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e);
} catch (InvocationTargetException e) {
- throw ODataJPARuntimeException.throwException(
- ODataJPARuntimeException.GENERAL.addContent(e
- .getMessage()), e);
+ throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e);
} catch (NoSuchMethodException e) {
- throw ODataJPARuntimeException.throwException(
- ODataJPARuntimeException.GENERAL.addContent(e
- .getMessage()), e);
+ throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e);
} catch (SecurityException e) {
- throw ODataJPARuntimeException.throwException(
- ODataJPARuntimeException.GENERAL.addContent(e
- .getMessage()), e);
+ throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e);
}
}
return JPAFunctionContext.this;
}
- private JPAFunction generateJPAFunction() throws EdmException,
- NoSuchMethodException, SecurityException,
- ODataJPAModelException, ODataJPARuntimeException {
+ private JPAFunction generateJPAFunction() throws EdmException, NoSuchMethodException, SecurityException, ODataJPAModelException, ODataJPARuntimeException {
Class<?>[] parameterTypes = getParameterTypes();
Method method = getMethod(parameterTypes);
Type returnType = getReturnType();
Object[] args = getAruguments();
- JPAFunction jpafunction = new JPAFunction(method, parameterTypes,
- returnType, args);
+ JPAFunction jpafunction = new JPAFunction(method, parameterTypes, returnType, args);
return jpafunction;
}
private Object[] getAruguments() throws EdmException {
- Map<String, EdmLiteral> edmArguements = functiontView
- .getFunctionImportParameters();
+ Map<String, EdmLiteral> edmArguements = functiontView.getFunctionImportParameters();
if (edmArguements == null) {
return null;
@@ -122,12 +103,9 @@ public class JPAFunctionContext extends JPAMethodContext {
int i = 0;
for (String paramName : functionImport.getParameterNames()) {
EdmLiteral literal = edmArguements.get(paramName);
- EdmParameter parameter = functionImport
- .getParameter(paramName);
- JPAEdmMapping mapping = (JPAEdmMapping) parameter
- .getMapping();
- args[i] = convertArguement(literal, parameter.getFacets(),
- mapping.getJPAType());
+ EdmParameter parameter = functionImport.getParameter(paramName);
+ JPAEdmMapping mapping = (JPAEdmMapping) parameter.getMapping();
+ args[i] = convertArguement(literal, parameter.getFacets(), mapping.getJPAType());
i++;
}
return args;
@@ -135,34 +113,27 @@ public class JPAFunctionContext extends JPAMethodContext {
}
- private Object convertArguement(final EdmLiteral edmLiteral,
- final EdmFacets facets, final Class<?> targetType)
- throws EdmSimpleTypeException {
+ private Object convertArguement(final EdmLiteral edmLiteral, final EdmFacets facets, final Class<?> targetType) throws EdmSimpleTypeException {
EdmSimpleType edmType = edmLiteral.getType();
- Object value = edmType.valueOfString(edmLiteral.getLiteral(),
- EdmLiteralKind.DEFAULT, facets, targetType);
+ Object value = edmType.valueOfString(edmLiteral.getLiteral(), EdmLiteralKind.DEFAULT, facets, targetType);
return value;
}
private Class<?>[] getParameterTypes() throws EdmException {
- Class<?>[] parameterTypes = new Class<?>[functionImport
- .getParameterNames().size()];
+ Class<?>[] parameterTypes = new Class<?>[functionImport.getParameterNames().size()];
int i = 0;
for (String parameterName : functionImport.getParameterNames()) {
- EdmParameter parameter = functionImport
- .getParameter(parameterName);
- parameterTypes[i] = ((JPAEdmMapping) parameter.getMapping())
- .getJPAType();
+ EdmParameter parameter = functionImport.getParameter(parameterName);
+ parameterTypes[i] = ((JPAEdmMapping) parameter.getMapping()).getJPAType();
i++;
}
return parameterTypes;
}
- private Method getMethod(final Class<?>[] parameterTypes)
- throws NoSuchMethodException, SecurityException {
+ private Method getMethod(final Class<?>[] parameterTypes) throws NoSuchMethodException, SecurityException {
Class<?> type = ((JPAEdmMapping) mapping).getJPAType();
Method method;
@@ -171,15 +142,11 @@ public class JPAFunctionContext extends JPAMethodContext {
return method;
}
- private Type getReturnType() throws ODataJPAModelException,
- ODataJPARuntimeException, EdmException {
+ private Type getReturnType() throws ODataJPAModelException, ODataJPARuntimeException, EdmException {
return null;
}
- private Object generateEnclosingObject() throws InstantiationException,
- IllegalAccessException, IllegalArgumentException,
- InvocationTargetException, NoSuchMethodException,
- SecurityException {
+ private Object generateEnclosingObject() throws InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException {
Class<?> type = ((JPAEdmMapping) mapping).getJPAType();
Object[] params = null;
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1e5280b7/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/access/data/JPAProcessorImpl.java
----------------------------------------------------------------------
diff --git a/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/access/data/JPAProcessorImpl.java b/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/access/data/JPAProcessorImpl.java
index 5ff10b0..b0c942b 100644
--- a/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/access/data/JPAProcessorImpl.java
+++ b/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/access/data/JPAProcessorImpl.java
@@ -65,49 +65,35 @@ public class JPAProcessorImpl implements JPAProcessor {
/* Process Function Import Request */
@SuppressWarnings("unchecked")
@Override
- public List<Object> process(final GetFunctionImportUriInfo uriParserResultView)
- throws ODataJPAModelException, ODataJPARuntimeException {
+ public List<Object> process(final GetFunctionImportUriInfo uriParserResultView) throws ODataJPAModelException, ODataJPARuntimeException {
- JPAMethodContext jpaMethodContext = JPAMethodContext.createBuilder(
- JPQLContextType.FUNCTION, uriParserResultView).build();
+ JPAMethodContext jpaMethodContext = JPAMethodContext.createBuilder(JPQLContextType.FUNCTION, uriParserResultView).build();
List<Object> resultObj = null;
try {
- JPAFunction jpaFunction = jpaMethodContext.getJPAFunctionList()
- .get(0);
+ JPAFunction jpaFunction = jpaMethodContext.getJPAFunctionList().get(0);
Method method = jpaFunction.getFunction();
Object[] args = jpaFunction.getArguments();
- if (uriParserResultView.getFunctionImport().getReturnType()
- .getMultiplicity().equals(EdmMultiplicity.MANY)) {
+ if (uriParserResultView.getFunctionImport().getReturnType().getMultiplicity().equals(EdmMultiplicity.MANY)) {
- resultObj = (List<Object>) method.invoke(
- jpaMethodContext.getEnclosingObject(), args);
+ resultObj = (List<Object>) method.invoke(jpaMethodContext.getEnclosingObject(), args);
} else {
resultObj = new ArrayList<Object>();
- Object result = method.invoke(
- jpaMethodContext.getEnclosingObject(), args);
+ Object result = method.invoke(jpaMethodContext.getEnclosingObject(), args);
resultObj.add(result);
}
} catch (EdmException e) {
- throw ODataJPARuntimeException
- .throwException(ODataJPARuntimeException.GENERAL
- .addContent(e.getMessage()), e);
+ throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e);
} catch (IllegalAccessException e) {
- throw ODataJPARuntimeException
- .throwException(ODataJPARuntimeException.GENERAL
- .addContent(e.getMessage()), e);
+ throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e);
} catch (IllegalArgumentException e) {
- throw ODataJPARuntimeException
- .throwException(ODataJPARuntimeException.GENERAL
- .addContent(e.getMessage()), e);
+ throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e);
} catch (InvocationTargetException e) {
- throw ODataJPARuntimeException
- .throwException(ODataJPARuntimeException.GENERAL
- .addContent(e.getTargetException().getMessage()), e.getTargetException());
+ throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getTargetException().getMessage()), e.getTargetException());
}
return resultObj;
@@ -116,31 +102,26 @@ public class JPAProcessorImpl implements JPAProcessor {
/* Process Get Entity Set Request (Query) */
@SuppressWarnings("unchecked")
@Override
- public <T> List<T> process(final GetEntitySetUriInfo uriParserResultView)
- throws ODataJPAModelException, ODataJPARuntimeException {
+ public <T> List<T> process(final GetEntitySetUriInfo uriParserResultView) throws ODataJPAModelException, ODataJPARuntimeException {
if (uriParserResultView.getFunctionImport() != null) {
return (List<T>) process((GetFunctionImportUriInfo) uriParserResultView);
}
JPQLContextType contextType = null;
try {
- if (!uriParserResultView.getStartEntitySet().getName()
- .equals(uriParserResultView.getTargetEntitySet().getName())) {
+ if (!uriParserResultView.getStartEntitySet().getName().equals(uriParserResultView.getTargetEntitySet().getName())) {
contextType = JPQLContextType.JOIN;
} else {
contextType = JPQLContextType.SELECT;
}
} catch (EdmException e) {
- ODataJPARuntimeException.throwException(
- ODataJPARuntimeException.GENERAL, e);
+ ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL, e);
}
- JPQLContext jpqlContext = JPQLContext.createBuilder(contextType,
- uriParserResultView).build();
+ JPQLContext jpqlContext = JPQLContext.createBuilder(contextType, uriParserResultView).build();
- JPQLStatement jpqlStatement = JPQLStatement.createBuilder(jpqlContext)
- .build();
+ JPQLStatement jpqlStatement = JPQLStatement.createBuilder(jpqlContext).build();
Query query = null;
try {
query = em.createQuery(jpqlStatement.toString());
@@ -159,30 +140,26 @@ public class JPAProcessorImpl implements JPAProcessor {
}
return query.getResultList();
} catch (IllegalArgumentException e) {
- throw ODataJPARuntimeException.throwException(
- ODataJPARuntimeException.ERROR_JPQL_QUERY_CREATE, e);
+ throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.ERROR_JPQL_QUERY_CREATE, e);
}
}
/* Process Get Entity Request (Read) */
@Override
- public <T> Object process(GetEntityUriInfo uriParserResultView)
- throws ODataJPAModelException, ODataJPARuntimeException {
+ public <T> Object process(GetEntityUriInfo uriParserResultView) throws ODataJPAModelException, ODataJPARuntimeException {
JPQLContextType contextType = null;
try {
if (uriParserResultView instanceof GetEntityUriInfo) {
uriParserResultView = ((GetEntityUriInfo) uriParserResultView);
- if (!((GetEntityUriInfo) uriParserResultView).getStartEntitySet().getName()
- .equals(((GetEntityUriInfo) uriParserResultView).getTargetEntitySet().getName())) {
+ if (!((GetEntityUriInfo) uriParserResultView).getStartEntitySet().getName().equals(((GetEntityUriInfo) uriParserResultView).getTargetEntitySet().getName())) {
contextType = JPQLContextType.JOIN_SINGLE;
} else {
contextType = JPQLContextType.SELECT_SINGLE;
}
}
} catch (EdmException e) {
- ODataJPARuntimeException.throwException(
- ODataJPARuntimeException.GENERAL, e);
+ ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL, e);
}
return readEntity(uriParserResultView, contextType);
@@ -190,27 +167,22 @@ public class JPAProcessorImpl implements JPAProcessor {
/* Process $count for Get Entity Set Request */
@Override
- public long process(final GetEntitySetCountUriInfo resultsView)
- throws ODataJPAModelException, ODataJPARuntimeException {
+ public long process(final GetEntitySetCountUriInfo resultsView) throws ODataJPAModelException, ODataJPARuntimeException {
JPQLContextType contextType = null;
try {
- if (!resultsView.getStartEntitySet().getName()
- .equals(resultsView.getTargetEntitySet().getName())) {
+ if (!resultsView.getStartEntitySet().getName().equals(resultsView.getTargetEntitySet().getName())) {
contextType = JPQLContextType.JOIN_COUNT;
} else {
contextType = JPQLContextType.SELECT_COUNT;
}
} catch (EdmException e) {
- ODataJPARuntimeException.throwException(
- ODataJPARuntimeException.GENERAL, e);
+ ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL, e);
}
- JPQLContext jpqlContext = JPQLContext.createBuilder(contextType,
- resultsView).build();
+ JPQLContext jpqlContext = JPQLContext.createBuilder(contextType, resultsView).build();
- JPQLStatement jpqlStatement = JPQLStatement.createBuilder(jpqlContext)
- .build();
+ JPQLStatement jpqlStatement = JPQLStatement.createBuilder(jpqlContext).build();
Query query = null;
try {
@@ -220,8 +192,7 @@ public class JPAProcessorImpl implements JPAProcessor {
return Long.valueOf(resultList.get(0).toString());
}
} catch (IllegalArgumentException e) {
- throw ODataJPARuntimeException.throwException(
- ODataJPARuntimeException.ERROR_JPQL_QUERY_CREATE, e);
+ throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.ERROR_JPQL_QUERY_CREATE, e);
}
return 0;
}
@@ -232,22 +203,18 @@ public class JPAProcessorImpl implements JPAProcessor {
JPQLContextType contextType = null;
try {
- if (!resultsView.getStartEntitySet().getName()
- .equals(resultsView.getTargetEntitySet().getName())) {
+ if (!resultsView.getStartEntitySet().getName().equals(resultsView.getTargetEntitySet().getName())) {
contextType = JPQLContextType.JOIN_COUNT;
} else {
contextType = JPQLContextType.SELECT_COUNT;
}
} catch (EdmException e) {
- ODataJPARuntimeException.throwException(
- ODataJPARuntimeException.GENERAL, e);
+ ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL, e);
}
- JPQLContext jpqlContext = JPQLContext.createBuilder(contextType,
- resultsView).build();
+ JPQLContext jpqlContext = JPQLContext.createBuilder(contextType, resultsView).build();
- JPQLStatement jpqlStatement = JPQLStatement.createBuilder(jpqlContext)
- .build();
+ JPQLStatement jpqlStatement = JPQLStatement.createBuilder(jpqlContext).build();
Query query = null;
try {
@@ -257,8 +224,7 @@ public class JPAProcessorImpl implements JPAProcessor {
return Long.valueOf(resultList.get(0).toString());
}
} catch (IllegalArgumentException e) {
- throw ODataJPARuntimeException.throwException(
- ODataJPARuntimeException.ERROR_JPQL_QUERY_CREATE, e);
+ throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.ERROR_JPQL_QUERY_CREATE, e);
}
return 0;
@@ -266,14 +232,10 @@ public class JPAProcessorImpl implements JPAProcessor {
/* Process Create Entity Request */
@Override
- public <T> List<T> process(final PostUriInfo createView, final InputStream content,
- final String requestedContentType) throws ODataJPAModelException,
- ODataJPARuntimeException {
-
- JPACreateRequest jpaCreateRequest = new JPACreateRequest(em
- .getEntityManagerFactory().getMetamodel());
- List<T> createObjectList = jpaCreateRequest.process(createView, content,
- requestedContentType);
+ public <T> List<T> process(final PostUriInfo createView, final InputStream content, final String requestedContentType) throws ODataJPAModelException, ODataJPARuntimeException {
+
+ JPACreateRequest jpaCreateRequest = new JPACreateRequest(em.getEntityManagerFactory().getMetamodel());
+ List<T> createObjectList = jpaCreateRequest.process(createView, content, requestedContentType);
try {
em.getTransaction().begin();
Object jpaEntity = createObjectList.get(0);
@@ -288,68 +250,58 @@ public class JPAProcessorImpl implements JPAProcessor {
}
} catch (Exception e) {
em.getTransaction().rollback();
- throw ODataJPARuntimeException.throwException(
- ODataJPARuntimeException.ERROR_JPQL_CREATE_REQUEST, e);
+ throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.ERROR_JPQL_CREATE_REQUEST, e);
}
return null;
}
/* Process Update Entity Request */
@Override
- public <T> Object process(PutMergePatchUriInfo updateView,
- final InputStream content, final String requestContentType)
- throws ODataJPAModelException, ODataJPARuntimeException {
+ public <T> Object process(PutMergePatchUriInfo updateView, final InputStream content, final String requestContentType) throws ODataJPAModelException, ODataJPARuntimeException {
JPQLContextType contextType = null;
try {
if (updateView instanceof PutMergePatchUriInfo) {
updateView = ((PutMergePatchUriInfo) updateView);
- if (!((PutMergePatchUriInfo) updateView).getStartEntitySet().getName()
- .equals(((PutMergePatchUriInfo) updateView).getTargetEntitySet().getName())) {
+ if (!((PutMergePatchUriInfo) updateView).getStartEntitySet().getName().equals(((PutMergePatchUriInfo) updateView).getTargetEntitySet().getName())) {
contextType = JPQLContextType.JOIN_SINGLE;
} else {
contextType = JPQLContextType.SELECT_SINGLE;
}
}
} catch (EdmException e) {
- ODataJPARuntimeException.throwException(
- ODataJPARuntimeException.GENERAL, e);
+ ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL, e);
}
JPAUpdateRequest jpaUpdateRequest = new JPAUpdateRequest();
Object updateObject = readEntity(updateView, contextType);
try {
em.getTransaction().begin();
- jpaUpdateRequest.process(updateObject, updateView, content,
- requestContentType);
+ jpaUpdateRequest.process(updateObject, updateView, content, requestContentType);
em.flush();
em.getTransaction().commit();
} catch (Exception e) {
em.getTransaction().rollback();
- throw ODataJPARuntimeException.throwException(
- ODataJPARuntimeException.ERROR_JPQL_UPDATE_REQUEST, e);
+ throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.ERROR_JPQL_UPDATE_REQUEST, e);
}
return updateObject;
}
/* Process Delete Entity Request */
@Override
- public Object process(DeleteUriInfo uriParserResultView, final String contentType)
- throws ODataJPAModelException, ODataJPARuntimeException {
+ public Object process(DeleteUriInfo uriParserResultView, final String contentType) throws ODataJPAModelException, ODataJPARuntimeException {
JPQLContextType contextType = null;
try {
if (uriParserResultView instanceof DeleteUriInfo) {
uriParserResultView = ((DeleteUriInfo) uriParserResultView);
- if (!((DeleteUriInfo) uriParserResultView).getStartEntitySet().getName()
- .equals(((DeleteUriInfo) uriParserResultView).getTargetEntitySet().getName())) {
+ if (!((DeleteUriInfo) uriParserResultView).getStartEntitySet().getName().equals(((DeleteUriInfo) uriParserResultView).getTargetEntitySet().getName())) {
contextType = JPQLContextType.JOIN_SINGLE;
} else {
contextType = JPQLContextType.SELECT_SINGLE;
}
}
} catch (EdmException e) {
- ODataJPARuntimeException.throwException(
- ODataJPARuntimeException.GENERAL, e);
+ ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL, e);
}
// First read the entity with read operation.
@@ -363,8 +315,7 @@ public class JPAProcessorImpl implements JPAProcessor {
em.getTransaction().commit();
} catch (Exception e) {
em.getTransaction().rollback();
- throw ODataJPARuntimeException.throwException(
- ODataJPARuntimeException.ERROR_JPQL_DELETE_REQUEST, e);
+ throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.ERROR_JPQL_DELETE_REQUEST, e);
}
}
return selectedObject;
@@ -372,41 +323,34 @@ public class JPAProcessorImpl implements JPAProcessor {
/* Process Get Entity Link Request */
@Override
- public Object process(final GetEntityLinkUriInfo uriParserResultView)
- throws ODataJPAModelException, ODataJPARuntimeException {
+ public Object process(final GetEntityLinkUriInfo uriParserResultView) throws ODataJPAModelException, ODataJPARuntimeException {
return this.process((GetEntityUriInfo) uriParserResultView);
}
/* Process Get Entity Set Link Request */
@Override
- public <T> List<T> process(final GetEntitySetLinksUriInfo uriParserResultView)
- throws ODataJPAModelException, ODataJPARuntimeException {
+ public <T> List<T> process(final GetEntitySetLinksUriInfo uriParserResultView) throws ODataJPAModelException, ODataJPARuntimeException {
return this.process((GetEntitySetUriInfo) uriParserResultView);
}
@Override
- public void process(final PostUriInfo uriInfo,
- final InputStream content, final String requestContentType, final String contentType)
- throws ODataJPARuntimeException, ODataJPAModelException {
+ public void process(final PostUriInfo uriInfo, final InputStream content, final String requestContentType, final String contentType) throws ODataJPARuntimeException, ODataJPAModelException {
JPALink link = new JPALink(oDataJPAContext);
link.create(uriInfo, content, requestContentType, contentType);
link.save();
}
/* Common method for Read and Delete */
- private Object readEntity(final Object uriParserResultView, final JPQLContextType contextType)
- throws ODataJPAModelException, ODataJPARuntimeException {
+ private Object readEntity(final Object uriParserResultView, final JPQLContextType contextType) throws ODataJPAModelException, ODataJPARuntimeException {
Object selectedObject = null;
if (uriParserResultView instanceof DeleteUriInfo || uriParserResultView instanceof GetEntityUriInfo || uriParserResultView instanceof PutMergePatchUriInfo) {
- JPQLContext selectJPQLContext = JPQLContext.createBuilder(
- contextType, uriParserResultView).build();
+ JPQLContext selectJPQLContext = JPQLContext.createBuilder(contextType, uriParserResultView).build();
- JPQLStatement selectJPQLStatement = JPQLStatement.createBuilder(
- selectJPQLContext).build();
+ JPQLStatement selectJPQLStatement = JPQLStatement.createBuilder(selectJPQLContext).build();
Query query = null;
try {
query = em.createQuery(selectJPQLStatement.toString());
@@ -414,17 +358,14 @@ public class JPAProcessorImpl implements JPAProcessor {
selectedObject = query.getResultList().get(0);
}
} catch (IllegalArgumentException e) {
- throw ODataJPARuntimeException.throwException(
- ODataJPARuntimeException.ERROR_JPQL_QUERY_CREATE, e);
+ throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.ERROR_JPQL_QUERY_CREATE, e);
}
}
return selectedObject;
}
@Override
- public void process(final PutMergePatchUriInfo putUriInfo,
- final InputStream content, final String requestContentType, final String contentType)
- throws ODataJPARuntimeException, ODataJPAModelException {
+ public void process(final PutMergePatchUriInfo putUriInfo, final InputStream content, final String requestContentType, final String contentType) throws ODataJPARuntimeException, ODataJPAModelException {
JPALink link = new JPALink(oDataJPAContext);
link.update(putUriInfo, content, requestContentType, contentType);
link.save();
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1e5280b7/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/access/model/EdmTypeConvertor.java
----------------------------------------------------------------------
diff --git a/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/access/model/EdmTypeConvertor.java b/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/access/model/EdmTypeConvertor.java
index fb07fb7..ae9dcf0 100644
--- a/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/access/model/EdmTypeConvertor.java
+++ b/jpa-core/src/main/java/org/apache/olingo/odata2/processor/core/jpa/access/model/EdmTypeConvertor.java
@@ -33,46 +33,34 @@ public class EdmTypeConvertor {
public static Class<?> convertToJavaType(final EdmType edmType) throws ODataJPAModelException, ODataJPARuntimeException {
if (edmType instanceof EdmSimpleType) {
- EdmSimpleType edmSimpleType = (EdmSimpleType) edmType;
- if (edmSimpleType == EdmSimpleTypeKind.String.getEdmSimpleTypeInstance()) {
- return String.class;
- }
- else if (edmSimpleType == EdmSimpleTypeKind.Int64.getEdmSimpleTypeInstance()) {
- return Long.TYPE;
- }
- else if (edmSimpleType == EdmSimpleTypeKind.Int16.getEdmSimpleTypeInstance()) {
- return Short.TYPE;
- }
- else if (edmSimpleType == EdmSimpleTypeKind.Int32.getEdmSimpleTypeInstance()) {
- return Integer.TYPE;
- }
- else if (edmSimpleType == EdmSimpleTypeKind.Double.getEdmSimpleTypeInstance()) {
- return Double.TYPE;
- }
- else if (edmSimpleType == EdmSimpleTypeKind.Single.getEdmSimpleTypeInstance()) {
- return Float.TYPE;
- }
- else if (edmSimpleType == EdmSimpleTypeKind.Decimal.getEdmSimpleTypeInstance()) {
- return BigDecimal.class;
- }
- else if (edmSimpleType == EdmSimpleTypeKind.Binary.getEdmSimpleTypeInstance()) {
- return byte[].class;
- }
- else if (edmSimpleType == EdmSimpleTypeKind.Byte.getEdmSimpleTypeInstance()) {
- return Byte.TYPE;
- }
- else if (edmSimpleType == EdmSimpleTypeKind.Boolean.getEdmSimpleTypeInstance()) {
- return Boolean.TYPE;
- }
- else if (edmSimpleType == EdmSimpleTypeKind.DateTime.getEdmSimpleTypeInstance()) {
- return Date.class;
- }
- else if (edmSimpleType == EdmSimpleTypeKind.DateTimeOffset.getEdmSimpleTypeInstance()) {
- return Calendar.class;
- }
- else if (edmSimpleType == EdmSimpleTypeKind.Guid.getEdmSimpleTypeInstance()) {
- return UUID.class;
- }
+ EdmSimpleType edmSimpleType = (EdmSimpleType) edmType;
+ if (edmSimpleType == EdmSimpleTypeKind.String.getEdmSimpleTypeInstance()) {
+ return String.class;
+ } else if (edmSimpleType == EdmSimpleTypeKind.Int64.getEdmSimpleTypeInstance()) {
+ return Long.TYPE;
+ } else if (edmSimpleType == EdmSimpleTypeKind.Int16.getEdmSimpleTypeInstance()) {
+ return Short.TYPE;
+ } else if (edmSimpleType == EdmSimpleTypeKind.Int32.getEdmSimpleTypeInstance()) {
+ return Integer.TYPE;
+ } else if (edmSimpleType == EdmSimpleTypeKind.Double.getEdmSimpleTypeInstance()) {
+ return Double.TYPE;
+ } else if (edmSimpleType == EdmSimpleTypeKind.Single.getEdmSimpleTypeInstance()) {
+ return Float.TYPE;
+ } else if (edmSimpleType == EdmSimpleTypeKind.Decimal.getEdmSimpleTypeInstance()) {
+ return BigDecimal.class;
+ } else if (edmSimpleType == EdmSimpleTypeKind.Binary.getEdmSimpleTypeInstance()) {
+ return byte[].class;
+ } else if (edmSimpleType == EdmSimpleTypeKind.Byte.getEdmSimpleTypeInstance()) {
+ return Byte.TYPE;
+ } else if (edmSimpleType == EdmSimpleTypeKind.Boolean.getEdmSimpleTypeInstance()) {
+ return Boolean.TYPE;
+ } else if (edmSimpleType == EdmSimpleTypeKind.DateTime.getEdmSimpleTypeInstance()) {
+ return Date.class;
+ } else if (edmSimpleType == EdmSimpleTypeKind.DateTimeOffset.getEdmSimpleTypeInstance()) {
+ return Calendar.class;
+ } else if (edmSimpleType == EdmSimpleTypeKind.Guid.getEdmSimpleTypeInstance()) {
+ return UUID.class;
+ }
}
throw ODataJPAModelException.throwException(ODataJPAModelException.TYPE_NOT_SUPPORTED.addContent(edmType.toString()), null);
}