how to get related (peer association) nodes progra

2019-06-09 20:22发布

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

标签: java alfresco
1条回答
何必那么认真
2楼-- · 2019-06-09 21:00

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();
查看更多
登录 后发表回答