* @brief Resolve a dataset by path, title, or uniqueId; exactly one key must be present. */
| 101 | * @brief Resolve a dataset by path, title, or uniqueId; exactly one key must be present. |
| 102 | */ |
| 103 | API::CommandResponse API::Handlers::AssistantHandler::datasetResolve(const QString& id, |
| 104 | const QJsonObject& params) |
| 105 | { |
| 106 | const bool hasPath = params.contains(QStringLiteral("path")); |
| 107 | const bool hasTitle = params.contains(QStringLiteral("title")); |
| 108 | const bool hasUniqueId = params.contains(Keys::UniqueId); |
| 109 | |
| 110 | const int presentCount = (hasPath ? 1 : 0) + (hasTitle ? 1 : 0) + (hasUniqueId ? 1 : 0); |
| 111 | if (presentCount == 0) |
| 112 | return CommandResponse::makeError( |
| 113 | id, |
| 114 | ErrorCode::MissingParam, |
| 115 | QStringLiteral("Provide exactly one of: path (e.g. 'Group/Dataset'), title, or uniqueId.")); |
| 116 | |
| 117 | if (presentCount > 1) |
| 118 | return CommandResponse::makeError( |
| 119 | id, |
| 120 | ErrorCode::InvalidParam, |
| 121 | QStringLiteral("Provide exactly one of {path, title, uniqueId} -- got %1.") |
| 122 | .arg(presentCount)); |
| 123 | |
| 124 | if (hasPath) |
| 125 | return forward(QStringLiteral("project.dataset.getByPath"), id, params); |
| 126 | |
| 127 | if (hasTitle) |
| 128 | return forward(QStringLiteral("project.dataset.getByTitle"), id, params); |
| 129 | |
| 130 | return forward(QStringLiteral("project.dataset.getByUniqueId"), id, params); |
| 131 | } |
| 132 | |
| 133 | //-------------------------------------------------------------------------------------------------- |
| 134 | // assistant.workspace.resolve: match by id or case-insensitive title |