2012-12-31 101 views
3

我正在使用Liferay 6.1.1 CE。工作流內容處理

我通過在xml文件(leaveapproval.xml)中編寫定義並將其加載到服務器,創建了一個多級kaleo工作流(即具有兩級批准)。它可以正常工作,因爲我在博客中測試了這個工作流。

所以現在,我想在完成第二級批准後將工作流的內容提交給Web服務。

我該如何處理工作流程的內容?

可能嗎?

<?xml version="1.0"?> 
<workflow-definition 
     xmlns="urn:liferay.com:liferay-workflow_6.1.0" 
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
     xsi:schemaLocation="urn:liferay.com:liferay-workflow_6.1.0 http://www.liferay.com/dtd/liferay-workflow-definition_6_1_0.xsd"> 
    <name>LEAVE IN ACTION USER ACTION</name> 
    <description>A sample multilevel approver can approve a workflow content.</description> 
    <version>1</version> 

    <state> 
     <name>created</name> 
     <metadata> 
      <![CDATA[ 
      {"xy":[36,51]} 
      ]]> 
     </metadata> 
     <initial>true</initial> 
     <transitions> 
      <transition> 
       <name>review</name> 
       <target>review</target> 
       <default>true</default> 
      </transition> 
     </transitions> 
    </state> 

    <task> 
     <name>review</name> 
     <metadata> 
      <![CDATA[ 
      {"xy":[168,36]} 
      ]]> 
     </metadata> 
     <actions> 
      <notification> 
       <name>Review Notification</name> 
       <template>You have a new submission waiting for review in the workflow.</template> 
       <template-language>text</template-language> 
       <notification-type>email</notification-type> 
       <execution-type>onAssignment</execution-type> 
      </notification> 
      <notification> 
       <name>Review Completion Notification</name> 
       <template> 
        Your submission has been reviewed and the reviewer has applied the following ${taskComments}.</template> 
       <template-language>freemarker</template-language> 
       <notification-type>email</notification-type> 
       <recipients> 
        <user /> 
       </recipients> 
       <execution-type>onExit</execution-type> 
      </notification> 
     </actions> 
     <assignments> 
      <roles> 
       <role> 
        <role-type>regular</role-type> 
        <name>Portal Head</name> 
       </role> 
       <role> 
        <role-type>regular</role-type> 
        <name>Portal Content Reviewer</name> 
       </role> 
      </roles> 
     </assignments> 
     <transitions> 
      <transition> 
       <name>approve</name> 
       <target>recommended</target> 
      </transition> 
      <transition> 
       <name>reject</name> 
       <target>update</target> 
       <default>false</default> 
      </transition> 
     </transitions> 
    </task> 

    <task> 
     <name>recommended</name> 
     <metadata> 
      <![CDATA[{"xy":[168,36]}]]> 
     </metadata> 
     <actions> 
      <notification> 
       <name>Review Notification</name> 
       <template>You have a new submission waiting for your review in the workflow.</template> 
       <template-language>text</template-language> 
       <notification-type>email</notification-type> 
       <execution-type>onAssignment</execution-type> 
      </notification> 
      <notification> 
       <name>Review Completion Notification</name> 
       <template> 
        Your submission has been reviewed and the reviewer has applied the following ${taskComments}.</template> 
       <template-language>freemarker</template-language> 
       <notification-type>email</notification-type> 
       <recipients> 
        <user /> 
       </recipients> 
       <execution-type>onExit</execution-type> 
      </notification> 
     </actions> 
     <assignments> 
      <user> 
       <user-id>13379</user-id> 
      </user> 
     </assignments> 
     <transitions> 
      <transition> 
       <name>approve</name> 
       <target>approved</target> 
      </transition> 
      <transition> 
       <name>reject</name> 
       <target>update</target> 
       <default>false</default> 
      </transition> 
     </transitions> 
    </task> 

    <task> 
     <name>update</name> 
     <metadata> 
      <![CDATA[ 
      {"transitions":{"resubmit":{"bendpoints":[[303,140]]}},"xy":[328,199]} 
      ]]> 
     </metadata> 
     <actions> 
      <action> 
       <name>reject</name> 
       <script> 
        <![CDATA[ 
        Packages.com.liferay.portal.kernel.workflow.WorkflowStatusManagerUtil.updateStatus(
         Packages.com.liferay.portal.kernel.workflow.WorkflowConstants.toStatus("denied"), 
         workflowContext); 

        Packages.com.liferay.portal.kernel.workflow.WorkflowStatusManagerUtil.updateStatus(
         Packages.com.liferay.portal.kernel.workflow.WorkflowConstants.toStatus("pending"), 
         workflowContext); 
        ]]> 
       </script> 
       <script-language>javascript</script-language> 
       <execution-type>onAssignment</execution-type> 
      </action> 
      <notification> 
       <name>Creator Modification Notification</name> 
       <template>Your submission was rejected by a reviewer, please modify and resubmit.</template> 
       <template-language>text</template-language> 
       <notification-type>email</notification-type> 
       <execution-type>onAssignment</execution-type> 
      </notification> 
     </actions> 
     <assignments> 
      <user /> 
     </assignments> 
     <transitions> 
      <transition> 
       <name>resubmit</name> 
       <target>review</target> 
      </transition> 
     </transitions> 
    </task> 

    <state> 
     <name>approved</name> 
     <metadata> 
      <![CDATA[ 
       {"xy":[380,51]} 
      ]]> 
     </metadata> 
     <actions> 
      <action> 
       <name>approve</name> 
       <script> 
        <![CDATA[Packages.com.liferay.portal.kernel.workflow.WorkflowStatusManagerUtil.updateStatus  (Packages.com.liferay.portal.kernel.workflow.WorkflowConstants.toStatus("approved"), workflowContext);]]> 

       </script> 
       <script-language>javascript</script-language> 
       <execution-type>onEntry</execution-type> 
      </action> 
     </actions> 
    </state> 
</workflow-definition> 

幫助我..

+0

應該可以,你可以包含你的'leaveapproval.xml'嗎? –

+0

@PrakashK ...更新我的問題的定義 –

+0

你好...我下載和部署Kaleo工作流並使用它Pradip Bhatt:它只提供2個狀態接受和拒絕現在我必須提供相同的這種單一的審批機制,但與三狀態1)Accpet 2)拒絕3)重新提交你能指導我嗎? –

回答

0

有關某個工作流步驟編程運行任何東西,你通常只需要一個<script>標籤,就像你在做更新的狀態。

因此,在您批准的<state>中,您可能需要添加另一個<action>標記,這個標記用於處理Web服務調用(並讓其他操作保持原樣)。

您將用於該腳本的語言將取決於您所熟悉的內容。我會使用groovy,因爲它很好地處理普通的java代碼,這就是我所知道的。

下面是它會是什麼樣子(僅包括最後<state>標籤):

<state> 
    <name>approved</name> 
    <metadata> 
     <![CDATA[ 
     {"xy":[380,51]} 
     ]]> 
    </metadata> 
    <actions> 
     <action> 
      <name>approve</name> 
      <script> 
       <![CDATA[ 
       Packages.com.liferay.portal.kernel.workflow.WorkflowStatusManagerUtil.updateStatus(
        Packages.com.liferay.portal.kernel.workflow.WorkflowConstants.toStatus("approved"), 
        workflowContext); 
       ]]> 
      </script> 
      <script-language>javascript</script-language> 
      <execution-type>onEntry</execution-type> 
     </action> 
     <action> 
      <name>submit-web-service</name> 
      <script> 
       <![CDATA[ 
       import java.io.* 
       import java.net.* 

       URL url = new URL(
        "www.my-web-service.com/api/whatever?theParam=" + 
         ${theRelevantContextVariable}); 

       URLConnection urlConnection = url.openConnection(); 

       // if necessary to read response data: 
       // BufferedReader bufferedReader = new BufferedReader(
       // new InputStreamReader(urlConnection.getInputStream())); 
       // String something = bufferedReader.readLine(); 
       // etc. 
       ]]> 
      </script> 
      <script-language>groovy</script-language> 
      <execution-type>onEntry</execution-type> 
     </action> 
    </actions> 
</state> 

您可能需要一個POST請求,而不是,在這種情況下,你不同的方式實現Web服務調用。但是,無論如何,您都需要將Web服務代碼寫入操作標籤。像這樣的東西應該工作。