问题
So I currently have one node, campaigns, which has a field/association that references the user table called authorised_by.
In code I can set the association like this:
nodeService.createAssociation(mcdNodeRef, newAuthority, CustomContentModel.ASSOC_MCD_CAMP_AUTHORITY);
Now I need to basically reverse engineer this process and get the value of the association back out of the alfresco DB but there is no getAssociation method and can't seem to work it out.
Thanks
回答1:
Solved it myself, here is solution:
final NodeRef oldCampaignAuthority = NodeUtils.getTargetAssociatedNodeRef(mcdNodeRef, CustomContentModel.ASSOC_MCD_CAMP_AUTHORITY, nodeService);
String oldAuthorityID = oldCampaignAuthority.getId();
String oldAuthorityUsername = new Node(new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, oldAuthorityID)).getProperties().get(ContentModel.PROP_USERNAME).toString();
来源:https://stackoverflow.com/questions/15011423/how-to-get-related-peer-association-nodes-programatically-in-alfresco-using-ja