Mercurial > hg > orthanc
comparison OrthancServer/Sources/OrthancRestApi/OrthancRestResources.cpp @ 5558:c1ed59a5bdc2
new LimitToThisLevelMainDicomTags reconstruct mode + * Housekeeper plugin: Added an option LimitMainDicomTagsReconstructLevel
author | Alain Mazy <am@orthanc.team> |
---|---|
date | Fri, 19 Apr 2024 11:27:39 +0200 |
parents | 48b8dae6dc77 |
children | 738f80622e91 f7adfb22e20e |
comparison
equal
deleted
inserted
replaced
5557:87c0fbc8f457 | 5558:c1ed59a5bdc2 |
---|---|
56 | 56 |
57 static const std::string CHECK_REVISIONS = "CheckRevisions"; | 57 static const std::string CHECK_REVISIONS = "CheckRevisions"; |
58 | 58 |
59 static const char* const IGNORE_LENGTH = "ignore-length"; | 59 static const char* const IGNORE_LENGTH = "ignore-length"; |
60 static const char* const RECONSTRUCT_FILES = "ReconstructFiles"; | 60 static const char* const RECONSTRUCT_FILES = "ReconstructFiles"; |
61 static const char* const LIMIT_TO_THIS_LEVEL_MAIN_DICOM_TAGS = "LimitToThisLevelMainDicomTags"; | |
61 | 62 |
62 | 63 |
63 namespace Orthanc | 64 namespace Orthanc |
64 { | 65 { |
65 static std::string GetDocumentationSampleResource(ResourceType type) | 66 static std::string GetDocumentationSampleResource(ResourceType type) |
3642 } | 3643 } |
3643 | 3644 |
3644 call.GetOutput().AnswerBuffer("", MimeType_PlainText); | 3645 call.GetOutput().AnswerBuffer("", MimeType_PlainText); |
3645 } | 3646 } |
3646 | 3647 |
3647 void DocumentReconstructFilesField(RestApiPostCall& call) | 3648 void DocumentReconstructFilesField(RestApiPostCall& call, bool documentLimitField) |
3648 { | 3649 { |
3649 call.GetDocumentation() | 3650 call.GetDocumentation() |
3650 .SetRequestField(RECONSTRUCT_FILES, RestApiCallDocumentation::Type_Boolean, | 3651 .SetRequestField(RECONSTRUCT_FILES, RestApiCallDocumentation::Type_Boolean, |
3651 "Also reconstruct the files of the resources (e.g: apply IngestTranscoding, StorageCompression). " | 3652 "Also reconstruct the files of the resources (e.g: apply IngestTranscoding, StorageCompression). " |
3652 "'false' by default. (New in Orthanc 1.11.0)", false); | 3653 "'false' by default. (New in Orthanc 1.11.0)", false); |
3654 if (documentLimitField) | |
3655 { | |
3656 call.GetDocumentation() | |
3657 .SetRequestField(LIMIT_TO_THIS_LEVEL_MAIN_DICOM_TAGS, RestApiCallDocumentation::Type_Boolean, | |
3658 "Only reconstruct this level MainDicomTags by re-reading them from a random child instance of the resource. " | |
3659 "This option is much faster than a full reconstruct and is usefull e.g. if you have modified the " | |
3660 "'ExtraMainDicomTags' at the Study level to optimize the speed of some C-Find. " | |
3661 "'false' by default. (New in Orthanc 1.12.4)", false); | |
3662 } | |
3653 } | 3663 } |
3654 | 3664 |
3655 bool GetReconstructFilesField(const RestApiPostCall& call) | 3665 bool GetReconstructFilesField(const RestApiPostCall& call) |
3656 { | 3666 { |
3657 bool reconstructFiles = false; | 3667 bool reconstructFiles = false; |
3668 reconstructFiles = request[RECONSTRUCT_FILES].asBool(); | 3678 reconstructFiles = request[RECONSTRUCT_FILES].asBool(); |
3669 } | 3679 } |
3670 | 3680 |
3671 return reconstructFiles; | 3681 return reconstructFiles; |
3672 } | 3682 } |
3683 | |
3684 bool GetLimitToThisLevelMainDicomTags(const RestApiPostCall& call) | |
3685 { | |
3686 bool limitToThisLevel = false; | |
3687 Json::Value request; | |
3688 | |
3689 if (call.GetBodySize() > 0 && call.ParseJsonRequest(request) && request.isMember(LIMIT_TO_THIS_LEVEL_MAIN_DICOM_TAGS)) | |
3690 { | |
3691 if (!request[LIMIT_TO_THIS_LEVEL_MAIN_DICOM_TAGS].isBool()) | |
3692 { | |
3693 throw OrthancException(ErrorCode_BadFileFormat, | |
3694 "The field " + std::string(LIMIT_TO_THIS_LEVEL_MAIN_DICOM_TAGS) + " must contain a Boolean"); | |
3695 } | |
3696 | |
3697 limitToThisLevel = request[LIMIT_TO_THIS_LEVEL_MAIN_DICOM_TAGS].asBool(); | |
3698 } | |
3699 | |
3700 return limitToThisLevel; | |
3701 } | |
3702 | |
3673 | 3703 |
3674 template <enum ResourceType type> | 3704 template <enum ResourceType type> |
3675 static void ReconstructResource(RestApiPostCall& call) | 3705 static void ReconstructResource(RestApiPostCall& call) |
3676 { | 3706 { |
3677 if (call.IsDocumentation()) | 3707 if (call.IsDocumentation()) |
3684 "in the URL. This is useful if child studies/series/instances have inconsistent values for " | 3714 "in the URL. This is useful if child studies/series/instances have inconsistent values for " |
3685 "higher-level tags, in order to force Orthanc to use the value from the resource of interest. " | 3715 "higher-level tags, in order to force Orthanc to use the value from the resource of interest. " |
3686 "Beware that this is a time-consuming operation, as all the children DICOM instances will be " | 3716 "Beware that this is a time-consuming operation, as all the children DICOM instances will be " |
3687 "parsed again, and the Orthanc index will be updated accordingly.") | 3717 "parsed again, and the Orthanc index will be updated accordingly.") |
3688 .SetUriArgument("id", "Orthanc identifier of the " + resource + " of interest"); | 3718 .SetUriArgument("id", "Orthanc identifier of the " + resource + " of interest"); |
3689 DocumentReconstructFilesField(call); | 3719 DocumentReconstructFilesField(call, true); |
3690 | 3720 |
3691 return; | 3721 return; |
3692 } | 3722 } |
3693 | 3723 |
3694 ServerContext& context = OrthancRestApi::GetContext(call); | 3724 ServerContext& context = OrthancRestApi::GetContext(call); |
3695 ServerToolbox::ReconstructResource(context, call.GetUriComponent("id", ""), GetReconstructFilesField(call)); | 3725 ServerToolbox::ReconstructResource(context, call.GetUriComponent("id", ""), GetReconstructFilesField(call), GetLimitToThisLevelMainDicomTags(call), type); |
3696 call.GetOutput().AnswerBuffer("", MimeType_PlainText); | 3726 call.GetOutput().AnswerBuffer("", MimeType_PlainText); |
3697 } | 3727 } |
3698 | 3728 |
3699 | 3729 |
3700 static void ReconstructAllResources(RestApiPostCall& call) | 3730 static void ReconstructAllResources(RestApiPostCall& call) |
3708 "This is notably useful after the deletion of resources whose children resources have inconsistent " | 3738 "This is notably useful after the deletion of resources whose children resources have inconsistent " |
3709 "values with their sibling resources. Beware that this is a highly time-consuming operation, " | 3739 "values with their sibling resources. Beware that this is a highly time-consuming operation, " |
3710 "as all the DICOM instances will be parsed again, and as all the Orthanc index will be regenerated. " | 3740 "as all the DICOM instances will be parsed again, and as all the Orthanc index will be regenerated. " |
3711 "If you have a large database to process, it is advised to use the Housekeeper plugin to perform " | 3741 "If you have a large database to process, it is advised to use the Housekeeper plugin to perform " |
3712 "this action resource by resource"); | 3742 "this action resource by resource"); |
3713 DocumentReconstructFilesField(call); | 3743 DocumentReconstructFilesField(call, false); |
3714 | 3744 |
3715 return; | 3745 return; |
3716 } | 3746 } |
3717 | 3747 |
3718 ServerContext& context = OrthancRestApi::GetContext(call); | 3748 ServerContext& context = OrthancRestApi::GetContext(call); |
3722 bool reconstructFiles = GetReconstructFilesField(call); | 3752 bool reconstructFiles = GetReconstructFilesField(call); |
3723 | 3753 |
3724 for (std::list<std::string>::const_iterator | 3754 for (std::list<std::string>::const_iterator |
3725 study = studies.begin(); study != studies.end(); ++study) | 3755 study = studies.begin(); study != studies.end(); ++study) |
3726 { | 3756 { |
3727 ServerToolbox::ReconstructResource(context, *study, reconstructFiles); | 3757 ServerToolbox::ReconstructResource(context, *study, reconstructFiles, false, ResourceType_Study /* dummy */); |
3728 } | 3758 } |
3729 | 3759 |
3730 call.GetOutput().AnswerBuffer("", MimeType_PlainText); | 3760 call.GetOutput().AnswerBuffer("", MimeType_PlainText); |
3731 } | 3761 } |
3732 | 3762 |