Mercurial > hg > orthanc
comparison OrthancServer/Sources/ResourceFinder.cpp @ 5621:732ec9feeea8 find-refactoring
introduction of FindRequest::ChildrenRetrieveSpecification
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Sat, 11 May 2024 15:43:07 +0200 |
parents | 4bfd885fb45f |
children | 3f13db27b399 |
comparison
equal
deleted
inserted
replaced
5620:4bfd885fb45f | 5621:732ec9feeea8 |
---|---|
369 { | 369 { |
370 request_.SetRetrieveMainDicomTags(true); | 370 request_.SetRetrieveMainDicomTags(true); |
371 request_.SetRetrieveMetadata(true); | 371 request_.SetRetrieveMetadata(true); |
372 request_.SetRetrieveLabels(true); | 372 request_.SetRetrieveLabels(true); |
373 | 373 |
374 if (level == ResourceType_Series) | 374 switch (level) |
375 { | 375 { |
376 request_.AddRetrieveChildrenMetadata(MetadataType_Instance_IndexInSeries); // required for the SeriesStatus | 376 case ResourceType_Patient: |
377 } | 377 request_.GetChildrenRetrieveSpecification(ResourceType_Study).SetRetrieveIdentifiers(true); |
378 | 378 break; |
379 if (level == ResourceType_Instance) | 379 |
380 { | 380 case ResourceType_Study: |
381 request_.SetRetrieveAttachments(true); // for FileSize & FileUuid | 381 request_.GetChildrenRetrieveSpecification(ResourceType_Series).SetRetrieveIdentifiers(true); |
382 } | 382 request_.SetRetrieveParentIdentifier(true); |
383 else | 383 break; |
384 { | 384 |
385 request_.SetRetrieveChildrenIdentifiers(true); | 385 case ResourceType_Series: |
386 } | 386 request_.AddRetrieveChildrenMetadata(MetadataType_Instance_IndexInSeries); // required for the SeriesStatus |
387 | 387 request_.GetChildrenRetrieveSpecification(ResourceType_Instance).SetRetrieveIdentifiers(true); |
388 if (level != ResourceType_Patient) | 388 request_.SetRetrieveParentIdentifier(true); |
389 { | 389 break; |
390 request_.SetRetrieveParentIdentifier(true); | 390 |
391 case ResourceType_Instance: | |
392 request_.SetRetrieveAttachments(true); // for FileSize & FileUuid | |
393 request_.SetRetrieveParentIdentifier(true); | |
394 break; | |
395 | |
396 default: | |
397 throw OrthancException(ErrorCode_ParameterOutOfRange); | |
391 } | 398 } |
392 } | 399 } |
393 } | 400 } |
394 | 401 |
395 | 402 |
489 } | 496 } |
490 } | 497 } |
491 | 498 |
492 | 499 |
493 void ResourceFinder::Execute(Json::Value& target, | 500 void ResourceFinder::Execute(Json::Value& target, |
494 ServerContext& context) | 501 ServerContext& context) const |
495 { | 502 { |
496 FindResponse response; | 503 FindResponse response; |
497 context.GetIndex().ExecuteFind(response, request_); | 504 context.GetIndex().ExecuteFind(response, request_); |
498 | 505 |
499 target = Json::arrayValue; | 506 target = Json::arrayValue; |
500 | 507 |
501 for (size_t i = 0; i < response.GetSize(); i++) | 508 for (size_t i = 0; i < response.GetSize(); i++) |
502 { | 509 { |
503 const FindResponse::Resource& resource = response.GetResourceByIndex(i); | 510 const FindResponse::Resource& resource = response.GetResourceByIndex(i); |
511 | |
512 { | |
513 Json::Value v; | |
514 resource.DebugExport(v, request_); | |
515 std::cout << v.toStyledString(); | |
516 } | |
504 | 517 |
505 if (expand_) | 518 if (expand_) |
506 { | 519 { |
507 Json::Value item; | 520 Json::Value item; |
508 Expand(item, resource, context.GetIndex()); | 521 Expand(item, resource, context.GetIndex()); |
605 } | 618 } |
606 } | 619 } |
607 | 620 |
608 | 621 |
609 bool ResourceFinder::ExecuteOneResource(Json::Value& target, | 622 bool ResourceFinder::ExecuteOneResource(Json::Value& target, |
610 ServerContext& context) | 623 ServerContext& context) const |
611 { | 624 { |
612 Json::Value answer; | 625 Json::Value answer; |
613 Execute(answer, context); | 626 Execute(answer, context); |
614 | 627 |
615 if (answer.type() != Json::arrayValue) | 628 if (answer.type() != Json::arrayValue) |