# HG changeset patch # User Sebastien Jodogne # Date 1545396484 -3600 # Node ID 6c5d4281da4aebf06e715531160659b7bbcd4d35 # Parent 71ac4f28176f46d08afd6024d22249676beb6523 removal of SQLiteDatabaseWrapper::GetAllInternalIds diff -r 71ac4f28176f -r 6c5d4281da4a OrthancServer/IDatabaseWrapper.h --- a/OrthancServer/IDatabaseWrapper.h Fri Dec 21 13:36:30 2018 +0100 +++ b/OrthancServer/IDatabaseWrapper.h Fri Dec 21 13:48:04 2018 +0100 @@ -102,10 +102,6 @@ virtual void GetAllMetadata(std::map& target, int64_t id) = 0; - // TODO: REMOVE THIS - virtual void GetAllInternalIds(std::list& target, - ResourceType resourceType) = 0; - virtual void GetAllPublicIds(std::list& target, ResourceType resourceType) = 0; diff -r 71ac4f28176f -r 6c5d4281da4a OrthancServer/SQLiteDatabaseWrapper.cpp --- a/OrthancServer/SQLiteDatabaseWrapper.cpp Fri Dec 21 13:36:30 2018 +0100 +++ b/OrthancServer/SQLiteDatabaseWrapper.cpp Fri Dec 21 13:48:04 2018 +0100 @@ -993,20 +993,6 @@ } - void SQLiteDatabaseWrapper::GetAllInternalIds(std::list& target, - ResourceType resourceType) - { - SQLite::Statement s(db_, SQLITE_FROM_HERE, "SELECT internalId FROM Resources WHERE resourceType=?"); - s.BindInt(0, resourceType); - - target.clear(); - while (s.Step()) - { - target.push_back(s.ColumnInt64(0)); - } - } - - void SQLiteDatabaseWrapper::GetAllPublicIds(std::list& target, ResourceType resourceType) { diff -r 71ac4f28176f -r 6c5d4281da4a OrthancServer/SQLiteDatabaseWrapper.h --- a/OrthancServer/SQLiteDatabaseWrapper.h Fri Dec 21 13:36:30 2018 +0100 +++ b/OrthancServer/SQLiteDatabaseWrapper.h Fri Dec 21 13:48:04 2018 +0100 @@ -283,10 +283,6 @@ virtual uint64_t GetResourceCount(ResourceType resourceType) ORTHANC_OVERRIDE; - virtual void GetAllInternalIds(std::list& target, - ResourceType resourceType) - ORTHANC_OVERRIDE; - virtual void GetAllPublicIds(std::list& target, ResourceType resourceType) ORTHANC_OVERRIDE; diff -r 71ac4f28176f -r 6c5d4281da4a OrthancServer/Search/Compatibility/CompatibilityDatabaseWrapper.h --- a/OrthancServer/Search/Compatibility/CompatibilityDatabaseWrapper.h Fri Dec 21 13:36:30 2018 +0100 +++ b/OrthancServer/Search/Compatibility/CompatibilityDatabaseWrapper.h Fri Dec 21 13:48:04 2018 +0100 @@ -55,6 +55,9 @@ class CompatibilityDatabaseWrapper : public IDatabaseWrapper { public: + virtual void GetAllInternalIds(std::list& target, + ResourceType resourceType) = 0; + virtual void LookupIdentifier(std::list& result, ResourceType level, const DicomTag& tag, diff -r 71ac4f28176f -r 6c5d4281da4a OrthancServer/Search/Compatibility/SetOfResources.cpp --- a/OrthancServer/Search/Compatibility/SetOfResources.cpp Fri Dec 21 13:36:30 2018 +0100 +++ b/OrthancServer/Search/Compatibility/SetOfResources.cpp Fri Dec 21 13:48:04 2018 +0100 @@ -39,118 +39,121 @@ namespace Orthanc { - void SetOfResources::Intersect(const std::list& resources) + namespace Compatibility { - if (resources_.get() == NULL) + void SetOfResources::Intersect(const std::list& resources) { - resources_.reset(new Resources); - - for (std::list::const_iterator - it = resources.begin(); it != resources.end(); ++it) + if (resources_.get() == NULL) { - resources_->insert(*it); - } - } - else - { - std::auto_ptr filtered(new Resources); + resources_.reset(new Resources); - for (std::list::const_iterator - it = resources.begin(); it != resources.end(); ++it) - { - if (resources_->find(*it) != resources_->end()) + for (std::list::const_iterator + it = resources.begin(); it != resources.end(); ++it) { - filtered->insert(*it); + resources_->insert(*it); } } - - resources_ = filtered; - } - } - + else + { + std::auto_ptr filtered(new Resources); - void SetOfResources::GoDown() - { - if (level_ == ResourceType_Instance) - { - throw OrthancException(ErrorCode_BadSequenceOfCalls); + for (std::list::const_iterator + it = resources.begin(); it != resources.end(); ++it) + { + if (resources_->find(*it) != resources_->end()) + { + filtered->insert(*it); + } + } + + resources_ = filtered; + } } - if (resources_.get() != NULL) + + void SetOfResources::GoDown() { - std::auto_ptr children(new Resources); - - for (Resources::const_iterator it = resources_->begin(); - it != resources_->end(); ++it) + if (level_ == ResourceType_Instance) { - std::list tmp; - database_.GetChildrenInternalId(tmp, *it); - - for (std::list::const_iterator - child = tmp.begin(); child != tmp.end(); ++child) - { - children->insert(*child); - } + throw OrthancException(ErrorCode_BadSequenceOfCalls); } - resources_ = children; - } + if (resources_.get() != NULL) + { + std::auto_ptr children(new Resources); - switch (level_) - { - case ResourceType_Patient: - level_ = ResourceType_Study; - break; + for (Resources::const_iterator it = resources_->begin(); + it != resources_->end(); ++it) + { + std::list tmp; + database_.GetChildrenInternalId(tmp, *it); + + for (std::list::const_iterator + child = tmp.begin(); child != tmp.end(); ++child) + { + children->insert(*child); + } + } - case ResourceType_Study: - level_ = ResourceType_Series; - break; + resources_ = children; + } + + switch (level_) + { + case ResourceType_Patient: + level_ = ResourceType_Study; + break; - case ResourceType_Series: - level_ = ResourceType_Instance; - break; + case ResourceType_Study: + level_ = ResourceType_Series; + break; - default: - throw OrthancException(ErrorCode_InternalError); + case ResourceType_Series: + level_ = ResourceType_Instance; + break; + + default: + throw OrthancException(ErrorCode_InternalError); + } } - } - void SetOfResources::Flatten(std::list& result) - { - result.clear(); - - if (resources_.get() == NULL) + void SetOfResources::Flatten(std::list& result) { - // All the resources of this level are part of the filter - database_.GetAllPublicIds(result, level_); - } - else - { - for (Resources::const_iterator it = resources_->begin(); - it != resources_->end(); ++it) + result.clear(); + + if (resources_.get() == NULL) { - result.push_back(database_.GetPublicId(*it)); + // All the resources of this level are part of the filter + database_.GetAllPublicIds(result, level_); + } + else + { + for (Resources::const_iterator it = resources_->begin(); + it != resources_->end(); ++it) + { + result.push_back(database_.GetPublicId(*it)); + } } } - } - void SetOfResources::Flatten(std::list& result) - { - result.clear(); - - if (resources_.get() == NULL) + void SetOfResources::Flatten(std::list& result) { - // All the resources of this level are part of the filter - database_.GetAllInternalIds(result, level_); - } - else - { - for (Resources::const_iterator it = resources_->begin(); - it != resources_->end(); ++it) + result.clear(); + + if (resources_.get() == NULL) { - result.push_back(*it); + // All the resources of this level are part of the filter + database_.GetAllInternalIds(result, level_); + } + else + { + for (Resources::const_iterator it = resources_->begin(); + it != resources_->end(); ++it) + { + result.push_back(*it); + } } } } diff -r 71ac4f28176f -r 6c5d4281da4a OrthancServer/Search/Compatibility/SetOfResources.h --- a/OrthancServer/Search/Compatibility/SetOfResources.h Fri Dec 21 13:36:30 2018 +0100 +++ b/OrthancServer/Search/Compatibility/SetOfResources.h Fri Dec 21 13:48:04 2018 +0100 @@ -33,47 +33,49 @@ #pragma once -#include "../../IDatabaseWrapper.h" +#include "CompatibilityDatabaseWrapper.h" #include -#include #include namespace Orthanc { - class SetOfResources : public boost::noncopyable + namespace Compatibility { - private: - typedef std::set Resources; + class SetOfResources : public boost::noncopyable + { + private: + typedef std::set Resources; - IDatabaseWrapper& database_; - ResourceType level_; - std::auto_ptr resources_; + CompatibilityDatabaseWrapper& database_; + ResourceType level_; + std::auto_ptr resources_; - public: - SetOfResources(IDatabaseWrapper& database, - ResourceType level) : - database_(database), - level_(level) - { - } + public: + SetOfResources(CompatibilityDatabaseWrapper& database, + ResourceType level) : + database_(database), + level_(level) + { + } - ResourceType GetLevel() const - { - return level_; - } + ResourceType GetLevel() const + { + return level_; + } - void Intersect(const std::list& resources); + void Intersect(const std::list& resources); - void GoDown(); + void GoDown(); - void Flatten(std::list& result); + void Flatten(std::list& result); - void Flatten(std::list& result); + void Flatten(std::list& result); - void Clear() - { - resources_.reset(NULL); - } - }; + void Clear() + { + resources_.reset(NULL); + } + }; + } }