changeset 3038:53d583d2c775 db-changes

removing IDatabaseWrapper::LookupIdentifier()
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 19 Dec 2018 18:06:46 +0100
parents d23c84b1c0f5
children 867140c61f30
files OrthancServer/IDatabaseWrapper.h OrthancServer/SQLiteDatabaseWrapper.cpp OrthancServer/SQLiteDatabaseWrapper.h OrthancServer/ServerEnumerations.h Plugins/Engine/OrthancPluginDatabase.cpp Plugins/Engine/OrthancPluginDatabase.h
diffstat 6 files changed, 2 insertions(+), 162 deletions(-) [+]
line wrap: on
line diff
--- a/OrthancServer/IDatabaseWrapper.h	Wed Dec 19 16:31:10 2018 +0100
+++ b/OrthancServer/IDatabaseWrapper.h	Wed Dec 19 18:06:46 2018 +0100
@@ -102,6 +102,7 @@
     virtual void GetAllMetadata(std::map<MetadataType, std::string>& target,
                                 int64_t id) = 0;
 
+    // TODO: REMOVE THIS
     virtual void GetAllInternalIds(std::list<int64_t>& target,
                                    ResourceType resourceType) = 0;
 
@@ -168,18 +169,6 @@
     virtual bool LookupGlobalProperty(std::string& target,
                                       GlobalProperty property) = 0;
 
-    virtual void LookupIdentifier(std::list<int64_t>& result,
-                                  ResourceType level,
-                                  const DicomTag& tag,
-                                  IdentifierConstraintType type,
-                                  const std::string& value) = 0;
-
-    virtual void LookupIdentifierRange(std::list<int64_t>& result,
-                                       ResourceType level,
-                                       const DicomTag& tag,
-                                       const std::string& start,
-                                       const std::string& end) = 0;
-
     virtual bool LookupMetadata(std::string& target,
                                 int64_t id,
                                 MetadataType type) = 0;
--- a/OrthancServer/SQLiteDatabaseWrapper.cpp	Wed Dec 19 16:31:10 2018 +0100
+++ b/OrthancServer/SQLiteDatabaseWrapper.cpp	Wed Dec 19 18:06:46 2018 +0100
@@ -1126,80 +1126,6 @@
   }
 
 
-  void SQLiteDatabaseWrapper::LookupIdentifier(std::list<int64_t>& target,
-                                               ResourceType level,
-                                               const DicomTag& tag,
-                                               IdentifierConstraintType type,
-                                               const std::string& value)
-  {
-    static const char* COMMON = ("SELECT d.id FROM DicomIdentifiers AS d, Resources AS r WHERE "
-                                 "d.id = r.internalId AND r.resourceType=? AND "
-                                 "d.tagGroup=? AND d.tagElement=? AND ");
-
-    std::auto_ptr<SQLite::Statement> s;
-
-    switch (type)
-    {
-      case IdentifierConstraintType_GreaterOrEqual:
-        s.reset(new SQLite::Statement(db_, std::string(COMMON) + "d.value>=?"));
-        break;
-
-      case IdentifierConstraintType_SmallerOrEqual:
-        s.reset(new SQLite::Statement(db_, std::string(COMMON) + "d.value<=?"));
-        break;
-
-      case IdentifierConstraintType_Wildcard:
-        s.reset(new SQLite::Statement(db_, std::string(COMMON) + "d.value GLOB ?"));
-        break;
-
-      case IdentifierConstraintType_Equal:
-      default:
-        s.reset(new SQLite::Statement(db_, std::string(COMMON) + "d.value=?"));
-        break;
-    }
-
-    assert(s.get() != NULL);
-
-    s->BindInt(0, level);
-    s->BindInt(1, tag.GetGroup());
-    s->BindInt(2, tag.GetElement());
-    s->BindString(3, value);
-
-    target.clear();
-
-    while (s->Step())
-    {
-      target.push_back(s->ColumnInt64(0));
-    }    
-  }
-
-
-  void SQLiteDatabaseWrapper::LookupIdentifierRange(std::list<int64_t>& target,
-                                                    ResourceType level,
-                                                    const DicomTag& tag,
-                                                    const std::string& start,
-                                                    const std::string& end)
-  {
-    SQLite::Statement statement(db_, SQLITE_FROM_HERE,
-                                "SELECT d.id FROM DicomIdentifiers AS d, Resources AS r WHERE "
-                                "d.id = r.internalId AND r.resourceType=? AND "
-                                "d.tagGroup=? AND d.tagElement=? AND d.value>=? AND d.value<=?");
-
-    statement.BindInt(0, level);
-    statement.BindInt(1, tag.GetGroup());
-    statement.BindInt(2, tag.GetElement());
-    statement.BindString(3, start);
-    statement.BindString(4, end);
-
-    target.clear();
-
-    while (statement.Step())
-    {
-      target.push_back(statement.ColumnInt64(0));
-    }    
-  }
-
-
   bool SQLiteDatabaseWrapper::IsDiskSizeAbove(uint64_t threshold)
   {
     return GetTotalCompressedSize() > threshold;
--- a/OrthancServer/SQLiteDatabaseWrapper.h	Wed Dec 19 16:31:10 2018 +0100
+++ b/OrthancServer/SQLiteDatabaseWrapper.h	Wed Dec 19 18:06:46 2018 +0100
@@ -263,18 +263,6 @@
 
     virtual bool IsExistingResource(int64_t internalId);
 
-    virtual void LookupIdentifier(std::list<int64_t>& result,
-                                  ResourceType level,
-                                  const DicomTag& tag,
-                                  IdentifierConstraintType type,
-                                  const std::string& value);
-
-    virtual void LookupIdentifierRange(std::list<int64_t>& result,
-                                       ResourceType level,
-                                       const DicomTag& tag,
-                                       const std::string& start,
-                                       const std::string& end);
-
     virtual bool IsDiskSizeAbove(uint64_t threshold);
 
     virtual void ApplyLookupResources(std::vector<std::string>& resourcesId,
--- a/OrthancServer/ServerEnumerations.h	Wed Dec 19 16:31:10 2018 +0100
+++ b/OrthancServer/ServerEnumerations.h	Wed Dec 19 18:06:46 2018 +0100
@@ -56,6 +56,7 @@
     StoreStatus_FilteredOut     // Removed by NewInstanceFilter
   };
 
+  // TODO REMOVE THIS
   enum IdentifierConstraintType
   {
     IdentifierConstraintType_Equal,
--- a/Plugins/Engine/OrthancPluginDatabase.cpp	Wed Dec 19 16:31:10 2018 +0100
+++ b/Plugins/Engine/OrthancPluginDatabase.cpp	Wed Dec 19 18:06:46 2018 +0100
@@ -695,58 +695,6 @@
   }
 
 
-  void OrthancPluginDatabase::LookupIdentifier(std::list<int64_t>& result,
-                                               ResourceType level,
-                                               const DicomTag& tag,
-                                               IdentifierConstraintType type,
-                                               const std::string& value)
-  {
-    if (extensions_.lookupIdentifier3 == NULL)
-    {
-      throw OrthancException(ErrorCode_DatabasePlugin,
-                             "The database plugin does not implement the LookupIdentifier3 primitive");
-    }
-
-    OrthancPluginDicomTag tmp;
-    tmp.group = tag.GetGroup();
-    tmp.element = tag.GetElement();
-    tmp.value = value.c_str();
-
-    ResetAnswers();
-    CheckSuccess(extensions_.lookupIdentifier3(GetContext(), payload_, Plugins::Convert(level),
-                                               &tmp, Plugins::Convert(type)));
-    ForwardAnswers(result);
-  }
-
-
-  void OrthancPluginDatabase::LookupIdentifierRange(std::list<int64_t>& result,
-                                                    ResourceType level,
-                                                    const DicomTag& tag,
-                                                    const std::string& start,
-                                                    const std::string& end)
-  {
-    if (extensions_.lookupIdentifierRange == NULL)
-    {
-      // Default implementation, for plugins using Orthanc SDK <= 1.3.2
-
-      LookupIdentifier(result, level, tag, IdentifierConstraintType_GreaterOrEqual, start);
-
-      std::list<int64_t> b;
-      LookupIdentifier(result, level, tag, IdentifierConstraintType_SmallerOrEqual, end);
-
-      result.splice(result.end(), b);
-    }
-    else
-    {
-      ResetAnswers();
-      CheckSuccess(extensions_.lookupIdentifierRange(GetContext(), payload_, Plugins::Convert(level),
-                                                     tag.GetGroup(), tag.GetElement(),
-                                                     start.c_str(), end.c_str()));
-      ForwardAnswers(result);
-    }
-  }
-
-
   bool OrthancPluginDatabase::LookupMetadata(std::string& target,
                                              int64_t id,
                                              MetadataType type)
--- a/Plugins/Engine/OrthancPluginDatabase.h	Wed Dec 19 16:31:10 2018 +0100
+++ b/Plugins/Engine/OrthancPluginDatabase.h	Wed Dec 19 18:06:46 2018 +0100
@@ -207,18 +207,6 @@
     virtual bool LookupGlobalProperty(std::string& target,
                                       GlobalProperty property);
 
-    virtual void LookupIdentifier(std::list<int64_t>& result,
-                                  ResourceType level,
-                                  const DicomTag& tag,
-                                  IdentifierConstraintType type,
-                                  const std::string& value);
-
-    virtual void LookupIdentifierRange(std::list<int64_t>& result,
-                                       ResourceType level,
-                                       const DicomTag& tag,
-                                       const std::string& start,
-                                       const std::string& end);
-
     virtual bool LookupMetadata(std::string& target,
                                 int64_t id,
                                 MetadataType type);