Mercurial > hg > orthanc
changeset 5238:367e8af46cfd db-protobuf
added "HasLabels" in /system
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 05 Apr 2023 10:02:19 +0200 |
parents | cd2258ca7894 |
children | 178b0434256a |
files | NEWS OrthancServer/Sources/Database/StatelessDatabaseOperations.cpp OrthancServer/Sources/Database/StatelessDatabaseOperations.h OrthancServer/Sources/OrthancRestApi/OrthancRestSystem.cpp |
diffstat | 4 files changed, 21 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/NEWS Wed Apr 05 09:07:47 2023 +0200 +++ b/NEWS Wed Apr 05 10:02:19 2023 +0200 @@ -12,9 +12,9 @@ * API version upgraded to 20 * New URIs "/.../{id}/labels/{label}" to test/set/remove labels * "/tools/find" accepts the "WithLabels" and "WithoutLabels" arguments -* The "/patients/{id}", "/studies/{id}", "/series/{id}" and "/instances/{id}" +* "/patients/{id}", "/studies/{id}", "/series/{id}" and "/instances/{id}" contain the "Labels" field -* "/system": added "UserMetadata" +* "/system": added "UserMetadata" and "HasLabels" Plugins -------
--- a/OrthancServer/Sources/Database/StatelessDatabaseOperations.cpp Wed Apr 05 09:07:47 2023 +0200 +++ b/OrthancServer/Sources/Database/StatelessDatabaseOperations.cpp Wed Apr 05 10:02:19 2023 +0200 @@ -1961,6 +1961,11 @@ } }; + if ((!withLabels.empty() || !withoutLabels.empty()) && + !db_.HasLabelsSupport()) + { + throw OrthancException(ErrorCode_NotImplemented, "The database backend doesn't support labels"); + } std::vector<DatabaseConstraint> normalized; NormalizeLookup(normalized, lookup, queryLevel); @@ -3630,4 +3635,11 @@ Operations operations(publicId, level, label, operation); Apply(operations); } + + + bool StatelessDatabaseOperations::HasLabelsSupport() + { + boost::shared_lock<boost::shared_mutex> lock(mutex_); + return db_.HasLabelsSupport(); + } }
--- a/OrthancServer/Sources/Database/StatelessDatabaseOperations.h Wed Apr 05 09:07:47 2023 +0200 +++ b/OrthancServer/Sources/Database/StatelessDatabaseOperations.h Wed Apr 05 10:02:19 2023 +0200 @@ -765,5 +765,7 @@ ResourceType level, const std::string& label, LabelOperation operation); + + bool HasLabelsSupport(); }; }
--- a/OrthancServer/Sources/OrthancRestApi/OrthancRestSystem.cpp Wed Apr 05 09:07:47 2023 +0200 +++ b/OrthancServer/Sources/OrthancRestApi/OrthancRestSystem.cpp Wed Apr 05 10:02:19 2023 +0200 @@ -89,6 +89,7 @@ static const char* const MAXIMUM_STORAGE_SIZE = "MaximumStorageSize"; static const char* const MAXIMUM_STORAGE_MODE = "MaximumStorageMode"; static const char* const USER_METADATA = "UserMetadata"; + static const char* const HAS_LABELS = "HasLabels"; if (call.IsDocumentation()) { @@ -131,6 +132,8 @@ "The configured MaximumStorageMode (new in Orthanc 1.11.3)") .SetAnswerField(USER_METADATA, RestApiCallDocumentation::Type_JsonObject, "The configured UserMetadata (new in Orthanc 1.12.0)") + .SetAnswerField(HAS_LABELS, RestApiCallDocumentation::Type_Boolean, + "Whether the database back-end supports labels (new in Orthanc 1.12.0)") .SetHttpGetSample("https://demo.orthanc-server.com/system", true); return; } @@ -187,6 +190,8 @@ result[USER_METADATA] = Json::objectValue; GetUserMetadataConfiguration(result[USER_METADATA]); + result[HAS_LABELS] = OrthancRestApi::GetIndex(call).HasLabelsSupport(); + call.GetOutput().AnswerJson(result); }