You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@olingo.apache.org by fm...@apache.org on 2014/07/28 22:24:06 UTC
git commit: [OLINGO-365] revert previous commit
Repository: olingo-odata4
Updated Branches:
refs/heads/master a5e983c9b -> 8c68516dc
[OLINGO-365] revert previous commit
Project: http://git-wip-us.apache.org/repos/asf/olingo-odata4/repo
Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata4/commit/8c68516d
Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata4/tree/8c68516d
Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata4/diff/8c68516d
Branch: refs/heads/master
Commit: 8c68516dcb6665083a5b6767458a83879edb3d0a
Parents: a5e983c
Author: fmartelli <fa...@gmail.com>
Authored: Mon Jul 28 22:23:54 2014 +0200
Committer: fmartelli <fa...@gmail.com>
Committed: Mon Jul 28 22:23:54 2014 +0200
----------------------------------------------------------------------
.../AbstractCollectionInvocationHandler.java | 5 -
.../commons/AbstractPersistenceManager.java | 133 ++++++-------------
.../proxy/commons/EntityInvocationHandler.java | 13 +-
.../fit/proxy/v4/APIBasicDesignTestITCase.java | 16 ++-
4 files changed, 50 insertions(+), 117 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/8c68516d/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/AbstractCollectionInvocationHandler.java
----------------------------------------------------------------------
diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/AbstractCollectionInvocationHandler.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/AbstractCollectionInvocationHandler.java
index b06b594..d276302 100644
--- a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/AbstractCollectionInvocationHandler.java
+++ b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/AbstractCollectionInvocationHandler.java
@@ -56,8 +56,6 @@ public abstract class AbstractCollectionInvocationHandler<T extends Serializable
protected Collection<String> referenceItems;
- protected Collection<T> newest;
-
protected final URI baseURI;
protected CommonURIBuilder<?> uri;
@@ -82,7 +80,6 @@ public abstract class AbstractCollectionInvocationHandler<T extends Serializable
this.itemRef = itemRef;
this.items = items;
this.referenceItems = new ArrayList<String>();
- this.newest = new ArrayList<T>();
this.uri = uri;
this.baseURI = this.uri == null ? null : this.uri.build();
}
@@ -182,7 +179,6 @@ public abstract class AbstractCollectionInvocationHandler<T extends Serializable
}
}
changed = true;
- newest.add(element);
return items.add(element);
}
@@ -258,7 +254,6 @@ public abstract class AbstractCollectionInvocationHandler<T extends Serializable
@Override
public boolean addAll(final Collection<? extends T> collection) {
changed = true;
- newest.addAll(collection);
return items.addAll(collection);
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/8c68516d/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/AbstractPersistenceManager.java
----------------------------------------------------------------------
diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/AbstractPersistenceManager.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/AbstractPersistenceManager.java
index 03d9072..62b701a 100644
--- a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/AbstractPersistenceManager.java
+++ b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/AbstractPersistenceManager.java
@@ -174,58 +174,61 @@ abstract class AbstractPersistenceManager implements PersistenceManager {
: ODataLinkType.ENTITY_NAVIGATION;
final Set<EntityInvocationHandler> toBeLinked = new HashSet<EntityInvocationHandler>();
+
for (Object proxy : type == ODataLinkType.ENTITY_SET_NAVIGATION
? (Collection<?>) property.getValue() : Collections.singleton(property.getValue())) {
final EntityInvocationHandler target = (EntityInvocationHandler) Proxy.getInvocationHandler(proxy);
- toBeLinked.addAll(processLinkChanges(
- handler, target, property.getKey(), type, pos, items, delayedUpdates, changeset));
- }
+ final AttachedEntityStatus status;
+ if (!service.getContext().entityContext().isAttached(target)) {
+ status = resolveNavigationLink(property.getKey(), target);
+ } else {
+ status = service.getContext().entityContext().getStatus(target);
+ }
- if (!toBeLinked.isEmpty()) {
- delayedUpdates.add(new EntityLinkDesc(property.getKey().name(), handler, toBeLinked, type));
- }
+ LOG.debug("Found link to '{}({})'", target, status);
- if (property.getValue() instanceof Proxy) {
- final InvocationHandler target = Proxy.getInvocationHandler(property.getValue());
+ final URI editLink = target.getEntity().getEditLink();
- if (target instanceof EntityCollectionInvocationHandler) {
- for (String ref : ((EntityCollectionInvocationHandler<?>) target).referenceItems) {
- delayedUpdates.add(new EntityLinkDesc(property.getKey().name(), handler, ref));
+ if ((status == AttachedEntityStatus.ATTACHED || status == AttachedEntityStatus.LINKED) && !target.isChanged()) {
+ LOG.debug("Add link to '{}'", target);
+ entity.addLink(buildNavigationLink(
+ property.getKey().name(),
+ URIUtils.getURI(service.getClient().getServiceRoot(), editLink.toASCIIString()), type));
+ } else {
+ if (!items.contains(target)) {
+ pos = processEntityContext(target, pos, items, delayedUpdates, changeset);
+ pos++;
+ }
+
+ final Integer targetPos = items.get(target);
+ if (targetPos == null) {
+ // schedule update for the current object
+ LOG.debug("Schedule '{}' from '{}' to '{}'", type.name(), handler, target);
+ toBeLinked.add(target);
+ } else if (status == AttachedEntityStatus.CHANGED) {
+ LOG.debug("Changed: '{}' from '{}' to (${}) '{}'", type.name(), handler, targetPos, target);
+ entity.addLink(buildNavigationLink(
+ property.getKey().name(),
+ URIUtils.getURI(service.getClient().getServiceRoot(), editLink.toASCIIString()), type));
+ } else {
+ // 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));
}
}
}
- }
- // Required by linking provided on existent object. Say:
- // container.getCustomers().getByKey(1).getOrders().add(order)
- // Required by linking provided via entity reference ID. Say:
- // container.getCustomers().getByKey(1).getOrders().addRef(order)
- for (Map.Entry<NavigationProperty, Object> property : handler.linkCache.entrySet()) {
+ if (!toBeLinked.isEmpty()) {
+ delayedUpdates.add(new EntityLinkDesc(property.getKey().name(), handler, toBeLinked, type));
+ }
+
if (property.getValue() instanceof Proxy) {
final InvocationHandler target = Proxy.getInvocationHandler(property.getValue());
- if (target instanceof EntityCollectionInvocationHandler
- && ((EntityCollectionInvocationHandler) target).isChanged()) {
-
- final ODataLinkType type = Collection.class.isAssignableFrom(property.getValue().getClass())
- ? ODataLinkType.ENTITY_SET_NAVIGATION
- : ODataLinkType.ENTITY_NAVIGATION;
-
- final Set<EntityInvocationHandler> toBeLinked = new HashSet<EntityInvocationHandler>();
-
- for (Object proxy : ((EntityCollectionInvocationHandler) target).newest) {
- final EntityInvocationHandler targetEntity = (EntityInvocationHandler) Proxy.getInvocationHandler(proxy);
-
- toBeLinked.addAll(processLinkChanges(
- handler, targetEntity, property.getKey(), type, pos, items, delayedUpdates, changeset));
- }
-
- if (!toBeLinked.isEmpty()) {
- delayedUpdates.add(new EntityLinkDesc(property.getKey().name(), handler, toBeLinked, type));
- }
-
+ if (target instanceof EntityCollectionInvocationHandler) {
for (String ref : ((EntityCollectionInvocationHandler<?>) target).referenceItems) {
delayedUpdates.add(new EntityLinkDesc(property.getKey().name(), handler, ref));
}
@@ -302,62 +305,6 @@ abstract class AbstractPersistenceManager implements PersistenceManager {
return pos;
}
- protected Set<EntityInvocationHandler> processLinkChanges(
- final EntityInvocationHandler source,
- final EntityInvocationHandler target,
- final NavigationProperty property,
- final ODataLinkType type,
- int pos,
- final TransactionItems items,
- final List<EntityLinkDesc> delayedUpdates,
- final PersistenceChanges changeset) {
-
- final Set<EntityInvocationHandler> toBeLinked = new HashSet<EntityInvocationHandler>();
-
- final AttachedEntityStatus status;
- if (!service.getContext().entityContext().isAttached(target)) {
- status = resolveNavigationLink(property, target);
- } else {
- status = service.getContext().entityContext().getStatus(target);
- }
-
- LOG.debug("Found link to '{}({})'", target, status);
-
- final URI editLink = target.getEntity().getEditLink();
-
- if ((status == AttachedEntityStatus.ATTACHED || status == AttachedEntityStatus.LINKED) && !target.isChanged()) {
- LOG.debug("Add link to '{}'", target);
- source.getEntity().addLink(buildNavigationLink(
- property.name(),
- URIUtils.getURI(service.getClient().getServiceRoot(), editLink.toASCIIString()), type));
- } else {
- if (!items.contains(target)) {
- pos = processEntityContext(target, pos, items, delayedUpdates, changeset);
- pos++;
- }
-
- final Integer targetPos = items.get(target);
- if (targetPos == null) {
- // schedule update for the current object
- LOG.debug("Schedule '{}' from '{}' to '{}'", type.name(), source, target);
- toBeLinked.add(target);
- } else if (status == AttachedEntityStatus.CHANGED) {
- LOG.debug("Changed: '{}' from '{}' to (${}) '{}'", type.name(), source, targetPos, target);
- source.getEntity().addLink(buildNavigationLink(
- property.name(),
- URIUtils.getURI(service.getClient().getServiceRoot(), editLink.toASCIIString()), type));
- } else {
- // create the link for the current object
- LOG.debug("'{}' from '{}' to (${}) '{}'", type.name(), source, targetPos, target);
-
- source.getEntity().addLink(
- buildNavigationLink(property.name(), URI.create("$" + targetPos), type));
- }
- }
-
- return toBeLinked;
- }
-
protected void processDelayedUpdates(
final List<EntityLinkDesc> delayedUpdates,
int pos,
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/8c68516d/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 51d62ad..e7e11b6 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
@@ -295,20 +295,9 @@ public class EntityInvocationHandler extends AbstractStructuredInvocationHandler
}
public boolean isChanged(final boolean deep) {
- boolean linkedChanges = false;
- for (Map.Entry<NavigationProperty, Object> link : linkCache.entrySet()) {
- final InvocationHandler handler = Proxy.getInvocationHandler(link.getValue());
- if (handler instanceof EntityInvocationHandler) {
- linkedChanges = linkedChanges || ((EntityInvocationHandler) handler).isChanged();
- } else if (handler instanceof EntityCollectionInvocationHandler) {
- linkedChanges = linkedChanges || ((EntityCollectionInvocationHandler) handler).isChanged();
- }
- }
-
return this.linkChanges.hashCode() != this.linksTag
|| this.propertyChanges.hashCode() != this.propertiesTag
- || (deep && (linkedChanges
- || this.stream != null
+ || (deep && (this.stream != null
|| !this.streamedPropertyChanges.isEmpty()));
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/8c68516d/fit/src/test/java/org/apache/olingo/fit/proxy/v4/APIBasicDesignTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/APIBasicDesignTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/APIBasicDesignTestITCase.java
index 6db0317..e687d41 100644
--- a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/APIBasicDesignTestITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/APIBasicDesignTestITCase.java
@@ -115,13 +115,6 @@ public class APIBasicDesignTestITCase extends AbstractTestITCase {
container.getCustomers().getByKey(1).setOrders(orders);
container.flush();
}
-
- @Test
- public void addViaReference2() {
- final Order order = container.getOrders().getByKey(8).load();
- container.getCustomers().getByKey(1).getOrders().addRef(order);
- container.flush();
- }
@Test
public void readAndCheckForPrimitive() {
@@ -492,6 +485,15 @@ public class APIBasicDesignTestITCase extends AbstractTestITCase {
}
@Test
+ public void createAndCallOperation() {
+ final Product product = container.newEntityInstance(Product.class);
+ product.setProductID(1001);
+ container.flush();
+
+ container.getProducts().getByKey(1000).operations().getProductDetails(1).execute();
+ }
+
+ @Test
public void workingWithOperations() {
// Primitive collections (available only skip and top)
final PrimitiveCollection<String> prods1 = container.operations().