Mercurial > hg > orthanc
diff OrthancServer/DatabaseWrapper.cpp @ 567:c2be0a0e049e find-move-scp
cont
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 19 Sep 2013 17:43:38 +0200 |
parents | 2c739f76d0bb |
children | ce5d2040c47b |
line wrap: on
line diff
--- a/OrthancServer/DatabaseWrapper.cpp Wed Sep 18 16:58:27 2013 +0200 +++ b/OrthancServer/DatabaseWrapper.cpp Thu Sep 19 17:43:38 2013 +0200 @@ -807,7 +807,7 @@ db_.Execute(query); } - // Sanity check of the version of the database + // Check the version of the database std::string version = GetGlobalProperty(GlobalProperty_DatabaseSchemaVersion, "Unknown"); bool ok = false; try @@ -815,9 +815,27 @@ LOG(INFO) << "Version of the Orthanc database: " << version; unsigned int v = boost::lexical_cast<unsigned int>(version); - // This version of Orthanc is only compatible with version 3 of - // the DB schema (since Orthanc 0.3.2) - ok = (v == 3); + // This version of Orthanc is only compatible with versions 3 + // (Orthanc 0.3.2 to 0.6.1) and 4 (since Orthanc 0.6.2) of the + // DB schema + ok = (v == 3 || v == 4); + + if (v == 3) + { + LOG(WARNING) << "Upgrading the database from version 3 to version 4 (reconstructing the index)"; + + // Reconstruct the index for case insensitive queries in C-FIND + db_.Execute("DROP INDEX IF EXISTS MainDicomTagsIndexValues;"); + db_.Execute("DROP TABLE IF EXISTS AvailableTags;"); + + std::string query; + EmbeddedResources::GetFileResource(query, EmbeddedResources::PREPARE_DATABASE_V4); + db_.Execute(query); + + db_.Execute("INSERT INTO AvailableTags SELECT DISTINCT tagGroup, tagElement FROM MainDicomTags;"); + + //SetGlobalProperty(GlobalProperty_DatabaseSchemaVersion, "4"); + } } catch (boost::bad_lexical_cast&) { @@ -828,6 +846,8 @@ throw OrthancException(ErrorCode_IncompatibleDatabaseVersion); } + CompleteMainDicomTags(); + signalRemainingAncestor_ = new Internals::SignalRemainingAncestor; db_.Register(signalRemainingAncestor_); db_.Register(new Internals::SignalFileDeleted(listener_)); @@ -995,4 +1015,11 @@ result.push_back(s.ColumnInt64(0)); } } + + + void DatabaseWrapper::CompleteMainDicomTags() + { + std::set<DicomTag> requiredTags; + + } }