Added create/remove association JavaScript API and improvements to the createNode() JavaScript API

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@5504 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Kevin Roast
2007-04-17 14:52:04 +00:00
parent 8977aaa12e
commit a650515ea8
2 changed files with 159 additions and 115 deletions

View File

@@ -72,12 +72,6 @@ public class TemplateNode extends BasePermissionsNode
private static Log logger = LogFactory.getLog(TemplateNode.class);
/** The target associations from this node */
private Map<String, List<TemplateNode>> targetAssocs = null;
/** The child associations from this node */
private Map<String, List<TemplateNode>> childAssocs = null;
/** All associations from this node */
private Map<String, List<TemplateNode>> assocs = null;
@@ -227,68 +221,28 @@ public class TemplateNode extends BasePermissionsNode
// Repository Node API
/**
* @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 The target associations for this Node. As a Map of assoc name to a List of TemplateNodes.
*/
public Map<String, List<TemplateNode>> getTargetAssocs()
{
if (this.targetAssocs == null)
{
List<AssociationRef> refs = this.services.getNodeService().getTargetAssocs(this.nodeRef, RegexQNamePattern.MATCH_ALL);
this.targetAssocs = new QNameMap<String, List<TemplateNode>>(this.services.getNamespaceService());
for (AssociationRef ref : refs)
{
String qname = ref.getTypeQName().toString();
List<TemplateNode> nodes = this.targetAssocs.get(qname);
if (nodes == null)
{
// first access for the list for this qname
nodes = new ArrayList<TemplateNode>(4);
this.targetAssocs.put(ref.getTypeQName().toString(), nodes);
}
nodes.add( new TemplateNode(ref.getTargetRef(), this.services, this.imageResolver) );
}
}
return this.targetAssocs;
}
/**
* @return All associations for this Node. As a Map of assoc name to a List of TemplateNodes.
* @return Target associations for this Node. As a Map of assoc name to a List of TemplateNodes.
*/
public Map<String, List<TemplateNode>> getAssocs()
{
if (this.assocs == null)
{
List<AssociationRef> refs = this.services.getNodeService().getTargetAssocs(this.nodeRef, RegexQNamePattern.MATCH_ALL);
this.assocs = new QNameMap<String, List<TemplateNode>>(this.services.getNamespaceService());
this.assocs.putAll(getTargetAssocs());
this.assocs.putAll(getChildAssocs());
for (AssociationRef ref : refs)
{
String qname = ref.getTypeQName().toString();
List<TemplateNode> nodes = this.assocs.get(qname);
if (nodes == null)
{
// first access for the list for this qname
nodes = new ArrayList<TemplateNode>(4);
this.assocs.put(ref.getTypeQName().toString(), nodes);
}
nodes.add( new TemplateNode(ref.getTargetRef(), this.services, this.imageResolver) );
}
}
return this.assocs;
}