comparison OrthancServer/Sources/Database/FindResponse.cpp @ 5568:b0b5546f1b9f find-refactoring

find refactor: re-use existing code. /studies?expand is almost fully implemented with new code
author Alain Mazy <am@orthanc.team>
date Thu, 25 Apr 2024 09:22:07 +0200
parents def06a42e5ef
children 17da828f9443
comparison
equal deleted inserted replaced
5567:f3562c1a150d 5568:b0b5546f1b9f
131 } 131 }
132 } 132 }
133 133
134 134
135 void FindResponse::Item::AddMetadata(MetadataType metadata, 135 void FindResponse::Item::AddMetadata(MetadataType metadata,
136 const std::string& value, 136 const std::string& value)
137 int64_t revision)
138 { 137 {
139 if (metadata_.find(metadata) != metadata_.end()) 138 if (metadata_.find(metadata) != metadata_.end())
140 { 139 {
141 throw OrthancException(ErrorCode_BadSequenceOfCalls); // Metadata already present 140 throw OrthancException(ErrorCode_BadSequenceOfCalls); // Metadata already present
142 } 141 }
143 else 142 else
144 { 143 {
145 metadata_[metadata] = StringWithRevision(value, revision); 144 metadata_[metadata] = value;
146 } 145 }
147 } 146 }
148 147
149 148
150 bool FindResponse::Item::LookupMetadata(std::string& value, 149 bool FindResponse::Item::LookupMetadata(std::string& value,
151 int64_t revision,
152 MetadataType metadata) const 150 MetadataType metadata) const
153 { 151 {
154 std::map<MetadataType, StringWithRevision>::const_iterator found = metadata_.find(metadata); 152 std::map<MetadataType, std::string>::const_iterator found = metadata_.find(metadata);
155 153
156 if (found == metadata_.end()) 154 if (found == metadata_.end())
157 { 155 {
158 return false; 156 return false;
159 } 157 }
160 else 158 else
161 { 159 {
162 value = found->second.GetValue(); 160 value = found->second;
163 revision = found->second.GetRevision();
164 return true; 161 return true;
165 } 162 }
166 } 163 }
167 164
168 165
169 void FindResponse::Item::ListMetadata(std::set<MetadataType>& target) const 166 void FindResponse::Item::ListMetadata(std::set<MetadataType>& target) const
170 { 167 {
171 target.clear(); 168 target.clear();
172 169
173 for (std::map<MetadataType, StringWithRevision>::const_iterator it = metadata_.begin(); it != metadata_.end(); ++it) 170 for (std::map<MetadataType, std::string>::const_iterator it = metadata_.begin(); it != metadata_.end(); ++it)
174 { 171 {
175 target.insert(it->first); 172 target.insert(it->first);
176 } 173 }
177 } 174 }
178 175
223 { 220 {
224 assert(items_[index] != NULL); 221 assert(items_[index] != NULL);
225 return *items_[index]; 222 return *items_[index];
226 } 223 }
227 } 224 }
225
226 void FindResponse::Item::AddDicomTag(uint16_t group, uint16_t element, const std::string& value, bool isBinary)
227 {
228 if (dicomMap_.get() == NULL)
229 {
230 dicomMap_.reset(new DicomMap());
231 }
232
233 dicomMap_->SetValue(group, element, value, isBinary);
234 }
235
236 void FindResponse::Item::AddChild(const std::string& childId)
237 {
238 children_.push_back(childId);
239 }
240
241
228 } 242 }