comparison OrthancServer/Sources/Database/SQLiteDatabaseWrapper.cpp @ 5227:988dab8deb1c db-protobuf

"/tools/find" accepts the "WithLabels" and "WithoutLabels" arguments
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 04 Apr 2023 09:16:12 +0200
parents d0f7c742d397
children a7d95f951f8a
comparison
equal deleted inserted replaced
5226:49e906a8fea2 5227:988dab8deb1c
343 ResourceType queryLevel, 343 ResourceType queryLevel,
344 const std::set<std::string>& withLabels, 344 const std::set<std::string>& withLabels,
345 const std::set<std::string>& withoutLabels, 345 const std::set<std::string>& withoutLabels,
346 uint32_t limit) ORTHANC_OVERRIDE 346 uint32_t limit) ORTHANC_OVERRIDE
347 { 347 {
348 if (!withLabels.empty() ||
349 !withoutLabels.empty())
350 {
351 throw OrthancException(ErrorCode_NotImplemented);
352 }
353
354 LookupFormatter formatter; 348 LookupFormatter formatter;
355 349
356 std::string sql; 350 std::string sql;
357 LookupFormatter::Apply(sql, formatter, lookup, queryLevel, limit); 351 LookupFormatter::Apply(sql, formatter, lookup, queryLevel, withLabels, withoutLabels, limit);
358 352
359 sql = "CREATE TEMPORARY TABLE Lookup AS " + sql; 353 sql = "CREATE TEMPORARY TABLE Lookup AS " + sql;
360 354
361 { 355 {
362 SQLite::Statement s(db_, SQLITE_FROM_HERE, "DROP TABLE IF EXISTS Lookup"); 356 SQLite::Statement s(db_, SQLITE_FROM_HERE, "DROP TABLE IF EXISTS Lookup");
1088 { 1082 {
1089 throw OrthancException(ErrorCode_ParameterOutOfRange); 1083 throw OrthancException(ErrorCode_ParameterOutOfRange);
1090 } 1084 }
1091 else 1085 else
1092 { 1086 {
1093 SQLite::Statement s(db_, SQLITE_FROM_HERE, "INSERT INTO Labels (internalId, label) VALUES(?, ?)"); 1087 SQLite::Statement s(db_, SQLITE_FROM_HERE, "INSERT OR IGNORE INTO Labels (internalId, label) VALUES(?, ?)");
1094 s.BindInt64(0, resource); 1088 s.BindInt64(0, resource);
1095 s.BindString(1, label); 1089 s.BindString(1, label);
1096 s.Run(); 1090 s.Run();
1097 } 1091 }
1098 } 1092 }