|
@@
-1,760
+1,780
|
|
1
|
#include <Catalogue/CatalogueController.h>
|
|
1
|
#include <Catalogue/CatalogueController.h>
|
|
2
|
#include <CatalogueIO.hpp>
|
|
2
|
#include <CatalogueIO.hpp>
|
|
3
|
#include <Common/containers.h>
|
|
3
|
#include <Common/containers.h>
|
|
4
|
#include <Common/debug.h>
|
|
4
|
#include <Common/debug.h>
|
|
5
|
#include <QDataStream>
|
|
5
|
#include <QDataStream>
|
|
6
|
#include <QDir>
|
|
6
|
#include <QDir>
|
|
7
|
#include <QMutex>
|
|
7
|
#include <QMutex>
|
|
8
|
#include <QStandardPaths>
|
|
8
|
#include <QStandardPaths>
|
|
9
|
#include <QThread>
|
|
9
|
#include <QThread>
|
|
10
|
|
|
10
|
|
|
11
|
using namespace SciQLop::containers;
|
|
11
|
using namespace SciQLop::containers;
|
|
12
|
|
|
12
|
|
|
13
|
// class CatalogueController::CatalogueControllerPrivate
|
|
13
|
// class CatalogueController::CatalogueControllerPrivate
|
|
14
|
//{
|
|
14
|
//{
|
|
15
|
|
|
15
|
|
|
16
|
// public:
|
|
16
|
// public:
|
|
17
|
// explicit CatalogueControllerPrivate(CatalogueController* parent) : m_Q {
|
|
17
|
// explicit CatalogueControllerPrivate(CatalogueController* parent) : m_Q {
|
|
18
|
// parent } {}
|
|
18
|
// parent } {}
|
|
19
|
|
|
19
|
|
|
20
|
// CatalogueDao m_CatalogueDao;
|
|
20
|
// CatalogueDao m_CatalogueDao;
|
|
21
|
|
|
21
|
|
|
22
|
// QStringList m_RepositoryList;
|
|
22
|
// QStringList m_RepositoryList;
|
|
23
|
// CatalogueController* m_Q;
|
|
23
|
// CatalogueController* m_Q;
|
|
24
|
|
|
24
|
|
|
25
|
// QSet<QString> m_KeysWithChanges;
|
|
25
|
// QSet<QString> m_KeysWithChanges;
|
|
26
|
|
|
26
|
|
|
27
|
// QString eventUniqueKey(const std::shared_ptr<DBEvent>& event) const;
|
|
27
|
// QString eventUniqueKey(const std::shared_ptr<DBEvent>& event) const;
|
|
28
|
// QString catalogueUniqueKey(const std::shared_ptr<DBCatalogue>& catalogue)
|
|
28
|
// QString catalogueUniqueKey(const std::shared_ptr<DBCatalogue>& catalogue)
|
|
29
|
// const;
|
|
29
|
// const;
|
|
30
|
|
|
30
|
|
|
31
|
// void copyDBtoDB(const QString& dbFrom, const QString& dbTo);
|
|
31
|
// void copyDBtoDB(const QString& dbFrom, const QString& dbTo);
|
|
32
|
// QString toWorkRepository(QString repository);
|
|
32
|
// QString toWorkRepository(QString repository);
|
|
33
|
// QString toSyncRepository(QString repository);
|
|
33
|
// QString toSyncRepository(QString repository);
|
|
34
|
// void savAllDB();
|
|
34
|
// void savAllDB();
|
|
35
|
|
|
35
|
|
|
36
|
// void saveEvent(std::shared_ptr<DBEvent> event, bool persist = true);
|
|
36
|
// void saveEvent(std::shared_ptr<DBEvent> event, bool persist = true);
|
|
37
|
// void saveCatalogue(std::shared_ptr<DBCatalogue> catalogue, bool persist =
|
|
37
|
// void saveCatalogue(std::shared_ptr<DBCatalogue> catalogue, bool persist =
|
|
38
|
// true);
|
|
38
|
// true);
|
|
39
|
|
|
39
|
|
|
40
|
// std::shared_ptr<IRequestPredicate> createFinder(
|
|
40
|
// std::shared_ptr<IRequestPredicate> createFinder(
|
|
41
|
// const QUuid& uniqId, const QString& repository, DBType type);
|
|
41
|
// const QUuid& uniqId, const QString& repository, DBType type);
|
|
42
|
//};
|
|
42
|
//};
|
|
43
|
|
|
43
|
|
|
44
|
CatalogueController::CatalogueController(QObject* parent)
|
|
44
|
CatalogueController::CatalogueController(QObject* parent)
|
|
45
|
//: impl { spimpl::make_unique_impl<CatalogueControllerPrivate>(this) }
|
|
45
|
//: impl { spimpl::make_unique_impl<CatalogueControllerPrivate>(this) }
|
|
46
|
{}
|
|
46
|
{}
|
|
47
|
|
|
47
|
|
|
48
|
CatalogueController::~CatalogueController() {}
|
|
48
|
CatalogueController::~CatalogueController() {}
|
|
49
|
|
|
49
|
|
|
50
|
QStringList CatalogueController::getRepositories() const
|
|
50
|
QStringList CatalogueController::repositories() const
|
|
51
|
{
|
|
51
|
{
|
|
52
|
QStringList repos;
|
|
52
|
QStringList repos;
|
|
53
|
std::transform(std::begin(_currentRepos), std::end(_currentRepos),
|
|
53
|
std::transform(std::begin(_currentRepos), std::end(_currentRepos),
|
|
54
|
std::back_inserter(repos),
|
|
54
|
std::back_inserter(repos),
|
|
55
|
[](auto& pair) { return pair.first; });
|
|
55
|
[](auto& pair) { return pair.first; });
|
|
56
|
return repos;
|
|
56
|
return repos;
|
|
57
|
}
|
|
57
|
}
|
|
58
|
|
|
58
|
|
|
59
|
void CatalogueController::loadRepository(const QString& path,
|
|
59
|
void CatalogueController::loadRepository(const QString& path,
|
|
60
|
const QString& name)
|
|
60
|
const QString& name)
|
|
61
|
{
|
|
61
|
{
|
|
62
|
if(QFile::exists(path))
|
|
62
|
if(QFile::exists(path))
|
|
63
|
{
|
|
63
|
{
|
|
64
|
auto repo = CatalogiCpp::load_repository<time_t>(path.toStdString());
|
|
64
|
auto repo = CatalogiCpp::load_repository<time_t>(path.toStdString());
|
|
65
|
_lastSavedRepos[name] = repo;
|
|
65
|
_lastSavedRepos[name] = repo;
|
|
66
|
_currentRepos[name] = repo;
|
|
66
|
_currentRepos[name] = repo;
|
|
67
|
}
|
|
67
|
}
|
|
68
|
}
|
|
68
|
}
|
|
69
|
|
|
69
|
|
|
70
|
void CatalogueController::saveRepository(const QString& path,
|
|
70
|
void CatalogueController::saveRepository(const QString& path,
|
|
71
|
const QString& name)
|
|
71
|
const QString& name)
|
|
72
|
{
|
|
72
|
{
|
|
73
|
if(contains(_currentRepos, name))
|
|
73
|
if(contains(_currentRepos, name))
|
|
74
|
{
|
|
74
|
{
|
|
75
|
CatalogiCpp::save_repository(_currentRepos[name], path.toStdString());
|
|
75
|
CatalogiCpp::save_repository(_currentRepos[name], path.toStdString());
|
|
76
|
_lastSavedRepos[name] = _currentRepos[name];
|
|
76
|
_lastSavedRepos[name] = _currentRepos[name];
|
|
77
|
}
|
|
77
|
}
|
|
78
|
}
|
|
78
|
}
|
|
79
|
|
|
79
|
|
|
80
|
std::vector<CatalogueController::Event_ptr> CatalogueController::events()
|
|
80
|
std::vector<CatalogueController::Event_ptr> CatalogueController::events()
|
|
81
|
{
|
|
81
|
{
|
|
82
|
std::vector<CatalogueController::Event_ptr> e_list;
|
|
82
|
std::vector<CatalogueController::Event_ptr> e_list;
|
|
83
|
for(auto& [_, repo] : _currentRepos)
|
|
83
|
for(auto& [_, repo] : _currentRepos)
|
|
84
|
{
|
|
84
|
{
|
|
85
|
for(auto& [_, event] : repo.events())
|
|
85
|
for(auto& [_, event] : repo.events())
|
|
86
|
e_list.push_back(event);
|
|
86
|
e_list.push_back(event);
|
|
87
|
}
|
|
87
|
}
|
|
88
|
return e_list;
|
|
88
|
return e_list;
|
|
89
|
}
|
|
89
|
}
|
|
90
|
|
|
90
|
|
|
91
|
std::vector<std::shared_ptr<CatalogueController::Event_t>>
|
|
91
|
std::vector<std::shared_ptr<CatalogueController::Event_t>>
|
|
92
|
CatalogueController::events(const QString& repository)
|
|
92
|
CatalogueController::events(const QString& repository)
|
|
93
|
{
|
|
93
|
{
|
|
94
|
std::vector<std::shared_ptr<CatalogueController::Event_t>> e_list;
|
|
94
|
std::vector<std::shared_ptr<CatalogueController::Event_t>> e_list;
|
|
95
|
if(contains(_currentRepos, repository))
|
|
95
|
if(contains(_currentRepos, repository))
|
|
96
|
{
|
|
96
|
{
|
|
97
|
auto repo = _currentRepos[repository];
|
|
97
|
auto repo = _currentRepos[repository];
|
|
98
|
for(auto& [_, event] : repo.events())
|
|
98
|
for(auto& [_, event] : repo.events())
|
|
99
|
e_list.push_back(event);
|
|
99
|
e_list.push_back(event);
|
|
100
|
}
|
|
100
|
}
|
|
101
|
return e_list;
|
|
101
|
return e_list;
|
|
102
|
}
|
|
102
|
}
|
|
103
|
|
|
103
|
|
|
104
|
std::vector<CatalogueController::Catalogue_ptr>
|
|
104
|
std::vector<CatalogueController::Catalogue_ptr>
|
|
105
|
CatalogueController::catalogues()
|
|
105
|
CatalogueController::catalogues()
|
|
106
|
{
|
|
106
|
{
|
|
107
|
std::vector<CatalogueController::Catalogue_ptr> c_list;
|
|
107
|
std::vector<CatalogueController::Catalogue_ptr> c_list;
|
|
108
|
for(auto& [_, repo] : _currentRepos)
|
|
108
|
for(auto& [_, repo] : _currentRepos)
|
|
109
|
{
|
|
109
|
{
|
|
110
|
for(auto& [_, catalogue] : repo.catalogues())
|
|
110
|
for(auto& [_, catalogue] : repo.catalogues())
|
|
111
|
c_list.push_back(catalogue);
|
|
111
|
c_list.push_back(catalogue);
|
|
112
|
}
|
|
112
|
}
|
|
113
|
return c_list;
|
|
113
|
return c_list;
|
|
114
|
}
|
|
114
|
}
|
|
115
|
|
|
115
|
|
|
116
|
std::vector<CatalogueController::Catalogue_ptr>
|
|
116
|
std::vector<CatalogueController::Catalogue_ptr>
|
|
117
|
CatalogueController::catalogues(const QString& repository)
|
|
117
|
CatalogueController::catalogues(const QString& repository)
|
|
118
|
{
|
|
118
|
{
|
|
119
|
std::vector<CatalogueController::Catalogue_ptr> c_list;
|
|
119
|
std::vector<CatalogueController::Catalogue_ptr> c_list;
|
|
120
|
if(contains(_currentRepos, repository))
|
|
120
|
if(contains(_currentRepos, repository))
|
|
121
|
{
|
|
121
|
{
|
|
122
|
auto repo = _currentRepos[repository];
|
|
122
|
auto repo = _currentRepos[repository];
|
|
123
|
for(auto& [_, catalogue] : repo.catalogues())
|
|
123
|
for(auto& [_, catalogue] : repo.catalogues())
|
|
124
|
c_list.push_back(catalogue);
|
|
124
|
c_list.push_back(catalogue);
|
|
125
|
}
|
|
125
|
}
|
|
126
|
return c_list;
|
|
126
|
return c_list;
|
|
127
|
}
|
|
127
|
}
|
|
128
|
|
|
128
|
|
|
129
|
bool CatalogueController::hasUnsavedChanges(
|
|
129
|
bool CatalogueController::hasUnsavedChanges(
|
|
130
|
CatalogueController::Event_ptr event)
|
|
130
|
CatalogueController::Event_ptr event)
|
|
131
|
{
|
|
131
|
{
|
|
132
|
if(auto repo = repository(event))
|
|
132
|
if(auto repo = repository(event))
|
|
133
|
{
|
|
133
|
{
|
|
134
|
if(contains(_lastSavedRepos, *repo))
|
|
134
|
if(contains(_lastSavedRepos, *repo))
|
|
135
|
{ return *event != *(_lastSavedRepos[*repo].event(event->uuid)); }
|
|
135
|
{ return *event != *(_lastSavedRepos[*repo].event(event->uuid)); }
|
|
136
|
}
|
|
136
|
}
|
|
137
|
return true;
|
|
137
|
return true;
|
|
138
|
}
|
|
138
|
}
|
|
139
|
|
|
139
|
|
|
140
|
std::optional<QString>
|
|
140
|
std::optional<QString>
|
|
141
|
CatalogueController::repository(CatalogueController::Event_ptr event)
|
|
141
|
CatalogueController::repository(CatalogueController::Event_ptr event)
|
|
142
|
{
|
|
142
|
{
|
|
143
|
for(auto& [repoName, repo] : _currentRepos)
|
|
143
|
for(auto& [repoName, repo] : _currentRepos)
|
|
144
|
{
|
|
144
|
{
|
|
145
|
if(repo.event(event->uuid)) return repoName;
|
|
145
|
if(repo.event(event->uuid)) return repoName;
|
|
146
|
}
|
|
146
|
}
|
|
147
|
return std::nullopt;
|
|
147
|
return std::nullopt;
|
|
148
|
}
|
|
148
|
}
|
|
149
|
|
|
149
|
|
|
150
|
std::optional<QString>
|
|
150
|
std::optional<QString>
|
|
151
|
CatalogueController::repository(CatalogueController::Catalogue_ptr catalogue)
|
|
151
|
CatalogueController::repository(CatalogueController::Catalogue_ptr catalogue)
|
|
152
|
{
|
|
152
|
{
|
|
153
|
for(auto& [repoName, repo] : _currentRepos)
|
|
153
|
for(auto& [repoName, repo] : _currentRepos)
|
|
154
|
{
|
|
154
|
{
|
|
155
|
if(repo.catalogue(catalogue->uuid)) return repoName;
|
|
155
|
if(repo.catalogue(catalogue->uuid)) return repoName;
|
|
156
|
}
|
|
156
|
}
|
|
157
|
return std::nullopt;
|
|
157
|
return std::nullopt;
|
|
158
|
}
|
|
158
|
}
|
|
159
|
|
|
159
|
|
|
160
|
void CatalogueController::save(CatalogueController::Event_ptr event)
|
|
160
|
void CatalogueController::save(CatalogueController::Event_ptr event)
|
|
161
|
{
|
|
161
|
{
|
|
162
|
auto repo_name = repository(event);
|
|
162
|
auto repo_name = repository(event);
|
|
163
|
if(repo_name && contains(_lastSavedRepos, *repo_name))
|
|
163
|
if(repo_name && contains(_lastSavedRepos, *repo_name))
|
|
164
|
{
|
|
164
|
{
|
|
165
|
auto repo = _lastSavedRepos[*repo_name];
|
|
165
|
auto repo = _lastSavedRepos[*repo_name];
|
|
166
|
if(contains(repo.events(), event->uuid))
|
|
166
|
if(contains(repo.events(), event->uuid))
|
|
167
|
{
|
|
167
|
{
|
|
168
|
auto saved_evemt = _lastSavedRepos[*repo_name].event(event->uuid);
|
|
168
|
auto saved_evemt = _lastSavedRepos[*repo_name].event(event->uuid);
|
|
169
|
*saved_evemt = *event;
|
|
169
|
*saved_evemt = *event;
|
|
170
|
}
|
|
170
|
}
|
|
171
|
else
|
|
171
|
else
|
|
172
|
{
|
|
172
|
{
|
|
173
|
// TODO/Question should we also take care of which catalogue has it?
|
|
173
|
// TODO/Question should we also take care of which catalogue has it?
|
|
174
|
// if an event is created and added to a catalogue, what should we do if
|
|
174
|
// if an event is created and added to a catalogue, what should we do if
|
|
175
|
// the user clicks the event save button?
|
|
175
|
// the user clicks the event save button?
|
|
176
|
// - Only save event value in all events list?
|
|
176
|
// - Only save event value in all events list?
|
|
177
|
// - Also save the fact that this event is added to a catalogue and save
|
|
177
|
// - Also save the fact that this event is added to a catalogue and save
|
|
178
|
// the catalogue?
|
|
178
|
// the catalogue?
|
|
179
|
repo.add(event);
|
|
179
|
repo.add(event);
|
|
180
|
}
|
|
180
|
}
|
|
181
|
}
|
|
181
|
}
|
|
182
|
}
|
|
182
|
}
|
|
183
|
|
|
183
|
|
|
184
|
void CatalogueController::save(CatalogueController::Catalogue_ptr catalogue)
|
|
184
|
void CatalogueController::save(CatalogueController::Catalogue_ptr catalogue)
|
|
185
|
{
|
|
185
|
{
|
|
186
|
auto repo_name = repository(catalogue);
|
|
186
|
auto repo_name = repository(catalogue);
|
|
187
|
if(repo_name && contains(_lastSavedRepos, *repo_name))
|
|
187
|
if(repo_name && contains(_lastSavedRepos, *repo_name))
|
|
188
|
{
|
|
188
|
{
|
|
189
|
auto repo = _lastSavedRepos[*repo_name];
|
|
189
|
auto repo = _lastSavedRepos[*repo_name];
|
|
190
|
if(contains(repo.catalogues(), catalogue->uuid))
|
|
190
|
if(contains(repo.catalogues(), catalogue->uuid))
|
|
191
|
{
|
|
191
|
{
|
|
192
|
auto saved_catalogue = repo.catalogue(catalogue->uuid);
|
|
192
|
auto saved_catalogue = repo.catalogue(catalogue->uuid);
|
|
193
|
*saved_catalogue = *catalogue;
|
|
193
|
*saved_catalogue = *catalogue;
|
|
194
|
}
|
|
194
|
}
|
|
195
|
else
|
|
195
|
else
|
|
196
|
{
|
|
196
|
{
|
|
197
|
repo.add(catalogue);
|
|
197
|
repo.add(catalogue);
|
|
198
|
}
|
|
198
|
}
|
|
199
|
}
|
|
199
|
}
|
|
200
|
}
|
|
200
|
}
|
|
201
|
|
|
201
|
|
|
202
|
void CatalogueController::save(const QString& repository)
|
|
202
|
void CatalogueController::save(const QString& repository)
|
|
203
|
{
|
|
203
|
{
|
|
204
|
if(contains(_currentRepos, repository))
|
|
204
|
if(contains(_currentRepos, repository))
|
|
205
|
{ _lastSavedRepos[repository] = _currentRepos[repository]; }
|
|
205
|
{ _lastSavedRepos[repository] = _currentRepos[repository]; }
|
|
206
|
else
|
|
206
|
else
|
|
207
|
{
|
|
207
|
{
|
|
208
|
SCIQLOP_ERROR(CatalogueController, "Trying to save an unknown repository");
|
|
208
|
SCIQLOP_ERROR(CatalogueController, "Trying to save an unknown repository");
|
|
209
|
}
|
|
209
|
}
|
|
210
|
}
|
|
210
|
}
|
|
211
|
|
|
211
|
|
|
|
|
|
212
|
void CatalogueController::add(const QString& repository)
|
|
|
|
|
213
|
{
|
|
|
|
|
214
|
if(!contains(_currentRepos, repository))
|
|
|
|
|
215
|
{ _currentRepos[repository] = Repository_t{}; }
|
|
|
|
|
216
|
}
|
|
|
|
|
217
|
|
|
|
|
|
218
|
void CatalogueController::add(const QString& catalogue,
|
|
|
|
|
219
|
const QString& repository)
|
|
|
|
|
220
|
{
|
|
|
|
|
221
|
if(!contains(_currentRepos, repository))
|
|
|
|
|
222
|
{ _currentRepos[repository] = Repository_t{}; }
|
|
|
|
|
223
|
auto new_catalogue = make_catalogue_ptr();
|
|
|
|
|
224
|
new_catalogue->name = catalogue.toStdString();
|
|
|
|
|
225
|
_currentRepos[repository].add(std::move(new_catalogue));
|
|
|
|
|
226
|
}
|
|
|
|
|
227
|
|
|
|
|
|
228
|
void CatalogueController::add(CatalogueController::Event_ptr event,
|
|
|
|
|
229
|
const QString& repository)
|
|
|
|
|
230
|
{}
|
|
|
|
|
231
|
|
|
212
|
// void CatalogueController::saveDB(const QString& destinationPath, const
|
|
232
|
// void CatalogueController::saveDB(const QString& destinationPath, const
|
|
213
|
// QString& repositoryName)
|
|
233
|
// QString& repositoryName)
|
|
214
|
//{
|
|
234
|
//{
|
|
215
|
// if (!impl->m_CatalogueDao.saveDB(destinationPath, repositoryName))
|
|
235
|
// if (!impl->m_CatalogueDao.saveDB(destinationPath, repositoryName))
|
|
216
|
// {
|
|
236
|
// {
|
|
217
|
// qCCritical(LOG_CatalogueController())
|
|
237
|
// qCCritical(LOG_CatalogueController())
|
|
218
|
// << tr("Impossible to saveDB %1 from %2 ").arg(repositoryName,
|
|
238
|
// << tr("Impossible to saveDB %1 from %2 ").arg(repositoryName,
|
|
219
|
// destinationPath);
|
|
239
|
// destinationPath);
|
|
220
|
// }
|
|
240
|
// }
|
|
221
|
//}
|
|
241
|
//}
|
|
222
|
|
|
242
|
|
|
223
|
// std::list<std::shared_ptr<DBEvent>> CatalogueController::retrieveEvents(
|
|
243
|
// std::list<std::shared_ptr<DBEvent>> CatalogueController::retrieveEvents(
|
|
224
|
// const QString& repository) const
|
|
244
|
// const QString& repository) const
|
|
225
|
//{
|
|
245
|
//{
|
|
226
|
// QString dbDireName = repository.isEmpty() ? REPOSITORY_DEFAULT :
|
|
246
|
// QString dbDireName = repository.isEmpty() ? REPOSITORY_DEFAULT :
|
|
227
|
// repository;
|
|
247
|
// repository;
|
|
228
|
|
|
248
|
|
|
229
|
// auto eventsShared = std::list<std::shared_ptr<DBEvent>> {};
|
|
249
|
// auto eventsShared = std::list<std::shared_ptr<DBEvent>> {};
|
|
230
|
// auto events =
|
|
250
|
// auto events =
|
|
231
|
// impl->m_CatalogueDao.getEvents(impl->toWorkRepository(dbDireName)); for
|
|
251
|
// impl->m_CatalogueDao.getEvents(impl->toWorkRepository(dbDireName)); for
|
|
232
|
// (auto event : events)
|
|
252
|
// (auto event : events)
|
|
233
|
// {
|
|
253
|
// {
|
|
234
|
// eventsShared.push_back(std::make_shared<DBEvent>(event));
|
|
254
|
// eventsShared.push_back(std::make_shared<DBEvent>(event));
|
|
235
|
// }
|
|
255
|
// }
|
|
236
|
// return eventsShared;
|
|
256
|
// return eventsShared;
|
|
237
|
//}
|
|
257
|
//}
|
|
238
|
|
|
258
|
|
|
239
|
// std::list<std::shared_ptr<DBEvent>> CatalogueController::retrieveAllEvents()
|
|
259
|
// std::list<std::shared_ptr<DBEvent>> CatalogueController::retrieveAllEvents()
|
|
240
|
// const
|
|
260
|
// const
|
|
241
|
//{
|
|
261
|
//{
|
|
242
|
// auto eventsShared = std::list<std::shared_ptr<DBEvent>> {};
|
|
262
|
// auto eventsShared = std::list<std::shared_ptr<DBEvent>> {};
|
|
243
|
// for (auto repository : impl->m_RepositoryList)
|
|
263
|
// for (auto repository : impl->m_RepositoryList)
|
|
244
|
// {
|
|
264
|
// {
|
|
245
|
// eventsShared.splice(eventsShared.end(), retrieveEvents(repository));
|
|
265
|
// eventsShared.splice(eventsShared.end(), retrieveEvents(repository));
|
|
246
|
// }
|
|
266
|
// }
|
|
247
|
|
|
267
|
|
|
248
|
// return eventsShared;
|
|
268
|
// return eventsShared;
|
|
249
|
//}
|
|
269
|
//}
|
|
250
|
|
|
270
|
|
|
251
|
// std::list<std::shared_ptr<DBEvent>>
|
|
271
|
// std::list<std::shared_ptr<DBEvent>>
|
|
252
|
// CatalogueController::retrieveEventsFromCatalogue(
|
|
272
|
// CatalogueController::retrieveEventsFromCatalogue(
|
|
253
|
// std::shared_ptr<DBCatalogue> catalogue) const
|
|
273
|
// std::shared_ptr<DBCatalogue> catalogue) const
|
|
254
|
//{
|
|
274
|
//{
|
|
255
|
// auto eventsShared = std::list<std::shared_ptr<DBEvent>> {};
|
|
275
|
// auto eventsShared = std::list<std::shared_ptr<DBEvent>> {};
|
|
256
|
// auto events = impl->m_CatalogueDao.getCatalogueEvents(*catalogue);
|
|
276
|
// auto events = impl->m_CatalogueDao.getCatalogueEvents(*catalogue);
|
|
257
|
// for (auto event : events)
|
|
277
|
// for (auto event : events)
|
|
258
|
// {
|
|
278
|
// {
|
|
259
|
// eventsShared.push_back(std::make_shared<DBEvent>(event));
|
|
279
|
// eventsShared.push_back(std::make_shared<DBEvent>(event));
|
|
260
|
// }
|
|
280
|
// }
|
|
261
|
// return eventsShared;
|
|
281
|
// return eventsShared;
|
|
262
|
//}
|
|
282
|
//}
|
|
263
|
|
|
283
|
|
|
264
|
// void CatalogueController::updateEvent(std::shared_ptr<DBEvent> event)
|
|
284
|
// void CatalogueController::updateEvent(std::shared_ptr<DBEvent> event)
|
|
265
|
//{
|
|
285
|
//{
|
|
266
|
// event->setRepository(impl->toWorkRepository(event->getRepository()));
|
|
286
|
// event->setRepository(impl->toWorkRepository(event->getRepository()));
|
|
267
|
|
|
287
|
|
|
268
|
// auto uniqueId = impl->eventUniqueKey(event);
|
|
288
|
// auto uniqueId = impl->eventUniqueKey(event);
|
|
269
|
// impl->m_KeysWithChanges.insert(uniqueId);
|
|
289
|
// impl->m_KeysWithChanges.insert(uniqueId);
|
|
270
|
|
|
290
|
|
|
271
|
// impl->m_CatalogueDao.updateEvent(*event);
|
|
291
|
// impl->m_CatalogueDao.updateEvent(*event);
|
|
272
|
//}
|
|
292
|
//}
|
|
273
|
|
|
293
|
|
|
274
|
// void CatalogueController::updateEventProduct(std::shared_ptr<DBEventProduct>
|
|
294
|
// void CatalogueController::updateEventProduct(std::shared_ptr<DBEventProduct>
|
|
275
|
// eventProduct)
|
|
295
|
// eventProduct)
|
|
276
|
//{
|
|
296
|
//{
|
|
277
|
// impl->m_CatalogueDao.updateEventProduct(*eventProduct);
|
|
297
|
// impl->m_CatalogueDao.updateEventProduct(*eventProduct);
|
|
278
|
//}
|
|
298
|
//}
|
|
279
|
|
|
299
|
|
|
280
|
// void CatalogueController::removeEvent(std::shared_ptr<DBEvent> event)
|
|
300
|
// void CatalogueController::removeEvent(std::shared_ptr<DBEvent> event)
|
|
281
|
//{
|
|
301
|
//{
|
|
282
|
// // Remove it from both repository and repository_work
|
|
302
|
// // Remove it from both repository and repository_work
|
|
283
|
// event->setRepository(impl->toWorkRepository(event->getRepository()));
|
|
303
|
// event->setRepository(impl->toWorkRepository(event->getRepository()));
|
|
284
|
// impl->m_CatalogueDao.removeEvent(*event);
|
|
304
|
// impl->m_CatalogueDao.removeEvent(*event);
|
|
285
|
// event->setRepository(impl->toSyncRepository(event->getRepository()));
|
|
305
|
// event->setRepository(impl->toSyncRepository(event->getRepository()));
|
|
286
|
// impl->m_CatalogueDao.removeEvent(*event);
|
|
306
|
// impl->m_CatalogueDao.removeEvent(*event);
|
|
287
|
// impl->savAllDB();
|
|
307
|
// impl->savAllDB();
|
|
288
|
//}
|
|
308
|
//}
|
|
289
|
|
|
309
|
|
|
290
|
// void CatalogueController::addEvent(std::shared_ptr<DBEvent> event)
|
|
310
|
// void CatalogueController::addEvent(std::shared_ptr<DBEvent> event)
|
|
291
|
//{
|
|
311
|
//{
|
|
292
|
// event->setRepository(impl->toWorkRepository(event->getRepository()));
|
|
312
|
// event->setRepository(impl->toWorkRepository(event->getRepository()));
|
|
293
|
|
|
313
|
|
|
294
|
// auto eventTemp = *event;
|
|
314
|
// auto eventTemp = *event;
|
|
295
|
// impl->m_CatalogueDao.addEvent(eventTemp);
|
|
315
|
// impl->m_CatalogueDao.addEvent(eventTemp);
|
|
296
|
|
|
316
|
|
|
297
|
// // Call update is necessary at the creation of add Event if it has some
|
|
317
|
// // Call update is necessary at the creation of add Event if it has some
|
|
298
|
// tags or some event
|
|
318
|
// tags or some event
|
|
299
|
// // products
|
|
319
|
// // products
|
|
300
|
// if (!event->getEventProducts().empty() || !event->getTags().empty())
|
|
320
|
// if (!event->getEventProducts().empty() || !event->getTags().empty())
|
|
301
|
// {
|
|
321
|
// {
|
|
302
|
|
|
322
|
|
|
303
|
// auto eventProductsTemp = eventTemp.getEventProducts();
|
|
323
|
// auto eventProductsTemp = eventTemp.getEventProducts();
|
|
304
|
// auto eventProductTempUpdated = std::list<DBEventProduct> {};
|
|
324
|
// auto eventProductTempUpdated = std::list<DBEventProduct> {};
|
|
305
|
// for (auto eventProductTemp : eventProductsTemp)
|
|
325
|
// for (auto eventProductTemp : eventProductsTemp)
|
|
306
|
// {
|
|
326
|
// {
|
|
307
|
// eventProductTemp.setEvent(eventTemp);
|
|
327
|
// eventProductTemp.setEvent(eventTemp);
|
|
308
|
// eventProductTempUpdated.push_back(eventProductTemp);
|
|
328
|
// eventProductTempUpdated.push_back(eventProductTemp);
|
|
309
|
// }
|
|
329
|
// }
|
|
310
|
// eventTemp.setEventProducts(eventProductTempUpdated);
|
|
330
|
// eventTemp.setEventProducts(eventProductTempUpdated);
|
|
311
|
|
|
331
|
|
|
312
|
// impl->m_CatalogueDao.updateEvent(eventTemp);
|
|
332
|
// impl->m_CatalogueDao.updateEvent(eventTemp);
|
|
313
|
// }
|
|
333
|
// }
|
|
314
|
|
|
334
|
|
|
315
|
// auto workPred = impl->createFinder(event->getUniqId(),
|
|
335
|
// auto workPred = impl->createFinder(event->getUniqId(),
|
|
316
|
// event->getRepository(), DBType::WORK);
|
|
336
|
// event->getRepository(), DBType::WORK);
|
|
317
|
|
|
337
|
|
|
318
|
// auto workEvent = impl->m_CatalogueDao.getEvent(workPred);
|
|
338
|
// auto workEvent = impl->m_CatalogueDao.getEvent(workPred);
|
|
319
|
// *event = workEvent;
|
|
339
|
// *event = workEvent;
|
|
320
|
|
|
340
|
|
|
321
|
// auto uniqueId = impl->eventUniqueKey(event);
|
|
341
|
// auto uniqueId = impl->eventUniqueKey(event);
|
|
322
|
// impl->m_KeysWithChanges.insert(uniqueId);
|
|
342
|
// impl->m_KeysWithChanges.insert(uniqueId);
|
|
323
|
//}
|
|
343
|
//}
|
|
324
|
|
|
344
|
|
|
325
|
// void CatalogueController::saveEvent(std::shared_ptr<DBEvent> event)
|
|
345
|
// void CatalogueController::saveEvent(std::shared_ptr<DBEvent> event)
|
|
326
|
//{
|
|
346
|
//{
|
|
327
|
// impl->saveEvent(event, true);
|
|
347
|
// impl->saveEvent(event, true);
|
|
328
|
// impl->m_KeysWithChanges.remove(impl->eventUniqueKey(event));
|
|
348
|
// impl->m_KeysWithChanges.remove(impl->eventUniqueKey(event));
|
|
329
|
//}
|
|
349
|
//}
|
|
330
|
|
|
350
|
|
|
331
|
// void CatalogueController::discardEvent(std::shared_ptr<DBEvent> event, bool&
|
|
351
|
// void CatalogueController::discardEvent(std::shared_ptr<DBEvent> event, bool&
|
|
332
|
// removed)
|
|
352
|
// removed)
|
|
333
|
//{
|
|
353
|
//{
|
|
334
|
// auto syncPred = impl->createFinder(event->getUniqId(),
|
|
354
|
// auto syncPred = impl->createFinder(event->getUniqId(),
|
|
335
|
// event->getRepository(), DBType::SYNC); auto workPred =
|
|
355
|
// event->getRepository(), DBType::SYNC); auto workPred =
|
|
336
|
// impl->createFinder(event->getUniqId(), event->getRepository(),
|
|
356
|
// impl->createFinder(event->getUniqId(), event->getRepository(),
|
|
337
|
// DBType::WORK);
|
|
357
|
// DBType::WORK);
|
|
338
|
|
|
358
|
|
|
339
|
// auto syncEvent = impl->m_CatalogueDao.getEvent(syncPred);
|
|
359
|
// auto syncEvent = impl->m_CatalogueDao.getEvent(syncPred);
|
|
340
|
// if (!syncEvent.getUniqId().isNull())
|
|
360
|
// if (!syncEvent.getUniqId().isNull())
|
|
341
|
// {
|
|
361
|
// {
|
|
342
|
// removed = false;
|
|
362
|
// removed = false;
|
|
343
|
// impl->m_CatalogueDao.copyEvent(
|
|
363
|
// impl->m_CatalogueDao.copyEvent(
|
|
344
|
// syncEvent, impl->toWorkRepository(event->getRepository()), true);
|
|
364
|
// syncEvent, impl->toWorkRepository(event->getRepository()), true);
|
|
345
|
|
|
365
|
|
|
346
|
// auto workEvent = impl->m_CatalogueDao.getEvent(workPred);
|
|
366
|
// auto workEvent = impl->m_CatalogueDao.getEvent(workPred);
|
|
347
|
// *event = workEvent;
|
|
367
|
// *event = workEvent;
|
|
348
|
// impl->m_KeysWithChanges.remove(impl->eventUniqueKey(event));
|
|
368
|
// impl->m_KeysWithChanges.remove(impl->eventUniqueKey(event));
|
|
349
|
// }
|
|
369
|
// }
|
|
350
|
// else
|
|
370
|
// else
|
|
351
|
// {
|
|
371
|
// {
|
|
352
|
// removed = true;
|
|
372
|
// removed = true;
|
|
353
|
// // Since the element wasn't in sync repository. Discard it means
|
|
373
|
// // Since the element wasn't in sync repository. Discard it means
|
|
354
|
// remove it
|
|
374
|
// remove it
|
|
355
|
// event->setRepository(impl->toWorkRepository(event->getRepository()));
|
|
375
|
// event->setRepository(impl->toWorkRepository(event->getRepository()));
|
|
356
|
// impl->m_CatalogueDao.removeEvent(*event);
|
|
376
|
// impl->m_CatalogueDao.removeEvent(*event);
|
|
357
|
// }
|
|
377
|
// }
|
|
358
|
//}
|
|
378
|
//}
|
|
359
|
|
|
379
|
|
|
360
|
// bool CatalogueController::eventHasChanges(std::shared_ptr<DBEvent> event)
|
|
380
|
// bool CatalogueController::eventHasChanges(std::shared_ptr<DBEvent> event)
|
|
361
|
// const
|
|
381
|
// const
|
|
362
|
//{
|
|
382
|
//{
|
|
363
|
// return impl->m_KeysWithChanges.contains(impl->eventUniqueKey(event));
|
|
383
|
// return impl->m_KeysWithChanges.contains(impl->eventUniqueKey(event));
|
|
364
|
//}
|
|
384
|
//}
|
|
365
|
|
|
385
|
|
|
366
|
// std::list<std::shared_ptr<DBCatalogue>>
|
|
386
|
// std::list<std::shared_ptr<DBCatalogue>>
|
|
367
|
// CatalogueController::retrieveCatalogues(
|
|
387
|
// CatalogueController::retrieveCatalogues(
|
|
368
|
// const QString& repository) const
|
|
388
|
// const QString& repository) const
|
|
369
|
//{
|
|
389
|
//{
|
|
370
|
// QString dbDireName = repository.isEmpty() ? REPOSITORY_DEFAULT :
|
|
390
|
// QString dbDireName = repository.isEmpty() ? REPOSITORY_DEFAULT :
|
|
371
|
// repository;
|
|
391
|
// repository;
|
|
372
|
|
|
392
|
|
|
373
|
// auto cataloguesShared = std::list<std::shared_ptr<DBCatalogue>> {};
|
|
393
|
// auto cataloguesShared = std::list<std::shared_ptr<DBCatalogue>> {};
|
|
374
|
// auto catalogues =
|
|
394
|
// auto catalogues =
|
|
375
|
// impl->m_CatalogueDao.getCatalogues(impl->toWorkRepository(dbDireName));
|
|
395
|
// impl->m_CatalogueDao.getCatalogues(impl->toWorkRepository(dbDireName));
|
|
376
|
// for (auto catalogue : catalogues)
|
|
396
|
// for (auto catalogue : catalogues)
|
|
377
|
// {
|
|
397
|
// {
|
|
378
|
// cataloguesShared.push_back(std::make_shared<DBCatalogue>(catalogue));
|
|
398
|
// cataloguesShared.push_back(std::make_shared<DBCatalogue>(catalogue));
|
|
379
|
// }
|
|
399
|
// }
|
|
380
|
// return cataloguesShared;
|
|
400
|
// return cataloguesShared;
|
|
381
|
//}
|
|
401
|
//}
|
|
382
|
|
|
402
|
|
|
383
|
// void CatalogueController::addCatalogue(std::shared_ptr<DBCatalogue>
|
|
403
|
// void CatalogueController::addCatalogue(std::shared_ptr<DBCatalogue>
|
|
384
|
// catalogue)
|
|
404
|
// catalogue)
|
|
385
|
//{
|
|
405
|
//{
|
|
386
|
// catalogue->setRepository(impl->toWorkRepository(catalogue->getRepository()));
|
|
406
|
// catalogue->setRepository(impl->toWorkRepository(catalogue->getRepository()));
|
|
387
|
|
|
407
|
|
|
388
|
// auto catalogueTemp = *catalogue;
|
|
408
|
// auto catalogueTemp = *catalogue;
|
|
389
|
// impl->m_CatalogueDao.addCatalogue(catalogueTemp);
|
|
409
|
// impl->m_CatalogueDao.addCatalogue(catalogueTemp);
|
|
390
|
|
|
410
|
|
|
391
|
// auto workPred
|
|
411
|
// auto workPred
|
|
392
|
// = impl->createFinder(catalogue->getUniqId(),
|
|
412
|
// = impl->createFinder(catalogue->getUniqId(),
|
|
393
|
// catalogue->getRepository(), DBType::WORK);
|
|
413
|
// catalogue->getRepository(), DBType::WORK);
|
|
394
|
|
|
414
|
|
|
395
|
// auto workCatalogue = impl->m_CatalogueDao.getCatalogue(workPred);
|
|
415
|
// auto workCatalogue = impl->m_CatalogueDao.getCatalogue(workPred);
|
|
396
|
// *catalogue = workCatalogue;
|
|
416
|
// *catalogue = workCatalogue;
|
|
397
|
|
|
417
|
|
|
398
|
// auto uniqueId = impl->catalogueUniqueKey(catalogue);
|
|
418
|
// auto uniqueId = impl->catalogueUniqueKey(catalogue);
|
|
399
|
// impl->m_KeysWithChanges.insert(uniqueId);
|
|
419
|
// impl->m_KeysWithChanges.insert(uniqueId);
|
|
400
|
//}
|
|
420
|
//}
|
|
401
|
|
|
421
|
|
|
402
|
// void CatalogueController::updateCatalogue(std::shared_ptr<DBCatalogue>
|
|
422
|
// void CatalogueController::updateCatalogue(std::shared_ptr<DBCatalogue>
|
|
403
|
// catalogue)
|
|
423
|
// catalogue)
|
|
404
|
//{
|
|
424
|
//{
|
|
405
|
// catalogue->setRepository(impl->toWorkRepository(catalogue->getRepository()));
|
|
425
|
// catalogue->setRepository(impl->toWorkRepository(catalogue->getRepository()));
|
|
406
|
|
|
426
|
|
|
407
|
// auto uniqueId = impl->catalogueUniqueKey(catalogue);
|
|
427
|
// auto uniqueId = impl->catalogueUniqueKey(catalogue);
|
|
408
|
// impl->m_KeysWithChanges.insert(uniqueId);
|
|
428
|
// impl->m_KeysWithChanges.insert(uniqueId);
|
|
409
|
|
|
429
|
|
|
410
|
// impl->m_CatalogueDao.updateCatalogue(*catalogue);
|
|
430
|
// impl->m_CatalogueDao.updateCatalogue(*catalogue);
|
|
411
|
//}
|
|
431
|
//}
|
|
412
|
|
|
432
|
|
|
413
|
// void CatalogueController::removeCatalogue(std::shared_ptr<DBCatalogue>
|
|
433
|
// void CatalogueController::removeCatalogue(std::shared_ptr<DBCatalogue>
|
|
414
|
// catalogue)
|
|
434
|
// catalogue)
|
|
415
|
//{
|
|
435
|
//{
|
|
416
|
// // Remove it from both repository and repository_work
|
|
436
|
// // Remove it from both repository and repository_work
|
|
417
|
// catalogue->setRepository(impl->toWorkRepository(catalogue->getRepository()));
|
|
437
|
// catalogue->setRepository(impl->toWorkRepository(catalogue->getRepository()));
|
|
418
|
// impl->m_CatalogueDao.removeCatalogue(*catalogue);
|
|
438
|
// impl->m_CatalogueDao.removeCatalogue(*catalogue);
|
|
419
|
// catalogue->setRepository(impl->toSyncRepository(catalogue->getRepository()));
|
|
439
|
// catalogue->setRepository(impl->toSyncRepository(catalogue->getRepository()));
|
|
420
|
// impl->m_CatalogueDao.removeCatalogue(*catalogue);
|
|
440
|
// impl->m_CatalogueDao.removeCatalogue(*catalogue);
|
|
421
|
// impl->savAllDB();
|
|
441
|
// impl->savAllDB();
|
|
422
|
//}
|
|
442
|
//}
|
|
423
|
|
|
443
|
|
|
424
|
// void CatalogueController::saveCatalogue(std::shared_ptr<DBCatalogue>
|
|
444
|
// void CatalogueController::saveCatalogue(std::shared_ptr<DBCatalogue>
|
|
425
|
// catalogue)
|
|
445
|
// catalogue)
|
|
426
|
//{
|
|
446
|
//{
|
|
427
|
// impl->saveCatalogue(catalogue, true);
|
|
447
|
// impl->saveCatalogue(catalogue, true);
|
|
428
|
// impl->m_KeysWithChanges.remove(impl->catalogueUniqueKey(catalogue));
|
|
448
|
// impl->m_KeysWithChanges.remove(impl->catalogueUniqueKey(catalogue));
|
|
429
|
|
|
449
|
|
|
430
|
// // remove key of events of the catalogue
|
|
450
|
// // remove key of events of the catalogue
|
|
431
|
// if (catalogue->getType() == CatalogueType::STATIC)
|
|
451
|
// if (catalogue->getType() == CatalogueType::STATIC)
|
|
432
|
// {
|
|
452
|
// {
|
|
433
|
// auto events = this->retrieveEventsFromCatalogue(catalogue);
|
|
453
|
// auto events = this->retrieveEventsFromCatalogue(catalogue);
|
|
434
|
// for (auto event : events)
|
|
454
|
// for (auto event : events)
|
|
435
|
// {
|
|
455
|
// {
|
|
436
|
// impl->m_KeysWithChanges.remove(impl->eventUniqueKey(event));
|
|
456
|
// impl->m_KeysWithChanges.remove(impl->eventUniqueKey(event));
|
|
437
|
// }
|
|
457
|
// }
|
|
438
|
// }
|
|
458
|
// }
|
|
439
|
//}
|
|
459
|
//}
|
|
440
|
|
|
460
|
|
|
441
|
// void CatalogueController::discardCatalogue(std::shared_ptr<DBCatalogue>
|
|
461
|
// void CatalogueController::discardCatalogue(std::shared_ptr<DBCatalogue>
|
|
442
|
// catalogue, bool& removed)
|
|
462
|
// catalogue, bool& removed)
|
|
443
|
//{
|
|
463
|
//{
|
|
444
|
// auto syncPred
|
|
464
|
// auto syncPred
|
|
445
|
// = impl->createFinder(catalogue->getUniqId(),
|
|
465
|
// = impl->createFinder(catalogue->getUniqId(),
|
|
446
|
// catalogue->getRepository(), DBType::SYNC);
|
|
466
|
// catalogue->getRepository(), DBType::SYNC);
|
|
447
|
// auto workPred
|
|
467
|
// auto workPred
|
|
448
|
// = impl->createFinder(catalogue->getUniqId(),
|
|
468
|
// = impl->createFinder(catalogue->getUniqId(),
|
|
449
|
// catalogue->getRepository(), DBType::WORK);
|
|
469
|
// catalogue->getRepository(), DBType::WORK);
|
|
450
|
|
|
470
|
|
|
451
|
// auto syncCatalogue = impl->m_CatalogueDao.getCatalogue(syncPred);
|
|
471
|
// auto syncCatalogue = impl->m_CatalogueDao.getCatalogue(syncPred);
|
|
452
|
// if (!syncCatalogue.getUniqId().isNull())
|
|
472
|
// if (!syncCatalogue.getUniqId().isNull())
|
|
453
|
// {
|
|
473
|
// {
|
|
454
|
// removed = false;
|
|
474
|
// removed = false;
|
|
455
|
// impl->m_CatalogueDao.copyCatalogue(
|
|
475
|
// impl->m_CatalogueDao.copyCatalogue(
|
|
456
|
// syncCatalogue, impl->toWorkRepository(catalogue->getRepository()),
|
|
476
|
// syncCatalogue, impl->toWorkRepository(catalogue->getRepository()),
|
|
457
|
// true);
|
|
477
|
// true);
|
|
458
|
|
|
478
|
|
|
459
|
// auto workCatalogue = impl->m_CatalogueDao.getCatalogue(workPred);
|
|
479
|
// auto workCatalogue = impl->m_CatalogueDao.getCatalogue(workPred);
|
|
460
|
// *catalogue = workCatalogue;
|
|
480
|
// *catalogue = workCatalogue;
|
|
461
|
// impl->m_KeysWithChanges.remove(impl->catalogueUniqueKey(catalogue));
|
|
481
|
// impl->m_KeysWithChanges.remove(impl->catalogueUniqueKey(catalogue));
|
|
462
|
// }
|
|
482
|
// }
|
|
463
|
// else
|
|
483
|
// else
|
|
464
|
// {
|
|
484
|
// {
|
|
465
|
// removed = true;
|
|
485
|
// removed = true;
|
|
466
|
// // Since the element wasn't in sync repository. Discard it means
|
|
486
|
// // Since the element wasn't in sync repository. Discard it means
|
|
467
|
// remove it
|
|
487
|
// remove it
|
|
468
|
// catalogue->setRepository(impl->toWorkRepository(catalogue->getRepository()));
|
|
488
|
// catalogue->setRepository(impl->toWorkRepository(catalogue->getRepository()));
|
|
469
|
// impl->m_CatalogueDao.removeCatalogue(*catalogue);
|
|
489
|
// impl->m_CatalogueDao.removeCatalogue(*catalogue);
|
|
470
|
// }
|
|
490
|
// }
|
|
471
|
//}
|
|
491
|
//}
|
|
472
|
|
|
492
|
|
|
473
|
// void CatalogueController::saveAll()
|
|
493
|
// void CatalogueController::saveAll()
|
|
474
|
//{
|
|
494
|
//{
|
|
475
|
// for (auto repository : impl->m_RepositoryList)
|
|
495
|
// for (auto repository : impl->m_RepositoryList)
|
|
476
|
// {
|
|
496
|
// {
|
|
477
|
// // Save Event
|
|
497
|
// // Save Event
|
|
478
|
// auto events = this->retrieveEvents(repository);
|
|
498
|
// auto events = this->retrieveEvents(repository);
|
|
479
|
// for (auto event : events)
|
|
499
|
// for (auto event : events)
|
|
480
|
// {
|
|
500
|
// {
|
|
481
|
// impl->saveEvent(event, false);
|
|
501
|
// impl->saveEvent(event, false);
|
|
482
|
// }
|
|
502
|
// }
|
|
483
|
|
|
503
|
|
|
484
|
// // Save Catalogue
|
|
504
|
// // Save Catalogue
|
|
485
|
// auto catalogues = this->retrieveCatalogues(repository);
|
|
505
|
// auto catalogues = this->retrieveCatalogues(repository);
|
|
486
|
// for (auto catalogue : catalogues)
|
|
506
|
// for (auto catalogue : catalogues)
|
|
487
|
// {
|
|
507
|
// {
|
|
488
|
// impl->saveCatalogue(catalogue, false);
|
|
508
|
// impl->saveCatalogue(catalogue, false);
|
|
489
|
// }
|
|
509
|
// }
|
|
490
|
// }
|
|
510
|
// }
|
|
491
|
|
|
511
|
|
|
492
|
// impl->savAllDB();
|
|
512
|
// impl->savAllDB();
|
|
493
|
// impl->m_KeysWithChanges.clear();
|
|
513
|
// impl->m_KeysWithChanges.clear();
|
|
494
|
//}
|
|
514
|
//}
|
|
495
|
|
|
515
|
|
|
496
|
// bool CatalogueController::hasChanges() const
|
|
516
|
// bool CatalogueController::hasChanges() const
|
|
497
|
//{
|
|
517
|
//{
|
|
498
|
// return !impl->m_KeysWithChanges.isEmpty();
|
|
518
|
// return !impl->m_KeysWithChanges.isEmpty();
|
|
499
|
//}
|
|
519
|
//}
|
|
500
|
|
|
520
|
|
|
501
|
// QByteArray CatalogueController::mimeDataForEvents(
|
|
521
|
// QByteArray CatalogueController::mimeDataForEvents(
|
|
502
|
// const QVector<std::shared_ptr<DBEvent>>& events) const
|
|
522
|
// const QVector<std::shared_ptr<DBEvent>>& events) const
|
|
503
|
//{
|
|
523
|
//{
|
|
504
|
// auto encodedData = QByteArray {};
|
|
524
|
// auto encodedData = QByteArray {};
|
|
505
|
|
|
525
|
|
|
506
|
// QMap<QString, QVariantList> idsPerRepository;
|
|
526
|
// QMap<QString, QVariantList> idsPerRepository;
|
|
507
|
// for (auto event : events)
|
|
527
|
// for (auto event : events)
|
|
508
|
// {
|
|
528
|
// {
|
|
509
|
// idsPerRepository[event->getRepository()] << event->getUniqId();
|
|
529
|
// idsPerRepository[event->getRepository()] << event->getUniqId();
|
|
510
|
// }
|
|
530
|
// }
|
|
511
|
|
|
531
|
|
|
512
|
// QDataStream stream { &encodedData, QIODevice::WriteOnly };
|
|
532
|
// QDataStream stream { &encodedData, QIODevice::WriteOnly };
|
|
513
|
// stream << idsPerRepository;
|
|
533
|
// stream << idsPerRepository;
|
|
514
|
|
|
534
|
|
|
515
|
// return encodedData;
|
|
535
|
// return encodedData;
|
|
516
|
//}
|
|
536
|
//}
|
|
517
|
|
|
537
|
|
|
518
|
// QVector<std::shared_ptr<DBEvent>> CatalogueController::eventsForMimeData(
|
|
538
|
// QVector<std::shared_ptr<DBEvent>> CatalogueController::eventsForMimeData(
|
|
519
|
// const QByteArray& mimeData) const
|
|
539
|
// const QByteArray& mimeData) const
|
|
520
|
//{
|
|
540
|
//{
|
|
521
|
// auto events = QVector<std::shared_ptr<DBEvent>> {};
|
|
541
|
// auto events = QVector<std::shared_ptr<DBEvent>> {};
|
|
522
|
// QDataStream stream { mimeData };
|
|
542
|
// QDataStream stream { mimeData };
|
|
523
|
|
|
543
|
|
|
524
|
// QMap<QString, QVariantList> idsPerRepository;
|
|
544
|
// QMap<QString, QVariantList> idsPerRepository;
|
|
525
|
// stream >> idsPerRepository;
|
|
545
|
// stream >> idsPerRepository;
|
|
526
|
|
|
546
|
|
|
527
|
// for (auto it = idsPerRepository.cbegin(); it != idsPerRepository.cend();
|
|
547
|
// for (auto it = idsPerRepository.cbegin(); it != idsPerRepository.cend();
|
|
528
|
// ++it)
|
|
548
|
// ++it)
|
|
529
|
// {
|
|
549
|
// {
|
|
530
|
// auto repository = it.key();
|
|
550
|
// auto repository = it.key();
|
|
531
|
// auto allRepositoryEvent = retrieveEvents(repository);
|
|
551
|
// auto allRepositoryEvent = retrieveEvents(repository);
|
|
532
|
// for (auto uuid : it.value())
|
|
552
|
// for (auto uuid : it.value())
|
|
533
|
// {
|
|
553
|
// {
|
|
534
|
// for (auto repositoryEvent : allRepositoryEvent)
|
|
554
|
// for (auto repositoryEvent : allRepositoryEvent)
|
|
535
|
// {
|
|
555
|
// {
|
|
536
|
// if (uuid.toUuid() == repositoryEvent->getUniqId())
|
|
556
|
// if (uuid.toUuid() == repositoryEvent->getUniqId())
|
|
537
|
// {
|
|
557
|
// {
|
|
538
|
// events << repositoryEvent;
|
|
558
|
// events << repositoryEvent;
|
|
539
|
// }
|
|
559
|
// }
|
|
540
|
// }
|
|
560
|
// }
|
|
541
|
// }
|
|
561
|
// }
|
|
542
|
// }
|
|
562
|
// }
|
|
543
|
|
|
563
|
|
|
544
|
// return events;
|
|
564
|
// return events;
|
|
545
|
//}
|
|
565
|
//}
|
|
546
|
|
|
566
|
|
|
547
|
// QByteArray CatalogueController::mimeDataForCatalogues(
|
|
567
|
// QByteArray CatalogueController::mimeDataForCatalogues(
|
|
548
|
// const QVector<std::shared_ptr<DBCatalogue>>& catalogues) const
|
|
568
|
// const QVector<std::shared_ptr<DBCatalogue>>& catalogues) const
|
|
549
|
//{
|
|
569
|
//{
|
|
550
|
// auto encodedData = QByteArray {};
|
|
570
|
// auto encodedData = QByteArray {};
|
|
551
|
|
|
571
|
|
|
552
|
// QMap<QString, QVariantList> idsPerRepository;
|
|
572
|
// QMap<QString, QVariantList> idsPerRepository;
|
|
553
|
// for (auto catalogue : catalogues)
|
|
573
|
// for (auto catalogue : catalogues)
|
|
554
|
// {
|
|
574
|
// {
|
|
555
|
// idsPerRepository[catalogue->getRepository()] <<
|
|
575
|
// idsPerRepository[catalogue->getRepository()] <<
|
|
556
|
// catalogue->getUniqId();
|
|
576
|
// catalogue->getUniqId();
|
|
557
|
// }
|
|
577
|
// }
|
|
558
|
|
|
578
|
|
|
559
|
// QDataStream stream { &encodedData, QIODevice::WriteOnly };
|
|
579
|
// QDataStream stream { &encodedData, QIODevice::WriteOnly };
|
|
560
|
// stream << idsPerRepository;
|
|
580
|
// stream << idsPerRepository;
|
|
561
|
|
|
581
|
|
|
562
|
// return encodedData;
|
|
582
|
// return encodedData;
|
|
563
|
//}
|
|
583
|
//}
|
|
564
|
|
|
584
|
|
|
565
|
// QVector<std::shared_ptr<DBCatalogue>>
|
|
585
|
// QVector<std::shared_ptr<DBCatalogue>>
|
|
566
|
// CatalogueController::cataloguesForMimeData(
|
|
586
|
// CatalogueController::cataloguesForMimeData(
|
|
567
|
// const QByteArray& mimeData) const
|
|
587
|
// const QByteArray& mimeData) const
|
|
568
|
//{
|
|
588
|
//{
|
|
569
|
// auto catalogues = QVector<std::shared_ptr<DBCatalogue>> {};
|
|
589
|
// auto catalogues = QVector<std::shared_ptr<DBCatalogue>> {};
|
|
570
|
// QDataStream stream { mimeData };
|
|
590
|
// QDataStream stream { mimeData };
|
|
571
|
|
|
591
|
|
|
572
|
// QMap<QString, QVariantList> idsPerRepository;
|
|
592
|
// QMap<QString, QVariantList> idsPerRepository;
|
|
573
|
// stream >> idsPerRepository;
|
|
593
|
// stream >> idsPerRepository;
|
|
574
|
|
|
594
|
|
|
575
|
// for (auto it = idsPerRepository.cbegin(); it != idsPerRepository.cend();
|
|
595
|
// for (auto it = idsPerRepository.cbegin(); it != idsPerRepository.cend();
|
|
576
|
// ++it)
|
|
596
|
// ++it)
|
|
577
|
// {
|
|
597
|
// {
|
|
578
|
// auto repository = it.key();
|
|
598
|
// auto repository = it.key();
|
|
579
|
// auto allRepositoryCatalogues = retrieveCatalogues(repository);
|
|
599
|
// auto allRepositoryCatalogues = retrieveCatalogues(repository);
|
|
580
|
// for (auto uuid : it.value())
|
|
600
|
// for (auto uuid : it.value())
|
|
581
|
// {
|
|
601
|
// {
|
|
582
|
// for (auto repositoryCatalogues : allRepositoryCatalogues)
|
|
602
|
// for (auto repositoryCatalogues : allRepositoryCatalogues)
|
|
583
|
// {
|
|
603
|
// {
|
|
584
|
// if (uuid.toUuid() == repositoryCatalogues->getUniqId())
|
|
604
|
// if (uuid.toUuid() == repositoryCatalogues->getUniqId())
|
|
585
|
// {
|
|
605
|
// {
|
|
586
|
// catalogues << repositoryCatalogues;
|
|
606
|
// catalogues << repositoryCatalogues;
|
|
587
|
// }
|
|
607
|
// }
|
|
588
|
// }
|
|
608
|
// }
|
|
589
|
// }
|
|
609
|
// }
|
|
590
|
// }
|
|
610
|
// }
|
|
591
|
|
|
611
|
|
|
592
|
// return catalogues;
|
|
612
|
// return catalogues;
|
|
593
|
//}
|
|
613
|
//}
|
|
594
|
|
|
614
|
|
|
595
|
// void CatalogueController::initialize()
|
|
615
|
// void CatalogueController::initialize()
|
|
596
|
//{
|
|
616
|
//{
|
|
597
|
// qCDebug(LOG_CatalogueController())
|
|
617
|
// qCDebug(LOG_CatalogueController())
|
|
598
|
// << tr("CatalogueController init") << QThread::currentThread();
|
|
618
|
// << tr("CatalogueController init") << QThread::currentThread();
|
|
599
|
|
|
619
|
|
|
600
|
// impl->m_CatalogueDao.initialize();
|
|
620
|
// impl->m_CatalogueDao.initialize();
|
|
601
|
// auto defaultRepositoryLocation
|
|
621
|
// auto defaultRepositoryLocation
|
|
602
|
// = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation);
|
|
622
|
// = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation);
|
|
603
|
|
|
623
|
|
|
604
|
// QDir defaultRepositoryLocationDir;
|
|
624
|
// QDir defaultRepositoryLocationDir;
|
|
605
|
// if (defaultRepositoryLocationDir.mkpath(defaultRepositoryLocation))
|
|
625
|
// if (defaultRepositoryLocationDir.mkpath(defaultRepositoryLocation))
|
|
606
|
// {
|
|
626
|
// {
|
|
607
|
// defaultRepositoryLocationDir.cd(defaultRepositoryLocation);
|
|
627
|
// defaultRepositoryLocationDir.cd(defaultRepositoryLocation);
|
|
608
|
// auto defaultRepository =
|
|
628
|
// auto defaultRepository =
|
|
609
|
// defaultRepositoryLocationDir.absoluteFilePath(REPOSITORY_DEFAULT);
|
|
629
|
// defaultRepositoryLocationDir.absoluteFilePath(REPOSITORY_DEFAULT);
|
|
610
|
|
|
630
|
|
|
611
|
// qCInfo(LOG_CatalogueController())
|
|
631
|
// qCInfo(LOG_CatalogueController())
|
|
612
|
// << tr("Persistant data loading from: ") << defaultRepository;
|
|
632
|
// << tr("Persistant data loading from: ") << defaultRepository;
|
|
613
|
|
|
633
|
|
|
614
|
// QDir dbDir(defaultRepository);
|
|
634
|
// QDir dbDir(defaultRepository);
|
|
615
|
// impl->m_RepositoryList << REPOSITORY_DEFAULT;
|
|
635
|
// impl->m_RepositoryList << REPOSITORY_DEFAULT;
|
|
616
|
// if (dbDir.exists())
|
|
636
|
// if (dbDir.exists())
|
|
617
|
// {
|
|
637
|
// {
|
|
618
|
// auto dirName = dbDir.dirName();
|
|
638
|
// auto dirName = dbDir.dirName();
|
|
619
|
|
|
639
|
|
|
620
|
// if (impl->m_CatalogueDao.addDB(defaultRepository, dirName))
|
|
640
|
// if (impl->m_CatalogueDao.addDB(defaultRepository, dirName))
|
|
621
|
// {
|
|
641
|
// {
|
|
622
|
// impl->copyDBtoDB(dirName, impl->toWorkRepository(dirName));
|
|
642
|
// impl->copyDBtoDB(dirName, impl->toWorkRepository(dirName));
|
|
623
|
// }
|
|
643
|
// }
|
|
624
|
// }
|
|
644
|
// }
|
|
625
|
// else
|
|
645
|
// else
|
|
626
|
// {
|
|
646
|
// {
|
|
627
|
// qCInfo(LOG_CatalogueController())
|
|
647
|
// qCInfo(LOG_CatalogueController())
|
|
628
|
// << tr("Initialisation of Default repository detected") <<
|
|
648
|
// << tr("Initialisation of Default repository detected") <<
|
|
629
|
// defaultRepository;
|
|
649
|
// defaultRepository;
|
|
630
|
// }
|
|
650
|
// }
|
|
631
|
// }
|
|
651
|
// }
|
|
632
|
// else
|
|
652
|
// else
|
|
633
|
// {
|
|
653
|
// {
|
|
634
|
// qCWarning(LOG_CatalogueController())
|
|
654
|
// qCWarning(LOG_CatalogueController())
|
|
635
|
// << tr("Cannot load the persistent default repository from ")
|
|
655
|
// << tr("Cannot load the persistent default repository from ")
|
|
636
|
// << defaultRepositoryLocation;
|
|
656
|
// << defaultRepositoryLocation;
|
|
637
|
// }
|
|
657
|
// }
|
|
638
|
|
|
658
|
|
|
639
|
// qCDebug(LOG_CatalogueController()) << tr("CatalogueController init END");
|
|
659
|
// qCDebug(LOG_CatalogueController()) << tr("CatalogueController init END");
|
|
640
|
//}
|
|
660
|
//}
|
|
641
|
|
|
661
|
|
|
642
|
// QString CatalogueController::CatalogueControllerPrivate::eventUniqueKey(
|
|
662
|
// QString CatalogueController::CatalogueControllerPrivate::eventUniqueKey(
|
|
643
|
// const std::shared_ptr<DBEvent>& event) const
|
|
663
|
// const std::shared_ptr<DBEvent>& event) const
|
|
644
|
//{
|
|
664
|
//{
|
|
645
|
// return event->getUniqId().toString().append(event->getRepository());
|
|
665
|
// return event->getUniqId().toString().append(event->getRepository());
|
|
646
|
//}
|
|
666
|
//}
|
|
647
|
|
|
667
|
|
|
648
|
// QString CatalogueController::CatalogueControllerPrivate::catalogueUniqueKey(
|
|
668
|
// QString CatalogueController::CatalogueControllerPrivate::catalogueUniqueKey(
|
|
649
|
// const std::shared_ptr<DBCatalogue>& catalogue) const
|
|
669
|
// const std::shared_ptr<DBCatalogue>& catalogue) const
|
|
650
|
//{
|
|
670
|
//{
|
|
651
|
// return
|
|
671
|
// return
|
|
652
|
// catalogue->getUniqId().toString().append(catalogue->getRepository());
|
|
672
|
// catalogue->getUniqId().toString().append(catalogue->getRepository());
|
|
653
|
//}
|
|
673
|
//}
|
|
654
|
|
|
674
|
|
|
655
|
// void CatalogueController::CatalogueControllerPrivate::copyDBtoDB(
|
|
675
|
// void CatalogueController::CatalogueControllerPrivate::copyDBtoDB(
|
|
656
|
// const QString& dbFrom, const QString& dbTo)
|
|
676
|
// const QString& dbFrom, const QString& dbTo)
|
|
657
|
//{
|
|
677
|
//{
|
|
658
|
// // auto cataloguesShared = std::list<std::shared_ptr<DBCatalogue> >{};
|
|
678
|
// // auto cataloguesShared = std::list<std::shared_ptr<DBCatalogue> >{};
|
|
659
|
// auto catalogues = m_CatalogueDao.getCatalogues(dbFrom);
|
|
679
|
// auto catalogues = m_CatalogueDao.getCatalogues(dbFrom);
|
|
660
|
// auto events = m_CatalogueDao.getEvents(dbFrom);
|
|
680
|
// auto events = m_CatalogueDao.getEvents(dbFrom);
|
|
661
|
// for (auto catalogue : catalogues)
|
|
681
|
// for (auto catalogue : catalogues)
|
|
662
|
// {
|
|
682
|
// {
|
|
663
|
// m_CatalogueDao.copyCatalogue(catalogue, dbTo, true);
|
|
683
|
// m_CatalogueDao.copyCatalogue(catalogue, dbTo, true);
|
|
664
|
// }
|
|
684
|
// }
|
|
665
|
|
|
685
|
|
|
666
|
// for (auto event : events)
|
|
686
|
// for (auto event : events)
|
|
667
|
// {
|
|
687
|
// {
|
|
668
|
// m_CatalogueDao.copyEvent(event, dbTo, true);
|
|
688
|
// m_CatalogueDao.copyEvent(event, dbTo, true);
|
|
669
|
// }
|
|
689
|
// }
|
|
670
|
//}
|
|
690
|
//}
|
|
671
|
|
|
691
|
|
|
672
|
// QString
|
|
692
|
// QString
|
|
673
|
// CatalogueController::CatalogueControllerPrivate::toWorkRepository(QString
|
|
693
|
// CatalogueController::CatalogueControllerPrivate::toWorkRepository(QString
|
|
674
|
// repository)
|
|
694
|
// repository)
|
|
675
|
//{
|
|
695
|
//{
|
|
676
|
// auto syncRepository = toSyncRepository(repository);
|
|
696
|
// auto syncRepository = toSyncRepository(repository);
|
|
677
|
|
|
697
|
|
|
678
|
// return QString("%1%2").arg(syncRepository, REPOSITORY_WORK_SUFFIX);
|
|
698
|
// return QString("%1%2").arg(syncRepository, REPOSITORY_WORK_SUFFIX);
|
|
679
|
//}
|
|
699
|
//}
|
|
680
|
|
|
700
|
|
|
681
|
// QString
|
|
701
|
// QString
|
|
682
|
// CatalogueController::CatalogueControllerPrivate::toSyncRepository(QString
|
|
702
|
// CatalogueController::CatalogueControllerPrivate::toSyncRepository(QString
|
|
683
|
// repository)
|
|
703
|
// repository)
|
|
684
|
//{
|
|
704
|
//{
|
|
685
|
// auto syncRepository = repository;
|
|
705
|
// auto syncRepository = repository;
|
|
686
|
// if (repository.endsWith(REPOSITORY_WORK_SUFFIX))
|
|
706
|
// if (repository.endsWith(REPOSITORY_WORK_SUFFIX))
|
|
687
|
// {
|
|
707
|
// {
|
|
688
|
// syncRepository.remove(REPOSITORY_WORK_SUFFIX);
|
|
708
|
// syncRepository.remove(REPOSITORY_WORK_SUFFIX);
|
|
689
|
// }
|
|
709
|
// }
|
|
690
|
// else if (repository.endsWith(REPOSITORY_TRASH_SUFFIX))
|
|
710
|
// else if (repository.endsWith(REPOSITORY_TRASH_SUFFIX))
|
|
691
|
// {
|
|
711
|
// {
|
|
692
|
// syncRepository.remove(REPOSITORY_TRASH_SUFFIX);
|
|
712
|
// syncRepository.remove(REPOSITORY_TRASH_SUFFIX);
|
|
693
|
// }
|
|
713
|
// }
|
|
694
|
// return syncRepository;
|
|
714
|
// return syncRepository;
|
|
695
|
//}
|
|
715
|
//}
|
|
696
|
|
|
716
|
|
|
697
|
// void CatalogueController::CatalogueControllerPrivate::savAllDB()
|
|
717
|
// void CatalogueController::CatalogueControllerPrivate::savAllDB()
|
|
698
|
//{
|
|
718
|
//{
|
|
699
|
// for (auto repository : m_RepositoryList)
|
|
719
|
// for (auto repository : m_RepositoryList)
|
|
700
|
// {
|
|
720
|
// {
|
|
701
|
// auto defaultRepositoryLocation
|
|
721
|
// auto defaultRepositoryLocation
|
|
702
|
// =
|
|
722
|
// =
|
|
703
|
// QStandardPaths::writableLocation(QStandardPaths::AppDataLocation);
|
|
723
|
// QStandardPaths::writableLocation(QStandardPaths::AppDataLocation);
|
|
704
|
// m_CatalogueDao.saveDB(defaultRepositoryLocation, repository);
|
|
724
|
// m_CatalogueDao.saveDB(defaultRepositoryLocation, repository);
|
|
705
|
// }
|
|
725
|
// }
|
|
706
|
//}
|
|
726
|
//}
|
|
707
|
|
|
727
|
|
|
708
|
// void CatalogueController::CatalogueControllerPrivate::saveEvent(
|
|
728
|
// void CatalogueController::CatalogueControllerPrivate::saveEvent(
|
|
709
|
// std::shared_ptr<DBEvent> event, bool persist)
|
|
729
|
// std::shared_ptr<DBEvent> event, bool persist)
|
|
710
|
//{
|
|
730
|
//{
|
|
711
|
// m_CatalogueDao.copyEvent(*event, toSyncRepository(event->getRepository()),
|
|
731
|
// m_CatalogueDao.copyEvent(*event, toSyncRepository(event->getRepository()),
|
|
712
|
// true); if (persist)
|
|
732
|
// true); if (persist)
|
|
713
|
// {
|
|
733
|
// {
|
|
714
|
// savAllDB();
|
|
734
|
// savAllDB();
|
|
715
|
// }
|
|
735
|
// }
|
|
716
|
//}
|
|
736
|
//}
|
|
717
|
|
|
737
|
|
|
718
|
// void CatalogueController::CatalogueControllerPrivate::saveCatalogue(
|
|
738
|
// void CatalogueController::CatalogueControllerPrivate::saveCatalogue(
|
|
719
|
// std::shared_ptr<DBCatalogue> catalogue, bool persist)
|
|
739
|
// std::shared_ptr<DBCatalogue> catalogue, bool persist)
|
|
720
|
//{
|
|
740
|
//{
|
|
721
|
// m_CatalogueDao.copyCatalogue(*catalogue,
|
|
741
|
// m_CatalogueDao.copyCatalogue(*catalogue,
|
|
722
|
// toSyncRepository(catalogue->getRepository()), true); if (persist)
|
|
742
|
// toSyncRepository(catalogue->getRepository()), true); if (persist)
|
|
723
|
// {
|
|
743
|
// {
|
|
724
|
// savAllDB();
|
|
744
|
// savAllDB();
|
|
725
|
// }
|
|
745
|
// }
|
|
726
|
//}
|
|
746
|
//}
|
|
727
|
|
|
747
|
|
|
728
|
// std::shared_ptr<IRequestPredicate>
|
|
748
|
// std::shared_ptr<IRequestPredicate>
|
|
729
|
// CatalogueController::CatalogueControllerPrivate::createFinder(
|
|
749
|
// CatalogueController::CatalogueControllerPrivate::createFinder(
|
|
730
|
// const QUuid& uniqId, const QString& repository, DBType type)
|
|
750
|
// const QUuid& uniqId, const QString& repository, DBType type)
|
|
731
|
//{
|
|
751
|
//{
|
|
732
|
// // update catalogue parameter
|
|
752
|
// // update catalogue parameter
|
|
733
|
// auto uniqIdPredicate = std::make_shared<ComparaisonPredicate>(
|
|
753
|
// auto uniqIdPredicate = std::make_shared<ComparaisonPredicate>(
|
|
734
|
// QString { "uniqId" }, uniqId, ComparaisonOperation::EQUALEQUAL);
|
|
754
|
// QString { "uniqId" }, uniqId, ComparaisonOperation::EQUALEQUAL);
|
|
735
|
|
|
755
|
|
|
736
|
// auto repositoryType = repository;
|
|
756
|
// auto repositoryType = repository;
|
|
737
|
// switch (type)
|
|
757
|
// switch (type)
|
|
738
|
// {
|
|
758
|
// {
|
|
739
|
// case DBType::SYNC:
|
|
759
|
// case DBType::SYNC:
|
|
740
|
// repositoryType = toSyncRepository(repositoryType);
|
|
760
|
// repositoryType = toSyncRepository(repositoryType);
|
|
741
|
// break;
|
|
761
|
// break;
|
|
742
|
// case DBType::WORK:
|
|
762
|
// case DBType::WORK:
|
|
743
|
// repositoryType = toWorkRepository(repositoryType);
|
|
763
|
// repositoryType = toWorkRepository(repositoryType);
|
|
744
|
// break;
|
|
764
|
// break;
|
|
745
|
// case DBType::TRASH:
|
|
765
|
// case DBType::TRASH:
|
|
746
|
// default:
|
|
766
|
// default:
|
|
747
|
// break;
|
|
767
|
// break;
|
|
748
|
// }
|
|
768
|
// }
|
|
749
|
|
|
769
|
|
|
750
|
// auto repositoryPredicate = std::make_shared<ComparaisonPredicate>(
|
|
770
|
// auto repositoryPredicate = std::make_shared<ComparaisonPredicate>(
|
|
751
|
// QString { "repository" }, repositoryType,
|
|
771
|
// QString { "repository" }, repositoryType,
|
|
752
|
// ComparaisonOperation::EQUALEQUAL);
|
|
772
|
// ComparaisonOperation::EQUALEQUAL);
|
|
753
|
|
|
773
|
|
|
754
|
// auto finderPred =
|
|
774
|
// auto finderPred =
|
|
755
|
// std::make_shared<CompoundPredicate>(CompoundOperation::AND);
|
|
775
|
// std::make_shared<CompoundPredicate>(CompoundOperation::AND);
|
|
756
|
// finderPred->AddRequestPredicate(uniqIdPredicate);
|
|
776
|
// finderPred->AddRequestPredicate(uniqIdPredicate);
|
|
757
|
// finderPred->AddRequestPredicate(repositoryPredicate);
|
|
777
|
// finderPred->AddRequestPredicate(repositoryPredicate);
|
|
758
|
|
|
778
|
|
|
759
|
// return finderPred;
|
|
779
|
// return finderPred;
|
|
760
|
//}
|
|
780
|
//}
|