Mercurial > hg > orthanc
comparison OrthancServer/ServerIndex.cpp @ 3082:847a0ed92654 db-changes
new extension for database plugin SDK: createInstance
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 04 Jan 2019 13:52:34 +0100 |
parents | 1a75595d8e44 |
children | 683d572424b6 |
comparison
equal
deleted
inserted
replaced
3081:2e5970ddcfeb | 3082:847a0ed92654 |
---|---|
718 IDatabaseWrapper::CreateInstanceResult status; | 718 IDatabaseWrapper::CreateInstanceResult status; |
719 int64_t instanceId; | 719 int64_t instanceId; |
720 | 720 |
721 // Check whether this instance is already stored | 721 // Check whether this instance is already stored |
722 if (!db_.CreateInstance(status, instanceId, hashPatient, | 722 if (!db_.CreateInstance(status, instanceId, hashPatient, |
723 hashStudy, hashSeries, hashInstance, overwrite_)) | 723 hashStudy, hashSeries, hashInstance)) |
724 { | 724 { |
725 // Do nothing if the instance already exists and overwriting is disabled | 725 // The instance already exists |
726 db_.GetAllMetadata(instanceMetadata, instanceId); | 726 |
727 return StoreStatus_AlreadyStored; | 727 if (overwrite_) |
728 { | |
729 // Overwrite the old instance | |
730 LOG(INFO) << "Overwriting instance: " << hashInstance; | |
731 db_.DeleteResource(instanceId); | |
732 | |
733 // Re-create the instance, now that the old one is removed | |
734 if (!db_.CreateInstance(status, instanceId, hashPatient, | |
735 hashStudy, hashSeries, hashInstance)) | |
736 { | |
737 throw OrthancException(ErrorCode_InternalError); | |
738 } | |
739 } | |
740 else | |
741 { | |
742 // Do nothing if the instance already exists and overwriting is disabled | |
743 db_.GetAllMetadata(instanceMetadata, instanceId); | |
744 return StoreStatus_AlreadyStored; | |
745 } | |
728 } | 746 } |
729 | 747 |
730 | 748 |
731 // Warn about the creation of new resources. The order must be from instance to patient. | 749 // Warn about the creation of new resources. The order must be from instance to patient. |
732 SignalNewResource(ChangeType_NewInstance, ResourceType_Instance, hashInstance, instanceId); | 750 SignalNewResource(ChangeType_NewInstance, ResourceType_Instance, hashInstance, instanceId); |