[jboss-cvs] jboss-seam/examples/wiki/src/main/org/jboss/seam/wiki/core/nestedset ...
Christian Bauer
christian at hibernate.org
Sat Sep 15 13:06:17 EDT 2007
User: cbauer
Date: 07/09/15 13:06:17
Modified: examples/wiki/src/main/org/jboss/seam/wiki/core/nestedset
NestedSetResultTransformer.java
NestedSetNodeWrapper.java
Log:
Various updates (tests still broken)
Revision Changes Path
1.3 +13 -4 jboss-seam/examples/wiki/src/main/org/jboss/seam/wiki/core/nestedset/NestedSetResultTransformer.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: NestedSetResultTransformer.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/examples/wiki/src/main/org/jboss/seam/wiki/core/nestedset/NestedSetResultTransformer.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- NestedSetResultTransformer.java 25 Aug 2007 17:59:20 -0000 1.2
+++ NestedSetResultTransformer.java 15 Sep 2007 17:06:17 -0000 1.3
@@ -146,7 +146,8 @@
}
// Connect the tree hierarchically (child to parent, skip child if parent isn't present)
- NestedSetNodeWrapper<N> nodeWrapper = new NestedSetNodeWrapper<N>(nestedSetNode, comparator, nestedSetNodeLevel, additionalProjectionValues);
+ NestedSetNodeWrapper<N> nodeWrapper =
+ createNestedSetNodeWrapper(nestedSetNode, comparator, rootWrapper.getLevel()+nestedSetNodeLevel, additionalProjectionValues);
if (!nestedSetNodeParentId.equals(currentParent.getWrappedNode().getId())) {
NestedSetNodeWrapper<N> foundParent = findParentInTree(nestedSetNodeParentId, currentParent);
if (foundParent != null) {
@@ -156,7 +157,7 @@
}
}
nodeWrapper.setWrappedParent(currentParent);
- currentParent.getWrappedChildren().add(nodeWrapper);
+ currentParent.addWrappedChild(nodeWrapper);
currentParent = nodeWrapper;
return rootWrapper; // Return just something so that transformList() will be called when we are done
@@ -184,10 +185,11 @@
}
// Recursively flatten tree
- private void flattenTree(List<NestedSetNodeWrapper<N>> flatChildren, long i, NestedSetNodeWrapper<N> wrapper) {
+ public void flattenTree(List<NestedSetNodeWrapper<N>> flatChildren, long i, NestedSetNodeWrapper<N> wrapper) {
NestedSetNodeWrapper<N> newWrapper =
- new NestedSetNodeWrapper<N>(wrapper.getWrappedNode(), comparator, i, wrapper.getAdditionalProjections());
+ createNestedSetNodeWrapper(wrapper.getWrappedNode(), comparator, i, wrapper.getAdditionalProjections());
flatChildren.add( newWrapper );
+
if (wrapper.getWrappedChildren().size() > 0 && wrapper.getLevel() < flattenToLevel) {
i++;
for (NestedSetNodeWrapper<N> child : wrapper.getWrappedChildrenSorted()) {
@@ -200,4 +202,11 @@
}
}
+ public NestedSetNodeWrapper<N> createNestedSetNodeWrapper(N nestedSetNode,
+ Comparator<NestedSetNodeWrapper<N>> comparator,
+ Long nestedSetNodeLevel,
+ Map<String, Object> additionalProjectionValues) {
+ return new NestedSetNodeWrapper<N>(nestedSetNode, comparator, nestedSetNodeLevel, additionalProjectionValues);
+ }
+
}
1.3 +7 -0 jboss-seam/examples/wiki/src/main/org/jboss/seam/wiki/core/nestedset/NestedSetNodeWrapper.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: NestedSetNodeWrapper.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/examples/wiki/src/main/org/jboss/seam/wiki/core/nestedset/NestedSetNodeWrapper.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- NestedSetNodeWrapper.java 25 Aug 2007 17:59:20 -0000 1.2
+++ NestedSetNodeWrapper.java 15 Sep 2007 17:06:17 -0000 1.3
@@ -49,6 +49,7 @@
Comparator<NestedSetNodeWrapper<N>> comparator;
Long level;
Map<String, Object> additionalProjections = new HashMap<String, Object>();
+ public boolean childrenLoaded = false;
public NestedSetNodeWrapper(N wrappedNode, Comparator<NestedSetNodeWrapper<N>> comparator) {
this(wrappedNode, comparator, 0l);
@@ -79,6 +80,7 @@
public void setWrappedParent(NestedSetNodeWrapper<N> wrappedParent) {
this.wrappedParent = wrappedParent;
+ childrenLoaded = true;
}
public List<NestedSetNodeWrapper<N>> getWrappedChildren() {
@@ -89,6 +91,11 @@
this.wrappedChildren = wrappedChildren;
}
+ public void addWrappedChild(NestedSetNodeWrapper<N> wrappedChild) {
+ getWrappedChildren().add(wrappedChild);
+ childrenLoaded = true;
+ }
+
public Comparator<NestedSetNodeWrapper<N>> getComparator() {
return comparator;
}
More information about the jboss-cvs-commits
mailing list