ORE Studio 0.0.4
Loading...
Searching...
No Matches
coding_scheme_service.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_CORE_SERVICE_CODING_SCHEME_SERVICE_HPP
21#define ORES_DQ_CORE_SERVICE_CODING_SCHEME_SERVICE_HPP
22
23#include <string>
24#include <vector>
25#include <optional>
26#include "ores.logging/make_logger.hpp"
27#include "ores.database/domain/context.hpp"
28#include "ores.dq.api/domain/coding_scheme.hpp"
29#include "ores.dq.api/domain/coding_scheme_authority_type.hpp"
30#include "ores.dq.core/repository/coding_scheme_repository.hpp"
31#include "ores.dq.core/repository/coding_scheme_authority_type_repository.hpp"
32
33namespace ores::dq::service {
34
43private:
44 inline static std::string_view logger_name =
45 "ores.dq.service.coding_scheme_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
61 explicit coding_scheme_service(context ctx);
62
63 // ========================================================================
64 // Coding Scheme Management
65 // ========================================================================
66
70 std::vector<domain::coding_scheme> list_coding_schemes();
71
75 std::vector<domain::coding_scheme>
76 list_coding_schemes(std::uint32_t offset, std::uint32_t limit);
77
81 std::vector<domain::coding_scheme>
82 list_coding_schemes_by_authority_type(const std::string& authority_type);
83
87 std::uint32_t get_coding_scheme_count();
88
92 std::optional<domain::coding_scheme>
93 find_coding_scheme(const std::string& code);
94
100 void save_coding_scheme(const domain::coding_scheme& scheme);
101
107 void save_coding_schemes(const std::vector<domain::coding_scheme>& schemes);
108
114 void remove_coding_scheme(const std::string& code);
115
119 void remove_coding_schemes(const std::vector<std::string>& codes);
120
127 std::vector<domain::coding_scheme>
128 get_coding_scheme_history(const std::string& code);
129
130 // ========================================================================
131 // Coding Scheme Authority Type Management
132 // ========================================================================
133
137 std::vector<domain::coding_scheme_authority_type> list_authority_types();
138
142 std::optional<domain::coding_scheme_authority_type>
143 find_authority_type(const std::string& code);
144
151 const domain::coding_scheme_authority_type& authority_type);
152
159 const std::vector<domain::coding_scheme_authority_type>& authority_types);
160
166 void remove_authority_type(const std::string& code);
167
171 void remove_authority_types(const std::vector<std::string>& codes);
172
179 std::vector<domain::coding_scheme_authority_type>
180 get_authority_type_history(const std::string& code);
181
182private:
183 repository::coding_scheme_repository coding_scheme_repo_;
185};
186
187}
188
189#endif
Implements logging infrastructure for ORE Studio.
Definition boost_severity.hpp:28
Context for the operations on a postgres database.
Definition context.hpp:47
Defines a coding or identification standard used to identify entities.
Definition coding_scheme.hpp:36
Classifies coding schemes by the type of authority that defines them.
Definition coding_scheme_authority_type.hpp:41
Reads and writes coding_scheme_authority_types to data storage.
Definition coding_scheme_authority_type_repository.hpp:35
Reads and writes coding_schemes to data storage.
Definition coding_scheme_repository.hpp:35
Service for managing coding schemes.
Definition coding_scheme_service.hpp:42
std::vector< domain::coding_scheme_authority_type > get_authority_type_history(const std::string &code)
Gets the version history for a coding scheme authority type.
Definition coding_scheme_service.cpp:161
std::vector< domain::coding_scheme > list_coding_schemes()
Lists all coding schemes.
Definition coding_scheme_service.cpp:35
std::vector< domain::coding_scheme > list_coding_schemes_by_authority_type(const std::string &authority_type)
Lists coding schemes for a specific authority type.
Definition coding_scheme_service.cpp:49
std::uint32_t get_coding_scheme_count()
Gets the total count of active coding schemes.
Definition coding_scheme_service.cpp:56
void save_coding_scheme(const domain::coding_scheme &scheme)
Saves a coding scheme (creates or updates).
Definition coding_scheme_service.cpp:70
void save_authority_types(const std::vector< domain::coding_scheme_authority_type > &authority_types)
Saves multiple coding scheme authority types (creates or updates).
Definition coding_scheme_service.cpp:138
void save_coding_schemes(const std::vector< domain::coding_scheme > &schemes)
Saves multiple coding schemes (creates or updates).
Definition coding_scheme_service.cpp:79
void remove_authority_types(const std::vector< std::string > &codes)
Removes multiple coding scheme authority types.
Definition coding_scheme_service.cpp:156
std::optional< domain::coding_scheme_authority_type > find_authority_type(const std::string &code)
Finds a coding scheme authority type by its code.
Definition coding_scheme_service.cpp:117
void save_authority_type(const domain::coding_scheme_authority_type &authority_type)
Saves a coding scheme authority type (creates or updates).
Definition coding_scheme_service.cpp:126
void remove_authority_type(const std::string &code)
Removes a coding scheme authority type.
Definition coding_scheme_service.cpp:150
std::optional< domain::coding_scheme > find_coding_scheme(const std::string &code)
Finds a coding scheme by its code.
Definition coding_scheme_service.cpp:61
void remove_coding_schemes(const std::vector< std::string > &codes)
Removes multiple coding schemes.
Definition coding_scheme_service.cpp:96
std::vector< domain::coding_scheme > get_coding_scheme_history(const std::string &code)
Gets the version history for a coding scheme.
Definition coding_scheme_service.cpp:101
std::vector< domain::coding_scheme_authority_type > list_authority_types()
Lists all coding scheme authority types.
Definition coding_scheme_service.cpp:111
void remove_coding_scheme(const std::string &code)
Removes a coding scheme.
Definition coding_scheme_service.cpp:90