ORE Studio 0.0.4
Loading...
Searching...
No Matches
party_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_REFDATA_CORE_SERVICE_PARTY_SERVICE_HPP
21#define ORES_REFDATA_CORE_SERVICE_PARTY_SERVICE_HPP
22
23#include <string>
24#include <vector>
25#include <cstdint>
26#include <optional>
27#include <boost/uuid/uuid.hpp>
28#include "ores.logging/make_logger.hpp"
29#include "ores.database/domain/context.hpp"
30#include "ores.refdata.api/domain/party.hpp"
31#include "ores.refdata.core/repository/party_repository.hpp"
32
33namespace ores::refdata::service {
34
42private:
43 inline static std::string_view logger_name =
44 "ores.refdata.service.party_service";
45
46 [[nodiscard]] static auto& lg() {
47 using namespace ores::logging;
48 static auto instance = make_logger(logger_name);
49 return instance;
50 }
51
52public:
54
60 explicit party_service(context ctx);
61
65 std::vector<domain::party> list_parties();
66
74 std::vector<domain::party> list_parties(std::uint32_t offset,
75 std::uint32_t limit);
76
82 std::uint32_t count_parties();
83
87 std::optional<domain::party>
88 find_party(const boost::uuids::uuid& id);
89
93 std::optional<domain::party>
94 find_party_by_code(const std::string& code);
95
101 void save_party(const domain::party& party);
102
108 void save_parties(const std::vector<domain::party>& parties);
109
115 void remove_party(const boost::uuids::uuid& id);
116
123 std::vector<domain::party>
124 get_party_history(const boost::uuids::uuid& id);
125
126private:
127 context ctx_;
129};
130
131}
132
133#endif
Implements logging infrastructure for ORE Studio.
Definition boost_severity.hpp:28
Context for the operations on a postgres database.
Definition context.hpp:47
An internal legal entity participating in financial transactions.
Definition party.hpp:37
Reads and writes parties to data storage.
Definition party_repository.hpp:37
Service for managing parties.
Definition party_service.hpp:41
std::vector< domain::party > list_parties()
Lists all parties.
Definition party_service.cpp:35
std::optional< domain::party > find_party(const boost::uuids::uuid &id)
Finds a party by its ID.
Definition party_service.cpp:53
std::optional< domain::party > find_party_by_code(const std::string &code)
Finds a party by its code.
Definition party_service.cpp:63
void save_parties(const std::vector< domain::party > &parties)
Saves multiple parties (creates or updates).
Definition party_service.cpp:83
std::uint32_t count_parties()
Gets the total count of active parties.
Definition party_service.cpp:47
std::vector< domain::party > get_party_history(const boost::uuids::uuid &id)
Gets the version history for a party.
Definition party_service.cpp:102
void save_party(const domain::party &party)
Saves a party (creates or updates).
Definition party_service.cpp:72
void remove_party(const boost::uuids::uuid &id)
Removes a party.
Definition party_service.cpp:95