annotate OrthancServer/Sources/ServerJobs/DicomMoveScuJob.cpp @ 4650:9804d6490872

Reduced memory consumption of HTTP/REST plugins calls on POST/PUT if chunked transfer is disabled
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 04 May 2021 10:57:42 +0200
parents d9473bd5ed43
children f0038043fb97 4e2247df6327
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2867
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 /**
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2 * Orthanc - A Lightweight, RESTful DICOM Store
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
4 * Department, University Hospital of Liege, Belgium
4437
d9473bd5ed43 upgrade to year 2021
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4206
diff changeset
5 * Copyright (C) 2017-2021 Osimis S.A., Belgium
2867
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6 *
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 * This program is free software: you can redistribute it and/or
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 * modify it under the terms of the GNU General Public License as
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 * published by the Free Software Foundation, either version 3 of the
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 * License, or (at your option) any later version.
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 *
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 * In addition, as a special exception, the copyright holders of this
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 * program give permission to link the code of its release with the
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 * OpenSSL project's "OpenSSL" library (or with modified versions of it
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 * that use the same license as the "OpenSSL" library), and distribute
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16 * the linked executables. You must obey the GNU General Public License
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17 * in all respects for all of the code used other than "OpenSSL". If you
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18 * modify file(s) with this exception, you may extend this exception to
251614c2edac DicomMoveScuJob
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
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20 * you do not wish to do so, delete this exception statement from your
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21 * version. If you delete this exception statement from all source files
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22 * in the program, then also delete it here.
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23 *
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24 * This program is distributed in the hope that it will be useful, but
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25 * WITHOUT ANY WARRANTY; without even the implied warranty of
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27 * General Public License for more details.
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28 *
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29 * You should have received a copy of the GNU General Public License
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30 * along with this program. If not, see <http://www.gnu.org/licenses/>.
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31 **/
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
33
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
34 #include "DicomMoveScuJob.h"
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
35
4045
05b8fd21089c fix path
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
36 #include "../../../OrthancFramework/Sources/SerializationToolbox.h"
3095
beeeb6096f27 removing dependencies upon ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
37 #include "../ServerContext.h"
2867
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
38
3303
a215182a0c2f "DicomMoveScu" jobs provide the associated C-FIND answer in their "Query" public field
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3095
diff changeset
39 static const char* const LOCAL_AET = "LocalAet";
a215182a0c2f "DicomMoveScu" jobs provide the associated C-FIND answer in their "Query" public field
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3095
diff changeset
40 static const char* const TARGET_AET = "TargetAet";
a215182a0c2f "DicomMoveScu" jobs provide the associated C-FIND answer in their "Query" public field
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3095
diff changeset
41 static const char* const REMOTE = "Remote";
a215182a0c2f "DicomMoveScu" jobs provide the associated C-FIND answer in their "Query" public field
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3095
diff changeset
42 static const char* const QUERY = "Query";
3870
09798f2b985f added a Timeout argument to every DICOM command + 'TargetAet' not mandatory anymore in /retrieve
Alain Mazy <alain@mazy.be>
parents: 3843
diff changeset
43 static const char* const TIMEOUT = "Timeout";
3303
a215182a0c2f "DicomMoveScu" jobs provide the associated C-FIND answer in their "Query" public field
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3095
diff changeset
44
2867
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
45 namespace Orthanc
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
46 {
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
47 class DicomMoveScuJob::Command : public SetOfCommandsJob::ICommand
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
48 {
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
49 private:
3712
2a170a8f1faf replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
50 DicomMoveScuJob& that_;
2a170a8f1faf replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
51 std::unique_ptr<DicomMap> findAnswer_;
2867
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
52
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
53 public:
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
54 Command(DicomMoveScuJob& that,
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
55 const DicomMap& findAnswer) :
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
56 that_(that),
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
57 findAnswer_(findAnswer.Clone())
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
58 {
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
59 }
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
60
3658
2d90dd30858c providing job ID to the IJob::Step() methods
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
61 virtual bool Execute(const std::string& jobId) ORTHANC_OVERRIDE
2867
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
62 {
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
63 that_.Retrieve(*findAnswer_);
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
64 return true;
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
65 }
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
66
3763
5ff5d5a0fd28 adding missing ORTHANC_OVERRIDE
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3713
diff changeset
67 virtual void Serialize(Json::Value& target) const ORTHANC_OVERRIDE
2867
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
68 {
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
69 findAnswer_->Serialize(target);
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
70 }
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
71 };
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
72
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
73
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
74 class DicomMoveScuJob::Unserializer :
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
75 public SetOfCommandsJob::ICommandUnserializer
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
76 {
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
77 private:
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
78 DicomMoveScuJob& that_;
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
79
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
80 public:
4205
d962a2996637 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
81 explicit Unserializer(DicomMoveScuJob& that) :
2867
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
82 that_(that)
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
83 {
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
84 }
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
85
4205
d962a2996637 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
86 virtual ICommand* Unserialize(const Json::Value& source) const ORTHANC_OVERRIDE
2867
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
87 {
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
88 DicomMap findAnswer;
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
89 findAnswer.Unserialize(source);
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
90 return new Command(that_, findAnswer);
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
91 }
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
92 };
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
93
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
94
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
95
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
96 void DicomMoveScuJob::Retrieve(const DicomMap& findAnswer)
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
97 {
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
98 if (connection_.get() == NULL)
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
99 {
3877
4b4f387c6bb8 making DicomMoveScuJob more consistent with DicomModalityStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
100 connection_.reset(new DicomControlUserConnection(parameters_));
2867
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
101 }
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
102
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
103 connection_->Move(targetAet_, findAnswer);
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
104 }
3303
a215182a0c2f "DicomMoveScu" jobs provide the associated C-FIND answer in their "Query" public field
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3095
diff changeset
105
a215182a0c2f "DicomMoveScu" jobs provide the associated C-FIND answer in their "Query" public field
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3095
diff changeset
106
a215182a0c2f "DicomMoveScu" jobs provide the associated C-FIND answer in their "Query" public field
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3095
diff changeset
107 static void AddTagIfString(Json::Value& target,
a215182a0c2f "DicomMoveScu" jobs provide the associated C-FIND answer in their "Query" public field
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3095
diff changeset
108 const DicomMap& answer,
a215182a0c2f "DicomMoveScu" jobs provide the associated C-FIND answer in their "Query" public field
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3095
diff changeset
109 const DicomTag& tag)
a215182a0c2f "DicomMoveScu" jobs provide the associated C-FIND answer in their "Query" public field
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3095
diff changeset
110 {
a215182a0c2f "DicomMoveScu" jobs provide the associated C-FIND answer in their "Query" public field
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3095
diff changeset
111 const DicomValue* value = answer.TestAndGetValue(tag);
a215182a0c2f "DicomMoveScu" jobs provide the associated C-FIND answer in their "Query" public field
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3095
diff changeset
112 if (value != NULL &&
a215182a0c2f "DicomMoveScu" jobs provide the associated C-FIND answer in their "Query" public field
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3095
diff changeset
113 !value->IsNull() &&
a215182a0c2f "DicomMoveScu" jobs provide the associated C-FIND answer in their "Query" public field
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3095
diff changeset
114 !value->IsBinary())
a215182a0c2f "DicomMoveScu" jobs provide the associated C-FIND answer in their "Query" public field
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3095
diff changeset
115 {
a215182a0c2f "DicomMoveScu" jobs provide the associated C-FIND answer in their "Query" public field
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3095
diff changeset
116 target[tag.Format()] = value->GetContent();
a215182a0c2f "DicomMoveScu" jobs provide the associated C-FIND answer in their "Query" public field
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3095
diff changeset
117 }
a215182a0c2f "DicomMoveScu" jobs provide the associated C-FIND answer in their "Query" public field
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3095
diff changeset
118 }
a215182a0c2f "DicomMoveScu" jobs provide the associated C-FIND answer in their "Query" public field
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3095
diff changeset
119
2867
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
120
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
121 void DicomMoveScuJob::AddFindAnswer(const DicomMap& answer)
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
122 {
3303
a215182a0c2f "DicomMoveScu" jobs provide the associated C-FIND answer in their "Query" public field
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3095
diff changeset
123 assert(query_.type() == Json::arrayValue);
a215182a0c2f "DicomMoveScu" jobs provide the associated C-FIND answer in their "Query" public field
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3095
diff changeset
124
a215182a0c2f "DicomMoveScu" jobs provide the associated C-FIND answer in their "Query" public field
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3095
diff changeset
125 // Copy the identifiers tags, if they exist
a215182a0c2f "DicomMoveScu" jobs provide the associated C-FIND answer in their "Query" public field
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3095
diff changeset
126 Json::Value item = Json::objectValue;
a215182a0c2f "DicomMoveScu" jobs provide the associated C-FIND answer in their "Query" public field
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3095
diff changeset
127 AddTagIfString(item, answer, DICOM_TAG_QUERY_RETRIEVE_LEVEL);
a215182a0c2f "DicomMoveScu" jobs provide the associated C-FIND answer in their "Query" public field
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3095
diff changeset
128 AddTagIfString(item, answer, DICOM_TAG_PATIENT_ID);
a215182a0c2f "DicomMoveScu" jobs provide the associated C-FIND answer in their "Query" public field
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3095
diff changeset
129 AddTagIfString(item, answer, DICOM_TAG_STUDY_INSTANCE_UID);
a215182a0c2f "DicomMoveScu" jobs provide the associated C-FIND answer in their "Query" public field
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3095
diff changeset
130 AddTagIfString(item, answer, DICOM_TAG_SERIES_INSTANCE_UID);
a215182a0c2f "DicomMoveScu" jobs provide the associated C-FIND answer in their "Query" public field
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3095
diff changeset
131 AddTagIfString(item, answer, DICOM_TAG_SOP_INSTANCE_UID);
a215182a0c2f "DicomMoveScu" jobs provide the associated C-FIND answer in their "Query" public field
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3095
diff changeset
132 AddTagIfString(item, answer, DICOM_TAG_ACCESSION_NUMBER);
a215182a0c2f "DicomMoveScu" jobs provide the associated C-FIND answer in their "Query" public field
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3095
diff changeset
133 query_.append(item);
a215182a0c2f "DicomMoveScu" jobs provide the associated C-FIND answer in their "Query" public field
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3095
diff changeset
134
2867
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
135 AddCommand(new Command(*this, answer));
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
136 }
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
137
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
138
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
139 void DicomMoveScuJob::AddFindAnswer(QueryRetrieveHandler& query,
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
140 size_t i)
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
141 {
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
142 DicomMap answer;
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
143 query.GetAnswer(answer, i);
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
144 AddFindAnswer(answer);
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
145 }
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
146
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
147
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
148 void DicomMoveScuJob::SetLocalAet(const std::string& aet)
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
149 {
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
150 if (IsStarted())
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
151 {
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
152 throw OrthancException(ErrorCode_BadSequenceOfCalls);
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
153 }
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
154 else
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
155 {
3877
4b4f387c6bb8 making DicomMoveScuJob more consistent with DicomModalityStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
156 parameters_.SetLocalApplicationEntityTitle(aet);
2867
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
157 }
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
158 }
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
159
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
160
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
161 void DicomMoveScuJob::SetTargetAet(const std::string& aet)
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
162 {
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
163 if (IsStarted())
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
164 {
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
165 throw OrthancException(ErrorCode_BadSequenceOfCalls);
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
166 }
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
167 else
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
168 {
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
169 targetAet_ = aet;
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
170 }
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
171 }
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
172
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
173
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
174 void DicomMoveScuJob::SetRemoteModality(const RemoteModalityParameters& remote)
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
175 {
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
176 if (IsStarted())
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
177 {
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
178 throw OrthancException(ErrorCode_BadSequenceOfCalls);
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
179 }
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
180 else
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
181 {
3877
4b4f387c6bb8 making DicomMoveScuJob more consistent with DicomModalityStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
182 parameters_.SetRemoteModality(remote);
4b4f387c6bb8 making DicomMoveScuJob more consistent with DicomModalityStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
183 }
4b4f387c6bb8 making DicomMoveScuJob more consistent with DicomModalityStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
184 }
4b4f387c6bb8 making DicomMoveScuJob more consistent with DicomModalityStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
185
4b4f387c6bb8 making DicomMoveScuJob more consistent with DicomModalityStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
186
4b4f387c6bb8 making DicomMoveScuJob more consistent with DicomModalityStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
187 void DicomMoveScuJob::SetTimeout(uint32_t seconds)
4b4f387c6bb8 making DicomMoveScuJob more consistent with DicomModalityStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
188 {
4b4f387c6bb8 making DicomMoveScuJob more consistent with DicomModalityStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
189 if (IsStarted())
4b4f387c6bb8 making DicomMoveScuJob more consistent with DicomModalityStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
190 {
4b4f387c6bb8 making DicomMoveScuJob more consistent with DicomModalityStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
191 throw OrthancException(ErrorCode_BadSequenceOfCalls);
4b4f387c6bb8 making DicomMoveScuJob more consistent with DicomModalityStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
192 }
4b4f387c6bb8 making DicomMoveScuJob more consistent with DicomModalityStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
193 else
4b4f387c6bb8 making DicomMoveScuJob more consistent with DicomModalityStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
194 {
4b4f387c6bb8 making DicomMoveScuJob more consistent with DicomModalityStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
195 parameters_.SetTimeout(seconds);
2867
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
196 }
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
197 }
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
198
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
199
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
200 void DicomMoveScuJob::Stop(JobStopReason reason)
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
201 {
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
202 connection_.reset();
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
203 }
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
204
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
205
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
206 void DicomMoveScuJob::GetPublicContent(Json::Value& value)
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
207 {
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
208 SetOfCommandsJob::GetPublicContent(value);
3877
4b4f387c6bb8 making DicomMoveScuJob more consistent with DicomModalityStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
209
4b4f387c6bb8 making DicomMoveScuJob more consistent with DicomModalityStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
210 value["LocalAet"] = parameters_.GetLocalApplicationEntityTitle();
4b4f387c6bb8 making DicomMoveScuJob more consistent with DicomModalityStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
211 value["RemoteAet"] = parameters_.GetRemoteModality().GetApplicationEntityTitle();
3303
a215182a0c2f "DicomMoveScu" jobs provide the associated C-FIND answer in their "Query" public field
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3095
diff changeset
212 value["Query"] = query_;
2867
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
213 }
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
214
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
215
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
216 DicomMoveScuJob::DicomMoveScuJob(ServerContext& context,
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
217 const Json::Value& serialized) :
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
218 SetOfCommandsJob(new Unserializer(*this), serialized),
3303
a215182a0c2f "DicomMoveScu" jobs provide the associated C-FIND answer in their "Query" public field
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3095
diff changeset
219 context_(context),
4206
171af1567473 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4205
diff changeset
220 parameters_(DicomAssociationParameters::UnserializeJob(serialized)),
171af1567473 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4205
diff changeset
221 targetAet_(SerializationToolbox::ReadString(serialized, TARGET_AET)),
3303
a215182a0c2f "DicomMoveScu" jobs provide the associated C-FIND answer in their "Query" public field
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3095
diff changeset
222 query_(Json::arrayValue)
2867
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
223 {
3303
a215182a0c2f "DicomMoveScu" jobs provide the associated C-FIND answer in their "Query" public field
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3095
diff changeset
224 if (serialized.isMember(QUERY) &&
a215182a0c2f "DicomMoveScu" jobs provide the associated C-FIND answer in their "Query" public field
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3095
diff changeset
225 serialized[QUERY].type() == Json::arrayValue)
a215182a0c2f "DicomMoveScu" jobs provide the associated C-FIND answer in their "Query" public field
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3095
diff changeset
226 {
a215182a0c2f "DicomMoveScu" jobs provide the associated C-FIND answer in their "Query" public field
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3095
diff changeset
227 query_ = serialized[QUERY];
a215182a0c2f "DicomMoveScu" jobs provide the associated C-FIND answer in their "Query" public field
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3095
diff changeset
228 }
2867
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
229 }
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
230
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
231
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
232 bool DicomMoveScuJob::Serialize(Json::Value& target)
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
233 {
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
234 if (!SetOfCommandsJob::Serialize(target))
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
235 {
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
236 return false;
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
237 }
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
238 else
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
239 {
3877
4b4f387c6bb8 making DicomMoveScuJob more consistent with DicomModalityStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
240 parameters_.SerializeJob(target);
2867
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
241 target[TARGET_AET] = targetAet_;
3303
a215182a0c2f "DicomMoveScu" jobs provide the associated C-FIND answer in their "Query" public field
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3095
diff changeset
242 target[QUERY] = query_;
2867
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
243 return true;
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
244 }
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
245 }
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
246 }