ORE Studio 0.0.4
Loading...
Searching...
No Matches
PublishDatasetsDialog.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_QT_PUBLISH_DATASETS_DIALOG_HPP
21#define ORES_QT_PUBLISH_DATASETS_DIALOG_HPP
22
23#include <vector>
24#include <QWizard>
25#include <QWizardPage>
26#include <QListWidget>
27#include <QComboBox>
28#include <QCheckBox>
29#include <QTableWidget>
30#include <QTextEdit>
31#include <QLabel>
32#include <QProgressBar>
33#include <boost/uuid/uuid.hpp>
34#include "ores.logging/make_logger.hpp"
35#include "ores.dq.api/domain/dataset.hpp"
36#include "ores.dq.api/domain/publication_mode.hpp"
37#include "ores.dq.api/domain/publication_result.hpp"
38
39namespace ores::qt {
40
41class ClientManager;
42
53class PublishDatasetsDialog final : public QWizard {
54 Q_OBJECT
55
56private:
57 inline static std::string_view logger_name = "ores.qt.publish_datasets_dialog";
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:
66signals:
74 void datasetsPublished(const QStringList& datasetCodes);
75
76public:
77 // Page IDs
78 enum PageId {
79 Page_Selection,
80 Page_Options,
81 Page_Review,
82 Page_Progress,
83 Page_Results
84 };
85
86 explicit PublishDatasetsDialog(
87 ClientManager* clientManager,
88 const QString& username,
89 QWidget* parent = nullptr);
90
91 ~PublishDatasetsDialog() override = default;
92
97 void setDatasets(const std::vector<dq::domain::dataset>& datasets);
98
99 // Accessors for wizard pages
100 ClientManager* clientManager() const { return clientManager_; }
101 const QString& username() const { return username_; }
102 const std::vector<dq::domain::dataset>& datasets() const { return datasets_; }
103 std::vector<dq::domain::dataset>& resolvedDatasets() { return resolvedDatasets_; }
104 std::vector<std::string>& requestedIds() { return requestedIds_; }
105 std::vector<dq::domain::publication_result>& results() { return results_; }
106 QString& lastError() { return lastError_; }
107
108 // State accessors
109 dq::domain::publication_mode selectedMode() const;
110 bool resolveDependencies() const;
111
112private:
113 void setupPages();
114
115 ClientManager* clientManager_;
116 QString username_;
117 std::vector<dq::domain::dataset> datasets_; // Originally selected
118 std::vector<dq::domain::dataset> resolvedDatasets_; // Full list including deps
119 std::vector<std::string> requestedIds_; // IDs explicitly requested
120 std::vector<dq::domain::publication_result> results_; // Publication results
121 QString lastError_; // Error message from failed publication attempt
122};
123
124// Forward declarations of page classes
125class SelectionPage;
126class OptionsPage;
127class ReviewPage;
128class ProgressPage;
129class ResultsPage;
130
134class SelectionPage final : public QWizardPage {
135 Q_OBJECT
136
137public:
138 explicit SelectionPage(PublishDatasetsDialog* wizard);
139 void initializePage() override;
140
141private:
142 PublishDatasetsDialog* wizard_;
143 QListWidget* datasetList_;
144 QLabel* countLabel_;
145};
146
150class OptionsPage final : public QWizardPage {
151 Q_OBJECT
152
153public:
154 explicit OptionsPage(PublishDatasetsDialog* wizard);
155
156 QComboBox* modeCombo() const { return modeCombo_; }
157 QCheckBox* resolveDependenciesCheck() const { return resolveDependenciesCheck_; }
158
159private:
160 PublishDatasetsDialog* wizard_;
161 QComboBox* modeCombo_;
162 QCheckBox* resolveDependenciesCheck_;
163};
164
168class ReviewPage final : public QWizardPage {
169 Q_OBJECT
170
171public:
172 explicit ReviewPage(PublishDatasetsDialog* wizard);
173 void initializePage() override;
174 bool isComplete() const override;
175
176private:
177 void resolveDependencies();
178 void updatePublicationOrder();
179
180 PublishDatasetsDialog* wizard_;
181 QTableWidget* orderTable_;
182 QLabel* summaryLabel_;
183 QLabel* statusLabel_;
184 bool resolved_ = false;
185};
186
190class ProgressPage final : public QWizardPage {
191 Q_OBJECT
192
193public:
194 explicit ProgressPage(PublishDatasetsDialog* wizard);
195 void initializePage() override;
196 bool isComplete() const override;
197 int nextId() const override;
198
199private:
200 void performPublish();
201
202 PublishDatasetsDialog* wizard_;
203 QLabel* statusLabel_;
204 QProgressBar* progressBar_;
205 QLabel* currentDatasetLabel_;
206 bool publishComplete_ = false;
207 bool publishSuccess_ = false;
208};
209
213class ResultsPage final : public QWizardPage {
214 Q_OBJECT
215
216public:
217 explicit ResultsPage(PublishDatasetsDialog* wizard);
218 void initializePage() override;
219
220private:
221 void appendLog(const QString& message);
222 void appendError(const QString& message);
223 void appendSuccess(const QString& message);
224
225 PublishDatasetsDialog* wizard_;
226 QTextEdit* logOutput_;
227 QLabel* summaryLabel_;
228};
229
230}
231
232#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
Wizard for publishing datasets from artefact tables to production.
Definition PublishDatasetsDialog.hpp:53
void datasetsPublished(const QStringList &datasetCodes)
Emitted when datasets are successfully published.
void setDatasets(const std::vector< dq::domain::dataset > &datasets)
Set the datasets to publish.
Definition PublishDatasetsDialog.cpp:78
Page showing the selected datasets.
Definition PublishDatasetsDialog.hpp:134
Page for configuring publication options.
Definition PublishDatasetsDialog.hpp:150
Page showing the resolved publication order.
Definition PublishDatasetsDialog.hpp:168
Page showing progress during publication.
Definition PublishDatasetsDialog.hpp:190
Page showing publication results.
Definition PublishDatasetsDialog.hpp:213