# HG changeset patch # User Sebastien Jodogne # Date 1725887968 -7200 # Node ID 1a23f1ce3b98d4fe887076172e5a19f32178270e # Parent e620f36b8e092bbd4c56df2b194b2ff15b808773 move classes DatabaseConstraint and ISqlLookupFormatter into namespace OrthancDatabases diff -r e620f36b8e09 -r 1a23f1ce3b98 Framework/Plugins/DatabaseBackendAdapterV2.cpp --- a/Framework/Plugins/DatabaseBackendAdapterV2.cpp Mon Sep 09 13:29:45 2024 +0200 +++ b/Framework/Plugins/DatabaseBackendAdapterV2.cpp Mon Sep 09 15:19:28 2024 +0200 @@ -1413,16 +1413,16 @@ { DatabaseBackendAdapterV2::Adapter::DatabaseAccessor accessor(*adapter); - Orthanc::DatabaseConstraints lookup; + DatabaseConstraints lookup; for (uint32_t i = 0; i < constraintsCount; i++) { - lookup.AddConstraint(new Orthanc::DatabaseConstraint(constraints[i])); + lookup.AddConstraint(new DatabaseConstraint(constraints[i])); } std::set noLabel; adapter->GetBackend().LookupResources(*output, accessor.GetManager(), lookup, queryLevel, noLabel, - Orthanc::LabelsConstraint_All, limit, (requestSomeInstance != 0)); + LabelsConstraint_All, limit, (requestSomeInstance != 0)); return OrthancPluginErrorCode_Success; } diff -r e620f36b8e09 -r 1a23f1ce3b98 Framework/Plugins/DatabaseBackendAdapterV3.cpp --- a/Framework/Plugins/DatabaseBackendAdapterV3.cpp Mon Sep 09 13:29:45 2024 +0200 +++ b/Framework/Plugins/DatabaseBackendAdapterV3.cpp Mon Sep 09 15:19:28 2024 +0200 @@ -1640,16 +1640,16 @@ { t->GetOutput().Clear(); - Orthanc::DatabaseConstraints lookup; + DatabaseConstraints lookup; for (uint32_t i = 0; i < constraintsCount; i++) { - lookup.AddConstraint(new Orthanc::DatabaseConstraint(constraints[i])); + lookup.AddConstraint(new DatabaseConstraint(constraints[i])); } std::set noLabel; t->GetBackend().LookupResources(t->GetOutput(), t->GetManager(), lookup, queryLevel, noLabel, - Orthanc::LabelsConstraint_All, limit, (requestSomeInstanceId != 0)); + LabelsConstraint_All, limit, (requestSomeInstanceId != 0)); return OrthancPluginErrorCode_Success; } ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext()); diff -r e620f36b8e09 -r 1a23f1ce3b98 Framework/Plugins/DatabaseBackendAdapterV4.cpp --- a/Framework/Plugins/DatabaseBackendAdapterV4.cpp Mon Sep 09 13:29:45 2024 +0200 +++ b/Framework/Plugins/DatabaseBackendAdapterV4.cpp Mon Sep 09 15:19:28 2024 +0200 @@ -555,7 +555,7 @@ std::vector values; values.reserve(countValues); - Orthanc::DatabaseConstraints lookup; + DatabaseConstraints lookup; for (int i = 0; i < request.lookup().size(); i++) { @@ -618,7 +618,7 @@ } } - lookup.AddConstraint(new Orthanc::DatabaseConstraint(c)); + lookup.AddConstraint(new DatabaseConstraint(c)); } assert(values.size() == countValues); @@ -630,19 +630,19 @@ labels.insert(request.labels(i)); } - Orthanc::LabelsConstraint labelsConstraint; + LabelsConstraint labelsConstraint; switch (request.labels_constraint()) { case Orthanc::DatabasePluginMessages::LABELS_CONSTRAINT_ALL: - labelsConstraint = Orthanc::LabelsConstraint_All; + labelsConstraint = LabelsConstraint_All; break; case Orthanc::DatabasePluginMessages::LABELS_CONSTRAINT_ANY: - labelsConstraint = Orthanc::LabelsConstraint_Any; + labelsConstraint = LabelsConstraint_Any; break; case Orthanc::DatabasePluginMessages::LABELS_CONSTRAINT_NONE: - labelsConstraint = Orthanc::LabelsConstraint_None; + labelsConstraint = LabelsConstraint_None; break; default: diff -r e620f36b8e09 -r 1a23f1ce3b98 Framework/Plugins/DatabaseConstraint.cpp --- a/Framework/Plugins/DatabaseConstraint.cpp Mon Sep 09 13:29:45 2024 +0200 +++ b/Framework/Plugins/DatabaseConstraint.cpp Mon Sep 09 15:19:28 2024 +0200 @@ -35,50 +35,50 @@ #include -namespace Orthanc +namespace OrthancDatabases { namespace Plugins { - OrthancPluginResourceType Convert(ResourceType type) + OrthancPluginResourceType Convert(Orthanc::ResourceType type) { switch (type) { - case ResourceType_Patient: + case Orthanc::ResourceType_Patient: return OrthancPluginResourceType_Patient; - case ResourceType_Study: + case Orthanc::ResourceType_Study: return OrthancPluginResourceType_Study; - case ResourceType_Series: + case Orthanc::ResourceType_Series: return OrthancPluginResourceType_Series; - case ResourceType_Instance: + case Orthanc::ResourceType_Instance: return OrthancPluginResourceType_Instance; default: - throw OrthancException(ErrorCode_ParameterOutOfRange); + throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); } } - ResourceType Convert(OrthancPluginResourceType type) + Orthanc::ResourceType Convert(OrthancPluginResourceType type) { switch (type) { case OrthancPluginResourceType_Patient: - return ResourceType_Patient; + return Orthanc::ResourceType_Patient; case OrthancPluginResourceType_Study: - return ResourceType_Study; + return Orthanc::ResourceType_Study; case OrthancPluginResourceType_Series: - return ResourceType_Series; + return Orthanc::ResourceType_Series; case OrthancPluginResourceType_Instance: - return ResourceType_Instance; + return Orthanc::ResourceType_Instance; default: - throw OrthancException(ErrorCode_ParameterOutOfRange); + throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); } } @@ -104,7 +104,7 @@ return OrthancPluginConstraintType_List; default: - throw OrthancException(ErrorCode_ParameterOutOfRange); + throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); } } #endif @@ -131,14 +131,14 @@ return ConstraintType_List; default: - throw OrthancException(ErrorCode_ParameterOutOfRange); + throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); } } #endif } - DatabaseConstraint::DatabaseConstraint(ResourceType level, - const DicomTag& tag, + DatabaseConstraint::DatabaseConstraint(Orthanc::ResourceType level, + const Orthanc::DicomTag& tag, bool isIdentifier, ConstraintType type, const std::vector& values, @@ -155,7 +155,7 @@ if (type != ConstraintType_List && values_.size() != 1) { - throw OrthancException(ErrorCode_ParameterOutOfRange); + throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); } } @@ -172,7 +172,7 @@ if (constraintType_ != ConstraintType_List && constraint.valuesCount != 1) { - throw OrthancException(ErrorCode_ParameterOutOfRange); + throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); } values_.resize(constraint.valuesCount); @@ -190,7 +190,7 @@ { if (index >= values_.size()) { - throw OrthancException(ErrorCode_ParameterOutOfRange); + throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); } else { @@ -203,7 +203,7 @@ { if (values_.size() != 1) { - throw OrthancException(ErrorCode_BadSequenceOfCalls); + throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); } else { @@ -254,7 +254,7 @@ { if (constraint == NULL) { - throw OrthancException(ErrorCode_NullPointer); + throw Orthanc::OrthancException(Orthanc::ErrorCode_NullPointer); } else { @@ -267,7 +267,7 @@ { if (index >= constraints_.size()) { - throw OrthancException(ErrorCode_ParameterOutOfRange); + throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); } else { diff -r e620f36b8e09 -r 1a23f1ce3b98 Framework/Plugins/DatabaseConstraint.h --- a/Framework/Plugins/DatabaseConstraint.h Mon Sep 09 13:29:45 2024 +0200 +++ b/Framework/Plugins/DatabaseConstraint.h Mon Sep 09 15:19:28 2024 +0200 @@ -45,7 +45,7 @@ #include -namespace Orthanc +namespace OrthancDatabases { enum ConstraintType { @@ -58,9 +58,9 @@ namespace Plugins { - OrthancPluginResourceType Convert(ResourceType type); + OrthancPluginResourceType Convert(Orthanc::ResourceType type); - ResourceType Convert(OrthancPluginResourceType type); + Orthanc::ResourceType Convert(OrthancPluginResourceType type); #if ORTHANC_PLUGINS_HAS_DATABASE_CONSTRAINT == 1 OrthancPluginConstraintType Convert(ConstraintType constraint); @@ -75,8 +75,8 @@ class DatabaseConstraint : public boost::noncopyable { private: - ResourceType level_; - DicomTag tag_; + Orthanc::ResourceType level_; + Orthanc::DicomTag tag_; bool isIdentifier_; ConstraintType constraintType_; std::vector values_; @@ -84,8 +84,8 @@ bool mandatory_; public: - DatabaseConstraint(ResourceType level, - const DicomTag& tag, + DatabaseConstraint(Orthanc::ResourceType level, + const Orthanc::DicomTag& tag, bool isIdentifier, ConstraintType type, const std::vector& values, @@ -96,12 +96,12 @@ explicit DatabaseConstraint(const OrthancPluginDatabaseConstraint& constraint); #endif - ResourceType GetLevel() const + Orthanc::ResourceType GetLevel() const { return level_; } - const DicomTag& GetTag() const + const Orthanc::DicomTag& GetTag() const { return tag_; } @@ -135,7 +135,7 @@ return mandatory_; } - bool IsMatch(const DicomMap& dicom) const; + bool IsMatch(const Orthanc::DicomMap& dicom) const; #if ORTHANC_PLUGINS_HAS_DATABASE_CONSTRAINT == 1 void EncodeForPlugins(OrthancPluginDatabaseConstraint& constraint, diff -r e620f36b8e09 -r 1a23f1ce3b98 Framework/Plugins/IDatabaseBackend.h --- a/Framework/Plugins/IDatabaseBackend.h Mon Sep 09 13:29:45 2024 +0200 +++ b/Framework/Plugins/IDatabaseBackend.h Mon Sep 09 15:19:28 2024 +0200 @@ -277,10 +277,10 @@ #if ORTHANC_PLUGINS_HAS_DATABASE_CONSTRAINT == 1 virtual void LookupResources(IDatabaseBackendOutput& output, DatabaseManager& manager, - const Orthanc::DatabaseConstraints& lookup, + const DatabaseConstraints& lookup, OrthancPluginResourceType queryLevel, - const std::set& labels, // New in Orthanc 1.12.0 - Orthanc::LabelsConstraint labelsConstraint, // New in Orthanc 1.12.0 + const std::set& labels, // New in Orthanc 1.12.0 + LabelsConstraint labelsConstraint, // New in Orthanc 1.12.0 uint32_t limit, bool requestSomeInstance) = 0; #endif diff -r e620f36b8e09 -r 1a23f1ce3b98 Framework/Plugins/ISqlLookupFormatter.cpp --- a/Framework/Plugins/ISqlLookupFormatter.cpp Mon Sep 09 13:29:45 2024 +0200 +++ b/Framework/Plugins/ISqlLookupFormatter.cpp Mon Sep 09 15:19:28 2024 +0200 @@ -40,26 +40,26 @@ #include -namespace Orthanc +namespace OrthancDatabases { - static std::string FormatLevel(ResourceType level) + static std::string FormatLevel(Orthanc::ResourceType level) { switch (level) { - case ResourceType_Patient: + case Orthanc::ResourceType_Patient: return "patients"; - case ResourceType_Study: + case Orthanc::ResourceType_Study: return "studies"; - case ResourceType_Series: + case Orthanc::ResourceType_Series: return "series"; - case ResourceType_Instance: + case Orthanc::ResourceType_Instance: return "instances"; default: - throw OrthancException(ErrorCode_InternalError); + throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError); } } @@ -96,7 +96,7 @@ break; default: - throw OrthancException(ErrorCode_InternalError); + throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError); } std::string parameter = formatter.GenerateParameter(constraint.GetSingleValue()); @@ -331,7 +331,7 @@ break; default: - throw OrthancException(ErrorCode_InternalError); + throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError); } std::string parameter = formatter.GenerateParameter(constraint.GetSingleValue()); @@ -366,7 +366,7 @@ } std::string values; - Toolbox::JoinStrings(values, comparisonValues, ", "); + Orthanc::Toolbox::JoinStrings(values, comparisonValues, ", "); if (constraint.IsCaseSensitive()) { @@ -469,21 +469,21 @@ } - void ISqlLookupFormatter::GetLookupLevels(ResourceType& lowerLevel, - ResourceType& upperLevel, - const ResourceType& queryLevel, + void ISqlLookupFormatter::GetLookupLevels(Orthanc::ResourceType& lowerLevel, + Orthanc::ResourceType& upperLevel, + const Orthanc::ResourceType& queryLevel, const DatabaseConstraints& lookup) { - assert(ResourceType_Patient < ResourceType_Study && - ResourceType_Study < ResourceType_Series && - ResourceType_Series < ResourceType_Instance); + assert(Orthanc::ResourceType_Patient < Orthanc::ResourceType_Study && + Orthanc::ResourceType_Study < Orthanc::ResourceType_Series && + Orthanc::ResourceType_Series < Orthanc::ResourceType_Instance); lowerLevel = queryLevel; upperLevel = queryLevel; for (size_t i = 0; i < lookup.GetSize(); i++) { - ResourceType level = lookup.GetConstraint(i).GetLevel(); + Orthanc::ResourceType level = lookup.GetConstraint(i).GetLevel(); if (level < upperLevel) { @@ -501,12 +501,12 @@ void ISqlLookupFormatter::Apply(std::string& sql, ISqlLookupFormatter& formatter, const DatabaseConstraints& lookup, - ResourceType queryLevel, + Orthanc::ResourceType queryLevel, const std::set& labels, LabelsConstraint labelsConstraint, size_t limit) { - ResourceType lowerLevel, upperLevel; + Orthanc::ResourceType lowerLevel, upperLevel; GetLookupLevels(lowerLevel, upperLevel, queryLevel, lookup); assert(upperLevel <= queryLevel && @@ -547,17 +547,17 @@ for (int level = queryLevel - 1; level >= upperLevel; level--) { sql += (" INNER JOIN Resources " + - FormatLevel(static_cast(level)) + " ON " + - FormatLevel(static_cast(level)) + ".internalId=" + - FormatLevel(static_cast(level + 1)) + ".parentId"); + FormatLevel(static_cast(level)) + " ON " + + FormatLevel(static_cast(level)) + ".internalId=" + + FormatLevel(static_cast(level + 1)) + ".parentId"); } for (int level = queryLevel + 1; level <= lowerLevel; level++) { sql += (" INNER JOIN Resources " + - FormatLevel(static_cast(level)) + " ON " + - FormatLevel(static_cast(level - 1)) + ".internalId=" + - FormatLevel(static_cast(level)) + ".parentId"); + FormatLevel(static_cast(level)) + " ON " + + FormatLevel(static_cast(level - 1)) + ".internalId=" + + FormatLevel(static_cast(level)) + ".parentId"); } std::list where; @@ -595,7 +595,7 @@ break; default: - throw OrthancException(ErrorCode_ParameterOutOfRange); + throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); } where.push_back("(SELECT COUNT(1) FROM Labels AS selectedLabels WHERE selectedLabels.id = " + FormatLevel(queryLevel) + @@ -614,13 +614,13 @@ void ISqlLookupFormatter::ApplySingleLevel(std::string& sql, ISqlLookupFormatter& formatter, const DatabaseConstraints& lookup, - ResourceType queryLevel, + Orthanc::ResourceType queryLevel, const std::set& labels, LabelsConstraint labelsConstraint, size_t limit ) { - ResourceType lowerLevel, upperLevel; + Orthanc::ResourceType lowerLevel, upperLevel; GetLookupLevels(lowerLevel, upperLevel, queryLevel, lookup); assert(upperLevel == queryLevel && @@ -708,7 +708,7 @@ break; default: - throw OrthancException(ErrorCode_ParameterOutOfRange); + throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); } sql += (" AND internalId " + inOrNotIn + " (SELECT id" diff -r e620f36b8e09 -r 1a23f1ce3b98 Framework/Plugins/ISqlLookupFormatter.h --- a/Framework/Plugins/ISqlLookupFormatter.h Mon Sep 09 13:29:45 2024 +0200 +++ b/Framework/Plugins/ISqlLookupFormatter.h Mon Sep 09 15:19:28 2024 +0200 @@ -35,7 +35,7 @@ #include #include -namespace Orthanc +namespace OrthancDatabases { class DatabaseConstraints; @@ -55,7 +55,7 @@ virtual std::string GenerateParameter(const std::string& value) = 0; - virtual std::string FormatResourceType(ResourceType level) = 0; + virtual std::string FormatResourceType(Orthanc::ResourceType level) = 0; virtual std::string FormatWildcardEscape() = 0; @@ -66,15 +66,15 @@ **/ virtual bool IsEscapeBrackets() const = 0; - static void GetLookupLevels(ResourceType& lowerLevel, - ResourceType& upperLevel, - const ResourceType& queryLevel, + static void GetLookupLevels(Orthanc::ResourceType& lowerLevel, + Orthanc::ResourceType& upperLevel, + const Orthanc::ResourceType& queryLevel, const DatabaseConstraints& lookup); static void Apply(std::string& sql, ISqlLookupFormatter& formatter, const DatabaseConstraints& lookup, - ResourceType queryLevel, + Orthanc::ResourceType queryLevel, const std::set& labels, // New in Orthanc 1.12.0 LabelsConstraint labelsConstraint, // New in Orthanc 1.12.0 size_t limit); @@ -82,7 +82,7 @@ static void ApplySingleLevel(std::string& sql, ISqlLookupFormatter& formatter, const DatabaseConstraints& lookup, - ResourceType queryLevel, + Orthanc::ResourceType queryLevel, const std::set& labels, // New in Orthanc 1.12.0 LabelsConstraint labelsConstraint, // New in Orthanc 1.12.0 size_t limit); diff -r e620f36b8e09 -r 1a23f1ce3b98 Framework/Plugins/IndexBackend.cpp --- a/Framework/Plugins/IndexBackend.cpp Mon Sep 09 13:29:45 2024 +0200 +++ b/Framework/Plugins/IndexBackend.cpp Mon Sep 09 15:19:28 2024 +0200 @@ -2021,7 +2021,7 @@ #if ORTHANC_PLUGINS_HAS_DATABASE_CONSTRAINT == 1 - class IndexBackend::LookupFormatter : public Orthanc::ISqlLookupFormatter + class IndexBackend::LookupFormatter : public ISqlLookupFormatter { private: Dialect dialect_; @@ -2052,7 +2052,7 @@ virtual std::string FormatResourceType(Orthanc::ResourceType level) { - return boost::lexical_cast(Orthanc::Plugins::Convert(level)); + return boost::lexical_cast(Plugins::Convert(level)); } virtual std::string FormatWildcardEscape() @@ -2101,24 +2101,24 @@ // New primitive since Orthanc 1.5.2 void IndexBackend::LookupResources(IDatabaseBackendOutput& output, DatabaseManager& manager, - const Orthanc::DatabaseConstraints& lookup, + const DatabaseConstraints& lookup, OrthancPluginResourceType queryLevel_, const std::set& labels, - Orthanc::LabelsConstraint labelsConstraint, + LabelsConstraint labelsConstraint, uint32_t limit, bool requestSomeInstance) { LookupFormatter formatter(manager.GetDialect()); - Orthanc::ResourceType queryLevel = Orthanc::Plugins::Convert(queryLevel_); + Orthanc::ResourceType queryLevel = Plugins::Convert(queryLevel_); Orthanc::ResourceType lowerLevel, upperLevel; - Orthanc::ISqlLookupFormatter::GetLookupLevels(lowerLevel, upperLevel, queryLevel, lookup); + ISqlLookupFormatter::GetLookupLevels(lowerLevel, upperLevel, queryLevel, lookup); std::string sql; bool enableNewStudyCode = true; if (enableNewStudyCode && lowerLevel == queryLevel && upperLevel == queryLevel) { - Orthanc::ISqlLookupFormatter::ApplySingleLevel(sql, formatter, lookup, queryLevel, labels, labelsConstraint, limit); + ISqlLookupFormatter::ApplySingleLevel(sql, formatter, lookup, queryLevel, labels, labelsConstraint, limit); if (requestSomeInstance) { @@ -2167,7 +2167,7 @@ } else { - Orthanc::ISqlLookupFormatter::Apply(sql, formatter, lookup, queryLevel, labels, labelsConstraint, limit); + ISqlLookupFormatter::Apply(sql, formatter, lookup, queryLevel, labels, labelsConstraint, limit); if (requestSomeInstance) { diff -r e620f36b8e09 -r 1a23f1ce3b98 Framework/Plugins/IndexBackend.h --- a/Framework/Plugins/IndexBackend.h Mon Sep 09 13:29:45 2024 +0200 +++ b/Framework/Plugins/IndexBackend.h Mon Sep 09 15:19:28 2024 +0200 @@ -303,10 +303,10 @@ // New primitive since Orthanc 1.5.2 virtual void LookupResources(IDatabaseBackendOutput& output, DatabaseManager& manager, - const Orthanc::DatabaseConstraints& lookup, + const DatabaseConstraints& lookup, OrthancPluginResourceType queryLevel, const std::set& labels, - Orthanc::LabelsConstraint labelsConstraint, + LabelsConstraint labelsConstraint, uint32_t limit, bool requestSomeInstance) ORTHANC_OVERRIDE; #endif