Mercurial > hg > orthanc
comparison Plugins/Engine/OrthancPluginDatabase.cpp @ 1673:0bbcfd9695e5 db-changes
UpgradeDatabase in the sample plugin
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 02 Oct 2015 13:26:05 +0200 |
parents | 4c5a85c3ff43 |
children | 2ad22b2970a2 |
comparison
equal
deleted
inserted
replaced
1672:4c5a85c3ff43 | 1673:0bbcfd9695e5 |
---|---|
690 } | 690 } |
691 | 691 |
692 | 692 |
693 void OrthancPluginDatabase::ClearMainDicomTags(int64_t id) | 693 void OrthancPluginDatabase::ClearMainDicomTags(int64_t id) |
694 { | 694 { |
695 if (extensions_.clearMainDicomTags != NULL) | 695 if (extensions_.clearMainDicomTags == NULL) |
696 { | 696 { |
697 LOG(ERROR) << "Your custom index plugin does not implement the ClearMainDicomTags() extension"; | 697 LOG(ERROR) << "Your custom index plugin does not implement the ClearMainDicomTags() extension"; |
698 throw OrthancException(ErrorCode_DatabasePlugin); | 698 throw OrthancException(ErrorCode_DatabasePlugin); |
699 } | 699 } |
700 | 700 |
846 void OrthancPluginDatabase::Upgrade(unsigned int targetVersion, | 846 void OrthancPluginDatabase::Upgrade(unsigned int targetVersion, |
847 IStorageArea& storageArea) | 847 IStorageArea& storageArea) |
848 { | 848 { |
849 if (extensions_.upgradeDatabase != NULL) | 849 if (extensions_.upgradeDatabase != NULL) |
850 { | 850 { |
851 CheckSuccess(extensions_.upgradeDatabase( | 851 Transaction transaction(backend_, payload_, errorDictionary_); |
852 payload_, targetVersion, | 852 transaction.Begin(); |
853 reinterpret_cast<OrthancPluginStorageArea*>(&storageArea))); | 853 |
854 OrthancPluginErrorCode code = extensions_.upgradeDatabase( | |
855 payload_, targetVersion, | |
856 reinterpret_cast<OrthancPluginStorageArea*>(&storageArea)); | |
857 | |
858 if (code == OrthancPluginErrorCode_Success) | |
859 { | |
860 transaction.Commit(); | |
861 } | |
862 else | |
863 { | |
864 transaction.Rollback(); | |
865 errorDictionary_.LogError(code, true); | |
866 throw OrthancException(static_cast<ErrorCode>(code)); | |
867 } | |
854 } | 868 } |
855 } | 869 } |
856 | 870 |
857 | 871 |
858 void OrthancPluginDatabase::AnswerReceived(const _OrthancPluginDatabaseAnswer& answer) | 872 void OrthancPluginDatabase::AnswerReceived(const _OrthancPluginDatabaseAnswer& answer) |