Alfresco platform - JAVA - get custom node association

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

Alfresco platform - JAVA - get custom node association

Jump to solution

Hi,

On alfresco V5.2 how get a custom model association on a node?

My model work fine (Alfresco share found node association) so on java I tryed all this functions :

LOGGER.debug("*** CUSTOM : " + nodeService.getChildAssocs(nodeRef, CustomModel.ASSOC_PRODUIT_SITE, RegexQNamePattern.MATCH_ALL));

LOGGER.debug("*** CATEGORIES : " + nodeService.getChildAssocs(nodeRef, ContentModel.ASSOC_CATEGORIES, RegexQNamePattern.MATCH_ALL).toString());
LOGGER.debug("*** CHILD : " + nodeService.getChildAssocs(nodeRef, ContentModel.ASSOC_CHILDREN, RegexQNamePattern.MATCH_ALL).toString());
LOGGER.debug("*** CONTAINS : " + nodeService.getChildAssocs(nodeRef, ContentModel.ASSOC_CONTAINS, RegexQNamePattern.MATCH_ALL).toString());
LOGGER.debug("*** MEMEBRES : " + nodeService.getChildAssocs(nodeRef, ContentModel.ASSOC_MEMBER, RegexQNamePattern.MATCH_ALL).toString());
LOGGER.debug("*** REF : " + nodeService.getChildAssocs(nodeRef, ContentModel.ASSOC_REFERENCES, RegexQNamePattern.MATCH_ALL).toString());
LOGGER.debug("*** SUB : " + nodeService.getChildAssocs(nodeRef, ContentModel.ASSOC_SUBCATEGORIES, RegexQNamePattern.MATCH_ALL).toString());

List<ChildAssociationRef> assocWithSiteTrt = nodeService.getChildAssocs(nodeRef, CustomModel.ASSOC_PRODUIT_SITE, RegexQNamePattern.MATCH_ALL);
LOGGER.debug("assocWithSiteTrt : " + assocWithSiteTrt.toString());
List<ChildAssociationRef> assocWithSiteTrt2 = nodeService.getChildAssocs(nodeRef, RegexQNamePattern.MATCH_ALL, CustomModel.ASSOC_PRODUIT_SITE);
LOGGER.debug("assocWithSiteTrt2 : " + assocWithSiteTrt2.toString());

LOGGER.debug("Array properties : " + nodeService.getProperties(nodeRef).toString());
LOGGER.debug("Array properties2 : " + nodeService.getChildAssocs(nodeRef));
LOGGER.debug("Array ASSOC : " + nodeService.getProperty(nodeRef, CustomModel.ASSOC_PRODUIT_SITE));

All this method return null value or empty value or not interesting value....

So, if i check this node on Alfresco console node Brower : my association is really exist :

Associations (1)

TypeRéférence de la cibleType d'association
st:siteworkspace://SpacesStore/ded70eb7-3fde-47a0-90aa-9189e7091a8ecustom:folderProduit_siteTrt_assoc

I will be crazy, I have any idea?

1 Solution

Accepted Solutions
gawel
Active Member II

Re: Alfresco platform - JAVA - get custom node association

Jump to solution

Hi.

Thx I found the solution after debug all nodeService.*assoc class :

The solution is 

List<AssociationRef> assocWithSiteTrt = nodeService.getTargetAssocs(nodeRef, CustomModel.ASSOC_PRODUIT_SITE);

View solution in original post

2 Replies
Highlighted
krutik_jayswal
Senior Member II

Re: Alfresco platform - JAVA - get custom node association

Jump to solution

You need to create your custom association like below in java.

static final QName ASSOC_CHILDREN =QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "children");

 

after creating QName you can get it using below method.

 

nodeService.getSourceAssocs(nodeRef, QName)  OR nodeService.getTargetAssocs(nodeRef, QName).

 

Remeber this will return list of childAssocRef.So if you want to get nodeRef you can get it using childAssocRef.getChildRef();

 

Again if you want to get properties of association ,you need to use nodeService.

gawel
Active Member II

Re: Alfresco platform - JAVA - get custom node association

Jump to solution

Hi.

Thx I found the solution after debug all nodeService.*assoc class :

The solution is 

List<AssociationRef> assocWithSiteTrt = nodeService.getTargetAssocs(nodeRef, CustomModel.ASSOC_PRODUIT_SITE);

View solution in original post