comparison UnitTests/ServerIndex.cpp @ 521:2c739f76d0bb

lookup tag values
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 29 Aug 2013 14:50:23 +0200
parents 7bbe77cb9e12
children f64e3838d6e1
comparison
equal deleted inserted replaced
519:1b2cdc855bd3 521:2c739f76d0bb
3 #include "../OrthancServer/DatabaseWrapper.h" 3 #include "../OrthancServer/DatabaseWrapper.h"
4 #include "../Core/Uuid.h" 4 #include "../Core/Uuid.h"
5 5
6 #include <ctype.h> 6 #include <ctype.h>
7 #include <glog/logging.h> 7 #include <glog/logging.h>
8 #include <algorithm>
8 9
9 using namespace Orthanc; 10 using namespace Orthanc;
10 11
11 namespace 12 namespace
12 { 13 {
430 ASSERT_EQ(1u, index.IncrementGlobalSequence(GlobalProperty_AnonymizationSequence)); 431 ASSERT_EQ(1u, index.IncrementGlobalSequence(GlobalProperty_AnonymizationSequence));
431 ASSERT_EQ(2u, index.IncrementGlobalSequence(GlobalProperty_AnonymizationSequence)); 432 ASSERT_EQ(2u, index.IncrementGlobalSequence(GlobalProperty_AnonymizationSequence));
432 ASSERT_EQ(3u, index.IncrementGlobalSequence(GlobalProperty_AnonymizationSequence)); 433 ASSERT_EQ(3u, index.IncrementGlobalSequence(GlobalProperty_AnonymizationSequence));
433 ASSERT_EQ(4u, index.IncrementGlobalSequence(GlobalProperty_AnonymizationSequence)); 434 ASSERT_EQ(4u, index.IncrementGlobalSequence(GlobalProperty_AnonymizationSequence));
434 } 435 }
436
437
438
439 TEST(DatabaseWrapper, LookupTagValue)
440 {
441 ServerIndexListener listener;
442 DatabaseWrapper index(listener);
443
444 int64_t a[] = {
445 index.CreateResource("a", ResourceType_Study), // 0
446 index.CreateResource("b", ResourceType_Study), // 1
447 index.CreateResource("c", ResourceType_Study), // 2
448 index.CreateResource("d", ResourceType_Series) // 3
449 };
450
451 DicomMap m;
452 m.Clear(); m.SetValue(DICOM_TAG_STUDY_INSTANCE_UID, "0"); index.SetMainDicomTags(a[0], m);
453 m.Clear(); m.SetValue(DICOM_TAG_STUDY_INSTANCE_UID, "1"); index.SetMainDicomTags(a[1], m);
454 m.Clear(); m.SetValue(DICOM_TAG_STUDY_INSTANCE_UID, "0"); index.SetMainDicomTags(a[2], m);
455 m.Clear(); m.SetValue(DICOM_TAG_SERIES_INSTANCE_UID, "0"); index.SetMainDicomTags(a[3], m);
456
457 std::list<int64_t> s;
458
459 index.LookupTagValue(s, DICOM_TAG_STUDY_INSTANCE_UID, "0");
460 ASSERT_EQ(2u, s.size());
461 ASSERT_TRUE(std::find(s.begin(), s.end(), a[0]) != s.end());
462 ASSERT_TRUE(std::find(s.begin(), s.end(), a[2]) != s.end());
463
464 index.LookupTagValue(s, "0");
465 ASSERT_EQ(3u, s.size());
466 ASSERT_TRUE(std::find(s.begin(), s.end(), a[0]) != s.end());
467 ASSERT_TRUE(std::find(s.begin(), s.end(), a[2]) != s.end());
468 ASSERT_TRUE(std::find(s.begin(), s.end(), a[3]) != s.end());
469
470 index.LookupTagValue(s, DICOM_TAG_STUDY_INSTANCE_UID, "1");
471 ASSERT_EQ(1u, s.size());
472 ASSERT_TRUE(std::find(s.begin(), s.end(), a[1]) != s.end());
473
474 index.LookupTagValue(s, "1");
475 ASSERT_EQ(1u, s.size());
476 ASSERT_TRUE(std::find(s.begin(), s.end(), a[1]) != s.end());
477
478
479 /*{
480 std::list<std::string> s;
481 context.GetIndex().LookupTagValue(s, DICOM_TAG_STUDY_INSTANCE_UID, "1.2.250.1.74.20130819132500.29000036381059");
482 for (std::list<std::string>::iterator i = s.begin(); i != s.end(); i++)
483 {
484 std::cout << "*** " << *i << std::endl;;
485 }
486 }*/
487
488
489 }