comparison OrthancServer/Plugins/Engine/OrthancPluginDatabaseV4.cpp @ 5220:df39c7583a49 db-protobuf

preparing virtual methods for labels
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 03 Apr 2023 18:09:04 +0200
parents 450ac804d3af
children d0f7c742d397
comparison
equal deleted inserted replaced
5218:afa96af2eb5a 5220:df39c7583a49
913 913
914 virtual void ApplyLookupResources(std::list<std::string>& resourcesId, 914 virtual void ApplyLookupResources(std::list<std::string>& resourcesId,
915 std::list<std::string>* instancesId, // Can be NULL if not needed 915 std::list<std::string>* instancesId, // Can be NULL if not needed
916 const std::vector<DatabaseConstraint>& lookup, 916 const std::vector<DatabaseConstraint>& lookup,
917 ResourceType queryLevel, 917 ResourceType queryLevel,
918 const std::set<std::string>& withLabels,
919 const std::set<std::string>& withoutLabels,
918 uint32_t limit) ORTHANC_OVERRIDE 920 uint32_t limit) ORTHANC_OVERRIDE
919 { 921 {
922 if (!database_.HasLabelsSupport() &&
923 (!withLabels.empty() ||
924 !withoutLabels.empty()))
925 {
926 throw OrthancException(ErrorCode_InternalError);
927 }
928
920 DatabasePluginMessages::TransactionRequest request; 929 DatabasePluginMessages::TransactionRequest request;
921 request.mutable_lookup_resources()->set_query_level(Convert(queryLevel)); 930 request.mutable_lookup_resources()->set_query_level(Convert(queryLevel));
922 request.mutable_lookup_resources()->set_limit(limit); 931 request.mutable_lookup_resources()->set_limit(limit);
923 request.mutable_lookup_resources()->set_retrieve_instances_ids(instancesId != NULL); 932 request.mutable_lookup_resources()->set_retrieve_instances_ids(instancesId != NULL);
924 933
963 break; 972 break;
964 973
965 default: 974 default:
966 throw OrthancException(ErrorCode_ParameterOutOfRange); 975 throw OrthancException(ErrorCode_ParameterOutOfRange);
967 } 976 }
977 }
978
979 if (!withLabels.empty() ||
980 !withoutLabels.empty())
981 {
982 throw OrthancException(ErrorCode_NotImplemented); // TODO
968 } 983 }
969 984
970 DatabasePluginMessages::TransactionResponse response; 985 DatabasePluginMessages::TransactionResponse response;
971 ExecuteTransaction(response, DatabasePluginMessages::OPERATION_LOOKUP_RESOURCES, request); 986 ExecuteTransaction(response, DatabasePluginMessages::OPERATION_LOOKUP_RESOURCES, request);
972 987
1130 else 1145 else
1131 { 1146 {
1132 return false; 1147 return false;
1133 } 1148 }
1134 } 1149 }
1150
1151
1152 virtual void AddLabel(int64_t resource,
1153 const std::string& label) ORTHANC_OVERRIDE
1154 {
1155 throw OrthancException(ErrorCode_NotImplemented);
1156 }
1157
1158
1159 virtual void RemoveLabel(int64_t resource,
1160 const std::string& label) ORTHANC_OVERRIDE
1161 {
1162 throw OrthancException(ErrorCode_NotImplemented);
1163 }
1164
1165
1166 virtual void GetLabels(std::set<std::string>& target,
1167 int64_t resource) ORTHANC_OVERRIDE
1168 {
1169 throw OrthancException(ErrorCode_NotImplemented);
1170 }
1135 }; 1171 };
1136 1172
1137 1173
1138 OrthancPluginDatabaseV4::OrthancPluginDatabaseV4(SharedLibrary& library, 1174 OrthancPluginDatabaseV4::OrthancPluginDatabaseV4(SharedLibrary& library,
1139 PluginsErrorDictionary& errorDictionary, 1175 PluginsErrorDictionary& errorDictionary,
1144 definition_(database), 1180 definition_(database),
1145 serverIdentifier_(serverIdentifier), 1181 serverIdentifier_(serverIdentifier),
1146 open_(false), 1182 open_(false),
1147 databaseVersion_(0), 1183 databaseVersion_(0),
1148 hasFlushToDisk_(false), 1184 hasFlushToDisk_(false),
1149 hasRevisionsSupport_(false) 1185 hasRevisionsSupport_(false),
1186 hasLabelsSupport_(false)
1150 { 1187 {
1151 CLOG(INFO, PLUGINS) << "Identifier of this Orthanc server for the global properties " 1188 CLOG(INFO, PLUGINS) << "Identifier of this Orthanc server for the global properties "
1152 << "of the custom database: \"" << serverIdentifier << "\""; 1189 << "of the custom database: \"" << serverIdentifier << "\"";
1153 1190
1154 if (definition_.backend == NULL || 1191 if (definition_.backend == NULL ||
1184 DatabasePluginMessages::DatabaseResponse response; 1221 DatabasePluginMessages::DatabaseResponse response;
1185 ExecuteDatabase(response, *this, DatabasePluginMessages::OPERATION_GET_SYSTEM_INFORMATION, request); 1222 ExecuteDatabase(response, *this, DatabasePluginMessages::OPERATION_GET_SYSTEM_INFORMATION, request);
1186 databaseVersion_ = response.get_system_information().database_version(); 1223 databaseVersion_ = response.get_system_information().database_version();
1187 hasFlushToDisk_ = response.get_system_information().supports_flush_to_disk(); 1224 hasFlushToDisk_ = response.get_system_information().supports_flush_to_disk();
1188 hasRevisionsSupport_ = response.get_system_information().supports_revisions(); 1225 hasRevisionsSupport_ = response.get_system_information().supports_revisions();
1226 hasLabelsSupport_ = response.get_system_information().supports_labels();
1189 } 1227 }
1190 1228
1191 open_ = true; 1229 open_ = true;
1192 } 1230 }
1193 1231
1305 else 1343 else
1306 { 1344 {
1307 return hasRevisionsSupport_; 1345 return hasRevisionsSupport_;
1308 } 1346 }
1309 } 1347 }
1348
1349
1350 bool OrthancPluginDatabaseV4::HasLabelsSupport() const
1351 {
1352 if (!open_)
1353 {
1354 throw OrthancException(ErrorCode_BadSequenceOfCalls);
1355 }
1356 else
1357 {
1358 return hasLabelsSupport_;
1359 }
1360 }
1310 } 1361 }