20#ifndef ORES_VARIABILITY_SERVICE_SYSTEM_SETTINGS_SERVICE_HPP
21#define ORES_VARIABILITY_SERVICE_SYSTEM_SETTINGS_SERVICE_HPP
27#include "ores.logging/make_logger.hpp"
28#include "ores.database/domain/context.hpp"
29#include "ores.variability.api/domain/system_setting.hpp"
30#include "ores.variability.core/repository/system_settings_repository.hpp"
43 inline static std::string_view logger_name =
44 "ores.variability.service.system_settings_service";
46 [[nodiscard]]
static auto& lg() {
48 static auto instance = make_logger(logger_name);
61 std::string tenant_id = {});
70 [[nodiscard]] std::optional<domain::system_setting>
71 get(
const std::string& name);
76 [[nodiscard]] std::vector<domain::system_setting>
get_all();
86 void remove(
const std::string& name);
91 [[nodiscard]] std::vector<domain::system_setting>
104 [[nodiscard]]
bool get_bool(std::string_view name)
const;
111 [[nodiscard]]
int get_int(std::string_view name)
const;
118 [[nodiscard]] std::string
get_string(std::string_view name)
const;
126 [[nodiscard]] std::string
get_json(std::string_view name)
const;
137 [[nodiscard]]
bool is_bootstrap_mode_enabled()
const;
138 void set_bootstrap_mode(
bool enabled, std::string_view modified_by,
139 std::string_view change_reason_code,
140 std::string_view change_commentary);
142 [[nodiscard]]
bool is_user_signups_enabled()
const;
143 void set_user_signups(
bool enabled, std::string_view modified_by,
144 std::string_view change_reason_code,
145 std::string_view change_commentary);
147 [[nodiscard]]
bool is_signup_requires_authorization_enabled()
const;
148 void set_signup_requires_authorization(
bool enabled,
149 std::string_view modified_by,
150 std::string_view change_reason_code,
151 std::string_view change_commentary);
153 [[nodiscard]]
bool is_password_validation_disabled()
const;
156 void set_bool_setting(std::string_view name,
bool value,
157 std::string_view modified_by,
158 std::string_view change_reason_code,
159 std::string_view change_commentary);
162 std::unordered_map<std::string, std::string> cache_;
165 std::string tenant_id_;
Implements logging infrastructure for ORE Studio.
Definition boost_severity.hpp:28
Service layer for the variability module.
Definition ores.variability.service.hpp:28
Context for the operations on a postgres database.
Definition context.hpp:47
Represents a typed system setting in the domain layer.
Definition system_setting.hpp:35
Reads and writes system settings from data storage.
Definition system_settings_repository.hpp:36
Service for managing typed system settings.
Definition system_settings_service.hpp:41
std::string get_json(std::string_view name) const
Returns the JSON value of a setting as a raw string.
Definition system_settings_service.cpp:138
std::string get_string(std::string_view name) const
Returns the string value of a setting.
Definition system_settings_service.cpp:131
std::vector< domain::system_setting > get_all()
Retrieves all currently active settings.
Definition system_settings_service.cpp:51
int get_int(std::string_view name) const
Returns the integer value of a setting.
Definition system_settings_service.cpp:115
void remove(const std::string &name)
Logically removes a setting.
Definition system_settings_service.cpp:72
void refresh()
Refreshes the in-memory cache by re-reading all settings from the DB.
Definition system_settings_service.cpp:89
void save(const domain::system_setting &setting)
Saves a setting using the bitemporal update pattern.
Definition system_settings_service.cpp:56
std::optional< domain::system_setting > get(const std::string &name)
Retrieves a single setting by name (latest active version).
Definition system_settings_service.cpp:35
bool get_bool(std::string_view name) const
Returns the boolean value of a setting.
Definition system_settings_service.cpp:100
std::vector< domain::system_setting > get_history(const std::string &name)
Retrieves all historical versions of a setting.
Definition system_settings_service.cpp:79