워크플로우 실행 보고
실행하는 데 다소 시간이 걸릴 수 있는 복잡한 워크플로우의 경우 워크플로우를 실행하는 사용자에게 명확한 진행 정보를 제공하면 유용할 수 있습니다. 워크플로우 실행이 이러한 방식으로 보고될 수 있도록 하려면 execute 멤버가 단계 배열을 반환해야 합니다. 각 배열 요소에는 다음 멤버가 포함되어야 합니다.
표 3-15 실행 보고의 필수 멤버
|
|
|
step
|
문자열
|
실행 단계의 이름을 나타내는 문자열입니다.
|
execute
|
함수
|
워크플로우 단계를 실행하는 함수입니다.
|
|
전체 워크플로우의 execute 함수와 마찬가지로 각 단계의 execute 멤버에는 워크플로우에 대한 매개변수를 포함하는 객체가 해당 인수로 사용됩니다. 다음은 세 단계를 거쳐 새 프로젝트, 공유 및 감사 레코드를 만드는 워크플로우 예입니다.
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); }
};