comparison Framework/Plugins/IndexBackend.cpp @ 209:13a3863df7fa

cont
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 19 Mar 2021 17:01:38 +0100
parents 2089d4071408
children a0c095a4ba7d
comparison
equal deleted inserted replaced
208:696bc0c9fddb 209:13a3863df7fa
728 return ReadString(statement, 0); 728 return ReadString(statement, 0);
729 } 729 }
730 } 730 }
731 731
732 732
733 uint64_t IndexBackend::GetResourceCount(OrthancPluginResourceType resourceType) 733 uint64_t IndexBackend::GetResourcesCount(OrthancPluginResourceType resourceType)
734 { 734 {
735 std::unique_ptr<DatabaseManager::CachedStatement> statement; 735 std::unique_ptr<DatabaseManager::CachedStatement> statement;
736 736
737 switch (manager_.GetDialect()) 737 switch (manager_.GetDialect())
738 { 738 {
937 937
938 ReadListOfIntegers<int32_t>(target, statement, args); 938 ReadListOfIntegers<int32_t>(target, statement, args);
939 } 939 }
940 940
941 941
942 void IndexBackend::LogChange(const OrthancPluginChange& change) 942 void IndexBackend::LogChange(int32_t changeType,
943 { 943 int64_t resourceId,
944 int64_t id; 944 OrthancPluginResourceType resourceType,
945 OrthancPluginResourceType type; 945 const char* date)
946 if (!LookupResource(id, type, change.publicId) || 946 {
947 type != change.resourceType)
948 {
949 throw Orthanc::OrthancException(Orthanc::ErrorCode_Database);
950 }
951
952 DatabaseManager::CachedStatement statement( 947 DatabaseManager::CachedStatement statement(
953 STATEMENT_FROM_HERE, manager_, 948 STATEMENT_FROM_HERE, manager_,
954 "INSERT INTO Changes VALUES(${}, ${changeType}, ${id}, ${resourceType}, ${date})"); 949 "INSERT INTO Changes VALUES(${}, ${changeType}, ${id}, ${resourceType}, ${date})");
955 950
956 statement.SetParameterType("changeType", ValueType_Integer64); 951 statement.SetParameterType("changeType", ValueType_Integer64);
957 statement.SetParameterType("id", ValueType_Integer64); 952 statement.SetParameterType("id", ValueType_Integer64);
958 statement.SetParameterType("resourceType", ValueType_Integer64); 953 statement.SetParameterType("resourceType", ValueType_Integer64);
959 statement.SetParameterType("date", ValueType_Utf8String); 954 statement.SetParameterType("date", ValueType_Utf8String);
960 955
961 Dictionary args; 956 Dictionary args;
962 args.SetIntegerValue("changeType", change.changeType); 957 args.SetIntegerValue("changeType", changeType);
963 args.SetIntegerValue("id", id); 958 args.SetIntegerValue("id", resourceId);
964 args.SetIntegerValue("resourceType", change.resourceType); 959 args.SetIntegerValue("resourceType", resourceType);
965 args.SetUtf8Value("date", change.date); 960 args.SetUtf8Value("date", date);
966 961
967 statement.Execute(args); 962 statement.Execute(args);
968 } 963 }
969 964
970 965
1502 } 1497 }
1503 } 1498 }
1504 1499
1505 1500
1506 // For unit testing only! 1501 // For unit testing only!
1507 uint64_t IndexBackend::GetResourcesCount() 1502 uint64_t IndexBackend::GetAllResourcesCount()
1508 { 1503 {
1509 std::unique_ptr<DatabaseManager::CachedStatement> statement; 1504 std::unique_ptr<DatabaseManager::CachedStatement> statement;
1510 1505
1511 switch (manager_.GetDialect()) 1506 switch (manager_.GetDialect())
1512 { 1507 {