annotate OrthancServer/DatabaseWrapper.cpp @ 224:4eb0c7ce86c9

refactoring for store
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 29 Nov 2012 22:22:00 +0100
parents 0200cd330582
children 8098448bd827
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
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3 * Copyright (C) 2012 Medical Physics Department, CHU of Liege,
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
4 * Belgium
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
5 *
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6 * This program is free software: you can redistribute it and/or
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 * modify it under the terms of the GNU General Public License as
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 * published by the Free Software Foundation, either version 3 of the
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 * License, or (at your option) any later version.
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 *
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 * In addition, as a special exception, the copyright holders of this
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 * program give permission to link the code of its release with the
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 * OpenSSL project's "OpenSSL" library (or with modified versions of it
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 * that use the same license as the "OpenSSL" library), and distribute
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 * the linked executables. You must obey the GNU General Public License
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16 * 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
17 * modify file(s) with this exception, you may extend this exception to
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18 * 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
19 * you do not wish to do so, delete this exception statement from your
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20 * version. If you delete this exception statement from all source files
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21 * in the program, then also delete it here.
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22 *
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23 * This program is distributed in the hope that it will be useful, but
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24 * WITHOUT ANY WARRANTY; without even the implied warranty of
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26 * General Public License for more details.
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27 *
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28 * You should have received a copy of the GNU General Public License
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29 * along with this program. If not, see <http://www.gnu.org/licenses/>.
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30 **/
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 #include "DatabaseWrapper.h"
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
34
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
35 #include "../Core/DicomFormat/DicomArray.h"
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
36 #include "EmbeddedResources.h"
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
37
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
38 #include <glog/logging.h>
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
39 #include <stdio.h>
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
40
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
41 namespace Orthanc
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
42 {
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
43
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
44 namespace Internals
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
45 {
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
46 class SignalFileDeleted : public SQLite::IScalarFunction
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
47 {
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
48 private:
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
49 IServerIndexListener& listener_;
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
50
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
51 public:
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
52 SignalFileDeleted(IServerIndexListener& listener) :
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
53 listener_(listener)
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
54 {
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
55 }
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
56
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
57 virtual const char* GetName() const
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
58 {
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
59 return "SignalFileDeleted";
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
60 }
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
61
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
62 virtual unsigned int GetCardinality() const
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
63 {
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
64 return 1;
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
65 }
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
66
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
67 virtual void Compute(SQLite::FunctionContext& context)
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
68 {
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
69 listener_.SignalFileDeleted(context.GetStringValue(0));
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
70 }
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
71 };
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
72
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
73 class SignalRemainingAncestor : public SQLite::IScalarFunction
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
74 {
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
75 private:
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
76 bool hasRemainingAncestor_;
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
77 std::string remainingPublicId_;
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
78 ResourceType remainingType_;
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
79
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
80 public:
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
81 void Reset()
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
82 {
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
83 hasRemainingAncestor_ = false;
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
84 }
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
85
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
86 virtual const char* GetName() const
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
87 {
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
88 return "SignalRemainingAncestor";
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
89 }
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
90
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
91 virtual unsigned int GetCardinality() const
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
92 {
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
93 return 2;
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
94 }
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
95
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
96 virtual void Compute(SQLite::FunctionContext& context)
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
97 {
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
98 VLOG(1) << "There exists a remaining ancestor with public ID \""
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
99 << context.GetStringValue(0)
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
100 << "\" of type "
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
101 << context.GetIntValue(1);
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
102
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
103 if (!hasRemainingAncestor_ ||
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
104 remainingType_ >= context.GetIntValue(1))
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
105 {
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
106 hasRemainingAncestor_ = true;
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
107 remainingPublicId_ = context.GetStringValue(0);
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
108 remainingType_ = static_cast<ResourceType>(context.GetIntValue(1));
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
109 }
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
110 }
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
111
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
112 bool HasRemainingAncestor() const
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
113 {
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
114 return hasRemainingAncestor_;
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
115 }
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
116
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
117 const std::string& GetRemainingAncestorId() const
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
118 {
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
119 assert(hasRemainingAncestor_);
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
120 return remainingPublicId_;
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
121 }
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
122
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
123 ResourceType GetRemainingAncestorType() const
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
124 {
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
125 assert(hasRemainingAncestor_);
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
126 return remainingType_;
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
127 }
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
128 };
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
129 }
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
130
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
131
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
132
206
4453a010d0db flush to disk thread
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 205
diff changeset
133 void DatabaseWrapper::SetGlobalProperty(GlobalProperty property,
183
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
134 const std::string& value)
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
135 {
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
136 SQLite::Statement s(db_, SQLITE_FROM_HERE, "INSERT OR REPLACE INTO GlobalProperties VALUES(?, ?)");
206
4453a010d0db flush to disk thread
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 205
diff changeset
137 s.BindInt(0, property);
183
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
138 s.BindString(1, value);
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
139 s.Run();
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
140 }
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
141
188
090cefdab1d1 fix because of Windows macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 187
diff changeset
142 bool DatabaseWrapper::LookupGlobalProperty(std::string& target,
206
4453a010d0db flush to disk thread
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 205
diff changeset
143 GlobalProperty property)
183
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
144 {
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
145 SQLite::Statement s(db_, SQLITE_FROM_HERE,
206
4453a010d0db flush to disk thread
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 205
diff changeset
146 "SELECT value FROM GlobalProperties WHERE property=?");
4453a010d0db flush to disk thread
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 205
diff changeset
147 s.BindInt(0, property);
183
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
148
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
149 if (!s.Step())
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
150 {
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
151 return false;
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
152 }
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
153 else
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
154 {
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
155 target = s.ColumnString(0);
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
156 return true;
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
157 }
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
158 }
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
159
206
4453a010d0db flush to disk thread
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 205
diff changeset
160 std::string DatabaseWrapper::GetGlobalProperty(GlobalProperty property,
183
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
161 const std::string& defaultValue)
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
162 {
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
163 std::string s;
206
4453a010d0db flush to disk thread
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 205
diff changeset
164 if (LookupGlobalProperty(s, property))
183
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
165 {
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
166 return s;
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
167 }
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
168 else
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
169 {
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
170 return defaultValue;
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
171 }
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 int64_t DatabaseWrapper::CreateResource(const std::string& publicId,
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
175 ResourceType type)
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
176 {
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
177 SQLite::Statement s(db_, SQLITE_FROM_HERE, "INSERT INTO Resources VALUES(NULL, ?, ?, NULL)");
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
178 s.BindInt(0, type);
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
179 s.BindString(1, publicId);
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
180 s.Run();
189
ccbc2cf64a0d record main dicom tags and changes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 188
diff changeset
181 int64_t id = db_.GetLastInsertRowId();
ccbc2cf64a0d record main dicom tags and changes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 188
diff changeset
182
ccbc2cf64a0d record main dicom tags and changes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 188
diff changeset
183 ChangeType changeType;
ccbc2cf64a0d record main dicom tags and changes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 188
diff changeset
184 switch (type)
ccbc2cf64a0d record main dicom tags and changes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 188
diff changeset
185 {
ccbc2cf64a0d record main dicom tags and changes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 188
diff changeset
186 case ResourceType_Patient:
ccbc2cf64a0d record main dicom tags and changes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 188
diff changeset
187 changeType = ChangeType_NewPatient;
ccbc2cf64a0d record main dicom tags and changes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 188
diff changeset
188 break;
ccbc2cf64a0d record main dicom tags and changes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 188
diff changeset
189
ccbc2cf64a0d record main dicom tags and changes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 188
diff changeset
190 case ResourceType_Study:
ccbc2cf64a0d record main dicom tags and changes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 188
diff changeset
191 changeType = ChangeType_NewStudy;
ccbc2cf64a0d record main dicom tags and changes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 188
diff changeset
192 break;
ccbc2cf64a0d record main dicom tags and changes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 188
diff changeset
193
ccbc2cf64a0d record main dicom tags and changes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 188
diff changeset
194 case ResourceType_Series:
ccbc2cf64a0d record main dicom tags and changes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 188
diff changeset
195 changeType = ChangeType_NewSeries;
ccbc2cf64a0d record main dicom tags and changes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 188
diff changeset
196 break;
ccbc2cf64a0d record main dicom tags and changes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 188
diff changeset
197
ccbc2cf64a0d record main dicom tags and changes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 188
diff changeset
198 case ResourceType_Instance:
ccbc2cf64a0d record main dicom tags and changes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 188
diff changeset
199 changeType = ChangeType_NewInstance;
ccbc2cf64a0d record main dicom tags and changes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 188
diff changeset
200 break;
ccbc2cf64a0d record main dicom tags and changes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 188
diff changeset
201
ccbc2cf64a0d record main dicom tags and changes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 188
diff changeset
202 default:
ccbc2cf64a0d record main dicom tags and changes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 188
diff changeset
203 throw OrthancException(ErrorCode_InternalError);
ccbc2cf64a0d record main dicom tags and changes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 188
diff changeset
204 }
ccbc2cf64a0d record main dicom tags and changes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 188
diff changeset
205
ccbc2cf64a0d record main dicom tags and changes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 188
diff changeset
206 LogChange(changeType, id, type);
ccbc2cf64a0d record main dicom tags and changes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 188
diff changeset
207 return id;
183
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
208 }
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
209
188
090cefdab1d1 fix because of Windows macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 187
diff changeset
210 bool DatabaseWrapper::LookupResource(const std::string& publicId,
090cefdab1d1 fix because of Windows macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 187
diff changeset
211 int64_t& id,
090cefdab1d1 fix because of Windows macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 187
diff changeset
212 ResourceType& type)
183
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
213 {
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
214 SQLite::Statement s(db_, SQLITE_FROM_HERE,
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
215 "SELECT internalId, resourceType FROM Resources WHERE publicId=?");
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
216 s.BindString(0, publicId);
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
217
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
218 if (!s.Step())
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
219 {
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
220 return false;
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
221 }
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
222 else
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
223 {
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
224 id = s.ColumnInt(0);
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
225 type = static_cast<ResourceType>(s.ColumnInt(1));
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
226
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
227 // Check whether there is a single resource with this public id
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
228 assert(!s.Step());
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
229
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
230 return true;
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
231 }
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
232 }
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
233
198
663cc6c46d0a before refactoring of ServerIndex::GetXXX
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 197
diff changeset
234 bool DatabaseWrapper::LookupParent(int64_t& parentId,
663cc6c46d0a before refactoring of ServerIndex::GetXXX
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 197
diff changeset
235 int64_t resourceId)
663cc6c46d0a before refactoring of ServerIndex::GetXXX
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 197
diff changeset
236 {
663cc6c46d0a before refactoring of ServerIndex::GetXXX
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 197
diff changeset
237 SQLite::Statement s(db_, SQLITE_FROM_HERE,
663cc6c46d0a before refactoring of ServerIndex::GetXXX
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 197
diff changeset
238 "SELECT parentId FROM Resources WHERE internalId=?");
663cc6c46d0a before refactoring of ServerIndex::GetXXX
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 197
diff changeset
239 s.BindInt(0, resourceId);
663cc6c46d0a before refactoring of ServerIndex::GetXXX
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 197
diff changeset
240
663cc6c46d0a before refactoring of ServerIndex::GetXXX
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 197
diff changeset
241 if (!s.Step())
663cc6c46d0a before refactoring of ServerIndex::GetXXX
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 197
diff changeset
242 {
663cc6c46d0a before refactoring of ServerIndex::GetXXX
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 197
diff changeset
243 throw OrthancException(ErrorCode_UnknownResource);
663cc6c46d0a before refactoring of ServerIndex::GetXXX
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 197
diff changeset
244 }
663cc6c46d0a before refactoring of ServerIndex::GetXXX
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 197
diff changeset
245
663cc6c46d0a before refactoring of ServerIndex::GetXXX
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 197
diff changeset
246 if (s.ColumnIsNull(0))
663cc6c46d0a before refactoring of ServerIndex::GetXXX
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 197
diff changeset
247 {
663cc6c46d0a before refactoring of ServerIndex::GetXXX
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 197
diff changeset
248 return false;
663cc6c46d0a before refactoring of ServerIndex::GetXXX
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 197
diff changeset
249 }
663cc6c46d0a before refactoring of ServerIndex::GetXXX
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 197
diff changeset
250 else
663cc6c46d0a before refactoring of ServerIndex::GetXXX
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 197
diff changeset
251 {
663cc6c46d0a before refactoring of ServerIndex::GetXXX
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 197
diff changeset
252 parentId = s.ColumnInt(0);
663cc6c46d0a before refactoring of ServerIndex::GetXXX
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 197
diff changeset
253 return true;
663cc6c46d0a before refactoring of ServerIndex::GetXXX
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 197
diff changeset
254 }
663cc6c46d0a before refactoring of ServerIndex::GetXXX
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 197
diff changeset
255 }
663cc6c46d0a before refactoring of ServerIndex::GetXXX
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 197
diff changeset
256
663cc6c46d0a before refactoring of ServerIndex::GetXXX
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 197
diff changeset
257 std::string DatabaseWrapper::GetPublicId(int64_t resourceId)
663cc6c46d0a before refactoring of ServerIndex::GetXXX
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 197
diff changeset
258 {
663cc6c46d0a before refactoring of ServerIndex::GetXXX
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 197
diff changeset
259 SQLite::Statement s(db_, SQLITE_FROM_HERE,
663cc6c46d0a before refactoring of ServerIndex::GetXXX
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 197
diff changeset
260 "SELECT publicId FROM Resources WHERE internalId=?");
663cc6c46d0a before refactoring of ServerIndex::GetXXX
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 197
diff changeset
261 s.BindInt(0, resourceId);
663cc6c46d0a before refactoring of ServerIndex::GetXXX
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 197
diff changeset
262
663cc6c46d0a before refactoring of ServerIndex::GetXXX
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 197
diff changeset
263 if (!s.Step())
663cc6c46d0a before refactoring of ServerIndex::GetXXX
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 197
diff changeset
264 {
663cc6c46d0a before refactoring of ServerIndex::GetXXX
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 197
diff changeset
265 throw OrthancException(ErrorCode_UnknownResource);
663cc6c46d0a before refactoring of ServerIndex::GetXXX
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 197
diff changeset
266 }
663cc6c46d0a before refactoring of ServerIndex::GetXXX
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 197
diff changeset
267
663cc6c46d0a before refactoring of ServerIndex::GetXXX
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 197
diff changeset
268 return s.ColumnString(0);
663cc6c46d0a before refactoring of ServerIndex::GetXXX
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 197
diff changeset
269 }
663cc6c46d0a before refactoring of ServerIndex::GetXXX
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 197
diff changeset
270
183
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
271 void DatabaseWrapper::AttachChild(int64_t parent,
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
272 int64_t child)
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
273 {
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
274 SQLite::Statement s(db_, SQLITE_FROM_HERE, "UPDATE Resources SET parentId = ? WHERE internalId = ?");
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
275 s.BindInt(0, parent);
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
276 s.BindInt(1, child);
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
277 s.Run();
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
278 }
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
279
193
a1b9d1e1497b failed attempt to compile with linux standard base
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 192
diff changeset
280 void DatabaseWrapper::GetChildren(Json::Value& childrenPublicIds,
a1b9d1e1497b failed attempt to compile with linux standard base
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 192
diff changeset
281 int64_t id)
a1b9d1e1497b failed attempt to compile with linux standard base
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 192
diff changeset
282 {
a1b9d1e1497b failed attempt to compile with linux standard base
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 192
diff changeset
283 SQLite::Statement s(db_, SQLITE_FROM_HERE, "SELECT publicId FROM Resources WHERE parentId=?");
a1b9d1e1497b failed attempt to compile with linux standard base
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 192
diff changeset
284 s.BindInt(0, id);
a1b9d1e1497b failed attempt to compile with linux standard base
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 192
diff changeset
285
a1b9d1e1497b failed attempt to compile with linux standard base
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 192
diff changeset
286 childrenPublicIds = Json::arrayValue;
a1b9d1e1497b failed attempt to compile with linux standard base
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 192
diff changeset
287 while (s.Step())
a1b9d1e1497b failed attempt to compile with linux standard base
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 192
diff changeset
288 {
a1b9d1e1497b failed attempt to compile with linux standard base
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 192
diff changeset
289 childrenPublicIds.append(s.ColumnString(0));
a1b9d1e1497b failed attempt to compile with linux standard base
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 192
diff changeset
290 }
a1b9d1e1497b failed attempt to compile with linux standard base
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 192
diff changeset
291 }
a1b9d1e1497b failed attempt to compile with linux standard base
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 192
diff changeset
292
a1b9d1e1497b failed attempt to compile with linux standard base
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 192
diff changeset
293
183
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
294 void DatabaseWrapper::DeleteResource(int64_t id)
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
295 {
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
296 signalRemainingAncestor_->Reset();
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
297
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
298 SQLite::Statement s(db_, SQLITE_FROM_HERE, "DELETE FROM Resources WHERE internalId=?");
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
299 s.BindInt(0, id);
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
300 s.Run();
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
301
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
302 if (signalRemainingAncestor_->HasRemainingAncestor())
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
303 {
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
304 listener_.SignalRemainingAncestor(signalRemainingAncestor_->GetRemainingAncestorType(),
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
305 signalRemainingAncestor_->GetRemainingAncestorId());
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
306 }
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
307 }
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
308
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
309 void DatabaseWrapper::SetMetadata(int64_t id,
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
310 MetadataType type,
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
311 const std::string& value)
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
312 {
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
313 SQLite::Statement s(db_, SQLITE_FROM_HERE, "INSERT OR REPLACE INTO Metadata VALUES(?, ?, ?)");
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
314 s.BindInt(0, id);
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
315 s.BindInt(1, type);
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
316 s.BindString(2, value);
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
317 s.Run();
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
318 }
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
319
188
090cefdab1d1 fix because of Windows macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 187
diff changeset
320 bool DatabaseWrapper::LookupMetadata(std::string& target,
090cefdab1d1 fix because of Windows macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 187
diff changeset
321 int64_t id,
090cefdab1d1 fix because of Windows macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 187
diff changeset
322 MetadataType type)
183
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
323 {
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
324 SQLite::Statement s(db_, SQLITE_FROM_HERE,
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
325 "SELECT value FROM Metadata WHERE id=? AND type=?");
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
326 s.BindInt(0, id);
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
327 s.BindInt(1, type);
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
328
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
329 if (!s.Step())
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
330 {
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
331 return false;
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
332 }
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
333 else
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
334 {
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
335 target = s.ColumnString(0);
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
336 return true;
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
337 }
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
338 }
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
339
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
340 std::string DatabaseWrapper::GetMetadata(int64_t id,
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
341 MetadataType type,
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
342 const std::string& defaultValue)
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
343 {
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
344 std::string s;
188
090cefdab1d1 fix because of Windows macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 187
diff changeset
345 if (LookupMetadata(s, id, type))
183
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
346 {
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
347 return s;
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
348 }
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
349 else
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
350 {
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
351 return defaultValue;
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
352 }
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
353 }
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
354
200
9c58b2b03cf0 refactoring of read operations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 199
diff changeset
355
9c58b2b03cf0 refactoring of read operations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 199
diff changeset
356 bool DatabaseWrapper::GetMetadataAsInteger(int& result,
9c58b2b03cf0 refactoring of read operations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 199
diff changeset
357 int64_t id,
9c58b2b03cf0 refactoring of read operations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 199
diff changeset
358 MetadataType type)
9c58b2b03cf0 refactoring of read operations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 199
diff changeset
359 {
9c58b2b03cf0 refactoring of read operations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 199
diff changeset
360 std::string s = GetMetadata(id, type, "");
9c58b2b03cf0 refactoring of read operations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 199
diff changeset
361 if (s.size() == 0)
9c58b2b03cf0 refactoring of read operations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 199
diff changeset
362 {
9c58b2b03cf0 refactoring of read operations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 199
diff changeset
363 return false;
9c58b2b03cf0 refactoring of read operations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 199
diff changeset
364 }
9c58b2b03cf0 refactoring of read operations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 199
diff changeset
365
9c58b2b03cf0 refactoring of read operations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 199
diff changeset
366 try
9c58b2b03cf0 refactoring of read operations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 199
diff changeset
367 {
9c58b2b03cf0 refactoring of read operations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 199
diff changeset
368 result = boost::lexical_cast<int>(s);
9c58b2b03cf0 refactoring of read operations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 199
diff changeset
369 return true;
9c58b2b03cf0 refactoring of read operations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 199
diff changeset
370 }
9c58b2b03cf0 refactoring of read operations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 199
diff changeset
371 catch (boost::bad_lexical_cast&)
9c58b2b03cf0 refactoring of read operations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 199
diff changeset
372 {
9c58b2b03cf0 refactoring of read operations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 199
diff changeset
373 return false;
9c58b2b03cf0 refactoring of read operations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 199
diff changeset
374 }
9c58b2b03cf0 refactoring of read operations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 199
diff changeset
375 }
9c58b2b03cf0 refactoring of read operations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 199
diff changeset
376
9c58b2b03cf0 refactoring of read operations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 199
diff changeset
377
9c58b2b03cf0 refactoring of read operations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 199
diff changeset
378
183
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
379 void DatabaseWrapper::AttachFile(int64_t id,
197
530a25320461 removal of text as ids in sqlite db
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 193
diff changeset
380 AttachedFileType contentType,
183
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
381 const std::string& fileUuid,
187
8e673a65564d refactoring of storing new instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 183
diff changeset
382 uint64_t compressedSize,
8e673a65564d refactoring of storing new instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 183
diff changeset
383 uint64_t uncompressedSize,
183
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
384 CompressionType compressionType)
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
385 {
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
386 SQLite::Statement s(db_, SQLITE_FROM_HERE, "INSERT INTO AttachedFiles VALUES(?, ?, ?, ?, ?, ?)");
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
387 s.BindInt(0, id);
197
530a25320461 removal of text as ids in sqlite db
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 193
diff changeset
388 s.BindInt(1, contentType);
183
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
389 s.BindString(2, fileUuid);
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
390 s.BindInt(3, compressedSize);
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
391 s.BindInt(4, uncompressedSize);
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
392 s.BindInt(5, compressionType);
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
393 s.Run();
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
394 }
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
395
188
090cefdab1d1 fix because of Windows macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 187
diff changeset
396 bool DatabaseWrapper::LookupFile(int64_t id,
197
530a25320461 removal of text as ids in sqlite db
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 193
diff changeset
397 AttachedFileType contentType,
188
090cefdab1d1 fix because of Windows macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 187
diff changeset
398 std::string& fileUuid,
090cefdab1d1 fix because of Windows macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 187
diff changeset
399 uint64_t& compressedSize,
090cefdab1d1 fix because of Windows macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 187
diff changeset
400 uint64_t& uncompressedSize,
090cefdab1d1 fix because of Windows macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 187
diff changeset
401 CompressionType& compressionType)
183
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
402 {
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
403 SQLite::Statement s(db_, SQLITE_FROM_HERE,
197
530a25320461 removal of text as ids in sqlite db
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 193
diff changeset
404 "SELECT uuid, compressedSize, uncompressedSize, compressionType FROM AttachedFiles WHERE id=? AND fileType=?");
183
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
405 s.BindInt(0, id);
197
530a25320461 removal of text as ids in sqlite db
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 193
diff changeset
406 s.BindInt(1, contentType);
183
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
407
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
408 if (!s.Step())
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
409 {
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
410 return false;
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
411 }
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
412 else
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
413 {
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
414 fileUuid = s.ColumnString(0);
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
415 compressedSize = s.ColumnInt(1);
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
416 uncompressedSize = s.ColumnInt(2);
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
417 compressionType = static_cast<CompressionType>(s.ColumnInt(3));
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
418 return true;
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
419 }
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
420 }
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
421
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
422 void DatabaseWrapper::SetMainDicomTags(int64_t id,
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
423 const DicomMap& tags)
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
424 {
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
425 DicomArray flattened(tags);
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
426 for (size_t i = 0; i < flattened.GetSize(); i++)
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
427 {
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
428 SQLite::Statement s(db_, SQLITE_FROM_HERE, "INSERT INTO MainDicomTags VALUES(?, ?, ?, ?)");
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
429 s.BindInt(0, id);
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
430 s.BindInt(1, flattened.GetElement(i).GetTag().GetGroup());
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
431 s.BindInt(2, flattened.GetElement(i).GetTag().GetElement());
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
432 s.BindString(3, flattened.GetElement(i).GetValue().AsString());
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
433 s.Run();
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
434 }
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
435 }
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
436
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
437 void DatabaseWrapper::GetMainDicomTags(DicomMap& map,
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
438 int64_t id)
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
439 {
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
440 map.Clear();
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
441
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
442 SQLite::Statement s(db_, SQLITE_FROM_HERE, "SELECT * FROM MainDicomTags WHERE id=?");
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
443 s.BindInt(0, id);
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
444 while (s.Step())
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
445 {
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
446 map.SetValue(s.ColumnInt(1),
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
447 s.ColumnInt(2),
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
448 s.ColumnString(3));
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
449 }
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
450 }
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
451
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
452
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
453 bool DatabaseWrapper::GetParentPublicId(std::string& result,
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
454 int64_t id)
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
455 {
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
456 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
457 "WHERE a.internalId = b.parentId AND b.internalId = ?");
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
458 s.BindInt(0, id);
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
459
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
460 if (s.Step())
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
461 {
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
462 result = s.ColumnString(0);
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
463 return true;
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
464 }
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
465 else
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
466 {
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
467 return false;
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
468 }
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
469 }
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
470
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
471
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
472 void DatabaseWrapper::GetChildrenPublicId(std::list<std::string>& result,
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
473 int64_t id)
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
474 {
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
475 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
476 "WHERE a.parentId = b.internalId AND b.internalId = ?");
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
477 s.BindInt(0, id);
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
478
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
479 result.clear();
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
480
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
481 while (s.Step())
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
482 {
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
483 result.push_back(s.ColumnString(0));
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
484 }
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
485 }
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
486
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
487
199
dfa2899d9960 refactoring cont
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 198
diff changeset
488 void DatabaseWrapper::GetChildrenInternalId(std::list<int64_t>& result,
dfa2899d9960 refactoring cont
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 198
diff changeset
489 int64_t id)
dfa2899d9960 refactoring cont
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 198
diff changeset
490 {
dfa2899d9960 refactoring cont
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 198
diff changeset
491 SQLite::Statement s(db_, SQLITE_FROM_HERE, "SELECT a.internalId FROM Resources AS a, Resources AS b "
dfa2899d9960 refactoring cont
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 198
diff changeset
492 "WHERE a.parentId = b.internalId AND b.internalId = ?");
dfa2899d9960 refactoring cont
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 198
diff changeset
493 s.BindInt(0, id);
dfa2899d9960 refactoring cont
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 198
diff changeset
494
dfa2899d9960 refactoring cont
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 198
diff changeset
495 result.clear();
dfa2899d9960 refactoring cont
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 198
diff changeset
496
dfa2899d9960 refactoring cont
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 198
diff changeset
497 while (s.Step())
dfa2899d9960 refactoring cont
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 198
diff changeset
498 {
dfa2899d9960 refactoring cont
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 198
diff changeset
499 result.push_back(s.ColumnInt(0));
dfa2899d9960 refactoring cont
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 198
diff changeset
500 }
dfa2899d9960 refactoring cont
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 198
diff changeset
501 }
dfa2899d9960 refactoring cont
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 198
diff changeset
502
dfa2899d9960 refactoring cont
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 198
diff changeset
503
183
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
504 void DatabaseWrapper::LogChange(ChangeType changeType,
189
ccbc2cf64a0d record main dicom tags and changes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 188
diff changeset
505 int64_t internalId,
183
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
506 ResourceType resourceType,
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
507 const boost::posix_time::ptime& date)
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
508 {
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
509 SQLite::Statement s(db_, SQLITE_FROM_HERE, "INSERT INTO Changes VALUES(NULL, ?, ?, ?, ?)");
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
510 s.BindInt(0, changeType);
189
ccbc2cf64a0d record main dicom tags and changes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 188
diff changeset
511 s.BindInt(1, internalId);
183
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
512 s.BindInt(2, resourceType);
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
513 s.BindString(3, boost::posix_time::to_iso_string(date));
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
514 s.Run();
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
515 }
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
516
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
517
204
7f4acf490179 changes api
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 203
diff changeset
518 void DatabaseWrapper::GetChanges(Json::Value& target,
7f4acf490179 changes api
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 203
diff changeset
519 int64_t since,
7f4acf490179 changes api
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 203
diff changeset
520 unsigned int maxResults)
7f4acf490179 changes api
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 203
diff changeset
521 {
7f4acf490179 changes api
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 203
diff changeset
522 SQLite::Statement s(db_, SQLITE_FROM_HERE, "SELECT * FROM Changes WHERE seq>? ORDER BY seq LIMIT ?");
7f4acf490179 changes api
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 203
diff changeset
523 s.BindInt(0, since);
7f4acf490179 changes api
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 203
diff changeset
524 s.BindInt(1, maxResults + 1);
7f4acf490179 changes api
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 203
diff changeset
525
7f4acf490179 changes api
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 203
diff changeset
526 Json::Value changes = Json::arrayValue;
7f4acf490179 changes api
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 203
diff changeset
527 int64_t last = 0;
7f4acf490179 changes api
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 203
diff changeset
528
7f4acf490179 changes api
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 203
diff changeset
529 while (changes.size() < maxResults && s.Step())
7f4acf490179 changes api
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 203
diff changeset
530 {
7f4acf490179 changes api
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 203
diff changeset
531 int64_t seq = s.ColumnInt(0);
7f4acf490179 changes api
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 203
diff changeset
532 ChangeType changeType = static_cast<ChangeType>(s.ColumnInt(1));
7f4acf490179 changes api
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 203
diff changeset
533 int64_t internalId = s.ColumnInt(2);
7f4acf490179 changes api
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 203
diff changeset
534 ResourceType resourceType = static_cast<ResourceType>(s.ColumnInt(3));
7f4acf490179 changes api
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 203
diff changeset
535 const std::string& date = s.ColumnString(4);
205
6ab754744446 logging of completed series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 204
diff changeset
536 std::string publicId = GetPublicId(internalId);
204
7f4acf490179 changes api
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 203
diff changeset
537
7f4acf490179 changes api
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 203
diff changeset
538 Json::Value item = Json::objectValue;
7f4acf490179 changes api
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 203
diff changeset
539 item["Seq"] = static_cast<int>(seq);
7f4acf490179 changes api
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 203
diff changeset
540 item["ChangeType"] = ToString(changeType);
7f4acf490179 changes api
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 203
diff changeset
541 item["ResourceType"] = ToString(resourceType);
205
6ab754744446 logging of completed series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 204
diff changeset
542 item["ID"] = publicId;
6ab754744446 logging of completed series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 204
diff changeset
543 item["Path"] = GetBasePath(resourceType, publicId);
204
7f4acf490179 changes api
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 203
diff changeset
544 item["Date"] = date;
7f4acf490179 changes api
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 203
diff changeset
545 last = seq;
7f4acf490179 changes api
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 203
diff changeset
546
7f4acf490179 changes api
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 203
diff changeset
547 changes.append(item);
7f4acf490179 changes api
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 203
diff changeset
548 }
7f4acf490179 changes api
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 203
diff changeset
549
7f4acf490179 changes api
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 203
diff changeset
550 target = Json::objectValue;
7f4acf490179 changes api
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 203
diff changeset
551 target["Changes"] = changes;
7f4acf490179 changes api
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 203
diff changeset
552 target["PendingChanges"] = (changes.size() == maxResults && s.Step());
7f4acf490179 changes api
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 203
diff changeset
553 target["LastSeq"] = static_cast<int>(last);
7f4acf490179 changes api
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 203
diff changeset
554 }
7f4acf490179 changes api
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 203
diff changeset
555
7f4acf490179 changes api
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 203
diff changeset
556
183
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
557 void DatabaseWrapper::LogExportedInstance(const std::string& remoteModality,
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
558 DicomInstanceHasher& hasher,
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
559 const boost::posix_time::ptime& date)
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
560 {
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
561 SQLite::Statement s(db_, SQLITE_FROM_HERE, "INSERT INTO ExportedInstances VALUES(NULL, ?, ?, ?, ?, ?, ?)");
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
562 s.BindString(0, remoteModality);
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
563 s.BindString(1, hasher.HashInstance());
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
564 s.BindString(2, hasher.GetPatientId());
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
565 s.BindString(3, hasher.GetStudyUid());
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
566 s.BindString(4, hasher.GetSeriesUid());
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
567 s.BindString(5, hasher.GetInstanceUid());
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
568 s.BindString(6, boost::posix_time::to_iso_string(date));
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
569 s.Run();
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
570 }
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
571
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
572
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
573 int64_t DatabaseWrapper::GetTableRecordCount(const std::string& table)
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
574 {
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
575 char buf[128];
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
576 sprintf(buf, "SELECT COUNT(*) FROM %s", table.c_str());
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
577 SQLite::Statement s(db_, buf);
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
578
218
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 206
diff changeset
579 if (!s.Step())
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 206
diff changeset
580 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 206
diff changeset
581 throw OrthancException(ErrorCode_InternalError);
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 206
diff changeset
582 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 206
diff changeset
583
183
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
584 int64_t c = s.ColumnInt(0);
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
585 assert(!s.Step());
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
586
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
587 return c;
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
588 }
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
589
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
590
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
591 uint64_t DatabaseWrapper::GetTotalCompressedSize()
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
592 {
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
593 SQLite::Statement s(db_, SQLITE_FROM_HERE, "SELECT SUM(compressedSize) FROM AttachedFiles");
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
594 s.Run();
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
595 return static_cast<uint64_t>(s.ColumnInt64(0));
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
596 }
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
597
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
598
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
599 uint64_t DatabaseWrapper::GetTotalUncompressedSize()
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
600 {
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
601 SQLite::Statement s(db_, SQLITE_FROM_HERE, "SELECT SUM(uncompressedSize) FROM AttachedFiles");
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
602 s.Run();
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
603 return static_cast<uint64_t>(s.ColumnInt64(0));
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
604 }
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
605
190
b6cef9d45cc3 getallpublicids
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 189
diff changeset
606 void DatabaseWrapper::GetAllPublicIds(Json::Value& target,
b6cef9d45cc3 getallpublicids
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 189
diff changeset
607 ResourceType resourceType)
b6cef9d45cc3 getallpublicids
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 189
diff changeset
608 {
b6cef9d45cc3 getallpublicids
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 189
diff changeset
609 SQLite::Statement s(db_, SQLITE_FROM_HERE, "SELECT publicId FROM Resources WHERE resourceType=?");
b6cef9d45cc3 getallpublicids
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 189
diff changeset
610 s.BindInt(0, resourceType);
b6cef9d45cc3 getallpublicids
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 189
diff changeset
611
b6cef9d45cc3 getallpublicids
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 189
diff changeset
612 target = Json::arrayValue;
b6cef9d45cc3 getallpublicids
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 189
diff changeset
613 while (s.Step())
b6cef9d45cc3 getallpublicids
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 189
diff changeset
614 {
b6cef9d45cc3 getallpublicids
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 189
diff changeset
615 target.append(s.ColumnString(0));
b6cef9d45cc3 getallpublicids
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 189
diff changeset
616 }
b6cef9d45cc3 getallpublicids
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 189
diff changeset
617 }
b6cef9d45cc3 getallpublicids
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 189
diff changeset
618
183
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
619
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
620 DatabaseWrapper::DatabaseWrapper(const std::string& path,
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
621 IServerIndexListener& listener) :
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
622 listener_(listener)
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
623 {
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
624 db_.Open(path);
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
625 Open();
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
626 }
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
627
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
628 DatabaseWrapper::DatabaseWrapper(IServerIndexListener& listener) :
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
629 listener_(listener)
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
630 {
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
631 db_.OpenInMemory();
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
632 Open();
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
633 }
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
634
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
635 void DatabaseWrapper::Open()
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
636 {
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
637 if (!db_.DoesTableExist("GlobalProperties"))
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
638 {
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
639 LOG(INFO) << "Creating the database";
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
640 std::string query;
203
9283552c25df db refactoring done
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 200
diff changeset
641 EmbeddedResources::GetFileResource(query, EmbeddedResources::PREPARE_DATABASE);
183
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
642 db_.Execute(query);
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
643 }
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
644
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
645 signalRemainingAncestor_ = new Internals::SignalRemainingAncestor;
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
646 db_.Register(signalRemainingAncestor_);
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
647 db_.Register(new Internals::SignalFileDeleted(listener_));
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
648 }
baada606da3c databasewrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
649 }