Author: julien(a)jboss.com
Date: 2008-07-06 16:31:36 -0400 (Sun, 06 Jul 2008)
New Revision: 11305
Removed:
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model/ChildrenVisit.java
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
Log:
simplify a bit
Deleted:
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model/ChildrenVisit.java
===================================================================
---
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model/ChildrenVisit.java 2008-07-06
20:05:38 UTC (rev 11304)
+++
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model/ChildrenVisit.java 2008-07-06
20:31:36 UTC (rev 11305)
@@ -1,70 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2008, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.portal.presentation.impl.model;
-
-import java.util.ArrayList;
-import java.util.Collection;
-
-/**
- * @author <a href="mailto:julien@jboss-portal.org">Julien
Viet</a>
- * @version $Revision: 630 $
- */
-public class ChildrenVisit
-{
-
- /** . */
- final Collection<ObjectVisit> addedObjects = new
ArrayList<ObjectVisit>();
-
- /** . */
- final Collection<ObjectVisit> validObjects = new
ArrayList<ObjectVisit>();
-
- /** . */
- final Collection<ObjectVisit> staleObjects = new
ArrayList<ObjectVisit>();
-
- /** . */
- final Collection<ObjectVisit> removedObjects = new
ArrayList<ObjectVisit>();
-
- ChildrenVisit()
- {
- }
-
- public Collection<ObjectVisit> getAddedObjects()
- {
- return addedObjects;
- }
-
- public Collection<ObjectVisit> getRemovedObjects()
- {
- return removedObjects;
- }
-
- public Collection<ObjectVisit> getValidObjects()
- {
- return validObjects;
- }
-
- public Collection<ObjectVisit> getStaleObjects()
- {
- return staleObjects;
- }
-}
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
20:05:38 UTC (rev 11304)
+++
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model/CreateDiffPhase.java 2008-07-06
20:31:36 UTC (rev 11305)
@@ -151,7 +151,10 @@
//
if (traversalType == ObjectTraversalType.RECURSIVE)
{
- ChildrenVisit childrenVisit = new ChildrenVisit();
+ Collection<ObjectVisit> addedObjects = new
ArrayList<ObjectVisit>();
+ Collection<ObjectVisit> validObjects = new
ArrayList<ObjectVisit>();
+ Collection<ObjectVisit> staleObjects = new
ArrayList<ObjectVisit>();
+ Collection<ObjectVisit> removedObjects = new
ArrayList<ObjectVisit>();
//
for (StructuralObject addedStructuralChild : refresh.getAddedChildren())
@@ -159,11 +162,11 @@
ObjectVisit childVisit = load(addedStructuralChild);
if (childVisit instanceof ObjectVisit.Load)
{
- childrenVisit.addedObjects.add(childVisit);
+ addedObjects.add(childVisit);
}
else if (childVisit instanceof ObjectVisit.Skip)
{
- childrenVisit.addedObjects.add(childVisit);
+ addedObjects.add(childVisit);
}
else
{
@@ -175,14 +178,14 @@
for (StructuralObject staleStructuralChild :
refresh.getStaleChildren().values())
{
ObjectVisit childVisit = diff(staleStructuralChild.getId());
- childrenVisit.staleObjects.add(childVisit);
+ staleObjects.add(childVisit);
}
//
for (String validChildId : refresh.getValidChildren())
{
ObjectVisit childVisit = diff(validChildId);
- childrenVisit.validObjects.add(childVisit);
+ validObjects.add(childVisit);
}
//
@@ -194,7 +197,7 @@
if (removedChild != null)
{
ObjectVisit.Evict childVisit = createEvict(removedChild);
- childrenVisit.removedObjects.add(childVisit);
+ removedObjects.add(childVisit);
}
else
{
@@ -209,7 +212,10 @@
refresh.getRemovedProperties(),
refresh.getUpdatedProperties(),
refresh.getAddedProperties(),
- childrenVisit);
+ addedObjects,
+ validObjects,
+ staleObjects,
+ removedObjects);
}
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
20:05:38 UTC (rev 11304)
+++
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model/CreateUpdatePhase.java 2008-07-06
20:31:36 UTC (rev 11305)
@@ -31,6 +31,8 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
+import java.util.Collection;
+import java.util.Collections;
/**
* @author <a href="mailto:julien@jboss-portal.org">Julien
Viet</a>
@@ -86,15 +88,23 @@
if (visit instanceof ObjectVisit.RecursiveLoad || visit instanceof
ObjectVisit.RecursiveUpdate)
{
- ChildrenVisit childrenVisit;
+ Collection<ObjectVisit> addedObjects;
+ Collection<ObjectVisit> validObjects;
+ Collection<ObjectVisit> staleObjects;
+ Collection<ObjectVisit> removedObjects;
if (visit instanceof ObjectVisit.RecursiveUpdate)
{
- childrenVisit = ((ObjectVisit.RecursiveUpdate)visit).getChildrenVisit();
+ addedObjects = ((ObjectVisit.RecursiveUpdate)visit).getAddedChildren();
+ validObjects = ((ObjectVisit.RecursiveUpdate)visit).getValidChildren();
+ staleObjects = ((ObjectVisit.RecursiveUpdate)visit).getStaleChildren();
+ removedObjects = ((ObjectVisit.RecursiveUpdate)visit).getRemovedChildren();
}
else
{
- childrenVisit = new ChildrenVisit();
-
childrenVisit.addedObjects.addAll(((ObjectVisit.RecursiveLoad)visit).getAddedChildren());
+ addedObjects = ((ObjectVisit.RecursiveLoad)visit).getAddedChildren();
+ validObjects = Collections.emptyList();
+ staleObjects = Collections.emptyList();
+ removedObjects = Collections.emptyList();
}
//
@@ -113,7 +123,7 @@
List<ObjectUpdate.UpdateObject> updateChildrenUpdates = new
ArrayList<ObjectUpdate.UpdateObject>();
//
- for (ObjectVisit addedObjectVisit : childrenVisit.getAddedObjects())
+ for (ObjectVisit addedObjectVisit : addedObjects)
{
ObjectUpdate childUpdate = createUpdate(addedObjectVisit);
@@ -164,14 +174,14 @@
}
//
- for (ObjectVisit removedChildVisit : childrenVisit.getRemovedObjects())
+ for (ObjectVisit removedChildVisit : removedObjects)
{
removedChildrenUpdates.add(new ObjectUpdate.RemoveChild(visit.getObjectId(),
createRemove((ObjectVisit.Evict)removedChildVisit)));
}
List<ObjectVisit> existingObjectVisits = new
ArrayList<ObjectVisit>();
- existingObjectVisits.addAll(childrenVisit.getValidObjects());
- existingObjectVisits.addAll(childrenVisit.getStaleObjects());
+ existingObjectVisits.addAll(validObjects);
+ existingObjectVisits.addAll(staleObjects);
//
for (ObjectVisit validObjectVisit : existingObjectVisits)
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
20:05:38 UTC (rev 11304)
+++
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model/ObjectVisit.java 2008-07-06
20:31:36 UTC (rev 11305)
@@ -71,9 +71,20 @@
Set<String> removedProperties,
Map<String, Serializable> updatedProperties,
Map<String, Serializable> addedProperties,
- ChildrenVisit children)
+ Collection<ObjectVisit> addedChildren,
+ Collection<ObjectVisit> validChildren,
+ Collection<ObjectVisit> staleChildren,
+ Collection<ObjectVisit> removedChildren)
{
- return new RecursiveUpdate(object, removedProperties, updatedProperties,
addedProperties, children);
+ return new RecursiveUpdate(
+ object,
+ removedProperties,
+ updatedProperties,
+ addedProperties,
+ addedChildren,
+ validChildren,
+ staleChildren,
+ removedChildren);
}
/** . */
@@ -121,7 +132,7 @@
{
/** . */
- final Collection<ObjectVisit> addedChildren;
+ private final Collection<ObjectVisit> addedChildren;
private RecursiveLoad(
UIObjectImpl object,
@@ -136,6 +147,15 @@
}
//
+// for (ObjectVisit addedChild : addedChildren)
+// {
+// if (!(addedChild instanceof Evict || addedChild instanceof Load))
+// {
+// throw new AssertionError();
+// }
+// }
+
+ //
this.addedChildren = addedChildren;
}
@@ -149,14 +169,26 @@
{
/** . */
- private final ChildrenVisit children;
+ private final Collection<ObjectVisit> addedChildren;
+ /** . */
+ private final Collection<ObjectVisit> validChildren;
+
+ /** . */
+ private final Collection<ObjectVisit> staleChildren;
+
+ /** . */
+ private final Collection<ObjectVisit> removedChildren;
+
private RecursiveUpdate(
UIObjectImpl object,
Set<String> removedProperties,
Map<String, Serializable> updatedProperties,
Map<String, Serializable> addedProperties,
- ChildrenVisit children)
+ Collection<ObjectVisit> addedChildren,
+ Collection<ObjectVisit> validChildren,
+ Collection<ObjectVisit> staleChildren,
+ Collection<ObjectVisit> removedChildren)
{
super(
object,
@@ -165,19 +197,49 @@
addedProperties);
//
- if (children == null)
+ if (addedChildren == null)
{
throw new IllegalArgumentException();
}
+ if (validChildren == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (staleChildren == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (removedChildren == null)
+ {
+ throw new IllegalArgumentException();
+ }
//
- this.children = children;
+ this.addedChildren = addedChildren;
+ this.validChildren = validChildren;
+ this.staleChildren = staleChildren;
+ this.removedChildren = removedChildren;
}
- public ChildrenVisit getChildrenVisit()
+ public Collection<ObjectVisit> getAddedChildren()
{
- return children;
+ return addedChildren;
}
+
+ public Collection<ObjectVisit> getValidChildren()
+ {
+ return validChildren;
+ }
+
+ public Collection<ObjectVisit> getStaleChildren()
+ {
+ return staleChildren;
+ }
+
+ public Collection<ObjectVisit> getRemovedChildren()
+ {
+ return removedChildren;
+ }
}
public static class SingleUpdate extends Update