Mercurial > hg > orthanc
comparison OrthancServer/UnitTestsSources/ServerIndexTests.cpp @ 5080:d7274e43ea7c attach-custom-data
allow plugins to store a customData in the Attachments table to e.g. store custom paths without requiring an external DB
author | Alain Mazy <am@osimis.io> |
---|---|
date | Thu, 08 Sep 2022 17:42:08 +0200 |
parents | 6fed78e13233 |
children | 9770d537880d |
comparison
equal
deleted
inserted
replaced
5079:4366b4c41441 | 5080:d7274e43ea7c |
---|---|
289 std::map<MetadataType, std::string> md; | 289 std::map<MetadataType, std::string> md; |
290 transaction_->GetAllMetadata(md, a[4]); | 290 transaction_->GetAllMetadata(md, a[4]); |
291 ASSERT_EQ(0u, md.size()); | 291 ASSERT_EQ(0u, md.size()); |
292 | 292 |
293 transaction_->AddAttachment(a[4], FileInfo("my json file", FileContentType_DicomAsJson, 42, "md5", | 293 transaction_->AddAttachment(a[4], FileInfo("my json file", FileContentType_DicomAsJson, 42, "md5", |
294 CompressionType_ZlibWithSize, 21, "compressedMD5"), 42); | 294 CompressionType_ZlibWithSize, 21, "compressedMD5", "customData"), 42); |
295 transaction_->AddAttachment(a[4], FileInfo("my dicom file", FileContentType_Dicom, 42, "md5"), 43); | 295 transaction_->AddAttachment(a[4], FileInfo("my dicom file", FileContentType_Dicom, 42, "md5", "customData"), 43); |
296 transaction_->AddAttachment(a[6], FileInfo("world", FileContentType_Dicom, 44, "md5"), 44); | 296 transaction_->AddAttachment(a[6], FileInfo("world", FileContentType_Dicom, 44, "md5", "customData"), 44); |
297 | 297 |
298 // TODO - REVISIONS - "42" is revision number, that is not currently stored (*) | 298 // TODO - REVISIONS - "42" is revision number, that is not currently stored (*) |
299 transaction_->SetMetadata(a[4], MetadataType_RemoteAet, "PINNACLE", 42); | 299 transaction_->SetMetadata(a[4], MetadataType_RemoteAet, "PINNACLE", 42); |
300 | 300 |
301 transaction_->GetAllMetadata(md, a[4]); | 301 transaction_->GetAllMetadata(md, a[4]); |
399 CheckTableRecordCount(0, "AttachedFiles"); | 399 CheckTableRecordCount(0, "AttachedFiles"); |
400 CheckTableRecordCount(3, "GlobalProperties"); | 400 CheckTableRecordCount(3, "GlobalProperties"); |
401 | 401 |
402 std::string tmp; | 402 std::string tmp; |
403 ASSERT_TRUE(transaction_->LookupGlobalProperty(tmp, GlobalProperty_DatabaseSchemaVersion, true)); | 403 ASSERT_TRUE(transaction_->LookupGlobalProperty(tmp, GlobalProperty_DatabaseSchemaVersion, true)); |
404 ASSERT_EQ("6", tmp); | 404 ASSERT_EQ("7", tmp); |
405 ASSERT_TRUE(transaction_->LookupGlobalProperty(tmp, GlobalProperty_FlushSleep, true)); | 405 ASSERT_TRUE(transaction_->LookupGlobalProperty(tmp, GlobalProperty_FlushSleep, true)); |
406 ASSERT_EQ("World", tmp); | 406 ASSERT_EQ("World", tmp); |
407 ASSERT_TRUE(transaction_->LookupGlobalProperty(tmp, GlobalProperty_GetTotalSizeIsFast, true)); | 407 ASSERT_TRUE(transaction_->LookupGlobalProperty(tmp, GlobalProperty_GetTotalSizeIsFast, true)); |
408 ASSERT_EQ("1", tmp); | 408 ASSERT_EQ("1", tmp); |
409 | 409 |
471 for (int i = 0; i < 10; i++) | 471 for (int i = 0; i < 10; i++) |
472 { | 472 { |
473 std::string p = "Patient " + boost::lexical_cast<std::string>(i); | 473 std::string p = "Patient " + boost::lexical_cast<std::string>(i); |
474 patients.push_back(transaction_->CreateResource(p, ResourceType_Patient)); | 474 patients.push_back(transaction_->CreateResource(p, ResourceType_Patient)); |
475 transaction_->AddAttachment(patients[i], FileInfo(p, FileContentType_Dicom, i + 10, | 475 transaction_->AddAttachment(patients[i], FileInfo(p, FileContentType_Dicom, i + 10, |
476 "md5-" + boost::lexical_cast<std::string>(i)), 42); | 476 "md5-" + boost::lexical_cast<std::string>(i), "customData"), 42); |
477 ASSERT_FALSE(transaction_->IsProtectedPatient(patients[i])); | 477 ASSERT_FALSE(transaction_->IsProtectedPatient(patients[i])); |
478 } | 478 } |
479 | 479 |
480 CheckTableRecordCount(10u, "Resources"); | 480 CheckTableRecordCount(10u, "Resources"); |
481 CheckTableRecordCount(10u, "PatientRecyclingOrder"); | 481 CheckTableRecordCount(10u, "PatientRecyclingOrder"); |
532 for (int i = 0; i < 5; i++) | 532 for (int i = 0; i < 5; i++) |
533 { | 533 { |
534 std::string p = "Patient " + boost::lexical_cast<std::string>(i); | 534 std::string p = "Patient " + boost::lexical_cast<std::string>(i); |
535 patients.push_back(transaction_->CreateResource(p, ResourceType_Patient)); | 535 patients.push_back(transaction_->CreateResource(p, ResourceType_Patient)); |
536 transaction_->AddAttachment(patients[i], FileInfo(p, FileContentType_Dicom, i + 10, | 536 transaction_->AddAttachment(patients[i], FileInfo(p, FileContentType_Dicom, i + 10, |
537 "md5-" + boost::lexical_cast<std::string>(i)), 42); | 537 "md5-" + boost::lexical_cast<std::string>(i), "customData"), 42); |
538 ASSERT_FALSE(transaction_->IsProtectedPatient(patients[i])); | 538 ASSERT_FALSE(transaction_->IsProtectedPatient(patients[i])); |
539 } | 539 } |
540 | 540 |
541 CheckTableRecordCount(5, "Resources"); | 541 CheckTableRecordCount(5, "Resources"); |
542 CheckTableRecordCount(5, "PatientRecyclingOrder"); | 542 CheckTableRecordCount(5, "PatientRecyclingOrder"); |
772 ASSERT_EQ(10u, countPatients); | 772 ASSERT_EQ(10u, countPatients); |
773 ASSERT_EQ(0u, diskSize); | 773 ASSERT_EQ(0u, diskSize); |
774 | 774 |
775 for (size_t i = 0; i < ids.size(); i++) | 775 for (size_t i = 0; i < ids.size(); i++) |
776 { | 776 { |
777 FileInfo info(Toolbox::GenerateUuid(), FileContentType_Dicom, 1, "md5"); | 777 FileInfo info(Toolbox::GenerateUuid(), FileContentType_Dicom, 1, "md5", "customData"); |
778 int64_t revision = -1; | 778 int64_t revision = -1; |
779 index.AddAttachment(revision, info, ids[i], false /* no previous revision */, -1, ""); | 779 index.AddAttachment(revision, info, ids[i], false /* no previous revision */, -1, ""); |
780 ASSERT_EQ(0, revision); | 780 ASSERT_EQ(0, revision); |
781 | 781 |
782 index.GetGlobalStatistics(diskSize, uncompressedSize, countPatients, | 782 index.GetGlobalStatistics(diskSize, uncompressedSize, countPatients, |