Mercurial > hg > orthanc
diff OrthancServer/ServerContext.cpp @ 3681:9dac85e807c2 storage-commitment
integration mainline->storage-commitment
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 20 Feb 2020 20:36:47 +0100 |
parents | d8371b4302ff 6358923d3ced |
children | 56f2397f027a |
line wrap: on
line diff
--- a/OrthancServer/ServerContext.cpp Mon Feb 17 17:54:40 2020 +0100 +++ b/OrthancServer/ServerContext.cpp Thu Feb 20 20:36:47 2020 +0100 @@ -254,6 +254,11 @@ jobsEngine_.SetWorkersCount(lock.GetConfiguration().GetUnsignedIntegerParameter("ConcurrentJobs", 2)); saveJobs_ = lock.GetConfiguration().GetBooleanParameter("SaveJobs", true); metricsRegistry_->SetEnabled(lock.GetConfiguration().GetBooleanParameter("MetricsEnabled", true)); + + // New configuration options in Orthanc 1.5.1 + findStorageAccessMode_ = StringToFindStorageAccessMode(lock.GetConfiguration().GetStringParameter("StorageAccessOnFind", "Always")); + limitFindInstances_ = lock.GetConfiguration().GetUnsignedIntegerParameter("LimitFindInstances", 0); + limitFindResults_ = lock.GetConfiguration().GetUnsignedIntegerParameter("LimitFindResults", 0); } jobsEngine_.SetThreadSleep(unitTesting ? 20 : 200); @@ -796,44 +801,9 @@ size_t since, size_t limit) { - LookupMode mode; - unsigned int databaseLimit; + unsigned int databaseLimit = (queryLevel == ResourceType_Instance ? + limitFindInstances_ : limitFindResults_); - { - // New configuration option in 1.5.1 - OrthancConfiguration::ReaderLock lock; - - std::string value = lock.GetConfiguration().GetStringParameter("StorageAccessOnFind", "Always"); - - if (value == "Always") - { - mode = LookupMode_DiskOnLookupAndAnswer; - } - else if (value == "Never") - { - mode = LookupMode_DatabaseOnly; - } - else if (value == "Answers") - { - mode = LookupMode_DiskOnAnswer; - } - else - { - throw OrthancException(ErrorCode_ParameterOutOfRange, - "Configuration option \"StorageAccessOnFind\" " - "should be \"Always\", \"Never\" or \"Answers\": " + value); - } - - if (queryLevel == ResourceType_Instance) - { - databaseLimit = lock.GetConfiguration().GetUnsignedIntegerParameter("LimitFindInstances", 0); - } - else - { - databaseLimit = lock.GetConfiguration().GetUnsignedIntegerParameter("LimitFindResults", 0); - } - } - std::vector<std::string> resources, instances; { @@ -846,6 +816,11 @@ LOG(INFO) << "Number of candidate resources after fast DB filtering on main DICOM tags: " << resources.size(); + /** + * "resources" contains the Orthanc ID of the resource at level + * "queryLevel", "instances" contains one the Orthanc ID of one + * sample instance from this resource. + **/ assert(resources.size() == instances.size()); size_t countResults = 0; @@ -863,19 +838,54 @@ bool hasOnlyMainDicomTags; DicomMap dicom; - if (mode == LookupMode_DatabaseOnly || - mode == LookupMode_DiskOnAnswer || + if (findStorageAccessMode_ == FindStorageAccessMode_DatabaseOnly || + findStorageAccessMode_ == FindStorageAccessMode_DiskOnAnswer || lookup.HasOnlyMainDicomTags()) { // Case (1): The main DICOM tags, as stored in the database, // are sufficient to look for match - if (!GetIndex().GetAllMainDicomTags(dicom, instances[i])) + DicomMap tmp; + if (!GetIndex().GetAllMainDicomTags(tmp, instances[i])) { // The instance has been removed during the execution of the // lookup, ignore it continue; } + +#if 1 + // New in Orthanc 1.6.0: Only keep the main DICOM tags at the + // level of interest for the query + switch (queryLevel) + { + // WARNING: Don't reorder cases below, and don't add "break" + case ResourceType_Instance: + dicom.MergeMainDicomTags(tmp, ResourceType_Instance); + + case ResourceType_Series: + dicom.MergeMainDicomTags(tmp, ResourceType_Series); + + case ResourceType_Study: + dicom.MergeMainDicomTags(tmp, ResourceType_Study); + + case ResourceType_Patient: + dicom.MergeMainDicomTags(tmp, ResourceType_Patient); + break; + + default: + throw OrthancException(ErrorCode_InternalError); + } + + // Special case of the "Modality" at the study level, in order + // to deal with C-FIND on "ModalitiesInStudy" (0008,0061). + // Check out integration test "test_rest_modalities_in_study". + if (queryLevel == ResourceType_Study) + { + dicom.CopyTagIfExists(tmp, DICOM_TAG_MODALITY); + } +#else + dicom.Assign(tmp); // This emulates Orthanc <= 1.5.8 +#endif hasOnlyMainDicomTags = true; } @@ -907,8 +917,8 @@ } else { - if ((mode == LookupMode_DiskOnLookupAndAnswer || - mode == LookupMode_DiskOnAnswer) && + if ((findStorageAccessMode_ == FindStorageAccessMode_DiskOnLookupAndAnswer || + findStorageAccessMode_ == FindStorageAccessMode_DiskOnAnswer) && dicomAsJson.get() == NULL && isDicomAsJsonNeeded) {