Mercurial > hg > orthanc-databases
diff PostgreSQL/Plugins/StoragePlugin.cpp @ 14:9774802fd05f
PostgreSQLStorageArea working
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 09 Jul 2018 20:28:27 +0200 |
parents | 41543239072d |
children | 9e419261f1c9 |
line wrap: on
line diff
--- a/PostgreSQL/Plugins/StoragePlugin.cpp Mon Jul 09 18:42:34 2018 +0200 +++ b/PostgreSQL/Plugins/StoragePlugin.cpp Mon Jul 09 20:28:27 2018 +0200 @@ -145,6 +145,33 @@ const std::string& uuid, OrthancPluginContentType type) { + DatabaseManager::CachedStatement statement( + STATEMENT_FROM_HERE, GetManager(), + "SELECT content FROM StorageArea WHERE uuid=$1 AND type=$2"); + + statement.SetParameterType("uuid", ValueType_Utf8String); + statement.SetParameterType("type", ValueType_Integer64); + + Dictionary args; + args.SetUtf8Value("uuid", uuid); + args.SetIntegerValue("type", type); + + statement.Execute(args); + + if (statement.IsDone()) + { + throw Orthanc::OrthancException(Orthanc::ErrorCode_UnknownResource); + } + else if (statement.GetResultFieldsCount() != 1 || + statement.GetResultField(0).GetType() != ValueType_File) + { + throw Orthanc::OrthancException(Orthanc::ErrorCode_Database); + } + else + { + const FileValue& value = dynamic_cast<const FileValue&>(statement.GetResultField(0)); + ReadFromString(content, size, value.GetContent()); + } }