return count;
}
Iterator ri = result.iterator();
if (ri.hasNext())
{
Node n = (Node)ri.next();
NodeImplProxy proxy = new NodeImplProxy(n);
root = new NodeCache(proxy);
addToCache(root);
count++;
}
else
{
return count;
}
Map parents = new HashMap();
parents.put(new Long(root.getNode().getNodeId()), root);
while (ri.hasNext())
{
// build children and subchildren
Node subNode = (Node)ri.next();
//System.out.println("*** Preloading: " + subNode.getFullPath());
// add to current node
NodeCache nodeKey = new NodeCache(subNode.getFullPath(), subNode.getNodeType());
NodeCache lookup = getNode(nodeKey.getCacheKey());
if (lookup == null)
{
NodeImplProxy proxy = new NodeImplProxy(subNode);
nodeKey.setNode(proxy);
addToCache(nodeKey);
lookup = nodeKey;
}
NodeCache parent = (NodeCache)parents.get(subNode.getParentNodeId());
if (parent != null)
{
if (parent.getChildren() == null)
parent.setChildren(new ArrayList());
parent.getChildren().add(lookup.getCacheKey());
count += parent.getChildren().size();
}
parents.put(new Long(subNode.getNodeId()), lookup);
count++;
}
return count;
}