comparison OrthancServer/DatabaseWrapper.cpp @ 1668:de1413733c97 db-changes

reconstructing main dicom tags
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 30 Sep 2015 17:18:39 +0200
parents 761a5c07fb1b
children a412ad57f0f9
comparison
equal deleted inserted replaced
1667:9e875db36aef 1668:de1413733c97
463 return true; 463 return true;
464 } 464 }
465 } 465 }
466 466
467 467
468 void DatabaseWrapper::ClearMainDicomTags(int64_t id)
469 {
470 {
471 SQLite::Statement s(db_, SQLITE_FROM_HERE, "DELETE FROM DicomIdentifiers WHERE id=?");
472 s.BindInt64(0, id);
473 s.Run();
474 }
475
476 {
477 SQLite::Statement s(db_, SQLITE_FROM_HERE, "DELETE FROM MainDicomTags WHERE id=?");
478 s.BindInt64(0, id);
479 s.Run();
480 }
481 }
482
483
468 static void SetMainDicomTagsInternal(SQLite::Statement& s, 484 static void SetMainDicomTagsInternal(SQLite::Statement& s,
469 int64_t id, 485 int64_t id,
470 const DicomTag& tag, 486 const DicomTag& tag,
471 const std::string& value) 487 const std::string& value)
472 { 488 {
834 db.Execute(upgrade); 850 db.Execute(upgrade);
835 db.CommitTransaction(); 851 db.CommitTransaction();
836 } 852 }
837 853
838 854
839 void DatabaseWrapper::ExecuteUpgrade5To6(IStorageArea& storageArea)
840 {
841 printf("ICI\n");
842
843 std::auto_ptr<SQLite::ITransaction> transaction(StartTransaction());
844 transaction->Begin();
845
846 std::list<std::string> studies;
847 GetAllPublicIds(studies, ResourceType_Study);
848
849 for (std::list<std::string>::const_iterator
850 it = studies.begin(); it != studies.end(); it++)
851 {
852 printf("[%s]\n", it->c_str());
853 }
854
855 SetGlobalProperty(GlobalProperty_DatabaseSchemaVersion, "6");
856
857 transaction->Commit();
858 }
859
860
861 void DatabaseWrapper::Upgrade(unsigned int targetVersion, 855 void DatabaseWrapper::Upgrade(unsigned int targetVersion,
862 IStorageArea& storageArea) 856 IStorageArea& storageArea)
863 { 857 {
864 if (targetVersion != 6) 858 if (targetVersion != 6)
865 { 859 {
891 } 885 }
892 886
893 if (version_ == 5) 887 if (version_ == 5)
894 { 888 {
895 LOG(WARNING) << "Upgrading database version from 5 to 6"; 889 LOG(WARNING) << "Upgrading database version from 5 to 6";
896 ExecuteUpgrade5To6(storageArea); 890 // No change in the DB schema, the step from version 5 to 6 only
891 // consists in reconstructing the main DICOM tags information.
892 db_.BeginTransaction();
893 SetGlobalProperty(GlobalProperty_DatabaseSchemaVersion, "6");
894 SetGlobalProperty(GlobalProperty_ReconstructStudiesTags, "1");
895 SetGlobalProperty(GlobalProperty_ReconstructSeriesTags, "1");
896 db_.CommitTransaction();
897 version_ = 6; 897 version_ = 6;
898 } 898 }
899 } 899 }
900 900
901 901