Mercurial > hg > orthanc
diff OrthancServer/ServerIndex.cpp @ 306:326d5a4a5af3
modification of instances
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 20 Dec 2012 16:44:50 +0100 |
parents | 4eea080e6e7a |
children | 6ab6cdeedf4e |
line wrap: on
line diff
--- a/OrthancServer/ServerIndex.cpp Thu Dec 20 13:01:46 2012 +0100 +++ b/OrthancServer/ServerIndex.cpp Thu Dec 20 16:44:50 2012 +0100 @@ -1012,4 +1012,61 @@ } } + + void ServerIndex::SetMetadata(const std::string& publicId, + MetadataType type, + const std::string& value) + { + boost::mutex::scoped_lock lock(mutex_); + + ResourceType rtype; + int64_t id; + if (!db_->LookupResource(publicId, id, rtype)) + { + throw OrthancException(ErrorCode_UnknownResource); + } + + db_->SetMetadata(id, type, value); + } + + bool ServerIndex::LookupMetadata(std::string& target, + const std::string& publicId, + MetadataType type) + { + boost::mutex::scoped_lock lock(mutex_); + + ResourceType rtype; + int64_t id; + if (!db_->LookupResource(publicId, id, rtype)) + { + throw OrthancException(ErrorCode_UnknownResource); + } + + return db_->LookupMetadata(target, id, type); + } + + + bool ServerIndex::LookupParent(std::string& target, + const std::string& publicId) + { + boost::mutex::scoped_lock lock(mutex_); + + ResourceType type; + int64_t id; + if (!db_->LookupResource(publicId, id, type)) + { + throw OrthancException(ErrorCode_UnknownResource); + } + + int64_t parentId; + if (db_->LookupParent(parentId, id)) + { + target = db_->GetPublicId(parentId); + return true; + } + else + { + return false; + } + } }