Mercurial > hg > orthanc
comparison OrthancServer/UnitTestsSources/ServerIndexTests.cpp @ 4627:f7d5372b59b3 db-changes
handling revisions of attachments
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 20 Apr 2021 15:11:59 +0200 |
parents | 95ffe3b6ef7c |
children | 66109d24d26e |
comparison
equal
deleted
inserted
replaced
4626:686f189a903d | 4627:f7d5372b59b3 |
---|---|
300 std::map<MetadataType, std::string> md; | 300 std::map<MetadataType, std::string> md; |
301 transaction_->GetAllMetadata(md, a[4]); | 301 transaction_->GetAllMetadata(md, a[4]); |
302 ASSERT_EQ(0u, md.size()); | 302 ASSERT_EQ(0u, md.size()); |
303 | 303 |
304 transaction_->AddAttachment(a[4], FileInfo("my json file", FileContentType_DicomAsJson, 42, "md5", | 304 transaction_->AddAttachment(a[4], FileInfo("my json file", FileContentType_DicomAsJson, 42, "md5", |
305 CompressionType_ZlibWithSize, 21, "compressedMD5")); | 305 CompressionType_ZlibWithSize, 21, "compressedMD5"), 42); |
306 transaction_->AddAttachment(a[4], FileInfo("my dicom file", FileContentType_Dicom, 42, "md5")); | 306 transaction_->AddAttachment(a[4], FileInfo("my dicom file", FileContentType_Dicom, 42, "md5"), 43); |
307 transaction_->AddAttachment(a[6], FileInfo("world", FileContentType_Dicom, 44, "md5")); | 307 transaction_->AddAttachment(a[6], FileInfo("world", FileContentType_Dicom, 44, "md5"), 44); |
308 | 308 |
309 // TODO - REVISIONS - "42" is revision number, that is not currently stored (*) | 309 // TODO - REVISIONS - "42" is revision number, that is not currently stored (*) |
310 transaction_->SetMetadata(a[4], MetadataType_RemoteAet, "PINNACLE", 42); | 310 transaction_->SetMetadata(a[4], MetadataType_RemoteAet, "PINNACLE", 42); |
311 | 311 |
312 transaction_->GetAllMetadata(md, a[4]); | 312 transaction_->GetAllMetadata(md, a[4]); |
313 ASSERT_EQ(1u, md.size()); | 313 ASSERT_EQ(1u, md.size()); |
360 ASSERT_TRUE(transaction_->LookupGlobalProperty(s, GlobalProperty_FlushSleep, true)); | 360 ASSERT_TRUE(transaction_->LookupGlobalProperty(s, GlobalProperty_FlushSleep, true)); |
361 ASSERT_FALSE(transaction_->LookupGlobalProperty(s, static_cast<GlobalProperty>(42), true)); | 361 ASSERT_FALSE(transaction_->LookupGlobalProperty(s, static_cast<GlobalProperty>(42), true)); |
362 ASSERT_EQ("World", s); | 362 ASSERT_EQ("World", s); |
363 | 363 |
364 FileInfo att; | 364 FileInfo att; |
365 ASSERT_TRUE(transaction_->LookupAttachment(att, a[4], FileContentType_DicomAsJson)); | 365 ASSERT_TRUE(transaction_->LookupAttachment(att, revision, a[4], FileContentType_DicomAsJson)); |
366 ASSERT_EQ(0, revision); // "0" instead of "42" because of (*) | |
366 ASSERT_EQ("my json file", att.GetUuid()); | 367 ASSERT_EQ("my json file", att.GetUuid()); |
367 ASSERT_EQ(21u, att.GetCompressedSize()); | 368 ASSERT_EQ(21u, att.GetCompressedSize()); |
368 ASSERT_EQ("md5", att.GetUncompressedMD5()); | 369 ASSERT_EQ("md5", att.GetUncompressedMD5()); |
369 ASSERT_EQ("compressedMD5", att.GetCompressedMD5()); | 370 ASSERT_EQ("compressedMD5", att.GetCompressedMD5()); |
370 ASSERT_EQ(42u, att.GetUncompressedSize()); | 371 ASSERT_EQ(42u, att.GetUncompressedSize()); |
371 ASSERT_EQ(CompressionType_ZlibWithSize, att.GetCompressionType()); | 372 ASSERT_EQ(CompressionType_ZlibWithSize, att.GetCompressionType()); |
372 | 373 |
373 ASSERT_TRUE(transaction_->LookupAttachment(att, a[6], FileContentType_Dicom)); | 374 ASSERT_TRUE(transaction_->LookupAttachment(att, revision, a[6], FileContentType_Dicom)); |
375 ASSERT_EQ(0, revision); // "0" instead of "42" because of (*) | |
374 ASSERT_EQ("world", att.GetUuid()); | 376 ASSERT_EQ("world", att.GetUuid()); |
375 ASSERT_EQ(44u, att.GetCompressedSize()); | 377 ASSERT_EQ(44u, att.GetCompressedSize()); |
376 ASSERT_EQ("md5", att.GetUncompressedMD5()); | 378 ASSERT_EQ("md5", att.GetUncompressedMD5()); |
377 ASSERT_EQ("md5", att.GetCompressedMD5()); | 379 ASSERT_EQ("md5", att.GetCompressedMD5()); |
378 ASSERT_EQ(44u, att.GetUncompressedSize()); | 380 ASSERT_EQ(44u, att.GetUncompressedSize()); |
480 for (int i = 0; i < 10; i++) | 482 for (int i = 0; i < 10; i++) |
481 { | 483 { |
482 std::string p = "Patient " + boost::lexical_cast<std::string>(i); | 484 std::string p = "Patient " + boost::lexical_cast<std::string>(i); |
483 patients.push_back(transaction_->CreateResource(p, ResourceType_Patient)); | 485 patients.push_back(transaction_->CreateResource(p, ResourceType_Patient)); |
484 transaction_->AddAttachment(patients[i], FileInfo(p, FileContentType_Dicom, i + 10, | 486 transaction_->AddAttachment(patients[i], FileInfo(p, FileContentType_Dicom, i + 10, |
485 "md5-" + boost::lexical_cast<std::string>(i))); | 487 "md5-" + boost::lexical_cast<std::string>(i)), 42); |
486 ASSERT_FALSE(transaction_->IsProtectedPatient(patients[i])); | 488 ASSERT_FALSE(transaction_->IsProtectedPatient(patients[i])); |
487 } | 489 } |
488 | 490 |
489 CheckTableRecordCount(10u, "Resources"); | 491 CheckTableRecordCount(10u, "Resources"); |
490 CheckTableRecordCount(10u, "PatientRecyclingOrder"); | 492 CheckTableRecordCount(10u, "PatientRecyclingOrder"); |
541 for (int i = 0; i < 5; i++) | 543 for (int i = 0; i < 5; i++) |
542 { | 544 { |
543 std::string p = "Patient " + boost::lexical_cast<std::string>(i); | 545 std::string p = "Patient " + boost::lexical_cast<std::string>(i); |
544 patients.push_back(transaction_->CreateResource(p, ResourceType_Patient)); | 546 patients.push_back(transaction_->CreateResource(p, ResourceType_Patient)); |
545 transaction_->AddAttachment(patients[i], FileInfo(p, FileContentType_Dicom, i + 10, | 547 transaction_->AddAttachment(patients[i], FileInfo(p, FileContentType_Dicom, i + 10, |
546 "md5-" + boost::lexical_cast<std::string>(i))); | 548 "md5-" + boost::lexical_cast<std::string>(i)), 42); |
547 ASSERT_FALSE(transaction_->IsProtectedPatient(patients[i])); | 549 ASSERT_FALSE(transaction_->IsProtectedPatient(patients[i])); |
548 } | 550 } |
549 | 551 |
550 CheckTableRecordCount(5, "Resources"); | 552 CheckTableRecordCount(5, "Resources"); |
551 CheckTableRecordCount(5, "PatientRecyclingOrder"); | 553 CheckTableRecordCount(5, "PatientRecyclingOrder"); |
781 ASSERT_EQ(0u, diskSize); | 783 ASSERT_EQ(0u, diskSize); |
782 | 784 |
783 for (size_t i = 0; i < ids.size(); i++) | 785 for (size_t i = 0; i < ids.size(); i++) |
784 { | 786 { |
785 FileInfo info(Toolbox::GenerateUuid(), FileContentType_Dicom, 1, "md5"); | 787 FileInfo info(Toolbox::GenerateUuid(), FileContentType_Dicom, 1, "md5"); |
786 index.AddAttachment(info, ids[i]); | 788 int64_t revision = -1; |
789 index.AddAttachment(revision, info, ids[i], false /* no previous revision */, -1); | |
790 ASSERT_EQ(0, revision); | |
787 | 791 |
788 index.GetGlobalStatistics(diskSize, uncompressedSize, countPatients, | 792 index.GetGlobalStatistics(diskSize, uncompressedSize, countPatients, |
789 countStudies, countSeries, countInstances); | 793 countStudies, countSeries, countInstances); |
790 ASSERT_GE(10u, diskSize); | 794 ASSERT_GE(10u, diskSize); |
791 } | 795 } |
859 ASSERT_EQ(id, id2); | 863 ASSERT_EQ(id, id2); |
860 } | 864 } |
861 | 865 |
862 { | 866 { |
863 FileInfo nope; | 867 FileInfo nope; |
864 ASSERT_FALSE(context.GetIndex().LookupAttachment(nope, id, FileContentType_DicomAsJson)); | 868 int64_t revision; |
869 ASSERT_FALSE(context.GetIndex().LookupAttachment(nope, revision, id, FileContentType_DicomAsJson)); | |
865 } | 870 } |
866 | 871 |
867 FileInfo dicom1, pixelData1; | 872 FileInfo dicom1, pixelData1; |
868 ASSERT_TRUE(context.GetIndex().LookupAttachment(dicom1, id, FileContentType_Dicom)); | 873 int64_t revision; |
869 ASSERT_TRUE(context.GetIndex().LookupAttachment(pixelData1, id, FileContentType_DicomUntilPixelData)); | 874 ASSERT_TRUE(context.GetIndex().LookupAttachment(dicom1, revision, id, FileContentType_Dicom)); |
875 ASSERT_EQ(0, revision); | |
876 revision = -1; | |
877 ASSERT_TRUE(context.GetIndex().LookupAttachment(pixelData1, revision, id, FileContentType_DicomUntilPixelData)); | |
878 ASSERT_EQ(0, revision); | |
870 | 879 |
871 context.GetIndex().GetGlobalStatistics(diskSize, uncompressedSize, countPatients, | 880 context.GetIndex().GetGlobalStatistics(diskSize, uncompressedSize, countPatients, |
872 countStudies, countSeries, countInstances); | 881 countStudies, countSeries, countInstances); |
873 ASSERT_EQ(1u, countInstances); | 882 ASSERT_EQ(1u, countInstances); |
874 ASSERT_EQ(dicom1.GetCompressedSize() + pixelData1.GetCompressedSize(), diskSize); | 883 ASSERT_EQ(dicom1.GetCompressedSize() + pixelData1.GetCompressedSize(), diskSize); |
904 ASSERT_EQ(id, id2); | 913 ASSERT_EQ(id, id2); |
905 } | 914 } |
906 | 915 |
907 { | 916 { |
908 FileInfo nope; | 917 FileInfo nope; |
909 ASSERT_FALSE(context.GetIndex().LookupAttachment(nope, id, FileContentType_DicomAsJson)); | 918 int64_t revision; |
919 ASSERT_FALSE(context.GetIndex().LookupAttachment(nope, revision, id, FileContentType_DicomAsJson)); | |
910 } | 920 } |
911 | 921 |
912 FileInfo dicom2, pixelData2; | 922 FileInfo dicom2, pixelData2; |
913 ASSERT_TRUE(context.GetIndex().LookupAttachment(dicom2, id, FileContentType_Dicom)); | 923 ASSERT_TRUE(context.GetIndex().LookupAttachment(dicom2, revision, id, FileContentType_Dicom)); |
914 ASSERT_TRUE(context.GetIndex().LookupAttachment(pixelData2, id, FileContentType_DicomUntilPixelData)); | 924 ASSERT_EQ(0, revision); |
925 revision = -1; | |
926 ASSERT_TRUE(context.GetIndex().LookupAttachment(pixelData2, revision, id, FileContentType_DicomUntilPixelData)); | |
927 ASSERT_EQ(0, revision); | |
915 | 928 |
916 context.GetIndex().GetGlobalStatistics(diskSize, uncompressedSize, countPatients, | 929 context.GetIndex().GetGlobalStatistics(diskSize, uncompressedSize, countPatients, |
917 countStudies, countSeries, countInstances); | 930 countStudies, countSeries, countInstances); |
918 ASSERT_EQ(1u, countInstances); | 931 ASSERT_EQ(1u, countInstances); |
919 ASSERT_EQ(dicom2.GetCompressedSize() + pixelData2.GetCompressedSize(), diskSize); | 932 ASSERT_EQ(dicom2.GetCompressedSize() + pixelData2.GetCompressedSize(), diskSize); |