Mercurial > hg > orthanc-databases
changeset 203:2089d4071408
moving classes out of OrthancPlugins namespace, to OrthancDatabases
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 18 Mar 2021 18:15:34 +0100 |
parents | 2def2df94f94 |
children | 7299410c3d61 |
files | Framework/Plugins/IDatabaseBackend.h Framework/Plugins/IDatabaseBackendOutput.h Framework/Plugins/IndexBackend.cpp Framework/Plugins/IndexBackend.h Framework/Plugins/IndexUnitTests.h Framework/Plugins/OrthancCppDatabasePlugin.h MySQL/Plugins/IndexPlugin.cpp MySQL/Plugins/MySQLIndex.cpp MySQL/Plugins/MySQLIndex.h PostgreSQL/Plugins/IndexPlugin.cpp SQLite/Plugins/IndexPlugin.cpp |
diffstat | 11 files changed, 98 insertions(+), 98 deletions(-) [+] |
line wrap: on
line diff
--- a/Framework/Plugins/IDatabaseBackend.h Thu Mar 18 17:00:38 2021 +0100 +++ b/Framework/Plugins/IDatabaseBackend.h Thu Mar 18 18:15:34 2021 +0100 @@ -26,7 +26,7 @@ #include <list> -namespace OrthancPlugins +namespace OrthancDatabases { class IDatabaseBackend : public boost::noncopyable { @@ -58,14 +58,14 @@ virtual int64_t CreateResource(const char* publicId, OrthancPluginResourceType type) = 0; - virtual void DeleteAttachment(OrthancPlugins::IDatabaseBackendOutput& output, + virtual void DeleteAttachment(IDatabaseBackendOutput& output, int64_t id, int32_t attachment) = 0; virtual void DeleteMetadata(int64_t id, int32_t metadataType) = 0; - virtual void DeleteResource(OrthancPlugins::IDatabaseBackendOutput& output, + virtual void DeleteResource(IDatabaseBackendOutput& output, int64_t id) = 0; virtual void GetAllInternalIds(std::list<int64_t>& target, @@ -80,7 +80,7 @@ uint64_t limit) = 0; /* Use GetOutput().AnswerChange() */ - virtual void GetChanges(OrthancPlugins::IDatabaseBackendOutput& output, + virtual void GetChanges(IDatabaseBackendOutput& output, bool& done /*out*/, int64_t since, uint32_t maxResults) = 0; @@ -92,19 +92,19 @@ int64_t id) = 0; /* Use GetOutput().AnswerExportedResource() */ - virtual void GetExportedResources(OrthancPlugins::IDatabaseBackendOutput& output, + virtual void GetExportedResources(IDatabaseBackendOutput& output, bool& done /*out*/, int64_t since, uint32_t maxResults) = 0; /* Use GetOutput().AnswerChange() */ - virtual void GetLastChange(OrthancPlugins::IDatabaseBackendOutput& output) = 0; + virtual void GetLastChange(IDatabaseBackendOutput& output) = 0; /* Use GetOutput().AnswerExportedResource() */ - virtual void GetLastExportedResource(OrthancPlugins::IDatabaseBackendOutput& output) = 0; + virtual void GetLastExportedResource(IDatabaseBackendOutput& output) = 0; /* Use GetOutput().AnswerDicomTag() */ - virtual void GetMainDicomTags(OrthancPlugins::IDatabaseBackendOutput& output, + virtual void GetMainDicomTags(IDatabaseBackendOutput& output, int64_t id) = 0; virtual std::string GetPublicId(int64_t resourceId) = 0; @@ -132,7 +132,7 @@ virtual void LogExportedResource(const OrthancPluginExportedResource& resource) = 0; /* Use GetOutput().AnswerAttachment() */ - virtual bool LookupAttachment(OrthancPlugins::IDatabaseBackendOutput& output, + virtual bool LookupAttachment(IDatabaseBackendOutput& output, int64_t id, int32_t contentType) = 0; @@ -210,7 +210,7 @@ virtual bool HasCreateInstance() const = 0; #if ORTHANC_PLUGINS_HAS_DATABASE_CONSTRAINT == 1 - virtual void LookupResources(OrthancPlugins::IDatabaseBackendOutput& output, + virtual void LookupResources(IDatabaseBackendOutput& output, const std::vector<Orthanc::DatabaseConstraint>& lookup, OrthancPluginResourceType queryLevel, uint32_t limit,
--- a/Framework/Plugins/IDatabaseBackendOutput.h Thu Mar 18 17:00:38 2021 +0100 +++ b/Framework/Plugins/IDatabaseBackendOutput.h Thu Mar 18 18:15:34 2021 +0100 @@ -23,7 +23,7 @@ #include "../../Resources/Orthanc/Databases/DatabaseConstraint.h" -namespace OrthancPlugins +namespace OrthancDatabases { class IDatabaseBackendOutput : public boost::noncopyable {
--- a/Framework/Plugins/IndexBackend.cpp Thu Mar 18 17:00:38 2021 +0100 +++ b/Framework/Plugins/IndexBackend.cpp Thu Mar 18 18:15:34 2021 +0100 @@ -171,7 +171,7 @@ } - void IndexBackend::ReadChangesInternal(OrthancPlugins::IDatabaseBackendOutput& output, + void IndexBackend::ReadChangesInternal(IDatabaseBackendOutput& output, bool& done, DatabaseManager::CachedStatement& statement, const Dictionary& args, @@ -200,7 +200,7 @@ } - void IndexBackend::ReadExportedResourcesInternal(OrthancPlugins::IDatabaseBackendOutput& output, + void IndexBackend::ReadExportedResourcesInternal(IDatabaseBackendOutput& output, bool& done, DatabaseManager::CachedStatement& statement, const Dictionary& args, @@ -257,7 +257,7 @@ } - void IndexBackend::SignalDeletedFiles(OrthancPlugins::IDatabaseBackendOutput& output) + void IndexBackend::SignalDeletedFiles(IDatabaseBackendOutput& output) { DatabaseManager::CachedStatement statement( STATEMENT_FROM_HERE, manager_, @@ -285,7 +285,7 @@ } - void IndexBackend::SignalDeletedResources(OrthancPlugins::IDatabaseBackendOutput& output) + void IndexBackend::SignalDeletedResources(IDatabaseBackendOutput& output) { DatabaseManager::CachedStatement statement( STATEMENT_FROM_HERE, manager_, @@ -313,7 +313,7 @@ } - void IndexBackend::SetOutputFactory(OrthancPlugins::IDatabaseBackendOutput::IFactory* factory) + void IndexBackend::SetOutputFactory(IDatabaseBackendOutput::IFactory* factory) { if (factory == NULL) { @@ -330,7 +330,7 @@ } - OrthancPlugins::IDatabaseBackendOutput* IndexBackend::CreateOutput() + IDatabaseBackendOutput* IndexBackend::CreateOutput() { if (outputFactory_.get() == NULL) { @@ -412,7 +412,7 @@ } - void IndexBackend::DeleteAttachment(OrthancPlugins::IDatabaseBackendOutput& output, + void IndexBackend::DeleteAttachment(IDatabaseBackendOutput& output, int64_t id, int32_t attachment) { @@ -455,7 +455,7 @@ } - void IndexBackend::DeleteResource(OrthancPlugins::IDatabaseBackendOutput& output, + void IndexBackend::DeleteResource(IDatabaseBackendOutput& output, int64_t id) { assert(manager_.GetDialect() != Dialect_MySQL); @@ -568,7 +568,7 @@ /* Use GetOutput().AnswerChange() */ - void IndexBackend::GetChanges(OrthancPlugins::IDatabaseBackendOutput& output, + void IndexBackend::GetChanges(IDatabaseBackendOutput& output, bool& done /*out*/, int64_t since, uint32_t maxResults) @@ -626,7 +626,7 @@ /* Use GetOutput().AnswerExportedResource() */ - void IndexBackend::GetExportedResources(OrthancPlugins::IDatabaseBackendOutput& output, + void IndexBackend::GetExportedResources(IDatabaseBackendOutput& output, bool& done /*out*/, int64_t since, uint32_t maxResults) @@ -648,7 +648,7 @@ /* Use GetOutput().AnswerChange() */ - void IndexBackend::GetLastChange(OrthancPlugins::IDatabaseBackendOutput& output) + void IndexBackend::GetLastChange(IDatabaseBackendOutput& output) { DatabaseManager::CachedStatement statement( STATEMENT_FROM_HERE, manager_, @@ -664,7 +664,7 @@ /* Use GetOutput().AnswerExportedResource() */ - void IndexBackend::GetLastExportedResource(OrthancPlugins::IDatabaseBackendOutput& output) + void IndexBackend::GetLastExportedResource(IDatabaseBackendOutput& output) { DatabaseManager::CachedStatement statement( STATEMENT_FROM_HERE, manager_, @@ -680,7 +680,7 @@ /* Use GetOutput().AnswerDicomTag() */ - void IndexBackend::GetMainDicomTags(OrthancPlugins::IDatabaseBackendOutput& output, + void IndexBackend::GetMainDicomTags(IDatabaseBackendOutput& output, int64_t id) { DatabaseManager::CachedStatement statement( @@ -999,7 +999,7 @@ /* Use GetOutput().AnswerAttachment() */ - bool IndexBackend::LookupAttachment(OrthancPlugins::IDatabaseBackendOutput& output, + bool IndexBackend::LookupAttachment(IDatabaseBackendOutput& output, int64_t id, int32_t contentType) { @@ -1693,7 +1693,7 @@ #if ORTHANC_PLUGINS_HAS_DATABASE_CONSTRAINT == 1 // New primitive since Orthanc 1.5.2 - void IndexBackend::LookupResources(OrthancPlugins::IDatabaseBackendOutput& output, + void IndexBackend::LookupResources(IDatabaseBackendOutput& output, const std::vector<Orthanc::DatabaseConstraint>& lookup, OrthancPluginResourceType queryLevel, uint32_t limit, @@ -1997,62 +1997,62 @@ #if defined(ORTHANC_PLUGINS_VERSION_IS_ABOVE) // Macro introduced in 1.3.1 # if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 5, 4) // New primitive since Orthanc 1.5.4 - bool IndexBackend::LookupResourceAndParent(int64_t& id, - OrthancPluginResourceType& type, - std::string& parentPublicId, - const char* publicId) - { - DatabaseManager::CachedStatement statement( - STATEMENT_FROM_HERE, manager_, - "SELECT resource.internalId, resource.resourceType, parent.publicId " - "FROM Resources AS resource LEFT JOIN Resources parent ON parent.internalId=resource.parentId " - "WHERE resource.publicId=${id}"); +bool IndexBackend::LookupResourceAndParent(int64_t& id, + OrthancPluginResourceType& type, + std::string& parentPublicId, + const char* publicId) +{ + DatabaseManager::CachedStatement statement( + STATEMENT_FROM_HERE, manager_, + "SELECT resource.internalId, resource.resourceType, parent.publicId " + "FROM Resources AS resource LEFT JOIN Resources parent ON parent.internalId=resource.parentId " + "WHERE resource.publicId=${id}"); - statement.SetParameterType("id", ValueType_Utf8String); + statement.SetParameterType("id", ValueType_Utf8String); - Dictionary args; - args.SetUtf8Value("id", publicId); + Dictionary args; + args.SetUtf8Value("id", publicId); + + statement.Execute(args); - statement.Execute(args); - - if (statement.IsDone()) + if (statement.IsDone()) + { + return false; + } + else + { + if (statement.GetResultFieldsCount() != 3) { - return false; + throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError); } - else + + statement.SetResultFieldType(0, ValueType_Integer64); + statement.SetResultFieldType(1, ValueType_Integer64); + statement.SetResultFieldType(2, ValueType_Utf8String); + + id = ReadInteger64(statement, 0); + type = static_cast<OrthancPluginResourceType>(ReadInteger32(statement, 1)); + + const IValue& value = statement.GetResultField(2); + + switch (value.GetType()) { - if (statement.GetResultFieldsCount() != 3) - { + case ValueType_Null: + parentPublicId.clear(); + break; + + case ValueType_Utf8String: + parentPublicId = dynamic_cast<const Utf8StringValue&>(value).GetContent(); + break; + + default: throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError); - } - - statement.SetResultFieldType(0, ValueType_Integer64); - statement.SetResultFieldType(1, ValueType_Integer64); - statement.SetResultFieldType(2, ValueType_Utf8String); - - id = ReadInteger64(statement, 0); - type = static_cast<OrthancPluginResourceType>(ReadInteger32(statement, 1)); - - const IValue& value = statement.GetResultField(2); + } - switch (value.GetType()) - { - case ValueType_Null: - parentPublicId.clear(); - break; - - case ValueType_Utf8String: - parentPublicId = dynamic_cast<const Utf8StringValue&>(value).GetContent(); - break; - - default: - throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError); - } - - assert((statement.Next(), statement.IsDone())); - return true; - } + assert((statement.Next(), statement.IsDone())); + return true; } +} # endif #endif
--- a/Framework/Plugins/IndexBackend.h Thu Mar 18 17:00:38 2021 +0100 +++ b/Framework/Plugins/IndexBackend.h Thu Mar 18 18:15:34 2021 +0100 @@ -27,7 +27,7 @@ namespace OrthancDatabases { - class IndexBackend : public OrthancPlugins::IDatabaseBackend + class IndexBackend : public IDatabaseBackend { private: class LookupFormatter; @@ -35,7 +35,7 @@ OrthancPluginContext* context_; DatabaseManager manager_; - std::unique_ptr<OrthancPlugins::IDatabaseBackendOutput::IFactory> outputFactory_; + std::unique_ptr<IDatabaseBackendOutput::IFactory> outputFactory_; protected: DatabaseManager& GetManager() @@ -65,18 +65,18 @@ void ClearDeletedResources(); - void SignalDeletedFiles(OrthancPlugins::IDatabaseBackendOutput& output); + void SignalDeletedFiles(IDatabaseBackendOutput& output); - void SignalDeletedResources(OrthancPlugins::IDatabaseBackendOutput& output); + void SignalDeletedResources(IDatabaseBackendOutput& output); private: - void ReadChangesInternal(OrthancPlugins::IDatabaseBackendOutput& output, + void ReadChangesInternal(IDatabaseBackendOutput& output, bool& done, DatabaseManager::CachedStatement& statement, const Dictionary& args, uint32_t maxResults); - void ReadExportedResourcesInternal(OrthancPlugins::IDatabaseBackendOutput& output, + void ReadExportedResourcesInternal(IDatabaseBackendOutput& output, bool& done, DatabaseManager::CachedStatement& statement, const Dictionary& args, @@ -91,9 +91,9 @@ return context_; } - virtual void SetOutputFactory(OrthancPlugins::IDatabaseBackendOutput::IFactory* factory) ORTHANC_OVERRIDE; + virtual void SetOutputFactory(IDatabaseBackendOutput::IFactory* factory) ORTHANC_OVERRIDE; - virtual OrthancPlugins::IDatabaseBackendOutput* CreateOutput() ORTHANC_OVERRIDE; + virtual IDatabaseBackendOutput* CreateOutput() ORTHANC_OVERRIDE; virtual void Open() ORTHANC_OVERRIDE { @@ -115,14 +115,14 @@ virtual void ClearExportedResources() ORTHANC_OVERRIDE; - virtual void DeleteAttachment(OrthancPlugins::IDatabaseBackendOutput& output, + virtual void DeleteAttachment(IDatabaseBackendOutput& output, int64_t id, int32_t attachment) ORTHANC_OVERRIDE; virtual void DeleteMetadata(int64_t id, int32_t metadataType) ORTHANC_OVERRIDE; - virtual void DeleteResource(OrthancPlugins::IDatabaseBackendOutput& output, + virtual void DeleteResource(IDatabaseBackendOutput& output, int64_t id) ORTHANC_OVERRIDE; virtual void GetAllInternalIds(std::list<int64_t>& target, @@ -136,7 +136,7 @@ uint64_t since, uint64_t limit) ORTHANC_OVERRIDE; - virtual void GetChanges(OrthancPlugins::IDatabaseBackendOutput& output, + virtual void GetChanges(IDatabaseBackendOutput& output, bool& done /*out*/, int64_t since, uint32_t maxResults) ORTHANC_OVERRIDE; @@ -147,16 +147,16 @@ virtual void GetChildrenPublicId(std::list<std::string>& target /*out*/, int64_t id) ORTHANC_OVERRIDE; - virtual void GetExportedResources(OrthancPlugins::IDatabaseBackendOutput& output, + virtual void GetExportedResources(IDatabaseBackendOutput& output, bool& done /*out*/, int64_t since, uint32_t maxResults) ORTHANC_OVERRIDE; - virtual void GetLastChange(OrthancPlugins::IDatabaseBackendOutput& output) ORTHANC_OVERRIDE; + virtual void GetLastChange(IDatabaseBackendOutput& output) ORTHANC_OVERRIDE; - virtual void GetLastExportedResource(OrthancPlugins::IDatabaseBackendOutput& output) ORTHANC_OVERRIDE; + virtual void GetLastExportedResource(IDatabaseBackendOutput& output) ORTHANC_OVERRIDE; - virtual void GetMainDicomTags(OrthancPlugins::IDatabaseBackendOutput& output, + virtual void GetMainDicomTags(IDatabaseBackendOutput& output, int64_t id) ORTHANC_OVERRIDE; virtual std::string GetPublicId(int64_t resourceId) ORTHANC_OVERRIDE; @@ -183,7 +183,7 @@ virtual void LogExportedResource(const OrthancPluginExportedResource& resource) ORTHANC_OVERRIDE; - virtual bool LookupAttachment(OrthancPlugins::IDatabaseBackendOutput& output, + virtual bool LookupAttachment(IDatabaseBackendOutput& output, int64_t id, int32_t contentType) ORTHANC_OVERRIDE; @@ -281,7 +281,7 @@ #if ORTHANC_PLUGINS_HAS_DATABASE_CONSTRAINT == 1 // New primitive since Orthanc 1.5.2 - virtual void LookupResources(OrthancPlugins::IDatabaseBackendOutput& output, + virtual void LookupResources(IDatabaseBackendOutput& output, const std::vector<Orthanc::DatabaseConstraint>& lookup, OrthancPluginResourceType queryLevel, uint32_t limit,
--- a/Framework/Plugins/IndexUnitTests.h Thu Mar 18 17:00:38 2021 +0100 +++ b/Framework/Plugins/IndexUnitTests.h Thu Mar 18 18:15:34 2021 +0100 @@ -179,10 +179,10 @@ # error Unsupported database backend #endif - db.SetOutputFactory(new OrthancPlugins::DatabaseBackendOutputV2::Factory(&context, NULL)); + db.SetOutputFactory(new DatabaseBackendOutputV2::Factory(&context, NULL)); db.Open(); - std::unique_ptr<OrthancPlugins::IDatabaseBackendOutput> output(db.CreateOutput()); + std::unique_ptr<IDatabaseBackendOutput> output(db.CreateOutput()); std::string s;
--- a/Framework/Plugins/OrthancCppDatabasePlugin.h Thu Mar 18 17:00:38 2021 +0100 +++ b/Framework/Plugins/OrthancCppDatabasePlugin.h Thu Mar 18 18:15:34 2021 +0100 @@ -64,7 +64,7 @@ #include <list> #include <string> -namespace OrthancPlugins +namespace OrthancDatabases { class DatabaseBackendOutputV2 : public IDatabaseBackendOutput {
--- a/MySQL/Plugins/IndexPlugin.cpp Thu Mar 18 17:00:38 2021 +0100 +++ b/MySQL/Plugins/IndexPlugin.cpp Thu Mar 18 18:15:34 2021 +0100 @@ -71,7 +71,7 @@ backend_.reset(new OrthancDatabases::MySQLIndex(context, parameters)); /* Register the MySQL index into Orthanc */ - OrthancPlugins::DatabaseBackendAdapterV2::Register(context, *backend_); + OrthancDatabases::DatabaseBackendAdapterV2::Register(context, *backend_); } catch (Orthanc::OrthancException& e) {
--- a/MySQL/Plugins/MySQLIndex.cpp Thu Mar 18 17:00:38 2021 +0100 +++ b/MySQL/Plugins/MySQLIndex.cpp Thu Mar 18 18:15:34 2021 +0100 @@ -306,7 +306,7 @@ } - void MySQLIndex::DeleteResource(OrthancPlugins::IDatabaseBackendOutput& output, + void MySQLIndex::DeleteResource(IDatabaseBackendOutput& output, int64_t id) { ClearDeletedFiles();
--- a/MySQL/Plugins/MySQLIndex.h Thu Mar 18 17:00:38 2021 +0100 +++ b/MySQL/Plugins/MySQLIndex.h Thu Mar 18 18:15:34 2021 +0100 @@ -75,7 +75,7 @@ OrthancPluginResourceType type) ORTHANC_OVERRIDE; - virtual void DeleteResource(OrthancPlugins::IDatabaseBackendOutput& output, + virtual void DeleteResource(IDatabaseBackendOutput& output, int64_t id) ORTHANC_OVERRIDE; virtual int64_t GetLastChangeIndex() ORTHANC_OVERRIDE;
--- a/PostgreSQL/Plugins/IndexPlugin.cpp Thu Mar 18 17:00:38 2021 +0100 +++ b/PostgreSQL/Plugins/IndexPlugin.cpp Thu Mar 18 18:15:34 2021 +0100 @@ -65,7 +65,7 @@ backend_.reset(new OrthancDatabases::PostgreSQLIndex(context, parameters)); /* Register the PostgreSQL index into Orthanc */ - OrthancPlugins::DatabaseBackendAdapterV2::Register(context, *backend_); + OrthancDatabases::DatabaseBackendAdapterV2::Register(context, *backend_); } catch (Orthanc::OrthancException& e) {
--- a/SQLite/Plugins/IndexPlugin.cpp Thu Mar 18 17:00:38 2021 +0100 +++ b/SQLite/Plugins/IndexPlugin.cpp Thu Mar 18 18:15:34 2021 +0100 @@ -65,7 +65,7 @@ backend_.reset(new OrthancDatabases::SQLiteIndex(context, "index.db")); // TODO parameter /* Register the SQLite index into Orthanc */ - OrthancPlugins::DatabaseBackendAdapterV2::Register(context, *backend_); + OrthancDatabases::DatabaseBackendAdapterV2::Register(context, *backend_); } catch (Orthanc::OrthancException& e) {