Mercurial > hg > orthanc
comparison OrthancServer/Plugins/Engine/OrthancPluginDatabase.cpp @ 4592:36bbf3169a27 db-changes
comments
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 15 Mar 2021 16:16:42 +0100 |
parents | ff8170d17d90 |
children | 60a860942c5e |
comparison
equal
deleted
inserted
replaced
4591:ff8170d17d90 | 4592:36bbf3169a27 |
---|---|
117 } | 117 } |
118 } | 118 } |
119 | 119 |
120 | 120 |
121 // From the "ILookupResources" interface | 121 // From the "ILookupResources" interface |
122 void GetAllInternalIds(std::list<int64_t>& target, | |
123 ResourceType resourceType) ORTHANC_OVERRIDE | |
124 { | |
125 if (that_.extensions_.getAllInternalIds == NULL) | |
126 { | |
127 throw OrthancException(ErrorCode_DatabasePlugin, | |
128 "The database plugin does not implement the mandatory GetAllInternalIds() extension"); | |
129 } | |
130 | |
131 that_.ResetAnswers(); | |
132 CheckSuccess(that_.extensions_.getAllInternalIds(that_.GetContext(), that_.payload_, Plugins::Convert(resourceType))); | |
133 that_.ForwardAnswers(target); | |
134 } | |
135 | |
136 | |
137 | |
138 // From the "ILookupResources" interface | |
139 void LookupIdentifier(std::list<int64_t>& result, | 122 void LookupIdentifier(std::list<int64_t>& result, |
140 ResourceType level, | 123 ResourceType level, |
141 const DicomTag& tag, | 124 const DicomTag& tag, |
142 Compatibility::IdentifierConstraintType type, | 125 Compatibility::IdentifierConstraintType type, |
143 const std::string& value) ORTHANC_OVERRIDE | 126 const std::string& value) ORTHANC_OVERRIDE |
157 CheckSuccess(that_.extensions_.lookupIdentifier3(that_.GetContext(), that_.payload_, Plugins::Convert(level), | 140 CheckSuccess(that_.extensions_.lookupIdentifier3(that_.GetContext(), that_.payload_, Plugins::Convert(level), |
158 &tmp, Compatibility::Convert(type))); | 141 &tmp, Compatibility::Convert(type))); |
159 that_.ForwardAnswers(result); | 142 that_.ForwardAnswers(result); |
160 } | 143 } |
161 | 144 |
162 | |
163 | |
164 /** | |
165 * Implementation of "ITransaction" | |
166 **/ | |
167 | 145 |
168 virtual void ApplyLookupResources(std::list<std::string>& resourcesId, | 146 virtual void ApplyLookupResources(std::list<std::string>& resourcesId, |
169 std::list<std::string>* instancesId, | 147 std::list<std::string>* instancesId, |
170 const std::vector<DatabaseConstraint>& lookup, | 148 const std::vector<DatabaseConstraint>& lookup, |
171 ResourceType queryLevel, | 149 ResourceType queryLevel, |
239 { | 217 { |
240 return false; | 218 return false; |
241 } | 219 } |
242 } | 220 } |
243 } | 221 } |
244 | |
245 | |
246 virtual int64_t CreateResource(const std::string& publicId, | |
247 ResourceType type) ORTHANC_OVERRIDE | |
248 { | |
249 int64_t id; | |
250 CheckSuccess(that_.backend_.createResource(&id, that_.payload_, publicId.c_str(), Plugins::Convert(type))); | |
251 return id; | |
252 } | |
253 | 222 |
254 | 223 |
255 virtual void AddAttachment(int64_t id, | 224 virtual void AddAttachment(int64_t id, |
256 const FileInfo& attachment) ORTHANC_OVERRIDE | 225 const FileInfo& attachment) ORTHANC_OVERRIDE |
257 { | 226 { |
266 | 235 |
267 CheckSuccess(that_.backend_.addAttachment(that_.payload_, id, &tmp)); | 236 CheckSuccess(that_.backend_.addAttachment(that_.payload_, id, &tmp)); |
268 } | 237 } |
269 | 238 |
270 | 239 |
240 // From the "ICreateInstance" interface | |
271 virtual void AttachChild(int64_t parent, | 241 virtual void AttachChild(int64_t parent, |
272 int64_t child) ORTHANC_OVERRIDE | 242 int64_t child) ORTHANC_OVERRIDE |
273 { | 243 { |
274 CheckSuccess(that_.backend_.attachChild(that_.payload_, parent, child)); | 244 CheckSuccess(that_.backend_.attachChild(that_.payload_, parent, child)); |
275 } | 245 } |
297 | 267 |
298 CheckSuccess(that_.extensions_.clearMainDicomTags(that_.payload_, id)); | 268 CheckSuccess(that_.extensions_.clearMainDicomTags(that_.payload_, id)); |
299 } | 269 } |
300 | 270 |
301 | 271 |
272 // From the "ICreateInstance" interface | |
273 virtual int64_t CreateResource(const std::string& publicId, | |
274 ResourceType type) ORTHANC_OVERRIDE | |
275 { | |
276 int64_t id; | |
277 CheckSuccess(that_.backend_.createResource(&id, that_.payload_, publicId.c_str(), Plugins::Convert(type))); | |
278 return id; | |
279 } | |
280 | |
281 | |
302 virtual void DeleteAttachment(int64_t id, | 282 virtual void DeleteAttachment(int64_t id, |
303 FileContentType attachment) ORTHANC_OVERRIDE | 283 FileContentType attachment) ORTHANC_OVERRIDE |
304 { | 284 { |
305 CheckSuccess(that_.backend_.deleteAttachment(that_.payload_, id, static_cast<int32_t>(attachment))); | 285 CheckSuccess(that_.backend_.deleteAttachment(that_.payload_, id, static_cast<int32_t>(attachment))); |
306 } | 286 } |
315 | 295 |
316 virtual void DeleteResource(int64_t id) ORTHANC_OVERRIDE | 296 virtual void DeleteResource(int64_t id) ORTHANC_OVERRIDE |
317 { | 297 { |
318 CheckSuccess(that_.backend_.deleteResource(that_.payload_, id)); | 298 CheckSuccess(that_.backend_.deleteResource(that_.payload_, id)); |
319 } | 299 } |
300 | |
301 | |
302 // From the "ILookupResources" interface | |
303 void GetAllInternalIds(std::list<int64_t>& target, | |
304 ResourceType resourceType) ORTHANC_OVERRIDE | |
305 { | |
306 if (that_.extensions_.getAllInternalIds == NULL) | |
307 { | |
308 throw OrthancException(ErrorCode_DatabasePlugin, | |
309 "The database plugin does not implement the mandatory GetAllInternalIds() extension"); | |
310 } | |
311 | |
312 that_.ResetAnswers(); | |
313 CheckSuccess(that_.extensions_.getAllInternalIds(that_.GetContext(), that_.payload_, Plugins::Convert(resourceType))); | |
314 that_.ForwardAnswers(target); | |
315 } | |
316 | |
320 | 317 |
321 | 318 |
322 virtual void GetAllMetadata(std::map<MetadataType, std::string>& target, | 319 virtual void GetAllMetadata(std::map<MetadataType, std::string>& target, |
323 int64_t id) ORTHANC_OVERRIDE | 320 int64_t id) ORTHANC_OVERRIDE |
324 { | 321 { |
712 | 709 |
713 return that_.ForwardSingleAnswer(target); | 710 return that_.ForwardSingleAnswer(target); |
714 } | 711 } |
715 | 712 |
716 | 713 |
714 // From the "ILookupResources" interface | |
717 virtual void LookupIdentifierRange(std::list<int64_t>& result, | 715 virtual void LookupIdentifierRange(std::list<int64_t>& result, |
718 ResourceType level, | 716 ResourceType level, |
719 const DicomTag& tag, | 717 const DicomTag& tag, |
720 const std::string& start, | 718 const std::string& start, |
721 const std::string& end) ORTHANC_OVERRIDE | 719 const std::string& end) ORTHANC_OVERRIDE |
869 CheckSuccess(that_.backend_.setGlobalProperty | 867 CheckSuccess(that_.backend_.setGlobalProperty |
870 (that_.payload_, static_cast<int32_t>(property), value.c_str())); | 868 (that_.payload_, static_cast<int32_t>(property), value.c_str())); |
871 } | 869 } |
872 | 870 |
873 | 871 |
872 // From the "ISetResourcesContent" interface | |
874 virtual void SetIdentifierTag(int64_t id, | 873 virtual void SetIdentifierTag(int64_t id, |
875 const DicomTag& tag, | 874 const DicomTag& tag, |
876 const std::string& value) ORTHANC_OVERRIDE | 875 const std::string& value) ORTHANC_OVERRIDE |
877 { | 876 { |
878 OrthancPluginDicomTag tmp; | 877 OrthancPluginDicomTag tmp; |
882 | 881 |
883 CheckSuccess(that_.backend_.setIdentifierTag(that_.payload_, id, &tmp)); | 882 CheckSuccess(that_.backend_.setIdentifierTag(that_.payload_, id, &tmp)); |
884 } | 883 } |
885 | 884 |
886 | 885 |
886 // From the "ISetResourcesContent" interface | |
887 virtual void SetMainDicomTag(int64_t id, | 887 virtual void SetMainDicomTag(int64_t id, |
888 const DicomTag& tag, | 888 const DicomTag& tag, |
889 const std::string& value) ORTHANC_OVERRIDE | 889 const std::string& value) ORTHANC_OVERRIDE |
890 { | 890 { |
891 OrthancPluginDicomTag tmp; | 891 OrthancPluginDicomTag tmp; |
911 { | 911 { |
912 CheckSuccess(that_.backend_.setProtectedPatient(that_.payload_, internalId, isProtected)); | 912 CheckSuccess(that_.backend_.setProtectedPatient(that_.payload_, internalId, isProtected)); |
913 } | 913 } |
914 | 914 |
915 | 915 |
916 // From the "ISetResourcesContent" interface | |
916 virtual void SetResourcesContent(const Orthanc::ResourcesContent& content) ORTHANC_OVERRIDE | 917 virtual void SetResourcesContent(const Orthanc::ResourcesContent& content) ORTHANC_OVERRIDE |
917 { | 918 { |
918 if (that_.extensions_.setResourcesContent == NULL) | 919 if (that_.extensions_.setResourcesContent == NULL) |
919 { | 920 { |
920 ISetResourcesContent::Apply(*this, content); | 921 ISetResourcesContent::Apply(*this, content); |
971 (metadata.empty() ? NULL : &metadata[0]))); | 972 (metadata.empty() ? NULL : &metadata[0]))); |
972 } | 973 } |
973 } | 974 } |
974 | 975 |
975 | 976 |
977 // From the "ICreateInstance" interface | |
976 virtual void TagMostRecentPatient(int64_t patient) ORTHANC_OVERRIDE | 978 virtual void TagMostRecentPatient(int64_t patient) ORTHANC_OVERRIDE |
977 { | 979 { |
978 if (that_.extensions_.tagMostRecentPatient != NULL) | 980 if (that_.extensions_.tagMostRecentPatient != NULL) |
979 { | 981 { |
980 CheckSuccess(that_.extensions_.tagMostRecentPatient(that_.payload_, patient)); | 982 CheckSuccess(that_.extensions_.tagMostRecentPatient(that_.payload_, patient)); |
981 } | 983 } |
982 } | 984 } |
983 | |
984 }; | 985 }; |
985 | 986 |
986 | 987 |
987 static FileInfo Convert(const OrthancPluginAttachment& attachment) | 988 static FileInfo Convert(const OrthancPluginAttachment& attachment) |
988 { | 989 { |