changeset 3087:df1b17be20f6 db-changes

cont
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 04 Jan 2019 17:22:47 +0100
parents 74e3e48aa9bd
children d498ece73562
files OrthancServer/Search/DatabaseConstraint.cpp OrthancServer/Search/DatabaseConstraint.h OrthancServer/ServerIndex.cpp
diffstat 3 files changed, 24 insertions(+), 22 deletions(-) [+]
line wrap: on
line diff
--- a/OrthancServer/Search/DatabaseConstraint.cpp	Fri Jan 04 17:10:58 2019 +0100
+++ b/OrthancServer/Search/DatabaseConstraint.cpp	Fri Jan 04 17:22:47 2019 +0100
@@ -89,7 +89,7 @@
 #endif
 
 
-#if ORTHANC_PLUGINS_HAS_DATABASE_CONSTRAINT == 1
+#if ORTHANC_PLUGINS_HAS_DATABASE_OPTIMIZATIONS_1 == 1
     OrthancPluginConstraintType Convert(ConstraintType constraint)
     {
       switch (constraint)
@@ -116,7 +116,7 @@
 #endif    
 
     
-#if ORTHANC_PLUGINS_HAS_DATABASE_CONSTRAINT == 1
+#if ORTHANC_PLUGINS_HAS_DATABASE_OPTIMIZATIONS_1 == 1
     ConstraintType Convert(OrthancPluginConstraintType constraint)
     {
       switch (constraint)
@@ -166,7 +166,7 @@
   }      
 
     
-#if ORTHANC_PLUGINS_HAS_DATABASE_CONSTRAINT == 1
+#if ORTHANC_PLUGINS_HAS_DATABASE_OPTIMIZATIONS_1 == 1
   DatabaseConstraint::DatabaseConstraint(const OrthancPluginDatabaseConstraint& constraint) :
     level_(Plugins::Convert(constraint.level)),
     tag_(constraint.tagGroup, constraint.tagElement),
@@ -218,7 +218,7 @@
   }
 
 
-#if ORTHANC_PLUGINS_HAS_DATABASE_CONSTRAINT == 1
+#if ORTHANC_PLUGINS_HAS_DATABASE_OPTIMIZATIONS_1 == 1
   void DatabaseConstraint::EncodeForPlugins(OrthancPluginDatabaseConstraint& constraint,
                                             std::vector<const char*>& tmpValues) const
   {
--- a/OrthancServer/Search/DatabaseConstraint.h	Fri Jan 04 17:10:58 2019 +0100
+++ b/OrthancServer/Search/DatabaseConstraint.h	Fri Jan 04 17:22:47 2019 +0100
@@ -36,14 +36,14 @@
 #include "../../Core/DicomFormat/DicomMap.h"
 #include "../ServerEnumerations.h"
 
-#define ORTHANC_PLUGINS_HAS_DATABASE_CONSTRAINT 0
+#define ORTHANC_PLUGINS_HAS_DATABASE_OPTIMIZATIONS_1 0
 
 #if ORTHANC_ENABLE_PLUGINS == 1
 #  include <orthanc/OrthancCDatabasePlugin.h>
 #  if defined(ORTHANC_PLUGINS_VERSION_IS_ABOVE)      // Macro introduced in 1.3.1
 #    if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 5, 2)
-#      undef  ORTHANC_PLUGINS_HAS_DATABASE_CONSTRAINT
-#      define ORTHANC_PLUGINS_HAS_DATABASE_CONSTRAINT 1
+#      undef  ORTHANC_PLUGINS_HAS_DATABASE_OPTIMIZATIONS_1
+#      define ORTHANC_PLUGINS_HAS_DATABASE_OPTIMIZATIONS_1 1
 #    endif
 #  endif
 #endif
@@ -60,11 +60,11 @@
     ResourceType Convert(OrthancPluginResourceType type);
 #endif
 
-#if ORTHANC_PLUGINS_HAS_DATABASE_CONSTRAINT == 1
+#if ORTHANC_PLUGINS_HAS_DATABASE_OPTIMIZATIONS_1 == 1
     OrthancPluginConstraintType Convert(ConstraintType constraint);
 #endif
 
-#if ORTHANC_PLUGINS_HAS_DATABASE_CONSTRAINT == 1
+#if ORTHANC_PLUGINS_HAS_DATABASE_OPTIMIZATIONS_1 == 1
     ConstraintType Convert(OrthancPluginConstraintType constraint);
 #endif
   }
@@ -91,7 +91,7 @@
                        bool caseSensitive,
                        bool mandatory);
 
-#if ORTHANC_PLUGINS_HAS_DATABASE_CONSTRAINT == 1
+#if ORTHANC_PLUGINS_HAS_DATABASE_OPTIMIZATIONS_1 == 1
     DatabaseConstraint(const OrthancPluginDatabaseConstraint& constraint);
 #endif
     
@@ -136,7 +136,7 @@
 
     bool IsMatch(const DicomMap& dicom) const;
 
-#if ORTHANC_PLUGINS_HAS_DATABASE_CONSTRAINT == 1
+#if ORTHANC_PLUGINS_HAS_DATABASE_OPTIMIZATIONS_1 == 1
     void EncodeForPlugins(OrthancPluginDatabaseConstraint& constraint,
                           std::vector<const char*>& tmpValues) const;
 #endif    
--- a/OrthancServer/ServerIndex.cpp	Fri Jan 04 17:10:58 2019 +0100
+++ b/OrthancServer/ServerIndex.cpp	Fri Jan 04 17:22:47 2019 +0100
@@ -499,7 +499,7 @@
   }
 
 
-  static void ComputeExpectedNumberOfInstances(IDatabaseWrapper& db,
+  static void ComputeExpectedNumberOfInstances(ResourcesContent& target,
                                                int64_t series,
                                                const DicomMap& dicomSummary)
   {
@@ -515,7 +515,7 @@
         int64_t imagesInAcquisition = boost::lexical_cast<int64_t>(value->GetContent());
         int64_t countTemporalPositions = boost::lexical_cast<int64_t>(value2->GetContent());
         std::string expected = boost::lexical_cast<std::string>(imagesInAcquisition * countTemporalPositions);
-        db.SetMetadata(series, MetadataType_Series_ExpectedNumberOfInstances, expected);
+        target.AddMetadata(series, MetadataType_Series_ExpectedNumberOfInstances, expected);
       }
 
       else if ((value = dicomSummary.TestAndGetValue(DICOM_TAG_NUMBER_OF_SLICES)) != NULL &&
@@ -525,12 +525,12 @@
         int64_t numberOfSlices = boost::lexical_cast<int64_t>(value->GetContent());
         int64_t numberOfTimeSlices = boost::lexical_cast<int64_t>(value2->GetContent());
         std::string expected = boost::lexical_cast<std::string>(numberOfSlices * numberOfTimeSlices);
-        db.SetMetadata(series, MetadataType_Series_ExpectedNumberOfInstances, expected);
+        target.AddMetadata(series, MetadataType_Series_ExpectedNumberOfInstances, expected);
       }
 
       else if ((value = dicomSummary.TestAndGetValue(DICOM_TAG_CARDIAC_NUMBER_OF_IMAGES)) != NULL)
       {
-        db.SetMetadata(series, MetadataType_Series_ExpectedNumberOfInstances, value->GetContent());
+        target.AddMetadata(series, MetadataType_Series_ExpectedNumberOfInstances, value->GetContent());
       }
     }
     catch (OrthancException&)
@@ -909,22 +909,24 @@
         }
 
         
+        // Check whether the series of this new instance is now completed
+        if (status.isNewSeries_)
+        {
+          ComputeExpectedNumberOfInstances(content, status.seriesId_, dicomSummary);
+        }
+
+        
         db_.SetResourcesContent(content);
       }
 
 
-
-      // Check whether the series of this new instance is now completed
-      if (status.isNewSeries_)
-      {
-        ComputeExpectedNumberOfInstances(db_, status.seriesId_, dicomSummary);
-      }
-
+      // TODO - SPEED THIS UP
       SeriesStatus seriesStatus = GetSeriesStatus(status.seriesId_);
       if (seriesStatus == SeriesStatus_Complete)
       {
         LogChange(status.seriesId_, ChangeType_CompletedSeries, ResourceType_Series, hashSeries);
       }
+      
 
       // Mark the parent resources of this instance as unstable
       MarkAsUnstable(status.seriesId_, ResourceType_Series, hashSeries);