comparison SQLite/Plugins/SQLiteIndex.cpp @ 569:f18e46d7dbf8 attach-custom-data

merged find-refactoring -> attach-custom-data
author Alain Mazy <am@orthanc.team>
date Tue, 24 Sep 2024 15:04:21 +0200
parents cd9521e04249 451125122692
children
comparison
equal deleted inserted replaced
368:82f73188b58d 569:f18e46d7dbf8
1 /** 1 /**
2 * Orthanc - A Lightweight, RESTful DICOM Store 2 * Orthanc - A Lightweight, RESTful DICOM Store
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics 3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
4 * Department, University Hospital of Liege, Belgium 4 * Department, University Hospital of Liege, Belgium
5 * Copyright (C) 2017-2021 Osimis S.A., Belgium 5 * Copyright (C) 2017-2023 Osimis S.A., Belgium
6 * Copyright (C) 2024-2024 Orthanc Team SRL, Belgium
7 * Copyright (C) 2021-2024 Sebastien Jodogne, ICTEAM UCLouvain, Belgium
6 * 8 *
7 * This program is free software: you can redistribute it and/or 9 * This program is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU Affero General Public License 10 * modify it under the terms of the GNU Affero General Public License
9 * as published by the Free Software Foundation, either version 3 of 11 * as published by the Free Software Foundation, either version 3 of
10 * the License, or (at your option) any later version. 12 * the License, or (at your option) any later version.
82 84
83 return new Factory(path_, fast_); 85 return new Factory(path_, fast_);
84 } 86 }
85 87
86 88
87 void SQLiteIndex::ConfigureDatabase(DatabaseManager& manager) 89 void SQLiteIndex::ConfigureDatabase(DatabaseManager& manager,
90 bool hasIdentifierTags,
91 const std::list<IdentifierTag>& identifierTags)
88 { 92 {
89 uint32_t expectedVersion = 6; 93 uint32_t expectedVersion = 6;
90 94
91 if (GetContext()) // "GetContext()" can possibly be NULL in the unit tests 95 if (GetContext()) // "GetContext()" can possibly be NULL in the unit tests
92 { 96 {
174 178
175 if (!t.GetDatabaseTransaction().DoesTableExist("ServerProperties")) 179 if (!t.GetDatabaseTransaction().DoesTableExist("ServerProperties"))
176 { 180 {
177 t.GetDatabaseTransaction().ExecuteMultiLines("CREATE TABLE ServerProperties(server TEXT, " 181 t.GetDatabaseTransaction().ExecuteMultiLines("CREATE TABLE ServerProperties(server TEXT, "
178 "property INTEGER, value TEXT, PRIMARY KEY(server, property))"); 182 "property INTEGER, value TEXT, PRIMARY KEY(server, property))");
183 }
184
185 t.Commit();
186 }
187
188 {
189 DatabaseManager::Transaction t(manager, TransactionType_ReadWrite);
190
191 if (!t.GetDatabaseTransaction().DoesTableExist("Labels"))
192 {
193 t.GetDatabaseTransaction().ExecuteMultiLines(
194 "CREATE TABLE Labels("
195 " id INTEGER REFERENCES Resources(internalId) ON DELETE CASCADE,"
196 " label TEXT NOT NULL,"
197 " PRIMARY KEY(id, label));"
198 "CREATE INDEX LabelsIndex1 ON Labels(id);"
199 "CREATE INDEX LabelsIndex2 ON Labels(label);");
179 } 200 }
180 201
181 t.Commit(); 202 t.Commit();
182 } 203 }
183 } 204 }
251 //LOG(ERROR) << value.Format(); 272 //LOG(ERROR) << value.Format();
252 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError); 273 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError);
253 } 274 }
254 } 275 }
255 } 276 }
277
278
279 #if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 12, 5)
280 bool SQLiteIndex::HasFindSupport() const
281 {
282 // TODO-FIND
283 return false;
284 }
285 #endif
286
287
288 #if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 12, 5)
289 void SQLiteIndex::ExecuteFind(Orthanc::DatabasePluginMessages::TransactionResponse& response,
290 DatabaseManager& manager,
291 const Orthanc::DatabasePluginMessages::Find_Request& request)
292 {
293 // TODO-FIND
294 throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented);
295 }
296 #endif
256 } 297 }