PACS System 0.1.0
PACS DICOM system library
Loading...
Searching...
No Matches
sync_history_repository.h
Go to the documentation of this file.
1// BSD 3-Clause License
2// Copyright (c) 2021-2025, 🍀☀🌕🌥 🌊
3// See the LICENSE file in the project root for full license information.
4
14#pragma once
15
18
19#ifdef PACS_WITH_DATABASE_SYSTEM
20
21namespace kcenon::pacs::storage {
22
26class sync_history_repository
27 : public base_repository<client::sync_history, int64_t> {
28public:
29 explicit sync_history_repository(std::shared_ptr<pacs_database_adapter> db);
30
31 [[nodiscard]] auto find_by_config(
32 std::string_view config_id,
33 size_t limit = 100) -> list_result_type;
34
35 [[nodiscard]] auto find_last_for_config(std::string_view config_id)
36 -> result_type;
37
38 [[nodiscard]] auto cleanup_old(std::chrono::hours max_age)
39 -> Result<size_t>;
40
41protected:
42 [[nodiscard]] auto map_row_to_entity(const database_row& row) const
43 -> client::sync_history override;
44
45 [[nodiscard]] auto entity_to_row(const client::sync_history& entity) const
46 -> std::map<std::string, database_value> override;
47
48 [[nodiscard]] auto get_pk(const client::sync_history& entity) const
49 -> int64_t override;
50
51 [[nodiscard]] auto has_pk(const client::sync_history& entity) const
52 -> bool override;
53
54 [[nodiscard]] auto select_columns() const
55 -> std::vector<std::string> override;
56
57private:
58 [[nodiscard]] auto parse_timestamp(const std::string& str) const
59 -> std::chrono::system_clock::time_point;
60
61 [[nodiscard]] auto format_timestamp(
62 std::chrono::system_clock::time_point tp) const -> std::string;
63
64 [[nodiscard]] static auto serialize_errors(
65 const std::vector<std::string>& errors) -> std::string;
66
67 [[nodiscard]] static auto deserialize_errors(
68 std::string_view json) -> std::vector<std::string>;
69};
70
71} // namespace kcenon::pacs::storage
72
73#endif // PACS_WITH_DATABASE_SYSTEM
Generic base repository for CRUD operations.
Types and structures for bidirectional DICOM synchronization.