annotate OrthancServer/DatabaseWrapper.cpp @ 3028:ff65c925f57a

fix indentation
author am@osimis.io
date Tue, 18 Dec 2018 14:37:53 +0100
parents bbfd95a0c429
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: 1847
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
831
84513f2ee1f3 pch for unit tests and server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 824
diff changeset
34 #include "PrecompiledHeadersServer.h"
183
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
35 #include "DatabaseWrapper.h"
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
36
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
37 #include "../Core/DicomFormat/DicomArray.h"
1486
f967bdf8534e refactoring to Logging.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1432
diff changeset
38 #include "../Core/Logging.h"
183
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
39 #include "EmbeddedResources.h"
1669
a412ad57f0f9 refactoring of sample plugins, OrthancPluginReconstructMainDicomTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
40 #include "ServerToolbox.h"
183
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
41
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
42 #include <stdio.h>
1247
32fcc5dc7562 abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1246
diff changeset
43 #include <boost/lexical_cast.hpp>
183
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
44
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
45 namespace Orthanc
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
46 {
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
47 namespace Internals
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
48 {
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
49 class SignalFileDeleted : public SQLite::IScalarFunction
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
50 {
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
51 private:
1432
0ac74fa21db8 rename IServerIndexListener as IDatabaseListener
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1407
diff changeset
52 IDatabaseListener& listener_;
183
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
53
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
54 public:
1432
0ac74fa21db8 rename IServerIndexListener as IDatabaseListener
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1407
diff changeset
55 SignalFileDeleted(IDatabaseListener& listener) :
183
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
56 listener_(listener)
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
57 {
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
58 }
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
59
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
60 virtual const char* GetName() const
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
61 {
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
62 return "SignalFileDeleted";
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
63 }
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
64
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
65 virtual unsigned int GetCardinality() const
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
66 {
693
01d8611c4a60 md5 for attached files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 689
diff changeset
67 return 7;
183
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
68 }
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
69
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
70 virtual void Compute(SQLite::FunctionContext& context)
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
71 {
694
72dc919a028c upgrade database from v3 to v4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 693
diff changeset
72 std::string uncompressedMD5, compressedMD5;
72dc919a028c upgrade database from v3 to v4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 693
diff changeset
73
72dc919a028c upgrade database from v3 to v4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 693
diff changeset
74 if (!context.IsNullValue(5))
72dc919a028c upgrade database from v3 to v4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 693
diff changeset
75 {
72dc919a028c upgrade database from v3 to v4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 693
diff changeset
76 uncompressedMD5 = context.GetStringValue(5);
72dc919a028c upgrade database from v3 to v4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 693
diff changeset
77 }
72dc919a028c upgrade database from v3 to v4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 693
diff changeset
78
72dc919a028c upgrade database from v3 to v4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 693
diff changeset
79 if (!context.IsNullValue(6))
72dc919a028c upgrade database from v3 to v4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 693
diff changeset
80 {
72dc919a028c upgrade database from v3 to v4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 693
diff changeset
81 compressedMD5 = context.GetStringValue(6);
72dc919a028c upgrade database from v3 to v4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 693
diff changeset
82 }
72dc919a028c upgrade database from v3 to v4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 693
diff changeset
83
273
d384af918264 more detailed signal about deleted file
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 268
diff changeset
84 FileInfo info(context.GetStringValue(0),
d384af918264 more detailed signal about deleted file
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 268
diff changeset
85 static_cast<FileContentType>(context.GetIntValue(1)),
d384af918264 more detailed signal about deleted file
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 268
diff changeset
86 static_cast<uint64_t>(context.GetInt64Value(2)),
694
72dc919a028c upgrade database from v3 to v4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 693
diff changeset
87 uncompressedMD5,
273
d384af918264 more detailed signal about deleted file
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 268
diff changeset
88 static_cast<CompressionType>(context.GetIntValue(3)),
693
01d8611c4a60 md5 for attached files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 689
diff changeset
89 static_cast<uint64_t>(context.GetInt64Value(4)),
694
72dc919a028c upgrade database from v3 to v4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 693
diff changeset
90 compressedMD5);
273
d384af918264 more detailed signal about deleted file
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 268
diff changeset
91
d384af918264 more detailed signal about deleted file
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 268
diff changeset
92 listener_.SignalFileDeleted(info);
183
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
93 }
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
94 };
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
95
1158
badc14fee61f speed up db
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1006
diff changeset
96 class SignalResourceDeleted : public SQLite::IScalarFunction
badc14fee61f speed up db
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1006
diff changeset
97 {
badc14fee61f speed up db
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1006
diff changeset
98 private:
1432
0ac74fa21db8 rename IServerIndexListener as IDatabaseListener
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1407
diff changeset
99 IDatabaseListener& listener_;
1158
badc14fee61f speed up db
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1006
diff changeset
100
badc14fee61f speed up db
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1006
diff changeset
101 public:
1432
0ac74fa21db8 rename IServerIndexListener as IDatabaseListener
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1407
diff changeset
102 SignalResourceDeleted(IDatabaseListener& listener) :
1158
badc14fee61f speed up db
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1006
diff changeset
103 listener_(listener)
badc14fee61f speed up db
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1006
diff changeset
104 {
badc14fee61f speed up db
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1006
diff changeset
105 }
badc14fee61f speed up db
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1006
diff changeset
106
badc14fee61f speed up db
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1006
diff changeset
107 virtual const char* GetName() const
badc14fee61f speed up db
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1006
diff changeset
108 {
badc14fee61f speed up db
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1006
diff changeset
109 return "SignalResourceDeleted";
badc14fee61f speed up db
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1006
diff changeset
110 }
badc14fee61f speed up db
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1006
diff changeset
111
badc14fee61f speed up db
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1006
diff changeset
112 virtual unsigned int GetCardinality() const
badc14fee61f speed up db
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1006
diff changeset
113 {
badc14fee61f speed up db
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1006
diff changeset
114 return 2;
badc14fee61f speed up db
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1006
diff changeset
115 }
badc14fee61f speed up db
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1006
diff changeset
116
badc14fee61f speed up db
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1006
diff changeset
117 virtual void Compute(SQLite::FunctionContext& context)
badc14fee61f speed up db
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1006
diff changeset
118 {
badc14fee61f speed up db
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1006
diff changeset
119 ResourceType type = static_cast<ResourceType>(context.GetIntValue(1));
1198
1169528a9a5f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1189
diff changeset
120 ServerIndexChange change(ChangeType_Deleted, type, context.GetStringValue(0));
1169528a9a5f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1189
diff changeset
121 listener_.SignalChange(change);
1158
badc14fee61f speed up db
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1006
diff changeset
122 }
badc14fee61f speed up db
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1006
diff changeset
123 };
badc14fee61f speed up db
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1006
diff changeset
124
183
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
125 class SignalRemainingAncestor : public SQLite::IScalarFunction
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
126 {
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
127 private:
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
128 bool hasRemainingAncestor_;
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
129 std::string remainingPublicId_;
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
130 ResourceType remainingType_;
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
131
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
132 public:
660
f0232774b913 fix warnings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 616
diff changeset
133 SignalRemainingAncestor() :
f0232774b913 fix warnings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 616
diff changeset
134 hasRemainingAncestor_(false)
f0232774b913 fix warnings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 616
diff changeset
135 {
f0232774b913 fix warnings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 616
diff changeset
136 }
f0232774b913 fix warnings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 616
diff changeset
137
183
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
138 void Reset()
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
139 {
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
140 hasRemainingAncestor_ = false;
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
141 }
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
142
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
143 virtual const char* GetName() const
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
144 {
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
145 return "SignalRemainingAncestor";
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
146 }
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
147
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
148 virtual unsigned int GetCardinality() const
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
149 {
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
150 return 2;
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
151 }
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
152
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
153 virtual void Compute(SQLite::FunctionContext& context)
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
154 {
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
155 VLOG(1) << "There exists a remaining ancestor with public ID \""
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
156 << context.GetStringValue(0)
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
157 << "\" of type "
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
158 << context.GetIntValue(1);
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
159
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
160 if (!hasRemainingAncestor_ ||
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
161 remainingType_ >= context.GetIntValue(1))
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
162 {
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
163 hasRemainingAncestor_ = true;
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
164 remainingPublicId_ = context.GetStringValue(0);
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
165 remainingType_ = static_cast<ResourceType>(context.GetIntValue(1));
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
166 }
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
167 }
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
168
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
169 bool HasRemainingAncestor() const
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
170 {
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
171 return hasRemainingAncestor_;
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
172 }
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
173
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
174 const std::string& GetRemainingAncestorId() const
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
175 {
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
176 assert(hasRemainingAncestor_);
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
177 return remainingPublicId_;
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
178 }
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
179
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
180 ResourceType GetRemainingAncestorType() const
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
181 {
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
182 assert(hasRemainingAncestor_);
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
183 return remainingType_;
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
184 }
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
185 };
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
186 }
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
187
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
188
2773
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
189 void DatabaseWrapper::GetChangesInternal(std::list<ServerIndexChange>& target,
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
190 bool& done,
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
191 SQLite::Statement& s,
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
192 uint32_t maxResults)
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
193 {
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
194 target.clear();
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
195
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
196 while (target.size() < maxResults && s.Step())
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
197 {
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
198 int64_t seq = s.ColumnInt64(0);
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
199 ChangeType changeType = static_cast<ChangeType>(s.ColumnInt(1));
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
200 ResourceType resourceType = static_cast<ResourceType>(s.ColumnInt(3));
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
201 const std::string& date = s.ColumnString(4);
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
202
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
203 int64_t internalId = s.ColumnInt64(2);
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
204 std::string publicId = GetPublicId(internalId);
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
205
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
206 target.push_back(ServerIndexChange(seq, changeType, resourceType, publicId, date));
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
207 }
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
208
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
209 done = !(target.size() == maxResults && s.Step());
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
210 }
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
211
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
212
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
213 void DatabaseWrapper::GetExportedResourcesInternal(std::list<ExportedResource>& target,
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
214 bool& done,
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
215 SQLite::Statement& s,
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
216 uint32_t maxResults)
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
217 {
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
218 target.clear();
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
219
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
220 while (target.size() < maxResults && s.Step())
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
221 {
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
222 int64_t seq = s.ColumnInt64(0);
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
223 ResourceType resourceType = static_cast<ResourceType>(s.ColumnInt(1));
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
224 std::string publicId = s.ColumnString(2);
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
225
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
226 ExportedResource resource(seq,
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
227 resourceType,
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
228 publicId,
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
229 s.ColumnString(3), // modality
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
230 s.ColumnString(8), // date
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
231 s.ColumnString(4), // patient ID
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
232 s.ColumnString(5), // study instance UID
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
233 s.ColumnString(6), // series instance UID
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
234 s.ColumnString(7)); // sop instance UID
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
235
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
236 target.push_back(resource);
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
237 }
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
238
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
239 done = !(target.size() == maxResults && s.Step());
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
240 }
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
241
1241
90d2f320862d refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1240
diff changeset
242
90d2f320862d refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1240
diff changeset
243 void DatabaseWrapper::GetChildren(std::list<std::string>& childrenPublicIds,
193
a1b9d1e1497b failed attempt to compile with linux standard base
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 192
diff changeset
244 int64_t id)
a1b9d1e1497b failed attempt to compile with linux standard base
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 192
diff changeset
245 {
a1b9d1e1497b failed attempt to compile with linux standard base
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 192
diff changeset
246 SQLite::Statement s(db_, SQLITE_FROM_HERE, "SELECT publicId FROM Resources WHERE parentId=?");
585
b2357f1f026f fix types
jodogne
parents: 521
diff changeset
247 s.BindInt64(0, id);
193
a1b9d1e1497b failed attempt to compile with linux standard base
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 192
diff changeset
248
1241
90d2f320862d refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1240
diff changeset
249 childrenPublicIds.clear();
193
a1b9d1e1497b failed attempt to compile with linux standard base
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 192
diff changeset
250 while (s.Step())
a1b9d1e1497b failed attempt to compile with linux standard base
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 192
diff changeset
251 {
1241
90d2f320862d refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1240
diff changeset
252 childrenPublicIds.push_back(s.ColumnString(0));
193
a1b9d1e1497b failed attempt to compile with linux standard base
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 192
diff changeset
253 }
a1b9d1e1497b failed attempt to compile with linux standard base
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 192
diff changeset
254 }
a1b9d1e1497b failed attempt to compile with linux standard base
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 192
diff changeset
255
a1b9d1e1497b failed attempt to compile with linux standard base
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 192
diff changeset
256
183
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
257 void DatabaseWrapper::DeleteResource(int64_t id)
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
258 {
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
259 signalRemainingAncestor_->Reset();
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
260
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
261 SQLite::Statement s(db_, SQLITE_FROM_HERE, "DELETE FROM Resources WHERE internalId=?");
585
b2357f1f026f fix types
jodogne
parents: 521
diff changeset
262 s.BindInt64(0, id);
183
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
263 s.Run();
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
264
1247
32fcc5dc7562 abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1246
diff changeset
265 if (signalRemainingAncestor_->HasRemainingAncestor() &&
32fcc5dc7562 abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1246
diff changeset
266 listener_ != NULL)
183
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
267 {
1247
32fcc5dc7562 abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1246
diff changeset
268 listener_->SignalRemainingAncestor(signalRemainingAncestor_->GetRemainingAncestorType(),
32fcc5dc7562 abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1246
diff changeset
269 signalRemainingAncestor_->GetRemainingAncestorId());
183
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
270 }
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
271 }
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
272
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
273
1301
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1300
diff changeset
274 bool DatabaseWrapper::GetParentPublicId(std::string& target,
183
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
275 int64_t id)
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
276 {
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
277 SQLite::Statement s(db_, SQLITE_FROM_HERE, "SELECT a.publicId FROM Resources AS a, Resources AS b "
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
278 "WHERE a.internalId = b.parentId AND b.internalId = ?");
585
b2357f1f026f fix types
jodogne
parents: 521
diff changeset
279 s.BindInt64(0, id);
183
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
280
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
281 if (s.Step())
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
282 {
1301
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1300
diff changeset
283 target = s.ColumnString(0);
183
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
284 return true;
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
285 }
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
286 else
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
287 {
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
288 return false;
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
289 }
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
290 }
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
291
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
292
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
293 int64_t DatabaseWrapper::GetTableRecordCount(const std::string& table)
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
294 {
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
295 char buf[128];
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
296 sprintf(buf, "SELECT COUNT(*) FROM %s", table.c_str());
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
297 SQLite::Statement s(db_, buf);
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
298
218
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 206
diff changeset
299 if (!s.Step())
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 206
diff changeset
300 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 206
diff changeset
301 throw OrthancException(ErrorCode_InternalError);
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 206
diff changeset
302 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 206
diff changeset
303
183
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
304 int64_t c = s.ColumnInt(0);
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
305 assert(!s.Step());
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
306
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
307 return c;
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
308 }
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
309
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
310
1847
559956d5ceb2 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1729
diff changeset
311 DatabaseWrapper::DatabaseWrapper(const std::string& path) :
559956d5ceb2 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1729
diff changeset
312 listener_(NULL),
559956d5ceb2 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1729
diff changeset
313 signalRemainingAncestor_(NULL),
559956d5ceb2 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1729
diff changeset
314 version_(0)
183
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
315 {
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
316 db_.Open(path);
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
317 }
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
318
2773
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
319
1847
559956d5ceb2 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1729
diff changeset
320 DatabaseWrapper::DatabaseWrapper() :
559956d5ceb2 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1729
diff changeset
321 listener_(NULL),
559956d5ceb2 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1729
diff changeset
322 signalRemainingAncestor_(NULL),
559956d5ceb2 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1729
diff changeset
323 version_(0)
183
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
324 {
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
325 db_.OpenInMemory();
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
326 }
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
327
2773
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
328
183
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
329 void DatabaseWrapper::Open()
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
330 {
1717
3926e6317a43 SetIdentifierTagInternal
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1712
diff changeset
331 db_.Execute("PRAGMA ENCODING=\"UTF-8\";");
3926e6317a43 SetIdentifierTagInternal
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1712
diff changeset
332
374
42e87c17cab8 some refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 310
diff changeset
333 // Performance tuning of SQLite with PRAGMAs
42e87c17cab8 some refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 310
diff changeset
334 // http://www.sqlite.org/pragma.html
42e87c17cab8 some refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 310
diff changeset
335 db_.Execute("PRAGMA SYNCHRONOUS=NORMAL;");
42e87c17cab8 some refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 310
diff changeset
336 db_.Execute("PRAGMA JOURNAL_MODE=WAL;");
42e87c17cab8 some refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 310
diff changeset
337 db_.Execute("PRAGMA LOCKING_MODE=EXCLUSIVE;");
42e87c17cab8 some refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 310
diff changeset
338 db_.Execute("PRAGMA WAL_AUTOCHECKPOINT=1000;");
42e87c17cab8 some refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 310
diff changeset
339 //db_.Execute("PRAGMA TEMP_STORE=memory");
42e87c17cab8 some refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 310
diff changeset
340
183
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
341 if (!db_.DoesTableExist("GlobalProperties"))
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
342 {
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
343 LOG(INFO) << "Creating the database";
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
344 std::string query;
203
9283552c25df db refactoring done
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 200
diff changeset
345 EmbeddedResources::GetFileResource(query, EmbeddedResources::PREPARE_DATABASE);
183
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
346 db_.Execute(query);
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
347 }
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
348
567
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 521
diff changeset
349 // Check the version of the database
1615
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1509
diff changeset
350 std::string tmp;
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1509
diff changeset
351 if (!LookupGlobalProperty(tmp, GlobalProperty_DatabaseSchemaVersion))
1239
92c6b3b57699 cleaning
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1238
diff changeset
352 {
1615
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1509
diff changeset
353 tmp = "Unknown";
1239
92c6b3b57699 cleaning
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1238
diff changeset
354 }
92c6b3b57699 cleaning
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1238
diff changeset
355
252
bd009f0b1931 db version
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 238
diff changeset
356 bool ok = false;
bd009f0b1931 db version
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 238
diff changeset
357 try
bd009f0b1931 db version
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 238
diff changeset
358 {
1615
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1509
diff changeset
359 LOG(INFO) << "Version of the Orthanc database: " << tmp;
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1509
diff changeset
360 version_ = boost::lexical_cast<unsigned int>(tmp);
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1509
diff changeset
361 ok = true;
252
bd009f0b1931 db version
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 238
diff changeset
362 }
bd009f0b1931 db version
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 238
diff changeset
363 catch (boost::bad_lexical_cast&)
bd009f0b1931 db version
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 238
diff changeset
364 {
bd009f0b1931 db version
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 238
diff changeset
365 }
bd009f0b1931 db version
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 238
diff changeset
366
bd009f0b1931 db version
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 238
diff changeset
367 if (!ok)
bd009f0b1931 db version
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 238
diff changeset
368 {
2955
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2773
diff changeset
369 throw OrthancException(ErrorCode_IncompatibleDatabaseVersion,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2773
diff changeset
370 "Incompatible version of the Orthanc database: " + tmp);
252
bd009f0b1931 db version
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 238
diff changeset
371 }
bd009f0b1931 db version
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 238
diff changeset
372
183
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
373 signalRemainingAncestor_ = new Internals::SignalRemainingAncestor;
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
374 db_.Register(signalRemainingAncestor_);
1247
32fcc5dc7562 abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1246
diff changeset
375 }
32fcc5dc7562 abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1246
diff changeset
376
1615
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1509
diff changeset
377
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1509
diff changeset
378 static void ExecuteUpgradeScript(SQLite::Connection& db,
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1509
diff changeset
379 EmbeddedResources::FileResourceId script)
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1509
diff changeset
380 {
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1509
diff changeset
381 std::string upgrade;
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1509
diff changeset
382 EmbeddedResources::GetFileResource(upgrade, script);
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1509
diff changeset
383 db.BeginTransaction();
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1509
diff changeset
384 db.Execute(upgrade);
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1509
diff changeset
385 db.CommitTransaction();
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1509
diff changeset
386 }
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1509
diff changeset
387
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1509
diff changeset
388
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1509
diff changeset
389 void DatabaseWrapper::Upgrade(unsigned int targetVersion,
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1509
diff changeset
390 IStorageArea& storageArea)
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1509
diff changeset
391 {
1664
0c58f189782d prepare migration to db v6
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1615
diff changeset
392 if (targetVersion != 6)
1615
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1509
diff changeset
393 {
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1509
diff changeset
394 throw OrthancException(ErrorCode_IncompatibleDatabaseVersion);
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1509
diff changeset
395 }
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1509
diff changeset
396
1664
0c58f189782d prepare migration to db v6
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1615
diff changeset
397 // This version of Orthanc is only compatible with versions 3, 4,
0c58f189782d prepare migration to db v6
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1615
diff changeset
398 // 5 and 6 of the DB schema
1615
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1509
diff changeset
399 if (version_ != 3 &&
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1509
diff changeset
400 version_ != 4 &&
1664
0c58f189782d prepare migration to db v6
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1615
diff changeset
401 version_ != 5 &&
0c58f189782d prepare migration to db v6
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1615
diff changeset
402 version_ != 6)
1615
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1509
diff changeset
403 {
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1509
diff changeset
404 throw OrthancException(ErrorCode_IncompatibleDatabaseVersion);
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1509
diff changeset
405 }
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1509
diff changeset
406
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1509
diff changeset
407 if (version_ == 3)
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1509
diff changeset
408 {
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1509
diff changeset
409 LOG(WARNING) << "Upgrading database version from 3 to 4";
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1509
diff changeset
410 ExecuteUpgradeScript(db_, EmbeddedResources::UPGRADE_DATABASE_3_TO_4);
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1509
diff changeset
411 version_ = 4;
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1509
diff changeset
412 }
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1509
diff changeset
413
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1509
diff changeset
414 if (version_ == 4)
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1509
diff changeset
415 {
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1509
diff changeset
416 LOG(WARNING) << "Upgrading database version from 4 to 5";
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1509
diff changeset
417 ExecuteUpgradeScript(db_, EmbeddedResources::UPGRADE_DATABASE_4_TO_5);
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1509
diff changeset
418 version_ = 5;
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1509
diff changeset
419 }
1664
0c58f189782d prepare migration to db v6
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1615
diff changeset
420
0c58f189782d prepare migration to db v6
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1615
diff changeset
421 if (version_ == 5)
0c58f189782d prepare migration to db v6
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1615
diff changeset
422 {
0c58f189782d prepare migration to db v6
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1615
diff changeset
423 LOG(WARNING) << "Upgrading database version from 5 to 6";
1668
de1413733c97 reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1665
diff changeset
424 // No change in the DB schema, the step from version 5 to 6 only
1710
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
425 // consists in reconstructing the main DICOM tags information
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
426 // (as more tags got included).
1668
de1413733c97 reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1665
diff changeset
427 db_.BeginTransaction();
2120
4b02ec79728a refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
428 ServerToolbox::ReconstructMainDicomTags(*this, storageArea, ResourceType_Patient);
4b02ec79728a refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
429 ServerToolbox::ReconstructMainDicomTags(*this, storageArea, ResourceType_Study);
4b02ec79728a refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
430 ServerToolbox::ReconstructMainDicomTags(*this, storageArea, ResourceType_Series);
4b02ec79728a refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
431 ServerToolbox::ReconstructMainDicomTags(*this, storageArea, ResourceType_Instance);
1710
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
432 db_.Execute("UPDATE GlobalProperties SET value=\"6\" WHERE property=" +
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
433 boost::lexical_cast<std::string>(GlobalProperty_DatabaseSchemaVersion) + ";");
1668
de1413733c97 reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1665
diff changeset
434 db_.CommitTransaction();
1664
0c58f189782d prepare migration to db v6
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1615
diff changeset
435 version_ = 6;
1729
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1725
diff changeset
436 }
1615
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1509
diff changeset
437 }
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1509
diff changeset
438
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1509
diff changeset
439
1432
0ac74fa21db8 rename IServerIndexListener as IDatabaseListener
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1407
diff changeset
440 void DatabaseWrapper::SetListener(IDatabaseListener& listener)
1247
32fcc5dc7562 abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1246
diff changeset
441 {
32fcc5dc7562 abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1246
diff changeset
442 listener_ = &listener;
32fcc5dc7562 abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1246
diff changeset
443 db_.Register(new Internals::SignalFileDeleted(listener));
32fcc5dc7562 abstraction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1246
diff changeset
444 db_.Register(new Internals::SignalResourceDeleted(listener));
183
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
445 }
238
e4148b0ab1d0 statistics URI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 237
diff changeset
446
413
47d63c941902 clearing /exports and /changes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 399
diff changeset
447
47d63c941902 clearing /exports and /changes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 399
diff changeset
448 void DatabaseWrapper::ClearTable(const std::string& tableName)
47d63c941902 clearing /exports and /changes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 399
diff changeset
449 {
47d63c941902 clearing /exports and /changes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 399
diff changeset
450 db_.Execute("DELETE FROM " + tableName);
47d63c941902 clearing /exports and /changes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 399
diff changeset
451 }
513
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 440
diff changeset
452
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 440
diff changeset
453
1671
2f2e2ec17bc4 sample database plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
454 bool DatabaseWrapper::LookupParent(int64_t& parentId,
2f2e2ec17bc4 sample database plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
455 int64_t resourceId)
2f2e2ec17bc4 sample database plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
456 {
2773
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
457 SQLite::Statement s(db_, SQLITE_FROM_HERE,
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
458 "SELECT parentId FROM Resources WHERE internalId=?");
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
459 s.BindInt64(0, resourceId);
1671
2f2e2ec17bc4 sample database plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
460
2773
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
461 if (!s.Step())
1671
2f2e2ec17bc4 sample database plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
462 {
2773
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
463 throw OrthancException(ErrorCode_UnknownResource);
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
464 }
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
465
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
466 if (s.ColumnIsNull(0))
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
467 {
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
468 return false;
1671
2f2e2ec17bc4 sample database plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
469 }
2f2e2ec17bc4 sample database plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
470 else
2f2e2ec17bc4 sample database plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
471 {
2773
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
472 parentId = s.ColumnInt(0);
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
473 return true;
1671
2f2e2ec17bc4 sample database plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
474 }
2f2e2ec17bc4 sample database plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
475 }
2f2e2ec17bc4 sample database plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
476
2f2e2ec17bc4 sample database plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
477
2f2e2ec17bc4 sample database plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
478 ResourceType DatabaseWrapper::GetResourceType(int64_t resourceId)
2f2e2ec17bc4 sample database plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
479 {
2773
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
480 SQLite::Statement s(db_, SQLITE_FROM_HERE,
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
481 "SELECT resourceType FROM Resources WHERE internalId=?");
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
482 s.BindInt64(0, resourceId);
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
483
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
484 if (s.Step())
1671
2f2e2ec17bc4 sample database plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
485 {
2773
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
486 return static_cast<ResourceType>(s.ColumnInt(0));
1671
2f2e2ec17bc4 sample database plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
487 }
2f2e2ec17bc4 sample database plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
488 else
2773
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
489 {
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
490 throw OrthancException(ErrorCode_UnknownResource);
1671
2f2e2ec17bc4 sample database plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
491 }
2f2e2ec17bc4 sample database plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
492 }
2f2e2ec17bc4 sample database plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
493
2f2e2ec17bc4 sample database plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
494
2f2e2ec17bc4 sample database plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
495 std::string DatabaseWrapper::GetPublicId(int64_t resourceId)
2f2e2ec17bc4 sample database plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
496 {
2773
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
497 SQLite::Statement s(db_, SQLITE_FROM_HERE,
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
498 "SELECT publicId FROM Resources WHERE internalId=?");
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
499 s.BindInt64(0, resourceId);
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
500
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
501 if (s.Step())
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
502 {
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
503 return s.ColumnString(0);
1671
2f2e2ec17bc4 sample database plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
504 }
2f2e2ec17bc4 sample database plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
505 else
2f2e2ec17bc4 sample database plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
506 {
2f2e2ec17bc4 sample database plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
507 throw OrthancException(ErrorCode_UnknownResource);
2f2e2ec17bc4 sample database plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
508 }
2f2e2ec17bc4 sample database plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
509 }
2f2e2ec17bc4 sample database plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
510
2f2e2ec17bc4 sample database plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
511
2f2e2ec17bc4 sample database plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
512 void DatabaseWrapper::GetChanges(std::list<ServerIndexChange>& target /*out*/,
2f2e2ec17bc4 sample database plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
513 bool& done /*out*/,
2f2e2ec17bc4 sample database plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
514 int64_t since,
2f2e2ec17bc4 sample database plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
515 uint32_t maxResults)
2f2e2ec17bc4 sample database plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
516 {
2773
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
517 SQLite::Statement s(db_, SQLITE_FROM_HERE, "SELECT * FROM Changes WHERE seq>? ORDER BY seq LIMIT ?");
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
518 s.BindInt64(0, since);
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
519 s.BindInt(1, maxResults + 1);
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
520 GetChangesInternal(target, done, s, maxResults);
1671
2f2e2ec17bc4 sample database plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
521 }
2f2e2ec17bc4 sample database plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
522
2f2e2ec17bc4 sample database plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
523
2f2e2ec17bc4 sample database plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
524 void DatabaseWrapper::GetLastChange(std::list<ServerIndexChange>& target /*out*/)
2f2e2ec17bc4 sample database plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
525 {
2773
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
526 bool done; // Ignored
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
527 SQLite::Statement s(db_, SQLITE_FROM_HERE, "SELECT * FROM Changes ORDER BY seq DESC LIMIT 1");
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
528 GetChangesInternal(target, done, s, 1);
1671
2f2e2ec17bc4 sample database plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
529 }
2f2e2ec17bc4 sample database plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
530
2f2e2ec17bc4 sample database plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1670
diff changeset
531
1301
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1300
diff changeset
532 void DatabaseWrapper::GetAllMetadata(std::map<MetadataType, std::string>& target,
1006
649d47854314 proper handling of metadata in Store
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
533 int64_t id)
649d47854314 proper handling of metadata in Store
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
534 {
1301
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1300
diff changeset
535 target.clear();
1006
649d47854314 proper handling of metadata in Store
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
536
649d47854314 proper handling of metadata in Store
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
537 SQLite::Statement s(db_, SQLITE_FROM_HERE, "SELECT type, value FROM Metadata WHERE id=?");
649d47854314 proper handling of metadata in Store
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
538 s.BindInt64(0, id);
649d47854314 proper handling of metadata in Store
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
539
649d47854314 proper handling of metadata in Store
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
540 while (s.Step())
649d47854314 proper handling of metadata in Store
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
541 {
649d47854314 proper handling of metadata in Store
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
542 MetadataType key = static_cast<MetadataType>(s.ColumnInt(0));
1301
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1300
diff changeset
543 target[key] = s.ColumnString(1);
1006
649d47854314 proper handling of metadata in Store
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
544 }
649d47854314 proper handling of metadata in Store
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
545 }
649d47854314 proper handling of metadata in Store
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
546
2773
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
547
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
548 void DatabaseWrapper::SetGlobalProperty(GlobalProperty property,
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
549 const std::string& value)
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
550 {
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
551 SQLite::Statement s(db_, SQLITE_FROM_HERE, "INSERT OR REPLACE INTO GlobalProperties VALUES(?, ?)");
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
552 s.BindInt(0, property);
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
553 s.BindString(1, value);
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
554 s.Run();
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
555 }
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
556
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
557
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
558 bool DatabaseWrapper::LookupGlobalProperty(std::string& target,
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
559 GlobalProperty property)
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
560 {
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
561 SQLite::Statement s(db_, SQLITE_FROM_HERE,
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
562 "SELECT value FROM GlobalProperties WHERE property=?");
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
563 s.BindInt(0, property);
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
564
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
565 if (!s.Step())
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
566 {
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
567 return false;
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
568 }
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
569 else
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
570 {
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
571 target = s.ColumnString(0);
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
572 return true;
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
573 }
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
574 }
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
575
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
576
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
577 int64_t DatabaseWrapper::CreateResource(const std::string& publicId,
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
578 ResourceType type)
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
579 {
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
580 SQLite::Statement s(db_, SQLITE_FROM_HERE, "INSERT INTO Resources VALUES(NULL, ?, ?, NULL)");
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
581 s.BindInt(0, type);
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
582 s.BindString(1, publicId);
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
583 s.Run();
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
584 return db_.GetLastInsertRowId();
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
585 }
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
586
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
587
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
588 bool DatabaseWrapper::LookupResource(int64_t& id,
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
589 ResourceType& type,
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
590 const std::string& publicId)
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
591 {
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
592 SQLite::Statement s(db_, SQLITE_FROM_HERE,
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
593 "SELECT internalId, resourceType FROM Resources WHERE publicId=?");
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
594 s.BindString(0, publicId);
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
595
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
596 if (!s.Step())
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
597 {
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
598 return false;
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
599 }
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
600 else
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
601 {
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
602 id = s.ColumnInt(0);
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
603 type = static_cast<ResourceType>(s.ColumnInt(1));
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
604
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
605 // Check whether there is a single resource with this public id
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
606 assert(!s.Step());
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
607
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
608 return true;
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
609 }
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
610 }
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
611
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
612
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
613 void DatabaseWrapper::AttachChild(int64_t parent,
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
614 int64_t child)
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
615 {
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
616 SQLite::Statement s(db_, SQLITE_FROM_HERE, "UPDATE Resources SET parentId = ? WHERE internalId = ?");
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
617 s.BindInt64(0, parent);
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
618 s.BindInt64(1, child);
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
619 s.Run();
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
620 }
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
621
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
622
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
623 void DatabaseWrapper::SetMetadata(int64_t id,
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
624 MetadataType type,
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
625 const std::string& value)
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
626 {
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
627 SQLite::Statement s(db_, SQLITE_FROM_HERE, "INSERT OR REPLACE INTO Metadata VALUES(?, ?, ?)");
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
628 s.BindInt64(0, id);
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
629 s.BindInt(1, type);
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
630 s.BindString(2, value);
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
631 s.Run();
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
632 }
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
633
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
634
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
635 void DatabaseWrapper::DeleteMetadata(int64_t id,
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
636 MetadataType type)
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
637 {
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
638 SQLite::Statement s(db_, SQLITE_FROM_HERE, "DELETE FROM Metadata WHERE id=? and type=?");
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
639 s.BindInt64(0, id);
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
640 s.BindInt(1, type);
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
641 s.Run();
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
642 }
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
643
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
644
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
645 bool DatabaseWrapper::LookupMetadata(std::string& target,
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
646 int64_t id,
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
647 MetadataType type)
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
648 {
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
649 SQLite::Statement s(db_, SQLITE_FROM_HERE,
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
650 "SELECT value FROM Metadata WHERE id=? AND type=?");
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
651 s.BindInt64(0, id);
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
652 s.BindInt(1, type);
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
653
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
654 if (!s.Step())
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
655 {
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
656 return false;
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
657 }
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
658 else
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
659 {
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
660 target = s.ColumnString(0);
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
661 return true;
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
662 }
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
663 }
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
664
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
665
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
666 void DatabaseWrapper::ListAvailableMetadata(std::list<MetadataType>& target,
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
667 int64_t id)
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
668 {
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
669 target.clear();
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
670
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
671 SQLite::Statement s(db_, SQLITE_FROM_HERE, "SELECT type FROM Metadata WHERE id=?");
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
672 s.BindInt64(0, id);
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
673
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
674 while (s.Step())
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
675 {
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
676 target.push_back(static_cast<MetadataType>(s.ColumnInt(0)));
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
677 }
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
678 }
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
679
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
680
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
681 void DatabaseWrapper::AddAttachment(int64_t id,
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
682 const FileInfo& attachment)
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
683 {
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
684 SQLite::Statement s(db_, SQLITE_FROM_HERE, "INSERT INTO AttachedFiles VALUES(?, ?, ?, ?, ?, ?, ?, ?)");
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
685 s.BindInt64(0, id);
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
686 s.BindInt(1, attachment.GetContentType());
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
687 s.BindString(2, attachment.GetUuid());
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
688 s.BindInt64(3, attachment.GetCompressedSize());
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
689 s.BindInt64(4, attachment.GetUncompressedSize());
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
690 s.BindInt(5, attachment.GetCompressionType());
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
691 s.BindString(6, attachment.GetUncompressedMD5());
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
692 s.BindString(7, attachment.GetCompressedMD5());
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
693 s.Run();
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
694 }
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
695
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
696
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
697 void DatabaseWrapper::DeleteAttachment(int64_t id,
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
698 FileContentType attachment)
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
699 {
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
700 SQLite::Statement s(db_, SQLITE_FROM_HERE, "DELETE FROM AttachedFiles WHERE id=? AND fileType=?");
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
701 s.BindInt64(0, id);
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
702 s.BindInt(1, attachment);
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
703 s.Run();
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
704 }
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
705
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
706
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
707 void DatabaseWrapper::ListAvailableAttachments(std::list<FileContentType>& target,
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
708 int64_t id)
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
709 {
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
710 target.clear();
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
711
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
712 SQLite::Statement s(db_, SQLITE_FROM_HERE,
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
713 "SELECT fileType FROM AttachedFiles WHERE id=?");
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
714 s.BindInt64(0, id);
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
715
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
716 while (s.Step())
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
717 {
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
718 target.push_back(static_cast<FileContentType>(s.ColumnInt(0)));
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
719 }
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
720 }
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
721
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
722 bool DatabaseWrapper::LookupAttachment(FileInfo& attachment,
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
723 int64_t id,
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
724 FileContentType contentType)
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
725 {
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
726 SQLite::Statement s(db_, SQLITE_FROM_HERE,
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
727 "SELECT uuid, uncompressedSize, compressionType, compressedSize, "
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
728 "uncompressedMD5, compressedMD5 FROM AttachedFiles WHERE id=? AND fileType=?");
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
729 s.BindInt64(0, id);
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
730 s.BindInt(1, contentType);
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
731
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
732 if (!s.Step())
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
733 {
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
734 return false;
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
735 }
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
736 else
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
737 {
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
738 attachment = FileInfo(s.ColumnString(0),
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
739 contentType,
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
740 s.ColumnInt64(1),
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
741 s.ColumnString(4),
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
742 static_cast<CompressionType>(s.ColumnInt(2)),
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
743 s.ColumnInt64(3),
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
744 s.ColumnString(5));
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
745 return true;
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
746 }
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
747 }
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
748
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
749
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
750 void DatabaseWrapper::ClearMainDicomTags(int64_t id)
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
751 {
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
752 {
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
753 SQLite::Statement s(db_, SQLITE_FROM_HERE, "DELETE FROM DicomIdentifiers WHERE id=?");
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
754 s.BindInt64(0, id);
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
755 s.Run();
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
756 }
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
757
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
758 {
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
759 SQLite::Statement s(db_, SQLITE_FROM_HERE, "DELETE FROM MainDicomTags WHERE id=?");
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
760 s.BindInt64(0, id);
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
761 s.Run();
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
762 }
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
763 }
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
764
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
765
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
766 void DatabaseWrapper::SetMainDicomTag(int64_t id,
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
767 const DicomTag& tag,
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
768 const std::string& value)
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
769 {
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
770 SQLite::Statement s(db_, SQLITE_FROM_HERE, "INSERT INTO MainDicomTags VALUES(?, ?, ?, ?)");
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
771 s.BindInt64(0, id);
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
772 s.BindInt(1, tag.GetGroup());
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
773 s.BindInt(2, tag.GetElement());
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
774 s.BindString(3, value);
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
775 s.Run();
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
776 }
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
777
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
778
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
779 void DatabaseWrapper::SetIdentifierTag(int64_t id,
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
780 const DicomTag& tag,
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
781 const std::string& value)
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
782 {
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
783 SQLite::Statement s(db_, SQLITE_FROM_HERE, "INSERT INTO DicomIdentifiers VALUES(?, ?, ?, ?)");
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
784 s.BindInt64(0, id);
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
785 s.BindInt(1, tag.GetGroup());
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
786 s.BindInt(2, tag.GetElement());
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
787 s.BindString(3, value);
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
788 s.Run();
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
789 }
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
790
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
791
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
792 void DatabaseWrapper::GetMainDicomTags(DicomMap& map,
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
793 int64_t id)
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
794 {
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
795 map.Clear();
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
796
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
797 SQLite::Statement s(db_, SQLITE_FROM_HERE, "SELECT * FROM MainDicomTags WHERE id=?");
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
798 s.BindInt64(0, id);
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
799 while (s.Step())
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
800 {
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
801 map.SetValue(s.ColumnInt(1),
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
802 s.ColumnInt(2),
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
803 s.ColumnString(3), false);
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
804 }
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
805 }
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
806
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
807
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
808 void DatabaseWrapper::GetChildrenPublicId(std::list<std::string>& target,
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
809 int64_t id)
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
810 {
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
811 SQLite::Statement s(db_, SQLITE_FROM_HERE, "SELECT a.publicId FROM Resources AS a, Resources AS b "
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
812 "WHERE a.parentId = b.internalId AND b.internalId = ?");
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
813 s.BindInt64(0, id);
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
814
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
815 target.clear();
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
816
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
817 while (s.Step())
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
818 {
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
819 target.push_back(s.ColumnString(0));
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
820 }
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
821 }
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
822
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
823
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
824 void DatabaseWrapper::GetChildrenInternalId(std::list<int64_t>& target,
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
825 int64_t id)
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
826 {
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
827 SQLite::Statement s(db_, SQLITE_FROM_HERE, "SELECT a.internalId FROM Resources AS a, Resources AS b "
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
828 "WHERE a.parentId = b.internalId AND b.internalId = ?");
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
829 s.BindInt64(0, id);
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
830
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
831 target.clear();
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
832
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
833 while (s.Step())
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
834 {
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
835 target.push_back(s.ColumnInt64(0));
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
836 }
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
837 }
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
838
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
839
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
840 void DatabaseWrapper::LogChange(int64_t internalId,
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
841 const ServerIndexChange& change)
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
842 {
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
843 SQLite::Statement s(db_, SQLITE_FROM_HERE, "INSERT INTO Changes VALUES(NULL, ?, ?, ?, ?)");
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
844 s.BindInt(0, change.GetChangeType());
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
845 s.BindInt64(1, internalId);
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
846 s.BindInt(2, change.GetResourceType());
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
847 s.BindString(3, change.GetDate());
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
848 s.Run();
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
849 }
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
850
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
851
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
852 void DatabaseWrapper::LogExportedResource(const ExportedResource& resource)
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
853 {
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
854 SQLite::Statement s(db_, SQLITE_FROM_HERE,
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
855 "INSERT INTO ExportedResources VALUES(NULL, ?, ?, ?, ?, ?, ?, ?, ?)");
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
856
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
857 s.BindInt(0, resource.GetResourceType());
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
858 s.BindString(1, resource.GetPublicId());
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
859 s.BindString(2, resource.GetModality());
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
860 s.BindString(3, resource.GetPatientId());
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
861 s.BindString(4, resource.GetStudyInstanceUid());
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
862 s.BindString(5, resource.GetSeriesInstanceUid());
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
863 s.BindString(6, resource.GetSopInstanceUid());
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
864 s.BindString(7, resource.GetDate());
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
865 s.Run();
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
866 }
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
867
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
868
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
869 void DatabaseWrapper::GetExportedResources(std::list<ExportedResource>& target,
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
870 bool& done,
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
871 int64_t since,
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
872 uint32_t maxResults)
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
873 {
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
874 SQLite::Statement s(db_, SQLITE_FROM_HERE,
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
875 "SELECT * FROM ExportedResources WHERE seq>? ORDER BY seq LIMIT ?");
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
876 s.BindInt64(0, since);
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
877 s.BindInt(1, maxResults + 1);
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
878 GetExportedResourcesInternal(target, done, s, maxResults);
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
879 }
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
880
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
881
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
882 void DatabaseWrapper::GetLastExportedResource(std::list<ExportedResource>& target)
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
883 {
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
884 bool done; // Ignored
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
885 SQLite::Statement s(db_, SQLITE_FROM_HERE,
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
886 "SELECT * FROM ExportedResources ORDER BY seq DESC LIMIT 1");
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
887 GetExportedResourcesInternal(target, done, s, 1);
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
888 }
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
889
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
890
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
891 uint64_t DatabaseWrapper::GetTotalCompressedSize()
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
892 {
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
893 SQLite::Statement s(db_, SQLITE_FROM_HERE, "SELECT SUM(compressedSize) FROM AttachedFiles");
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
894 s.Run();
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
895 return static_cast<uint64_t>(s.ColumnInt64(0));
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
896 }
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
897
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
898
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
899 uint64_t DatabaseWrapper::GetTotalUncompressedSize()
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
900 {
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
901 SQLite::Statement s(db_, SQLITE_FROM_HERE, "SELECT SUM(uncompressedSize) FROM AttachedFiles");
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
902 s.Run();
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
903 return static_cast<uint64_t>(s.ColumnInt64(0));
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
904 }
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
905
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
906
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
907 uint64_t DatabaseWrapper::GetResourceCount(ResourceType resourceType)
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
908 {
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
909 SQLite::Statement s(db_, SQLITE_FROM_HERE,
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
910 "SELECT COUNT(*) FROM Resources WHERE resourceType=?");
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
911 s.BindInt(0, resourceType);
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
912
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
913 if (!s.Step())
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
914 {
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
915 return 0;
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
916 }
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
917 else
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
918 {
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
919 int64_t c = s.ColumnInt(0);
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
920 assert(!s.Step());
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
921 return c;
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
922 }
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
923 }
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
924
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
925
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
926 void DatabaseWrapper::GetAllInternalIds(std::list<int64_t>& target,
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
927 ResourceType resourceType)
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
928 {
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
929 SQLite::Statement s(db_, SQLITE_FROM_HERE, "SELECT internalId FROM Resources WHERE resourceType=?");
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
930 s.BindInt(0, resourceType);
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
931
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
932 target.clear();
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
933 while (s.Step())
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
934 {
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
935 target.push_back(s.ColumnInt64(0));
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
936 }
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
937 }
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
938
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
939
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
940 void DatabaseWrapper::GetAllPublicIds(std::list<std::string>& target,
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
941 ResourceType resourceType)
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
942 {
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
943 SQLite::Statement s(db_, SQLITE_FROM_HERE, "SELECT publicId FROM Resources WHERE resourceType=?");
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
944 s.BindInt(0, resourceType);
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
945
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
946 target.clear();
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
947 while (s.Step())
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
948 {
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
949 target.push_back(s.ColumnString(0));
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
950 }
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
951 }
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
952
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
953
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
954 void DatabaseWrapper::GetAllPublicIds(std::list<std::string>& target,
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
955 ResourceType resourceType,
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
956 size_t since,
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
957 size_t limit)
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
958 {
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
959 if (limit == 0)
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
960 {
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
961 target.clear();
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
962 return;
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
963 }
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
964
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
965 SQLite::Statement s(db_, SQLITE_FROM_HERE,
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
966 "SELECT publicId FROM Resources WHERE "
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
967 "resourceType=? LIMIT ? OFFSET ?");
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
968 s.BindInt(0, resourceType);
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
969 s.BindInt64(1, limit);
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
970 s.BindInt64(2, since);
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
971
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
972 target.clear();
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
973 while (s.Step())
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
974 {
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
975 target.push_back(s.ColumnString(0));
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
976 }
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
977 }
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
978
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
979
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
980 bool DatabaseWrapper::SelectPatientToRecycle(int64_t& internalId)
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
981 {
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
982 SQLite::Statement s(db_, SQLITE_FROM_HERE,
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
983 "SELECT patientId FROM PatientRecyclingOrder ORDER BY seq ASC LIMIT 1");
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
984
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
985 if (!s.Step())
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
986 {
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
987 // No patient remaining or all the patients are protected
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
988 return false;
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
989 }
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
990 else
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
991 {
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
992 internalId = s.ColumnInt(0);
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
993 return true;
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
994 }
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
995 }
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
996
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
997
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
998 bool DatabaseWrapper::SelectPatientToRecycle(int64_t& internalId,
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
999 int64_t patientIdToAvoid)
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
1000 {
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
1001 SQLite::Statement s(db_, SQLITE_FROM_HERE,
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
1002 "SELECT patientId FROM PatientRecyclingOrder "
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
1003 "WHERE patientId != ? ORDER BY seq ASC LIMIT 1");
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
1004 s.BindInt64(0, patientIdToAvoid);
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
1005
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
1006 if (!s.Step())
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
1007 {
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
1008 // No patient remaining or all the patients are protected
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
1009 return false;
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
1010 }
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
1011 else
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
1012 {
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
1013 internalId = s.ColumnInt(0);
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
1014 return true;
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
1015 }
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
1016 }
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
1017
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
1018
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
1019 bool DatabaseWrapper::IsProtectedPatient(int64_t internalId)
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
1020 {
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
1021 SQLite::Statement s(db_, SQLITE_FROM_HERE,
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
1022 "SELECT * FROM PatientRecyclingOrder WHERE patientId = ?");
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
1023 s.BindInt64(0, internalId);
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
1024 return !s.Step();
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
1025 }
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
1026
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
1027
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
1028 void DatabaseWrapper::SetProtectedPatient(int64_t internalId,
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
1029 bool isProtected)
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
1030 {
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
1031 if (isProtected)
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
1032 {
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
1033 SQLite::Statement s(db_, SQLITE_FROM_HERE, "DELETE FROM PatientRecyclingOrder WHERE patientId=?");
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
1034 s.BindInt64(0, internalId);
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
1035 s.Run();
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
1036 }
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
1037 else if (IsProtectedPatient(internalId))
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
1038 {
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
1039 SQLite::Statement s(db_, SQLITE_FROM_HERE, "INSERT INTO PatientRecyclingOrder VALUES(NULL, ?)");
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
1040 s.BindInt64(0, internalId);
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
1041 s.Run();
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
1042 }
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
1043 else
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
1044 {
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
1045 // Nothing to do: The patient is already unprotected
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
1046 }
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
1047 }
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
1048
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
1049
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
1050 bool DatabaseWrapper::IsExistingResource(int64_t internalId)
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
1051 {
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
1052 SQLite::Statement s(db_, SQLITE_FROM_HERE,
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
1053 "SELECT * FROM Resources WHERE internalId=?");
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
1054 s.BindInt64(0, internalId);
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
1055 return s.Step();
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
1056 }
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
1057
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
1058
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
1059 void DatabaseWrapper::LookupIdentifier(std::list<int64_t>& target,
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
1060 ResourceType level,
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
1061 const DicomTag& tag,
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
1062 IdentifierConstraintType type,
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
1063 const std::string& value)
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
1064 {
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
1065 static const char* COMMON = ("SELECT d.id FROM DicomIdentifiers AS d, Resources AS r WHERE "
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
1066 "d.id = r.internalId AND r.resourceType=? AND "
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
1067 "d.tagGroup=? AND d.tagElement=? AND ");
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
1068
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
1069 std::auto_ptr<SQLite::Statement> s;
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
1070
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
1071 switch (type)
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
1072 {
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
1073 case IdentifierConstraintType_GreaterOrEqual:
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
1074 s.reset(new SQLite::Statement(db_, std::string(COMMON) + "d.value>=?"));
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
1075 break;
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
1076
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
1077 case IdentifierConstraintType_SmallerOrEqual:
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
1078 s.reset(new SQLite::Statement(db_, std::string(COMMON) + "d.value<=?"));
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
1079 break;
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
1080
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
1081 case IdentifierConstraintType_Wildcard:
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
1082 s.reset(new SQLite::Statement(db_, std::string(COMMON) + "d.value GLOB ?"));
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
1083 break;
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
1084
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
1085 case IdentifierConstraintType_Equal:
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
1086 default:
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
1087 s.reset(new SQLite::Statement(db_, std::string(COMMON) + "d.value=?"));
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
1088 break;
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
1089 }
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
1090
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
1091 assert(s.get() != NULL);
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
1092
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
1093 s->BindInt(0, level);
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
1094 s->BindInt(1, tag.GetGroup());
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
1095 s->BindInt(2, tag.GetElement());
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
1096 s->BindString(3, value);
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
1097
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
1098 target.clear();
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
1099
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
1100 while (s->Step())
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
1101 {
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
1102 target.push_back(s->ColumnInt64(0));
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
1103 }
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
1104 }
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
1105
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
1106
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
1107 void DatabaseWrapper::LookupIdentifierRange(std::list<int64_t>& target,
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
1108 ResourceType level,
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
1109 const DicomTag& tag,
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
1110 const std::string& start,
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
1111 const std::string& end)
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
1112 {
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
1113 SQLite::Statement statement(db_, SQLITE_FROM_HERE,
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
1114 "SELECT d.id FROM DicomIdentifiers AS d, Resources AS r WHERE "
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
1115 "d.id = r.internalId AND r.resourceType=? AND "
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
1116 "d.tagGroup=? AND d.tagElement=? AND d.value>=? AND d.value<=?");
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
1117
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
1118 statement.BindInt(0, level);
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
1119 statement.BindInt(1, tag.GetGroup());
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
1120 statement.BindInt(2, tag.GetElement());
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
1121 statement.BindString(3, start);
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
1122 statement.BindString(4, end);
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
1123
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
1124 target.clear();
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
1125
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
1126 while (statement.Step())
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
1127 {
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
1128 target.push_back(statement.ColumnInt64(0));
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
1129 }
bb63068844ae moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
1130 }
183
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1131 }