Mercurial > hg > orthanc
annotate OrthancServer/Sources/Database/FindResponse.cpp @ 5595:a87f2a56257d find-refactoring
implemented FindRequest::retrieveChildrenMetadata_
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 07 May 2024 12:53:12 +0200 |
parents | a906dc19264c |
children | 81a29ad7fb4b |
rev | line source |
---|---|
5554
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1 /** |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2 * Orthanc - A Lightweight, RESTful DICOM Store |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
4 * Department, University Hospital of Liege, Belgium |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
5 * Copyright (C) 2017-2024 Osimis S.A., Belgium |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
6 * Copyright (C) 2021-2024 Sebastien Jodogne, ICTEAM UCLouvain, Belgium |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
7 * |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
8 * This program is free software: you can redistribute it and/or |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
9 * modify it under the terms of the GNU General Public License as |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
10 * published by the Free Software Foundation, either version 3 of the |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
11 * License, or (at your option) any later version. |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
12 * |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
13 * This program is distributed in the hope that it will be useful, but |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
14 * WITHOUT ANY WARRANTY; without even the implied warranty of |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
16 * General Public License for more details. |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
17 * |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
18 * You should have received a copy of the GNU General Public License |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
19 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
20 **/ |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
21 |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
22 |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
23 #include "FindResponse.h" |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
24 |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
25 #include "../../../OrthancFramework/Sources/DicomFormat/DicomInstanceHasher.h" |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
26 #include "../../../OrthancFramework/Sources/OrthancException.h" |
5595
a87f2a56257d
implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5594
diff
changeset
|
27 #include "../../../OrthancFramework/Sources/SerializationToolbox.h" |
5554
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
28 |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
29 #include <cassert> |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
30 |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
31 |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
32 namespace Orthanc |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
33 { |
5592
1e2631b8b9af
GenericFind::Execute() is working for a basic request
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
34 class FindResponse::Resource::DicomValue : public boost::noncopyable |
5586
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
35 { |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
36 public: |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
37 enum ValueType |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
38 { |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
39 ValueType_String, |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
40 ValueType_Null |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
41 }; |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
42 |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
43 private: |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
44 ValueType type_; |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
45 std::string value_; |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
46 |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
47 public: |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
48 DicomValue(ValueType type, |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
49 const std::string& value) : |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
50 type_(type), |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
51 value_(value) |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
52 { |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
53 } |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
54 |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
55 ValueType GetType() const |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
56 { |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
57 return type_; |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
58 } |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
59 |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
60 const std::string& GetValue() const |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
61 { |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
62 switch (type_) |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
63 { |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
64 case ValueType_Null: |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
65 throw OrthancException(ErrorCode_BadSequenceOfCalls); |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
66 |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
67 case ValueType_String: |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
68 return value_; |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
69 |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
70 default: |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
71 throw OrthancException(ErrorCode_ParameterOutOfRange); |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
72 } |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
73 } |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
74 }; |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
75 |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
76 |
5592
1e2631b8b9af
GenericFind::Execute() is working for a basic request
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
77 void FindResponse::Resource::AddNullDicomTag(uint16_t group, |
1e2631b8b9af
GenericFind::Execute() is working for a basic request
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
78 uint16_t element) |
5586
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
79 { |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
80 const DicomTag tag(group, element); |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
81 |
5592
1e2631b8b9af
GenericFind::Execute() is working for a basic request
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
82 if (mainDicomTags_.find(tag) == mainDicomTags_.end()) |
5586
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
83 { |
5592
1e2631b8b9af
GenericFind::Execute() is working for a basic request
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
84 mainDicomTags_[tag] = new DicomValue(DicomValue::ValueType_Null, ""); |
5586
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
85 } |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
86 else |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
87 { |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
88 throw OrthancException(ErrorCode_BadSequenceOfCalls); |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
89 } |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
90 } |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
91 |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
92 |
5592
1e2631b8b9af
GenericFind::Execute() is working for a basic request
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
93 void FindResponse::Resource::AddStringDicomTag(uint16_t group, |
1e2631b8b9af
GenericFind::Execute() is working for a basic request
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
94 uint16_t element, |
1e2631b8b9af
GenericFind::Execute() is working for a basic request
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
95 const std::string& value) |
5586
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
96 { |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
97 const DicomTag tag(group, element); |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
98 |
5592
1e2631b8b9af
GenericFind::Execute() is working for a basic request
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
99 if (mainDicomTags_.find(tag) == mainDicomTags_.end()) |
5586
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
100 { |
5592
1e2631b8b9af
GenericFind::Execute() is working for a basic request
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
101 mainDicomTags_[tag] = new DicomValue(DicomValue::ValueType_String, value); |
5586
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
102 } |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
103 else |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
104 { |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
105 throw OrthancException(ErrorCode_BadSequenceOfCalls); |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
106 } |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
107 } |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
108 |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
109 |
5592
1e2631b8b9af
GenericFind::Execute() is working for a basic request
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
110 void FindResponse::Resource::GetMainDicomTags(DicomMap& target) const |
5586
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
111 { |
5592
1e2631b8b9af
GenericFind::Execute() is working for a basic request
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
112 for (MainDicomTags::const_iterator it = mainDicomTags_.begin(); it != mainDicomTags_.end(); ++it) |
5586
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
113 { |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
114 assert(it->second != NULL); |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
115 |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
116 switch (it->second->GetType()) |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
117 { |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
118 case DicomValue::ValueType_String: |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
119 target.SetValue(it->first, it->second->GetValue(), false /* not binary */); |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
120 break; |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
121 |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
122 case DicomValue::ValueType_Null: |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
123 target.SetNullValue(it->first); |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
124 break; |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
125 |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
126 default: |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
127 throw OrthancException(ErrorCode_InternalError); |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
128 } |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
129 } |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
130 } |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
131 |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
132 |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
133 void FindResponse::ChildrenAtLevel::AddIdentifier(const std::string& identifier) |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
134 { |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
135 if (identifiers_.find(identifier) == identifiers_.end()) |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
136 { |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
137 identifiers_.insert(identifier); |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
138 } |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
139 else |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
140 { |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
141 throw OrthancException(ErrorCode_BadSequenceOfCalls); |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
142 } |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
143 } |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
144 |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
145 |
5589
b51ee994cd6f
renamed FindResponse::Item as FindResponse::Resource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5588
diff
changeset
|
146 FindResponse::ChildrenAtLevel& FindResponse::Resource::GetChildrenAtLevel(ResourceType level) |
5554
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
147 { |
5586
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
148 switch (level) |
5554
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
149 { |
5586
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
150 case ResourceType_Study: |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
151 if (level_ == ResourceType_Patient) |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
152 { |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
153 return childrenStudies_; |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
154 } |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
155 else |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
156 { |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
157 throw OrthancException(ErrorCode_BadParameterType); |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
158 } |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
159 |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
160 case ResourceType_Series: |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
161 if (level_ == ResourceType_Patient || |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
162 level_ == ResourceType_Study) |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
163 { |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
164 return childrenSeries_; |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
165 } |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
166 else |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
167 { |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
168 throw OrthancException(ErrorCode_BadParameterType); |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
169 } |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
170 |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
171 case ResourceType_Instance: |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
172 if (level_ == ResourceType_Patient || |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
173 level_ == ResourceType_Study || |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
174 level_ == ResourceType_Series) |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
175 { |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
176 return childrenInstances_; |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
177 } |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
178 else |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
179 { |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
180 throw OrthancException(ErrorCode_BadParameterType); |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
181 } |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
182 |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
183 default: |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
184 throw OrthancException(ErrorCode_ParameterOutOfRange); |
5554
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
185 } |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
186 } |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
187 |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
188 |
5589
b51ee994cd6f
renamed FindResponse::Item as FindResponse::Resource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5588
diff
changeset
|
189 void FindResponse::Resource::AddMetadata(MetadataType metadata, |
b51ee994cd6f
renamed FindResponse::Item as FindResponse::Resource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5588
diff
changeset
|
190 const std::string& value) |
5554
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
191 { |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
192 if (metadata_.find(metadata) != metadata_.end()) |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
193 { |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
194 throw OrthancException(ErrorCode_BadSequenceOfCalls); // Metadata already present |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
195 } |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
196 else |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
197 { |
5568
b0b5546f1b9f
find refactor: re-use existing code. /studies?expand is almost fully implemented with new code
Alain Mazy <am@orthanc.team>
parents:
5565
diff
changeset
|
198 metadata_[metadata] = value; |
5554
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
199 } |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
200 } |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
201 |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
202 |
5589
b51ee994cd6f
renamed FindResponse::Item as FindResponse::Resource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5588
diff
changeset
|
203 bool FindResponse::Resource::LookupMetadata(std::string& value, |
b51ee994cd6f
renamed FindResponse::Item as FindResponse::Resource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5588
diff
changeset
|
204 MetadataType metadata) const |
5554
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
205 { |
5568
b0b5546f1b9f
find refactor: re-use existing code. /studies?expand is almost fully implemented with new code
Alain Mazy <am@orthanc.team>
parents:
5565
diff
changeset
|
206 std::map<MetadataType, std::string>::const_iterator found = metadata_.find(metadata); |
5554
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
207 |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
208 if (found == metadata_.end()) |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
209 { |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
210 return false; |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
211 } |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
212 else |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
213 { |
5568
b0b5546f1b9f
find refactor: re-use existing code. /studies?expand is almost fully implemented with new code
Alain Mazy <am@orthanc.team>
parents:
5565
diff
changeset
|
214 value = found->second; |
5554
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
215 return true; |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
216 } |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
217 } |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
218 |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
219 |
5589
b51ee994cd6f
renamed FindResponse::Item as FindResponse::Resource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5588
diff
changeset
|
220 void FindResponse::Resource::ListMetadata(std::set<MetadataType>& target) const |
5554
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
221 { |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
222 target.clear(); |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
223 |
5568
b0b5546f1b9f
find refactor: re-use existing code. /studies?expand is almost fully implemented with new code
Alain Mazy <am@orthanc.team>
parents:
5565
diff
changeset
|
224 for (std::map<MetadataType, std::string>::const_iterator it = metadata_.begin(); it != metadata_.end(); ++it) |
5554
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
225 { |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
226 target.insert(it->first); |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
227 } |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
228 } |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
229 |
5589
b51ee994cd6f
renamed FindResponse::Item as FindResponse::Resource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5588
diff
changeset
|
230 const std::string& FindResponse::Resource::GetParentIdentifier() const |
5586
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
231 { |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
232 if (level_ == ResourceType_Patient) |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
233 { |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
234 throw OrthancException(ErrorCode_BadParameterType); |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
235 } |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
236 else if (HasParentIdentifier()) |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
237 { |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
238 return *parentIdentifier_; |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
239 } |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
240 else |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
241 { |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
242 throw OrthancException(ErrorCode_BadSequenceOfCalls); |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
243 } |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
244 } |
5554
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
245 |
5586
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
246 |
5592
1e2631b8b9af
GenericFind::Execute() is working for a basic request
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
247 FindResponse::Resource::~Resource() |
1e2631b8b9af
GenericFind::Execute() is working for a basic request
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
248 { |
1e2631b8b9af
GenericFind::Execute() is working for a basic request
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
249 for (MainDicomTags::iterator it = mainDicomTags_.begin(); it != mainDicomTags_.end(); ++it) |
1e2631b8b9af
GenericFind::Execute() is working for a basic request
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
250 { |
1e2631b8b9af
GenericFind::Execute() is working for a basic request
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
251 assert(it->second != NULL); |
1e2631b8b9af
GenericFind::Execute() is working for a basic request
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
252 delete it->second; |
1e2631b8b9af
GenericFind::Execute() is working for a basic request
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
253 } |
5595
a87f2a56257d
implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5594
diff
changeset
|
254 |
a87f2a56257d
implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5594
diff
changeset
|
255 for (ChildrenMetadata::iterator it = childrenMetadata_.begin(); it != childrenMetadata_.end(); ++it) |
a87f2a56257d
implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5594
diff
changeset
|
256 { |
a87f2a56257d
implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5594
diff
changeset
|
257 assert(it->second != NULL); |
a87f2a56257d
implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5594
diff
changeset
|
258 delete it->second; |
a87f2a56257d
implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5594
diff
changeset
|
259 } |
5592
1e2631b8b9af
GenericFind::Execute() is working for a basic request
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
260 } |
1e2631b8b9af
GenericFind::Execute() is working for a basic request
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
261 |
1e2631b8b9af
GenericFind::Execute() is working for a basic request
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
262 |
5589
b51ee994cd6f
renamed FindResponse::Item as FindResponse::Resource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5588
diff
changeset
|
263 void FindResponse::Resource::SetParentIdentifier(const std::string& id) |
5554
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
264 { |
5586
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
265 if (level_ == ResourceType_Patient) |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
266 { |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
267 throw OrthancException(ErrorCode_BadParameterType); |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
268 } |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
269 else if (HasParentIdentifier()) |
5554
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
270 { |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
271 throw OrthancException(ErrorCode_BadSequenceOfCalls); |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
272 } |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
273 else |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
274 { |
5586
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
275 parentIdentifier_.reset(new std::string(id)); |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
276 } |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
277 } |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
278 |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
279 |
5589
b51ee994cd6f
renamed FindResponse::Item as FindResponse::Resource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5588
diff
changeset
|
280 bool FindResponse::Resource::HasParentIdentifier() const |
5586
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
281 { |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
282 if (level_ == ResourceType_Patient) |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
283 { |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
284 throw OrthancException(ErrorCode_BadParameterType); |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
285 } |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
286 else |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
287 { |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
288 return parentIdentifier_.get() != NULL; |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
289 } |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
290 } |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
291 |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
292 |
5589
b51ee994cd6f
renamed FindResponse::Item as FindResponse::Resource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5588
diff
changeset
|
293 void FindResponse::Resource::AddLabel(const std::string& label) |
5586
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
294 { |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
295 if (labels_.find(label) == labels_.end()) |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
296 { |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
297 labels_.insert(label); |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
298 } |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
299 else |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
300 { |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
301 throw OrthancException(ErrorCode_BadSequenceOfCalls); |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
302 } |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
303 } |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
304 |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
305 |
5589
b51ee994cd6f
renamed FindResponse::Item as FindResponse::Resource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5588
diff
changeset
|
306 void FindResponse::Resource::AddAttachment(const FileInfo& attachment) |
5586
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
307 { |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
308 if (attachments_.find(attachment.GetContentType()) == attachments_.end()) |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
309 { |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
310 attachments_[attachment.GetContentType()] = attachment; |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
311 } |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
312 else |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
313 { |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
314 throw OrthancException(ErrorCode_BadSequenceOfCalls); |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
315 } |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
316 } |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
317 |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
318 |
5589
b51ee994cd6f
renamed FindResponse::Item as FindResponse::Resource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5588
diff
changeset
|
319 bool FindResponse::Resource::LookupAttachment(FileInfo& target, FileContentType type) const |
5586
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
320 { |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
321 std::map<FileContentType, FileInfo>::const_iterator it = attachments_.find(type); |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
322 if (it != attachments_.end()) |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
323 { |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
324 target = it->second; |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
325 return true; |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
326 } |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
327 else |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
328 { |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
329 return false; |
5554
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
330 } |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
331 } |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
332 |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
333 |
5595
a87f2a56257d
implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5594
diff
changeset
|
334 void FindResponse::Resource::AddChildrenMetadata(MetadataType metadata, |
a87f2a56257d
implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5594
diff
changeset
|
335 const std::list<std::string>& values) |
a87f2a56257d
implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5594
diff
changeset
|
336 { |
a87f2a56257d
implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5594
diff
changeset
|
337 if (childrenMetadata_.find(metadata) == childrenMetadata_.end()) |
a87f2a56257d
implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5594
diff
changeset
|
338 { |
a87f2a56257d
implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5594
diff
changeset
|
339 childrenMetadata_[metadata] = new std::list<std::string>(values); |
a87f2a56257d
implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5594
diff
changeset
|
340 } |
a87f2a56257d
implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5594
diff
changeset
|
341 else |
a87f2a56257d
implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5594
diff
changeset
|
342 { |
a87f2a56257d
implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5594
diff
changeset
|
343 throw OrthancException(ErrorCode_BadSequenceOfCalls); |
a87f2a56257d
implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5594
diff
changeset
|
344 } |
a87f2a56257d
implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5594
diff
changeset
|
345 } |
a87f2a56257d
implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5594
diff
changeset
|
346 |
a87f2a56257d
implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5594
diff
changeset
|
347 |
a87f2a56257d
implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5594
diff
changeset
|
348 bool FindResponse::Resource::LookupChildrenMetadata(std::list<std::string>& values, |
a87f2a56257d
implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5594
diff
changeset
|
349 MetadataType metadata) const |
a87f2a56257d
implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5594
diff
changeset
|
350 { |
a87f2a56257d
implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5594
diff
changeset
|
351 ChildrenMetadata::const_iterator found = childrenMetadata_.find(metadata); |
a87f2a56257d
implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5594
diff
changeset
|
352 if (found == childrenMetadata_.end()) |
a87f2a56257d
implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5594
diff
changeset
|
353 { |
a87f2a56257d
implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5594
diff
changeset
|
354 return false; |
a87f2a56257d
implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5594
diff
changeset
|
355 } |
a87f2a56257d
implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5594
diff
changeset
|
356 else |
a87f2a56257d
implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5594
diff
changeset
|
357 { |
a87f2a56257d
implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5594
diff
changeset
|
358 assert(found->second != NULL); |
a87f2a56257d
implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5594
diff
changeset
|
359 values = *found->second; |
a87f2a56257d
implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5594
diff
changeset
|
360 return true; |
a87f2a56257d
implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5594
diff
changeset
|
361 } |
a87f2a56257d
implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5594
diff
changeset
|
362 } |
a87f2a56257d
implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5594
diff
changeset
|
363 |
a87f2a56257d
implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5594
diff
changeset
|
364 |
a87f2a56257d
implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5594
diff
changeset
|
365 SeriesStatus FindResponse::Resource::GetSeriesStatus(uint32_t& expectedNumberOfInstances) const |
a87f2a56257d
implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5594
diff
changeset
|
366 { |
a87f2a56257d
implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5594
diff
changeset
|
367 if (level_ != ResourceType_Series) |
a87f2a56257d
implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5594
diff
changeset
|
368 { |
a87f2a56257d
implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5594
diff
changeset
|
369 throw OrthancException(ErrorCode_BadParameterType); |
a87f2a56257d
implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5594
diff
changeset
|
370 } |
a87f2a56257d
implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5594
diff
changeset
|
371 |
a87f2a56257d
implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5594
diff
changeset
|
372 std::string s; |
a87f2a56257d
implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5594
diff
changeset
|
373 if (!LookupMetadata(s, MetadataType_Series_ExpectedNumberOfInstances) || |
a87f2a56257d
implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5594
diff
changeset
|
374 !SerializationToolbox::ParseUnsignedInteger32(expectedNumberOfInstances, s)) |
a87f2a56257d
implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5594
diff
changeset
|
375 { |
a87f2a56257d
implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5594
diff
changeset
|
376 return SeriesStatus_Unknown; |
a87f2a56257d
implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5594
diff
changeset
|
377 } |
a87f2a56257d
implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5594
diff
changeset
|
378 |
a87f2a56257d
implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5594
diff
changeset
|
379 std::list<std::string> values; |
a87f2a56257d
implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5594
diff
changeset
|
380 if (!LookupChildrenMetadata(values, MetadataType_Instance_IndexInSeries)) |
a87f2a56257d
implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5594
diff
changeset
|
381 { |
a87f2a56257d
implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5594
diff
changeset
|
382 throw OrthancException(ErrorCode_BadSequenceOfCalls); |
a87f2a56257d
implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5594
diff
changeset
|
383 } |
a87f2a56257d
implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5594
diff
changeset
|
384 |
a87f2a56257d
implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5594
diff
changeset
|
385 std::set<int64_t> instances; |
a87f2a56257d
implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5594
diff
changeset
|
386 |
a87f2a56257d
implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5594
diff
changeset
|
387 for (std::list<std::string>::const_iterator |
a87f2a56257d
implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5594
diff
changeset
|
388 it = values.begin(); it != values.end(); ++it) |
a87f2a56257d
implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5594
diff
changeset
|
389 { |
a87f2a56257d
implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5594
diff
changeset
|
390 int64_t index; |
a87f2a56257d
implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5594
diff
changeset
|
391 |
a87f2a56257d
implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5594
diff
changeset
|
392 if (!SerializationToolbox::ParseInteger64(index, *it)) |
a87f2a56257d
implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5594
diff
changeset
|
393 { |
a87f2a56257d
implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5594
diff
changeset
|
394 return SeriesStatus_Unknown; |
a87f2a56257d
implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5594
diff
changeset
|
395 } |
a87f2a56257d
implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5594
diff
changeset
|
396 |
a87f2a56257d
implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5594
diff
changeset
|
397 if (index <= 0 || |
a87f2a56257d
implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5594
diff
changeset
|
398 index > static_cast<int64_t>(expectedNumberOfInstances)) |
a87f2a56257d
implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5594
diff
changeset
|
399 { |
a87f2a56257d
implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5594
diff
changeset
|
400 // Out-of-range instance index |
a87f2a56257d
implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5594
diff
changeset
|
401 return SeriesStatus_Inconsistent; |
a87f2a56257d
implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5594
diff
changeset
|
402 } |
a87f2a56257d
implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5594
diff
changeset
|
403 |
a87f2a56257d
implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5594
diff
changeset
|
404 if (instances.find(index) != instances.end()) |
a87f2a56257d
implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5594
diff
changeset
|
405 { |
a87f2a56257d
implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5594
diff
changeset
|
406 // Twice the same instance index |
a87f2a56257d
implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5594
diff
changeset
|
407 return SeriesStatus_Inconsistent; |
a87f2a56257d
implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5594
diff
changeset
|
408 } |
a87f2a56257d
implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5594
diff
changeset
|
409 |
a87f2a56257d
implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5594
diff
changeset
|
410 instances.insert(index); |
a87f2a56257d
implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5594
diff
changeset
|
411 } |
a87f2a56257d
implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5594
diff
changeset
|
412 |
a87f2a56257d
implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5594
diff
changeset
|
413 if (instances.size() == static_cast<size_t>(expectedNumberOfInstances)) |
a87f2a56257d
implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5594
diff
changeset
|
414 { |
a87f2a56257d
implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5594
diff
changeset
|
415 return SeriesStatus_Complete; |
a87f2a56257d
implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5594
diff
changeset
|
416 } |
a87f2a56257d
implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5594
diff
changeset
|
417 else |
a87f2a56257d
implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5594
diff
changeset
|
418 { |
a87f2a56257d
implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5594
diff
changeset
|
419 return SeriesStatus_Missing; |
a87f2a56257d
implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5594
diff
changeset
|
420 } |
a87f2a56257d
implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5594
diff
changeset
|
421 } |
a87f2a56257d
implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5594
diff
changeset
|
422 |
a87f2a56257d
implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5594
diff
changeset
|
423 |
a87f2a56257d
implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5594
diff
changeset
|
424 void FindResponse::Resource::Expand(Json::Value& target, |
5594
a906dc19264c
created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
425 const FindRequest& request) const |
a906dc19264c
created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
426 { |
a906dc19264c
created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
427 /** |
a906dc19264c
created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
428 |
a906dc19264c
created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
429 TODO-FIND: |
a906dc19264c
created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
430 |
a906dc19264c
created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
431 - Metadata / Series / ExpectedNumberOfInstances |
a906dc19264c
created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
432 |
a906dc19264c
created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
433 - Metadata / Series / Status |
a906dc19264c
created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
434 |
a906dc19264c
created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
435 - Metadata / Instance / FileSize |
a906dc19264c
created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
436 |
a906dc19264c
created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
437 - Metadata / Instance / FileUuid |
a906dc19264c
created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
438 |
a906dc19264c
created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
439 - Metadata / Instance / IndexInSeries |
a906dc19264c
created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
440 |
a906dc19264c
created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
441 - Metadata / AnonymizedFrom |
a906dc19264c
created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
442 |
a906dc19264c
created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
443 - Metadata / ModifiedFrom |
a906dc19264c
created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
444 |
a906dc19264c
created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
445 **/ |
a906dc19264c
created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
446 |
a906dc19264c
created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
447 target = Json::objectValue; |
a906dc19264c
created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
448 target["ID"] = identifier_; |
a906dc19264c
created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
449 target["Type"] = GetResourceTypeText(level_, false, true); |
a906dc19264c
created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
450 |
a906dc19264c
created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
451 if (request.IsRetrieveMetadata()) |
a906dc19264c
created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
452 { |
a906dc19264c
created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
453 Json::Value metadata = Json::objectValue; |
a906dc19264c
created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
454 |
a906dc19264c
created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
455 for (std::map<MetadataType, std::string>::const_iterator |
a906dc19264c
created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
456 it = metadata_.begin(); it != metadata_.end(); ++it) |
a906dc19264c
created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
457 { |
a906dc19264c
created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
458 metadata[EnumerationToString(it->first)] = it->second; |
a906dc19264c
created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
459 } |
a906dc19264c
created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
460 |
a906dc19264c
created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
461 target["Metadata"] = metadata; |
a906dc19264c
created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
462 } |
a906dc19264c
created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
463 |
a906dc19264c
created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
464 if (request.IsRetrieveLabels()) |
a906dc19264c
created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
465 { |
a906dc19264c
created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
466 Json::Value labels = Json::arrayValue; |
a906dc19264c
created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
467 |
a906dc19264c
created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
468 for (std::set<std::string>::const_iterator it = labels_.begin(); it != labels_.end(); ++it) |
a906dc19264c
created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
469 { |
a906dc19264c
created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
470 labels.append(*it); |
a906dc19264c
created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
471 } |
a906dc19264c
created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
472 |
a906dc19264c
created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
473 target["Labels"] = labels; |
a906dc19264c
created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
474 } |
a906dc19264c
created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
475 |
a906dc19264c
created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
476 if (request.IsRetrieveParentIdentifier()) |
a906dc19264c
created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
477 { |
a906dc19264c
created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
478 switch (level_) |
a906dc19264c
created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
479 { |
a906dc19264c
created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
480 case ResourceType_Patient: |
a906dc19264c
created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
481 break; |
a906dc19264c
created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
482 |
a906dc19264c
created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
483 case ResourceType_Study: |
a906dc19264c
created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
484 target["ParentPatient"] = GetParentIdentifier(); |
a906dc19264c
created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
485 break; |
a906dc19264c
created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
486 |
a906dc19264c
created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
487 case ResourceType_Series: |
a906dc19264c
created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
488 target["ParentStudy"] = GetParentIdentifier(); |
a906dc19264c
created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
489 break; |
a906dc19264c
created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
490 |
a906dc19264c
created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
491 case ResourceType_Instance: |
a906dc19264c
created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
492 target["ParentSeries"] = GetParentIdentifier(); |
a906dc19264c
created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
493 break; |
a906dc19264c
created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
494 |
a906dc19264c
created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
495 default: |
a906dc19264c
created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
496 throw OrthancException(ErrorCode_InternalError); |
a906dc19264c
created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
497 } |
a906dc19264c
created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
498 } |
a906dc19264c
created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
499 |
a906dc19264c
created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
500 if (request.IsRetrieveChildrenIdentifiers()) |
a906dc19264c
created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
501 { |
a906dc19264c
created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
502 Json::Value c = Json::arrayValue; |
a906dc19264c
created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
503 |
a906dc19264c
created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
504 const std::set<std::string>& children = GetChildrenAtLevel(GetChildResourceType(level_)).GetIdentifiers(); |
a906dc19264c
created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
505 |
a906dc19264c
created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
506 for (std::set<std::string>::const_iterator |
a906dc19264c
created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
507 it = children.begin(); it != children.end(); ++it) |
a906dc19264c
created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
508 { |
a906dc19264c
created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
509 c.append(*it); |
a906dc19264c
created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
510 } |
a906dc19264c
created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
511 |
a906dc19264c
created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
512 switch (level_) |
a906dc19264c
created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
513 { |
a906dc19264c
created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
514 case ResourceType_Patient: |
a906dc19264c
created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
515 target["Studies"] = c; |
a906dc19264c
created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
516 break; |
a906dc19264c
created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
517 |
a906dc19264c
created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
518 case ResourceType_Study: |
a906dc19264c
created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
519 target["Series"] = c; |
a906dc19264c
created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
520 break; |
a906dc19264c
created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
521 |
a906dc19264c
created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
522 case ResourceType_Series: |
a906dc19264c
created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
523 target["Instances"] = c; |
a906dc19264c
created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
524 break; |
a906dc19264c
created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
525 |
a906dc19264c
created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
526 default: |
a906dc19264c
created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
527 throw OrthancException(ErrorCode_InternalError); |
a906dc19264c
created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
528 } |
a906dc19264c
created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
529 } |
a906dc19264c
created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
530 } |
a906dc19264c
created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
531 |
a906dc19264c
created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
532 |
5554
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
533 FindResponse::~FindResponse() |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
534 { |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
535 for (size_t i = 0; i < items_.size(); i++) |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
536 { |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
537 assert(items_[i] != NULL); |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
538 delete items_[i]; |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
539 } |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
540 } |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
541 |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
542 |
5589
b51ee994cd6f
renamed FindResponse::Item as FindResponse::Resource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5588
diff
changeset
|
543 void FindResponse::Add(Resource* item /* takes ownership */) |
5554
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
544 { |
5589
b51ee994cd6f
renamed FindResponse::Item as FindResponse::Resource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5588
diff
changeset
|
545 std::unique_ptr<Resource> protection(item); |
5586
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
546 |
5554
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
547 if (item == NULL) |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
548 { |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
549 throw OrthancException(ErrorCode_NullPointer); |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
550 } |
5588
1b0fc6685f57
add index of resources into FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5586
diff
changeset
|
551 else if (!items_.empty() && |
1b0fc6685f57
add index of resources into FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5586
diff
changeset
|
552 items_[0]->GetLevel() != item->GetLevel()) |
1b0fc6685f57
add index of resources into FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5586
diff
changeset
|
553 { |
1b0fc6685f57
add index of resources into FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5586
diff
changeset
|
554 throw OrthancException(ErrorCode_BadParameterType, "A find response must only contain resources of the same type"); |
1b0fc6685f57
add index of resources into FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5586
diff
changeset
|
555 } |
5554
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
556 else |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
557 { |
5586
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
558 const std::string& id = item->GetIdentifier(); |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
559 |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
560 if (index_.find(id) == index_.end()) |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
561 { |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
562 items_.push_back(protection.release()); |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
563 index_[id] = item; |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
564 } |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
565 else |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
566 { |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
567 throw OrthancException(ErrorCode_BadSequenceOfCalls, "This resource has already been added: " + id); |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
568 } |
5554
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
569 } |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
570 } |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
571 |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
572 |
5589
b51ee994cd6f
renamed FindResponse::Item as FindResponse::Resource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5588
diff
changeset
|
573 const FindResponse::Resource& FindResponse::GetResource(size_t index) const |
5554
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
574 { |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
575 if (index >= items_.size()) |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
576 { |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
577 throw OrthancException(ErrorCode_ParameterOutOfRange); |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
578 } |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
579 else |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
580 { |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
581 assert(items_[index] != NULL); |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
582 return *items_[index]; |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
583 } |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
584 } |
5568
b0b5546f1b9f
find refactor: re-use existing code. /studies?expand is almost fully implemented with new code
Alain Mazy <am@orthanc.team>
parents:
5565
diff
changeset
|
585 |
5586
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
586 |
5589
b51ee994cd6f
renamed FindResponse::Item as FindResponse::Resource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5588
diff
changeset
|
587 FindResponse::Resource& FindResponse::GetResource(const std::string& id) |
5568
b0b5546f1b9f
find refactor: re-use existing code. /studies?expand is almost fully implemented with new code
Alain Mazy <am@orthanc.team>
parents:
5565
diff
changeset
|
588 { |
5586
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
589 Index::const_iterator found = index_.find(id); |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
590 |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
591 if (found == index_.end()) |
5568
b0b5546f1b9f
find refactor: re-use existing code. /studies?expand is almost fully implemented with new code
Alain Mazy <am@orthanc.team>
parents:
5565
diff
changeset
|
592 { |
5588
1b0fc6685f57
add index of resources into FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5586
diff
changeset
|
593 throw OrthancException(ErrorCode_InexistentItem); |
5568
b0b5546f1b9f
find refactor: re-use existing code. /studies?expand is almost fully implemented with new code
Alain Mazy <am@orthanc.team>
parents:
5565
diff
changeset
|
594 } |
5586
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
595 else |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
596 { |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
597 assert(found->second != NULL); |
5588
1b0fc6685f57
add index of resources into FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5586
diff
changeset
|
598 return *found->second; |
5586
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
599 } |
5568
b0b5546f1b9f
find refactor: re-use existing code. /studies?expand is almost fully implemented with new code
Alain Mazy <am@orthanc.team>
parents:
5565
diff
changeset
|
600 } |
5554
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
601 } |