ORE Studio 0.0.4
Loading...
Searching...
No Matches
badge_service.hpp
1/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 *
3 * Copyright (C) 2026 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_CORE_SERVICE_BADGE_SERVICE_HPP
21#define ORES_DQ_CORE_SERVICE_BADGE_SERVICE_HPP
22
23#include <string>
24#include <vector>
25#include "ores.logging/make_logger.hpp"
26#include "ores.database/domain/context.hpp"
27#include "ores.dq/domain/badge_severity.hpp"
28#include "ores.dq/domain/badge_definition.hpp"
29#include "ores.dq/domain/code_domain.hpp"
30#include "ores.dq/repository/badge_severity_repository.hpp"
31#include "ores.dq/repository/badge_definition_repository.hpp"
32#include "ores.dq/repository/code_domain_repository.hpp"
33#include "ores.dq.api/messaging/badge_protocol.hpp"
34#include "ores.dq.core/repository/badge_mapping_repository.hpp"
35
36namespace ores::dq::service {
37
43private:
44 inline static std::string_view logger_name =
45 "ores.dq.service.badge_service";
46
47 [[nodiscard]] static auto& lg() {
48 using namespace ores::logging;
49 static auto instance = make_logger(logger_name);
50 return instance;
51 }
52
53public:
55
56 explicit badge_service(context ctx);
57
58 // =========================================================================
59 // Badge Severity
60 // =========================================================================
61
62 std::vector<domain::badge_severity> list_severities();
63 void save_severity(const domain::badge_severity& v);
64 void remove_severities(const std::vector<std::string>& codes);
65 std::vector<domain::badge_severity> get_severity_history(const std::string& code);
66
67 // =========================================================================
68 // Code Domain
69 // =========================================================================
70
71 std::vector<domain::code_domain> list_code_domains();
72 void save_code_domain(const domain::code_domain& v);
73 void remove_code_domains(const std::vector<std::string>& codes);
74 std::vector<domain::code_domain> get_code_domain_history(const std::string& code);
75
76 // =========================================================================
77 // Badge Definition
78 // =========================================================================
79
80 std::vector<domain::badge_definition> list_definitions();
81 void save_definition(const domain::badge_definition& v);
82 void remove_definitions(const std::vector<std::string>& codes);
83 std::vector<domain::badge_definition> get_definition_history(const std::string& code);
84
85 // =========================================================================
86 // Badge Mapping (read-only)
87 // =========================================================================
88
89 std::vector<messaging::badge_mapping> list_mappings();
90
91private:
92 context ctx_;
97};
98
99}
100
101#endif
Implements logging infrastructure for ORE Studio.
Definition boost_severity.hpp:28
Context for the operations on a postgres database.
Definition context.hpp:47
Read-only repository for badge mappings.
Definition badge_mapping_repository.hpp:37
Service for managing badges, badge severities, code domains, and badge mappings.
Definition badge_service.hpp:42
Visual definition for a badge, including colours, label, and severity.
Definition badge_definition.hpp:41
Severity levels for badge visual classification.
Definition badge_severity.hpp:38
A named namespace for disambiguating enum codes across entity types.
Definition code_domain.hpp:41
Reads and writes badge definitions to data storage.
Definition badge_definition_repository.hpp:35
Reads and writes badge severities to data storage.
Definition badge_severity_repository.hpp:35
Reads and writes code domains to data storage.
Definition code_domain_repository.hpp:35