comparison OrthancServer/Sources/ServerToolbox.cpp @ 4988:8fba26292a9f

Housekeeper plugin: finalizing + integration tests ok
author Alain Mazy <am@osimis.io>
date Sat, 30 Apr 2022 19:39:40 +0200
parents 94a7b681b340
children b1fe3b44ce1d
comparison
equal deleted inserted replaced
4986:a25e74fad379 4988:8fba26292a9f
252 return false; 252 return false;
253 } 253 }
254 254
255 255
256 void ReconstructResource(ServerContext& context, 256 void ReconstructResource(ServerContext& context,
257 const std::string& resource) 257 const std::string& resource,
258 bool reconstructFiles)
258 { 259 {
259 LOG(WARNING) << "Reconstructing resource " << resource; 260 LOG(WARNING) << "Reconstructing resource " << resource;
260 261
261 std::list<std::string> instances; 262 std::list<std::string> instances;
262 context.GetIndex().GetChildInstances(instances, resource); 263 context.GetIndex().GetChildInstances(instances, resource);
269 // Delay the reconstruction of DICOM-as-JSON to its next access through "ServerContext" 270 // Delay the reconstruction of DICOM-as-JSON to its next access through "ServerContext"
270 context.GetIndex().DeleteAttachment(*it, FileContentType_DicomAsJson, false /* no revision */, 271 context.GetIndex().DeleteAttachment(*it, FileContentType_DicomAsJson, false /* no revision */,
271 -1 /* dummy revision */, "" /* dummy MD5 */); 272 -1 /* dummy revision */, "" /* dummy MD5 */);
272 273
273 context.GetIndex().ReconstructInstance(locker.GetDicom()); 274 context.GetIndex().ReconstructInstance(locker.GetDicom());
275
276 if (reconstructFiles)
277 {
278 // preserve metadata from old resource
279 typedef std::map<MetadataType, std::string> InstanceMetadata;
280 InstanceMetadata instanceMetadata;
281
282 std::string resultPublicId; // ignored
283 std::unique_ptr<DicomInstanceToStore> dicomInstancetoStore(DicomInstanceToStore::CreateFromParsedDicomFile(locker.GetDicom()));
284
285 context.GetIndex().GetAllMetadata(instanceMetadata, *it, ResourceType_Instance);
286
287 for (InstanceMetadata::const_iterator itm = instanceMetadata.begin();
288 itm != instanceMetadata.end(); ++itm)
289 {
290 dicomInstancetoStore->AddMetadata(ResourceType_Instance, itm->first, itm->second);
291 }
292
293 context.TranscodeAndStore(resultPublicId, dicomInstancetoStore.get(), StoreInstanceMode_OverwriteDuplicate, true);
294 }
274 } 295 }
275 } 296 }
276 } 297 }
277 } 298 }
299
300
301 todo: add a status route for the plugin !!!