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_SERVICE_CODING_SCHEME_SERVICE_HPP
21#define ORES_DQ_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/domain/coding_scheme.hpp"
29#include "ores.dq/domain/coding_scheme_authority_type.hpp"
30#include "ores.dq/repository/coding_scheme_repository.hpp"
31#include "ores.dq/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 remove_coding_scheme(const std::string& code);
108
115 std::vector<domain::coding_scheme>
116 get_coding_scheme_history(const std::string& code);
117
118 // ========================================================================
119 // Coding Scheme Authority Type Management
120 // ========================================================================
121
125 std::vector<domain::coding_scheme_authority_type> list_authority_types();
126
130 std::optional<domain::coding_scheme_authority_type>
131 find_authority_type(const std::string& code);
132
139 const domain::coding_scheme_authority_type& authority_type);
140
146 void remove_authority_type(const std::string& code);
147
154 std::vector<domain::coding_scheme_authority_type>
155 get_authority_type_history(const std::string& code);
156
157private:
158 repository::coding_scheme_repository coding_scheme_repo_;
160};
161
162}
163
164#endif
Implements logging infrastructure for ORE Studio.
Definition boost_severity.hpp:28
Context for the operations on a postgres database.
Definition context.hpp:30
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:40
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:130
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
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:102
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:111
void remove_authority_type(const std::string &code)
Removes a coding scheme authority type.
Definition coding_scheme_service.cpp:123
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
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:86
std::vector< domain::coding_scheme_authority_type > list_authority_types()
Lists all coding scheme authority types.
Definition coding_scheme_service.cpp:96
void remove_coding_scheme(const std::string &code)
Removes a coding scheme.
Definition coding_scheme_service.cpp:79