changeset 187:d08d75fc6d6a java-code-model

synchronization of the code model with orthanc-java project
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 02 Jul 2024 17:02:11 +0200
parents 55473de7694f
children 87e546600cbe
files NEWS Resources/OrthancCPlugin-1.10.0.patch Resources/OrthancCPlugin-1.5.7.patch Resources/SyncOrthancFolder.py
diffstat 4 files changed, 38 insertions(+), 241 deletions(-) [+]
line wrap: on
line diff
--- a/NEWS	Tue Jul 02 16:10:35 2024 +0200
+++ b/NEWS	Tue Jul 02 17:02:11 2024 +0200
@@ -3,6 +3,7 @@
 
 * Created Python documentation for the Orthanc interface, check out "orthanc.pyi"
 * Added possibility to release the GIL during the call to the native SDK functions
+* Code model is now generated by the "orthanc-java" project
 * Added Windows builder for Python 3.12
 
 
--- a/Resources/OrthancCPlugin-1.10.0.patch	Tue Jul 02 16:10:35 2024 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,155 +0,0 @@
---- OrthancCPlugin.h.orig	2023-10-14 17:06:44.406226125 +0200
-+++ OrthancCPlugin.h	2023-10-14 17:09:26.978745058 +0200
-@@ -837,7 +837,7 @@
-    **/
-   typedef enum
-   {
--    OrthancPluginDicomToJsonFlags_None                  = 0,
-+    OrthancPluginDicomToJsonFlags_None                  = 0,         /*!< Default formatting */
-     OrthancPluginDicomToJsonFlags_IncludeBinary         = (1 << 0),  /*!< Include the binary tags */
-     OrthancPluginDicomToJsonFlags_IncludePrivateTags    = (1 << 1),  /*!< Include the private tags */
-     OrthancPluginDicomToJsonFlags_IncludeUnknownTags    = (1 << 2),  /*!< Include the tags unknown by the dictionary */
-@@ -858,7 +858,7 @@
-    **/
-   typedef enum
-   {
--    OrthancPluginCreateDicomFlags_None                  = 0,
-+    OrthancPluginCreateDicomFlags_None                  = 0,         /*!< Default mode */
-     OrthancPluginCreateDicomFlags_DecodeDataUriScheme   = (1 << 0),  /*!< Decode fields encoded using data URI scheme */
-     OrthancPluginCreateDicomFlags_GenerateIdentifiers   = (1 << 1),  /*!< Automatically generate DICOM identifiers */
- 
-@@ -975,32 +975,46 @@
-    **/
-   typedef enum
-   {
-+    /**
-+     * Success: The DICOM instance is properly stored in the SCP
-+     **/
-     OrthancPluginStorageCommitmentFailureReason_Success = 0,
--    /*!< Success: The DICOM instance is properly stored in the SCP */
- 
-+    /**
-+     * 0110H: A general failure in processing the operation was encountered
-+     **/
-     OrthancPluginStorageCommitmentFailureReason_ProcessingFailure = 1,
--    /*!< 0110H: A general failure in processing the operation was encountered */
- 
-+    /**
-+     * 0112H: One or more of the elements in the Referenced SOP
-+     * Instance Sequence was not available
-+     **/
-     OrthancPluginStorageCommitmentFailureReason_NoSuchObjectInstance = 2,
--    /*!< 0112H: One or more of the elements in the Referenced SOP
--      Instance Sequence was not available */
- 
-+    /**
-+     * 0213H: The SCP does not currently have enough resources to
-+     * store the requested SOP Instance(s)
-+     **/
-     OrthancPluginStorageCommitmentFailureReason_ResourceLimitation = 3,
--    /*!< 0213H: The SCP does not currently have enough resources to
--      store the requested SOP Instance(s) */
- 
-+    /**
-+     * 0122H: Storage Commitment has been requested for a SOP Instance
-+     * with a SOP Class that is not supported by the SCP
-+     **/
-     OrthancPluginStorageCommitmentFailureReason_ReferencedSOPClassNotSupported = 4,
--    /*!< 0122H: Storage Commitment has been requested for a SOP
--      Instance with a SOP Class that is not supported by the SCP */
- 
-+    /**
-+     * 0119H: The SOP Class of an element in the Referenced SOP
-+     * Instance Sequence did not correspond to the SOP class
-+     * registered for this SOP Instance at the SCP
-+     **/
-     OrthancPluginStorageCommitmentFailureReason_ClassInstanceConflict = 5,
--    /*!< 0119H: The SOP Class of an element in the Referenced SOP
--      Instance Sequence did not correspond to the SOP class registered
--      for this SOP Instance at the SCP */
- 
-+    /**
-+     * 0131H: The Transaction UID of the Storage Commitment Request is
-+     * already in use
-+     **/
-     OrthancPluginStorageCommitmentFailureReason_DuplicateTransactionUID = 6
--    /*!< 0131H: The Transaction UID of the Storage Commitment Request
--      is already in use */
-   } OrthancPluginStorageCommitmentFailureReason;
- 
- 
-@@ -1829,15 +1843,16 @@
-    * @see OrthancPluginCheckVersion
-    * @ingroup Callbacks
-    **/
--  ORTHANC_PLUGIN_INLINE int  OrthancPluginCheckVersionAdvanced(
-+  ORTHANC_PLUGIN_INLINE int32_t  OrthancPluginCheckVersionAdvanced(
-     OrthancPluginContext* context,
--    int expectedMajor,
--    int expectedMinor,
--    int expectedRevision)
-+    int32_t expectedMajor,
-+    int32_t expectedMinor,
-+    int32_t expectedRevision)
-   {
--    int major, minor, revision;
-+    int32_t major, minor, revision;
- 
--    if (sizeof(int32_t) != sizeof(OrthancPluginErrorCode) ||
-+    if (sizeof(int) != sizeof(int32_t) || /* Ensure binary compatibility with Orthanc SDK <= 1.12.1 */
-+        sizeof(int32_t) != sizeof(OrthancPluginErrorCode) ||
-         sizeof(int32_t) != sizeof(OrthancPluginHttpMethod) ||
-         sizeof(int32_t) != sizeof(_OrthancPluginService) ||
-         sizeof(int32_t) != sizeof(_OrthancPluginProperty) ||
-@@ -1935,7 +1950,7 @@
-    * @see OrthancPluginCheckVersionAdvanced
-    * @ingroup Callbacks
-    **/
--  ORTHANC_PLUGIN_INLINE int  OrthancPluginCheckVersion(
-+  ORTHANC_PLUGIN_INLINE int32_t  OrthancPluginCheckVersion(
-     OrthancPluginContext* context)
-   {
-     return OrthancPluginCheckVersionAdvanced(
-@@ -3077,7 +3092,7 @@
-    * @return 1 if the metadata is present, 0 if it is absent, -1 in case of error.
-    * @ingroup DicomInstance
-    **/
--  ORTHANC_PLUGIN_INLINE int  OrthancPluginHasInstanceMetadata(
-+  ORTHANC_PLUGIN_INLINE int32_t  OrthancPluginHasInstanceMetadata(
-     OrthancPluginContext*              context,
-     const OrthancPluginDicomInstance*  instance,
-     const char*                        metadata)
-@@ -3856,13 +3871,13 @@
-     OrthancPluginContext*    context,
-     OrthancPluginRestOutput* output,
-     uint16_t                 status,
--    const char*              body,
-+    const void*              body,
-     uint32_t                 bodySize)
-   {
-     _OrthancPluginSendHttpStatus params;
-     params.output = output;
-     params.status = status;
--    params.body = body;
-+    params.body = reinterpret_cast<const char*>(body);
-     params.bodySize = bodySize;
-     context->InvokeService(context, _OrthancPluginService_SendHttpStatus, &params);
-   }
-@@ -6760,7 +6775,7 @@
-   {
-     char**             resultId;
-     OrthancPluginJob  *job;
--    int                priority;
-+    int32_t            priority;
-   } _OrthancPluginSubmitJob;
- 
-   /**
-@@ -6779,7 +6794,7 @@
-   ORTHANC_PLUGIN_INLINE char *OrthancPluginSubmitJob(
-     OrthancPluginContext   *context,
-     OrthancPluginJob       *job,
--    int                     priority)
-+    int32_t                 priority)
-   {
-     char* resultId = NULL;
- 
--- a/Resources/OrthancCPlugin-1.5.7.patch	Tue Jul 02 16:10:35 2024 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,59 +0,0 @@
---- OrthancCPlugin.h.orig	2020-03-26 16:23:11.963320239 +0100
-+++ OrthancCPlugin.h	2020-03-26 16:24:45.403002064 +0100
-@@ -909,14 +909,14 @@
-    **/
-   typedef enum
-   {
--    OrthancPluginMetricsType_Default,   /*!< Default metrics */
-+    OrthancPluginMetricsType_Default = 0,   /*!< Default metrics */
- 
-     /**
-      * This metrics represents a time duration. Orthanc will keep the
-      * maximum value of the metrics over a sliding window of ten
-      * seconds, which is useful if the metrics is sampled frequently.
-      **/
--    OrthancPluginMetricsType_Timer
-+    OrthancPluginMetricsType_Timer = 1
-   } OrthancPluginMetricsType;
-   
- 
-@@ -926,9 +926,9 @@
-    **/
-   typedef enum
-   {
--    OrthancPluginDicomWebBinaryMode_Ignore,        /*!< Don't include binary tags */
--    OrthancPluginDicomWebBinaryMode_InlineBinary,  /*!< Inline encoding using Base64 */
--    OrthancPluginDicomWebBinaryMode_BulkDataUri    /*!< Use a bulk data URI field */
-+    OrthancPluginDicomWebBinaryMode_Ignore = 0,        /*!< Don't include binary tags */
-+    OrthancPluginDicomWebBinaryMode_InlineBinary = 1,  /*!< Inline encoding using Base64 */
-+    OrthancPluginDicomWebBinaryMode_BulkDataUri = 2    /*!< Use a bulk data URI field */
-   } OrthancPluginDicomWebBinaryMode;
- 
-   
-@@ -1915,7 +1915,7 @@
-   typedef struct
-   {
-     OrthancPluginRestOutput* output;
--    const char*              answer;
-+    const void*              answer;
-     uint32_t                 answerSize;
-     const char*              mimeType;
-   } _OrthancPluginAnswerBuffer;
-@@ -1935,7 +1935,7 @@
-   ORTHANC_PLUGIN_INLINE void OrthancPluginAnswerBuffer(
-     OrthancPluginContext*    context,
-     OrthancPluginRestOutput* output,
--    const char*              answer,
-+    const void*              answer,
-     uint32_t                 answerSize,
-     const char*              mimeType)
-   {
-@@ -2732,7 +2732,7 @@
-    * @return The pointer to the DICOM data, NULL in case of error.
-    * @ingroup Callbacks
-    **/
--  ORTHANC_PLUGIN_INLINE const char* OrthancPluginGetInstanceData(
-+  ORTHANC_PLUGIN_INLINE const void* OrthancPluginGetInstanceData(
-     OrthancPluginContext*        context,
-     OrthancPluginDicomInstance*  instance)
-   {
--- a/Resources/SyncOrthancFolder.py	Tue Jul 02 16:10:35 2024 +0200
+++ b/Resources/SyncOrthancFolder.py	Tue Jul 02 17:02:11 2024 +0200
@@ -12,8 +12,10 @@
 import urllib.request
 
 TARGET = os.path.join(os.path.dirname(__file__), 'Orthanc')
+ORTHANC_JAVA_VERSION = '1.0'
 PLUGIN_SDK_VERSION = '1.10.0'
-REPOSITORY = 'https://orthanc.uclouvain.be/hg/orthanc/raw-file'
+ORTHANC_CORE_REPOSITORY = 'https://orthanc.uclouvain.be/hg/orthanc/raw-file'
+ORTHANC_JAVA_REPOSITORY = 'https://orthanc.uclouvain.be/hg/orthanc-java/raw-file'
 
 FILES = [
     ('OrthancFramework/Resources/CMake/AutoGeneratedCode.cmake', 'CMake'),
@@ -34,15 +36,12 @@
     ('OrthancServer/Plugins/Samples/Common/VersionScriptPlugins.map', 'Plugins'),
 ]
 
-SDK = [
-    'orthanc/OrthancCPlugin.h',
-]
-
 
 def Download(x):
-    branch = x[0]
-    source = x[1]
-    target = os.path.join(TARGET, x[2])
+    repository = x[0]
+    branch = x[1]
+    source = x[2]
+    target = os.path.join(TARGET, x[3])
     print(target)
 
     try:
@@ -50,7 +49,7 @@
     except:
         pass
 
-    url = '%s/%s/%s' % (REPOSITORY, branch, source)
+    url = '%s/%s/%s' % (repository, branch, source)
 
     with open(target, 'wb') as f:
         try:
@@ -63,26 +62,37 @@
 commands = []
 
 for f in FILES:
-    commands.append([ 'default',
-                      f[0],
-                      os.path.join(f[1], os.path.basename(f[0])) ])
+    commands.append([
+        ORTHANC_CORE_REPOSITORY,
+        'default',
+        f[0],
+        os.path.join(f[1], os.path.basename(f[0]))
+    ])
+
+
+commands.append([
+    ORTHANC_JAVA_REPOSITORY,
+    'OrthancJava-%s' % ORTHANC_JAVA_VERSION,
+    'Resources/Orthanc/Sdk-%s/orthanc/OrthancCPlugin.h' % PLUGIN_SDK_VERSION,
+    'Sdk-%s/orthanc/OrthancCPlugin.h' % PLUGIN_SDK_VERSION,
+])
 
-for f in SDK:
-    commands.append([
-        'Orthanc-%s' % PLUGIN_SDK_VERSION, 
-        'OrthancServer/Plugins/Include/%s' % f,
-        'Sdk-%s/%s' % (PLUGIN_SDK_VERSION, f) 
-    ])
+
+commands.append([
+    ORTHANC_JAVA_REPOSITORY,
+    'OrthancJava-%s' % ORTHANC_JAVA_VERSION,
+    'CodeGeneration/CodeModel.json',
+    'Sdk-%s/CodeModel.json' % PLUGIN_SDK_VERSION,
+])
+
+
+commands.append([
+    ORTHANC_JAVA_REPOSITORY,
+    'OrthancJava-%s' % ORTHANC_JAVA_VERSION,
+    'CodeGeneration/CodeModel.json.license',
+    'Sdk-%s/CodeModel.json.license' % PLUGIN_SDK_VERSION,
+])
 
 
 pool = multiprocessing.Pool(10)  # simultaneous downloads
 pool.map(Download, commands)
-
-# Patch the SDK, if need be
-patch = os.path.join(os.path.abspath(os.path.dirname(__file__)),
-                     'OrthancCPlugin-%s.patch' % PLUGIN_SDK_VERSION)
-if os.path.exists(patch):
-    subprocess.check_call([ 'patch', '-p0', '-i', patch ],
-                          cwd = os.path.join(os.path.dirname(__file__),
-                                             'Orthanc',
-                                             'Sdk-%s' % PLUGIN_SDK_VERSION, 'orthanc'))