Alfresco - 在工作流程中获取用户名

时间:2015-11-19 08:21:45

标签: java workflow alfresco alfresco-share alfresco-webscripts

当我在工作流程上创建时,我正在搜索assignees的用户名...

我用这个:

public void notify(DelegateExecution execution) {
    // get value of property mymodel:myproperty 
    Object assignees = execution.getVariable("bpm_assignees"); 
}

当我得到bpm_assignees时,我明白了:

  

bpm_assignees地图值:[节点类型:   {alfresco.org/model/content/...}person,Node Aspects:   [{alfresco.org/model/content/...}ownable,   {alfresco.org/model/system/1.0}referenceable,   {alfresco.org/model/system/1.0}localized],节点类型:   {alfresco.org/model/content/...}person,Node Aspects:   [{alfresco.org/model/content/...}ownable,   {alfresco.org/model/system/1.0}referenceable,   {alfresco.org/model/system/1.0}localized]

我如何获得username

1 个答案:

答案 0 :(得分:3)

这些对象是Person NodeRefs。如果您从该节点获取属性,您将获得用户的用户名,电子邮件地址等内容。您可以看到可用的属性by looking at the core content model(向下滚动到cm:person)

假设返回的对象是ActivitiScriptNodeList,那么它们将会轻易地包含访问器等,因为它们将是ActivitiScriptNode。这些扩展了正常的Alfresco JavaScript ScriptNode objects。这意味着你需要做的是:

public void notify(DelegateExecution execution){
   ActivitiScriptNodeList assignees = execution.getVariable("bpm_assignees"); 
   for (ActivitiScriptNode personNode : assignees) {
       String username = personNode.getProperties().get("cm:userName");
       String email = personNode.getProperties().get("cm:email");
       // TODO Use this
   }
}
相关问题