annotate OrthancServer/ServerIndex.cpp @ 224:4eb0c7ce86c9

refactoring for store
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 29 Nov 2012 22:22:00 +0100
parents bb8c260c0092
children 8a26a8e85edf
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 /**
62
a70bb32802ae renaming Server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 57
diff changeset
2 * Orthanc - A Lightweight, RESTful DICOM Store
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3 * Copyright (C) 2012 Medical Physics Department, CHU of Liege,
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
4 * Belgium
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
5 *
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6 * This program is free software: you can redistribute it and/or
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 * modify it under the terms of the GNU General Public License as
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 * published by the Free Software Foundation, either version 3 of the
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 * License, or (at your option) any later version.
136
fe180eae201d openssl exception
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 108
diff changeset
10 *
fe180eae201d openssl exception
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 108
diff changeset
11 * In addition, as a special exception, the copyright holders of this
fe180eae201d openssl exception
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 108
diff changeset
12 * program give permission to link the code of its release with the
fe180eae201d openssl exception
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 108
diff changeset
13 * OpenSSL project's "OpenSSL" library (or with modified versions of it
fe180eae201d openssl exception
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 108
diff changeset
14 * that use the same license as the "OpenSSL" library), and distribute
fe180eae201d openssl exception
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 108
diff changeset
15 * the linked executables. You must obey the GNU General Public License
fe180eae201d openssl exception
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 108
diff changeset
16 * in all respects for all of the code used other than "OpenSSL". If you
fe180eae201d openssl exception
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 108
diff changeset
17 * modify file(s) with this exception, you may extend this exception to
fe180eae201d openssl exception
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 108
diff changeset
18 * your version of the file(s), but you are not obligated to do so. If
fe180eae201d openssl exception
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 108
diff changeset
19 * you do not wish to do so, delete this exception statement from your
fe180eae201d openssl exception
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 108
diff changeset
20 * version. If you delete this exception statement from all source files
fe180eae201d openssl exception
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 108
diff changeset
21 * in the program, then also delete it here.
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22 *
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23 * This program is distributed in the hope that it will be useful, but
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24 * WITHOUT ANY WARRANTY; without even the implied warranty of
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26 * General Public License for more details.
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27 *
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28 * You should have received a copy of the GNU General Public License
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29 * along with this program. If not, see <http://www.gnu.org/licenses/>.
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30 **/
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
33 #include "ServerIndex.h"
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
34
62
a70bb32802ae renaming Server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 57
diff changeset
35 using namespace Orthanc;
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
36
6
9d483cf71d17 fix warnings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2
diff changeset
37 #ifndef NOMINMAX
2
67a6978503b7 fixing Windows build
Jodogne@Laptop
parents: 0
diff changeset
38 #define NOMINMAX
6
9d483cf71d17 fix warnings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2
diff changeset
39 #endif
9d483cf71d17 fix warnings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2
diff changeset
40
8
3a584803783e build with visual studio
jodogne
parents: 6
diff changeset
41 #include "EmbeddedResources.h"
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
42 #include "../Core/Toolbox.h"
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
43 #include "../Core/Uuid.h"
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
44 #include "../Core/DicomFormat/DicomArray.h"
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
45 #include "../Core/SQLite/Transaction.h"
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
46 #include "FromDcmtkBridge.h"
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
47
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
48 #include <boost/lexical_cast.hpp>
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
49 #include <stdio.h>
108
a6e41de88a53 using glog
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 84
diff changeset
50 #include <glog/logging.h>
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
51
62
a70bb32802ae renaming Server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 57
diff changeset
52 namespace Orthanc
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
53 {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
54 namespace Internals
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
55 {
202
1650557bd81a refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 201
diff changeset
56 class ServerIndexListener : public IServerIndexListener
201
bee20e978835 refactoring of delete
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 200
diff changeset
57 {
bee20e978835 refactoring of delete
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 200
diff changeset
58 private:
bee20e978835 refactoring of delete
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 200
diff changeset
59 FileStorage& fileStorage_;
bee20e978835 refactoring of delete
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 200
diff changeset
60 bool hasRemainingLevel_;
bee20e978835 refactoring of delete
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 200
diff changeset
61 ResourceType remainingType_;
bee20e978835 refactoring of delete
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 200
diff changeset
62 std::string remainingPublicId_;
bee20e978835 refactoring of delete
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 200
diff changeset
63
bee20e978835 refactoring of delete
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 200
diff changeset
64 public:
202
1650557bd81a refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 201
diff changeset
65 ServerIndexListener(FileStorage& fileStorage) :
201
bee20e978835 refactoring of delete
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 200
diff changeset
66 fileStorage_(fileStorage),
bee20e978835 refactoring of delete
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 200
diff changeset
67 hasRemainingLevel_(false)
bee20e978835 refactoring of delete
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 200
diff changeset
68 {
bee20e978835 refactoring of delete
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 200
diff changeset
69 assert(ResourceType_Patient < ResourceType_Study &&
bee20e978835 refactoring of delete
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 200
diff changeset
70 ResourceType_Study < ResourceType_Series &&
bee20e978835 refactoring of delete
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 200
diff changeset
71 ResourceType_Series < ResourceType_Instance);
bee20e978835 refactoring of delete
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 200
diff changeset
72 }
bee20e978835 refactoring of delete
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 200
diff changeset
73
bee20e978835 refactoring of delete
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 200
diff changeset
74 void Reset()
bee20e978835 refactoring of delete
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 200
diff changeset
75 {
bee20e978835 refactoring of delete
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 200
diff changeset
76 hasRemainingLevel_ = false;
bee20e978835 refactoring of delete
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 200
diff changeset
77 }
bee20e978835 refactoring of delete
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 200
diff changeset
78
bee20e978835 refactoring of delete
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 200
diff changeset
79 virtual void SignalRemainingAncestor(ResourceType parentType,
bee20e978835 refactoring of delete
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 200
diff changeset
80 const std::string& publicId)
bee20e978835 refactoring of delete
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 200
diff changeset
81 {
bee20e978835 refactoring of delete
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 200
diff changeset
82 LOG(INFO) << "Remaining ancestor \"" << publicId << "\" (" << parentType << ")";
bee20e978835 refactoring of delete
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 200
diff changeset
83
bee20e978835 refactoring of delete
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 200
diff changeset
84 if (hasRemainingLevel_)
bee20e978835 refactoring of delete
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 200
diff changeset
85 {
bee20e978835 refactoring of delete
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 200
diff changeset
86 if (parentType < remainingType_)
bee20e978835 refactoring of delete
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 200
diff changeset
87 {
bee20e978835 refactoring of delete
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 200
diff changeset
88 remainingType_ = parentType;
bee20e978835 refactoring of delete
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 200
diff changeset
89 remainingPublicId_ = publicId;
bee20e978835 refactoring of delete
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 200
diff changeset
90 }
bee20e978835 refactoring of delete
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 200
diff changeset
91 }
bee20e978835 refactoring of delete
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 200
diff changeset
92 else
bee20e978835 refactoring of delete
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 200
diff changeset
93 {
bee20e978835 refactoring of delete
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 200
diff changeset
94 hasRemainingLevel_ = true;
bee20e978835 refactoring of delete
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 200
diff changeset
95 remainingType_ = parentType;
bee20e978835 refactoring of delete
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 200
diff changeset
96 remainingPublicId_ = publicId;
bee20e978835 refactoring of delete
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 200
diff changeset
97 }
bee20e978835 refactoring of delete
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 200
diff changeset
98 }
bee20e978835 refactoring of delete
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 200
diff changeset
99
bee20e978835 refactoring of delete
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 200
diff changeset
100 virtual void SignalFileDeleted(const std::string& fileUuid)
bee20e978835 refactoring of delete
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 200
diff changeset
101 {
bee20e978835 refactoring of delete
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 200
diff changeset
102 assert(Toolbox::IsUuid(fileUuid));
bee20e978835 refactoring of delete
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 200
diff changeset
103 fileStorage_.Remove(fileUuid);
bee20e978835 refactoring of delete
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 200
diff changeset
104 }
bee20e978835 refactoring of delete
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 200
diff changeset
105
bee20e978835 refactoring of delete
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 200
diff changeset
106 bool HasRemainingLevel() const
bee20e978835 refactoring of delete
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 200
diff changeset
107 {
bee20e978835 refactoring of delete
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 200
diff changeset
108 return hasRemainingLevel_;
bee20e978835 refactoring of delete
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 200
diff changeset
109 }
bee20e978835 refactoring of delete
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 200
diff changeset
110
bee20e978835 refactoring of delete
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 200
diff changeset
111 ResourceType GetRemainingType() const
bee20e978835 refactoring of delete
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 200
diff changeset
112 {
bee20e978835 refactoring of delete
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 200
diff changeset
113 assert(HasRemainingLevel());
bee20e978835 refactoring of delete
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 200
diff changeset
114 return remainingType_;
bee20e978835 refactoring of delete
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 200
diff changeset
115 }
bee20e978835 refactoring of delete
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 200
diff changeset
116
bee20e978835 refactoring of delete
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 200
diff changeset
117 const std::string& GetRemainingPublicId() const
bee20e978835 refactoring of delete
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 200
diff changeset
118 {
bee20e978835 refactoring of delete
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 200
diff changeset
119 assert(HasRemainingLevel());
bee20e978835 refactoring of delete
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 200
diff changeset
120 return remainingPublicId_;
bee20e978835 refactoring of delete
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 200
diff changeset
121 }
bee20e978835 refactoring of delete
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 200
diff changeset
122 };
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
123 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
124
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
125
212
f276b175dcaf delete resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 206
diff changeset
126 bool ServerIndex::DeleteResource(Json::Value& target,
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
127 const std::string& uuid,
202
1650557bd81a refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 201
diff changeset
128 ResourceType expectedType)
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
129 {
206
4453a010d0db flush to disk thread
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 205
diff changeset
130 boost::mutex::scoped_lock lock(mutex_);
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
131
202
1650557bd81a refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 201
diff changeset
132 listener_->Reset();
201
bee20e978835 refactoring of delete
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 200
diff changeset
133
202
1650557bd81a refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 201
diff changeset
134 std::auto_ptr<SQLite::Transaction> t(db_->StartTransaction());
1650557bd81a refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 201
diff changeset
135 t->Begin();
201
bee20e978835 refactoring of delete
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 200
diff changeset
136
202
1650557bd81a refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 201
diff changeset
137 int64_t id;
1650557bd81a refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 201
diff changeset
138 ResourceType type;
1650557bd81a refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 201
diff changeset
139 if (!db_->LookupResource(uuid, id, type) ||
1650557bd81a refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 201
diff changeset
140 expectedType != type)
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
141 {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
142 return false;
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
143 }
202
1650557bd81a refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 201
diff changeset
144
1650557bd81a refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 201
diff changeset
145 db_->DeleteResource(id);
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
146
202
1650557bd81a refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 201
diff changeset
147 if (listener_->HasRemainingLevel())
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
148 {
202
1650557bd81a refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 201
diff changeset
149 ResourceType type = listener_->GetRemainingType();
1650557bd81a refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 201
diff changeset
150 const std::string& uuid = listener_->GetRemainingPublicId();
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
151
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
152 target["RemainingAncestor"] = Json::Value(Json::objectValue);
204
7f4acf490179 changes api
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 202
diff changeset
153 target["RemainingAncestor"]["Path"] = GetBasePath(type, uuid);
202
1650557bd81a refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 201
diff changeset
154 target["RemainingAncestor"]["Type"] = ToString(type);
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
155 target["RemainingAncestor"]["ID"] = uuid;
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
156 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
157 else
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
158 {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
159 target["RemainingAncestor"] = Json::nullValue;
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
160 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
161
202
1650557bd81a refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 201
diff changeset
162 t->Commit();
1650557bd81a refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 201
diff changeset
163
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
164 return true;
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
165 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
166
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
167
206
4453a010d0db flush to disk thread
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 205
diff changeset
168 static void FlushThread(DatabaseWrapper* db,
220
bb8c260c0092 fix for windows
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 212
diff changeset
169 boost::mutex* mutex,
bb8c260c0092 fix for windows
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 212
diff changeset
170 unsigned int sleep)
206
4453a010d0db flush to disk thread
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 205
diff changeset
171 {
4453a010d0db flush to disk thread
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 205
diff changeset
172 LOG(INFO) << "Starting the database flushing thread (sleep = " << sleep << ")";
4453a010d0db flush to disk thread
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 205
diff changeset
173
4453a010d0db flush to disk thread
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 205
diff changeset
174 while (1)
4453a010d0db flush to disk thread
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 205
diff changeset
175 {
4453a010d0db flush to disk thread
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 205
diff changeset
176 boost::this_thread::sleep(boost::posix_time::seconds(sleep));
4453a010d0db flush to disk thread
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 205
diff changeset
177 boost::mutex::scoped_lock lock(*mutex);
4453a010d0db flush to disk thread
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 205
diff changeset
178 db->FlushToDisk();
4453a010d0db flush to disk thread
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 205
diff changeset
179 }
4453a010d0db flush to disk thread
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 205
diff changeset
180 }
4453a010d0db flush to disk thread
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 205
diff changeset
181
4453a010d0db flush to disk thread
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 205
diff changeset
182
201
bee20e978835 refactoring of delete
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 200
diff changeset
183 ServerIndex::ServerIndex(FileStorage& fileStorage,
220
bb8c260c0092 fix for windows
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 212
diff changeset
184 const std::string& dbPath) : mutex_()
186
f68c039b0571 preparing refactoring of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 180
diff changeset
185 {
202
1650557bd81a refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 201
diff changeset
186 listener_.reset(new Internals::ServerIndexListener(fileStorage));
186
f68c039b0571 preparing refactoring of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 180
diff changeset
187
201
bee20e978835 refactoring of delete
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 200
diff changeset
188 if (dbPath == ":memory:")
180
626777d01dc4 use of hashes to index dicom objects
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 179
diff changeset
189 {
202
1650557bd81a refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 201
diff changeset
190 db_.reset(new DatabaseWrapper(*listener_));
180
626777d01dc4 use of hashes to index dicom objects
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 179
diff changeset
191 }
626777d01dc4 use of hashes to index dicom objects
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 179
diff changeset
192 else
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
193 {
201
bee20e978835 refactoring of delete
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 200
diff changeset
194 boost::filesystem::path p = dbPath;
180
626777d01dc4 use of hashes to index dicom objects
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 179
diff changeset
195
626777d01dc4 use of hashes to index dicom objects
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 179
diff changeset
196 try
626777d01dc4 use of hashes to index dicom objects
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 179
diff changeset
197 {
201
bee20e978835 refactoring of delete
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 200
diff changeset
198 boost::filesystem::create_directories(p);
180
626777d01dc4 use of hashes to index dicom objects
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 179
diff changeset
199 }
626777d01dc4 use of hashes to index dicom objects
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 179
diff changeset
200 catch (boost::filesystem::filesystem_error)
626777d01dc4 use of hashes to index dicom objects
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 179
diff changeset
201 {
626777d01dc4 use of hashes to index dicom objects
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 179
diff changeset
202 }
626777d01dc4 use of hashes to index dicom objects
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 179
diff changeset
203
202
1650557bd81a refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 201
diff changeset
204 db_.reset(new DatabaseWrapper(p.string() + "/index", *listener_));
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
205 }
206
4453a010d0db flush to disk thread
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 205
diff changeset
206
220
bb8c260c0092 fix for windows
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 212
diff changeset
207 unsigned int sleep;
bb8c260c0092 fix for windows
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 212
diff changeset
208 try
bb8c260c0092 fix for windows
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 212
diff changeset
209 {
bb8c260c0092 fix for windows
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 212
diff changeset
210 std::string sleepString = db_->GetGlobalProperty(GlobalProperty_FlushSleep);
bb8c260c0092 fix for windows
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 212
diff changeset
211 sleep = boost::lexical_cast<unsigned int>(sleepString);
bb8c260c0092 fix for windows
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 212
diff changeset
212 }
bb8c260c0092 fix for windows
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 212
diff changeset
213 catch (boost::bad_lexical_cast&)
bb8c260c0092 fix for windows
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 212
diff changeset
214 {
bb8c260c0092 fix for windows
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 212
diff changeset
215 // By default, wait for 10 seconds before flushing
bb8c260c0092 fix for windows
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 212
diff changeset
216 sleep = 10;
bb8c260c0092 fix for windows
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 212
diff changeset
217 }
bb8c260c0092 fix for windows
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 212
diff changeset
218
bb8c260c0092 fix for windows
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 212
diff changeset
219 flushThread_ = boost::thread(FlushThread, db_.get(), &mutex_, sleep);
206
4453a010d0db flush to disk thread
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 205
diff changeset
220 }
4453a010d0db flush to disk thread
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 205
diff changeset
221
4453a010d0db flush to disk thread
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 205
diff changeset
222
4453a010d0db flush to disk thread
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 205
diff changeset
223 ServerIndex::~ServerIndex()
4453a010d0db flush to disk thread
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 205
diff changeset
224 {
4453a010d0db flush to disk thread
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 205
diff changeset
225 LOG(INFO) << "Stopping the database flushing thread";
220
bb8c260c0092 fix for windows
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 212
diff changeset
226 /*flushThread_.terminate();
bb8c260c0092 fix for windows
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 212
diff changeset
227 flushThread_.join();*/
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
228 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
229
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
230
187
8e673a65564d refactoring of storing new instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 186
diff changeset
231 StoreStatus ServerIndex::Store(const DicomMap& dicomSummary,
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
232 const std::string& fileUuid,
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
233 uint64_t uncompressedFileSize,
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
234 const std::string& jsonUuid,
187
8e673a65564d refactoring of storing new instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 186
diff changeset
235 const std::string& remoteAet)
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
236 {
206
4453a010d0db flush to disk thread
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 205
diff changeset
237 boost::mutex::scoped_lock lock(mutex_);
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
238
178
5739b4d10a4b hashing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 147
diff changeset
239 DicomInstanceHasher hasher(dicomSummary);
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
240
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
241 try
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
242 {
202
1650557bd81a refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 201
diff changeset
243 std::auto_ptr<SQLite::Transaction> t(db_->StartTransaction());
1650557bd81a refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 201
diff changeset
244 t->Begin();
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
245
202
1650557bd81a refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 201
diff changeset
246 int64_t patient, study, series, instance;
1650557bd81a refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 201
diff changeset
247 ResourceType type;
1650557bd81a refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 201
diff changeset
248 bool isNewSeries = false;
1650557bd81a refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 201
diff changeset
249
1650557bd81a refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 201
diff changeset
250 // Do nothing if the instance already exists
1650557bd81a refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 201
diff changeset
251 if (db_->LookupResource(hasher.HashInstance(), patient, type))
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
252 {
202
1650557bd81a refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 201
diff changeset
253 assert(type == ResourceType_Instance);
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
254 return StoreStatus_AlreadyStored;
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
255 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
256
202
1650557bd81a refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 201
diff changeset
257 // Create the instance
1650557bd81a refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 201
diff changeset
258 instance = db_->CreateResource(hasher.HashInstance(), ResourceType_Instance);
1650557bd81a refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 201
diff changeset
259
1650557bd81a refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 201
diff changeset
260 DicomMap dicom;
1650557bd81a refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 201
diff changeset
261 dicomSummary.ExtractInstanceInformation(dicom);
1650557bd81a refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 201
diff changeset
262 db_->SetMainDicomTags(instance, dicom);
1650557bd81a refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 201
diff changeset
263
1650557bd81a refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 201
diff changeset
264 // Create the patient/study/series/instance hierarchy
1650557bd81a refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 201
diff changeset
265 if (!db_->LookupResource(hasher.HashSeries(), series, type))
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
266 {
202
1650557bd81a refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 201
diff changeset
267 // This is a new series
1650557bd81a refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 201
diff changeset
268 isNewSeries = true;
1650557bd81a refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 201
diff changeset
269 series = db_->CreateResource(hasher.HashSeries(), ResourceType_Series);
1650557bd81a refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 201
diff changeset
270 dicomSummary.ExtractSeriesInformation(dicom);
1650557bd81a refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 201
diff changeset
271 db_->SetMainDicomTags(series, dicom);
1650557bd81a refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 201
diff changeset
272 db_->AttachChild(series, instance);
1650557bd81a refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 201
diff changeset
273
1650557bd81a refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 201
diff changeset
274 if (!db_->LookupResource(hasher.HashStudy(), study, type))
1650557bd81a refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 201
diff changeset
275 {
1650557bd81a refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 201
diff changeset
276 // This is a new study
1650557bd81a refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 201
diff changeset
277 study = db_->CreateResource(hasher.HashStudy(), ResourceType_Study);
1650557bd81a refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 201
diff changeset
278 dicomSummary.ExtractStudyInformation(dicom);
1650557bd81a refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 201
diff changeset
279 db_->SetMainDicomTags(study, dicom);
1650557bd81a refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 201
diff changeset
280 db_->AttachChild(study, series);
1650557bd81a refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 201
diff changeset
281
1650557bd81a refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 201
diff changeset
282 if (!db_->LookupResource(hasher.HashPatient(), patient, type))
1650557bd81a refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 201
diff changeset
283 {
1650557bd81a refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 201
diff changeset
284 // This is a new patient
1650557bd81a refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 201
diff changeset
285 patient = db_->CreateResource(hasher.HashPatient(), ResourceType_Patient);
1650557bd81a refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 201
diff changeset
286 dicomSummary.ExtractPatientInformation(dicom);
1650557bd81a refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 201
diff changeset
287 db_->SetMainDicomTags(patient, dicom);
1650557bd81a refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 201
diff changeset
288 db_->AttachChild(patient, study);
1650557bd81a refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 201
diff changeset
289 }
1650557bd81a refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 201
diff changeset
290 else
1650557bd81a refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 201
diff changeset
291 {
1650557bd81a refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 201
diff changeset
292 assert(type == ResourceType_Patient);
1650557bd81a refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 201
diff changeset
293 db_->AttachChild(patient, study);
1650557bd81a refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 201
diff changeset
294 }
1650557bd81a refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 201
diff changeset
295 }
1650557bd81a refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 201
diff changeset
296 else
1650557bd81a refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 201
diff changeset
297 {
1650557bd81a refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 201
diff changeset
298 assert(type == ResourceType_Study);
1650557bd81a refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 201
diff changeset
299 db_->AttachChild(study, series);
1650557bd81a refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 201
diff changeset
300 }
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
301 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
302 else
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
303 {
202
1650557bd81a refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 201
diff changeset
304 assert(type == ResourceType_Series);
1650557bd81a refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 201
diff changeset
305 db_->AttachChild(series, instance);
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
306 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
307
202
1650557bd81a refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 201
diff changeset
308 // Attach the files to the newly created instance
1650557bd81a refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 201
diff changeset
309 db_->AttachFile(instance, AttachedFileType_Dicom, fileUuid, uncompressedFileSize);
1650557bd81a refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 201
diff changeset
310 db_->AttachFile(instance, AttachedFileType_Json, jsonUuid, 0); // TODO "0"
1650557bd81a refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 201
diff changeset
311
1650557bd81a refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 201
diff changeset
312 // Attach the metadata
1650557bd81a refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 201
diff changeset
313 db_->SetMetadata(instance, MetadataType_Instance_ReceptionDate, Toolbox::GetNowIsoString());
1650557bd81a refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 201
diff changeset
314 db_->SetMetadata(instance, MetadataType_Instance_RemoteAet, remoteAet);
1650557bd81a refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 201
diff changeset
315
1650557bd81a refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 201
diff changeset
316 const DicomValue* value;
1650557bd81a refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 201
diff changeset
317 if ((value = dicomSummary.TestAndGetValue(DICOM_TAG_INSTANCE_NUMBER)) != NULL ||
1650557bd81a refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 201
diff changeset
318 (value = dicomSummary.TestAndGetValue(DICOM_TAG_IMAGE_INDEX)) != NULL)
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
319 {
202
1650557bd81a refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 201
diff changeset
320 db_->SetMetadata(instance, MetadataType_Instance_IndexInSeries, value->AsString());
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
321 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
322
202
1650557bd81a refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 201
diff changeset
323 if (isNewSeries)
1650557bd81a refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 201
diff changeset
324 {
1650557bd81a refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 201
diff changeset
325 if ((value = dicomSummary.TestAndGetValue(DICOM_TAG_NUMBER_OF_SLICES)) != NULL ||
1650557bd81a refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 201
diff changeset
326 (value = dicomSummary.TestAndGetValue(DICOM_TAG_IMAGES_IN_ACQUISITION)) != NULL ||
1650557bd81a refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 201
diff changeset
327 (value = dicomSummary.TestAndGetValue(DICOM_TAG_CARDIAC_NUMBER_OF_IMAGES)) != NULL)
1650557bd81a refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 201
diff changeset
328 {
1650557bd81a refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 201
diff changeset
329 db_->SetMetadata(series, MetadataType_Series_ExpectedNumberOfInstances, value->AsString());
1650557bd81a refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 201
diff changeset
330 }
1650557bd81a refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 201
diff changeset
331 }
1650557bd81a refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 201
diff changeset
332
205
6ab754744446 logging of completed series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 204
diff changeset
333 // Check whether the series of this new instance is now completed
6ab754744446 logging of completed series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 204
diff changeset
334 SeriesStatus seriesStatus = GetSeriesStatus(series);
6ab754744446 logging of completed series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 204
diff changeset
335 if (seriesStatus == SeriesStatus_Complete)
6ab754744446 logging of completed series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 204
diff changeset
336 {
6ab754744446 logging of completed series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 204
diff changeset
337 db_->LogChange(ChangeType_CompletedSeries, series, ResourceType_Series);
6ab754744446 logging of completed series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 204
diff changeset
338 }
6ab754744446 logging of completed series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 204
diff changeset
339
202
1650557bd81a refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 201
diff changeset
340 t->Commit();
1650557bd81a refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 201
diff changeset
341
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
342 return StoreStatus_Success;
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
343 }
62
a70bb32802ae renaming Server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 57
diff changeset
344 catch (OrthancException& e)
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
345 {
202
1650557bd81a refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 201
diff changeset
346 LOG(ERROR) << "EXCEPTION2 [" << e.What() << "]" << " " << db_->GetErrorMessage();
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
347 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
348
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
349 return StoreStatus_Failure;
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
350 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
351
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
352
187
8e673a65564d refactoring of storing new instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 186
diff changeset
353 uint64_t ServerIndex::GetTotalCompressedSize()
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
354 {
206
4453a010d0db flush to disk thread
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 205
diff changeset
355 boost::mutex::scoped_lock lock(mutex_);
202
1650557bd81a refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 201
diff changeset
356 return db_->GetTotalCompressedSize();
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
357 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
358
187
8e673a65564d refactoring of storing new instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 186
diff changeset
359 uint64_t ServerIndex::GetTotalUncompressedSize()
8e673a65564d refactoring of storing new instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 186
diff changeset
360 {
206
4453a010d0db flush to disk thread
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 205
diff changeset
361 boost::mutex::scoped_lock lock(mutex_);
202
1650557bd81a refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 201
diff changeset
362 return db_->GetTotalUncompressedSize();
187
8e673a65564d refactoring of storing new instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 186
diff changeset
363 }
8e673a65564d refactoring of storing new instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 186
diff changeset
364
8e673a65564d refactoring of storing new instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 186
diff changeset
365
199
dfa2899d9960 refactoring cont
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 198
diff changeset
366 SeriesStatus ServerIndex::GetSeriesStatus(int id)
dfa2899d9960 refactoring cont
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 198
diff changeset
367 {
dfa2899d9960 refactoring cont
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 198
diff changeset
368 // Get the expected number of instances in this series (from the metadata)
202
1650557bd81a refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 201
diff changeset
369 std::string s = db_->GetMetadata(id, MetadataType_Series_ExpectedNumberOfInstances);
199
dfa2899d9960 refactoring cont
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 198
diff changeset
370
dfa2899d9960 refactoring cont
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 198
diff changeset
371 size_t expected;
dfa2899d9960 refactoring cont
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 198
diff changeset
372 try
dfa2899d9960 refactoring cont
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 198
diff changeset
373 {
dfa2899d9960 refactoring cont
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 198
diff changeset
374 expected = boost::lexical_cast<size_t>(s);
dfa2899d9960 refactoring cont
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 198
diff changeset
375 if (expected < 0)
dfa2899d9960 refactoring cont
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 198
diff changeset
376 {
dfa2899d9960 refactoring cont
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 198
diff changeset
377 return SeriesStatus_Unknown;
dfa2899d9960 refactoring cont
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 198
diff changeset
378 }
dfa2899d9960 refactoring cont
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 198
diff changeset
379 }
dfa2899d9960 refactoring cont
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 198
diff changeset
380 catch (boost::bad_lexical_cast&)
dfa2899d9960 refactoring cont
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 198
diff changeset
381 {
dfa2899d9960 refactoring cont
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 198
diff changeset
382 return SeriesStatus_Unknown;
dfa2899d9960 refactoring cont
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 198
diff changeset
383 }
dfa2899d9960 refactoring cont
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 198
diff changeset
384
dfa2899d9960 refactoring cont
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 198
diff changeset
385 // Loop over the instances of this series
dfa2899d9960 refactoring cont
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 198
diff changeset
386 std::list<int64_t> children;
202
1650557bd81a refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 201
diff changeset
387 db_->GetChildrenInternalId(children, id);
199
dfa2899d9960 refactoring cont
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 198
diff changeset
388
dfa2899d9960 refactoring cont
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 198
diff changeset
389 std::set<size_t> instances;
dfa2899d9960 refactoring cont
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 198
diff changeset
390 for (std::list<int64_t>::const_iterator
dfa2899d9960 refactoring cont
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 198
diff changeset
391 it = children.begin(); it != children.end(); it++)
dfa2899d9960 refactoring cont
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 198
diff changeset
392 {
dfa2899d9960 refactoring cont
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 198
diff changeset
393 // Get the index of this instance in the series
202
1650557bd81a refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 201
diff changeset
394 s = db_->GetMetadata(*it, MetadataType_Instance_IndexInSeries);
199
dfa2899d9960 refactoring cont
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 198
diff changeset
395 size_t index;
dfa2899d9960 refactoring cont
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 198
diff changeset
396 try
dfa2899d9960 refactoring cont
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 198
diff changeset
397 {
dfa2899d9960 refactoring cont
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 198
diff changeset
398 index = boost::lexical_cast<size_t>(s);
dfa2899d9960 refactoring cont
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 198
diff changeset
399 }
dfa2899d9960 refactoring cont
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 198
diff changeset
400 catch (boost::bad_lexical_cast&)
dfa2899d9960 refactoring cont
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 198
diff changeset
401 {
dfa2899d9960 refactoring cont
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 198
diff changeset
402 return SeriesStatus_Unknown;
dfa2899d9960 refactoring cont
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 198
diff changeset
403 }
dfa2899d9960 refactoring cont
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 198
diff changeset
404
dfa2899d9960 refactoring cont
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 198
diff changeset
405 if (index <= 0 || index > expected)
dfa2899d9960 refactoring cont
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 198
diff changeset
406 {
dfa2899d9960 refactoring cont
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 198
diff changeset
407 // Out-of-range instance index
dfa2899d9960 refactoring cont
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 198
diff changeset
408 return SeriesStatus_Inconsistent;
dfa2899d9960 refactoring cont
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 198
diff changeset
409 }
dfa2899d9960 refactoring cont
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 198
diff changeset
410
dfa2899d9960 refactoring cont
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 198
diff changeset
411 if (instances.find(index) != instances.end())
dfa2899d9960 refactoring cont
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 198
diff changeset
412 {
dfa2899d9960 refactoring cont
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 198
diff changeset
413 // Twice the same instance index
dfa2899d9960 refactoring cont
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 198
diff changeset
414 return SeriesStatus_Inconsistent;
dfa2899d9960 refactoring cont
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 198
diff changeset
415 }
dfa2899d9960 refactoring cont
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 198
diff changeset
416
dfa2899d9960 refactoring cont
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 198
diff changeset
417 instances.insert(index);
dfa2899d9960 refactoring cont
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 198
diff changeset
418 }
dfa2899d9960 refactoring cont
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 198
diff changeset
419
dfa2899d9960 refactoring cont
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 198
diff changeset
420 if (instances.size() == expected)
dfa2899d9960 refactoring cont
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 198
diff changeset
421 {
dfa2899d9960 refactoring cont
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 198
diff changeset
422 return SeriesStatus_Complete;
dfa2899d9960 refactoring cont
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 198
diff changeset
423 }
dfa2899d9960 refactoring cont
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 198
diff changeset
424 else
dfa2899d9960 refactoring cont
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 198
diff changeset
425 {
dfa2899d9960 refactoring cont
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 198
diff changeset
426 return SeriesStatus_Missing;
dfa2899d9960 refactoring cont
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 198
diff changeset
427 }
dfa2899d9960 refactoring cont
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 198
diff changeset
428 }
dfa2899d9960 refactoring cont
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 198
diff changeset
429
dfa2899d9960 refactoring cont
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 198
diff changeset
430
dfa2899d9960 refactoring cont
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 198
diff changeset
431
202
1650557bd81a refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 201
diff changeset
432 void ServerIndex::MainDicomTagsToJson(Json::Value& target,
1650557bd81a refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 201
diff changeset
433 int64_t resourceId)
198
663cc6c46d0a before refactoring of ServerIndex::GetXXX
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 197
diff changeset
434 {
663cc6c46d0a before refactoring of ServerIndex::GetXXX
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 197
diff changeset
435 DicomMap tags;
202
1650557bd81a refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 201
diff changeset
436 db_->GetMainDicomTags(tags, resourceId);
198
663cc6c46d0a before refactoring of ServerIndex::GetXXX
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 197
diff changeset
437 target["MainDicomTags"] = Json::objectValue;
663cc6c46d0a before refactoring of ServerIndex::GetXXX
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 197
diff changeset
438 FromDcmtkBridge::ToJson(target["MainDicomTags"], tags);
663cc6c46d0a before refactoring of ServerIndex::GetXXX
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 197
diff changeset
439 }
663cc6c46d0a before refactoring of ServerIndex::GetXXX
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 197
diff changeset
440
663cc6c46d0a before refactoring of ServerIndex::GetXXX
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 197
diff changeset
441 bool ServerIndex::LookupResource(Json::Value& result,
199
dfa2899d9960 refactoring cont
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 198
diff changeset
442 const std::string& publicId,
dfa2899d9960 refactoring cont
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 198
diff changeset
443 ResourceType expectedType)
198
663cc6c46d0a before refactoring of ServerIndex::GetXXX
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 197
diff changeset
444 {
663cc6c46d0a before refactoring of ServerIndex::GetXXX
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 197
diff changeset
445 result = Json::objectValue;
663cc6c46d0a before refactoring of ServerIndex::GetXXX
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 197
diff changeset
446
206
4453a010d0db flush to disk thread
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 205
diff changeset
447 boost::mutex::scoped_lock lock(mutex_);
199
dfa2899d9960 refactoring cont
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 198
diff changeset
448
198
663cc6c46d0a before refactoring of ServerIndex::GetXXX
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 197
diff changeset
449 // Lookup for the requested resource
663cc6c46d0a before refactoring of ServerIndex::GetXXX
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 197
diff changeset
450 int64_t id;
663cc6c46d0a before refactoring of ServerIndex::GetXXX
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 197
diff changeset
451 ResourceType type;
202
1650557bd81a refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 201
diff changeset
452 if (!db_->LookupResource(publicId, id, type) ||
199
dfa2899d9960 refactoring cont
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 198
diff changeset
453 type != expectedType)
198
663cc6c46d0a before refactoring of ServerIndex::GetXXX
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 197
diff changeset
454 {
663cc6c46d0a before refactoring of ServerIndex::GetXXX
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 197
diff changeset
455 return false;
663cc6c46d0a before refactoring of ServerIndex::GetXXX
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 197
diff changeset
456 }
663cc6c46d0a before refactoring of ServerIndex::GetXXX
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 197
diff changeset
457
663cc6c46d0a before refactoring of ServerIndex::GetXXX
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 197
diff changeset
458 // Find the parent resource (if it exists)
663cc6c46d0a before refactoring of ServerIndex::GetXXX
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 197
diff changeset
459 if (type != ResourceType_Patient)
663cc6c46d0a before refactoring of ServerIndex::GetXXX
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 197
diff changeset
460 {
663cc6c46d0a before refactoring of ServerIndex::GetXXX
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 197
diff changeset
461 int64_t parentId;
202
1650557bd81a refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 201
diff changeset
462 if (!db_->LookupParent(parentId, id))
198
663cc6c46d0a before refactoring of ServerIndex::GetXXX
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 197
diff changeset
463 {
663cc6c46d0a before refactoring of ServerIndex::GetXXX
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 197
diff changeset
464 throw OrthancException(ErrorCode_InternalError);
663cc6c46d0a before refactoring of ServerIndex::GetXXX
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 197
diff changeset
465 }
663cc6c46d0a before refactoring of ServerIndex::GetXXX
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 197
diff changeset
466
202
1650557bd81a refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 201
diff changeset
467 std::string parent = db_->GetPublicId(parentId);
198
663cc6c46d0a before refactoring of ServerIndex::GetXXX
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 197
diff changeset
468
663cc6c46d0a before refactoring of ServerIndex::GetXXX
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 197
diff changeset
469 switch (type)
663cc6c46d0a before refactoring of ServerIndex::GetXXX
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 197
diff changeset
470 {
663cc6c46d0a before refactoring of ServerIndex::GetXXX
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 197
diff changeset
471 case ResourceType_Study:
663cc6c46d0a before refactoring of ServerIndex::GetXXX
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 197
diff changeset
472 result["ParentPatient"] = parent;
663cc6c46d0a before refactoring of ServerIndex::GetXXX
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 197
diff changeset
473 break;
663cc6c46d0a before refactoring of ServerIndex::GetXXX
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 197
diff changeset
474
663cc6c46d0a before refactoring of ServerIndex::GetXXX
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 197
diff changeset
475 case ResourceType_Series:
663cc6c46d0a before refactoring of ServerIndex::GetXXX
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 197
diff changeset
476 result["ParentStudy"] = parent;
663cc6c46d0a before refactoring of ServerIndex::GetXXX
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 197
diff changeset
477 break;
663cc6c46d0a before refactoring of ServerIndex::GetXXX
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 197
diff changeset
478
663cc6c46d0a before refactoring of ServerIndex::GetXXX
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 197
diff changeset
479 case ResourceType_Instance:
663cc6c46d0a before refactoring of ServerIndex::GetXXX
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 197
diff changeset
480 result["ParentSeries"] = parent;
663cc6c46d0a before refactoring of ServerIndex::GetXXX
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 197
diff changeset
481 break;
663cc6c46d0a before refactoring of ServerIndex::GetXXX
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 197
diff changeset
482
663cc6c46d0a before refactoring of ServerIndex::GetXXX
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 197
diff changeset
483 default:
663cc6c46d0a before refactoring of ServerIndex::GetXXX
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 197
diff changeset
484 throw OrthancException(ErrorCode_InternalError);
663cc6c46d0a before refactoring of ServerIndex::GetXXX
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 197
diff changeset
485 }
663cc6c46d0a before refactoring of ServerIndex::GetXXX
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 197
diff changeset
486 }
663cc6c46d0a before refactoring of ServerIndex::GetXXX
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 197
diff changeset
487
663cc6c46d0a before refactoring of ServerIndex::GetXXX
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 197
diff changeset
488 // List the children resources
663cc6c46d0a before refactoring of ServerIndex::GetXXX
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 197
diff changeset
489 std::list<std::string> children;
202
1650557bd81a refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 201
diff changeset
490 db_->GetChildrenPublicId(children, id);
198
663cc6c46d0a before refactoring of ServerIndex::GetXXX
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 197
diff changeset
491
663cc6c46d0a before refactoring of ServerIndex::GetXXX
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 197
diff changeset
492 if (type != ResourceType_Instance)
663cc6c46d0a before refactoring of ServerIndex::GetXXX
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 197
diff changeset
493 {
663cc6c46d0a before refactoring of ServerIndex::GetXXX
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 197
diff changeset
494 Json::Value c = Json::arrayValue;
663cc6c46d0a before refactoring of ServerIndex::GetXXX
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 197
diff changeset
495
663cc6c46d0a before refactoring of ServerIndex::GetXXX
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 197
diff changeset
496 for (std::list<std::string>::const_iterator
663cc6c46d0a before refactoring of ServerIndex::GetXXX
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 197
diff changeset
497 it = children.begin(); it != children.end(); it++)
663cc6c46d0a before refactoring of ServerIndex::GetXXX
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 197
diff changeset
498 {
663cc6c46d0a before refactoring of ServerIndex::GetXXX
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 197
diff changeset
499 c.append(*it);
663cc6c46d0a before refactoring of ServerIndex::GetXXX
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 197
diff changeset
500 }
663cc6c46d0a before refactoring of ServerIndex::GetXXX
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 197
diff changeset
501
663cc6c46d0a before refactoring of ServerIndex::GetXXX
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 197
diff changeset
502 switch (type)
663cc6c46d0a before refactoring of ServerIndex::GetXXX
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 197
diff changeset
503 {
663cc6c46d0a before refactoring of ServerIndex::GetXXX
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 197
diff changeset
504 case ResourceType_Patient:
663cc6c46d0a before refactoring of ServerIndex::GetXXX
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 197
diff changeset
505 result["Studies"] = c;
663cc6c46d0a before refactoring of ServerIndex::GetXXX
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 197
diff changeset
506 break;
663cc6c46d0a before refactoring of ServerIndex::GetXXX
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 197
diff changeset
507
663cc6c46d0a before refactoring of ServerIndex::GetXXX
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 197
diff changeset
508 case ResourceType_Study:
663cc6c46d0a before refactoring of ServerIndex::GetXXX
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 197
diff changeset
509 result["Series"] = c;
663cc6c46d0a before refactoring of ServerIndex::GetXXX
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 197
diff changeset
510 break;
663cc6c46d0a before refactoring of ServerIndex::GetXXX
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 197
diff changeset
511
663cc6c46d0a before refactoring of ServerIndex::GetXXX
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 197
diff changeset
512 case ResourceType_Series:
663cc6c46d0a before refactoring of ServerIndex::GetXXX
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 197
diff changeset
513 result["Instances"] = c;
663cc6c46d0a before refactoring of ServerIndex::GetXXX
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 197
diff changeset
514 break;
663cc6c46d0a before refactoring of ServerIndex::GetXXX
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 197
diff changeset
515
663cc6c46d0a before refactoring of ServerIndex::GetXXX
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 197
diff changeset
516 default:
663cc6c46d0a before refactoring of ServerIndex::GetXXX
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 197
diff changeset
517 throw OrthancException(ErrorCode_InternalError);
663cc6c46d0a before refactoring of ServerIndex::GetXXX
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 197
diff changeset
518 }
663cc6c46d0a before refactoring of ServerIndex::GetXXX
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 197
diff changeset
519 }
663cc6c46d0a before refactoring of ServerIndex::GetXXX
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 197
diff changeset
520
663cc6c46d0a before refactoring of ServerIndex::GetXXX
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 197
diff changeset
521 // Set the resource type
663cc6c46d0a before refactoring of ServerIndex::GetXXX
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 197
diff changeset
522 switch (type)
663cc6c46d0a before refactoring of ServerIndex::GetXXX
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 197
diff changeset
523 {
663cc6c46d0a before refactoring of ServerIndex::GetXXX
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 197
diff changeset
524 case ResourceType_Patient:
663cc6c46d0a before refactoring of ServerIndex::GetXXX
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 197
diff changeset
525 result["Type"] = "Patient";
663cc6c46d0a before refactoring of ServerIndex::GetXXX
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 197
diff changeset
526 break;
663cc6c46d0a before refactoring of ServerIndex::GetXXX
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 197
diff changeset
527
663cc6c46d0a before refactoring of ServerIndex::GetXXX
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 197
diff changeset
528 case ResourceType_Study:
663cc6c46d0a before refactoring of ServerIndex::GetXXX
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 197
diff changeset
529 result["Type"] = "Study";
663cc6c46d0a before refactoring of ServerIndex::GetXXX
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 197
diff changeset
530 break;
663cc6c46d0a before refactoring of ServerIndex::GetXXX
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 197
diff changeset
531
663cc6c46d0a before refactoring of ServerIndex::GetXXX
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 197
diff changeset
532 case ResourceType_Series:
199
dfa2899d9960 refactoring cont
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 198
diff changeset
533 {
198
663cc6c46d0a before refactoring of ServerIndex::GetXXX
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 197
diff changeset
534 result["Type"] = "Series";
199
dfa2899d9960 refactoring cont
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 198
diff changeset
535 result["Status"] = ToString(GetSeriesStatus(id));
dfa2899d9960 refactoring cont
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 198
diff changeset
536
200
9c58b2b03cf0 refactoring of read operations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 199
diff changeset
537 int i;
202
1650557bd81a refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 201
diff changeset
538 if (db_->GetMetadataAsInteger(i, id, MetadataType_Series_ExpectedNumberOfInstances))
200
9c58b2b03cf0 refactoring of read operations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 199
diff changeset
539 result["ExpectedNumberOfInstances"] = i;
202
1650557bd81a refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 201
diff changeset
540 else
199
dfa2899d9960 refactoring cont
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 198
diff changeset
541 result["ExpectedNumberOfInstances"] = Json::nullValue;
200
9c58b2b03cf0 refactoring of read operations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 199
diff changeset
542
198
663cc6c46d0a before refactoring of ServerIndex::GetXXX
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 197
diff changeset
543 break;
199
dfa2899d9960 refactoring cont
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 198
diff changeset
544 }
198
663cc6c46d0a before refactoring of ServerIndex::GetXXX
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 197
diff changeset
545
663cc6c46d0a before refactoring of ServerIndex::GetXXX
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 197
diff changeset
546 case ResourceType_Instance:
200
9c58b2b03cf0 refactoring of read operations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 199
diff changeset
547 {
198
663cc6c46d0a before refactoring of ServerIndex::GetXXX
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 197
diff changeset
548 result["Type"] = "Instance";
200
9c58b2b03cf0 refactoring of read operations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 199
diff changeset
549
9c58b2b03cf0 refactoring of read operations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 199
diff changeset
550 std::string fileUuid;
9c58b2b03cf0 refactoring of read operations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 199
diff changeset
551 uint64_t uncompressedSize;
202
1650557bd81a refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 201
diff changeset
552 if (!db_->LookupFile(id, AttachedFileType_Dicom, fileUuid, uncompressedSize))
200
9c58b2b03cf0 refactoring of read operations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 199
diff changeset
553 {
9c58b2b03cf0 refactoring of read operations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 199
diff changeset
554 throw OrthancException(ErrorCode_InternalError);
9c58b2b03cf0 refactoring of read operations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 199
diff changeset
555 }
9c58b2b03cf0 refactoring of read operations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 199
diff changeset
556
9c58b2b03cf0 refactoring of read operations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 199
diff changeset
557 result["FileSize"] = static_cast<unsigned int>(uncompressedSize);
9c58b2b03cf0 refactoring of read operations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 199
diff changeset
558 result["FileUuid"] = fileUuid;
9c58b2b03cf0 refactoring of read operations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 199
diff changeset
559
9c58b2b03cf0 refactoring of read operations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 199
diff changeset
560 int i;
202
1650557bd81a refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 201
diff changeset
561 if (db_->GetMetadataAsInteger(i, id, MetadataType_Instance_IndexInSeries))
200
9c58b2b03cf0 refactoring of read operations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 199
diff changeset
562 result["IndexInSeries"] = i;
9c58b2b03cf0 refactoring of read operations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 199
diff changeset
563 else
9c58b2b03cf0 refactoring of read operations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 199
diff changeset
564 result["IndexInSeries"] = Json::nullValue;
9c58b2b03cf0 refactoring of read operations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 199
diff changeset
565
198
663cc6c46d0a before refactoring of ServerIndex::GetXXX
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 197
diff changeset
566 break;
200
9c58b2b03cf0 refactoring of read operations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 199
diff changeset
567 }
198
663cc6c46d0a before refactoring of ServerIndex::GetXXX
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 197
diff changeset
568
663cc6c46d0a before refactoring of ServerIndex::GetXXX
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 197
diff changeset
569 default:
663cc6c46d0a before refactoring of ServerIndex::GetXXX
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 197
diff changeset
570 throw OrthancException(ErrorCode_InternalError);
663cc6c46d0a before refactoring of ServerIndex::GetXXX
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 197
diff changeset
571 }
663cc6c46d0a before refactoring of ServerIndex::GetXXX
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 197
diff changeset
572
663cc6c46d0a before refactoring of ServerIndex::GetXXX
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 197
diff changeset
573 // Record the remaining information
663cc6c46d0a before refactoring of ServerIndex::GetXXX
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 197
diff changeset
574 result["ID"] = publicId;
202
1650557bd81a refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 201
diff changeset
575 MainDicomTagsToJson(result, id);
198
663cc6c46d0a before refactoring of ServerIndex::GetXXX
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 197
diff changeset
576
663cc6c46d0a before refactoring of ServerIndex::GetXXX
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 197
diff changeset
577 return true;
663cc6c46d0a before refactoring of ServerIndex::GetXXX
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 197
diff changeset
578 }
663cc6c46d0a before refactoring of ServerIndex::GetXXX
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 197
diff changeset
579
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
580
193
a1b9d1e1497b failed attempt to compile with linux standard base
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 192
diff changeset
581 bool ServerIndex::GetFile(std::string& fileUuid,
a1b9d1e1497b failed attempt to compile with linux standard base
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 192
diff changeset
582 CompressionType& compressionType,
a1b9d1e1497b failed attempt to compile with linux standard base
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 192
diff changeset
583 const std::string& instanceUuid,
197
530a25320461 removal of text as ids in sqlite db
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 194
diff changeset
584 AttachedFileType contentType)
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
585 {
206
4453a010d0db flush to disk thread
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 205
diff changeset
586 boost::mutex::scoped_lock lock(mutex_);
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
587
193
a1b9d1e1497b failed attempt to compile with linux standard base
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 192
diff changeset
588 int64_t id;
a1b9d1e1497b failed attempt to compile with linux standard base
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 192
diff changeset
589 ResourceType type;
202
1650557bd81a refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 201
diff changeset
590 if (!db_->LookupResource(instanceUuid, id, type) ||
193
a1b9d1e1497b failed attempt to compile with linux standard base
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 192
diff changeset
591 type != ResourceType_Instance)
192
c56dc32266e0 refactoring getfile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 191
diff changeset
592 {
c56dc32266e0 refactoring getfile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 191
diff changeset
593 throw OrthancException(ErrorCode_InternalError);
c56dc32266e0 refactoring getfile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 191
diff changeset
594 }
193
a1b9d1e1497b failed attempt to compile with linux standard base
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 192
diff changeset
595
a1b9d1e1497b failed attempt to compile with linux standard base
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 192
diff changeset
596 uint64_t compressedSize, uncompressedSize;
a1b9d1e1497b failed attempt to compile with linux standard base
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 192
diff changeset
597
202
1650557bd81a refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 201
diff changeset
598 return db_->LookupFile(id, contentType, fileUuid, compressedSize, uncompressedSize, compressionType);
192
c56dc32266e0 refactoring getfile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 191
diff changeset
599 }
c56dc32266e0 refactoring getfile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 191
diff changeset
600
c56dc32266e0 refactoring getfile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 191
diff changeset
601
c56dc32266e0 refactoring getfile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 191
diff changeset
602
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
603 void ServerIndex::GetAllUuids(Json::Value& target,
190
b6cef9d45cc3 getallpublicids
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 189
diff changeset
604 ResourceType resourceType)
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
605 {
206
4453a010d0db flush to disk thread
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 205
diff changeset
606 boost::mutex::scoped_lock lock(mutex_);
202
1650557bd81a refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 201
diff changeset
607 db_->GetAllPublicIds(target, resourceType);
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
608 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
609
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
610
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
611 bool ServerIndex::GetChanges(Json::Value& target,
204
7f4acf490179 changes api
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 202
diff changeset
612 int64_t since,
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
613 unsigned int maxResults)
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
614 {
206
4453a010d0db flush to disk thread
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 205
diff changeset
615 boost::mutex::scoped_lock lock(mutex_);
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
616
204
7f4acf490179 changes api
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 202
diff changeset
617 db_->GetChanges(target, since, maxResults);
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
618
204
7f4acf490179 changes api
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 202
diff changeset
619 return true;
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
620 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
621 }