Mercurial > hg > orthanc
comparison OrthancServer/Sources/ServerJobs/MergeStudyJob.cpp @ 4717:783f8a048035 openssl-3.x
integration mainline->openssl-3.x
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 23 Jun 2021 16:23:23 +0200 |
parents | f0038043fb97 fb98db281d1d |
children | 70d2a97ca8cb |
comparison
equal
deleted
inserted
replaced
4711:816a9ecc6ea1 | 4717:783f8a048035 |
---|---|
28 #include "../ServerContext.h" | 28 #include "../ServerContext.h" |
29 | 29 |
30 | 30 |
31 namespace Orthanc | 31 namespace Orthanc |
32 { | 32 { |
33 static void RegisterSeries(std::map<std::string, std::string>& target, | |
34 const std::string& series) | |
35 { | |
36 // Generate a target SeriesInstanceUID for this series | |
37 if (target.find(series) == target.end()) | |
38 { | |
39 target[series] = FromDcmtkBridge::GenerateUniqueIdentifier(ResourceType_Series); | |
40 } | |
41 } | |
42 | |
43 | |
33 void MergeStudyJob::AddSourceSeriesInternal(const std::string& series) | 44 void MergeStudyJob::AddSourceSeriesInternal(const std::string& series) |
34 { | 45 { |
35 // Generate a target SeriesInstanceUID for this series | 46 RegisterSeries(seriesUidMap_, series); |
36 seriesUidMap_[series] = FromDcmtkBridge::GenerateUniqueIdentifier(ResourceType_Series); | |
37 | 47 |
38 // Add all the instances of the series as to be processed | 48 // Add all the instances of the series as to be processed |
39 std::list<std::string> instances; | 49 std::list<std::string> instances; |
40 GetContext().GetIndex().GetChildren(instances, series); | 50 GetContext().GetIndex().GetChildren(instances, series); |
41 | 51 |
226 { | 236 { |
227 SetOrigin(DicomInstanceOrigin::FromRest(call)); | 237 SetOrigin(DicomInstanceOrigin::FromRest(call)); |
228 } | 238 } |
229 | 239 |
230 | 240 |
231 void MergeStudyJob::AddSource(const std::string& studyOrSeries) | 241 void MergeStudyJob::AddSource(const std::string& publicId) |
232 { | 242 { |
233 ResourceType level; | 243 ResourceType level; |
234 | 244 |
235 if (IsStarted()) | 245 if (IsStarted()) |
236 { | 246 { |
237 throw OrthancException(ErrorCode_BadSequenceOfCalls); | 247 throw OrthancException(ErrorCode_BadSequenceOfCalls); |
238 } | 248 } |
239 else if (!GetContext().GetIndex().LookupResourceType(level, studyOrSeries)) | 249 else if (!GetContext().GetIndex().LookupResourceType(level, publicId)) |
240 { | 250 { |
241 throw OrthancException(ErrorCode_UnknownResource, | 251 throw OrthancException(ErrorCode_UnknownResource, |
242 "Cannot find this resource: " + studyOrSeries); | 252 "Cannot find this resource: " + publicId); |
243 } | 253 } |
244 else | 254 else |
245 { | 255 { |
246 switch (level) | 256 switch (level) |
247 { | 257 { |
248 case ResourceType_Study: | 258 case ResourceType_Study: |
249 AddSourceStudyInternal(studyOrSeries); | 259 AddSourceStudyInternal(publicId); |
250 break; | 260 break; |
251 | 261 |
252 case ResourceType_Series: | 262 case ResourceType_Series: |
253 AddSourceSeries(studyOrSeries); | 263 AddSourceSeries(publicId); |
264 break; | |
265 | |
266 case ResourceType_Instance: | |
267 AddSourceInstance(publicId); | |
254 break; | 268 break; |
255 | 269 |
256 default: | 270 default: |
257 throw OrthancException(ErrorCode_UnknownResource, | 271 throw OrthancException(ErrorCode_UnknownResource, |
258 "This resource is neither a study, nor a series: " + | 272 "This resource is neither a study, nor a series, nor an instance: " + |
259 studyOrSeries + " is a " + | 273 publicId + " is a " + std::string(EnumerationToString(level))); |
260 std::string(EnumerationToString(level))); | |
261 } | 274 } |
262 } | 275 } |
263 } | 276 } |
264 | 277 |
265 | 278 |
307 { | 320 { |
308 AddSourceStudyInternal(study); | 321 AddSourceStudyInternal(study); |
309 } | 322 } |
310 } | 323 } |
311 | 324 |
325 | |
326 void MergeStudyJob::AddSourceInstance(const std::string& instance) | |
327 { | |
328 std::string parentStudy, parentSeries; | |
329 | |
330 if (IsStarted()) | |
331 { | |
332 throw OrthancException(ErrorCode_BadSequenceOfCalls); | |
333 } | |
334 else if (!GetContext().GetIndex().LookupParent(parentSeries, instance, ResourceType_Series) || | |
335 !GetContext().GetIndex().LookupParent(parentStudy, parentSeries, ResourceType_Study)) | |
336 { | |
337 throw OrthancException(ErrorCode_UnknownResource, | |
338 "This resource is not an instance: " + instance); | |
339 } | |
340 else if (parentStudy == targetStudy_) | |
341 { | |
342 throw OrthancException(ErrorCode_UnknownResource, | |
343 "Cannot merge instance " + instance + | |
344 " into its parent study " + targetStudy_); | |
345 } | |
346 else | |
347 { | |
348 RegisterSeries(seriesUidMap_, parentSeries); | |
349 AddInstance(instance); | |
350 } | |
351 } | |
352 | |
312 | 353 |
313 void MergeStudyJob::GetPublicContent(Json::Value& value) | 354 void MergeStudyJob::GetPublicContent(Json::Value& value) |
314 { | 355 { |
315 CleaningInstancesJob::GetPublicContent(value); | 356 CleaningInstancesJob::GetPublicContent(value); |
316 value["TargetStudy"] = targetStudy_; | 357 value["TargetStudy"] = targetStudy_; |