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 2014/05/19 15:28:37 UTC
[48/50] [abbrv] git commit: [OLINGO-260] contained tests
[OLINGO-260] contained tests
Project: http://git-wip-us.apache.org/repos/asf/olingo-odata4/repo
Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata4/commit/32953c0b
Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata4/tree/32953c0b
Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata4/diff/32953c0b
Branch: refs/heads/master
Commit: 32953c0b11aac62165e51b1aa81ca8355292622c
Parents: b7471a4
Author: Francesco Chicchiriccò <--global>
Authored: Sat May 17 16:06:18 2014 +0200
Committer: Stephan Klevenz <st...@sap.com>
Committed: Mon May 19 14:36:12 2014 +0200
----------------------------------------------------------------------
.../commons/AbstractInvocationHandler.java | 36 +++++---
.../AbstractStructuredInvocationHandler.java | 43 +++++-----
.../ComplexFactoryInvocationHandler.java | 18 ++--
.../proxy/commons/ComplexInvocationHandler.java | 20 ++---
.../olingo/ext/proxy/commons/ContainerImpl.java | 84 +++++++++---------
.../EntityContainerInvocationHandler.java | 4 +-
.../proxy/commons/EntityInvocationHandler.java | 49 ++++++-----
.../commons/EntitySetInvocationHandler.java | 72 ++++++++--------
.../commons/OperationInvocationHandler.java | 8 +-
.../commons/SingletonInvocationHandler.java | 12 +--
.../ext/proxy/context/AttachedEntity.java | 8 +-
.../olingo/ext/proxy/context/EntityContext.java | 28 +++---
.../ext/proxy/context/EntityLinkDesc.java | 20 ++---
.../olingo/ext/proxy/utils/CoreUtils.java | 26 +++---
.../olingo/ext/pojogen/AbstractPOJOGenMojo.java | 29 +++++++
.../olingo/fit/proxy/v3/ContextTestITCase.java | 90 ++++++++++----------
.../fit/proxy/v3/EntityUpdateTestITCase.java | 4 +-
.../fit/proxy/v4/DerivedTypeTestITCase.java | 13 ++-
.../fit/proxy/v4/EntityCreateTestITCase.java | 33 +++++++
.../fit/proxy/v4/EntityRetrieveTestITCase.java | 14 ++-
.../fit/proxy/v4/EntityUpdateTestITCase.java | 20 ++++-
.../odata/services/opentypesservicev4/Row.java | 2 +-
.../services/opentypesservicev4/RowIndex.java | 2 +-
.../services/odatawcfservice/Accounts.java | 1 -
.../odata/services/odatawcfservice/Boss.java | 1 -
.../odata/services/odatawcfservice/Company.java | 1 -
.../services/odatawcfservice/Customers.java | 1 -
.../odatawcfservice/DefaultStoredPI.java | 1 -
.../services/odatawcfservice/Departments.java | 1 -
.../services/odatawcfservice/Employees.java | 1 -
.../odatawcfservice/InMemoryEntities.java | 1 -
.../services/odatawcfservice/LabourUnion.java | 1 -
.../services/odatawcfservice/OrderDetails.java | 1 -
.../odata/services/odatawcfservice/Orders.java | 1 -
.../odata/services/odatawcfservice/People.java | 1 -
.../odatawcfservice/ProductDetails.java | 1 -
.../odatawcfservice/ProductReviews.java | 1 -
.../services/odatawcfservice/Products.java | 1 -
.../services/odatawcfservice/PublicCompany.java | 1 -
.../services/odatawcfservice/StoredPIs.java | 1 -
.../odatawcfservice/SubscriptionTemplates.java | 1 -
.../services/odatawcfservice/VipCustomer.java | 1 -
.../services/odatawcfservice/package-info.java | 1 -
.../odatawcfservice/types/AccessLevel.java | 1 -
.../services/odatawcfservice/types/Account.java | 1 -
.../types/AccountCollection.java | 1 -
.../odatawcfservice/types/AccountInfo.java | 1 -
.../services/odatawcfservice/types/Address.java | 1 -
.../services/odatawcfservice/types/Asset.java | 1 -
.../odatawcfservice/types/AssetCollection.java | 1 -
.../services/odatawcfservice/types/Club.java | 1 -
.../odatawcfservice/types/ClubCollection.java | 1 -
.../services/odatawcfservice/types/Color.java | 1 -
.../services/odatawcfservice/types/Company.java | 1 -
.../odatawcfservice/types/CompanyAddress.java | 1 -
.../odatawcfservice/types/CompanyCategory.java | 1 -
.../types/CompanyCollection.java | 1 -
.../odatawcfservice/types/CreditCardPI.java | 1 -
.../types/CreditCardPICollection.java | 1 -
.../odatawcfservice/types/CreditRecord.java | 1 -
.../types/CreditRecordCollection.java | 1 -
.../odatawcfservice/types/Customer.java | 1 -
.../types/CustomerCollection.java | 1 -
.../odatawcfservice/types/Department.java | 1 -
.../types/DepartmentCollection.java | 1 -
.../odatawcfservice/types/Employee.java | 1 -
.../types/EmployeeCollection.java | 1 -
.../odatawcfservice/types/GiftCard.java | 1 -
.../types/GiftCardCollection.java | 1 -
.../odatawcfservice/types/HomeAddress.java | 1 -
.../odatawcfservice/types/LabourUnion.java | 1 -
.../types/LabourUnionCollection.java | 1 -
.../services/odatawcfservice/types/Order.java | 1 -
.../odatawcfservice/types/OrderCollection.java | 1 -
.../odatawcfservice/types/OrderDetail.java | 1 -
.../types/OrderDetailCollection.java | 1 -
.../odatawcfservice/types/OrderDetailKey.java | 1 -
.../types/PaymentInstrument.java | 1 -
.../types/PaymentInstrumentCollection.java | 1 -
.../services/odatawcfservice/types/Person.java | 1 -
.../odatawcfservice/types/PersonCollection.java | 1 -
.../services/odatawcfservice/types/Product.java | 1 -
.../types/ProductCollection.java | 1 -
.../odatawcfservice/types/ProductDetail.java | 1 -
.../types/ProductDetailCollection.java | 1 -
.../odatawcfservice/types/ProductDetailKey.java | 1 -
.../odatawcfservice/types/ProductReview.java | 1 -
.../types/ProductReviewCollection.java | 1 -
.../odatawcfservice/types/ProductReviewKey.java | 1 -
.../odatawcfservice/types/PublicCompany.java | 1 -
.../types/PublicCompanyCollection.java | 1 -
.../odatawcfservice/types/Statement.java | 1 -
.../types/StatementCollection.java | 1 -
.../odatawcfservice/types/StoredPI.java | 1 -
.../types/StoredPICollection.java | 1 -
.../odatawcfservice/types/Subscription.java | 1 -
.../types/SubscriptionCollection.java | 1 -
.../odatawcfservice/types/package-info.java | 1 -
.../core/edm/primitivetype/EdmDuration.java | 1 -
99 files changed, 381 insertions(+), 330 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/32953c0b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/AbstractInvocationHandler.java
----------------------------------------------------------------------
diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/AbstractInvocationHandler.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/AbstractInvocationHandler.java
index 5181b48..e3a2bc9 100644
--- a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/AbstractInvocationHandler.java
+++ b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/AbstractInvocationHandler.java
@@ -87,7 +87,7 @@ abstract class AbstractInvocationHandler implements InvocationHandler {
}
@SuppressWarnings({"unchecked", "rawtypes"})
- protected Object getEntityCollection(
+ protected Object getEntityCollectionProxy(
final Class<?> typeRef,
final Class<?> typeCollectionRef,
final String entityContainerName,
@@ -99,7 +99,7 @@ abstract class AbstractInvocationHandler implements InvocationHandler {
for (CommonODataEntity entityFromSet : entitySet.getEntities()) {
items.add(getEntityProxy(
- entityFromSet, entityContainerName, null, typeRef, checkInTheContext));
+ entityFromSet.getEditLink(), entityFromSet, entityContainerName, null, typeRef, checkInTheContext));
}
return Proxy.newProxyInstance(
@@ -108,27 +108,38 @@ abstract class AbstractInvocationHandler implements InvocationHandler {
new EntityCollectionInvocationHandler(containerHandler, items, typeRef, uri));
}
- protected <T> T getEntityProxy(
+ protected Object getEntitySetProxy(
+ final Class<?> typeRef,
+ final URI uri) {
+
+ return Proxy.newProxyInstance(
+ Thread.currentThread().getContextClassLoader(),
+ new Class<?>[] {typeRef},
+ EntitySetInvocationHandler.getInstance(typeRef, containerHandler, uri));
+ }
+
+ protected Object getEntityProxy(
+ final URI entityURI,
final CommonODataEntity entity,
final String entityContainerName,
- final String entitySetName,
+ final URI entitySetURI,
final Class<?> type,
final boolean checkInTheContext) {
- return getEntityProxy(entity, entityContainerName, entitySetName, type, null, checkInTheContext);
+ return getEntityProxy(entityURI, entity, entityContainerName, entitySetURI, type, null, checkInTheContext);
}
- @SuppressWarnings({"unchecked"})
- protected <T> T getEntityProxy(
+ protected Object getEntityProxy(
+ final URI entityURI,
final CommonODataEntity entity,
final String entityContainerName,
- final String entitySetName,
+ final URI entitySetURI,
final Class<?> type,
final String eTag,
final boolean checkInTheContext) {
- EntityTypeInvocationHandler handler =
- EntityTypeInvocationHandler.getInstance(entity, entitySetName, type, containerHandler);
+ EntityInvocationHandler handler =
+ EntityInvocationHandler.getInstance(entityURI, entity, entitySetURI, type, containerHandler);
if (StringUtils.isNotBlank(eTag)) {
// override ETag into the wrapped object.
@@ -139,7 +150,7 @@ abstract class AbstractInvocationHandler implements InvocationHandler {
handler = EntityContainerFactory.getContext().entityContext().getEntity(handler.getUUID());
}
- return (T) Proxy.newProxyInstance(
+ return Proxy.newProxyInstance(
Thread.currentThread().getContextClassLoader(),
new Class<?>[] {type},
handler);
@@ -196,7 +207,7 @@ abstract class AbstractInvocationHandler implements InvocationHandler {
if (edmType.isCollection()) {
final ParameterizedType collType = (ParameterizedType) method.getReturnType().getGenericInterfaces()[0];
final Class<?> collItemType = (Class<?>) collType.getActualTypeArguments()[0];
- return getEntityCollection(
+ return getEntityCollectionProxy(
collItemType,
method.getReturnType(),
null,
@@ -205,6 +216,7 @@ abstract class AbstractInvocationHandler implements InvocationHandler {
false);
} else {
return getEntityProxy(
+ ((CommonODataEntity) result).getEditLink(),
(CommonODataEntity) result,
null,
null,
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/32953c0b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/AbstractStructuredInvocationHandler.java
----------------------------------------------------------------------
diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/AbstractStructuredInvocationHandler.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/AbstractStructuredInvocationHandler.java
index 169ddfe..2e6103e 100644
--- a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/AbstractStructuredInvocationHandler.java
+++ b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/AbstractStructuredInvocationHandler.java
@@ -37,6 +37,7 @@ import org.apache.olingo.commons.api.domain.ODataLink;
import org.apache.olingo.commons.api.domain.ODataLinked;
import org.apache.olingo.ext.proxy.EntityContainerFactory;
import org.apache.olingo.ext.proxy.api.AbstractEntityCollection;
+import org.apache.olingo.ext.proxy.api.AbstractEntitySet;
import org.apache.olingo.ext.proxy.api.annotations.EntityType;
import org.apache.olingo.ext.proxy.api.annotations.NavigationProperty;
import org.apache.olingo.ext.proxy.api.annotations.Property;
@@ -46,24 +47,24 @@ import org.apache.olingo.ext.proxy.utils.ClassUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public abstract class AbstractTypeInvocationHandler extends AbstractInvocationHandler {
+public abstract class AbstractStructuredInvocationHandler extends AbstractInvocationHandler {
private static final long serialVersionUID = 2629912294765040037L;
/**
* Logger.
*/
- protected static final Logger LOG = LoggerFactory.getLogger(AbstractTypeInvocationHandler.class);
+ protected static final Logger LOG = LoggerFactory.getLogger(AbstractStructuredInvocationHandler.class);
protected final Class<?> typeRef;
protected final EntityContext entityContext = EntityContainerFactory.getContext().entityContext();
- protected EntityTypeInvocationHandler entityHandler;
+ protected EntityInvocationHandler entityHandler;
protected Object internal;
- protected AbstractTypeInvocationHandler(
+ protected AbstractStructuredInvocationHandler(
final CommonEdmEnabledODataClient<?> client,
final Class<?> typeRef,
final Object internal,
@@ -72,14 +73,14 @@ public abstract class AbstractTypeInvocationHandler extends AbstractInvocationHa
super(client, containerHandler);
this.internal = internal;
this.typeRef = typeRef;
- this.entityHandler = EntityTypeInvocationHandler.class.cast(this);
+ this.entityHandler = EntityInvocationHandler.class.cast(this);
}
- protected AbstractTypeInvocationHandler(
+ protected AbstractStructuredInvocationHandler(
final CommonEdmEnabledODataClient<?> client,
final Class<?> typeRef,
final Object internal,
- final EntityTypeInvocationHandler entityHandler) {
+ final EntityInvocationHandler entityHandler) {
super(client, entityHandler == null ? null : entityHandler.containerHandler);
this.internal = internal;
@@ -87,11 +88,11 @@ public abstract class AbstractTypeInvocationHandler extends AbstractInvocationHa
this.entityHandler = entityHandler;
}
- public EntityTypeInvocationHandler getEntityHandler() {
+ public EntityInvocationHandler getEntityHandler() {
return entityHandler;
}
- public void setEntityHandler(EntityTypeInvocationHandler entityHandler) {
+ public void setEntityHandler(EntityInvocationHandler entityHandler) {
this.entityHandler = entityHandler;
}
@@ -191,7 +192,9 @@ public abstract class AbstractTypeInvocationHandler extends AbstractInvocationHa
protected abstract Object getNavigationPropertyValue(final NavigationProperty property, final Method getter);
- protected Object retriveNavigationProperty(final NavigationProperty property, final Method getter) {
+ protected Object retrieveNavigationProperty(
+ final NavigationProperty property, final Method getter, final String serviceRoot) {
+
final Class<?> type = getter.getReturnType();
final Class<?> collItemType;
if (AbstractEntityCollection.class.isAssignableFrom(type)) {
@@ -208,14 +211,15 @@ public abstract class AbstractTypeInvocationHandler extends AbstractInvocationHa
if (link instanceof ODataInlineEntity) {
// return entity
navPropValue = getEntityProxy(
+ null,
((ODataInlineEntity) link).getEntity(),
property.targetContainer(),
- property.targetEntitySet(),
+ client.getURIBuilder(serviceRoot).appendEntitySetSegment(property.targetEntitySet()).build(),
type,
false);
} else if (link instanceof ODataInlineEntitySet) {
// return entity set
- navPropValue = getEntityCollection(
+ navPropValue = getEntityCollectionProxy(
collItemType,
type,
property.targetContainer(),
@@ -224,25 +228,26 @@ public abstract class AbstractTypeInvocationHandler extends AbstractInvocationHa
false);
} else {
// navigate
- final URI uri = URIUtils.getURI(
- containerHandler.getFactory().getServiceRoot(), link.getLink().toASCIIString());
-
+ final URI uri = URIUtils.getURI(containerHandler.getFactory().getServiceRoot(), link.getLink().toASCIIString());
if (AbstractEntityCollection.class.isAssignableFrom(type)) {
- navPropValue = getEntityCollection(
+ navPropValue = getEntityCollectionProxy(
collItemType,
type,
property.targetContainer(),
client.getRetrieveRequestFactory().getEntitySetRequest(uri).execute().getBody(),
uri,
true);
+ } else if (AbstractEntitySet.class.isAssignableFrom(type)) {
+ navPropValue = getEntitySetProxy(type, uri);
} else {
final ODataRetrieveResponse<CommonODataEntity> res =
client.getRetrieveRequestFactory().getEntityRequest(uri).execute();
navPropValue = getEntityProxy(
+ uri,
res.getBody(),
property.targetContainer(),
- property.targetEntitySet(),
+ client.getURIBuilder(serviceRoot).appendEntitySetSegment(property.targetEntitySet()).build(),
type,
res.getETag(),
true);
@@ -280,11 +285,11 @@ public abstract class AbstractTypeInvocationHandler extends AbstractInvocationHa
? (AbstractEntityCollection) value : Collections.singleton(value)) {
final InvocationHandler etih = Proxy.getInvocationHandler(link);
- if (!(etih instanceof EntityTypeInvocationHandler)) {
+ if (!(etih instanceof EntityInvocationHandler)) {
throw new IllegalArgumentException("Invalid argument type");
}
- final EntityTypeInvocationHandler linkedHandler = (EntityTypeInvocationHandler) etih;
+ final EntityInvocationHandler linkedHandler = (EntityInvocationHandler) etih;
if (!linkedHandler.getTypeRef().isAnnotationPresent(EntityType.class)) {
throw new IllegalArgumentException("Invalid argument type " + linkedHandler.getTypeRef().getSimpleName());
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/32953c0b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/ComplexFactoryInvocationHandler.java
----------------------------------------------------------------------
diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/ComplexFactoryInvocationHandler.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/ComplexFactoryInvocationHandler.java
index 2f833c6..74ea465 100644
--- a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/ComplexFactoryInvocationHandler.java
+++ b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/ComplexFactoryInvocationHandler.java
@@ -29,22 +29,22 @@ class ComplexFactoryInvocationHandler extends AbstractInvocationHandler implemen
private static final long serialVersionUID = 2629912294765040027L;
- private final EntityTypeInvocationHandler entityHandler;
+ private final EntityInvocationHandler entityHandler;
- private final AbstractTypeInvocationHandler invokerHandler;
+ private final AbstractStructuredInvocationHandler invokerHandler;
static ComplexFactoryInvocationHandler getInstance(
final CommonEdmEnabledODataClient<?> client,
final EntityContainerInvocationHandler containerHandler,
- final EntityTypeInvocationHandler entityHandler,
- final AbstractTypeInvocationHandler targetHandler) {
+ final EntityInvocationHandler entityHandler,
+ final AbstractStructuredInvocationHandler targetHandler) {
return new ComplexFactoryInvocationHandler(client, containerHandler, entityHandler, targetHandler);
}
static ComplexFactoryInvocationHandler getInstance(
- final EntityTypeInvocationHandler entityHandler,
- final AbstractTypeInvocationHandler targetHandler) {
+ final EntityInvocationHandler entityHandler,
+ final AbstractStructuredInvocationHandler targetHandler) {
return new ComplexFactoryInvocationHandler(
entityHandler == null ? null : entityHandler.containerHandler.client,
targetHandler == null
@@ -56,8 +56,8 @@ class ComplexFactoryInvocationHandler extends AbstractInvocationHandler implemen
private ComplexFactoryInvocationHandler(
final CommonEdmEnabledODataClient<?> client,
final EntityContainerInvocationHandler containerHandler,
- final EntityTypeInvocationHandler entityHandler,
- final AbstractTypeInvocationHandler targetHandler) {
+ final EntityInvocationHandler entityHandler,
+ final AbstractStructuredInvocationHandler targetHandler) {
super(client, containerHandler);
this.invokerHandler = targetHandler;
@@ -78,7 +78,7 @@ class ComplexFactoryInvocationHandler extends AbstractInvocationHandler implemen
return Proxy.newProxyInstance(
Thread.currentThread().getContextClassLoader(),
new Class<?>[] {method.getReturnType()},
- ComplexTypeInvocationHandler.getInstance(client, property.name(), method.getReturnType(), entityHandler));
+ ComplexInvocationHandler.getInstance(client, property.name(), method.getReturnType(), entityHandler));
} else {
throw new NoSuchMethodException(method.getName());
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/32953c0b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/ComplexInvocationHandler.java
----------------------------------------------------------------------
diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/ComplexInvocationHandler.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/ComplexInvocationHandler.java
index 2175e8c..72d42e8 100644
--- a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/ComplexInvocationHandler.java
+++ b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/ComplexInvocationHandler.java
@@ -41,15 +41,15 @@ import org.apache.olingo.ext.proxy.context.AttachedEntityStatus;
import org.apache.olingo.ext.proxy.utils.ClassUtils;
import org.apache.olingo.ext.proxy.utils.CoreUtils;
-public class ComplexTypeInvocationHandler extends AbstractTypeInvocationHandler {
+public class ComplexInvocationHandler extends AbstractStructuredInvocationHandler {
private static final long serialVersionUID = 2629912294765040037L;
- public static ComplexTypeInvocationHandler getInstance(
+ public static ComplexInvocationHandler getInstance(
final CommonEdmEnabledODataClient<?> client,
final String propertyName,
final Class<?> reference,
- final EntityTypeInvocationHandler handler) {
+ final EntityInvocationHandler handler) {
final Class<?> complexTypeRef;
if (Collection.class.isAssignableFrom(reference)) {
@@ -69,24 +69,24 @@ public class ComplexTypeInvocationHandler extends AbstractTypeInvocationHandler
final ODataComplexValue<? extends CommonODataProperty> complex =
client.getObjectFactory().newComplexValue(typeName.toString());
- return (ComplexTypeInvocationHandler) ComplexTypeInvocationHandler.getInstance(
+ return (ComplexInvocationHandler) ComplexInvocationHandler.getInstance(
client, complex, complexTypeRef, handler);
}
- public static ComplexTypeInvocationHandler getInstance(
+ public static ComplexInvocationHandler getInstance(
final CommonEdmEnabledODataClient<?> client,
final ODataComplexValue<?> complex,
final Class<?> typeRef,
- final EntityTypeInvocationHandler handler) {
+ final EntityInvocationHandler handler) {
- return new ComplexTypeInvocationHandler(client, complex, typeRef, handler);
+ return new ComplexInvocationHandler(client, complex, typeRef, handler);
}
- public ComplexTypeInvocationHandler(
+ public ComplexInvocationHandler(
final CommonEdmEnabledODataClient<?> client,
final ODataComplexValue<?> complex,
final Class<?> typeRef,
- final EntityTypeInvocationHandler handler) {
+ final EntityInvocationHandler handler) {
super(client, typeRef, complex, handler);
}
@@ -166,7 +166,7 @@ public class ComplexTypeInvocationHandler extends AbstractTypeInvocationHandler
throw new UnsupportedOperationException("Internal object is not navigable");
}
- return retriveNavigationProperty(property, getter);
+ return retrieveNavigationProperty(property, getter, containerHandler.getFactory().getServiceRoot());
}
@Override
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/32953c0b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/ContainerImpl.java
----------------------------------------------------------------------
diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/ContainerImpl.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/ContainerImpl.java
index ab824ec..90a4d75 100644
--- a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/ContainerImpl.java
+++ b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/ContainerImpl.java
@@ -46,7 +46,6 @@ import org.apache.olingo.client.api.communication.response.ODataBatchResponse;
import org.apache.olingo.client.api.communication.response.ODataEntityCreateResponse;
import org.apache.olingo.client.api.communication.response.ODataEntityUpdateResponse;
import org.apache.olingo.client.api.communication.response.ODataResponse;
-import org.apache.olingo.client.api.uri.CommonURIBuilder;
import org.apache.olingo.client.core.communication.request.batch.ODataChangesetResponseItem;
import org.apache.olingo.client.core.uri.URIUtils;
import org.apache.olingo.commons.api.domain.CommonODataEntity;
@@ -75,9 +74,9 @@ class ContainerImpl implements Container {
private final CommonEdmEnabledODataClient<?> client;
- private final EntityContainerFactory factory;
+ private final EntityContainerFactory<?> factory;
- ContainerImpl(final CommonEdmEnabledODataClient<?> client, final EntityContainerFactory factory) {
+ ContainerImpl(final CommonEdmEnabledODataClient<?> client, final EntityContainerFactory<?> factory) {
this.client = client;
this.factory = factory;
}
@@ -88,7 +87,7 @@ class ContainerImpl implements Container {
@Override
public void flush() {
final CommonODataBatchRequest request = client.getBatchRequestFactory().getBatchRequest(client.getServiceRoot());
- ((ODataRequest)request).setAccept(client.getConfiguration().getDefaultBatchAcceptFormat());
+ ((ODataRequest) request).setAccept(client.getConfiguration().getDefaultBatchAcceptFormat());
final BatchStreamManager streamManager = (BatchStreamManager) ((ODataStreamedRequest) request).execute();
@@ -138,13 +137,13 @@ class ContainerImpl implements Container {
throw new IllegalStateException("Transaction failed: " + res.getStatusMessage());
}
- final EntityTypeInvocationHandler handler = items.get(changesetItemId);
+ final EntityInvocationHandler handler = items.get(changesetItemId);
if (handler != null) {
- if (res instanceof ODataEntityCreateResponse) {
+ if (res instanceof ODataEntityCreateResponse && res.getStatusCode() == 201) {
handler.setEntity(((ODataEntityCreateResponse) res).getBody());
LOG.debug("Upgrade created object '{}'", handler);
- } else if (res instanceof ODataEntityUpdateResponse) {
+ } else if (res instanceof ODataEntityUpdateResponse && res.getStatusCode() == 200) {
handler.setEntity(((ODataEntityUpdateResponse) res).getBody());
LOG.debug("Upgrade updated object '{}'", handler);
}
@@ -156,7 +155,7 @@ class ContainerImpl implements Container {
}
private void batch(
- final EntityTypeInvocationHandler handler,
+ final EntityInvocationHandler handler,
final CommonODataEntity entity,
final ODataChangeset changeset) {
@@ -181,19 +180,17 @@ class ContainerImpl implements Container {
}
private void batchCreate(
- final EntityTypeInvocationHandler handler,
+ final EntityInvocationHandler handler,
final CommonODataEntity entity,
final ODataChangeset changeset) {
LOG.debug("Create '{}'", handler);
- final CommonURIBuilder<?> uriBuilder = client.getURIBuilder(factory.getServiceRoot()).
- appendEntitySetSegment(handler.getEntitySetName());
- changeset.addRequest(client.getCUDRequestFactory().getEntityCreateRequest(uriBuilder.build(), entity));
+ changeset.addRequest(client.getCUDRequestFactory().getEntityCreateRequest(handler.getEntitySetURI(), entity));
}
private void batchUpdateMediaEntity(
- final EntityTypeInvocationHandler handler,
+ final EntityInvocationHandler handler,
final URI uri,
final InputStream input,
final ODataChangeset changeset) {
@@ -215,7 +212,7 @@ class ContainerImpl implements Container {
}
private void batchUpdateMediaResource(
- final EntityTypeInvocationHandler handler,
+ final EntityInvocationHandler handler,
final URI uri,
final InputStream input,
final ODataChangeset changeset) {
@@ -232,18 +229,20 @@ class ContainerImpl implements Container {
}
private void batchUpdate(
- final EntityTypeInvocationHandler handler,
+ final EntityInvocationHandler handler,
final CommonODataEntity changes,
final ODataChangeset changeset) {
- LOG.debug("Update '{}'", changes.getEditLink());
+ LOG.debug("Update '{}'", handler.getEntityURI());
final ODataEntityUpdateRequest<CommonODataEntity> req =
client.getServiceVersion().compareTo(ODataServiceVersion.V30) <= 0
? ((org.apache.olingo.client.api.v3.EdmEnabledODataClient) client).getCUDRequestFactory().
- getEntityUpdateRequest(org.apache.olingo.client.api.communication.request.cud.v3.UpdateType.PATCH, changes)
+ getEntityUpdateRequest(handler.getEntityURI(),
+ org.apache.olingo.client.api.communication.request.cud.v3.UpdateType.PATCH, changes)
: ((org.apache.olingo.client.api.v4.EdmEnabledODataClient) client).getCUDRequestFactory().
- getEntityUpdateRequest(org.apache.olingo.client.api.communication.request.cud.v4.UpdateType.PATCH, changes);
+ getEntityUpdateRequest(handler.getEntityURI(),
+ org.apache.olingo.client.api.communication.request.cud.v4.UpdateType.PATCH, changes);
req.setPrefer(new ODataPreferences(client.getServiceVersion()).returnContent());
@@ -255,7 +254,7 @@ class ContainerImpl implements Container {
}
private void batchUpdate(
- final EntityTypeInvocationHandler handler,
+ final EntityInvocationHandler handler,
final URI uri,
final CommonODataEntity changes,
final ODataChangeset changeset) {
@@ -265,11 +264,11 @@ class ContainerImpl implements Container {
final ODataEntityUpdateRequest<CommonODataEntity> req =
client.getServiceVersion().compareTo(ODataServiceVersion.V30) <= 0
? ((org.apache.olingo.client.api.v3.EdmEnabledODataClient) client).getCUDRequestFactory().
- getEntityUpdateRequest(
- uri, org.apache.olingo.client.api.communication.request.cud.v3.UpdateType.PATCH, changes)
+ getEntityUpdateRequest(uri,
+ org.apache.olingo.client.api.communication.request.cud.v3.UpdateType.PATCH, changes)
: ((org.apache.olingo.client.api.v4.EdmEnabledODataClient) client).getCUDRequestFactory().
- getEntityUpdateRequest(
- uri, org.apache.olingo.client.api.communication.request.cud.v4.UpdateType.PATCH, changes);
+ getEntityUpdateRequest(uri,
+ org.apache.olingo.client.api.communication.request.cud.v4.UpdateType.PATCH, changes);
req.setPrefer(new ODataPreferences(client.getServiceVersion()).returnContent());
@@ -281,14 +280,14 @@ class ContainerImpl implements Container {
}
private void batchDelete(
- final EntityTypeInvocationHandler handler,
+ final EntityInvocationHandler handler,
final CommonODataEntity entity,
final ODataChangeset changeset) {
- LOG.debug("Delete '{}'", entity.getEditLink());
+ final URI deleteURI = handler.getEntityURI() == null ? entity.getEditLink() : handler.getEntityURI();
+ LOG.debug("Delete '{}'", deleteURI);
- final ODataDeleteRequest req = client.getCUDRequestFactory().getDeleteRequest(URIUtils.getURI(
- factory.getServiceRoot(), entity.getEditLink().toASCIIString()));
+ final ODataDeleteRequest req = client.getCUDRequestFactory().getDeleteRequest(deleteURI);
if (StringUtils.isNotBlank(handler.getETag())) {
req.setIfMatch(handler.getETag());
@@ -298,7 +297,7 @@ class ContainerImpl implements Container {
}
private int processEntityContext(
- final EntityTypeInvocationHandler handler,
+ final EntityInvocationHandler handler,
int pos,
final TransactionItems items,
final List<EntityLinkDesc> delayedUpdates,
@@ -323,14 +322,14 @@ class ContainerImpl implements Container {
? ODataLinkType.ENTITY_SET_NAVIGATION
: ODataLinkType.ENTITY_NAVIGATION;
- final Set<EntityTypeInvocationHandler> toBeLinked = new HashSet<EntityTypeInvocationHandler>();
+ final Set<EntityInvocationHandler> toBeLinked = new HashSet<EntityInvocationHandler>();
final String serviceRoot = factory.getServiceRoot();
for (Object proxy : type == ODataLinkType.ENTITY_SET_NAVIGATION
? (Collection) property.getValue() : Collections.singleton(property.getValue())) {
- final EntityTypeInvocationHandler target =
- (EntityTypeInvocationHandler) Proxy.getInvocationHandler(proxy);
+ final EntityInvocationHandler target =
+ (EntityInvocationHandler) Proxy.getInvocationHandler(proxy);
final AttachedEntityStatus status =
EntityContainerFactory.getContext().entityContext().getStatus(target);
@@ -360,8 +359,7 @@ class ContainerImpl implements Container {
// create the link for the current object
LOG.debug("'{}' from '{}' to (${}) '{}'", type.name(), handler, targetPos, target);
- entity.addLink(
- buildNavigationLink(property.getKey().name(), URI.create("$" + targetPos), type));
+ entity.addLink(buildNavigationLink(property.getKey().name(), URI.create("$" + targetPos), type));
}
}
}
@@ -396,7 +394,7 @@ class ContainerImpl implements Container {
final URI targetURI = currentStatus == AttachedEntityStatus.NEW
? URI.create("$" + startingPos + "/$value")
: URIUtils.getURI(
- factory.getServiceRoot(), handler.getEntity().getEditLink().toASCIIString() + "/$value");
+ factory.getServiceRoot(), handler.getEntity().getEditLink().toASCIIString() + "/$value");
batchUpdateMediaEntity(handler, targetURI, handler.getStreamChanges(), changeset);
@@ -409,8 +407,8 @@ class ContainerImpl implements Container {
for (Map.Entry<String, InputStream> streamedChanges : handler.getStreamedPropertyChanges().entrySet()) {
final URI targetURI = currentStatus == AttachedEntityStatus.NEW
? URI.create("$" + startingPos) : URIUtils.getURI(
- factory.getServiceRoot(),
- CoreUtils.getMediaEditLink(streamedChanges.getKey(), entity).toASCIIString());
+ factory.getServiceRoot(),
+ CoreUtils.getMediaEditLink(streamedChanges.getKey(), entity).toASCIIString());
batchUpdateMediaResource(handler, targetURI, streamedChanges.getValue(), changeset);
@@ -467,7 +465,7 @@ class ContainerImpl implements Container {
sourceURI = URI.create("$" + sourcePos);
}
- for (EntityTypeInvocationHandler target : delayedUpdate.getTargets()) {
+ for (EntityInvocationHandler target : delayedUpdate.getTargets()) {
status = EntityContainerFactory.getContext().entityContext().getStatus(target);
final URI targetURI;
@@ -492,11 +490,11 @@ class ContainerImpl implements Container {
private class TransactionItems {
- private final List<EntityTypeInvocationHandler> keys = new ArrayList<EntityTypeInvocationHandler>();
+ private final List<EntityInvocationHandler> keys = new ArrayList<EntityInvocationHandler>();
private final List<Integer> values = new ArrayList<Integer>();
- public EntityTypeInvocationHandler get(final Integer value) {
+ public EntityInvocationHandler get(final Integer value) {
if (value != null && values.contains(value)) {
return keys.get(values.indexOf(value));
} else {
@@ -504,7 +502,7 @@ class ContainerImpl implements Container {
}
}
- public Integer get(final EntityTypeInvocationHandler key) {
+ public Integer get(final EntityInvocationHandler key) {
if (key != null && keys.contains(key)) {
return values.get(keys.indexOf(key));
} else {
@@ -512,14 +510,14 @@ class ContainerImpl implements Container {
}
}
- public void remove(final EntityTypeInvocationHandler key) {
+ public void remove(final EntityInvocationHandler key) {
if (keys.contains(key)) {
values.remove(keys.indexOf(key));
keys.remove(key);
}
}
- public void put(final EntityTypeInvocationHandler key, final Integer value) {
+ public void put(final EntityInvocationHandler key, final Integer value) {
// replace just in case of null current value; otherwise add the new entry
if (key != null && keys.contains(key) && values.get(keys.indexOf(key)) == null) {
remove(key);
@@ -534,7 +532,7 @@ class ContainerImpl implements Container {
return sortedValues;
}
- public boolean contains(final EntityTypeInvocationHandler key) {
+ public boolean contains(final EntityInvocationHandler key) {
return keys.contains(key);
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/32953c0b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/EntityContainerInvocationHandler.java
----------------------------------------------------------------------
diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/EntityContainerInvocationHandler.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/EntityContainerInvocationHandler.java
index 299a842..17f2f5c 100644
--- a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/EntityContainerInvocationHandler.java
+++ b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/EntityContainerInvocationHandler.java
@@ -113,13 +113,13 @@ public final class EntityContainerInvocationHandler extends AbstractInvocationHa
return Proxy.newProxyInstance(
Thread.currentThread().getContextClassLoader(),
new Class<?>[] {returnType},
- SingletonInvocationHandler.getInstance(returnType, this));
+ SingletonInvocationHandler.getInstance(returnType, this, singleton.name()));
}
} else {
return Proxy.newProxyInstance(
Thread.currentThread().getContextClassLoader(),
new Class<?>[] {returnType},
- EntitySetInvocationHandler.getInstance(returnType, this));
+ EntitySetInvocationHandler.getInstance(returnType, this, entitySet.name()));
}
throw new NoSuchMethodException(method.getName());
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/32953c0b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/EntityInvocationHandler.java
----------------------------------------------------------------------
diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/EntityInvocationHandler.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/EntityInvocationHandler.java
index 57b73d0..361c140 100644
--- a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/EntityInvocationHandler.java
+++ b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/EntityInvocationHandler.java
@@ -47,10 +47,12 @@ import org.apache.olingo.ext.proxy.context.AttachedEntityStatus;
import org.apache.olingo.ext.proxy.context.EntityUUID;
import org.apache.olingo.ext.proxy.utils.CoreUtils;
-public class EntityTypeInvocationHandler extends AbstractTypeInvocationHandler {
+public class EntityInvocationHandler extends AbstractStructuredInvocationHandler {
private static final long serialVersionUID = 2629912294765040037L;
+ private final URI entityURI;
+
protected Map<String, Object> propertyChanges = new HashMap<String, Object>();
protected Map<NavigationProperty, Object> linkChanges = new HashMap<NavigationProperty, Object>();
@@ -65,41 +67,46 @@ public class EntityTypeInvocationHandler extends AbstractTypeInvocationHandler {
private EntityUUID uuid;
- static EntityTypeInvocationHandler getInstance(
+ static EntityInvocationHandler getInstance(
+ final URI entityURI,
final CommonODataEntity entity,
final EntitySetInvocationHandler<?, ?, ?> entitySet,
final Class<?> typeRef) {
return getInstance(
+ entityURI,
entity,
- entitySet.getEntitySetName(),
+ entitySet.getEntitySetURI(),
typeRef,
entitySet.containerHandler);
}
- static EntityTypeInvocationHandler getInstance(
+ static EntityInvocationHandler getInstance(
+ final URI entityURI,
final CommonODataEntity entity,
- final String entitySetName,
+ final URI entitySetURI,
final Class<?> typeRef,
final EntityContainerInvocationHandler containerHandler) {
- return new EntityTypeInvocationHandler(entity, entitySetName, typeRef, containerHandler);
+ return new EntityInvocationHandler(entityURI, entity, entitySetURI, typeRef, containerHandler);
}
- private EntityTypeInvocationHandler(
+ private EntityInvocationHandler(
+ final URI entityURI,
final CommonODataEntity entity,
- final String entitySetName,
+ final URI entitySetURI,
final Class<?> typeRef,
final EntityContainerInvocationHandler containerHandler) {
super(containerHandler.getClient(), typeRef, (ODataLinked) entity, containerHandler);
+ this.entityURI = entityURI;
this.internal = entity;
getEntity().setMediaEntity(typeRef.getAnnotation(EntityType.class).hasStream());
this.uuid = new EntityUUID(
containerHandler.getEntityContainerName(),
- entitySetName,
+ entitySetURI,
typeRef,
CoreUtils.getKey(client, typeRef, entity));
}
@@ -110,7 +117,7 @@ public class EntityTypeInvocationHandler extends AbstractTypeInvocationHandler {
this.uuid = new EntityUUID(
getUUID().getContainerName(),
- getUUID().getEntitySetName(),
+ getUUID().getEntitySetURI(),
getUUID().getType(),
CoreUtils.getKey(client, typeRef, entity));
@@ -129,14 +136,18 @@ public class EntityTypeInvocationHandler extends AbstractTypeInvocationHandler {
return uuid.getContainerName();
}
- public String getEntitySetName() {
- return uuid.getEntitySetName();
+ public URI getEntitySetURI() {
+ return uuid.getEntitySetURI();
}
public final CommonODataEntity getEntity() {
return (CommonODataEntity) internal;
}
+ public URI getEntityURI() {
+ return entityURI;
+ }
+
/**
* Gets the current ETag defined into the wrapped entity.
*
@@ -240,9 +251,9 @@ public class EntityTypeInvocationHandler extends AbstractTypeInvocationHandler {
for (Object item : coll) {
if (item instanceof Proxy) {
final InvocationHandler handler = Proxy.getInvocationHandler(item);
- if ((handler instanceof ComplexTypeInvocationHandler)
- && ((ComplexTypeInvocationHandler) handler).getEntityHandler() == null) {
- ((ComplexTypeInvocationHandler) handler).setEntityHandler(this);
+ if ((handler instanceof ComplexInvocationHandler)
+ && ((ComplexInvocationHandler) handler).getEntityHandler() == null) {
+ ((ComplexInvocationHandler) handler).setEntityHandler(this);
}
}
}
@@ -277,7 +288,6 @@ public class EntityTypeInvocationHandler extends AbstractTypeInvocationHandler {
}
public InputStream getStream() {
-
final URI contentSource = getEntity().getMediaContentSource();
if (this.stream == null
@@ -297,7 +307,6 @@ public class EntityTypeInvocationHandler extends AbstractTypeInvocationHandler {
}
public Object getStreamedProperty(final Property property) {
-
InputStream res = streamedPropertyChanges.get(property.name());
try {
@@ -334,7 +343,7 @@ public class EntityTypeInvocationHandler extends AbstractTypeInvocationHandler {
if (linkChanges.containsKey(property)) {
navPropValue = linkChanges.get(property);
} else {
- navPropValue = retriveNavigationProperty(property, getter);
+ navPropValue = retrieveNavigationProperty(property, getter, containerHandler.getFactory().getServiceRoot());
}
if (navPropValue != null) {
@@ -370,7 +379,7 @@ public class EntityTypeInvocationHandler extends AbstractTypeInvocationHandler {
@Override
public boolean equals(final Object obj) {
- return obj instanceof EntityTypeInvocationHandler
- && ((EntityTypeInvocationHandler) obj).getUUID().equals(uuid);
+ return obj instanceof EntityInvocationHandler
+ && ((EntityInvocationHandler) obj).getUUID().equals(uuid);
}
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/32953c0b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/EntitySetInvocationHandler.java
----------------------------------------------------------------------
diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/EntitySetInvocationHandler.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/EntitySetInvocationHandler.java
index 18c2ce2..6e70a0e 100644
--- a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/EntitySetInvocationHandler.java
+++ b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/EntitySetInvocationHandler.java
@@ -73,8 +73,6 @@ class EntitySetInvocationHandler<
*/
private static final Logger LOG = LoggerFactory.getLogger(EntitySetInvocationHandler.class);
- private final String entitySetName;
-
private final boolean isSingleton;
private final Class<T> typeRef;
@@ -85,20 +83,38 @@ class EntitySetInvocationHandler<
@SuppressWarnings({"rawtypes", "unchecked"})
static EntitySetInvocationHandler getInstance(
- final Class<?> ref, final EntityContainerInvocationHandler containerHandler) {
+ final Class<?> ref, final EntityContainerInvocationHandler containerHandler, final String entitySetName) {
+
+ final CommonURIBuilder<?> uriBuilder = containerHandler.getClient().
+ getURIBuilder(containerHandler.getFactory().getServiceRoot());
- return new EntitySetInvocationHandler(ref, containerHandler, (ref.getAnnotation(EntitySet.class)).name());
+ final StringBuilder entitySetSegment = new StringBuilder();
+ if (!containerHandler.isDefaultEntityContainer()) {
+ entitySetSegment.append(containerHandler.getEntityContainerName()).append('.');
+ }
+ entitySetSegment.append(entitySetName);
+
+ uriBuilder.appendEntitySetSegment(entitySetSegment.toString());
+
+ return new EntitySetInvocationHandler(ref, containerHandler, entitySetName, uriBuilder.build());
+ }
+
+ @SuppressWarnings({"rawtypes", "unchecked"})
+ static EntitySetInvocationHandler getInstance(
+ final Class<?> ref, final EntityContainerInvocationHandler containerHandler, final URI uri) {
+
+ return new EntitySetInvocationHandler(ref, containerHandler, (ref.getAnnotation(EntitySet.class)).name(), uri);
}
@SuppressWarnings("unchecked")
protected EntitySetInvocationHandler(
final Class<?> ref,
final EntityContainerInvocationHandler containerHandler,
- final String entitySetName) {
+ final String entitySetName,
+ final URI uri) {
super(containerHandler.getClient(), containerHandler);
- this.entitySetName = entitySetName;
this.isSingleton = AbstractSingleton.class.isAssignableFrom(ref);
final Type[] entitySetParams = ((ParameterizedType) ref.getGenericInterfaces()[0]).getActualTypeArguments();
@@ -106,16 +122,7 @@ class EntitySetInvocationHandler<
this.typeRef = (Class<T>) entitySetParams[0];
this.collTypeRef = (Class<EC>) entitySetParams[2];
- final CommonURIBuilder<?> uriBuilder = client.getURIBuilder(containerHandler.getFactory().getServiceRoot());
-
- final StringBuilder entitySetSegment = new StringBuilder();
- if (!containerHandler.isDefaultEntityContainer()) {
- entitySetSegment.append(containerHandler.getEntityContainerName()).append('.');
- }
- entitySetSegment.append(entitySetName);
-
- uriBuilder.appendEntitySetSegment(entitySetSegment.toString());
- this.uri = uriBuilder.build();
+ this.uri = uri;
}
protected Class<T> getTypeRef() {
@@ -126,11 +133,7 @@ class EntitySetInvocationHandler<
return collTypeRef;
}
- protected String getEntitySetName() {
- return entitySetName;
- }
-
- protected URI getURI() {
+ protected URI getEntitySetURI() {
return uri;
}
@@ -155,8 +158,8 @@ class EntitySetInvocationHandler<
final CommonODataEntity entity = client.getObjectFactory().newEntity(
new FullQualifiedName(containerHandler.getSchemaName(), ClassUtils.getEntityTypeName(reference)));
- final EntityTypeInvocationHandler handler =
- EntityTypeInvocationHandler.getInstance(entity, entitySetName, reference, containerHandler);
+ final EntityInvocationHandler handler =
+ EntityInvocationHandler.getInstance(null, entity, uri, reference, containerHandler);
EntityContainerFactory.getContext().entityContext().attachNew(handler);
return (NE) Proxy.newProxyInstance(
@@ -188,7 +191,7 @@ class EntitySetInvocationHandler<
try {
result = get(key) != null;
} catch (Exception e) {
- LOG.error("Could not check existence of {}({})", this.entitySetName, key, e);
+ LOG.error("Could not check existence of {}({})", this.uri, key, e);
}
return result;
@@ -230,10 +233,10 @@ class EntitySetInvocationHandler<
throw new IllegalArgumentException("Null key");
}
- final EntityUUID uuid = new EntityUUID(containerHandler.getEntityContainerName(), entitySetName, typeRef, key);
+ final EntityUUID uuid = new EntityUUID(containerHandler.getEntityContainerName(), uri, typeRef, key);
LOG.debug("Ask for '{}({})'", typeRef.getSimpleName(), key);
- EntityTypeInvocationHandler handler = EntityContainerFactory.getContext().entityContext().getEntity(uuid);
+ EntityInvocationHandler handler = EntityContainerFactory.getContext().entityContext().getEntity(uuid);
if (handler == null) {
// not yet attached: search against the service
@@ -261,7 +264,7 @@ class EntitySetInvocationHandler<
throw new IllegalArgumentException("Invalid " + typeRef.getSimpleName() + "(" + key + ")");
}
- handler = EntityTypeInvocationHandler.getInstance(entity, this, typeRef);
+ handler = EntityInvocationHandler.getInstance(uriBuilder.build(), entity, this, typeRef);
handler.setETag(etag);
} catch (Exception e) {
LOG.info("Entity '" + uuid + "' not found", e);
@@ -301,9 +304,10 @@ class EntitySetInvocationHandler<
final List<S> items = new ArrayList<S>(entities.size());
for (CommonODataEntity entity : entities) {
- final EntityTypeInvocationHandler handler = EntityTypeInvocationHandler.getInstance(entity, this, typeRef);
+ final EntityInvocationHandler handler =
+ EntityInvocationHandler.getInstance(entity.getEditLink(), entity, this, typeRef);
- final EntityTypeInvocationHandler handlerInTheContext =
+ final EntityInvocationHandler handlerInTheContext =
EntityContainerFactory.getContext().entityContext().getEntity(handler.getUUID());
items.add((S) Proxy.newProxyInstance(
@@ -396,16 +400,16 @@ class EntitySetInvocationHandler<
public void delete(final KEY key) throws IllegalArgumentException {
final EntityContext entityContext = EntityContainerFactory.getContext().entityContext();
- EntityTypeInvocationHandler entity = entityContext.getEntity(new EntityUUID(
+ EntityInvocationHandler entity = entityContext.getEntity(new EntityUUID(
containerHandler.getEntityContainerName(),
- entitySetName,
+ uri,
typeRef,
key));
if (entity == null) {
// search for entity
final T searched = get(key);
- entity = (EntityTypeInvocationHandler) Proxy.getInvocationHandler(searched);
+ entity = (EntityInvocationHandler) Proxy.getInvocationHandler(searched);
entityContext.attach(entity, AttachedEntityStatus.DELETED);
} else {
entityContext.setStatus(entity, AttachedEntityStatus.DELETED);
@@ -417,7 +421,7 @@ class EntitySetInvocationHandler<
final EntityContext entityContext = EntityContainerFactory.getContext().entityContext();
for (T en : entities) {
- final EntityTypeInvocationHandler entity = (EntityTypeInvocationHandler) Proxy.getInvocationHandler(en);
+ final EntityInvocationHandler entity = (EntityInvocationHandler) Proxy.getInvocationHandler(en);
if (entityContext.isAttached(entity)) {
entityContext.setStatus(entity, AttachedEntityStatus.DELETED);
} else {
@@ -426,7 +430,7 @@ class EntitySetInvocationHandler<
}
}
- private boolean isDeleted(final EntityTypeInvocationHandler handler) {
+ private boolean isDeleted(final EntityInvocationHandler handler) {
return EntityContainerFactory.getContext().entityContext().getStatus(handler) == AttachedEntityStatus.DELETED;
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/32953c0b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/OperationInvocationHandler.java
----------------------------------------------------------------------
diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/OperationInvocationHandler.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/OperationInvocationHandler.java
index cdc0bfb..69e1f9b 100644
--- a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/OperationInvocationHandler.java
+++ b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/OperationInvocationHandler.java
@@ -55,7 +55,7 @@ class OperationInvocationHandler extends AbstractInvocationHandler implements Op
return new OperationInvocationHandler(containerHandler);
}
- static OperationInvocationHandler getInstance(final EntityTypeInvocationHandler entityHandler) {
+ static OperationInvocationHandler getInstance(final EntityInvocationHandler entityHandler) {
return new OperationInvocationHandler(entityHandler);
}
@@ -74,7 +74,7 @@ class OperationInvocationHandler extends AbstractInvocationHandler implements Op
this.serviceRoot = containerHandler.getFactory().getServiceRoot();
}
- private OperationInvocationHandler(final EntityTypeInvocationHandler entityHandler) {
+ private OperationInvocationHandler(final EntityInvocationHandler entityHandler) {
super(entityHandler.getClient(), entityHandler.containerHandler);
this.target = entityHandler;
@@ -128,7 +128,7 @@ class OperationInvocationHandler extends AbstractInvocationHandler implements Op
final Map.Entry<URI, EdmOperation> edmOperation;
if (target instanceof EntityContainerInvocationHandler) {
edmOperation = getUnboundOperation(operation, parameterNames);
- } else if (target instanceof EntityTypeInvocationHandler) {
+ } else if (target instanceof EntityInvocationHandler) {
edmOperation = getBoundOperation(operation, parameterNames);
} else if (target instanceof EntityCollectionInvocationHandler) {
edmOperation = getCollectionBoundOperation(operation, parameterNames);
@@ -161,7 +161,7 @@ class OperationInvocationHandler extends AbstractInvocationHandler implements Op
}
private Map.Entry<URI, EdmOperation> getBoundOperation(final Operation operation, final List<String> parameterNames) {
- final CommonODataEntity entity = ((EntityTypeInvocationHandler) target).getEntity();
+ final CommonODataEntity entity = ((EntityInvocationHandler) target).getEntity();
ODataOperation boundOp = entity.getOperation(operation.name());
if (boundOp == null) {
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/32953c0b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/SingletonInvocationHandler.java
----------------------------------------------------------------------
diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/SingletonInvocationHandler.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/SingletonInvocationHandler.java
index 4ec75eb..57b1b39 100644
--- a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/SingletonInvocationHandler.java
+++ b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/SingletonInvocationHandler.java
@@ -22,7 +22,6 @@ import java.io.Serializable;
import java.lang.reflect.Method;
import org.apache.olingo.ext.proxy.api.AbstractEntityCollection;
import org.apache.olingo.ext.proxy.api.AbstractSingleton;
-import org.apache.olingo.ext.proxy.api.annotations.Singleton;
public class SingletonInvocationHandler<
T extends Serializable, KEY extends Serializable, EC extends AbstractEntityCollection<T>>
@@ -33,18 +32,19 @@ public class SingletonInvocationHandler<
@SuppressWarnings({"rawtypes", "unchecked"})
static SingletonInvocationHandler getInstance(
- final Class<?> ref, final EntityContainerInvocationHandler containerHandler) {
+ final Class<?> ref, final EntityContainerInvocationHandler containerHandler, final String singletonName) {
- return new SingletonInvocationHandler(ref, containerHandler);
+ return new SingletonInvocationHandler(ref, containerHandler, singletonName);
}
private final EntitySetInvocationHandler<?, ?, ?> entitySetHandler;
@SuppressWarnings({"rawtypes", "unchecked"})
- private SingletonInvocationHandler(final Class<?> ref, final EntityContainerInvocationHandler containerHandler) {
+ private SingletonInvocationHandler(
+ final Class<?> ref, final EntityContainerInvocationHandler containerHandler, final String singletonName) {
+
super(containerHandler.getClient(), containerHandler);
- this.entitySetHandler =
- new EntitySetInvocationHandler(ref, containerHandler, (ref.getAnnotation(Singleton.class)).name());
+ this.entitySetHandler = EntitySetInvocationHandler.getInstance(ref, containerHandler, singletonName);
}
@Override
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/32953c0b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/context/AttachedEntity.java
----------------------------------------------------------------------
diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/context/AttachedEntity.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/context/AttachedEntity.java
index 96cad42..8126bcc 100644
--- a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/context/AttachedEntity.java
+++ b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/context/AttachedEntity.java
@@ -18,20 +18,20 @@
*/
package org.apache.olingo.ext.proxy.context;
-import org.apache.olingo.ext.proxy.commons.EntityTypeInvocationHandler;
+import org.apache.olingo.ext.proxy.commons.EntityInvocationHandler;
public class AttachedEntity {
- private final EntityTypeInvocationHandler entity;
+ private final EntityInvocationHandler entity;
private final AttachedEntityStatus status;
- public AttachedEntity(final EntityTypeInvocationHandler entity, final AttachedEntityStatus status) {
+ public AttachedEntity(final EntityInvocationHandler entity, final AttachedEntityStatus status) {
this.entity = entity;
this.status = status;
}
- public EntityTypeInvocationHandler getEntity() {
+ public EntityInvocationHandler getEntity() {
return entity;
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/32953c0b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/context/EntityContext.java
----------------------------------------------------------------------
diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/context/EntityContext.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/context/EntityContext.java
index ab2c9a8..2b42cd1 100644
--- a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/context/EntityContext.java
+++ b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/context/EntityContext.java
@@ -24,7 +24,7 @@ import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
-import org.apache.olingo.ext.proxy.commons.EntityTypeInvocationHandler;
+import org.apache.olingo.ext.proxy.commons.EntityInvocationHandler;
/**
* Entity context.
@@ -36,16 +36,16 @@ public class EntityContext implements Iterable<AttachedEntity> {
* <br/>
* This map have to be used to search for entities by key.
*/
- private final Map<EntityUUID, EntityTypeInvocationHandler> searchableEntities =
- new HashMap<EntityUUID, EntityTypeInvocationHandler>();
+ private final Map<EntityUUID, EntityInvocationHandler> searchableEntities =
+ new HashMap<EntityUUID, EntityInvocationHandler>();
/**
* All attached entities (new entities included).
* <br/>
* Attachment order will be maintained.
*/
- private final Map<EntityTypeInvocationHandler, AttachedEntityStatus> allAttachedEntities =
- new LinkedHashMap<EntityTypeInvocationHandler, AttachedEntityStatus>();
+ private final Map<EntityInvocationHandler, AttachedEntityStatus> allAttachedEntities =
+ new LinkedHashMap<EntityInvocationHandler, AttachedEntityStatus>();
/**
* Attaches an entity with status <tt>NEW</tt>.
@@ -55,7 +55,7 @@ public class EntityContext implements Iterable<AttachedEntity> {
* @see AttachedEntityStatus
* @param entity entity to be attached.
*/
- public void attachNew(final EntityTypeInvocationHandler entity) {
+ public void attachNew(final EntityInvocationHandler entity) {
if (allAttachedEntities.containsKey(entity)) {
throw new IllegalStateException("An entity with the same key has already been attached");
}
@@ -70,7 +70,7 @@ public class EntityContext implements Iterable<AttachedEntity> {
* @see AttachedEntityStatus
* @param entity entity to be attached.
*/
- public void attach(final EntityTypeInvocationHandler entity) {
+ public void attach(final EntityInvocationHandler entity) {
attach(entity, AttachedEntityStatus.ATTACHED);
}
@@ -83,7 +83,7 @@ public class EntityContext implements Iterable<AttachedEntity> {
* @param entity entity to be attached.
* @param status status.
*/
- public void attach(final EntityTypeInvocationHandler entity, final AttachedEntityStatus status) {
+ public void attach(final EntityInvocationHandler entity, final AttachedEntityStatus status) {
if (isAttached(entity)) {
throw new IllegalStateException("An entity with the same profile has already been attached");
}
@@ -100,7 +100,7 @@ public class EntityContext implements Iterable<AttachedEntity> {
*
* @param entity entity to be detached.
*/
- public void detach(final EntityTypeInvocationHandler entity) {
+ public void detach(final EntityInvocationHandler entity) {
if (searchableEntities.containsKey(entity.getUUID())) {
searchableEntities.remove(entity.getUUID());
}
@@ -123,7 +123,7 @@ public class EntityContext implements Iterable<AttachedEntity> {
* @param uuid entity key.
* @return retrieved entity.
*/
- public EntityTypeInvocationHandler getEntity(final EntityUUID uuid) {
+ public EntityInvocationHandler getEntity(final EntityUUID uuid) {
return searchableEntities.get(uuid);
}
@@ -133,7 +133,7 @@ public class EntityContext implements Iterable<AttachedEntity> {
* @param entity entity to be retrieved.
* @return attached entity status.
*/
- public AttachedEntityStatus getStatus(final EntityTypeInvocationHandler entity) {
+ public AttachedEntityStatus getStatus(final EntityInvocationHandler entity) {
if (!isAttached(entity)) {
throw new IllegalStateException("Entity is not in the context");
}
@@ -147,7 +147,7 @@ public class EntityContext implements Iterable<AttachedEntity> {
* @param entity attached entity to be modified.
* @param status new status.
*/
- public void setStatus(final EntityTypeInvocationHandler entity, final AttachedEntityStatus status) {
+ public void setStatus(final EntityInvocationHandler entity, final AttachedEntityStatus status) {
if (!isAttached(entity)) {
throw new IllegalStateException("Entity is not in the context");
}
@@ -177,7 +177,7 @@ public class EntityContext implements Iterable<AttachedEntity> {
* @param entity entity.
* @return <tt>true</tt> if is attached; <tt>false</tt> otherwise.
*/
- public boolean isAttached(final EntityTypeInvocationHandler entity) {
+ public boolean isAttached(final EntityInvocationHandler entity) {
return allAttachedEntities.containsKey(entity)
|| (entity.getUUID().getKey() != null && searchableEntities.containsKey(entity.getUUID()));
}
@@ -190,7 +190,7 @@ public class EntityContext implements Iterable<AttachedEntity> {
@Override
public Iterator<AttachedEntity> iterator() {
final List<AttachedEntity> res = new ArrayList<AttachedEntity>();
- for (Map.Entry<EntityTypeInvocationHandler, AttachedEntityStatus> attachedEntity : allAttachedEntities.
+ for (Map.Entry<EntityInvocationHandler, AttachedEntityStatus> attachedEntity : allAttachedEntities.
entrySet()) {
res.add(new AttachedEntity(attachedEntity.getKey(), attachedEntity.getValue()));
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/32953c0b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/context/EntityLinkDesc.java
----------------------------------------------------------------------
diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/context/EntityLinkDesc.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/context/EntityLinkDesc.java
index 791f471..3c8dadd 100644
--- a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/context/EntityLinkDesc.java
+++ b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/context/EntityLinkDesc.java
@@ -26,7 +26,7 @@ import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import org.apache.olingo.commons.api.domain.ODataLinkType;
-import org.apache.olingo.ext.proxy.commons.EntityTypeInvocationHandler;
+import org.apache.olingo.ext.proxy.commons.EntityInvocationHandler;
public class EntityLinkDesc implements Serializable {
@@ -34,16 +34,16 @@ public class EntityLinkDesc implements Serializable {
private final String sourceName;
- private final EntityTypeInvocationHandler source;
+ private final EntityInvocationHandler source;
- private final Collection<EntityTypeInvocationHandler> targets;
+ private final Collection<EntityInvocationHandler> targets;
private final ODataLinkType type;
public EntityLinkDesc(
final String sourceName,
- final EntityTypeInvocationHandler source,
- final Collection<EntityTypeInvocationHandler> target,
+ final EntityInvocationHandler source,
+ final Collection<EntityInvocationHandler> target,
final ODataLinkType type) {
this.sourceName = sourceName;
this.source = source;
@@ -53,12 +53,12 @@ public class EntityLinkDesc implements Serializable {
public EntityLinkDesc(
final String sourceName,
- final EntityTypeInvocationHandler source,
- final EntityTypeInvocationHandler target,
+ final EntityInvocationHandler source,
+ final EntityInvocationHandler target,
final ODataLinkType type) {
this.sourceName = sourceName;
this.source = source;
- this.targets = Collections.<EntityTypeInvocationHandler>singleton(target);
+ this.targets = Collections.<EntityInvocationHandler>singleton(target);
this.type = type;
}
@@ -66,11 +66,11 @@ public class EntityLinkDesc implements Serializable {
return sourceName;
}
- public EntityTypeInvocationHandler getSource() {
+ public EntityInvocationHandler getSource() {
return source;
}
- public Collection<EntityTypeInvocationHandler> getTargets() {
+ public Collection<EntityInvocationHandler> getTargets() {
return targets;
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/32953c0b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/utils/CoreUtils.java
----------------------------------------------------------------------
diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/utils/CoreUtils.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/utils/CoreUtils.java
index cda964e..38dd4cc 100644
--- a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/utils/CoreUtils.java
+++ b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/utils/CoreUtils.java
@@ -60,9 +60,9 @@ import org.apache.olingo.ext.proxy.api.annotations.EnumType;
import org.apache.olingo.ext.proxy.api.annotations.Key;
import org.apache.olingo.ext.proxy.api.annotations.Namespace;
import org.apache.olingo.ext.proxy.api.annotations.Property;
-import org.apache.olingo.ext.proxy.commons.AbstractTypeInvocationHandler;
-import org.apache.olingo.ext.proxy.commons.ComplexTypeInvocationHandler;
-import org.apache.olingo.ext.proxy.commons.EntityTypeInvocationHandler;
+import org.apache.olingo.ext.proxy.commons.AbstractStructuredInvocationHandler;
+import org.apache.olingo.ext.proxy.commons.ComplexInvocationHandler;
+import org.apache.olingo.ext.proxy.commons.EntityInvocationHandler;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -112,10 +112,10 @@ public final class CoreUtils {
} else {
objHandler = obj;
}
- if (objHandler instanceof ComplexTypeInvocationHandler) {
- value = ((ComplexTypeInvocationHandler) objHandler).getComplex();
+ if (objHandler instanceof ComplexInvocationHandler) {
+ value = ((ComplexInvocationHandler) objHandler).getComplex();
- final Class<?> typeRef = ((ComplexTypeInvocationHandler) objHandler).getTypeRef();
+ final Class<?> typeRef = ((ComplexInvocationHandler) objHandler).getTypeRef();
for (Method method : typeRef.getMethods()) {
final Property propAnn = method.getAnnotation(Property.class);
if (propAnn != null) {
@@ -385,8 +385,8 @@ public final class CoreUtils {
final Class<?> typeRef;
if (bean instanceof Proxy) {
final InvocationHandler handler = Proxy.getInvocationHandler(bean);
- if (handler instanceof AbstractTypeInvocationHandler) {
- typeRef = ((ComplexTypeInvocationHandler) handler).getTypeRef();
+ if (handler instanceof AbstractStructuredInvocationHandler) {
+ typeRef = ((ComplexInvocationHandler) handler).getTypeRef();
} else {
throw new IllegalStateException("Invalid bean " + bean);
}
@@ -425,7 +425,7 @@ public final class CoreUtils {
final Object complex = Proxy.newProxyInstance(
Thread.currentThread().getContextClassLoader(),
new Class<?>[] {getter.getReturnType()},
- ComplexTypeInvocationHandler.getInstance(
+ ComplexInvocationHandler.getInstance(
client, property.getName(), getter.getReturnType(), null));
populate(client, complex, Property.class, property.getValue().asComplex().iterator());
@@ -450,7 +450,7 @@ public final class CoreUtils {
final Object collItem = Proxy.newProxyInstance(
Thread.currentThread().getContextClassLoader(),
new Class<?>[] {collItemClass},
- ComplexTypeInvocationHandler.getInstance(
+ ComplexInvocationHandler.getInstance(
client, property.getName(), collItemClass, null));
populate(client, collItem, Property.class, value.asComplex().iterator());
@@ -471,7 +471,7 @@ public final class CoreUtils {
final CommonEdmEnabledODataClient<?> client,
final CommonODataProperty property,
final Type typeRef,
- final EntityTypeInvocationHandler entityHandler)
+ final EntityInvocationHandler entityHandler)
throws InstantiationException, IllegalAccessException {
Class<?> internalRef;
@@ -495,7 +495,7 @@ public final class CoreUtils {
res = Proxy.newProxyInstance(
Thread.currentThread().getContextClassLoader(),
new Class<?>[] {internalRef},
- ComplexTypeInvocationHandler.getInstance(
+ ComplexInvocationHandler.getInstance(
client, property.getValue().asComplex(), internalRef, entityHandler));
} else if (property.hasCollectionValue()) {
final ArrayList<Object> collection = new ArrayList<Object>();
@@ -510,7 +510,7 @@ public final class CoreUtils {
final Object collItem = Proxy.newProxyInstance(
Thread.currentThread().getContextClassLoader(),
new Class<?>[] {internalRef},
- ComplexTypeInvocationHandler.getInstance(
+ ComplexInvocationHandler.getInstance(
client, value.asComplex(), internalRef, entityHandler));
collection.add(collItem);
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/32953c0b/ext/pojogen-maven-plugin/src/main/java/org/apache/olingo/ext/pojogen/AbstractPOJOGenMojo.java
----------------------------------------------------------------------
diff --git a/ext/pojogen-maven-plugin/src/main/java/org/apache/olingo/ext/pojogen/AbstractPOJOGenMojo.java b/ext/pojogen-maven-plugin/src/main/java/org/apache/olingo/ext/pojogen/AbstractPOJOGenMojo.java
index 420d4c2..f8ab5f2 100644
--- a/ext/pojogen-maven-plugin/src/main/java/org/apache/olingo/ext/pojogen/AbstractPOJOGenMojo.java
+++ b/ext/pojogen-maven-plugin/src/main/java/org/apache/olingo/ext/pojogen/AbstractPOJOGenMojo.java
@@ -44,6 +44,7 @@ import org.apache.olingo.commons.api.edm.EdmEntityContainer;
import org.apache.olingo.commons.api.edm.EdmEntitySet;
import org.apache.olingo.commons.api.edm.EdmEntityType;
import org.apache.olingo.commons.api.edm.EdmEnumType;
+import org.apache.olingo.commons.api.edm.EdmNavigationProperty;
import org.apache.olingo.commons.api.edm.EdmSchema;
import org.apache.olingo.commons.api.edm.EdmSingleton;
import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
@@ -267,6 +268,20 @@ public abstract class AbstractPOJOGenMojo extends AbstractMojo {
objs.clear();
objs.put("complexType", complex);
parseObj(typesBaseDir, typesPkg, "complexType", className + ".java", objs);
+
+ for (String navPropName : complex.getNavigationPropertyNames()) {
+ final EdmNavigationProperty navProp = complex.getNavigationProperty(navPropName);
+ if ((complex.getBaseType() == null
+ || edm.getEntityType(complex.getBaseType().getFullQualifiedName()).
+ getNavigationProperty(navPropName) == null)
+ && navProp.containsTarget()) {
+
+ objs.clear();
+ objs.put("navProp", navProp);
+ parseObj(base, pkg, "containedEntitySet",
+ utility.capitalize(navProp.getName()) + ".java", objs);
+ }
+ }
}
for (EdmEntityType entity : schema.getEntityTypes()) {
@@ -304,6 +319,20 @@ public abstract class AbstractPOJOGenMojo extends AbstractMojo {
utility.capitalize(entity.getName()) + ".java", objs);
parseObj(typesBaseDir, typesPkg, "entityCollection",
utility.capitalize(entity.getName()) + "Collection.java", objs);
+
+ for (String navPropName : entity.getNavigationPropertyNames()) {
+ final EdmNavigationProperty navProp = entity.getNavigationProperty(navPropName);
+ if ((entity.getBaseType() == null
+ || edm.getEntityType(entity.getBaseType().getFullQualifiedName()).
+ getNavigationProperty(navPropName) == null)
+ && navProp.containsTarget()) {
+
+ objs.clear();
+ objs.put("navProp", navProp);
+ parseObj(base, pkg, "containedEntitySet",
+ utility.capitalize(navProp.getName()) + ".java", objs);
+ }
+ }
}
// write container and top entity sets into the base package