-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add initialization tasks and procedure finding
functions
- Loading branch information
Showing
4 changed files
with
72 additions
and
2 deletions.
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
...hestration/initialize/initialize-tasks.ts → src/orchestration/initialize/create-tasks.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/** | ||
* @author WMXPY | ||
* @namespace Orchestration_Initialize | ||
* @description Recursive Add Task | ||
*/ | ||
|
||
import { PubProcedureConfiguration } from "../../procedure/definition/configuration"; | ||
import { PubTask } from "../../task/task"; | ||
import { PubCachedWorkflowConfiguration } from "../../workflow/cache/configuration"; | ||
import { findNextProcedures } from "../procedure/find-next-procedure"; | ||
|
||
export const initializeRecursiveAddTask = ( | ||
configuration: PubCachedWorkflowConfiguration, | ||
currentProcedure: PubProcedureConfiguration, | ||
tasks: PubTask[], | ||
): PubTask[] => { | ||
|
||
const nextProcedures: PubProcedureConfiguration[] = findNextProcedures( | ||
currentProcedure, | ||
configuration, | ||
); | ||
|
||
const nextTasks: PubTask[] = nextProcedures.map((procedure: PubProcedureConfiguration) => { | ||
|
||
return PubTask.fromIdentifier(procedure.identifier); | ||
}); | ||
|
||
return [ | ||
...tasks, | ||
...nextTasks, | ||
]; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/** | ||
* @author WMXPY | ||
* @namespace Orchestration_Procedure | ||
* @description Find Next Procedure | ||
*/ | ||
|
||
import { PUB_CONNECTION_WAYPOINT_TYPE } from "../../connection/definition/configuration"; | ||
import { PubProcedureConfiguration } from "../../procedure/definition/configuration"; | ||
import { PubCachedWorkflowConfiguration } from "../../workflow/cache/configuration"; | ||
|
||
export const findNextProcedures = ( | ||
currentProcedure: PubProcedureConfiguration, | ||
configuration: PubCachedWorkflowConfiguration, | ||
): PubProcedureConfiguration[] => { | ||
|
||
const triggerConnections = configuration.configuration.connections | ||
.filter((connection) => { | ||
|
||
return connection.triggerProcedureIdentifier === | ||
currentProcedure.identifier | ||
&& connection.triggerProcedureWaypointType === | ||
PUB_CONNECTION_WAYPOINT_TYPE.PROCEDURE_SELF_END; | ||
}); | ||
|
||
const nextProcedures: PubProcedureConfiguration[] = triggerConnections | ||
.filter((connection) => { | ||
return connection.nextProcedureWaypointType === | ||
PUB_CONNECTION_WAYPOINT_TYPE.PROCEDURE_SELF_START; | ||
}) | ||
.map((connection) => { | ||
return configuration.getProcedureByIdentifier(connection.nextProcedureIdentifier); | ||
}) | ||
.filter((procedure): procedure is PubProcedureConfiguration => { | ||
return Boolean(procedure); | ||
}); | ||
|
||
return nextProcedures; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters