ORE Studio 0.0.4
Loading...
Searching...
No Matches
dq_message_handler.hpp
1/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 *
3 * Copyright (C) 2025 Marco Craveiro <marco.craveiro@gmail.com>
4 *
5 * This program is free software; you can redistribute it and/or modify it under
6 * the terms of the GNU General Public License as published by the Free Software
7 * Foundation; either version 3 of the License, or (at your option) any later
8 * version.
9 *
10 * This program is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
13 * details.
14 *
15 * You should have received a copy of the GNU General Public License along with
16 * this program; if not, write to the Free Software Foundation, Inc., 51
17 * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 *
19 */
20#ifndef ORES_DQ_MESSAGING_DQ_MESSAGE_HANDLER_HPP
21#define ORES_DQ_MESSAGING_DQ_MESSAGE_HANDLER_HPP
22
23#include <memory>
24#include "ores.database/domain/context.hpp"
25#include "ores.logging/make_logger.hpp"
26#include "ores.comms/messaging/message_handler.hpp"
27#include "ores.comms/service/auth_session_service.hpp"
28#include "ores.iam/service/authorization_service.hpp"
29#include "ores.dq/service/change_management_service.hpp"
30#include "ores.dq/service/data_organization_service.hpp"
31#include "ores.dq/service/dataset_service.hpp"
32#include "ores.dq/service/coding_scheme_service.hpp"
33#include "ores.dq/service/dimension_service.hpp"
34#include "ores.dq/service/publication_service.hpp"
35#include "ores.dq/service/dataset_bundle_service.hpp"
36#include "ores.dq/service/dataset_bundle_member_service.hpp"
37
38namespace ores::dq::messaging {
39
51private:
52 [[nodiscard]] static auto& lg() {
53 using namespace ores::logging;
54 static auto instance = make_logger(
55 "ores.dq.messaging.dq_message_handler");
56 return instance;
57 }
58
59public:
68 std::shared_ptr<comms::service::auth_session_service> sessions,
69 std::shared_ptr<iam::service::authorization_service> auth_service);
70
71 using handler_result = boost::asio::awaitable<
72 std::expected<std::vector<std::byte>, ores::utility::serialization::error_code>
73 >;
74
83 handler_result
84 handle_message(comms::messaging::message_type type,
85 std::span<const std::byte> payload,
86 const std::string& remote_address) override;
87
88private:
89 // =========================================================================
90 // Change Management Handlers
91 // =========================================================================
92
98 handler_result
99 handle_get_change_reason_categories_request(
100 std::span<const std::byte> payload,
101 const std::string& remote_address);
102
108 handler_result
109 handle_get_change_reasons_request(std::span<const std::byte> payload,
110 const std::string& remote_address);
111
117 handler_result
118 handle_get_change_reasons_by_category_request(
119 std::span<const std::byte> payload,
120 const std::string& remote_address);
121
127 handler_result
128 handle_save_change_reason_request(std::span<const std::byte> payload,
129 const std::string& remote_address);
130
136 handler_result
137 handle_delete_change_reason_request(std::span<const std::byte> payload,
138 const std::string& remote_address);
139
145 handler_result
146 handle_get_change_reason_history_request(std::span<const std::byte> payload,
147 const std::string& remote_address);
148
154 handler_result
155 handle_save_change_reason_category_request(
156 std::span<const std::byte> payload,
157 const std::string& remote_address);
158
164 handler_result
165 handle_delete_change_reason_category_request(
166 std::span<const std::byte> payload,
167 const std::string& remote_address);
168
174 handler_result
175 handle_get_change_reason_category_history_request(
176 std::span<const std::byte> payload,
177 const std::string& remote_address);
178
179 // =========================================================================
180 // Catalog Handlers
181 // =========================================================================
182
183 handler_result
184 handle_get_catalogs_request(std::span<const std::byte> payload,
185 const std::string& remote_address);
186
187 handler_result
188 handle_save_catalog_request(std::span<const std::byte> payload,
189 const std::string& remote_address);
190
191 handler_result
192 handle_delete_catalog_request(std::span<const std::byte> payload,
193 const std::string& remote_address);
194
195 handler_result
196 handle_get_catalog_history_request(std::span<const std::byte> payload,
197 const std::string& remote_address);
198
199 // =========================================================================
200 // Dataset Dependency Handlers
201 // =========================================================================
202
203 handler_result
204 handle_get_dataset_dependencies_request(std::span<const std::byte> payload,
205 const std::string& remote_address);
206
207 handler_result
208 handle_get_dataset_dependencies_by_dataset_request(
209 std::span<const std::byte> payload,
210 const std::string& remote_address);
211
212 // =========================================================================
213 // Data Domain Handlers
214 // =========================================================================
215
216 handler_result
217 handle_get_data_domains_request(std::span<const std::byte> payload,
218 const std::string& remote_address);
219
220 handler_result
221 handle_save_data_domain_request(std::span<const std::byte> payload,
222 const std::string& remote_address);
223
224 handler_result
225 handle_delete_data_domain_request(std::span<const std::byte> payload,
226 const std::string& remote_address);
227
228 handler_result
229 handle_get_data_domain_history_request(std::span<const std::byte> payload,
230 const std::string& remote_address);
231
232 // =========================================================================
233 // Subject Area Handlers
234 // =========================================================================
235
236 handler_result
237 handle_get_subject_areas_request(std::span<const std::byte> payload,
238 const std::string& remote_address);
239
240 handler_result
241 handle_get_subject_areas_by_domain_request(std::span<const std::byte> payload,
242 const std::string& remote_address);
243
244 handler_result
245 handle_save_subject_area_request(std::span<const std::byte> payload,
246 const std::string& remote_address);
247
248 handler_result
249 handle_delete_subject_area_request(std::span<const std::byte> payload,
250 const std::string& remote_address);
251
252 handler_result
253 handle_get_subject_area_history_request(std::span<const std::byte> payload,
254 const std::string& remote_address);
255
256 // =========================================================================
257 // Dataset Handlers
258 // =========================================================================
259
260 handler_result
261 handle_get_datasets_request(std::span<const std::byte> payload,
262 const std::string& remote_address);
263
264 handler_result
265 handle_save_dataset_request(std::span<const std::byte> payload,
266 const std::string& remote_address);
267
268 handler_result
269 handle_delete_dataset_request(std::span<const std::byte> payload,
270 const std::string& remote_address);
271
272 handler_result
273 handle_get_dataset_history_request(std::span<const std::byte> payload,
274 const std::string& remote_address);
275
276 // =========================================================================
277 // Methodology Handlers
278 // =========================================================================
279
280 handler_result
281 handle_get_methodologies_request(std::span<const std::byte> payload,
282 const std::string& remote_address);
283
284 handler_result
285 handle_save_methodology_request(std::span<const std::byte> payload,
286 const std::string& remote_address);
287
288 handler_result
289 handle_delete_methodology_request(std::span<const std::byte> payload,
290 const std::string& remote_address);
291
292 handler_result
293 handle_get_methodology_history_request(std::span<const std::byte> payload,
294 const std::string& remote_address);
295
296 // =========================================================================
297 // Coding Scheme Handlers
298 // =========================================================================
299
300 handler_result
301 handle_get_coding_schemes_request(std::span<const std::byte> payload,
302 const std::string& remote_address);
303
304 handler_result
305 handle_get_coding_schemes_by_authority_type_request(
306 std::span<const std::byte> payload,
307 const std::string& remote_address);
308
309 handler_result
310 handle_save_coding_scheme_request(std::span<const std::byte> payload,
311 const std::string& remote_address);
312
313 handler_result
314 handle_delete_coding_scheme_request(std::span<const std::byte> payload,
315 const std::string& remote_address);
316
317 handler_result
318 handle_get_coding_scheme_history_request(std::span<const std::byte> payload,
319 const std::string& remote_address);
320
321 // =========================================================================
322 // Coding Scheme Authority Type Handlers
323 // =========================================================================
324
325 handler_result
326 handle_get_coding_scheme_authority_types_request(
327 std::span<const std::byte> payload,
328 const std::string& remote_address);
329
330 handler_result
331 handle_save_coding_scheme_authority_type_request(
332 std::span<const std::byte> payload,
333 const std::string& remote_address);
334
335 handler_result
336 handle_delete_coding_scheme_authority_type_request(
337 std::span<const std::byte> payload,
338 const std::string& remote_address);
339
340 handler_result
341 handle_get_coding_scheme_authority_type_history_request(
342 std::span<const std::byte> payload,
343 const std::string& remote_address);
344
345 // =========================================================================
346 // Nature Dimension Handlers
347 // =========================================================================
348
349 handler_result
350 handle_get_nature_dimensions_request(std::span<const std::byte> payload,
351 const std::string& remote_address);
352
353 handler_result
354 handle_save_nature_dimension_request(std::span<const std::byte> payload,
355 const std::string& remote_address);
356
357 handler_result
358 handle_delete_nature_dimension_request(std::span<const std::byte> payload,
359 const std::string& remote_address);
360
361 handler_result
362 handle_get_nature_dimension_history_request(std::span<const std::byte> payload,
363 const std::string& remote_address);
364
365 // =========================================================================
366 // Origin Dimension Handlers
367 // =========================================================================
368
369 handler_result
370 handle_get_origin_dimensions_request(std::span<const std::byte> payload,
371 const std::string& remote_address);
372
373 handler_result
374 handle_save_origin_dimension_request(std::span<const std::byte> payload,
375 const std::string& remote_address);
376
377 handler_result
378 handle_delete_origin_dimension_request(std::span<const std::byte> payload,
379 const std::string& remote_address);
380
381 handler_result
382 handle_get_origin_dimension_history_request(std::span<const std::byte> payload,
383 const std::string& remote_address);
384
385 // =========================================================================
386 // Treatment Dimension Handlers
387 // =========================================================================
388
389 handler_result
390 handle_get_treatment_dimensions_request(std::span<const std::byte> payload,
391 const std::string& remote_address);
392
393 handler_result
394 handle_save_treatment_dimension_request(std::span<const std::byte> payload,
395 const std::string& remote_address);
396
397 handler_result
398 handle_delete_treatment_dimension_request(std::span<const std::byte> payload,
399 const std::string& remote_address);
400
401 handler_result
402 handle_get_treatment_dimension_history_request(std::span<const std::byte> payload,
403 const std::string& remote_address);
404
405 // =========================================================================
406 // Publication Handlers
407 // =========================================================================
408
415 handler_result
416 handle_publish_datasets_request(std::span<const std::byte> payload,
417 const std::string& remote_address);
418
424 handler_result
425 handle_get_publications_request(std::span<const std::byte> payload,
426 const std::string& remote_address);
427
435 handler_result
436 handle_resolve_dependencies_request(std::span<const std::byte> payload,
437 const std::string& remote_address);
438
445 handler_result
446 handle_publish_bundle_request(std::span<const std::byte> payload,
447 const std::string& remote_address);
448
449 // =========================================================================
450 // Dataset Bundle Handlers
451 // =========================================================================
452
453 handler_result
454 handle_get_dataset_bundles_request(std::span<const std::byte> payload,
455 const std::string& remote_address);
456
457 handler_result
458 handle_save_dataset_bundle_request(std::span<const std::byte> payload,
459 const std::string& remote_address);
460
461 handler_result
462 handle_delete_dataset_bundle_request(std::span<const std::byte> payload,
463 const std::string& remote_address);
464
465 handler_result
466 handle_get_dataset_bundle_history_request(std::span<const std::byte> payload,
467 const std::string& remote_address);
468
469 // =========================================================================
470 // Dataset Bundle Member Handlers
471 // =========================================================================
472
473 handler_result
474 handle_get_dataset_bundle_members_request(std::span<const std::byte> payload,
475 const std::string& remote_address);
476
477 handler_result
478 handle_get_dataset_bundle_members_by_bundle_request(
479 std::span<const std::byte> payload,
480 const std::string& remote_address);
481
482 handler_result
483 handle_save_dataset_bundle_member_request(std::span<const std::byte> payload,
484 const std::string& remote_address);
485
486 handler_result
487 handle_delete_dataset_bundle_member_request(std::span<const std::byte> payload,
488 const std::string& remote_address);
489
495 using auth_check_result = std::expected<
497 ores::utility::serialization::error_code
498 >;
499
511 auth_check_result check_authorization(
512 const std::string& remote_address,
513 std::string_view permission,
514 std::string_view operation_name);
515
525 auth_check_result get_authenticated_session(
526 const std::string& remote_address,
527 std::string_view operation_name);
528
530 std::shared_ptr<comms::service::auth_session_service> sessions_;
531 std::shared_ptr<iam::service::authorization_service> auth_service_;
532 service::change_management_service change_management_service_;
533 service::data_organization_service data_organization_service_;
534 service::dataset_service dataset_service_;
535 service::coding_scheme_service coding_scheme_service_;
536 service::dimension_service dimension_service_;
537 service::publication_service publication_service_;
538 service::dataset_bundle_service dataset_bundle_service_;
539 service::dataset_bundle_member_service dataset_bundle_member_service_;
540};
541
542}
543
544#endif
Implements logging infrastructure for ORE Studio.
Definition boost_severity.hpp:28
Abstract interface for handling messages from a subsystem.
Definition message_handler.hpp:66
Lightweight session info for backward compatibility.
Definition auth_session_service.hpp:43
Context for the operations on a postgres database.
Definition context.hpp:30
Message handler for Data Quality (DQ) subsystem messages.
Definition dq_message_handler.hpp:50
handler_result handle_message(comms::messaging::message_type type, std::span< const std::byte > payload, const std::string &remote_address) override
Handle a DQ subsystem message.
Definition dq_message_handler.cpp:55
Service for managing change reason categories and change reasons.
Definition change_management_service.hpp:43
Service for managing coding schemes.
Definition coding_scheme_service.hpp:42
Service for managing data organization entities.
Definition data_organization_service.hpp:46
Service for managing dataset bundle members.
Definition dataset_bundle_member_service.hpp:38
Service for managing dataset bundles.
Definition dataset_bundle_service.hpp:40
Service for managing datasets and methodologies.
Definition dataset_service.hpp:43
Service for managing dimensions (nature, origin, treatment).
Definition dimension_service.hpp:45
Service for publishing datasets to production tables.
Definition publication_service.hpp:54