Mercurial > hg > orthanc
annotate OrthancServer/Sources/ServerJobs/OrthancJobUnserializer.cpp @ 5853:4d932683049d get-scu tip
very first implementation of C-Get SCU
author | Alain Mazy <am@orthanc.team> |
---|---|
date | Tue, 29 Oct 2024 17:25:49 +0100 |
parents | f7adfb22e20e |
children |
rev | line source |
---|---|
2621
83ac5a05ce84
primitives for unserializing jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1 /** |
83ac5a05ce84
primitives for unserializing jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2 * Orthanc - A Lightweight, RESTful DICOM Store |
83ac5a05ce84
primitives for unserializing jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics |
83ac5a05ce84
primitives for unserializing jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
4 * Department, University Hospital of Liege, Belgium |
5640
f7adfb22e20e
updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5485
diff
changeset
|
5 * Copyright (C) 2017-2023 Osimis S.A., Belgium |
f7adfb22e20e
updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5485
diff
changeset
|
6 * Copyright (C) 2024-2024 Orthanc Team SRL, Belgium |
5485
48b8dae6dc77
upgrade to year 2024
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
7 * Copyright (C) 2021-2024 Sebastien Jodogne, ICTEAM UCLouvain, Belgium |
2621
83ac5a05ce84
primitives for unserializing jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
8 * |
83ac5a05ce84
primitives for unserializing jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
9 * This program is free software: you can redistribute it and/or |
83ac5a05ce84
primitives for unserializing jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
10 * modify it under the terms of the GNU General Public License as |
83ac5a05ce84
primitives for unserializing jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
11 * published by the Free Software Foundation, either version 3 of the |
83ac5a05ce84
primitives for unserializing jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
12 * License, or (at your option) any later version. |
83ac5a05ce84
primitives for unserializing jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
13 * |
83ac5a05ce84
primitives for unserializing jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
14 * This program is distributed in the hope that it will be useful, but |
83ac5a05ce84
primitives for unserializing jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
15 * WITHOUT ANY WARRANTY; without even the implied warranty of |
83ac5a05ce84
primitives for unserializing jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
83ac5a05ce84
primitives for unserializing jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
17 * General Public License for more details. |
83ac5a05ce84
primitives for unserializing jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
18 * |
83ac5a05ce84
primitives for unserializing jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
19 * You should have received a copy of the GNU General Public License |
83ac5a05ce84
primitives for unserializing jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
20 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
83ac5a05ce84
primitives for unserializing jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
21 **/ |
83ac5a05ce84
primitives for unserializing jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
22 |
83ac5a05ce84
primitives for unserializing jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
23 |
83ac5a05ce84
primitives for unserializing jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
24 #include "../PrecompiledHeadersServer.h" |
83ac5a05ce84
primitives for unserializing jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
25 #include "OrthancJobUnserializer.h" |
83ac5a05ce84
primitives for unserializing jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
26 |
4045 | 27 #include "../../../OrthancFramework/Sources/Logging.h" |
28 #include "../../../OrthancFramework/Sources/OrthancException.h" | |
29 #include "../../../OrthancFramework/Sources/SerializationToolbox.h" | |
3085 | 30 #include "../../Plugins/Engine/OrthancPlugins.h" |
3096 | 31 #include "../ServerContext.h" |
2621
83ac5a05ce84
primitives for unserializing jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
32 |
2655 | 33 #include "Operations/DeleteResourceOperation.h" |
2641 | 34 #include "Operations/DicomInstanceOperationValue.h" |
2655 | 35 #include "Operations/ModifyInstanceOperation.h" |
36 #include "Operations/StorePeerOperation.h" | |
37 #include "Operations/StoreScuOperation.h" | |
38 #include "Operations/SystemCallOperation.h" | |
2621
83ac5a05ce84
primitives for unserializing jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
39 |
2664
a21b244efb37
serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2656
diff
changeset
|
40 #include "DicomModalityStoreJob.h" |
2867 | 41 #include "DicomMoveScuJob.h" |
3638
ae866fc06df5
serialization of StorageCommitmentScpJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3096
diff
changeset
|
42 #include "MergeStudyJob.h" |
2664
a21b244efb37
serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2656
diff
changeset
|
43 #include "OrthancPeerStoreJob.h" |
a21b244efb37
serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2656
diff
changeset
|
44 #include "ResourceModificationJob.h" |
2845
218e2c864d1d
serialization of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
45 #include "SplitStudyJob.h" |
3638
ae866fc06df5
serialization of StorageCommitmentScpJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3096
diff
changeset
|
46 #include "StorageCommitmentScpJob.h" |
2664
a21b244efb37
serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2656
diff
changeset
|
47 |
3085 | 48 |
2621
83ac5a05ce84
primitives for unserializing jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
49 namespace Orthanc |
83ac5a05ce84
primitives for unserializing jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
50 { |
2652 | 51 IJob* OrthancJobUnserializer::UnserializeJob(const Json::Value& source) |
2621
83ac5a05ce84
primitives for unserializing jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
52 { |
2664
a21b244efb37
serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2656
diff
changeset
|
53 const std::string type = SerializationToolbox::ReadString(source, "Type"); |
a21b244efb37
serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2656
diff
changeset
|
54 |
2815
925d8dc03a23
unserialization of jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2664
diff
changeset
|
55 #if ORTHANC_ENABLE_PLUGINS == 1 |
925d8dc03a23
unserialization of jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2664
diff
changeset
|
56 if (context_.HasPlugins()) |
925d8dc03a23
unserialization of jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2664
diff
changeset
|
57 { |
3712
2a170a8f1faf
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
58 std::unique_ptr<IJob> job(context_.GetPlugins().UnserializeJob(type, source)); |
2815
925d8dc03a23
unserialization of jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2664
diff
changeset
|
59 if (job.get() != NULL) |
925d8dc03a23
unserialization of jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2664
diff
changeset
|
60 { |
925d8dc03a23
unserialization of jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2664
diff
changeset
|
61 return job.release(); |
925d8dc03a23
unserialization of jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2664
diff
changeset
|
62 } |
925d8dc03a23
unserialization of jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2664
diff
changeset
|
63 } |
925d8dc03a23
unserialization of jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2664
diff
changeset
|
64 #endif |
925d8dc03a23
unserialization of jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2664
diff
changeset
|
65 |
2664
a21b244efb37
serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2656
diff
changeset
|
66 if (type == "DicomModalityStore") |
a21b244efb37
serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2656
diff
changeset
|
67 { |
a21b244efb37
serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2656
diff
changeset
|
68 return new DicomModalityStoreJob(context_, source); |
a21b244efb37
serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2656
diff
changeset
|
69 } |
a21b244efb37
serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2656
diff
changeset
|
70 else if (type == "OrthancPeerStore") |
a21b244efb37
serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2656
diff
changeset
|
71 { |
a21b244efb37
serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2656
diff
changeset
|
72 return new OrthancPeerStoreJob(context_, source); |
a21b244efb37
serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2656
diff
changeset
|
73 } |
a21b244efb37
serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2656
diff
changeset
|
74 else if (type == "ResourceModification") |
a21b244efb37
serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2656
diff
changeset
|
75 { |
a21b244efb37
serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2656
diff
changeset
|
76 return new ResourceModificationJob(context_, source); |
a21b244efb37
serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2656
diff
changeset
|
77 } |
2853
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2845
diff
changeset
|
78 else if (type == "MergeStudy") |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2845
diff
changeset
|
79 { |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2845
diff
changeset
|
80 return new MergeStudyJob(context_, source); |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2845
diff
changeset
|
81 } |
2845
218e2c864d1d
serialization of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
82 else if (type == "SplitStudy") |
218e2c864d1d
serialization of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
83 { |
218e2c864d1d
serialization of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
84 return new SplitStudyJob(context_, source); |
218e2c864d1d
serialization of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
85 } |
2867 | 86 else if (type == "DicomMoveScu") |
87 { | |
88 return new DicomMoveScuJob(context_, source); | |
89 } | |
3638
ae866fc06df5
serialization of StorageCommitmentScpJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3096
diff
changeset
|
90 else if (type == "StorageCommitmentScp") |
ae866fc06df5
serialization of StorageCommitmentScpJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3096
diff
changeset
|
91 { |
ae866fc06df5
serialization of StorageCommitmentScpJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3096
diff
changeset
|
92 return new StorageCommitmentScpJob(context_, source); |
ae866fc06df5
serialization of StorageCommitmentScpJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3096
diff
changeset
|
93 } |
2664
a21b244efb37
serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2656
diff
changeset
|
94 else |
a21b244efb37
serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2656
diff
changeset
|
95 { |
a21b244efb37
serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2656
diff
changeset
|
96 return GenericJobUnserializer::UnserializeJob(source); |
a21b244efb37
serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2656
diff
changeset
|
97 } |
2621
83ac5a05ce84
primitives for unserializing jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
98 } |
83ac5a05ce84
primitives for unserializing jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
99 |
83ac5a05ce84
primitives for unserializing jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
100 |
83ac5a05ce84
primitives for unserializing jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
101 IJobOperation* OrthancJobUnserializer::UnserializeOperation(const Json::Value& source) |
83ac5a05ce84
primitives for unserializing jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
102 { |
2656
a6d3e45eeff5
SerializationToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2655
diff
changeset
|
103 const std::string type = SerializationToolbox::ReadString(source, "Type"); |
2621
83ac5a05ce84
primitives for unserializing jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
104 |
2655 | 105 if (type == "DeleteResource") |
106 { | |
107 return new DeleteResourceOperation(context_); | |
108 } | |
109 else if (type == "ModifyInstance") | |
110 { | |
111 return new ModifyInstanceOperation(context_, source); | |
112 } | |
113 else if (type == "StorePeer") | |
114 { | |
115 return new StorePeerOperation(source); | |
116 } | |
117 else if (type == "StoreScu") | |
118 { | |
3851
6498739a3c3c
refactoring: TimeoutDicomConnectionManager is now only used by Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3713
diff
changeset
|
119 return new StoreScuOperation( |
3894
8f7ad4989fec
transcoding to uncompressed transfer syntaxes over DICOM protocol is implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3851
diff
changeset
|
120 context_, context_.GetLuaScripting().GetDicomConnectionManager(), source); |
2655 | 121 } |
122 else if (type == "SystemCall") | |
123 { | |
124 return new SystemCallOperation(source); | |
125 } | |
126 else | |
127 { | |
128 return GenericJobUnserializer::UnserializeOperation(source); | |
129 } | |
2621
83ac5a05ce84
primitives for unserializing jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
130 } |
83ac5a05ce84
primitives for unserializing jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
131 |
83ac5a05ce84
primitives for unserializing jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
132 |
4310
2ae905070221
renaming pure interface JobOperationValue as IJobOperationValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4045
diff
changeset
|
133 IJobOperationValue* OrthancJobUnserializer::UnserializeValue(const Json::Value& source) |
2621
83ac5a05ce84
primitives for unserializing jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
134 { |
2656
a6d3e45eeff5
SerializationToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2655
diff
changeset
|
135 const std::string type = SerializationToolbox::ReadString(source, "Type"); |
2621
83ac5a05ce84
primitives for unserializing jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
136 |
83ac5a05ce84
primitives for unserializing jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
137 if (type == "DicomInstance") |
83ac5a05ce84
primitives for unserializing jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
138 { |
2656
a6d3e45eeff5
SerializationToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2655
diff
changeset
|
139 return new DicomInstanceOperationValue(context_, SerializationToolbox::ReadString(source, "ID")); |
2621
83ac5a05ce84
primitives for unserializing jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
140 } |
83ac5a05ce84
primitives for unserializing jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
141 else |
83ac5a05ce84
primitives for unserializing jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
142 { |
83ac5a05ce84
primitives for unserializing jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
143 return GenericJobUnserializer::UnserializeValue(source); |
83ac5a05ce84
primitives for unserializing jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
144 } |
83ac5a05ce84
primitives for unserializing jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
145 } |
83ac5a05ce84
primitives for unserializing jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
146 } |