Mercurial > hg > orthanc
comparison OrthancServer/DatabaseWrapper.cpp @ 616:dbecea588ef5 find-move-scp
revert to database v3
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 25 Oct 2013 11:06:10 +0200 |
parents | ce5d2040c47b |
children | f0232774b913 |
comparison
equal
deleted
inserted
replaced
615:ec0b7a51d7bd | 616:dbecea588ef5 |
---|---|
813 try | 813 try |
814 { | 814 { |
815 LOG(INFO) << "Version of the Orthanc database: " << version; | 815 LOG(INFO) << "Version of the Orthanc database: " << version; |
816 unsigned int v = boost::lexical_cast<unsigned int>(version); | 816 unsigned int v = boost::lexical_cast<unsigned int>(version); |
817 | 817 |
818 // This version of Orthanc is only compatible with versions 3 | 818 // This version of Orthanc is only compatible with version 3 of |
819 // (Orthanc 0.3.2 to 0.6.1) and 4 (since Orthanc 0.6.2) of the | 819 // the DB schema (since Orthanc 0.3.2) |
820 // DB schema | 820 ok = (v == 3); |
821 ok = (v == 3 || v == 4); | |
822 | |
823 if (v == 3) | |
824 { | |
825 LOG(WARNING) << "Upgrading the database from version 3 to version 4 (reconstructing the index)"; | |
826 | |
827 // Reconstruct the index for case insensitive queries in C-FIND | |
828 db_.Execute("DROP INDEX IF EXISTS MainDicomTagsIndexValues;"); | |
829 db_.Execute("DROP TABLE IF EXISTS AvailableTags;"); | |
830 | |
831 std::string query; | |
832 EmbeddedResources::GetFileResource(query, EmbeddedResources::PREPARE_DATABASE_V4); | |
833 db_.Execute(query); | |
834 | |
835 db_.Execute("INSERT INTO AvailableTags SELECT DISTINCT tagGroup, tagElement FROM MainDicomTags;"); | |
836 | |
837 //SetGlobalProperty(GlobalProperty_DatabaseSchemaVersion, "4"); | |
838 } | |
839 } | 821 } |
840 catch (boost::bad_lexical_cast&) | 822 catch (boost::bad_lexical_cast&) |
841 { | 823 { |
842 } | 824 } |
843 | 825 |
844 if (!ok) | 826 if (!ok) |
845 { | 827 { |
846 throw OrthancException(ErrorCode_IncompatibleDatabaseVersion); | 828 throw OrthancException(ErrorCode_IncompatibleDatabaseVersion); |
847 } | 829 } |
848 | |
849 CompleteMainDicomTags(); | |
850 | 830 |
851 signalRemainingAncestor_ = new Internals::SignalRemainingAncestor; | 831 signalRemainingAncestor_ = new Internals::SignalRemainingAncestor; |
852 db_.Register(signalRemainingAncestor_); | 832 db_.Register(signalRemainingAncestor_); |
853 db_.Register(new Internals::SignalFileDeleted(listener_)); | 833 db_.Register(new Internals::SignalFileDeleted(listener_)); |
854 } | 834 } |
1013 while (s.Step()) | 993 while (s.Step()) |
1014 { | 994 { |
1015 result.push_back(s.ColumnInt64(0)); | 995 result.push_back(s.ColumnInt64(0)); |
1016 } | 996 } |
1017 } | 997 } |
1018 | |
1019 | |
1020 void DatabaseWrapper::CompleteMainDicomTags() | |
1021 { | |
1022 std::set<DicomTag> requiredTags; | |
1023 | |
1024 } | |
1025 } | 998 } |