changeset 782:a60040857ce6

reorganization
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 02 May 2014 12:59:05 +0200
parents e7eb70772fbe
children efd0215736d9
files CMakeLists.txt OrthancServer/OrthancRestApi/OrthancRestAnonymizeModify.cpp OrthancServer/OrthancRestApi/OrthancRestResources.cpp UnitTestsSources/FromDcmtk.cpp UnitTestsSources/UnitTestsMain.cpp
diffstat 5 files changed, 42 insertions(+), 38 deletions(-) [+]
line wrap: on
line diff
--- a/CMakeLists.txt	Fri May 02 11:05:26 2014 +0200
+++ b/CMakeLists.txt	Fri May 02 12:59:05 2014 +0200
@@ -263,6 +263,7 @@
   ${GTEST_SOURCES}
   UnitTestsSources/DicomMap.cpp
   UnitTestsSources/FileStorage.cpp
+  UnitTestsSources/FromDcmtk.cpp
   UnitTestsSources/MemoryCache.cpp
   UnitTestsSources/Png.cpp
   UnitTestsSources/RestApi.cpp
--- a/OrthancServer/OrthancRestApi/OrthancRestAnonymizeModify.cpp	Fri May 02 11:05:26 2014 +0200
+++ b/OrthancServer/OrthancRestApi/OrthancRestAnonymizeModify.cpp	Fri May 02 12:59:05 2014 +0200
@@ -36,19 +36,6 @@
 
 namespace Orthanc
 {
-  // Raw access to the DICOM tags of an instance ------------------------------
-
-  static void GetRawContent(RestApi::GetCall& call)
-  {
-    std::string id = call.GetUriComponent("id", "");
-
-    ServerContext::DicomCacheLocker locker(OrthancRestApi::GetContext(call), id);
-
-    locker.GetDicom().SendPathValue(call.GetOutput(), call.GetTrailingUri());
-  }
-
-
-
   // Modification of DICOM instances ------------------------------------------
 
   namespace
@@ -61,7 +48,6 @@
   static void ReplaceInstanceInternal(ParsedDicomFile& toModify,
                                       const Removals& removals,
                                       const Replacements& replacements,
-                                      DicomReplaceMode mode,
                                       bool removePrivateTags)
   {
     if (removePrivateTags)
@@ -78,7 +64,7 @@
     for (Replacements::const_iterator it = replacements.begin(); 
          it != replacements.end(); ++it)
     {
-      toModify.Replace(it->first, it->second, mode);
+      toModify.Replace(it->first, it->second, DicomReplaceMode_InsertIfAbsent);
     }
 
     // A new SOP instance UID is automatically generated
@@ -336,7 +322,7 @@
     ServerContext::DicomCacheLocker locker(OrthancRestApi::GetContext(call), id);
 
     std::auto_ptr<ParsedDicomFile> modified(locker.GetDicom().Clone());
-    ReplaceInstanceInternal(*modified, removals, replacements, DicomReplaceMode_InsertIfAbsent, removePrivateTags);
+    ReplaceInstanceInternal(*modified, removals, replacements, removePrivateTags);
     modified->Answer(call.GetOutput());
   }
 
@@ -460,7 +446,7 @@
        **/
 
       std::auto_ptr<ParsedDicomFile> modified(original.Clone());
-      ReplaceInstanceInternal(*modified, removals, replacements, DicomReplaceMode_InsertIfAbsent, removePrivateTags);
+      ReplaceInstanceInternal(*modified, removals, replacements, removePrivateTags);
 
       std::string modifiedInstance;
       if (context.Store(modifiedInstance, modified->GetDicom()) != StoreStatus_Success)
@@ -680,8 +666,6 @@
 
   void OrthancRestApi::RegisterAnonymizeModify()
   {
-    Register("/instances/{id}/content/*", GetRawContent);
-
     Register("/instances/{id}/modify", ModifyInstance);
     Register("/series/{id}/modify", ModifySeriesInplace);
     Register("/studies/{id}/modify", ModifyStudyInplace);
--- a/OrthancServer/OrthancRestApi/OrthancRestResources.cpp	Fri May 02 11:05:26 2014 +0200
+++ b/OrthancServer/OrthancRestApi/OrthancRestResources.cpp	Fri May 02 12:59:05 2014 +0200
@@ -541,6 +541,17 @@
   }
 
 
+  // Raw access to the DICOM tags of an instance ------------------------------
+
+  static void GetRawContent(RestApi::GetCall& call)
+  {
+    std::string id = call.GetUriComponent("id", "");
+
+    ServerContext::DicomCacheLocker locker(OrthancRestApi::GetContext(call), id);
+
+    locker.GetDicom().SendPathValue(call.GetOutput(), call.GetTrailingUri());
+  }
+
 
 
   void OrthancRestApi::RegisterResources()
@@ -598,5 +609,7 @@
     Register("/{resourceType}/{id}/attachments/{name}/size", GetAttachmentSize);
     Register("/{resourceType}/{id}/attachments/{name}/verify-md5", VerifyAttachment);
     Register("/{resourceType}/{id}/attachments/{name}", UploadAttachment);
+
+    Register("/instances/{id}/content/*", GetRawContent);
   }
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/UnitTestsSources/FromDcmtk.cpp	Fri May 02 12:59:05 2014 +0200
@@ -0,0 +1,25 @@
+#include "gtest/gtest.h"
+
+#include "../OrthancServer/FromDcmtkBridge.h"
+#include "../OrthancServer/OrthancInitialization.h"
+
+using namespace Orthanc;
+
+TEST(DicomFormat, Tag)
+{
+  ASSERT_EQ("PatientName", FromDcmtkBridge::GetName(DicomTag(0x0010, 0x0010)));
+
+  DicomTag t = FromDcmtkBridge::ParseTag("SeriesDescription");
+  ASSERT_EQ(0x0008, t.GetGroup());
+  ASSERT_EQ(0x103E, t.GetElement());
+
+  t = FromDcmtkBridge::ParseTag("0020-e040");
+  ASSERT_EQ(0x0020, t.GetGroup());
+  ASSERT_EQ(0xe040, t.GetElement());
+
+  // Test ==() and !=() operators
+  ASSERT_TRUE(DICOM_TAG_PATIENT_ID == DicomTag(0x0010, 0x0020));
+  ASSERT_FALSE(DICOM_TAG_PATIENT_ID != DicomTag(0x0010, 0x0020));
+}
+
+
--- a/UnitTestsSources/UnitTestsMain.cpp	Fri May 02 11:05:26 2014 +0200
+++ b/UnitTestsSources/UnitTestsMain.cpp	Fri May 02 12:59:05 2014 +0200
@@ -10,7 +10,6 @@
 #include "../Core/OrthancException.h"
 #include "../Core/Toolbox.h"
 #include "../Core/Uuid.h"
-#include "../OrthancServer/FromDcmtkBridge.h"
 #include "../OrthancServer/OrthancInitialization.h"
 
 using namespace Orthanc;
@@ -178,24 +177,6 @@
   ASSERT_EQ(a["aaa"], "");
 }
 
-TEST(DicomFormat, Tag)
-{
-  ASSERT_EQ("PatientName", FromDcmtkBridge::GetName(DicomTag(0x0010, 0x0010)));
-
-  DicomTag t = FromDcmtkBridge::ParseTag("SeriesDescription");
-  ASSERT_EQ(0x0008, t.GetGroup());
-  ASSERT_EQ(0x103E, t.GetElement());
-
-  t = FromDcmtkBridge::ParseTag("0020-e040");
-  ASSERT_EQ(0x0020, t.GetGroup());
-  ASSERT_EQ(0xe040, t.GetElement());
-
-  // Test ==() and !=() operators
-  ASSERT_TRUE(DICOM_TAG_PATIENT_ID == DicomTag(0x0010, 0x0020));
-  ASSERT_FALSE(DICOM_TAG_PATIENT_ID != DicomTag(0x0010, 0x0020));
-}
-
-
 TEST(Uri, SplitUriComponents)
 {
   UriComponents c;