12-05-2017 10:31 AM
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?
12-05-2017 11:55 AM
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);
12-05-2017 11:27 AM
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.
12-05-2017 11:55 AM
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);
Explore our Alfresco products with the links below. Use labels to filter content by product module.