* @brief Find a dataset by its uniqueId across all groups. */
| 3351 | * @brief Find a dataset by its uniqueId across all groups. |
| 3352 | */ |
| 3353 | API::CommandResponse API::Handlers::ProjectHandler::datasetGetByUniqueId(const QString& id, |
| 3354 | const QJsonObject& params) |
| 3355 | { |
| 3356 | if (!params.contains(Keys::UniqueId)) |
| 3357 | return CommandResponse::makeError( |
| 3358 | id, ErrorCode::MissingParam, QStringLiteral("Missing required parameter: uniqueId")); |
| 3359 | |
| 3360 | const int uniqueId = params.value(Keys::UniqueId).toInt(); |
| 3361 | const auto& groups = DataModel::ProjectModel::instance().groups(); |
| 3362 | |
| 3363 | for (const auto& group : groups) { |
| 3364 | for (const auto& dataset : group.datasets) |
| 3365 | if (dataset.uniqueId == uniqueId) |
| 3366 | return CommandResponse::makeSuccess(id, buildDatasetObject(dataset, group)); |
| 3367 | } |
| 3368 | |
| 3369 | return CommandResponse::makeError( |
| 3370 | id, ErrorCode::InvalidParam, QStringLiteral("Dataset not found for uniqueId %1").arg(uniqueId)); |
| 3371 | } |
| 3372 | |
| 3373 | /** |
| 3374 | * @brief Find a dataset by title (optionally narrowed by sourceId / groupId). |
nothing calls this directly
no test coverage detected