Mercurial > hg > orthanc
comparison 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 |
comparison
equal
deleted
inserted
replaced
305:86bb79522f19 | 306:326d5a4a5af3 |
---|---|
1010 } | 1010 } |
1011 } | 1011 } |
1012 } | 1012 } |
1013 } | 1013 } |
1014 | 1014 |
1015 | |
1016 void ServerIndex::SetMetadata(const std::string& publicId, | |
1017 MetadataType type, | |
1018 const std::string& value) | |
1019 { | |
1020 boost::mutex::scoped_lock lock(mutex_); | |
1021 | |
1022 ResourceType rtype; | |
1023 int64_t id; | |
1024 if (!db_->LookupResource(publicId, id, rtype)) | |
1025 { | |
1026 throw OrthancException(ErrorCode_UnknownResource); | |
1027 } | |
1028 | |
1029 db_->SetMetadata(id, type, value); | |
1030 } | |
1031 | |
1032 bool ServerIndex::LookupMetadata(std::string& target, | |
1033 const std::string& publicId, | |
1034 MetadataType type) | |
1035 { | |
1036 boost::mutex::scoped_lock lock(mutex_); | |
1037 | |
1038 ResourceType rtype; | |
1039 int64_t id; | |
1040 if (!db_->LookupResource(publicId, id, rtype)) | |
1041 { | |
1042 throw OrthancException(ErrorCode_UnknownResource); | |
1043 } | |
1044 | |
1045 return db_->LookupMetadata(target, id, type); | |
1046 } | |
1047 | |
1048 | |
1049 bool ServerIndex::LookupParent(std::string& target, | |
1050 const std::string& publicId) | |
1051 { | |
1052 boost::mutex::scoped_lock lock(mutex_); | |
1053 | |
1054 ResourceType type; | |
1055 int64_t id; | |
1056 if (!db_->LookupResource(publicId, id, type)) | |
1057 { | |
1058 throw OrthancException(ErrorCode_UnknownResource); | |
1059 } | |
1060 | |
1061 int64_t parentId; | |
1062 if (db_->LookupParent(parentId, id)) | |
1063 { | |
1064 target = db_->GetPublicId(parentId); | |
1065 return true; | |
1066 } | |
1067 else | |
1068 { | |
1069 return false; | |
1070 } | |
1071 } | |
1015 } | 1072 } |