Child association (map) support for JavaScript API. Fix to child association support for Template API.

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@5508 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Kevin Roast
2007-04-18 11:19:05 +00:00
parent a650515ea8
commit e2329988bd
2 changed files with 82 additions and 3 deletions

View File

@@ -72,9 +72,12 @@ public class TemplateNode extends BasePermissionsNode
private static Log logger = LogFactory.getLog(TemplateNode.class);
/** All associations from this node */
/** Target associations from this node */
private Map<String, List<TemplateNode>> assocs = null;
/** The child associations from this node */
private Map<String, List<TemplateNode>> childAssocs = null;
/** Cached values */
protected NodeRef nodeRef;
private String name;
@@ -246,6 +249,32 @@ public class TemplateNode extends BasePermissionsNode
return this.assocs;
}
/**
* @return The child associations for this Node. As a Map of assoc name to a List of TemplateNodes.
*/
public Map<String, List<TemplateNode>> getChildAssocs()
{
if (this.childAssocs == null)
{
List<ChildAssociationRef> refs = this.services.getNodeService().getChildAssocs(this.nodeRef);
this.childAssocs = new QNameMap<String, List<TemplateNode>>(this.services.getNamespaceService());
for (ChildAssociationRef ref : refs)
{
String qname = ref.getTypeQName().toString();
List<TemplateNode> nodes = this.childAssocs.get(qname);
if (nodes == null)
{
// first access for the list for this qname
nodes = new ArrayList<TemplateNode>(4);
this.childAssocs.put(ref.getTypeQName().toString(), nodes);
}
nodes.add( new TemplateNode(ref.getChildRef(), this.services, this.imageResolver) );
}
}
return this.childAssocs;
}
/**
* @return true if the node is currently locked
*/