ワークフローの実行のレポート
実行にある程度の時間が必要な複雑なワークフローの場合は、そのワークフローを実行しているユーザーに明確な進捗状況を表示すると有効です。ワークフローの実行をこの方法で報告できるようにするには、execute メンバーが手順の配列を返すべきです。各配列要素には、次のメンバーが必要です。
Table 3-16 実行のレポートの必須メンバー
|
|
|
step
|
文字列
|
実行手順の名前を示す文字列
|
execute
|
関数
|
ワークフローの手順を実行する関数
|
|
全体としてのワークフロー上の execute 関数と同様に、各手順の execute メンバーは、そのワークフローへのパラメータを含むオブジェクトを引数として受け取ります。例として、3 つの手順で新しいプロジェクト、シェア、および監査レコードを作成するワークフローを次に示します。
var steps = [ {
step: 'Checking for associated project',
execute: function (params) {
try {
run('shares select ' + params.unit);
} catch (err) {
if (err.code != EAKSH_ENTITY_BADSELECT)
throw (err);
/*
* We haven't yet created a project that corresponds to
* this business unit; create it now.
*/
run('shares project ' + params.unit);
set('mountpoint', '/export/' + params.unit);
run('commit');
run('shares select ' + params.unit);
}
}
}, {
step: 'Creating share',
execute: function (params) {
run('filesystem ' + params.name);
run('commit');
}
}, {
step: 'Creating audit record',
execute: function (params) {
audit('created "' + params.name + '" in "' + params.unit);
}
} ];
var workflow = {
name: 'Create share',
description: 'Creates a new share in a business unit',
parameters: {
name: {
label: 'Name of new share',
type: 'String'
},
unit: {
label: 'Business unit',
type: 'ChooseOne',
options: [ 'development', 'finance', 'qa', 'sales' ],
optionlabels: [ 'Development', 'Finance',
'Quality Assurance', 'Sales/Administrative' ],
}
},
validate: function (params) {
try {
run('shares select ' + params.unit);
run('select ' + params.name);
} catch (err) {
if (err.code == EAKSH_ENTITY_BADSELECT)
return;
}
return ({ name: 'share already exists' });
},
execute: function (params) { return (steps); }
};