Mercurial > hg > orthanc
comparison OrthancServer/ServerIndex.cpp @ 3075:ead8576a02ef db-changes
IDatabaseWrapper::ApplyLookupResources now returns lists
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 02 Jan 2019 18:39:25 +0100 |
parents | 0e9d1731b1b0 |
children | 1a75595d8e44 |
comparison
equal
deleted
inserted
replaced
3074:495c5edce708 | 3075:ead8576a02ef |
---|---|
56 | 56 |
57 static const uint64_t MEGA_BYTES = 1024 * 1024; | 57 static const uint64_t MEGA_BYTES = 1024 * 1024; |
58 | 58 |
59 namespace Orthanc | 59 namespace Orthanc |
60 { | 60 { |
61 static void CopyListToVector(std::vector<std::string>& target, | |
62 const std::list<std::string>& source) | |
63 { | |
64 target.resize(source.size()); | |
65 | |
66 size_t pos = 0; | |
67 | |
68 for (std::list<std::string>::const_iterator | |
69 it = source.begin(); it != source.end(); ++it) | |
70 { | |
71 target[pos] = *it; | |
72 pos ++; | |
73 } | |
74 } | |
75 | |
76 | |
61 class ServerIndex::Listener : public IDatabaseListener | 77 class ServerIndex::Listener : public IDatabaseListener |
62 { | 78 { |
63 private: | 79 private: |
64 struct FileToRemove | 80 struct FileToRemove |
65 { | 81 { |
2139 DicomTagConstraint c(tag, ConstraintType_Equal, value, true, true); | 2155 DicomTagConstraint c(tag, ConstraintType_Equal, value, true, true); |
2140 | 2156 |
2141 std::vector<DatabaseConstraint> query; | 2157 std::vector<DatabaseConstraint> query; |
2142 query.push_back(c.ConvertToDatabaseConstraint(level, DicomTagType_Identifier)); | 2158 query.push_back(c.ConvertToDatabaseConstraint(level, DicomTagType_Identifier)); |
2143 | 2159 |
2160 std::list<std::string> tmp; | |
2161 | |
2144 { | 2162 { |
2145 boost::mutex::scoped_lock lock(mutex_); | 2163 boost::mutex::scoped_lock lock(mutex_); |
2146 db_.ApplyLookupResources(result, NULL, query, level, 0); | 2164 db_.ApplyLookupResources(tmp, NULL, query, level, 0); |
2147 } | 2165 } |
2166 | |
2167 CopyListToVector(result, tmp); | |
2148 } | 2168 } |
2149 | 2169 |
2150 | 2170 |
2151 StoreStatus ServerIndex::AddAttachment(const FileInfo& attachment, | 2171 StoreStatus ServerIndex::AddAttachment(const FileInfo& attachment, |
2152 const std::string& publicId) | 2172 const std::string& publicId) |
2568 size_t limit) | 2588 size_t limit) |
2569 { | 2589 { |
2570 std::vector<DatabaseConstraint> normalized; | 2590 std::vector<DatabaseConstraint> normalized; |
2571 NormalizeLookup(normalized, lookup, queryLevel); | 2591 NormalizeLookup(normalized, lookup, queryLevel); |
2572 | 2592 |
2593 std::list<std::string> resourcesList, instancesList; | |
2594 | |
2573 { | 2595 { |
2574 boost::mutex::scoped_lock lock(mutex_); | 2596 boost::mutex::scoped_lock lock(mutex_); |
2575 db_.ApplyLookupResources(resourcesId, instancesId, normalized, queryLevel, limit); | 2597 |
2598 if (instancesId == NULL) | |
2599 { | |
2600 db_.ApplyLookupResources(resourcesList, NULL, normalized, queryLevel, limit); | |
2601 } | |
2602 else | |
2603 { | |
2604 db_.ApplyLookupResources(resourcesList, &instancesList, normalized, queryLevel, limit); | |
2605 } | |
2606 } | |
2607 | |
2608 CopyListToVector(resourcesId, resourcesList); | |
2609 | |
2610 if (instancesId != NULL) | |
2611 { | |
2612 CopyListToVector(*instancesId, instancesList); | |
2576 } | 2613 } |
2577 } | 2614 } |
2578 } | 2615 } |