Mercurial > hg > orthanc
annotate OrthancServer/Sources/Database/SQLiteDatabaseWrapper.cpp @ 5676:b744a2cf408a find-refactoring
shorten ParentRetrieveSpecification/ChildrenRetrieveSpecification as ParentSpecification/ChildrenSpecification
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Sat, 06 Jul 2024 15:04:28 +0200 |
parents | 3f13db27b399 |
children | 77875b51cf95 |
rev | line source |
---|---|
183 | 1 /** |
2 * Orthanc - A Lightweight, RESTful DICOM Store | |
1900 | 3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics |
1288
6e7e5ed91c2d
upgrade to year 2015
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1286
diff
changeset
|
4 * Department, University Hospital of Liege, Belgium |
5640
f7adfb22e20e
updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5521
diff
changeset
|
5 * Copyright (C) 2017-2023 Osimis S.A., Belgium |
f7adfb22e20e
updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5521
diff
changeset
|
6 * Copyright (C) 2024-2024 Orthanc Team SRL, Belgium |
5485
48b8dae6dc77
upgrade to year 2024
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5256
diff
changeset
|
7 * Copyright (C) 2021-2024 Sebastien Jodogne, ICTEAM UCLouvain, Belgium |
183 | 8 * |
9 * This program is free software: you can redistribute it and/or | |
10 * modify it under the terms of the GNU General Public License as | |
11 * published by the Free Software Foundation, either version 3 of the | |
12 * License, or (at your option) any later version. | |
13 * | |
14 * This program is distributed in the hope that it will be useful, but | |
15 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
17 * General Public License for more details. | |
18 * | |
19 * You should have received a copy of the GNU General Public License | |
20 * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
21 **/ | |
22 | |
23 | |
3093
2e1808b6146a
reorganization of folders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3080
diff
changeset
|
24 #include "../PrecompiledHeadersServer.h" |
3017
517fc4767ae0
renamed class DatabaseWrapper as SQLiteDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2955
diff
changeset
|
25 #include "SQLiteDatabaseWrapper.h" |
183 | 26 |
4045 | 27 #include "../../../OrthancFramework/Sources/DicomFormat/DicomArray.h" |
28 #include "../../../OrthancFramework/Sources/Logging.h" | |
29 #include "../../../OrthancFramework/Sources/SQLite/Transaction.h" | |
3093
2e1808b6146a
reorganization of folders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3080
diff
changeset
|
30 #include "../Search/ISqlLookupFormatter.h" |
2e1808b6146a
reorganization of folders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3080
diff
changeset
|
31 #include "../ServerToolbox.h" |
5554
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5521
diff
changeset
|
32 #include "Compatibility/GenericFind.h" |
4591
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
33 #include "Compatibility/ICreateInstance.h" |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
34 #include "Compatibility/IGetChildrenMetadata.h" |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
35 #include "Compatibility/ILookupResourceAndParent.h" |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
36 #include "Compatibility/ISetResourcesContent.h" |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
37 #include "VoidDatabaseListener.h" |
3093
2e1808b6146a
reorganization of folders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3080
diff
changeset
|
38 |
4032
058b5ade8acd
renaming embedded resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4031
diff
changeset
|
39 #include <OrthancServerResources.h> |
183 | 40 |
41 #include <stdio.h> | |
1247 | 42 #include <boost/lexical_cast.hpp> |
183 | 43 |
44 namespace Orthanc | |
4591
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
45 { |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
46 class SQLiteDatabaseWrapper::LookupFormatter : public ISqlLookupFormatter |
183 | 47 { |
4589
bec74e29f86b
attaching the listener to transactions in IDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4571
diff
changeset
|
48 private: |
4591
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
49 std::list<std::string> values_; |
4589
bec74e29f86b
attaching the listener to transactions in IDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4571
diff
changeset
|
50 |
bec74e29f86b
attaching the listener to transactions in IDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4571
diff
changeset
|
51 public: |
4591
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
52 virtual std::string GenerateParameter(const std::string& value) ORTHANC_OVERRIDE |
4589
bec74e29f86b
attaching the listener to transactions in IDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4571
diff
changeset
|
53 { |
4591
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
54 values_.push_back(value); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
55 return "?"; |
4589
bec74e29f86b
attaching the listener to transactions in IDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4571
diff
changeset
|
56 } |
4591
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
57 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
58 virtual std::string FormatResourceType(ResourceType level) ORTHANC_OVERRIDE |
4589
bec74e29f86b
attaching the listener to transactions in IDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4571
diff
changeset
|
59 { |
4591
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
60 return boost::lexical_cast<std::string>(level); |
4589
bec74e29f86b
attaching the listener to transactions in IDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4571
diff
changeset
|
61 } |
183 | 62 |
4591
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
63 virtual std::string FormatWildcardEscape() ORTHANC_OVERRIDE |
4589
bec74e29f86b
attaching the listener to transactions in IDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4571
diff
changeset
|
64 { |
4591
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
65 return "ESCAPE '\\'"; |
4589
bec74e29f86b
attaching the listener to transactions in IDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4571
diff
changeset
|
66 } |
1158 | 67 |
4817
b8fcd331b4b3
added ISqlLookupFormatter::IsEscapeBrackets()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4627
diff
changeset
|
68 virtual bool IsEscapeBrackets() const ORTHANC_OVERRIDE |
b8fcd331b4b3
added ISqlLookupFormatter::IsEscapeBrackets()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4627
diff
changeset
|
69 { |
b8fcd331b4b3
added ISqlLookupFormatter::IsEscapeBrackets()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4627
diff
changeset
|
70 return false; |
b8fcd331b4b3
added ISqlLookupFormatter::IsEscapeBrackets()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4627
diff
changeset
|
71 } |
b8fcd331b4b3
added ISqlLookupFormatter::IsEscapeBrackets()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4627
diff
changeset
|
72 |
4591
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
73 void Bind(SQLite::Statement& statement) const |
4589
bec74e29f86b
attaching the listener to transactions in IDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4571
diff
changeset
|
74 { |
4591
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
75 size_t pos = 0; |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
76 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
77 for (std::list<std::string>::const_iterator |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
78 it = values_.begin(); it != values_.end(); ++it, pos++) |
1158 | 79 { |
4591
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
80 statement.BindString(pos, *it); |
1158 | 81 } |
4589
bec74e29f86b
attaching the listener to transactions in IDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4571
diff
changeset
|
82 } |
bec74e29f86b
attaching the listener to transactions in IDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4571
diff
changeset
|
83 }; |
1158 | 84 |
4589
bec74e29f86b
attaching the listener to transactions in IDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4571
diff
changeset
|
85 |
bec74e29f86b
attaching the listener to transactions in IDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4571
diff
changeset
|
86 class SQLiteDatabaseWrapper::SignalRemainingAncestor : public SQLite::IScalarFunction |
bec74e29f86b
attaching the listener to transactions in IDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4571
diff
changeset
|
87 { |
bec74e29f86b
attaching the listener to transactions in IDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4571
diff
changeset
|
88 private: |
bec74e29f86b
attaching the listener to transactions in IDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4571
diff
changeset
|
89 bool hasRemainingAncestor_; |
bec74e29f86b
attaching the listener to transactions in IDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4571
diff
changeset
|
90 std::string remainingPublicId_; |
bec74e29f86b
attaching the listener to transactions in IDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4571
diff
changeset
|
91 ResourceType remainingType_; |
660 | 92 |
4589
bec74e29f86b
attaching the listener to transactions in IDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4571
diff
changeset
|
93 public: |
bec74e29f86b
attaching the listener to transactions in IDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4571
diff
changeset
|
94 SignalRemainingAncestor() : |
bec74e29f86b
attaching the listener to transactions in IDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4571
diff
changeset
|
95 hasRemainingAncestor_(false) |
bec74e29f86b
attaching the listener to transactions in IDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4571
diff
changeset
|
96 { |
bec74e29f86b
attaching the listener to transactions in IDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4571
diff
changeset
|
97 } |
183 | 98 |
4589
bec74e29f86b
attaching the listener to transactions in IDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4571
diff
changeset
|
99 void Reset() |
bec74e29f86b
attaching the listener to transactions in IDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4571
diff
changeset
|
100 { |
bec74e29f86b
attaching the listener to transactions in IDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4571
diff
changeset
|
101 hasRemainingAncestor_ = false; |
bec74e29f86b
attaching the listener to transactions in IDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4571
diff
changeset
|
102 } |
183 | 103 |
4589
bec74e29f86b
attaching the listener to transactions in IDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4571
diff
changeset
|
104 virtual const char* GetName() const ORTHANC_OVERRIDE |
bec74e29f86b
attaching the listener to transactions in IDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4571
diff
changeset
|
105 { |
bec74e29f86b
attaching the listener to transactions in IDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4571
diff
changeset
|
106 return "SignalRemainingAncestor"; |
bec74e29f86b
attaching the listener to transactions in IDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4571
diff
changeset
|
107 } |
183 | 108 |
4589
bec74e29f86b
attaching the listener to transactions in IDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4571
diff
changeset
|
109 virtual unsigned int GetCardinality() const ORTHANC_OVERRIDE |
bec74e29f86b
attaching the listener to transactions in IDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4571
diff
changeset
|
110 { |
bec74e29f86b
attaching the listener to transactions in IDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4571
diff
changeset
|
111 return 2; |
bec74e29f86b
attaching the listener to transactions in IDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4571
diff
changeset
|
112 } |
bec74e29f86b
attaching the listener to transactions in IDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4571
diff
changeset
|
113 |
bec74e29f86b
attaching the listener to transactions in IDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4571
diff
changeset
|
114 virtual void Compute(SQLite::FunctionContext& context) ORTHANC_OVERRIDE |
bec74e29f86b
attaching the listener to transactions in IDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4571
diff
changeset
|
115 { |
bec74e29f86b
attaching the listener to transactions in IDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4571
diff
changeset
|
116 CLOG(TRACE, SQLITE) << "There exists a remaining ancestor with public ID \"" |
bec74e29f86b
attaching the listener to transactions in IDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4571
diff
changeset
|
117 << context.GetStringValue(0) << "\" of type " |
bec74e29f86b
attaching the listener to transactions in IDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4571
diff
changeset
|
118 << context.GetIntValue(1); |
183 | 119 |
4589
bec74e29f86b
attaching the listener to transactions in IDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4571
diff
changeset
|
120 if (!hasRemainingAncestor_ || |
bec74e29f86b
attaching the listener to transactions in IDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4571
diff
changeset
|
121 remainingType_ >= context.GetIntValue(1)) |
bec74e29f86b
attaching the listener to transactions in IDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4571
diff
changeset
|
122 { |
bec74e29f86b
attaching the listener to transactions in IDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4571
diff
changeset
|
123 hasRemainingAncestor_ = true; |
bec74e29f86b
attaching the listener to transactions in IDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4571
diff
changeset
|
124 remainingPublicId_ = context.GetStringValue(0); |
bec74e29f86b
attaching the listener to transactions in IDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4571
diff
changeset
|
125 remainingType_ = static_cast<ResourceType>(context.GetIntValue(1)); |
183 | 126 } |
4589
bec74e29f86b
attaching the listener to transactions in IDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4571
diff
changeset
|
127 } |
183 | 128 |
4589
bec74e29f86b
attaching the listener to transactions in IDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4571
diff
changeset
|
129 bool HasRemainingAncestor() const |
bec74e29f86b
attaching the listener to transactions in IDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4571
diff
changeset
|
130 { |
bec74e29f86b
attaching the listener to transactions in IDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4571
diff
changeset
|
131 return hasRemainingAncestor_; |
bec74e29f86b
attaching the listener to transactions in IDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4571
diff
changeset
|
132 } |
183 | 133 |
4589
bec74e29f86b
attaching the listener to transactions in IDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4571
diff
changeset
|
134 const std::string& GetRemainingAncestorId() const |
bec74e29f86b
attaching the listener to transactions in IDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4571
diff
changeset
|
135 { |
bec74e29f86b
attaching the listener to transactions in IDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4571
diff
changeset
|
136 assert(hasRemainingAncestor_); |
bec74e29f86b
attaching the listener to transactions in IDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4571
diff
changeset
|
137 return remainingPublicId_; |
bec74e29f86b
attaching the listener to transactions in IDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4571
diff
changeset
|
138 } |
bec74e29f86b
attaching the listener to transactions in IDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4571
diff
changeset
|
139 |
bec74e29f86b
attaching the listener to transactions in IDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4571
diff
changeset
|
140 ResourceType GetRemainingAncestorType() const |
bec74e29f86b
attaching the listener to transactions in IDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4571
diff
changeset
|
141 { |
bec74e29f86b
attaching the listener to transactions in IDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4571
diff
changeset
|
142 assert(hasRemainingAncestor_); |
bec74e29f86b
attaching the listener to transactions in IDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4571
diff
changeset
|
143 return remainingType_; |
bec74e29f86b
attaching the listener to transactions in IDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4571
diff
changeset
|
144 } |
bec74e29f86b
attaching the listener to transactions in IDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4571
diff
changeset
|
145 }; |
183 | 146 |
147 | |
4591
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
148 class SQLiteDatabaseWrapper::TransactionBase : |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
149 public SQLiteDatabaseWrapper::UnitTestsTransaction, |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
150 public Compatibility::ICreateInstance, |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
151 public Compatibility::IGetChildrenMetadata, |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
152 public Compatibility::ILookupResourceAndParent, |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
153 public Compatibility::ISetResourcesContent |
2773
bb63068844ae
moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
154 { |
4591
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
155 private: |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
156 void AnswerLookup(std::list<std::string>& resourcesId, |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
157 std::list<std::string>& instancesId, |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
158 ResourceType level) |
2773
bb63068844ae
moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
159 { |
4591
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
160 resourcesId.clear(); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
161 instancesId.clear(); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
162 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
163 std::unique_ptr<SQLite::Statement> statement; |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
164 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
165 switch (level) |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
166 { |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
167 case ResourceType_Patient: |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
168 { |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
169 statement.reset( |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
170 new SQLite::Statement( |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
171 db_, SQLITE_FROM_HERE, |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
172 "SELECT patients.publicId, instances.publicID FROM Lookup AS patients " |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
173 "INNER JOIN Resources studies ON patients.internalId=studies.parentId " |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
174 "INNER JOIN Resources series ON studies.internalId=series.parentId " |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
175 "INNER JOIN Resources instances ON series.internalId=instances.parentId " |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
176 "GROUP BY patients.publicId")); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
177 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
178 break; |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
179 } |
2773
bb63068844ae
moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
180 |
4591
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
181 case ResourceType_Study: |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
182 { |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
183 statement.reset( |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
184 new SQLite::Statement( |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
185 db_, SQLITE_FROM_HERE, |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
186 "SELECT studies.publicId, instances.publicID FROM Lookup AS studies " |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
187 "INNER JOIN Resources series ON studies.internalId=series.parentId " |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
188 "INNER JOIN Resources instances ON series.internalId=instances.parentId " |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
189 "GROUP BY studies.publicId")); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
190 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
191 break; |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
192 } |
2773
bb63068844ae
moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
193 |
4591
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
194 case ResourceType_Series: |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
195 { |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
196 statement.reset( |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
197 new SQLite::Statement( |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
198 db_, SQLITE_FROM_HERE, |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
199 "SELECT series.publicId, instances.publicID FROM Lookup AS series " |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
200 "INNER JOIN Resources instances ON series.internalId=instances.parentId " |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
201 "GROUP BY series.publicId")); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
202 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
203 break; |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
204 } |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
205 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
206 case ResourceType_Instance: |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
207 { |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
208 statement.reset( |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
209 new SQLite::Statement( |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
210 db_, SQLITE_FROM_HERE, "SELECT publicId, publicId FROM Lookup")); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
211 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
212 break; |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
213 } |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
214 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
215 default: |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
216 throw OrthancException(ErrorCode_InternalError); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
217 } |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
218 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
219 assert(statement.get() != NULL); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
220 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
221 while (statement->Step()) |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
222 { |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
223 resourcesId.push_back(statement->ColumnString(0)); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
224 instancesId.push_back(statement->ColumnString(1)); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
225 } |
2773
bb63068844ae
moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
226 } |
bb63068844ae
moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
227 |
4591
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
228 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
229 void ClearTable(const std::string& tableName) |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
230 { |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
231 db_.Execute("DELETE FROM " + tableName); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
232 } |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
233 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
234 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
235 void GetChangesInternal(std::list<ServerIndexChange>& target, |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
236 bool& done, |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
237 SQLite::Statement& s, |
5213
055428d92772
clarifying types of since/limit in IDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5193
diff
changeset
|
238 uint32_t limit) |
4591
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
239 { |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
240 target.clear(); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
241 |
5213
055428d92772
clarifying types of since/limit in IDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5193
diff
changeset
|
242 while (target.size() < limit && s.Step()) |
4591
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
243 { |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
244 int64_t seq = s.ColumnInt64(0); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
245 ChangeType changeType = static_cast<ChangeType>(s.ColumnInt(1)); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
246 ResourceType resourceType = static_cast<ResourceType>(s.ColumnInt(3)); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
247 const std::string& date = s.ColumnString(4); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
248 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
249 int64_t internalId = s.ColumnInt64(2); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
250 std::string publicId = GetPublicId(internalId); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
251 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
252 target.push_back(ServerIndexChange(seq, changeType, resourceType, publicId, date)); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
253 } |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
254 |
5213
055428d92772
clarifying types of since/limit in IDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5193
diff
changeset
|
255 done = !(target.size() == limit && s.Step()); |
4591
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
256 } |
2773
bb63068844ae
moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
257 |
bb63068844ae
moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
258 |
4591
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
259 void GetExportedResourcesInternal(std::list<ExportedResource>& target, |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
260 bool& done, |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
261 SQLite::Statement& s, |
5213
055428d92772
clarifying types of since/limit in IDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5193
diff
changeset
|
262 uint32_t limit) |
2773
bb63068844ae
moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
263 { |
4591
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
264 target.clear(); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
265 |
5213
055428d92772
clarifying types of since/limit in IDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5193
diff
changeset
|
266 while (target.size() < limit && s.Step()) |
4591
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
267 { |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
268 int64_t seq = s.ColumnInt64(0); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
269 ResourceType resourceType = static_cast<ResourceType>(s.ColumnInt(1)); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
270 std::string publicId = s.ColumnString(2); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
271 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
272 ExportedResource resource(seq, |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
273 resourceType, |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
274 publicId, |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
275 s.ColumnString(3), // modality |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
276 s.ColumnString(8), // date |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
277 s.ColumnString(4), // patient ID |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
278 s.ColumnString(5), // study instance UID |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
279 s.ColumnString(6), // series instance UID |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
280 s.ColumnString(7)); // sop instance UID |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
281 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
282 target.push_back(resource); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
283 } |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
284 |
5213
055428d92772
clarifying types of since/limit in IDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5193
diff
changeset
|
285 done = !(target.size() == limit && s.Step()); |
4591
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
286 } |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
287 |
2773
bb63068844ae
moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
288 |
4591
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
289 void GetChildren(std::list<std::string>& childrenPublicIds, |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
290 int64_t id) |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
291 { |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
292 SQLite::Statement s(db_, SQLITE_FROM_HERE, "SELECT publicId FROM Resources WHERE parentId=?"); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
293 s.BindInt64(0, id); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
294 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
295 childrenPublicIds.clear(); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
296 while (s.Step()) |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
297 { |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
298 childrenPublicIds.push_back(s.ColumnString(0)); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
299 } |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
300 } |
2773
bb63068844ae
moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
301 |
4594
d494b4f1103e
removed the global database mutex from ServerIndex and StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4592
diff
changeset
|
302 boost::mutex::scoped_lock lock_; |
d494b4f1103e
removed the global database mutex from ServerIndex and StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4592
diff
changeset
|
303 IDatabaseListener& listener_; |
d494b4f1103e
removed the global database mutex from ServerIndex and StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4592
diff
changeset
|
304 SignalRemainingAncestor& signalRemainingAncestor_; |
4591
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
305 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
306 public: |
4594
d494b4f1103e
removed the global database mutex from ServerIndex and StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4592
diff
changeset
|
307 TransactionBase(boost::mutex& mutex, |
d494b4f1103e
removed the global database mutex from ServerIndex and StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4592
diff
changeset
|
308 SQLite::Connection& db, |
4591
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
309 IDatabaseListener& listener, |
5521
0d0f8788884a
removed unused variable dbCapabilities_ in SQLiteDatabaseWrapper::TransactionBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5519
diff
changeset
|
310 SignalRemainingAncestor& signalRemainingAncestor) : |
4591
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
311 UnitTestsTransaction(db), |
4594
d494b4f1103e
removed the global database mutex from ServerIndex and StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4592
diff
changeset
|
312 lock_(mutex), |
4591
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
313 listener_(listener), |
5521
0d0f8788884a
removed unused variable dbCapabilities_ in SQLiteDatabaseWrapper::TransactionBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5519
diff
changeset
|
314 signalRemainingAncestor_(signalRemainingAncestor) |
4591
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
315 { |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
316 } |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
317 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
318 IDatabaseListener& GetListener() const |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
319 { |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
320 return listener_; |
2773
bb63068844ae
moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
321 } |
bb63068844ae
moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
322 |
4591
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
323 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
324 virtual void AddAttachment(int64_t id, |
4627
f7d5372b59b3
handling revisions of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4623
diff
changeset
|
325 const FileInfo& attachment, |
f7d5372b59b3
handling revisions of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4623
diff
changeset
|
326 int64_t revision) ORTHANC_OVERRIDE |
4591
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
327 { |
4627
f7d5372b59b3
handling revisions of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4623
diff
changeset
|
328 // TODO - REVISIONS |
5090
cc1a8b3ff319
Made the default SQLite DB more robust wrt future updates like adding new columns in DB.
Alain Mazy <am@osimis.io>
parents:
5057
diff
changeset
|
329 SQLite::Statement s(db_, SQLITE_FROM_HERE, "INSERT INTO AttachedFiles (id, fileType, uuid, compressedSize, uncompressedSize, compressionType, uncompressedMD5, compressedMD5) VALUES(?, ?, ?, ?, ?, ?, ?, ?)"); |
4591
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
330 s.BindInt64(0, id); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
331 s.BindInt(1, attachment.GetContentType()); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
332 s.BindString(2, attachment.GetUuid()); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
333 s.BindInt64(3, attachment.GetCompressedSize()); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
334 s.BindInt64(4, attachment.GetUncompressedSize()); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
335 s.BindInt(5, attachment.GetCompressionType()); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
336 s.BindString(6, attachment.GetUncompressedMD5()); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
337 s.BindString(7, attachment.GetCompressedMD5()); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
338 s.Run(); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
339 } |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
340 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
341 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
342 virtual void ApplyLookupResources(std::list<std::string>& resourcesId, |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
343 std::list<std::string>* instancesId, |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
344 const std::vector<DatabaseConstraint>& lookup, |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
345 ResourceType queryLevel, |
5248
a7d95f951f8a
replaced "WithLabels" and "WithoutLabels", by "Labels" and "LabelsConstraint"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5227
diff
changeset
|
346 const std::set<std::string>& labels, |
a7d95f951f8a
replaced "WithLabels" and "WithoutLabels", by "Labels" and "LabelsConstraint"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5227
diff
changeset
|
347 LabelsConstraint labelsConstraint, |
5213
055428d92772
clarifying types of since/limit in IDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5193
diff
changeset
|
348 uint32_t limit) ORTHANC_OVERRIDE |
4591
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
349 { |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
350 LookupFormatter formatter; |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
351 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
352 std::string sql; |
5248
a7d95f951f8a
replaced "WithLabels" and "WithoutLabels", by "Labels" and "LabelsConstraint"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5227
diff
changeset
|
353 LookupFormatter::Apply(sql, formatter, lookup, queryLevel, labels, labelsConstraint, limit); |
4591
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
354 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
355 sql = "CREATE TEMPORARY TABLE Lookup AS " + sql; |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
356 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
357 { |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
358 SQLite::Statement s(db_, SQLITE_FROM_HERE, "DROP TABLE IF EXISTS Lookup"); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
359 s.Run(); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
360 } |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
361 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
362 { |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
363 SQLite::Statement statement(db_, sql); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
364 formatter.Bind(statement); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
365 statement.Run(); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
366 } |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
367 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
368 if (instancesId != NULL) |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
369 { |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
370 AnswerLookup(resourcesId, *instancesId, queryLevel); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
371 } |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
372 else |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
373 { |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
374 resourcesId.clear(); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
375 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
376 SQLite::Statement s(db_, SQLITE_FROM_HERE, "SELECT publicId FROM Lookup"); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
377 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
378 while (s.Step()) |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
379 { |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
380 resourcesId.push_back(s.ColumnString(0)); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
381 } |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
382 } |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
383 } |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
384 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
385 |
4592 | 386 // From the "ICreateInstance" interface |
4591
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
387 virtual void AttachChild(int64_t parent, |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
388 int64_t child) ORTHANC_OVERRIDE |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
389 { |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
390 SQLite::Statement s(db_, SQLITE_FROM_HERE, "UPDATE Resources SET parentId = ? WHERE internalId = ?"); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
391 s.BindInt64(0, parent); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
392 s.BindInt64(1, child); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
393 s.Run(); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
394 } |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
395 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
396 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
397 virtual void ClearChanges() ORTHANC_OVERRIDE |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
398 { |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
399 ClearTable("Changes"); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
400 } |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
401 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
402 virtual void ClearExportedResources() ORTHANC_OVERRIDE |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
403 { |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
404 ClearTable("ExportedResources"); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
405 } |
2773
bb63068844ae
moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
406 |
1241 | 407 |
4591
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
408 virtual void ClearMainDicomTags(int64_t id) ORTHANC_OVERRIDE |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
409 { |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
410 { |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
411 SQLite::Statement s(db_, SQLITE_FROM_HERE, "DELETE FROM DicomIdentifiers WHERE id=?"); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
412 s.BindInt64(0, id); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
413 s.Run(); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
414 } |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
415 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
416 { |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
417 SQLite::Statement s(db_, SQLITE_FROM_HERE, "DELETE FROM MainDicomTags WHERE id=?"); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
418 s.BindInt64(0, id); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
419 s.Run(); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
420 } |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
421 } |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
422 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
423 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
424 virtual bool CreateInstance(CreateInstanceResult& result, |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
425 int64_t& instanceId, |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
426 const std::string& patient, |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
427 const std::string& study, |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
428 const std::string& series, |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
429 const std::string& instance) ORTHANC_OVERRIDE |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
430 { |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
431 return ICreateInstance::Apply |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
432 (*this, result, instanceId, patient, study, series, instance); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
433 } |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
434 |
193
a1b9d1e1497b
failed attempt to compile with linux standard base
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
435 |
4592 | 436 // From the "ICreateInstance" interface |
4591
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
437 virtual int64_t CreateResource(const std::string& publicId, |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
438 ResourceType type) ORTHANC_OVERRIDE |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
439 { |
5090
cc1a8b3ff319
Made the default SQLite DB more robust wrt future updates like adding new columns in DB.
Alain Mazy <am@osimis.io>
parents:
5057
diff
changeset
|
440 SQLite::Statement s(db_, SQLITE_FROM_HERE, "INSERT INTO Resources (internalId, resourceType, publicId, parentId) VALUES(NULL, ?, ?, NULL)"); |
4591
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
441 s.BindInt(0, type); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
442 s.BindString(1, publicId); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
443 s.Run(); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
444 return db_.GetLastInsertRowId(); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
445 } |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
446 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
447 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
448 virtual void DeleteAttachment(int64_t id, |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
449 FileContentType attachment) ORTHANC_OVERRIDE |
193
a1b9d1e1497b
failed attempt to compile with linux standard base
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
450 { |
4591
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
451 SQLite::Statement s(db_, SQLITE_FROM_HERE, "DELETE FROM AttachedFiles WHERE id=? AND fileType=?"); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
452 s.BindInt64(0, id); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
453 s.BindInt(1, attachment); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
454 s.Run(); |
193
a1b9d1e1497b
failed attempt to compile with linux standard base
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
455 } |
4591
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
456 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
457 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
458 virtual void DeleteMetadata(int64_t id, |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
459 MetadataType type) ORTHANC_OVERRIDE |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
460 { |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
461 SQLite::Statement s(db_, SQLITE_FROM_HERE, "DELETE FROM Metadata WHERE id=? and type=?"); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
462 s.BindInt64(0, id); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
463 s.BindInt(1, type); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
464 s.Run(); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
465 } |
193
a1b9d1e1497b
failed attempt to compile with linux standard base
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
466 |
a1b9d1e1497b
failed attempt to compile with linux standard base
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
467 |
4591
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
468 virtual void DeleteResource(int64_t id) ORTHANC_OVERRIDE |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
469 { |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
470 signalRemainingAncestor_.Reset(); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
471 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
472 SQLite::Statement s(db_, SQLITE_FROM_HERE, "DELETE FROM Resources WHERE internalId=?"); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
473 s.BindInt64(0, id); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
474 s.Run(); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
475 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
476 if (signalRemainingAncestor_.HasRemainingAncestor()) |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
477 { |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
478 listener_.SignalRemainingAncestor(signalRemainingAncestor_.GetRemainingAncestorType(), |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
479 signalRemainingAncestor_.GetRemainingAncestorId()); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
480 } |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
481 } |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
482 |
183 | 483 |
4591
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
484 virtual void GetAllMetadata(std::map<MetadataType, std::string>& target, |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
485 int64_t id) ORTHANC_OVERRIDE |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
486 { |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
487 target.clear(); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
488 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
489 SQLite::Statement s(db_, SQLITE_FROM_HERE, "SELECT type, value FROM Metadata WHERE id=?"); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
490 s.BindInt64(0, id); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
491 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
492 while (s.Step()) |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
493 { |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
494 MetadataType key = static_cast<MetadataType>(s.ColumnInt(0)); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
495 target[key] = s.ColumnString(1); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
496 } |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
497 } |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
498 |
183 | 499 |
4591
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
500 virtual void GetAllPublicIds(std::list<std::string>& target, |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
501 ResourceType resourceType) ORTHANC_OVERRIDE |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
502 { |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
503 SQLite::Statement s(db_, SQLITE_FROM_HERE, "SELECT publicId FROM Resources WHERE resourceType=?"); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
504 s.BindInt(0, resourceType); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
505 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
506 target.clear(); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
507 while (s.Step()) |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
508 { |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
509 target.push_back(s.ColumnString(0)); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
510 } |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
511 } |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
512 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
513 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
514 virtual void GetAllPublicIds(std::list<std::string>& target, |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
515 ResourceType resourceType, |
5213
055428d92772
clarifying types of since/limit in IDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5193
diff
changeset
|
516 int64_t since, |
055428d92772
clarifying types of since/limit in IDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5193
diff
changeset
|
517 uint32_t limit) ORTHANC_OVERRIDE |
183 | 518 { |
4591
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
519 if (limit == 0) |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
520 { |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
521 target.clear(); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
522 return; |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
523 } |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
524 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
525 SQLite::Statement s(db_, SQLITE_FROM_HERE, |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
526 "SELECT publicId FROM Resources WHERE " |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
527 "resourceType=? LIMIT ? OFFSET ?"); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
528 s.BindInt(0, resourceType); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
529 s.BindInt64(1, limit); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
530 s.BindInt64(2, since); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
531 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
532 target.clear(); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
533 while (s.Step()) |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
534 { |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
535 target.push_back(s.ColumnString(0)); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
536 } |
183 | 537 } |
538 | |
539 | |
4591
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
540 virtual void GetChanges(std::list<ServerIndexChange>& target /*out*/, |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
541 bool& done /*out*/, |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
542 int64_t since, |
5213
055428d92772
clarifying types of since/limit in IDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5193
diff
changeset
|
543 uint32_t limit) ORTHANC_OVERRIDE |
4591
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
544 { |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
545 SQLite::Statement s(db_, SQLITE_FROM_HERE, "SELECT * FROM Changes WHERE seq>? ORDER BY seq LIMIT ?"); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
546 s.BindInt64(0, since); |
5213
055428d92772
clarifying types of since/limit in IDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5193
diff
changeset
|
547 s.BindInt(1, limit + 1); |
055428d92772
clarifying types of since/limit in IDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5193
diff
changeset
|
548 GetChangesInternal(target, done, s, limit); |
4591
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
549 } |
183 | 550 |
4591
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
551 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
552 virtual void GetChildrenMetadata(std::list<std::string>& target, |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
553 int64_t resourceId, |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
554 MetadataType metadata) ORTHANC_OVERRIDE |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
555 { |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
556 IGetChildrenMetadata::Apply(*this, target, resourceId, metadata); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
557 } |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
558 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
559 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
560 virtual void GetChildrenInternalId(std::list<int64_t>& target, |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
561 int64_t id) ORTHANC_OVERRIDE |
183 | 562 { |
4591
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
563 SQLite::Statement s(db_, SQLITE_FROM_HERE, "SELECT a.internalId FROM Resources AS a, Resources AS b " |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
564 "WHERE a.parentId = b.internalId AND b.internalId = ?"); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
565 s.BindInt64(0, id); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
566 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
567 target.clear(); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
568 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
569 while (s.Step()) |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
570 { |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
571 target.push_back(s.ColumnInt64(0)); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
572 } |
183 | 573 } |
4591
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
574 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
575 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
576 virtual void GetChildrenPublicId(std::list<std::string>& target, |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
577 int64_t id) ORTHANC_OVERRIDE |
183 | 578 { |
4591
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
579 SQLite::Statement s(db_, SQLITE_FROM_HERE, "SELECT a.publicId FROM Resources AS a, Resources AS b " |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
580 "WHERE a.parentId = b.internalId AND b.internalId = ?"); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
581 s.BindInt64(0, id); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
582 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
583 target.clear(); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
584 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
585 while (s.Step()) |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
586 { |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
587 target.push_back(s.ColumnString(0)); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
588 } |
183 | 589 } |
4591
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
590 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
591 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
592 virtual void GetExportedResources(std::list<ExportedResource>& target, |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
593 bool& done, |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
594 int64_t since, |
5213
055428d92772
clarifying types of since/limit in IDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5193
diff
changeset
|
595 uint32_t limit) ORTHANC_OVERRIDE |
4591
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
596 { |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
597 SQLite::Statement s(db_, SQLITE_FROM_HERE, |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
598 "SELECT * FROM ExportedResources WHERE seq>? ORDER BY seq LIMIT ?"); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
599 s.BindInt64(0, since); |
5213
055428d92772
clarifying types of since/limit in IDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5193
diff
changeset
|
600 s.BindInt(1, limit + 1); |
055428d92772
clarifying types of since/limit in IDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5193
diff
changeset
|
601 GetExportedResourcesInternal(target, done, s, limit); |
4591
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
602 } |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
603 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
604 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
605 virtual void GetLastChange(std::list<ServerIndexChange>& target /*out*/) ORTHANC_OVERRIDE |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
606 { |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
607 bool done; // Ignored |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
608 SQLite::Statement s(db_, SQLITE_FROM_HERE, "SELECT * FROM Changes ORDER BY seq DESC LIMIT 1"); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
609 GetChangesInternal(target, done, s, 1); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
610 } |
183 | 611 |
612 | |
4591
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
613 int64_t GetLastChangeIndex() ORTHANC_OVERRIDE |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
614 { |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
615 SQLite::Statement s(db_, SQLITE_FROM_HERE, |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
616 "SELECT seq FROM sqlite_sequence WHERE name='Changes'"); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
617 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
618 if (s.Step()) |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
619 { |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
620 int64_t c = s.ColumnInt(0); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
621 assert(!s.Step()); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
622 return c; |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
623 } |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
624 else |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
625 { |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
626 // No change has been recorded so far in the database |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
627 return 0; |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
628 } |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
629 } |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
630 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
631 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
632 virtual void GetLastExportedResource(std::list<ExportedResource>& target) ORTHANC_OVERRIDE |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
633 { |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
634 bool done; // Ignored |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
635 SQLite::Statement s(db_, SQLITE_FROM_HERE, |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
636 "SELECT * FROM ExportedResources ORDER BY seq DESC LIMIT 1"); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
637 GetExportedResourcesInternal(target, done, s, 1); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
638 } |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
639 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
640 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
641 virtual void GetMainDicomTags(DicomMap& map, |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
642 int64_t id) ORTHANC_OVERRIDE |
3809
2bf30ef727e3
enforcing SQLiteDatabaseWrapper::GetTableRecordCount() against SQL injection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3712
diff
changeset
|
643 { |
4591
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
644 map.Clear(); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
645 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
646 SQLite::Statement s(db_, SQLITE_FROM_HERE, "SELECT * FROM MainDicomTags WHERE id=?"); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
647 s.BindInt64(0, id); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
648 while (s.Step()) |
3809
2bf30ef727e3
enforcing SQLiteDatabaseWrapper::GetTableRecordCount() against SQL injection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3712
diff
changeset
|
649 { |
4591
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
650 map.SetValue(s.ColumnInt(1), |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
651 s.ColumnInt(2), |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
652 s.ColumnString(3), false); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
653 } |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
654 } |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
655 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
656 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
657 virtual std::string GetPublicId(int64_t resourceId) ORTHANC_OVERRIDE |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
658 { |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
659 SQLite::Statement s(db_, SQLITE_FROM_HERE, |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
660 "SELECT publicId FROM Resources WHERE internalId=?"); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
661 s.BindInt64(0, resourceId); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
662 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
663 if (s.Step()) |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
664 { |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
665 return s.ColumnString(0); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
666 } |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
667 else |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
668 { |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
669 throw OrthancException(ErrorCode_UnknownResource); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
670 } |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
671 } |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
672 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
673 |
4595
cc64385593ef
added OrthancPluginRegisterDatabaseBackendV3() to plugin sdk
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4594
diff
changeset
|
674 virtual uint64_t GetResourcesCount(ResourceType resourceType) ORTHANC_OVERRIDE |
4591
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
675 { |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
676 SQLite::Statement s(db_, SQLITE_FROM_HERE, |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
677 "SELECT COUNT(*) FROM Resources WHERE resourceType=?"); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
678 s.BindInt(0, resourceType); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
679 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
680 if (!s.Step()) |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
681 { |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
682 return 0; |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
683 } |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
684 else |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
685 { |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
686 int64_t c = s.ColumnInt(0); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
687 assert(!s.Step()); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
688 return c; |
3809
2bf30ef727e3
enforcing SQLiteDatabaseWrapper::GetTableRecordCount() against SQL injection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3712
diff
changeset
|
689 } |
2bf30ef727e3
enforcing SQLiteDatabaseWrapper::GetTableRecordCount() against SQL injection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3712
diff
changeset
|
690 } |
183 | 691 |
3809
2bf30ef727e3
enforcing SQLiteDatabaseWrapper::GetTableRecordCount() against SQL injection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3712
diff
changeset
|
692 |
4591
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
693 virtual ResourceType GetResourceType(int64_t resourceId) ORTHANC_OVERRIDE |
3809
2bf30ef727e3
enforcing SQLiteDatabaseWrapper::GetTableRecordCount() against SQL injection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3712
diff
changeset
|
694 { |
4591
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
695 SQLite::Statement s(db_, SQLITE_FROM_HERE, |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
696 "SELECT resourceType FROM Resources WHERE internalId=?"); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
697 s.BindInt64(0, resourceId); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
698 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
699 if (s.Step()) |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
700 { |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
701 return static_cast<ResourceType>(s.ColumnInt(0)); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
702 } |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
703 else |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
704 { |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
705 throw OrthancException(ErrorCode_UnknownResource); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
706 } |
3809
2bf30ef727e3
enforcing SQLiteDatabaseWrapper::GetTableRecordCount() against SQL injection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3712
diff
changeset
|
707 } |
4591
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
708 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
709 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
710 virtual uint64_t GetTotalCompressedSize() ORTHANC_OVERRIDE |
218 | 711 { |
4591
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
712 // Old SQL query that was used in Orthanc <= 1.5.0: |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
713 // SQLite::Statement s(db_, SQLITE_FROM_HERE, "SELECT SUM(compressedSize) FROM AttachedFiles"); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
714 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
715 SQLite::Statement s(db_, SQLITE_FROM_HERE, "SELECT value FROM GlobalIntegers WHERE key=0"); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
716 s.Run(); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
717 return static_cast<uint64_t>(s.ColumnInt64(0)); |
218 | 718 } |
183 | 719 |
720 | |
4591
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
721 virtual uint64_t GetTotalUncompressedSize() ORTHANC_OVERRIDE |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
722 { |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
723 // Old SQL query that was used in Orthanc <= 1.5.0: |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
724 // SQLite::Statement s(db_, SQLITE_FROM_HERE, "SELECT SUM(uncompressedSize) FROM AttachedFiles"); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
725 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
726 SQLite::Statement s(db_, SQLITE_FROM_HERE, "SELECT value FROM GlobalIntegers WHERE key=1"); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
727 s.Run(); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
728 return static_cast<uint64_t>(s.ColumnInt64(0)); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
729 } |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
730 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
731 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
732 virtual bool IsDiskSizeAbove(uint64_t threshold) ORTHANC_OVERRIDE |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
733 { |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
734 return GetTotalCompressedSize() > threshold; |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
735 } |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
736 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
737 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
738 virtual bool IsProtectedPatient(int64_t internalId) ORTHANC_OVERRIDE |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
739 { |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
740 SQLite::Statement s(db_, SQLITE_FROM_HERE, |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
741 "SELECT * FROM PatientRecyclingOrder WHERE patientId = ?"); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
742 s.BindInt64(0, internalId); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
743 return !s.Step(); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
744 } |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
745 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
746 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
747 virtual void ListAvailableAttachments(std::set<FileContentType>& target, |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
748 int64_t id) ORTHANC_OVERRIDE |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
749 { |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
750 target.clear(); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
751 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
752 SQLite::Statement s(db_, SQLITE_FROM_HERE, |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
753 "SELECT fileType FROM AttachedFiles WHERE id=?"); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
754 s.BindInt64(0, id); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
755 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
756 while (s.Step()) |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
757 { |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
758 target.insert(static_cast<FileContentType>(s.ColumnInt(0))); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
759 } |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
760 } |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
761 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
762 |
5216
450ac804d3af
simplifying IDatabaseWrapper::LogChange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5213
diff
changeset
|
763 virtual void LogChange(ChangeType changeType, |
450ac804d3af
simplifying IDatabaseWrapper::LogChange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5213
diff
changeset
|
764 ResourceType resourceType, |
450ac804d3af
simplifying IDatabaseWrapper::LogChange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5213
diff
changeset
|
765 int64_t internalId, |
450ac804d3af
simplifying IDatabaseWrapper::LogChange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5213
diff
changeset
|
766 const std::string& /* publicId - unused */, |
450ac804d3af
simplifying IDatabaseWrapper::LogChange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5213
diff
changeset
|
767 const std::string& date) ORTHANC_OVERRIDE |
4591
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
768 { |
5090
cc1a8b3ff319
Made the default SQLite DB more robust wrt future updates like adding new columns in DB.
Alain Mazy <am@osimis.io>
parents:
5057
diff
changeset
|
769 SQLite::Statement s(db_, SQLITE_FROM_HERE, "INSERT INTO Changes (seq, changeType, internalId, resourceType, date) VALUES(NULL, ?, ?, ?, ?)"); |
5216
450ac804d3af
simplifying IDatabaseWrapper::LogChange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5213
diff
changeset
|
770 s.BindInt(0, changeType); |
4591
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
771 s.BindInt64(1, internalId); |
5216
450ac804d3af
simplifying IDatabaseWrapper::LogChange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5213
diff
changeset
|
772 s.BindInt(2, resourceType); |
450ac804d3af
simplifying IDatabaseWrapper::LogChange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5213
diff
changeset
|
773 s.BindString(3, date); |
4591
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
774 s.Run(); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
775 } |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
776 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
777 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
778 virtual void LogExportedResource(const ExportedResource& resource) ORTHANC_OVERRIDE |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
779 { |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
780 SQLite::Statement s(db_, SQLITE_FROM_HERE, |
5090
cc1a8b3ff319
Made the default SQLite DB more robust wrt future updates like adding new columns in DB.
Alain Mazy <am@osimis.io>
parents:
5057
diff
changeset
|
781 "INSERT INTO ExportedResources (seq, resourceType, publicId, remoteModality, patientId, studyInstanceUid, seriesInstanceUid, sopInstanceUid, date) VALUES(NULL, ?, ?, ?, ?, ?, ?, ?, ?)"); |
4591
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
782 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
783 s.BindInt(0, resource.GetResourceType()); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
784 s.BindString(1, resource.GetPublicId()); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
785 s.BindString(2, resource.GetModality()); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
786 s.BindString(3, resource.GetPatientId()); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
787 s.BindString(4, resource.GetStudyInstanceUid()); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
788 s.BindString(5, resource.GetSeriesInstanceUid()); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
789 s.BindString(6, resource.GetSopInstanceUid()); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
790 s.BindString(7, resource.GetDate()); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
791 s.Run(); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
792 } |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
793 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
794 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
795 virtual bool LookupAttachment(FileInfo& attachment, |
4627
f7d5372b59b3
handling revisions of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4623
diff
changeset
|
796 int64_t& revision, |
4591
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
797 int64_t id, |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
798 FileContentType contentType) ORTHANC_OVERRIDE |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
799 { |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
800 SQLite::Statement s(db_, SQLITE_FROM_HERE, |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
801 "SELECT uuid, uncompressedSize, compressionType, compressedSize, " |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
802 "uncompressedMD5, compressedMD5 FROM AttachedFiles WHERE id=? AND fileType=?"); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
803 s.BindInt64(0, id); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
804 s.BindInt(1, contentType); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
805 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
806 if (!s.Step()) |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
807 { |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
808 return false; |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
809 } |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
810 else |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
811 { |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
812 attachment = FileInfo(s.ColumnString(0), |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
813 contentType, |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
814 s.ColumnInt64(1), |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
815 s.ColumnString(4), |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
816 static_cast<CompressionType>(s.ColumnInt(2)), |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
817 s.ColumnInt64(3), |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
818 s.ColumnString(5)); |
4627
f7d5372b59b3
handling revisions of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4623
diff
changeset
|
819 revision = 0; // TODO - REVISIONS |
4591
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
820 return true; |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
821 } |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
822 } |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
823 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
824 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
825 virtual bool LookupGlobalProperty(std::string& target, |
4607
f75c63aa9de0
differentiating between shared and private global properties
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4595
diff
changeset
|
826 GlobalProperty property, |
f75c63aa9de0
differentiating between shared and private global properties
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4595
diff
changeset
|
827 bool shared) ORTHANC_OVERRIDE |
4591
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
828 { |
4607
f75c63aa9de0
differentiating between shared and private global properties
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4595
diff
changeset
|
829 // The "shared" info is not used by the SQLite database, as it |
f75c63aa9de0
differentiating between shared and private global properties
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4595
diff
changeset
|
830 // can only be used by one Orthanc server. |
f75c63aa9de0
differentiating between shared and private global properties
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4595
diff
changeset
|
831 |
4591
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
832 SQLite::Statement s(db_, SQLITE_FROM_HERE, |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
833 "SELECT value FROM GlobalProperties WHERE property=?"); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
834 s.BindInt(0, property); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
835 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
836 if (!s.Step()) |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
837 { |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
838 return false; |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
839 } |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
840 else |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
841 { |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
842 target = s.ColumnString(0); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
843 return true; |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
844 } |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
845 } |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
846 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
847 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
848 virtual bool LookupMetadata(std::string& target, |
4623
95ffe3b6ef7c
handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4607
diff
changeset
|
849 int64_t& revision, |
4591
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
850 int64_t id, |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
851 MetadataType type) ORTHANC_OVERRIDE |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
852 { |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
853 SQLite::Statement s(db_, SQLITE_FROM_HERE, |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
854 "SELECT value FROM Metadata WHERE id=? AND type=?"); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
855 s.BindInt64(0, id); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
856 s.BindInt(1, type); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
857 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
858 if (!s.Step()) |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
859 { |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
860 return false; |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
861 } |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
862 else |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
863 { |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
864 target = s.ColumnString(0); |
4623
95ffe3b6ef7c
handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4607
diff
changeset
|
865 revision = 0; // TODO - REVISIONS |
4591
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
866 return true; |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
867 } |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
868 } |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
869 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
870 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
871 virtual bool LookupParent(int64_t& parentId, |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
872 int64_t resourceId) ORTHANC_OVERRIDE |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
873 { |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
874 SQLite::Statement s(db_, SQLITE_FROM_HERE, |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
875 "SELECT parentId FROM Resources WHERE internalId=?"); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
876 s.BindInt64(0, resourceId); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
877 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
878 if (!s.Step()) |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
879 { |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
880 throw OrthancException(ErrorCode_UnknownResource); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
881 } |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
882 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
883 if (s.ColumnIsNull(0)) |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
884 { |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
885 return false; |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
886 } |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
887 else |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
888 { |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
889 parentId = s.ColumnInt(0); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
890 return true; |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
891 } |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
892 } |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
893 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
894 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
895 virtual bool LookupResourceAndParent(int64_t& id, |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
896 ResourceType& type, |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
897 std::string& parentPublicId, |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
898 const std::string& publicId) ORTHANC_OVERRIDE |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
899 { |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
900 return ILookupResourceAndParent::Apply(*this, id, type, parentPublicId, publicId); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
901 } |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
902 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
903 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
904 virtual bool LookupResource(int64_t& id, |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
905 ResourceType& type, |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
906 const std::string& publicId) ORTHANC_OVERRIDE |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
907 { |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
908 SQLite::Statement s(db_, SQLITE_FROM_HERE, |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
909 "SELECT internalId, resourceType FROM Resources WHERE publicId=?"); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
910 s.BindString(0, publicId); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
911 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
912 if (!s.Step()) |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
913 { |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
914 return false; |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
915 } |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
916 else |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
917 { |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
918 id = s.ColumnInt(0); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
919 type = static_cast<ResourceType>(s.ColumnInt(1)); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
920 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
921 // Check whether there is a single resource with this public id |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
922 assert(!s.Step()); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
923 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
924 return true; |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
925 } |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
926 } |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
927 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
928 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
929 virtual bool SelectPatientToRecycle(int64_t& internalId) ORTHANC_OVERRIDE |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
930 { |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
931 SQLite::Statement s(db_, SQLITE_FROM_HERE, |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
932 "SELECT patientId FROM PatientRecyclingOrder ORDER BY seq ASC LIMIT 1"); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
933 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
934 if (!s.Step()) |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
935 { |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
936 // No patient remaining or all the patients are protected |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
937 return false; |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
938 } |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
939 else |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
940 { |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
941 internalId = s.ColumnInt(0); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
942 return true; |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
943 } |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
944 } |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
945 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
946 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
947 virtual bool SelectPatientToRecycle(int64_t& internalId, |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
948 int64_t patientIdToAvoid) ORTHANC_OVERRIDE |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
949 { |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
950 SQLite::Statement s(db_, SQLITE_FROM_HERE, |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
951 "SELECT patientId FROM PatientRecyclingOrder " |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
952 "WHERE patientId != ? ORDER BY seq ASC LIMIT 1"); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
953 s.BindInt64(0, patientIdToAvoid); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
954 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
955 if (!s.Step()) |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
956 { |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
957 // No patient remaining or all the patients are protected |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
958 return false; |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
959 } |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
960 else |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
961 { |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
962 internalId = s.ColumnInt(0); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
963 return true; |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
964 } |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
965 } |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
966 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
967 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
968 virtual void SetGlobalProperty(GlobalProperty property, |
4607
f75c63aa9de0
differentiating between shared and private global properties
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4595
diff
changeset
|
969 bool shared, |
4591
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
970 const std::string& value) ORTHANC_OVERRIDE |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
971 { |
4607
f75c63aa9de0
differentiating between shared and private global properties
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4595
diff
changeset
|
972 // The "shared" info is not used by the SQLite database, as it |
f75c63aa9de0
differentiating between shared and private global properties
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4595
diff
changeset
|
973 // can only be used by one Orthanc server. |
f75c63aa9de0
differentiating between shared and private global properties
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4595
diff
changeset
|
974 |
5090
cc1a8b3ff319
Made the default SQLite DB more robust wrt future updates like adding new columns in DB.
Alain Mazy <am@osimis.io>
parents:
5057
diff
changeset
|
975 SQLite::Statement s(db_, SQLITE_FROM_HERE, "INSERT OR REPLACE INTO GlobalProperties (property, value) VALUES(?, ?)"); |
4591
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
976 s.BindInt(0, property); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
977 s.BindString(1, value); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
978 s.Run(); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
979 } |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
980 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
981 |
4592 | 982 // From the "ISetResourcesContent" interface |
4591
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
983 virtual void SetIdentifierTag(int64_t id, |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
984 const DicomTag& tag, |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
985 const std::string& value) ORTHANC_OVERRIDE |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
986 { |
5090
cc1a8b3ff319
Made the default SQLite DB more robust wrt future updates like adding new columns in DB.
Alain Mazy <am@osimis.io>
parents:
5057
diff
changeset
|
987 SQLite::Statement s(db_, SQLITE_FROM_HERE, "INSERT INTO DicomIdentifiers (id, tagGroup, tagElement, value) VALUES(?, ?, ?, ?)"); |
4591
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
988 s.BindInt64(0, id); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
989 s.BindInt(1, tag.GetGroup()); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
990 s.BindInt(2, tag.GetElement()); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
991 s.BindString(3, value); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
992 s.Run(); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
993 } |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
994 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
995 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
996 virtual void SetProtectedPatient(int64_t internalId, |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
997 bool isProtected) ORTHANC_OVERRIDE |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
998 { |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
999 if (isProtected) |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1000 { |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1001 SQLite::Statement s(db_, SQLITE_FROM_HERE, "DELETE FROM PatientRecyclingOrder WHERE patientId=?"); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1002 s.BindInt64(0, internalId); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1003 s.Run(); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1004 } |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1005 else if (IsProtectedPatient(internalId)) |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1006 { |
5090
cc1a8b3ff319
Made the default SQLite DB more robust wrt future updates like adding new columns in DB.
Alain Mazy <am@osimis.io>
parents:
5057
diff
changeset
|
1007 SQLite::Statement s(db_, SQLITE_FROM_HERE, "INSERT INTO PatientRecyclingOrder (seq, patientId) VALUES(NULL, ?)"); |
4591
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1008 s.BindInt64(0, internalId); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1009 s.Run(); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1010 } |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1011 else |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1012 { |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1013 // Nothing to do: The patient is already unprotected |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1014 } |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1015 } |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1016 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1017 |
4592 | 1018 // From the "ISetResourcesContent" interface |
4591
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1019 virtual void SetMainDicomTag(int64_t id, |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1020 const DicomTag& tag, |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1021 const std::string& value) ORTHANC_OVERRIDE |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1022 { |
5090
cc1a8b3ff319
Made the default SQLite DB more robust wrt future updates like adding new columns in DB.
Alain Mazy <am@osimis.io>
parents:
5057
diff
changeset
|
1023 SQLite::Statement s(db_, SQLITE_FROM_HERE, "INSERT INTO MainDicomTags (id, tagGroup, tagElement, value) VALUES(?, ?, ?, ?)"); |
4591
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1024 s.BindInt64(0, id); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1025 s.BindInt(1, tag.GetGroup()); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1026 s.BindInt(2, tag.GetElement()); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1027 s.BindString(3, value); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1028 s.Run(); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1029 } |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1030 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1031 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1032 virtual void SetMetadata(int64_t id, |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1033 MetadataType type, |
4623
95ffe3b6ef7c
handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4607
diff
changeset
|
1034 const std::string& value, |
95ffe3b6ef7c
handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4607
diff
changeset
|
1035 int64_t revision) ORTHANC_OVERRIDE |
4591
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1036 { |
4623
95ffe3b6ef7c
handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4607
diff
changeset
|
1037 // TODO - REVISIONS |
5090
cc1a8b3ff319
Made the default SQLite DB more robust wrt future updates like adding new columns in DB.
Alain Mazy <am@osimis.io>
parents:
5057
diff
changeset
|
1038 SQLite::Statement s(db_, SQLITE_FROM_HERE, "INSERT OR REPLACE INTO Metadata (id, type, value) VALUES(?, ?, ?)"); |
4591
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1039 s.BindInt64(0, id); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1040 s.BindInt(1, type); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1041 s.BindString(2, value); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1042 s.Run(); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1043 } |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1044 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1045 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1046 virtual void SetResourcesContent(const Orthanc::ResourcesContent& content) ORTHANC_OVERRIDE |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1047 { |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1048 ISetResourcesContent::Apply(*this, content); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1049 } |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1050 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1051 |
4592 | 1052 // From the "ICreateInstance" interface |
4591
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1053 virtual void TagMostRecentPatient(int64_t patient) ORTHANC_OVERRIDE |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1054 { |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1055 { |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1056 SQLite::Statement s(db_, SQLITE_FROM_HERE, |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1057 "DELETE FROM PatientRecyclingOrder WHERE patientId=?"); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1058 s.BindInt64(0, patient); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1059 s.Run(); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1060 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1061 assert(db_.GetLastChangeCount() == 0 || |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1062 db_.GetLastChangeCount() == 1); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1063 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1064 if (db_.GetLastChangeCount() == 0) |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1065 { |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1066 // The patient was protected, there was nothing to delete from the recycling order |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1067 return; |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1068 } |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1069 } |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1070 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1071 { |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1072 SQLite::Statement s(db_, SQLITE_FROM_HERE, |
5090
cc1a8b3ff319
Made the default SQLite DB more robust wrt future updates like adding new columns in DB.
Alain Mazy <am@osimis.io>
parents:
5057
diff
changeset
|
1073 "INSERT INTO PatientRecyclingOrder (seq, patientId) VALUES(NULL, ?)"); |
4591
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1074 s.BindInt64(0, patient); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1075 s.Run(); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1076 } |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1077 } |
5220
df39c7583a49
preparing virtual methods for labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5216
diff
changeset
|
1078 |
df39c7583a49
preparing virtual methods for labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5216
diff
changeset
|
1079 |
df39c7583a49
preparing virtual methods for labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5216
diff
changeset
|
1080 virtual void AddLabel(int64_t resource, |
df39c7583a49
preparing virtual methods for labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5216
diff
changeset
|
1081 const std::string& label) ORTHANC_OVERRIDE |
df39c7583a49
preparing virtual methods for labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5216
diff
changeset
|
1082 { |
5221
d0f7c742d397
started implementation of labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5220
diff
changeset
|
1083 if (label.empty()) |
d0f7c742d397
started implementation of labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5220
diff
changeset
|
1084 { |
d0f7c742d397
started implementation of labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5220
diff
changeset
|
1085 throw OrthancException(ErrorCode_ParameterOutOfRange); |
d0f7c742d397
started implementation of labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5220
diff
changeset
|
1086 } |
d0f7c742d397
started implementation of labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5220
diff
changeset
|
1087 else |
d0f7c742d397
started implementation of labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5220
diff
changeset
|
1088 { |
5256 | 1089 SQLite::Statement s(db_, SQLITE_FROM_HERE, "INSERT OR IGNORE INTO Labels (id, label) VALUES(?, ?)"); |
5221
d0f7c742d397
started implementation of labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5220
diff
changeset
|
1090 s.BindInt64(0, resource); |
d0f7c742d397
started implementation of labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5220
diff
changeset
|
1091 s.BindString(1, label); |
d0f7c742d397
started implementation of labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5220
diff
changeset
|
1092 s.Run(); |
d0f7c742d397
started implementation of labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5220
diff
changeset
|
1093 } |
5220
df39c7583a49
preparing virtual methods for labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5216
diff
changeset
|
1094 } |
df39c7583a49
preparing virtual methods for labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5216
diff
changeset
|
1095 |
df39c7583a49
preparing virtual methods for labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5216
diff
changeset
|
1096 |
df39c7583a49
preparing virtual methods for labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5216
diff
changeset
|
1097 virtual void RemoveLabel(int64_t resource, |
df39c7583a49
preparing virtual methods for labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5216
diff
changeset
|
1098 const std::string& label) ORTHANC_OVERRIDE |
df39c7583a49
preparing virtual methods for labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5216
diff
changeset
|
1099 { |
5221
d0f7c742d397
started implementation of labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5220
diff
changeset
|
1100 if (label.empty()) |
d0f7c742d397
started implementation of labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5220
diff
changeset
|
1101 { |
d0f7c742d397
started implementation of labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5220
diff
changeset
|
1102 throw OrthancException(ErrorCode_ParameterOutOfRange); |
d0f7c742d397
started implementation of labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5220
diff
changeset
|
1103 } |
d0f7c742d397
started implementation of labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5220
diff
changeset
|
1104 else |
d0f7c742d397
started implementation of labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5220
diff
changeset
|
1105 { |
5256 | 1106 SQLite::Statement s(db_, SQLITE_FROM_HERE, "DELETE FROM Labels WHERE id=? AND label=?"); |
5221
d0f7c742d397
started implementation of labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5220
diff
changeset
|
1107 s.BindInt64(0, resource); |
d0f7c742d397
started implementation of labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5220
diff
changeset
|
1108 s.BindString(1, label); |
d0f7c742d397
started implementation of labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5220
diff
changeset
|
1109 s.Run(); |
d0f7c742d397
started implementation of labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5220
diff
changeset
|
1110 } |
5220
df39c7583a49
preparing virtual methods for labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5216
diff
changeset
|
1111 } |
df39c7583a49
preparing virtual methods for labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5216
diff
changeset
|
1112 |
df39c7583a49
preparing virtual methods for labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5216
diff
changeset
|
1113 |
5221
d0f7c742d397
started implementation of labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5220
diff
changeset
|
1114 virtual void ListLabels(std::set<std::string>& target, |
d0f7c742d397
started implementation of labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5220
diff
changeset
|
1115 int64_t resource) ORTHANC_OVERRIDE |
5220
df39c7583a49
preparing virtual methods for labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5216
diff
changeset
|
1116 { |
5221
d0f7c742d397
started implementation of labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5220
diff
changeset
|
1117 target.clear(); |
d0f7c742d397
started implementation of labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5220
diff
changeset
|
1118 |
d0f7c742d397
started implementation of labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5220
diff
changeset
|
1119 SQLite::Statement s(db_, SQLITE_FROM_HERE, |
5256 | 1120 "SELECT label FROM Labels WHERE id=?"); |
5221
d0f7c742d397
started implementation of labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5220
diff
changeset
|
1121 s.BindInt64(0, resource); |
d0f7c742d397
started implementation of labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5220
diff
changeset
|
1122 |
d0f7c742d397
started implementation of labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5220
diff
changeset
|
1123 while (s.Step()) |
d0f7c742d397
started implementation of labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5220
diff
changeset
|
1124 { |
d0f7c742d397
started implementation of labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5220
diff
changeset
|
1125 target.insert(s.ColumnString(0)); |
d0f7c742d397
started implementation of labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5220
diff
changeset
|
1126 } |
5220
df39c7583a49
preparing virtual methods for labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5216
diff
changeset
|
1127 } |
5249
f22c8fac764b
added "/tools/labels" to list all the labels that are associated with any resource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5248
diff
changeset
|
1128 |
f22c8fac764b
added "/tools/labels" to list all the labels that are associated with any resource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5248
diff
changeset
|
1129 |
f22c8fac764b
added "/tools/labels" to list all the labels that are associated with any resource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5248
diff
changeset
|
1130 virtual void ListAllLabels(std::set<std::string>& target) ORTHANC_OVERRIDE |
f22c8fac764b
added "/tools/labels" to list all the labels that are associated with any resource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5248
diff
changeset
|
1131 { |
f22c8fac764b
added "/tools/labels" to list all the labels that are associated with any resource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5248
diff
changeset
|
1132 target.clear(); |
f22c8fac764b
added "/tools/labels" to list all the labels that are associated with any resource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5248
diff
changeset
|
1133 |
f22c8fac764b
added "/tools/labels" to list all the labels that are associated with any resource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5248
diff
changeset
|
1134 SQLite::Statement s(db_, SQLITE_FROM_HERE, |
f22c8fac764b
added "/tools/labels" to list all the labels that are associated with any resource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5248
diff
changeset
|
1135 "SELECT DISTINCT label FROM Labels"); |
f22c8fac764b
added "/tools/labels" to list all the labels that are associated with any resource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5248
diff
changeset
|
1136 |
f22c8fac764b
added "/tools/labels" to list all the labels that are associated with any resource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5248
diff
changeset
|
1137 while (s.Step()) |
f22c8fac764b
added "/tools/labels" to list all the labels that are associated with any resource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5248
diff
changeset
|
1138 { |
f22c8fac764b
added "/tools/labels" to list all the labels that are associated with any resource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5248
diff
changeset
|
1139 target.insert(s.ColumnString(0)); |
f22c8fac764b
added "/tools/labels" to list all the labels that are associated with any resource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5248
diff
changeset
|
1140 } |
f22c8fac764b
added "/tools/labels" to list all the labels that are associated with any resource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5248
diff
changeset
|
1141 } |
5554
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5521
diff
changeset
|
1142 |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5521
diff
changeset
|
1143 |
5593
862b54b4cfe2
implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
1144 #if 0 |
862b54b4cfe2
implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
1145 // TODO-FIND: Remove this implementation, as it should be done by |
862b54b4cfe2
implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
1146 // the compatibility mode implemented by "GenericFind" |
862b54b4cfe2
implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
1147 |
5554
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5521
diff
changeset
|
1148 virtual void ExecuteFind(FindResponse& response, |
5568
b0b5546f1b9f
find refactor: re-use existing code. /studies?expand is almost fully implemented with new code
Alain Mazy <am@orthanc.team>
parents:
5567
diff
changeset
|
1149 const FindRequest& request, |
b0b5546f1b9f
find refactor: re-use existing code. /studies?expand is almost fully implemented with new code
Alain Mazy <am@orthanc.team>
parents:
5567
diff
changeset
|
1150 const std::vector<DatabaseConstraint>& normalized) ORTHANC_OVERRIDE |
5554
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5521
diff
changeset
|
1151 { |
5568
b0b5546f1b9f
find refactor: re-use existing code. /studies?expand is almost fully implemented with new code
Alain Mazy <am@orthanc.team>
parents:
5567
diff
changeset
|
1152 #if 0 |
5554
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5521
diff
changeset
|
1153 Compatibility::GenericFind find(*this); |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5521
diff
changeset
|
1154 find.Execute(response, request); |
5567
f3562c1a150d
FindRequest: group metadata and tag constrains in a single class, allow ordering against metadata
Alain Mazy <am@orthanc.team>
parents:
5554
diff
changeset
|
1155 #else |
f3562c1a150d
FindRequest: group metadata and tag constrains in a single class, allow ordering against metadata
Alain Mazy <am@orthanc.team>
parents:
5554
diff
changeset
|
1156 { |
f3562c1a150d
FindRequest: group metadata and tag constrains in a single class, allow ordering against metadata
Alain Mazy <am@orthanc.team>
parents:
5554
diff
changeset
|
1157 SQLite::Statement s(db_, SQLITE_FROM_HERE, "DROP TABLE IF EXISTS FilteredResourcesIds"); |
f3562c1a150d
FindRequest: group metadata and tag constrains in a single class, allow ordering against metadata
Alain Mazy <am@orthanc.team>
parents:
5554
diff
changeset
|
1158 s.Run(); |
f3562c1a150d
FindRequest: group metadata and tag constrains in a single class, allow ordering against metadata
Alain Mazy <am@orthanc.team>
parents:
5554
diff
changeset
|
1159 } |
f3562c1a150d
FindRequest: group metadata and tag constrains in a single class, allow ordering against metadata
Alain Mazy <am@orthanc.team>
parents:
5554
diff
changeset
|
1160 |
f3562c1a150d
FindRequest: group metadata and tag constrains in a single class, allow ordering against metadata
Alain Mazy <am@orthanc.team>
parents:
5554
diff
changeset
|
1161 { |
5568
b0b5546f1b9f
find refactor: re-use existing code. /studies?expand is almost fully implemented with new code
Alain Mazy <am@orthanc.team>
parents:
5567
diff
changeset
|
1162 |
b0b5546f1b9f
find refactor: re-use existing code. /studies?expand is almost fully implemented with new code
Alain Mazy <am@orthanc.team>
parents:
5567
diff
changeset
|
1163 LookupFormatter formatter; |
b0b5546f1b9f
find refactor: re-use existing code. /studies?expand is almost fully implemented with new code
Alain Mazy <am@orthanc.team>
parents:
5567
diff
changeset
|
1164 |
b0b5546f1b9f
find refactor: re-use existing code. /studies?expand is almost fully implemented with new code
Alain Mazy <am@orthanc.team>
parents:
5567
diff
changeset
|
1165 std::string sqlLookup; |
b0b5546f1b9f
find refactor: re-use existing code. /studies?expand is almost fully implemented with new code
Alain Mazy <am@orthanc.team>
parents:
5567
diff
changeset
|
1166 LookupFormatter::Apply(sqlLookup, |
b0b5546f1b9f
find refactor: re-use existing code. /studies?expand is almost fully implemented with new code
Alain Mazy <am@orthanc.team>
parents:
5567
diff
changeset
|
1167 formatter, |
b0b5546f1b9f
find refactor: re-use existing code. /studies?expand is almost fully implemented with new code
Alain Mazy <am@orthanc.team>
parents:
5567
diff
changeset
|
1168 normalized, |
b0b5546f1b9f
find refactor: re-use existing code. /studies?expand is almost fully implemented with new code
Alain Mazy <am@orthanc.team>
parents:
5567
diff
changeset
|
1169 request.GetLevel(), |
b0b5546f1b9f
find refactor: re-use existing code. /studies?expand is almost fully implemented with new code
Alain Mazy <am@orthanc.team>
parents:
5567
diff
changeset
|
1170 request.GetLabels(), |
b0b5546f1b9f
find refactor: re-use existing code. /studies?expand is almost fully implemented with new code
Alain Mazy <am@orthanc.team>
parents:
5567
diff
changeset
|
1171 request.GetLabelsConstraint(), |
b0b5546f1b9f
find refactor: re-use existing code. /studies?expand is almost fully implemented with new code
Alain Mazy <am@orthanc.team>
parents:
5567
diff
changeset
|
1172 (request.HasLimits() ? request.GetLimitsCount() : 0)); // TODO: handles since and count |
b0b5546f1b9f
find refactor: re-use existing code. /studies?expand is almost fully implemented with new code
Alain Mazy <am@orthanc.team>
parents:
5567
diff
changeset
|
1173 |
5590
8b32213af23e
replaced FindRequest::ResponseContent by booleans
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
1174 { |
8b32213af23e
replaced FindRequest::ResponseContent by booleans
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
1175 // first create a temporary table that with the filtered and ordered results |
8b32213af23e
replaced FindRequest::ResponseContent by booleans
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
1176 sqlLookup = "CREATE TEMPORARY TABLE FilteredResourcesIds AS " + sqlLookup; |
8b32213af23e
replaced FindRequest::ResponseContent by booleans
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
1177 |
8b32213af23e
replaced FindRequest::ResponseContent by booleans
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
1178 SQLite::Statement statement(db_, SQLITE_FROM_HERE_DYNAMIC(sqlLookup), sqlLookup); |
8b32213af23e
replaced FindRequest::ResponseContent by booleans
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
1179 formatter.Bind(statement); |
8b32213af23e
replaced FindRequest::ResponseContent by booleans
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
1180 statement.Run(); |
8b32213af23e
replaced FindRequest::ResponseContent by booleans
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
1181 } |
8b32213af23e
replaced FindRequest::ResponseContent by booleans
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
1182 |
8b32213af23e
replaced FindRequest::ResponseContent by booleans
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
1183 { |
8b32213af23e
replaced FindRequest::ResponseContent by booleans
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
1184 // create the response item with the public ids only |
8b32213af23e
replaced FindRequest::ResponseContent by booleans
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
1185 SQLite::Statement statement(db_, SQLITE_FROM_HERE, "SELECT publicId FROM FilteredResourcesIds"); |
8b32213af23e
replaced FindRequest::ResponseContent by booleans
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
1186 formatter.Bind(statement); |
8b32213af23e
replaced FindRequest::ResponseContent by booleans
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
1187 |
8b32213af23e
replaced FindRequest::ResponseContent by booleans
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
1188 while (statement.Step()) |
8b32213af23e
replaced FindRequest::ResponseContent by booleans
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
1189 { |
8b32213af23e
replaced FindRequest::ResponseContent by booleans
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
1190 const std::string resourceId = statement.ColumnString(0); |
8b32213af23e
replaced FindRequest::ResponseContent by booleans
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
1191 response.Add(new FindResponse::Resource(request.GetLevel(), resourceId)); |
8b32213af23e
replaced FindRequest::ResponseContent by booleans
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
1192 } |
8b32213af23e
replaced FindRequest::ResponseContent by booleans
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
1193 } |
8b32213af23e
replaced FindRequest::ResponseContent by booleans
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
1194 |
8b32213af23e
replaced FindRequest::ResponseContent by booleans
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
1195 // request Each response content through INNER JOIN with the temporary table |
5592
1e2631b8b9af
GenericFind::Execute() is working for a basic request
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5590
diff
changeset
|
1196 if (request.IsRetrieveMainDicomTags()) |
5568
b0b5546f1b9f
find refactor: re-use existing code. /studies?expand is almost fully implemented with new code
Alain Mazy <am@orthanc.team>
parents:
5567
diff
changeset
|
1197 { |
5590
8b32213af23e
replaced FindRequest::ResponseContent by booleans
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
1198 // TODO-FIND: handle the case where we request tags from multiple levels |
8b32213af23e
replaced FindRequest::ResponseContent by booleans
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
1199 SQLite::Statement statement(db_, SQLITE_FROM_HERE, |
8b32213af23e
replaced FindRequest::ResponseContent by booleans
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
1200 "SELECT publicId, tagGroup, tagElement, value FROM MainDicomTags AS tags " |
8b32213af23e
replaced FindRequest::ResponseContent by booleans
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
1201 " INNER JOIN FilteredResourcesIds ON tags.id = FilteredResourcesIds.internalId"); |
8b32213af23e
replaced FindRequest::ResponseContent by booleans
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
1202 formatter.Bind(statement); |
8b32213af23e
replaced FindRequest::ResponseContent by booleans
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
1203 |
8b32213af23e
replaced FindRequest::ResponseContent by booleans
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
1204 while (statement.Step()) |
8b32213af23e
replaced FindRequest::ResponseContent by booleans
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
1205 { |
8b32213af23e
replaced FindRequest::ResponseContent by booleans
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
1206 const std::string& resourceId = statement.ColumnString(0); |
8b32213af23e
replaced FindRequest::ResponseContent by booleans
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
1207 assert(response.HasResource(resourceId)); |
5592
1e2631b8b9af
GenericFind::Execute() is working for a basic request
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5590
diff
changeset
|
1208 response.GetResource(resourceId).AddStringDicomTag(statement.ColumnInt(1), |
5590
8b32213af23e
replaced FindRequest::ResponseContent by booleans
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
1209 statement.ColumnInt(2), |
8b32213af23e
replaced FindRequest::ResponseContent by booleans
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
1210 statement.ColumnString(3)); |
8b32213af23e
replaced FindRequest::ResponseContent by booleans
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
1211 } |
8b32213af23e
replaced FindRequest::ResponseContent by booleans
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
1212 } |
8b32213af23e
replaced FindRequest::ResponseContent by booleans
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
1213 |
8b32213af23e
replaced FindRequest::ResponseContent by booleans
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
1214 if (request.IsRetrieveChildrenIdentifiers()) |
8b32213af23e
replaced FindRequest::ResponseContent by booleans
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
1215 { |
8b32213af23e
replaced FindRequest::ResponseContent by booleans
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
1216 SQLite::Statement statement(db_, SQLITE_FROM_HERE, |
8b32213af23e
replaced FindRequest::ResponseContent by booleans
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
1217 "SELECT filtered.publicId, childLevel.publicId AS childPublicId " |
8b32213af23e
replaced FindRequest::ResponseContent by booleans
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
1218 "FROM Resources as currentLevel " |
8b32213af23e
replaced FindRequest::ResponseContent by booleans
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
1219 " INNER JOIN FilteredResourcesIds filtered ON filtered.internalId = currentLevel.internalId " |
8b32213af23e
replaced FindRequest::ResponseContent by booleans
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
1220 " INNER JOIN Resources childLevel ON childLevel.parentId = currentLevel.internalId"); |
5568
b0b5546f1b9f
find refactor: re-use existing code. /studies?expand is almost fully implemented with new code
Alain Mazy <am@orthanc.team>
parents:
5567
diff
changeset
|
1221 formatter.Bind(statement); |
b0b5546f1b9f
find refactor: re-use existing code. /studies?expand is almost fully implemented with new code
Alain Mazy <am@orthanc.team>
parents:
5567
diff
changeset
|
1222 |
b0b5546f1b9f
find refactor: re-use existing code. /studies?expand is almost fully implemented with new code
Alain Mazy <am@orthanc.team>
parents:
5567
diff
changeset
|
1223 while (statement.Step()) |
b0b5546f1b9f
find refactor: re-use existing code. /studies?expand is almost fully implemented with new code
Alain Mazy <am@orthanc.team>
parents:
5567
diff
changeset
|
1224 { |
5590
8b32213af23e
replaced FindRequest::ResponseContent by booleans
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
1225 const std::string& resourceId = statement.ColumnString(0); |
8b32213af23e
replaced FindRequest::ResponseContent by booleans
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
1226 assert(response.HasResource(resourceId)); |
8b32213af23e
replaced FindRequest::ResponseContent by booleans
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
1227 response.GetResource(resourceId).AddChildIdentifier(GetChildResourceType(request.GetLevel()), statement.ColumnString(1)); |
8b32213af23e
replaced FindRequest::ResponseContent by booleans
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
1228 } |
8b32213af23e
replaced FindRequest::ResponseContent by booleans
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
1229 } |
8b32213af23e
replaced FindRequest::ResponseContent by booleans
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
1230 |
8b32213af23e
replaced FindRequest::ResponseContent by booleans
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
1231 if (request.IsRetrieveParentIdentifier()) |
8b32213af23e
replaced FindRequest::ResponseContent by booleans
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
1232 { |
8b32213af23e
replaced FindRequest::ResponseContent by booleans
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
1233 SQLite::Statement statement(db_, SQLITE_FROM_HERE, |
8b32213af23e
replaced FindRequest::ResponseContent by booleans
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
1234 "SELECT filtered.publicId, parentLevel.publicId AS parentPublicId " |
8b32213af23e
replaced FindRequest::ResponseContent by booleans
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
1235 "FROM Resources as currentLevel " |
8b32213af23e
replaced FindRequest::ResponseContent by booleans
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
1236 " INNER JOIN FilteredResourcesIds filtered ON filtered.internalId = currentLevel.internalId " |
8b32213af23e
replaced FindRequest::ResponseContent by booleans
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
1237 " INNER JOIN Resources parentLevel ON currentLevel.parentId = parentLevel.internalId"); |
8b32213af23e
replaced FindRequest::ResponseContent by booleans
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
1238 |
8b32213af23e
replaced FindRequest::ResponseContent by booleans
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
1239 while (statement.Step()) |
8b32213af23e
replaced FindRequest::ResponseContent by booleans
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
1240 { |
8b32213af23e
replaced FindRequest::ResponseContent by booleans
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
1241 const std::string& resourceId = statement.ColumnString(0); |
8b32213af23e
replaced FindRequest::ResponseContent by booleans
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
1242 const std::string& parentId = statement.ColumnString(1); |
8b32213af23e
replaced FindRequest::ResponseContent by booleans
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
1243 assert(response.HasResource(resourceId)); |
8b32213af23e
replaced FindRequest::ResponseContent by booleans
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
1244 response.GetResource(resourceId).SetParentIdentifier(parentId); |
8b32213af23e
replaced FindRequest::ResponseContent by booleans
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
1245 } |
8b32213af23e
replaced FindRequest::ResponseContent by booleans
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
1246 } |
8b32213af23e
replaced FindRequest::ResponseContent by booleans
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
1247 |
8b32213af23e
replaced FindRequest::ResponseContent by booleans
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
1248 if (request.IsRetrieveMetadata()) |
8b32213af23e
replaced FindRequest::ResponseContent by booleans
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
1249 { |
8b32213af23e
replaced FindRequest::ResponseContent by booleans
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
1250 SQLite::Statement statement(db_, SQLITE_FROM_HERE, |
8b32213af23e
replaced FindRequest::ResponseContent by booleans
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
1251 "SELECT filtered.publicId, metadata.type, metadata.value " |
8b32213af23e
replaced FindRequest::ResponseContent by booleans
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
1252 "FROM Metadata " |
8b32213af23e
replaced FindRequest::ResponseContent by booleans
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
1253 " INNER JOIN FilteredResourcesIds filtered ON filtered.internalId = Metadata.id"); |
8b32213af23e
replaced FindRequest::ResponseContent by booleans
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
1254 |
8b32213af23e
replaced FindRequest::ResponseContent by booleans
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
1255 while (statement.Step()) |
8b32213af23e
replaced FindRequest::ResponseContent by booleans
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
1256 { |
8b32213af23e
replaced FindRequest::ResponseContent by booleans
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
1257 const std::string& resourceId = statement.ColumnString(0); |
8b32213af23e
replaced FindRequest::ResponseContent by booleans
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
1258 assert(response.HasResource(resourceId)); |
8b32213af23e
replaced FindRequest::ResponseContent by booleans
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
1259 response.GetResource(resourceId).AddMetadata(static_cast<MetadataType>(statement.ColumnInt(1)), |
8b32213af23e
replaced FindRequest::ResponseContent by booleans
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
1260 statement.ColumnString(2)); |
5568
b0b5546f1b9f
find refactor: re-use existing code. /studies?expand is almost fully implemented with new code
Alain Mazy <am@orthanc.team>
parents:
5567
diff
changeset
|
1261 } |
b0b5546f1b9f
find refactor: re-use existing code. /studies?expand is almost fully implemented with new code
Alain Mazy <am@orthanc.team>
parents:
5567
diff
changeset
|
1262 } |
5590
8b32213af23e
replaced FindRequest::ResponseContent by booleans
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
1263 |
8b32213af23e
replaced FindRequest::ResponseContent by booleans
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
1264 if (request.IsRetrieveLabels()) |
5568
b0b5546f1b9f
find refactor: re-use existing code. /studies?expand is almost fully implemented with new code
Alain Mazy <am@orthanc.team>
parents:
5567
diff
changeset
|
1265 { |
5590
8b32213af23e
replaced FindRequest::ResponseContent by booleans
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
1266 SQLite::Statement statement(db_, SQLITE_FROM_HERE, |
8b32213af23e
replaced FindRequest::ResponseContent by booleans
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
1267 "SELECT filtered.publicId, label " |
8b32213af23e
replaced FindRequest::ResponseContent by booleans
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
1268 "FROM Labels " |
8b32213af23e
replaced FindRequest::ResponseContent by booleans
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
1269 " INNER JOIN FilteredResourcesIds filtered ON filtered.internalId = Labels.id"); |
5568
b0b5546f1b9f
find refactor: re-use existing code. /studies?expand is almost fully implemented with new code
Alain Mazy <am@orthanc.team>
parents:
5567
diff
changeset
|
1270 |
5590
8b32213af23e
replaced FindRequest::ResponseContent by booleans
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
1271 while (statement.Step()) |
5568
b0b5546f1b9f
find refactor: re-use existing code. /studies?expand is almost fully implemented with new code
Alain Mazy <am@orthanc.team>
parents:
5567
diff
changeset
|
1272 { |
5590
8b32213af23e
replaced FindRequest::ResponseContent by booleans
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
1273 const std::string& resourceId = statement.ColumnString(0); |
8b32213af23e
replaced FindRequest::ResponseContent by booleans
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
1274 assert(response.HasResource(resourceId)); |
8b32213af23e
replaced FindRequest::ResponseContent by booleans
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
1275 response.GetResource(resourceId).AddLabel(statement.ColumnString(1)); |
5568
b0b5546f1b9f
find refactor: re-use existing code. /studies?expand is almost fully implemented with new code
Alain Mazy <am@orthanc.team>
parents:
5567
diff
changeset
|
1276 } |
5590
8b32213af23e
replaced FindRequest::ResponseContent by booleans
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
1277 } |
5568
b0b5546f1b9f
find refactor: re-use existing code. /studies?expand is almost fully implemented with new code
Alain Mazy <am@orthanc.team>
parents:
5567
diff
changeset
|
1278 |
5590
8b32213af23e
replaced FindRequest::ResponseContent by booleans
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
1279 if (request.IsRetrieveAttachments()) |
8b32213af23e
replaced FindRequest::ResponseContent by booleans
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
1280 { |
8b32213af23e
replaced FindRequest::ResponseContent by booleans
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
1281 SQLite::Statement statement(db_, SQLITE_FROM_HERE, |
8b32213af23e
replaced FindRequest::ResponseContent by booleans
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
1282 "SELECT filtered.publicId, uuid, fileType, uncompressedSize, compressionType, compressedSize, " |
8b32213af23e
replaced FindRequest::ResponseContent by booleans
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
1283 " uncompressedMD5, compressedMD5 " |
8b32213af23e
replaced FindRequest::ResponseContent by booleans
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
1284 "FROM AttachedFiles " |
8b32213af23e
replaced FindRequest::ResponseContent by booleans
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
1285 " INNER JOIN FilteredResourcesIds filtered ON filtered.internalId = AttachedFiles.id"); |
5568
b0b5546f1b9f
find refactor: re-use existing code. /studies?expand is almost fully implemented with new code
Alain Mazy <am@orthanc.team>
parents:
5567
diff
changeset
|
1286 |
5590
8b32213af23e
replaced FindRequest::ResponseContent by booleans
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
1287 while (statement.Step()) |
5574
5a13483d12c5
find-refactoring: attachments
Alain Mazy <am@orthanc.team>
parents:
5568
diff
changeset
|
1288 { |
5590
8b32213af23e
replaced FindRequest::ResponseContent by booleans
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
1289 const std::string& resourceId = statement.ColumnString(0); |
8b32213af23e
replaced FindRequest::ResponseContent by booleans
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
1290 FileInfo attachment = FileInfo(statement.ColumnString(1), |
8b32213af23e
replaced FindRequest::ResponseContent by booleans
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
1291 static_cast<FileContentType>(statement.ColumnInt(2)), |
8b32213af23e
replaced FindRequest::ResponseContent by booleans
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
1292 statement.ColumnInt64(3), |
8b32213af23e
replaced FindRequest::ResponseContent by booleans
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
1293 statement.ColumnString(6), |
8b32213af23e
replaced FindRequest::ResponseContent by booleans
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
1294 static_cast<CompressionType>(statement.ColumnInt(4)), |
8b32213af23e
replaced FindRequest::ResponseContent by booleans
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
1295 statement.ColumnInt64(5), |
8b32213af23e
replaced FindRequest::ResponseContent by booleans
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
1296 statement.ColumnString(7)); |
5574
5a13483d12c5
find-refactoring: attachments
Alain Mazy <am@orthanc.team>
parents:
5568
diff
changeset
|
1297 |
5590
8b32213af23e
replaced FindRequest::ResponseContent by booleans
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
1298 assert(response.HasResource(resourceId)); |
8b32213af23e
replaced FindRequest::ResponseContent by booleans
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
1299 response.GetResource(resourceId).AddAttachment(attachment); |
8b32213af23e
replaced FindRequest::ResponseContent by booleans
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
1300 }; |
8b32213af23e
replaced FindRequest::ResponseContent by booleans
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
1301 } |
5588
1b0fc6685f57
add index of resources into FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5586
diff
changeset
|
1302 |
5590
8b32213af23e
replaced FindRequest::ResponseContent by booleans
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
1303 // TODO-FIND: implement other responseContent: ResponseContent_ChildInstanceId, ResponseContent_ChildrenMetadata (later: ResponseContent_IsStable) |
5574
5a13483d12c5
find-refactoring: attachments
Alain Mazy <am@orthanc.team>
parents:
5568
diff
changeset
|
1304 |
5567
f3562c1a150d
FindRequest: group metadata and tag constrains in a single class, allow ordering against metadata
Alain Mazy <am@orthanc.team>
parents:
5554
diff
changeset
|
1305 } |
5568
b0b5546f1b9f
find refactor: re-use existing code. /studies?expand is almost fully implemented with new code
Alain Mazy <am@orthanc.team>
parents:
5567
diff
changeset
|
1306 |
5567
f3562c1a150d
FindRequest: group metadata and tag constrains in a single class, allow ordering against metadata
Alain Mazy <am@orthanc.team>
parents:
5554
diff
changeset
|
1307 #endif |
5554
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5521
diff
changeset
|
1308 } |
5593
862b54b4cfe2
implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
1309 #endif |
862b54b4cfe2
implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
1310 |
4591
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1311 }; |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1312 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1313 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1314 class SQLiteDatabaseWrapper::SignalFileDeleted : public SQLite::IScalarFunction |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1315 { |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1316 private: |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1317 SQLiteDatabaseWrapper& sqlite_; |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1318 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1319 public: |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1320 SignalFileDeleted(SQLiteDatabaseWrapper& sqlite) : |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1321 sqlite_(sqlite) |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1322 { |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1323 } |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1324 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1325 virtual const char* GetName() const ORTHANC_OVERRIDE |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1326 { |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1327 return "SignalFileDeleted"; |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1328 } |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1329 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1330 virtual unsigned int GetCardinality() const ORTHANC_OVERRIDE |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1331 { |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1332 return 7; |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1333 } |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1334 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1335 virtual void Compute(SQLite::FunctionContext& context) ORTHANC_OVERRIDE |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1336 { |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1337 if (sqlite_.activeTransaction_ != NULL) |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1338 { |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1339 std::string uncompressedMD5, compressedMD5; |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1340 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1341 if (!context.IsNullValue(5)) |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1342 { |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1343 uncompressedMD5 = context.GetStringValue(5); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1344 } |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1345 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1346 if (!context.IsNullValue(6)) |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1347 { |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1348 compressedMD5 = context.GetStringValue(6); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1349 } |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1350 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1351 FileInfo info(context.GetStringValue(0), |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1352 static_cast<FileContentType>(context.GetIntValue(1)), |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1353 static_cast<uint64_t>(context.GetInt64Value(2)), |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1354 uncompressedMD5, |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1355 static_cast<CompressionType>(context.GetIntValue(3)), |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1356 static_cast<uint64_t>(context.GetInt64Value(4)), |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1357 compressedMD5); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1358 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1359 sqlite_.activeTransaction_->GetListener().SignalAttachmentDeleted(info); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1360 } |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1361 } |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1362 }; |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1363 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1364 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1365 class SQLiteDatabaseWrapper::SignalResourceDeleted : public SQLite::IScalarFunction |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1366 { |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1367 private: |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1368 SQLiteDatabaseWrapper& sqlite_; |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1369 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1370 public: |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1371 SignalResourceDeleted(SQLiteDatabaseWrapper& sqlite) : |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1372 sqlite_(sqlite) |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1373 { |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1374 } |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1375 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1376 virtual const char* GetName() const ORTHANC_OVERRIDE |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1377 { |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1378 return "SignalResourceDeleted"; |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1379 } |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1380 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1381 virtual unsigned int GetCardinality() const ORTHANC_OVERRIDE |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1382 { |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1383 return 2; |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1384 } |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1385 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1386 virtual void Compute(SQLite::FunctionContext& context) ORTHANC_OVERRIDE |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1387 { |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1388 if (sqlite_.activeTransaction_ != NULL) |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1389 { |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1390 sqlite_.activeTransaction_->GetListener(). |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1391 SignalResourceDeleted(static_cast<ResourceType>(context.GetIntValue(1)), |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1392 context.GetStringValue(0)); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1393 } |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1394 } |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1395 }; |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1396 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1397 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1398 class SQLiteDatabaseWrapper::ReadWriteTransaction : public SQLiteDatabaseWrapper::TransactionBase |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1399 { |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1400 private: |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1401 SQLiteDatabaseWrapper& that_; |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1402 std::unique_ptr<SQLite::Transaction> transaction_; |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1403 int64_t initialDiskSize_; |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1404 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1405 public: |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1406 ReadWriteTransaction(SQLiteDatabaseWrapper& that, |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1407 IDatabaseListener& listener) : |
5521
0d0f8788884a
removed unused variable dbCapabilities_ in SQLiteDatabaseWrapper::TransactionBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5519
diff
changeset
|
1408 TransactionBase(that.mutex_, that.db_, listener, *that.signalRemainingAncestor_), |
4591
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1409 that_(that), |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1410 transaction_(new SQLite::Transaction(that_.db_)) |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1411 { |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1412 if (that_.activeTransaction_ != NULL) |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1413 { |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1414 throw OrthancException(ErrorCode_InternalError); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1415 } |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1416 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1417 that_.activeTransaction_ = this; |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1418 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1419 #if defined(NDEBUG) |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1420 // Release mode |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1421 initialDiskSize_ = 0; |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1422 #else |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1423 // Debug mode |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1424 initialDiskSize_ = static_cast<int64_t>(GetTotalCompressedSize()); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1425 #endif |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1426 } |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1427 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1428 virtual ~ReadWriteTransaction() |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1429 { |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1430 assert(that_.activeTransaction_ != NULL); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1431 that_.activeTransaction_ = NULL; |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1432 } |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1433 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1434 void Begin() |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1435 { |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1436 transaction_->Begin(); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1437 } |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1438 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1439 virtual void Rollback() ORTHANC_OVERRIDE |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1440 { |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1441 transaction_->Rollback(); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1442 } |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1443 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1444 virtual void Commit(int64_t fileSizeDelta /* only used in debug */) ORTHANC_OVERRIDE |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1445 { |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1446 transaction_->Commit(); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1447 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1448 assert(initialDiskSize_ + fileSizeDelta >= 0 && |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1449 initialDiskSize_ + fileSizeDelta == static_cast<int64_t>(GetTotalCompressedSize())); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1450 } |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1451 }; |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1452 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1453 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1454 class SQLiteDatabaseWrapper::ReadOnlyTransaction : public SQLiteDatabaseWrapper::TransactionBase |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1455 { |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1456 private: |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1457 SQLiteDatabaseWrapper& that_; |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1458 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1459 public: |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1460 ReadOnlyTransaction(SQLiteDatabaseWrapper& that, |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1461 IDatabaseListener& listener) : |
5521
0d0f8788884a
removed unused variable dbCapabilities_ in SQLiteDatabaseWrapper::TransactionBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5519
diff
changeset
|
1462 TransactionBase(that.mutex_, that.db_, listener, *that.signalRemainingAncestor_), |
4591
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1463 that_(that) |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1464 { |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1465 if (that_.activeTransaction_ != NULL) |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1466 { |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1467 throw OrthancException(ErrorCode_InternalError); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1468 } |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1469 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1470 that_.activeTransaction_ = this; |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1471 } |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1472 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1473 virtual ~ReadOnlyTransaction() |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1474 { |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1475 assert(that_.activeTransaction_ != NULL); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1476 that_.activeTransaction_ = NULL; |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1477 } |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1478 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1479 virtual void Rollback() ORTHANC_OVERRIDE |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1480 { |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1481 } |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1482 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1483 virtual void Commit(int64_t fileSizeDelta /* only used in debug */) ORTHANC_OVERRIDE |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1484 { |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1485 if (fileSizeDelta != 0) |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1486 { |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1487 throw OrthancException(ErrorCode_InternalError); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1488 } |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1489 } |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1490 }; |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1491 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1492 |
3017
517fc4767ae0
renamed class DatabaseWrapper as SQLiteDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2955
diff
changeset
|
1493 SQLiteDatabaseWrapper::SQLiteDatabaseWrapper(const std::string& path) : |
4591
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1494 activeTransaction_(NULL), |
1847 | 1495 signalRemainingAncestor_(NULL), |
5517
0d433132b249
refactoring IDatabaseWrapper::Capabilities
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5497
diff
changeset
|
1496 version_(0) |
183 | 1497 { |
5517
0d433132b249
refactoring IDatabaseWrapper::Capabilities
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5497
diff
changeset
|
1498 // TODO: implement revisions in SQLite |
0d433132b249
refactoring IDatabaseWrapper::Capabilities
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5497
diff
changeset
|
1499 dbCapabilities_.SetFlushToDisk(true); |
0d433132b249
refactoring IDatabaseWrapper::Capabilities
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5497
diff
changeset
|
1500 dbCapabilities_.SetLabelsSupport(true); |
183 | 1501 db_.Open(path); |
1502 } | |
1503 | |
2773
bb63068844ae
moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
1504 |
3017
517fc4767ae0
renamed class DatabaseWrapper as SQLiteDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2955
diff
changeset
|
1505 SQLiteDatabaseWrapper::SQLiteDatabaseWrapper() : |
4591
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1506 activeTransaction_(NULL), |
1847 | 1507 signalRemainingAncestor_(NULL), |
5517
0d433132b249
refactoring IDatabaseWrapper::Capabilities
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5497
diff
changeset
|
1508 version_(0) |
183 | 1509 { |
5517
0d433132b249
refactoring IDatabaseWrapper::Capabilities
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5497
diff
changeset
|
1510 // TODO: implement revisions in SQLite |
0d433132b249
refactoring IDatabaseWrapper::Capabilities
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5497
diff
changeset
|
1511 dbCapabilities_.SetFlushToDisk(true); |
0d433132b249
refactoring IDatabaseWrapper::Capabilities
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5497
diff
changeset
|
1512 dbCapabilities_.SetLabelsSupport(true); |
183 | 1513 db_.OpenInMemory(); |
1514 } | |
1515 | |
4591
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1516 SQLiteDatabaseWrapper::~SQLiteDatabaseWrapper() |
3116 | 1517 { |
4591
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1518 if (activeTransaction_ != NULL) |
3116 | 1519 { |
4591
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1520 LOG(ERROR) << "A SQLite transaction is still active in the SQLiteDatabaseWrapper destructor: Expect a crash"; |
3116 | 1521 } |
1522 } | |
1523 | |
1524 | |
3017
517fc4767ae0
renamed class DatabaseWrapper as SQLiteDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2955
diff
changeset
|
1525 void SQLiteDatabaseWrapper::Open() |
183 | 1526 { |
4591
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1527 { |
4594
d494b4f1103e
removed the global database mutex from ServerIndex and StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4592
diff
changeset
|
1528 boost::mutex::scoped_lock lock(mutex_); |
1717
3926e6317a43
SetIdentifierTagInternal
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1712
diff
changeset
|
1529 |
4594
d494b4f1103e
removed the global database mutex from ServerIndex and StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4592
diff
changeset
|
1530 if (signalRemainingAncestor_ != NULL) |
d494b4f1103e
removed the global database mutex from ServerIndex and StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4592
diff
changeset
|
1531 { |
d494b4f1103e
removed the global database mutex from ServerIndex and StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4592
diff
changeset
|
1532 throw OrthancException(ErrorCode_BadSequenceOfCalls); // Cannot open twice |
d494b4f1103e
removed the global database mutex from ServerIndex and StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4592
diff
changeset
|
1533 } |
d494b4f1103e
removed the global database mutex from ServerIndex and StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4592
diff
changeset
|
1534 |
d494b4f1103e
removed the global database mutex from ServerIndex and StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4592
diff
changeset
|
1535 signalRemainingAncestor_ = dynamic_cast<SignalRemainingAncestor*>(db_.Register(new SignalRemainingAncestor)); |
d494b4f1103e
removed the global database mutex from ServerIndex and StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4592
diff
changeset
|
1536 db_.Register(new SignalFileDeleted(*this)); |
d494b4f1103e
removed the global database mutex from ServerIndex and StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4592
diff
changeset
|
1537 db_.Register(new SignalResourceDeleted(*this)); |
d494b4f1103e
removed the global database mutex from ServerIndex and StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4592
diff
changeset
|
1538 |
d494b4f1103e
removed the global database mutex from ServerIndex and StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4592
diff
changeset
|
1539 db_.Execute("PRAGMA ENCODING=\"UTF-8\";"); |
374 | 1540 |
4594
d494b4f1103e
removed the global database mutex from ServerIndex and StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4592
diff
changeset
|
1541 // Performance tuning of SQLite with PRAGMAs |
d494b4f1103e
removed the global database mutex from ServerIndex and StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4592
diff
changeset
|
1542 // http://www.sqlite.org/pragma.html |
d494b4f1103e
removed the global database mutex from ServerIndex and StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4592
diff
changeset
|
1543 db_.Execute("PRAGMA SYNCHRONOUS=NORMAL;"); |
d494b4f1103e
removed the global database mutex from ServerIndex and StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4592
diff
changeset
|
1544 db_.Execute("PRAGMA JOURNAL_MODE=WAL;"); |
d494b4f1103e
removed the global database mutex from ServerIndex and StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4592
diff
changeset
|
1545 db_.Execute("PRAGMA LOCKING_MODE=EXCLUSIVE;"); |
d494b4f1103e
removed the global database mutex from ServerIndex and StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4592
diff
changeset
|
1546 db_.Execute("PRAGMA WAL_AUTOCHECKPOINT=1000;"); |
d494b4f1103e
removed the global database mutex from ServerIndex and StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4592
diff
changeset
|
1547 //db_.Execute("PRAGMA TEMP_STORE=memory"); |
d494b4f1103e
removed the global database mutex from ServerIndex and StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4592
diff
changeset
|
1548 |
d494b4f1103e
removed the global database mutex from ServerIndex and StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4592
diff
changeset
|
1549 // Make "LIKE" case-sensitive in SQLite |
d494b4f1103e
removed the global database mutex from ServerIndex and StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4592
diff
changeset
|
1550 db_.Execute("PRAGMA case_sensitive_like = true;"); |
d494b4f1103e
removed the global database mutex from ServerIndex and StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4592
diff
changeset
|
1551 } |
4591
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1552 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1553 VoidDatabaseListener listener; |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1554 |
183 | 1555 { |
4591
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1556 std::unique_ptr<ITransaction> transaction(StartTransaction(TransactionType_ReadOnly, listener)); |
1239 | 1557 |
3116 | 1558 if (!db_.DoesTableExist("GlobalProperties")) |
3018
e3b5c07146a3
speeding up the computation of the size of the attachments in SQLite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3017
diff
changeset
|
1559 { |
3116 | 1560 LOG(INFO) << "Creating the database"; |
3018
e3b5c07146a3
speeding up the computation of the size of the attachments in SQLite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3017
diff
changeset
|
1561 std::string query; |
4031
e3b3af80732d
ServerResources, and moving EmbeddedResourceHttpHandler from Core to OrthancServer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4030
diff
changeset
|
1562 ServerResources::GetFileResource(query, ServerResources::PREPARE_DATABASE); |
3018
e3b5c07146a3
speeding up the computation of the size of the attachments in SQLite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3017
diff
changeset
|
1563 db_.Execute(query); |
e3b5c07146a3
speeding up the computation of the size of the attachments in SQLite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3017
diff
changeset
|
1564 } |
3116 | 1565 |
1566 // Check the version of the database | |
1567 std::string tmp; | |
4607
f75c63aa9de0
differentiating between shared and private global properties
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4595
diff
changeset
|
1568 if (!transaction->LookupGlobalProperty(tmp, GlobalProperty_DatabaseSchemaVersion, true /* unused in SQLite */)) |
3116 | 1569 { |
1570 tmp = "Unknown"; | |
1571 } | |
1572 | |
1573 bool ok = false; | |
1574 try | |
1575 { | |
1576 LOG(INFO) << "Version of the Orthanc database: " << tmp; | |
1577 version_ = boost::lexical_cast<unsigned int>(tmp); | |
1578 ok = true; | |
1579 } | |
1580 catch (boost::bad_lexical_cast&) | |
1581 { | |
1582 } | |
1583 | |
1584 if (!ok) | |
1585 { | |
1586 throw OrthancException(ErrorCode_IncompatibleDatabaseVersion, | |
1587 "Incompatible version of the Orthanc database: " + tmp); | |
1588 } | |
1589 | |
1590 if (version_ == 6) | |
1591 { | |
5221
d0f7c742d397
started implementation of labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5220
diff
changeset
|
1592 // New in Orthanc 1.5.1 |
4607
f75c63aa9de0
differentiating between shared and private global properties
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4595
diff
changeset
|
1593 if (!transaction->LookupGlobalProperty(tmp, GlobalProperty_GetTotalSizeIsFast, true /* unused in SQLite */) || |
3116 | 1594 tmp != "1") |
1595 { | |
1596 LOG(INFO) << "Installing the SQLite triggers to track the size of the attachments"; | |
1597 std::string query; | |
4031
e3b3af80732d
ServerResources, and moving EmbeddedResourceHttpHandler from Core to OrthancServer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4030
diff
changeset
|
1598 ServerResources::GetFileResource(query, ServerResources::INSTALL_TRACK_ATTACHMENTS_SIZE); |
3116 | 1599 db_.Execute(query); |
1600 } | |
5221
d0f7c742d397
started implementation of labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5220
diff
changeset
|
1601 |
d0f7c742d397
started implementation of labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5220
diff
changeset
|
1602 // New in Orthanc 1.12.0 |
d0f7c742d397
started implementation of labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5220
diff
changeset
|
1603 if (!db_.DoesTableExist("Labels")) |
d0f7c742d397
started implementation of labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5220
diff
changeset
|
1604 { |
d0f7c742d397
started implementation of labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5220
diff
changeset
|
1605 LOG(INFO) << "Installing the \"Labels\" table"; |
d0f7c742d397
started implementation of labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5220
diff
changeset
|
1606 std::string query; |
d0f7c742d397
started implementation of labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5220
diff
changeset
|
1607 ServerResources::GetFileResource(query, ServerResources::INSTALL_LABELS_TABLE); |
d0f7c742d397
started implementation of labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5220
diff
changeset
|
1608 db_.Execute(query); |
d0f7c742d397
started implementation of labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5220
diff
changeset
|
1609 } |
3116 | 1610 } |
1611 | |
4591
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1612 transaction->Commit(0); |
3018
e3b5c07146a3
speeding up the computation of the size of the attachments in SQLite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3017
diff
changeset
|
1613 } |
1247 | 1614 } |
1615 | |
1615
c40fe92a68e7
Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1509
diff
changeset
|
1616 |
4594
d494b4f1103e
removed the global database mutex from ServerIndex and StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4592
diff
changeset
|
1617 void SQLiteDatabaseWrapper::Close() |
d494b4f1103e
removed the global database mutex from ServerIndex and StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4592
diff
changeset
|
1618 { |
d494b4f1103e
removed the global database mutex from ServerIndex and StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4592
diff
changeset
|
1619 boost::mutex::scoped_lock lock(mutex_); |
5057
e6f26be401fa
SQLite: close and delete WAL and SHM files on exit (contribution from Sebastian Höffner)
Alain Mazy <am@osimis.io>
parents:
4892
diff
changeset
|
1620 // close and delete the WAL when exiting properly -> the DB is stored in a single file (no more -wal and -shm files) |
e6f26be401fa
SQLite: close and delete WAL and SHM files on exit (contribution from Sebastian Höffner)
Alain Mazy <am@osimis.io>
parents:
4892
diff
changeset
|
1621 db_.Execute("PRAGMA JOURNAL_MODE=DELETE;"); |
4594
d494b4f1103e
removed the global database mutex from ServerIndex and StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4592
diff
changeset
|
1622 db_.Close(); |
d494b4f1103e
removed the global database mutex from ServerIndex and StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4592
diff
changeset
|
1623 } |
d494b4f1103e
removed the global database mutex from ServerIndex and StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4592
diff
changeset
|
1624 |
d494b4f1103e
removed the global database mutex from ServerIndex and StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4592
diff
changeset
|
1625 |
1615
c40fe92a68e7
Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1509
diff
changeset
|
1626 static void ExecuteUpgradeScript(SQLite::Connection& db, |
4031
e3b3af80732d
ServerResources, and moving EmbeddedResourceHttpHandler from Core to OrthancServer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4030
diff
changeset
|
1627 ServerResources::FileResourceId script) |
1615
c40fe92a68e7
Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1509
diff
changeset
|
1628 { |
c40fe92a68e7
Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1509
diff
changeset
|
1629 std::string upgrade; |
4031
e3b3af80732d
ServerResources, and moving EmbeddedResourceHttpHandler from Core to OrthancServer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4030
diff
changeset
|
1630 ServerResources::GetFileResource(upgrade, script); |
1615
c40fe92a68e7
Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1509
diff
changeset
|
1631 db.BeginTransaction(); |
c40fe92a68e7
Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1509
diff
changeset
|
1632 db.Execute(upgrade); |
c40fe92a68e7
Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1509
diff
changeset
|
1633 db.CommitTransaction(); |
c40fe92a68e7
Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1509
diff
changeset
|
1634 } |
c40fe92a68e7
Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1509
diff
changeset
|
1635 |
c40fe92a68e7
Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1509
diff
changeset
|
1636 |
3017
517fc4767ae0
renamed class DatabaseWrapper as SQLiteDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2955
diff
changeset
|
1637 void SQLiteDatabaseWrapper::Upgrade(unsigned int targetVersion, |
517fc4767ae0
renamed class DatabaseWrapper as SQLiteDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2955
diff
changeset
|
1638 IStorageArea& storageArea) |
1615
c40fe92a68e7
Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1509
diff
changeset
|
1639 { |
4594
d494b4f1103e
removed the global database mutex from ServerIndex and StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4592
diff
changeset
|
1640 boost::mutex::scoped_lock lock(mutex_); |
d494b4f1103e
removed the global database mutex from ServerIndex and StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4592
diff
changeset
|
1641 |
1664
0c58f189782d
prepare migration to db v6
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1615
diff
changeset
|
1642 if (targetVersion != 6) |
1615
c40fe92a68e7
Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1509
diff
changeset
|
1643 { |
c40fe92a68e7
Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1509
diff
changeset
|
1644 throw OrthancException(ErrorCode_IncompatibleDatabaseVersion); |
c40fe92a68e7
Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1509
diff
changeset
|
1645 } |
c40fe92a68e7
Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1509
diff
changeset
|
1646 |
1664
0c58f189782d
prepare migration to db v6
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1615
diff
changeset
|
1647 // This version of Orthanc is only compatible with versions 3, 4, |
0c58f189782d
prepare migration to db v6
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1615
diff
changeset
|
1648 // 5 and 6 of the DB schema |
1615
c40fe92a68e7
Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1509
diff
changeset
|
1649 if (version_ != 3 && |
c40fe92a68e7
Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1509
diff
changeset
|
1650 version_ != 4 && |
1664
0c58f189782d
prepare migration to db v6
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1615
diff
changeset
|
1651 version_ != 5 && |
0c58f189782d
prepare migration to db v6
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1615
diff
changeset
|
1652 version_ != 6) |
1615
c40fe92a68e7
Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1509
diff
changeset
|
1653 { |
c40fe92a68e7
Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1509
diff
changeset
|
1654 throw OrthancException(ErrorCode_IncompatibleDatabaseVersion); |
c40fe92a68e7
Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1509
diff
changeset
|
1655 } |
c40fe92a68e7
Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1509
diff
changeset
|
1656 |
c40fe92a68e7
Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1509
diff
changeset
|
1657 if (version_ == 3) |
c40fe92a68e7
Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1509
diff
changeset
|
1658 { |
c40fe92a68e7
Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1509
diff
changeset
|
1659 LOG(WARNING) << "Upgrading database version from 3 to 4"; |
4031
e3b3af80732d
ServerResources, and moving EmbeddedResourceHttpHandler from Core to OrthancServer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4030
diff
changeset
|
1660 ExecuteUpgradeScript(db_, ServerResources::UPGRADE_DATABASE_3_TO_4); |
1615
c40fe92a68e7
Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1509
diff
changeset
|
1661 version_ = 4; |
c40fe92a68e7
Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1509
diff
changeset
|
1662 } |
c40fe92a68e7
Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1509
diff
changeset
|
1663 |
c40fe92a68e7
Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1509
diff
changeset
|
1664 if (version_ == 4) |
c40fe92a68e7
Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1509
diff
changeset
|
1665 { |
c40fe92a68e7
Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1509
diff
changeset
|
1666 LOG(WARNING) << "Upgrading database version from 4 to 5"; |
4031
e3b3af80732d
ServerResources, and moving EmbeddedResourceHttpHandler from Core to OrthancServer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4030
diff
changeset
|
1667 ExecuteUpgradeScript(db_, ServerResources::UPGRADE_DATABASE_4_TO_5); |
1615
c40fe92a68e7
Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1509
diff
changeset
|
1668 version_ = 5; |
c40fe92a68e7
Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1509
diff
changeset
|
1669 } |
1664
0c58f189782d
prepare migration to db v6
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1615
diff
changeset
|
1670 |
0c58f189782d
prepare migration to db v6
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1615
diff
changeset
|
1671 if (version_ == 5) |
0c58f189782d
prepare migration to db v6
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1615
diff
changeset
|
1672 { |
0c58f189782d
prepare migration to db v6
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1615
diff
changeset
|
1673 LOG(WARNING) << "Upgrading database version from 5 to 6"; |
1668
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1665
diff
changeset
|
1674 // No change in the DB schema, the step from version 5 to 6 only |
1710 | 1675 // consists in reconstructing the main DICOM tags information |
1676 // (as more tags got included). | |
4591
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1677 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1678 VoidDatabaseListener listener; |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1679 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1680 { |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1681 std::unique_ptr<ITransaction> transaction(StartTransaction(TransactionType_ReadWrite, listener)); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1682 ServerToolbox::ReconstructMainDicomTags(*transaction, storageArea, ResourceType_Patient); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1683 ServerToolbox::ReconstructMainDicomTags(*transaction, storageArea, ResourceType_Study); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1684 ServerToolbox::ReconstructMainDicomTags(*transaction, storageArea, ResourceType_Series); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1685 ServerToolbox::ReconstructMainDicomTags(*transaction, storageArea, ResourceType_Instance); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1686 db_.Execute("UPDATE GlobalProperties SET value=\"6\" WHERE property=" + |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1687 boost::lexical_cast<std::string>(GlobalProperty_DatabaseSchemaVersion) + ";"); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1688 transaction->Commit(0); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1689 } |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1690 |
1664
0c58f189782d
prepare migration to db v6
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1615
diff
changeset
|
1691 version_ = 6; |
1729 | 1692 } |
1615
c40fe92a68e7
Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1509
diff
changeset
|
1693 } |
c40fe92a68e7
Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1509
diff
changeset
|
1694 |
c40fe92a68e7
Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1509
diff
changeset
|
1695 |
4589
bec74e29f86b
attaching the listener to transactions in IDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4571
diff
changeset
|
1696 IDatabaseWrapper::ITransaction* SQLiteDatabaseWrapper::StartTransaction(TransactionType type, |
bec74e29f86b
attaching the listener to transactions in IDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4571
diff
changeset
|
1697 IDatabaseListener& listener) |
4570
648defffc8cc
new enum: TransactionType
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4556
diff
changeset
|
1698 { |
648defffc8cc
new enum: TransactionType
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4556
diff
changeset
|
1699 switch (type) |
648defffc8cc
new enum: TransactionType
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4556
diff
changeset
|
1700 { |
648defffc8cc
new enum: TransactionType
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4556
diff
changeset
|
1701 case TransactionType_ReadOnly: |
4589
bec74e29f86b
attaching the listener to transactions in IDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4571
diff
changeset
|
1702 return new ReadOnlyTransaction(*this, listener); // This is a no-op transaction in SQLite (thanks to mutex) |
4570
648defffc8cc
new enum: TransactionType
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4556
diff
changeset
|
1703 |
648defffc8cc
new enum: TransactionType
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4556
diff
changeset
|
1704 case TransactionType_ReadWrite: |
648defffc8cc
new enum: TransactionType
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4556
diff
changeset
|
1705 { |
648defffc8cc
new enum: TransactionType
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4556
diff
changeset
|
1706 std::unique_ptr<ReadWriteTransaction> transaction; |
4589
bec74e29f86b
attaching the listener to transactions in IDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4571
diff
changeset
|
1707 transaction.reset(new ReadWriteTransaction(*this, listener)); |
4570
648defffc8cc
new enum: TransactionType
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4556
diff
changeset
|
1708 transaction->Begin(); |
648defffc8cc
new enum: TransactionType
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4556
diff
changeset
|
1709 return transaction.release(); |
648defffc8cc
new enum: TransactionType
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4556
diff
changeset
|
1710 } |
648defffc8cc
new enum: TransactionType
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4556
diff
changeset
|
1711 |
648defffc8cc
new enum: TransactionType
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4556
diff
changeset
|
1712 default: |
648defffc8cc
new enum: TransactionType
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4556
diff
changeset
|
1713 throw OrthancException(ErrorCode_InternalError); |
648defffc8cc
new enum: TransactionType
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4556
diff
changeset
|
1714 } |
3019
8336204d95dc
refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3018
diff
changeset
|
1715 } |
8336204d95dc
refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3018
diff
changeset
|
1716 |
4591
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1717 |
4594
d494b4f1103e
removed the global database mutex from ServerIndex and StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4592
diff
changeset
|
1718 void SQLiteDatabaseWrapper::FlushToDisk() |
d494b4f1103e
removed the global database mutex from ServerIndex and StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4592
diff
changeset
|
1719 { |
d494b4f1103e
removed the global database mutex from ServerIndex and StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4592
diff
changeset
|
1720 boost::mutex::scoped_lock lock(mutex_); |
d494b4f1103e
removed the global database mutex from ServerIndex and StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4592
diff
changeset
|
1721 db_.FlushToDisk(); |
d494b4f1103e
removed the global database mutex from ServerIndex and StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4592
diff
changeset
|
1722 } |
d494b4f1103e
removed the global database mutex from ServerIndex and StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4592
diff
changeset
|
1723 |
d494b4f1103e
removed the global database mutex from ServerIndex and StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4592
diff
changeset
|
1724 |
4591
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1725 int64_t SQLiteDatabaseWrapper::UnitTestsTransaction::CreateResource(const std::string& publicId, |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1726 ResourceType type) |
2773
bb63068844ae
moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
1727 { |
5090
cc1a8b3ff319
Made the default SQLite DB more robust wrt future updates like adding new columns in DB.
Alain Mazy <am@osimis.io>
parents:
5057
diff
changeset
|
1728 SQLite::Statement s(db_, SQLITE_FROM_HERE, "INSERT INTO Resources (internalId, resourceType, publicId, parentId) VALUES(NULL, ?, ?, NULL)"); |
2773
bb63068844ae
moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
1729 s.BindInt(0, type); |
bb63068844ae
moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
1730 s.BindString(1, publicId); |
bb63068844ae
moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
1731 s.Run(); |
bb63068844ae
moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
1732 return db_.GetLastInsertRowId(); |
bb63068844ae
moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
1733 } |
bb63068844ae
moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
1734 |
bb63068844ae
moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
1735 |
4591
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1736 void SQLiteDatabaseWrapper::UnitTestsTransaction::AttachChild(int64_t parent, |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1737 int64_t child) |
2773
bb63068844ae
moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
1738 { |
bb63068844ae
moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
1739 SQLite::Statement s(db_, SQLITE_FROM_HERE, "UPDATE Resources SET parentId = ? WHERE internalId = ?"); |
bb63068844ae
moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
1740 s.BindInt64(0, parent); |
bb63068844ae
moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
1741 s.BindInt64(1, child); |
bb63068844ae
moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
1742 s.Run(); |
bb63068844ae
moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
1743 } |
bb63068844ae
moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
1744 |
bb63068844ae
moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
1745 |
4591
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1746 void SQLiteDatabaseWrapper::UnitTestsTransaction::SetIdentifierTag(int64_t id, |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1747 const DicomTag& tag, |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1748 const std::string& value) |
2773
bb63068844ae
moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
1749 { |
5090
cc1a8b3ff319
Made the default SQLite DB more robust wrt future updates like adding new columns in DB.
Alain Mazy <am@osimis.io>
parents:
5057
diff
changeset
|
1750 SQLite::Statement s(db_, SQLITE_FROM_HERE, "INSERT INTO DicomIdentifiers (id, tagGroup, tagElement, value) VALUES(?, ?, ?, ?)"); |
2773
bb63068844ae
moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
1751 s.BindInt64(0, id); |
bb63068844ae
moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
1752 s.BindInt(1, tag.GetGroup()); |
bb63068844ae
moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
1753 s.BindInt(2, tag.GetElement()); |
bb63068844ae
moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
1754 s.BindString(3, value); |
bb63068844ae
moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
1755 s.Run(); |
bb63068844ae
moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
1756 } |
bb63068844ae
moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
1757 |
bb63068844ae
moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
1758 |
4591
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1759 void SQLiteDatabaseWrapper::UnitTestsTransaction::SetMainDicomTag(int64_t id, |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1760 const DicomTag& tag, |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1761 const std::string& value) |
2773
bb63068844ae
moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
1762 { |
5090
cc1a8b3ff319
Made the default SQLite DB more robust wrt future updates like adding new columns in DB.
Alain Mazy <am@osimis.io>
parents:
5057
diff
changeset
|
1763 SQLite::Statement s(db_, SQLITE_FROM_HERE, "INSERT INTO MainDicomTags (id, tagGroup, tagElement, value) VALUES(?, ?, ?, ?)"); |
2773
bb63068844ae
moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
1764 s.BindInt64(0, id); |
4591
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1765 s.BindInt(1, tag.GetGroup()); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1766 s.BindInt(2, tag.GetElement()); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1767 s.BindString(3, value); |
2773
bb63068844ae
moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
1768 s.Run(); |
bb63068844ae
moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
1769 } |
bb63068844ae
moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
1770 |
bb63068844ae
moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
1771 |
4591
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1772 int64_t SQLiteDatabaseWrapper::UnitTestsTransaction::GetTableRecordCount(const std::string& table) |
2773
bb63068844ae
moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
1773 { |
4591
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1774 /** |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1775 * "Generally one cannot use SQL parameters/placeholders for |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1776 * database identifiers (tables, columns, views, schemas, etc.) or |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1777 * database functions (e.g., CURRENT_DATE), but instead only for |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1778 * binding literal values." => To avoid any SQL injection, we |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1779 * check that the "table" parameter has only alphabetic |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1780 * characters. |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1781 * https://stackoverflow.com/a/1274764/881731 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1782 **/ |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1783 for (size_t i = 0; i < table.size(); i++) |
2773
bb63068844ae
moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
1784 { |
4591
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1785 if (!isalpha(table[i])) |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1786 { |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1787 throw OrthancException(ErrorCode_ParameterOutOfRange); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1788 } |
2773
bb63068844ae
moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
1789 } |
bb63068844ae
moving DatabaseWrapperBase into graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
1790 |
4591
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1791 // Don't use "SQLITE_FROM_HERE", otherwise "table" would be cached |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1792 SQLite::Statement s(db_, "SELECT COUNT(*) FROM " + table); |
3105
2e1711f80f74
More consistent handling of the "Last" field returned by the "/changes" URI
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3093
diff
changeset
|
1793 |
2e1711f80f74
More consistent handling of the "Last" field returned by the "/changes" URI
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3093
diff
changeset
|
1794 if (s.Step()) |
2e1711f80f74
More consistent handling of the "Last" field returned by the "/changes" URI
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3093
diff
changeset
|
1795 { |
2e1711f80f74
More consistent handling of the "Last" field returned by the "/changes" URI
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3093
diff
changeset
|
1796 int64_t c = s.ColumnInt(0); |
2e1711f80f74
More consistent handling of the "Last" field returned by the "/changes" URI
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3093
diff
changeset
|
1797 assert(!s.Step()); |
2e1711f80f74
More consistent handling of the "Last" field returned by the "/changes" URI
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3093
diff
changeset
|
1798 return c; |
2e1711f80f74
More consistent handling of the "Last" field returned by the "/changes" URI
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3093
diff
changeset
|
1799 } |
2e1711f80f74
More consistent handling of the "Last" field returned by the "/changes" URI
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3093
diff
changeset
|
1800 else |
2e1711f80f74
More consistent handling of the "Last" field returned by the "/changes" URI
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3093
diff
changeset
|
1801 { |
4591
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1802 throw OrthancException(ErrorCode_InternalError); |
3105
2e1711f80f74
More consistent handling of the "Last" field returned by the "/changes" URI
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3093
diff
changeset
|
1803 } |
2e1711f80f74
More consistent handling of the "Last" field returned by the "/changes" URI
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3093
diff
changeset
|
1804 } |
3121 | 1805 |
1806 | |
4591
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1807 bool SQLiteDatabaseWrapper::UnitTestsTransaction::GetParentPublicId(std::string& target, |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1808 int64_t id) |
3121 | 1809 { |
4591
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1810 SQLite::Statement s(db_, SQLITE_FROM_HERE, "SELECT a.publicId FROM Resources AS a, Resources AS b " |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1811 "WHERE a.internalId = b.parentId AND b.internalId = ?"); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1812 s.BindInt64(0, id); |
3124
c0d7aee8c3f8
Fix issue #58 (Patient recycling order should be defined by their received last instance)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3121
diff
changeset
|
1813 |
4591
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1814 if (s.Step()) |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1815 { |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1816 target = s.ColumnString(0); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1817 return true; |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1818 } |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1819 else |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1820 { |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1821 return false; |
3124
c0d7aee8c3f8
Fix issue #58 (Patient recycling order should be defined by their received last instance)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3121
diff
changeset
|
1822 } |
4591
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1823 } |
3124
c0d7aee8c3f8
Fix issue #58 (Patient recycling order should be defined by their received last instance)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3121
diff
changeset
|
1824 |
4591
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1825 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1826 void SQLiteDatabaseWrapper::UnitTestsTransaction::GetChildren(std::list<std::string>& childrenPublicIds, |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1827 int64_t id) |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1828 { |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1829 SQLite::Statement s(db_, SQLITE_FROM_HERE, "SELECT publicId FROM Resources WHERE parentId=?"); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1830 s.BindInt64(0, id); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1831 |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1832 childrenPublicIds.clear(); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1833 while (s.Step()) |
3124
c0d7aee8c3f8
Fix issue #58 (Patient recycling order should be defined by their received last instance)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3121
diff
changeset
|
1834 { |
4591
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
1835 childrenPublicIds.push_back(s.ColumnString(0)); |
3124
c0d7aee8c3f8
Fix issue #58 (Patient recycling order should be defined by their received last instance)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3121
diff
changeset
|
1836 } |
3121 | 1837 } |
183 | 1838 } |