changeset 1823:0ef4e6e66b56

"Origin" metadata for the instances
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 25 Nov 2015 10:32:54 +0100
parents 9ed9458aa44f
children b530c3dfe2a6
files Core/Enumerations.cpp Core/Enumerations.h Core/HttpServer/MongooseServer.cpp NEWS OrthancServer/DicomInstanceToStore.cpp OrthancServer/ServerEnumerations.cpp OrthancServer/ServerEnumerations.h OrthancServer/ServerIndex.cpp Plugins/Engine/PluginsEnumerations.cpp UnitTestsSources/ServerIndexTests.cpp
diffstat 10 files changed, 34 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- a/Core/Enumerations.cpp	Wed Nov 25 10:06:50 2015 +0100
+++ b/Core/Enumerations.cpp	Wed Nov 25 10:32:54 2015 +0100
@@ -681,8 +681,8 @@
       case RequestOrigin_DicomProtocol:
         return "DicomProtocol";
 
-      case RequestOrigin_Http:
-        return "Http";
+      case RequestOrigin_RestApi:
+        return "RestApi";
 
       case RequestOrigin_Plugins:
         return "Plugins";
--- a/Core/Enumerations.h	Wed Nov 25 10:06:50 2015 +0100
+++ b/Core/Enumerations.h	Wed Nov 25 10:32:54 2015 +0100
@@ -370,7 +370,7 @@
   {
     RequestOrigin_Unknown,
     RequestOrigin_DicomProtocol,
-    RequestOrigin_Http,
+    RequestOrigin_RestApi,
     RequestOrigin_Plugins,
     RequestOrigin_Lua
   };
--- a/Core/HttpServer/MongooseServer.cpp	Wed Nov 25 10:06:50 2015 +0100
+++ b/Core/HttpServer/MongooseServer.cpp	Wed Nov 25 10:32:54 2015 +0100
@@ -727,7 +727,7 @@
       {
         if (that->HasHandler())
         {
-          found = that->GetHandler().Handle(output, RequestOrigin_Http, remoteIp, username.c_str(), 
+          found = that->GetHandler().Handle(output, RequestOrigin_RestApi, remoteIp, username.c_str(), 
                                             method, uri, headers, argumentsGET, body.c_str(), body.size());
         }
       }
--- a/NEWS	Wed Nov 25 10:06:50 2015 +0100
+++ b/NEWS	Wed Nov 25 10:32:54 2015 +0100
@@ -7,6 +7,23 @@
 * Experimental support of DICOM C-Find SCP for modality worklists through plugins
 * Support of DICOM C-Find SCU for modality worklists ("/modalities/{dicom}/find-worklist")
 
+REST API
+--------
+
+* New URIs:
+  - "/series/.../ordered-slices" to order the slices of a 2D+t or 3D series
+  - "/tools/shutdown" to stop Orthanc from the REST API
+  - ".../compress", ".../uncompress" and ".../is-compressed" for attachments
+  - "/tools/create-archive" to create ZIP from a set of resources
+  - "/tools/create-media" to create ZIP+DICOMDIR from a set of resources
+* "/tools/create-dicom":
+  - Support of binary tags encoded using data URI scheme
+  - Support of hierarchical structures (creation of sequences)
+  - Create tags with unknown VR
+* "/modify" can insert/modify sequences
+* ".../preview" and ".../image-uint8" can return JPEG images if the HTTP Accept Header asks so
+* "Origin" metadata for the instances
+
 Minor
 -----
 
@@ -14,18 +31,7 @@
   - "UnknownSopClassAccepted" to disable promiscuous mode (accept unknown SOP class UID)
   - New configuration option: "Dictionary" to declare custom DICOM tags
 * Add ".dcm" suffix to files in ZIP archives (cf. URI ".../archive")
-* "/tools/create-dicom":
-  - Support of binary tags encoded using data URI scheme
-  - Support of hierarchical structures (creation of sequences)
-  - Create tags with unknown VR
-* "/modify" can insert/modify sequences
-* "/series/.../ordered-slices" to order the slices of a 2D+t or 3D image
-* New URI "/tools/shutdown" to stop Orthanc from the REST API
-* New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
 * MIME content type can be associated to custom attachments (cf. "UserContentType")
-* New URIs "/tools/create-archive" and "/tools/create-media" to create ZIP/DICOMDIR
-  from a set of resources
-* ".../preview" and ".../image-uint8" can return JPEG images if the HTTP Accept Header asks so
 
 Plugins
 -------
--- a/OrthancServer/DicomInstanceToStore.cpp	Wed Nov 25 10:06:50 2015 +0100
+++ b/OrthancServer/DicomInstanceToStore.cpp	Wed Nov 25 10:32:54 2015 +0100
@@ -202,7 +202,7 @@
         break;
       }
 
-      case RequestOrigin_Http:
+      case RequestOrigin_RestApi:
       {
         result["RemoteIp"] = remoteIp_;
         result["Username"] = httpUsername_;
@@ -236,7 +236,7 @@
   {
     origin_ = call.GetRequestOrigin();
 
-    if (origin_ == RequestOrigin_Http)
+    if (origin_ == RequestOrigin_RestApi)
     {
       remoteIp_ = call.GetRemoteIp();
       httpUsername_ = call.GetUsername();
@@ -246,7 +246,7 @@
   void DicomInstanceToStore::SetHttpOrigin(const char* remoteIp,
                                            const char* username)
   {
-    origin_ = RequestOrigin_Http;
+    origin_ = RequestOrigin_RestApi;
     remoteIp_ = remoteIp;
     httpUsername_ = username;
   }
--- a/OrthancServer/ServerEnumerations.cpp	Wed Nov 25 10:06:50 2015 +0100
+++ b/OrthancServer/ServerEnumerations.cpp	Wed Nov 25 10:32:54 2015 +0100
@@ -63,6 +63,7 @@
     dictMetadataType_.Add(MetadataType_ModifiedFrom, "ModifiedFrom");
     dictMetadataType_.Add(MetadataType_AnonymizedFrom, "AnonymizedFrom");
     dictMetadataType_.Add(MetadataType_LastUpdate, "LastUpdate");
+    dictMetadataType_.Add(MetadataType_Instance_Origin, "Origin");
 
     dictContentType_.Add(FileContentType_Dicom, "dicom");
     dictContentType_.Add(FileContentType_DicomAsJson, "dicom-as-json");
--- a/OrthancServer/ServerEnumerations.h	Wed Nov 25 10:06:50 2015 +0100
+++ b/OrthancServer/ServerEnumerations.h	Wed Nov 25 10:32:54 2015 +0100
@@ -164,6 +164,7 @@
     MetadataType_ModifiedFrom = 5,
     MetadataType_AnonymizedFrom = 6,
     MetadataType_LastUpdate = 7,
+    MetadataType_Instance_Origin = 8,   // New in Orthanc 0.9.5
 
     // Make sure that the value "65535" can be stored into this enumeration
     MetadataType_StartUser = 1024,
--- a/OrthancServer/ServerIndex.cpp	Wed Nov 25 10:06:50 2015 +0100
+++ b/OrthancServer/ServerIndex.cpp	Wed Nov 25 10:32:54 2015 +0100
@@ -771,6 +771,12 @@
       db_.SetMetadata(instance, MetadataType_Instance_RemoteAet, instanceToStore.GetRemoteAet());
       instanceMetadata[MetadataType_Instance_RemoteAet] = instanceToStore.GetRemoteAet();
 
+      {
+        std::string s = EnumerationToString(instanceToStore.GetRequestOrigin());
+        db_.SetMetadata(instance, MetadataType_Instance_Origin, s);
+        instanceMetadata[MetadataType_Instance_Origin] = s;
+      }
+
       const DicomValue* value;
       if ((value = dicomSummary.TestAndGetValue(DICOM_TAG_INSTANCE_NUMBER)) != NULL ||
           (value = dicomSummary.TestAndGetValue(DICOM_TAG_IMAGE_INDEX)) != NULL)
--- a/Plugins/Engine/PluginsEnumerations.cpp	Wed Nov 25 10:06:50 2015 +0100
+++ b/Plugins/Engine/PluginsEnumerations.cpp	Wed Nov 25 10:32:54 2015 +0100
@@ -286,7 +286,7 @@
         case RequestOrigin_DicomProtocol:
           return OrthancPluginInstanceOrigin_DicomProtocol;
 
-        case RequestOrigin_Http:
+        case RequestOrigin_RestApi:
           return OrthancPluginInstanceOrigin_RestApi;
 
         case RequestOrigin_Lua:
--- a/UnitTestsSources/ServerIndexTests.cpp	Wed Nov 25 10:06:50 2015 +0100
+++ b/UnitTestsSources/ServerIndexTests.cpp	Wed Nov 25 10:32:54 2015 +0100
@@ -799,7 +799,7 @@
     DicomInstanceToStore toStore;
     toStore.SetSummary(instance);
     ASSERT_EQ(StoreStatus_Success, index.Store(instanceMetadata, toStore, attachments));
-    ASSERT_EQ(2u, instanceMetadata.size());
+    ASSERT_EQ(3u, instanceMetadata.size());
     ASSERT_TRUE(instanceMetadata.find(MetadataType_Instance_RemoteAet) != instanceMetadata.end());
     ASSERT_TRUE(instanceMetadata.find(MetadataType_Instance_ReceptionDate) != instanceMetadata.end());