# HG changeset patch # User Sebastien Jodogne # Date 1732897124 -3600 # Node ID 1625fa53a6a30a1a7a684106f1fd9384d71ece9b # Parent 9b73ec6a07bebab118638ad1f221c109db31c796 refactoring StatelessDatabaseOperations::LookupIdentifierExact() diff -r 9b73ec6a07be -r 1625fa53a6a3 OrthancServer/Sources/Database/Compatibility/GenericFind.cpp --- a/OrthancServer/Sources/Database/Compatibility/GenericFind.cpp Fri Nov 29 16:29:46 2024 +0100 +++ b/OrthancServer/Sources/Database/Compatibility/GenericFind.cpp Fri Nov 29 17:18:44 2024 +0100 @@ -241,9 +241,9 @@ !request.GetOrthancIdentifiers().HasSeriesId() && !request.GetOrthancIdentifiers().HasInstanceId()) { - transaction_.ApplyLookupResources(identifiers, NULL /* TODO-FIND: Could the "instancesId" information be exploited? */, - request.GetDicomTagConstraints(), request.GetLevel(), request.GetLabels(), - request.GetLabelsConstraint(), request.HasLimits() ? request.GetLimitsCount() : 0); + compatibilityTransaction_.ApplyLookupResources(identifiers, NULL /* TODO-FIND: Could the "instancesId" information be exploited? */, + request.GetDicomTagConstraints(), request.GetLevel(), request.GetLabels(), + request.GetLabelsConstraint(), request.HasLimits() ? request.GetLimitsCount() : 0); } else { diff -r 9b73ec6a07be -r 1625fa53a6a3 OrthancServer/Sources/Database/IDatabaseWrapper.h --- a/OrthancServer/Sources/Database/IDatabaseWrapper.h Fri Nov 29 16:29:46 2024 +0100 +++ b/OrthancServer/Sources/Database/IDatabaseWrapper.h Fri Nov 29 17:18:44 2024 +0100 @@ -310,13 +310,6 @@ virtual bool IsDiskSizeAbove(uint64_t threshold) = 0; - virtual void ApplyLookupResources(std::list& resourcesId, - std::list* instancesId, // Can be NULL if not needed - const DatabaseDicomTagConstraints& lookup, - ResourceType queryLevel, - const std::set& labels, - LabelsConstraint labelsConstraint, - uint32_t limit) = 0; // Returns "true" iff. the instance is new and has been inserted // into the database. If "false" is returned, the content of @@ -432,6 +425,18 @@ int64_t id) = 0; /** + * Primitives introduced in Orthanc 1.5.2 + **/ + + virtual void ApplyLookupResources(std::list& resourcesId, + std::list* instancesId, // Can be NULL if not needed + const DatabaseDicomTagConstraints& lookup, + ResourceType queryLevel, + const std::set& labels, + LabelsConstraint labelsConstraint, + uint32_t limit) = 0; + + /** * Primitives introduced in Orthanc 1.5.4 **/ diff -r 9b73ec6a07be -r 1625fa53a6a3 OrthancServer/Sources/Database/StatelessDatabaseOperations.cpp --- a/OrthancServer/Sources/Database/StatelessDatabaseOperations.cpp Fri Nov 29 16:29:46 2024 +0100 +++ b/OrthancServer/Sources/Database/StatelessDatabaseOperations.cpp Fri Nov 29 17:18:44 2024 +0100 @@ -288,22 +288,6 @@ } - static void CopyListToVector(std::vector& target, - const std::list& source) - { - target.resize(source.size()); - - size_t pos = 0; - - for (std::list::const_iterator - it = source.begin(); it != source.end(); ++it) - { - target[pos] = *it; - pos ++; - } - } - - void StatelessDatabaseOperations::ReadWriteTransaction::LogChange(int64_t internalId, ChangeType changeType, ResourceType resourceType, @@ -1245,45 +1229,24 @@ (level == ResourceType_Study && tag == DICOM_TAG_ACCESSION_NUMBER) || (level == ResourceType_Series && tag == DICOM_TAG_SERIES_INSTANCE_UID) || (level == ResourceType_Instance && tag == DICOM_TAG_SOP_INSTANCE_UID)); - - result.clear(); + + FindRequest request(level); DicomTagConstraint c(tag, ConstraintType_Equal, value, true, true); - DatabaseDicomTagConstraints query; bool isIdentical; // unused - query.AddConstraint(c.ConvertToDatabaseConstraint(isIdentical, level, DicomTagType_Identifier)); - - - class Operations : public IReadOnlyOperations + request.GetDicomTagConstraints().AddConstraint(c.ConvertToDatabaseConstraint(isIdentical, level, DicomTagType_Identifier)); + + FindResponse response; + ExecuteFind(response, request); + + result.clear(); + result.reserve(response.GetSize()); + + for (size_t i = 0; i < response.GetSize(); i++) { - private: - std::vector& result_; - const DatabaseDicomTagConstraints& query_; - ResourceType level_; - - public: - Operations(std::vector& result, - const DatabaseDicomTagConstraints& query, - ResourceType level) : - result_(result), - query_(query), - level_(level) - { - } - - virtual void Apply(ReadOnlyTransaction& transaction) ORTHANC_OVERRIDE - { - // TODO - CANDIDATE FOR "TransactionType_Implicit" - std::list tmp; - std::set labels; - transaction.ApplyLookupResources(tmp, NULL, query_, level_, labels, LabelsConstraint_Any, 0); - CopyListToVector(result_, tmp); - } - }; - - Operations operations(result, query, level); - Apply(operations); + result.push_back(response.GetResourceByIndex(i).GetIdentifier()); + } } diff -r 9b73ec6a07be -r 1625fa53a6a3 OrthancServer/Sources/Database/StatelessDatabaseOperations.h --- a/OrthancServer/Sources/Database/StatelessDatabaseOperations.h Fri Nov 29 16:29:46 2024 +0100 +++ b/OrthancServer/Sources/Database/StatelessDatabaseOperations.h Fri Nov 29 17:18:44 2024 +0100 @@ -123,18 +123,6 @@ * Read-only methods from "IDatabaseWrapper" **/ - void ApplyLookupResources(std::list& resourcesId, - std::list* instancesId, // Can be NULL if not needed - const DatabaseDicomTagConstraints& lookup, - ResourceType queryLevel, - const std::set& labels, // New in Orthanc 1.12.0 - LabelsConstraint labelsConstraint, // New in Orthanc 1.12.0 - uint32_t limit) - { - return transaction_.ApplyLookupResources(resourcesId, instancesId, lookup, queryLevel, - labels, labelsConstraint, limit); - } - void GetAllMetadata(std::map& target, int64_t id) {