Mercurial > hg > orthanc
comparison OrthancServer/Sources/ServerIndex.cpp @ 4506:ac69c9f76c71
refactoring ServerIndex::Store()
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 10 Feb 2021 17:01:44 +0100 |
parents | 97d103b57cd1 |
children | b4c58795f3a8 |
comparison
equal
deleted
inserted
replaced
4505:97d103b57cd1 | 4506:ac69c9f76c71 |
---|---|
43 #include "../../OrthancFramework/Sources/DicomParsing/ParsedDicomFile.h" | 43 #include "../../OrthancFramework/Sources/DicomParsing/ParsedDicomFile.h" |
44 #include "../../OrthancFramework/Sources/Logging.h" | 44 #include "../../OrthancFramework/Sources/Logging.h" |
45 #include "../../OrthancFramework/Sources/Toolbox.h" | 45 #include "../../OrthancFramework/Sources/Toolbox.h" |
46 | 46 |
47 #include "Database/ResourcesContent.h" | 47 #include "Database/ResourcesContent.h" |
48 #include "DicomInstanceToStore.h" | |
49 #include "OrthancConfiguration.h" | 48 #include "OrthancConfiguration.h" |
50 #include "Search/DatabaseLookup.h" | 49 #include "Search/DatabaseLookup.h" |
51 #include "Search/DicomTagConstraint.h" | 50 #include "Search/DicomTagConstraint.h" |
52 #include "ServerContext.h" | 51 #include "ServerContext.h" |
53 #include "ServerIndexChange.h" | 52 #include "ServerIndexChange.h" |
754 listener_->SignalChange(change); | 753 listener_->SignalChange(change); |
755 } | 754 } |
756 | 755 |
757 | 756 |
758 StoreStatus ServerIndex::Store(std::map<MetadataType, std::string>& instanceMetadata, | 757 StoreStatus ServerIndex::Store(std::map<MetadataType, std::string>& instanceMetadata, |
759 DicomInstanceToStore& instanceToStore, | |
760 const DicomMap& dicomSummary, | 758 const DicomMap& dicomSummary, |
761 DicomInstanceHasher& hasher, | |
762 const Attachments& attachments, | 759 const Attachments& attachments, |
760 const MetadataMap& metadata, | |
761 const DicomInstanceOrigin& origin, | |
763 bool overwrite, | 762 bool overwrite, |
763 bool hasTransferSyntax, | |
764 const std::string& transferSyntax, | |
764 bool hasPixelDataOffset, | 765 bool hasPixelDataOffset, |
765 uint64_t pixelDataOffset) | 766 uint64_t pixelDataOffset) |
766 { | 767 { |
767 boost::mutex::scoped_lock lock(mutex_); | 768 boost::mutex::scoped_lock lock(mutex_); |
768 | |
769 const ServerIndex::MetadataMap& metadata = instanceToStore.GetMetadata(); | |
770 | 769 |
771 int64_t expectedInstances; | 770 int64_t expectedInstances; |
772 const bool hasExpectedInstances = | 771 const bool hasExpectedInstances = |
773 ComputeExpectedNumberOfInstances(expectedInstances, dicomSummary); | 772 ComputeExpectedNumberOfInstances(expectedInstances, dicomSummary); |
774 | 773 |
775 instanceMetadata.clear(); | 774 instanceMetadata.clear(); |
776 | 775 |
776 DicomInstanceHasher hasher(dicomSummary); | |
777 const std::string hashPatient = hasher.HashPatient(); | 777 const std::string hashPatient = hasher.HashPatient(); |
778 const std::string hashStudy = hasher.HashStudy(); | 778 const std::string hashStudy = hasher.HashStudy(); |
779 const std::string hashSeries = hasher.HashSeries(); | 779 const std::string hashSeries = hasher.HashSeries(); |
780 const std::string hashInstance = hasher.HashInstance(); | 780 const std::string hashInstance = hasher.HashInstance(); |
781 | 781 |
926 boost::lexical_cast<std::string>(expectedInstances)); | 926 boost::lexical_cast<std::string>(expectedInstances)); |
927 } | 927 } |
928 | 928 |
929 // New in Orthanc 1.9.0 | 929 // New in Orthanc 1.9.0 |
930 content.AddMetadata(status.seriesId_, MetadataType_RemoteAet, | 930 content.AddMetadata(status.seriesId_, MetadataType_RemoteAet, |
931 instanceToStore.GetOrigin().GetRemoteAetC()); | 931 origin.GetRemoteAetC()); |
932 } | 932 } |
933 | 933 |
934 | 934 |
935 // Attach the auto-computed metadata for the instance level, | 935 // Attach the auto-computed metadata for the instance level, |
936 // reflecting these additions into the input metadata map | 936 // reflecting these additions into the input metadata map |
937 SetInstanceMetadata(content, instanceMetadata, instanceId, | 937 SetInstanceMetadata(content, instanceMetadata, instanceId, |
938 MetadataType_Instance_ReceptionDate, now); | 938 MetadataType_Instance_ReceptionDate, now); |
939 SetInstanceMetadata(content, instanceMetadata, instanceId, MetadataType_RemoteAet, | 939 SetInstanceMetadata(content, instanceMetadata, instanceId, MetadataType_RemoteAet, |
940 instanceToStore.GetOrigin().GetRemoteAetC()); | 940 origin.GetRemoteAetC()); |
941 SetInstanceMetadata(content, instanceMetadata, instanceId, MetadataType_Instance_Origin, | 941 SetInstanceMetadata(content, instanceMetadata, instanceId, MetadataType_Instance_Origin, |
942 EnumerationToString(instanceToStore.GetOrigin().GetRequestOrigin())); | 942 EnumerationToString(origin.GetRequestOrigin())); |
943 | 943 |
944 | |
945 if (hasTransferSyntax) | |
946 { | |
947 // New in Orthanc 1.2.0 | |
948 SetInstanceMetadata(content, instanceMetadata, instanceId, | |
949 MetadataType_Instance_TransferSyntax, transferSyntax); | |
950 } | |
944 | 951 |
945 { | 952 { |
946 std::string s; | 953 std::string s; |
947 | 954 |
948 if (instanceToStore.LookupTransferSyntax(s)) | 955 if (origin.LookupRemoteIp(s)) |
949 { | |
950 // New in Orthanc 1.2.0 | |
951 SetInstanceMetadata(content, instanceMetadata, instanceId, | |
952 MetadataType_Instance_TransferSyntax, s); | |
953 } | |
954 | |
955 if (instanceToStore.GetOrigin().LookupRemoteIp(s)) | |
956 { | 956 { |
957 // New in Orthanc 1.4.0 | 957 // New in Orthanc 1.4.0 |
958 SetInstanceMetadata(content, instanceMetadata, instanceId, | 958 SetInstanceMetadata(content, instanceMetadata, instanceId, |
959 MetadataType_Instance_RemoteIp, s); | 959 MetadataType_Instance_RemoteIp, s); |
960 } | 960 } |
961 | 961 |
962 if (instanceToStore.GetOrigin().LookupCalledAet(s)) | 962 if (origin.LookupCalledAet(s)) |
963 { | 963 { |
964 // New in Orthanc 1.4.0 | 964 // New in Orthanc 1.4.0 |
965 SetInstanceMetadata(content, instanceMetadata, instanceId, | 965 SetInstanceMetadata(content, instanceMetadata, instanceId, |
966 MetadataType_Instance_CalledAet, s); | 966 MetadataType_Instance_CalledAet, s); |
967 } | 967 } |
968 | 968 |
969 if (instanceToStore.GetOrigin().LookupHttpUsername(s)) | 969 if (origin.LookupHttpUsername(s)) |
970 { | 970 { |
971 // New in Orthanc 1.4.0 | 971 // New in Orthanc 1.4.0 |
972 SetInstanceMetadata(content, instanceMetadata, instanceId, | 972 SetInstanceMetadata(content, instanceMetadata, instanceId, |
973 MetadataType_Instance_HttpUsername, s); | 973 MetadataType_Instance_HttpUsername, s); |
974 } | 974 } |