annotate OrthancServer/ServerJobs/ResourceModificationJob.cpp @ 3944:aae045f802f4 transcoding

preparing simplified interface for IDicomTranscoder
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 19 May 2020 10:17:06 +0200
parents b26d25d3c1c7
children 0b3256c3ee14
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2642
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 /**
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2 * Orthanc - A Lightweight, RESTful DICOM Store
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
4 * Department, University Hospital of Liege, Belgium
3640
94f4a18a79cc upgrade to year 2020
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3430
diff changeset
5 * Copyright (C) 2017-2020 Osimis S.A., Belgium
2642
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6 *
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 * This program is free software: you can redistribute it and/or
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 * modify it under the terms of the GNU General Public License as
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 * published by the Free Software Foundation, either version 3 of the
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 * License, or (at your option) any later version.
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 *
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 * In addition, as a special exception, the copyright holders of this
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 * program give permission to link the code of its release with the
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 * OpenSSL project's "OpenSSL" library (or with modified versions of it
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 * that use the same license as the "OpenSSL" library), and distribute
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16 * the linked executables. You must obey the GNU General Public License
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17 * in all respects for all of the code used other than "OpenSSL". If you
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18 * modify file(s) with this exception, you may extend this exception to
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
19 * your version of the file(s), but you are not obligated to do so. If
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20 * you do not wish to do so, delete this exception statement from your
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21 * version. If you delete this exception statement from all source files
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22 * in the program, then also delete it here.
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23 *
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24 * This program is distributed in the hope that it will be useful, but
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25 * WITHOUT ANY WARRANTY; without even the implied warranty of
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27 * General Public License for more details.
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28 *
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29 * You should have received a copy of the GNU General Public License
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30 * along with this program. If not, see <http://www.gnu.org/licenses/>.
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31 **/
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
33
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
34 #include "../PrecompiledHeadersServer.h"
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
35 #include "ResourceModificationJob.h"
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
36
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
37 #include "../../Core/Logging.h"
2664
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
38 #include "../../Core/SerializationToolbox.h"
3095
beeeb6096f27 removing dependencies upon ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
39 #include "../ServerContext.h"
2642
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
40
3943
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
41 #include <dcmtk/dcmdata/dcfilefo.h>
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
42
2642
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
43 namespace Orthanc
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
44 {
2868
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
45 class ResourceModificationJob::Output : public boost::noncopyable
2642
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
46 {
2868
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
47 private:
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
48 ResourceType level_;
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
49 bool isFirst_;
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
50 std::string id_;
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
51 std::string patientId_;
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
52
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
53 public:
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
54 Output(ResourceType level) :
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
55 level_(level),
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
56 isFirst_(true)
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
57 {
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
58 if (level_ != ResourceType_Patient &&
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
59 level_ != ResourceType_Study &&
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
60 level_ != ResourceType_Series)
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
61 {
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
62 throw OrthancException(ErrorCode_ParameterOutOfRange);
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
63 }
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
64 }
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
65
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
66 ResourceType GetLevel() const
2642
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
67 {
2868
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
68 return level_;
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
69 }
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
70
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
71
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
72 void Update(DicomInstanceHasher& hasher)
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
73 {
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
74 if (isFirst_)
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
75 {
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
76 switch (level_)
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
77 {
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
78 case ResourceType_Series:
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
79 id_ = hasher.HashSeries();
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
80 break;
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
81
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
82 case ResourceType_Study:
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
83 id_ = hasher.HashStudy();
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
84 break;
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
85
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
86 case ResourceType_Patient:
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
87 id_ = hasher.HashPatient();
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
88 break;
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
89
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
90 default:
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
91 throw OrthancException(ErrorCode_InternalError);
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
92 }
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
93
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
94 patientId_ = hasher.HashPatient();
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
95 isFirst_ = false;
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
96 }
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
97 }
2642
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
98
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
99
2868
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
100 bool Format(Json::Value& target)
2642
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
101 {
2868
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
102 if (isFirst_)
2642
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
103 {
2868
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
104 return false;
2642
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
105 }
2868
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
106 else
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
107 {
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
108 target = Json::objectValue;
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
109 target["Type"] = EnumerationToString(level_);
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
110 target["ID"] = id_;
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
111 target["Path"] = GetBasePath(level_, id_);
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
112 target["PatientID"] = patientId_;
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
113 return true;
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
114 }
2642
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
115 }
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
116
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
117
2868
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
118 bool GetIdentifier(std::string& id)
2642
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
119 {
2868
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
120 if (isFirst_)
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
121 {
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
122 return false;
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
123 }
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
124 else
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
125 {
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
126 id = id_;
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
127 return true;
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
128 }
2642
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
129 }
2868
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
130 };
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
131
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
132
2642
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
133
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
134
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
135 bool ResourceModificationJob::HandleInstance(const std::string& instance)
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
136 {
2868
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
137 if (modification_.get() == NULL ||
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
138 output_.get() == NULL)
2642
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
139 {
2955
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2868
diff changeset
140 throw OrthancException(ErrorCode_BadSequenceOfCalls,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2868
diff changeset
141 "No modification was provided for this job");
2642
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
142 }
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
143
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
144
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
145 LOG(INFO) << "Modifying instance in a job: " << instance;
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
146
2825
8aa6aef11b70 New configuration option "OverwriteInstances" to choose how duplicate SOPInstanceUID are handled
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2664
diff changeset
147
8aa6aef11b70 New configuration option "OverwriteInstances" to choose how duplicate SOPInstanceUID are handled
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2664
diff changeset
148 /**
8aa6aef11b70 New configuration option "OverwriteInstances" to choose how duplicate SOPInstanceUID are handled
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2664
diff changeset
149 * Retrieve the original instance from the DICOM cache.
8aa6aef11b70 New configuration option "OverwriteInstances" to choose how duplicate SOPInstanceUID are handled
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2664
diff changeset
150 **/
8aa6aef11b70 New configuration option "OverwriteInstances" to choose how duplicate SOPInstanceUID are handled
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2664
diff changeset
151
3712
2a170a8f1faf replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
152 std::unique_ptr<DicomInstanceHasher> originalHasher;
2a170a8f1faf replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
153 std::unique_ptr<ParsedDicomFile> modified;
2642
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
154
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
155 try
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
156 {
3942
5b882ad2ffd0 "/{patients|studies|series}/.../modify": New option "KeepSource"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3938
diff changeset
157 ServerContext::DicomCacheLocker locker(GetContext(), instance);
2825
8aa6aef11b70 New configuration option "OverwriteInstances" to choose how duplicate SOPInstanceUID are handled
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2664
diff changeset
158 ParsedDicomFile& original = locker.GetDicom();
8aa6aef11b70 New configuration option "OverwriteInstances" to choose how duplicate SOPInstanceUID are handled
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2664
diff changeset
159
8aa6aef11b70 New configuration option "OverwriteInstances" to choose how duplicate SOPInstanceUID are handled
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2664
diff changeset
160 originalHasher.reset(new DicomInstanceHasher(original.GetHasher()));
8aa6aef11b70 New configuration option "OverwriteInstances" to choose how duplicate SOPInstanceUID are handled
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2664
diff changeset
161 modified.reset(original.Clone(true));
2642
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
162 }
3430
4c45e018bd3d improved logging
Alain Mazy <alain@mazy.be>
parents: 3095
diff changeset
163 catch (OrthancException& e)
2642
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
164 {
3430
4c45e018bd3d improved logging
Alain Mazy <alain@mazy.be>
parents: 3095
diff changeset
165 LOG(WARNING) << "An error occurred while executing a Modification job on instance " << instance << ": " << e.GetDetails();
2642
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
166 return false;
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
167 }
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
168
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
169
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
170 /**
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
171 * Compute the resulting DICOM instance.
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
172 **/
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
173
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
174 modification_->Apply(*modified);
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
175
3943
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
176 if (transcode_)
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
177 {
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
178 std::set<DicomTransferSyntax> syntaxes;
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
179 syntaxes.insert(transferSyntax_);
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
180
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
181 std::string s;
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
182 modified->SaveToMemoryBuffer(s); // TODO - AVOID THIS SERIALIZATION IF NO PLUGIN
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
183
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
184 std::unique_ptr<IDicomTranscoder::TranscodedDicom> transcoded;
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
185 transcoded.reset(GetContext().TranscodeToParsed(modified->GetDcmtkObject(), s.empty() ? NULL : s.c_str(), s.size(), syntaxes, true));
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
186 if (transcoded.get() == NULL)
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
187 {
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
188 LOG(WARNING) << "Cannot transcode instance, keeping original transfer syntax: " << instance;
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
189 }
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
190 else
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
191 {
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
192 modified.reset(ParsedDicomFile::AcquireDcmtkObject(transcoded->ReleaseDicom()));
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
193 }
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
194 }
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
195
2642
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
196 DicomInstanceToStore toStore;
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
197 toStore.SetOrigin(origin_);
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
198 toStore.SetParsedDicomFile(*modified);
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
199
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
200
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
201 /**
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
202 * Prepare the metadata information to associate with the
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
203 * resulting DICOM instance (AnonymizedFrom/ModifiedFrom).
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
204 **/
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
205
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
206 DicomInstanceHasher modifiedHasher = modified->GetHasher();
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
207
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
208 MetadataType metadataType = (isAnonymization_ ?
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
209 MetadataType_AnonymizedFrom :
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
210 MetadataType_ModifiedFrom);
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
211
2825
8aa6aef11b70 New configuration option "OverwriteInstances" to choose how duplicate SOPInstanceUID are handled
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2664
diff changeset
212 if (originalHasher->HashSeries() != modifiedHasher.HashSeries())
2642
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
213 {
2825
8aa6aef11b70 New configuration option "OverwriteInstances" to choose how duplicate SOPInstanceUID are handled
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2664
diff changeset
214 toStore.AddMetadata(ResourceType_Series, metadataType, originalHasher->HashSeries());
2642
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
215 }
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
216
2825
8aa6aef11b70 New configuration option "OverwriteInstances" to choose how duplicate SOPInstanceUID are handled
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2664
diff changeset
217 if (originalHasher->HashStudy() != modifiedHasher.HashStudy())
2642
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
218 {
2825
8aa6aef11b70 New configuration option "OverwriteInstances" to choose how duplicate SOPInstanceUID are handled
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2664
diff changeset
219 toStore.AddMetadata(ResourceType_Study, metadataType, originalHasher->HashStudy());
2642
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
220 }
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
221
2825
8aa6aef11b70 New configuration option "OverwriteInstances" to choose how duplicate SOPInstanceUID are handled
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2664
diff changeset
222 if (originalHasher->HashPatient() != modifiedHasher.HashPatient())
2642
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
223 {
2825
8aa6aef11b70 New configuration option "OverwriteInstances" to choose how duplicate SOPInstanceUID are handled
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2664
diff changeset
224 toStore.AddMetadata(ResourceType_Patient, metadataType, originalHasher->HashPatient());
2642
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
225 }
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
226
2825
8aa6aef11b70 New configuration option "OverwriteInstances" to choose how duplicate SOPInstanceUID are handled
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2664
diff changeset
227 assert(instance == originalHasher->HashInstance());
2642
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
228 toStore.AddMetadata(ResourceType_Instance, metadataType, instance);
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
229
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
230
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
231 /**
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
232 * Store the resulting DICOM instance into the Orthanc store.
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
233 **/
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
234
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
235 std::string modifiedInstance;
3942
5b882ad2ffd0 "/{patients|studies|series}/.../modify": New option "KeepSource"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3938
diff changeset
236 if (GetContext().Store(modifiedInstance, toStore,
5b882ad2ffd0 "/{patients|studies|series}/.../modify": New option "KeepSource"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3938
diff changeset
237 StoreInstanceMode_Default) != StoreStatus_Success)
2642
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
238 {
2955
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2868
diff changeset
239 throw OrthancException(ErrorCode_CannotStoreInstance,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2868
diff changeset
240 "Error while storing a modified instance " + instance);
2642
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
241 }
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
242
3938
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3814
diff changeset
243 /**
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3814
diff changeset
244 * The assertion below will fail if automated transcoding to a
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3814
diff changeset
245 * lossy transfer syntax is enabled in the Orthanc core, and if
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3814
diff changeset
246 * the source instance is not in this transfer syntax.
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3814
diff changeset
247 **/
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3814
diff changeset
248 // assert(modifiedInstance == modifiedHasher.HashInstance());
2642
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
249
2868
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
250 output_->Update(modifiedHasher);
2642
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
251
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
252 return true;
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
253 }
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
254
2842
ff0ed5ea9e4e trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2825
diff changeset
255
3943
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
256 ResourceModificationJob::ResourceModificationJob(ServerContext& context) :
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
257 CleaningInstancesJob(context, true /* by default, keep source */),
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
258 modification_(new DicomModification),
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
259 isAnonymization_(false),
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
260 transcode_(false)
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
261 {
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
262 }
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
263
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
264
2642
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
265 void ResourceModificationJob::SetModification(DicomModification* modification,
2868
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
266 ResourceType level,
2642
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
267 bool isAnonymization)
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
268 {
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
269 if (modification == NULL)
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
270 {
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
271 throw OrthancException(ErrorCode_NullPointer);
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
272 }
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
273 else if (IsStarted())
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
274 {
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
275 throw OrthancException(ErrorCode_BadSequenceOfCalls);
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
276 }
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
277 else
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
278 {
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
279 modification_.reset(modification);
2868
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
280 output_.reset(new Output(level));
2642
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
281 isAnonymization_ = isAnonymization;
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
282 }
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
283 }
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
284
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
285
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
286 void ResourceModificationJob::SetOrigin(const DicomInstanceOrigin& origin)
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
287 {
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
288 if (IsStarted())
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
289 {
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
290 throw OrthancException(ErrorCode_BadSequenceOfCalls);
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
291 }
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
292 else
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
293 {
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
294 origin_ = origin;
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
295 }
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
296 }
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
297
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
298
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
299 void ResourceModificationJob::SetOrigin(const RestApiCall& call)
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
300 {
2664
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
301 SetOrigin(DicomInstanceOrigin::FromRest(call));
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
302 }
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
303
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
304
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
305 const DicomModification& ResourceModificationJob::GetModification() const
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
306 {
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
307 if (modification_.get() == NULL)
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
308 {
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
309 throw OrthancException(ErrorCode_BadSequenceOfCalls);
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
310 }
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
311 else
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
312 {
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
313 return *modification_;
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
314 }
2642
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
315 }
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
316
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
317
3943
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
318 DicomTransferSyntax ResourceModificationJob::GetTransferSyntax() const
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
319 {
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
320 if (transcode_)
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
321 {
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
322 return transferSyntax_;
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
323 }
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
324 else
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
325 {
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
326 throw OrthancException(ErrorCode_BadSequenceOfCalls);
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
327 }
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
328 }
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
329
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
330
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
331 void ResourceModificationJob::SetTranscode(DicomTransferSyntax syntax)
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
332 {
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
333 if (IsStarted())
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
334 {
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
335 throw OrthancException(ErrorCode_BadSequenceOfCalls);
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
336 }
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
337 else
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
338 {
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
339 transcode_ = true;
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
340 transferSyntax_ = syntax;
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
341 }
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
342 }
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
343
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
344
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
345 void ResourceModificationJob::SetTranscode(const std::string& transferSyntaxUid)
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
346 {
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
347 DicomTransferSyntax s;
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
348 if (LookupTransferSyntax(s, transferSyntaxUid))
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
349 {
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
350 SetTranscode(s);
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
351 }
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
352 else
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
353 {
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
354 throw OrthancException(ErrorCode_BadFileFormat,
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
355 "Unknown transfer syntax UID: " + transferSyntaxUid);
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
356 }
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
357 }
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
358
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
359
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
360 void ResourceModificationJob::ClearTranscode()
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
361 {
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
362 if (IsStarted())
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
363 {
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
364 throw OrthancException(ErrorCode_BadSequenceOfCalls);
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
365 }
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
366 else
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
367 {
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
368 transcode_ = false;
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
369 }
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
370 }
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
371
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
372
2642
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
373 void ResourceModificationJob::GetPublicContent(Json::Value& value)
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
374 {
3942
5b882ad2ffd0 "/{patients|studies|series}/.../modify": New option "KeepSource"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3938
diff changeset
375 CleaningInstancesJob::GetPublicContent(value);
2642
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
376
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
377 value["IsAnonymization"] = isAnonymization_;
2868
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
378
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
379 if (output_.get() != NULL)
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
380 {
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
381 output_->Format(value);
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
382 }
3943
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
383
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
384 if (transcode_)
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
385 {
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
386 value["Transcode"] = GetTransferSyntaxUid(transferSyntax_);
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
387 }
2642
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
388 }
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
389
2664
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
390
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
391 static const char* MODIFICATION = "Modification";
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
392 static const char* ORIGIN = "Origin";
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
393 static const char* IS_ANONYMIZATION = "IsAnonymization";
3943
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
394 static const char* TRANSCODE = "Transcode";
2664
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
395
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
396
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
397 ResourceModificationJob::ResourceModificationJob(ServerContext& context,
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
398 const Json::Value& serialized) :
3942
5b882ad2ffd0 "/{patients|studies|series}/.../modify": New option "KeepSource"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3938
diff changeset
399 CleaningInstancesJob(context, serialized, true /* by default, keep source */)
2664
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
400 {
3943
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
401 assert(serialized.type() == Json::objectValue);
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
402
2664
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
403 isAnonymization_ = SerializationToolbox::ReadBoolean(serialized, IS_ANONYMIZATION);
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
404 origin_ = DicomInstanceOrigin(serialized[ORIGIN]);
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
405 modification_.reset(new DicomModification(serialized[MODIFICATION]));
3943
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
406
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
407 if (serialized.isMember(TRANSCODE))
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
408 {
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
409 SetTranscode(SerializationToolbox::ReadString(serialized, TRANSCODE));
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
410 }
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
411 else
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
412 {
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
413 transcode_ = false;
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
414 }
2664
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
415 }
2642
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
416
2663
228e2783ce83 some jobs might not be serializable
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2648
diff changeset
417 bool ResourceModificationJob::Serialize(Json::Value& value)
2642
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
418 {
3942
5b882ad2ffd0 "/{patients|studies|series}/.../modify": New option "KeepSource"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3938
diff changeset
419 if (!CleaningInstancesJob::Serialize(value))
2664
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
420 {
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
421 return false;
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
422 }
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
423 else
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
424 {
3943
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
425 assert(value.type() == Json::objectValue);
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
426
2664
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
427 value[IS_ANONYMIZATION] = isAnonymization_;
3943
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
428
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
429 if (transcode_)
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
430 {
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
431 value[TRANSCODE] = GetTransferSyntaxUid(transferSyntax_);
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
432 }
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
433
2664
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
434 origin_.Serialize(value[ORIGIN]);
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
435
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
436 Json::Value tmp;
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
437 modification_->Serialize(tmp);
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
438 value[MODIFICATION] = tmp;
2642
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
439
2664
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
440 return true;
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
441 }
2642
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
442 }
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
443 }