This is a sample of how to create an enhanced workflow orchestrator workflow using the Build Tools.
GitHub Repository: https://github.com/SimonSparksUK/Orchestrator
Filename: WorflowGeneralSampleEnhanced.wf.ts
import{Logger}from"com.vmware.pscoe.library.ts.logging/Logger";
import{DefaultErrorHandler,In,Item,Out,RootItem,Workflow}from"vrotsc-annotations";
@Workflow({
name:"Sample - Enhanced",
path:"CompanyName/Workflows/General",
description:"",
restartMode:1,// restartMode - 0: Do not resume workflow run, 1: Resume workflow run (default)
resumeFromFailedMode:0,// resumeFromFailedMode - 0: System default (default), 1: Enabled, 2: Disabled
attributes:{
businessStatus:{
type:"string"
},
endMode:{
type:"number"
},
strErrorMessage:{
type:"string"
},
},
input:{
strProjectID:{
type:"string"
},
blnScheduleOperation:{
title:"Schedule Operation ?",
type:"boolean",
},
dteScheduleStartDateTime:{
title:"Schedule Time",
type:"Date",
},
},
output:{
},
})
exportclassgeneralSampleEnhanced{
@DefaultErrorHandler({
target:"processError",
})
publicdefaultErrorHandler(@OutstrErrorMessage:string):void{
// NO OP
}
@Item({
target:"workflowEndFailure",
})
publicprocessError(@InstrErrorMessage:string,@InstrProjectID:string):void{
System.log(`Sending Error Message with message '${strErrorMessage}'.`);
}
@WorkflowEndItem({
endMode:1,
businessStatus:"Failure",
})
publicworkflowEndFailure(@ErrstrErrorMessage:string){
// NOOP
}
@RootItem({
target:"decisionElement",
})
publicworkflowStart(@IninputProperties:Properties,@InstrResourceActionType:string,@InstrResourceActionName:string,@OutobjResourceProperties:Properties):void{
letstrWorkflowName:string=`${strResourceActionType} -${strResourceActionName}`;
letobjLogger:Logger=Logger.getLogger(strWorkflowName);
Utilities.logExecutionContext(objLogger);
Utilities.logInputPropertiesForWorkflow(objLogger,inputProperties,strWorkflowName);
objResourceProperties=Utilities.getExecutionContext();
}
@DecisionItem({
target:"waitingForEvent",
else:"workflowExecute",
})
publicdecisionElement(blnScheduleOperation:boolean){
returnblnScheduleOperation===true;
}
@WaitingTimerItem({
target:"workflowExecute",
})
publicwaitingForEvent(@IndteScheduleStartDateTime:Date){
// NO OP
}
@Item({
target:"workflowEnd",
})
publicworkflowExecute(@InstrProjectID:string):void{
try{
letstrResourceActionType:string="General";
letstrResourceActionName:string="Sample - Enhanced";
letobjLogger:Logger=Logger.getLogger(`${strResourceActionType} -${strResourceActionName}`);
letobjError:Error=objExceptionasError;
objLogger.error(`${strFunctionName} - Name:${objError.name}`);
objLogger.error(`${strFunctionName} - Message:${objError.message}`);
if (objError.stack){
objLogger.error(`${strFunctionName} - Message:${objError.message}`);
}
if (strCustomErrorMessage!==""){
objLogger.error(`${strFunctionName} - Custom Error Message:${strCustomErrorMessage}`);
}
}catch (e){
throwe;
}finally{
}
}
@WorkflowEndItem({
endMode:0
})
publicworkflowEnd(){
// NOOP
}
}
Discover more from Cloud Build Tools
Subscribe to get the latest posts sent to your email.
