Mercurial > hg > orthanc
comparison OrthancServer/Sources/ServerJobs/ResourceModificationJob.cpp @ 5136:e71b22a43c0b
Threaded modifications continued: call ReconstructInstance at the end of the modification to update the DB model
author | Alain Mazy <am@osimis.io> |
---|---|
date | Tue, 17 Jan 2023 17:54:38 +0100 |
parents | 6aa41d86b948 |
children | 15109c3f0f7d |
comparison
equal
deleted
inserted
replaced
5135:252385892197 | 5136:e71b22a43c0b |
---|---|
159 virtual bool IsSingleResource() const ORTHANC_OVERRIDE | 159 virtual bool IsSingleResource() const ORTHANC_OVERRIDE |
160 { | 160 { |
161 return false; | 161 return false; |
162 } | 162 } |
163 }; | 163 }; |
164 | |
165 // Reset is called when resubmitting a failed job | |
166 void ResourceModificationJob::Reset() | |
167 { | |
168 boost::recursive_mutex::scoped_lock lock(mutex_); | |
169 | |
170 // TODO: cleanup the instances that have been generated during the previous run | |
171 modifiedInstances_.clear(); | |
172 | |
173 ThreadedSetOfInstancesJob::Reset(); | |
174 } | |
175 | |
176 void ResourceModificationJob::PostProcessInstances() | |
177 { | |
178 boost::recursive_mutex::scoped_lock lock(mutex_); | |
179 | |
180 // reconstruct the parents MainDicomTags in case one of them has changed | |
181 if (modifiedInstances_.size() > 0) | |
182 { | |
183 ServerContext::DicomCacheLocker locker(GetContext(), *(modifiedInstances_.begin())); | |
184 ParsedDicomFile& modifiedDicom = locker.GetDicom(); | |
185 | |
186 GetContext().GetIndex().ReconstructInstance(modifiedDicom); | |
187 } | |
164 | 188 |
165 | 189 } |
166 | 190 |
167 bool ResourceModificationJob::HandleInstance(const std::string& instance) | 191 bool ResourceModificationJob::HandleInstance(const std::string& instance) |
168 { | 192 { |
169 if (modification_.get() == NULL || | 193 if (modification_.get() == NULL || |
170 output_.get() == NULL) | 194 output_.get() == NULL) |
294 | 318 |
295 { | 319 { |
296 boost::recursive_mutex::scoped_lock lock(outputMutex_); | 320 boost::recursive_mutex::scoped_lock lock(outputMutex_); |
297 | 321 |
298 output_->Update(modifiedHasher); | 322 output_->Update(modifiedHasher); |
323 modifiedInstances_.insert(modifiedInstance); | |
299 } | 324 } |
300 | 325 |
301 return true; | 326 return true; |
302 } | 327 } |
303 | 328 |
304 | 329 |
305 ResourceModificationJob::ResourceModificationJob(ServerContext& context, unsigned int workersCount) : | 330 ResourceModificationJob::ResourceModificationJob(ServerContext& context, unsigned int workersCount) : |
306 ThreadedSetOfInstancesJob(context, false /* no post processing step */, true /* by default, keep source */, workersCount), | 331 ThreadedSetOfInstancesJob(context, true /* post processing step */, true /* by default, keep source */, workersCount), |
307 isAnonymization_(false), | 332 isAnonymization_(false), |
308 transcode_(false), | 333 transcode_(false), |
309 transferSyntax_(DicomTransferSyntax_LittleEndianExplicit) // dummy initialization | 334 transferSyntax_(DicomTransferSyntax_LittleEndianExplicit) // dummy initialization |
310 { | 335 { |
311 } | 336 } |