Mercurial > hg > orthanc-databases
comparison 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 |
comparison
equal
deleted
inserted
replaced
13:927264a0c137 | 14:9774802fd05f |
---|---|
143 size_t& size, | 143 size_t& size, |
144 DatabaseManager::Transaction& transaction, | 144 DatabaseManager::Transaction& transaction, |
145 const std::string& uuid, | 145 const std::string& uuid, |
146 OrthancPluginContentType type) | 146 OrthancPluginContentType type) |
147 { | 147 { |
148 DatabaseManager::CachedStatement statement( | |
149 STATEMENT_FROM_HERE, GetManager(), | |
150 "SELECT content FROM StorageArea WHERE uuid=$1 AND type=$2"); | |
151 | |
152 statement.SetParameterType("uuid", ValueType_Utf8String); | |
153 statement.SetParameterType("type", ValueType_Integer64); | |
154 | |
155 Dictionary args; | |
156 args.SetUtf8Value("uuid", uuid); | |
157 args.SetIntegerValue("type", type); | |
158 | |
159 statement.Execute(args); | |
160 | |
161 if (statement.IsDone()) | |
162 { | |
163 throw Orthanc::OrthancException(Orthanc::ErrorCode_UnknownResource); | |
164 } | |
165 else if (statement.GetResultFieldsCount() != 1 || | |
166 statement.GetResultField(0).GetType() != ValueType_File) | |
167 { | |
168 throw Orthanc::OrthancException(Orthanc::ErrorCode_Database); | |
169 } | |
170 else | |
171 { | |
172 const FileValue& value = dynamic_cast<const FileValue&>(statement.GetResultField(0)); | |
173 ReadFromString(content, size, value.GetContent()); | |
174 } | |
148 } | 175 } |
149 | 176 |
150 | 177 |
151 virtual void Remove(DatabaseManager::Transaction& transaction, | 178 virtual void Remove(DatabaseManager::Transaction& transaction, |
152 const std::string& uuid, | 179 const std::string& uuid, |