annotate OrthancServer/Sources/ServerJobs/DicomMoveScuJob.cpp @ 4704:f0038043fb97 openssl-3.x

removed OpenSSL license exception, as OpenSSL 3.0 was relicensed under Apache 2.0
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 22 Jun 2021 07:37:20 +0200
parents d9473bd5ed43
children c1d6ce00be3f
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 * This program is distributed in the hope that it will be useful, but
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 * General Public License for more details.
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16 *
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17 * You should have received a copy of the GNU General Public License
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
19 **/
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22 #include "DicomMoveScuJob.h"
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23
4045
05b8fd21089c fix path
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
24 #include "../../../OrthancFramework/Sources/SerializationToolbox.h"
3095
beeeb6096f27 removing dependencies upon ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
25 #include "../ServerContext.h"
2867
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26
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
27 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
28 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
29 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
30 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
31 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
32
2867
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
33 namespace Orthanc
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
34 {
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
35 class DicomMoveScuJob::Command : public SetOfCommandsJob::ICommand
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
36 {
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
37 private:
3712
2a170a8f1faf replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
38 DicomMoveScuJob& that_;
2a170a8f1faf replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
39 std::unique_ptr<DicomMap> findAnswer_;
2867
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
40
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
41 public:
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
42 Command(DicomMoveScuJob& that,
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
43 const DicomMap& findAnswer) :
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
44 that_(that),
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
45 findAnswer_(findAnswer.Clone())
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
46 {
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
47 }
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
48
3658
2d90dd30858c providing job ID to the IJob::Step() methods
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
49 virtual bool Execute(const std::string& jobId) ORTHANC_OVERRIDE
2867
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
50 {
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
51 that_.Retrieve(*findAnswer_);
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
52 return true;
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
53 }
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
54
3763
5ff5d5a0fd28 adding missing ORTHANC_OVERRIDE
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3713
diff changeset
55 virtual void Serialize(Json::Value& target) const ORTHANC_OVERRIDE
2867
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
56 {
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
57 findAnswer_->Serialize(target);
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
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
61
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
62 class DicomMoveScuJob::Unserializer :
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
63 public SetOfCommandsJob::ICommandUnserializer
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
64 {
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
65 private:
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
66 DicomMoveScuJob& that_;
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
67
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
68 public:
4205
d962a2996637 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
69 explicit Unserializer(DicomMoveScuJob& that) :
2867
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
70 that_(that)
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
4205
d962a2996637 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
74 virtual ICommand* Unserialize(const Json::Value& source) const ORTHANC_OVERRIDE
2867
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
75 {
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
76 DicomMap findAnswer;
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
77 findAnswer.Unserialize(source);
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
78 return new Command(that_, findAnswer);
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
79 }
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
80 };
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
81
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
82
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
83
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
84 void DicomMoveScuJob::Retrieve(const DicomMap& findAnswer)
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
85 {
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
86 if (connection_.get() == NULL)
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
87 {
3877
4b4f387c6bb8 making DicomMoveScuJob more consistent with DicomModalityStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
88 connection_.reset(new DicomControlUserConnection(parameters_));
2867
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
89 }
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
90
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
91 connection_->Move(targetAet_, findAnswer);
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
92 }
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
93
a215182a0c2f "DicomMoveScu" jobs provide the associated C-FIND answer in their "Query" public field
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3095
diff changeset
94
a215182a0c2f "DicomMoveScu" jobs provide the associated C-FIND answer in their "Query" public field
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3095
diff changeset
95 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
96 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
97 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
98 {
a215182a0c2f "DicomMoveScu" jobs provide the associated C-FIND answer in their "Query" public field
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3095
diff changeset
99 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
100 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
101 !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
102 !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
103 {
a215182a0c2f "DicomMoveScu" jobs provide the associated C-FIND answer in their "Query" public field
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3095
diff changeset
104 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
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
2867
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
108
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
109 void DicomMoveScuJob::AddFindAnswer(const DicomMap& answer)
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
110 {
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
111 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
112
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 // 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
114 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
115 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
116 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
117 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
118 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
119 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
120 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
121 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
122
2867
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
123 AddCommand(new Command(*this, answer));
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
124 }
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
125
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
126
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
127 void DicomMoveScuJob::AddFindAnswer(QueryRetrieveHandler& query,
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
128 size_t i)
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
129 {
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
130 DicomMap answer;
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
131 query.GetAnswer(answer, i);
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
132 AddFindAnswer(answer);
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
133 }
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
134
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
135
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
136 void DicomMoveScuJob::SetLocalAet(const std::string& aet)
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
137 {
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
138 if (IsStarted())
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
139 {
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
140 throw OrthancException(ErrorCode_BadSequenceOfCalls);
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
141 }
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
142 else
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
143 {
3877
4b4f387c6bb8 making DicomMoveScuJob more consistent with DicomModalityStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
144 parameters_.SetLocalApplicationEntityTitle(aet);
2867
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
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
149 void DicomMoveScuJob::SetTargetAet(const std::string& aet)
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
150 {
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
151 if (IsStarted())
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
152 {
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
153 throw OrthancException(ErrorCode_BadSequenceOfCalls);
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
154 }
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
155 else
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
156 {
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
157 targetAet_ = aet;
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
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
162 void DicomMoveScuJob::SetRemoteModality(const RemoteModalityParameters& remote)
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
163 {
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
164 if (IsStarted())
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
165 {
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
166 throw OrthancException(ErrorCode_BadSequenceOfCalls);
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
167 }
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
168 else
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
169 {
3877
4b4f387c6bb8 making DicomMoveScuJob more consistent with DicomModalityStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
170 parameters_.SetRemoteModality(remote);
4b4f387c6bb8 making DicomMoveScuJob more consistent with DicomModalityStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
171 }
4b4f387c6bb8 making DicomMoveScuJob more consistent with DicomModalityStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
172 }
4b4f387c6bb8 making DicomMoveScuJob more consistent with DicomModalityStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
173
4b4f387c6bb8 making DicomMoveScuJob more consistent with DicomModalityStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
174
4b4f387c6bb8 making DicomMoveScuJob more consistent with DicomModalityStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
175 void DicomMoveScuJob::SetTimeout(uint32_t seconds)
4b4f387c6bb8 making DicomMoveScuJob more consistent with DicomModalityStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
176 {
4b4f387c6bb8 making DicomMoveScuJob more consistent with DicomModalityStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
177 if (IsStarted())
4b4f387c6bb8 making DicomMoveScuJob more consistent with DicomModalityStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
178 {
4b4f387c6bb8 making DicomMoveScuJob more consistent with DicomModalityStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
179 throw OrthancException(ErrorCode_BadSequenceOfCalls);
4b4f387c6bb8 making DicomMoveScuJob more consistent with DicomModalityStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
180 }
4b4f387c6bb8 making DicomMoveScuJob more consistent with DicomModalityStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
181 else
4b4f387c6bb8 making DicomMoveScuJob more consistent with DicomModalityStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
182 {
4b4f387c6bb8 making DicomMoveScuJob more consistent with DicomModalityStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
183 parameters_.SetTimeout(seconds);
2867
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
184 }
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
185 }
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
186
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
187
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
188 void DicomMoveScuJob::Stop(JobStopReason reason)
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
189 {
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
190 connection_.reset();
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
191 }
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
192
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
193
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
194 void DicomMoveScuJob::GetPublicContent(Json::Value& value)
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
195 {
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
196 SetOfCommandsJob::GetPublicContent(value);
3877
4b4f387c6bb8 making DicomMoveScuJob more consistent with DicomModalityStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
197
4b4f387c6bb8 making DicomMoveScuJob more consistent with DicomModalityStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
198 value["LocalAet"] = parameters_.GetLocalApplicationEntityTitle();
4b4f387c6bb8 making DicomMoveScuJob more consistent with DicomModalityStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
199 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
200 value["Query"] = query_;
2867
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
201 }
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
202
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
203
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
204 DicomMoveScuJob::DicomMoveScuJob(ServerContext& context,
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
205 const Json::Value& serialized) :
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
206 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
207 context_(context),
4206
171af1567473 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4205
diff changeset
208 parameters_(DicomAssociationParameters::UnserializeJob(serialized)),
171af1567473 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4205
diff changeset
209 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
210 query_(Json::arrayValue)
2867
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
211 {
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 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
213 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
214 {
a215182a0c2f "DicomMoveScu" jobs provide the associated C-FIND answer in their "Query" public field
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3095
diff changeset
215 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
216 }
2867
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
217 }
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
218
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
219
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
220 bool DicomMoveScuJob::Serialize(Json::Value& target)
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
221 {
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
222 if (!SetOfCommandsJob::Serialize(target))
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
223 {
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
224 return false;
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
225 }
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
226 else
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
227 {
3877
4b4f387c6bb8 making DicomMoveScuJob more consistent with DicomModalityStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
228 parameters_.SerializeJob(target);
2867
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
229 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
230 target[QUERY] = query_;
2867
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
231 return true;
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
232 }
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
233 }
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
234 }