Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Operations<T>

The Operations class extends Operation and is used to create a 'string' of operations that must be completed in serial order.

The implementing class is responsible (in defineOperations) for creating each operation (and invoking addNextOperation) to add the operations to the list. You must also call "defineOperations" from your constructor. This allows you to setup anything you need (in your constructor) before defining the list of operations.

You can initiate the operation by invoking performOperation, which will iterate through each operation defined and perform them in sequence. If a operation chooses to diverge, then

Type parameters

  • T

Hierarchy

Implements

Index

Constructors

constructor

  • new Operations(opName: string, critical?: boolean): Operations

Properties

errorMessages

errorMessages: string[] = []

infoMessages

infoMessages: string[] = []

Protected log

log: Logger

Private mCurrentOperation

mCurrentOperation: number = 0

The current operation that is being executed.

Private mInputParameters

mInputParameters: T

The input parameters to this string of operations

Private mOperationList

mOperationList: Array<Operation<any>> = []

The list of operations that should be executed in sequence

Protected mOperationResult

mOperationResult: IOperationResult<any>

the result from the operation

Protected mOperationResults

mOperationResults: IOperationResult<any> = null

The full list of operation results

Private mOperationUndoIndex

mOperationUndoIndex: number = 0

The current operation undo index.

Private mOperationUndoList

mOperationUndoList: Array<Operation<any>> = []

In the event of an undo request, we will prepare a list that will be traversed to complete each undo function.

Private mOperationsCompleteCallback

mOperationsCompleteCallback: IOperationResultReady<any>

the callers operations complete callback

Private mOverallStatusMessage

mOverallStatusMessage: string

Optionally give a status message in your Operations object instead of letting the message from your sub-operations come through.

Static Readonly NO_OUTPUT

NO_OUTPUT: any = null

Static Readonly NO_PARMS

NO_PARMS: any = null

Accessors

allFilesCreated

  • get allFilesCreated(): string[]

fileToUndo

  • get fileToUndo(): string[]

operationName

  • get operationName(): string

operationResult

operationResultMessage

  • set operationResultMessage(message: string): void

operationSucceeded

  • get operationSucceeded(): boolean

percentComplete

  • get percentComplete(): number

stageName

statusMessage

  • get statusMessage(): string

totalOperations

  • get totalOperations(): number

Methods

Protected addFileCreated

  • addFileCreated(fileUndoable: boolean, file: string): void

Protected addNextOperation

  • addNextOperation(newOperation: Operation<any>): void

Protected addResult

Protected createFile

  • createFile(filePath: string, message: string, saveFileNameForUndo: boolean, isDir: boolean): void

Protected Abstract defineOperations

  • defineOperations(): void

Protected execute

  • execute(): void

Private executeNextOperation

  • executeNextOperation(input: any): void

Private executeNextUndo

  • executeNextUndo(): void

executeOperation

Protected logOperationBeginMessages

  • logOperationBeginMessages(): void

logOperationResults

  • logOperationResults(): void

Protected operationCompleted

performUndo

Private prepareForUndo

  • prepareForUndo(): void
  • Prepare a list of operations to 'undo', we will traverse the list calling the undo function of each operation. Only operations that are marked as 'undoa-able' will be called.

    TODO - we could probably fire off all undo functions here async, but for now they are serial

    Returns void

Protected printFilesCreatedList

  • printFilesCreatedList(): void

Protected setOperationDiverge

  • setOperationDiverge(operation: Operation<any>, continuePathAfterDiverge: boolean): void

Protected setOperationFailed

  • setOperationFailed(): void

Protected setOperationUndoAttempted

  • setOperationUndoAttempted(): void

Protected setOperationUndoFailed

  • setOperationUndoFailed(): void

Protected setOperationUndoable

  • setOperationUndoable(): void

setStatusMessage

  • setStatusMessage(message: string, ...args: any[]): string
  • Set the status message for the overall Operations object, which takes precedence over the sub-operations' messages

    Parameters

    • message: string

      the message, including any templates you want replaced like %s or "{{myObject}}"

    • Rest ...args: any[]

      variable args as allowed by printf-like syntax or {myObject: this.myObject}

    Returns string

    the final translated and formatted string (in case you want to log it etc.)

Protected undo

  • undo(): void

Private undoOpComplete

  • undoOpComplete(): void

Static summarizeResults

Generated using TypeDoc