Author: julien(a)jboss.com
Date: 2008-07-06 16:00:43 -0400 (Sun, 06 Jul 2008)
New Revision: 11303
Modified:
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model/CreateDiffPhase.java
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model/CreateUpdatePhase.java
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model/ObjectVisit.java
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/RemoveChildTestCase.java
Log:
implement and test the case where a child was not loaded and it is removed and loaded in
the next refresh
Modified:
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model/CreateDiffPhase.java
===================================================================
---
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model/CreateDiffPhase.java 2008-07-06
15:11:34 UTC (rev 11302)
+++
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model/CreateDiffPhase.java 2008-07-06
20:00:43 UTC (rev 11303)
@@ -103,8 +103,6 @@
private ObjectVisit.Evict createEvict(UIObjectImpl object)
{
-
- //
Collection<ObjectVisit.Evict> evictedChildren =
createEvictedChildren(object);
//
@@ -159,7 +157,18 @@
for (StructuralObject addedStructuralChild : refresh.getAddedChildren())
{
ObjectVisit childVisit = load(addedStructuralChild);
- childrenVisit.addedObjects.add(childVisit);
+ if (childVisit instanceof ObjectVisit.Load)
+ {
+ childrenVisit.addedObjects.add(childVisit);
+ }
+ else if (childVisit instanceof ObjectVisit.Skip)
+ {
+ childrenVisit.addedObjects.add(childVisit);
+ }
+ else
+ {
+ throw new AssertionError();
+ }
}
//
@@ -180,8 +189,18 @@
for (String removedChildId : refresh.getRemovedChildren())
{
UIObjectImpl removedChild =
(UIObjectImpl)context.getObject(removedChildId);
- ObjectVisit childVisit = createEvict(removedChild);
- childrenVisit.removedObjects.add(childVisit);
+
+ //
+ if (removedChild != null)
+ {
+ ObjectVisit.Evict childVisit = createEvict(removedChild);
+ childrenVisit.removedObjects.add(childVisit);
+ }
+ else
+ {
+ // It means that the child was not loaded previously and it has
+ // been removed in the current refresh, so we do nothing
+ }
}
//
@@ -229,18 +248,26 @@
}
else
{
- ChildrenVisit childrenVisit = null;
-
- //
if (traversalType == ObjectTraversalType.RECURSIVE)
{
- childrenVisit = new ChildrenVisit();
+ Collection<ObjectVisit> addedChildren = new
ArrayList<ObjectVisit>();
for (StructuralObject structuralChild :
structuralStateContext.loadChildren(structuralObject))
{
ObjectVisit childVisit = load(structuralChild);
- childrenVisit.addedObjects.add(childVisit);
+ if (childVisit instanceof ObjectVisit.Load)
+ {
+ addedChildren.add(childVisit);
+ }
+ else if (childVisit instanceof ObjectVisit.Skip)
+ {
+ addedChildren.add(childVisit);
+ }
+ else
+ {
+ throw new AssertionError();
+ }
}
- return ObjectVisit.createRecursiveLoad(object, childrenVisit);
+ return ObjectVisit.createRecursiveLoad(object, addedChildren);
}
else
{
Modified:
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model/CreateUpdatePhase.java
===================================================================
---
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model/CreateUpdatePhase.java 2008-07-06
15:11:34 UTC (rev 11302)
+++
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model/CreateUpdatePhase.java 2008-07-06
20:00:43 UTC (rev 11303)
@@ -86,7 +86,16 @@
if (visit instanceof ObjectVisit.RecursiveLoad || visit instanceof
ObjectVisit.RecursiveUpdate)
{
- ChildrenVisit childrenVisit = visit instanceof ObjectVisit.Load ?
((ObjectVisit.RecursiveLoad)visit).getChildrenVisit() :
((ObjectVisit.RecursiveUpdate)visit).getChildrenVisit();
+ ChildrenVisit childrenVisit;
+ if (visit instanceof ObjectVisit.RecursiveUpdate)
+ {
+ childrenVisit = ((ObjectVisit.RecursiveUpdate)visit).getChildrenVisit();
+ }
+ else
+ {
+ childrenVisit = new ChildrenVisit();
+
childrenVisit.addedObjects.addAll(((ObjectVisit.RecursiveLoad)visit).getAddedChildren());
+ }
//
if (object != null)
Modified:
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model/ObjectVisit.java
===================================================================
---
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model/ObjectVisit.java 2008-07-06
15:11:34 UTC (rev 11302)
+++
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model/ObjectVisit.java 2008-07-06
20:00:43 UTC (rev 11303)
@@ -41,9 +41,9 @@
return new Evict(object, evictedChildren);
}
- static RecursiveLoad createRecursiveLoad(UIObjectImpl object, ChildrenVisit children)
+ static RecursiveLoad createRecursiveLoad(UIObjectImpl object,
Collection<ObjectVisit> addedChildren)
{
- return new RecursiveLoad(object, children);
+ return new RecursiveLoad(object, addedChildren);
}
static ObjectVisit createLoad(UIObjectImpl object)
@@ -121,25 +121,27 @@
{
/** . */
- private final ChildrenVisit children;
+ final Collection<ObjectVisit> addedChildren;
- private RecursiveLoad(UIObjectImpl object, ChildrenVisit children)
+ private RecursiveLoad(
+ UIObjectImpl object,
+ Collection<ObjectVisit> addedChildren)
{
super(object);
//
- if (children == null)
+ if (addedChildren == null)
{
throw new IllegalArgumentException();
}
//
- this.children = children;
+ this.addedChildren = addedChildren;
}
- public ChildrenVisit getChildrenVisit()
+ public Collection<ObjectVisit> getAddedChildren()
{
- return children;
+ return addedChildren;
}
}
Modified:
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/RemoveChildTestCase.java
===================================================================
---
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/RemoveChildTestCase.java 2008-07-06
15:11:34 UTC (rev 11302)
+++
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/RemoveChildTestCase.java 2008-07-06
20:00:43 UTC (rev 11303)
@@ -46,6 +46,9 @@
NodeDef juuDef = fooDef.addChild("juu");
//
+ juuDef.setTraversal(before[0]);
+
+ //
rootDef.populate(mockModel);
//