mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-06-16 17:55:15 +00:00
Child and target associations available via templatenode API. Absurl method available in the Template Content Servlet.
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@5412 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
parent
42eabcf15d
commit
20b62e50ca
@ -88,7 +88,13 @@ public class TemplateNode implements Serializable
|
|||||||
/** The children of this node */
|
/** The children of this node */
|
||||||
private List<TemplateNode> children = null;
|
private List<TemplateNode> children = null;
|
||||||
|
|
||||||
/** The associations from this node */
|
/** 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;
|
private Map<String, List<TemplateNode>> assocs = null;
|
||||||
|
|
||||||
/** Cached values */
|
/** Cached values */
|
||||||
@ -225,28 +231,68 @@ public class TemplateNode implements Serializable
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return The associations for this Node. As a Map of assoc name to a List of TemplateNodes.
|
* @return The child associations for this Node. As a Map of assoc name to a List of TemplateNodes.
|
||||||
*/
|
*/
|
||||||
public Map<String, List<TemplateNode>> getAssocs()
|
public Map<String, List<TemplateNode>> getChildAssocs()
|
||||||
{
|
{
|
||||||
if (this.assocs == null)
|
if (this.childAssocs == null)
|
||||||
{
|
{
|
||||||
List<AssociationRef> refs = this.services.getNodeService().getTargetAssocs(this.nodeRef, RegexQNamePattern.MATCH_ALL);
|
List<ChildAssociationRef> refs = this.services.getNodeService().getChildAssocs(this.nodeRef);
|
||||||
this.assocs = new QNameMap<String, List<TemplateNode>>(this.services.getNamespaceService());
|
this.childAssocs = new QNameMap<String, List<TemplateNode>>(this.services.getNamespaceService());
|
||||||
for (AssociationRef ref : refs)
|
for (ChildAssociationRef ref : refs)
|
||||||
{
|
{
|
||||||
String qname = ref.getTypeQName().toString();
|
String qname = ref.getTypeQName().toString();
|
||||||
List<TemplateNode> nodes = assocs.get(qname);
|
List<TemplateNode> nodes = this.childAssocs.get(qname);
|
||||||
if (nodes == null)
|
if (nodes == null)
|
||||||
{
|
{
|
||||||
// first access for the list for this qname
|
// first access for the list for this qname
|
||||||
nodes = new ArrayList<TemplateNode>(4);
|
nodes = new ArrayList<TemplateNode>(4);
|
||||||
this.assocs.put(ref.getTypeQName().toString(), nodes);
|
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) );
|
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.
|
||||||
|
*/
|
||||||
|
public Map<String, List<TemplateNode>> getAssocs()
|
||||||
|
{
|
||||||
|
if (this.assocs == null)
|
||||||
|
{
|
||||||
|
this.assocs = new QNameMap<String, List<TemplateNode>>(this.services.getNamespaceService());
|
||||||
|
this.assocs.putAll(getTargetAssocs());
|
||||||
|
this.assocs.putAll(getChildAssocs());
|
||||||
|
}
|
||||||
return this.assocs;
|
return this.assocs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ import org.apache.commons.logging.LogFactory;
|
|||||||
public class QNameMap<K,V> implements Map, Cloneable
|
public class QNameMap<K,V> implements Map, Cloneable
|
||||||
{
|
{
|
||||||
protected static Log logger = LogFactory.getLog(QNameMap.class);
|
protected static Log logger = LogFactory.getLog(QNameMap.class);
|
||||||
protected Map<String, Object> contents = new HashMap<String, Object>(11, 1.0f);
|
protected Map<String, Object> contents = new HashMap<String, Object>(16, 1.0f);
|
||||||
protected NamespacePrefixResolver resolver = null;
|
protected NamespacePrefixResolver resolver = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user