Mercurial > hg > orthanc
comparison OrthancServer/Plugins/Samples/Housekeeper/Plugin.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 | 6ce05f8b5b13 |
children | 0b18690c1935 |
comparison
equal
deleted
inserted
replaced
5557:87c0fbc8f457 | 5558:c1ed59a5bdc2 |
---|---|
46 static bool triggerOnStorageCompressionChange_ = true; | 46 static bool triggerOnStorageCompressionChange_ = true; |
47 static bool triggerOnMainDicomTagsChange_ = true; | 47 static bool triggerOnMainDicomTagsChange_ = true; |
48 static bool triggerOnUnnecessaryDicomAsJsonFiles_ = true; | 48 static bool triggerOnUnnecessaryDicomAsJsonFiles_ = true; |
49 static bool triggerOnIngestTranscodingChange_ = true; | 49 static bool triggerOnIngestTranscodingChange_ = true; |
50 static bool triggerOnDicomWebCacheChange_ = true; | 50 static bool triggerOnDicomWebCacheChange_ = true; |
51 static std::string limitMainDicomTagsReconstructLevel_ = ""; | |
52 static std::string limitToChange_ = ""; | |
53 static std::string limitToUrl_ = ""; | |
54 | |
51 | 55 |
52 struct RunningPeriod | 56 struct RunningPeriod |
53 { | 57 { |
54 int fromHour_; | 58 int fromHour_; |
55 int toHour_; | 59 int toHour_; |
542 for (Json::ArrayIndex i = 0; i < changes["Changes"].size(); i++) | 546 for (Json::ArrayIndex i = 0; i < changes["Changes"].size(); i++) |
543 { | 547 { |
544 const Json::Value& change = changes["Changes"][i]; | 548 const Json::Value& change = changes["Changes"][i]; |
545 int64_t seq = change["Seq"].asInt64(); | 549 int64_t seq = change["Seq"].asInt64(); |
546 | 550 |
547 if (change["ChangeType"] == "NewStudy") // some StableStudy might be missing if orthanc was shutdown during a StableAge -> consider only the NewStudy events that can not be missed | 551 if (!limitToChange_.empty()) // if updating only maindicomtags for a single level |
548 { | 552 { |
549 Json::Value result; | 553 if (change["ChangeType"] == limitToChange_) |
550 | |
551 if (needsReconstruct) | |
552 { | 554 { |
555 Json::Value result; | |
553 Json::Value request; | 556 Json::Value request; |
554 if (needsReingest) | 557 request["ReconstructFiles"] = false; |
558 request["LimitToThisLevelMainDicomTags"] = true; | |
559 OrthancPlugins::RestApiPost(result, "/" + limitToUrl_ + "/" + change["ID"].asString() + "/reconstruct", request, false); | |
560 } | |
561 } | |
562 else | |
563 { | |
564 if (change["ChangeType"] == "NewStudy") // some StableStudy might be missing if orthanc was shutdown during a StableAge -> consider only the NewStudy events that can not be missed | |
565 { | |
566 Json::Value result; | |
567 | |
568 if (needsReconstruct) | |
555 { | 569 { |
556 request["ReconstructFiles"] = true; | 570 Json::Value request; |
571 if (needsReingest) | |
572 { | |
573 request["ReconstructFiles"] = true; | |
574 } | |
575 OrthancPlugins::RestApiPost(result, "/studies/" + change["ID"].asString() + "/reconstruct", request, false); | |
557 } | 576 } |
558 OrthancPlugins::RestApiPost(result, "/studies/" + change["ID"].asString() + "/reconstruct", request, false); | 577 |
559 } | 578 if (needsDicomWebCaching) |
560 | 579 { |
561 if (needsDicomWebCaching) | 580 Json::Value request; |
562 { | 581 OrthancPlugins::RestApiPost(result, "/studies/" + change["ID"].asString() + "/update-dicomweb-cache", request, true); |
563 Json::Value request; | 582 } |
564 OrthancPlugins::RestApiPost(result, "/studies/" + change["ID"].asString() + "/update-dicomweb-cache", request, true); | |
565 } | 583 } |
566 } | 584 } |
567 | 585 |
568 { | 586 { |
569 boost::recursive_mutex::scoped_lock lock(pluginStatusMutex_); | 587 boost::recursive_mutex::scoped_lock lock(pluginStatusMutex_); |
840 "Triggers" : { | 858 "Triggers" : { |
841 "StorageCompressionChange": true, | 859 "StorageCompressionChange": true, |
842 "MainDicomTagsChange": true, | 860 "MainDicomTagsChange": true, |
843 "UnnecessaryDicomAsJsonFiles": true, | 861 "UnnecessaryDicomAsJsonFiles": true, |
844 "DicomWebCacheChange": true // new in 1.12.2 | 862 "DicomWebCacheChange": true // new in 1.12.2 |
845 } | 863 }, |
864 | |
865 // When rebuilding MainDicomTags, limit to a single level of resource. | |
866 // Allowed values: "Patient", "Study", "Series", "Instance" | |
867 "LimitMainDicomTagsReconstructLevel": "Study" | |
846 | 868 |
847 } | 869 } |
848 } | 870 } |
849 */ | 871 */ |
850 | 872 |
863 triggerOnUnnecessaryDicomAsJsonFiles_ = triggers.GetBooleanValue("UnnecessaryDicomAsJsonFiles", true); | 885 triggerOnUnnecessaryDicomAsJsonFiles_ = triggers.GetBooleanValue("UnnecessaryDicomAsJsonFiles", true); |
864 triggerOnIngestTranscodingChange_ = triggers.GetBooleanValue("IngestTranscodingChange", true); | 886 triggerOnIngestTranscodingChange_ = triggers.GetBooleanValue("IngestTranscodingChange", true); |
865 triggerOnDicomWebCacheChange_ = triggers.GetBooleanValue("DicomWebCacheChange", true); | 887 triggerOnDicomWebCacheChange_ = triggers.GetBooleanValue("DicomWebCacheChange", true); |
866 } | 888 } |
867 | 889 |
890 limitMainDicomTagsReconstructLevel_ = housekeeper.GetStringValue("LimitMainDicomTagsReconstructLevel", ""); | |
891 if (limitMainDicomTagsReconstructLevel_ != "Patient" && limitMainDicomTagsReconstructLevel_ != "Study" | |
892 && limitMainDicomTagsReconstructLevel_ != "Series" && limitMainDicomTagsReconstructLevel_ != "Instance") | |
893 { | |
894 OrthancPlugins::LogError("Housekeeper invalid value for 'LimitMainDicomTagsReconstructLevel': '" + limitMainDicomTagsReconstructLevel_ + "'"); | |
895 } | |
896 else if (limitMainDicomTagsReconstructLevel_ == "Patient") | |
897 { | |
898 limitToChange_ = "NewPatient"; | |
899 limitToUrl_ = "patients"; | |
900 } | |
901 else if (limitMainDicomTagsReconstructLevel_ == "Study") | |
902 { | |
903 limitToChange_ = "NewStudy"; | |
904 limitToUrl_ = "studies"; | |
905 } | |
906 else if (limitMainDicomTagsReconstructLevel_ == "Series") | |
907 { | |
908 limitToChange_ = "NewSeries"; | |
909 limitToUrl_ = "series"; | |
910 } | |
911 else if (limitMainDicomTagsReconstructLevel_ == "Instance") | |
912 { | |
913 limitToChange_ = "NewInstance"; | |
914 limitToUrl_ = "instances"; | |
915 } | |
916 | |
868 if (housekeeper.GetJson().isMember("Schedule")) | 917 if (housekeeper.GetJson().isMember("Schedule")) |
869 { | 918 { |
870 runningPeriods_.load(housekeeper.GetJson()["Schedule"]); | 919 runningPeriods_.load(housekeeper.GetJson()["Schedule"]); |
871 } | 920 } |
872 | 921 |