comparison OrthancServer/ServerIndex.cpp @ 3034:54e422fe31ce db-changes

moving LookupResource to graveyard
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 19 Dec 2018 14:20:11 +0100
parents 5da6d1063d8f
children 8fd203510d8b
comparison
equal deleted inserted replaced
3033:5da6d1063d8f 3034:54e422fe31ce
48 #include "../Core/DicomFormat/DicomArray.h" 48 #include "../Core/DicomFormat/DicomArray.h"
49 49
50 #include "../Core/DicomParsing/FromDcmtkBridge.h" 50 #include "../Core/DicomParsing/FromDcmtkBridge.h"
51 #include "ServerContext.h" 51 #include "ServerContext.h"
52 #include "DicomInstanceToStore.h" 52 #include "DicomInstanceToStore.h"
53 #include "Search/LookupResource.h"
54 53
55 #include <boost/lexical_cast.hpp> 54 #include <boost/lexical_cast.hpp>
56 #include <stdio.h> 55 #include <stdio.h>
57 56
58 static const uint64_t MEGA_BYTES = 1024 * 1024; 57 static const uint64_t MEGA_BYTES = 1024 * 1024;
2122 LogChange(id, ChangeType_NewChildInstance, type, publicId); 2121 LogChange(id, ChangeType_NewChildInstance, type, publicId);
2123 } 2122 }
2124 2123
2125 2124
2126 2125
2127 void ServerIndex::LookupIdentifierExact(std::list<std::string>& result, 2126 void ServerIndex::LookupIdentifierExact(std::vector<std::string>& result,
2128 ResourceType level, 2127 ResourceType level,
2129 const DicomTag& tag, 2128 const DicomTag& tag,
2130 const std::string& value) 2129 const std::string& value)
2131 { 2130 {
2132 assert((level == ResourceType_Patient && tag == DICOM_TAG_PATIENT_ID) || 2131 assert((level == ResourceType_Patient && tag == DICOM_TAG_PATIENT_ID) ||
2135 (level == ResourceType_Series && tag == DICOM_TAG_SERIES_INSTANCE_UID) || 2134 (level == ResourceType_Series && tag == DICOM_TAG_SERIES_INSTANCE_UID) ||
2136 (level == ResourceType_Instance && tag == DICOM_TAG_SOP_INSTANCE_UID)); 2135 (level == ResourceType_Instance && tag == DICOM_TAG_SOP_INSTANCE_UID));
2137 2136
2138 result.clear(); 2137 result.clear();
2139 2138
2140 boost::mutex::scoped_lock lock(mutex_); 2139 DicomTagConstraint c(tag, ConstraintType_Equal, value, true, true);
2141 2140
2142 LookupIdentifierQuery query(level); 2141 std::vector<DatabaseConstraint> query;
2143 query.AddConstraint(tag, IdentifierConstraintType_Equal, value); 2142 query.push_back(DatabaseConstraint(c, level, DicomTagType_Identifier));
2144 query.Apply(result, db_); 2143
2144 std::vector<std::string> instancesId;
2145
2146 {
2147 boost::mutex::scoped_lock lock(mutex_);
2148 db_.ApplyLookupResources(result, instancesId, query, level, 0);
2149 }
2145 } 2150 }
2146 2151
2147 2152
2148 StoreStatus ServerIndex::AddAttachment(const FileInfo& attachment, 2153 StoreStatus ServerIndex::AddAttachment(const FileInfo& attachment,
2149 const std::string& publicId) 2154 const std::string& publicId)
2426 2431
2427 unsigned int ServerIndex::GetDatabaseVersion() 2432 unsigned int ServerIndex::GetDatabaseVersion()
2428 { 2433 {
2429 boost::mutex::scoped_lock lock(mutex_); 2434 boost::mutex::scoped_lock lock(mutex_);
2430 return db_.GetDatabaseVersion(); 2435 return db_.GetDatabaseVersion();
2431 }
2432
2433
2434 void ServerIndex::FindCandidates(std::vector<std::string>& resources,
2435 std::vector<std::string>& instances,
2436 const ::Orthanc::LookupResource& lookup)
2437 {
2438 boost::mutex::scoped_lock lock(mutex_);
2439
2440 std::list<int64_t> tmp;
2441 lookup.FindCandidates(tmp, db_);
2442
2443 resources.resize(tmp.size());
2444 instances.resize(tmp.size());
2445
2446 size_t pos = 0;
2447 for (std::list<int64_t>::const_iterator
2448 it = tmp.begin(); it != tmp.end(); ++it, pos++)
2449 {
2450 assert(db_.GetResourceType(*it) == lookup.GetLevel());
2451
2452 int64_t instance;
2453 if (!ServerToolbox::FindOneChildInstance(instance, db_, *it, lookup.GetLevel()))
2454 {
2455 throw OrthancException(ErrorCode_InternalError);
2456 }
2457
2458 resources[pos] = db_.GetPublicId(*it);
2459 instances[pos] = db_.GetPublicId(instance);
2460 }
2461 } 2436 }
2462 2437
2463 2438
2464 bool ServerIndex::LookupParent(std::string& target, 2439 bool ServerIndex::LookupParent(std::string& target,
2465 const std::string& publicId, 2440 const std::string& publicId,