| 169 | } |
| 170 | |
| 171 | FlowState Flow::execute() |
| 172 | { |
| 173 | emit executionStarted(); |
| 174 | |
| 175 | if (!isValid()) { |
| 176 | emit executionFinished(FlowState::Failed); |
| 177 | return FlowState::Failed; |
| 178 | } |
| 179 | |
| 180 | if (hasCircularDependencies()) { |
| 181 | qWarning() << "Flow::execute - Circular dependencies detected"; |
| 182 | emit executionFinished(FlowState::Failed); |
| 183 | return FlowState::Failed; |
| 184 | } |
| 185 | |
| 186 | QList<BaseTask *> executionOrder = getExecutionOrder(); |
| 187 | |
| 188 | for (BaseTask *task : executionOrder) { |
| 189 | TaskState taskResult = task->execute(); |
| 190 | |
| 191 | if (taskResult == TaskState::Failed) { |
| 192 | qWarning() << "Flow::execute - Task" << task->taskId() << "failed"; |
| 193 | emit executionFinished(FlowState::Failed); |
| 194 | return FlowState::Failed; |
| 195 | } |
| 196 | |
| 197 | if (taskResult == TaskState::Cancelled) { |
| 198 | qWarning() << "Flow::execute - Task" << task->taskId() << "cancelled"; |
| 199 | emit executionFinished(FlowState::Cancelled); |
| 200 | return FlowState::Cancelled; |
| 201 | } |
| 202 | } |
| 203 | |
| 204 | emit executionFinished(FlowState::Success); |
| 205 | return FlowState::Success; |
| 206 | } |
| 207 | |
| 208 | bool Flow::isValid() const |
| 209 | { |