Mercurial > hg > orthanc
comparison UnitTestsSources/ServerIndexTests.cpp @ 1763:f7014cca73c7
integration db-changes->mainline
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 29 Oct 2015 12:45:20 +0100 |
parents | ca69082ab200 |
children | 9ead18ef460a |
comparison
equal
deleted
inserted
replaced
1743:8fc1d096aa38 | 1763:f7014cca73c7 |
---|---|
37 #include "../Core/Logging.h" | 37 #include "../Core/Logging.h" |
38 #include "../Core/Uuid.h" | 38 #include "../Core/Uuid.h" |
39 #include "../OrthancServer/DatabaseWrapper.h" | 39 #include "../OrthancServer/DatabaseWrapper.h" |
40 #include "../OrthancServer/ServerContext.h" | 40 #include "../OrthancServer/ServerContext.h" |
41 #include "../OrthancServer/ServerIndex.h" | 41 #include "../OrthancServer/ServerIndex.h" |
42 #include "../OrthancServer/Search/LookupIdentifierQuery.h" | |
42 | 43 |
43 #include <ctype.h> | 44 #include <ctype.h> |
44 #include <algorithm> | 45 #include <algorithm> |
45 | 46 |
46 using namespace Orthanc; | 47 using namespace Orthanc; |
243 | 244 |
244 default: | 245 default: |
245 throw OrthancException(ErrorCode_InternalError); | 246 throw OrthancException(ErrorCode_InternalError); |
246 } | 247 } |
247 } | 248 } |
249 | |
250 | |
251 void DoLookup(std::list<std::string>& result, | |
252 ResourceType level, | |
253 const DicomTag& tag, | |
254 const std::string& value) | |
255 { | |
256 LookupIdentifierQuery query(level); | |
257 query.AddConstraint(tag, IdentifierConstraintType_Equal, value); | |
258 query.Apply(result, *index_); | |
259 } | |
260 | |
248 }; | 261 }; |
249 } | 262 } |
250 | 263 |
251 | 264 |
252 INSTANTIATE_TEST_CASE_P(DatabaseWrapperName, | 265 INSTANTIATE_TEST_CASE_P(DatabaseWrapperName, |
688 index_->SetIdentifierTag(a[0], DICOM_TAG_STUDY_INSTANCE_UID, "0"); | 701 index_->SetIdentifierTag(a[0], DICOM_TAG_STUDY_INSTANCE_UID, "0"); |
689 index_->SetIdentifierTag(a[1], DICOM_TAG_STUDY_INSTANCE_UID, "1"); | 702 index_->SetIdentifierTag(a[1], DICOM_TAG_STUDY_INSTANCE_UID, "1"); |
690 index_->SetIdentifierTag(a[2], DICOM_TAG_STUDY_INSTANCE_UID, "0"); | 703 index_->SetIdentifierTag(a[2], DICOM_TAG_STUDY_INSTANCE_UID, "0"); |
691 index_->SetIdentifierTag(a[3], DICOM_TAG_SERIES_INSTANCE_UID, "0"); | 704 index_->SetIdentifierTag(a[3], DICOM_TAG_SERIES_INSTANCE_UID, "0"); |
692 | 705 |
693 std::list<int64_t> s; | 706 std::list<std::string> s; |
694 | 707 |
695 index_->LookupIdentifier(s, DICOM_TAG_STUDY_INSTANCE_UID, "0"); | 708 DoLookup(s, ResourceType_Study, DICOM_TAG_STUDY_INSTANCE_UID, "0"); |
696 ASSERT_EQ(2u, s.size()); | 709 ASSERT_EQ(2u, s.size()); |
697 ASSERT_TRUE(std::find(s.begin(), s.end(), a[0]) != s.end()); | 710 ASSERT_TRUE(std::find(s.begin(), s.end(), "a") != s.end()); |
698 ASSERT_TRUE(std::find(s.begin(), s.end(), a[2]) != s.end()); | 711 ASSERT_TRUE(std::find(s.begin(), s.end(), "c") != s.end()); |
699 | 712 |
700 index_->LookupIdentifier(s, DICOM_TAG_SERIES_INSTANCE_UID, "0"); | 713 DoLookup(s, ResourceType_Series, DICOM_TAG_SERIES_INSTANCE_UID, "0"); |
701 ASSERT_EQ(1u, s.size()); | 714 ASSERT_EQ(1u, s.size()); |
702 ASSERT_TRUE(std::find(s.begin(), s.end(), a[3]) != s.end()); | 715 ASSERT_TRUE(std::find(s.begin(), s.end(), "d") != s.end()); |
703 | 716 |
704 index_->LookupIdentifier(s, DICOM_TAG_STUDY_INSTANCE_UID, "1"); | 717 DoLookup(s, ResourceType_Study, DICOM_TAG_STUDY_INSTANCE_UID, "1"); |
705 ASSERT_EQ(1u, s.size()); | 718 ASSERT_EQ(1u, s.size()); |
706 ASSERT_TRUE(std::find(s.begin(), s.end(), a[1]) != s.end()); | 719 ASSERT_TRUE(std::find(s.begin(), s.end(), "b") != s.end()); |
707 | 720 |
708 index_->LookupIdentifier(s, DICOM_TAG_STUDY_INSTANCE_UID, "1"); | 721 DoLookup(s, ResourceType_Study, DICOM_TAG_STUDY_INSTANCE_UID, "1"); |
709 ASSERT_EQ(1u, s.size()); | 722 ASSERT_EQ(1u, s.size()); |
710 ASSERT_TRUE(std::find(s.begin(), s.end(), a[1]) != s.end()); | 723 ASSERT_TRUE(std::find(s.begin(), s.end(), "b") != s.end()); |
711 | 724 |
712 index_->LookupIdentifier(s, DICOM_TAG_SERIES_INSTANCE_UID, "1"); | 725 DoLookup(s, ResourceType_Series, DICOM_TAG_SERIES_INSTANCE_UID, "1"); |
713 ASSERT_EQ(0u, s.size()); | 726 ASSERT_EQ(0u, s.size()); |
714 | 727 |
715 /*{ | 728 { |
716 std::list<std::string> s; | 729 LookupIdentifierQuery query(ResourceType_Study); |
717 context.GetIndex().LookupIdentifier(s, DICOM_TAG_STUDY_INSTANCE_UID, "1.2.250.1.74.20130819132500.29000036381059"); | 730 query.AddConstraint(DICOM_TAG_STUDY_INSTANCE_UID, IdentifierConstraintType_GreaterOrEqual, "0"); |
718 for (std::list<std::string>::iterator i = s.begin(); i != s.end(); i++) | 731 query.Apply(s, *index_); |
719 { | 732 ASSERT_EQ(3u, s.size()); |
720 std::cout << "*** " << *i << std::endl;; | 733 } |
721 } | 734 |
722 }*/ | 735 { |
736 LookupIdentifierQuery query(ResourceType_Study); | |
737 query.AddConstraint(DICOM_TAG_STUDY_INSTANCE_UID, IdentifierConstraintType_GreaterOrEqual, "0"); | |
738 query.AddConstraint(DICOM_TAG_STUDY_INSTANCE_UID, IdentifierConstraintType_SmallerOrEqual, "0"); | |
739 query.Apply(s, *index_); | |
740 ASSERT_EQ(2u, s.size()); | |
741 } | |
742 | |
743 { | |
744 LookupIdentifierQuery query(ResourceType_Study); | |
745 query.AddConstraint(DICOM_TAG_STUDY_INSTANCE_UID, IdentifierConstraintType_GreaterOrEqual, "1"); | |
746 query.AddConstraint(DICOM_TAG_STUDY_INSTANCE_UID, IdentifierConstraintType_SmallerOrEqual, "1"); | |
747 query.Apply(s, *index_); | |
748 ASSERT_EQ(1u, s.size()); | |
749 } | |
750 | |
751 { | |
752 LookupIdentifierQuery query(ResourceType_Study); | |
753 query.AddConstraint(DICOM_TAG_STUDY_INSTANCE_UID, IdentifierConstraintType_GreaterOrEqual, "1"); | |
754 query.Apply(s, *index_); | |
755 ASSERT_EQ(1u, s.size()); | |
756 } | |
757 | |
758 { | |
759 LookupIdentifierQuery query(ResourceType_Study); | |
760 query.AddConstraint(DICOM_TAG_STUDY_INSTANCE_UID, IdentifierConstraintType_GreaterOrEqual, "2"); | |
761 query.Apply(s, *index_); | |
762 ASSERT_EQ(0u, s.size()); | |
763 } | |
723 } | 764 } |
724 | 765 |
725 | 766 |
726 | 767 |
727 TEST(ServerIndex, AttachmentRecycling) | 768 TEST(ServerIndex, AttachmentRecycling) |