comparison UnitTestsSources/ServerIndexTests.cpp @ 1746:d143db00a794 db-changes

SetOfResources
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 26 Oct 2015 16:04:58 +0100
parents b3de74dec2d5
children ca69082ab200
comparison
equal deleted inserted replaced
1745:38dda23c7d7d 1746:d143db00a794
243 243
244 default: 244 default:
245 throw OrthancException(ErrorCode_InternalError); 245 throw OrthancException(ErrorCode_InternalError);
246 } 246 }
247 } 247 }
248
249
250 void DoLookup(std::list<std::string>& result,
251 ResourceType level,
252 const DicomTag& tag,
253 const std::string& value)
254 {
255 LookupIdentifierQuery query(level);
256 query.AddConstraint(tag, IdentifierConstraintType_Equal, value);
257 query.Apply(result, *index_);
258 }
259
248 }; 260 };
249 } 261 }
250 262
251 263
252 INSTANTIATE_TEST_CASE_P(DatabaseWrapperName, 264 INSTANTIATE_TEST_CASE_P(DatabaseWrapperName,
688 index_->SetIdentifierTag(a[0], DICOM_TAG_STUDY_INSTANCE_UID, "0"); 700 index_->SetIdentifierTag(a[0], DICOM_TAG_STUDY_INSTANCE_UID, "0");
689 index_->SetIdentifierTag(a[1], DICOM_TAG_STUDY_INSTANCE_UID, "1"); 701 index_->SetIdentifierTag(a[1], DICOM_TAG_STUDY_INSTANCE_UID, "1");
690 index_->SetIdentifierTag(a[2], DICOM_TAG_STUDY_INSTANCE_UID, "0"); 702 index_->SetIdentifierTag(a[2], DICOM_TAG_STUDY_INSTANCE_UID, "0");
691 index_->SetIdentifierTag(a[3], DICOM_TAG_SERIES_INSTANCE_UID, "0"); 703 index_->SetIdentifierTag(a[3], DICOM_TAG_SERIES_INSTANCE_UID, "0");
692 704
693 std::list<int64_t> s; 705 std::list<std::string> s;
694 706
695 index_->LookupIdentifierExact(s, ResourceType_Study, DICOM_TAG_STUDY_INSTANCE_UID, "0"); 707 DoLookup(s, ResourceType_Study, DICOM_TAG_STUDY_INSTANCE_UID, "0");
696 ASSERT_EQ(2u, s.size()); 708 ASSERT_EQ(2u, s.size());
697 ASSERT_TRUE(std::find(s.begin(), s.end(), a[0]) != s.end()); 709 ASSERT_TRUE(std::find(s.begin(), s.end(), "a") != s.end());
698 ASSERT_TRUE(std::find(s.begin(), s.end(), a[2]) != s.end()); 710 ASSERT_TRUE(std::find(s.begin(), s.end(), "c") != s.end());
699 711
700 index_->LookupIdentifierExact(s, ResourceType_Series, DICOM_TAG_SERIES_INSTANCE_UID, "0"); 712 DoLookup(s, ResourceType_Series, DICOM_TAG_SERIES_INSTANCE_UID, "0");
701 ASSERT_EQ(1u, s.size()); 713 ASSERT_EQ(1u, s.size());
702 ASSERT_TRUE(std::find(s.begin(), s.end(), a[3]) != s.end()); 714 ASSERT_TRUE(std::find(s.begin(), s.end(), "d") != s.end());
703 715
704 index_->LookupIdentifierExact(s, ResourceType_Study, DICOM_TAG_STUDY_INSTANCE_UID, "1"); 716 DoLookup(s, ResourceType_Study, DICOM_TAG_STUDY_INSTANCE_UID, "1");
705 ASSERT_EQ(1u, s.size()); 717 ASSERT_EQ(1u, s.size());
706 ASSERT_TRUE(std::find(s.begin(), s.end(), a[1]) != s.end()); 718 ASSERT_TRUE(std::find(s.begin(), s.end(), "b") != s.end());
707 719
708 index_->LookupIdentifierExact(s, ResourceType_Study, DICOM_TAG_STUDY_INSTANCE_UID, "1"); 720 DoLookup(s, ResourceType_Study, DICOM_TAG_STUDY_INSTANCE_UID, "1");
709 ASSERT_EQ(1u, s.size()); 721 ASSERT_EQ(1u, s.size());
710 ASSERT_TRUE(std::find(s.begin(), s.end(), a[1]) != s.end()); 722 ASSERT_TRUE(std::find(s.begin(), s.end(), "b") != s.end());
711 723
712 index_->LookupIdentifierExact(s, ResourceType_Series, DICOM_TAG_SERIES_INSTANCE_UID, "1"); 724 DoLookup(s, ResourceType_Series, DICOM_TAG_SERIES_INSTANCE_UID, "1");
713 ASSERT_EQ(0u, s.size()); 725 ASSERT_EQ(0u, s.size());
714 726
715 /*{ 727 {
716 std::list<std::string> s; 728 LookupIdentifierQuery query(ResourceType_Study);
717 context.GetIndex().LookupIdentifierExact(s, DICOM_TAG_STUDY_INSTANCE_UID, "1.2.250.1.74.20130819132500.29000036381059"); 729 query.AddConstraint(DICOM_TAG_STUDY_INSTANCE_UID, IdentifierConstraintType_GreaterOrEqual, "0");
718 for (std::list<std::string>::iterator i = s.begin(); i != s.end(); i++) 730 query.Apply(s, *index_);
719 { 731 ASSERT_EQ(3u, s.size());
720 std::cout << "*** " << *i << std::endl;; 732 }
721 } 733
722 }*/ 734 {
735 LookupIdentifierQuery query(ResourceType_Study);
736 query.AddConstraint(DICOM_TAG_STUDY_INSTANCE_UID, IdentifierConstraintType_GreaterOrEqual, "0");
737 query.AddConstraint(DICOM_TAG_STUDY_INSTANCE_UID, IdentifierConstraintType_SmallerOrEqual, "0");
738 query.Apply(s, *index_);
739 ASSERT_EQ(2u, s.size());
740 }
741
742 {
743 LookupIdentifierQuery query(ResourceType_Study);
744 query.AddConstraint(DICOM_TAG_STUDY_INSTANCE_UID, IdentifierConstraintType_GreaterOrEqual, "1");
745 query.AddConstraint(DICOM_TAG_STUDY_INSTANCE_UID, IdentifierConstraintType_SmallerOrEqual, "1");
746 query.Apply(s, *index_);
747 ASSERT_EQ(1u, s.size());
748 }
749
750 {
751 LookupIdentifierQuery query(ResourceType_Study);
752 query.AddConstraint(DICOM_TAG_STUDY_INSTANCE_UID, IdentifierConstraintType_GreaterOrEqual, "1");
753 query.Apply(s, *index_);
754 ASSERT_EQ(1u, s.size());
755 }
756
757 {
758 LookupIdentifierQuery query(ResourceType_Study);
759 query.AddConstraint(DICOM_TAG_STUDY_INSTANCE_UID, IdentifierConstraintType_GreaterOrEqual, "2");
760 query.Apply(s, *index_);
761 ASSERT_EQ(0u, s.size());
762 }
723 } 763 }
724 764
725 765
726 766
727 TEST(ServerIndex, AttachmentRecycling) 767 TEST(ServerIndex, AttachmentRecycling)