comparison Framework/Plugins/IndexBackend.cpp @ 1:d17b2631bb67

starting StorageBackend
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 04 Jul 2018 18:05:24 +0200
parents 7cea966b6829
children aa2e27f77cc8
comparison
equal deleted inserted replaced
0:7cea966b6829 1:d17b2631bb67
417 } 417 }
418 418
419 419
420 void IndexBackend::DeleteResource(int64_t id) 420 void IndexBackend::DeleteResource(int64_t id)
421 { 421 {
422 assert(GetDialect() != Dialect_MySQL); 422 assert(manager_.GetDialect() != Dialect_MySQL);
423 423
424 ClearDeletedFiles(); 424 ClearDeletedFiles();
425 ClearDeletedResources(); 425 ClearDeletedResources();
426 426
427 { 427 {
690 690
691 uint64_t IndexBackend::GetResourceCount(OrthancPluginResourceType resourceType) 691 uint64_t IndexBackend::GetResourceCount(OrthancPluginResourceType resourceType)
692 { 692 {
693 std::auto_ptr<DatabaseManager::CachedStatement> statement; 693 std::auto_ptr<DatabaseManager::CachedStatement> statement;
694 694
695 switch (GetDialect()) 695 switch (manager_.GetDialect())
696 { 696 {
697 case Dialect_MySQL: 697 case Dialect_MySQL:
698 statement.reset(new DatabaseManager::CachedStatement( 698 statement.reset(new DatabaseManager::CachedStatement(
699 STATEMENT_FROM_HERE, GetManager(), 699 STATEMENT_FROM_HERE, GetManager(),
700 "SELECT CAST(COUNT(*) AS UNSIGNED INT) FROM Resources WHERE resourceType=${type}")); 700 "SELECT CAST(COUNT(*) AS UNSIGNED INT) FROM Resources WHERE resourceType=${type}"));
757 { 757 {
758 std::auto_ptr<DatabaseManager::CachedStatement> statement; 758 std::auto_ptr<DatabaseManager::CachedStatement> statement;
759 759
760 // NB: "COALESCE" is used to replace "NULL" by "0" if the number of rows is empty 760 // NB: "COALESCE" is used to replace "NULL" by "0" if the number of rows is empty
761 761
762 switch (GetDialect()) 762 switch (manager_.GetDialect())
763 { 763 {
764 case Dialect_MySQL: 764 case Dialect_MySQL:
765 statement.reset(new DatabaseManager::CachedStatement( 765 statement.reset(new DatabaseManager::CachedStatement(
766 STATEMENT_FROM_HERE, GetManager(), 766 STATEMENT_FROM_HERE, GetManager(),
767 "SELECT CAST(COALESCE(SUM(compressedSize), 0) AS UNSIGNED INTEGER) FROM AttachedFiles")); 767 "SELECT CAST(COALESCE(SUM(compressedSize), 0) AS UNSIGNED INTEGER) FROM AttachedFiles"));
794 { 794 {
795 std::auto_ptr<DatabaseManager::CachedStatement> statement; 795 std::auto_ptr<DatabaseManager::CachedStatement> statement;
796 796
797 // NB: "COALESCE" is used to replace "NULL" by "0" if the number of rows is empty 797 // NB: "COALESCE" is used to replace "NULL" by "0" if the number of rows is empty
798 798
799 switch (GetDialect()) 799 switch (manager_.GetDialect())
800 { 800 {
801 case Dialect_MySQL: 801 case Dialect_MySQL:
802 statement.reset(new DatabaseManager::CachedStatement( 802 statement.reset(new DatabaseManager::CachedStatement(
803 STATEMENT_FROM_HERE, GetManager(), 803 STATEMENT_FROM_HERE, GetManager(),
804 "SELECT CAST(COALESCE(SUM(uncompressedSize), 0) AS UNSIGNED INTEGER) FROM AttachedFiles")); 804 "SELECT CAST(COALESCE(SUM(uncompressedSize), 0) AS UNSIGNED INTEGER) FROM AttachedFiles"));
1305 1305
1306 void IndexBackend::SetMetadata(int64_t id, 1306 void IndexBackend::SetMetadata(int64_t id,
1307 int32_t metadataType, 1307 int32_t metadataType,
1308 const char* value) 1308 const char* value)
1309 { 1309 {
1310 if (GetDialect() == Dialect_SQLite) 1310 if (manager_.GetDialect() == Dialect_SQLite)
1311 { 1311 {
1312 DatabaseManager::CachedStatement statement( 1312 DatabaseManager::CachedStatement statement(
1313 STATEMENT_FROM_HERE, manager_, 1313 STATEMENT_FROM_HERE, manager_,
1314 "INSERT OR REPLACE INTO Metadata VALUES (${id}, ${type}, ${value})"); 1314 "INSERT OR REPLACE INTO Metadata VALUES (${id}, ${type}, ${value})");
1315 1315
1463 // For unit testing only! 1463 // For unit testing only!
1464 uint64_t IndexBackend::GetResourcesCount() 1464 uint64_t IndexBackend::GetResourcesCount()
1465 { 1465 {
1466 std::auto_ptr<DatabaseManager::CachedStatement> statement; 1466 std::auto_ptr<DatabaseManager::CachedStatement> statement;
1467 1467
1468 switch (GetDialect()) 1468 switch (manager_.GetDialect())
1469 { 1469 {
1470 case Dialect_MySQL: 1470 case Dialect_MySQL:
1471 statement.reset(new DatabaseManager::CachedStatement( 1471 statement.reset(new DatabaseManager::CachedStatement(
1472 STATEMENT_FROM_HERE, GetManager(), 1472 STATEMENT_FROM_HERE, GetManager(),
1473 "SELECT CAST(COUNT(*) AS UNSIGNED INT) FROM Resources")); 1473 "SELECT CAST(COUNT(*) AS UNSIGNED INT) FROM Resources"));
1499 // For unit testing only! 1499 // For unit testing only!
1500 uint64_t IndexBackend::GetUnprotectedPatientsCount() 1500 uint64_t IndexBackend::GetUnprotectedPatientsCount()
1501 { 1501 {
1502 std::auto_ptr<DatabaseManager::CachedStatement> statement; 1502 std::auto_ptr<DatabaseManager::CachedStatement> statement;
1503 1503
1504 switch (GetDialect()) 1504 switch (manager_.GetDialect())
1505 { 1505 {
1506 case Dialect_MySQL: 1506 case Dialect_MySQL:
1507 statement.reset(new DatabaseManager::CachedStatement( 1507 statement.reset(new DatabaseManager::CachedStatement(
1508 STATEMENT_FROM_HERE, GetManager(), 1508 STATEMENT_FROM_HERE, GetManager(),
1509 "SELECT CAST(COUNT(*) AS UNSIGNED INT) FROM PatientRecyclingOrder")); 1509 "SELECT CAST(COUNT(*) AS UNSIGNED INT) FROM PatientRecyclingOrder"));