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: {
},
})
export class generalSampleEnhanced {
@DefaultErrorHandler({
target: "processError",
})
public defaultErrorHandler(@Out strErrorMessage: string): void {
// NO OP
}
@Item({
target: "workflowEndFailure",
})
public processError(@In strErrorMessage: string, @In strProjectID: string): void {
System.log(`Sending Error Message with message '${strErrorMessage}'.`);
}
@WorkflowEndItem({
endMode: 1,
businessStatus: "Failure",
})
public workflowEndFailure(@Err strErrorMessage: string) {
// NOOP
}
@RootItem({
target: "decisionElement",
})
public workflowStart(@In inputProperties: Properties, @In strResourceActionType: string, @In strResourceActionName: string, @Out objResourceProperties: Properties): void {
let strWorkflowName: string = `${strResourceActionType} - ${strResourceActionName}`;
let objLogger: Logger = Logger.getLogger(strWorkflowName);
Utilities.logExecutionContext(objLogger);
Utilities.logInputPropertiesForWorkflow(objLogger, inputProperties, strWorkflowName);
objResourceProperties = Utilities.getExecutionContext();
}
@DecisionItem({
target: "waitingForEvent",
else: "workflowExecute",
})
public decisionElement(blnScheduleOperation: boolean) {
return blnScheduleOperation === true;
}
@WaitingTimerItem({
target: "workflowExecute",
})
public waitingForEvent(@In dteScheduleStartDateTime: Date) {
// NO OP
}
@Item({
target: "workflowEnd",
})
public workflowExecute(@In strProjectID: string): void {
try {
let strResourceActionType: string = "General";
let strResourceActionName: string = "Sample - Enhanced";
let objLogger: Logger = Logger.getLogger(`${strResourceActionType} - ${strResourceActionName}`);
let objError: Error = objException as Error;
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) {
throw e;
} finally {
}
}
@WorkflowEndItem({
endMode: 0
})
public workflowEnd() {
// NOOP
}
}
Discover more from Cloud Build Tools
Subscribe to get the latest posts sent to your email.
