Mercurial > hg > orthanc
annotate OrthancServer/Sources/Database/StatelessDatabaseOperations.cpp @ 5656:a3c244090f67 find-refactoring
integration mainline->find-refactoring
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 06 Jun 2024 13:24:04 +0200 |
parents | 3f13db27b399 |
children | dc96401dbe88 |
rev | line source |
---|---|
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1 /** |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2 * Orthanc - A Lightweight, RESTful DICOM Store |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
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:
5635
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:
5635
diff
changeset
|
6 * Copyright (C) 2024-2024 Orthanc Team SRL, Belgium |
5485
48b8dae6dc77
upgrade to year 2024
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5324
diff
changeset
|
7 * Copyright (C) 2021-2024 Sebastien Jodogne, ICTEAM UCLouvain, Belgium |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
8 * |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
9 * This program is free software: you can redistribute it and/or |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
10 * modify it under the terms of the GNU General Public License as |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
11 * published by the Free Software Foundation, either version 3 of the |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
12 * License, or (at your option) any later version. |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
13 * |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
14 * This program is distributed in the hope that it will be useful, but |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
15 * WITHOUT ANY WARRANTY; without even the implied warranty of |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
17 * General Public License for more details. |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
18 * |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
19 * You should have received a copy of the GNU General Public License |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
20 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
21 **/ |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
22 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
23 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
24 #include "../PrecompiledHeadersServer.h" |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
25 #include "StatelessDatabaseOperations.h" |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
26 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
27 #ifndef NOMINMAX |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
28 #define NOMINMAX |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
29 #endif |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
30 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
31 #include "../../../OrthancFramework/Sources/DicomParsing/FromDcmtkBridge.h" |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
32 #include "../../../OrthancFramework/Sources/DicomParsing/ParsedDicomFile.h" |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
33 #include "../../../OrthancFramework/Sources/Logging.h" |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
34 #include "../../../OrthancFramework/Sources/OrthancException.h" |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
35 #include "../OrthancConfiguration.h" |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
36 #include "../Search/DatabaseLookup.h" |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
37 #include "../ServerIndexChange.h" |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
38 #include "../ServerToolbox.h" |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
39 #include "ResourcesContent.h" |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
40 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
41 #include <boost/lexical_cast.hpp> |
4633 | 42 #include <boost/thread.hpp> |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
43 #include <boost/tuple/tuple.hpp> |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
44 #include <stack> |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
45 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
46 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
47 namespace Orthanc |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
48 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
49 namespace |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
50 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
51 /** |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
52 * Some handy templates to reduce the verbosity in the definitions |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
53 * of the internal classes. |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
54 **/ |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
55 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
56 template <typename Operations, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
57 typename Tuple> |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
58 class TupleOperationsWrapper : public StatelessDatabaseOperations::IReadOnlyOperations |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
59 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
60 protected: |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
61 Operations& operations_; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
62 const Tuple& tuple_; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
63 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
64 public: |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
65 TupleOperationsWrapper(Operations& operations, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
66 const Tuple& tuple) : |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
67 operations_(operations), |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
68 tuple_(tuple) |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
69 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
70 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
71 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
72 virtual void Apply(StatelessDatabaseOperations::ReadOnlyTransaction& transaction) ORTHANC_OVERRIDE |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
73 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
74 operations_.ApplyTuple(transaction, tuple_); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
75 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
76 }; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
77 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
78 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
79 template <typename T1> |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
80 class ReadOnlyOperationsT1 : public boost::noncopyable |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
81 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
82 public: |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
83 typedef typename boost::tuple<T1> Tuple; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
84 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
85 virtual ~ReadOnlyOperationsT1() |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
86 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
87 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
88 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
89 virtual void ApplyTuple(StatelessDatabaseOperations::ReadOnlyTransaction& transaction, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
90 const Tuple& tuple) = 0; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
91 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
92 void Apply(StatelessDatabaseOperations& index, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
93 T1 t1) |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
94 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
95 const Tuple tuple(t1); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
96 TupleOperationsWrapper<ReadOnlyOperationsT1, Tuple> wrapper(*this, tuple); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
97 index.Apply(wrapper); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
98 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
99 }; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
100 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
101 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
102 template <typename T1, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
103 typename T2> |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
104 class ReadOnlyOperationsT2 : public boost::noncopyable |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
105 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
106 public: |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
107 typedef typename boost::tuple<T1, T2> Tuple; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
108 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
109 virtual ~ReadOnlyOperationsT2() |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
110 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
111 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
112 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
113 virtual void ApplyTuple(StatelessDatabaseOperations::ReadOnlyTransaction& transaction, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
114 const Tuple& tuple) = 0; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
115 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
116 void Apply(StatelessDatabaseOperations& index, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
117 T1 t1, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
118 T2 t2) |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
119 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
120 const Tuple tuple(t1, t2); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
121 TupleOperationsWrapper<ReadOnlyOperationsT2, Tuple> wrapper(*this, tuple); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
122 index.Apply(wrapper); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
123 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
124 }; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
125 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
126 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
127 template <typename T1, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
128 typename T2, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
129 typename T3> |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
130 class ReadOnlyOperationsT3 : public boost::noncopyable |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
131 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
132 public: |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
133 typedef typename boost::tuple<T1, T2, T3> Tuple; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
134 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
135 virtual ~ReadOnlyOperationsT3() |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
136 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
137 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
138 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
139 virtual void ApplyTuple(StatelessDatabaseOperations::ReadOnlyTransaction& transaction, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
140 const Tuple& tuple) = 0; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
141 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
142 void Apply(StatelessDatabaseOperations& index, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
143 T1 t1, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
144 T2 t2, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
145 T3 t3) |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
146 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
147 const Tuple tuple(t1, t2, t3); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
148 TupleOperationsWrapper<ReadOnlyOperationsT3, Tuple> wrapper(*this, tuple); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
149 index.Apply(wrapper); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
150 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
151 }; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
152 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
153 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
154 template <typename T1, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
155 typename T2, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
156 typename T3, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
157 typename T4> |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
158 class ReadOnlyOperationsT4 : public boost::noncopyable |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
159 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
160 public: |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
161 typedef typename boost::tuple<T1, T2, T3, T4> Tuple; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
162 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
163 virtual ~ReadOnlyOperationsT4() |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
164 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
165 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
166 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
167 virtual void ApplyTuple(StatelessDatabaseOperations::ReadOnlyTransaction& transaction, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
168 const Tuple& tuple) = 0; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
169 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
170 void Apply(StatelessDatabaseOperations& index, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
171 T1 t1, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
172 T2 t2, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
173 T3 t3, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
174 T4 t4) |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
175 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
176 const Tuple tuple(t1, t2, t3, t4); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
177 TupleOperationsWrapper<ReadOnlyOperationsT4, Tuple> wrapper(*this, tuple); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
178 index.Apply(wrapper); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
179 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
180 }; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
181 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
182 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
183 template <typename T1, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
184 typename T2, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
185 typename T3, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
186 typename T4, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
187 typename T5> |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
188 class ReadOnlyOperationsT5 : public boost::noncopyable |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
189 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
190 public: |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
191 typedef typename boost::tuple<T1, T2, T3, T4, T5> Tuple; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
192 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
193 virtual ~ReadOnlyOperationsT5() |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
194 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
195 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
196 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
197 virtual void ApplyTuple(StatelessDatabaseOperations::ReadOnlyTransaction& transaction, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
198 const Tuple& tuple) = 0; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
199 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
200 void Apply(StatelessDatabaseOperations& index, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
201 T1 t1, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
202 T2 t2, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
203 T3 t3, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
204 T4 t4, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
205 T5 t5) |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
206 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
207 const Tuple tuple(t1, t2, t3, t4, t5); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
208 TupleOperationsWrapper<ReadOnlyOperationsT5, Tuple> wrapper(*this, tuple); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
209 index.Apply(wrapper); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
210 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
211 }; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
212 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
213 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
214 template <typename T1, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
215 typename T2, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
216 typename T3, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
217 typename T4, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
218 typename T5, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
219 typename T6> |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
220 class ReadOnlyOperationsT6 : public boost::noncopyable |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
221 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
222 public: |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
223 typedef typename boost::tuple<T1, T2, T3, T4, T5, T6> Tuple; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
224 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
225 virtual ~ReadOnlyOperationsT6() |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
226 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
227 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
228 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
229 virtual void ApplyTuple(StatelessDatabaseOperations::ReadOnlyTransaction& transaction, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
230 const Tuple& tuple) = 0; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
231 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
232 void Apply(StatelessDatabaseOperations& index, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
233 T1 t1, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
234 T2 t2, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
235 T3 t3, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
236 T4 t4, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
237 T5 t5, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
238 T6 t6) |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
239 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
240 const Tuple tuple(t1, t2, t3, t4, t5, t6); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
241 TupleOperationsWrapper<ReadOnlyOperationsT6, Tuple> wrapper(*this, tuple); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
242 index.Apply(wrapper); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
243 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
244 }; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
245 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
246 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
247 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
248 template <typename T> |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
249 static void FormatLog(Json::Value& target, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
250 const std::list<T>& log, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
251 const std::string& name, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
252 bool done, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
253 int64_t since, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
254 bool hasLast, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
255 int64_t last) |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
256 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
257 Json::Value items = Json::arrayValue; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
258 for (typename std::list<T>::const_iterator |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
259 it = log.begin(); it != log.end(); ++it) |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
260 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
261 Json::Value item; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
262 it->Format(item); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
263 items.append(item); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
264 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
265 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
266 target = Json::objectValue; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
267 target[name] = items; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
268 target["Done"] = done; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
269 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
270 if (!hasLast) |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
271 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
272 // Best-effort guess of the last index in the sequence |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
273 if (log.empty()) |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
274 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
275 last = since; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
276 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
277 else |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
278 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
279 last = log.back().GetSeq(); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
280 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
281 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
282 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
283 target["Last"] = static_cast<int>(last); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
284 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
285 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
286 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
287 static void CopyListToVector(std::vector<std::string>& target, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
288 const std::list<std::string>& source) |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
289 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
290 target.resize(source.size()); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
291 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
292 size_t pos = 0; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
293 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
294 for (std::list<std::string>::const_iterator |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
295 it = source.begin(); it != source.end(); ++it) |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
296 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
297 target[pos] = *it; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
298 pos ++; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
299 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
300 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
301 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
302 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
303 void StatelessDatabaseOperations::ReadWriteTransaction::LogChange(int64_t internalId, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
304 ChangeType changeType, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
305 ResourceType resourceType, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
306 const std::string& publicId) |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
307 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
308 ServerIndexChange change(changeType, resourceType, publicId); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
309 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
310 if (changeType <= ChangeType_INTERNAL_LastLogged) |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
311 { |
5216
450ac804d3af
simplifying IDatabaseWrapper::LogChange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
312 transaction_.LogChange(changeType, resourceType, internalId, publicId, change.GetDate()); |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
313 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
314 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
315 GetTransactionContext().SignalChange(change); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
316 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
317 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
318 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
319 SeriesStatus StatelessDatabaseOperations::ReadOnlyTransaction::GetSeriesStatus(int64_t id, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
320 int64_t expectedNumberOfInstances) |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
321 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
322 std::list<std::string> values; |
4591
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
323 transaction_.GetChildrenMetadata(values, id, MetadataType_Instance_IndexInSeries); |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
324 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
325 std::set<int64_t> instances; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
326 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
327 for (std::list<std::string>::const_iterator |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
328 it = values.begin(); it != values.end(); ++it) |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
329 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
330 int64_t index; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
331 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
332 try |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
333 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
334 index = boost::lexical_cast<int64_t>(*it); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
335 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
336 catch (boost::bad_lexical_cast&) |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
337 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
338 return SeriesStatus_Unknown; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
339 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
340 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
341 if (!(index > 0 && index <= expectedNumberOfInstances)) |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
342 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
343 // Out-of-range instance index |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
344 return SeriesStatus_Inconsistent; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
345 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
346 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
347 if (instances.find(index) != instances.end()) |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
348 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
349 // Twice the same instance index |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
350 return SeriesStatus_Inconsistent; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
351 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
352 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
353 instances.insert(index); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
354 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
355 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
356 if (static_cast<int64_t>(instances.size()) == expectedNumberOfInstances) |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
357 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
358 return SeriesStatus_Complete; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
359 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
360 else |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
361 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
362 return SeriesStatus_Missing; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
363 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
364 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
365 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
366 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
367 void StatelessDatabaseOperations::NormalizeLookup(std::vector<DatabaseConstraint>& target, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
368 const DatabaseLookup& source, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
369 ResourceType queryLevel) const |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
370 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
371 assert(mainDicomTagsRegistry_.get() != NULL); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
372 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
373 target.clear(); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
374 target.reserve(source.GetConstraintsCount()); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
375 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
376 for (size_t i = 0; i < source.GetConstraintsCount(); i++) |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
377 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
378 ResourceType level; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
379 DicomTagType type; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
380 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
381 mainDicomTagsRegistry_->LookupTag(level, type, source.GetConstraint(i).GetTag()); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
382 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
383 if (type == DicomTagType_Identifier || |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
384 type == DicomTagType_Main) |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
385 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
386 // Use the fact that patient-level tags are copied at the study level |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
387 if (level == ResourceType_Patient && |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
388 queryLevel != ResourceType_Patient) |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
389 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
390 level = ResourceType_Study; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
391 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
392 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
393 target.push_back(source.GetConstraint(i).ConvertToDatabaseConstraint(level, type)); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
394 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
395 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
396 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
397 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
398 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
399 class StatelessDatabaseOperations::Transaction : public boost::noncopyable |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
400 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
401 private: |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
402 IDatabaseWrapper& db_; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
403 std::unique_ptr<IDatabaseWrapper::ITransaction> transaction_; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
404 std::unique_ptr<ITransactionContext> context_; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
405 bool isCommitted_; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
406 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
407 public: |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
408 Transaction(IDatabaseWrapper& db, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
409 ITransactionContextFactory& factory, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
410 TransactionType type) : |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
411 db_(db), |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
412 isCommitted_(false) |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
413 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
414 context_.reset(factory.Create()); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
415 if (context_.get() == NULL) |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
416 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
417 throw OrthancException(ErrorCode_NullPointer); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
418 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
419 |
4589
bec74e29f86b
attaching the listener to transactions in IDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4587
diff
changeset
|
420 transaction_.reset(db_.StartTransaction(type, *context_)); |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
421 if (transaction_.get() == NULL) |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
422 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
423 throw OrthancException(ErrorCode_NullPointer); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
424 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
425 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
426 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
427 ~Transaction() |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
428 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
429 if (!isCommitted_) |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
430 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
431 try |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
432 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
433 transaction_->Rollback(); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
434 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
435 catch (OrthancException& e) |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
436 { |
4612
4982733a4e39
fix database retries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4609
diff
changeset
|
437 LOG(INFO) << "Cannot rollback transaction: " << e.What(); |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
438 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
439 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
440 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
441 |
4591
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
442 IDatabaseWrapper::ITransaction& GetDatabaseTransaction() |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
443 { |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
444 assert(transaction_.get() != NULL); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
445 return *transaction_; |
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 |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
448 void Commit() |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
449 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
450 if (isCommitted_) |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
451 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
452 throw OrthancException(ErrorCode_BadSequenceOfCalls); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
453 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
454 else |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
455 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
456 int64_t delta = context_->GetCompressedSizeDelta(); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
457 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
458 transaction_->Commit(delta); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
459 context_->Commit(); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
460 isCommitted_ = true; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
461 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
462 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
463 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
464 ITransactionContext& GetContext() const |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
465 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
466 assert(context_.get() != NULL); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
467 return *context_; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
468 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
469 }; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
470 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
471 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
472 void StatelessDatabaseOperations::ApplyInternal(IReadOnlyOperations* readOperations, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
473 IReadWriteOperations* writeOperations) |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
474 { |
4613
2684544ff03c
maximum number of database retries for writer collisions is now set by the plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4612
diff
changeset
|
475 boost::shared_lock<boost::shared_mutex> lock(mutex_); // To protect "factory_" and "maxRetries_" |
2684544ff03c
maximum number of database retries for writer collisions is now set by the plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4612
diff
changeset
|
476 |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
477 if ((readOperations == NULL && writeOperations == NULL) || |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
478 (readOperations != NULL && writeOperations != NULL)) |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
479 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
480 throw OrthancException(ErrorCode_InternalError); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
481 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
482 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
483 if (factory_.get() == NULL) |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
484 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
485 throw OrthancException(ErrorCode_BadSequenceOfCalls, "No transaction context was provided"); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
486 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
487 |
4613
2684544ff03c
maximum number of database retries for writer collisions is now set by the plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4612
diff
changeset
|
488 unsigned int attempt = 0; |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
489 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
490 for (;;) |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
491 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
492 try |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
493 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
494 if (readOperations != NULL) |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
495 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
496 /** |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
497 * IMPORTANT: In Orthanc <= 1.9.1, there was no transaction |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
498 * in this case. This was OK because of the presence of the |
4594
d494b4f1103e
removed the global database mutex from ServerIndex and StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4591
diff
changeset
|
499 * global mutex that was protecting the database. |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
500 **/ |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
501 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
502 Transaction transaction(db_, *factory_, TransactionType_ReadOnly); // TODO - Only if not "TransactionType_Implicit" |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
503 { |
5522
dd430a1b21fe
simplifying StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5497
diff
changeset
|
504 ReadOnlyTransaction t(transaction.GetDatabaseTransaction(), transaction.GetContext()); |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
505 readOperations->Apply(t); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
506 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
507 transaction.Commit(); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
508 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
509 else |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
510 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
511 assert(writeOperations != NULL); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
512 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
513 Transaction transaction(db_, *factory_, TransactionType_ReadWrite); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
514 { |
5522
dd430a1b21fe
simplifying StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5497
diff
changeset
|
515 ReadWriteTransaction t(transaction.GetDatabaseTransaction(), transaction.GetContext()); |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
516 writeOperations->Apply(t); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
517 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
518 transaction.Commit(); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
519 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
520 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
521 return; // Success |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
522 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
523 catch (OrthancException& e) |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
524 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
525 if (e.GetErrorCode() == ErrorCode_DatabaseCannotSerialize) |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
526 { |
4613
2684544ff03c
maximum number of database retries for writer collisions is now set by the plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4612
diff
changeset
|
527 if (attempt >= maxRetries_) |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
528 { |
5492
26877f4b306f
now only logging 'Maximum transactions retries reached' as an error
Alain Mazy <am@osimis.io>
parents:
5466
diff
changeset
|
529 LOG(ERROR) << "Maximum transactions retries reached " << e.GetDetails(); |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
530 throw; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
531 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
532 else |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
533 { |
4613
2684544ff03c
maximum number of database retries for writer collisions is now set by the plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4612
diff
changeset
|
534 attempt++; |
2684544ff03c
maximum number of database retries for writer collisions is now set by the plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4612
diff
changeset
|
535 |
2684544ff03c
maximum number of database retries for writer collisions is now set by the plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4612
diff
changeset
|
536 // The "rand()" adds some jitter to de-synchronize writers |
4619
fda80844b920
separate db retries by 100ms instead of 50ms to simplify documentation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4613
diff
changeset
|
537 boost::this_thread::sleep(boost::posix_time::milliseconds(100 * attempt + 5 * (rand() % 10))); |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
538 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
539 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
540 else |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
541 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
542 throw; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
543 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
544 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
545 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
546 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
547 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
548 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
549 StatelessDatabaseOperations::StatelessDatabaseOperations(IDatabaseWrapper& db) : |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
550 db_(db), |
4587
888868a5dc4e
ServerIndex now uses StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4586
diff
changeset
|
551 mainDicomTagsRegistry_(new MainDicomTagsRegistry), |
4613
2684544ff03c
maximum number of database retries for writer collisions is now set by the plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4612
diff
changeset
|
552 maxRetries_(0) |
4587
888868a5dc4e
ServerIndex now uses StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4586
diff
changeset
|
553 { |
888868a5dc4e
ServerIndex now uses StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4586
diff
changeset
|
554 } |
888868a5dc4e
ServerIndex now uses StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4586
diff
changeset
|
555 |
888868a5dc4e
ServerIndex now uses StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4586
diff
changeset
|
556 |
888868a5dc4e
ServerIndex now uses StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4586
diff
changeset
|
557 void StatelessDatabaseOperations::FlushToDisk() |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
558 { |
4587
888868a5dc4e
ServerIndex now uses StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4586
diff
changeset
|
559 try |
888868a5dc4e
ServerIndex now uses StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4586
diff
changeset
|
560 { |
888868a5dc4e
ServerIndex now uses StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4586
diff
changeset
|
561 db_.FlushToDisk(); |
888868a5dc4e
ServerIndex now uses StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4586
diff
changeset
|
562 } |
888868a5dc4e
ServerIndex now uses StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4586
diff
changeset
|
563 catch (OrthancException&) |
888868a5dc4e
ServerIndex now uses StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4586
diff
changeset
|
564 { |
888868a5dc4e
ServerIndex now uses StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4586
diff
changeset
|
565 LOG(ERROR) << "Cannot flush the SQLite database to the disk (is your filesystem full?)"; |
888868a5dc4e
ServerIndex now uses StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4586
diff
changeset
|
566 } |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
567 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
568 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
569 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
570 void StatelessDatabaseOperations::SetTransactionContextFactory(ITransactionContextFactory* factory) |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
571 { |
4613
2684544ff03c
maximum number of database retries for writer collisions is now set by the plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4612
diff
changeset
|
572 boost::unique_lock<boost::shared_mutex> lock(mutex_); |
2684544ff03c
maximum number of database retries for writer collisions is now set by the plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4612
diff
changeset
|
573 |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
574 if (factory == NULL) |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
575 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
576 throw OrthancException(ErrorCode_NullPointer); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
577 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
578 else if (factory_.get() != NULL) |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
579 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
580 throw OrthancException(ErrorCode_BadSequenceOfCalls); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
581 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
582 else |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
583 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
584 factory_.reset(factory); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
585 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
586 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
587 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
588 |
4613
2684544ff03c
maximum number of database retries for writer collisions is now set by the plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4612
diff
changeset
|
589 void StatelessDatabaseOperations::SetMaxDatabaseRetries(unsigned int maxRetries) |
2684544ff03c
maximum number of database retries for writer collisions is now set by the plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4612
diff
changeset
|
590 { |
2684544ff03c
maximum number of database retries for writer collisions is now set by the plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4612
diff
changeset
|
591 boost::unique_lock<boost::shared_mutex> lock(mutex_); |
2684544ff03c
maximum number of database retries for writer collisions is now set by the plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4612
diff
changeset
|
592 maxRetries_ = maxRetries; |
2684544ff03c
maximum number of database retries for writer collisions is now set by the plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4612
diff
changeset
|
593 } |
2684544ff03c
maximum number of database retries for writer collisions is now set by the plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4612
diff
changeset
|
594 |
2684544ff03c
maximum number of database retries for writer collisions is now set by the plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4612
diff
changeset
|
595 |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
596 void StatelessDatabaseOperations::Apply(IReadOnlyOperations& operations) |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
597 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
598 ApplyInternal(&operations, NULL); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
599 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
600 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
601 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
602 void StatelessDatabaseOperations::Apply(IReadWriteOperations& operations) |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
603 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
604 ApplyInternal(NULL, &operations); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
605 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
606 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
607 |
4935
acd3f72e2a21
split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents:
4934
diff
changeset
|
608 bool StatelessDatabaseOperations::ExpandResource(ExpandedResource& target, |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
609 const std::string& publicId, |
4697
569d9ef165b1
Added "short", "simplify" and/or "full" options to control the format of DICOM tags wherever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4694
diff
changeset
|
610 ResourceType level, |
4940
304514ce84ee
tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents:
4939
diff
changeset
|
611 const std::set<DicomTag>& requestedTags, |
5222
3a61fd50f804
starting refactoring ExpandedResource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5221
diff
changeset
|
612 ExpandResourceFlags expandFlags) |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
613 { |
4940
304514ce84ee
tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents:
4939
diff
changeset
|
614 class Operations : public ReadOnlyOperationsT6< |
5222
3a61fd50f804
starting refactoring ExpandedResource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5221
diff
changeset
|
615 bool&, ExpandedResource&, const std::string&, ResourceType, const std::set<DicomTag>&, ExpandResourceFlags> |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
616 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
617 private: |
5522
dd430a1b21fe
simplifying StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5497
diff
changeset
|
618 bool hasLabelsSupport_; |
dd430a1b21fe
simplifying StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5497
diff
changeset
|
619 |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
620 static bool LookupStringMetadata(std::string& result, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
621 const std::map<MetadataType, std::string>& metadata, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
622 MetadataType type) |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
623 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
624 std::map<MetadataType, std::string>::const_iterator found = metadata.find(type); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
625 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
626 if (found == metadata.end()) |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
627 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
628 return false; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
629 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
630 else |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
631 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
632 result = found->second; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
633 return true; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
634 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
635 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
636 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
637 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
638 static bool LookupIntegerMetadata(int64_t& result, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
639 const std::map<MetadataType, std::string>& metadata, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
640 MetadataType type) |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
641 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
642 std::string s; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
643 if (!LookupStringMetadata(s, metadata, type)) |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
644 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
645 return false; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
646 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
647 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
648 try |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
649 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
650 result = boost::lexical_cast<int64_t>(s); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
651 return true; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
652 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
653 catch (boost::bad_lexical_cast&) |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
654 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
655 return false; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
656 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
657 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
658 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
659 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
660 public: |
5526 | 661 explicit Operations(bool hasLabelsSupport) : |
5522
dd430a1b21fe
simplifying StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5497
diff
changeset
|
662 hasLabelsSupport_(hasLabelsSupport) |
dd430a1b21fe
simplifying StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5497
diff
changeset
|
663 { |
dd430a1b21fe
simplifying StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5497
diff
changeset
|
664 } |
dd430a1b21fe
simplifying StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5497
diff
changeset
|
665 |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
666 virtual void ApplyTuple(ReadOnlyTransaction& transaction, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
667 const Tuple& tuple) ORTHANC_OVERRIDE |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
668 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
669 // Lookup for the requested resource |
4936
8422e4f99a18
Handling RequestedTags in ExpandResource -> read parent main dicom tags if required. Not yet getting missing tags from file. Integration tests ok
Alain Mazy <am@osimis.io>
parents:
4935
diff
changeset
|
670 int64_t internalId; |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
671 ResourceType type; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
672 std::string parent; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
673 if (!transaction.LookupResourceAndParent(internalId, type, parent, tuple.get<2>()) || |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
674 type != tuple.get<3>()) |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
675 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
676 tuple.get<0>() = false; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
677 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
678 else |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
679 { |
4935
acd3f72e2a21
split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents:
4934
diff
changeset
|
680 ExpandedResource& target = tuple.get<1>(); |
5222
3a61fd50f804
starting refactoring ExpandedResource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5221
diff
changeset
|
681 ExpandResourceFlags expandFlags = tuple.get<5>(); |
4935
acd3f72e2a21
split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents:
4934
diff
changeset
|
682 |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
683 // Set information about the parent resource (if it exists) |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
684 if (type == ResourceType_Patient) |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
685 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
686 if (!parent.empty()) |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
687 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
688 throw OrthancException(ErrorCode_DatabasePlugin); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
689 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
690 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
691 else |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
692 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
693 if (parent.empty()) |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
694 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
695 throw OrthancException(ErrorCode_DatabasePlugin); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
696 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
697 |
4935
acd3f72e2a21
split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents:
4934
diff
changeset
|
698 target.parentId_ = parent; |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
699 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
700 |
5222
3a61fd50f804
starting refactoring ExpandedResource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5221
diff
changeset
|
701 target.SetResource(type, tuple.get<2>()); |
3a61fd50f804
starting refactoring ExpandedResource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5221
diff
changeset
|
702 |
3a61fd50f804
starting refactoring ExpandedResource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5221
diff
changeset
|
703 if (expandFlags & ExpandResourceFlags_IncludeChildren) |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
704 { |
4940
304514ce84ee
tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents:
4939
diff
changeset
|
705 // List the children resources |
304514ce84ee
tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents:
4939
diff
changeset
|
706 transaction.GetChildrenPublicId(target.childrenIds_, internalId); |
304514ce84ee
tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents:
4939
diff
changeset
|
707 } |
304514ce84ee
tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents:
4939
diff
changeset
|
708 |
5222
3a61fd50f804
starting refactoring ExpandedResource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5221
diff
changeset
|
709 if (expandFlags & ExpandResourceFlags_IncludeMetadata) |
4940
304514ce84ee
tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents:
4939
diff
changeset
|
710 { |
304514ce84ee
tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents:
4939
diff
changeset
|
711 // Extract the metadata |
304514ce84ee
tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents:
4939
diff
changeset
|
712 transaction.GetAllMetadata(target.metadata_, internalId); |
304514ce84ee
tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents:
4939
diff
changeset
|
713 |
304514ce84ee
tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents:
4939
diff
changeset
|
714 switch (type) |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
715 { |
4940
304514ce84ee
tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents:
4939
diff
changeset
|
716 case ResourceType_Patient: |
304514ce84ee
tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents:
4939
diff
changeset
|
717 case ResourceType_Study: |
304514ce84ee
tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents:
4939
diff
changeset
|
718 break; |
304514ce84ee
tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents:
4939
diff
changeset
|
719 |
304514ce84ee
tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents:
4939
diff
changeset
|
720 case ResourceType_Series: |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
721 { |
4940
304514ce84ee
tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents:
4939
diff
changeset
|
722 int64_t i; |
304514ce84ee
tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents:
4939
diff
changeset
|
723 if (LookupIntegerMetadata(i, target.metadata_, MetadataType_Series_ExpectedNumberOfInstances)) |
304514ce84ee
tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents:
4939
diff
changeset
|
724 { |
304514ce84ee
tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents:
4939
diff
changeset
|
725 target.expectedNumberOfInstances_ = static_cast<int>(i); |
304514ce84ee
tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents:
4939
diff
changeset
|
726 target.status_ = EnumerationToString(transaction.GetSeriesStatus(internalId, i)); |
304514ce84ee
tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents:
4939
diff
changeset
|
727 } |
304514ce84ee
tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents:
4939
diff
changeset
|
728 else |
304514ce84ee
tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents:
4939
diff
changeset
|
729 { |
304514ce84ee
tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents:
4939
diff
changeset
|
730 target.expectedNumberOfInstances_ = -1; |
304514ce84ee
tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents:
4939
diff
changeset
|
731 target.status_ = EnumerationToString(SeriesStatus_Unknown); |
304514ce84ee
tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents:
4939
diff
changeset
|
732 } |
304514ce84ee
tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents:
4939
diff
changeset
|
733 |
304514ce84ee
tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents:
4939
diff
changeset
|
734 break; |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
735 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
736 |
4940
304514ce84ee
tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents:
4939
diff
changeset
|
737 case ResourceType_Instance: |
4936
8422e4f99a18
Handling RequestedTags in ExpandResource -> read parent main dicom tags if required. Not yet getting missing tags from file. Integration tests ok
Alain Mazy <am@osimis.io>
parents:
4935
diff
changeset
|
738 { |
4940
304514ce84ee
tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents:
4939
diff
changeset
|
739 FileInfo attachment; |
304514ce84ee
tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents:
4939
diff
changeset
|
740 int64_t revision; // ignored |
304514ce84ee
tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents:
4939
diff
changeset
|
741 if (!transaction.LookupAttachment(attachment, revision, internalId, FileContentType_Dicom)) |
304514ce84ee
tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents:
4939
diff
changeset
|
742 { |
304514ce84ee
tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents:
4939
diff
changeset
|
743 throw OrthancException(ErrorCode_InternalError); |
304514ce84ee
tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents:
4939
diff
changeset
|
744 } |
304514ce84ee
tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents:
4939
diff
changeset
|
745 |
304514ce84ee
tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents:
4939
diff
changeset
|
746 target.fileSize_ = static_cast<unsigned int>(attachment.GetUncompressedSize()); |
304514ce84ee
tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents:
4939
diff
changeset
|
747 target.fileUuid_ = attachment.GetUuid(); |
304514ce84ee
tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents:
4939
diff
changeset
|
748 |
304514ce84ee
tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents:
4939
diff
changeset
|
749 int64_t i; |
304514ce84ee
tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents:
4939
diff
changeset
|
750 if (LookupIntegerMetadata(i, target.metadata_, MetadataType_Instance_IndexInSeries)) |
304514ce84ee
tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents:
4939
diff
changeset
|
751 { |
304514ce84ee
tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents:
4939
diff
changeset
|
752 target.indexInSeries_ = static_cast<int>(i); |
304514ce84ee
tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents:
4939
diff
changeset
|
753 } |
304514ce84ee
tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents:
4939
diff
changeset
|
754 else |
304514ce84ee
tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents:
4939
diff
changeset
|
755 { |
304514ce84ee
tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents:
4939
diff
changeset
|
756 target.indexInSeries_ = -1; |
304514ce84ee
tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents:
4939
diff
changeset
|
757 } |
304514ce84ee
tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents:
4939
diff
changeset
|
758 |
4936
8422e4f99a18
Handling RequestedTags in ExpandResource -> read parent main dicom tags if required. Not yet getting missing tags from file. Integration tests ok
Alain Mazy <am@osimis.io>
parents:
4935
diff
changeset
|
759 break; |
8422e4f99a18
Handling RequestedTags in ExpandResource -> read parent main dicom tags if required. Not yet getting missing tags from file. Integration tests ok
Alain Mazy <am@osimis.io>
parents:
4935
diff
changeset
|
760 } |
8422e4f99a18
Handling RequestedTags in ExpandResource -> read parent main dicom tags if required. Not yet getting missing tags from file. Integration tests ok
Alain Mazy <am@osimis.io>
parents:
4935
diff
changeset
|
761 |
4940
304514ce84ee
tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents:
4939
diff
changeset
|
762 default: |
304514ce84ee
tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents:
4939
diff
changeset
|
763 throw OrthancException(ErrorCode_InternalError); |
4936
8422e4f99a18
Handling RequestedTags in ExpandResource -> read parent main dicom tags if required. Not yet getting missing tags from file. Integration tests ok
Alain Mazy <am@osimis.io>
parents:
4935
diff
changeset
|
764 } |
4938
f630796a59b1
ExpandResource now able to return computed tags (like ModalitiesInStudies)
Alain Mazy <am@osimis.io>
parents:
4936
diff
changeset
|
765 |
4940
304514ce84ee
tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents:
4939
diff
changeset
|
766 // check the main dicom tags list has not changed since the resource was stored |
304514ce84ee
tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents:
4939
diff
changeset
|
767 target.mainDicomTagsSignature_ = DicomMap::GetDefaultMainDicomTagsSignature(type); |
304514ce84ee
tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents:
4939
diff
changeset
|
768 LookupStringMetadata(target.mainDicomTagsSignature_, target.metadata_, MetadataType_MainDicomTagsSignature); |
304514ce84ee
tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents:
4939
diff
changeset
|
769 } |
304514ce84ee
tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents:
4939
diff
changeset
|
770 |
5222
3a61fd50f804
starting refactoring ExpandedResource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5221
diff
changeset
|
771 if (expandFlags & ExpandResourceFlags_IncludeMainDicomTags) |
4940
304514ce84ee
tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents:
4939
diff
changeset
|
772 { |
304514ce84ee
tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents:
4939
diff
changeset
|
773 // read all tags from DB |
5222
3a61fd50f804
starting refactoring ExpandedResource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5221
diff
changeset
|
774 transaction.GetMainDicomTags(target.GetMainDicomTags(), internalId); |
4940
304514ce84ee
tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents:
4939
diff
changeset
|
775 |
5036
877bc3b96476
Handle Dicom sequences in ExtraMainDicomTags and save them in the 'MainDicomSequences' metadata
Alain Mazy <am@osimis.io>
parents:
4988
diff
changeset
|
776 // read all main sequences from DB |
877bc3b96476
Handle Dicom sequences in ExtraMainDicomTags and save them in the 'MainDicomSequences' metadata
Alain Mazy <am@osimis.io>
parents:
4988
diff
changeset
|
777 std::string serializedSequences; |
877bc3b96476
Handle Dicom sequences in ExtraMainDicomTags and save them in the 'MainDicomSequences' metadata
Alain Mazy <am@osimis.io>
parents:
4988
diff
changeset
|
778 if (LookupStringMetadata(serializedSequences, target.metadata_, MetadataType_MainDicomSequences)) |
877bc3b96476
Handle Dicom sequences in ExtraMainDicomTags and save them in the 'MainDicomSequences' metadata
Alain Mazy <am@osimis.io>
parents:
4988
diff
changeset
|
779 { |
877bc3b96476
Handle Dicom sequences in ExtraMainDicomTags and save them in the 'MainDicomSequences' metadata
Alain Mazy <am@osimis.io>
parents:
4988
diff
changeset
|
780 Json::Value jsonMetadata; |
877bc3b96476
Handle Dicom sequences in ExtraMainDicomTags and save them in the 'MainDicomSequences' metadata
Alain Mazy <am@osimis.io>
parents:
4988
diff
changeset
|
781 Toolbox::ReadJson(jsonMetadata, serializedSequences); |
877bc3b96476
Handle Dicom sequences in ExtraMainDicomTags and save them in the 'MainDicomSequences' metadata
Alain Mazy <am@osimis.io>
parents:
4988
diff
changeset
|
782 |
877bc3b96476
Handle Dicom sequences in ExtraMainDicomTags and save them in the 'MainDicomSequences' metadata
Alain Mazy <am@osimis.io>
parents:
4988
diff
changeset
|
783 assert(jsonMetadata["Version"].asInt() == 1); |
5222
3a61fd50f804
starting refactoring ExpandedResource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5221
diff
changeset
|
784 target.GetMainDicomTags().FromDicomAsJson(jsonMetadata["Sequences"], true /* append */, true /* parseSequences */); |
5036
877bc3b96476
Handle Dicom sequences in ExtraMainDicomTags and save them in the 'MainDicomSequences' metadata
Alain Mazy <am@osimis.io>
parents:
4988
diff
changeset
|
785 } |
877bc3b96476
Handle Dicom sequences in ExtraMainDicomTags and save them in the 'MainDicomSequences' metadata
Alain Mazy <am@osimis.io>
parents:
4988
diff
changeset
|
786 |
4940
304514ce84ee
tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents:
4939
diff
changeset
|
787 // check if we have access to all requestedTags or if we must get tags from parents |
304514ce84ee
tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents:
4939
diff
changeset
|
788 const std::set<DicomTag>& requestedTags = tuple.get<4>(); |
304514ce84ee
tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents:
4939
diff
changeset
|
789 |
304514ce84ee
tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents:
4939
diff
changeset
|
790 if (requestedTags.size() > 0) |
304514ce84ee
tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents:
4939
diff
changeset
|
791 { |
304514ce84ee
tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents:
4939
diff
changeset
|
792 std::set<DicomTag> savedMainDicomTags; |
304514ce84ee
tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents:
4939
diff
changeset
|
793 |
304514ce84ee
tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents:
4939
diff
changeset
|
794 FromDcmtkBridge::ParseListOfTags(savedMainDicomTags, target.mainDicomTagsSignature_); |
304514ce84ee
tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents:
4939
diff
changeset
|
795 |
5036
877bc3b96476
Handle Dicom sequences in ExtraMainDicomTags and save them in the 'MainDicomSequences' metadata
Alain Mazy <am@osimis.io>
parents:
4988
diff
changeset
|
796 // read parent main dicom tags as long as we have not gathered all requested tags |
5222
3a61fd50f804
starting refactoring ExpandedResource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5221
diff
changeset
|
797 ResourceType currentLevel = target.GetLevel(); |
4940
304514ce84ee
tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents:
4939
diff
changeset
|
798 int64_t currentInternalId = internalId; |
304514ce84ee
tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents:
4939
diff
changeset
|
799 Toolbox::GetMissingsFromSet(target.missingRequestedTags_, requestedTags, savedMainDicomTags); |
304514ce84ee
tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents:
4939
diff
changeset
|
800 |
304514ce84ee
tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents:
4939
diff
changeset
|
801 while ((target.missingRequestedTags_.size() > 0) |
5595
a87f2a56257d
implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5593
diff
changeset
|
802 && currentLevel != ResourceType_Patient) |
4938
f630796a59b1
ExpandResource now able to return computed tags (like ModalitiesInStudies)
Alain Mazy <am@osimis.io>
parents:
4936
diff
changeset
|
803 { |
4940
304514ce84ee
tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents:
4939
diff
changeset
|
804 currentLevel = GetParentResourceType(currentLevel); |
304514ce84ee
tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents:
4939
diff
changeset
|
805 |
304514ce84ee
tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents:
4939
diff
changeset
|
806 int64_t currentParentId; |
304514ce84ee
tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents:
4939
diff
changeset
|
807 if (!transaction.LookupParent(currentParentId, currentInternalId)) |
304514ce84ee
tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents:
4939
diff
changeset
|
808 { |
304514ce84ee
tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents:
4939
diff
changeset
|
809 break; |
304514ce84ee
tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents:
4939
diff
changeset
|
810 } |
304514ce84ee
tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents:
4939
diff
changeset
|
811 |
304514ce84ee
tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents:
4939
diff
changeset
|
812 std::map<MetadataType, std::string> parentMetadata; |
304514ce84ee
tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents:
4939
diff
changeset
|
813 transaction.GetAllMetadata(parentMetadata, currentParentId); |
304514ce84ee
tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents:
4939
diff
changeset
|
814 |
304514ce84ee
tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents:
4939
diff
changeset
|
815 std::string parentMainDicomTagsSignature = DicomMap::GetDefaultMainDicomTagsSignature(currentLevel); |
304514ce84ee
tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents:
4939
diff
changeset
|
816 LookupStringMetadata(parentMainDicomTagsSignature, parentMetadata, MetadataType_MainDicomTagsSignature); |
304514ce84ee
tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents:
4939
diff
changeset
|
817 |
304514ce84ee
tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents:
4939
diff
changeset
|
818 std::set<DicomTag> parentSavedMainDicomTags; |
304514ce84ee
tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents:
4939
diff
changeset
|
819 FromDcmtkBridge::ParseListOfTags(parentSavedMainDicomTags, parentMainDicomTagsSignature); |
304514ce84ee
tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents:
4939
diff
changeset
|
820 |
304514ce84ee
tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents:
4939
diff
changeset
|
821 size_t previousMissingCount = target.missingRequestedTags_.size(); |
304514ce84ee
tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents:
4939
diff
changeset
|
822 Toolbox::AppendSets(savedMainDicomTags, parentSavedMainDicomTags); |
304514ce84ee
tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents:
4939
diff
changeset
|
823 Toolbox::GetMissingsFromSet(target.missingRequestedTags_, requestedTags, savedMainDicomTags); |
304514ce84ee
tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents:
4939
diff
changeset
|
824 |
304514ce84ee
tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents:
4939
diff
changeset
|
825 // read the parent tags from DB only if it reduces the number of missing tags |
304514ce84ee
tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents:
4939
diff
changeset
|
826 if (target.missingRequestedTags_.size() < previousMissingCount) |
304514ce84ee
tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents:
4939
diff
changeset
|
827 { |
304514ce84ee
tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents:
4939
diff
changeset
|
828 Toolbox::AppendSets(savedMainDicomTags, parentSavedMainDicomTags); |
304514ce84ee
tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents:
4939
diff
changeset
|
829 |
304514ce84ee
tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents:
4939
diff
changeset
|
830 DicomMap parentTags; |
304514ce84ee
tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents:
4939
diff
changeset
|
831 transaction.GetMainDicomTags(parentTags, currentParentId); |
304514ce84ee
tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents:
4939
diff
changeset
|
832 |
5222
3a61fd50f804
starting refactoring ExpandedResource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5221
diff
changeset
|
833 target.GetMainDicomTags().Merge(parentTags); |
4940
304514ce84ee
tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents:
4939
diff
changeset
|
834 } |
304514ce84ee
tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents:
4939
diff
changeset
|
835 |
304514ce84ee
tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents:
4939
diff
changeset
|
836 currentInternalId = currentParentId; |
4938
f630796a59b1
ExpandResource now able to return computed tags (like ModalitiesInStudies)
Alain Mazy <am@osimis.io>
parents:
4936
diff
changeset
|
837 } |
4940
304514ce84ee
tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents:
4939
diff
changeset
|
838 } |
4936
8422e4f99a18
Handling RequestedTags in ExpandResource -> read parent main dicom tags if required. Not yet getting missing tags from file. Integration tests ok
Alain Mazy <am@osimis.io>
parents:
4935
diff
changeset
|
839 } |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
840 |
5237
cd2258ca7894
log about missing support for labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5234
diff
changeset
|
841 if ((expandFlags & ExpandResourceFlags_IncludeLabels) && |
5522
dd430a1b21fe
simplifying StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5497
diff
changeset
|
842 hasLabelsSupport_) |
5221
d0f7c742d397
started implementation of labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5220
diff
changeset
|
843 { |
d0f7c742d397
started implementation of labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5220
diff
changeset
|
844 transaction.ListLabels(target.labels_, internalId); |
d0f7c742d397
started implementation of labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5220
diff
changeset
|
845 } |
d0f7c742d397
started implementation of labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5220
diff
changeset
|
846 |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
847 std::string tmp; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
848 |
4935
acd3f72e2a21
split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents:
4934
diff
changeset
|
849 if (LookupStringMetadata(tmp, target.metadata_, MetadataType_AnonymizedFrom)) |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
850 { |
4935
acd3f72e2a21
split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents:
4934
diff
changeset
|
851 target.anonymizedFrom_ = tmp; |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
852 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
853 |
4935
acd3f72e2a21
split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents:
4934
diff
changeset
|
854 if (LookupStringMetadata(tmp, target.metadata_, MetadataType_ModifiedFrom)) |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
855 { |
4935
acd3f72e2a21
split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents:
4934
diff
changeset
|
856 target.modifiedFrom_ = tmp; |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
857 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
858 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
859 if (type == ResourceType_Patient || |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
860 type == ResourceType_Study || |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
861 type == ResourceType_Series) |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
862 { |
5603
b2a97dfd719f
monitoring of stable resources now also considers the resource type
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5558
diff
changeset
|
863 target.isStable_ = !transaction.GetTransactionContext().IsUnstableResource(type, internalId); |
4935
acd3f72e2a21
split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents:
4934
diff
changeset
|
864 |
acd3f72e2a21
split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents:
4934
diff
changeset
|
865 if (LookupStringMetadata(tmp, target.metadata_, MetadataType_LastUpdate)) |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
866 { |
4935
acd3f72e2a21
split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents:
4934
diff
changeset
|
867 target.lastUpdate_ = tmp; |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
868 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
869 } |
4935
acd3f72e2a21
split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents:
4934
diff
changeset
|
870 else |
acd3f72e2a21
split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents:
4934
diff
changeset
|
871 { |
acd3f72e2a21
split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents:
4934
diff
changeset
|
872 target.isStable_ = false; |
acd3f72e2a21
split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents:
4934
diff
changeset
|
873 } |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
874 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
875 tuple.get<0>() = true; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
876 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
877 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
878 }; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
879 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
880 bool found; |
5522
dd430a1b21fe
simplifying StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5497
diff
changeset
|
881 Operations operations(db_.GetDatabaseCapabilities().HasLabelsSupport()); |
4940
304514ce84ee
tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents:
4939
diff
changeset
|
882 operations.Apply(*this, found, target, publicId, level, requestedTags, expandFlags); |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
883 return found; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
884 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
885 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
886 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
887 void StatelessDatabaseOperations::GetAllMetadata(std::map<MetadataType, std::string>& target, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
888 const std::string& publicId, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
889 ResourceType level) |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
890 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
891 class Operations : public ReadOnlyOperationsT3<std::map<MetadataType, std::string>&, const std::string&, ResourceType> |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
892 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
893 public: |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
894 virtual void ApplyTuple(ReadOnlyTransaction& transaction, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
895 const Tuple& tuple) ORTHANC_OVERRIDE |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
896 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
897 ResourceType type; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
898 int64_t id; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
899 if (!transaction.LookupResource(id, type, tuple.get<1>()) || |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
900 tuple.get<2>() != type) |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
901 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
902 throw OrthancException(ErrorCode_UnknownResource); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
903 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
904 else |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
905 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
906 transaction.GetAllMetadata(tuple.get<0>(), id); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
907 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
908 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
909 }; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
910 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
911 Operations operations; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
912 operations.Apply(*this, target, publicId, level); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
913 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
914 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
915 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
916 bool StatelessDatabaseOperations::LookupAttachment(FileInfo& attachment, |
4627
f7d5372b59b3
handling revisions of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4623
diff
changeset
|
917 int64_t& revision, |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
918 const std::string& instancePublicId, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
919 FileContentType contentType) |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
920 { |
4627
f7d5372b59b3
handling revisions of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4623
diff
changeset
|
921 class Operations : public ReadOnlyOperationsT5<bool&, FileInfo&, int64_t&, const std::string&, FileContentType> |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
922 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
923 public: |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
924 virtual void ApplyTuple(ReadOnlyTransaction& transaction, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
925 const Tuple& tuple) ORTHANC_OVERRIDE |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
926 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
927 int64_t internalId; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
928 ResourceType type; |
4627
f7d5372b59b3
handling revisions of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4623
diff
changeset
|
929 if (!transaction.LookupResource(internalId, type, tuple.get<3>())) |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
930 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
931 throw OrthancException(ErrorCode_UnknownResource); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
932 } |
4627
f7d5372b59b3
handling revisions of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4623
diff
changeset
|
933 else if (transaction.LookupAttachment(tuple.get<1>(), tuple.get<2>(), internalId, tuple.get<4>())) |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
934 { |
4627
f7d5372b59b3
handling revisions of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4623
diff
changeset
|
935 assert(tuple.get<1>().GetContentType() == tuple.get<4>()); |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
936 tuple.get<0>() = true; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
937 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
938 else |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
939 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
940 tuple.get<0>() = false; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
941 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
942 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
943 }; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
944 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
945 bool found; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
946 Operations operations; |
4627
f7d5372b59b3
handling revisions of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4623
diff
changeset
|
947 operations.Apply(*this, found, attachment, revision, instancePublicId, contentType); |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
948 return found; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
949 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
950 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
951 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
952 void StatelessDatabaseOperations::GetAllUuids(std::list<std::string>& target, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
953 ResourceType resourceType) |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
954 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
955 class Operations : public ReadOnlyOperationsT2<std::list<std::string>&, ResourceType> |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
956 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
957 public: |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
958 virtual void ApplyTuple(ReadOnlyTransaction& transaction, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
959 const Tuple& tuple) ORTHANC_OVERRIDE |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
960 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
961 // TODO - CANDIDATE FOR "TransactionType_Implicit" |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
962 transaction.GetAllPublicIds(tuple.get<0>(), tuple.get<1>()); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
963 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
964 }; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
965 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
966 Operations operations; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
967 operations.Apply(*this, target, resourceType); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
968 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
969 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
970 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
971 void StatelessDatabaseOperations::GetAllUuids(std::list<std::string>& target, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
972 ResourceType resourceType, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
973 size_t since, |
5220
df39c7583a49
preparing virtual methods for labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5216
diff
changeset
|
974 uint32_t limit) |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
975 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
976 if (limit == 0) |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
977 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
978 target.clear(); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
979 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
980 else |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
981 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
982 class Operations : public ReadOnlyOperationsT4<std::list<std::string>&, ResourceType, size_t, size_t> |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
983 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
984 public: |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
985 virtual void ApplyTuple(ReadOnlyTransaction& transaction, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
986 const Tuple& tuple) ORTHANC_OVERRIDE |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
987 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
988 // TODO - CANDIDATE FOR "TransactionType_Implicit" |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
989 transaction.GetAllPublicIds(tuple.get<0>(), tuple.get<1>(), tuple.get<2>(), tuple.get<3>()); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
990 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
991 }; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
992 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
993 Operations operations; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
994 operations.Apply(*this, target, resourceType, since, limit); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
995 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
996 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
997 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
998 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
999 void StatelessDatabaseOperations::GetGlobalStatistics(/* out */ uint64_t& diskSize, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1000 /* out */ uint64_t& uncompressedSize, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1001 /* out */ uint64_t& countPatients, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1002 /* out */ uint64_t& countStudies, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1003 /* out */ uint64_t& countSeries, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1004 /* out */ uint64_t& countInstances) |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1005 { |
5523 | 1006 // Code introduced in Orthanc 1.12.3 that updates and gets all statistics. |
5466
dceed5e3d6a9
new DB plugin primitive: UpdateAndGetStatistics
Alain Mazy <am@osimis.io>
parents:
5464
diff
changeset
|
1007 // I.e, PostgreSQL now store "changes" to apply to the statistics to prevent row locking |
dceed5e3d6a9
new DB plugin primitive: UpdateAndGetStatistics
Alain Mazy <am@osimis.io>
parents:
5464
diff
changeset
|
1008 // of the GlobalIntegers table while multiple clients are inserting/deleting new resources. |
dceed5e3d6a9
new DB plugin primitive: UpdateAndGetStatistics
Alain Mazy <am@osimis.io>
parents:
5464
diff
changeset
|
1009 // Then, the statistics are updated when requested to make sure they are correct. |
dceed5e3d6a9
new DB plugin primitive: UpdateAndGetStatistics
Alain Mazy <am@osimis.io>
parents:
5464
diff
changeset
|
1010 class Operations : public IReadWriteOperations |
dceed5e3d6a9
new DB plugin primitive: UpdateAndGetStatistics
Alain Mazy <am@osimis.io>
parents:
5464
diff
changeset
|
1011 { |
dceed5e3d6a9
new DB plugin primitive: UpdateAndGetStatistics
Alain Mazy <am@osimis.io>
parents:
5464
diff
changeset
|
1012 private: |
dceed5e3d6a9
new DB plugin primitive: UpdateAndGetStatistics
Alain Mazy <am@osimis.io>
parents:
5464
diff
changeset
|
1013 int64_t diskSize_; |
dceed5e3d6a9
new DB plugin primitive: UpdateAndGetStatistics
Alain Mazy <am@osimis.io>
parents:
5464
diff
changeset
|
1014 int64_t uncompressedSize_; |
dceed5e3d6a9
new DB plugin primitive: UpdateAndGetStatistics
Alain Mazy <am@osimis.io>
parents:
5464
diff
changeset
|
1015 int64_t countPatients_; |
dceed5e3d6a9
new DB plugin primitive: UpdateAndGetStatistics
Alain Mazy <am@osimis.io>
parents:
5464
diff
changeset
|
1016 int64_t countStudies_; |
dceed5e3d6a9
new DB plugin primitive: UpdateAndGetStatistics
Alain Mazy <am@osimis.io>
parents:
5464
diff
changeset
|
1017 int64_t countSeries_; |
dceed5e3d6a9
new DB plugin primitive: UpdateAndGetStatistics
Alain Mazy <am@osimis.io>
parents:
5464
diff
changeset
|
1018 int64_t countInstances_; |
dceed5e3d6a9
new DB plugin primitive: UpdateAndGetStatistics
Alain Mazy <am@osimis.io>
parents:
5464
diff
changeset
|
1019 |
dceed5e3d6a9
new DB plugin primitive: UpdateAndGetStatistics
Alain Mazy <am@osimis.io>
parents:
5464
diff
changeset
|
1020 public: |
dceed5e3d6a9
new DB plugin primitive: UpdateAndGetStatistics
Alain Mazy <am@osimis.io>
parents:
5464
diff
changeset
|
1021 Operations() : |
dceed5e3d6a9
new DB plugin primitive: UpdateAndGetStatistics
Alain Mazy <am@osimis.io>
parents:
5464
diff
changeset
|
1022 diskSize_(0), |
dceed5e3d6a9
new DB plugin primitive: UpdateAndGetStatistics
Alain Mazy <am@osimis.io>
parents:
5464
diff
changeset
|
1023 uncompressedSize_(0), |
dceed5e3d6a9
new DB plugin primitive: UpdateAndGetStatistics
Alain Mazy <am@osimis.io>
parents:
5464
diff
changeset
|
1024 countPatients_(0), |
dceed5e3d6a9
new DB plugin primitive: UpdateAndGetStatistics
Alain Mazy <am@osimis.io>
parents:
5464
diff
changeset
|
1025 countStudies_(0), |
dceed5e3d6a9
new DB plugin primitive: UpdateAndGetStatistics
Alain Mazy <am@osimis.io>
parents:
5464
diff
changeset
|
1026 countSeries_(0), |
dceed5e3d6a9
new DB plugin primitive: UpdateAndGetStatistics
Alain Mazy <am@osimis.io>
parents:
5464
diff
changeset
|
1027 countInstances_(0) |
dceed5e3d6a9
new DB plugin primitive: UpdateAndGetStatistics
Alain Mazy <am@osimis.io>
parents:
5464
diff
changeset
|
1028 { |
dceed5e3d6a9
new DB plugin primitive: UpdateAndGetStatistics
Alain Mazy <am@osimis.io>
parents:
5464
diff
changeset
|
1029 } |
dceed5e3d6a9
new DB plugin primitive: UpdateAndGetStatistics
Alain Mazy <am@osimis.io>
parents:
5464
diff
changeset
|
1030 |
dceed5e3d6a9
new DB plugin primitive: UpdateAndGetStatistics
Alain Mazy <am@osimis.io>
parents:
5464
diff
changeset
|
1031 void GetValues(uint64_t& diskSize, |
dceed5e3d6a9
new DB plugin primitive: UpdateAndGetStatistics
Alain Mazy <am@osimis.io>
parents:
5464
diff
changeset
|
1032 uint64_t& uncompressedSize, |
dceed5e3d6a9
new DB plugin primitive: UpdateAndGetStatistics
Alain Mazy <am@osimis.io>
parents:
5464
diff
changeset
|
1033 uint64_t& countPatients, |
dceed5e3d6a9
new DB plugin primitive: UpdateAndGetStatistics
Alain Mazy <am@osimis.io>
parents:
5464
diff
changeset
|
1034 uint64_t& countStudies, |
dceed5e3d6a9
new DB plugin primitive: UpdateAndGetStatistics
Alain Mazy <am@osimis.io>
parents:
5464
diff
changeset
|
1035 uint64_t& countSeries, |
dceed5e3d6a9
new DB plugin primitive: UpdateAndGetStatistics
Alain Mazy <am@osimis.io>
parents:
5464
diff
changeset
|
1036 uint64_t& countInstances) const |
dceed5e3d6a9
new DB plugin primitive: UpdateAndGetStatistics
Alain Mazy <am@osimis.io>
parents:
5464
diff
changeset
|
1037 { |
dceed5e3d6a9
new DB plugin primitive: UpdateAndGetStatistics
Alain Mazy <am@osimis.io>
parents:
5464
diff
changeset
|
1038 diskSize = static_cast<uint64_t>(diskSize_); |
dceed5e3d6a9
new DB plugin primitive: UpdateAndGetStatistics
Alain Mazy <am@osimis.io>
parents:
5464
diff
changeset
|
1039 uncompressedSize = static_cast<uint64_t>(uncompressedSize_); |
dceed5e3d6a9
new DB plugin primitive: UpdateAndGetStatistics
Alain Mazy <am@osimis.io>
parents:
5464
diff
changeset
|
1040 countPatients = static_cast<uint64_t>(countPatients_); |
dceed5e3d6a9
new DB plugin primitive: UpdateAndGetStatistics
Alain Mazy <am@osimis.io>
parents:
5464
diff
changeset
|
1041 countStudies = static_cast<uint64_t>(countStudies_); |
dceed5e3d6a9
new DB plugin primitive: UpdateAndGetStatistics
Alain Mazy <am@osimis.io>
parents:
5464
diff
changeset
|
1042 countSeries = static_cast<uint64_t>(countSeries_); |
dceed5e3d6a9
new DB plugin primitive: UpdateAndGetStatistics
Alain Mazy <am@osimis.io>
parents:
5464
diff
changeset
|
1043 countInstances = static_cast<uint64_t>(countInstances_); |
dceed5e3d6a9
new DB plugin primitive: UpdateAndGetStatistics
Alain Mazy <am@osimis.io>
parents:
5464
diff
changeset
|
1044 } |
dceed5e3d6a9
new DB plugin primitive: UpdateAndGetStatistics
Alain Mazy <am@osimis.io>
parents:
5464
diff
changeset
|
1045 |
dceed5e3d6a9
new DB plugin primitive: UpdateAndGetStatistics
Alain Mazy <am@osimis.io>
parents:
5464
diff
changeset
|
1046 virtual void Apply(ReadWriteTransaction& transaction) ORTHANC_OVERRIDE |
dceed5e3d6a9
new DB plugin primitive: UpdateAndGetStatistics
Alain Mazy <am@osimis.io>
parents:
5464
diff
changeset
|
1047 { |
dceed5e3d6a9
new DB plugin primitive: UpdateAndGetStatistics
Alain Mazy <am@osimis.io>
parents:
5464
diff
changeset
|
1048 transaction.UpdateAndGetStatistics(countPatients_, countStudies_, countSeries_, countInstances_, diskSize_, uncompressedSize_); |
dceed5e3d6a9
new DB plugin primitive: UpdateAndGetStatistics
Alain Mazy <am@osimis.io>
parents:
5464
diff
changeset
|
1049 } |
dceed5e3d6a9
new DB plugin primitive: UpdateAndGetStatistics
Alain Mazy <am@osimis.io>
parents:
5464
diff
changeset
|
1050 }; |
dceed5e3d6a9
new DB plugin primitive: UpdateAndGetStatistics
Alain Mazy <am@osimis.io>
parents:
5464
diff
changeset
|
1051 |
5523 | 1052 // Compatibility with Orthanc SDK <= 1.12.2 that reads each entry individualy |
5466
dceed5e3d6a9
new DB plugin primitive: UpdateAndGetStatistics
Alain Mazy <am@osimis.io>
parents:
5464
diff
changeset
|
1053 class LegacyOperations : public ReadOnlyOperationsT6<uint64_t&, uint64_t&, uint64_t&, uint64_t&, uint64_t&, uint64_t&> |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1054 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1055 public: |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1056 virtual void ApplyTuple(ReadOnlyTransaction& transaction, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1057 const Tuple& tuple) ORTHANC_OVERRIDE |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1058 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1059 tuple.get<0>() = transaction.GetTotalCompressedSize(); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1060 tuple.get<1>() = transaction.GetTotalUncompressedSize(); |
4595
cc64385593ef
added OrthancPluginRegisterDatabaseBackendV3() to plugin sdk
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4594
diff
changeset
|
1061 tuple.get<2>() = transaction.GetResourcesCount(ResourceType_Patient); |
cc64385593ef
added OrthancPluginRegisterDatabaseBackendV3() to plugin sdk
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4594
diff
changeset
|
1062 tuple.get<3>() = transaction.GetResourcesCount(ResourceType_Study); |
cc64385593ef
added OrthancPluginRegisterDatabaseBackendV3() to plugin sdk
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4594
diff
changeset
|
1063 tuple.get<4>() = transaction.GetResourcesCount(ResourceType_Series); |
cc64385593ef
added OrthancPluginRegisterDatabaseBackendV3() to plugin sdk
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4594
diff
changeset
|
1064 tuple.get<5>() = transaction.GetResourcesCount(ResourceType_Instance); |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1065 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1066 }; |
5466
dceed5e3d6a9
new DB plugin primitive: UpdateAndGetStatistics
Alain Mazy <am@osimis.io>
parents:
5464
diff
changeset
|
1067 |
dceed5e3d6a9
new DB plugin primitive: UpdateAndGetStatistics
Alain Mazy <am@osimis.io>
parents:
5464
diff
changeset
|
1068 if (GetDatabaseCapabilities().HasUpdateAndGetStatistics()) |
dceed5e3d6a9
new DB plugin primitive: UpdateAndGetStatistics
Alain Mazy <am@osimis.io>
parents:
5464
diff
changeset
|
1069 { |
dceed5e3d6a9
new DB plugin primitive: UpdateAndGetStatistics
Alain Mazy <am@osimis.io>
parents:
5464
diff
changeset
|
1070 Operations operations; |
dceed5e3d6a9
new DB plugin primitive: UpdateAndGetStatistics
Alain Mazy <am@osimis.io>
parents:
5464
diff
changeset
|
1071 Apply(operations); |
dceed5e3d6a9
new DB plugin primitive: UpdateAndGetStatistics
Alain Mazy <am@osimis.io>
parents:
5464
diff
changeset
|
1072 |
dceed5e3d6a9
new DB plugin primitive: UpdateAndGetStatistics
Alain Mazy <am@osimis.io>
parents:
5464
diff
changeset
|
1073 operations.GetValues(diskSize, uncompressedSize, countPatients, countStudies, countSeries, countInstances); |
dceed5e3d6a9
new DB plugin primitive: UpdateAndGetStatistics
Alain Mazy <am@osimis.io>
parents:
5464
diff
changeset
|
1074 } |
dceed5e3d6a9
new DB plugin primitive: UpdateAndGetStatistics
Alain Mazy <am@osimis.io>
parents:
5464
diff
changeset
|
1075 else |
dceed5e3d6a9
new DB plugin primitive: UpdateAndGetStatistics
Alain Mazy <am@osimis.io>
parents:
5464
diff
changeset
|
1076 { |
dceed5e3d6a9
new DB plugin primitive: UpdateAndGetStatistics
Alain Mazy <am@osimis.io>
parents:
5464
diff
changeset
|
1077 LegacyOperations operations; |
dceed5e3d6a9
new DB plugin primitive: UpdateAndGetStatistics
Alain Mazy <am@osimis.io>
parents:
5464
diff
changeset
|
1078 operations.Apply(*this, diskSize, uncompressedSize, countPatients, |
dceed5e3d6a9
new DB plugin primitive: UpdateAndGetStatistics
Alain Mazy <am@osimis.io>
parents:
5464
diff
changeset
|
1079 countStudies, countSeries, countInstances); |
dceed5e3d6a9
new DB plugin primitive: UpdateAndGetStatistics
Alain Mazy <am@osimis.io>
parents:
5464
diff
changeset
|
1080 } |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1081 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1082 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1083 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1084 void StatelessDatabaseOperations::GetChanges(Json::Value& target, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1085 int64_t since, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1086 unsigned int maxResults) |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1087 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1088 class Operations : public ReadOnlyOperationsT3<Json::Value&, int64_t, unsigned int> |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1089 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1090 public: |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1091 virtual void ApplyTuple(ReadOnlyTransaction& transaction, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1092 const Tuple& tuple) ORTHANC_OVERRIDE |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1093 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1094 // NB: In Orthanc <= 1.3.2, a transaction was missing, as |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1095 // "GetLastChange()" involves calls to "GetPublicId()" |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1096 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1097 std::list<ServerIndexChange> changes; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1098 bool done; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1099 bool hasLast = false; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1100 int64_t last = 0; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1101 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1102 transaction.GetChanges(changes, done, tuple.get<1>(), tuple.get<2>()); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1103 if (changes.empty()) |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1104 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1105 last = transaction.GetLastChangeIndex(); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1106 hasLast = true; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1107 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1108 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1109 FormatLog(tuple.get<0>(), changes, "Changes", done, tuple.get<1>(), hasLast, last); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1110 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1111 }; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1112 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1113 Operations operations; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1114 operations.Apply(*this, target, since, maxResults); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1115 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1116 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1117 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1118 void StatelessDatabaseOperations::GetLastChange(Json::Value& target) |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1119 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1120 class Operations : public ReadOnlyOperationsT1<Json::Value&> |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1121 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1122 public: |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1123 virtual void ApplyTuple(ReadOnlyTransaction& transaction, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1124 const Tuple& tuple) ORTHANC_OVERRIDE |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1125 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1126 // NB: In Orthanc <= 1.3.2, a transaction was missing, as |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1127 // "GetLastChange()" involves calls to "GetPublicId()" |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1128 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1129 std::list<ServerIndexChange> changes; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1130 bool hasLast = false; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1131 int64_t last = 0; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1132 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1133 transaction.GetLastChange(changes); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1134 if (changes.empty()) |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1135 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1136 last = transaction.GetLastChangeIndex(); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1137 hasLast = true; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1138 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1139 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1140 FormatLog(tuple.get<0>(), changes, "Changes", true, 0, hasLast, last); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1141 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1142 }; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1143 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1144 Operations operations; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1145 operations.Apply(*this, target); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1146 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1147 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1148 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1149 void StatelessDatabaseOperations::GetExportedResources(Json::Value& target, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1150 int64_t since, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1151 unsigned int maxResults) |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1152 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1153 class Operations : public ReadOnlyOperationsT3<Json::Value&, int64_t, unsigned int> |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1154 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1155 public: |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1156 virtual void ApplyTuple(ReadOnlyTransaction& transaction, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1157 const Tuple& tuple) ORTHANC_OVERRIDE |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1158 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1159 // TODO - CANDIDATE FOR "TransactionType_Implicit" |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1160 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1161 std::list<ExportedResource> exported; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1162 bool done; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1163 transaction.GetExportedResources(exported, done, tuple.get<1>(), tuple.get<2>()); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1164 FormatLog(tuple.get<0>(), exported, "Exports", done, tuple.get<1>(), false, -1); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1165 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1166 }; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1167 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1168 Operations operations; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1169 operations.Apply(*this, target, since, maxResults); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1170 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1171 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1172 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1173 void StatelessDatabaseOperations::GetLastExportedResource(Json::Value& target) |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1174 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1175 class Operations : public ReadOnlyOperationsT1<Json::Value&> |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1176 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1177 public: |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1178 virtual void ApplyTuple(ReadOnlyTransaction& transaction, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1179 const Tuple& tuple) ORTHANC_OVERRIDE |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1180 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1181 // TODO - CANDIDATE FOR "TransactionType_Implicit" |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1182 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1183 std::list<ExportedResource> exported; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1184 transaction.GetLastExportedResource(exported); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1185 FormatLog(tuple.get<0>(), exported, "Exports", true, 0, false, -1); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1186 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1187 }; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1188 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1189 Operations operations; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1190 operations.Apply(*this, target); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1191 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1192 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1193 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1194 bool StatelessDatabaseOperations::IsProtectedPatient(const std::string& publicId) |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1195 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1196 class Operations : public ReadOnlyOperationsT2<bool&, const std::string&> |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1197 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1198 public: |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1199 virtual void ApplyTuple(ReadOnlyTransaction& transaction, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1200 const Tuple& tuple) ORTHANC_OVERRIDE |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1201 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1202 // Lookup for the requested resource |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1203 int64_t id; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1204 ResourceType type; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1205 if (!transaction.LookupResource(id, type, tuple.get<1>()) || |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1206 type != ResourceType_Patient) |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1207 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1208 throw OrthancException(ErrorCode_ParameterOutOfRange); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1209 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1210 else |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1211 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1212 tuple.get<0>() = transaction.IsProtectedPatient(id); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1213 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1214 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1215 }; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1216 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1217 bool isProtected; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1218 Operations operations; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1219 operations.Apply(*this, isProtected, publicId); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1220 return isProtected; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1221 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1222 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1223 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1224 void StatelessDatabaseOperations::GetChildren(std::list<std::string>& result, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1225 const std::string& publicId) |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1226 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1227 class Operations : public ReadOnlyOperationsT2<std::list<std::string>&, const std::string&> |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1228 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1229 public: |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1230 virtual void ApplyTuple(ReadOnlyTransaction& transaction, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1231 const Tuple& tuple) ORTHANC_OVERRIDE |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1232 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1233 ResourceType type; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1234 int64_t resource; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1235 if (!transaction.LookupResource(resource, type, tuple.get<1>())) |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1236 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1237 throw OrthancException(ErrorCode_UnknownResource); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1238 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1239 else if (type == ResourceType_Instance) |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1240 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1241 // An instance cannot have a child |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1242 throw OrthancException(ErrorCode_BadParameterType); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1243 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1244 else |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1245 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1246 std::list<int64_t> tmp; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1247 transaction.GetChildrenInternalId(tmp, resource); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1248 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1249 tuple.get<0>().clear(); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1250 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1251 for (std::list<int64_t>::const_iterator |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1252 it = tmp.begin(); it != tmp.end(); ++it) |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1253 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1254 tuple.get<0>().push_back(transaction.GetPublicId(*it)); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1255 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1256 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1257 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1258 }; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1259 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1260 Operations operations; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1261 operations.Apply(*this, result, publicId); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1262 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1263 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1264 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1265 void StatelessDatabaseOperations::GetChildInstances(std::list<std::string>& result, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1266 const std::string& publicId) |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1267 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1268 class Operations : public ReadOnlyOperationsT2<std::list<std::string>&, const std::string&> |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1269 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1270 public: |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1271 virtual void ApplyTuple(ReadOnlyTransaction& transaction, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1272 const Tuple& tuple) ORTHANC_OVERRIDE |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1273 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1274 tuple.get<0>().clear(); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1275 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1276 ResourceType type; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1277 int64_t top; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1278 if (!transaction.LookupResource(top, type, tuple.get<1>())) |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1279 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1280 throw OrthancException(ErrorCode_UnknownResource); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1281 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1282 else if (type == ResourceType_Instance) |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1283 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1284 // The resource is already an instance: Do not go down the hierarchy |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1285 tuple.get<0>().push_back(tuple.get<1>()); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1286 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1287 else |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1288 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1289 std::stack<int64_t> toExplore; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1290 toExplore.push(top); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1291 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1292 std::list<int64_t> tmp; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1293 while (!toExplore.empty()) |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1294 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1295 // Get the internal ID of the current resource |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1296 int64_t resource = toExplore.top(); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1297 toExplore.pop(); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1298 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1299 // TODO - This could be optimized by seeing how many |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1300 // levels "type == transaction.GetResourceType(top)" is |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1301 // above the "instances level" |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1302 if (transaction.GetResourceType(resource) == ResourceType_Instance) |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1303 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1304 tuple.get<0>().push_back(transaction.GetPublicId(resource)); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1305 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1306 else |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1307 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1308 // Tag all the children of this resource as to be explored |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1309 transaction.GetChildrenInternalId(tmp, resource); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1310 for (std::list<int64_t>::const_iterator |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1311 it = tmp.begin(); it != tmp.end(); ++it) |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1312 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1313 toExplore.push(*it); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1314 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1315 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1316 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1317 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1318 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1319 }; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1320 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1321 Operations operations; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1322 operations.Apply(*this, result, publicId); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1323 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1324 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1325 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1326 bool StatelessDatabaseOperations::LookupMetadata(std::string& target, |
4623
95ffe3b6ef7c
handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4619
diff
changeset
|
1327 int64_t& revision, |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1328 const std::string& publicId, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1329 ResourceType expectedType, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1330 MetadataType type) |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1331 { |
4623
95ffe3b6ef7c
handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4619
diff
changeset
|
1332 class Operations : public ReadOnlyOperationsT6<bool&, std::string&, int64_t&, |
95ffe3b6ef7c
handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4619
diff
changeset
|
1333 const std::string&, ResourceType, MetadataType> |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1334 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1335 public: |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1336 virtual void ApplyTuple(ReadOnlyTransaction& transaction, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1337 const Tuple& tuple) ORTHANC_OVERRIDE |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1338 { |
4623
95ffe3b6ef7c
handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4619
diff
changeset
|
1339 ResourceType resourceType; |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1340 int64_t id; |
4623
95ffe3b6ef7c
handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4619
diff
changeset
|
1341 if (!transaction.LookupResource(id, resourceType, tuple.get<3>()) || |
95ffe3b6ef7c
handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4619
diff
changeset
|
1342 resourceType != tuple.get<4>()) |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1343 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1344 throw OrthancException(ErrorCode_UnknownResource); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1345 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1346 else |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1347 { |
4623
95ffe3b6ef7c
handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4619
diff
changeset
|
1348 tuple.get<0>() = transaction.LookupMetadata(tuple.get<1>(), tuple.get<2>(), id, tuple.get<5>()); |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1349 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1350 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1351 }; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1352 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1353 bool found; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1354 Operations operations; |
4623
95ffe3b6ef7c
handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4619
diff
changeset
|
1355 operations.Apply(*this, found, target, revision, publicId, expectedType, type); |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1356 return found; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1357 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1358 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1359 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1360 void StatelessDatabaseOperations::ListAvailableAttachments(std::set<FileContentType>& target, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1361 const std::string& publicId, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1362 ResourceType expectedType) |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1363 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1364 class Operations : public ReadOnlyOperationsT3<std::set<FileContentType>&, const std::string&, ResourceType> |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1365 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1366 public: |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1367 virtual void ApplyTuple(ReadOnlyTransaction& transaction, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1368 const Tuple& tuple) ORTHANC_OVERRIDE |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1369 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1370 ResourceType type; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1371 int64_t id; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1372 if (!transaction.LookupResource(id, type, tuple.get<1>()) || |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1373 tuple.get<2>() != type) |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1374 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1375 throw OrthancException(ErrorCode_UnknownResource); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1376 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1377 else |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1378 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1379 transaction.ListAvailableAttachments(tuple.get<0>(), id); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1380 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1381 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1382 }; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1383 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1384 Operations operations; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1385 operations.Apply(*this, target, publicId, expectedType); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1386 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1387 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1388 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1389 bool StatelessDatabaseOperations::LookupParent(std::string& target, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1390 const std::string& publicId) |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1391 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1392 class Operations : public ReadOnlyOperationsT3<bool&, std::string&, const std::string&> |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1393 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1394 public: |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1395 virtual void ApplyTuple(ReadOnlyTransaction& transaction, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1396 const Tuple& tuple) ORTHANC_OVERRIDE |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1397 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1398 ResourceType type; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1399 int64_t id; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1400 if (!transaction.LookupResource(id, type, tuple.get<2>())) |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1401 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1402 throw OrthancException(ErrorCode_UnknownResource); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1403 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1404 else |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1405 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1406 int64_t parentId; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1407 if (transaction.LookupParent(parentId, id)) |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1408 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1409 tuple.get<1>() = transaction.GetPublicId(parentId); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1410 tuple.get<0>() = true; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1411 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1412 else |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1413 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1414 tuple.get<0>() = false; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1415 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1416 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1417 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1418 }; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1419 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1420 bool found; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1421 Operations operations; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1422 operations.Apply(*this, found, target, publicId); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1423 return found; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1424 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1425 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1426 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1427 void StatelessDatabaseOperations::GetResourceStatistics(/* out */ ResourceType& type, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1428 /* out */ uint64_t& diskSize, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1429 /* out */ uint64_t& uncompressedSize, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1430 /* out */ unsigned int& countStudies, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1431 /* out */ unsigned int& countSeries, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1432 /* out */ unsigned int& countInstances, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1433 /* out */ uint64_t& dicomDiskSize, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1434 /* out */ uint64_t& dicomUncompressedSize, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1435 const std::string& publicId) |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1436 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1437 class Operations : public IReadOnlyOperations |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1438 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1439 private: |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1440 ResourceType& type_; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1441 uint64_t& diskSize_; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1442 uint64_t& uncompressedSize_; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1443 unsigned int& countStudies_; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1444 unsigned int& countSeries_; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1445 unsigned int& countInstances_; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1446 uint64_t& dicomDiskSize_; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1447 uint64_t& dicomUncompressedSize_; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1448 const std::string& publicId_; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1449 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1450 public: |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1451 explicit Operations(ResourceType& type, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1452 uint64_t& diskSize, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1453 uint64_t& uncompressedSize, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1454 unsigned int& countStudies, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1455 unsigned int& countSeries, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1456 unsigned int& countInstances, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1457 uint64_t& dicomDiskSize, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1458 uint64_t& dicomUncompressedSize, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1459 const std::string& publicId) : |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1460 type_(type), |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1461 diskSize_(diskSize), |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1462 uncompressedSize_(uncompressedSize), |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1463 countStudies_(countStudies), |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1464 countSeries_(countSeries), |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1465 countInstances_(countInstances), |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1466 dicomDiskSize_(dicomDiskSize), |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1467 dicomUncompressedSize_(dicomUncompressedSize), |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1468 publicId_(publicId) |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1469 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1470 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1471 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1472 virtual void Apply(ReadOnlyTransaction& transaction) ORTHANC_OVERRIDE |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1473 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1474 int64_t top; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1475 if (!transaction.LookupResource(top, type_, publicId_)) |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1476 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1477 throw OrthancException(ErrorCode_UnknownResource); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1478 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1479 else |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1480 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1481 countInstances_ = 0; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1482 countSeries_ = 0; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1483 countStudies_ = 0; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1484 diskSize_ = 0; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1485 uncompressedSize_ = 0; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1486 dicomDiskSize_ = 0; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1487 dicomUncompressedSize_ = 0; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1488 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1489 std::stack<int64_t> toExplore; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1490 toExplore.push(top); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1491 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1492 while (!toExplore.empty()) |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1493 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1494 // Get the internal ID of the current resource |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1495 int64_t resource = toExplore.top(); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1496 toExplore.pop(); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1497 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1498 ResourceType thisType = transaction.GetResourceType(resource); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1499 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1500 std::set<FileContentType> f; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1501 transaction.ListAvailableAttachments(f, resource); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1502 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1503 for (std::set<FileContentType>::const_iterator |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1504 it = f.begin(); it != f.end(); ++it) |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1505 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1506 FileInfo attachment; |
4627
f7d5372b59b3
handling revisions of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4623
diff
changeset
|
1507 int64_t revision; // ignored |
f7d5372b59b3
handling revisions of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4623
diff
changeset
|
1508 if (transaction.LookupAttachment(attachment, revision, resource, *it)) |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1509 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1510 if (attachment.GetContentType() == FileContentType_Dicom) |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1511 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1512 dicomDiskSize_ += attachment.GetCompressedSize(); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1513 dicomUncompressedSize_ += attachment.GetUncompressedSize(); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1514 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1515 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1516 diskSize_ += attachment.GetCompressedSize(); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1517 uncompressedSize_ += attachment.GetUncompressedSize(); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1518 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1519 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1520 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1521 if (thisType == ResourceType_Instance) |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1522 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1523 countInstances_++; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1524 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1525 else |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1526 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1527 switch (thisType) |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1528 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1529 case ResourceType_Study: |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1530 countStudies_++; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1531 break; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1532 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1533 case ResourceType_Series: |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1534 countSeries_++; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1535 break; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1536 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1537 default: |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1538 break; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1539 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1540 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1541 // Tag all the children of this resource as to be explored |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1542 std::list<int64_t> tmp; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1543 transaction.GetChildrenInternalId(tmp, resource); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1544 for (std::list<int64_t>::const_iterator |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1545 it = tmp.begin(); it != tmp.end(); ++it) |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1546 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1547 toExplore.push(*it); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1548 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1549 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1550 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1551 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1552 if (countStudies_ == 0) |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1553 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1554 countStudies_ = 1; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1555 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1556 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1557 if (countSeries_ == 0) |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1558 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1559 countSeries_ = 1; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1560 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1561 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1562 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1563 }; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1564 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1565 Operations operations(type, diskSize, uncompressedSize, countStudies, countSeries, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1566 countInstances, dicomDiskSize, dicomUncompressedSize, publicId); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1567 Apply(operations); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1568 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1569 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1570 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1571 void StatelessDatabaseOperations::LookupIdentifierExact(std::vector<std::string>& result, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1572 ResourceType level, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1573 const DicomTag& tag, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1574 const std::string& value) |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1575 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1576 assert((level == ResourceType_Patient && tag == DICOM_TAG_PATIENT_ID) || |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1577 (level == ResourceType_Study && tag == DICOM_TAG_STUDY_INSTANCE_UID) || |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1578 (level == ResourceType_Study && tag == DICOM_TAG_ACCESSION_NUMBER) || |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1579 (level == ResourceType_Series && tag == DICOM_TAG_SERIES_INSTANCE_UID) || |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1580 (level == ResourceType_Instance && tag == DICOM_TAG_SOP_INSTANCE_UID)); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1581 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1582 result.clear(); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1583 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1584 DicomTagConstraint c(tag, ConstraintType_Equal, value, true, true); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1585 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1586 std::vector<DatabaseConstraint> query; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1587 query.push_back(c.ConvertToDatabaseConstraint(level, DicomTagType_Identifier)); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1588 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1589 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1590 class Operations : public IReadOnlyOperations |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1591 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1592 private: |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1593 std::vector<std::string>& result_; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1594 const std::vector<DatabaseConstraint>& query_; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1595 ResourceType level_; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1596 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1597 public: |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1598 Operations(std::vector<std::string>& result, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1599 const std::vector<DatabaseConstraint>& query, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1600 ResourceType level) : |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1601 result_(result), |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1602 query_(query), |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1603 level_(level) |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1604 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1605 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1606 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1607 virtual void Apply(ReadOnlyTransaction& transaction) ORTHANC_OVERRIDE |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1608 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1609 // TODO - CANDIDATE FOR "TransactionType_Implicit" |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1610 std::list<std::string> tmp; |
5248
a7d95f951f8a
replaced "WithLabels" and "WithoutLabels", by "Labels" and "LabelsConstraint"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5244
diff
changeset
|
1611 std::set<std::string> labels; |
a7d95f951f8a
replaced "WithLabels" and "WithoutLabels", by "Labels" and "LabelsConstraint"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5244
diff
changeset
|
1612 transaction.ApplyLookupResources(tmp, NULL, query_, level_, labels, LabelsConstraint_Any, 0); |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1613 CopyListToVector(result_, tmp); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1614 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1615 }; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1616 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1617 Operations operations(result, query, level); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1618 Apply(operations); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1619 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1620 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1621 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1622 bool StatelessDatabaseOperations::LookupGlobalProperty(std::string& value, |
4607
f75c63aa9de0
differentiating between shared and private global properties
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4602
diff
changeset
|
1623 GlobalProperty property, |
f75c63aa9de0
differentiating between shared and private global properties
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4602
diff
changeset
|
1624 bool shared) |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1625 { |
4607
f75c63aa9de0
differentiating between shared and private global properties
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4602
diff
changeset
|
1626 class Operations : public ReadOnlyOperationsT4<bool&, std::string&, GlobalProperty, bool> |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1627 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1628 public: |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1629 virtual void ApplyTuple(ReadOnlyTransaction& transaction, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1630 const Tuple& tuple) ORTHANC_OVERRIDE |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1631 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1632 // TODO - CANDIDATE FOR "TransactionType_Implicit" |
4607
f75c63aa9de0
differentiating between shared and private global properties
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4602
diff
changeset
|
1633 tuple.get<0>() = transaction.LookupGlobalProperty(tuple.get<1>(), tuple.get<2>(), tuple.get<3>()); |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1634 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1635 }; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1636 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1637 bool found; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1638 Operations operations; |
4607
f75c63aa9de0
differentiating between shared and private global properties
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4602
diff
changeset
|
1639 operations.Apply(*this, found, value, property, shared); |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1640 return found; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1641 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1642 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1643 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1644 std::string StatelessDatabaseOperations::GetGlobalProperty(GlobalProperty property, |
4607
f75c63aa9de0
differentiating between shared and private global properties
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4602
diff
changeset
|
1645 bool shared, |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1646 const std::string& defaultValue) |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1647 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1648 std::string s; |
4607
f75c63aa9de0
differentiating between shared and private global properties
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4602
diff
changeset
|
1649 if (LookupGlobalProperty(s, property, shared)) |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1650 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1651 return s; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1652 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1653 else |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1654 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1655 return defaultValue; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1656 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1657 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1658 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1659 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1660 bool StatelessDatabaseOperations::GetMainDicomTags(DicomMap& result, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1661 const std::string& publicId, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1662 ResourceType expectedType, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1663 ResourceType levelOfInterest) |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1664 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1665 // Yes, the following test could be shortened, but we wish to make it as clear as possible |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1666 if (!(expectedType == ResourceType_Patient && levelOfInterest == ResourceType_Patient) && |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1667 !(expectedType == ResourceType_Study && levelOfInterest == ResourceType_Patient) && |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1668 !(expectedType == ResourceType_Study && levelOfInterest == ResourceType_Study) && |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1669 !(expectedType == ResourceType_Series && levelOfInterest == ResourceType_Series) && |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1670 !(expectedType == ResourceType_Instance && levelOfInterest == ResourceType_Instance)) |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1671 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1672 throw OrthancException(ErrorCode_ParameterOutOfRange); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1673 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1674 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1675 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1676 class Operations : public ReadOnlyOperationsT5<bool&, DicomMap&, const std::string&, ResourceType, ResourceType> |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1677 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1678 public: |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1679 virtual void ApplyTuple(ReadOnlyTransaction& transaction, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1680 const Tuple& tuple) ORTHANC_OVERRIDE |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1681 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1682 // Lookup for the requested resource |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1683 int64_t id; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1684 ResourceType type; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1685 if (!transaction.LookupResource(id, type, tuple.get<2>()) || |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1686 type != tuple.get<3>()) |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1687 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1688 tuple.get<0>() = false; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1689 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1690 else if (type == ResourceType_Study) |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1691 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1692 DicomMap tmp; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1693 transaction.GetMainDicomTags(tmp, id); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1694 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1695 switch (tuple.get<4>()) |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1696 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1697 case ResourceType_Patient: |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1698 tmp.ExtractPatientInformation(tuple.get<1>()); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1699 tuple.get<0>() = true; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1700 break; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1701 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1702 case ResourceType_Study: |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1703 tmp.ExtractStudyInformation(tuple.get<1>()); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1704 tuple.get<0>() = true; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1705 break; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1706 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1707 default: |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1708 throw OrthancException(ErrorCode_InternalError); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1709 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1710 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1711 else |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1712 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1713 transaction.GetMainDicomTags(tuple.get<1>(), id); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1714 tuple.get<0>() = true; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1715 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1716 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1717 }; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1718 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1719 result.Clear(); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1720 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1721 bool found; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1722 Operations operations; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1723 operations.Apply(*this, found, result, publicId, expectedType, levelOfInterest); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1724 return found; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1725 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1726 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1727 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1728 bool StatelessDatabaseOperations::GetAllMainDicomTags(DicomMap& result, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1729 const std::string& instancePublicId) |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1730 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1731 class Operations : public ReadOnlyOperationsT3<bool&, DicomMap&, const std::string&> |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1732 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1733 public: |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1734 virtual void ApplyTuple(ReadOnlyTransaction& transaction, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1735 const Tuple& tuple) ORTHANC_OVERRIDE |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1736 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1737 // Lookup for the requested resource |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1738 int64_t instance; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1739 ResourceType type; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1740 if (!transaction.LookupResource(instance, type, tuple.get<2>()) || |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1741 type != ResourceType_Instance) |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1742 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1743 tuple.get<0>() = false; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1744 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1745 else |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1746 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1747 DicomMap tmp; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1748 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1749 transaction.GetMainDicomTags(tmp, instance); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1750 tuple.get<1>().Merge(tmp); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1751 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1752 int64_t series; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1753 if (!transaction.LookupParent(series, instance)) |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1754 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1755 throw OrthancException(ErrorCode_InternalError); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1756 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1757 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1758 tmp.Clear(); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1759 transaction.GetMainDicomTags(tmp, series); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1760 tuple.get<1>().Merge(tmp); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1761 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1762 int64_t study; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1763 if (!transaction.LookupParent(study, series)) |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1764 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1765 throw OrthancException(ErrorCode_InternalError); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1766 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1767 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1768 tmp.Clear(); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1769 transaction.GetMainDicomTags(tmp, study); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1770 tuple.get<1>().Merge(tmp); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1771 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1772 #ifndef NDEBUG |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1773 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1774 // Sanity test to check that all the main DICOM tags from the |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1775 // patient level are copied at the study level |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1776 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1777 int64_t patient; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1778 if (!transaction.LookupParent(patient, study)) |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1779 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1780 throw OrthancException(ErrorCode_InternalError); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1781 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1782 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1783 tmp.Clear(); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1784 transaction.GetMainDicomTags(tmp, study); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1785 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1786 std::set<DicomTag> patientTags; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1787 tmp.GetTags(patientTags); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1788 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1789 for (std::set<DicomTag>::const_iterator |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1790 it = patientTags.begin(); it != patientTags.end(); ++it) |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1791 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1792 assert(tuple.get<1>().HasTag(*it)); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1793 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1794 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1795 #endif |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1796 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1797 tuple.get<0>() = true; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1798 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1799 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1800 }; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1801 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1802 result.Clear(); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1803 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1804 bool found; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1805 Operations operations; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1806 operations.Apply(*this, found, result, instancePublicId); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1807 return found; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1808 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1809 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1810 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1811 bool StatelessDatabaseOperations::LookupResourceType(ResourceType& type, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1812 const std::string& publicId) |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1813 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1814 class Operations : public ReadOnlyOperationsT3<bool&, ResourceType&, const std::string&> |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1815 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1816 public: |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1817 virtual void ApplyTuple(ReadOnlyTransaction& transaction, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1818 const Tuple& tuple) ORTHANC_OVERRIDE |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1819 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1820 // TODO - CANDIDATE FOR "TransactionType_Implicit" |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1821 int64_t id; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1822 tuple.get<0>() = transaction.LookupResource(id, tuple.get<1>(), tuple.get<2>()); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1823 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1824 }; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1825 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1826 bool found; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1827 Operations operations; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1828 operations.Apply(*this, found, type, publicId); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1829 return found; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1830 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1831 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1832 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1833 bool StatelessDatabaseOperations::LookupParent(std::string& target, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1834 const std::string& publicId, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1835 ResourceType parentType) |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1836 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1837 class Operations : public ReadOnlyOperationsT4<bool&, std::string&, const std::string&, ResourceType> |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1838 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1839 public: |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1840 virtual void ApplyTuple(ReadOnlyTransaction& transaction, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1841 const Tuple& tuple) ORTHANC_OVERRIDE |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1842 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1843 ResourceType type; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1844 int64_t id; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1845 if (!transaction.LookupResource(id, type, tuple.get<2>())) |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1846 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1847 throw OrthancException(ErrorCode_UnknownResource); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1848 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1849 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1850 while (type != tuple.get<3>()) |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1851 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1852 int64_t parentId; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1853 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1854 if (type == ResourceType_Patient || // Cannot further go up in hierarchy |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1855 !transaction.LookupParent(parentId, id)) |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1856 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1857 tuple.get<0>() = false; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1858 return; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1859 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1860 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1861 id = parentId; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1862 type = GetParentResourceType(type); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1863 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1864 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1865 tuple.get<0>() = true; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1866 tuple.get<1>() = transaction.GetPublicId(id); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1867 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1868 }; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1869 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1870 bool found; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1871 Operations operations; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1872 operations.Apply(*this, found, target, publicId, parentType); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1873 return found; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1874 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1875 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1876 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1877 void StatelessDatabaseOperations::ApplyLookupResources(std::vector<std::string>& resourcesId, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1878 std::vector<std::string>* instancesId, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1879 const DatabaseLookup& lookup, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1880 ResourceType queryLevel, |
5248
a7d95f951f8a
replaced "WithLabels" and "WithoutLabels", by "Labels" and "LabelsConstraint"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5244
diff
changeset
|
1881 const std::set<std::string>& labels, |
a7d95f951f8a
replaced "WithLabels" and "WithoutLabels", by "Labels" and "LabelsConstraint"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5244
diff
changeset
|
1882 LabelsConstraint labelsConstraint, |
5220
df39c7583a49
preparing virtual methods for labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5216
diff
changeset
|
1883 uint32_t limit) |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1884 { |
5220
df39c7583a49
preparing virtual methods for labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5216
diff
changeset
|
1885 class Operations : public ReadOnlyOperationsT6<bool, const std::vector<DatabaseConstraint>&, ResourceType, |
5248
a7d95f951f8a
replaced "WithLabels" and "WithoutLabels", by "Labels" and "LabelsConstraint"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5244
diff
changeset
|
1886 const std::set<std::string>&, LabelsConstraint, size_t> |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1887 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1888 private: |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1889 std::list<std::string> resourcesList_; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1890 std::list<std::string> instancesList_; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1891 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1892 public: |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1893 const std::list<std::string>& GetResourcesList() const |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1894 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1895 return resourcesList_; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1896 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1897 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1898 const std::list<std::string>& GetInstancesList() const |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1899 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1900 return instancesList_; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1901 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1902 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1903 virtual void ApplyTuple(ReadOnlyTransaction& transaction, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1904 const Tuple& tuple) ORTHANC_OVERRIDE |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1905 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1906 // TODO - CANDIDATE FOR "TransactionType_Implicit" |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1907 if (tuple.get<0>()) |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1908 { |
5220
df39c7583a49
preparing virtual methods for labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5216
diff
changeset
|
1909 transaction.ApplyLookupResources( |
df39c7583a49
preparing virtual methods for labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5216
diff
changeset
|
1910 resourcesList_, &instancesList_, tuple.get<1>(), tuple.get<2>(), tuple.get<3>(), tuple.get<4>(), tuple.get<5>()); |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1911 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1912 else |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1913 { |
5220
df39c7583a49
preparing virtual methods for labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5216
diff
changeset
|
1914 transaction.ApplyLookupResources( |
df39c7583a49
preparing virtual methods for labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5216
diff
changeset
|
1915 resourcesList_, NULL, tuple.get<1>(), tuple.get<2>(), tuple.get<3>(), tuple.get<4>(), tuple.get<5>()); |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1916 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1917 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1918 }; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1919 |
5248
a7d95f951f8a
replaced "WithLabels" and "WithoutLabels", by "Labels" and "LabelsConstraint"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5244
diff
changeset
|
1920 if (!labels.empty() && |
5455
176bc05f85f4
DB: new Capabilities class to manage future new methods from DB plugins + Added IncrementGlobalProperty
Alain Mazy <am@osimis.io>
parents:
5324
diff
changeset
|
1921 !db_.GetDatabaseCapabilities().HasLabelsSupport()) |
5238
367e8af46cfd
added "HasLabels" in /system
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5237
diff
changeset
|
1922 { |
367e8af46cfd
added "HasLabels" in /system
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5237
diff
changeset
|
1923 throw OrthancException(ErrorCode_NotImplemented, "The database backend doesn't support labels"); |
367e8af46cfd
added "HasLabels" in /system
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5237
diff
changeset
|
1924 } |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1925 |
5248
a7d95f951f8a
replaced "WithLabels" and "WithoutLabels", by "Labels" and "LabelsConstraint"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5244
diff
changeset
|
1926 for (std::set<std::string>::const_iterator it = labels.begin(); it != labels.end(); ++it) |
a7d95f951f8a
replaced "WithLabels" and "WithoutLabels", by "Labels" and "LabelsConstraint"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5244
diff
changeset
|
1927 { |
a7d95f951f8a
replaced "WithLabels" and "WithoutLabels", by "Labels" and "LabelsConstraint"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5244
diff
changeset
|
1928 ServerToolbox::CheckValidLabel(*it); |
a7d95f951f8a
replaced "WithLabels" and "WithoutLabels", by "Labels" and "LabelsConstraint"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5244
diff
changeset
|
1929 } |
5244
72dfa0ac84eb
lookup for labels in orthanc explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5238
diff
changeset
|
1930 |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1931 std::vector<DatabaseConstraint> normalized; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1932 NormalizeLookup(normalized, lookup, queryLevel); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1933 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1934 Operations operations; |
5248
a7d95f951f8a
replaced "WithLabels" and "WithoutLabels", by "Labels" and "LabelsConstraint"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5244
diff
changeset
|
1935 operations.Apply(*this, (instancesId != NULL), normalized, queryLevel, labels, labelsConstraint, limit); |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1936 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1937 CopyListToVector(resourcesId, operations.GetResourcesList()); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1938 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1939 if (instancesId != NULL) |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1940 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1941 CopyListToVector(*instancesId, operations.GetInstancesList()); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1942 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1943 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1944 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1945 |
4694
da1edb7d6332
"/tools/bulk-delete" to delete a group of multiple, unrelated resources at once
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4640
diff
changeset
|
1946 bool StatelessDatabaseOperations::DeleteResource(Json::Value& remainingAncestor, |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1947 const std::string& uuid, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1948 ResourceType expectedType) |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1949 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1950 class Operations : public IReadWriteOperations |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1951 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1952 private: |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1953 bool found_; |
4694
da1edb7d6332
"/tools/bulk-delete" to delete a group of multiple, unrelated resources at once
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4640
diff
changeset
|
1954 Json::Value& remainingAncestor_; |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1955 const std::string& uuid_; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1956 ResourceType expectedType_; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1957 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1958 public: |
4694
da1edb7d6332
"/tools/bulk-delete" to delete a group of multiple, unrelated resources at once
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4640
diff
changeset
|
1959 Operations(Json::Value& remainingAncestor, |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1960 const std::string& uuid, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1961 ResourceType expectedType) : |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1962 found_(false), |
4694
da1edb7d6332
"/tools/bulk-delete" to delete a group of multiple, unrelated resources at once
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4640
diff
changeset
|
1963 remainingAncestor_(remainingAncestor), |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1964 uuid_(uuid), |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1965 expectedType_(expectedType) |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1966 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1967 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1968 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1969 bool IsFound() const |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1970 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1971 return found_; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1972 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1973 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1974 virtual void Apply(ReadWriteTransaction& transaction) ORTHANC_OVERRIDE |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1975 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1976 int64_t id; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1977 ResourceType type; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1978 if (!transaction.LookupResource(id, type, uuid_) || |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1979 expectedType_ != type) |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1980 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1981 found_ = false; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1982 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1983 else |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1984 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1985 found_ = true; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1986 transaction.DeleteResource(id); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1987 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1988 std::string remainingPublicId; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1989 ResourceType remainingLevel; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1990 if (transaction.GetTransactionContext().LookupRemainingLevel(remainingPublicId, remainingLevel)) |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1991 { |
4694
da1edb7d6332
"/tools/bulk-delete" to delete a group of multiple, unrelated resources at once
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4640
diff
changeset
|
1992 remainingAncestor_["RemainingAncestor"] = Json::Value(Json::objectValue); |
da1edb7d6332
"/tools/bulk-delete" to delete a group of multiple, unrelated resources at once
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4640
diff
changeset
|
1993 remainingAncestor_["RemainingAncestor"]["Path"] = GetBasePath(remainingLevel, remainingPublicId); |
da1edb7d6332
"/tools/bulk-delete" to delete a group of multiple, unrelated resources at once
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4640
diff
changeset
|
1994 remainingAncestor_["RemainingAncestor"]["Type"] = EnumerationToString(remainingLevel); |
da1edb7d6332
"/tools/bulk-delete" to delete a group of multiple, unrelated resources at once
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4640
diff
changeset
|
1995 remainingAncestor_["RemainingAncestor"]["ID"] = remainingPublicId; |
5297
c78138dc3889
When deleting a resource, its parents LastUpdate metadata is now updated
Alain Mazy <am@osimis.io>
parents:
5296
diff
changeset
|
1996 |
c78138dc3889
When deleting a resource, its parents LastUpdate metadata is now updated
Alain Mazy <am@osimis.io>
parents:
5296
diff
changeset
|
1997 { // update the LastUpdate metadata of all parents |
c78138dc3889
When deleting a resource, its parents LastUpdate metadata is now updated
Alain Mazy <am@osimis.io>
parents:
5296
diff
changeset
|
1998 std::string now = SystemToolbox::GetNowIsoString(true /* use UTC time (not local time) */); |
c78138dc3889
When deleting a resource, its parents LastUpdate metadata is now updated
Alain Mazy <am@osimis.io>
parents:
5296
diff
changeset
|
1999 ResourcesContent content(true); |
c78138dc3889
When deleting a resource, its parents LastUpdate metadata is now updated
Alain Mazy <am@osimis.io>
parents:
5296
diff
changeset
|
2000 |
c78138dc3889
When deleting a resource, its parents LastUpdate metadata is now updated
Alain Mazy <am@osimis.io>
parents:
5296
diff
changeset
|
2001 int64_t parentId = 0; |
c78138dc3889
When deleting a resource, its parents LastUpdate metadata is now updated
Alain Mazy <am@osimis.io>
parents:
5296
diff
changeset
|
2002 if (transaction.LookupResource(parentId, remainingLevel, remainingPublicId)) |
c78138dc3889
When deleting a resource, its parents LastUpdate metadata is now updated
Alain Mazy <am@osimis.io>
parents:
5296
diff
changeset
|
2003 { |
c78138dc3889
When deleting a resource, its parents LastUpdate metadata is now updated
Alain Mazy <am@osimis.io>
parents:
5296
diff
changeset
|
2004 |
c78138dc3889
When deleting a resource, its parents LastUpdate metadata is now updated
Alain Mazy <am@osimis.io>
parents:
5296
diff
changeset
|
2005 do |
c78138dc3889
When deleting a resource, its parents LastUpdate metadata is now updated
Alain Mazy <am@osimis.io>
parents:
5296
diff
changeset
|
2006 { |
c78138dc3889
When deleting a resource, its parents LastUpdate metadata is now updated
Alain Mazy <am@osimis.io>
parents:
5296
diff
changeset
|
2007 content.AddMetadata(parentId, MetadataType_LastUpdate, now); |
c78138dc3889
When deleting a resource, its parents LastUpdate metadata is now updated
Alain Mazy <am@osimis.io>
parents:
5296
diff
changeset
|
2008 } |
c78138dc3889
When deleting a resource, its parents LastUpdate metadata is now updated
Alain Mazy <am@osimis.io>
parents:
5296
diff
changeset
|
2009 while (transaction.LookupParent(parentId, parentId)); |
c78138dc3889
When deleting a resource, its parents LastUpdate metadata is now updated
Alain Mazy <am@osimis.io>
parents:
5296
diff
changeset
|
2010 |
c78138dc3889
When deleting a resource, its parents LastUpdate metadata is now updated
Alain Mazy <am@osimis.io>
parents:
5296
diff
changeset
|
2011 transaction.SetResourcesContent(content); |
c78138dc3889
When deleting a resource, its parents LastUpdate metadata is now updated
Alain Mazy <am@osimis.io>
parents:
5296
diff
changeset
|
2012 } |
c78138dc3889
When deleting a resource, its parents LastUpdate metadata is now updated
Alain Mazy <am@osimis.io>
parents:
5296
diff
changeset
|
2013 } |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2014 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2015 else |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2016 { |
4694
da1edb7d6332
"/tools/bulk-delete" to delete a group of multiple, unrelated resources at once
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4640
diff
changeset
|
2017 remainingAncestor_["RemainingAncestor"] = Json::nullValue; |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2018 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2019 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2020 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2021 }; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2022 |
4694
da1edb7d6332
"/tools/bulk-delete" to delete a group of multiple, unrelated resources at once
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4640
diff
changeset
|
2023 Operations operations(remainingAncestor, uuid, expectedType); |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2024 Apply(operations); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2025 return operations.IsFound(); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2026 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2027 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2028 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2029 void StatelessDatabaseOperations::LogExportedResource(const std::string& publicId, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2030 const std::string& remoteModality) |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2031 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2032 class Operations : public IReadWriteOperations |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2033 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2034 private: |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2035 const std::string& publicId_; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2036 const std::string& remoteModality_; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2037 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2038 public: |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2039 Operations(const std::string& publicId, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2040 const std::string& remoteModality) : |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2041 publicId_(publicId), |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2042 remoteModality_(remoteModality) |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2043 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2044 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2045 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2046 virtual void Apply(ReadWriteTransaction& transaction) ORTHANC_OVERRIDE |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2047 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2048 int64_t id; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2049 ResourceType type; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2050 if (!transaction.LookupResource(id, type, publicId_)) |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2051 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2052 throw OrthancException(ErrorCode_InexistentItem); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2053 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2054 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2055 std::string patientId; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2056 std::string studyInstanceUid; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2057 std::string seriesInstanceUid; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2058 std::string sopInstanceUid; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2059 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2060 int64_t currentId = id; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2061 ResourceType currentType = type; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2062 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2063 // Iteratively go up inside the patient/study/series/instance hierarchy |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2064 bool done = false; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2065 while (!done) |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2066 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2067 DicomMap map; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2068 transaction.GetMainDicomTags(map, currentId); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2069 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2070 switch (currentType) |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2071 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2072 case ResourceType_Patient: |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2073 if (map.HasTag(DICOM_TAG_PATIENT_ID)) |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2074 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2075 patientId = map.GetValue(DICOM_TAG_PATIENT_ID).GetContent(); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2076 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2077 done = true; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2078 break; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2079 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2080 case ResourceType_Study: |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2081 if (map.HasTag(DICOM_TAG_STUDY_INSTANCE_UID)) |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2082 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2083 studyInstanceUid = map.GetValue(DICOM_TAG_STUDY_INSTANCE_UID).GetContent(); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2084 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2085 currentType = ResourceType_Patient; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2086 break; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2087 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2088 case ResourceType_Series: |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2089 if (map.HasTag(DICOM_TAG_SERIES_INSTANCE_UID)) |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2090 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2091 seriesInstanceUid = map.GetValue(DICOM_TAG_SERIES_INSTANCE_UID).GetContent(); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2092 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2093 currentType = ResourceType_Study; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2094 break; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2095 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2096 case ResourceType_Instance: |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2097 if (map.HasTag(DICOM_TAG_SOP_INSTANCE_UID)) |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2098 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2099 sopInstanceUid = map.GetValue(DICOM_TAG_SOP_INSTANCE_UID).GetContent(); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2100 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2101 currentType = ResourceType_Series; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2102 break; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2103 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2104 default: |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2105 throw OrthancException(ErrorCode_InternalError); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2106 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2107 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2108 // If we have not reached the Patient level, find the parent of |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2109 // the current resource |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2110 if (!done) |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2111 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2112 bool ok = transaction.LookupParent(currentId, currentId); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2113 (void) ok; // Remove warning about unused variable in release builds |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2114 assert(ok); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2115 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2116 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2117 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2118 ExportedResource resource(-1, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2119 type, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2120 publicId_, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2121 remoteModality_, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2122 SystemToolbox::GetNowIsoString(true /* use UTC time (not local time) */), |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2123 patientId, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2124 studyInstanceUid, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2125 seriesInstanceUid, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2126 sopInstanceUid); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2127 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2128 transaction.LogExportedResource(resource); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2129 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2130 }; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2131 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2132 Operations operations(publicId, remoteModality); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2133 Apply(operations); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2134 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2135 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2136 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2137 void StatelessDatabaseOperations::SetProtectedPatient(const std::string& publicId, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2138 bool isProtected) |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2139 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2140 class Operations : public IReadWriteOperations |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2141 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2142 private: |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2143 const std::string& publicId_; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2144 bool isProtected_; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2145 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2146 public: |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2147 Operations(const std::string& publicId, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2148 bool isProtected) : |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2149 publicId_(publicId), |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2150 isProtected_(isProtected) |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2151 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2152 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2153 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2154 virtual void Apply(ReadWriteTransaction& transaction) ORTHANC_OVERRIDE |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2155 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2156 // Lookup for the requested resource |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2157 int64_t id; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2158 ResourceType type; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2159 if (!transaction.LookupResource(id, type, publicId_) || |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2160 type != ResourceType_Patient) |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2161 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2162 throw OrthancException(ErrorCode_ParameterOutOfRange); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2163 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2164 else |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2165 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2166 transaction.SetProtectedPatient(id, isProtected_); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2167 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2168 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2169 }; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2170 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2171 Operations operations(publicId, isProtected); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2172 Apply(operations); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2173 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2174 if (isProtected) |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2175 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2176 LOG(INFO) << "Patient " << publicId << " has been protected"; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2177 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2178 else |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2179 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2180 LOG(INFO) << "Patient " << publicId << " has been unprotected"; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2181 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2182 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2183 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2184 |
4623
95ffe3b6ef7c
handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4619
diff
changeset
|
2185 void StatelessDatabaseOperations::SetMetadata(int64_t& newRevision, |
95ffe3b6ef7c
handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4619
diff
changeset
|
2186 const std::string& publicId, |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2187 MetadataType type, |
4623
95ffe3b6ef7c
handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4619
diff
changeset
|
2188 const std::string& value, |
95ffe3b6ef7c
handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4619
diff
changeset
|
2189 bool hasOldRevision, |
4640
66109d24d26e
"ETag" headers for metadata and attachments now allow strong comparison (MD5 is included)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4633
diff
changeset
|
2190 int64_t oldRevision, |
66109d24d26e
"ETag" headers for metadata and attachments now allow strong comparison (MD5 is included)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4633
diff
changeset
|
2191 const std::string& oldMD5) |
4623
95ffe3b6ef7c
handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4619
diff
changeset
|
2192 { |
95ffe3b6ef7c
handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4619
diff
changeset
|
2193 class Operations : public IReadWriteOperations |
95ffe3b6ef7c
handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4619
diff
changeset
|
2194 { |
95ffe3b6ef7c
handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4619
diff
changeset
|
2195 private: |
95ffe3b6ef7c
handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4619
diff
changeset
|
2196 int64_t& newRevision_; |
95ffe3b6ef7c
handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4619
diff
changeset
|
2197 const std::string& publicId_; |
95ffe3b6ef7c
handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4619
diff
changeset
|
2198 MetadataType type_; |
95ffe3b6ef7c
handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4619
diff
changeset
|
2199 const std::string& value_; |
95ffe3b6ef7c
handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4619
diff
changeset
|
2200 bool hasOldRevision_; |
95ffe3b6ef7c
handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4619
diff
changeset
|
2201 int64_t oldRevision_; |
4640
66109d24d26e
"ETag" headers for metadata and attachments now allow strong comparison (MD5 is included)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4633
diff
changeset
|
2202 const std::string& oldMD5_; |
4623
95ffe3b6ef7c
handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4619
diff
changeset
|
2203 |
95ffe3b6ef7c
handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4619
diff
changeset
|
2204 public: |
95ffe3b6ef7c
handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4619
diff
changeset
|
2205 Operations(int64_t& newRevision, |
95ffe3b6ef7c
handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4619
diff
changeset
|
2206 const std::string& publicId, |
95ffe3b6ef7c
handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4619
diff
changeset
|
2207 MetadataType type, |
95ffe3b6ef7c
handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4619
diff
changeset
|
2208 const std::string& value, |
95ffe3b6ef7c
handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4619
diff
changeset
|
2209 bool hasOldRevision, |
4640
66109d24d26e
"ETag" headers for metadata and attachments now allow strong comparison (MD5 is included)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4633
diff
changeset
|
2210 int64_t oldRevision, |
66109d24d26e
"ETag" headers for metadata and attachments now allow strong comparison (MD5 is included)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4633
diff
changeset
|
2211 const std::string& oldMD5) : |
4623
95ffe3b6ef7c
handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4619
diff
changeset
|
2212 newRevision_(newRevision), |
95ffe3b6ef7c
handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4619
diff
changeset
|
2213 publicId_(publicId), |
95ffe3b6ef7c
handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4619
diff
changeset
|
2214 type_(type), |
95ffe3b6ef7c
handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4619
diff
changeset
|
2215 value_(value), |
95ffe3b6ef7c
handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4619
diff
changeset
|
2216 hasOldRevision_(hasOldRevision), |
4640
66109d24d26e
"ETag" headers for metadata and attachments now allow strong comparison (MD5 is included)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4633
diff
changeset
|
2217 oldRevision_(oldRevision), |
66109d24d26e
"ETag" headers for metadata and attachments now allow strong comparison (MD5 is included)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4633
diff
changeset
|
2218 oldMD5_(oldMD5) |
4623
95ffe3b6ef7c
handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4619
diff
changeset
|
2219 { |
95ffe3b6ef7c
handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4619
diff
changeset
|
2220 } |
95ffe3b6ef7c
handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4619
diff
changeset
|
2221 |
95ffe3b6ef7c
handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4619
diff
changeset
|
2222 virtual void Apply(ReadWriteTransaction& transaction) ORTHANC_OVERRIDE |
95ffe3b6ef7c
handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4619
diff
changeset
|
2223 { |
95ffe3b6ef7c
handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4619
diff
changeset
|
2224 ResourceType resourceType; |
95ffe3b6ef7c
handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4619
diff
changeset
|
2225 int64_t id; |
95ffe3b6ef7c
handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4619
diff
changeset
|
2226 if (!transaction.LookupResource(id, resourceType, publicId_)) |
95ffe3b6ef7c
handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4619
diff
changeset
|
2227 { |
95ffe3b6ef7c
handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4619
diff
changeset
|
2228 throw OrthancException(ErrorCode_UnknownResource); |
95ffe3b6ef7c
handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4619
diff
changeset
|
2229 } |
95ffe3b6ef7c
handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4619
diff
changeset
|
2230 else |
95ffe3b6ef7c
handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4619
diff
changeset
|
2231 { |
95ffe3b6ef7c
handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4619
diff
changeset
|
2232 std::string oldValue; |
95ffe3b6ef7c
handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4619
diff
changeset
|
2233 int64_t expectedRevision; |
95ffe3b6ef7c
handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4619
diff
changeset
|
2234 if (transaction.LookupMetadata(oldValue, expectedRevision, id, type_)) |
95ffe3b6ef7c
handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4619
diff
changeset
|
2235 { |
4640
66109d24d26e
"ETag" headers for metadata and attachments now allow strong comparison (MD5 is included)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4633
diff
changeset
|
2236 if (hasOldRevision_) |
4623
95ffe3b6ef7c
handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4619
diff
changeset
|
2237 { |
4640
66109d24d26e
"ETag" headers for metadata and attachments now allow strong comparison (MD5 is included)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4633
diff
changeset
|
2238 std::string expectedMD5; |
66109d24d26e
"ETag" headers for metadata and attachments now allow strong comparison (MD5 is included)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4633
diff
changeset
|
2239 Toolbox::ComputeMD5(expectedMD5, oldValue); |
66109d24d26e
"ETag" headers for metadata and attachments now allow strong comparison (MD5 is included)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4633
diff
changeset
|
2240 |
66109d24d26e
"ETag" headers for metadata and attachments now allow strong comparison (MD5 is included)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4633
diff
changeset
|
2241 if (expectedRevision != oldRevision_ || |
66109d24d26e
"ETag" headers for metadata and attachments now allow strong comparison (MD5 is included)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4633
diff
changeset
|
2242 expectedMD5 != oldMD5_) |
66109d24d26e
"ETag" headers for metadata and attachments now allow strong comparison (MD5 is included)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4633
diff
changeset
|
2243 { |
66109d24d26e
"ETag" headers for metadata and attachments now allow strong comparison (MD5 is included)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4633
diff
changeset
|
2244 throw OrthancException(ErrorCode_Revision); |
66109d24d26e
"ETag" headers for metadata and attachments now allow strong comparison (MD5 is included)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4633
diff
changeset
|
2245 } |
4623
95ffe3b6ef7c
handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4619
diff
changeset
|
2246 } |
4640
66109d24d26e
"ETag" headers for metadata and attachments now allow strong comparison (MD5 is included)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4633
diff
changeset
|
2247 |
66109d24d26e
"ETag" headers for metadata and attachments now allow strong comparison (MD5 is included)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4633
diff
changeset
|
2248 newRevision_ = expectedRevision + 1; |
4623
95ffe3b6ef7c
handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4619
diff
changeset
|
2249 } |
95ffe3b6ef7c
handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4619
diff
changeset
|
2250 else |
95ffe3b6ef7c
handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4619
diff
changeset
|
2251 { |
95ffe3b6ef7c
handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4619
diff
changeset
|
2252 // The metadata is not existing yet: Ignore "oldRevision" |
95ffe3b6ef7c
handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4619
diff
changeset
|
2253 // and initialize a new sequence of revisions |
95ffe3b6ef7c
handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4619
diff
changeset
|
2254 newRevision_ = 0; |
95ffe3b6ef7c
handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4619
diff
changeset
|
2255 } |
95ffe3b6ef7c
handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4619
diff
changeset
|
2256 |
95ffe3b6ef7c
handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4619
diff
changeset
|
2257 transaction.SetMetadata(id, type_, value_, newRevision_); |
95ffe3b6ef7c
handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4619
diff
changeset
|
2258 |
95ffe3b6ef7c
handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4619
diff
changeset
|
2259 if (IsUserMetadata(type_)) |
95ffe3b6ef7c
handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4619
diff
changeset
|
2260 { |
95ffe3b6ef7c
handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4619
diff
changeset
|
2261 transaction.LogChange(id, ChangeType_UpdatedMetadata, resourceType, publicId_); |
95ffe3b6ef7c
handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4619
diff
changeset
|
2262 } |
95ffe3b6ef7c
handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4619
diff
changeset
|
2263 } |
95ffe3b6ef7c
handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4619
diff
changeset
|
2264 } |
95ffe3b6ef7c
handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4619
diff
changeset
|
2265 }; |
95ffe3b6ef7c
handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4619
diff
changeset
|
2266 |
4640
66109d24d26e
"ETag" headers for metadata and attachments now allow strong comparison (MD5 is included)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4633
diff
changeset
|
2267 Operations operations(newRevision, publicId, type, value, hasOldRevision, oldRevision, oldMD5); |
4623
95ffe3b6ef7c
handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4619
diff
changeset
|
2268 Apply(operations); |
95ffe3b6ef7c
handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4619
diff
changeset
|
2269 } |
95ffe3b6ef7c
handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4619
diff
changeset
|
2270 |
95ffe3b6ef7c
handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4619
diff
changeset
|
2271 |
95ffe3b6ef7c
handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4619
diff
changeset
|
2272 void StatelessDatabaseOperations::OverwriteMetadata(const std::string& publicId, |
95ffe3b6ef7c
handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4619
diff
changeset
|
2273 MetadataType type, |
95ffe3b6ef7c
handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4619
diff
changeset
|
2274 const std::string& value) |
95ffe3b6ef7c
handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4619
diff
changeset
|
2275 { |
95ffe3b6ef7c
handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4619
diff
changeset
|
2276 int64_t newRevision; // Unused |
4640
66109d24d26e
"ETag" headers for metadata and attachments now allow strong comparison (MD5 is included)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4633
diff
changeset
|
2277 SetMetadata(newRevision, publicId, type, value, false /* no old revision */, -1 /* dummy */, "" /* dummy */); |
4623
95ffe3b6ef7c
handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4619
diff
changeset
|
2278 } |
95ffe3b6ef7c
handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4619
diff
changeset
|
2279 |
95ffe3b6ef7c
handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4619
diff
changeset
|
2280 |
95ffe3b6ef7c
handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4619
diff
changeset
|
2281 bool StatelessDatabaseOperations::DeleteMetadata(const std::string& publicId, |
95ffe3b6ef7c
handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4619
diff
changeset
|
2282 MetadataType type, |
95ffe3b6ef7c
handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4619
diff
changeset
|
2283 bool hasRevision, |
4640
66109d24d26e
"ETag" headers for metadata and attachments now allow strong comparison (MD5 is included)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4633
diff
changeset
|
2284 int64_t revision, |
66109d24d26e
"ETag" headers for metadata and attachments now allow strong comparison (MD5 is included)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4633
diff
changeset
|
2285 const std::string& md5) |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2286 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2287 class Operations : public IReadWriteOperations |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2288 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2289 private: |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2290 const std::string& publicId_; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2291 MetadataType type_; |
4623
95ffe3b6ef7c
handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4619
diff
changeset
|
2292 bool hasRevision_; |
95ffe3b6ef7c
handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4619
diff
changeset
|
2293 int64_t revision_; |
4640
66109d24d26e
"ETag" headers for metadata and attachments now allow strong comparison (MD5 is included)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4633
diff
changeset
|
2294 const std::string& md5_; |
4623
95ffe3b6ef7c
handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4619
diff
changeset
|
2295 bool found_; |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2296 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2297 public: |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2298 Operations(const std::string& publicId, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2299 MetadataType type, |
4623
95ffe3b6ef7c
handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4619
diff
changeset
|
2300 bool hasRevision, |
4640
66109d24d26e
"ETag" headers for metadata and attachments now allow strong comparison (MD5 is included)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4633
diff
changeset
|
2301 int64_t revision, |
66109d24d26e
"ETag" headers for metadata and attachments now allow strong comparison (MD5 is included)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4633
diff
changeset
|
2302 const std::string& md5) : |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2303 publicId_(publicId), |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2304 type_(type), |
4623
95ffe3b6ef7c
handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4619
diff
changeset
|
2305 hasRevision_(hasRevision), |
95ffe3b6ef7c
handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4619
diff
changeset
|
2306 revision_(revision), |
4640
66109d24d26e
"ETag" headers for metadata and attachments now allow strong comparison (MD5 is included)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4633
diff
changeset
|
2307 md5_(md5), |
4623
95ffe3b6ef7c
handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4619
diff
changeset
|
2308 found_(false) |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2309 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2310 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2311 |
4623
95ffe3b6ef7c
handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4619
diff
changeset
|
2312 bool HasFound() const |
95ffe3b6ef7c
handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4619
diff
changeset
|
2313 { |
95ffe3b6ef7c
handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4619
diff
changeset
|
2314 return found_; |
95ffe3b6ef7c
handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4619
diff
changeset
|
2315 } |
95ffe3b6ef7c
handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4619
diff
changeset
|
2316 |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2317 virtual void Apply(ReadWriteTransaction& transaction) ORTHANC_OVERRIDE |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2318 { |
4623
95ffe3b6ef7c
handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4619
diff
changeset
|
2319 ResourceType resourceType; |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2320 int64_t id; |
4623
95ffe3b6ef7c
handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4619
diff
changeset
|
2321 if (!transaction.LookupResource(id, resourceType, publicId_)) |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2322 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2323 throw OrthancException(ErrorCode_UnknownResource); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2324 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2325 else |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2326 { |
4640
66109d24d26e
"ETag" headers for metadata and attachments now allow strong comparison (MD5 is included)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4633
diff
changeset
|
2327 std::string value; |
4623
95ffe3b6ef7c
handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4619
diff
changeset
|
2328 int64_t expectedRevision; |
4640
66109d24d26e
"ETag" headers for metadata and attachments now allow strong comparison (MD5 is included)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4633
diff
changeset
|
2329 if (transaction.LookupMetadata(value, expectedRevision, id, type_)) |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2330 { |
4640
66109d24d26e
"ETag" headers for metadata and attachments now allow strong comparison (MD5 is included)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4633
diff
changeset
|
2331 if (hasRevision_) |
4623
95ffe3b6ef7c
handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4619
diff
changeset
|
2332 { |
4640
66109d24d26e
"ETag" headers for metadata and attachments now allow strong comparison (MD5 is included)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4633
diff
changeset
|
2333 std::string expectedMD5; |
66109d24d26e
"ETag" headers for metadata and attachments now allow strong comparison (MD5 is included)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4633
diff
changeset
|
2334 Toolbox::ComputeMD5(expectedMD5, value); |
66109d24d26e
"ETag" headers for metadata and attachments now allow strong comparison (MD5 is included)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4633
diff
changeset
|
2335 |
66109d24d26e
"ETag" headers for metadata and attachments now allow strong comparison (MD5 is included)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4633
diff
changeset
|
2336 if (expectedRevision != revision_ || |
66109d24d26e
"ETag" headers for metadata and attachments now allow strong comparison (MD5 is included)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4633
diff
changeset
|
2337 expectedMD5 != md5_) |
66109d24d26e
"ETag" headers for metadata and attachments now allow strong comparison (MD5 is included)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4633
diff
changeset
|
2338 { |
66109d24d26e
"ETag" headers for metadata and attachments now allow strong comparison (MD5 is included)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4633
diff
changeset
|
2339 throw OrthancException(ErrorCode_Revision); |
66109d24d26e
"ETag" headers for metadata and attachments now allow strong comparison (MD5 is included)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4633
diff
changeset
|
2340 } |
4623
95ffe3b6ef7c
handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4619
diff
changeset
|
2341 } |
95ffe3b6ef7c
handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4619
diff
changeset
|
2342 |
95ffe3b6ef7c
handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4619
diff
changeset
|
2343 found_ = true; |
95ffe3b6ef7c
handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4619
diff
changeset
|
2344 transaction.DeleteMetadata(id, type_); |
4640
66109d24d26e
"ETag" headers for metadata and attachments now allow strong comparison (MD5 is included)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4633
diff
changeset
|
2345 |
4623
95ffe3b6ef7c
handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4619
diff
changeset
|
2346 if (IsUserMetadata(type_)) |
95ffe3b6ef7c
handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4619
diff
changeset
|
2347 { |
95ffe3b6ef7c
handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4619
diff
changeset
|
2348 transaction.LogChange(id, ChangeType_UpdatedMetadata, resourceType, publicId_); |
95ffe3b6ef7c
handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4619
diff
changeset
|
2349 } |
95ffe3b6ef7c
handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4619
diff
changeset
|
2350 } |
95ffe3b6ef7c
handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4619
diff
changeset
|
2351 else |
95ffe3b6ef7c
handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4619
diff
changeset
|
2352 { |
95ffe3b6ef7c
handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4619
diff
changeset
|
2353 found_ = false; |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2354 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2355 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2356 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2357 }; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2358 |
4640
66109d24d26e
"ETag" headers for metadata and attachments now allow strong comparison (MD5 is included)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4633
diff
changeset
|
2359 Operations operations(publicId, type, hasRevision, revision, md5); |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2360 Apply(operations); |
4623
95ffe3b6ef7c
handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4619
diff
changeset
|
2361 return operations.HasFound(); |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2362 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2363 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2364 |
4607
f75c63aa9de0
differentiating between shared and private global properties
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4602
diff
changeset
|
2365 uint64_t StatelessDatabaseOperations::IncrementGlobalSequence(GlobalProperty sequence, |
f75c63aa9de0
differentiating between shared and private global properties
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4602
diff
changeset
|
2366 bool shared) |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2367 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2368 class Operations : public IReadWriteOperations |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2369 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2370 private: |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2371 uint64_t newValue_; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2372 GlobalProperty sequence_; |
4607
f75c63aa9de0
differentiating between shared and private global properties
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4602
diff
changeset
|
2373 bool shared_; |
5522
dd430a1b21fe
simplifying StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5497
diff
changeset
|
2374 bool hasAtomicIncrementGlobalProperty_; |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2375 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2376 public: |
4607
f75c63aa9de0
differentiating between shared and private global properties
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4602
diff
changeset
|
2377 Operations(GlobalProperty sequence, |
5522
dd430a1b21fe
simplifying StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5497
diff
changeset
|
2378 bool shared, |
dd430a1b21fe
simplifying StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5497
diff
changeset
|
2379 bool hasAtomicIncrementGlobalProperty) : |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2380 newValue_(0), // Dummy initialization |
4607
f75c63aa9de0
differentiating between shared and private global properties
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4602
diff
changeset
|
2381 sequence_(sequence), |
5522
dd430a1b21fe
simplifying StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5497
diff
changeset
|
2382 shared_(shared), |
dd430a1b21fe
simplifying StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5497
diff
changeset
|
2383 hasAtomicIncrementGlobalProperty_(hasAtomicIncrementGlobalProperty) |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2384 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2385 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2386 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2387 uint64_t GetNewValue() const |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2388 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2389 return newValue_; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2390 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2391 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2392 virtual void Apply(ReadWriteTransaction& transaction) ORTHANC_OVERRIDE |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2393 { |
5522
dd430a1b21fe
simplifying StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5497
diff
changeset
|
2394 if (hasAtomicIncrementGlobalProperty_) |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2395 { |
5455
176bc05f85f4
DB: new Capabilities class to manage future new methods from DB plugins + Added IncrementGlobalProperty
Alain Mazy <am@osimis.io>
parents:
5324
diff
changeset
|
2396 newValue_ = static_cast<uint64_t>(transaction.IncrementGlobalProperty(sequence_, shared_, 1)); |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2397 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2398 else |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2399 { |
5455
176bc05f85f4
DB: new Capabilities class to manage future new methods from DB plugins + Added IncrementGlobalProperty
Alain Mazy <am@osimis.io>
parents:
5324
diff
changeset
|
2400 std::string oldString; |
176bc05f85f4
DB: new Capabilities class to manage future new methods from DB plugins + Added IncrementGlobalProperty
Alain Mazy <am@osimis.io>
parents:
5324
diff
changeset
|
2401 |
176bc05f85f4
DB: new Capabilities class to manage future new methods from DB plugins + Added IncrementGlobalProperty
Alain Mazy <am@osimis.io>
parents:
5324
diff
changeset
|
2402 if (transaction.LookupGlobalProperty(oldString, sequence_, shared_)) |
176bc05f85f4
DB: new Capabilities class to manage future new methods from DB plugins + Added IncrementGlobalProperty
Alain Mazy <am@osimis.io>
parents:
5324
diff
changeset
|
2403 { |
176bc05f85f4
DB: new Capabilities class to manage future new methods from DB plugins + Added IncrementGlobalProperty
Alain Mazy <am@osimis.io>
parents:
5324
diff
changeset
|
2404 uint64_t oldValue; |
176bc05f85f4
DB: new Capabilities class to manage future new methods from DB plugins + Added IncrementGlobalProperty
Alain Mazy <am@osimis.io>
parents:
5324
diff
changeset
|
2405 |
176bc05f85f4
DB: new Capabilities class to manage future new methods from DB plugins + Added IncrementGlobalProperty
Alain Mazy <am@osimis.io>
parents:
5324
diff
changeset
|
2406 try |
176bc05f85f4
DB: new Capabilities class to manage future new methods from DB plugins + Added IncrementGlobalProperty
Alain Mazy <am@osimis.io>
parents:
5324
diff
changeset
|
2407 { |
176bc05f85f4
DB: new Capabilities class to manage future new methods from DB plugins + Added IncrementGlobalProperty
Alain Mazy <am@osimis.io>
parents:
5324
diff
changeset
|
2408 oldValue = boost::lexical_cast<uint64_t>(oldString); |
176bc05f85f4
DB: new Capabilities class to manage future new methods from DB plugins + Added IncrementGlobalProperty
Alain Mazy <am@osimis.io>
parents:
5324
diff
changeset
|
2409 } |
176bc05f85f4
DB: new Capabilities class to manage future new methods from DB plugins + Added IncrementGlobalProperty
Alain Mazy <am@osimis.io>
parents:
5324
diff
changeset
|
2410 catch (boost::bad_lexical_cast&) |
176bc05f85f4
DB: new Capabilities class to manage future new methods from DB plugins + Added IncrementGlobalProperty
Alain Mazy <am@osimis.io>
parents:
5324
diff
changeset
|
2411 { |
176bc05f85f4
DB: new Capabilities class to manage future new methods from DB plugins + Added IncrementGlobalProperty
Alain Mazy <am@osimis.io>
parents:
5324
diff
changeset
|
2412 LOG(ERROR) << "Cannot read the global sequence " |
5595
a87f2a56257d
implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5593
diff
changeset
|
2413 << boost::lexical_cast<std::string>(sequence_) << ", resetting it"; |
5455
176bc05f85f4
DB: new Capabilities class to manage future new methods from DB plugins + Added IncrementGlobalProperty
Alain Mazy <am@osimis.io>
parents:
5324
diff
changeset
|
2414 oldValue = 0; |
176bc05f85f4
DB: new Capabilities class to manage future new methods from DB plugins + Added IncrementGlobalProperty
Alain Mazy <am@osimis.io>
parents:
5324
diff
changeset
|
2415 } |
176bc05f85f4
DB: new Capabilities class to manage future new methods from DB plugins + Added IncrementGlobalProperty
Alain Mazy <am@osimis.io>
parents:
5324
diff
changeset
|
2416 |
176bc05f85f4
DB: new Capabilities class to manage future new methods from DB plugins + Added IncrementGlobalProperty
Alain Mazy <am@osimis.io>
parents:
5324
diff
changeset
|
2417 newValue_ = oldValue + 1; |
176bc05f85f4
DB: new Capabilities class to manage future new methods from DB plugins + Added IncrementGlobalProperty
Alain Mazy <am@osimis.io>
parents:
5324
diff
changeset
|
2418 } |
176bc05f85f4
DB: new Capabilities class to manage future new methods from DB plugins + Added IncrementGlobalProperty
Alain Mazy <am@osimis.io>
parents:
5324
diff
changeset
|
2419 else |
176bc05f85f4
DB: new Capabilities class to manage future new methods from DB plugins + Added IncrementGlobalProperty
Alain Mazy <am@osimis.io>
parents:
5324
diff
changeset
|
2420 { |
176bc05f85f4
DB: new Capabilities class to manage future new methods from DB plugins + Added IncrementGlobalProperty
Alain Mazy <am@osimis.io>
parents:
5324
diff
changeset
|
2421 // Initialize the sequence at "1" |
176bc05f85f4
DB: new Capabilities class to manage future new methods from DB plugins + Added IncrementGlobalProperty
Alain Mazy <am@osimis.io>
parents:
5324
diff
changeset
|
2422 newValue_ = 1; |
176bc05f85f4
DB: new Capabilities class to manage future new methods from DB plugins + Added IncrementGlobalProperty
Alain Mazy <am@osimis.io>
parents:
5324
diff
changeset
|
2423 } |
176bc05f85f4
DB: new Capabilities class to manage future new methods from DB plugins + Added IncrementGlobalProperty
Alain Mazy <am@osimis.io>
parents:
5324
diff
changeset
|
2424 |
176bc05f85f4
DB: new Capabilities class to manage future new methods from DB plugins + Added IncrementGlobalProperty
Alain Mazy <am@osimis.io>
parents:
5324
diff
changeset
|
2425 transaction.SetGlobalProperty(sequence_, shared_, boost::lexical_cast<std::string>(newValue_)); |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2426 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2427 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2428 }; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2429 |
5522
dd430a1b21fe
simplifying StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5497
diff
changeset
|
2430 Operations operations(sequence, shared, GetDatabaseCapabilities().HasAtomicIncrementGlobalProperty()); |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2431 Apply(operations); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2432 assert(operations.GetNewValue() != 0); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2433 return operations.GetNewValue(); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2434 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2435 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2436 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2437 void StatelessDatabaseOperations::DeleteChanges() |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2438 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2439 class Operations : public IReadWriteOperations |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2440 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2441 public: |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2442 virtual void Apply(ReadWriteTransaction& transaction) ORTHANC_OVERRIDE |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2443 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2444 transaction.ClearChanges(); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2445 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2446 }; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2447 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2448 Operations operations; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2449 Apply(operations); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2450 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2451 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2452 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2453 void StatelessDatabaseOperations::DeleteExportedResources() |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2454 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2455 class Operations : public IReadWriteOperations |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2456 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2457 public: |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2458 virtual void Apply(ReadWriteTransaction& transaction) ORTHANC_OVERRIDE |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2459 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2460 transaction.ClearExportedResources(); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2461 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2462 }; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2463 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2464 Operations operations; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2465 Apply(operations); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2466 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2467 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2468 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2469 void StatelessDatabaseOperations::SetGlobalProperty(GlobalProperty property, |
4607
f75c63aa9de0
differentiating between shared and private global properties
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4602
diff
changeset
|
2470 bool shared, |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2471 const std::string& value) |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2472 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2473 class Operations : public IReadWriteOperations |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2474 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2475 private: |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2476 GlobalProperty property_; |
4607
f75c63aa9de0
differentiating between shared and private global properties
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4602
diff
changeset
|
2477 bool shared_; |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2478 const std::string& value_; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2479 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2480 public: |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2481 Operations(GlobalProperty property, |
4607
f75c63aa9de0
differentiating between shared and private global properties
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4602
diff
changeset
|
2482 bool shared, |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2483 const std::string& value) : |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2484 property_(property), |
4607
f75c63aa9de0
differentiating between shared and private global properties
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4602
diff
changeset
|
2485 shared_(shared), |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2486 value_(value) |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2487 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2488 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2489 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2490 virtual void Apply(ReadWriteTransaction& transaction) ORTHANC_OVERRIDE |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2491 { |
4607
f75c63aa9de0
differentiating between shared and private global properties
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4602
diff
changeset
|
2492 transaction.SetGlobalProperty(property_, shared_, value_); |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2493 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2494 }; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2495 |
4607
f75c63aa9de0
differentiating between shared and private global properties
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4602
diff
changeset
|
2496 Operations operations(property, shared, value); |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2497 Apply(operations); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2498 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2499 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2500 |
4627
f7d5372b59b3
handling revisions of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4623
diff
changeset
|
2501 bool StatelessDatabaseOperations::DeleteAttachment(const std::string& publicId, |
f7d5372b59b3
handling revisions of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4623
diff
changeset
|
2502 FileContentType type, |
f7d5372b59b3
handling revisions of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4623
diff
changeset
|
2503 bool hasRevision, |
4640
66109d24d26e
"ETag" headers for metadata and attachments now allow strong comparison (MD5 is included)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4633
diff
changeset
|
2504 int64_t revision, |
66109d24d26e
"ETag" headers for metadata and attachments now allow strong comparison (MD5 is included)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4633
diff
changeset
|
2505 const std::string& md5) |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2506 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2507 class Operations : public IReadWriteOperations |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2508 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2509 private: |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2510 const std::string& publicId_; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2511 FileContentType type_; |
4627
f7d5372b59b3
handling revisions of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4623
diff
changeset
|
2512 bool hasRevision_; |
f7d5372b59b3
handling revisions of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4623
diff
changeset
|
2513 int64_t revision_; |
4640
66109d24d26e
"ETag" headers for metadata and attachments now allow strong comparison (MD5 is included)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4633
diff
changeset
|
2514 const std::string& md5_; |
4627
f7d5372b59b3
handling revisions of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4623
diff
changeset
|
2515 bool found_; |
f7d5372b59b3
handling revisions of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4623
diff
changeset
|
2516 |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2517 public: |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2518 Operations(const std::string& publicId, |
4627
f7d5372b59b3
handling revisions of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4623
diff
changeset
|
2519 FileContentType type, |
f7d5372b59b3
handling revisions of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4623
diff
changeset
|
2520 bool hasRevision, |
4640
66109d24d26e
"ETag" headers for metadata and attachments now allow strong comparison (MD5 is included)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4633
diff
changeset
|
2521 int64_t revision, |
66109d24d26e
"ETag" headers for metadata and attachments now allow strong comparison (MD5 is included)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4633
diff
changeset
|
2522 const std::string& md5) : |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2523 publicId_(publicId), |
4627
f7d5372b59b3
handling revisions of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4623
diff
changeset
|
2524 type_(type), |
f7d5372b59b3
handling revisions of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4623
diff
changeset
|
2525 hasRevision_(hasRevision), |
f7d5372b59b3
handling revisions of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4623
diff
changeset
|
2526 revision_(revision), |
4640
66109d24d26e
"ETag" headers for metadata and attachments now allow strong comparison (MD5 is included)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4633
diff
changeset
|
2527 md5_(md5), |
4627
f7d5372b59b3
handling revisions of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4623
diff
changeset
|
2528 found_(false) |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2529 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2530 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2531 |
4627
f7d5372b59b3
handling revisions of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4623
diff
changeset
|
2532 bool HasFound() const |
f7d5372b59b3
handling revisions of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4623
diff
changeset
|
2533 { |
f7d5372b59b3
handling revisions of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4623
diff
changeset
|
2534 return found_; |
f7d5372b59b3
handling revisions of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4623
diff
changeset
|
2535 } |
f7d5372b59b3
handling revisions of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4623
diff
changeset
|
2536 |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2537 virtual void Apply(ReadWriteTransaction& transaction) ORTHANC_OVERRIDE |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2538 { |
4623
95ffe3b6ef7c
handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4619
diff
changeset
|
2539 ResourceType resourceType; |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2540 int64_t id; |
4623
95ffe3b6ef7c
handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4619
diff
changeset
|
2541 if (!transaction.LookupResource(id, resourceType, publicId_)) |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2542 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2543 throw OrthancException(ErrorCode_UnknownResource); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2544 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2545 else |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2546 { |
4627
f7d5372b59b3
handling revisions of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4623
diff
changeset
|
2547 FileInfo info; |
f7d5372b59b3
handling revisions of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4623
diff
changeset
|
2548 int64_t expectedRevision; |
f7d5372b59b3
handling revisions of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4623
diff
changeset
|
2549 if (transaction.LookupAttachment(info, expectedRevision, id, type_)) |
f7d5372b59b3
handling revisions of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4623
diff
changeset
|
2550 { |
f7d5372b59b3
handling revisions of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4623
diff
changeset
|
2551 if (hasRevision_ && |
4640
66109d24d26e
"ETag" headers for metadata and attachments now allow strong comparison (MD5 is included)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4633
diff
changeset
|
2552 (expectedRevision != revision_ || |
66109d24d26e
"ETag" headers for metadata and attachments now allow strong comparison (MD5 is included)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4633
diff
changeset
|
2553 info.GetUncompressedMD5() != md5_)) |
4627
f7d5372b59b3
handling revisions of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4623
diff
changeset
|
2554 { |
f7d5372b59b3
handling revisions of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4623
diff
changeset
|
2555 throw OrthancException(ErrorCode_Revision); |
f7d5372b59b3
handling revisions of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4623
diff
changeset
|
2556 } |
f7d5372b59b3
handling revisions of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4623
diff
changeset
|
2557 |
f7d5372b59b3
handling revisions of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4623
diff
changeset
|
2558 found_ = true; |
f7d5372b59b3
handling revisions of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4623
diff
changeset
|
2559 transaction.DeleteAttachment(id, type_); |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2560 |
4627
f7d5372b59b3
handling revisions of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4623
diff
changeset
|
2561 if (IsUserContentType(type_)) |
f7d5372b59b3
handling revisions of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4623
diff
changeset
|
2562 { |
f7d5372b59b3
handling revisions of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4623
diff
changeset
|
2563 transaction.LogChange(id, ChangeType_UpdatedAttachment, resourceType, publicId_); |
f7d5372b59b3
handling revisions of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4623
diff
changeset
|
2564 } |
f7d5372b59b3
handling revisions of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4623
diff
changeset
|
2565 } |
f7d5372b59b3
handling revisions of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4623
diff
changeset
|
2566 else |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2567 { |
4627
f7d5372b59b3
handling revisions of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4623
diff
changeset
|
2568 found_ = false; |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2569 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2570 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2571 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2572 }; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2573 |
4640
66109d24d26e
"ETag" headers for metadata and attachments now allow strong comparison (MD5 is included)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4633
diff
changeset
|
2574 Operations operations(publicId, type, hasRevision, revision, md5); |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2575 Apply(operations); |
4627
f7d5372b59b3
handling revisions of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4623
diff
changeset
|
2576 return operations.HasFound(); |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2577 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2578 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2579 |
4587
888868a5dc4e
ServerIndex now uses StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4586
diff
changeset
|
2580 void StatelessDatabaseOperations::LogChange(int64_t internalId, |
888868a5dc4e
ServerIndex now uses StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4586
diff
changeset
|
2581 ChangeType changeType, |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2582 const std::string& publicId, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2583 ResourceType level) |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2584 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2585 class Operations : public IReadWriteOperations |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2586 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2587 private: |
4587
888868a5dc4e
ServerIndex now uses StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4586
diff
changeset
|
2588 int64_t internalId_; |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2589 ChangeType changeType_; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2590 const std::string& publicId_; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2591 ResourceType level_; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2592 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2593 public: |
4587
888868a5dc4e
ServerIndex now uses StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4586
diff
changeset
|
2594 Operations(int64_t internalId, |
888868a5dc4e
ServerIndex now uses StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4586
diff
changeset
|
2595 ChangeType changeType, |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2596 const std::string& publicId, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2597 ResourceType level) : |
4587
888868a5dc4e
ServerIndex now uses StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4586
diff
changeset
|
2598 internalId_(internalId), |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2599 changeType_(changeType), |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2600 publicId_(publicId), |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2601 level_(level) |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2602 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2603 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2604 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2605 virtual void Apply(ReadWriteTransaction& transaction) ORTHANC_OVERRIDE |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2606 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2607 int64_t id; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2608 ResourceType type; |
4587
888868a5dc4e
ServerIndex now uses StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4586
diff
changeset
|
2609 if (transaction.LookupResource(id, type, publicId_) && |
888868a5dc4e
ServerIndex now uses StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4586
diff
changeset
|
2610 id == internalId_) |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2611 { |
4587
888868a5dc4e
ServerIndex now uses StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4586
diff
changeset
|
2612 /** |
888868a5dc4e
ServerIndex now uses StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4586
diff
changeset
|
2613 * Make sure that the resource is still existing, with the |
888868a5dc4e
ServerIndex now uses StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4586
diff
changeset
|
2614 * same internal ID, which indicates the absence of bouncing |
888868a5dc4e
ServerIndex now uses StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4586
diff
changeset
|
2615 * (if deleting then recreating the same resource). Don't |
888868a5dc4e
ServerIndex now uses StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4586
diff
changeset
|
2616 * throw an exception if the resource has been deleted, |
888868a5dc4e
ServerIndex now uses StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4586
diff
changeset
|
2617 * because this function might e.g. be called from |
888868a5dc4e
ServerIndex now uses StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4586
diff
changeset
|
2618 * "StatelessDatabaseOperations::UnstableResourcesMonitorThread()" |
888868a5dc4e
ServerIndex now uses StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4586
diff
changeset
|
2619 * (for which a deleted resource is *not* an error case). |
888868a5dc4e
ServerIndex now uses StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4586
diff
changeset
|
2620 **/ |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2621 if (type == level_) |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2622 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2623 transaction.LogChange(id, changeType_, type, publicId_); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2624 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2625 else |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2626 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2627 // Consistency check |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2628 throw OrthancException(ErrorCode_UnknownResource); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2629 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2630 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2631 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2632 }; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2633 |
4587
888868a5dc4e
ServerIndex now uses StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4586
diff
changeset
|
2634 Operations operations(internalId, changeType, publicId, level); |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2635 Apply(operations); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2636 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2637 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2638 |
5044
6fed78e13233
Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents:
5043
diff
changeset
|
2639 static void GetMainDicomSequenceMetadataContent(std::string& result, |
6fed78e13233
Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents:
5043
diff
changeset
|
2640 const DicomMap& dicomSummary, |
6fed78e13233
Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents:
5043
diff
changeset
|
2641 ResourceType level) |
6fed78e13233
Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents:
5043
diff
changeset
|
2642 { |
6fed78e13233
Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents:
5043
diff
changeset
|
2643 DicomMap levelSummary; |
6fed78e13233
Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents:
5043
diff
changeset
|
2644 DicomMap levelSequences; |
6fed78e13233
Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents:
5043
diff
changeset
|
2645 |
6fed78e13233
Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents:
5043
diff
changeset
|
2646 dicomSummary.ExtractResourceInformation(levelSummary, level); |
6fed78e13233
Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents:
5043
diff
changeset
|
2647 levelSummary.ExtractSequences(levelSequences); |
6fed78e13233
Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents:
5043
diff
changeset
|
2648 |
6fed78e13233
Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents:
5043
diff
changeset
|
2649 if (levelSequences.GetSize() > 0) |
6fed78e13233
Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents:
5043
diff
changeset
|
2650 { |
6fed78e13233
Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents:
5043
diff
changeset
|
2651 Json::Value jsonMetadata; |
6fed78e13233
Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents:
5043
diff
changeset
|
2652 jsonMetadata["Version"] = 1; |
6fed78e13233
Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents:
5043
diff
changeset
|
2653 jsonMetadata["Sequences"] = Json::objectValue; |
6fed78e13233
Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents:
5043
diff
changeset
|
2654 FromDcmtkBridge::ToJson(jsonMetadata["Sequences"], levelSequences, DicomToJsonFormat_Full); |
6fed78e13233
Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents:
5043
diff
changeset
|
2655 |
6fed78e13233
Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents:
5043
diff
changeset
|
2656 Toolbox::WriteFastJson(result, jsonMetadata); |
6fed78e13233
Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents:
5043
diff
changeset
|
2657 } |
6fed78e13233
Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents:
5043
diff
changeset
|
2658 } |
6fed78e13233
Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents:
5043
diff
changeset
|
2659 |
6fed78e13233
Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents:
5043
diff
changeset
|
2660 |
5558
c1ed59a5bdc2
new LimitToThisLevelMainDicomTags reconstruct mode + * Housekeeper plugin: Added an option LimitMainDicomTagsReconstructLevel
Alain Mazy <am@orthanc.team>
parents:
5526
diff
changeset
|
2661 void StatelessDatabaseOperations::ReconstructInstance(const ParsedDicomFile& dicom, bool limitToThisLevelDicomTags, ResourceType limitToLevel) |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2662 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2663 class Operations : public IReadWriteOperations |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2664 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2665 private: |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2666 DicomMap summary_; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2667 std::unique_ptr<DicomInstanceHasher> hasher_; |
5558
c1ed59a5bdc2
new LimitToThisLevelMainDicomTags reconstruct mode + * Housekeeper plugin: Added an option LimitMainDicomTagsReconstructLevel
Alain Mazy <am@orthanc.team>
parents:
5526
diff
changeset
|
2668 bool limitToThisLevelDicomTags_; |
c1ed59a5bdc2
new LimitToThisLevelMainDicomTags reconstruct mode + * Housekeeper plugin: Added an option LimitMainDicomTagsReconstructLevel
Alain Mazy <am@orthanc.team>
parents:
5526
diff
changeset
|
2669 ResourceType limitToLevel_; |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2670 bool hasTransferSyntax_; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2671 DicomTransferSyntax transferSyntax_; |
4623
95ffe3b6ef7c
handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4619
diff
changeset
|
2672 |
95ffe3b6ef7c
handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4619
diff
changeset
|
2673 static void ReplaceMetadata(ReadWriteTransaction& transaction, |
95ffe3b6ef7c
handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4619
diff
changeset
|
2674 int64_t instance, |
95ffe3b6ef7c
handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4619
diff
changeset
|
2675 MetadataType metadata, |
95ffe3b6ef7c
handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4619
diff
changeset
|
2676 const std::string& value) |
95ffe3b6ef7c
handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4619
diff
changeset
|
2677 { |
95ffe3b6ef7c
handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4619
diff
changeset
|
2678 std::string oldValue; |
95ffe3b6ef7c
handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4619
diff
changeset
|
2679 int64_t oldRevision; |
95ffe3b6ef7c
handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4619
diff
changeset
|
2680 |
95ffe3b6ef7c
handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4619
diff
changeset
|
2681 if (transaction.LookupMetadata(oldValue, oldRevision, instance, metadata)) |
95ffe3b6ef7c
handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4619
diff
changeset
|
2682 { |
95ffe3b6ef7c
handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4619
diff
changeset
|
2683 transaction.SetMetadata(instance, metadata, value, oldRevision + 1); |
95ffe3b6ef7c
handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4619
diff
changeset
|
2684 } |
95ffe3b6ef7c
handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4619
diff
changeset
|
2685 else |
95ffe3b6ef7c
handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4619
diff
changeset
|
2686 { |
95ffe3b6ef7c
handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4619
diff
changeset
|
2687 transaction.SetMetadata(instance, metadata, value, 0); |
95ffe3b6ef7c
handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4619
diff
changeset
|
2688 } |
95ffe3b6ef7c
handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4619
diff
changeset
|
2689 } |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2690 |
5044
6fed78e13233
Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents:
5043
diff
changeset
|
2691 static void SetMainDicomSequenceMetadata(ReadWriteTransaction& transaction, |
6fed78e13233
Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents:
5043
diff
changeset
|
2692 int64_t instance, |
6fed78e13233
Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents:
5043
diff
changeset
|
2693 const DicomMap& dicomSummary, |
6fed78e13233
Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents:
5043
diff
changeset
|
2694 ResourceType level) |
6fed78e13233
Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents:
5043
diff
changeset
|
2695 { |
6fed78e13233
Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents:
5043
diff
changeset
|
2696 std::string serialized; |
6fed78e13233
Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents:
5043
diff
changeset
|
2697 GetMainDicomSequenceMetadataContent(serialized, dicomSummary, level); |
6fed78e13233
Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents:
5043
diff
changeset
|
2698 |
6fed78e13233
Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents:
5043
diff
changeset
|
2699 if (!serialized.empty()) |
6fed78e13233
Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents:
5043
diff
changeset
|
2700 { |
6fed78e13233
Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents:
5043
diff
changeset
|
2701 ReplaceMetadata(transaction, instance, MetadataType_MainDicomSequences, serialized); |
6fed78e13233
Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents:
5043
diff
changeset
|
2702 } |
6fed78e13233
Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents:
5043
diff
changeset
|
2703 else |
6fed78e13233
Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents:
5043
diff
changeset
|
2704 { |
6fed78e13233
Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents:
5043
diff
changeset
|
2705 transaction.DeleteMetadata(instance, MetadataType_MainDicomSequences); |
6fed78e13233
Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents:
5043
diff
changeset
|
2706 } |
6fed78e13233
Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents:
5043
diff
changeset
|
2707 |
6fed78e13233
Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents:
5043
diff
changeset
|
2708 } |
6fed78e13233
Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents:
5043
diff
changeset
|
2709 |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2710 public: |
5558
c1ed59a5bdc2
new LimitToThisLevelMainDicomTags reconstruct mode + * Housekeeper plugin: Added an option LimitMainDicomTagsReconstructLevel
Alain Mazy <am@orthanc.team>
parents:
5526
diff
changeset
|
2711 explicit Operations(const ParsedDicomFile& dicom, bool limitToThisLevelDicomTags, ResourceType limitToLevel) |
5595
a87f2a56257d
implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5593
diff
changeset
|
2712 : limitToThisLevelDicomTags_(limitToThisLevelDicomTags), |
a87f2a56257d
implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5593
diff
changeset
|
2713 limitToLevel_(limitToLevel) |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2714 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2715 OrthancConfiguration::DefaultExtractDicomSummary(summary_, dicom); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2716 hasher_.reset(new DicomInstanceHasher(summary_)); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2717 hasTransferSyntax_ = dicom.LookupTransferSyntax(transferSyntax_); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2718 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2719 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2720 virtual void Apply(ReadWriteTransaction& transaction) ORTHANC_OVERRIDE |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2721 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2722 int64_t patient = -1, study = -1, series = -1, instance = -1; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2723 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2724 ResourceType type1, type2, type3, type4; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2725 if (!transaction.LookupResource(patient, type1, hasher_->HashPatient()) || |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2726 !transaction.LookupResource(study, type2, hasher_->HashStudy()) || |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2727 !transaction.LookupResource(series, type3, hasher_->HashSeries()) || |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2728 !transaction.LookupResource(instance, type4, hasher_->HashInstance()) || |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2729 type1 != ResourceType_Patient || |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2730 type2 != ResourceType_Study || |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2731 type3 != ResourceType_Series || |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2732 type4 != ResourceType_Instance || |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2733 patient == -1 || |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2734 study == -1 || |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2735 series == -1 || |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2736 instance == -1) |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2737 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2738 throw OrthancException(ErrorCode_InternalError); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2739 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2740 |
5558
c1ed59a5bdc2
new LimitToThisLevelMainDicomTags reconstruct mode + * Housekeeper plugin: Added an option LimitMainDicomTagsReconstructLevel
Alain Mazy <am@orthanc.team>
parents:
5526
diff
changeset
|
2741 if (limitToThisLevelDicomTags_) |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2742 { |
4623
95ffe3b6ef7c
handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4619
diff
changeset
|
2743 ResourcesContent content(false /* prevent the setting of metadata */); |
5558
c1ed59a5bdc2
new LimitToThisLevelMainDicomTags reconstruct mode + * Housekeeper plugin: Added an option LimitMainDicomTagsReconstructLevel
Alain Mazy <am@orthanc.team>
parents:
5526
diff
changeset
|
2744 int64_t resource = -1; |
c1ed59a5bdc2
new LimitToThisLevelMainDicomTags reconstruct mode + * Housekeeper plugin: Added an option LimitMainDicomTagsReconstructLevel
Alain Mazy <am@orthanc.team>
parents:
5526
diff
changeset
|
2745 if (limitToLevel_ == ResourceType_Patient) |
c1ed59a5bdc2
new LimitToThisLevelMainDicomTags reconstruct mode + * Housekeeper plugin: Added an option LimitMainDicomTagsReconstructLevel
Alain Mazy <am@orthanc.team>
parents:
5526
diff
changeset
|
2746 { |
c1ed59a5bdc2
new LimitToThisLevelMainDicomTags reconstruct mode + * Housekeeper plugin: Added an option LimitMainDicomTagsReconstructLevel
Alain Mazy <am@orthanc.team>
parents:
5526
diff
changeset
|
2747 resource = patient; |
c1ed59a5bdc2
new LimitToThisLevelMainDicomTags reconstruct mode + * Housekeeper plugin: Added an option LimitMainDicomTagsReconstructLevel
Alain Mazy <am@orthanc.team>
parents:
5526
diff
changeset
|
2748 } |
c1ed59a5bdc2
new LimitToThisLevelMainDicomTags reconstruct mode + * Housekeeper plugin: Added an option LimitMainDicomTagsReconstructLevel
Alain Mazy <am@orthanc.team>
parents:
5526
diff
changeset
|
2749 else if (limitToLevel_ == ResourceType_Study) |
c1ed59a5bdc2
new LimitToThisLevelMainDicomTags reconstruct mode + * Housekeeper plugin: Added an option LimitMainDicomTagsReconstructLevel
Alain Mazy <am@orthanc.team>
parents:
5526
diff
changeset
|
2750 { |
c1ed59a5bdc2
new LimitToThisLevelMainDicomTags reconstruct mode + * Housekeeper plugin: Added an option LimitMainDicomTagsReconstructLevel
Alain Mazy <am@orthanc.team>
parents:
5526
diff
changeset
|
2751 resource = study; |
c1ed59a5bdc2
new LimitToThisLevelMainDicomTags reconstruct mode + * Housekeeper plugin: Added an option LimitMainDicomTagsReconstructLevel
Alain Mazy <am@orthanc.team>
parents:
5526
diff
changeset
|
2752 } |
c1ed59a5bdc2
new LimitToThisLevelMainDicomTags reconstruct mode + * Housekeeper plugin: Added an option LimitMainDicomTagsReconstructLevel
Alain Mazy <am@orthanc.team>
parents:
5526
diff
changeset
|
2753 else if (limitToLevel_ == ResourceType_Series) |
c1ed59a5bdc2
new LimitToThisLevelMainDicomTags reconstruct mode + * Housekeeper plugin: Added an option LimitMainDicomTagsReconstructLevel
Alain Mazy <am@orthanc.team>
parents:
5526
diff
changeset
|
2754 { |
c1ed59a5bdc2
new LimitToThisLevelMainDicomTags reconstruct mode + * Housekeeper plugin: Added an option LimitMainDicomTagsReconstructLevel
Alain Mazy <am@orthanc.team>
parents:
5526
diff
changeset
|
2755 resource = series; |
c1ed59a5bdc2
new LimitToThisLevelMainDicomTags reconstruct mode + * Housekeeper plugin: Added an option LimitMainDicomTagsReconstructLevel
Alain Mazy <am@orthanc.team>
parents:
5526
diff
changeset
|
2756 } |
c1ed59a5bdc2
new LimitToThisLevelMainDicomTags reconstruct mode + * Housekeeper plugin: Added an option LimitMainDicomTagsReconstructLevel
Alain Mazy <am@orthanc.team>
parents:
5526
diff
changeset
|
2757 else if (limitToLevel_ == ResourceType_Instance) |
c1ed59a5bdc2
new LimitToThisLevelMainDicomTags reconstruct mode + * Housekeeper plugin: Added an option LimitMainDicomTagsReconstructLevel
Alain Mazy <am@orthanc.team>
parents:
5526
diff
changeset
|
2758 { |
c1ed59a5bdc2
new LimitToThisLevelMainDicomTags reconstruct mode + * Housekeeper plugin: Added an option LimitMainDicomTagsReconstructLevel
Alain Mazy <am@orthanc.team>
parents:
5526
diff
changeset
|
2759 resource = instance; |
c1ed59a5bdc2
new LimitToThisLevelMainDicomTags reconstruct mode + * Housekeeper plugin: Added an option LimitMainDicomTagsReconstructLevel
Alain Mazy <am@orthanc.team>
parents:
5526
diff
changeset
|
2760 } |
c1ed59a5bdc2
new LimitToThisLevelMainDicomTags reconstruct mode + * Housekeeper plugin: Added an option LimitMainDicomTagsReconstructLevel
Alain Mazy <am@orthanc.team>
parents:
5526
diff
changeset
|
2761 |
c1ed59a5bdc2
new LimitToThisLevelMainDicomTags reconstruct mode + * Housekeeper plugin: Added an option LimitMainDicomTagsReconstructLevel
Alain Mazy <am@orthanc.team>
parents:
5526
diff
changeset
|
2762 transaction.ClearMainDicomTags(resource); |
c1ed59a5bdc2
new LimitToThisLevelMainDicomTags reconstruct mode + * Housekeeper plugin: Added an option LimitMainDicomTagsReconstructLevel
Alain Mazy <am@orthanc.team>
parents:
5526
diff
changeset
|
2763 content.AddResource(resource, limitToLevel_, summary_); |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2764 transaction.SetResourcesContent(content); |
5558
c1ed59a5bdc2
new LimitToThisLevelMainDicomTags reconstruct mode + * Housekeeper plugin: Added an option LimitMainDicomTagsReconstructLevel
Alain Mazy <am@orthanc.team>
parents:
5526
diff
changeset
|
2765 ReplaceMetadata(transaction, resource, MetadataType_MainDicomTagsSignature, DicomMap::GetMainDicomTagsSignature(limitToLevel_)); |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2766 } |
5558
c1ed59a5bdc2
new LimitToThisLevelMainDicomTags reconstruct mode + * Housekeeper plugin: Added an option LimitMainDicomTagsReconstructLevel
Alain Mazy <am@orthanc.team>
parents:
5526
diff
changeset
|
2767 else |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2768 { |
5558
c1ed59a5bdc2
new LimitToThisLevelMainDicomTags reconstruct mode + * Housekeeper plugin: Added an option LimitMainDicomTagsReconstructLevel
Alain Mazy <am@orthanc.team>
parents:
5526
diff
changeset
|
2769 transaction.ClearMainDicomTags(patient); |
c1ed59a5bdc2
new LimitToThisLevelMainDicomTags reconstruct mode + * Housekeeper plugin: Added an option LimitMainDicomTagsReconstructLevel
Alain Mazy <am@orthanc.team>
parents:
5526
diff
changeset
|
2770 transaction.ClearMainDicomTags(study); |
c1ed59a5bdc2
new LimitToThisLevelMainDicomTags reconstruct mode + * Housekeeper plugin: Added an option LimitMainDicomTagsReconstructLevel
Alain Mazy <am@orthanc.team>
parents:
5526
diff
changeset
|
2771 transaction.ClearMainDicomTags(series); |
c1ed59a5bdc2
new LimitToThisLevelMainDicomTags reconstruct mode + * Housekeeper plugin: Added an option LimitMainDicomTagsReconstructLevel
Alain Mazy <am@orthanc.team>
parents:
5526
diff
changeset
|
2772 transaction.ClearMainDicomTags(instance); |
c1ed59a5bdc2
new LimitToThisLevelMainDicomTags reconstruct mode + * Housekeeper plugin: Added an option LimitMainDicomTagsReconstructLevel
Alain Mazy <am@orthanc.team>
parents:
5526
diff
changeset
|
2773 |
c1ed59a5bdc2
new LimitToThisLevelMainDicomTags reconstruct mode + * Housekeeper plugin: Added an option LimitMainDicomTagsReconstructLevel
Alain Mazy <am@orthanc.team>
parents:
5526
diff
changeset
|
2774 { |
c1ed59a5bdc2
new LimitToThisLevelMainDicomTags reconstruct mode + * Housekeeper plugin: Added an option LimitMainDicomTagsReconstructLevel
Alain Mazy <am@orthanc.team>
parents:
5526
diff
changeset
|
2775 ResourcesContent content(false /* prevent the setting of metadata */); |
c1ed59a5bdc2
new LimitToThisLevelMainDicomTags reconstruct mode + * Housekeeper plugin: Added an option LimitMainDicomTagsReconstructLevel
Alain Mazy <am@orthanc.team>
parents:
5526
diff
changeset
|
2776 content.AddResource(patient, ResourceType_Patient, summary_); |
c1ed59a5bdc2
new LimitToThisLevelMainDicomTags reconstruct mode + * Housekeeper plugin: Added an option LimitMainDicomTagsReconstructLevel
Alain Mazy <am@orthanc.team>
parents:
5526
diff
changeset
|
2777 content.AddResource(study, ResourceType_Study, summary_); |
c1ed59a5bdc2
new LimitToThisLevelMainDicomTags reconstruct mode + * Housekeeper plugin: Added an option LimitMainDicomTagsReconstructLevel
Alain Mazy <am@orthanc.team>
parents:
5526
diff
changeset
|
2778 content.AddResource(series, ResourceType_Series, summary_); |
c1ed59a5bdc2
new LimitToThisLevelMainDicomTags reconstruct mode + * Housekeeper plugin: Added an option LimitMainDicomTagsReconstructLevel
Alain Mazy <am@orthanc.team>
parents:
5526
diff
changeset
|
2779 content.AddResource(instance, ResourceType_Instance, summary_); |
c1ed59a5bdc2
new LimitToThisLevelMainDicomTags reconstruct mode + * Housekeeper plugin: Added an option LimitMainDicomTagsReconstructLevel
Alain Mazy <am@orthanc.team>
parents:
5526
diff
changeset
|
2780 |
c1ed59a5bdc2
new LimitToThisLevelMainDicomTags reconstruct mode + * Housekeeper plugin: Added an option LimitMainDicomTagsReconstructLevel
Alain Mazy <am@orthanc.team>
parents:
5526
diff
changeset
|
2781 transaction.SetResourcesContent(content); |
c1ed59a5bdc2
new LimitToThisLevelMainDicomTags reconstruct mode + * Housekeeper plugin: Added an option LimitMainDicomTagsReconstructLevel
Alain Mazy <am@orthanc.team>
parents:
5526
diff
changeset
|
2782 |
c1ed59a5bdc2
new LimitToThisLevelMainDicomTags reconstruct mode + * Housekeeper plugin: Added an option LimitMainDicomTagsReconstructLevel
Alain Mazy <am@orthanc.team>
parents:
5526
diff
changeset
|
2783 ReplaceMetadata(transaction, patient, MetadataType_MainDicomTagsSignature, DicomMap::GetMainDicomTagsSignature(ResourceType_Patient)); // New in Orthanc 1.11.0 |
c1ed59a5bdc2
new LimitToThisLevelMainDicomTags reconstruct mode + * Housekeeper plugin: Added an option LimitMainDicomTagsReconstructLevel
Alain Mazy <am@orthanc.team>
parents:
5526
diff
changeset
|
2784 ReplaceMetadata(transaction, study, MetadataType_MainDicomTagsSignature, DicomMap::GetMainDicomTagsSignature(ResourceType_Study)); // New in Orthanc 1.11.0 |
c1ed59a5bdc2
new LimitToThisLevelMainDicomTags reconstruct mode + * Housekeeper plugin: Added an option LimitMainDicomTagsReconstructLevel
Alain Mazy <am@orthanc.team>
parents:
5526
diff
changeset
|
2785 ReplaceMetadata(transaction, series, MetadataType_MainDicomTagsSignature, DicomMap::GetMainDicomTagsSignature(ResourceType_Series)); // New in Orthanc 1.11.0 |
c1ed59a5bdc2
new LimitToThisLevelMainDicomTags reconstruct mode + * Housekeeper plugin: Added an option LimitMainDicomTagsReconstructLevel
Alain Mazy <am@orthanc.team>
parents:
5526
diff
changeset
|
2786 ReplaceMetadata(transaction, instance, MetadataType_MainDicomTagsSignature, DicomMap::GetMainDicomTagsSignature(ResourceType_Instance)); // New in Orthanc 1.11.0 |
c1ed59a5bdc2
new LimitToThisLevelMainDicomTags reconstruct mode + * Housekeeper plugin: Added an option LimitMainDicomTagsReconstructLevel
Alain Mazy <am@orthanc.team>
parents:
5526
diff
changeset
|
2787 |
c1ed59a5bdc2
new LimitToThisLevelMainDicomTags reconstruct mode + * Housekeeper plugin: Added an option LimitMainDicomTagsReconstructLevel
Alain Mazy <am@orthanc.team>
parents:
5526
diff
changeset
|
2788 SetMainDicomSequenceMetadata(transaction, patient, summary_, ResourceType_Patient); |
c1ed59a5bdc2
new LimitToThisLevelMainDicomTags reconstruct mode + * Housekeeper plugin: Added an option LimitMainDicomTagsReconstructLevel
Alain Mazy <am@orthanc.team>
parents:
5526
diff
changeset
|
2789 SetMainDicomSequenceMetadata(transaction, study, summary_, ResourceType_Study); |
c1ed59a5bdc2
new LimitToThisLevelMainDicomTags reconstruct mode + * Housekeeper plugin: Added an option LimitMainDicomTagsReconstructLevel
Alain Mazy <am@orthanc.team>
parents:
5526
diff
changeset
|
2790 SetMainDicomSequenceMetadata(transaction, series, summary_, ResourceType_Series); |
c1ed59a5bdc2
new LimitToThisLevelMainDicomTags reconstruct mode + * Housekeeper plugin: Added an option LimitMainDicomTagsReconstructLevel
Alain Mazy <am@orthanc.team>
parents:
5526
diff
changeset
|
2791 SetMainDicomSequenceMetadata(transaction, instance, summary_, ResourceType_Instance); |
c1ed59a5bdc2
new LimitToThisLevelMainDicomTags reconstruct mode + * Housekeeper plugin: Added an option LimitMainDicomTagsReconstructLevel
Alain Mazy <am@orthanc.team>
parents:
5526
diff
changeset
|
2792 } |
c1ed59a5bdc2
new LimitToThisLevelMainDicomTags reconstruct mode + * Housekeeper plugin: Added an option LimitMainDicomTagsReconstructLevel
Alain Mazy <am@orthanc.team>
parents:
5526
diff
changeset
|
2793 |
c1ed59a5bdc2
new LimitToThisLevelMainDicomTags reconstruct mode + * Housekeeper plugin: Added an option LimitMainDicomTagsReconstructLevel
Alain Mazy <am@orthanc.team>
parents:
5526
diff
changeset
|
2794 if (hasTransferSyntax_) |
c1ed59a5bdc2
new LimitToThisLevelMainDicomTags reconstruct mode + * Housekeeper plugin: Added an option LimitMainDicomTagsReconstructLevel
Alain Mazy <am@orthanc.team>
parents:
5526
diff
changeset
|
2795 { |
c1ed59a5bdc2
new LimitToThisLevelMainDicomTags reconstruct mode + * Housekeeper plugin: Added an option LimitMainDicomTagsReconstructLevel
Alain Mazy <am@orthanc.team>
parents:
5526
diff
changeset
|
2796 ReplaceMetadata(transaction, instance, MetadataType_Instance_TransferSyntax, GetTransferSyntaxUid(transferSyntax_)); |
c1ed59a5bdc2
new LimitToThisLevelMainDicomTags reconstruct mode + * Housekeeper plugin: Added an option LimitMainDicomTagsReconstructLevel
Alain Mazy <am@orthanc.team>
parents:
5526
diff
changeset
|
2797 } |
c1ed59a5bdc2
new LimitToThisLevelMainDicomTags reconstruct mode + * Housekeeper plugin: Added an option LimitMainDicomTagsReconstructLevel
Alain Mazy <am@orthanc.team>
parents:
5526
diff
changeset
|
2798 |
c1ed59a5bdc2
new LimitToThisLevelMainDicomTags reconstruct mode + * Housekeeper plugin: Added an option LimitMainDicomTagsReconstructLevel
Alain Mazy <am@orthanc.team>
parents:
5526
diff
changeset
|
2799 const DicomValue* value; |
c1ed59a5bdc2
new LimitToThisLevelMainDicomTags reconstruct mode + * Housekeeper plugin: Added an option LimitMainDicomTagsReconstructLevel
Alain Mazy <am@orthanc.team>
parents:
5526
diff
changeset
|
2800 if ((value = summary_.TestAndGetValue(DICOM_TAG_SOP_CLASS_UID)) != NULL && |
c1ed59a5bdc2
new LimitToThisLevelMainDicomTags reconstruct mode + * Housekeeper plugin: Added an option LimitMainDicomTagsReconstructLevel
Alain Mazy <am@orthanc.team>
parents:
5526
diff
changeset
|
2801 !value->IsNull() && |
c1ed59a5bdc2
new LimitToThisLevelMainDicomTags reconstruct mode + * Housekeeper plugin: Added an option LimitMainDicomTagsReconstructLevel
Alain Mazy <am@orthanc.team>
parents:
5526
diff
changeset
|
2802 !value->IsBinary()) |
c1ed59a5bdc2
new LimitToThisLevelMainDicomTags reconstruct mode + * Housekeeper plugin: Added an option LimitMainDicomTagsReconstructLevel
Alain Mazy <am@orthanc.team>
parents:
5526
diff
changeset
|
2803 { |
c1ed59a5bdc2
new LimitToThisLevelMainDicomTags reconstruct mode + * Housekeeper plugin: Added an option LimitMainDicomTagsReconstructLevel
Alain Mazy <am@orthanc.team>
parents:
5526
diff
changeset
|
2804 ReplaceMetadata(transaction, instance, MetadataType_Instance_SopClassUid, value->GetContent()); |
c1ed59a5bdc2
new LimitToThisLevelMainDicomTags reconstruct mode + * Housekeeper plugin: Added an option LimitMainDicomTagsReconstructLevel
Alain Mazy <am@orthanc.team>
parents:
5526
diff
changeset
|
2805 } |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2806 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2807 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2808 }; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2809 |
5558
c1ed59a5bdc2
new LimitToThisLevelMainDicomTags reconstruct mode + * Housekeeper plugin: Added an option LimitMainDicomTagsReconstructLevel
Alain Mazy <am@orthanc.team>
parents:
5526
diff
changeset
|
2810 Operations operations(dicom, limitToThisLevelDicomTags, limitToLevel); |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2811 Apply(operations); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2812 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2813 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2814 |
5061
e95fadefeb72
new MaximumStorageMode configuration
Alain Mazy <am@osimis.io>
parents:
5044
diff
changeset
|
2815 bool StatelessDatabaseOperations::ReadWriteTransaction::HasReachedMaxStorageSize(uint64_t maximumStorageSize, |
e95fadefeb72
new MaximumStorageMode configuration
Alain Mazy <am@osimis.io>
parents:
5044
diff
changeset
|
2816 uint64_t addedInstanceSize) |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2817 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2818 if (maximumStorageSize != 0) |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2819 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2820 if (maximumStorageSize < addedInstanceSize) |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2821 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2822 throw OrthancException(ErrorCode_FullStorage, "Cannot store an instance of size " + |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2823 boost::lexical_cast<std::string>(addedInstanceSize) + |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2824 " bytes in a storage area limited to " + |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2825 boost::lexical_cast<std::string>(maximumStorageSize)); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2826 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2827 |
5061
e95fadefeb72
new MaximumStorageMode configuration
Alain Mazy <am@osimis.io>
parents:
5044
diff
changeset
|
2828 if (transaction_.IsDiskSizeAbove(maximumStorageSize - addedInstanceSize)) |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2829 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2830 return true; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2831 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2832 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2833 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2834 return false; |
5061
e95fadefeb72
new MaximumStorageMode configuration
Alain Mazy <am@osimis.io>
parents:
5044
diff
changeset
|
2835 } |
e95fadefeb72
new MaximumStorageMode configuration
Alain Mazy <am@osimis.io>
parents:
5044
diff
changeset
|
2836 |
e95fadefeb72
new MaximumStorageMode configuration
Alain Mazy <am@osimis.io>
parents:
5044
diff
changeset
|
2837 bool StatelessDatabaseOperations::ReadWriteTransaction::HasReachedMaxPatientCount(unsigned int maximumPatientCount, |
5595
a87f2a56257d
implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5593
diff
changeset
|
2838 const std::string& patientId) |
5061
e95fadefeb72
new MaximumStorageMode configuration
Alain Mazy <am@osimis.io>
parents:
5044
diff
changeset
|
2839 { |
e95fadefeb72
new MaximumStorageMode configuration
Alain Mazy <am@osimis.io>
parents:
5044
diff
changeset
|
2840 if (maximumPatientCount != 0) |
e95fadefeb72
new MaximumStorageMode configuration
Alain Mazy <am@osimis.io>
parents:
5044
diff
changeset
|
2841 { |
e95fadefeb72
new MaximumStorageMode configuration
Alain Mazy <am@osimis.io>
parents:
5044
diff
changeset
|
2842 uint64_t patientCount = transaction_.GetResourcesCount(ResourceType_Patient); // at this time, the new patient has already been added (as part of the transaction) |
e95fadefeb72
new MaximumStorageMode configuration
Alain Mazy <am@osimis.io>
parents:
5044
diff
changeset
|
2843 return patientCount > maximumPatientCount; |
e95fadefeb72
new MaximumStorageMode configuration
Alain Mazy <am@osimis.io>
parents:
5044
diff
changeset
|
2844 } |
e95fadefeb72
new MaximumStorageMode configuration
Alain Mazy <am@osimis.io>
parents:
5044
diff
changeset
|
2845 |
e95fadefeb72
new MaximumStorageMode configuration
Alain Mazy <am@osimis.io>
parents:
5044
diff
changeset
|
2846 return false; |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2847 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2848 |
5061
e95fadefeb72
new MaximumStorageMode configuration
Alain Mazy <am@osimis.io>
parents:
5044
diff
changeset
|
2849 bool StatelessDatabaseOperations::ReadWriteTransaction::IsRecyclingNeeded(uint64_t maximumStorageSize, |
e95fadefeb72
new MaximumStorageMode configuration
Alain Mazy <am@osimis.io>
parents:
5044
diff
changeset
|
2850 unsigned int maximumPatients, |
e95fadefeb72
new MaximumStorageMode configuration
Alain Mazy <am@osimis.io>
parents:
5044
diff
changeset
|
2851 uint64_t addedInstanceSize, |
e95fadefeb72
new MaximumStorageMode configuration
Alain Mazy <am@osimis.io>
parents:
5044
diff
changeset
|
2852 const std::string& newPatientId) |
e95fadefeb72
new MaximumStorageMode configuration
Alain Mazy <am@osimis.io>
parents:
5044
diff
changeset
|
2853 { |
e95fadefeb72
new MaximumStorageMode configuration
Alain Mazy <am@osimis.io>
parents:
5044
diff
changeset
|
2854 return HasReachedMaxStorageSize(maximumStorageSize, addedInstanceSize) |
e95fadefeb72
new MaximumStorageMode configuration
Alain Mazy <am@osimis.io>
parents:
5044
diff
changeset
|
2855 || HasReachedMaxPatientCount(maximumPatients, newPatientId); |
e95fadefeb72
new MaximumStorageMode configuration
Alain Mazy <am@osimis.io>
parents:
5044
diff
changeset
|
2856 } |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2857 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2858 void StatelessDatabaseOperations::ReadWriteTransaction::Recycle(uint64_t maximumStorageSize, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2859 unsigned int maximumPatients, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2860 uint64_t addedInstanceSize, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2861 const std::string& newPatientId) |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2862 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2863 // TODO - Performance: Avoid calls to "IsRecyclingNeeded()" |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2864 |
5061
e95fadefeb72
new MaximumStorageMode configuration
Alain Mazy <am@osimis.io>
parents:
5044
diff
changeset
|
2865 if (IsRecyclingNeeded(maximumStorageSize, maximumPatients, addedInstanceSize, newPatientId)) |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2866 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2867 // Check whether other DICOM instances from this patient are |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2868 // already stored |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2869 int64_t patientToAvoid; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2870 bool hasPatientToAvoid; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2871 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2872 if (newPatientId.empty()) |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2873 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2874 hasPatientToAvoid = false; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2875 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2876 else |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2877 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2878 ResourceType type; |
4591
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
2879 hasPatientToAvoid = transaction_.LookupResource(patientToAvoid, type, newPatientId); |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2880 if (type != ResourceType_Patient) |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2881 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2882 throw OrthancException(ErrorCode_InternalError); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2883 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2884 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2885 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2886 // Iteratively select patient to remove until there is enough |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2887 // space in the DICOM store |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2888 int64_t patientToRecycle; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2889 while (true) |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2890 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2891 // If other instances of this patient are already in the store, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2892 // we must avoid to recycle them |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2893 bool ok = (hasPatientToAvoid ? |
4591
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
2894 transaction_.SelectPatientToRecycle(patientToRecycle, patientToAvoid) : |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
2895 transaction_.SelectPatientToRecycle(patientToRecycle)); |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2896 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2897 if (!ok) |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2898 { |
4801
23aeffecb8cb
Fix instances accumulating in DB while their attachments were not stored because of MaximumStorageSize limit reached with a single patient in DB.
Alain Mazy <am@osimis.io>
parents:
4697
diff
changeset
|
2899 throw OrthancException(ErrorCode_FullStorage, "Cannot recycle more patients"); |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2900 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2901 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2902 LOG(TRACE) << "Recycling one patient"; |
4591
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
2903 transaction_.DeleteResource(patientToRecycle); |
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
2904 |
5061
e95fadefeb72
new MaximumStorageMode configuration
Alain Mazy <am@osimis.io>
parents:
5044
diff
changeset
|
2905 if (!IsRecyclingNeeded(maximumStorageSize, maximumPatients, addedInstanceSize, newPatientId)) |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2906 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2907 // OK, we're done |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2908 return; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2909 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2910 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2911 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2912 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2913 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2914 |
5061
e95fadefeb72
new MaximumStorageMode configuration
Alain Mazy <am@osimis.io>
parents:
5044
diff
changeset
|
2915 void StatelessDatabaseOperations::StandaloneRecycling(MaxStorageMode maximumStorageMode, |
e95fadefeb72
new MaximumStorageMode configuration
Alain Mazy <am@osimis.io>
parents:
5044
diff
changeset
|
2916 uint64_t maximumStorageSize, |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2917 unsigned int maximumPatientCount) |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2918 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2919 class Operations : public IReadWriteOperations |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2920 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2921 private: |
5061
e95fadefeb72
new MaximumStorageMode configuration
Alain Mazy <am@osimis.io>
parents:
5044
diff
changeset
|
2922 uint64_t maximumStorageSize_; |
e95fadefeb72
new MaximumStorageMode configuration
Alain Mazy <am@osimis.io>
parents:
5044
diff
changeset
|
2923 unsigned int maximumPatientCount_; |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2924 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2925 public: |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2926 Operations(uint64_t maximumStorageSize, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2927 unsigned int maximumPatientCount) : |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2928 maximumStorageSize_(maximumStorageSize), |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2929 maximumPatientCount_(maximumPatientCount) |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2930 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2931 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2932 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2933 virtual void Apply(ReadWriteTransaction& transaction) ORTHANC_OVERRIDE |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2934 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2935 transaction.Recycle(maximumStorageSize_, maximumPatientCount_, 0, ""); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2936 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2937 }; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2938 |
5061
e95fadefeb72
new MaximumStorageMode configuration
Alain Mazy <am@osimis.io>
parents:
5044
diff
changeset
|
2939 if (maximumStorageMode == MaxStorageMode_Recycle |
5595
a87f2a56257d
implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5593
diff
changeset
|
2940 && (maximumStorageSize != 0 || maximumPatientCount != 0)) |
4602
cfdd1f59ff6f
fix OrthancCDatabasePlugin.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4595
diff
changeset
|
2941 { |
cfdd1f59ff6f
fix OrthancCDatabasePlugin.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4595
diff
changeset
|
2942 Operations operations(maximumStorageSize, maximumPatientCount); |
cfdd1f59ff6f
fix OrthancCDatabasePlugin.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4595
diff
changeset
|
2943 Apply(operations); |
cfdd1f59ff6f
fix OrthancCDatabasePlugin.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4595
diff
changeset
|
2944 } |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2945 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2946 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2947 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2948 StoreStatus StatelessDatabaseOperations::Store(std::map<MetadataType, std::string>& instanceMetadata, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2949 const DicomMap& dicomSummary, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2950 const Attachments& attachments, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2951 const MetadataMap& metadata, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2952 const DicomInstanceOrigin& origin, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2953 bool overwrite, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2954 bool hasTransferSyntax, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2955 DicomTransferSyntax transferSyntax, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2956 bool hasPixelDataOffset, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2957 uint64_t pixelDataOffset, |
5316
03501a258d9e
added instance metadata "PixelDataVR"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5297
diff
changeset
|
2958 ValueRepresentation pixelDataVR, |
5061
e95fadefeb72
new MaximumStorageMode configuration
Alain Mazy <am@osimis.io>
parents:
5044
diff
changeset
|
2959 MaxStorageMode maximumStorageMode, |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2960 uint64_t maximumStorageSize, |
4988
8fba26292a9f
Housekeeper plugin: finalizing + integration tests ok
Alain Mazy <am@osimis.io>
parents:
4940
diff
changeset
|
2961 unsigned int maximumPatients, |
8fba26292a9f
Housekeeper plugin: finalizing + integration tests ok
Alain Mazy <am@osimis.io>
parents:
4940
diff
changeset
|
2962 bool isReconstruct) |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2963 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2964 class Operations : public IReadWriteOperations |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2965 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2966 private: |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2967 StoreStatus storeStatus_; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2968 std::map<MetadataType, std::string>& instanceMetadata_; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2969 const DicomMap& dicomSummary_; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2970 const Attachments& attachments_; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2971 const MetadataMap& metadata_; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2972 const DicomInstanceOrigin& origin_; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2973 bool overwrite_; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2974 bool hasTransferSyntax_; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2975 DicomTransferSyntax transferSyntax_; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2976 bool hasPixelDataOffset_; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2977 uint64_t pixelDataOffset_; |
5316
03501a258d9e
added instance metadata "PixelDataVR"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5297
diff
changeset
|
2978 ValueRepresentation pixelDataVR_; |
5061
e95fadefeb72
new MaximumStorageMode configuration
Alain Mazy <am@osimis.io>
parents:
5044
diff
changeset
|
2979 MaxStorageMode maximumStorageMode_; |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2980 uint64_t maximumStorageSize_; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2981 unsigned int maximumPatientCount_; |
4988
8fba26292a9f
Housekeeper plugin: finalizing + integration tests ok
Alain Mazy <am@osimis.io>
parents:
4940
diff
changeset
|
2982 bool isReconstruct_; |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2983 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2984 // Auto-computed fields |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2985 bool hasExpectedInstances_; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2986 int64_t expectedInstances_; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2987 std::string hashPatient_; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2988 std::string hashStudy_; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2989 std::string hashSeries_; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2990 std::string hashInstance_; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2991 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2992 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2993 static void SetInstanceMetadata(ResourcesContent& content, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2994 std::map<MetadataType, std::string>& instanceMetadata, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2995 int64_t instance, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2996 MetadataType metadata, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2997 const std::string& value) |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2998 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2999 content.AddMetadata(instance, metadata, value); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3000 instanceMetadata[metadata] = value; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3001 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3002 |
5036
877bc3b96476
Handle Dicom sequences in ExtraMainDicomTags and save them in the 'MainDicomSequences' metadata
Alain Mazy <am@osimis.io>
parents:
4988
diff
changeset
|
3003 static void SetMainDicomSequenceMetadata(ResourcesContent& content, |
5595
a87f2a56257d
implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5593
diff
changeset
|
3004 int64_t resource, |
a87f2a56257d
implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5593
diff
changeset
|
3005 const DicomMap& dicomSummary, |
a87f2a56257d
implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5593
diff
changeset
|
3006 ResourceType level) |
5036
877bc3b96476
Handle Dicom sequences in ExtraMainDicomTags and save them in the 'MainDicomSequences' metadata
Alain Mazy <am@osimis.io>
parents:
4988
diff
changeset
|
3007 { |
5044
6fed78e13233
Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents:
5043
diff
changeset
|
3008 std::string serialized; |
6fed78e13233
Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents:
5043
diff
changeset
|
3009 GetMainDicomSequenceMetadataContent(serialized, dicomSummary, level); |
6fed78e13233
Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents:
5043
diff
changeset
|
3010 |
6fed78e13233
Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents:
5043
diff
changeset
|
3011 if (!serialized.empty()) |
5036
877bc3b96476
Handle Dicom sequences in ExtraMainDicomTags and save them in the 'MainDicomSequences' metadata
Alain Mazy <am@osimis.io>
parents:
4988
diff
changeset
|
3012 { |
877bc3b96476
Handle Dicom sequences in ExtraMainDicomTags and save them in the 'MainDicomSequences' metadata
Alain Mazy <am@osimis.io>
parents:
4988
diff
changeset
|
3013 content.AddMetadata(resource, MetadataType_MainDicomSequences, serialized); |
877bc3b96476
Handle Dicom sequences in ExtraMainDicomTags and save them in the 'MainDicomSequences' metadata
Alain Mazy <am@osimis.io>
parents:
4988
diff
changeset
|
3014 } |
877bc3b96476
Handle Dicom sequences in ExtraMainDicomTags and save them in the 'MainDicomSequences' metadata
Alain Mazy <am@osimis.io>
parents:
4988
diff
changeset
|
3015 } |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3016 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3017 static bool ComputeExpectedNumberOfInstances(int64_t& target, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3018 const DicomMap& dicomSummary) |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3019 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3020 try |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3021 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3022 const DicomValue* value; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3023 const DicomValue* value2; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3024 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3025 if ((value = dicomSummary.TestAndGetValue(DICOM_TAG_IMAGES_IN_ACQUISITION)) != NULL && |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3026 !value->IsNull() && |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3027 !value->IsBinary() && |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3028 (value2 = dicomSummary.TestAndGetValue(DICOM_TAG_NUMBER_OF_TEMPORAL_POSITIONS)) != NULL && |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3029 !value2->IsNull() && |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3030 !value2->IsBinary()) |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3031 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3032 // Patch for series with temporal positions thanks to Will Ryder |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3033 int64_t imagesInAcquisition = boost::lexical_cast<int64_t>(value->GetContent()); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3034 int64_t countTemporalPositions = boost::lexical_cast<int64_t>(value2->GetContent()); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3035 target = imagesInAcquisition * countTemporalPositions; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3036 return (target > 0); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3037 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3038 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3039 else if ((value = dicomSummary.TestAndGetValue(DICOM_TAG_NUMBER_OF_SLICES)) != NULL && |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3040 !value->IsNull() && |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3041 !value->IsBinary() && |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3042 (value2 = dicomSummary.TestAndGetValue(DICOM_TAG_NUMBER_OF_TIME_SLICES)) != NULL && |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3043 !value2->IsBinary() && |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3044 !value2->IsNull()) |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3045 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3046 // Support of Cardio-PET images |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3047 int64_t numberOfSlices = boost::lexical_cast<int64_t>(value->GetContent()); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3048 int64_t numberOfTimeSlices = boost::lexical_cast<int64_t>(value2->GetContent()); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3049 target = numberOfSlices * numberOfTimeSlices; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3050 return (target > 0); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3051 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3052 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3053 else if ((value = dicomSummary.TestAndGetValue(DICOM_TAG_CARDIAC_NUMBER_OF_IMAGES)) != NULL && |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3054 !value->IsNull() && |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3055 !value->IsBinary()) |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3056 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3057 target = boost::lexical_cast<int64_t>(value->GetContent()); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3058 return (target > 0); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3059 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3060 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3061 catch (OrthancException&) |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3062 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3063 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3064 catch (boost::bad_lexical_cast&) |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3065 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3066 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3067 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3068 return false; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3069 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3070 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3071 public: |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3072 Operations(std::map<MetadataType, std::string>& instanceMetadata, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3073 const DicomMap& dicomSummary, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3074 const Attachments& attachments, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3075 const MetadataMap& metadata, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3076 const DicomInstanceOrigin& origin, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3077 bool overwrite, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3078 bool hasTransferSyntax, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3079 DicomTransferSyntax transferSyntax, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3080 bool hasPixelDataOffset, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3081 uint64_t pixelDataOffset, |
5316
03501a258d9e
added instance metadata "PixelDataVR"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5297
diff
changeset
|
3082 ValueRepresentation pixelDataVR, |
5061
e95fadefeb72
new MaximumStorageMode configuration
Alain Mazy <am@osimis.io>
parents:
5044
diff
changeset
|
3083 MaxStorageMode maximumStorageMode, |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3084 uint64_t maximumStorageSize, |
4988
8fba26292a9f
Housekeeper plugin: finalizing + integration tests ok
Alain Mazy <am@osimis.io>
parents:
4940
diff
changeset
|
3085 unsigned int maximumPatientCount, |
8fba26292a9f
Housekeeper plugin: finalizing + integration tests ok
Alain Mazy <am@osimis.io>
parents:
4940
diff
changeset
|
3086 bool isReconstruct) : |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3087 storeStatus_(StoreStatus_Failure), |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3088 instanceMetadata_(instanceMetadata), |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3089 dicomSummary_(dicomSummary), |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3090 attachments_(attachments), |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3091 metadata_(metadata), |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3092 origin_(origin), |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3093 overwrite_(overwrite), |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3094 hasTransferSyntax_(hasTransferSyntax), |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3095 transferSyntax_(transferSyntax), |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3096 hasPixelDataOffset_(hasPixelDataOffset), |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3097 pixelDataOffset_(pixelDataOffset), |
5316
03501a258d9e
added instance metadata "PixelDataVR"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5297
diff
changeset
|
3098 pixelDataVR_(pixelDataVR), |
5061
e95fadefeb72
new MaximumStorageMode configuration
Alain Mazy <am@osimis.io>
parents:
5044
diff
changeset
|
3099 maximumStorageMode_(maximumStorageMode), |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3100 maximumStorageSize_(maximumStorageSize), |
4988
8fba26292a9f
Housekeeper plugin: finalizing + integration tests ok
Alain Mazy <am@osimis.io>
parents:
4940
diff
changeset
|
3101 maximumPatientCount_(maximumPatientCount), |
8fba26292a9f
Housekeeper plugin: finalizing + integration tests ok
Alain Mazy <am@osimis.io>
parents:
4940
diff
changeset
|
3102 isReconstruct_(isReconstruct) |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3103 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3104 hasExpectedInstances_ = ComputeExpectedNumberOfInstances(expectedInstances_, dicomSummary); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3105 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3106 instanceMetadata_.clear(); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3107 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3108 DicomInstanceHasher hasher(dicomSummary); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3109 hashPatient_ = hasher.HashPatient(); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3110 hashStudy_ = hasher.HashStudy(); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3111 hashSeries_ = hasher.HashSeries(); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3112 hashInstance_ = hasher.HashInstance(); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3113 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3114 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3115 StoreStatus GetStoreStatus() const |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3116 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3117 return storeStatus_; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3118 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3119 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3120 virtual void Apply(ReadWriteTransaction& transaction) ORTHANC_OVERRIDE |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3121 { |
5296
5053a10da5a2
Fix orphan files remaining in storage when working with MaximumStorageSize
Alain Mazy <am@osimis.io>
parents:
5249
diff
changeset
|
3122 IDatabaseWrapper::CreateInstanceResult status; |
5053a10da5a2
Fix orphan files remaining in storage when working with MaximumStorageSize
Alain Mazy <am@osimis.io>
parents:
5249
diff
changeset
|
3123 int64_t instanceId; |
5053a10da5a2
Fix orphan files remaining in storage when working with MaximumStorageSize
Alain Mazy <am@osimis.io>
parents:
5249
diff
changeset
|
3124 |
5053a10da5a2
Fix orphan files remaining in storage when working with MaximumStorageSize
Alain Mazy <am@osimis.io>
parents:
5249
diff
changeset
|
3125 bool isNewInstance = transaction.CreateInstance(status, instanceId, hashPatient_, |
5053a10da5a2
Fix orphan files remaining in storage when working with MaximumStorageSize
Alain Mazy <am@osimis.io>
parents:
5249
diff
changeset
|
3126 hashStudy_, hashSeries_, hashInstance_); |
5053a10da5a2
Fix orphan files remaining in storage when working with MaximumStorageSize
Alain Mazy <am@osimis.io>
parents:
5249
diff
changeset
|
3127 |
5053a10da5a2
Fix orphan files remaining in storage when working with MaximumStorageSize
Alain Mazy <am@osimis.io>
parents:
5249
diff
changeset
|
3128 if (isReconstruct_ && isNewInstance) |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3129 { |
5296
5053a10da5a2
Fix orphan files remaining in storage when working with MaximumStorageSize
Alain Mazy <am@osimis.io>
parents:
5249
diff
changeset
|
3130 // In case of reconstruct, we just want to modify the attachments and some metadata like the TransferSyntex |
5053a10da5a2
Fix orphan files remaining in storage when working with MaximumStorageSize
Alain Mazy <am@osimis.io>
parents:
5249
diff
changeset
|
3131 // The DicomTags and many metadata have already been updated before we get here in ReconstructInstance |
5053a10da5a2
Fix orphan files remaining in storage when working with MaximumStorageSize
Alain Mazy <am@osimis.io>
parents:
5249
diff
changeset
|
3132 throw OrthancException(ErrorCode_InternalError, "New instance while reconstructing; this should not happen."); |
5053a10da5a2
Fix orphan files remaining in storage when working with MaximumStorageSize
Alain Mazy <am@osimis.io>
parents:
5249
diff
changeset
|
3133 } |
5053a10da5a2
Fix orphan files remaining in storage when working with MaximumStorageSize
Alain Mazy <am@osimis.io>
parents:
5249
diff
changeset
|
3134 |
5053a10da5a2
Fix orphan files remaining in storage when working with MaximumStorageSize
Alain Mazy <am@osimis.io>
parents:
5249
diff
changeset
|
3135 // Check whether this instance is already stored |
5053a10da5a2
Fix orphan files remaining in storage when working with MaximumStorageSize
Alain Mazy <am@osimis.io>
parents:
5249
diff
changeset
|
3136 if (!isNewInstance && !isReconstruct_) |
5053a10da5a2
Fix orphan files remaining in storage when working with MaximumStorageSize
Alain Mazy <am@osimis.io>
parents:
5249
diff
changeset
|
3137 { |
5053a10da5a2
Fix orphan files remaining in storage when working with MaximumStorageSize
Alain Mazy <am@osimis.io>
parents:
5249
diff
changeset
|
3138 // The instance already exists |
5053a10da5a2
Fix orphan files remaining in storage when working with MaximumStorageSize
Alain Mazy <am@osimis.io>
parents:
5249
diff
changeset
|
3139 if (overwrite_) |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3140 { |
5296
5053a10da5a2
Fix orphan files remaining in storage when working with MaximumStorageSize
Alain Mazy <am@osimis.io>
parents:
5249
diff
changeset
|
3141 // Overwrite the old instance |
5053a10da5a2
Fix orphan files remaining in storage when working with MaximumStorageSize
Alain Mazy <am@osimis.io>
parents:
5249
diff
changeset
|
3142 LOG(INFO) << "Overwriting instance: " << hashInstance_; |
5053a10da5a2
Fix orphan files remaining in storage when working with MaximumStorageSize
Alain Mazy <am@osimis.io>
parents:
5249
diff
changeset
|
3143 transaction.DeleteResource(instanceId); |
5053a10da5a2
Fix orphan files remaining in storage when working with MaximumStorageSize
Alain Mazy <am@osimis.io>
parents:
5249
diff
changeset
|
3144 |
5053a10da5a2
Fix orphan files remaining in storage when working with MaximumStorageSize
Alain Mazy <am@osimis.io>
parents:
5249
diff
changeset
|
3145 // Re-create the instance, now that the old one is removed |
5053a10da5a2
Fix orphan files remaining in storage when working with MaximumStorageSize
Alain Mazy <am@osimis.io>
parents:
5249
diff
changeset
|
3146 if (!transaction.CreateInstance(status, instanceId, hashPatient_, |
5053a10da5a2
Fix orphan files remaining in storage when working with MaximumStorageSize
Alain Mazy <am@osimis.io>
parents:
5249
diff
changeset
|
3147 hashStudy_, hashSeries_, hashInstance_)) |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3148 { |
5456
06eb8bc9f024
raise 409 if multiple clients are writing the same instance at the same time
Alain Mazy <am@osimis.io>
parents:
5455
diff
changeset
|
3149 // Note that, sometime, it does not create a new instance, |
06eb8bc9f024
raise 409 if multiple clients are writing the same instance at the same time
Alain Mazy <am@osimis.io>
parents:
5455
diff
changeset
|
3150 // in very rare occasions in READ COMMITTED mode when multiple clients are pushing the same instance at the same time, |
06eb8bc9f024
raise 409 if multiple clients are writing the same instance at the same time
Alain Mazy <am@osimis.io>
parents:
5455
diff
changeset
|
3151 // this thread will not create the instance because another thread has created it in the meantime. |
06eb8bc9f024
raise 409 if multiple clients are writing the same instance at the same time
Alain Mazy <am@osimis.io>
parents:
5455
diff
changeset
|
3152 // At the end, there is always a thread that creates the instance and this is what we expect. |
5464
38f1d06875ad
delete attachment in case of same instance being uploaded multiple times at the same time
Alain Mazy <am@osimis.io>
parents:
5456
diff
changeset
|
3153 |
38f1d06875ad
delete attachment in case of same instance being uploaded multiple times at the same time
Alain Mazy <am@osimis.io>
parents:
5456
diff
changeset
|
3154 // Note, we must delete the attachments that have already been stored from this failed insertion (they have not yet been added into the DB) |
38f1d06875ad
delete attachment in case of same instance being uploaded multiple times at the same time
Alain Mazy <am@osimis.io>
parents:
5456
diff
changeset
|
3155 throw OrthancException(ErrorCode_DuplicateResource, "No new instance while overwriting; this might happen if another client has pushed the same instance at the same time."); |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3156 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3157 } |
5296
5053a10da5a2
Fix orphan files remaining in storage when working with MaximumStorageSize
Alain Mazy <am@osimis.io>
parents:
5249
diff
changeset
|
3158 else |
5053a10da5a2
Fix orphan files remaining in storage when working with MaximumStorageSize
Alain Mazy <am@osimis.io>
parents:
5249
diff
changeset
|
3159 { |
5053a10da5a2
Fix orphan files remaining in storage when working with MaximumStorageSize
Alain Mazy <am@osimis.io>
parents:
5249
diff
changeset
|
3160 // Do nothing if the instance already exists and overwriting is disabled |
5053a10da5a2
Fix orphan files remaining in storage when working with MaximumStorageSize
Alain Mazy <am@osimis.io>
parents:
5249
diff
changeset
|
3161 transaction.GetAllMetadata(instanceMetadata_, instanceId); |
5053a10da5a2
Fix orphan files remaining in storage when working with MaximumStorageSize
Alain Mazy <am@osimis.io>
parents:
5249
diff
changeset
|
3162 storeStatus_ = StoreStatus_AlreadyStored; |
5053a10da5a2
Fix orphan files remaining in storage when working with MaximumStorageSize
Alain Mazy <am@osimis.io>
parents:
5249
diff
changeset
|
3163 return; |
5053a10da5a2
Fix orphan files remaining in storage when working with MaximumStorageSize
Alain Mazy <am@osimis.io>
parents:
5249
diff
changeset
|
3164 } |
5053a10da5a2
Fix orphan files remaining in storage when working with MaximumStorageSize
Alain Mazy <am@osimis.io>
parents:
5249
diff
changeset
|
3165 } |
5053a10da5a2
Fix orphan files remaining in storage when working with MaximumStorageSize
Alain Mazy <am@osimis.io>
parents:
5249
diff
changeset
|
3166 |
5053a10da5a2
Fix orphan files remaining in storage when working with MaximumStorageSize
Alain Mazy <am@osimis.io>
parents:
5249
diff
changeset
|
3167 |
5053a10da5a2
Fix orphan files remaining in storage when working with MaximumStorageSize
Alain Mazy <am@osimis.io>
parents:
5249
diff
changeset
|
3168 if (!isReconstruct_) // don't signal new resources if this is a reconstruction |
5053a10da5a2
Fix orphan files remaining in storage when working with MaximumStorageSize
Alain Mazy <am@osimis.io>
parents:
5249
diff
changeset
|
3169 { |
5053a10da5a2
Fix orphan files remaining in storage when working with MaximumStorageSize
Alain Mazy <am@osimis.io>
parents:
5249
diff
changeset
|
3170 // Warn about the creation of new resources. The order must be |
5053a10da5a2
Fix orphan files remaining in storage when working with MaximumStorageSize
Alain Mazy <am@osimis.io>
parents:
5249
diff
changeset
|
3171 // from instance to patient. |
5053a10da5a2
Fix orphan files remaining in storage when working with MaximumStorageSize
Alain Mazy <am@osimis.io>
parents:
5249
diff
changeset
|
3172 |
5053a10da5a2
Fix orphan files remaining in storage when working with MaximumStorageSize
Alain Mazy <am@osimis.io>
parents:
5249
diff
changeset
|
3173 // NB: In theory, could be sped up by grouping the underlying |
5053a10da5a2
Fix orphan files remaining in storage when working with MaximumStorageSize
Alain Mazy <am@osimis.io>
parents:
5249
diff
changeset
|
3174 // calls to "transaction.LogChange()". However, this would only have an |
5053a10da5a2
Fix orphan files remaining in storage when working with MaximumStorageSize
Alain Mazy <am@osimis.io>
parents:
5249
diff
changeset
|
3175 // impact when new patient/study/series get created, which |
5053a10da5a2
Fix orphan files remaining in storage when working with MaximumStorageSize
Alain Mazy <am@osimis.io>
parents:
5249
diff
changeset
|
3176 // occurs far less often that creating new instances. The |
5053a10da5a2
Fix orphan files remaining in storage when working with MaximumStorageSize
Alain Mazy <am@osimis.io>
parents:
5249
diff
changeset
|
3177 // positive impact looks marginal in practice. |
5053a10da5a2
Fix orphan files remaining in storage when working with MaximumStorageSize
Alain Mazy <am@osimis.io>
parents:
5249
diff
changeset
|
3178 transaction.LogChange(instanceId, ChangeType_NewInstance, ResourceType_Instance, hashInstance_); |
5053a10da5a2
Fix orphan files remaining in storage when working with MaximumStorageSize
Alain Mazy <am@osimis.io>
parents:
5249
diff
changeset
|
3179 |
5053a10da5a2
Fix orphan files remaining in storage when working with MaximumStorageSize
Alain Mazy <am@osimis.io>
parents:
5249
diff
changeset
|
3180 if (status.isNewSeries_) |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3181 { |
5296
5053a10da5a2
Fix orphan files remaining in storage when working with MaximumStorageSize
Alain Mazy <am@osimis.io>
parents:
5249
diff
changeset
|
3182 transaction.LogChange(status.seriesId_, ChangeType_NewSeries, ResourceType_Series, hashSeries_); |
5053a10da5a2
Fix orphan files remaining in storage when working with MaximumStorageSize
Alain Mazy <am@osimis.io>
parents:
5249
diff
changeset
|
3183 } |
5053a10da5a2
Fix orphan files remaining in storage when working with MaximumStorageSize
Alain Mazy <am@osimis.io>
parents:
5249
diff
changeset
|
3184 |
5053a10da5a2
Fix orphan files remaining in storage when working with MaximumStorageSize
Alain Mazy <am@osimis.io>
parents:
5249
diff
changeset
|
3185 if (status.isNewStudy_) |
5053a10da5a2
Fix orphan files remaining in storage when working with MaximumStorageSize
Alain Mazy <am@osimis.io>
parents:
5249
diff
changeset
|
3186 { |
5053a10da5a2
Fix orphan files remaining in storage when working with MaximumStorageSize
Alain Mazy <am@osimis.io>
parents:
5249
diff
changeset
|
3187 transaction.LogChange(status.studyId_, ChangeType_NewStudy, ResourceType_Study, hashStudy_); |
5053a10da5a2
Fix orphan files remaining in storage when working with MaximumStorageSize
Alain Mazy <am@osimis.io>
parents:
5249
diff
changeset
|
3188 } |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3189 |
5296
5053a10da5a2
Fix orphan files remaining in storage when working with MaximumStorageSize
Alain Mazy <am@osimis.io>
parents:
5249
diff
changeset
|
3190 if (status.isNewPatient_) |
5053a10da5a2
Fix orphan files remaining in storage when working with MaximumStorageSize
Alain Mazy <am@osimis.io>
parents:
5249
diff
changeset
|
3191 { |
5053a10da5a2
Fix orphan files remaining in storage when working with MaximumStorageSize
Alain Mazy <am@osimis.io>
parents:
5249
diff
changeset
|
3192 transaction.LogChange(status.patientId_, ChangeType_NewPatient, ResourceType_Patient, hashPatient_); |
5053a10da5a2
Fix orphan files remaining in storage when working with MaximumStorageSize
Alain Mazy <am@osimis.io>
parents:
5249
diff
changeset
|
3193 } |
5053a10da5a2
Fix orphan files remaining in storage when working with MaximumStorageSize
Alain Mazy <am@osimis.io>
parents:
5249
diff
changeset
|
3194 } |
5053a10da5a2
Fix orphan files remaining in storage when working with MaximumStorageSize
Alain Mazy <am@osimis.io>
parents:
5249
diff
changeset
|
3195 |
5053a10da5a2
Fix orphan files remaining in storage when working with MaximumStorageSize
Alain Mazy <am@osimis.io>
parents:
5249
diff
changeset
|
3196 // Ensure there is enough room in the storage for the new instance |
5053a10da5a2
Fix orphan files remaining in storage when working with MaximumStorageSize
Alain Mazy <am@osimis.io>
parents:
5249
diff
changeset
|
3197 uint64_t instanceSize = 0; |
5053a10da5a2
Fix orphan files remaining in storage when working with MaximumStorageSize
Alain Mazy <am@osimis.io>
parents:
5249
diff
changeset
|
3198 for (Attachments::const_iterator it = attachments_.begin(); |
5595
a87f2a56257d
implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5593
diff
changeset
|
3199 it != attachments_.end(); ++it) |
5296
5053a10da5a2
Fix orphan files remaining in storage when working with MaximumStorageSize
Alain Mazy <am@osimis.io>
parents:
5249
diff
changeset
|
3200 { |
5053a10da5a2
Fix orphan files remaining in storage when working with MaximumStorageSize
Alain Mazy <am@osimis.io>
parents:
5249
diff
changeset
|
3201 instanceSize += it->GetCompressedSize(); |
5053a10da5a2
Fix orphan files remaining in storage when working with MaximumStorageSize
Alain Mazy <am@osimis.io>
parents:
5249
diff
changeset
|
3202 } |
5053a10da5a2
Fix orphan files remaining in storage when working with MaximumStorageSize
Alain Mazy <am@osimis.io>
parents:
5249
diff
changeset
|
3203 |
5053a10da5a2
Fix orphan files remaining in storage when working with MaximumStorageSize
Alain Mazy <am@osimis.io>
parents:
5249
diff
changeset
|
3204 if (!isReconstruct_) // reconstruction should not affect recycling |
5053a10da5a2
Fix orphan files remaining in storage when working with MaximumStorageSize
Alain Mazy <am@osimis.io>
parents:
5249
diff
changeset
|
3205 { |
5053a10da5a2
Fix orphan files remaining in storage when working with MaximumStorageSize
Alain Mazy <am@osimis.io>
parents:
5249
diff
changeset
|
3206 if (maximumStorageMode_ == MaxStorageMode_Reject) |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3207 { |
5296
5053a10da5a2
Fix orphan files remaining in storage when working with MaximumStorageSize
Alain Mazy <am@osimis.io>
parents:
5249
diff
changeset
|
3208 if (transaction.HasReachedMaxStorageSize(maximumStorageSize_, instanceSize)) |
5061
e95fadefeb72
new MaximumStorageMode configuration
Alain Mazy <am@osimis.io>
parents:
5044
diff
changeset
|
3209 { |
5296
5053a10da5a2
Fix orphan files remaining in storage when working with MaximumStorageSize
Alain Mazy <am@osimis.io>
parents:
5249
diff
changeset
|
3210 storeStatus_ = StoreStatus_StorageFull; |
5053a10da5a2
Fix orphan files remaining in storage when working with MaximumStorageSize
Alain Mazy <am@osimis.io>
parents:
5249
diff
changeset
|
3211 throw OrthancException(ErrorCode_FullStorage, HttpStatus_507_InsufficientStorage, "Maximum storage size reached"); // throw to cancel the transaction |
5053a10da5a2
Fix orphan files remaining in storage when working with MaximumStorageSize
Alain Mazy <am@osimis.io>
parents:
5249
diff
changeset
|
3212 } |
5053a10da5a2
Fix orphan files remaining in storage when working with MaximumStorageSize
Alain Mazy <am@osimis.io>
parents:
5249
diff
changeset
|
3213 if (transaction.HasReachedMaxPatientCount(maximumPatientCount_, hashPatient_)) |
5053a10da5a2
Fix orphan files remaining in storage when working with MaximumStorageSize
Alain Mazy <am@osimis.io>
parents:
5249
diff
changeset
|
3214 { |
5053a10da5a2
Fix orphan files remaining in storage when working with MaximumStorageSize
Alain Mazy <am@osimis.io>
parents:
5249
diff
changeset
|
3215 storeStatus_ = StoreStatus_StorageFull; |
5053a10da5a2
Fix orphan files remaining in storage when working with MaximumStorageSize
Alain Mazy <am@osimis.io>
parents:
5249
diff
changeset
|
3216 throw OrthancException(ErrorCode_FullStorage, HttpStatus_507_InsufficientStorage, "Maximum patient count reached"); // throw to cancel the transaction |
5061
e95fadefeb72
new MaximumStorageMode configuration
Alain Mazy <am@osimis.io>
parents:
5044
diff
changeset
|
3217 } |
5296
5053a10da5a2
Fix orphan files remaining in storage when working with MaximumStorageSize
Alain Mazy <am@osimis.io>
parents:
5249
diff
changeset
|
3218 } |
5053a10da5a2
Fix orphan files remaining in storage when working with MaximumStorageSize
Alain Mazy <am@osimis.io>
parents:
5249
diff
changeset
|
3219 else |
5053a10da5a2
Fix orphan files remaining in storage when working with MaximumStorageSize
Alain Mazy <am@osimis.io>
parents:
5249
diff
changeset
|
3220 { |
5053a10da5a2
Fix orphan files remaining in storage when working with MaximumStorageSize
Alain Mazy <am@osimis.io>
parents:
5249
diff
changeset
|
3221 transaction.Recycle(maximumStorageSize_, maximumPatientCount_, |
5053a10da5a2
Fix orphan files remaining in storage when working with MaximumStorageSize
Alain Mazy <am@osimis.io>
parents:
5249
diff
changeset
|
3222 instanceSize, hashPatient_ /* don't consider the current patient for recycling */); |
5053a10da5a2
Fix orphan files remaining in storage when working with MaximumStorageSize
Alain Mazy <am@osimis.io>
parents:
5249
diff
changeset
|
3223 } |
5053a10da5a2
Fix orphan files remaining in storage when working with MaximumStorageSize
Alain Mazy <am@osimis.io>
parents:
5249
diff
changeset
|
3224 } |
5053a10da5a2
Fix orphan files remaining in storage when working with MaximumStorageSize
Alain Mazy <am@osimis.io>
parents:
5249
diff
changeset
|
3225 |
5053a10da5a2
Fix orphan files remaining in storage when working with MaximumStorageSize
Alain Mazy <am@osimis.io>
parents:
5249
diff
changeset
|
3226 // Attach the files to the newly created instance |
5053a10da5a2
Fix orphan files remaining in storage when working with MaximumStorageSize
Alain Mazy <am@osimis.io>
parents:
5249
diff
changeset
|
3227 for (Attachments::const_iterator it = attachments_.begin(); |
5595
a87f2a56257d
implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5593
diff
changeset
|
3228 it != attachments_.end(); ++it) |
5296
5053a10da5a2
Fix orphan files remaining in storage when working with MaximumStorageSize
Alain Mazy <am@osimis.io>
parents:
5249
diff
changeset
|
3229 { |
5053a10da5a2
Fix orphan files remaining in storage when working with MaximumStorageSize
Alain Mazy <am@osimis.io>
parents:
5249
diff
changeset
|
3230 if (isReconstruct_) |
5053a10da5a2
Fix orphan files remaining in storage when working with MaximumStorageSize
Alain Mazy <am@osimis.io>
parents:
5249
diff
changeset
|
3231 { |
5053a10da5a2
Fix orphan files remaining in storage when working with MaximumStorageSize
Alain Mazy <am@osimis.io>
parents:
5249
diff
changeset
|
3232 // we are replacing attachments during a reconstruction |
5053a10da5a2
Fix orphan files remaining in storage when working with MaximumStorageSize
Alain Mazy <am@osimis.io>
parents:
5249
diff
changeset
|
3233 transaction.DeleteAttachment(instanceId, it->GetContentType()); |
5053a10da5a2
Fix orphan files remaining in storage when working with MaximumStorageSize
Alain Mazy <am@osimis.io>
parents:
5249
diff
changeset
|
3234 } |
5053a10da5a2
Fix orphan files remaining in storage when working with MaximumStorageSize
Alain Mazy <am@osimis.io>
parents:
5249
diff
changeset
|
3235 |
5053a10da5a2
Fix orphan files remaining in storage when working with MaximumStorageSize
Alain Mazy <am@osimis.io>
parents:
5249
diff
changeset
|
3236 transaction.AddAttachment(instanceId, *it, 0 /* this is the first revision */); |
5053a10da5a2
Fix orphan files remaining in storage when working with MaximumStorageSize
Alain Mazy <am@osimis.io>
parents:
5249
diff
changeset
|
3237 } |
5053a10da5a2
Fix orphan files remaining in storage when working with MaximumStorageSize
Alain Mazy <am@osimis.io>
parents:
5249
diff
changeset
|
3238 |
5635
0e16e677fe64
fixed broken /instances/../tags after reconstructing studies when IngestTranscoding has changed
Alain Mazy <am@orthanc.team>
parents:
5603
diff
changeset
|
3239 ResourcesContent content(true /* new resource, metadata can be set */); |
0e16e677fe64
fixed broken /instances/../tags after reconstructing studies when IngestTranscoding has changed
Alain Mazy <am@orthanc.team>
parents:
5603
diff
changeset
|
3240 |
0e16e677fe64
fixed broken /instances/../tags after reconstructing studies when IngestTranscoding has changed
Alain Mazy <am@orthanc.team>
parents:
5603
diff
changeset
|
3241 // Attach the user-specified metadata (in case of reconstruction, metadata_ contains all past metadata, including the system ones we want to keep) |
0e16e677fe64
fixed broken /instances/../tags after reconstructing studies when IngestTranscoding has changed
Alain Mazy <am@orthanc.team>
parents:
5603
diff
changeset
|
3242 for (MetadataMap::const_iterator |
0e16e677fe64
fixed broken /instances/../tags after reconstructing studies when IngestTranscoding has changed
Alain Mazy <am@orthanc.team>
parents:
5603
diff
changeset
|
3243 it = metadata_.begin(); it != metadata_.end(); ++it) |
0e16e677fe64
fixed broken /instances/../tags after reconstructing studies when IngestTranscoding has changed
Alain Mazy <am@orthanc.team>
parents:
5603
diff
changeset
|
3244 { |
0e16e677fe64
fixed broken /instances/../tags after reconstructing studies when IngestTranscoding has changed
Alain Mazy <am@orthanc.team>
parents:
5603
diff
changeset
|
3245 switch (it->first.first) |
0e16e677fe64
fixed broken /instances/../tags after reconstructing studies when IngestTranscoding has changed
Alain Mazy <am@orthanc.team>
parents:
5603
diff
changeset
|
3246 { |
0e16e677fe64
fixed broken /instances/../tags after reconstructing studies when IngestTranscoding has changed
Alain Mazy <am@orthanc.team>
parents:
5603
diff
changeset
|
3247 case ResourceType_Patient: |
0e16e677fe64
fixed broken /instances/../tags after reconstructing studies when IngestTranscoding has changed
Alain Mazy <am@orthanc.team>
parents:
5603
diff
changeset
|
3248 content.AddMetadata(status.patientId_, it->first.second, it->second); |
0e16e677fe64
fixed broken /instances/../tags after reconstructing studies when IngestTranscoding has changed
Alain Mazy <am@orthanc.team>
parents:
5603
diff
changeset
|
3249 break; |
0e16e677fe64
fixed broken /instances/../tags after reconstructing studies when IngestTranscoding has changed
Alain Mazy <am@orthanc.team>
parents:
5603
diff
changeset
|
3250 |
0e16e677fe64
fixed broken /instances/../tags after reconstructing studies when IngestTranscoding has changed
Alain Mazy <am@orthanc.team>
parents:
5603
diff
changeset
|
3251 case ResourceType_Study: |
0e16e677fe64
fixed broken /instances/../tags after reconstructing studies when IngestTranscoding has changed
Alain Mazy <am@orthanc.team>
parents:
5603
diff
changeset
|
3252 content.AddMetadata(status.studyId_, it->first.second, it->second); |
0e16e677fe64
fixed broken /instances/../tags after reconstructing studies when IngestTranscoding has changed
Alain Mazy <am@orthanc.team>
parents:
5603
diff
changeset
|
3253 break; |
0e16e677fe64
fixed broken /instances/../tags after reconstructing studies when IngestTranscoding has changed
Alain Mazy <am@orthanc.team>
parents:
5603
diff
changeset
|
3254 |
0e16e677fe64
fixed broken /instances/../tags after reconstructing studies when IngestTranscoding has changed
Alain Mazy <am@orthanc.team>
parents:
5603
diff
changeset
|
3255 case ResourceType_Series: |
0e16e677fe64
fixed broken /instances/../tags after reconstructing studies when IngestTranscoding has changed
Alain Mazy <am@orthanc.team>
parents:
5603
diff
changeset
|
3256 content.AddMetadata(status.seriesId_, it->first.second, it->second); |
0e16e677fe64
fixed broken /instances/../tags after reconstructing studies when IngestTranscoding has changed
Alain Mazy <am@orthanc.team>
parents:
5603
diff
changeset
|
3257 break; |
0e16e677fe64
fixed broken /instances/../tags after reconstructing studies when IngestTranscoding has changed
Alain Mazy <am@orthanc.team>
parents:
5603
diff
changeset
|
3258 |
0e16e677fe64
fixed broken /instances/../tags after reconstructing studies when IngestTranscoding has changed
Alain Mazy <am@orthanc.team>
parents:
5603
diff
changeset
|
3259 case ResourceType_Instance: |
0e16e677fe64
fixed broken /instances/../tags after reconstructing studies when IngestTranscoding has changed
Alain Mazy <am@orthanc.team>
parents:
5603
diff
changeset
|
3260 SetInstanceMetadata(content, instanceMetadata_, instanceId, |
0e16e677fe64
fixed broken /instances/../tags after reconstructing studies when IngestTranscoding has changed
Alain Mazy <am@orthanc.team>
parents:
5603
diff
changeset
|
3261 it->first.second, it->second); |
0e16e677fe64
fixed broken /instances/../tags after reconstructing studies when IngestTranscoding has changed
Alain Mazy <am@orthanc.team>
parents:
5603
diff
changeset
|
3262 break; |
0e16e677fe64
fixed broken /instances/../tags after reconstructing studies when IngestTranscoding has changed
Alain Mazy <am@orthanc.team>
parents:
5603
diff
changeset
|
3263 |
0e16e677fe64
fixed broken /instances/../tags after reconstructing studies when IngestTranscoding has changed
Alain Mazy <am@orthanc.team>
parents:
5603
diff
changeset
|
3264 default: |
0e16e677fe64
fixed broken /instances/../tags after reconstructing studies when IngestTranscoding has changed
Alain Mazy <am@orthanc.team>
parents:
5603
diff
changeset
|
3265 throw OrthancException(ErrorCode_ParameterOutOfRange); |
0e16e677fe64
fixed broken /instances/../tags after reconstructing studies when IngestTranscoding has changed
Alain Mazy <am@orthanc.team>
parents:
5603
diff
changeset
|
3266 } |
0e16e677fe64
fixed broken /instances/../tags after reconstructing studies when IngestTranscoding has changed
Alain Mazy <am@orthanc.team>
parents:
5603
diff
changeset
|
3267 } |
0e16e677fe64
fixed broken /instances/../tags after reconstructing studies when IngestTranscoding has changed
Alain Mazy <am@orthanc.team>
parents:
5603
diff
changeset
|
3268 |
5296
5053a10da5a2
Fix orphan files remaining in storage when working with MaximumStorageSize
Alain Mazy <am@osimis.io>
parents:
5249
diff
changeset
|
3269 if (!isReconstruct_) |
5053a10da5a2
Fix orphan files remaining in storage when working with MaximumStorageSize
Alain Mazy <am@osimis.io>
parents:
5249
diff
changeset
|
3270 { |
5635
0e16e677fe64
fixed broken /instances/../tags after reconstructing studies when IngestTranscoding has changed
Alain Mazy <am@orthanc.team>
parents:
5603
diff
changeset
|
3271 // Populate the tags of the newly-created resources |
0e16e677fe64
fixed broken /instances/../tags after reconstructing studies when IngestTranscoding has changed
Alain Mazy <am@orthanc.team>
parents:
5603
diff
changeset
|
3272 content.AddResource(instanceId, ResourceType_Instance, dicomSummary_); |
0e16e677fe64
fixed broken /instances/../tags after reconstructing studies when IngestTranscoding has changed
Alain Mazy <am@orthanc.team>
parents:
5603
diff
changeset
|
3273 SetInstanceMetadata(content, instanceMetadata_, instanceId, MetadataType_MainDicomTagsSignature, DicomMap::GetMainDicomTagsSignature(ResourceType_Instance)); // New in Orthanc 1.11.0 |
0e16e677fe64
fixed broken /instances/../tags after reconstructing studies when IngestTranscoding has changed
Alain Mazy <am@orthanc.team>
parents:
5603
diff
changeset
|
3274 SetMainDicomSequenceMetadata(content, instanceId, dicomSummary_, ResourceType_Instance); // new in Orthanc 1.11.1 |
0e16e677fe64
fixed broken /instances/../tags after reconstructing studies when IngestTranscoding has changed
Alain Mazy <am@orthanc.team>
parents:
5603
diff
changeset
|
3275 |
0e16e677fe64
fixed broken /instances/../tags after reconstructing studies when IngestTranscoding has changed
Alain Mazy <am@orthanc.team>
parents:
5603
diff
changeset
|
3276 if (status.isNewSeries_) |
5296
5053a10da5a2
Fix orphan files remaining in storage when working with MaximumStorageSize
Alain Mazy <am@osimis.io>
parents:
5249
diff
changeset
|
3277 { |
5635
0e16e677fe64
fixed broken /instances/../tags after reconstructing studies when IngestTranscoding has changed
Alain Mazy <am@orthanc.team>
parents:
5603
diff
changeset
|
3278 content.AddResource(status.seriesId_, ResourceType_Series, dicomSummary_); |
0e16e677fe64
fixed broken /instances/../tags after reconstructing studies when IngestTranscoding has changed
Alain Mazy <am@orthanc.team>
parents:
5603
diff
changeset
|
3279 content.AddMetadata(status.seriesId_, MetadataType_MainDicomTagsSignature, DicomMap::GetMainDicomTagsSignature(ResourceType_Series)); // New in Orthanc 1.11.0 |
0e16e677fe64
fixed broken /instances/../tags after reconstructing studies when IngestTranscoding has changed
Alain Mazy <am@orthanc.team>
parents:
5603
diff
changeset
|
3280 SetMainDicomSequenceMetadata(content, status.seriesId_, dicomSummary_, ResourceType_Series); // new in Orthanc 1.11.1 |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3281 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3282 |
5635
0e16e677fe64
fixed broken /instances/../tags after reconstructing studies when IngestTranscoding has changed
Alain Mazy <am@orthanc.team>
parents:
5603
diff
changeset
|
3283 if (status.isNewStudy_) |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3284 { |
5635
0e16e677fe64
fixed broken /instances/../tags after reconstructing studies when IngestTranscoding has changed
Alain Mazy <am@orthanc.team>
parents:
5603
diff
changeset
|
3285 content.AddResource(status.studyId_, ResourceType_Study, dicomSummary_); |
0e16e677fe64
fixed broken /instances/../tags after reconstructing studies when IngestTranscoding has changed
Alain Mazy <am@orthanc.team>
parents:
5603
diff
changeset
|
3286 content.AddMetadata(status.studyId_, MetadataType_MainDicomTagsSignature, DicomMap::GetMainDicomTagsSignature(ResourceType_Study)); // New in Orthanc 1.11.0 |
0e16e677fe64
fixed broken /instances/../tags after reconstructing studies when IngestTranscoding has changed
Alain Mazy <am@orthanc.team>
parents:
5603
diff
changeset
|
3287 SetMainDicomSequenceMetadata(content, status.studyId_, dicomSummary_, ResourceType_Study); // new in Orthanc 1.11.1 |
0e16e677fe64
fixed broken /instances/../tags after reconstructing studies when IngestTranscoding has changed
Alain Mazy <am@orthanc.team>
parents:
5603
diff
changeset
|
3288 } |
0e16e677fe64
fixed broken /instances/../tags after reconstructing studies when IngestTranscoding has changed
Alain Mazy <am@orthanc.team>
parents:
5603
diff
changeset
|
3289 |
0e16e677fe64
fixed broken /instances/../tags after reconstructing studies when IngestTranscoding has changed
Alain Mazy <am@orthanc.team>
parents:
5603
diff
changeset
|
3290 if (status.isNewPatient_) |
0e16e677fe64
fixed broken /instances/../tags after reconstructing studies when IngestTranscoding has changed
Alain Mazy <am@orthanc.team>
parents:
5603
diff
changeset
|
3291 { |
0e16e677fe64
fixed broken /instances/../tags after reconstructing studies when IngestTranscoding has changed
Alain Mazy <am@orthanc.team>
parents:
5603
diff
changeset
|
3292 content.AddResource(status.patientId_, ResourceType_Patient, dicomSummary_); |
0e16e677fe64
fixed broken /instances/../tags after reconstructing studies when IngestTranscoding has changed
Alain Mazy <am@orthanc.team>
parents:
5603
diff
changeset
|
3293 content.AddMetadata(status.patientId_, MetadataType_MainDicomTagsSignature, DicomMap::GetMainDicomTagsSignature(ResourceType_Patient)); // New in Orthanc 1.11.0 |
0e16e677fe64
fixed broken /instances/../tags after reconstructing studies when IngestTranscoding has changed
Alain Mazy <am@orthanc.team>
parents:
5603
diff
changeset
|
3294 SetMainDicomSequenceMetadata(content, status.patientId_, dicomSummary_, ResourceType_Patient); // new in Orthanc 1.11.1 |
0e16e677fe64
fixed broken /instances/../tags after reconstructing studies when IngestTranscoding has changed
Alain Mazy <am@orthanc.team>
parents:
5603
diff
changeset
|
3295 } |
0e16e677fe64
fixed broken /instances/../tags after reconstructing studies when IngestTranscoding has changed
Alain Mazy <am@orthanc.team>
parents:
5603
diff
changeset
|
3296 |
0e16e677fe64
fixed broken /instances/../tags after reconstructing studies when IngestTranscoding has changed
Alain Mazy <am@orthanc.team>
parents:
5603
diff
changeset
|
3297 // Attach the auto-computed metadata for the patient/study/series levels |
0e16e677fe64
fixed broken /instances/../tags after reconstructing studies when IngestTranscoding has changed
Alain Mazy <am@orthanc.team>
parents:
5603
diff
changeset
|
3298 std::string now = SystemToolbox::GetNowIsoString(true /* use UTC time (not local time) */); |
0e16e677fe64
fixed broken /instances/../tags after reconstructing studies when IngestTranscoding has changed
Alain Mazy <am@orthanc.team>
parents:
5603
diff
changeset
|
3299 content.AddMetadata(status.seriesId_, MetadataType_LastUpdate, now); |
0e16e677fe64
fixed broken /instances/../tags after reconstructing studies when IngestTranscoding has changed
Alain Mazy <am@orthanc.team>
parents:
5603
diff
changeset
|
3300 content.AddMetadata(status.studyId_, MetadataType_LastUpdate, now); |
0e16e677fe64
fixed broken /instances/../tags after reconstructing studies when IngestTranscoding has changed
Alain Mazy <am@orthanc.team>
parents:
5603
diff
changeset
|
3301 content.AddMetadata(status.patientId_, MetadataType_LastUpdate, now); |
0e16e677fe64
fixed broken /instances/../tags after reconstructing studies when IngestTranscoding has changed
Alain Mazy <am@orthanc.team>
parents:
5603
diff
changeset
|
3302 |
0e16e677fe64
fixed broken /instances/../tags after reconstructing studies when IngestTranscoding has changed
Alain Mazy <am@orthanc.team>
parents:
5603
diff
changeset
|
3303 if (status.isNewSeries_) |
0e16e677fe64
fixed broken /instances/../tags after reconstructing studies when IngestTranscoding has changed
Alain Mazy <am@orthanc.team>
parents:
5603
diff
changeset
|
3304 { |
0e16e677fe64
fixed broken /instances/../tags after reconstructing studies when IngestTranscoding has changed
Alain Mazy <am@orthanc.team>
parents:
5603
diff
changeset
|
3305 if (hasExpectedInstances_) |
5296
5053a10da5a2
Fix orphan files remaining in storage when working with MaximumStorageSize
Alain Mazy <am@osimis.io>
parents:
5249
diff
changeset
|
3306 { |
5635
0e16e677fe64
fixed broken /instances/../tags after reconstructing studies when IngestTranscoding has changed
Alain Mazy <am@orthanc.team>
parents:
5603
diff
changeset
|
3307 content.AddMetadata(status.seriesId_, MetadataType_Series_ExpectedNumberOfInstances, |
0e16e677fe64
fixed broken /instances/../tags after reconstructing studies when IngestTranscoding has changed
Alain Mazy <am@orthanc.team>
parents:
5603
diff
changeset
|
3308 boost::lexical_cast<std::string>(expectedInstances_)); |
5296
5053a10da5a2
Fix orphan files remaining in storage when working with MaximumStorageSize
Alain Mazy <am@osimis.io>
parents:
5249
diff
changeset
|
3309 } |
5053a10da5a2
Fix orphan files remaining in storage when working with MaximumStorageSize
Alain Mazy <am@osimis.io>
parents:
5249
diff
changeset
|
3310 |
5635
0e16e677fe64
fixed broken /instances/../tags after reconstructing studies when IngestTranscoding has changed
Alain Mazy <am@orthanc.team>
parents:
5603
diff
changeset
|
3311 // New in Orthanc 1.9.0 |
0e16e677fe64
fixed broken /instances/../tags after reconstructing studies when IngestTranscoding has changed
Alain Mazy <am@orthanc.team>
parents:
5603
diff
changeset
|
3312 content.AddMetadata(status.seriesId_, MetadataType_RemoteAet, |
0e16e677fe64
fixed broken /instances/../tags after reconstructing studies when IngestTranscoding has changed
Alain Mazy <am@orthanc.team>
parents:
5603
diff
changeset
|
3313 origin_.GetRemoteAetC()); |
5296
5053a10da5a2
Fix orphan files remaining in storage when working with MaximumStorageSize
Alain Mazy <am@osimis.io>
parents:
5249
diff
changeset
|
3314 } |
5635
0e16e677fe64
fixed broken /instances/../tags after reconstructing studies when IngestTranscoding has changed
Alain Mazy <am@orthanc.team>
parents:
5603
diff
changeset
|
3315 // Attach the auto-computed metadata for the instance level, |
0e16e677fe64
fixed broken /instances/../tags after reconstructing studies when IngestTranscoding has changed
Alain Mazy <am@orthanc.team>
parents:
5603
diff
changeset
|
3316 // reflecting these additions into the input metadata map |
0e16e677fe64
fixed broken /instances/../tags after reconstructing studies when IngestTranscoding has changed
Alain Mazy <am@orthanc.team>
parents:
5603
diff
changeset
|
3317 SetInstanceMetadata(content, instanceMetadata_, instanceId, |
0e16e677fe64
fixed broken /instances/../tags after reconstructing studies when IngestTranscoding has changed
Alain Mazy <am@orthanc.team>
parents:
5603
diff
changeset
|
3318 MetadataType_Instance_ReceptionDate, now); |
0e16e677fe64
fixed broken /instances/../tags after reconstructing studies when IngestTranscoding has changed
Alain Mazy <am@orthanc.team>
parents:
5603
diff
changeset
|
3319 SetInstanceMetadata(content, instanceMetadata_, instanceId, MetadataType_RemoteAet, |
0e16e677fe64
fixed broken /instances/../tags after reconstructing studies when IngestTranscoding has changed
Alain Mazy <am@orthanc.team>
parents:
5603
diff
changeset
|
3320 origin_.GetRemoteAetC()); |
0e16e677fe64
fixed broken /instances/../tags after reconstructing studies when IngestTranscoding has changed
Alain Mazy <am@orthanc.team>
parents:
5603
diff
changeset
|
3321 SetInstanceMetadata(content, instanceMetadata_, instanceId, MetadataType_Instance_Origin, |
0e16e677fe64
fixed broken /instances/../tags after reconstructing studies when IngestTranscoding has changed
Alain Mazy <am@orthanc.team>
parents:
5603
diff
changeset
|
3322 EnumerationToString(origin_.GetRequestOrigin())); |
0e16e677fe64
fixed broken /instances/../tags after reconstructing studies when IngestTranscoding has changed
Alain Mazy <am@orthanc.team>
parents:
5603
diff
changeset
|
3323 |
0e16e677fe64
fixed broken /instances/../tags after reconstructing studies when IngestTranscoding has changed
Alain Mazy <am@orthanc.team>
parents:
5603
diff
changeset
|
3324 std::string s; |
0e16e677fe64
fixed broken /instances/../tags after reconstructing studies when IngestTranscoding has changed
Alain Mazy <am@orthanc.team>
parents:
5603
diff
changeset
|
3325 |
0e16e677fe64
fixed broken /instances/../tags after reconstructing studies when IngestTranscoding has changed
Alain Mazy <am@orthanc.team>
parents:
5603
diff
changeset
|
3326 if (origin_.LookupRemoteIp(s)) |
5296
5053a10da5a2
Fix orphan files remaining in storage when working with MaximumStorageSize
Alain Mazy <am@osimis.io>
parents:
5249
diff
changeset
|
3327 { |
5635
0e16e677fe64
fixed broken /instances/../tags after reconstructing studies when IngestTranscoding has changed
Alain Mazy <am@orthanc.team>
parents:
5603
diff
changeset
|
3328 // New in Orthanc 1.4.0 |
0e16e677fe64
fixed broken /instances/../tags after reconstructing studies when IngestTranscoding has changed
Alain Mazy <am@orthanc.team>
parents:
5603
diff
changeset
|
3329 SetInstanceMetadata(content, instanceMetadata_, instanceId, |
0e16e677fe64
fixed broken /instances/../tags after reconstructing studies when IngestTranscoding has changed
Alain Mazy <am@orthanc.team>
parents:
5603
diff
changeset
|
3330 MetadataType_Instance_RemoteIp, s); |
0e16e677fe64
fixed broken /instances/../tags after reconstructing studies when IngestTranscoding has changed
Alain Mazy <am@orthanc.team>
parents:
5603
diff
changeset
|
3331 } |
0e16e677fe64
fixed broken /instances/../tags after reconstructing studies when IngestTranscoding has changed
Alain Mazy <am@orthanc.team>
parents:
5603
diff
changeset
|
3332 |
0e16e677fe64
fixed broken /instances/../tags after reconstructing studies when IngestTranscoding has changed
Alain Mazy <am@orthanc.team>
parents:
5603
diff
changeset
|
3333 if (origin_.LookupCalledAet(s)) |
0e16e677fe64
fixed broken /instances/../tags after reconstructing studies when IngestTranscoding has changed
Alain Mazy <am@orthanc.team>
parents:
5603
diff
changeset
|
3334 { |
0e16e677fe64
fixed broken /instances/../tags after reconstructing studies when IngestTranscoding has changed
Alain Mazy <am@orthanc.team>
parents:
5603
diff
changeset
|
3335 // New in Orthanc 1.4.0 |
5296
5053a10da5a2
Fix orphan files remaining in storage when working with MaximumStorageSize
Alain Mazy <am@osimis.io>
parents:
5249
diff
changeset
|
3336 SetInstanceMetadata(content, instanceMetadata_, instanceId, |
5635
0e16e677fe64
fixed broken /instances/../tags after reconstructing studies when IngestTranscoding has changed
Alain Mazy <am@orthanc.team>
parents:
5603
diff
changeset
|
3337 MetadataType_Instance_CalledAet, s); |
0e16e677fe64
fixed broken /instances/../tags after reconstructing studies when IngestTranscoding has changed
Alain Mazy <am@orthanc.team>
parents:
5603
diff
changeset
|
3338 } |
0e16e677fe64
fixed broken /instances/../tags after reconstructing studies when IngestTranscoding has changed
Alain Mazy <am@orthanc.team>
parents:
5603
diff
changeset
|
3339 |
0e16e677fe64
fixed broken /instances/../tags after reconstructing studies when IngestTranscoding has changed
Alain Mazy <am@orthanc.team>
parents:
5603
diff
changeset
|
3340 if (origin_.LookupHttpUsername(s)) |
0e16e677fe64
fixed broken /instances/../tags after reconstructing studies when IngestTranscoding has changed
Alain Mazy <am@orthanc.team>
parents:
5603
diff
changeset
|
3341 { |
0e16e677fe64
fixed broken /instances/../tags after reconstructing studies when IngestTranscoding has changed
Alain Mazy <am@orthanc.team>
parents:
5603
diff
changeset
|
3342 // New in Orthanc 1.4.0 |
0e16e677fe64
fixed broken /instances/../tags after reconstructing studies when IngestTranscoding has changed
Alain Mazy <am@orthanc.team>
parents:
5603
diff
changeset
|
3343 SetInstanceMetadata(content, instanceMetadata_, instanceId, |
0e16e677fe64
fixed broken /instances/../tags after reconstructing studies when IngestTranscoding has changed
Alain Mazy <am@orthanc.team>
parents:
5603
diff
changeset
|
3344 MetadataType_Instance_HttpUsername, s); |
5296
5053a10da5a2
Fix orphan files remaining in storage when working with MaximumStorageSize
Alain Mazy <am@osimis.io>
parents:
5249
diff
changeset
|
3345 } |
5635
0e16e677fe64
fixed broken /instances/../tags after reconstructing studies when IngestTranscoding has changed
Alain Mazy <am@orthanc.team>
parents:
5603
diff
changeset
|
3346 } |
0e16e677fe64
fixed broken /instances/../tags after reconstructing studies when IngestTranscoding has changed
Alain Mazy <am@orthanc.team>
parents:
5603
diff
changeset
|
3347 |
0e16e677fe64
fixed broken /instances/../tags after reconstructing studies when IngestTranscoding has changed
Alain Mazy <am@orthanc.team>
parents:
5603
diff
changeset
|
3348 // Following metadatas are also updated if reconstructing the instance. |
0e16e677fe64
fixed broken /instances/../tags after reconstructing studies when IngestTranscoding has changed
Alain Mazy <am@orthanc.team>
parents:
5603
diff
changeset
|
3349 // They might be missing since they have been introduced along Orthanc versions. |
0e16e677fe64
fixed broken /instances/../tags after reconstructing studies when IngestTranscoding has changed
Alain Mazy <am@orthanc.team>
parents:
5603
diff
changeset
|
3350 |
0e16e677fe64
fixed broken /instances/../tags after reconstructing studies when IngestTranscoding has changed
Alain Mazy <am@orthanc.team>
parents:
5603
diff
changeset
|
3351 if (hasTransferSyntax_) |
0e16e677fe64
fixed broken /instances/../tags after reconstructing studies when IngestTranscoding has changed
Alain Mazy <am@orthanc.team>
parents:
5603
diff
changeset
|
3352 { |
0e16e677fe64
fixed broken /instances/../tags after reconstructing studies when IngestTranscoding has changed
Alain Mazy <am@orthanc.team>
parents:
5603
diff
changeset
|
3353 // New in Orthanc 1.2.0 |
0e16e677fe64
fixed broken /instances/../tags after reconstructing studies when IngestTranscoding has changed
Alain Mazy <am@orthanc.team>
parents:
5603
diff
changeset
|
3354 SetInstanceMetadata(content, instanceMetadata_, instanceId, |
0e16e677fe64
fixed broken /instances/../tags after reconstructing studies when IngestTranscoding has changed
Alain Mazy <am@orthanc.team>
parents:
5603
diff
changeset
|
3355 MetadataType_Instance_TransferSyntax, |
0e16e677fe64
fixed broken /instances/../tags after reconstructing studies when IngestTranscoding has changed
Alain Mazy <am@orthanc.team>
parents:
5603
diff
changeset
|
3356 GetTransferSyntaxUid(transferSyntax_)); |
0e16e677fe64
fixed broken /instances/../tags after reconstructing studies when IngestTranscoding has changed
Alain Mazy <am@orthanc.team>
parents:
5603
diff
changeset
|
3357 } |
0e16e677fe64
fixed broken /instances/../tags after reconstructing studies when IngestTranscoding has changed
Alain Mazy <am@orthanc.team>
parents:
5603
diff
changeset
|
3358 |
0e16e677fe64
fixed broken /instances/../tags after reconstructing studies when IngestTranscoding has changed
Alain Mazy <am@orthanc.team>
parents:
5603
diff
changeset
|
3359 if (hasPixelDataOffset_) |
0e16e677fe64
fixed broken /instances/../tags after reconstructing studies when IngestTranscoding has changed
Alain Mazy <am@orthanc.team>
parents:
5603
diff
changeset
|
3360 { |
0e16e677fe64
fixed broken /instances/../tags after reconstructing studies when IngestTranscoding has changed
Alain Mazy <am@orthanc.team>
parents:
5603
diff
changeset
|
3361 // New in Orthanc 1.9.1 |
0e16e677fe64
fixed broken /instances/../tags after reconstructing studies when IngestTranscoding has changed
Alain Mazy <am@orthanc.team>
parents:
5603
diff
changeset
|
3362 SetInstanceMetadata(content, instanceMetadata_, instanceId, |
0e16e677fe64
fixed broken /instances/../tags after reconstructing studies when IngestTranscoding has changed
Alain Mazy <am@orthanc.team>
parents:
5603
diff
changeset
|
3363 MetadataType_Instance_PixelDataOffset, |
0e16e677fe64
fixed broken /instances/../tags after reconstructing studies when IngestTranscoding has changed
Alain Mazy <am@orthanc.team>
parents:
5603
diff
changeset
|
3364 boost::lexical_cast<std::string>(pixelDataOffset_)); |
0e16e677fe64
fixed broken /instances/../tags after reconstructing studies when IngestTranscoding has changed
Alain Mazy <am@orthanc.team>
parents:
5603
diff
changeset
|
3365 |
0e16e677fe64
fixed broken /instances/../tags after reconstructing studies when IngestTranscoding has changed
Alain Mazy <am@orthanc.team>
parents:
5603
diff
changeset
|
3366 // New in Orthanc 1.12.1 |
0e16e677fe64
fixed broken /instances/../tags after reconstructing studies when IngestTranscoding has changed
Alain Mazy <am@orthanc.team>
parents:
5603
diff
changeset
|
3367 if (dicomSummary_.GuessPixelDataValueRepresentation(transferSyntax_) != pixelDataVR_) |
5296
5053a10da5a2
Fix orphan files remaining in storage when working with MaximumStorageSize
Alain Mazy <am@osimis.io>
parents:
5249
diff
changeset
|
3368 { |
5635
0e16e677fe64
fixed broken /instances/../tags after reconstructing studies when IngestTranscoding has changed
Alain Mazy <am@orthanc.team>
parents:
5603
diff
changeset
|
3369 // Store the VR of pixel data if it doesn't comply with the standard |
5296
5053a10da5a2
Fix orphan files remaining in storage when working with MaximumStorageSize
Alain Mazy <am@osimis.io>
parents:
5249
diff
changeset
|
3370 SetInstanceMetadata(content, instanceMetadata_, instanceId, |
5635
0e16e677fe64
fixed broken /instances/../tags after reconstructing studies when IngestTranscoding has changed
Alain Mazy <am@orthanc.team>
parents:
5603
diff
changeset
|
3371 MetadataType_Instance_PixelDataVR, |
0e16e677fe64
fixed broken /instances/../tags after reconstructing studies when IngestTranscoding has changed
Alain Mazy <am@orthanc.team>
parents:
5603
diff
changeset
|
3372 EnumerationToString(pixelDataVR_)); |
5296
5053a10da5a2
Fix orphan files remaining in storage when working with MaximumStorageSize
Alain Mazy <am@osimis.io>
parents:
5249
diff
changeset
|
3373 } |
5635
0e16e677fe64
fixed broken /instances/../tags after reconstructing studies when IngestTranscoding has changed
Alain Mazy <am@orthanc.team>
parents:
5603
diff
changeset
|
3374 } |
0e16e677fe64
fixed broken /instances/../tags after reconstructing studies when IngestTranscoding has changed
Alain Mazy <am@orthanc.team>
parents:
5603
diff
changeset
|
3375 |
0e16e677fe64
fixed broken /instances/../tags after reconstructing studies when IngestTranscoding has changed
Alain Mazy <am@orthanc.team>
parents:
5603
diff
changeset
|
3376 const DicomValue* value; |
0e16e677fe64
fixed broken /instances/../tags after reconstructing studies when IngestTranscoding has changed
Alain Mazy <am@orthanc.team>
parents:
5603
diff
changeset
|
3377 if ((value = dicomSummary_.TestAndGetValue(DICOM_TAG_SOP_CLASS_UID)) != NULL && |
0e16e677fe64
fixed broken /instances/../tags after reconstructing studies when IngestTranscoding has changed
Alain Mazy <am@orthanc.team>
parents:
5603
diff
changeset
|
3378 !value->IsNull() && |
0e16e677fe64
fixed broken /instances/../tags after reconstructing studies when IngestTranscoding has changed
Alain Mazy <am@orthanc.team>
parents:
5603
diff
changeset
|
3379 !value->IsBinary()) |
0e16e677fe64
fixed broken /instances/../tags after reconstructing studies when IngestTranscoding has changed
Alain Mazy <am@orthanc.team>
parents:
5603
diff
changeset
|
3380 { |
0e16e677fe64
fixed broken /instances/../tags after reconstructing studies when IngestTranscoding has changed
Alain Mazy <am@orthanc.team>
parents:
5603
diff
changeset
|
3381 SetInstanceMetadata(content, instanceMetadata_, instanceId, |
0e16e677fe64
fixed broken /instances/../tags after reconstructing studies when IngestTranscoding has changed
Alain Mazy <am@orthanc.team>
parents:
5603
diff
changeset
|
3382 MetadataType_Instance_SopClassUid, value->GetContent()); |
0e16e677fe64
fixed broken /instances/../tags after reconstructing studies when IngestTranscoding has changed
Alain Mazy <am@orthanc.team>
parents:
5603
diff
changeset
|
3383 } |
0e16e677fe64
fixed broken /instances/../tags after reconstructing studies when IngestTranscoding has changed
Alain Mazy <am@orthanc.team>
parents:
5603
diff
changeset
|
3384 |
0e16e677fe64
fixed broken /instances/../tags after reconstructing studies when IngestTranscoding has changed
Alain Mazy <am@orthanc.team>
parents:
5603
diff
changeset
|
3385 |
0e16e677fe64
fixed broken /instances/../tags after reconstructing studies when IngestTranscoding has changed
Alain Mazy <am@orthanc.team>
parents:
5603
diff
changeset
|
3386 if ((value = dicomSummary_.TestAndGetValue(DICOM_TAG_INSTANCE_NUMBER)) != NULL || |
0e16e677fe64
fixed broken /instances/../tags after reconstructing studies when IngestTranscoding has changed
Alain Mazy <am@orthanc.team>
parents:
5603
diff
changeset
|
3387 (value = dicomSummary_.TestAndGetValue(DICOM_TAG_IMAGE_INDEX)) != NULL) |
0e16e677fe64
fixed broken /instances/../tags after reconstructing studies when IngestTranscoding has changed
Alain Mazy <am@orthanc.team>
parents:
5603
diff
changeset
|
3388 { |
0e16e677fe64
fixed broken /instances/../tags after reconstructing studies when IngestTranscoding has changed
Alain Mazy <am@orthanc.team>
parents:
5603
diff
changeset
|
3389 if (!value->IsNull() && |
5296
5053a10da5a2
Fix orphan files remaining in storage when working with MaximumStorageSize
Alain Mazy <am@osimis.io>
parents:
5249
diff
changeset
|
3390 !value->IsBinary()) |
5053a10da5a2
Fix orphan files remaining in storage when working with MaximumStorageSize
Alain Mazy <am@osimis.io>
parents:
5249
diff
changeset
|
3391 { |
5053a10da5a2
Fix orphan files remaining in storage when working with MaximumStorageSize
Alain Mazy <am@osimis.io>
parents:
5249
diff
changeset
|
3392 SetInstanceMetadata(content, instanceMetadata_, instanceId, |
5635
0e16e677fe64
fixed broken /instances/../tags after reconstructing studies when IngestTranscoding has changed
Alain Mazy <am@orthanc.team>
parents:
5603
diff
changeset
|
3393 MetadataType_Instance_IndexInSeries, Toolbox::StripSpaces(value->GetContent())); |
5296
5053a10da5a2
Fix orphan files remaining in storage when working with MaximumStorageSize
Alain Mazy <am@osimis.io>
parents:
5249
diff
changeset
|
3394 } |
5635
0e16e677fe64
fixed broken /instances/../tags after reconstructing studies when IngestTranscoding has changed
Alain Mazy <am@orthanc.team>
parents:
5603
diff
changeset
|
3395 } |
0e16e677fe64
fixed broken /instances/../tags after reconstructing studies when IngestTranscoding has changed
Alain Mazy <am@orthanc.team>
parents:
5603
diff
changeset
|
3396 |
0e16e677fe64
fixed broken /instances/../tags after reconstructing studies when IngestTranscoding has changed
Alain Mazy <am@orthanc.team>
parents:
5603
diff
changeset
|
3397 |
0e16e677fe64
fixed broken /instances/../tags after reconstructing studies when IngestTranscoding has changed
Alain Mazy <am@orthanc.team>
parents:
5603
diff
changeset
|
3398 transaction.SetResourcesContent(content); |
0e16e677fe64
fixed broken /instances/../tags after reconstructing studies when IngestTranscoding has changed
Alain Mazy <am@orthanc.team>
parents:
5603
diff
changeset
|
3399 |
0e16e677fe64
fixed broken /instances/../tags after reconstructing studies when IngestTranscoding has changed
Alain Mazy <am@orthanc.team>
parents:
5603
diff
changeset
|
3400 |
0e16e677fe64
fixed broken /instances/../tags after reconstructing studies when IngestTranscoding has changed
Alain Mazy <am@orthanc.team>
parents:
5603
diff
changeset
|
3401 if (!isReconstruct_) // a reconstruct shall not trigger any events |
0e16e677fe64
fixed broken /instances/../tags after reconstructing studies when IngestTranscoding has changed
Alain Mazy <am@orthanc.team>
parents:
5603
diff
changeset
|
3402 { |
0e16e677fe64
fixed broken /instances/../tags after reconstructing studies when IngestTranscoding has changed
Alain Mazy <am@orthanc.team>
parents:
5603
diff
changeset
|
3403 // Check whether the series of this new instance is now completed |
0e16e677fe64
fixed broken /instances/../tags after reconstructing studies when IngestTranscoding has changed
Alain Mazy <am@orthanc.team>
parents:
5603
diff
changeset
|
3404 int64_t expectedNumberOfInstances; |
0e16e677fe64
fixed broken /instances/../tags after reconstructing studies when IngestTranscoding has changed
Alain Mazy <am@orthanc.team>
parents:
5603
diff
changeset
|
3405 if (ComputeExpectedNumberOfInstances(expectedNumberOfInstances, dicomSummary_)) |
5296
5053a10da5a2
Fix orphan files remaining in storage when working with MaximumStorageSize
Alain Mazy <am@osimis.io>
parents:
5249
diff
changeset
|
3406 { |
5635
0e16e677fe64
fixed broken /instances/../tags after reconstructing studies when IngestTranscoding has changed
Alain Mazy <am@orthanc.team>
parents:
5603
diff
changeset
|
3407 SeriesStatus seriesStatus = transaction.GetSeriesStatus(status.seriesId_, expectedNumberOfInstances); |
0e16e677fe64
fixed broken /instances/../tags after reconstructing studies when IngestTranscoding has changed
Alain Mazy <am@orthanc.team>
parents:
5603
diff
changeset
|
3408 if (seriesStatus == SeriesStatus_Complete) |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3409 { |
5635
0e16e677fe64
fixed broken /instances/../tags after reconstructing studies when IngestTranscoding has changed
Alain Mazy <am@orthanc.team>
parents:
5603
diff
changeset
|
3410 transaction.LogChange(status.seriesId_, ChangeType_CompletedSeries, ResourceType_Series, hashSeries_); |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3411 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3412 } |
5635
0e16e677fe64
fixed broken /instances/../tags after reconstructing studies when IngestTranscoding has changed
Alain Mazy <am@orthanc.team>
parents:
5603
diff
changeset
|
3413 |
0e16e677fe64
fixed broken /instances/../tags after reconstructing studies when IngestTranscoding has changed
Alain Mazy <am@orthanc.team>
parents:
5603
diff
changeset
|
3414 transaction.LogChange(status.seriesId_, ChangeType_NewChildInstance, ResourceType_Series, hashSeries_); |
0e16e677fe64
fixed broken /instances/../tags after reconstructing studies when IngestTranscoding has changed
Alain Mazy <am@orthanc.team>
parents:
5603
diff
changeset
|
3415 transaction.LogChange(status.studyId_, ChangeType_NewChildInstance, ResourceType_Study, hashStudy_); |
0e16e677fe64
fixed broken /instances/../tags after reconstructing studies when IngestTranscoding has changed
Alain Mazy <am@orthanc.team>
parents:
5603
diff
changeset
|
3416 transaction.LogChange(status.patientId_, ChangeType_NewChildInstance, ResourceType_Patient, hashPatient_); |
0e16e677fe64
fixed broken /instances/../tags after reconstructing studies when IngestTranscoding has changed
Alain Mazy <am@orthanc.team>
parents:
5603
diff
changeset
|
3417 |
0e16e677fe64
fixed broken /instances/../tags after reconstructing studies when IngestTranscoding has changed
Alain Mazy <am@orthanc.team>
parents:
5603
diff
changeset
|
3418 // Mark the parent resources of this instance as unstable |
0e16e677fe64
fixed broken /instances/../tags after reconstructing studies when IngestTranscoding has changed
Alain Mazy <am@orthanc.team>
parents:
5603
diff
changeset
|
3419 transaction.GetTransactionContext().MarkAsUnstable(ResourceType_Series, status.seriesId_, hashSeries_); |
0e16e677fe64
fixed broken /instances/../tags after reconstructing studies when IngestTranscoding has changed
Alain Mazy <am@orthanc.team>
parents:
5603
diff
changeset
|
3420 transaction.GetTransactionContext().MarkAsUnstable(ResourceType_Study, status.studyId_, hashStudy_); |
0e16e677fe64
fixed broken /instances/../tags after reconstructing studies when IngestTranscoding has changed
Alain Mazy <am@orthanc.team>
parents:
5603
diff
changeset
|
3421 transaction.GetTransactionContext().MarkAsUnstable(ResourceType_Patient, status.patientId_, hashPatient_); |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3422 } |
5296
5053a10da5a2
Fix orphan files remaining in storage when working with MaximumStorageSize
Alain Mazy <am@osimis.io>
parents:
5249
diff
changeset
|
3423 |
5053a10da5a2
Fix orphan files remaining in storage when working with MaximumStorageSize
Alain Mazy <am@osimis.io>
parents:
5249
diff
changeset
|
3424 transaction.GetTransactionContext().SignalAttachmentsAdded(instanceSize); |
5635
0e16e677fe64
fixed broken /instances/../tags after reconstructing studies when IngestTranscoding has changed
Alain Mazy <am@orthanc.team>
parents:
5603
diff
changeset
|
3425 storeStatus_ = StoreStatus_Success; |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3426 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3427 }; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3428 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3429 |
5316
03501a258d9e
added instance metadata "PixelDataVR"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5297
diff
changeset
|
3430 Operations operations(instanceMetadata, dicomSummary, attachments, metadata, origin, overwrite, |
03501a258d9e
added instance metadata "PixelDataVR"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5297
diff
changeset
|
3431 hasTransferSyntax, transferSyntax, hasPixelDataOffset, pixelDataOffset, |
03501a258d9e
added instance metadata "PixelDataVR"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5297
diff
changeset
|
3432 pixelDataVR, maximumStorageMode, maximumStorageSize, maximumPatients, isReconstruct); |
5296
5053a10da5a2
Fix orphan files remaining in storage when working with MaximumStorageSize
Alain Mazy <am@osimis.io>
parents:
5249
diff
changeset
|
3433 |
5053a10da5a2
Fix orphan files remaining in storage when working with MaximumStorageSize
Alain Mazy <am@osimis.io>
parents:
5249
diff
changeset
|
3434 try |
5053a10da5a2
Fix orphan files remaining in storage when working with MaximumStorageSize
Alain Mazy <am@osimis.io>
parents:
5249
diff
changeset
|
3435 { |
5053a10da5a2
Fix orphan files remaining in storage when working with MaximumStorageSize
Alain Mazy <am@osimis.io>
parents:
5249
diff
changeset
|
3436 Apply(operations); |
5053a10da5a2
Fix orphan files remaining in storage when working with MaximumStorageSize
Alain Mazy <am@osimis.io>
parents:
5249
diff
changeset
|
3437 return operations.GetStoreStatus(); |
5053a10da5a2
Fix orphan files remaining in storage when working with MaximumStorageSize
Alain Mazy <am@osimis.io>
parents:
5249
diff
changeset
|
3438 } |
5053a10da5a2
Fix orphan files remaining in storage when working with MaximumStorageSize
Alain Mazy <am@osimis.io>
parents:
5249
diff
changeset
|
3439 catch (OrthancException& e) |
5053a10da5a2
Fix orphan files remaining in storage when working with MaximumStorageSize
Alain Mazy <am@osimis.io>
parents:
5249
diff
changeset
|
3440 { |
5053a10da5a2
Fix orphan files remaining in storage when working with MaximumStorageSize
Alain Mazy <am@osimis.io>
parents:
5249
diff
changeset
|
3441 if (e.GetErrorCode() == ErrorCode_FullStorage) |
5053a10da5a2
Fix orphan files remaining in storage when working with MaximumStorageSize
Alain Mazy <am@osimis.io>
parents:
5249
diff
changeset
|
3442 { |
5053a10da5a2
Fix orphan files remaining in storage when working with MaximumStorageSize
Alain Mazy <am@osimis.io>
parents:
5249
diff
changeset
|
3443 return StoreStatus_StorageFull; |
5053a10da5a2
Fix orphan files remaining in storage when working with MaximumStorageSize
Alain Mazy <am@osimis.io>
parents:
5249
diff
changeset
|
3444 } |
5053a10da5a2
Fix orphan files remaining in storage when working with MaximumStorageSize
Alain Mazy <am@osimis.io>
parents:
5249
diff
changeset
|
3445 else |
5053a10da5a2
Fix orphan files remaining in storage when working with MaximumStorageSize
Alain Mazy <am@osimis.io>
parents:
5249
diff
changeset
|
3446 { |
5053a10da5a2
Fix orphan files remaining in storage when working with MaximumStorageSize
Alain Mazy <am@osimis.io>
parents:
5249
diff
changeset
|
3447 // the transaction has failed -> do not commit the current transaction (and retry) |
5053a10da5a2
Fix orphan files remaining in storage when working with MaximumStorageSize
Alain Mazy <am@osimis.io>
parents:
5249
diff
changeset
|
3448 throw; |
5053a10da5a2
Fix orphan files remaining in storage when working with MaximumStorageSize
Alain Mazy <am@osimis.io>
parents:
5249
diff
changeset
|
3449 } |
5053a10da5a2
Fix orphan files remaining in storage when working with MaximumStorageSize
Alain Mazy <am@osimis.io>
parents:
5249
diff
changeset
|
3450 } |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3451 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3452 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3453 |
4627
f7d5372b59b3
handling revisions of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4623
diff
changeset
|
3454 StoreStatus StatelessDatabaseOperations::AddAttachment(int64_t& newRevision, |
f7d5372b59b3
handling revisions of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4623
diff
changeset
|
3455 const FileInfo& attachment, |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3456 const std::string& publicId, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3457 uint64_t maximumStorageSize, |
4627
f7d5372b59b3
handling revisions of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4623
diff
changeset
|
3458 unsigned int maximumPatients, |
f7d5372b59b3
handling revisions of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4623
diff
changeset
|
3459 bool hasOldRevision, |
4640
66109d24d26e
"ETag" headers for metadata and attachments now allow strong comparison (MD5 is included)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4633
diff
changeset
|
3460 int64_t oldRevision, |
66109d24d26e
"ETag" headers for metadata and attachments now allow strong comparison (MD5 is included)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4633
diff
changeset
|
3461 const std::string& oldMD5) |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3462 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3463 class Operations : public IReadWriteOperations |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3464 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3465 private: |
4627
f7d5372b59b3
handling revisions of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4623
diff
changeset
|
3466 int64_t& newRevision_; |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3467 StoreStatus status_; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3468 const FileInfo& attachment_; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3469 const std::string& publicId_; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3470 uint64_t maximumStorageSize_; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3471 unsigned int maximumPatientCount_; |
4627
f7d5372b59b3
handling revisions of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4623
diff
changeset
|
3472 bool hasOldRevision_; |
f7d5372b59b3
handling revisions of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4623
diff
changeset
|
3473 int64_t oldRevision_; |
4640
66109d24d26e
"ETag" headers for metadata and attachments now allow strong comparison (MD5 is included)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4633
diff
changeset
|
3474 const std::string& oldMD5_; |
4627
f7d5372b59b3
handling revisions of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4623
diff
changeset
|
3475 |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3476 public: |
4627
f7d5372b59b3
handling revisions of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4623
diff
changeset
|
3477 Operations(int64_t& newRevision, |
f7d5372b59b3
handling revisions of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4623
diff
changeset
|
3478 const FileInfo& attachment, |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3479 const std::string& publicId, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3480 uint64_t maximumStorageSize, |
4627
f7d5372b59b3
handling revisions of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4623
diff
changeset
|
3481 unsigned int maximumPatientCount, |
f7d5372b59b3
handling revisions of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4623
diff
changeset
|
3482 bool hasOldRevision, |
4640
66109d24d26e
"ETag" headers for metadata and attachments now allow strong comparison (MD5 is included)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4633
diff
changeset
|
3483 int64_t oldRevision, |
66109d24d26e
"ETag" headers for metadata and attachments now allow strong comparison (MD5 is included)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4633
diff
changeset
|
3484 const std::string& oldMD5) : |
4627
f7d5372b59b3
handling revisions of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4623
diff
changeset
|
3485 newRevision_(newRevision), |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3486 status_(StoreStatus_Failure), |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3487 attachment_(attachment), |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3488 publicId_(publicId), |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3489 maximumStorageSize_(maximumStorageSize), |
4627
f7d5372b59b3
handling revisions of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4623
diff
changeset
|
3490 maximumPatientCount_(maximumPatientCount), |
f7d5372b59b3
handling revisions of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4623
diff
changeset
|
3491 hasOldRevision_(hasOldRevision), |
4640
66109d24d26e
"ETag" headers for metadata and attachments now allow strong comparison (MD5 is included)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4633
diff
changeset
|
3492 oldRevision_(oldRevision), |
66109d24d26e
"ETag" headers for metadata and attachments now allow strong comparison (MD5 is included)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4633
diff
changeset
|
3493 oldMD5_(oldMD5) |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3494 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3495 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3496 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3497 StoreStatus GetStatus() const |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3498 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3499 return status_; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3500 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3501 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3502 virtual void Apply(ReadWriteTransaction& transaction) ORTHANC_OVERRIDE |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3503 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3504 ResourceType resourceType; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3505 int64_t resourceId; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3506 if (!transaction.LookupResource(resourceId, resourceType, publicId_)) |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3507 { |
5296
5053a10da5a2
Fix orphan files remaining in storage when working with MaximumStorageSize
Alain Mazy <am@osimis.io>
parents:
5249
diff
changeset
|
3508 throw OrthancException(ErrorCode_InexistentItem, HttpStatus_404_NotFound); |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3509 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3510 else |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3511 { |
4627
f7d5372b59b3
handling revisions of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4623
diff
changeset
|
3512 // Possibly remove previous attachment |
f7d5372b59b3
handling revisions of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4623
diff
changeset
|
3513 { |
f7d5372b59b3
handling revisions of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4623
diff
changeset
|
3514 FileInfo oldFile; |
f7d5372b59b3
handling revisions of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4623
diff
changeset
|
3515 int64_t expectedRevision; |
f7d5372b59b3
handling revisions of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4623
diff
changeset
|
3516 if (transaction.LookupAttachment(oldFile, expectedRevision, resourceId, attachment_.GetContentType())) |
f7d5372b59b3
handling revisions of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4623
diff
changeset
|
3517 { |
f7d5372b59b3
handling revisions of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4623
diff
changeset
|
3518 if (hasOldRevision_ && |
4640
66109d24d26e
"ETag" headers for metadata and attachments now allow strong comparison (MD5 is included)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4633
diff
changeset
|
3519 (expectedRevision != oldRevision_ || |
66109d24d26e
"ETag" headers for metadata and attachments now allow strong comparison (MD5 is included)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4633
diff
changeset
|
3520 oldFile.GetUncompressedMD5() != oldMD5_)) |
4627
f7d5372b59b3
handling revisions of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4623
diff
changeset
|
3521 { |
f7d5372b59b3
handling revisions of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4623
diff
changeset
|
3522 throw OrthancException(ErrorCode_Revision); |
f7d5372b59b3
handling revisions of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4623
diff
changeset
|
3523 } |
f7d5372b59b3
handling revisions of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4623
diff
changeset
|
3524 else |
f7d5372b59b3
handling revisions of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4623
diff
changeset
|
3525 { |
f7d5372b59b3
handling revisions of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4623
diff
changeset
|
3526 newRevision_ = expectedRevision + 1; |
f7d5372b59b3
handling revisions of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4623
diff
changeset
|
3527 transaction.DeleteAttachment(resourceId, attachment_.GetContentType()); |
f7d5372b59b3
handling revisions of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4623
diff
changeset
|
3528 } |
f7d5372b59b3
handling revisions of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4623
diff
changeset
|
3529 } |
f7d5372b59b3
handling revisions of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4623
diff
changeset
|
3530 else |
f7d5372b59b3
handling revisions of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4623
diff
changeset
|
3531 { |
f7d5372b59b3
handling revisions of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4623
diff
changeset
|
3532 // The attachment is not existing yet: Ignore "oldRevision" |
f7d5372b59b3
handling revisions of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4623
diff
changeset
|
3533 // and initialize a new sequence of revisions |
f7d5372b59b3
handling revisions of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4623
diff
changeset
|
3534 newRevision_ = 0; |
f7d5372b59b3
handling revisions of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4623
diff
changeset
|
3535 } |
f7d5372b59b3
handling revisions of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4623
diff
changeset
|
3536 } |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3537 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3538 // Locate the patient of the target resource |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3539 int64_t patientId = resourceId; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3540 for (;;) |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3541 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3542 int64_t parent; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3543 if (transaction.LookupParent(parent, patientId)) |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3544 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3545 // We have not reached the patient level yet |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3546 patientId = parent; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3547 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3548 else |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3549 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3550 // We have reached the patient level |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3551 break; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3552 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3553 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3554 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3555 // Possibly apply the recycling mechanism while preserving this patient |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3556 assert(transaction.GetResourceType(patientId) == ResourceType_Patient); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3557 transaction.Recycle(maximumStorageSize_, maximumPatientCount_, |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3558 attachment_.GetCompressedSize(), transaction.GetPublicId(patientId)); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3559 |
4627
f7d5372b59b3
handling revisions of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4623
diff
changeset
|
3560 transaction.AddAttachment(resourceId, attachment_, newRevision_); |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3561 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3562 if (IsUserContentType(attachment_.GetContentType())) |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3563 { |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3564 transaction.LogChange(resourceId, ChangeType_UpdatedAttachment, resourceType, publicId_); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3565 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3566 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3567 transaction.GetTransactionContext().SignalAttachmentsAdded(attachment_.GetCompressedSize()); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3568 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3569 status_ = StoreStatus_Success; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3570 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3571 } |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3572 }; |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3573 |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3574 |
4640
66109d24d26e
"ETag" headers for metadata and attachments now allow strong comparison (MD5 is included)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4633
diff
changeset
|
3575 Operations operations(newRevision, attachment, publicId, maximumStorageSize, maximumPatients, |
66109d24d26e
"ETag" headers for metadata and attachments now allow strong comparison (MD5 is included)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4633
diff
changeset
|
3576 hasOldRevision, oldRevision, oldMD5); |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3577 Apply(operations); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3578 return operations.GetStatus(); |
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3579 } |
5221
d0f7c742d397
started implementation of labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5220
diff
changeset
|
3580 |
d0f7c742d397
started implementation of labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5220
diff
changeset
|
3581 |
d0f7c742d397
started implementation of labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5220
diff
changeset
|
3582 void StatelessDatabaseOperations::ListLabels(std::set<std::string>& target, |
d0f7c742d397
started implementation of labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5220
diff
changeset
|
3583 const std::string& publicId, |
d0f7c742d397
started implementation of labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5220
diff
changeset
|
3584 ResourceType level) |
d0f7c742d397
started implementation of labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5220
diff
changeset
|
3585 { |
d0f7c742d397
started implementation of labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5220
diff
changeset
|
3586 class Operations : public ReadOnlyOperationsT3<std::set<std::string>&, const std::string&, ResourceType> |
d0f7c742d397
started implementation of labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5220
diff
changeset
|
3587 { |
d0f7c742d397
started implementation of labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5220
diff
changeset
|
3588 public: |
d0f7c742d397
started implementation of labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5220
diff
changeset
|
3589 virtual void ApplyTuple(ReadOnlyTransaction& transaction, |
d0f7c742d397
started implementation of labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5220
diff
changeset
|
3590 const Tuple& tuple) ORTHANC_OVERRIDE |
d0f7c742d397
started implementation of labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5220
diff
changeset
|
3591 { |
d0f7c742d397
started implementation of labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5220
diff
changeset
|
3592 ResourceType type; |
d0f7c742d397
started implementation of labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5220
diff
changeset
|
3593 int64_t id; |
d0f7c742d397
started implementation of labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5220
diff
changeset
|
3594 if (!transaction.LookupResource(id, type, tuple.get<1>()) || |
d0f7c742d397
started implementation of labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5220
diff
changeset
|
3595 tuple.get<2>() != type) |
d0f7c742d397
started implementation of labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5220
diff
changeset
|
3596 { |
d0f7c742d397
started implementation of labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5220
diff
changeset
|
3597 throw OrthancException(ErrorCode_UnknownResource); |
d0f7c742d397
started implementation of labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5220
diff
changeset
|
3598 } |
d0f7c742d397
started implementation of labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5220
diff
changeset
|
3599 else |
d0f7c742d397
started implementation of labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5220
diff
changeset
|
3600 { |
d0f7c742d397
started implementation of labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5220
diff
changeset
|
3601 transaction.ListLabels(tuple.get<0>(), id); |
d0f7c742d397
started implementation of labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5220
diff
changeset
|
3602 } |
d0f7c742d397
started implementation of labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5220
diff
changeset
|
3603 } |
d0f7c742d397
started implementation of labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5220
diff
changeset
|
3604 }; |
d0f7c742d397
started implementation of labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5220
diff
changeset
|
3605 |
d0f7c742d397
started implementation of labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5220
diff
changeset
|
3606 Operations operations; |
d0f7c742d397
started implementation of labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5220
diff
changeset
|
3607 operations.Apply(*this, target, publicId, level); |
d0f7c742d397
started implementation of labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5220
diff
changeset
|
3608 } |
d0f7c742d397
started implementation of labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5220
diff
changeset
|
3609 |
d0f7c742d397
started implementation of labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5220
diff
changeset
|
3610 |
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
|
3611 void StatelessDatabaseOperations::ListAllLabels(std::set<std::string>& target) |
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
|
3612 { |
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
|
3613 class Operations : public ReadOnlyOperationsT1<std::set<std::string>& > |
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
|
3614 { |
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
|
3615 public: |
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
|
3616 virtual void ApplyTuple(ReadOnlyTransaction& transaction, |
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
|
3617 const Tuple& tuple) 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
|
3618 { |
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
|
3619 transaction.ListAllLabels(tuple.get<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
|
3620 } |
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
|
3621 }; |
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
|
3622 |
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
|
3623 Operations operations; |
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
|
3624 operations.Apply(*this, target); |
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
|
3625 } |
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
|
3626 |
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
|
3627 |
5495
4b3f5986eca1
Added a 'KeepLabels' option in /modify routes (default = false)
Alain Mazy <am@osimis.io>
parents:
5485
diff
changeset
|
3628 void StatelessDatabaseOperations::AddLabels(const std::string& publicId, |
4b3f5986eca1
Added a 'KeepLabels' option in /modify routes (default = false)
Alain Mazy <am@osimis.io>
parents:
5485
diff
changeset
|
3629 ResourceType level, |
4b3f5986eca1
Added a 'KeepLabels' option in /modify routes (default = false)
Alain Mazy <am@osimis.io>
parents:
5485
diff
changeset
|
3630 const std::set<std::string>& labels) |
4b3f5986eca1
Added a 'KeepLabels' option in /modify routes (default = false)
Alain Mazy <am@osimis.io>
parents:
5485
diff
changeset
|
3631 { |
4b3f5986eca1
Added a 'KeepLabels' option in /modify routes (default = false)
Alain Mazy <am@osimis.io>
parents:
5485
diff
changeset
|
3632 for (std::set<std::string>::const_iterator it = labels.begin(); it != labels.end(); ++it) |
4b3f5986eca1
Added a 'KeepLabels' option in /modify routes (default = false)
Alain Mazy <am@osimis.io>
parents:
5485
diff
changeset
|
3633 { |
4b3f5986eca1
Added a 'KeepLabels' option in /modify routes (default = false)
Alain Mazy <am@osimis.io>
parents:
5485
diff
changeset
|
3634 ModifyLabel(publicId, level, *it, LabelOperation_Add); |
4b3f5986eca1
Added a 'KeepLabels' option in /modify routes (default = false)
Alain Mazy <am@osimis.io>
parents:
5485
diff
changeset
|
3635 } |
4b3f5986eca1
Added a 'KeepLabels' option in /modify routes (default = false)
Alain Mazy <am@osimis.io>
parents:
5485
diff
changeset
|
3636 } |
4b3f5986eca1
Added a 'KeepLabels' option in /modify routes (default = false)
Alain Mazy <am@osimis.io>
parents:
5485
diff
changeset
|
3637 |
4b3f5986eca1
Added a 'KeepLabels' option in /modify routes (default = false)
Alain Mazy <am@osimis.io>
parents:
5485
diff
changeset
|
3638 |
5221
d0f7c742d397
started implementation of labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5220
diff
changeset
|
3639 void StatelessDatabaseOperations::ModifyLabel(const std::string& publicId, |
d0f7c742d397
started implementation of labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5220
diff
changeset
|
3640 ResourceType level, |
d0f7c742d397
started implementation of labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5220
diff
changeset
|
3641 const std::string& label, |
d0f7c742d397
started implementation of labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5220
diff
changeset
|
3642 LabelOperation operation) |
d0f7c742d397
started implementation of labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5220
diff
changeset
|
3643 { |
d0f7c742d397
started implementation of labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5220
diff
changeset
|
3644 class Operations : public IReadWriteOperations |
d0f7c742d397
started implementation of labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5220
diff
changeset
|
3645 { |
d0f7c742d397
started implementation of labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5220
diff
changeset
|
3646 private: |
d0f7c742d397
started implementation of labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5220
diff
changeset
|
3647 const std::string& publicId_; |
d0f7c742d397
started implementation of labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5220
diff
changeset
|
3648 ResourceType level_; |
d0f7c742d397
started implementation of labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5220
diff
changeset
|
3649 const std::string& label_; |
d0f7c742d397
started implementation of labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5220
diff
changeset
|
3650 LabelOperation operation_; |
d0f7c742d397
started implementation of labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5220
diff
changeset
|
3651 |
d0f7c742d397
started implementation of labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5220
diff
changeset
|
3652 public: |
d0f7c742d397
started implementation of labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5220
diff
changeset
|
3653 Operations(const std::string& publicId, |
d0f7c742d397
started implementation of labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5220
diff
changeset
|
3654 ResourceType level, |
d0f7c742d397
started implementation of labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5220
diff
changeset
|
3655 const std::string& label, |
d0f7c742d397
started implementation of labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5220
diff
changeset
|
3656 LabelOperation operation) : |
d0f7c742d397
started implementation of labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5220
diff
changeset
|
3657 publicId_(publicId), |
d0f7c742d397
started implementation of labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5220
diff
changeset
|
3658 level_(level), |
d0f7c742d397
started implementation of labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5220
diff
changeset
|
3659 label_(label), |
d0f7c742d397
started implementation of labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5220
diff
changeset
|
3660 operation_(operation) |
d0f7c742d397
started implementation of labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5220
diff
changeset
|
3661 { |
d0f7c742d397
started implementation of labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5220
diff
changeset
|
3662 } |
d0f7c742d397
started implementation of labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5220
diff
changeset
|
3663 |
d0f7c742d397
started implementation of labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5220
diff
changeset
|
3664 virtual void Apply(ReadWriteTransaction& transaction) ORTHANC_OVERRIDE |
d0f7c742d397
started implementation of labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5220
diff
changeset
|
3665 { |
d0f7c742d397
started implementation of labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5220
diff
changeset
|
3666 ResourceType type; |
d0f7c742d397
started implementation of labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5220
diff
changeset
|
3667 int64_t id; |
d0f7c742d397
started implementation of labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5220
diff
changeset
|
3668 if (!transaction.LookupResource(id, type, publicId_) || |
d0f7c742d397
started implementation of labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5220
diff
changeset
|
3669 level_ != type) |
d0f7c742d397
started implementation of labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5220
diff
changeset
|
3670 { |
d0f7c742d397
started implementation of labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5220
diff
changeset
|
3671 throw OrthancException(ErrorCode_UnknownResource); |
d0f7c742d397
started implementation of labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5220
diff
changeset
|
3672 } |
d0f7c742d397
started implementation of labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5220
diff
changeset
|
3673 else |
d0f7c742d397
started implementation of labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5220
diff
changeset
|
3674 { |
d0f7c742d397
started implementation of labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5220
diff
changeset
|
3675 switch (operation_) |
d0f7c742d397
started implementation of labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5220
diff
changeset
|
3676 { |
d0f7c742d397
started implementation of labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5220
diff
changeset
|
3677 case LabelOperation_Add: |
d0f7c742d397
started implementation of labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5220
diff
changeset
|
3678 transaction.AddLabel(id, label_); |
d0f7c742d397
started implementation of labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5220
diff
changeset
|
3679 break; |
d0f7c742d397
started implementation of labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5220
diff
changeset
|
3680 |
d0f7c742d397
started implementation of labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5220
diff
changeset
|
3681 case LabelOperation_Remove: |
d0f7c742d397
started implementation of labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5220
diff
changeset
|
3682 transaction.RemoveLabel(id, label_); |
d0f7c742d397
started implementation of labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5220
diff
changeset
|
3683 break; |
d0f7c742d397
started implementation of labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5220
diff
changeset
|
3684 |
d0f7c742d397
started implementation of labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5220
diff
changeset
|
3685 default: |
d0f7c742d397
started implementation of labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5220
diff
changeset
|
3686 throw OrthancException(ErrorCode_ParameterOutOfRange); |
d0f7c742d397
started implementation of labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5220
diff
changeset
|
3687 } |
d0f7c742d397
started implementation of labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5220
diff
changeset
|
3688 } |
d0f7c742d397
started implementation of labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5220
diff
changeset
|
3689 } |
d0f7c742d397
started implementation of labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5220
diff
changeset
|
3690 }; |
d0f7c742d397
started implementation of labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5220
diff
changeset
|
3691 |
5244
72dfa0ac84eb
lookup for labels in orthanc explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5238
diff
changeset
|
3692 ServerToolbox::CheckValidLabel(label); |
5221
d0f7c742d397
started implementation of labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5220
diff
changeset
|
3693 |
d0f7c742d397
started implementation of labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5220
diff
changeset
|
3694 Operations operations(publicId, level, label, operation); |
d0f7c742d397
started implementation of labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5220
diff
changeset
|
3695 Apply(operations); |
d0f7c742d397
started implementation of labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5220
diff
changeset
|
3696 } |
5238
367e8af46cfd
added "HasLabels" in /system
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5237
diff
changeset
|
3697 |
367e8af46cfd
added "HasLabels" in /system
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5237
diff
changeset
|
3698 |
367e8af46cfd
added "HasLabels" in /system
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5237
diff
changeset
|
3699 bool StatelessDatabaseOperations::HasLabelsSupport() |
367e8af46cfd
added "HasLabels" in /system
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5237
diff
changeset
|
3700 { |
367e8af46cfd
added "HasLabels" in /system
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5237
diff
changeset
|
3701 boost::shared_lock<boost::shared_mutex> lock(mutex_); |
5455
176bc05f85f4
DB: new Capabilities class to manage future new methods from DB plugins + Added IncrementGlobalProperty
Alain Mazy <am@osimis.io>
parents:
5324
diff
changeset
|
3702 return db_.GetDatabaseCapabilities().HasLabelsSupport(); |
5238
367e8af46cfd
added "HasLabels" in /system
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5237
diff
changeset
|
3703 } |
5554
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5526
diff
changeset
|
3704 |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5526
diff
changeset
|
3705 |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5526
diff
changeset
|
3706 void StatelessDatabaseOperations::ExecuteFind(FindResponse& response, |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5526
diff
changeset
|
3707 const FindRequest& request) |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5526
diff
changeset
|
3708 { |
5614
4640b7ae9a11
moving normalization of constraints into FindRequest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5605
diff
changeset
|
3709 class IntegratedFind : public ReadOnlyOperationsT2<FindResponse&, const FindRequest&> |
5593
862b54b4cfe2
implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
3710 { |
862b54b4cfe2
implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
3711 public: |
862b54b4cfe2
implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
3712 virtual void ApplyTuple(ReadOnlyTransaction& transaction, |
862b54b4cfe2
implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
3713 const Tuple& tuple) ORTHANC_OVERRIDE |
862b54b4cfe2
implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
3714 { |
5614
4640b7ae9a11
moving normalization of constraints into FindRequest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5605
diff
changeset
|
3715 transaction.ExecuteFind(tuple.get<0>(), tuple.get<1>()); |
5593
862b54b4cfe2
implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
3716 } |
862b54b4cfe2
implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
3717 }; |
862b54b4cfe2
implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
3718 |
5614
4640b7ae9a11
moving normalization of constraints into FindRequest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5605
diff
changeset
|
3719 class FindStage : public ReadOnlyOperationsT2<std::list<std::string>&, const FindRequest&> |
5554
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5526
diff
changeset
|
3720 { |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5526
diff
changeset
|
3721 public: |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5526
diff
changeset
|
3722 virtual void ApplyTuple(ReadOnlyTransaction& transaction, |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5526
diff
changeset
|
3723 const Tuple& tuple) ORTHANC_OVERRIDE |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5526
diff
changeset
|
3724 { |
5614
4640b7ae9a11
moving normalization of constraints into FindRequest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5605
diff
changeset
|
3725 transaction.ExecuteFind(tuple.get<0>(), tuple.get<1>()); |
5554
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5526
diff
changeset
|
3726 } |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5526
diff
changeset
|
3727 }; |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5526
diff
changeset
|
3728 |
5593
862b54b4cfe2
implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
3729 class ExpandStage : public ReadOnlyOperationsT3<FindResponse&, const FindRequest&, const std::string&> |
862b54b4cfe2
implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
3730 { |
862b54b4cfe2
implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
3731 public: |
862b54b4cfe2
implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
3732 virtual void ApplyTuple(ReadOnlyTransaction& transaction, |
862b54b4cfe2
implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
3733 const Tuple& tuple) ORTHANC_OVERRIDE |
862b54b4cfe2
implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
3734 { |
862b54b4cfe2
implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
3735 transaction.ExecuteExpand(tuple.get<0>(), tuple.get<1>(), tuple.get<2>()); |
862b54b4cfe2
implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
3736 } |
862b54b4cfe2
implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
3737 }; |
862b54b4cfe2
implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
3738 |
862b54b4cfe2
implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
3739 if (db_.HasIntegratedFind()) |
862b54b4cfe2
implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
3740 { |
862b54b4cfe2
implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
3741 /** |
862b54b4cfe2
implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
3742 * In this flavor, the "find" and the "expand" phases are |
862b54b4cfe2
implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
3743 * executed in one single transaction. |
862b54b4cfe2
implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
3744 **/ |
862b54b4cfe2
implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
3745 IntegratedFind operations; |
5614
4640b7ae9a11
moving normalization of constraints into FindRequest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5605
diff
changeset
|
3746 operations.Apply(*this, response, request); |
5593
862b54b4cfe2
implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
3747 } |
862b54b4cfe2
implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
3748 else |
862b54b4cfe2
implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
3749 { |
862b54b4cfe2
implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
3750 /** |
862b54b4cfe2
implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
3751 * In this flavor, the "find" and the "expand" phases for each |
862b54b4cfe2
implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
3752 * found resource are executed in distinct transactions. This is |
862b54b4cfe2
implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
3753 * the compatibility mode equivalent to Orthanc <= 1.12.3. |
862b54b4cfe2
implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
3754 **/ |
862b54b4cfe2
implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
3755 std::list<std::string> identifiers; |
862b54b4cfe2
implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
3756 |
862b54b4cfe2
implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
3757 FindStage find; |
5614
4640b7ae9a11
moving normalization of constraints into FindRequest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5605
diff
changeset
|
3758 find.Apply(*this, identifiers, request); |
5593
862b54b4cfe2
implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
3759 |
862b54b4cfe2
implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
3760 ExpandStage expand; |
862b54b4cfe2
implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
3761 |
862b54b4cfe2
implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
3762 for (std::list<std::string>::const_iterator it = identifiers.begin(); it != identifiers.end(); ++it) |
862b54b4cfe2
implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
3763 { |
862b54b4cfe2
implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
3764 /** |
862b54b4cfe2
implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
3765 * Not that the resource might have been deleted (as we are in |
862b54b4cfe2
implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
3766 * another transaction). The database engine must ignore such |
862b54b4cfe2
implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
3767 * error cases. |
862b54b4cfe2
implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
3768 **/ |
862b54b4cfe2
implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
3769 expand.Apply(*this, response, request, *it); |
862b54b4cfe2
implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
3770 } |
862b54b4cfe2
implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
3771 } |
5568
b0b5546f1b9f
find refactor: re-use existing code. /studies?expand is almost fully implemented with new code
Alain Mazy <am@orthanc.team>
parents:
5554
diff
changeset
|
3772 } |
4586
1d96fe7e054e
taking StatelessDatabaseOperations out of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3773 } |