annotate OrthancServer/DatabaseWrapper.h @ 2813:6d5b20af216f

fix
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 06 Sep 2018 18:24:44 +0200
parents bb63068844ae
children 4e43e67f8ecf
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
183
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 /**
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2 * Orthanc - A Lightweight, RESTful DICOM Store
1900
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1750
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
1288
6e7e5ed91c2d upgrade to year 2015
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1286
diff changeset
4 * Department, University Hospital of Liege, Belgium
2447
878b59270859 upgrade to year 2018
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
5 * Copyright (C) 2017-2018 Osimis S.A., Belgium
183
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6 *
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 * This program is free software: you can redistribute it and/or
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 * modify it under the terms of the GNU General Public License as
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 * published by the Free Software Foundation, either version 3 of the
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 * License, or (at your option) any later version.
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 *
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 * In addition, as a special exception, the copyright holders of this
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 * program give permission to link the code of its release with the
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 * OpenSSL project's "OpenSSL" library (or with modified versions of it
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 * that use the same license as the "OpenSSL" library), and distribute
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16 * the linked executables. You must obey the GNU General Public License
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17 * in all respects for all of the code used other than "OpenSSL". If you
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18 * modify file(s) with this exception, you may extend this exception to
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
19 * your version of the file(s), but you are not obligated to do so. If
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20 * you do not wish to do so, delete this exception statement from your
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21 * version. If you delete this exception statement from all source files
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22 * in the program, then also delete it here.
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23 *
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24 * This program is distributed in the hope that it will be useful, but
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25 * WITHOUT ANY WARRANTY; without even the implied warranty of
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27 * General Public License for more details.
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28 *
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29 * You should have received a copy of the GNU General Public License
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30 * along with this program. If not, see <http://www.gnu.org/licenses/>.
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31 **/
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
33
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
34 #pragma once
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
35
1247
32fcc5dc7562 abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1246
diff changeset
36 #include "IDatabaseWrapper.h"
32fcc5dc7562 abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1246
diff changeset
37
183
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
38 #include "../Core/SQLite/Connection.h"
187
8e673a65564d refactoring of storing new instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 183
diff changeset
39 #include "../Core/SQLite/Transaction.h"
1242
58e6a89c3ef4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1241
diff changeset
40
183
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
41 namespace Orthanc
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
42 {
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
43 namespace Internals
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
44 {
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
45 class SignalRemainingAncestor;
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
46 }
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
47
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
48 /**
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
49 * This class manages an instance of the Orthanc SQLite database. It
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
50 * translates low-level requests into SQL statements. Mutual
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
51 * exclusion MUST be implemented at a higher level.
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
52 **/
1247
32fcc5dc7562 abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1246
diff changeset
53 class DatabaseWrapper : public IDatabaseWrapper
183
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
54 {
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
55 private:
1432
0ac74fa21db8 rename IServerIndexListener as IDatabaseListener
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1306
diff changeset
56 IDatabaseListener* listener_;
183
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
57 SQLite::Connection db_;
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
58 Internals::SignalRemainingAncestor* signalRemainingAncestor_;
1615
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1509
diff changeset
59 unsigned int version_;
183
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
60
2773
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2772
diff changeset
61 void GetChangesInternal(std::list<ServerIndexChange>& target,
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2772
diff changeset
62 bool& done,
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2772
diff changeset
63 SQLite::Statement& s,
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2772
diff changeset
64 uint32_t maxResults);
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2772
diff changeset
65
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2772
diff changeset
66 void GetExportedResourcesInternal(std::list<ExportedResource>& target,
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2772
diff changeset
67 bool& done,
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2772
diff changeset
68 SQLite::Statement& s,
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2772
diff changeset
69 uint32_t maxResults);
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2772
diff changeset
70
1286
b4acdb37e43b refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1252
diff changeset
71 void ClearTable(const std::string& tableName);
b4acdb37e43b refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1252
diff changeset
72
183
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
73 public:
1247
32fcc5dc7562 abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1246
diff changeset
74 DatabaseWrapper(const std::string& path);
32fcc5dc7562 abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1246
diff changeset
75
32fcc5dc7562 abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1246
diff changeset
76 DatabaseWrapper();
32fcc5dc7562 abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1246
diff changeset
77
1672
4c5a85c3ff43 sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
78 virtual void Open();
4c5a85c3ff43 sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
79
4c5a85c3ff43 sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
80 virtual void Close()
4c5a85c3ff43 sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
81 {
4c5a85c3ff43 sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
82 db_.Close();
4c5a85c3ff43 sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
83 }
4c5a85c3ff43 sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1671
diff changeset
84
1432
0ac74fa21db8 rename IServerIndexListener as IDatabaseListener
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1306
diff changeset
85 virtual void SetListener(IDatabaseListener& listener);
183
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
86
2772
f3df536e7366 moving the outdated database plugin sample into the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2697
diff changeset
87 virtual bool LookupParent(int64_t& parentId,
f3df536e7366 moving the outdated database plugin sample into the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2697
diff changeset
88 int64_t resourceId);
f3df536e7366 moving the outdated database plugin sample into the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2697
diff changeset
89
f3df536e7366 moving the outdated database plugin sample into the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2697
diff changeset
90 virtual std::string GetPublicId(int64_t resourceId);
f3df536e7366 moving the outdated database plugin sample into the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2697
diff changeset
91
f3df536e7366 moving the outdated database plugin sample into the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2697
diff changeset
92 virtual ResourceType GetResourceType(int64_t resourceId);
f3df536e7366 moving the outdated database plugin sample into the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2697
diff changeset
93
f3df536e7366 moving the outdated database plugin sample into the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2697
diff changeset
94 virtual void DeleteResource(int64_t id);
f3df536e7366 moving the outdated database plugin sample into the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2697
diff changeset
95
f3df536e7366 moving the outdated database plugin sample into the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2697
diff changeset
96 virtual void GetChanges(std::list<ServerIndexChange>& target /*out*/,
f3df536e7366 moving the outdated database plugin sample into the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2697
diff changeset
97 bool& done /*out*/,
f3df536e7366 moving the outdated database plugin sample into the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2697
diff changeset
98 int64_t since,
f3df536e7366 moving the outdated database plugin sample into the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2697
diff changeset
99 uint32_t maxResults);
f3df536e7366 moving the outdated database plugin sample into the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2697
diff changeset
100
f3df536e7366 moving the outdated database plugin sample into the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2697
diff changeset
101 virtual void GetLastChange(std::list<ServerIndexChange>& target /*out*/);
f3df536e7366 moving the outdated database plugin sample into the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2697
diff changeset
102
f3df536e7366 moving the outdated database plugin sample into the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2697
diff changeset
103 virtual SQLite::ITransaction* StartTransaction()
f3df536e7366 moving the outdated database plugin sample into the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2697
diff changeset
104 {
f3df536e7366 moving the outdated database plugin sample into the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2697
diff changeset
105 return new SQLite::Transaction(db_);
f3df536e7366 moving the outdated database plugin sample into the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2697
diff changeset
106 }
f3df536e7366 moving the outdated database plugin sample into the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2697
diff changeset
107
f3df536e7366 moving the outdated database plugin sample into the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2697
diff changeset
108 virtual void FlushToDisk()
f3df536e7366 moving the outdated database plugin sample into the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2697
diff changeset
109 {
f3df536e7366 moving the outdated database plugin sample into the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2697
diff changeset
110 db_.FlushToDisk();
f3df536e7366 moving the outdated database plugin sample into the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2697
diff changeset
111 }
f3df536e7366 moving the outdated database plugin sample into the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2697
diff changeset
112
f3df536e7366 moving the outdated database plugin sample into the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2697
diff changeset
113 virtual bool HasFlushToDisk() const
f3df536e7366 moving the outdated database plugin sample into the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2697
diff changeset
114 {
f3df536e7366 moving the outdated database plugin sample into the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2697
diff changeset
115 return true;
f3df536e7366 moving the outdated database plugin sample into the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2697
diff changeset
116 }
f3df536e7366 moving the outdated database plugin sample into the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2697
diff changeset
117
f3df536e7366 moving the outdated database plugin sample into the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2697
diff changeset
118 virtual void ClearChanges()
f3df536e7366 moving the outdated database plugin sample into the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2697
diff changeset
119 {
f3df536e7366 moving the outdated database plugin sample into the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2697
diff changeset
120 ClearTable("Changes");
f3df536e7366 moving the outdated database plugin sample into the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2697
diff changeset
121 }
f3df536e7366 moving the outdated database plugin sample into the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2697
diff changeset
122
f3df536e7366 moving the outdated database plugin sample into the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2697
diff changeset
123 virtual void ClearExportedResources()
f3df536e7366 moving the outdated database plugin sample into the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2697
diff changeset
124 {
f3df536e7366 moving the outdated database plugin sample into the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2697
diff changeset
125 ClearTable("ExportedResources");
f3df536e7366 moving the outdated database plugin sample into the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2697
diff changeset
126 }
f3df536e7366 moving the outdated database plugin sample into the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2697
diff changeset
127
f3df536e7366 moving the outdated database plugin sample into the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2697
diff changeset
128 virtual void GetAllMetadata(std::map<MetadataType, std::string>& target,
f3df536e7366 moving the outdated database plugin sample into the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2697
diff changeset
129 int64_t id);
f3df536e7366 moving the outdated database plugin sample into the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2697
diff changeset
130
f3df536e7366 moving the outdated database plugin sample into the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2697
diff changeset
131 virtual unsigned int GetDatabaseVersion()
f3df536e7366 moving the outdated database plugin sample into the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2697
diff changeset
132 {
f3df536e7366 moving the outdated database plugin sample into the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2697
diff changeset
133 return version_;
f3df536e7366 moving the outdated database plugin sample into the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2697
diff changeset
134 }
f3df536e7366 moving the outdated database plugin sample into the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2697
diff changeset
135
f3df536e7366 moving the outdated database plugin sample into the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2697
diff changeset
136 virtual void Upgrade(unsigned int targetVersion,
f3df536e7366 moving the outdated database plugin sample into the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2697
diff changeset
137 IStorageArea& storageArea);
f3df536e7366 moving the outdated database plugin sample into the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2697
diff changeset
138
f3df536e7366 moving the outdated database plugin sample into the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2697
diff changeset
139
f3df536e7366 moving the outdated database plugin sample into the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2697
diff changeset
140 /**
f3df536e7366 moving the outdated database plugin sample into the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2697
diff changeset
141 * The methods declared below are for unit testing only!
f3df536e7366 moving the outdated database plugin sample into the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2697
diff changeset
142 **/
f3df536e7366 moving the outdated database plugin sample into the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2697
diff changeset
143
f3df536e7366 moving the outdated database plugin sample into the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2697
diff changeset
144 const char* GetErrorMessage() const
f3df536e7366 moving the outdated database plugin sample into the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2697
diff changeset
145 {
f3df536e7366 moving the outdated database plugin sample into the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2697
diff changeset
146 return db_.GetErrorMessage();
f3df536e7366 moving the outdated database plugin sample into the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2697
diff changeset
147 }
f3df536e7366 moving the outdated database plugin sample into the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2697
diff changeset
148
f3df536e7366 moving the outdated database plugin sample into the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2697
diff changeset
149 void GetChildren(std::list<std::string>& childrenPublicIds,
f3df536e7366 moving the outdated database plugin sample into the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2697
diff changeset
150 int64_t id);
f3df536e7366 moving the outdated database plugin sample into the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2697
diff changeset
151
f3df536e7366 moving the outdated database plugin sample into the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2697
diff changeset
152 int64_t GetTableRecordCount(const std::string& table);
f3df536e7366 moving the outdated database plugin sample into the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2697
diff changeset
153
f3df536e7366 moving the outdated database plugin sample into the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2697
diff changeset
154 bool GetParentPublicId(std::string& target,
f3df536e7366 moving the outdated database plugin sample into the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2697
diff changeset
155 int64_t id);
f3df536e7366 moving the outdated database plugin sample into the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2697
diff changeset
156
f3df536e7366 moving the outdated database plugin sample into the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2697
diff changeset
157
f3df536e7366 moving the outdated database plugin sample into the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2697
diff changeset
158
f3df536e7366 moving the outdated database plugin sample into the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2697
diff changeset
159 /**
f3df536e7366 moving the outdated database plugin sample into the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2697
diff changeset
160 * Until Orthanc 1.4.0, the methods below were part of the
f3df536e7366 moving the outdated database plugin sample into the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2697
diff changeset
161 * "DatabaseWrapperBase" class, that is now placed in the
f3df536e7366 moving the outdated database plugin sample into the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2697
diff changeset
162 * graveyard.
f3df536e7366 moving the outdated database plugin sample into the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2697
diff changeset
163 **/
f3df536e7366 moving the outdated database plugin sample into the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2697
diff changeset
164
1247
32fcc5dc7562 abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1246
diff changeset
165 virtual void SetGlobalProperty(GlobalProperty property,
2773
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2772
diff changeset
166 const std::string& value);
183
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
167
1247
32fcc5dc7562 abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1246
diff changeset
168 virtual bool LookupGlobalProperty(std::string& target,
2773
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2772
diff changeset
169 GlobalProperty property);
1247
32fcc5dc7562 abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1246
diff changeset
170
32fcc5dc7562 abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1246
diff changeset
171 virtual int64_t CreateResource(const std::string& publicId,
2773
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2772
diff changeset
172 ResourceType type);
183
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
173
1294
910478b2d4e4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
174 virtual bool LookupResource(int64_t& id,
910478b2d4e4 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
175 ResourceType& type,
2773
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2772
diff changeset
176 const std::string& publicId);
183
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
177
1247
32fcc5dc7562 abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1246
diff changeset
178 virtual void AttachChild(int64_t parent,
2773
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2772
diff changeset
179 int64_t child);
304
4eea080e6e7a refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 268
diff changeset
180
1247
32fcc5dc7562 abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1246
diff changeset
181 virtual void SetMetadata(int64_t id,
32fcc5dc7562 abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1246
diff changeset
182 MetadataType type,
2773
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2772
diff changeset
183 const std::string& value);
1247
32fcc5dc7562 abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1246
diff changeset
184
32fcc5dc7562 abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1246
diff changeset
185 virtual void DeleteMetadata(int64_t id,
2773
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2772
diff changeset
186 MetadataType type);
183
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
187
1247
32fcc5dc7562 abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1246
diff changeset
188 virtual bool LookupMetadata(std::string& target,
32fcc5dc7562 abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1246
diff changeset
189 int64_t id,
2773
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2772
diff changeset
190 MetadataType type);
183
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
191
1247
32fcc5dc7562 abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1246
diff changeset
192 virtual void ListAvailableMetadata(std::list<MetadataType>& target,
2773
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2772
diff changeset
193 int64_t id);
438
7bbe77cb9e12 DELETE metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 436
diff changeset
194
1247
32fcc5dc7562 abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1246
diff changeset
195 virtual void AddAttachment(int64_t id,
2773
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2772
diff changeset
196 const FileInfo& attachment);
183
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
197
1247
32fcc5dc7562 abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1246
diff changeset
198 virtual void DeleteAttachment(int64_t id,
2773
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2772
diff changeset
199 FileContentType attachment);
1247
32fcc5dc7562 abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1246
diff changeset
200
1301
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1294
diff changeset
201 virtual void ListAvailableAttachments(std::list<FileContentType>& target,
2773
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2772
diff changeset
202 int64_t id);
436
d51186bf7602 read access to metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 413
diff changeset
203
1247
32fcc5dc7562 abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1246
diff changeset
204 virtual bool LookupAttachment(FileInfo& attachment,
32fcc5dc7562 abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1246
diff changeset
205 int64_t id,
2773
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2772
diff changeset
206 FileContentType contentType);
183
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
207
2773
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2772
diff changeset
208 virtual void ClearMainDicomTags(int64_t id);
1668
de1413733c97 reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1664
diff changeset
209
1286
b4acdb37e43b refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1252
diff changeset
210 virtual void SetMainDicomTag(int64_t id,
b4acdb37e43b refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1252
diff changeset
211 const DicomTag& tag,
2773
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2772
diff changeset
212 const std::string& value);
699
2929e17f8447 add attachments to resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 689
diff changeset
213
1713
4db9200c7f46 SetIdentifierTag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1711
diff changeset
214 virtual void SetIdentifierTag(int64_t id,
2773
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2772
diff changeset
215 const DicomTag& tag,
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2772
diff changeset
216 const std::string& value);
1713
4db9200c7f46 SetIdentifierTag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1711
diff changeset
217
1247
32fcc5dc7562 abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1246
diff changeset
218 virtual void GetMainDicomTags(DicomMap& map,
2773
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2772
diff changeset
219 int64_t id);
440
23e5b35e3c5c statistics for patient/studies/series/instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 438
diff changeset
220
1301
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1294
diff changeset
221 virtual void GetChildrenPublicId(std::list<std::string>& target,
2773
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2772
diff changeset
222 int64_t id);
200
9c58b2b03cf0 refactoring of read operations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 199
diff changeset
223
1301
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1294
diff changeset
224 virtual void GetChildrenInternalId(std::list<int64_t>& target,
2773
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2772
diff changeset
225 int64_t id);
183
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
226
1247
32fcc5dc7562 abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1246
diff changeset
227 virtual void LogChange(int64_t internalId,
2773
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2772
diff changeset
228 const ServerIndexChange& change);
183
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
229
2773
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2772
diff changeset
230 virtual void LogExportedResource(const ExportedResource& resource);
183
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
231
1247
32fcc5dc7562 abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1246
diff changeset
232 virtual void GetExportedResources(std::list<ExportedResource>& target /*out*/,
32fcc5dc7562 abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1246
diff changeset
233 bool& done /*out*/,
32fcc5dc7562 abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1246
diff changeset
234 int64_t since,
2773
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2772
diff changeset
235 uint32_t maxResults);
237
16a4ac70bd8a last change and export
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 233
diff changeset
236
2773
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2772
diff changeset
237 virtual void GetLastExportedResource(std::list<ExportedResource>& target /*out*/);
183
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
238
2773
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2772
diff changeset
239 virtual uint64_t GetTotalCompressedSize();
1247
32fcc5dc7562 abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1246
diff changeset
240
2773
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2772
diff changeset
241 virtual uint64_t GetTotalUncompressedSize();
238
e4148b0ab1d0 statistics URI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 237
diff changeset
242
2773
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2772
diff changeset
243 virtual uint64_t GetResourceCount(ResourceType resourceType);
190
b6cef9d45cc3 getallpublicids
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 189
diff changeset
244
1750
55d52567bebb LookupResource implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1746
diff changeset
245 virtual void GetAllInternalIds(std::list<int64_t>& target,
2773
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2772
diff changeset
246 ResourceType resourceType);
1750
55d52567bebb LookupResource implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1746
diff changeset
247
1247
32fcc5dc7562 abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1246
diff changeset
248 virtual void GetAllPublicIds(std::list<std::string>& target,
2773
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2772
diff changeset
249 ResourceType resourceType);
262
2354560daf2f primitives for recycling patients
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 238
diff changeset
250
1509
0586ed8897f1 limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1432
diff changeset
251 virtual void GetAllPublicIds(std::list<std::string>& target,
0586ed8897f1 limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1432
diff changeset
252 ResourceType resourceType,
0586ed8897f1 limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1432
diff changeset
253 size_t since,
2773
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2772
diff changeset
254 size_t limit);
1509
0586ed8897f1 limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1432
diff changeset
255
2773
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2772
diff changeset
256 virtual bool SelectPatientToRecycle(int64_t& internalId);
262
2354560daf2f primitives for recycling patients
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 238
diff changeset
257
1247
32fcc5dc7562 abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1246
diff changeset
258 virtual bool SelectPatientToRecycle(int64_t& internalId,
2773
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2772
diff changeset
259 int64_t patientIdToAvoid);
1247
32fcc5dc7562 abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1246
diff changeset
260
2773
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2772
diff changeset
261 virtual bool IsProtectedPatient(int64_t internalId);
262
2354560daf2f primitives for recycling patients
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 238
diff changeset
262
1247
32fcc5dc7562 abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1246
diff changeset
263 virtual void SetProtectedPatient(int64_t internalId,
2773
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2772
diff changeset
264 bool isProtected);
183
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
265
2773
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2772
diff changeset
266 virtual bool IsExistingResource(int64_t internalId);
521
2c739f76d0bb lookup tag values
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 513
diff changeset
267
1746
d143db00a794 SetOfResources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1745
diff changeset
268 virtual void LookupIdentifier(std::list<int64_t>& result,
d143db00a794 SetOfResources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1745
diff changeset
269 ResourceType level,
d143db00a794 SetOfResources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1745
diff changeset
270 const DicomTag& tag,
d143db00a794 SetOfResources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1745
diff changeset
271 IdentifierConstraintType type,
2773
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2772
diff changeset
272 const std::string& value);
2697
e583478e0c6c New primitive in database SDK: "lookupIdentifierRange" to speed up range searches
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
273
e583478e0c6c New primitive in database SDK: "lookupIdentifierRange" to speed up range searches
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
274 virtual void LookupIdentifierRange(std::list<int64_t>& result,
e583478e0c6c New primitive in database SDK: "lookupIdentifierRange" to speed up range searches
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
275 ResourceType level,
e583478e0c6c New primitive in database SDK: "lookupIdentifierRange" to speed up range searches
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
276 const DicomTag& tag,
e583478e0c6c New primitive in database SDK: "lookupIdentifierRange" to speed up range searches
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
277 const std::string& start,
2773
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2772
diff changeset
278 const std::string& end);
183
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
279 };
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
280 }