java - 将任务文档的附件移动到另一个节点

标签 java workflow alfresco activiti bpmn

向社区问好,我正在使用 alfresco 6.0.0 社区版,我想在任务完成时将附加到任务的文档移动到另一个节点。

我从这里找到https://community.alfresco.com/thread/204737-workflow-parallel-group-review-with-move关于这个“移动”功能,所以我目前正在做的事情如下:

  1. 启动流程
  2. 将项目附加到我使用
  3. 创建的任务

/tasks/{taskId}/items (POST) method of the alfresco REST API.

  • 完成任务
  • 我的 bpmn 中移动文件的部分如下:

    <activiti:taskListener event="complete" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
                  <activiti:field name="script">
                     <activiti:string> 
    
                       java.lang.System.out.println(bpm_package.children.length);
                        for (var i = 0; i &lt; bpm_package.children.length; i++){
                         bpm_package.children.move("b162be92-fb36-44f0-83c1-4432b8261c5a");
                        }
                     </activiti:string>
                  </activiti:field>
               </activiti:taskListener>
    

    其中b162be92-fb36-44f0-83c1-4432b8261c5a是我创建的文件夹的节点ID。

    不幸的是,当我完成此任务时,出现以下错误:

    Node Type: {http://www.alfresco.org/model/content/1.0}content, Node Aspects: [{http://www.alfresco.org/model/content/1.0}auditable, {http://www.alfresco.org/model/system/1.0}referenceable, {http://www.alfresco.org/model/system/1.0}localized] 0.0 2018-11-15 15:43:24,936 ERROR [impl.interceptor.CommandContext] [http-apr-8080-exec-3] Error while closing command context org.activiti.engine.ActivitiException: Exception while invoking TaskListener: Exception while invoking TaskListener: 10150807 Failed to execute supplied script: 10150806 TypeError: Cannot find function move in object Node Type: {http://www.alfresco.org/model/content/1.0}content, Node Aspects: [{http://www.alfresco.org/model/content/1.0}auditable, {http://www.alfresco.org/model/system/1.0}referenceable, {http://www.alfresco.org/model/system/1.0}localized]. (AlfrescoJS#10) at org.activiti.engine.impl.persistence.entity.TaskEntity.fireEvent(TaskEntity.java:742) at org.activiti.engine.impl.persistence.entity.TaskEntity.complete(TaskEntity.java:184) at org.activiti.engine.impl.cmd.CompleteTaskCmd.execute(CompleteTaskCmd.java:52) at org.activiti.engine.impl.cmd.CompleteTaskCmd.execute(CompleteTaskCmd.java:24) at org.activiti.engine.impl.cmd.NeedsActiveTaskCmd.execute(NeedsActiveTaskCmd.java:59) at org.activiti.engine.impl.interceptor.CommandInvoker.execute(CommandInvoker.java:24) at org.activiti.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:57) at org.activiti.spring.SpringTransactionInterceptor$1.doInTransaction(SpringTransactionInterceptor.java:47) at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:131) at org.activiti.spring.SpringTransactionInterceptor.execute(SpringTransactionInterceptor.java:45) at org.activiti.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:31) at org.activiti.engine.impl.cfg.CommandExecutorImpl.execute(CommandExecutorImpl.java:40) at org.activiti.engine.impl.cfg.CommandExecutorImpl.execute(CommandExecutorImpl.java:35) at org.activiti.engine.impl.TaskServiceImpl.complete(TaskServiceImpl.java:178) at org.alfresco.rest.workflow.api.impl.TasksImpl.update(TasksImpl.java:821) at sun.reflect.GeneratedMethodAccessor1556.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498)

    有人可以解释一下吗?非常感谢任何帮助:)

    最佳答案

    已解决

    问题是 move 函数需要一个节点元素,而不是我传递给它的 id(字符串)。

    修复了以下代码:

    <activiti:taskListener event="complete" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
              <activiti:field name="script">
                 <activiti:string> 
                    for (var i = 0; i &lt; bpm_package.children.length; i++){
                     var p = bpm_package;
                     var doc = p.children[i];
                     var myNode = initiatorhome.childByNamePath("foldertomove/testFolder"); <!-- the names of the nodes under the root directory where the file should be moved to-->
                     doc.move(myNode); 
                    }
                 </activiti:string>
              </activiti:field>
           </activiti:taskListener>
    

    关于java - 将任务文档的附件移动到另一个节点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53320569/

    相关文章:

    javascript - 在category.ftl中动态设置值

    java - 逐渐增加变异概率

    java - 如何使用 Spring 验证密码

    php - PHP 中的用户状态工作流引擎

    go - Cadence分别注册工作流程和事件

    java - 在 Alfresco 中从 Java 网页脚本调用 js 网页脚本

    java - 如何使用 Java 在 Alfresco 中编辑修改和修饰符属性

    java - 图像为空时数据未插入数据库

    java - Hibernate 无法初始化代理 - 没有 session

    git - Web 开发问题的基本版本控制 - 单个开发人员。 (SVN/GIT)