Get count of Associations for a folder and asset

cancel
Showing results for 
Search instead for 
Did you mean: 
ajendra
Member II

Get count of Associations for a folder and asset

I am trying to get the number (count) of associations for an asset/folder by using the reference type in Java.

But, I don't have an idea how to achieve this. 

I have written a query to get this, but this is from alfresco tables. Also, this query fetches the associations only for Asset types not for folders. 

Here is the query what I have written

SELECT COUNT(*) FROM alf_node  aNode

INNER JOIN   alf_node_assoc ana   ON  aNode.id = ana.source_node_id

INNER JOIN  alf_qname aqn   ON   ana.type_qname_id = aqn.id

WHERE aNode.uuid = "897f6e7a-a9bf-46ea-95b8-b9hyyji7hhuu8"

AND  aqn.local_name = "imageReference";

 

I need this result but, from java code and also, the above query works for asset but not for folders.

I don't need the records, I just need the count of associations

Any help will be really appriciated.

 

Thanks in advance

2 Replies
angelborroy
Alfresco Employee

Re: Get count of Associations for a folder and asset

You may try using NodeService.getSourceAssocs() or NodeService.getTargetAssocs() methods.

http://dev.alfresco.com/resource/AlfrescoOne/5.0/PublicAPI/org/alfresco/service/cmr/repository/NodeS...

http://dev.alfresco.com/resource/AlfrescoOne/5.0/PublicAPI/org/alfresco/service/cmr/repository/NodeS...

In order to get every QNamePattern use QNamePattern.MATCH_ALL for the second argument (http://dev.alfresco.com/resource/AlfrescoOne/5.0/PublicAPI/org/alfresco/service/namespace/RegexQName...)

Hyland Developer Evangelist
ajendra
Member II

Re: Get count of Associations for a folder and asset

Thanks for the reply, but it does not fullfill the requirement. 

 

Please refere the attahed image, I need those associations count .

Also, nodeService.getSourceAssocs and nodeService.getTargetAssocs does not give the result what I need. 

 

MicrosoftTeams-image (2).pngThanks,