# HG changeset patch # User Sebastien Jodogne # Date 1445012242 -7200 # Node ID 4db9200c7f464300f44ae96880969f9643fdc74d # Parent a7745f3a2cc4db4aac3664c4727607e2118db1e9 SetIdentifierTag diff -r a7745f3a2cc4 -r 4db9200c7f46 OrthancServer/DatabaseWrapper.h --- a/OrthancServer/DatabaseWrapper.h Fri Oct 16 17:36:59 2015 +0200 +++ b/OrthancServer/DatabaseWrapper.h Fri Oct 16 18:17:22 2015 +0200 @@ -178,6 +178,13 @@ base_.SetMainDicomTag(id, tag, value); } + virtual void SetIdentifierTag(int64_t id, + const DicomTag& tag, + const std::string& value) + { + base_.SetIdentifierTag(id, tag, value); + } + virtual void GetMainDicomTags(DicomMap& map, int64_t id) { diff -r a7745f3a2cc4 -r 4db9200c7f46 OrthancServer/DatabaseWrapperBase.cpp --- a/OrthancServer/DatabaseWrapperBase.cpp Fri Oct 16 17:36:59 2015 +0200 +++ b/OrthancServer/DatabaseWrapperBase.cpp Fri Oct 16 18:17:22 2015 +0200 @@ -329,18 +329,20 @@ const DicomTag& tag, const std::string& value) { - if (tag.IsIdentifier()) - { - SQLite::Statement s(db_, SQLITE_FROM_HERE, "INSERT INTO DicomIdentifiers VALUES(?, ?, ?, ?)"); - SetMainDicomTagsInternal(s, id, tag, value); - } - else - { - SQLite::Statement s(db_, SQLITE_FROM_HERE, "INSERT INTO MainDicomTags VALUES(?, ?, ?, ?)"); - SetMainDicomTagsInternal(s, id, tag, value); - } + SQLite::Statement s(db_, SQLITE_FROM_HERE, "INSERT INTO MainDicomTags VALUES(?, ?, ?, ?)"); + SetMainDicomTagsInternal(s, id, tag, value); } + + void DatabaseWrapperBase::SetIdentifierTag(int64_t id, + const DicomTag& tag, + const std::string& value) + { + SQLite::Statement s(db_, SQLITE_FROM_HERE, "INSERT INTO DicomIdentifiers VALUES(?, ?, ?, ?)"); + SetMainDicomTagsInternal(s, id, tag, value); + } + + void DatabaseWrapperBase::GetMainDicomTags(DicomMap& map, int64_t id) { diff -r a7745f3a2cc4 -r 4db9200c7f46 OrthancServer/DatabaseWrapperBase.h --- a/OrthancServer/DatabaseWrapperBase.h Fri Oct 16 17:36:59 2015 +0200 +++ b/OrthancServer/DatabaseWrapperBase.h Fri Oct 16 18:17:22 2015 +0200 @@ -132,6 +132,10 @@ const DicomTag& tag, const std::string& value); + void SetIdentifierTag(int64_t id, + const DicomTag& tag, + const std::string& value); + void GetMainDicomTags(DicomMap& map, int64_t id); diff -r a7745f3a2cc4 -r 4db9200c7f46 OrthancServer/IDatabaseWrapper.h --- a/OrthancServer/IDatabaseWrapper.h Fri Oct 16 17:36:59 2015 +0200 +++ b/OrthancServer/IDatabaseWrapper.h Fri Oct 16 18:17:22 2015 +0200 @@ -178,6 +178,10 @@ const DicomTag& tag, const std::string& value) = 0; + virtual void SetIdentifierTag(int64_t id, + const DicomTag& tag, + const std::string& value) = 0; + virtual void SetMetadata(int64_t id, MetadataType type, const std::string& value) = 0; diff -r a7745f3a2cc4 -r 4db9200c7f46 OrthancServer/ServerToolbox.cpp --- a/OrthancServer/ServerToolbox.cpp Fri Oct 16 17:36:59 2015 +0200 +++ b/OrthancServer/ServerToolbox.cpp Fri Oct 16 18:17:22 2015 +0200 @@ -194,11 +194,18 @@ for (size_t i = 0; i < flattened.GetSize(); i++) { const DicomElement& element = flattened.GetElement(i); + const DicomTag& tag = element.GetTag(); - if (includeIdentifiers || - !element.GetTag().IsIdentifier()) + if (tag.IsIdentifier()) { - database.SetMainDicomTag(resource, element.GetTag(), element.GetValue().AsString()); + if (includeIdentifiers) + { + database.SetIdentifierTag(resource, tag, element.GetValue().AsString()); + } + } + else + { + database.SetMainDicomTag(resource, tag, element.GetValue().AsString()); } } } diff -r a7745f3a2cc4 -r 4db9200c7f46 Plugins/Engine/OrthancPluginDatabase.cpp --- a/Plugins/Engine/OrthancPluginDatabase.cpp Fri Oct 16 17:36:59 2015 +0200 +++ b/Plugins/Engine/OrthancPluginDatabase.cpp Fri Oct 16 18:17:22 2015 +0200 @@ -711,18 +711,20 @@ tmp.element = tag.GetElement(); tmp.value = value.c_str(); - OrthancPluginErrorCode code; + CheckSuccess(backend_.setMainDicomTag(payload_, id, &tmp)); + } + - if (tag.IsIdentifier()) - { - code = backend_.setIdentifierTag(payload_, id, &tmp); - } - else - { - code = backend_.setMainDicomTag(payload_, id, &tmp); - } + void OrthancPluginDatabase::SetIdentifierTag(int64_t id, + const DicomTag& tag, + const std::string& value) + { + OrthancPluginDicomTag tmp; + tmp.group = tag.GetGroup(); + tmp.element = tag.GetElement(); + tmp.value = value.c_str(); - CheckSuccess(code); + CheckSuccess(backend_.setIdentifierTag(payload_, id, &tmp)); } diff -r a7745f3a2cc4 -r 4db9200c7f46 Plugins/Engine/OrthancPluginDatabase.h --- a/Plugins/Engine/OrthancPluginDatabase.h Fri Oct 16 17:36:59 2015 +0200 +++ b/Plugins/Engine/OrthancPluginDatabase.h Fri Oct 16 18:17:22 2015 +0200 @@ -235,6 +235,10 @@ const DicomTag& tag, const std::string& value); + virtual void SetIdentifierTag(int64_t id, + const DicomTag& tag, + const std::string& value); + virtual void SetMetadata(int64_t id, MetadataType type, const std::string& value); diff -r a7745f3a2cc4 -r 4db9200c7f46 UnitTestsSources/ServerIndexTests.cpp --- a/UnitTestsSources/ServerIndexTests.cpp Fri Oct 16 17:36:59 2015 +0200 +++ b/UnitTestsSources/ServerIndexTests.cpp Fri Oct 16 18:17:22 2015 +0200 @@ -686,10 +686,10 @@ index_->CreateResource("d", ResourceType_Series) // 3 }; - index_->SetMainDicomTag(a[0], DICOM_TAG_STUDY_INSTANCE_UID, "0"); - index_->SetMainDicomTag(a[1], DICOM_TAG_STUDY_INSTANCE_UID, "1"); - index_->SetMainDicomTag(a[2], DICOM_TAG_STUDY_INSTANCE_UID, "0"); - index_->SetMainDicomTag(a[3], DICOM_TAG_SERIES_INSTANCE_UID, "0"); + index_->SetIdentifierTag(a[0], DICOM_TAG_STUDY_INSTANCE_UID, "0"); + index_->SetIdentifierTag(a[1], DICOM_TAG_STUDY_INSTANCE_UID, "1"); + index_->SetIdentifierTag(a[2], DICOM_TAG_STUDY_INSTANCE_UID, "0"); + index_->SetIdentifierTag(a[3], DICOM_TAG_SERIES_INSTANCE_UID, "0"); std::list s;