how to get related (peer association) nodes programatically in alfresco using java?

自作多情 提交于 2019-12-08 13:24:39

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!