comparison OrthancServer/ServerJobs/DicomMoveScuJob.cpp @ 3877:4b4f387c6bb8 transcoding

making DicomMoveScuJob more consistent with DicomModalityStoreJob
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 04 May 2020 16:00:38 +0200
parents ea1d32861cfc
children
comparison
equal deleted inserted replaced
3876:92ecaf877baf 3877:4b4f387c6bb8
95 95
96 void DicomMoveScuJob::Retrieve(const DicomMap& findAnswer) 96 void DicomMoveScuJob::Retrieve(const DicomMap& findAnswer)
97 { 97 {
98 if (connection_.get() == NULL) 98 if (connection_.get() == NULL)
99 { 99 {
100 DicomAssociationParameters params(localAet_, remote_); 100 connection_.reset(new DicomControlUserConnection(parameters_));
101
102 if (timeout_ >= 0)
103 {
104 params.SetTimeout(static_cast<uint32_t>(timeout_));
105 }
106
107 connection_.reset(new DicomControlUserConnection(params));
108 } 101 }
109 102
110 connection_->Move(targetAet_, findAnswer); 103 connection_->Move(targetAet_, findAnswer);
111 } 104 }
112 105
158 { 151 {
159 throw OrthancException(ErrorCode_BadSequenceOfCalls); 152 throw OrthancException(ErrorCode_BadSequenceOfCalls);
160 } 153 }
161 else 154 else
162 { 155 {
163 localAet_ = aet; 156 parameters_.SetLocalApplicationEntityTitle(aet);
164 } 157 }
165 } 158 }
166 159
167 160
168 void DicomMoveScuJob::SetTargetAet(const std::string& aet) 161 void DicomMoveScuJob::SetTargetAet(const std::string& aet)
184 { 177 {
185 throw OrthancException(ErrorCode_BadSequenceOfCalls); 178 throw OrthancException(ErrorCode_BadSequenceOfCalls);
186 } 179 }
187 else 180 else
188 { 181 {
189 remote_ = remote; 182 parameters_.SetRemoteModality(remote);
183 }
184 }
185
186
187 void DicomMoveScuJob::SetTimeout(uint32_t seconds)
188 {
189 if (IsStarted())
190 {
191 throw OrthancException(ErrorCode_BadSequenceOfCalls);
192 }
193 else
194 {
195 parameters_.SetTimeout(seconds);
190 } 196 }
191 } 197 }
192 198
193 199
194 void DicomMoveScuJob::Stop(JobStopReason reason) 200 void DicomMoveScuJob::Stop(JobStopReason reason)
198 204
199 205
200 void DicomMoveScuJob::GetPublicContent(Json::Value& value) 206 void DicomMoveScuJob::GetPublicContent(Json::Value& value)
201 { 207 {
202 SetOfCommandsJob::GetPublicContent(value); 208 SetOfCommandsJob::GetPublicContent(value);
203 209
204 value["LocalAet"] = localAet_; 210 value["LocalAet"] = parameters_.GetLocalApplicationEntityTitle();
205 value["RemoteAet"] = remote_.GetApplicationEntityTitle(); 211 value["RemoteAet"] = parameters_.GetRemoteModality().GetApplicationEntityTitle();
206 value["Query"] = query_; 212 value["Query"] = query_;
207 } 213 }
208 214
209 215
210 DicomMoveScuJob::DicomMoveScuJob(ServerContext& context, 216 DicomMoveScuJob::DicomMoveScuJob(ServerContext& context,
211 const Json::Value& serialized) : 217 const Json::Value& serialized) :
212 SetOfCommandsJob(new Unserializer(*this), serialized), 218 SetOfCommandsJob(new Unserializer(*this), serialized),
213 context_(context), 219 context_(context),
214 query_(Json::arrayValue) 220 query_(Json::arrayValue)
215 { 221 {
216 localAet_ = SerializationToolbox::ReadString(serialized, LOCAL_AET); 222 parameters_ = DicomAssociationParameters::UnserializeJob(serialized);
217 targetAet_ = SerializationToolbox::ReadString(serialized, TARGET_AET); 223 targetAet_ = SerializationToolbox::ReadString(serialized, TARGET_AET);
218 remote_ = RemoteModalityParameters(serialized[REMOTE]);
219 224
220 if (serialized.isMember(QUERY) && 225 if (serialized.isMember(QUERY) &&
221 serialized[QUERY].type() == Json::arrayValue) 226 serialized[QUERY].type() == Json::arrayValue)
222 { 227 {
223 query_ = serialized[QUERY]; 228 query_ = serialized[QUERY];
224 } 229 }
225
226 // New in Orthanc in 1.7.0
227 timeout_ = SerializationToolbox::ReadInteger(serialized, TIMEOUT, -1);
228 } 230 }
229 231
230 232
231 bool DicomMoveScuJob::Serialize(Json::Value& target) 233 bool DicomMoveScuJob::Serialize(Json::Value& target)
232 { 234 {
234 { 236 {
235 return false; 237 return false;
236 } 238 }
237 else 239 else
238 { 240 {
239 target[LOCAL_AET] = localAet_; 241 parameters_.SerializeJob(target);
240 target[TARGET_AET] = targetAet_; 242 target[TARGET_AET] = targetAet_;
241 target[QUERY] = query_; 243 target[QUERY] = query_;
242 target[TIMEOUT] = timeout_;
243 remote_.Serialize(target[REMOTE], true /* force advanced format */);
244 return true; 244 return true;
245 } 245 }
246 } 246 }
247 } 247 }