comparison OrthancServer/ServerJobs/MergeStudyJob.cpp @ 2955:bbfd95a0c429

cont
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 03 Dec 2018 14:59:23 +0100
parents 8b00e4cb4a6b
children 4e43e67f8ecf
comparison
equal deleted inserted replaced
2954:d924f9bb61cc 2955:bbfd95a0c429
59 59
60 void MergeStudyJob::AddSourceStudyInternal(const std::string& study) 60 void MergeStudyJob::AddSourceStudyInternal(const std::string& study)
61 { 61 {
62 if (study == targetStudy_) 62 if (study == targetStudy_)
63 { 63 {
64 LOG(ERROR) << "Cannot merge a study into the same study: " << study; 64 throw OrthancException(ErrorCode_UnknownResource,
65 throw OrthancException(ErrorCode_UnknownResource); 65 "Cannot merge a study into the same study: " + study);
66 } 66 }
67 else 67 else
68 { 68 {
69 std::list<std::string> series; 69 std::list<std::string> series;
70 context_.GetIndex().GetChildren(series, study); 70 context_.GetIndex().GetChildren(series, study);
181 ResourceType type; 181 ResourceType type;
182 182
183 if (!context_.GetIndex().LookupResourceType(type, targetStudy) || 183 if (!context_.GetIndex().LookupResourceType(type, targetStudy) ||
184 type != ResourceType_Study) 184 type != ResourceType_Study)
185 { 185 {
186 LOG(ERROR) << "Cannot merge into an unknown study: " << targetStudy; 186 throw OrthancException(ErrorCode_UnknownResource,
187 throw OrthancException(ErrorCode_UnknownResource); 187 "Cannot merge into an unknown study: " + targetStudy);
188 } 188 }
189 189
190 190
191 /** 191 /**
192 * Detect the tags to be removed/replaced by parsing one child 192 * Detect the tags to be removed/replaced by parsing one child
255 { 255 {
256 throw OrthancException(ErrorCode_BadSequenceOfCalls); 256 throw OrthancException(ErrorCode_BadSequenceOfCalls);
257 } 257 }
258 else if (!context_.GetIndex().LookupResourceType(level, studyOrSeries)) 258 else if (!context_.GetIndex().LookupResourceType(level, studyOrSeries))
259 { 259 {
260 LOG(ERROR) << "Cannot find this resource: " << studyOrSeries; 260 throw OrthancException(ErrorCode_UnknownResource,
261 throw OrthancException(ErrorCode_UnknownResource); 261 "Cannot find this resource: " + studyOrSeries);
262 } 262 }
263 else 263 else
264 { 264 {
265 switch (level) 265 switch (level)
266 { 266 {
271 case ResourceType_Series: 271 case ResourceType_Series:
272 AddSourceSeries(studyOrSeries); 272 AddSourceSeries(studyOrSeries);
273 break; 273 break;
274 274
275 default: 275 default:
276 LOG(ERROR) << "This resource is neither a study, nor a series: " 276 throw OrthancException(ErrorCode_UnknownResource,
277 << studyOrSeries << " is a " << EnumerationToString(level); 277 "This resource is neither a study, nor a series: " +
278 throw OrthancException(ErrorCode_UnknownResource); 278 studyOrSeries + " is a " +
279 std::string(EnumerationToString(level)));
279 } 280 }
280 } 281 }
281 } 282 }
282 283
283 284
289 { 290 {
290 throw OrthancException(ErrorCode_BadSequenceOfCalls); 291 throw OrthancException(ErrorCode_BadSequenceOfCalls);
291 } 292 }
292 else if (!context_.GetIndex().LookupParent(parent, series, ResourceType_Study)) 293 else if (!context_.GetIndex().LookupParent(parent, series, ResourceType_Study))
293 { 294 {
294 LOG(ERROR) << "This resource is not a series: " << series; 295 throw OrthancException(ErrorCode_UnknownResource,
295 throw OrthancException(ErrorCode_UnknownResource); 296 "This resource is not a series: " + series);
296 } 297 }
297 else if (parent == targetStudy_) 298 else if (parent == targetStudy_)
298 { 299 {
299 LOG(ERROR) << "Cannot merge series " << series 300 throw OrthancException(ErrorCode_UnknownResource,
300 << " into its parent study " << targetStudy_; 301 "Cannot merge series " + series +
301 throw OrthancException(ErrorCode_UnknownResource); 302 " into its parent study " + targetStudy_);
302 } 303 }
303 else 304 else
304 { 305 {
305 AddSourceSeriesInternal(series); 306 AddSourceSeriesInternal(series);
306 } 307 }
316 throw OrthancException(ErrorCode_BadSequenceOfCalls); 317 throw OrthancException(ErrorCode_BadSequenceOfCalls);
317 } 318 }
318 else if (!context_.GetIndex().LookupResourceType(actualLevel, study) || 319 else if (!context_.GetIndex().LookupResourceType(actualLevel, study) ||
319 actualLevel != ResourceType_Study) 320 actualLevel != ResourceType_Study)
320 { 321 {
321 LOG(ERROR) << "This resource is not a study: " << study; 322 throw OrthancException(ErrorCode_UnknownResource,
322 throw OrthancException(ErrorCode_UnknownResource); 323 "This resource is not a study: " + study);
323 } 324 }
324 else 325 else
325 { 326 {
326 AddSourceStudyInternal(study); 327 AddSourceStudyInternal(study);
327 } 328 }