executeWorkflow method
Execute workflow
Implementation
@override
Future<WorkflowExecutionResult> executeWorkflow(
String workflowId, {
Map<String, dynamic>? inputData,
}) async {
final workflow = _workflows[workflowId];
if (workflow == null) {
throw ArgumentError('Workflow not found');
}
final executionId = 'execution_${DateTime.now().millisecondsSinceEpoch}';
final startedAt = DateTime.now();
// Create execution result
final executionResult = WorkflowExecutionResult(
workflowId: workflowId,
executionId: executionId,
status: WorkflowStatus.running,
result: inputData,
error: null,
startedAt: startedAt,
completedAt: null,
);
_executionResults[executionId] = executionResult;
// Simulate workflow execution for Linux
_eventController.add(WorkflowEvent(
executionId: executionId,
eventType: WorkflowEventType.workflowStarted,
stepId: null,
data: {'workflowId': workflowId},
error: null,
timestamp: DateTime.now(),
));
// Process workflow steps
await _processWorkflowSteps(workflow, executionId, inputData ?? {});
// Update execution result with completion
final completedExecutionResult = WorkflowExecutionResult(
workflowId: workflowId,
executionId: executionId,
status: WorkflowStatus.completed,
result: inputData, // In a real implementation, this would contain the actual result
error: null,
startedAt: startedAt,
completedAt: DateTime.now(),
);
_executionResults[executionId] = completedExecutionResult;
_eventController.add(WorkflowEvent(
executionId: executionId,
eventType: WorkflowEventType.workflowCompleted,
stepId: null,
data: {'result': inputData},
error: null,
timestamp: DateTime.now(),
));
return completedExecutionResult;
}