changeset 1761:f4286d99ee0a db-changes

fix sample database plugin
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 29 Oct 2015 11:22:48 +0100
parents 51db4a25a741
children 2b91363cc1d1
files Core/DicomFormat/DicomValue.cpp Core/DicomFormat/DicomValue.h OrthancServer/DatabaseWrapperBase.cpp Plugins/Engine/PluginsEnumerations.cpp Plugins/Engine/PluginsEnumerations.h Plugins/Samples/DatabasePlugin/CMakeLists.txt Plugins/Samples/DatabasePlugin/Database.cpp Plugins/Samples/DatabasePlugin/Database.h
diffstat 8 files changed, 49 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/Core/DicomFormat/DicomValue.cpp	Thu Oct 29 11:09:00 2015 +0100
+++ b/Core/DicomFormat/DicomValue.cpp	Thu Oct 29 11:22:48 2015 +0100
@@ -81,10 +81,13 @@
   }
 
   
+#if !defined(ORTHANC_ENABLE_BASE64) || ORTHANC_ENABLE_BASE64 == 1
   void DicomValue::FormatDataUriScheme(std::string& target,
                                        const std::string& mime) const
   {
     Toolbox::EncodeBase64(target, GetContent());
     target.insert(0, "data:" + mime + ";base64,");
   }
+#endif
+
 }
--- a/Core/DicomFormat/DicomValue.h	Thu Oct 29 11:09:00 2015 +0100
+++ b/Core/DicomFormat/DicomValue.h	Thu Oct 29 11:22:48 2015 +0100
@@ -78,6 +78,7 @@
     
     DicomValue* Clone() const;
 
+#if !defined(ORTHANC_ENABLE_BASE64) || ORTHANC_ENABLE_BASE64 == 1
     void FormatDataUriScheme(std::string& target,
                              const std::string& mime) const;
 
@@ -85,5 +86,6 @@
     {
       FormatDataUriScheme(target, "application/octet-stream");
     }
+#endif
   };
 }
--- a/OrthancServer/DatabaseWrapperBase.cpp	Thu Oct 29 11:09:00 2015 +0100
+++ b/OrthancServer/DatabaseWrapperBase.cpp	Thu Oct 29 11:22:48 2015 +0100
@@ -695,10 +695,6 @@
 
     switch (type)
     {
-      case IdentifierConstraintType_Equal:
-        s.reset(new SQLite::Statement(db_, std::string(COMMON) + "d.value=?"));
-        break;
-
       case IdentifierConstraintType_GreaterOrEqual:
         s.reset(new SQLite::Statement(db_, std::string(COMMON) + "d.value>=?"));
         break;
@@ -711,8 +707,10 @@
         s.reset(new SQLite::Statement(db_, std::string(COMMON) + "d.value GLOB ?"));
         break;
 
+      case IdentifierConstraintType_Equal:
       default:
-        throw OrthancException(ErrorCode_ParameterOutOfRange);
+        s.reset(new SQLite::Statement(db_, std::string(COMMON) + "d.value=?"));
+        break;
     }
 
     assert(s.get() != NULL);
--- a/Plugins/Engine/PluginsEnumerations.cpp	Thu Oct 29 11:09:00 2015 +0100
+++ b/Plugins/Engine/PluginsEnumerations.cpp	Thu Oct 29 11:22:48 2015 +0100
@@ -251,6 +251,28 @@
     }
 
 
+    IdentifierConstraintType Convert(OrthancPluginIdentifierConstraint constraint)
+    {
+      switch (constraint)
+      {
+        case OrthancPluginIdentifierConstraint_Equal:
+          return IdentifierConstraintType_Equal;
+
+        case OrthancPluginIdentifierConstraint_GreaterOrEqual:
+          return IdentifierConstraintType_GreaterOrEqual;
+
+        case OrthancPluginIdentifierConstraint_SmallerOrEqual:
+          return IdentifierConstraintType_SmallerOrEqual;
+
+        case OrthancPluginIdentifierConstraint_Wildcard:
+          return IdentifierConstraintType_Wildcard;
+
+        default:
+          throw OrthancException(ErrorCode_ParameterOutOfRange);
+      }
+    }
+
+
 #if !defined(ORTHANC_ENABLE_DCMTK) || ORTHANC_ENABLE_DCMTK != 0
     DcmEVR Convert(OrthancPluginValueRepresentation vr)
     {
--- a/Plugins/Engine/PluginsEnumerations.h	Thu Oct 29 11:09:00 2015 +0100
+++ b/Plugins/Engine/PluginsEnumerations.h	Thu Oct 29 11:22:48 2015 +0100
@@ -63,6 +63,8 @@
 
     OrthancPluginIdentifierConstraint Convert(IdentifierConstraintType constraint);
 
+    IdentifierConstraintType Convert(OrthancPluginIdentifierConstraint constraint);
+
 #if !defined(ORTHANC_ENABLE_DCMTK) || ORTHANC_ENABLE_DCMTK != 0
     DcmEVR Convert(OrthancPluginValueRepresentation vr);
 #endif
--- a/Plugins/Samples/DatabasePlugin/CMakeLists.txt	Thu Oct 29 11:09:00 2015 +0100
+++ b/Plugins/Samples/DatabasePlugin/CMakeLists.txt	Thu Oct 29 11:22:48 2015 +0100
@@ -46,6 +46,7 @@
   ${ORTHANC_ROOT}/Core/DicomFormat/DicomArray.cpp
   ${ORTHANC_ROOT}/Core/DicomFormat/DicomMap.cpp
   ${ORTHANC_ROOT}/Core/DicomFormat/DicomTag.cpp
+  ${ORTHANC_ROOT}/Core/DicomFormat/DicomValue.cpp
   ${ORTHANC_ROOT}/Core/Enumerations.cpp
   ${ORTHANC_ROOT}/Core/SQLite/Connection.cpp
   ${ORTHANC_ROOT}/Core/SQLite/FunctionContext.cpp
--- a/Plugins/Samples/DatabasePlugin/Database.cpp	Thu Oct 29 11:09:00 2015 +0100
+++ b/Plugins/Samples/DatabasePlugin/Database.cpp	Thu Oct 29 11:22:48 2015 +0100
@@ -340,7 +340,7 @@
   {
     GetOutput().AnswerDicomTag(arr.GetElement(i).GetTag().GetGroup(),
                                arr.GetElement(i).GetTag().GetElement(),
-                               arr.GetElement(i).GetValue().AsString());
+                               arr.GetElement(i).GetValue().GetContent());
   }
 }
 
--- a/Plugins/Samples/DatabasePlugin/Database.h	Thu Oct 29 11:09:00 2015 +0100
+++ b/Plugins/Samples/DatabasePlugin/Database.h	Thu Oct 29 11:22:48 2015 +0100
@@ -99,6 +99,12 @@
 
   virtual void DeleteResource(int64_t id);
 
+  virtual void GetAllInternalIds(std::list<int64_t>& target,
+                                 OrthancPluginResourceType resourceType)
+  {
+    base_.GetAllInternalIds(target, Orthanc::Plugins::Convert(resourceType));
+  }
+
   virtual void GetAllPublicIds(std::list<std::string>& target,
                                OrthancPluginResourceType resourceType)
   {
@@ -187,14 +193,16 @@
     return base_.LookupGlobalProperty(target, static_cast<Orthanc::GlobalProperty>(property));
   }
 
-  virtual void LookupIdentifierExact(std::list<int64_t>& target /*out*/,
-                                     OrthancPluginResourceType level,
-                                     uint16_t group,
-                                     uint16_t element,
-                                     const char* value)
+  virtual void LookupIdentifier(std::list<int64_t>& target /*out*/,
+                                OrthancPluginResourceType level,
+                                uint16_t group,
+                                uint16_t element,
+                                OrthancPluginIdentifierConstraint constraint,
+                                const char* value)
   {
-    base_.LookupIdentifierExact(target, Orthanc::Plugins::Convert(level),
-                                Orthanc::DicomTag(group, element), value);
+    base_.LookupIdentifier(target, Orthanc::Plugins::Convert(level),
+                           Orthanc::DicomTag(group, element), 
+                           Orthanc::Plugins::Convert(constraint), value);
   }
 
   virtual bool LookupMetadata(std::string& target /*out*/,