Mercurial > hg > orthanc
diff OrthancServer/Search/Compatibility/SetOfResources.cpp @ 3056:6c5d4281da4a db-changes
removal of SQLiteDatabaseWrapper::GetAllInternalIds
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 21 Dec 2018 13:48:04 +0100 |
parents | c7db469bbe8e |
children | ce272138f15e |
line wrap: on
line diff
--- 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<int64_t>& resources) + namespace Compatibility { - if (resources_.get() == NULL) + void SetOfResources::Intersect(const std::list<int64_t>& resources) { - resources_.reset(new Resources); - - for (std::list<int64_t>::const_iterator - it = resources.begin(); it != resources.end(); ++it) + if (resources_.get() == NULL) { - resources_->insert(*it); - } - } - else - { - std::auto_ptr<Resources> filtered(new Resources); + resources_.reset(new Resources); - for (std::list<int64_t>::const_iterator - it = resources.begin(); it != resources.end(); ++it) - { - if (resources_->find(*it) != resources_->end()) + for (std::list<int64_t>::const_iterator + it = resources.begin(); it != resources.end(); ++it) { - filtered->insert(*it); + resources_->insert(*it); } } - - resources_ = filtered; - } - } - + else + { + std::auto_ptr<Resources> filtered(new Resources); - void SetOfResources::GoDown() - { - if (level_ == ResourceType_Instance) - { - throw OrthancException(ErrorCode_BadSequenceOfCalls); + for (std::list<int64_t>::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<Resources> children(new Resources); - - for (Resources::const_iterator it = resources_->begin(); - it != resources_->end(); ++it) + if (level_ == ResourceType_Instance) { - std::list<int64_t> tmp; - database_.GetChildrenInternalId(tmp, *it); - - for (std::list<int64_t>::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<Resources> 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<int64_t> tmp; + database_.GetChildrenInternalId(tmp, *it); + + for (std::list<int64_t>::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<std::string>& result) - { - result.clear(); - - if (resources_.get() == NULL) + void SetOfResources::Flatten(std::list<std::string>& 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<int64_t>& result) - { - result.clear(); - - if (resources_.get() == NULL) + void SetOfResources::Flatten(std::list<int64_t>& 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); + } } } }