ofbiz工作流程原始碼學習(2)–WfExecutionObject介面

來源:互聯網
上載者:User
WfExecutionObject介面與實現

1.概述

WfExecutionObject介面是一個抽象基類介面,它定義了WfProcess和WfActivity公有的屬性,狀態和操作。WfExecutionObject的操作返回的狀態與流程狀態是不同的。WfExecutionObject提供了方法來擷取當前的狀態並完成從目前狀態向另一狀態的轉變。但WfExecutionObject的狀態是執行對象的狀態,WfProcess的狀態是流程的狀態,他們之間並沒有必然的關係。

 

2.屬性及相應方法

2.1 name

   name屬性是工作流程執行對象的描述性名字,name屬性的擷取和設定是通過GenericDelegator和workEffortId來完成的:

    public String name() throws WfException {

        return getRuntimeObject().getString("workEffortName");

    }

    public void setName(String newValue) throws WfException {

        GenericValue dataObject = getRuntimeObject();

        try {

            dataObject.set("workEffortName", newValue);

            dataObject.store();

        } catch (GenericEntityException e) {

            throw new WfException(e.getMessage(), e);

        }

    }

  

2.2 key

   key是工作流程執行對象的唯一標示符。一個特定的工作流程管理器產生的流程集合中,每個流程都有一個唯一的key;一個流程包含的活動集合中,每個活動都有一個唯一的key。當工作流程執行對象產生時,由工作流程管理器為它分配一個特定的key。

   Key不同於對象標示符,它是工作流程執行對象生命週期中流程或活動的reference。它由activityId或processId來表示。

2.3 process_context

   process_context是定義執行對象環境的流程相關資料,它由一系列的名字屬性來描述。process_context由一系列的名值對來表達,process_context的擷取和設定是通過runtimeDataId和GenericValue來實現的。

2.4 priority

   priority的有效值在0到5之間,一個為highest,三個為normal,另外一個為其它情況。

2.5 last_state_time

   表示上次狀態改變的時間,如下:

    public Timestamp lastStateTime() throws WfException {

        GenericValue dataObject = getRuntimeObject();

 

        if (dataObject == null || dataObject.get("lastStatusUpdate") == null)

            throw new WfException("No runtime object or status has never been set.");

        return dataObject.getTimestamp("lastStatusUpdate");

}

 

3.狀態

   總的狀態分為open和closed。

   Open分為open.running和open.not_running。

   Open.not_running分為not_running.not_started和not_running.suspended。

   Closed分為closed.completed,closed.terminated和closed.aborted。

   從not_running.suspended到open.running應該用resume()方法。另外調用terminate()方法,abort()方法或complete()方法,suspend()方法可以到相應的狀態。當然了,最通用的改變狀態的方法是用changeState(int state)方法。

 

 

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.