changeset 273:d384af918264

more detailed signal about deleted file
author Sebastien Jodogne <s.jodogne@gmail.com>
date Sat, 08 Dec 2012 22:34:56 +0100
parents 337c506461d2
children f2286c741109
files Core/SQLite/FunctionContext.cpp Core/SQLite/FunctionContext.h OrthancServer/DatabaseWrapper.cpp OrthancServer/IServerIndexListener.h OrthancServer/PrepareDatabase.sql OrthancServer/ServerIndex.cpp UnitTests/ServerIndex.cpp
diffstat 7 files changed, 26 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/Core/SQLite/FunctionContext.cpp	Fri Dec 07 18:21:04 2012 +0100
+++ b/Core/SQLite/FunctionContext.cpp	Sat Dec 08 22:34:56 2012 +0100
@@ -72,6 +72,12 @@
       return sqlite3_value_int(argv_[index]);
     }
 
+    int64_t FunctionContext::GetInt64Value(unsigned int index) const
+    {
+      CheckIndex(index);
+      return sqlite3_value_int64(argv_[index]);
+    }
+
     double FunctionContext::GetDoubleValue(unsigned int index) const
     {
       CheckIndex(index);
--- a/Core/SQLite/FunctionContext.h	Fri Dec 07 18:21:04 2012 +0100
+++ b/Core/SQLite/FunctionContext.h	Sat Dec 08 22:34:56 2012 +0100
@@ -69,6 +69,8 @@
 
       int GetIntValue(unsigned int index) const;
 
+      int64_t GetInt64Value(unsigned int index) const;
+
       double GetDoubleValue(unsigned int index) const;
 
       std::string GetStringValue(unsigned int index) const;
--- a/OrthancServer/DatabaseWrapper.cpp	Fri Dec 07 18:21:04 2012 +0100
+++ b/OrthancServer/DatabaseWrapper.cpp	Sat Dec 08 22:34:56 2012 +0100
@@ -33,6 +33,7 @@
 #include "DatabaseWrapper.h"
 
 #include "../Core/DicomFormat/DicomArray.h"
+#include "../Core/Uuid.h"
 #include "EmbeddedResources.h"
 
 #include <glog/logging.h>
@@ -61,12 +62,18 @@
 
       virtual unsigned int GetCardinality() const
       {
-        return 1;
+        return 5;
       }
 
       virtual void Compute(SQLite::FunctionContext& context)
       {
-        listener_.SignalFileDeleted(context.GetStringValue(0));
+        FileInfo info(context.GetStringValue(0),
+                      static_cast<FileContentType>(context.GetIntValue(1)),
+                      static_cast<uint64_t>(context.GetInt64Value(2)),
+                      static_cast<CompressionType>(context.GetIntValue(3)),
+                      static_cast<uint64_t>(context.GetInt64Value(4)));
+        
+        listener_.SignalFileDeleted(info);
       }
     };
 
--- a/OrthancServer/IServerIndexListener.h	Fri Dec 07 18:21:04 2012 +0100
+++ b/OrthancServer/IServerIndexListener.h	Sat Dec 08 22:34:56 2012 +0100
@@ -47,7 +47,6 @@
     virtual void SignalRemainingAncestor(ResourceType parentType,
                                          const std::string& publicId) = 0;
 
-    virtual void SignalFileDeleted(const std::string& fileUuid) = 0;                     
-                                 
+    virtual void SignalFileDeleted(const FileInfo& info) = 0;
   };
 }
--- a/OrthancServer/PrepareDatabase.sql	Fri Dec 07 18:21:04 2012 +0100
+++ b/OrthancServer/PrepareDatabase.sql	Sat Dec 08 22:34:56 2012 +0100
@@ -74,7 +74,8 @@
 CREATE TRIGGER AttachedFileDeleted
 AFTER DELETE ON AttachedFiles
 BEGIN
-  SELECT SignalFileDeleted(old.uuid);
+  SELECT SignalFileDeleted(old.uuid, old.fileType, old.uncompressedSize, 
+                           old.compressionType, old.compressedSize);
 END;
 
 CREATE TRIGGER ResourceDeleted
--- a/OrthancServer/ServerIndex.cpp	Fri Dec 07 18:21:04 2012 +0100
+++ b/OrthancServer/ServerIndex.cpp	Sat Dec 08 22:34:56 2012 +0100
@@ -108,10 +108,10 @@
         }        
       }
 
-      virtual void SignalFileDeleted(const std::string& fileUuid)
+      virtual void SignalFileDeleted(const FileInfo& info)
       {
-        assert(Toolbox::IsUuid(fileUuid));
-        pendingFilesToRemove_.push_back(fileUuid);
+        assert(Toolbox::IsUuid(info.GetUuid()));
+        pendingFilesToRemove_.push_back(info.GetUuid());
       }
 
       bool HasRemainingLevel() const
--- a/UnitTests/ServerIndex.cpp	Fri Dec 07 18:21:04 2012 +0100
+++ b/UnitTests/ServerIndex.cpp	Sat Dec 08 22:34:56 2012 +0100
@@ -1,7 +1,7 @@
 #include "gtest/gtest.h"
 
 #include "../OrthancServer/DatabaseWrapper.h"
-#include "../Core/Toolbox.h"
+#include "../Core/Uuid.h"
 
 #include <ctype.h>
 #include <glog/logging.h>
@@ -30,8 +30,9 @@
       ancestorType_ = type;
     }
 
-    virtual void SignalFileDeleted(const std::string& fileUuid)
+    virtual void SignalFileDeleted(const FileInfo& info)
     {
+      const std::string fileUuid = info.GetUuid();
       deletedFiles_.push_back(fileUuid);
       LOG(INFO) << "A file must be removed: " << fileUuid;
     }