comparison SQLite/Plugins/SQLiteIndex.cpp @ 241:a063bbf10a3e

simplification of class DatabaseManager::Transaction
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 13 Apr 2021 12:07:30 +0200
parents f033cc039264
children d663d9e44f8d
comparison
equal deleted inserted replaced
240:c82c2cf84ae8 241:a063bbf10a3e
83 } 83 }
84 84
85 { 85 {
86 DatabaseManager::Transaction t(manager, TransactionType_ReadWrite); 86 DatabaseManager::Transaction t(manager, TransactionType_ReadWrite);
87 87
88 if (!t.DoesTableExist("Resources")) 88 if (!t.GetDatabaseTransaction().DoesTableExist("Resources"))
89 { 89 {
90 std::string query; 90 std::string query;
91 91
92 Orthanc::EmbeddedResources::GetFileResource 92 Orthanc::EmbeddedResources::GetFileResource
93 (query, Orthanc::EmbeddedResources::SQLITE_PREPARE_INDEX); 93 (query, Orthanc::EmbeddedResources::SQLITE_PREPARE_INDEX);
94 94
95 t.ExecuteMultiLines(query); 95 t.GetDatabaseTransaction().ExecuteMultiLines(query);
96 96
97 SetGlobalIntegerProperty(manager, MISSING_SERVER_IDENTIFIER, Orthanc::GlobalProperty_DatabaseSchemaVersion, expectedVersion); 97 SetGlobalIntegerProperty(manager, MISSING_SERVER_IDENTIFIER, Orthanc::GlobalProperty_DatabaseSchemaVersion, expectedVersion);
98 SetGlobalIntegerProperty(manager, MISSING_SERVER_IDENTIFIER, Orthanc::GlobalProperty_DatabasePatchLevel, 1); 98 SetGlobalIntegerProperty(manager, MISSING_SERVER_IDENTIFIER, Orthanc::GlobalProperty_DatabasePatchLevel, 1);
99 } 99 }
100 100
102 } 102 }
103 103
104 { 104 {
105 DatabaseManager::Transaction t(manager, TransactionType_ReadWrite); 105 DatabaseManager::Transaction t(manager, TransactionType_ReadWrite);
106 106
107 if (!t.DoesTableExist("Resources")) 107 if (!t.GetDatabaseTransaction().DoesTableExist("Resources"))
108 { 108 {
109 LOG(ERROR) << "Corrupted SQLite database"; 109 LOG(ERROR) << "Corrupted SQLite database";
110 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError); 110 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError);
111 } 111 }
112 112
135 } 135 }
136 136
137 { 137 {
138 DatabaseManager::Transaction t(manager, TransactionType_ReadWrite); 138 DatabaseManager::Transaction t(manager, TransactionType_ReadWrite);
139 139
140 if (!t.DoesTableExist("ServerProperties")) 140 if (!t.GetDatabaseTransaction().DoesTableExist("ServerProperties"))
141 { 141 {
142 t.ExecuteMultiLines("CREATE TABLE ServerProperties(server TEXT, " 142 t.GetDatabaseTransaction().ExecuteMultiLines("CREATE TABLE ServerProperties(server TEXT, "
143 "property INTEGER, value TEXT, PRIMARY KEY(server, property))"); 143 "property INTEGER, value TEXT, PRIMARY KEY(server, property))");
144 } 144 }
145 145
146 t.Commit(); 146 t.Commit();
147 } 147 }
148 } 148 }