ORE Studio 0.0.4
Loading...
Searching...
No Matches
publication_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_PUBLICATION_SERVICE_HPP
21#define ORES_DQ_SERVICE_PUBLICATION_SERVICE_HPP
22
23#include <map>
24#include <string>
25#include <vector>
26#include <boost/uuid/uuid.hpp>
27#include "ores.logging/make_logger.hpp"
28#include "ores.database/domain/context.hpp"
29#include "ores.dq/domain/artefact_type.hpp"
30#include "ores.dq/domain/dataset.hpp"
31#include "ores.dq/domain/publication.hpp"
32#include "ores.dq/domain/publication_mode.hpp"
33#include "ores.dq/domain/publication_result.hpp"
34#include "ores.dq/messaging/publish_bundle_protocol.hpp"
35#include "ores.dq/repository/dataset_repository.hpp"
36#include "ores.dq/repository/dataset_dependency_repository.hpp"
37#include "ores.dq/repository/publication_repository.hpp"
38#include "ores.dq/repository/artefact_type_repository.hpp"
39
40namespace ores::dq::service {
41
55private:
56 inline static std::string_view logger_name =
57 "ores.dq.service.publication_service";
58
59 [[nodiscard]] static auto& lg() {
60 using namespace ores::logging;
61 static auto instance = make_logger(logger_name);
62 return instance;
63 }
64
65public:
67
73 explicit publication_service(context ctx);
74
90 std::vector<domain::publication_result> publish(
91 const std::vector<boost::uuids::uuid>& dataset_ids,
92 domain::publication_mode mode,
93 const std::string& published_by,
94 bool resolve_dependencies = true);
95
111 const std::string& bundle_code,
112 domain::publication_mode mode,
113 const std::string& published_by,
114 bool atomic = true);
115
126 std::vector<domain::dataset> resolve_publication_order(
127 const std::vector<boost::uuids::uuid>& dataset_ids);
128
135 std::vector<domain::publication> get_publication_history(
136 const boost::uuids::uuid& dataset_id);
137
144 std::vector<domain::publication> get_recent_publications(
145 std::uint32_t limit = 100);
146
147private:
154 std::map<std::string, domain::artefact_type> build_artefact_type_cache(
155 const std::vector<domain::dataset>& datasets);
156
168 domain::publication_result publish_dataset(
169 const domain::dataset& dataset,
170 domain::publication_mode mode,
171 const std::map<std::string, domain::artefact_type>& artefact_type_cache);
172
180 void record_publication(
181 const domain::publication_result& result,
182 domain::publication_mode mode,
183 const std::string& published_by);
184
193 domain::publication_result call_populate_function(
194 const domain::dataset& dataset,
195 const domain::artefact_type& artefact_type,
196 domain::publication_mode mode);
197
198 context ctx_;
199 repository::dataset_repository dataset_repo_;
201 repository::publication_repository publication_repo_;
202 repository::artefact_type_repository artefact_type_repo_;
203};
204
205}
206
207#endif
Implements logging infrastructure for ORE Studio.
Definition boost_severity.hpp:28
Context for the operations on a postgres database.
Definition context.hpp:30
Maps artefact type codes to their population functions and tables.
Definition artefact_type.hpp:39
Represents a data quality dataset with lineage tracking.
Definition dataset.hpp:36
Result of publishing a single dataset to a target table.
Definition publication_result.hpp:35
Response containing results of bundle publication.
Definition publish_bundle_protocol.hpp:116
Reads artefact_types from data storage.
Definition artefact_type_repository.hpp:39
Reads dataset dependencies from data storage.
Definition dataset_dependency_repository.hpp:35
Reads and writes datasets to data storage.
Definition dataset_repository.hpp:36
Repository for reading and writing publication audit records.
Definition publication_repository.hpp:37
Service for publishing datasets to production tables.
Definition publication_service.hpp:54
messaging::publish_bundle_response publish_bundle(const std::string &bundle_code, domain::publication_mode mode, const std::string &published_by, bool atomic=true)
Publishes all datasets in a bundle.
Definition publication_service.cpp:423
std::vector< domain::publication > get_publication_history(const boost::uuids::uuid &dataset_id)
Gets the publication history for a dataset.
Definition publication_service.cpp:229
std::vector< domain::publication > get_recent_publications(std::uint32_t limit=100)
Gets recent publication history across all datasets.
Definition publication_service.cpp:238
std::vector< domain::publication_result > publish(const std::vector< boost::uuids::uuid > &dataset_ids, domain::publication_mode mode, const std::string &published_by, bool resolve_dependencies=true)
Publishes one or more datasets to production tables.
Definition publication_service.cpp:45
std::vector< domain::dataset > resolve_publication_order(const std::vector< boost::uuids::uuid > &dataset_ids)
Resolves the publication order for datasets.
Definition publication_service.cpp:117