# HG changeset patch # User Sebastien Jodogne # Date 1480430386 -3600 # Node ID 7cfc2e0383b3f3c8b7d0848e6f392573977abccd # Parent ad72fbd700b7f2d19428ab5ab3d9324aabcb1059 refactoring diff -r ad72fbd700b7 -r 7cfc2e0383b3 OrthancServer/ServerIndex.cpp --- 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& instanceMetadata, + int64_t instance, + MetadataType metadata, + const std::string& value) + { + db_.SetMetadata(instance, metadata, value); + instanceMetadata[metadata] = value; + } + + + StoreStatus ServerIndex::Store(std::map& 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()); } } diff -r ad72fbd700b7 -r 7cfc2e0383b3 OrthancServer/ServerIndex.h --- 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& instanceMetadata, + int64_t instance, + MetadataType metadata, + const std::string& value); + public: ServerIndex(ServerContext& context, IDatabaseWrapper& database);