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 :
Type | Référence de la cible | Type d'association |
---|---|---|
st:site | workspace://SpacesStore/ded70eb7-3fde-47a0-90aa-9189e7091a8e | custom:folderProduit_siteTrt_assoc |
I will be crazy, I have any idea?
Solved! Go 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);
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.
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);
Ask for and offer help to other Alfresco Content Services Users and members of the Alfresco team.
Related links:
By using this site, you are agreeing to allow us to collect and use cookies as outlined in Alfresco’s Cookie Statement and Terms of Use (and you have a legitimate interest in Alfresco and our products, authorizing us to contact you in such methods). If you are not ok with these terms, please do not use this website.