comparison OrthancServer/Sources/ServerIndex.cpp @ 4460:6831de40acd9

New metadata automatically computed at the series level: "RemoteAET"
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 20 Jan 2021 14:20:37 +0100
parents d9473bd5ed43
children 50b3f4c8107e
comparison
equal deleted inserted replaced
4459:16392fe89ce0 4460:6831de40acd9
912 std::string now = SystemToolbox::GetNowIsoString(true /* use UTC time (not local time) */); 912 std::string now = SystemToolbox::GetNowIsoString(true /* use UTC time (not local time) */);
913 content.AddMetadata(status.seriesId_, MetadataType_LastUpdate, now); 913 content.AddMetadata(status.seriesId_, MetadataType_LastUpdate, now);
914 content.AddMetadata(status.studyId_, MetadataType_LastUpdate, now); 914 content.AddMetadata(status.studyId_, MetadataType_LastUpdate, now);
915 content.AddMetadata(status.patientId_, MetadataType_LastUpdate, now); 915 content.AddMetadata(status.patientId_, MetadataType_LastUpdate, now);
916 916
917 if (status.isNewSeries_ && 917 if (status.isNewSeries_)
918 hasExpectedInstances) 918 {
919 { 919 if (hasExpectedInstances)
920 content.AddMetadata(status.seriesId_, MetadataType_Series_ExpectedNumberOfInstances, 920 {
921 boost::lexical_cast<std::string>(expectedInstances)); 921 content.AddMetadata(status.seriesId_, MetadataType_Series_ExpectedNumberOfInstances,
922 boost::lexical_cast<std::string>(expectedInstances));
923 }
924
925 // New in Orthanc 1.9.0
926 content.AddMetadata(status.seriesId_, MetadataType_RemoteAet,
927 instanceToStore.GetOrigin().GetRemoteAetC());
922 } 928 }
923 929
924 930
925 // Attach the auto-computed metadata for the instance level, 931 // Attach the auto-computed metadata for the instance level,
926 // reflecting these additions into the input metadata map 932 // reflecting these additions into the input metadata map
927 SetInstanceMetadata(content, instanceMetadata, instanceId, 933 SetInstanceMetadata(content, instanceMetadata, instanceId,
928 MetadataType_Instance_ReceptionDate, now); 934 MetadataType_Instance_ReceptionDate, now);
929 SetInstanceMetadata(content, instanceMetadata, instanceId, MetadataType_Instance_RemoteAet, 935 SetInstanceMetadata(content, instanceMetadata, instanceId, MetadataType_RemoteAet,
930 instanceToStore.GetOrigin().GetRemoteAetC()); 936 instanceToStore.GetOrigin().GetRemoteAetC());
931 SetInstanceMetadata(content, instanceMetadata, instanceId, MetadataType_Instance_Origin, 937 SetInstanceMetadata(content, instanceMetadata, instanceId, MetadataType_Instance_Origin,
932 EnumerationToString(instanceToStore.GetOrigin().GetRequestOrigin())); 938 EnumerationToString(instanceToStore.GetOrigin().GetRequestOrigin()));
933 939
934 940
1847 } 1853 }
1848 1854
1849 1855
1850 bool ServerIndex::LookupMetadata(std::string& target, 1856 bool ServerIndex::LookupMetadata(std::string& target,
1851 const std::string& publicId, 1857 const std::string& publicId,
1858 ResourceType expectedType,
1852 MetadataType type) 1859 MetadataType type)
1853 { 1860 {
1854 boost::mutex::scoped_lock lock(mutex_); 1861 boost::mutex::scoped_lock lock(mutex_);
1855 1862
1856 ResourceType rtype; 1863 ResourceType rtype;
1857 int64_t id; 1864 int64_t id;
1858 if (!db_.LookupResource(id, rtype, publicId)) 1865 if (!db_.LookupResource(id, rtype, publicId) ||
1866 rtype != expectedType)
1859 { 1867 {
1860 throw OrthancException(ErrorCode_UnknownResource); 1868 throw OrthancException(ErrorCode_UnknownResource);
1861 } 1869 }
1862 1870
1863 return db_.LookupMetadata(target, id, type); 1871 return db_.LookupMetadata(target, id, type);
1864 } 1872 }
1865 1873
1866 1874
1867 void ServerIndex::GetAllMetadata(std::map<MetadataType, std::string>& target, 1875 void ServerIndex::GetAllMetadata(std::map<MetadataType, std::string>& target,
1868 const std::string& publicId) 1876 const std::string& publicId,
1877 ResourceType expectedType)
1869 { 1878 {
1870 boost::mutex::scoped_lock lock(mutex_); 1879 boost::mutex::scoped_lock lock(mutex_);
1871 1880
1872 ResourceType type; 1881 ResourceType type;
1873 int64_t id; 1882 int64_t id;
1874 if (!db_.LookupResource(id, type, publicId)) 1883 if (!db_.LookupResource(id, type, publicId) ||
1884 expectedType != type)
1875 { 1885 {
1876 throw OrthancException(ErrorCode_UnknownResource); 1886 throw OrthancException(ErrorCode_UnknownResource);
1877 } 1887 }
1878 1888
1879 return db_.GetAllMetadata(target, id); 1889 return db_.GetAllMetadata(target, id);