36 #include "OrthancCDatabasePlugin.h"
49 NonCopyable(
const NonCopyable&);
51 NonCopyable& operator= (
const NonCopyable&);
101 AllowedAnswers_Attachment,
102 AllowedAnswers_Change,
103 AllowedAnswers_DicomTag,
104 AllowedAnswers_ExportedResource
109 AllowedAnswers allowedAnswers_;
111 void SetAllowedAnswers(AllowedAnswers allowed)
113 allowedAnswers_ = allowed;
121 allowedAnswers_(AllowedAnswers_All )
130 void LogError(
const std::string& message)
135 void LogWarning(
const std::string& message)
140 void LogInfo(
const std::string& message)
145 void SignalDeletedAttachment(
const std::string& uuid,
147 uint64_t uncompressedSize,
148 const std::string& uncompressedHash,
149 int32_t compressionType,
150 uint64_t compressedSize,
151 const std::string& compressedHash)
153 OrthancPluginAttachment attachment;
154 attachment.uuid = uuid.c_str();
155 attachment.contentType = contentType;
156 attachment.uncompressedSize = uncompressedSize;
157 attachment.uncompressedHash = uncompressedHash.c_str();
158 attachment.compressionType = compressionType;
159 attachment.compressedSize = compressedSize;
160 attachment.compressedHash = compressedHash.c_str();
162 OrthancPluginDatabaseSignalDeletedAttachment(context_, database_, &attachment);
165 void SignalDeletedResource(
const std::string& publicId,
168 OrthancPluginDatabaseSignalDeletedResource(context_, database_, publicId.c_str(), resourceType);
171 void SignalRemainingAncestor(
const std::string& ancestorId,
174 OrthancPluginDatabaseSignalRemainingAncestor(context_, database_, ancestorId.c_str(), ancestorType);
177 void AnswerAttachment(
const std::string& uuid,
179 uint64_t uncompressedSize,
180 const std::string& uncompressedHash,
181 int32_t compressionType,
182 uint64_t compressedSize,
183 const std::string& compressedHash)
185 if (allowedAnswers_ != AllowedAnswers_All &&
186 allowedAnswers_ != AllowedAnswers_Attachment)
188 throw std::runtime_error(
"Cannot answer with an attachment in the current state");
191 OrthancPluginAttachment attachment;
192 attachment.uuid = uuid.c_str();
193 attachment.contentType = contentType;
194 attachment.uncompressedSize = uncompressedSize;
195 attachment.uncompressedHash = uncompressedHash.c_str();
196 attachment.compressionType = compressionType;
197 attachment.compressedSize = compressedSize;
198 attachment.compressedHash = compressedHash.c_str();
200 OrthancPluginDatabaseAnswerAttachment(context_, database_, &attachment);
203 void AnswerChange(int64_t seq,
206 const std::string& publicId,
207 const std::string& date)
209 if (allowedAnswers_ != AllowedAnswers_All &&
210 allowedAnswers_ != AllowedAnswers_Change)
212 throw std::runtime_error(
"Cannot answer with a change in the current state");
215 OrthancPluginChange change;
217 change.changeType = changeType;
218 change.resourceType = resourceType;
219 change.publicId = publicId.c_str();
220 change.date = date.c_str();
222 OrthancPluginDatabaseAnswerChange(context_, database_, &change);
225 void AnswerDicomTag(uint16_t group,
227 const std::string& value)
229 if (allowedAnswers_ != AllowedAnswers_All &&
230 allowedAnswers_ != AllowedAnswers_DicomTag)
232 throw std::runtime_error(
"Cannot answer with a DICOM tag in the current state");
235 OrthancPluginDicomTag tag;
237 tag.element = element;
238 tag.value = value.c_str();
240 OrthancPluginDatabaseAnswerDicomTag(context_, database_, &tag);
243 void AnswerExportedResource(int64_t seq,
245 const std::string& publicId,
246 const std::string& modality,
247 const std::string& date,
248 const std::string& patientId,
249 const std::string& studyInstanceUid,
250 const std::string& seriesInstanceUid,
251 const std::string& sopInstanceUid)
253 if (allowedAnswers_ != AllowedAnswers_All &&
254 allowedAnswers_ != AllowedAnswers_ExportedResource)
256 throw std::runtime_error(
"Cannot answer with an exported resource in the current state");
259 OrthancPluginExportedResource exported;
261 exported.resourceType = resourceType;
262 exported.publicId = publicId.c_str();
263 exported.modality = modality.c_str();
264 exported.date = date.c_str();
265 exported.patientId = patientId.c_str();
266 exported.studyInstanceUid = studyInstanceUid.c_str();
267 exported.seriesInstanceUid = seriesInstanceUid.c_str();
268 exported.sopInstanceUid = sopInstanceUid.c_str();
270 OrthancPluginDatabaseAnswerExportedResource(context_, database_, &exported);
317 virtual void Open() = 0;
319 virtual void Close() = 0;
321 virtual void AddAttachment(int64_t
id,
322 const OrthancPluginAttachment& attachment) = 0;
324 virtual void AttachChild(int64_t parent,
327 virtual void ClearChanges() = 0;
329 virtual void ClearExportedResources() = 0;
331 virtual int64_t CreateResource(
const char* publicId,
334 virtual void DeleteAttachment(int64_t
id,
335 int32_t attachment) = 0;
337 virtual void DeleteMetadata(int64_t
id,
338 int32_t metadataType) = 0;
340 virtual void DeleteResource(int64_t
id) = 0;
342 virtual void GetAllInternalIds(std::list<int64_t>& target,
345 virtual void GetAllPublicIds(std::list<std::string>& target,
348 virtual void GetAllPublicIds(std::list<std::string>& target,
354 virtual void GetChanges(
bool& done ,
356 uint32_t maxResults) = 0;
358 virtual void GetChildrenInternalId(std::list<int64_t>& target ,
361 virtual void GetChildrenPublicId(std::list<std::string>& target ,
365 virtual void GetExportedResources(
bool& done ,
367 uint32_t maxResults) = 0;
370 virtual void GetLastChange() = 0;
373 virtual void GetLastExportedResource() = 0;
376 virtual void GetMainDicomTags(int64_t
id) = 0;
378 virtual std::string GetPublicId(int64_t resourceId) = 0;
384 virtual uint64_t GetTotalCompressedSize() = 0;
386 virtual uint64_t GetTotalUncompressedSize() = 0;
388 virtual bool IsExistingResource(int64_t internalId) = 0;
390 virtual bool IsProtectedPatient(int64_t internalId) = 0;
392 virtual void ListAvailableMetadata(std::list<int32_t>& target ,
395 virtual void ListAvailableAttachments(std::list<int32_t>& target ,
398 virtual void LogChange(
const OrthancPluginChange& change) = 0;
400 virtual void LogExportedResource(
const OrthancPluginExportedResource& resource) = 0;
403 virtual bool LookupAttachment(int64_t
id,
404 int32_t contentType) = 0;
406 virtual bool LookupGlobalProperty(std::string& target ,
407 int32_t property) = 0;
409 virtual void LookupIdentifier(std::list<int64_t>& target ,
414 const char* value) = 0;
416 virtual bool LookupMetadata(std::string& target ,
418 int32_t metadataType) = 0;
420 virtual bool LookupParent(int64_t& parentId ,
421 int64_t resourceId) = 0;
423 virtual bool LookupResource(int64_t&
id ,
425 const char* publicId) = 0;
427 virtual bool SelectPatientToRecycle(int64_t& internalId ) = 0;
429 virtual bool SelectPatientToRecycle(int64_t& internalId ,
430 int64_t patientIdToAvoid) = 0;
432 virtual void SetGlobalProperty(int32_t property,
433 const char* value) = 0;
435 virtual void SetMainDicomTag(int64_t
id,
438 const char* value) = 0;
440 virtual void SetIdentifierTag(int64_t
id,
443 const char* value) = 0;
445 virtual void SetMetadata(int64_t
id,
446 int32_t metadataType,
447 const char* value) = 0;
449 virtual void SetProtectedPatient(int64_t internalId,
450 bool isProtected) = 0;
452 virtual void StartTransaction() = 0;
454 virtual void RollbackTransaction() = 0;
456 virtual void CommitTransaction() = 0;
458 virtual uint32_t GetDatabaseVersion() = 0;
468 virtual void ClearMainDicomTags(int64_t internalId) = 0;
491 const std::runtime_error& e)
493 backend->GetOutput().LogError(
"Exception in database back-end: " + std::string(e.what()));
499 const OrthancPluginAttachment* attachment)
502 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None);
506 backend->AddAttachment(
id, *attachment);
509 catch (std::runtime_error& e)
511 LogError(backend, e);
516 return e.GetErrorCode();
526 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None);
530 backend->AttachChild(parent, child);
533 catch (std::runtime_error& e)
535 LogError(backend, e);
540 return e.GetErrorCode();
548 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None);
552 backend->ClearChanges();
555 catch (std::runtime_error& e)
557 LogError(backend, e);
562 return e.GetErrorCode();
570 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None);
574 backend->ClearExportedResources();
577 catch (std::runtime_error& e)
579 LogError(backend, e);
584 return e.GetErrorCode();
591 const char* publicId,
595 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None);
599 *
id = backend->CreateResource(publicId, resourceType);
602 catch (std::runtime_error& e)
604 LogError(backend, e);
609 return e.GetErrorCode();
619 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None);
623 backend->DeleteAttachment(
id, contentType);
626 catch (std::runtime_error& e)
628 LogError(backend, e);
633 return e.GetErrorCode();
640 int32_t metadataType)
643 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None);
647 backend->DeleteMetadata(
id, metadataType);
650 catch (std::runtime_error& e)
652 LogError(backend, e);
657 return e.GetErrorCode();
666 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None);
670 backend->DeleteResource(
id);
673 catch (std::runtime_error& e)
675 LogError(backend, e);
680 return e.GetErrorCode();
690 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None);
694 std::list<int64_t> target;
695 backend->GetAllInternalIds(target, resourceType);
697 for (std::list<int64_t>::const_iterator
698 it = target.begin(); it != target.end(); ++it)
700 OrthancPluginDatabaseAnswerInt64(backend->GetOutput().context_,
701 backend->GetOutput().database_, *it);
706 catch (std::runtime_error& e)
708 LogError(backend, e);
713 return e.GetErrorCode();
723 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None);
727 std::list<std::string> ids;
728 backend->GetAllPublicIds(ids, resourceType);
730 for (std::list<std::string>::const_iterator
731 it = ids.begin(); it != ids.end(); ++it)
733 OrthancPluginDatabaseAnswerString(backend->GetOutput().context_,
734 backend->GetOutput().database_,
740 catch (std::runtime_error& e)
742 LogError(backend, e);
747 return e.GetErrorCode();
759 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None);
763 std::list<std::string> ids;
764 backend->GetAllPublicIds(ids, resourceType, since, limit);
766 for (std::list<std::string>::const_iterator
767 it = ids.begin(); it != ids.end(); ++it)
769 OrthancPluginDatabaseAnswerString(backend->GetOutput().context_,
770 backend->GetOutput().database_,
776 catch (std::runtime_error& e)
778 LogError(backend, e);
783 return e.GetErrorCode();
794 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_Change);
799 backend->GetChanges(done, since, maxResult);
803 OrthancPluginDatabaseAnswerChangesDone(backend->GetOutput().context_,
804 backend->GetOutput().database_);
809 catch (std::runtime_error& e)
811 LogError(backend, e);
816 return e.GetErrorCode();
826 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None);
830 std::list<int64_t> target;
831 backend->GetChildrenInternalId(target,
id);
833 for (std::list<int64_t>::const_iterator
834 it = target.begin(); it != target.end(); ++it)
836 OrthancPluginDatabaseAnswerInt64(backend->GetOutput().context_,
837 backend->GetOutput().database_, *it);
842 catch (std::runtime_error& e)
844 LogError(backend, e);
849 return e.GetErrorCode();
859 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None);
863 std::list<std::string> ids;
864 backend->GetChildrenPublicId(ids,
id);
866 for (std::list<std::string>::const_iterator
867 it = ids.begin(); it != ids.end(); ++it)
869 OrthancPluginDatabaseAnswerString(backend->GetOutput().context_,
870 backend->GetOutput().database_,
876 catch (std::runtime_error& e)
878 LogError(backend, e);
883 return e.GetErrorCode();
894 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_ExportedResource);
899 backend->GetExportedResources(done, since, maxResult);
903 OrthancPluginDatabaseAnswerExportedResourcesDone(backend->GetOutput().context_,
904 backend->GetOutput().database_);
908 catch (std::runtime_error& e)
910 LogError(backend, e);
915 return e.GetErrorCode();
924 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_Change);
928 backend->GetLastChange();
931 catch (std::runtime_error& e)
933 LogError(backend, e);
938 return e.GetErrorCode();
947 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_ExportedResource);
951 backend->GetLastExportedResource();
954 catch (std::runtime_error& e)
956 LogError(backend, e);
961 return e.GetErrorCode();
971 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_DicomTag);
975 backend->GetMainDicomTags(
id);
978 catch (std::runtime_error& e)
980 LogError(backend, e);
985 return e.GetErrorCode();
995 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None);
999 std::string s = backend->GetPublicId(
id);
1000 OrthancPluginDatabaseAnswerString(backend->GetOutput().context_,
1001 backend->GetOutput().database_,
1006 catch (std::runtime_error& e)
1008 LogError(backend, e);
1013 return e.GetErrorCode();
1023 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None);
1027 *target = backend->GetResourceCount(resourceType);
1030 catch (std::runtime_error& e)
1032 LogError(backend, e);
1037 return e.GetErrorCode();
1047 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None);
1051 *resourceType = backend->GetResourceType(
id);
1054 catch (std::runtime_error& e)
1056 LogError(backend, e);
1061 return e.GetErrorCode();
1070 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None);
1074 *target = backend->GetTotalCompressedSize();
1077 catch (std::runtime_error& e)
1079 LogError(backend, e);
1084 return e.GetErrorCode();
1093 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None);
1097 *target = backend->GetTotalUncompressedSize();
1100 catch (std::runtime_error& e)
1102 LogError(backend, e);
1107 return e.GetErrorCode();
1117 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None);
1121 *existing = backend->IsExistingResource(
id);
1124 catch (std::runtime_error& e)
1126 LogError(backend, e);
1131 return e.GetErrorCode();
1141 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None);
1145 *isProtected = backend->IsProtectedPatient(
id);
1148 catch (std::runtime_error& e)
1150 LogError(backend, e);
1155 return e.GetErrorCode();
1165 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None);
1169 std::list<int32_t> target;
1170 backend->ListAvailableMetadata(target,
id);
1172 for (std::list<int32_t>::const_iterator
1173 it = target.begin(); it != target.end(); ++it)
1175 OrthancPluginDatabaseAnswerInt32(backend->GetOutput().context_,
1176 backend->GetOutput().database_,
1182 catch (std::runtime_error& e)
1184 LogError(backend, e);
1189 return e.GetErrorCode();
1199 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None);
1203 std::list<int32_t> target;
1204 backend->ListAvailableAttachments(target,
id);
1206 for (std::list<int32_t>::const_iterator
1207 it = target.begin(); it != target.end(); ++it)
1209 OrthancPluginDatabaseAnswerInt32(backend->GetOutput().context_,
1210 backend->GetOutput().database_,
1216 catch (std::runtime_error& e)
1218 LogError(backend, e);
1223 return e.GetErrorCode();
1229 const OrthancPluginChange* change)
1232 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None);
1236 backend->LogChange(*change);
1239 catch (std::runtime_error& e)
1241 LogError(backend, e);
1246 return e.GetErrorCode();
1252 const OrthancPluginExportedResource* exported)
1255 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None);
1259 backend->LogExportedResource(*exported);
1262 catch (std::runtime_error& e)
1264 LogError(backend, e);
1269 return e.GetErrorCode();
1277 int32_t contentType)
1280 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_Attachment);
1284 backend->LookupAttachment(
id, contentType);
1287 catch (std::runtime_error& e)
1289 LogError(backend, e);
1294 return e.GetErrorCode();
1304 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None);
1309 if (backend->LookupGlobalProperty(s, property))
1311 OrthancPluginDatabaseAnswerString(backend->GetOutput().context_,
1312 backend->GetOutput().database_,
1318 catch (std::runtime_error& e)
1320 LogError(backend, e);
1325 return e.GetErrorCode();
1333 const OrthancPluginDicomTag* tag,
1337 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None);
1341 std::list<int64_t> target;
1342 backend->LookupIdentifier(target, resourceType, tag->group, tag->element, constraint, tag->value);
1344 for (std::list<int64_t>::const_iterator
1345 it = target.begin(); it != target.end(); ++it)
1347 OrthancPluginDatabaseAnswerInt64(backend->GetOutput().context_,
1348 backend->GetOutput().database_, *it);
1353 catch (std::runtime_error& e)
1355 LogError(backend, e);
1360 return e.GetErrorCode();
1371 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None);
1376 if (backend->LookupMetadata(s,
id, metadata))
1378 OrthancPluginDatabaseAnswerString(backend->GetOutput().context_,
1379 backend->GetOutput().database_, s.c_str());
1384 catch (std::runtime_error& e)
1386 LogError(backend, e);
1391 return e.GetErrorCode();
1401 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None);
1406 if (backend->LookupParent(parent,
id))
1408 OrthancPluginDatabaseAnswerInt64(backend->GetOutput().context_,
1409 backend->GetOutput().database_, parent);
1414 catch (std::runtime_error& e)
1416 LogError(backend, e);
1421 return e.GetErrorCode();
1428 const char* publicId)
1431 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None);
1437 if (backend->LookupResource(
id, type, publicId))
1439 OrthancPluginDatabaseAnswerResource(backend->GetOutput().context_,
1440 backend->GetOutput().database_,
1446 catch (std::runtime_error& e)
1448 LogError(backend, e);
1453 return e.GetErrorCode();
1462 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None);
1467 if (backend->SelectPatientToRecycle(
id))
1469 OrthancPluginDatabaseAnswerInt64(backend->GetOutput().context_,
1470 backend->GetOutput().database_, id);
1475 catch (std::runtime_error& e)
1477 LogError(backend, e);
1482 return e.GetErrorCode();
1489 int64_t patientIdToAvoid)
1492 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None);
1497 if (backend->SelectPatientToRecycle(
id, patientIdToAvoid))
1499 OrthancPluginDatabaseAnswerInt64(backend->GetOutput().context_,
1500 backend->GetOutput().database_, id);
1505 catch (std::runtime_error& e)
1507 LogError(backend, e);
1512 return e.GetErrorCode();
1522 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None);
1526 backend->SetGlobalProperty(property, value);
1529 catch (std::runtime_error& e)
1531 LogError(backend, e);
1536 return e.GetErrorCode();
1543 const OrthancPluginDicomTag* tag)
1546 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None);
1550 backend->SetMainDicomTag(
id, tag->group, tag->element, tag->value);
1553 catch (std::runtime_error& e)
1555 LogError(backend, e);
1560 return e.GetErrorCode();
1567 const OrthancPluginDicomTag* tag)
1570 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None);
1574 backend->SetIdentifierTag(
id, tag->group, tag->element, tag->value);
1577 catch (std::runtime_error& e)
1579 LogError(backend, e);
1584 return e.GetErrorCode();
1595 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None);
1599 backend->SetMetadata(
id, metadata, value);
1602 catch (std::runtime_error& e)
1604 LogError(backend, e);
1609 return e.GetErrorCode();
1616 int32_t isProtected)
1619 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None);
1623 backend->SetProtectedPatient(
id, (isProtected != 0));
1626 catch (std::runtime_error& e)
1628 LogError(backend, e);
1633 return e.GetErrorCode();
1641 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None);
1645 backend->StartTransaction();
1648 catch (std::runtime_error& e)
1650 LogError(backend, e);
1655 return e.GetErrorCode();
1663 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None);
1667 backend->RollbackTransaction();
1670 catch (std::runtime_error& e)
1672 LogError(backend, e);
1677 return e.GetErrorCode();
1685 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None);
1689 backend->CommitTransaction();
1692 catch (std::runtime_error& e)
1694 LogError(backend, e);
1699 return e.GetErrorCode();
1707 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None);
1714 catch (std::runtime_error& e)
1716 LogError(backend, e);
1721 return e.GetErrorCode();
1729 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None);
1736 catch (std::runtime_error& e)
1738 LogError(backend, e);
1743 return e.GetErrorCode();
1755 *version = backend->GetDatabaseVersion();
1758 catch (std::runtime_error& e)
1760 LogError(backend, e);
1765 return e.GetErrorCode();
1771 uint32_t targetVersion,
1781 catch (std::runtime_error& e)
1783 LogError(backend, e);
1788 return e.GetErrorCode();
1800 backend->ClearMainDicomTags(internalId);
1803 catch (std::runtime_error& e)
1805 LogError(backend, e);
1810 return e.GetErrorCode();
1826 OrthancPluginDatabaseBackend params;
1827 memset(¶ms, 0,
sizeof(params));
1829 OrthancPluginDatabaseExtensions extensions;
1830 memset(&extensions, 0,
sizeof(extensions));
1832 params.addAttachment = AddAttachment;
1833 params.attachChild = AttachChild;
1834 params.clearChanges = ClearChanges;
1835 params.clearExportedResources = ClearExportedResources;
1836 params.createResource = CreateResource;
1837 params.deleteAttachment = DeleteAttachment;
1838 params.deleteMetadata = DeleteMetadata;
1839 params.deleteResource = DeleteResource;
1840 params.getAllPublicIds = GetAllPublicIds;
1841 params.getChanges = GetChanges;
1842 params.getChildrenInternalId = GetChildrenInternalId;
1843 params.getChildrenPublicId = GetChildrenPublicId;
1844 params.getExportedResources = GetExportedResources;
1845 params.getLastChange = GetLastChange;
1846 params.getLastExportedResource = GetLastExportedResource;
1847 params.getMainDicomTags = GetMainDicomTags;
1848 params.getPublicId = GetPublicId;
1849 params.getResourceCount = GetResourceCount;
1850 params.getResourceType = GetResourceType;
1851 params.getTotalCompressedSize = GetTotalCompressedSize;
1852 params.getTotalUncompressedSize = GetTotalUncompressedSize;
1853 params.isExistingResource = IsExistingResource;
1854 params.isProtectedPatient = IsProtectedPatient;
1855 params.listAvailableMetadata = ListAvailableMetadata;
1856 params.listAvailableAttachments = ListAvailableAttachments;
1857 params.logChange = LogChange;
1858 params.logExportedResource = LogExportedResource;
1859 params.lookupAttachment = LookupAttachment;
1860 params.lookupGlobalProperty = LookupGlobalProperty;
1861 params.lookupIdentifier = NULL;
1862 params.lookupIdentifier2 = NULL;
1863 params.lookupMetadata = LookupMetadata;
1864 params.lookupParent = LookupParent;
1865 params.lookupResource = LookupResource;
1866 params.selectPatientToRecycle = SelectPatientToRecycle;
1867 params.selectPatientToRecycle2 = SelectPatientToRecycle2;
1868 params.setGlobalProperty = SetGlobalProperty;
1869 params.setMainDicomTag = SetMainDicomTag;
1870 params.setIdentifierTag = SetIdentifierTag;
1871 params.setMetadata = SetMetadata;
1872 params.setProtectedPatient = SetProtectedPatient;
1873 params.startTransaction = StartTransaction;
1874 params.rollbackTransaction = RollbackTransaction;
1875 params.commitTransaction = CommitTransaction;
1877 params.close = Close;
1879 extensions.getAllPublicIdsWithLimit = GetAllPublicIdsWithLimit;
1880 extensions.getDatabaseVersion = GetDatabaseVersion;
1881 extensions.upgradeDatabase = UpgradeDatabase;
1882 extensions.clearMainDicomTags = ClearMainDicomTags;
1883 extensions.getAllInternalIds = GetAllInternalIds;
1884 extensions.lookupIdentifier3 = LookupIdentifier3;
1889 throw std::runtime_error(
"Unable to register the database backend");
struct _OrthancPluginStorageArea_t OrthancPluginStorageArea
Opaque structure that represents the storage area that is actually used by Orthanc.
Definition: OrthancCPlugin.h:805
virtual void UpgradeDatabase(uint32_t targetVersion, OrthancPluginStorageArea *storageArea)=0
static void Register(OrthancPluginContext *context, IDatabaseBackend &backend)
Definition: OrthancCppDatabasePlugin.h:1823
Definition: OrthancCppDatabasePlugin.h:42
Definition: OrthancCppDatabasePlugin.h:68
Bridge between C and C++ database engines.
Definition: OrthancCppDatabasePlugin.h:482
Definition: OrthancCppDatabasePlugin.h:92
struct _OrthancPluginDatabaseContext_t OrthancPluginDatabaseContext
Definition: OrthancCDatabasePlugin.h:55
OrthancPluginDatabaseContext * OrthancPluginRegisterDatabaseBackendV2(OrthancPluginContext *context, const OrthancPluginDatabaseBackend *backend, const OrthancPluginDatabaseExtensions *extensions, void *payload)
Definition: OrthancCDatabasePlugin.h:768
Definition: OrthancCppDatabasePlugin.h:278