Mercurial > hg > orthanc
changeset 2188:7cfc2e0383b3
refactoring
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 29 Nov 2016 15:39:46 +0100 |
parents | ad72fbd700b7 |
children | c4b3259c8bce |
files | OrthancServer/ServerIndex.cpp OrthancServer/ServerIndex.h |
diffstat | 2 files changed, 21 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/OrthancServer/ServerIndex.cpp Tue Nov 29 12:28:09 2016 +0100 +++ b/OrthancServer/ServerIndex.cpp Tue Nov 29 15:39:46 2016 +0100 @@ -591,6 +591,17 @@ + void ServerIndex::SetInstanceMetadata(std::map<MetadataType, std::string>& instanceMetadata, + int64_t instance, + MetadataType metadata, + const std::string& value) + { + db_.SetMetadata(instance, metadata, value); + instanceMetadata[metadata] = value; + } + + + StoreStatus ServerIndex::Store(std::map<MetadataType, std::string>& instanceMetadata, DicomInstanceToStore& instanceToStore, const Attachments& attachments) @@ -746,8 +757,7 @@ break; case ResourceType_Instance: - db_.SetMetadata(instance, it->first.second, it->second); - instanceMetadata[it->first.second] = it->second; + SetInstanceMetadata(instanceMetadata, instance, it->first.second, it->second); break; default: @@ -763,16 +773,12 @@ // Attach the auto-computed metadata for the instance level, // reflecting these additions into the input metadata map - db_.SetMetadata(instance, MetadataType_Instance_ReceptionDate, now); - instanceMetadata[MetadataType_Instance_ReceptionDate] = now; - - db_.SetMetadata(instance, MetadataType_Instance_RemoteAet, instanceToStore.GetRemoteAet()); - instanceMetadata[MetadataType_Instance_RemoteAet] = instanceToStore.GetRemoteAet(); + SetInstanceMetadata(instanceMetadata, instance, MetadataType_Instance_ReceptionDate, now); + SetInstanceMetadata(instanceMetadata, instance, MetadataType_Instance_RemoteAet, instanceToStore.GetRemoteAet()); { std::string s = EnumerationToString(instanceToStore.GetRequestOrigin()); - db_.SetMetadata(instance, MetadataType_Instance_Origin, s); - instanceMetadata[MetadataType_Instance_Origin] = s; + SetInstanceMetadata(instanceMetadata, instance, MetadataType_Instance_Origin, s); } const DicomValue* value; @@ -782,8 +788,7 @@ if (!value->IsNull() && !value->IsBinary()) { - db_.SetMetadata(instance, MetadataType_Instance_IndexInSeries, value->GetContent()); - instanceMetadata[MetadataType_Instance_IndexInSeries] = value->GetContent(); + SetInstanceMetadata(instanceMetadata, instance, MetadataType_Instance_IndexInSeries, value->GetContent()); } }
--- a/OrthancServer/ServerIndex.h Tue Nov 29 12:28:09 2016 +0100 +++ b/OrthancServer/ServerIndex.h Tue Nov 29 15:39:46 2016 +0100 @@ -115,6 +115,11 @@ int64_t CreateResource(const std::string& publicId, ResourceType type); + void SetInstanceMetadata(std::map<MetadataType, std::string>& instanceMetadata, + int64_t instance, + MetadataType metadata, + const std::string& value); + public: ServerIndex(ServerContext& context, IDatabaseWrapper& database);