Alfresco - 批准工作流程中的任务

时间:2016-02-13 16:43:15

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

我将小程序集成到Alfresco的工作流程中。我在这里创建了一个新按钮org/alfresco/components/form/controls/workflow/activiti-transitions.ftl

  ...

    <button onclick="changePDF(); this.disabled=true; return false;"> Change </button>
    <div id="pdfTexto" style="width:1000px;height:1000px"></div>
        <div class="applet">
            <script type="text/javascript">
                deploy();
            </script>
        </div>
    </#if>

此按钮更改(通过applet的javascript)调用applet的功能,该功能在相应工作流程的文件中进行更改。在此之后,我想将"Approved"放在按钮accept标准下。但是,我只想在更改生效后再进行此操作。完成更改后,我的applet返回"ok" POST请求已完成),之后,我想将"Approved"并重定向到&#的同一页面34;接受&#34;按钮重定向。在简历中,在&#34; ok&#34;之后,按下接受按钮。

我的applet使用以下内容更新现有文档的内容: http://localhost:8080/share/proxy/alfresco/api/upload ...

我该怎么做?有什么提示可以获得更好的解决方案吗?

演进: 我试图做到这一点:

 var form = new FormData();
     form.append("prop_wf_reviewOutcome","Approve");
     form.append("prop_bpm_comment","good");
     form.append("prop_transitions","Next");
     var requestTask = new XMLHttpRequest();
         requestTask[Alfresco.util.CSRFPolicy.getHeader()] = Alfresco.util.CSRFPolicy.getToken();
         requestTask.open("POST", "http://localhost:8080/share/proxy/alfresco/api/task/"+ taskidVar+ "/formprocessor" + "?" + Alfresco.util.CSRFPolicy.getParameter() + "=" + encodeURIComponent(Alfresco.util.CSRFPolicy.getToken()));
         requestTask.send(form);

但缺少重定向页面作为&#34;批准&#34;按钮。

1 个答案:

答案 0 :(得分:5)

首先,您需要定义您的行为:

package com.someco.alfresco.policy;

import org.alfresco.model.ContentModel;
import org.alfresco.repo.content.ContentServicePolicies;
import org.alfresco.repo.policy.Behaviour;
import org.alfresco.repo.policy.JavaBehaviour;
import org.alfresco.repo.policy.PolicyComponent;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.namespace.NamespaceService;
import org.alfresco.service.namespace.QName;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

public class DocumentUpdatePolicy implements ContentServicePolicies.OnContentUpdatePolicy {
    private final Log logger = LogFactory.getLog(getClass());

    private PolicyComponent policyComponent;    
    private NodeService nodeService;    

    public void init() {
        this.policyComponent.bindClassBehaviour(
                QName.createQName(NamespaceService.ALFRESCO_URI, "onContentUpdate"),
                ContentModel.TYPE_CONTENT,
                new JavaBehaviour(this, "onContentUpdate", Behaviour.NotificationFrequency.EVERY_EVENT));
    }

    @Override
    public void onContentUpdate(NodeRef nodeRef, boolean newContent) {

        logger.debug("Called on: " + nodeRef);
        if (null == nodeRef || !nodeService.exists(nodeRef)) {
            logger.error("Wrong nodeRef");
            /* This can happen in some circumstances */
            /* Do you want to just ignore it or do something ? You decide */
            return;
        }

        /* Here goes the code to update the task */
    }

    public void setPolicyComponent(final PolicyComponent policyComponent) {
        this.policyComponent = policyComponent;
    }

    public void setNodeService(NodeService nodeService) {
        this.nodeService = nodeService;
    }


}

您需要在自定义Spring上下文中初始化它:

<bean id="onDocumentUpdatePolicy" class="com.someco.alfresco.policy.DocumentUpdatePolicy">
    <property name="policyComponent">
        <ref bean="policyComponent" />
    </property>
    <property name="nodeService">
        <ref bean="NodeService" />
    </property>
</bean>