changeset 82:9eb40cad7935

fixes
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 24 Sep 2012 14:05:19 +0200
parents 0ec5e2e327b1
children a7bffca29031
files Core/DicomFormat/DicomMap.cpp Core/Uuid.cpp Core/Uuid.h NEWS OrthancExplorer/explorer.js OrthancServer/PrepareDatabase.sql OrthancServer/ServerIndex.cpp OrthancServer/ServerIndex.h
diffstat 8 files changed, 86 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/Core/DicomFormat/DicomMap.cpp	Mon Sep 24 10:33:41 2012 +0200
+++ b/Core/DicomFormat/DicomMap.cpp	Mon Sep 24 14:05:19 2012 +0200
@@ -64,7 +64,7 @@
     DicomTag(0x0018, 0x0024),   // SequenceName
     DicomTag(0x0018, 0x1030),   // ProtocolName
     DicomTag(0x0020, 0x0011),   // SeriesNumber
-    DICOM_TAG_CARDIAC_NUMBER_OF_IMAGES,
+    //DICOM_TAG_CARDIAC_NUMBER_OF_IMAGES,
     DICOM_TAG_IMAGES_IN_ACQUISITION,
     DICOM_TAG_NUMBER_OF_FRAMES,
     DICOM_TAG_NUMBER_OF_SLICES,
--- a/Core/Uuid.cpp	Mon Sep 24 10:33:41 2012 +0200
+++ b/Core/Uuid.cpp	Mon Sep 24 14:05:19 2012 +0200
@@ -31,6 +31,8 @@
 #endif
 }
 
+#include <boost/filesystem.hpp>
+
 namespace Orthanc
 {
   namespace Toolbox
@@ -80,5 +82,20 @@
 
       return true;
     }
+
+
+    TemporaryFile::TemporaryFile()
+    {
+      // We use UUID to create unique path to temporary files
+      boost::filesystem::path tmp = boost::filesystem::temp_directory_path();
+      tmp /= "Orthanc-" + Orthanc::Toolbox::GenerateUuid();
+      path_ = tmp.string();
+    }
+
+
+    TemporaryFile::~TemporaryFile()
+    {
+      boost::filesystem::remove(path_);
+    }  
   }
 }
--- a/Core/Uuid.h	Mon Sep 24 10:33:41 2012 +0200
+++ b/Core/Uuid.h	Mon Sep 24 14:05:19 2012 +0200
@@ -38,5 +38,21 @@
     std::string GenerateUuid();
 
     bool IsUuid(const std::string& str);
+
+    class TemporaryFile
+    {
+    private:
+      std::string path_;
+
+    public:
+      TemporaryFile();
+
+      ~TemporaryFile();
+
+      const std::string& GetPath() const
+      {
+        return path_;
+      }
+    };
   }
 }
--- a/NEWS	Mon Sep 24 10:33:41 2012 +0200
+++ b/NEWS	Mon Sep 24 14:05:19 2012 +0200
@@ -2,6 +2,7 @@
 ===============================
 
 * Status of series
+* Continuous Integration Server is up and running
 
 
 Version 0.2.0 (2012/09/16)
--- a/OrthancExplorer/explorer.js	Mon Sep 24 10:33:41 2012 +0200
+++ b/OrthancExplorer/explorer.js	Mon Sep 24 14:05:19 2012 +0200
@@ -274,9 +274,10 @@
 function FormatSeries(series, link, isReverse)
 {
   var c;
-  if (series.Instances.length == series.ExpectedNumberOfInstances)
+  if (series.ExpectedNumberOfInstances == null ||
+      series.Instances.length == series.ExpectedNumberOfInstances)
   {
-    c = series.ExpectedNumberOfInstances;
+    c = series.Instances.length;
   }
   else
   {
--- a/OrthancServer/PrepareDatabase.sql	Mon Sep 24 10:33:41 2012 +0200
+++ b/OrthancServer/PrepareDatabase.sql	Mon Sep 24 14:05:19 2012 +0200
@@ -3,6 +3,11 @@
        value TEXT
        );
 
+CREATE TABLE Resources(
+       uuid TEXT PRIMARY KEY,
+       resourceType INTEGER
+       );
+
 CREATE TABLE Patients(
        uuid TEXT PRIMARY KEY,
        dicomPatientId TEXT
@@ -65,6 +70,7 @@
 CREATE TRIGGER InstanceRemoved
 AFTER DELETE ON Instances
 FOR EACH ROW BEGIN
+  DELETE FROM Resources WHERE uuid = old.uuid;
   DELETE FROM MainDicomTags WHERE uuid = old.uuid;
   DELETE FROM Changes WHERE uuid = old.uuid;
   SELECT DeleteFromFileStorage(old.fileUuid);
@@ -75,6 +81,7 @@
 CREATE TRIGGER SeriesRemoved
 AFTER DELETE ON Series
 FOR EACH ROW BEGIN
+  DELETE FROM Resources WHERE uuid = old.uuid;
   DELETE FROM MainDicomTags WHERE uuid = old.uuid;
   DELETE FROM Changes WHERE uuid = old.uuid;
   SELECT SignalDeletedLevel(2, old.parentStudy);
@@ -83,6 +90,7 @@
 CREATE TRIGGER StudyRemoved
 AFTER DELETE ON Studies
 FOR EACH ROW BEGIN
+  DELETE FROM Resources WHERE uuid = old.uuid;
   DELETE FROM MainDicomTags WHERE uuid = old.uuid;
   DELETE FROM Changes WHERE uuid = old.uuid;
   SELECT SignalDeletedLevel(1, old.parentPatient);
@@ -91,6 +99,7 @@
 CREATE TRIGGER PatientRemoved
 AFTER DELETE ON Patients
 FOR EACH ROW BEGIN
+  DELETE FROM Resources WHERE uuid = old.uuid;
   DELETE FROM MainDicomTags WHERE uuid = old.uuid;
   DELETE FROM Changes WHERE uuid = old.uuid;
   SELECT SignalDeletedLevel(0, "");
--- a/OrthancServer/ServerIndex.cpp	Mon Sep 24 10:33:41 2012 +0200
+++ b/OrthancServer/ServerIndex.cpp	Mon Sep 24 14:05:19 2012 +0200
@@ -231,6 +231,11 @@
   {
     std::string instanceUuid = Toolbox::GenerateUuid();
 
+    SQLite::Statement s2(db_, SQLITE_FROM_HERE, "INSERT INTO Resources VALUES(?, ?)");
+    s2.BindString(0, instanceUuid);
+    s2.BindInt(1, ResourceType_Instance);
+    s2.Run();
+
     SQLite::Statement s(db_, SQLITE_FROM_HERE, "INSERT INTO Instances VALUES(?, ?, ?, ?, ?, ?, ?, ?)");
     s.BindString(0, instanceUuid);
     s.BindString(1, parentSeriesUuid);
@@ -291,6 +296,11 @@
   {
     std::string seriesUuid = Toolbox::GenerateUuid();
 
+    SQLite::Statement s2(db_, SQLITE_FROM_HERE, "INSERT INTO Resources VALUES(?, ?)");
+    s2.BindString(0, seriesUuid);
+    s2.BindInt(1, ResourceType_Series);
+    s2.Run();
+
     SQLite::Statement s(db_, SQLITE_FROM_HERE, "INSERT INTO Series VALUES(?, ?, ?, ?)");
     s.BindString(0, seriesUuid);
     s.BindString(1, parentStudyUuid);
@@ -299,7 +309,7 @@
     const DicomValue* expectedNumberOfInstances;
     if ((expectedNumberOfInstances = dicomSummary.TestAndGetValue(DICOM_TAG_NUMBER_OF_FRAMES)) != NULL ||
         (expectedNumberOfInstances = dicomSummary.TestAndGetValue(DICOM_TAG_NUMBER_OF_SLICES)) != NULL ||
-        (expectedNumberOfInstances = dicomSummary.TestAndGetValue(DICOM_TAG_CARDIAC_NUMBER_OF_IMAGES)) != NULL ||
+        //(expectedNumberOfInstances = dicomSummary.TestAndGetValue(DICOM_TAG_CARDIAC_NUMBER_OF_IMAGES)) != NULL ||
         (expectedNumberOfInstances = dicomSummary.TestAndGetValue(DICOM_TAG_IMAGES_IN_ACQUISITION)) != NULL)
     {
       s.BindInt(3, boost::lexical_cast<unsigned int>(expectedNumberOfInstances->AsString()));
@@ -342,6 +352,11 @@
   {
     std::string studyUuid = Toolbox::GenerateUuid();
 
+    SQLite::Statement s2(db_, SQLITE_FROM_HERE, "INSERT INTO Resources VALUES(?, ?)");
+    s2.BindString(0, studyUuid);
+    s2.BindInt(1, ResourceType_Study);
+    s2.Run();
+
     SQLite::Statement s(db_, SQLITE_FROM_HERE, "INSERT INTO Studies VALUES(?, ?, ?)");
     s.BindString(0, studyUuid);
     s.BindString(1, parentPatientUuid);
@@ -381,6 +396,11 @@
     std::string patientUuid = Toolbox::GenerateUuid();
     std::string dicomPatientId = dicomSummary.GetValue(DICOM_TAG_PATIENT_ID).AsString();
 
+    SQLite::Statement s2(db_, SQLITE_FROM_HERE, "INSERT INTO Resources VALUES(?, ?)");
+    s2.BindString(0, patientUuid);
+    s2.BindInt(1, ResourceType_Patient);
+    s2.Run();
+
     SQLite::Statement s(db_, SQLITE_FROM_HERE, "INSERT INTO Patients VALUES(?, ?)");
     s.BindString(0, patientUuid);
     s.BindString(1, dicomPatientId);
@@ -611,7 +631,7 @@
   {
     SQLite::Statement s1(db_, SQLITE_FROM_HERE, "SELECT expectedNumberOfInstances FROM Series WHERE uuid=?");
     s1.BindString(0, seriesUuid);
-    if (!s1.Step())
+    if (!s1.Step() || s1.ColumnIsNull(0))
     {
       return SeriesStatus_Unknown;
     }
@@ -678,7 +698,7 @@
       
       if (s.ColumnIsNull(4))
       {
-        result["IndexInSeries"] = -1;
+        result["IndexInSeries"] = Json::nullValue;
       }
       else
       {
@@ -719,7 +739,7 @@
 
     if (s1.ColumnIsNull(2))
     {
-      result["ExpectedNumberOfInstances"] = -1;
+      result["ExpectedNumberOfInstances"] = Json::nullValue;
     }
     else
     {
@@ -926,4 +946,5 @@
 
     return true;
   }
+
 }
--- a/OrthancServer/ServerIndex.h	Mon Sep 24 10:33:41 2012 +0200
+++ b/OrthancServer/ServerIndex.h	Mon Sep 24 14:05:19 2012 +0200
@@ -45,6 +45,16 @@
   };
 
 
+  enum ResourceType
+  {
+    ResourceType_Patient = 1,
+    ResourceType_Study = 2,
+    ResourceType_Series = 3,
+    ResourceType_Instance = 4,
+    ResourceType_File = 5
+  };
+
+
   namespace Internals
   {
     class SignalDeletedLevelFunction;
@@ -189,5 +199,9 @@
                     int64_t since,
                     const std::string& filter,
                     unsigned int maxResults);
+
+    /*bool GetAllInstances(std::list<std::string>& instancesUuid,
+                         const std::string& uuid,
+                         bool clear = true);*/
   };
 }