Author: julien(a)jboss.com
Date: 2008-07-04 11:23:32 -0400 (Fri, 04 Jul 2008)
New Revision: 11299
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/state/structural/adapter/StructuralStateContextImpl.java
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/state/structural/StructuralObject.java
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/state/AbstractStructuralStateContextTestCase.java
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/state/mock/impl/MockModelImpl.java
Log:
make the properties change more detailed
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-04
14:58:43 UTC (rev 11298)
+++
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/model/ObjectVisit.java 2008-07-04
15:23:32 UTC (rev 11299)
@@ -46,7 +46,9 @@
return new Skip(object);
}
- static ObjectVisit createUpdate(UIObjectImpl object, ChildrenVisit children)
+ static ObjectVisit createUpdate(
+ UIObjectImpl object,
+ ChildrenVisit children)
{
return new Update(object, children);
}
Modified:
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/state/structural/adapter/StructuralStateContextImpl.java
===================================================================
---
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/state/structural/adapter/StructuralStateContextImpl.java 2008-07-04
14:58:43 UTC (rev 11298)
+++
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/state/structural/adapter/StructuralStateContextImpl.java 2008-07-04
15:23:32 UTC (rev 11299)
@@ -260,7 +260,9 @@
return new StructuralObject.Refresh(
parentNode != null ? takeSnapshot(parentNode) : null,
nodeSnapshot,
+ new HashSet<String>(),
new HashMap<String, Serializable>(),
+ new HashMap<String, Serializable>(),
addedStructuralChildren,
removedChildrenIds,
staleStructuralChildren,
Modified:
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/state/structural/StructuralObject.java
===================================================================
---
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/state/structural/StructuralObject.java 2008-07-04
14:58:43 UTC (rev 11298)
+++
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/state/structural/StructuralObject.java 2008-07-04
15:23:32 UTC (rev 11299)
@@ -52,9 +52,15 @@
private final StructuralObject object;
/** . */
- private final Map<String, Serializable> propertiesUpdate;
+ private final Set<String> removedProperties;
/** . */
+ private final Map<String, Serializable> updatedProperties;
+
+ /** . */
+ private final Map<String, Serializable> addedProperties;
+
+ /** . */
private final Set<StructuralObject> addedChildren;
/** . */
@@ -69,7 +75,9 @@
public Refresh(
StructuralObject parent,
StructuralObject object,
- Map<String, Serializable> propertiesUpdate,
+ Set<String> removedProperties,
+ Map<String, Serializable> updatedProperties,
+ Map<String, Serializable> addedProperties,
Set<StructuralObject> addedChildren,
Set<String> removedChildren,
Map<String, StructuralObject> staleChildren,
@@ -79,10 +87,18 @@
{
throw new IllegalArgumentException();
}
- if (propertiesUpdate == null)
+ if (removedProperties == null)
{
throw new IllegalArgumentException();
}
+ if (updatedProperties == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (addedProperties == null)
+ {
+ throw new IllegalArgumentException();
+ }
if (addedChildren == null)
{
throw new IllegalArgumentException();
@@ -102,7 +118,9 @@
//
this.parent = parent;
- this.propertiesUpdate = propertiesUpdate;
+ this.removedProperties = removedProperties;
+ this.updatedProperties = updatedProperties;
+ this.addedProperties = addedProperties;
this.object = object;
this.addedChildren = addedChildren;
this.validChildren = validChildren;
@@ -115,11 +133,21 @@
return parent;
}
- public Map<String, Serializable> getPropertiesUpdate()
+ public Set<String> getRemovedProperties()
{
- return propertiesUpdate;
+ return removedProperties;
}
+ public Map<String, Serializable> getUpdatedProperties()
+ {
+ return updatedProperties;
+ }
+
+ public Map<String, Serializable> getAddedProperties()
+ {
+ return addedProperties;
+ }
+
public StructuralObject getObject()
{
return object;
Modified:
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/state/AbstractStructuralStateContextTestCase.java
===================================================================
---
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/state/AbstractStructuralStateContextTestCase.java 2008-07-04
14:58:43 UTC (rev 11298)
+++
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/state/AbstractStructuralStateContextTestCase.java 2008-07-04
15:23:32 UTC (rev 11299)
@@ -406,8 +406,10 @@
setProperty(mockRoot, "bar", "bar_1");
setProperty(mockRoot, "daa", "daa_1");
StructuralObject.Refresh refresh1 = getStructuralStateContext().refresh(rootV0);
- Map<String, Serializable> update1 = MapBuilder.hashMap("foo",
(Serializable)"foo_1").put("bar",
"bar_1").put("daa", "daa_1").get();
- assertEquals(update1, refresh1.getPropertiesUpdate());
+ Map<String, Serializable> added1 = MapBuilder.hashMap("foo",
(Serializable)"foo_1").put("bar",
"bar_1").put("daa", "daa_1").get();
+ assertEquals(Collections.emptySet(), refresh1.getRemovedProperties());
+ assertEquals(Collections.emptyMap(), refresh1.getUpdatedProperties());
+ assertEquals(added1, refresh1.getAddedProperties());
//
StructuralObject rootV1 = getStructuralStateContext().load(rootId);
@@ -416,12 +418,17 @@
setProperty(mockRoot, "foo", null);
setProperty(mockRoot, "bar", "bar_2");
setProperty(mockRoot, "juu", "juu_1");
+
StructuralObject.Refresh refresh2_1 = getStructuralStateContext().refresh(rootV1);
- Map<String, Serializable> update2_1 = MapBuilder.hashMap("foo",
(Serializable)null).put("bar", "bar_2").put("juu",
"juu_1").get();
- assertEquals(update2_1, refresh2_1.getPropertiesUpdate());
+ assertEquals(Collections.singleton("foo"),
refresh2_1.getRemovedProperties());
+ assertEquals(Collections.singletonMap("bar",
(Serializable)"bar_2"), refresh2_1.getUpdatedProperties());
+ assertEquals(Collections.singletonMap("juu",
(Serializable)"juu_1"), refresh2_1.getAddedProperties());
+
StructuralObject.Refresh refresh2_2 = getStructuralStateContext().refresh(rootV0);
Map<String, Serializable> update2_2 = MapBuilder.hashMap("bar",
(Serializable)"bar_2").put("daa",
"daa_1").put("juu", "juu_1").get();
- assertEquals(update2_2, refresh2_2.getPropertiesUpdate());
+ assertEquals(Collections.emptySet(), refresh2_2.getRemovedProperties());
+ assertEquals(Collections.emptyMap(), refresh2_2.getUpdatedProperties());
+ assertEquals(update2_2, refresh2_2.getAddedProperties());
}
protected final void assertValidity(StructuralObject object, Class<? extends
StateException> expected) throws MockException
Modified:
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/state/mock/impl/MockModelImpl.java
===================================================================
---
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/state/mock/impl/MockModelImpl.java 2008-07-04
14:58:43 UTC (rev 11298)
+++
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/state/mock/impl/MockModelImpl.java 2008-07-04
15:23:32 UTC (rev 11299)
@@ -150,18 +150,22 @@
//
Map<String, Serializable> currentProperties =
current.getState().getProperties();
Map<String, Serializable> previousProperties =
previous.getState().getProperties();
- Map<String, Serializable> propertiesUpdate = Collections.emptyMap();
+ //
+ Set<String> removedProperties = Collections.emptySet();
+ Map<String, Serializable> updatedProperties = Collections.emptyMap();
+ Map<String, Serializable> addedProperties = Collections.emptyMap();
+
// Find all removed properties
for (String key : previousProperties.keySet())
{
if (!currentProperties.containsKey(key))
{
- if (propertiesUpdate.isEmpty())
+ if (removedProperties.isEmpty())
{
- propertiesUpdate = new HashMap<String, Serializable>();
+ removedProperties = new HashSet<String>();
}
- propertiesUpdate.put(key, null);
+ removedProperties.add(key);
}
}
@@ -171,14 +175,22 @@
String currentKey = entry.getKey();
Serializable currentValue = entry.getValue();
Serializable previousValue = previousProperties.get(currentKey);
- if (previousValue == null || !previousValue.equals(currentValue))
+ if (previousValue == null)
{
- if (propertiesUpdate.isEmpty())
+ if (addedProperties.isEmpty())
{
- propertiesUpdate = new HashMap<String, Serializable>();
+ addedProperties = new HashMap<String, Serializable>();
}
- propertiesUpdate.put(currentKey, currentValue);
+ addedProperties.put(currentKey, currentValue);
}
+ else if (!previousValue.equals(currentValue))
+ {
+ if (updatedProperties.isEmpty())
+ {
+ updatedProperties = new HashMap<String, Serializable>();
+ }
+ updatedProperties.put(currentKey, currentValue);
+ }
}
//
@@ -249,7 +261,9 @@
return new StructuralObject.Refresh(
parent,
current,
- propertiesUpdate,
+ removedProperties,
+ updatedProperties,
+ addedProperties,
addedChildren,
removedChildren,
staleChildrenHandleMap,