ORE Studio 0.0.4
Loading...
Searching...
No Matches
DataLibrarianWindow.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_DATA_LIBRARIAN_WINDOW_HPP
21#define ORES_QT_DATA_LIBRARIAN_WINDOW_HPP
22
23#include <map>
24#include <QWidget>
25#include <QSplitter>
26#include <QTreeView>
27#include <QTableView>
28#include <QToolBar>
29#include <QStatusBar>
30#include <QLabel>
31#include <QProgressBar>
32#include <QSortFilterProxyModel>
33#include <QStandardItemModel>
34#include "ores.qt/ClientManager.hpp"
35#include "ores.qt/ClientDatasetModel.hpp"
36#include "ores.qt/ClientDataDomainModel.hpp"
37#include "ores.qt/ClientSubjectAreaModel.hpp"
38#include "ores.qt/ClientCatalogModel.hpp"
39#include "ores.qt/ClientDatasetDependencyModel.hpp"
40#include "ores.qt/ClientMethodologyModel.hpp"
41#include "ores.qt/ClientDatasetBundleModel.hpp"
42#include "ores.qt/ClientOriginDimensionModel.hpp"
43#include "ores.qt/ClientNatureDimensionModel.hpp"
44#include "ores.qt/ClientTreatmentDimensionModel.hpp"
45#include "ores.logging/make_logger.hpp"
46#include "ores.dq.api/domain/dataset.hpp"
47#include "ores.dq.api/domain/methodology.hpp"
48
49namespace ores::qt {
50
51class BadgeCache;
52
65class DataLibrarianWindow final : public QWidget {
66 Q_OBJECT
67
68private:
69 inline static std::string_view logger_name = "ores.qt.data_librarian_window";
70 static constexpr int total_model_loads = 10; // 6 original + 4 new (bundle, 3 dimensions)
71
72 [[nodiscard]] static auto& lg() {
73 using namespace ores::logging;
74 static auto instance = make_logger(logger_name);
75 return instance;
76 }
77
78public:
79 explicit DataLibrarianWindow(ClientManager* clientManager,
80 const QString& username,
81 BadgeCache* badgeCache,
82 QWidget* parent = nullptr);
83 ~DataLibrarianWindow() override = default;
84
85 QSize sizeHint() const override { return QSize(1600, 900); }
86
87signals:
88 void statusChanged(const QString& message);
89 void errorOccurred(const QString& error_message);
90
98 void datasetsPublished(const QStringList& datasetCodes);
99
100 // Signals to open related windows
101 void openOriginDimensionsRequested();
102 void openNatureDimensionsRequested();
103 void openTreatmentDimensionsRequested();
104 void openCodingSchemesRequested();
105 void openMethodologiesRequested();
106 void openBundlesRequested();
107 void openDataDomainsRequested();
108 void openSubjectAreasRequested();
109 void openCatalogsRequested();
110
111private slots:
112 void onNavigationSelectionChanged(const QModelIndex& current,
113 const QModelIndex& previous);
114 void onDatasetSelectionChanged();
115 void onDatasetDoubleClicked(const QModelIndex& index);
116 void onRefreshClicked();
117 void onViewDatasetClicked();
118 void onPublishClicked();
119 void onPublicationHistoryClicked();
120 void onDataLoaded();
121 void onLoadError(const QString& error_message, const QString& details = {});
122
123 // Navigation data loaded
124 void onDomainsLoaded();
125 void onSubjectAreasLoaded();
126 void onCatalogsLoaded();
127 void onDatasetDependenciesLoaded();
128 void onMethodologiesLoaded();
129 void onBundlesLoaded();
130 void onBundleMembersLoaded();
131 void onOriginDimensionsLoaded();
132 void onNatureDimensionsLoaded();
133 void onTreatmentDimensionsLoaded();
134
135 // Column visibility context menu
136 void showHeaderContextMenu(const QPoint& pos);
137
138 // Dataset context menu
139 void showDatasetContextMenu(const QPoint& pos);
140
141 // Navigation tree context menu
142 void showNavigationContextMenu(const QPoint& pos);
143
144private:
145 void setupUi();
146 void setupNavigationSidebar();
147 void setupCentralWorkspace();
148 void setupToolbar();
149 void setupConnections();
150 void buildNavigationTree();
151 void showDatasetDetailDialog(const dq::domain::dataset* dataset);
152 void filterDatasetsByCatalog(const QString& catalogName);
153 void filterDatasetsByDomain(const QString& domainName);
154 void filterDatasetsBySubjectArea(const QString& subjectAreaName);
155 void filterDatasetsByBundle(const QString& bundleCode);
156 void filterDatasetsByOrigin(const QString& originCode);
157 void filterDatasetsByNature(const QString& natureCode);
158 void filterDatasetsByTreatment(const QString& treatmentCode);
159 void clearDatasetFilter();
160 void selectFirstDataset();
161 void setupColumnVisibility();
162 void applyDefaultColumnVisibility();
163 void fetchBundleMembers();
164 std::vector<dq::domain::dataset> getDatasetsUnderNode(const QModelIndex& index);
165
166 ClientManager* clientManager_;
167 QString username_;
168 BadgeCache* badgeCache_;
169
170 // Main layout
171 QSplitter* mainSplitter_;
172 QSplitter* centralSplitter_;
173
174 // Navigation sidebar ("The Stacks")
175 QTreeView* navigationTree_;
176 QStandardItemModel* navigationModel_;
177
178 // Toolbar
179 QToolBar* toolbar_;
180 QAction* refreshAction_;
181 QAction* viewDatasetAction_;
182 QAction* publishAction_;
183 QAction* publicationHistoryAction_;
184 QAction* originDimensionsAction_;
185 QAction* natureDimensionsAction_;
186 QAction* treatmentDimensionsAction_;
187 QAction* codingSchemesAction_;
188 QAction* methodologiesAction_;
189 QAction* bundlesAction_;
190
191 // Central workspace - Dataset table
192 QTableView* datasetTable_;
193 ClientDatasetModel* datasetModel_;
194 QSortFilterProxyModel* datasetProxyModel_;
195
196 // Data models for navigation
197 ClientDataDomainModel* dataDomainModel_;
198 ClientSubjectAreaModel* subjectAreaModel_;
199 ClientCatalogModel* catalogModel_;
200 ClientDatasetDependencyModel* datasetDependencyModel_;
201 ClientMethodologyModel* methodologyModel_;
202 ClientDatasetBundleModel* bundleModel_;
203 ClientOriginDimensionModel* originDimensionModel_;
204 ClientNatureDimensionModel* natureDimensionModel_;
205 ClientTreatmentDimensionModel* treatmentDimensionModel_;
206
207 // Bundle member cache for filtering (bundle_code -> list of dataset_codes)
208 std::map<QString, QStringList> bundleMemberCache_;
209
210 // Status bar with loading indicator
211 QStatusBar* statusBar_;
212 QProgressBar* loadingProgressBar_;
213 QLabel* statusLabel_;
214 int pendingLoads_{0};
215 int totalLoads_{0};
216
217 // Track selected filter
218 QString selectedCatalogName_;
219 QString selectedDomainName_;
220 QString selectedSubjectAreaName_;
221 QString selectedBundleCode_;
222 QString selectedOriginCode_;
223 QString selectedNatureCode_;
224 QString selectedTreatmentCode_;
225};
226
227}
228
229#endif
Implements logging infrastructure for ORE Studio.
Definition boost_severity.hpp:28
Qt-based graphical user interface for ORE Studio.
Definition AboutDialog.hpp:29
Represents a data quality dataset with lineage tracking.
Definition dataset.hpp:37
Client-side cache of badge definitions and mappings.
Definition BadgeCache.hpp:46
Table model for displaying catalogs in a QTableView.
Definition ClientCatalogModel.hpp:42
Model for displaying dataset bundles fetched from the server.
Definition ClientDatasetBundleModel.hpp:41
Table model for displaying dataset dependencies.
Definition ClientDatasetDependencyModel.hpp:37
Manages the lifecycle of the NATS client and login state.
Definition ClientManager.hpp:112
Model for displaying origin dimensions fetched from the server.
Definition ClientOriginDimensionModel.hpp:43
The Data Librarian window for browsing and managing datasets.
Definition DataLibrarianWindow.hpp:65
void datasetsPublished(const QStringList &datasetCodes)
Emitted when datasets are successfully published.