ORE Studio 0.0.4
Loading...
Searching...
No Matches
PublishBundleWizard.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_QT_PUBLISH_BUNDLE_WIZARD_HPP
21#define ORES_QT_PUBLISH_BUNDLE_WIZARD_HPP
22
23#include <vector>
24#include <QWizard>
25#include <QWizardPage>
26#include <QLabel>
27#include <QComboBox>
28#include <QCheckBox>
29#include <QProgressBar>
30#include <QTableView>
31#include <QStandardItemModel>
32#include <QSet>
33#include <QVBoxLayout>
34#include "ores.logging/make_logger.hpp"
35#include "ores.qt/ClientManager.hpp"
36#include "ores.dq.api/domain/dataset_bundle_member.hpp"
37#include "ores.dq.api/domain/publication_mode.hpp"
38#include "ores.dq.api/messaging/publish_bundle_protocol.hpp"
39
40namespace ores::qt {
41
42class LeiEntityPicker;
43
55class PublishBundleWizard final : public QWizard {
56 Q_OBJECT
57
58private:
59 inline static std::string_view logger_name =
60 "ores.qt.publish_bundle_wizard";
61
62 [[nodiscard]] static auto& lg() {
63 using namespace ores::logging;
64 static auto instance = make_logger(logger_name);
65 return instance;
66 }
67
68public:
69 enum PageId {
70 Page_BundleSummary,
71 Page_OptionalDatasets,
72 Page_LeiPartyConfig,
73 Page_Confirm,
74 Page_Progress,
75 Page_Results
76 };
77
78 explicit PublishBundleWizard(
79 ClientManager* clientManager,
80 const QString& bundleCode,
81 const QString& bundleName,
82 QWidget* parent = nullptr);
83
84 ~PublishBundleWizard() override = default;
85
86 ClientManager* clientManager() const { return clientManager_; }
87 QString bundleCode() const { return bundleCode_; }
88 QString bundleName() const { return bundleName_; }
89
90 bool needsLeiPartyConfig() const { return needsLeiPartyConfig_; }
91 void setNeedsLeiPartyConfig(bool needs) { needsLeiPartyConfig_ = needs; }
92
93 QString rootLei() const { return rootLei_; }
94 void setRootLei(const QString& lei) { rootLei_ = lei; }
95
96 QString rootLeiName() const { return rootLeiName_; }
97 void setRootLeiName(const QString& name) { rootLeiName_ = name; }
98
99 QString leiDatasetSize() const { return leiDatasetSize_; }
100 void setLeiDatasetSize(const QString& size) { leiDatasetSize_ = size; }
101
102 bool hasOptionalDatasets() const { return hasOptionalDatasets_; }
103 void setHasOptionalDatasets(bool has) { hasOptionalDatasets_ = has; }
104
105 const QSet<QString>& optedInDatasets() const { return optedInDatasets_; }
106 void setOptedInDatasets(const QSet<QString>& datasets) {
107 optedInDatasets_ = datasets;
108 }
109
113 const std::vector<dq::domain::dataset_bundle_member>& members() const {
114 return members_;
115 }
116
120 void setMembers(std::vector<dq::domain::dataset_bundle_member> members) {
121 members_ = std::move(members);
122 }
123
127 dq::domain::publication_mode selectedMode() const { return selectedMode_; }
128 void setSelectedMode(dq::domain::publication_mode mode) {
129 selectedMode_ = mode;
130 }
131
135 bool isAtomic() const { return atomic_; }
136 void setAtomic(bool atomic) { atomic_ = atomic; }
137
138signals:
144 void bundlePublished(const QString& bundleCode);
145
146private:
147 void setupPages();
148
149 ClientManager* clientManager_;
150 QString bundleCode_;
151 QString bundleName_;
152 bool needsLeiPartyConfig_ = false;
153 bool hasOptionalDatasets_ = false;
154 QSet<QString> optedInDatasets_;
155 QString rootLei_;
156 QString rootLeiName_;
157 QString leiDatasetSize_ = QStringLiteral("large");
158 std::vector<dq::domain::dataset_bundle_member> members_;
159 dq::domain::publication_mode selectedMode_ =
160 dq::domain::publication_mode::upsert;
161 bool atomic_ = true;
162};
163
164// Forward declarations of page classes
171
178class BundleSummaryPage final : public QWizardPage {
179 Q_OBJECT
180
181private:
182 inline static std::string_view logger_name =
183 "ores.qt.bundle_summary_page";
184
185 [[nodiscard]] static auto& lg() {
186 using namespace ores::logging;
187 static auto instance = make_logger(logger_name);
188 return instance;
189 }
190
191public:
192 explicit BundleSummaryPage(PublishBundleWizard* wizard);
193 void initializePage() override;
194 int nextId() const override;
195
196private:
197 void setupUI();
198 void loadMembers();
199 void populateTable();
200
201 PublishBundleWizard* wizard_;
202 QLabel* bundleNameLabel_;
203 QTableView* membersTable_;
204 QStandardItemModel* membersModel_;
205 QLabel* statusLabel_;
206 bool membersLoaded_ = false;
207};
208
217class OptionalDatasetsPage final : public QWizardPage {
218 Q_OBJECT
219
220public:
222 void initializePage() override;
223 bool validatePage() override;
224 int nextId() const override;
225
226private:
227 void setupUI();
228
229 PublishBundleWizard* wizard_;
230 QVBoxLayout* checkboxLayout_;
231 std::vector<QCheckBox*> checkboxes_;
232};
233
240class LeiPartyConfigPage final : public QWizardPage {
241 Q_OBJECT
242
243public:
244 explicit LeiPartyConfigPage(PublishBundleWizard* wizard);
245 void initializePage() override;
246 bool validatePage() override;
247 int nextId() const override;
248
249private:
250 void setupUI();
251
252 PublishBundleWizard* wizard_;
253 LeiEntityPicker* leiPicker_;
254 QLabel* instructionLabel_;
255 QLabel* selectedEntityLabel_;
256 bool leiLoaded_ = false;
257};
258
265class ConfirmPublishPage final : public QWizardPage {
266 Q_OBJECT
267
268public:
269 explicit ConfirmPublishPage(PublishBundleWizard* wizard);
270 void initializePage() override;
271 bool validatePage() override;
272 int nextId() const override;
273
274private:
275 void setupUI();
276
277 PublishBundleWizard* wizard_;
278 QLabel* summaryLabel_;
279 QComboBox* modeCombo_;
280 QCheckBox* atomicCheckbox_;
281};
282
289class PublishProgressPage final : public QWizardPage {
290 Q_OBJECT
291
292private:
293 inline static std::string_view logger_name =
294 "ores.qt.publish_progress_page";
295
296 [[nodiscard]] static auto& lg() {
297 using namespace ores::logging;
298 static auto instance = make_logger(logger_name);
299 return instance;
300 }
301
302public:
304 void initializePage() override;
305 bool isComplete() const override;
306 int nextId() const override;
307
308private:
309 void startPublish();
310
311 PublishBundleWizard* wizard_;
312 QLabel* statusLabel_;
313 QProgressBar* progressBar_;
314 bool publishComplete_ = false;
315 bool publishSuccess_ = false;
316};
317
325class PublishResultsPage final : public QWizardPage {
326 Q_OBJECT
327
328public:
329 explicit PublishResultsPage(PublishBundleWizard* wizard);
330 void initializePage() override;
331
337 void setResults(bool overallSuccess,
338 const QString& errorMessage,
339 const std::vector<dq::messaging::bundle_dataset_result>& results);
340
341private:
342 void setupUI();
343 void populateResults();
344
345 PublishBundleWizard* wizard_;
346 QLabel* overallStatusLabel_;
347 QTableView* resultsTable_;
348 QStandardItemModel* resultsModel_;
349
350 bool overallSuccess_ = false;
351 QString errorMessage_;
352 std::vector<dq::messaging::bundle_dataset_result> datasetResults_;
353};
354
355}
356
357#endif
Implements logging infrastructure for ORE Studio.
Definition boost_severity.hpp:28
Qt-based graphical user interface for ORE Studio.
Definition AboutDialog.hpp:29
Manages the lifecycle of the NATS client and login state.
Definition ClientManager.hpp:109
Reusable widget for searching and selecting an LEI entity.
Definition LeiEntityPicker.hpp:42
Wizard for publishing a dataset bundle.
Definition PublishBundleWizard.hpp:55
void bundlePublished(const QString &bundleCode)
Emitted when the bundle has been published successfully.
const std::vector< dq::domain::dataset_bundle_member > & members() const
Get the loaded bundle members.
Definition PublishBundleWizard.hpp:113
dq::domain::publication_mode selectedMode() const
Get the selected publication mode.
Definition PublishBundleWizard.hpp:127
bool isAtomic() const
Get the atomic publication flag.
Definition PublishBundleWizard.hpp:135
void setMembers(std::vector< dq::domain::dataset_bundle_member > members)
Set the loaded bundle members.
Definition PublishBundleWizard.hpp:120
Page showing bundle contents and dataset list.
Definition PublishBundleWizard.hpp:178
Page for opting in to optional datasets.
Definition PublishBundleWizard.hpp:217
Page for configuring LEI entity parameters.
Definition PublishBundleWizard.hpp:240
Confirmation page showing publication summary.
Definition PublishBundleWizard.hpp:265
Progress page that executes the publication.
Definition PublishBundleWizard.hpp:289
Results page showing per-dataset publication outcomes.
Definition PublishBundleWizard.hpp:325
void setResults(bool overallSuccess, const QString &errorMessage, const std::vector< dq::messaging::bundle_dataset_result > &results)
Set results data for display.
Definition PublishBundleWizard.cpp:719