ORE Studio 0.0.4
Loading...
Searching...
No Matches
business_unit_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_BUSINESS_UNIT_SERVICE_HPP
21#define ORES_REFDATA_CORE_SERVICE_BUSINESS_UNIT_SERVICE_HPP
22
23#include <string>
24#include <vector>
25#include <optional>
26#include <boost/uuid/uuid.hpp>
27#include "ores.logging/make_logger.hpp"
28#include "ores.database/domain/context.hpp"
29#include "ores.refdata.api/domain/business_unit.hpp"
30#include "ores.refdata.core/repository/business_unit_repository.hpp"
31
32namespace ores::refdata::service {
33
41private:
42 inline static std::string_view logger_name =
43 "ores.refdata.service.business_unit_service";
44
45 [[nodiscard]] static auto& lg() {
46 using namespace ores::logging;
47 static auto instance = make_logger(logger_name);
48 return instance;
49 }
50
51public:
53
59 explicit business_unit_service(context ctx);
60
64 std::vector<domain::business_unit> list_business_units();
65
69 std::optional<domain::business_unit>
70 find_business_unit(const boost::uuids::uuid& id);
71
75 std::optional<domain::business_unit>
76 find_business_unit_by_code(const std::string& code);
77
83 void save_business_unit(const domain::business_unit& business_unit);
84
90 void save_business_units(const std::vector<domain::business_unit>& business_units);
91
97 void remove_business_unit(const boost::uuids::uuid& id);
98
105 std::vector<domain::business_unit>
106 get_business_unit_history(const boost::uuids::uuid& id);
107
108private:
109 context ctx_;
111};
112
113}
114
115#endif
Implements logging infrastructure for ORE Studio.
Definition boost_severity.hpp:28
Context for the operations on a postgres database.
Definition context.hpp:47
Internal organizational unit within a party.
Definition business_unit.hpp:37
Reads and writes business units to data storage.
Definition business_unit_repository.hpp:36
Service for managing business units.
Definition business_unit_service.hpp:40
std::vector< domain::business_unit > list_business_units()
Lists all business units.
Definition business_unit_service.cpp:35
std::optional< domain::business_unit > find_business_unit_by_code(const std::string &code)
Finds a business unit by its code.
Definition business_unit_service.cpp:51
std::vector< domain::business_unit > get_business_unit_history(const boost::uuids::uuid &id)
Gets the version history for a business unit.
Definition business_unit_service.cpp:91
void remove_business_unit(const boost::uuids::uuid &id)
Removes a business unit.
Definition business_unit_service.cpp:84
void save_business_units(const std::vector< domain::business_unit > &business_units)
Saves multiple business units (creates or updates).
Definition business_unit_service.cpp:71
std::optional< domain::business_unit > find_business_unit(const boost::uuids::uuid &id)
Finds a business unit by its ID.
Definition business_unit_service.cpp:41
void save_business_unit(const domain::business_unit &business_unit)
Saves a business unit (creates or updates).
Definition business_unit_service.cpp:60