comparison OrthancServer/UnitTestsSources/ServerIndexTests.cpp @ 4623:95ffe3b6ef7c db-changes

handling of revisions for metadata
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 16 Apr 2021 17:13:03 +0200
parents f75c63aa9de0
children f7d5372b59b3
comparison
equal deleted inserted replaced
4622:9086aeb9d9d2 4623:95ffe3b6ef7c
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"));
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"));
307 transaction_->AddAttachment(a[6], FileInfo("world", FileContentType_Dicom, 44, "md5")); 307 transaction_->AddAttachment(a[6], FileInfo("world", FileContentType_Dicom, 44, "md5"));
308 transaction_->SetMetadata(a[4], MetadataType_RemoteAet, "PINNACLE"); 308
309 // TODO - REVISIONS - "42" is revision number, that is not currently stored (*)
310 transaction_->SetMetadata(a[4], MetadataType_RemoteAet, "PINNACLE", 42);
309 311
310 transaction_->GetAllMetadata(md, a[4]); 312 transaction_->GetAllMetadata(md, a[4]);
311 ASSERT_EQ(1u, md.size()); 313 ASSERT_EQ(1u, md.size());
312 ASSERT_EQ("PINNACLE", md[MetadataType_RemoteAet]); 314 ASSERT_EQ("PINNACLE", md[MetadataType_RemoteAet]);
313 transaction_->SetMetadata(a[4], MetadataType_ModifiedFrom, "TUTU"); 315 transaction_->SetMetadata(a[4], MetadataType_ModifiedFrom, "TUTU", 10);
314 transaction_->GetAllMetadata(md, a[4]); 316 transaction_->GetAllMetadata(md, a[4]);
315 ASSERT_EQ(2u, md.size()); 317 ASSERT_EQ(2u, md.size());
316 318
317 std::map<MetadataType, std::string> md2; 319 std::map<MetadataType, std::string> md2;
318 transaction_->GetAllMetadata(md2, a[4]); 320 transaction_->GetAllMetadata(md2, a[4]);
339 ResourceType t; 341 ResourceType t;
340 ASSERT_TRUE(transaction_->LookupResource(b, t, "g")); 342 ASSERT_TRUE(transaction_->LookupResource(b, t, "g"));
341 ASSERT_EQ(7, b); 343 ASSERT_EQ(7, b);
342 ASSERT_EQ(ResourceType_Study, t); 344 ASSERT_EQ(ResourceType_Study, t);
343 345
344 ASSERT_TRUE(transaction_->LookupMetadata(s, a[4], MetadataType_RemoteAet)); 346 int64_t revision;
345 ASSERT_FALSE(transaction_->LookupMetadata(s, a[4], MetadataType_Instance_IndexInSeries)); 347 ASSERT_TRUE(transaction_->LookupMetadata(s, revision, a[4], MetadataType_RemoteAet));
348 ASSERT_EQ(0, revision); // "0" instead of "42" because of (*)
349 ASSERT_FALSE(transaction_->LookupMetadata(s, revision, a[4], MetadataType_Instance_IndexInSeries));
350 ASSERT_EQ(0, revision);
346 ASSERT_EQ("PINNACLE", s); 351 ASSERT_EQ("PINNACLE", s);
347 352
348 std::string u; 353 std::string u;
349 ASSERT_TRUE(transaction_->LookupMetadata(u, a[4], MetadataType_RemoteAet)); 354 ASSERT_TRUE(transaction_->LookupMetadata(u, revision, a[4], MetadataType_RemoteAet));
355 ASSERT_EQ(0, revision);
350 ASSERT_EQ("PINNACLE", u); 356 ASSERT_EQ("PINNACLE", u);
351 ASSERT_FALSE(transaction_->LookupMetadata(u, a[4], MetadataType_Instance_IndexInSeries)); 357 ASSERT_FALSE(transaction_->LookupMetadata(u, revision, a[4], MetadataType_Instance_IndexInSeries));
358 ASSERT_EQ(0, revision);
352 359
353 ASSERT_TRUE(transaction_->LookupGlobalProperty(s, GlobalProperty_FlushSleep, true)); 360 ASSERT_TRUE(transaction_->LookupGlobalProperty(s, GlobalProperty_FlushSleep, true));
354 ASSERT_FALSE(transaction_->LookupGlobalProperty(s, static_cast<GlobalProperty>(42), true)); 361 ASSERT_FALSE(transaction_->LookupGlobalProperty(s, static_cast<GlobalProperty>(42), true));
355 ASSERT_EQ("World", s); 362 ASSERT_EQ("World", s);
356 363
1006 { 1013 {
1007 ASSERT_EQ(1u, attachments.size()); 1014 ASSERT_EQ(1u, attachments.size());
1008 } 1015 }
1009 1016
1010 std::string s; 1017 std::string s;
1011 bool found = context.GetIndex().LookupMetadata(s, id, ResourceType_Instance, 1018 int64_t revision;
1019 bool found = context.GetIndex().LookupMetadata(s, revision, id, ResourceType_Instance,
1012 MetadataType_Instance_PixelDataOffset); 1020 MetadataType_Instance_PixelDataOffset);
1013 1021
1014 if (withPixelData) 1022 if (withPixelData)
1015 { 1023 {
1016 ASSERT_TRUE(found); 1024 ASSERT_TRUE(found);
1025 ASSERT_EQ(0, revision);
1017 ASSERT_GT(boost::lexical_cast<int>(s), 128 /* length of the DICOM preamble */); 1026 ASSERT_GT(boost::lexical_cast<int>(s), 128 /* length of the DICOM preamble */);
1018 ASSERT_LT(boost::lexical_cast<size_t>(s), dicomSize); 1027 ASSERT_LT(boost::lexical_cast<size_t>(s), dicomSize);
1019 } 1028 }
1020 else 1029 else
1021 { 1030 {