annotate OrthancServer/Sources/ServerContext.cpp @ 5431:4be5f117aa0d

metrics
author Alain Mazy <am@osimis.io>
date Tue, 21 Nov 2023 10:32:42 +0100
parents 111e21b4f8bc
children 6f2b11bfee8d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
224
4eb0c7ce86c9 refactoring for store
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 /**
4eb0c7ce86c9 refactoring for store
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2 * Orthanc - A Lightweight, RESTful DICOM Store
1900
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
1288
6e7e5ed91c2d upgrade to year 2015
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1285
diff changeset
4 * Department, University Hospital of Liege, Belgium
5185
0ea402b4d901 upgrade to year 2023
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5184
diff changeset
5 * Copyright (C) 2017-2023 Osimis S.A., Belgium
0ea402b4d901 upgrade to year 2023
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5184
diff changeset
6 * Copyright (C) 2021-2023 Sebastien Jodogne, ICTEAM UCLouvain, Belgium
224
4eb0c7ce86c9 refactoring for store
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 *
4eb0c7ce86c9 refactoring for store
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 * This program is free software: you can redistribute it and/or
4eb0c7ce86c9 refactoring for store
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 * modify it under the terms of the GNU General Public License as
4eb0c7ce86c9 refactoring for store
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 * published by the Free Software Foundation, either version 3 of the
4eb0c7ce86c9 refactoring for store
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 * License, or (at your option) any later version.
4eb0c7ce86c9 refactoring for store
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 *
4eb0c7ce86c9 refactoring for store
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 * This program is distributed in the hope that it will be useful, but
4eb0c7ce86c9 refactoring for store
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
4eb0c7ce86c9 refactoring for store
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
4eb0c7ce86c9 refactoring for store
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16 * General Public License for more details.
4eb0c7ce86c9 refactoring for store
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17 *
4eb0c7ce86c9 refactoring for store
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18 * You should have received a copy of the GNU General Public License
4eb0c7ce86c9 refactoring for store
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
4eb0c7ce86c9 refactoring for store
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20 **/
4eb0c7ce86c9 refactoring for store
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21
4eb0c7ce86c9 refactoring for store
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22
831
84513f2ee1f3 pch for unit tests and server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 824
diff changeset
23 #include "PrecompiledHeadersServer.h"
224
4eb0c7ce86c9 refactoring for store
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24 #include "ServerContext.h"
4eb0c7ce86c9 refactoring for store
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25
4045
05b8fd21089c fix path
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
26 #include "../../OrthancFramework/Sources/Cache/SharedArchive.h"
4375
208029732d51 New config option "DeidentifyDimseQueryLogs"
Mark Poscablo <Mark.Poscablo@varian.com>
parents: 4274
diff changeset
27 #include "../../OrthancFramework/Sources/DicomFormat/DicomElement.h"
4499
6f99949b2878 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4473
diff changeset
28 #include "../../OrthancFramework/Sources/DicomFormat/DicomStreamReader.h"
4045
05b8fd21089c fix path
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
29 #include "../../OrthancFramework/Sources/DicomParsing/DcmtkTranscoder.h"
4375
208029732d51 New config option "DeidentifyDimseQueryLogs"
Mark Poscablo <Mark.Poscablo@varian.com>
parents: 4274
diff changeset
30 #include "../../OrthancFramework/Sources/DicomParsing/DicomModification.h"
4045
05b8fd21089c fix path
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
31 #include "../../OrthancFramework/Sources/DicomParsing/FromDcmtkBridge.h"
4196
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
32 #include "../../OrthancFramework/Sources/DicomParsing/Internals/DicomImageDecoder.h"
4045
05b8fd21089c fix path
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
33 #include "../../OrthancFramework/Sources/FileStorage/StorageAccessor.h"
05b8fd21089c fix path
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
34 #include "../../OrthancFramework/Sources/HttpServer/FilesystemHttpSender.h"
05b8fd21089c fix path
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
35 #include "../../OrthancFramework/Sources/HttpServer/HttpStreamTranscoder.h"
05b8fd21089c fix path
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
36 #include "../../OrthancFramework/Sources/JobsEngine/SetOfInstancesJob.h"
05b8fd21089c fix path
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
37 #include "../../OrthancFramework/Sources/Logging.h"
4845
02d77189d8ba added ReceivedInstanceCallback + sample C++ plugin
Alain Mazy <am@osimis.io>
parents: 4831
diff changeset
38 #include "../../OrthancFramework/Sources/MallocMemoryBuffer.h"
4045
05b8fd21089c fix path
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
39 #include "../../OrthancFramework/Sources/MetricsRegistry.h"
2668
d26dd081df97 saving jobs engine on exit
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2665
diff changeset
40 #include "../Plugins/Engine/OrthancPlugins.h"
3095
beeeb6096f27 removing dependencies upon ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3094
diff changeset
41
2940
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2925
diff changeset
42 #include "OrthancConfiguration.h"
2668
d26dd081df97 saving jobs engine on exit
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2665
diff changeset
43 #include "OrthancRestApi/OrthancRestApi.h"
3094
61da3c9b4121 cont reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3061
diff changeset
44 #include "Search/DatabaseLookup.h"
2668
d26dd081df97 saving jobs engine on exit
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2665
diff changeset
45 #include "ServerJobs/OrthancJobUnserializer.h"
397
941ea46e9e26 lua filter of new instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 394
diff changeset
46 #include "ServerToolbox.h"
3736
0540b54324f1 StorageCommitmentReports
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3713
diff changeset
47 #include "StorageCommitmentReports.h"
226
8a26a8e85edf refactoring to read files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 224
diff changeset
48
794
437c4a83d2cc refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 792
diff changeset
49 #include <dcmtk/dcmdata/dcfilefo.h>
4796
94616af363ec added ReceivedCStoreInstanceFilter lua callback + OrthancPluginRegisterIncomingCStoreInstanceFilter in sdk
Alain Mazy <am@osimis.io>
parents: 4789
diff changeset
50 #include <dcmtk/dcmnet/dimse.h>
5160
9f16979b6124 fix osx build
Alain Mazy <am@osimis.io>
parents: 5159
diff changeset
51
9f16979b6124 fix osx build
Alain Mazy <am@osimis.io>
parents: 5159
diff changeset
52 #if HAVE_MALLOC_TRIM == 1
9f16979b6124 fix osx build
Alain Mazy <am@osimis.io>
parents: 5159
diff changeset
53 # include <malloc.h>
9f16979b6124 fix osx build
Alain Mazy <am@osimis.io>
parents: 5159
diff changeset
54 #endif
1001
f3929718ea7e autorouting primitives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 998
diff changeset
55
4457
789676a8c96a Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
56 static size_t DICOM_CACHE_SIZE = 128 * 1024 * 1024; // 128 MB
1001
f3929718ea7e autorouting primitives
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 998
diff changeset
57
285
4031f73fe0e4 access to the raw dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 269
diff changeset
58
227
209ca3f6db62 dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 226
diff changeset
59 /**
209ca3f6db62 dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 226
diff changeset
60 * IMPORTANT: We make the assumption that the same instance of
209ca3f6db62 dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 226
diff changeset
61 * FileStorage can be accessed from multiple threads. This seems OK
209ca3f6db62 dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 226
diff changeset
62 * since the filesystem implements the required locking mechanisms,
209ca3f6db62 dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 226
diff changeset
63 * but maybe a read-writer lock on the "FileStorage" could be
209ca3f6db62 dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 226
diff changeset
64 * useful. Conversely, "ServerIndex" already implements mutex-based
209ca3f6db62 dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 226
diff changeset
65 * locking.
209ca3f6db62 dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 226
diff changeset
66 **/
209ca3f6db62 dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 226
diff changeset
67
224
4eb0c7ce86c9 refactoring for store
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
68 namespace Orthanc
4eb0c7ce86c9 refactoring for store
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
69 {
4978
2cfa50d8eb60 Speed-up handling of DicomModalitiesInStudy in C-Find and tools/find queries
Alain Mazy <am@osimis.io>
parents: 4977
diff changeset
70 static void ComputeStudyTags(ExpandedResource& resource,
2cfa50d8eb60 Speed-up handling of DicomModalitiesInStudy in C-Find and tools/find queries
Alain Mazy <am@osimis.io>
parents: 4977
diff changeset
71 ServerContext& context,
2cfa50d8eb60 Speed-up handling of DicomModalitiesInStudy in C-Find and tools/find queries
Alain Mazy <am@osimis.io>
parents: 4977
diff changeset
72 const std::string& studyPublicId,
2cfa50d8eb60 Speed-up handling of DicomModalitiesInStudy in C-Find and tools/find queries
Alain Mazy <am@osimis.io>
parents: 4977
diff changeset
73 const std::set<DicomTag>& requestedTags);
2cfa50d8eb60 Speed-up handling of DicomModalitiesInStudy in C-Find and tools/find queries
Alain Mazy <am@osimis.io>
parents: 4977
diff changeset
74
2cfa50d8eb60 Speed-up handling of DicomModalitiesInStudy in C-Find and tools/find queries
Alain Mazy <am@osimis.io>
parents: 4977
diff changeset
75
4384
7e0d015ad109 new configuration options IngestTranscodingOfUncompressed and IngestTranscodingOfCompressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4376
diff changeset
76 static bool IsUncompressedTransferSyntax(DicomTransferSyntax transferSyntax)
7e0d015ad109 new configuration options IngestTranscodingOfUncompressed and IngestTranscodingOfCompressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4376
diff changeset
77 {
7e0d015ad109 new configuration options IngestTranscodingOfUncompressed and IngestTranscodingOfCompressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4376
diff changeset
78 return (transferSyntax == DicomTransferSyntax_LittleEndianImplicit ||
7e0d015ad109 new configuration options IngestTranscodingOfUncompressed and IngestTranscodingOfCompressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4376
diff changeset
79 transferSyntax == DicomTransferSyntax_LittleEndianExplicit ||
7e0d015ad109 new configuration options IngestTranscodingOfUncompressed and IngestTranscodingOfCompressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4376
diff changeset
80 transferSyntax == DicomTransferSyntax_BigEndianExplicit);
7e0d015ad109 new configuration options IngestTranscodingOfUncompressed and IngestTranscodingOfCompressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4376
diff changeset
81 }
7e0d015ad109 new configuration options IngestTranscodingOfUncompressed and IngestTranscodingOfCompressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4376
diff changeset
82
7e0d015ad109 new configuration options IngestTranscodingOfUncompressed and IngestTranscodingOfCompressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4376
diff changeset
83
7e0d015ad109 new configuration options IngestTranscodingOfUncompressed and IngestTranscodingOfCompressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4376
diff changeset
84 static bool IsTranscodableTransferSyntax(DicomTransferSyntax transferSyntax)
7e0d015ad109 new configuration options IngestTranscodingOfUncompressed and IngestTranscodingOfCompressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4376
diff changeset
85 {
7e0d015ad109 new configuration options IngestTranscodingOfUncompressed and IngestTranscodingOfCompressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4376
diff changeset
86 return (
7e0d015ad109 new configuration options IngestTranscodingOfUncompressed and IngestTranscodingOfCompressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4376
diff changeset
87 // Do not try to transcode DICOM videos (new in Orthanc 1.8.2)
7e0d015ad109 new configuration options IngestTranscodingOfUncompressed and IngestTranscodingOfCompressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4376
diff changeset
88 transferSyntax != DicomTransferSyntax_MPEG2MainProfileAtMainLevel &&
7e0d015ad109 new configuration options IngestTranscodingOfUncompressed and IngestTranscodingOfCompressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4376
diff changeset
89 transferSyntax != DicomTransferSyntax_MPEG2MainProfileAtHighLevel &&
7e0d015ad109 new configuration options IngestTranscodingOfUncompressed and IngestTranscodingOfCompressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4376
diff changeset
90 transferSyntax != DicomTransferSyntax_MPEG4HighProfileLevel4_1 &&
7e0d015ad109 new configuration options IngestTranscodingOfUncompressed and IngestTranscodingOfCompressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4376
diff changeset
91 transferSyntax != DicomTransferSyntax_MPEG4BDcompatibleHighProfileLevel4_1 &&
7e0d015ad109 new configuration options IngestTranscodingOfUncompressed and IngestTranscodingOfCompressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4376
diff changeset
92 transferSyntax != DicomTransferSyntax_MPEG4HighProfileLevel4_2_For2DVideo &&
7e0d015ad109 new configuration options IngestTranscodingOfUncompressed and IngestTranscodingOfCompressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4376
diff changeset
93 transferSyntax != DicomTransferSyntax_MPEG4HighProfileLevel4_2_For3DVideo &&
7e0d015ad109 new configuration options IngestTranscodingOfUncompressed and IngestTranscodingOfCompressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4376
diff changeset
94 transferSyntax != DicomTransferSyntax_MPEG4StereoHighProfileLevel4_2 &&
7e0d015ad109 new configuration options IngestTranscodingOfUncompressed and IngestTranscodingOfCompressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4376
diff changeset
95 transferSyntax != DicomTransferSyntax_HEVCMainProfileLevel5_1 &&
7e0d015ad109 new configuration options IngestTranscodingOfUncompressed and IngestTranscodingOfCompressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4376
diff changeset
96 transferSyntax != DicomTransferSyntax_HEVCMain10ProfileLevel5_1 &&
7e0d015ad109 new configuration options IngestTranscodingOfUncompressed and IngestTranscodingOfCompressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4376
diff changeset
97
7e0d015ad109 new configuration options IngestTranscodingOfUncompressed and IngestTranscodingOfCompressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4376
diff changeset
98 // Do not try to transcode special transfer syntaxes
7e0d015ad109 new configuration options IngestTranscodingOfUncompressed and IngestTranscodingOfCompressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4376
diff changeset
99 transferSyntax != DicomTransferSyntax_RFC2557MimeEncapsulation &&
7e0d015ad109 new configuration options IngestTranscodingOfUncompressed and IngestTranscodingOfCompressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4376
diff changeset
100 transferSyntax != DicomTransferSyntax_XML);
7e0d015ad109 new configuration options IngestTranscodingOfUncompressed and IngestTranscodingOfCompressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4376
diff changeset
101 }
7e0d015ad109 new configuration options IngestTranscodingOfUncompressed and IngestTranscodingOfCompressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4376
diff changeset
102
4796
94616af363ec added ReceivedCStoreInstanceFilter lua callback + OrthancPluginRegisterIncomingCStoreInstanceFilter in sdk
Alain Mazy <am@osimis.io>
parents: 4789
diff changeset
103
94616af363ec added ReceivedCStoreInstanceFilter lua callback + OrthancPluginRegisterIncomingCStoreInstanceFilter in sdk
Alain Mazy <am@osimis.io>
parents: 4789
diff changeset
104 ServerContext::StoreResult::StoreResult() :
94616af363ec added ReceivedCStoreInstanceFilter lua callback + OrthancPluginRegisterIncomingCStoreInstanceFilter in sdk
Alain Mazy <am@osimis.io>
parents: 4789
diff changeset
105 status_(StoreStatus_Failure),
94616af363ec added ReceivedCStoreInstanceFilter lua callback + OrthancPluginRegisterIncomingCStoreInstanceFilter in sdk
Alain Mazy <am@osimis.io>
parents: 4789
diff changeset
106 cstoreStatusCode_(0)
94616af363ec added ReceivedCStoreInstanceFilter lua callback + OrthancPluginRegisterIncomingCStoreInstanceFilter in sdk
Alain Mazy <am@osimis.io>
parents: 4789
diff changeset
107 {
94616af363ec added ReceivedCStoreInstanceFilter lua callback + OrthancPluginRegisterIncomingCStoreInstanceFilter in sdk
Alain Mazy <am@osimis.io>
parents: 4789
diff changeset
108 }
94616af363ec added ReceivedCStoreInstanceFilter lua callback + OrthancPluginRegisterIncomingCStoreInstanceFilter in sdk
Alain Mazy <am@osimis.io>
parents: 4789
diff changeset
109
5182
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5181
diff changeset
110
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5181
diff changeset
111 #if HAVE_MALLOC_TRIM == 1
5183
5ec3dcdf78b9 renamed HousekeeperThread as MemoryTrimmingThread to avoid confusion with Housekeeper plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5182
diff changeset
112 void ServerContext::MemoryTrimmingThread(ServerContext* that,
5346
566e8d32bd3a Reduce the frequency of memory trimming from 100ms to 30s to avoid high idle CPU load
Alain Mazy <am@osimis.io>
parents: 5337
diff changeset
113 unsigned int intervalInSeconds)
5152
c81f363d3aa3 housekeeper thread to call malloc_trim and give back memory to the system
Alain Mazy <am@osimis.io>
parents: 5149
diff changeset
114 {
5346
566e8d32bd3a Reduce the frequency of memory trimming from 100ms to 30s to avoid high idle CPU load
Alain Mazy <am@osimis.io>
parents: 5337
diff changeset
115 boost::posix_time::ptime lastExecution = boost::posix_time::second_clock::universal_time();
566e8d32bd3a Reduce the frequency of memory trimming from 100ms to 30s to avoid high idle CPU load
Alain Mazy <am@osimis.io>
parents: 5337
diff changeset
116
5183
5ec3dcdf78b9 renamed HousekeeperThread as MemoryTrimmingThread to avoid confusion with Housekeeper plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5182
diff changeset
117 // This thread is started only if malloc_trim is defined
5152
c81f363d3aa3 housekeeper thread to call malloc_trim and give back memory to the system
Alain Mazy <am@osimis.io>
parents: 5149
diff changeset
118 while (!that->done_)
c81f363d3aa3 housekeeper thread to call malloc_trim and give back memory to the system
Alain Mazy <am@osimis.io>
parents: 5149
diff changeset
119 {
5346
566e8d32bd3a Reduce the frequency of memory trimming from 100ms to 30s to avoid high idle CPU load
Alain Mazy <am@osimis.io>
parents: 5337
diff changeset
120 boost::posix_time::ptime now = boost::posix_time::second_clock::universal_time();
566e8d32bd3a Reduce the frequency of memory trimming from 100ms to 30s to avoid high idle CPU load
Alain Mazy <am@osimis.io>
parents: 5337
diff changeset
121 boost::posix_time::time_duration elapsed = now - lastExecution;
566e8d32bd3a Reduce the frequency of memory trimming from 100ms to 30s to avoid high idle CPU load
Alain Mazy <am@osimis.io>
parents: 5337
diff changeset
122
566e8d32bd3a Reduce the frequency of memory trimming from 100ms to 30s to avoid high idle CPU load
Alain Mazy <am@osimis.io>
parents: 5337
diff changeset
123 if (elapsed.total_seconds() > intervalInSeconds)
566e8d32bd3a Reduce the frequency of memory trimming from 100ms to 30s to avoid high idle CPU load
Alain Mazy <am@osimis.io>
parents: 5337
diff changeset
124 {
566e8d32bd3a Reduce the frequency of memory trimming from 100ms to 30s to avoid high idle CPU load
Alain Mazy <am@osimis.io>
parents: 5337
diff changeset
125 // If possible, gives memory back to the system
566e8d32bd3a Reduce the frequency of memory trimming from 100ms to 30s to avoid high idle CPU load
Alain Mazy <am@osimis.io>
parents: 5337
diff changeset
126 // (see OrthancServer/Resources/ImplementationNotes/memory_consumption.txt)
566e8d32bd3a Reduce the frequency of memory trimming from 100ms to 30s to avoid high idle CPU load
Alain Mazy <am@osimis.io>
parents: 5337
diff changeset
127 {
566e8d32bd3a Reduce the frequency of memory trimming from 100ms to 30s to avoid high idle CPU load
Alain Mazy <am@osimis.io>
parents: 5337
diff changeset
128 MetricsRegistry::Timer timer(that->GetMetricsRegistry(), "orthanc_memory_trimming_duration_ms");
566e8d32bd3a Reduce the frequency of memory trimming from 100ms to 30s to avoid high idle CPU load
Alain Mazy <am@osimis.io>
parents: 5337
diff changeset
129 malloc_trim(128*1024);
566e8d32bd3a Reduce the frequency of memory trimming from 100ms to 30s to avoid high idle CPU load
Alain Mazy <am@osimis.io>
parents: 5337
diff changeset
130 }
566e8d32bd3a Reduce the frequency of memory trimming from 100ms to 30s to avoid high idle CPU load
Alain Mazy <am@osimis.io>
parents: 5337
diff changeset
131 lastExecution = boost::posix_time::second_clock::universal_time();
566e8d32bd3a Reduce the frequency of memory trimming from 100ms to 30s to avoid high idle CPU load
Alain Mazy <am@osimis.io>
parents: 5337
diff changeset
132 }
566e8d32bd3a Reduce the frequency of memory trimming from 100ms to 30s to avoid high idle CPU load
Alain Mazy <am@osimis.io>
parents: 5337
diff changeset
133
566e8d32bd3a Reduce the frequency of memory trimming from 100ms to 30s to avoid high idle CPU load
Alain Mazy <am@osimis.io>
parents: 5337
diff changeset
134 boost::this_thread::sleep(boost::posix_time::milliseconds(100));
5152
c81f363d3aa3 housekeeper thread to call malloc_trim and give back memory to the system
Alain Mazy <am@osimis.io>
parents: 5149
diff changeset
135 }
c81f363d3aa3 housekeeper thread to call malloc_trim and give back memory to the system
Alain Mazy <am@osimis.io>
parents: 5149
diff changeset
136 }
5182
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5181
diff changeset
137 #endif
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5181
diff changeset
138
4384
7e0d015ad109 new configuration options IngestTranscodingOfUncompressed and IngestTranscodingOfCompressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4376
diff changeset
139
2668
d26dd081df97 saving jobs engine on exit
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2665
diff changeset
140 void ServerContext::ChangeThread(ServerContext* that,
d26dd081df97 saving jobs engine on exit
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2665
diff changeset
141 unsigned int sleepDelay)
1436
0a3e3be59094 uncoupling of SignalChange for Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1434
diff changeset
142 {
0a3e3be59094 uncoupling of SignalChange for Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1434
diff changeset
143 while (!that->done_)
0a3e3be59094 uncoupling of SignalChange for Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1434
diff changeset
144 {
3712
2a170a8f1faf replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3679
diff changeset
145 std::unique_ptr<IDynamicObject> obj(that->pendingChanges_.Dequeue(sleepDelay));
1436
0a3e3be59094 uncoupling of SignalChange for Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1434
diff changeset
146
0a3e3be59094 uncoupling of SignalChange for Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1434
diff changeset
147 if (obj.get() != NULL)
0a3e3be59094 uncoupling of SignalChange for Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1434
diff changeset
148 {
0a3e3be59094 uncoupling of SignalChange for Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1434
diff changeset
149 const ServerIndexChange& change = dynamic_cast<const ServerIndexChange&>(*obj.get());
0a3e3be59094 uncoupling of SignalChange for Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1434
diff changeset
150
3947
cf6eb4fc6841 fix issue 179: use a shared mutex to avoid deadlock in python plugins
Alain Mazy <alain@mazy.be>
parents: 3945
diff changeset
151 boost::shared_lock<boost::shared_mutex> lock(that->listenersMutex_);
1436
0a3e3be59094 uncoupling of SignalChange for Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1434
diff changeset
152 for (ServerListeners::iterator it = that->listeners_.begin();
0a3e3be59094 uncoupling of SignalChange for Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1434
diff changeset
153 it != that->listeners_.end(); ++it)
0a3e3be59094 uncoupling of SignalChange for Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1434
diff changeset
154 {
0a3e3be59094 uncoupling of SignalChange for Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1434
diff changeset
155 try
0a3e3be59094 uncoupling of SignalChange for Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1434
diff changeset
156 {
2134
ddc75c6c712d Avoid hard crash if not enough memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2128
diff changeset
157 try
ddc75c6c712d Avoid hard crash if not enough memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2128
diff changeset
158 {
ddc75c6c712d Avoid hard crash if not enough memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2128
diff changeset
159 it->GetListener().SignalChange(change);
ddc75c6c712d Avoid hard crash if not enough memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2128
diff changeset
160 }
ddc75c6c712d Avoid hard crash if not enough memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2128
diff changeset
161 catch (std::bad_alloc&)
ddc75c6c712d Avoid hard crash if not enough memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2128
diff changeset
162 {
ddc75c6c712d Avoid hard crash if not enough memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2128
diff changeset
163 LOG(ERROR) << "Not enough memory while signaling a change";
ddc75c6c712d Avoid hard crash if not enough memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2128
diff changeset
164 }
ddc75c6c712d Avoid hard crash if not enough memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2128
diff changeset
165 catch (...)
ddc75c6c712d Avoid hard crash if not enough memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2128
diff changeset
166 {
5410
16cbfefa15e9 Solved a deadlock related to the Job Engine events and plugins
Alain Mazy <am@osimis.io>
parents: 5346
diff changeset
167 throw OrthancException(ErrorCode_InternalError, "Error while signaling a change");
2134
ddc75c6c712d Avoid hard crash if not enough memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2128
diff changeset
168 }
1436
0a3e3be59094 uncoupling of SignalChange for Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1434
diff changeset
169 }
0a3e3be59094 uncoupling of SignalChange for Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1434
diff changeset
170 catch (OrthancException& e)
0a3e3be59094 uncoupling of SignalChange for Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1434
diff changeset
171 {
0a3e3be59094 uncoupling of SignalChange for Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1434
diff changeset
172 LOG(ERROR) << "Error in the " << it->GetDescription()
2135
cadfe0a2a393 fix in the sample basic plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2134
diff changeset
173 << " callback while signaling a change: " << e.What()
cadfe0a2a393 fix in the sample basic plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2134
diff changeset
174 << " (code " << e.GetErrorCode() << ")";
1436
0a3e3be59094 uncoupling of SignalChange for Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1434
diff changeset
175 }
0a3e3be59094 uncoupling of SignalChange for Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1434
diff changeset
176 }
0a3e3be59094 uncoupling of SignalChange for Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1434
diff changeset
177 }
0a3e3be59094 uncoupling of SignalChange for Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1434
diff changeset
178 }
0a3e3be59094 uncoupling of SignalChange for Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1434
diff changeset
179 }
0a3e3be59094 uncoupling of SignalChange for Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1434
diff changeset
180
0a3e3be59094 uncoupling of SignalChange for Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1434
diff changeset
181
5410
16cbfefa15e9 Solved a deadlock related to the Job Engine events and plugins
Alain Mazy <am@osimis.io>
parents: 5346
diff changeset
182 void ServerContext::JobEventsThread(ServerContext* that,
16cbfefa15e9 Solved a deadlock related to the Job Engine events and plugins
Alain Mazy <am@osimis.io>
parents: 5346
diff changeset
183 unsigned int sleepDelay)
16cbfefa15e9 Solved a deadlock related to the Job Engine events and plugins
Alain Mazy <am@osimis.io>
parents: 5346
diff changeset
184 {
16cbfefa15e9 Solved a deadlock related to the Job Engine events and plugins
Alain Mazy <am@osimis.io>
parents: 5346
diff changeset
185 while (!that->done_)
16cbfefa15e9 Solved a deadlock related to the Job Engine events and plugins
Alain Mazy <am@osimis.io>
parents: 5346
diff changeset
186 {
16cbfefa15e9 Solved a deadlock related to the Job Engine events and plugins
Alain Mazy <am@osimis.io>
parents: 5346
diff changeset
187 std::unique_ptr<IDynamicObject> obj(that->pendingJobEvents_.Dequeue(sleepDelay));
16cbfefa15e9 Solved a deadlock related to the Job Engine events and plugins
Alain Mazy <am@osimis.io>
parents: 5346
diff changeset
188
16cbfefa15e9 Solved a deadlock related to the Job Engine events and plugins
Alain Mazy <am@osimis.io>
parents: 5346
diff changeset
189 if (obj.get() != NULL)
16cbfefa15e9 Solved a deadlock related to the Job Engine events and plugins
Alain Mazy <am@osimis.io>
parents: 5346
diff changeset
190 {
16cbfefa15e9 Solved a deadlock related to the Job Engine events and plugins
Alain Mazy <am@osimis.io>
parents: 5346
diff changeset
191 const JobEvent& event = dynamic_cast<const JobEvent&>(*obj.get());
16cbfefa15e9 Solved a deadlock related to the Job Engine events and plugins
Alain Mazy <am@osimis.io>
parents: 5346
diff changeset
192
16cbfefa15e9 Solved a deadlock related to the Job Engine events and plugins
Alain Mazy <am@osimis.io>
parents: 5346
diff changeset
193 boost::shared_lock<boost::shared_mutex> lock(that->listenersMutex_);
16cbfefa15e9 Solved a deadlock related to the Job Engine events and plugins
Alain Mazy <am@osimis.io>
parents: 5346
diff changeset
194 for (ServerListeners::iterator it = that->listeners_.begin();
16cbfefa15e9 Solved a deadlock related to the Job Engine events and plugins
Alain Mazy <am@osimis.io>
parents: 5346
diff changeset
195 it != that->listeners_.end(); ++it)
16cbfefa15e9 Solved a deadlock related to the Job Engine events and plugins
Alain Mazy <am@osimis.io>
parents: 5346
diff changeset
196 {
16cbfefa15e9 Solved a deadlock related to the Job Engine events and plugins
Alain Mazy <am@osimis.io>
parents: 5346
diff changeset
197 try
16cbfefa15e9 Solved a deadlock related to the Job Engine events and plugins
Alain Mazy <am@osimis.io>
parents: 5346
diff changeset
198 {
16cbfefa15e9 Solved a deadlock related to the Job Engine events and plugins
Alain Mazy <am@osimis.io>
parents: 5346
diff changeset
199 try
16cbfefa15e9 Solved a deadlock related to the Job Engine events and plugins
Alain Mazy <am@osimis.io>
parents: 5346
diff changeset
200 {
16cbfefa15e9 Solved a deadlock related to the Job Engine events and plugins
Alain Mazy <am@osimis.io>
parents: 5346
diff changeset
201 it->GetListener().SignalJobEvent(event);
16cbfefa15e9 Solved a deadlock related to the Job Engine events and plugins
Alain Mazy <am@osimis.io>
parents: 5346
diff changeset
202 }
16cbfefa15e9 Solved a deadlock related to the Job Engine events and plugins
Alain Mazy <am@osimis.io>
parents: 5346
diff changeset
203 catch (std::bad_alloc&)
16cbfefa15e9 Solved a deadlock related to the Job Engine events and plugins
Alain Mazy <am@osimis.io>
parents: 5346
diff changeset
204 {
16cbfefa15e9 Solved a deadlock related to the Job Engine events and plugins
Alain Mazy <am@osimis.io>
parents: 5346
diff changeset
205 LOG(ERROR) << "Not enough memory while signaling a job event";
16cbfefa15e9 Solved a deadlock related to the Job Engine events and plugins
Alain Mazy <am@osimis.io>
parents: 5346
diff changeset
206 }
16cbfefa15e9 Solved a deadlock related to the Job Engine events and plugins
Alain Mazy <am@osimis.io>
parents: 5346
diff changeset
207 catch (...)
16cbfefa15e9 Solved a deadlock related to the Job Engine events and plugins
Alain Mazy <am@osimis.io>
parents: 5346
diff changeset
208 {
16cbfefa15e9 Solved a deadlock related to the Job Engine events and plugins
Alain Mazy <am@osimis.io>
parents: 5346
diff changeset
209 throw OrthancException(ErrorCode_InternalError, "Error while signaling a job event");
16cbfefa15e9 Solved a deadlock related to the Job Engine events and plugins
Alain Mazy <am@osimis.io>
parents: 5346
diff changeset
210 }
16cbfefa15e9 Solved a deadlock related to the Job Engine events and plugins
Alain Mazy <am@osimis.io>
parents: 5346
diff changeset
211 }
16cbfefa15e9 Solved a deadlock related to the Job Engine events and plugins
Alain Mazy <am@osimis.io>
parents: 5346
diff changeset
212 catch (OrthancException& e)
16cbfefa15e9 Solved a deadlock related to the Job Engine events and plugins
Alain Mazy <am@osimis.io>
parents: 5346
diff changeset
213 {
16cbfefa15e9 Solved a deadlock related to the Job Engine events and plugins
Alain Mazy <am@osimis.io>
parents: 5346
diff changeset
214 LOG(ERROR) << "Error in the " << it->GetDescription()
16cbfefa15e9 Solved a deadlock related to the Job Engine events and plugins
Alain Mazy <am@osimis.io>
parents: 5346
diff changeset
215 << " callback while signaling a job event: " << e.What()
16cbfefa15e9 Solved a deadlock related to the Job Engine events and plugins
Alain Mazy <am@osimis.io>
parents: 5346
diff changeset
216 << " (code " << e.GetErrorCode() << ")";
16cbfefa15e9 Solved a deadlock related to the Job Engine events and plugins
Alain Mazy <am@osimis.io>
parents: 5346
diff changeset
217 }
16cbfefa15e9 Solved a deadlock related to the Job Engine events and plugins
Alain Mazy <am@osimis.io>
parents: 5346
diff changeset
218 }
16cbfefa15e9 Solved a deadlock related to the Job Engine events and plugins
Alain Mazy <am@osimis.io>
parents: 5346
diff changeset
219 }
16cbfefa15e9 Solved a deadlock related to the Job Engine events and plugins
Alain Mazy <am@osimis.io>
parents: 5346
diff changeset
220 }
16cbfefa15e9 Solved a deadlock related to the Job Engine events and plugins
Alain Mazy <am@osimis.io>
parents: 5346
diff changeset
221 }
16cbfefa15e9 Solved a deadlock related to the Job Engine events and plugins
Alain Mazy <am@osimis.io>
parents: 5346
diff changeset
222
16cbfefa15e9 Solved a deadlock related to the Job Engine events and plugins
Alain Mazy <am@osimis.io>
parents: 5346
diff changeset
223
2672
3efc44fac209 periodically saving jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2671
diff changeset
224 void ServerContext::SaveJobsThread(ServerContext* that,
3efc44fac209 periodically saving jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2671
diff changeset
225 unsigned int sleepDelay)
3efc44fac209 periodically saving jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2671
diff changeset
226 {
3efc44fac209 periodically saving jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2671
diff changeset
227 static const boost::posix_time::time_duration PERIODICITY =
3efc44fac209 periodically saving jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2671
diff changeset
228 boost::posix_time::seconds(10);
3efc44fac209 periodically saving jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2671
diff changeset
229
3efc44fac209 periodically saving jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2671
diff changeset
230 boost::posix_time::ptime next =
3efc44fac209 periodically saving jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2671
diff changeset
231 boost::posix_time::microsec_clock::universal_time() + PERIODICITY;
3efc44fac209 periodically saving jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2671
diff changeset
232
3efc44fac209 periodically saving jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2671
diff changeset
233 while (!that->done_)
3efc44fac209 periodically saving jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2671
diff changeset
234 {
3efc44fac209 periodically saving jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2671
diff changeset
235 boost::this_thread::sleep(boost::posix_time::milliseconds(sleepDelay));
3efc44fac209 periodically saving jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2671
diff changeset
236
2673
8e0bc055d18c JobsRegistry::IObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2672
diff changeset
237 if (that->haveJobsChanged_ ||
8e0bc055d18c JobsRegistry::IObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2672
diff changeset
238 boost::posix_time::microsec_clock::universal_time() >= next)
2672
3efc44fac209 periodically saving jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2671
diff changeset
239 {
2673
8e0bc055d18c JobsRegistry::IObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2672
diff changeset
240 that->haveJobsChanged_ = false;
8e0bc055d18c JobsRegistry::IObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2672
diff changeset
241 that->SaveJobsEngine();
2672
3efc44fac209 periodically saving jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2671
diff changeset
242 next = boost::posix_time::microsec_clock::universal_time() + PERIODICITY;
3efc44fac209 periodically saving jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2671
diff changeset
243 }
3efc44fac209 periodically saving jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2671
diff changeset
244 }
3efc44fac209 periodically saving jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2671
diff changeset
245 }
2673
8e0bc055d18c JobsRegistry::IObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2672
diff changeset
246
8e0bc055d18c JobsRegistry::IObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2672
diff changeset
247
8e0bc055d18c JobsRegistry::IObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2672
diff changeset
248 void ServerContext::SignalJobSubmitted(const std::string& jobId)
8e0bc055d18c JobsRegistry::IObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2672
diff changeset
249 {
8e0bc055d18c JobsRegistry::IObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2672
diff changeset
250 haveJobsChanged_ = true;
5410
16cbfefa15e9 Solved a deadlock related to the Job Engine events and plugins
Alain Mazy <am@osimis.io>
parents: 5346
diff changeset
251 pendingJobEvents_.Enqueue(new JobEvent(JobEventType_Submitted, jobId));
2673
8e0bc055d18c JobsRegistry::IObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2672
diff changeset
252 }
8e0bc055d18c JobsRegistry::IObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2672
diff changeset
253
8e0bc055d18c JobsRegistry::IObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2672
diff changeset
254
8e0bc055d18c JobsRegistry::IObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2672
diff changeset
255 void ServerContext::SignalJobSuccess(const std::string& jobId)
8e0bc055d18c JobsRegistry::IObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2672
diff changeset
256 {
8e0bc055d18c JobsRegistry::IObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2672
diff changeset
257 haveJobsChanged_ = true;
5410
16cbfefa15e9 Solved a deadlock related to the Job Engine events and plugins
Alain Mazy <am@osimis.io>
parents: 5346
diff changeset
258 pendingJobEvents_.Enqueue(new JobEvent(JobEventType_Success, jobId));
2673
8e0bc055d18c JobsRegistry::IObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2672
diff changeset
259 }
2672
3efc44fac209 periodically saving jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2671
diff changeset
260
3efc44fac209 periodically saving jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2671
diff changeset
261
2673
8e0bc055d18c JobsRegistry::IObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2672
diff changeset
262 void ServerContext::SignalJobFailure(const std::string& jobId)
8e0bc055d18c JobsRegistry::IObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2672
diff changeset
263 {
8e0bc055d18c JobsRegistry::IObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2672
diff changeset
264 haveJobsChanged_ = true;
5410
16cbfefa15e9 Solved a deadlock related to the Job Engine events and plugins
Alain Mazy <am@osimis.io>
parents: 5346
diff changeset
265 pendingJobEvents_.Enqueue(new JobEvent(JobEventType_Failure, jobId));
2673
8e0bc055d18c JobsRegistry::IObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2672
diff changeset
266 }
8e0bc055d18c JobsRegistry::IObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2672
diff changeset
267
8e0bc055d18c JobsRegistry::IObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2672
diff changeset
268
2671
06c0a6b8a871 new command-line argument: --no-jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2668
diff changeset
269 void ServerContext::SetupJobsEngine(bool unitTesting,
06c0a6b8a871 new command-line argument: --no-jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2668
diff changeset
270 bool loadJobsFromDatabase)
2668
d26dd081df97 saving jobs engine on exit
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2665
diff changeset
271 {
2671
06c0a6b8a871 new command-line argument: --no-jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2668
diff changeset
272 if (loadJobsFromDatabase)
2668
d26dd081df97 saving jobs engine on exit
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2665
diff changeset
273 {
2671
06c0a6b8a871 new command-line argument: --no-jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2668
diff changeset
274 std::string serialized;
4607
f75c63aa9de0 differentiating between shared and private global properties
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4519
diff changeset
275 if (index_.LookupGlobalProperty(serialized, GlobalProperty_JobsRegistry, false /* not shared */))
2671
06c0a6b8a871 new command-line argument: --no-jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2668
diff changeset
276 {
06c0a6b8a871 new command-line argument: --no-jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2668
diff changeset
277 LOG(WARNING) << "Reloading the jobs from the last execution of Orthanc";
2668
d26dd081df97 saving jobs engine on exit
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2665
diff changeset
278
2671
06c0a6b8a871 new command-line argument: --no-jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2668
diff changeset
279 try
06c0a6b8a871 new command-line argument: --no-jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2668
diff changeset
280 {
4205
d962a2996637 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4203
diff changeset
281 OrthancJobUnserializer unserializer(*this);
2815
925d8dc03a23 unserialization of jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2808
diff changeset
282 jobsEngine_.LoadRegistryFromString(unserializer, serialized);
2671
06c0a6b8a871 new command-line argument: --no-jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2668
diff changeset
283 }
06c0a6b8a871 new command-line argument: --no-jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2668
diff changeset
284 catch (OrthancException& e)
06c0a6b8a871 new command-line argument: --no-jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2668
diff changeset
285 {
2925
a80ba85d89e6 Orthanc starts even if jobs from a previous execution cannot be unserialized
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2898
diff changeset
286 LOG(WARNING) << "Cannot unserialize the jobs engine, starting anyway: " << e.What();
2671
06c0a6b8a871 new command-line argument: --no-jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2668
diff changeset
287 }
2668
d26dd081df97 saving jobs engine on exit
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2665
diff changeset
288 }
2671
06c0a6b8a871 new command-line argument: --no-jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2668
diff changeset
289 else
2668
d26dd081df97 saving jobs engine on exit
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2665
diff changeset
290 {
2671
06c0a6b8a871 new command-line argument: --no-jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2668
diff changeset
291 LOG(INFO) << "The last execution of Orthanc has archived no job";
2668
d26dd081df97 saving jobs engine on exit
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2665
diff changeset
292 }
d26dd081df97 saving jobs engine on exit
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2665
diff changeset
293 }
d26dd081df97 saving jobs engine on exit
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2665
diff changeset
294 else
d26dd081df97 saving jobs engine on exit
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2665
diff changeset
295 {
2925
a80ba85d89e6 Orthanc starts even if jobs from a previous execution cannot be unserialized
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2898
diff changeset
296 LOG(INFO) << "Not reloading the jobs from the last execution of Orthanc";
2668
d26dd081df97 saving jobs engine on exit
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2665
diff changeset
297 }
d26dd081df97 saving jobs engine on exit
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2665
diff changeset
298
4024
1d2b31fc782f new 'changes': JobSubmitted, JobSuccess, JobFailure
Alain Mazy <alain@mazy.be>
parents: 4022
diff changeset
299 jobsEngine_.GetRegistry().SetObserver(*this);
2668
d26dd081df97 saving jobs engine on exit
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2665
diff changeset
300 jobsEngine_.Start();
2815
925d8dc03a23 unserialization of jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2808
diff changeset
301 isJobsEngineUnserialized_ = true;
925d8dc03a23 unserialization of jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2808
diff changeset
302
925d8dc03a23 unserialization of jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2808
diff changeset
303 saveJobsThread_ = boost::thread(SaveJobsThread, this, (unitTesting ? 20 : 100));
2668
d26dd081df97 saving jobs engine on exit
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2665
diff changeset
304 }
d26dd081df97 saving jobs engine on exit
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2665
diff changeset
305
d26dd081df97 saving jobs engine on exit
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2665
diff changeset
306
d26dd081df97 saving jobs engine on exit
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2665
diff changeset
307 void ServerContext::SaveJobsEngine()
d26dd081df97 saving jobs engine on exit
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2665
diff changeset
308 {
3165
1fe524e211af New configuration option: "SaveJobs" to specify whether jobs are stored in the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3097
diff changeset
309 if (saveJobs_)
1fe524e211af New configuration option: "SaveJobs" to specify whether jobs are stored in the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3097
diff changeset
310 {
4268
0ae2ca210077 new macro TLOG() to replace VLOG() for trace logs with a category
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4265
diff changeset
311 LOG(TRACE) << "Serializing the content of the jobs engine";
2668
d26dd081df97 saving jobs engine on exit
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2665
diff changeset
312
3165
1fe524e211af New configuration option: "SaveJobs" to specify whether jobs are stored in the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3097
diff changeset
313 try
1fe524e211af New configuration option: "SaveJobs" to specify whether jobs are stored in the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3097
diff changeset
314 {
1fe524e211af New configuration option: "SaveJobs" to specify whether jobs are stored in the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3097
diff changeset
315 Json::Value value;
1fe524e211af New configuration option: "SaveJobs" to specify whether jobs are stored in the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3097
diff changeset
316 jobsEngine_.GetRegistry().Serialize(value);
2668
d26dd081df97 saving jobs engine on exit
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2665
diff changeset
317
4392
3af1d763763a confining Json::Reader and Json::*Writer into Toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4384
diff changeset
318 std::string serialized;
4394
f7104e9d044c functions to read/write JSON in OrthancPluginCppWrapper.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4392
diff changeset
319 Toolbox::WriteFastJson(serialized, value);
2668
d26dd081df97 saving jobs engine on exit
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2665
diff changeset
320
4607
f75c63aa9de0 differentiating between shared and private global properties
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4519
diff changeset
321 index_.SetGlobalProperty(GlobalProperty_JobsRegistry, false /* not shared */, serialized);
3165
1fe524e211af New configuration option: "SaveJobs" to specify whether jobs are stored in the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3097
diff changeset
322 }
1fe524e211af New configuration option: "SaveJobs" to specify whether jobs are stored in the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3097
diff changeset
323 catch (OrthancException& e)
1fe524e211af New configuration option: "SaveJobs" to specify whether jobs are stored in the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3097
diff changeset
324 {
1fe524e211af New configuration option: "SaveJobs" to specify whether jobs are stored in the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3097
diff changeset
325 LOG(ERROR) << "Cannot serialize the jobs engine: " << e.What();
1fe524e211af New configuration option: "SaveJobs" to specify whether jobs are stored in the database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3097
diff changeset
326 }
2668
d26dd081df97 saving jobs engine on exit
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2665
diff changeset
327 }
d26dd081df97 saving jobs engine on exit
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2665
diff changeset
328 }
d26dd081df97 saving jobs engine on exit
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2665
diff changeset
329
d26dd081df97 saving jobs engine on exit
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2665
diff changeset
330
5431
4be5f117aa0d metrics
Alain Mazy <am@osimis.io>
parents: 5427
diff changeset
331 void ServerContext::PublishCacheMetrics()
4457
789676a8c96a Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
332 {
5431
4be5f117aa0d metrics
Alain Mazy <am@osimis.io>
parents: 5427
diff changeset
333 metricsRegistry_->SetFloatValue("orthanc_dicom_cache_size_mb",
5337
b376abae664a Metrics can be stored either as floating-point numbers, or as integers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5334
diff changeset
334 static_cast<float>(dicomCache_.GetCurrentSize()) / static_cast<float>(1024 * 1024));
b376abae664a Metrics can be stored either as floating-point numbers, or as integers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5334
diff changeset
335 metricsRegistry_->SetIntegerValue("orthanc_dicom_cache_count", dicomCache_.GetNumberOfItems());
5431
4be5f117aa0d metrics
Alain Mazy <am@osimis.io>
parents: 5427
diff changeset
336
4be5f117aa0d metrics
Alain Mazy <am@osimis.io>
parents: 5427
diff changeset
337 metricsRegistry_->SetFloatValue("orthanc_storage_cache_size_mb",
4be5f117aa0d metrics
Alain Mazy <am@osimis.io>
parents: 5427
diff changeset
338 static_cast<float>(storageCache_.GetCurrentSize()) / static_cast<float>(1024 * 1024));
4be5f117aa0d metrics
Alain Mazy <am@osimis.io>
parents: 5427
diff changeset
339 metricsRegistry_->SetIntegerValue("orthanc_storage_cache_count", storageCache_.GetNumberOfItems());
4457
789676a8c96a Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
340 }
789676a8c96a Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
341
789676a8c96a Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
342
1549
e5e975e9b738 refactoring and simplification of StorageAccessor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1548
diff changeset
343 ServerContext::ServerContext(IDatabaseWrapper& database,
2665
389d050a2e66 fix deadlock, speed up unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2626
diff changeset
344 IStorageArea& area,
2950
dc18d5804746 support of JobsHistorySize set to zero
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2940
diff changeset
345 bool unitTesting,
dc18d5804746 support of JobsHistorySize set to zero
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2940
diff changeset
346 size_t maxCompletedJobs) :
2665
389d050a2e66 fix deadlock, speed up unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2626
diff changeset
347 index_(*this, database, (unitTesting ? 20 : 500)),
1549
e5e975e9b738 refactoring and simplification of StorageAccessor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1548
diff changeset
348 area_(area),
656
08eca5d86aad fixes to cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 409
diff changeset
349 compressionEnabled_(false),
1549
e5e975e9b738 refactoring and simplification of StorageAccessor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1548
diff changeset
350 storeMD5_(true),
4457
789676a8c96a Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
351 largeDicomThrottler_(1),
789676a8c96a Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
352 dicomCache_(DICOM_CACHE_SIZE),
2738
3a55b77339ff fix deadlock in Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2716
diff changeset
353 mainLua_(*this),
3a55b77339ff fix deadlock in Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2716
diff changeset
354 filterLua_(*this),
3a55b77339ff fix deadlock in Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2716
diff changeset
355 luaListener_(*this),
2950
dc18d5804746 support of JobsHistorySize set to zero
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2940
diff changeset
356 jobsEngine_(maxCompletedJobs),
2136
dd609a99d39a uniformization of the macro naming
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2135
diff changeset
357 #if ORTHANC_ENABLE_PLUGINS == 1
1232
f1c01451a8ee Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
358 plugins_(NULL),
1632
eb8fbcf008b5 fix build with plugins disabled
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1582
diff changeset
359 #endif
1436
0a3e3be59094 uncoupling of SignalChange for Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1434
diff changeset
360 done_(false),
2673
8e0bc055d18c JobsRegistry::IObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2672
diff changeset
361 haveJobsChanged_(false),
3174
8ea7c4546c3a primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3165
diff changeset
362 isJobsEngineUnserialized_(false),
3533
2090ec6a83a5 create a default user if none is provided, while issuing a warning in Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3346
diff changeset
363 metricsRegistry_(new MetricsRegistry),
3535
41365091a41e display a security warning in the logs at startup when ExecuteLuaEnabled is true
Alain Mazy <alain@mazy.be>
parents: 3534
diff changeset
364 isHttpServerSecure_(true),
3813
aaaa442bfe39 moving SetOverwriteInstances from ServerIndex to ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3736
diff changeset
365 isExecuteLuaEnabled_(false),
5200
f8f1c4a9a216 New configuration option 'RestApiWriteToFileSystemEnabled'
Alain Mazy <am@osimis.io>
parents: 5185
diff changeset
366 isRestApiWriteToFileSystemEnabled_(false),
3894
8f7ad4989fec transcoding to uncompressed transfer syntaxes over DICOM protocol is implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3839
diff changeset
367 overwriteInstances_(false),
3939
c205f670098e new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3938
diff changeset
368 dcmtkTranscoder_(new DcmtkTranscoder),
4375
208029732d51 New config option "DeidentifyDimseQueryLogs"
Mark Poscablo <Mark.Poscablo@varian.com>
parents: 4274
diff changeset
369 isIngestTranscoding_(false),
4384
7e0d015ad109 new configuration options IngestTranscodingOfUncompressed and IngestTranscodingOfCompressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4376
diff changeset
370 ingestTranscodingOfUncompressed_(true),
7e0d015ad109 new configuration options IngestTranscodingOfUncompressed and IngestTranscodingOfCompressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4376
diff changeset
371 ingestTranscodingOfCompressed_(true),
4465
fe774d8e904b New configuration option: "DicomScuPreferredTransferSyntax" to control transcoding in C-STORE SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4460
diff changeset
372 preferredTransferSyntax_(DicomTransferSyntax_LittleEndianExplicit),
5111
7547c7dfd017 /tools/metrics-prometheus: added orthanc_last_change and orthanc_up_time_s
Alain Mazy <am@osimis.io>
parents: 5060
diff changeset
373 deidentifyLogs_(false),
7547c7dfd017 /tools/metrics-prometheus: added orthanc_last_change and orthanc_up_time_s
Alain Mazy <am@osimis.io>
parents: 5060
diff changeset
374 serverStartTimeUtc_(boost::posix_time::second_clock::universal_time())
224
4eb0c7ce86c9 refactoring for store
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
375 {
3939
c205f670098e new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3938
diff changeset
376 try
2940
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2925
diff changeset
377 {
3939
c205f670098e new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3938
diff changeset
378 unsigned int lossyQuality;
c205f670098e new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3938
diff changeset
379
c205f670098e new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3938
diff changeset
380 {
c205f670098e new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3938
diff changeset
381 OrthancConfiguration::ReaderLock lock;
2965
9c0b0a6d8b54 MediaArchiveSize configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
382
3939
c205f670098e new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3938
diff changeset
383 queryRetrieveArchive_.reset(
c205f670098e new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3938
diff changeset
384 new SharedArchive(lock.GetConfiguration().GetUnsignedIntegerParameter("QueryRetrieveSize", 100)));
c205f670098e new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3938
diff changeset
385 mediaArchive_.reset(
c205f670098e new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3938
diff changeset
386 new SharedArchive(lock.GetConfiguration().GetUnsignedIntegerParameter("MediaArchiveSize", 1)));
4143
1ec3e1e18f50 Add missing tag "Retrieve AE Title (0008,0054)" in C-FIND SCP responses
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4140
diff changeset
387 defaultLocalAet_ = lock.GetConfiguration().GetOrthancAET();
3939
c205f670098e new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3938
diff changeset
388 jobsEngine_.SetWorkersCount(lock.GetConfiguration().GetUnsignedIntegerParameter("ConcurrentJobs", 2));
c205f670098e new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3938
diff changeset
389 saveJobs_ = lock.GetConfiguration().GetBooleanParameter("SaveJobs", true);
c205f670098e new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3938
diff changeset
390 metricsRegistry_->SetEnabled(lock.GetConfiguration().GetBooleanParameter("MetricsEnabled", true));
c205f670098e new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3938
diff changeset
391
c205f670098e new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3938
diff changeset
392 // New configuration options in Orthanc 1.5.1
c205f670098e new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3938
diff changeset
393 findStorageAccessMode_ = StringToFindStorageAccessMode(lock.GetConfiguration().GetStringParameter("StorageAccessOnFind", "Always"));
c205f670098e new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3938
diff changeset
394 limitFindInstances_ = lock.GetConfiguration().GetUnsignedIntegerParameter("LimitFindInstances", 0);
c205f670098e new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3938
diff changeset
395 limitFindResults_ = lock.GetConfiguration().GetUnsignedIntegerParameter("LimitFindResults", 0);
c205f670098e new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3938
diff changeset
396
c205f670098e new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3938
diff changeset
397 // New configuration option in Orthanc 1.6.0
c205f670098e new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3938
diff changeset
398 storageCommitmentReports_.reset(new StorageCommitmentReports(lock.GetConfiguration().GetUnsignedIntegerParameter("StorageCommitmentReportsSize", 100)));
c205f670098e new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3938
diff changeset
399
c205f670098e new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3938
diff changeset
400 // New options in Orthanc 1.7.0
c205f670098e new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3938
diff changeset
401 transcodeDicomProtocol_ = lock.GetConfiguration().GetBooleanParameter("TranscodeDicomProtocol", true);
c205f670098e new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3938
diff changeset
402 builtinDecoderTranscoderOrder_ = StringToBuiltinDecoderTranscoderOrder(lock.GetConfiguration().GetStringParameter("BuiltinDecoderTranscoderOrder", "After"));
c205f670098e new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3938
diff changeset
403 lossyQuality = lock.GetConfiguration().GetUnsignedIntegerParameter("DicomLossyTranscodingQuality", 90);
3677
4182cde57afb refactoring FindStorageAccessMode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
404
3939
c205f670098e new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3938
diff changeset
405 std::string s;
c205f670098e new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3938
diff changeset
406 if (lock.GetConfiguration().LookupStringParameter(s, "IngestTranscoding"))
c205f670098e new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3938
diff changeset
407 {
c205f670098e new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3938
diff changeset
408 if (LookupTransferSyntax(ingestTransferSyntax_, s))
c205f670098e new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3938
diff changeset
409 {
c205f670098e new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3938
diff changeset
410 isIngestTranscoding_ = true;
c205f670098e new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3938
diff changeset
411 LOG(WARNING) << "Incoming DICOM instances will automatically be transcoded to "
c205f670098e new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3938
diff changeset
412 << "transfer syntax: " << GetTransferSyntaxUid(ingestTransferSyntax_);
4384
7e0d015ad109 new configuration options IngestTranscodingOfUncompressed and IngestTranscodingOfCompressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4376
diff changeset
413
4465
fe774d8e904b New configuration option: "DicomScuPreferredTransferSyntax" to control transcoding in C-STORE SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4460
diff changeset
414 // New options in Orthanc 1.8.2
4384
7e0d015ad109 new configuration options IngestTranscodingOfUncompressed and IngestTranscodingOfCompressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4376
diff changeset
415 ingestTranscodingOfUncompressed_ = lock.GetConfiguration().GetBooleanParameter("IngestTranscodingOfUncompressed", true);
7e0d015ad109 new configuration options IngestTranscodingOfUncompressed and IngestTranscodingOfCompressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4376
diff changeset
416 ingestTranscodingOfCompressed_ = lock.GetConfiguration().GetBooleanParameter("IngestTranscodingOfCompressed", true);
7e0d015ad109 new configuration options IngestTranscodingOfUncompressed and IngestTranscodingOfCompressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4376
diff changeset
417
7e0d015ad109 new configuration options IngestTranscodingOfUncompressed and IngestTranscodingOfCompressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4376
diff changeset
418 LOG(WARNING) << " Ingest transcoding will "
7e0d015ad109 new configuration options IngestTranscodingOfUncompressed and IngestTranscodingOfCompressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4376
diff changeset
419 << (ingestTranscodingOfUncompressed_ ? "be applied" : "*not* be applied")
7e0d015ad109 new configuration options IngestTranscodingOfUncompressed and IngestTranscodingOfCompressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4376
diff changeset
420 << " to uncompressed transfer syntaxes (Little Endian Implicit/Explicit, Big Endian Explicit)";
7e0d015ad109 new configuration options IngestTranscodingOfUncompressed and IngestTranscodingOfCompressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4376
diff changeset
421
7e0d015ad109 new configuration options IngestTranscodingOfUncompressed and IngestTranscodingOfCompressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4376
diff changeset
422 LOG(WARNING) << " Ingest transcoding will "
7e0d015ad109 new configuration options IngestTranscodingOfUncompressed and IngestTranscodingOfCompressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4376
diff changeset
423 << (ingestTranscodingOfCompressed_ ? "be applied" : "*not* be applied")
7e0d015ad109 new configuration options IngestTranscodingOfUncompressed and IngestTranscodingOfCompressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4376
diff changeset
424 << " to compressed transfer syntaxes";
3939
c205f670098e new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3938
diff changeset
425 }
c205f670098e new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3938
diff changeset
426 else
c205f670098e new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3938
diff changeset
427 {
c205f670098e new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3938
diff changeset
428 throw OrthancException(ErrorCode_ParameterOutOfRange,
c205f670098e new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3938
diff changeset
429 "Unknown transfer syntax for ingest transcoding: " + s);
c205f670098e new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3938
diff changeset
430 }
c205f670098e new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3938
diff changeset
431 }
c205f670098e new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3938
diff changeset
432 else
c205f670098e new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3938
diff changeset
433 {
3941
771dbd9eb3bd class CleaningInstancesJob to share cleaning code by merge/split jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3939
diff changeset
434 isIngestTranscoding_ = false;
3939
c205f670098e new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3938
diff changeset
435 LOG(INFO) << "Automated transcoding of incoming DICOM instances is disabled";
c205f670098e new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3938
diff changeset
436 }
4375
208029732d51 New config option "DeidentifyDimseQueryLogs"
Mark Poscablo <Mark.Poscablo@varian.com>
parents: 4274
diff changeset
437
4465
fe774d8e904b New configuration option: "DicomScuPreferredTransferSyntax" to control transcoding in C-STORE SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4460
diff changeset
438 // New options in Orthanc 1.8.2
4376
b002f9abe802 review of changeset 4375:208029732d51
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4375
diff changeset
439 if (lock.GetConfiguration().GetBooleanParameter("DeidentifyLogs", true))
4375
208029732d51 New config option "DeidentifyDimseQueryLogs"
Mark Poscablo <Mark.Poscablo@varian.com>
parents: 4274
diff changeset
440 {
4376
b002f9abe802 review of changeset 4375:208029732d51
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4375
diff changeset
441 deidentifyLogs_ = true;
b002f9abe802 review of changeset 4375:208029732d51
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4375
diff changeset
442 CLOG(INFO, DICOM) << "Deidentification of log contents (notably for DIMSE queries) is enabled";
4375
208029732d51 New config option "DeidentifyDimseQueryLogs"
Mark Poscablo <Mark.Poscablo@varian.com>
parents: 4274
diff changeset
443
4376
b002f9abe802 review of changeset 4375:208029732d51
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4375
diff changeset
444 DicomVersion version = StringToDicomVersion(
5334
5b2a5cc64cb1 upgraded anonymization to Basic Profile of PS 3.15-2023b Table E.1-1
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5333
diff changeset
445 lock.GetConfiguration().GetStringParameter("DeidentifyLogsDicomVersion", "2023b"));
4375
208029732d51 New config option "DeidentifyDimseQueryLogs"
Mark Poscablo <Mark.Poscablo@varian.com>
parents: 4274
diff changeset
446 CLOG(INFO, DICOM) << "Version of DICOM standard used for deidentification is "
4376
b002f9abe802 review of changeset 4375:208029732d51
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4375
diff changeset
447 << EnumerationToString(version);
b002f9abe802 review of changeset 4375:208029732d51
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4375
diff changeset
448
b002f9abe802 review of changeset 4375:208029732d51
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4375
diff changeset
449 logsDeidentifierRules_.SetupAnonymization(version);
4375
208029732d51 New config option "DeidentifyDimseQueryLogs"
Mark Poscablo <Mark.Poscablo@varian.com>
parents: 4274
diff changeset
450 }
208029732d51 New config option "DeidentifyDimseQueryLogs"
Mark Poscablo <Mark.Poscablo@varian.com>
parents: 4274
diff changeset
451 else
208029732d51 New config option "DeidentifyDimseQueryLogs"
Mark Poscablo <Mark.Poscablo@varian.com>
parents: 4274
diff changeset
452 {
4376
b002f9abe802 review of changeset 4375:208029732d51
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4375
diff changeset
453 deidentifyLogs_ = false;
b002f9abe802 review of changeset 4375:208029732d51
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4375
diff changeset
454 CLOG(INFO, DICOM) << "Deidentification of log contents (notably for DIMSE queries) is disabled";
4375
208029732d51 New config option "DeidentifyDimseQueryLogs"
Mark Poscablo <Mark.Poscablo@varian.com>
parents: 4274
diff changeset
455 }
4465
fe774d8e904b New configuration option: "DicomScuPreferredTransferSyntax" to control transcoding in C-STORE SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4460
diff changeset
456
4473
68f52897c119 new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4465
diff changeset
457 // New options in Orthanc 1.9.0
4465
fe774d8e904b New configuration option: "DicomScuPreferredTransferSyntax" to control transcoding in C-STORE SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4460
diff changeset
458 if (lock.GetConfiguration().LookupStringParameter(s, "DicomScuPreferredTransferSyntax") &&
fe774d8e904b New configuration option: "DicomScuPreferredTransferSyntax" to control transcoding in C-STORE SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4460
diff changeset
459 !LookupTransferSyntax(preferredTransferSyntax_, s))
fe774d8e904b New configuration option: "DicomScuPreferredTransferSyntax" to control transcoding in C-STORE SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4460
diff changeset
460 {
fe774d8e904b New configuration option: "DicomScuPreferredTransferSyntax" to control transcoding in C-STORE SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4460
diff changeset
461 throw OrthancException(ErrorCode_ParameterOutOfRange,
fe774d8e904b New configuration option: "DicomScuPreferredTransferSyntax" to control transcoding in C-STORE SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4460
diff changeset
462 "Unknown preferred transfer syntax: " + s);
fe774d8e904b New configuration option: "DicomScuPreferredTransferSyntax" to control transcoding in C-STORE SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4460
diff changeset
463 }
fe774d8e904b New configuration option: "DicomScuPreferredTransferSyntax" to control transcoding in C-STORE SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4460
diff changeset
464
fe774d8e904b New configuration option: "DicomScuPreferredTransferSyntax" to control transcoding in C-STORE SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4460
diff changeset
465 CLOG(INFO, DICOM) << "Preferred transfer syntax for Orthanc C-STORE SCU: "
fe774d8e904b New configuration option: "DicomScuPreferredTransferSyntax" to control transcoding in C-STORE SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4460
diff changeset
466 << GetTransferSyntaxUid(preferredTransferSyntax_);
4473
68f52897c119 new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4465
diff changeset
467
68f52897c119 new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4465
diff changeset
468 lock.GetConfiguration().GetAcceptedTransferSyntaxes(acceptedTransferSyntaxes_);
68f52897c119 new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4465
diff changeset
469
68f52897c119 new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4465
diff changeset
470 isUnknownSopClassAccepted_ = lock.GetConfiguration().GetBooleanParameter("UnknownSopClassAccepted", false);
3939
c205f670098e new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3938
diff changeset
471 }
3894
8f7ad4989fec transcoding to uncompressed transfer syntaxes over DICOM protocol is implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3839
diff changeset
472
3939
c205f670098e new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3938
diff changeset
473 jobsEngine_.SetThreadSleep(unitTesting ? 20 : 200);
2940
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2925
diff changeset
474
3939
c205f670098e new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3938
diff changeset
475 listeners_.push_back(ServerListener(luaListener_, "Lua"));
c205f670098e new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3938
diff changeset
476 changeThread_ = boost::thread(ChangeThread, this, (unitTesting ? 20 : 100));
5410
16cbfefa15e9 Solved a deadlock related to the Job Engine events and plugins
Alain Mazy <am@osimis.io>
parents: 5346
diff changeset
477 jobEventsThread_ = boost::thread(JobEventsThread, this, (unitTesting ? 20 : 100));
5182
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5181
diff changeset
478
5159
f5907aecbaed conditional usage of malloc_trim
Alain Mazy <am@osimis.io>
parents: 5152
diff changeset
479 #if HAVE_MALLOC_TRIM == 1
5346
566e8d32bd3a Reduce the frequency of memory trimming from 100ms to 30s to avoid high idle CPU load
Alain Mazy <am@osimis.io>
parents: 5337
diff changeset
480 LOG(INFO) << "Starting memory trimming thread at 30 seconds interval";
566e8d32bd3a Reduce the frequency of memory trimming from 100ms to 30s to avoid high idle CPU load
Alain Mazy <am@osimis.io>
parents: 5337
diff changeset
481 memoryTrimmingThread_ = boost::thread(MemoryTrimmingThread, this, 30);
5159
f5907aecbaed conditional usage of malloc_trim
Alain Mazy <am@osimis.io>
parents: 5152
diff changeset
482 #else
5183
5ec3dcdf78b9 renamed HousekeeperThread as MemoryTrimmingThread to avoid confusion with Housekeeper plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5182
diff changeset
483 LOG(INFO) << "Your platform does not support malloc_trim(), not starting the memory trimming thread";
5159
f5907aecbaed conditional usage of malloc_trim
Alain Mazy <am@osimis.io>
parents: 5152
diff changeset
484 #endif
5182
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5181
diff changeset
485
3939
c205f670098e new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3938
diff changeset
486 dynamic_cast<DcmtkTranscoder&>(*dcmtkTranscoder_).SetLossyQuality(lossyQuality);
c205f670098e new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3938
diff changeset
487 }
c205f670098e new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3938
diff changeset
488 catch (OrthancException&)
c205f670098e new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3938
diff changeset
489 {
c205f670098e new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3938
diff changeset
490 Stop();
c205f670098e new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3938
diff changeset
491 throw;
c205f670098e new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3938
diff changeset
492 }
224
4eb0c7ce86c9 refactoring for store
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
493 }
4eb0c7ce86c9 refactoring for store
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
494
1436
0a3e3be59094 uncoupling of SignalChange for Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1434
diff changeset
495
0a3e3be59094 uncoupling of SignalChange for Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1434
diff changeset
496
0a3e3be59094 uncoupling of SignalChange for Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1434
diff changeset
497 ServerContext::~ServerContext()
0a3e3be59094 uncoupling of SignalChange for Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1434
diff changeset
498 {
1453
c0bdc47165ef code to warn about possible threading problems
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1447
diff changeset
499 if (!done_)
c0bdc47165ef code to warn about possible threading problems
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1447
diff changeset
500 {
c0bdc47165ef code to warn about possible threading problems
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1447
diff changeset
501 LOG(ERROR) << "INTERNAL ERROR: ServerContext::Stop() should be invoked manually to avoid mess in the destruction order!";
c0bdc47165ef code to warn about possible threading problems
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1447
diff changeset
502 Stop();
c0bdc47165ef code to warn about possible threading problems
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1447
diff changeset
503 }
1447
5ba7471780ae refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1436
diff changeset
504 }
5ba7471780ae refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1436
diff changeset
505
1436
0a3e3be59094 uncoupling of SignalChange for Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1434
diff changeset
506
1447
5ba7471780ae refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1436
diff changeset
507 void ServerContext::Stop()
5ba7471780ae refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1436
diff changeset
508 {
5ba7471780ae refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1436
diff changeset
509 if (!done_)
1436
0a3e3be59094 uncoupling of SignalChange for Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1434
diff changeset
510 {
1459
040d58493998 security
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1456
diff changeset
511 {
3947
cf6eb4fc6841 fix issue 179: use a shared mutex to avoid deadlock in python plugins
Alain Mazy <alain@mazy.be>
parents: 3945
diff changeset
512 boost::unique_lock<boost::shared_mutex> lock(listenersMutex_);
1459
040d58493998 security
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1456
diff changeset
513 listeners_.clear();
040d58493998 security
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1456
diff changeset
514 }
040d58493998 security
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1456
diff changeset
515
1447
5ba7471780ae refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1436
diff changeset
516 done_ = true;
5ba7471780ae refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1436
diff changeset
517
5ba7471780ae refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1436
diff changeset
518 if (changeThread_.joinable())
5ba7471780ae refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1436
diff changeset
519 {
5ba7471780ae refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1436
diff changeset
520 changeThread_.join();
5ba7471780ae refactoring: HttpToolbox, DumpJson in Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1436
diff changeset
521 }
1453
c0bdc47165ef code to warn about possible threading problems
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1447
diff changeset
522
5410
16cbfefa15e9 Solved a deadlock related to the Job Engine events and plugins
Alain Mazy <am@osimis.io>
parents: 5346
diff changeset
523 if (jobEventsThread_.joinable())
16cbfefa15e9 Solved a deadlock related to the Job Engine events and plugins
Alain Mazy <am@osimis.io>
parents: 5346
diff changeset
524 {
16cbfefa15e9 Solved a deadlock related to the Job Engine events and plugins
Alain Mazy <am@osimis.io>
parents: 5346
diff changeset
525 jobEventsThread_.join();
16cbfefa15e9 Solved a deadlock related to the Job Engine events and plugins
Alain Mazy <am@osimis.io>
parents: 5346
diff changeset
526 }
16cbfefa15e9 Solved a deadlock related to the Job Engine events and plugins
Alain Mazy <am@osimis.io>
parents: 5346
diff changeset
527
2672
3efc44fac209 periodically saving jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2671
diff changeset
528 if (saveJobsThread_.joinable())
3efc44fac209 periodically saving jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2671
diff changeset
529 {
3efc44fac209 periodically saving jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2671
diff changeset
530 saveJobsThread_.join();
3efc44fac209 periodically saving jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2671
diff changeset
531 }
3efc44fac209 periodically saving jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2671
diff changeset
532
5183
5ec3dcdf78b9 renamed HousekeeperThread as MemoryTrimmingThread to avoid confusion with Housekeeper plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5182
diff changeset
533 if (memoryTrimmingThread_.joinable())
5181
65b05b44ae4c properly finalizing the housekeeper thread that periodically calls malloc_trim()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5176
diff changeset
534 {
5183
5ec3dcdf78b9 renamed HousekeeperThread as MemoryTrimmingThread to avoid confusion with Housekeeper plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5182
diff changeset
535 memoryTrimmingThread_.join();
5181
65b05b44ae4c properly finalizing the housekeeper thread that periodically calls malloc_trim()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5176
diff changeset
536 }
65b05b44ae4c properly finalizing the housekeeper thread that periodically calls malloc_trim()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5176
diff changeset
537
4024
1d2b31fc782f new 'changes': JobSubmitted, JobSuccess, JobFailure
Alain Mazy <alain@mazy.be>
parents: 4022
diff changeset
538 jobsEngine_.GetRegistry().ResetObserver();
2815
925d8dc03a23 unserialization of jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2808
diff changeset
539
925d8dc03a23 unserialization of jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2808
diff changeset
540 if (isJobsEngineUnserialized_)
925d8dc03a23 unserialization of jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2808
diff changeset
541 {
925d8dc03a23 unserialization of jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2808
diff changeset
542 // Avoid losing jobs if the JobsRegistry cannot be unserialized
925d8dc03a23 unserialization of jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2808
diff changeset
543 SaveJobsEngine();
925d8dc03a23 unserialization of jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2808
diff changeset
544 }
2668
d26dd081df97 saving jobs engine on exit
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2665
diff changeset
545
1453
c0bdc47165ef code to warn about possible threading problems
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1447
diff changeset
546 // Do not change the order below!
2570
2e879c796ec7 JobsRegistry::SubmitAndWait(), StoreScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2507
diff changeset
547 jobsEngine_.Stop();
1453
c0bdc47165ef code to warn about possible threading problems
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1447
diff changeset
548 index_.Stop();
1436
0a3e3be59094 uncoupling of SignalChange for Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1434
diff changeset
549 }
0a3e3be59094 uncoupling of SignalChange for Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1434
diff changeset
550 }
0a3e3be59094 uncoupling of SignalChange for Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1434
diff changeset
551
0a3e3be59094 uncoupling of SignalChange for Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1434
diff changeset
552
236
6d9be2b470b4 compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 233
diff changeset
553 void ServerContext::SetCompressionEnabled(bool enabled)
6d9be2b470b4 compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 233
diff changeset
554 {
6d9be2b470b4 compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 233
diff changeset
555 if (enabled)
6d9be2b470b4 compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 233
diff changeset
556 LOG(WARNING) << "Disk compression is enabled";
6d9be2b470b4 compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 233
diff changeset
557 else
6d9be2b470b4 compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 233
diff changeset
558 LOG(WARNING) << "Disk compression is disabled";
6d9be2b470b4 compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 233
diff changeset
559
6d9be2b470b4 compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 233
diff changeset
560 compressionEnabled_ = enabled;
6d9be2b470b4 compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 233
diff changeset
561 }
6d9be2b470b4 compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 233
diff changeset
562
1549
e5e975e9b738 refactoring and simplification of StorageAccessor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1548
diff changeset
563
1126
bf67431a7383 handling of file content type in IStorageArea
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1124
diff changeset
564 void ServerContext::RemoveFile(const std::string& fileUuid,
bf67431a7383 handling of file content type in IStorageArea
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1124
diff changeset
565 FileContentType type)
227
209ca3f6db62 dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 226
diff changeset
566 {
5184
dd085f7e7e71 cleaning new constructors of StorageAccessor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5183
diff changeset
567 StorageAccessor accessor(area_, storageCache_, GetMetricsRegistry());
3175
574890d14c92 new metrics: orthanc_store_dicom_duration_ms, orthanc_storage_[create|read|remove]_duration_ms
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3174
diff changeset
568 accessor.Remove(fileUuid, type);
227
209ca3f6db62 dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 226
diff changeset
569 }
209ca3f6db62 dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 226
diff changeset
570
996
cf52f3bcb2b3 clarification of Lua classes wrt multithreading
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 995
diff changeset
571
4796
94616af363ec added ReceivedCStoreInstanceFilter lua callback + OrthancPluginRegisterIncomingCStoreInstanceFilter in sdk
Alain Mazy <am@osimis.io>
parents: 4789
diff changeset
572 ServerContext::StoreResult ServerContext::StoreAfterTranscoding(std::string& resultPublicId,
94616af363ec added ReceivedCStoreInstanceFilter lua callback + OrthancPluginRegisterIncomingCStoreInstanceFilter in sdk
Alain Mazy <am@osimis.io>
parents: 4789
diff changeset
573 DicomInstanceToStore& dicom,
4988
8fba26292a9f Housekeeper plugin: finalizing + integration tests ok
Alain Mazy <am@osimis.io>
parents: 4984
diff changeset
574 StoreInstanceMode mode,
8fba26292a9f Housekeeper plugin: finalizing + integration tests ok
Alain Mazy <am@osimis.io>
parents: 4984
diff changeset
575 bool isReconstruct)
1004
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1002
diff changeset
576 {
3814
023b2a9f3aa1 new enum: StoreInstanceMode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3813
diff changeset
577 bool overwrite;
023b2a9f3aa1 new enum: StoreInstanceMode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3813
diff changeset
578 switch (mode)
023b2a9f3aa1 new enum: StoreInstanceMode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3813
diff changeset
579 {
023b2a9f3aa1 new enum: StoreInstanceMode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3813
diff changeset
580 case StoreInstanceMode_Default:
023b2a9f3aa1 new enum: StoreInstanceMode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3813
diff changeset
581 overwrite = overwriteInstances_;
023b2a9f3aa1 new enum: StoreInstanceMode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3813
diff changeset
582 break;
023b2a9f3aa1 new enum: StoreInstanceMode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3813
diff changeset
583
023b2a9f3aa1 new enum: StoreInstanceMode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3813
diff changeset
584 case StoreInstanceMode_OverwriteDuplicate:
023b2a9f3aa1 new enum: StoreInstanceMode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3813
diff changeset
585 overwrite = true;
023b2a9f3aa1 new enum: StoreInstanceMode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3813
diff changeset
586 break;
023b2a9f3aa1 new enum: StoreInstanceMode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3813
diff changeset
587
023b2a9f3aa1 new enum: StoreInstanceMode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3813
diff changeset
588 case StoreInstanceMode_IgnoreDuplicate:
023b2a9f3aa1 new enum: StoreInstanceMode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3813
diff changeset
589 overwrite = false;
023b2a9f3aa1 new enum: StoreInstanceMode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3813
diff changeset
590 break;
023b2a9f3aa1 new enum: StoreInstanceMode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3813
diff changeset
591
023b2a9f3aa1 new enum: StoreInstanceMode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3813
diff changeset
592 default:
023b2a9f3aa1 new enum: StoreInstanceMode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3813
diff changeset
593 throw OrthancException(ErrorCode_ParameterOutOfRange);
4499
6f99949b2878 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4473
diff changeset
594 }
6f99949b2878 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4473
diff changeset
595
6f99949b2878 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4473
diff changeset
596 bool hasPixelDataOffset;
6f99949b2878 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4473
diff changeset
597 uint64_t pixelDataOffset;
5316
03501a258d9e added instance metadata "PixelDataVR"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5296
diff changeset
598 ValueRepresentation pixelDataVR;
4499
6f99949b2878 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4473
diff changeset
599 hasPixelDataOffset = DicomStreamReader::LookupPixelDataOffset(
5316
03501a258d9e added instance metadata "PixelDataVR"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5296
diff changeset
600 pixelDataOffset, pixelDataVR, dicom.GetBufferData(), dicom.GetBufferSize());
4506
ac69c9f76c71 refactoring ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4505
diff changeset
601
4507
b4c58795f3a8 widening the use of DicomTransferSyntax enum
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4506
diff changeset
602 DicomTransferSyntax transferSyntax;
4506
ac69c9f76c71 refactoring ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4505
diff changeset
603 bool hasTransferSyntax = dicom.LookupTransferSyntax(transferSyntax);
4507
b4c58795f3a8 widening the use of DicomTransferSyntax enum
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4506
diff changeset
604
4505
97d103b57cd1 removed cached dicom summary from DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4504
diff changeset
605 DicomMap summary;
5044
6fed78e13233 Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents: 5043
diff changeset
606 dicom.GetSummary(summary); // -> from Orthanc 1.11.1, this includes the leaf nodes and sequences
5036
877bc3b96476 Handle Dicom sequences in ExtraMainDicomTags and save them in the 'MainDicomSequences' metadata
Alain Mazy <am@osimis.io>
parents: 4994
diff changeset
607
5176
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5160
diff changeset
608 std::set<DicomTag> allMainDicomTags;
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5160
diff changeset
609 DicomMap::GetAllMainDicomTags(allMainDicomTags);
4505
97d103b57cd1 removed cached dicom summary from DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4504
diff changeset
610
1004
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1002
diff changeset
611 try
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1002
diff changeset
612 {
3175
574890d14c92 new metrics: orthanc_store_dicom_duration_ms, orthanc_storage_[create|read|remove]_duration_ms
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3174
diff changeset
613 MetricsRegistry::Timer timer(GetMetricsRegistry(), "orthanc_store_dicom_duration_ms");
5184
dd085f7e7e71 cleaning new constructors of StorageAccessor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5183
diff changeset
614 StorageAccessor accessor(area_, storageCache_, GetMetricsRegistry());
1549
e5e975e9b738 refactoring and simplification of StorageAccessor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1548
diff changeset
615
4507
b4c58795f3a8 widening the use of DicomTransferSyntax enum
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4506
diff changeset
616 DicomInstanceHasher hasher(summary);
b4c58795f3a8 widening the use of DicomTransferSyntax enum
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4506
diff changeset
617 resultPublicId = hasher.HashInstance();
1004
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1002
diff changeset
618
5044
6fed78e13233 Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents: 5043
diff changeset
619 Json::Value dicomAsJson;
6fed78e13233 Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents: 5043
diff changeset
620 dicom.GetDicomAsJson(dicomAsJson, allMainDicomTags); // don't crop any main dicom tags
5036
877bc3b96476 Handle Dicom sequences in ExtraMainDicomTags and save them in the 'MainDicomSequences' metadata
Alain Mazy <am@osimis.io>
parents: 4994
diff changeset
621
1574
0c29ebe80ac9 give access to full request origin in ReceivedInstanceFilter (Lua)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1550
diff changeset
622 Json::Value simplifiedTags;
4504
7d1eabfac6e0 removed cached dicom-as-json from DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4500
diff changeset
623 Toolbox::SimplifyDicomAsJson(simplifiedTags, dicomAsJson, DicomToJsonFormat_Human);
1004
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1002
diff changeset
624
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1002
diff changeset
625 // Test if the instance must be filtered out
4796
94616af363ec added ReceivedCStoreInstanceFilter lua callback + OrthancPluginRegisterIncomingCStoreInstanceFilter in sdk
Alain Mazy <am@osimis.io>
parents: 4789
diff changeset
626 StoreResult result;
1433
461e7554bff7 refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1427
diff changeset
627
4988
8fba26292a9f Housekeeper plugin: finalizing + integration tests ok
Alain Mazy <am@osimis.io>
parents: 4984
diff changeset
628 if (!isReconstruct) // skip all filters if this is a reconstruction
1433
461e7554bff7 refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1427
diff changeset
629 {
3947
cf6eb4fc6841 fix issue 179: use a shared mutex to avoid deadlock in python plugins
Alain Mazy <alain@mazy.be>
parents: 3945
diff changeset
630 boost::shared_lock<boost::shared_mutex> lock(listenersMutex_);
1453
c0bdc47165ef code to warn about possible threading problems
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1447
diff changeset
631
c0bdc47165ef code to warn about possible threading problems
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1447
diff changeset
632 for (ServerListeners::iterator it = listeners_.begin(); it != listeners_.end(); ++it)
1433
461e7554bff7 refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1427
diff changeset
633 {
1453
c0bdc47165ef code to warn about possible threading problems
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1447
diff changeset
634 try
1433
461e7554bff7 refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1427
diff changeset
635 {
1574
0c29ebe80ac9 give access to full request origin in ReceivedInstanceFilter (Lua)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1550
diff changeset
636 if (!it->GetListener().FilterIncomingInstance(dicom, simplifiedTags))
1453
c0bdc47165ef code to warn about possible threading problems
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1447
diff changeset
637 {
4796
94616af363ec added ReceivedCStoreInstanceFilter lua callback + OrthancPluginRegisterIncomingCStoreInstanceFilter in sdk
Alain Mazy <am@osimis.io>
parents: 4789
diff changeset
638 result.SetStatus(StoreStatus_FilteredOut);
94616af363ec added ReceivedCStoreInstanceFilter lua callback + OrthancPluginRegisterIncomingCStoreInstanceFilter in sdk
Alain Mazy <am@osimis.io>
parents: 4789
diff changeset
639 result.SetCStoreStatusCode(STATUS_Success); // to keep backward compatibility, we still return 'success'
1453
c0bdc47165ef code to warn about possible threading problems
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1447
diff changeset
640 break;
c0bdc47165ef code to warn about possible threading problems
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1447
diff changeset
641 }
4796
94616af363ec added ReceivedCStoreInstanceFilter lua callback + OrthancPluginRegisterIncomingCStoreInstanceFilter in sdk
Alain Mazy <am@osimis.io>
parents: 4789
diff changeset
642
94616af363ec added ReceivedCStoreInstanceFilter lua callback + OrthancPluginRegisterIncomingCStoreInstanceFilter in sdk
Alain Mazy <am@osimis.io>
parents: 4789
diff changeset
643 if (dicom.GetOrigin().GetRequestOrigin() == Orthanc::RequestOrigin_DicomProtocol)
94616af363ec added ReceivedCStoreInstanceFilter lua callback + OrthancPluginRegisterIncomingCStoreInstanceFilter in sdk
Alain Mazy <am@osimis.io>
parents: 4789
diff changeset
644 {
4921
309fb4f02704 fix signature of OrthancPluginIncomingCStoreInstanceFilter
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4919
diff changeset
645 uint16_t filterResult = STATUS_Success;
309fb4f02704 fix signature of OrthancPluginIncomingCStoreInstanceFilter
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4919
diff changeset
646 if (!it->GetListener().FilterIncomingCStoreInstance(filterResult, dicom, simplifiedTags))
4796
94616af363ec added ReceivedCStoreInstanceFilter lua callback + OrthancPluginRegisterIncomingCStoreInstanceFilter in sdk
Alain Mazy <am@osimis.io>
parents: 4789
diff changeset
647 {
4921
309fb4f02704 fix signature of OrthancPluginIncomingCStoreInstanceFilter
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4919
diff changeset
648 // The instance is to be discarded
4796
94616af363ec added ReceivedCStoreInstanceFilter lua callback + OrthancPluginRegisterIncomingCStoreInstanceFilter in sdk
Alain Mazy <am@osimis.io>
parents: 4789
diff changeset
649 result.SetStatus(StoreStatus_FilteredOut);
94616af363ec added ReceivedCStoreInstanceFilter lua callback + OrthancPluginRegisterIncomingCStoreInstanceFilter in sdk
Alain Mazy <am@osimis.io>
parents: 4789
diff changeset
650 result.SetCStoreStatusCode(filterResult);
94616af363ec added ReceivedCStoreInstanceFilter lua callback + OrthancPluginRegisterIncomingCStoreInstanceFilter in sdk
Alain Mazy <am@osimis.io>
parents: 4789
diff changeset
651 break;
94616af363ec added ReceivedCStoreInstanceFilter lua callback + OrthancPluginRegisterIncomingCStoreInstanceFilter in sdk
Alain Mazy <am@osimis.io>
parents: 4789
diff changeset
652 }
94616af363ec added ReceivedCStoreInstanceFilter lua callback + OrthancPluginRegisterIncomingCStoreInstanceFilter in sdk
Alain Mazy <am@osimis.io>
parents: 4789
diff changeset
653 }
94616af363ec added ReceivedCStoreInstanceFilter lua callback + OrthancPluginRegisterIncomingCStoreInstanceFilter in sdk
Alain Mazy <am@osimis.io>
parents: 4789
diff changeset
654
1433
461e7554bff7 refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1427
diff changeset
655 }
1453
c0bdc47165ef code to warn about possible threading problems
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1447
diff changeset
656 catch (OrthancException& e)
c0bdc47165ef code to warn about possible threading problems
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1447
diff changeset
657 {
c0bdc47165ef code to warn about possible threading problems
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1447
diff changeset
658 LOG(ERROR) << "Error in the " << it->GetDescription()
2135
cadfe0a2a393 fix in the sample basic plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2134
diff changeset
659 << " callback while receiving an instance: " << e.What()
cadfe0a2a393 fix in the sample basic plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2134
diff changeset
660 << " (code " << e.GetErrorCode() << ")";
1453
c0bdc47165ef code to warn about possible threading problems
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1447
diff changeset
661 throw;
c0bdc47165ef code to warn about possible threading problems
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1447
diff changeset
662 }
1433
461e7554bff7 refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1427
diff changeset
663 }
461e7554bff7 refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1427
diff changeset
664 }
461e7554bff7 refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1427
diff changeset
665
4796
94616af363ec added ReceivedCStoreInstanceFilter lua callback + OrthancPluginRegisterIncomingCStoreInstanceFilter in sdk
Alain Mazy <am@osimis.io>
parents: 4789
diff changeset
666 if (result.GetStatus() == StoreStatus_FilteredOut)
1004
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1002
diff changeset
667 {
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1002
diff changeset
668 LOG(INFO) << "An incoming instance has been discarded by the filter";
4796
94616af363ec added ReceivedCStoreInstanceFilter lua callback + OrthancPluginRegisterIncomingCStoreInstanceFilter in sdk
Alain Mazy <am@osimis.io>
parents: 4789
diff changeset
669 return result;
1004
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1002
diff changeset
670 }
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1002
diff changeset
671
4457
789676a8c96a Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
672 // Remove the file from the DicomCache (useful if
789676a8c96a Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
673 // "OverwriteInstances" is set to "true")
789676a8c96a Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
674 dicomCache_.Invalidate(resultPublicId);
2825
8aa6aef11b70 New configuration option "OverwriteInstances" to choose how duplicate SOPInstanceUID are handled
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2815
diff changeset
675
1549
e5e975e9b738 refactoring and simplification of StorageAccessor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1548
diff changeset
676 // TODO Should we use "gzip" instead?
e5e975e9b738 refactoring and simplification of StorageAccessor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1548
diff changeset
677 CompressionType compression = (compressionEnabled_ ? CompressionType_ZlibWithSize : CompressionType_None);
1004
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1002
diff changeset
678
1549
e5e975e9b738 refactoring and simplification of StorageAccessor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1548
diff changeset
679 FileInfo dicomInfo = accessor.Write(dicom.GetBufferData(), dicom.GetBufferSize(),
e5e975e9b738 refactoring and simplification of StorageAccessor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1548
diff changeset
680 FileContentType_Dicom, compression, storeMD5_);
1004
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1002
diff changeset
681
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1002
diff changeset
682 ServerIndex::Attachments attachments;
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1002
diff changeset
683 attachments.push_back(dicomInfo);
4500
3b4940bca158 added safeguards in Orthanc::FileInfo
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4499
diff changeset
684
4514
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
685 FileInfo dicomUntilPixelData;
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
686 if (hasPixelDataOffset &&
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
687 (!area_.HasReadRange() ||
4519
a3c6678aa7b1 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4514
diff changeset
688 compressionEnabled_))
4500
3b4940bca158 added safeguards in Orthanc::FileInfo
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4499
diff changeset
689 {
4514
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
690 dicomUntilPixelData = accessor.Write(dicom.GetBufferData(), pixelDataOffset,
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
691 FileContentType_DicomUntilPixelData, compression, storeMD5_);
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
692 attachments.push_back(dicomUntilPixelData);
4500
3b4940bca158 added safeguards in Orthanc::FileInfo
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4499
diff changeset
693 }
1004
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1002
diff changeset
694
1067
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
695 typedef std::map<MetadataType, std::string> InstanceMetadata;
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
696 InstanceMetadata instanceMetadata;
4796
94616af363ec added ReceivedCStoreInstanceFilter lua callback + OrthancPluginRegisterIncomingCStoreInstanceFilter in sdk
Alain Mazy <am@osimis.io>
parents: 4789
diff changeset
697 result.SetStatus(index_.Store(
5044
6fed78e13233 Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents: 5043
diff changeset
698 instanceMetadata, summary, attachments, dicom.GetMetadata(), dicom.GetOrigin(), overwrite,
5316
03501a258d9e added instance metadata "PixelDataVR"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5296
diff changeset
699 hasTransferSyntax, transferSyntax, hasPixelDataOffset, pixelDataOffset, pixelDataVR, isReconstruct));
1004
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1002
diff changeset
700
1433
461e7554bff7 refactoring: LuaScripting
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1427
diff changeset
701 // Only keep the metadata for the "instance" level
4506
ac69c9f76c71 refactoring ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4505
diff changeset
702 dicom.ClearMetadata();
1067
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
703
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
704 for (InstanceMetadata::const_iterator it = instanceMetadata.begin();
1304
7b6925b0890d cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
705 it != instanceMetadata.end(); ++it)
1067
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
706 {
4506
ac69c9f76c71 refactoring ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4505
diff changeset
707 dicom.AddMetadata(ResourceType_Instance, it->first, it->second);
1067
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
708 }
ace99e272203 access metadata in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1066
diff changeset
709
4796
94616af363ec added ReceivedCStoreInstanceFilter lua callback + OrthancPluginRegisterIncomingCStoreInstanceFilter in sdk
Alain Mazy <am@osimis.io>
parents: 4789
diff changeset
710 if (result.GetStatus() != StoreStatus_Success)
1004
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1002
diff changeset
711 {
1549
e5e975e9b738 refactoring and simplification of StorageAccessor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1548
diff changeset
712 accessor.Remove(dicomInfo);
4500
3b4940bca158 added safeguards in Orthanc::FileInfo
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4499
diff changeset
713
4514
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
714 if (dicomUntilPixelData.IsValid())
4500
3b4940bca158 added safeguards in Orthanc::FileInfo
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4499
diff changeset
715 {
4514
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
716 accessor.Remove(dicomUntilPixelData);
4500
3b4940bca158 added safeguards in Orthanc::FileInfo
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4499
diff changeset
717 }
1004
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1002
diff changeset
718 }
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1002
diff changeset
719
4994
2f30aa99c2db cppcheck
Alain Mazy <am@osimis.io>
parents: 4988
diff changeset
720 if (!isReconstruct)
1004
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1002
diff changeset
721 {
4994
2f30aa99c2db cppcheck
Alain Mazy <am@osimis.io>
parents: 4988
diff changeset
722 // skip logs in case of reconstruction
4988
8fba26292a9f Housekeeper plugin: finalizing + integration tests ok
Alain Mazy <am@osimis.io>
parents: 4984
diff changeset
723 switch (result.GetStatus())
8fba26292a9f Housekeeper plugin: finalizing + integration tests ok
Alain Mazy <am@osimis.io>
parents: 4984
diff changeset
724 {
8fba26292a9f Housekeeper plugin: finalizing + integration tests ok
Alain Mazy <am@osimis.io>
parents: 4984
diff changeset
725 case StoreStatus_Success:
8fba26292a9f Housekeeper plugin: finalizing + integration tests ok
Alain Mazy <am@osimis.io>
parents: 4984
diff changeset
726 LOG(INFO) << "New instance stored";
8fba26292a9f Housekeeper plugin: finalizing + integration tests ok
Alain Mazy <am@osimis.io>
parents: 4984
diff changeset
727 break;
1004
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1002
diff changeset
728
4988
8fba26292a9f Housekeeper plugin: finalizing + integration tests ok
Alain Mazy <am@osimis.io>
parents: 4984
diff changeset
729 case StoreStatus_AlreadyStored:
8fba26292a9f Housekeeper plugin: finalizing + integration tests ok
Alain Mazy <am@osimis.io>
parents: 4984
diff changeset
730 LOG(INFO) << "Already stored";
8fba26292a9f Housekeeper plugin: finalizing + integration tests ok
Alain Mazy <am@osimis.io>
parents: 4984
diff changeset
731 break;
1004
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1002
diff changeset
732
4988
8fba26292a9f Housekeeper plugin: finalizing + integration tests ok
Alain Mazy <am@osimis.io>
parents: 4984
diff changeset
733 case StoreStatus_Failure:
5296
5053a10da5a2 Fix orphan files remaining in storage when working with MaximumStorageSize
Alain Mazy <am@osimis.io>
parents: 5248
diff changeset
734 LOG(ERROR) << "Unknown store failure";
5053a10da5a2 Fix orphan files remaining in storage when working with MaximumStorageSize
Alain Mazy <am@osimis.io>
parents: 5248
diff changeset
735 throw OrthancException(ErrorCode_InternalError, HttpStatus_500_InternalServerError);
5053a10da5a2 Fix orphan files remaining in storage when working with MaximumStorageSize
Alain Mazy <am@osimis.io>
parents: 5248
diff changeset
736
5053a10da5a2 Fix orphan files remaining in storage when working with MaximumStorageSize
Alain Mazy <am@osimis.io>
parents: 5248
diff changeset
737 case StoreStatus_StorageFull:
5053a10da5a2 Fix orphan files remaining in storage when working with MaximumStorageSize
Alain Mazy <am@osimis.io>
parents: 5248
diff changeset
738 LOG(ERROR) << "Storage full";
5053a10da5a2 Fix orphan files remaining in storage when working with MaximumStorageSize
Alain Mazy <am@osimis.io>
parents: 5248
diff changeset
739 throw OrthancException(ErrorCode_FullStorage, HttpStatus_507_InsufficientStorage);
1004
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1002
diff changeset
740
4988
8fba26292a9f Housekeeper plugin: finalizing + integration tests ok
Alain Mazy <am@osimis.io>
parents: 4984
diff changeset
741 default:
8fba26292a9f Housekeeper plugin: finalizing + integration tests ok
Alain Mazy <am@osimis.io>
parents: 4984
diff changeset
742 // This should never happen
8fba26292a9f Housekeeper plugin: finalizing + integration tests ok
Alain Mazy <am@osimis.io>
parents: 4984
diff changeset
743 break;
8fba26292a9f Housekeeper plugin: finalizing + integration tests ok
Alain Mazy <am@osimis.io>
parents: 4984
diff changeset
744 }
1004
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1002
diff changeset
745
4994
2f30aa99c2db cppcheck
Alain Mazy <am@osimis.io>
parents: 4988
diff changeset
746 // skip all signals if this is a reconstruction
4988
8fba26292a9f Housekeeper plugin: finalizing + integration tests ok
Alain Mazy <am@osimis.io>
parents: 4984
diff changeset
747 if (result.GetStatus() == StoreStatus_Success ||
8fba26292a9f Housekeeper plugin: finalizing + integration tests ok
Alain Mazy <am@osimis.io>
parents: 4984
diff changeset
748 result.GetStatus() == StoreStatus_AlreadyStored)
1066
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1065
diff changeset
749 {
4988
8fba26292a9f Housekeeper plugin: finalizing + integration tests ok
Alain Mazy <am@osimis.io>
parents: 4984
diff changeset
750 boost::shared_lock<boost::shared_mutex> lock(listenersMutex_);
8fba26292a9f Housekeeper plugin: finalizing + integration tests ok
Alain Mazy <am@osimis.io>
parents: 4984
diff changeset
751
8fba26292a9f Housekeeper plugin: finalizing + integration tests ok
Alain Mazy <am@osimis.io>
parents: 4984
diff changeset
752 for (ServerListeners::iterator it = listeners_.begin(); it != listeners_.end(); ++it)
1066
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1065
diff changeset
753 {
4988
8fba26292a9f Housekeeper plugin: finalizing + integration tests ok
Alain Mazy <am@osimis.io>
parents: 4984
diff changeset
754 try
8fba26292a9f Housekeeper plugin: finalizing + integration tests ok
Alain Mazy <am@osimis.io>
parents: 4984
diff changeset
755 {
8fba26292a9f Housekeeper plugin: finalizing + integration tests ok
Alain Mazy <am@osimis.io>
parents: 4984
diff changeset
756 it->GetListener().SignalStoredInstance(resultPublicId, dicom, simplifiedTags);
8fba26292a9f Housekeeper plugin: finalizing + integration tests ok
Alain Mazy <am@osimis.io>
parents: 4984
diff changeset
757 }
8fba26292a9f Housekeeper plugin: finalizing + integration tests ok
Alain Mazy <am@osimis.io>
parents: 4984
diff changeset
758 catch (OrthancException& e)
8fba26292a9f Housekeeper plugin: finalizing + integration tests ok
Alain Mazy <am@osimis.io>
parents: 4984
diff changeset
759 {
8fba26292a9f Housekeeper plugin: finalizing + integration tests ok
Alain Mazy <am@osimis.io>
parents: 4984
diff changeset
760 LOG(ERROR) << "Error in the " << it->GetDescription()
8fba26292a9f Housekeeper plugin: finalizing + integration tests ok
Alain Mazy <am@osimis.io>
parents: 4984
diff changeset
761 << " callback while receiving an instance: " << e.What()
8fba26292a9f Housekeeper plugin: finalizing + integration tests ok
Alain Mazy <am@osimis.io>
parents: 4984
diff changeset
762 << " (code " << e.GetErrorCode() << ")";
8fba26292a9f Housekeeper plugin: finalizing + integration tests ok
Alain Mazy <am@osimis.io>
parents: 4984
diff changeset
763 }
1066
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1065
diff changeset
764 }
bb82e5e818e9 OnStoredInstance callback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1065
diff changeset
765 }
1004
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1002
diff changeset
766 }
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1002
diff changeset
767
4796
94616af363ec added ReceivedCStoreInstanceFilter lua callback + OrthancPluginRegisterIncomingCStoreInstanceFilter in sdk
Alain Mazy <am@osimis.io>
parents: 4789
diff changeset
768 return result;
1004
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1002
diff changeset
769 }
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1002
diff changeset
770 catch (OrthancException& e)
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1002
diff changeset
771 {
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1002
diff changeset
772 if (e.GetErrorCode() == ErrorCode_InexistentTag)
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1002
diff changeset
773 {
4505
97d103b57cd1 removed cached dicom summary from DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4504
diff changeset
774 summary.LogMissingTagsForStore();
1004
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1002
diff changeset
775 }
4505
97d103b57cd1 removed cached dicom summary from DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4504
diff changeset
776
1004
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1002
diff changeset
777 throw;
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1002
diff changeset
778 }
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1002
diff changeset
779 }
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1002
diff changeset
780
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1002
diff changeset
781
4796
94616af363ec added ReceivedCStoreInstanceFilter lua callback + OrthancPluginRegisterIncomingCStoreInstanceFilter in sdk
Alain Mazy <am@osimis.io>
parents: 4789
diff changeset
782 ServerContext::StoreResult ServerContext::Store(std::string& resultPublicId,
4845
02d77189d8ba added ReceivedInstanceCallback + sample C++ plugin
Alain Mazy <am@osimis.io>
parents: 4831
diff changeset
783 DicomInstanceToStore& receivedDicom,
4796
94616af363ec added ReceivedCStoreInstanceFilter lua callback + OrthancPluginRegisterIncomingCStoreInstanceFilter in sdk
Alain Mazy <am@osimis.io>
parents: 4789
diff changeset
784 StoreInstanceMode mode)
4845
02d77189d8ba added ReceivedInstanceCallback + sample C++ plugin
Alain Mazy <am@osimis.io>
parents: 4831
diff changeset
785 {
02d77189d8ba added ReceivedInstanceCallback + sample C++ plugin
Alain Mazy <am@osimis.io>
parents: 4831
diff changeset
786 DicomInstanceToStore* dicom = &receivedDicom;
4913
c1b19f95e166 fix signature of OrthancPluginReceivedInstanceCallback for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4900
diff changeset
787
c1b19f95e166 fix signature of OrthancPluginReceivedInstanceCallback for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4900
diff changeset
788 // WARNING: The scope of "modifiedBuffer" and "modifiedDicom" must
c1b19f95e166 fix signature of OrthancPluginReceivedInstanceCallback for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4900
diff changeset
789 // be the same as that of "dicom"
c1b19f95e166 fix signature of OrthancPluginReceivedInstanceCallback for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4900
diff changeset
790 MallocMemoryBuffer modifiedBuffer;
4845
02d77189d8ba added ReceivedInstanceCallback + sample C++ plugin
Alain Mazy <am@osimis.io>
parents: 4831
diff changeset
791 std::unique_ptr<DicomInstanceToStore> modifiedDicom;
02d77189d8ba added ReceivedInstanceCallback + sample C++ plugin
Alain Mazy <am@osimis.io>
parents: 4831
diff changeset
792
02d77189d8ba added ReceivedInstanceCallback + sample C++ plugin
Alain Mazy <am@osimis.io>
parents: 4831
diff changeset
793 #if ORTHANC_ENABLE_PLUGINS == 1
02d77189d8ba added ReceivedInstanceCallback + sample C++ plugin
Alain Mazy <am@osimis.io>
parents: 4831
diff changeset
794 if (HasPlugins())
02d77189d8ba added ReceivedInstanceCallback + sample C++ plugin
Alain Mazy <am@osimis.io>
parents: 4831
diff changeset
795 {
4913
c1b19f95e166 fix signature of OrthancPluginReceivedInstanceCallback for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4900
diff changeset
796 // New in Orthanc 1.10.0
4845
02d77189d8ba added ReceivedInstanceCallback + sample C++ plugin
Alain Mazy <am@osimis.io>
parents: 4831
diff changeset
797
4919
676e03e69703 added origin in OrthancPluginReceivedInstanceCallback
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4913
diff changeset
798 OrthancPluginReceivedInstanceAction action = GetPlugins().ApplyReceivedInstanceCallbacks(
676e03e69703 added origin in OrthancPluginReceivedInstanceCallback
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4913
diff changeset
799 modifiedBuffer, receivedDicom.GetBufferData(), receivedDicom.GetBufferSize(), receivedDicom.GetOrigin().GetRequestOrigin());
4845
02d77189d8ba added ReceivedInstanceCallback + sample C++ plugin
Alain Mazy <am@osimis.io>
parents: 4831
diff changeset
800
4913
c1b19f95e166 fix signature of OrthancPluginReceivedInstanceCallback for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4900
diff changeset
801 switch (action)
4845
02d77189d8ba added ReceivedInstanceCallback + sample C++ plugin
Alain Mazy <am@osimis.io>
parents: 4831
diff changeset
802 {
4919
676e03e69703 added origin in OrthancPluginReceivedInstanceCallback
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4913
diff changeset
803 case OrthancPluginReceivedInstanceAction_Discard:
4913
c1b19f95e166 fix signature of OrthancPluginReceivedInstanceCallback for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4900
diff changeset
804 {
c1b19f95e166 fix signature of OrthancPluginReceivedInstanceCallback for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4900
diff changeset
805 CLOG(INFO, PLUGINS) << "A plugin has discarded the instance in its ReceivedInstanceCallback";
c1b19f95e166 fix signature of OrthancPluginReceivedInstanceCallback for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4900
diff changeset
806 StoreResult result;
c1b19f95e166 fix signature of OrthancPluginReceivedInstanceCallback for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4900
diff changeset
807 result.SetStatus(StoreStatus_FilteredOut);
c1b19f95e166 fix signature of OrthancPluginReceivedInstanceCallback for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4900
diff changeset
808 return result;
c1b19f95e166 fix signature of OrthancPluginReceivedInstanceCallback for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4900
diff changeset
809 }
c1b19f95e166 fix signature of OrthancPluginReceivedInstanceCallback for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4900
diff changeset
810
4919
676e03e69703 added origin in OrthancPluginReceivedInstanceCallback
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4913
diff changeset
811 case OrthancPluginReceivedInstanceAction_KeepAsIs:
676e03e69703 added origin in OrthancPluginReceivedInstanceCallback
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4913
diff changeset
812 // This path is also used when no ReceivedInstanceCallback is installed by the plugins
4913
c1b19f95e166 fix signature of OrthancPluginReceivedInstanceCallback for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4900
diff changeset
813 break;
4845
02d77189d8ba added ReceivedInstanceCallback + sample C++ plugin
Alain Mazy <am@osimis.io>
parents: 4831
diff changeset
814
4919
676e03e69703 added origin in OrthancPluginReceivedInstanceCallback
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4913
diff changeset
815 case OrthancPluginReceivedInstanceAction_Modify:
4913
c1b19f95e166 fix signature of OrthancPluginReceivedInstanceCallback for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4900
diff changeset
816 if (modifiedBuffer.GetSize() > 0 &&
c1b19f95e166 fix signature of OrthancPluginReceivedInstanceCallback for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4900
diff changeset
817 modifiedBuffer.GetData() != NULL)
c1b19f95e166 fix signature of OrthancPluginReceivedInstanceCallback for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4900
diff changeset
818 {
c1b19f95e166 fix signature of OrthancPluginReceivedInstanceCallback for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4900
diff changeset
819 CLOG(INFO, PLUGINS) << "A plugin has modified the instance in its ReceivedInstanceCallback";
c1b19f95e166 fix signature of OrthancPluginReceivedInstanceCallback for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4900
diff changeset
820 modifiedDicom.reset(DicomInstanceToStore::CreateFromBuffer(modifiedBuffer.GetData(), modifiedBuffer.GetSize()));
4919
676e03e69703 added origin in OrthancPluginReceivedInstanceCallback
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4913
diff changeset
821 modifiedDicom->SetOrigin(receivedDicom.GetOrigin());
4913
c1b19f95e166 fix signature of OrthancPluginReceivedInstanceCallback for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4900
diff changeset
822 dicom = modifiedDicom.get();
c1b19f95e166 fix signature of OrthancPluginReceivedInstanceCallback for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4900
diff changeset
823 }
c1b19f95e166 fix signature of OrthancPluginReceivedInstanceCallback for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4900
diff changeset
824 else
c1b19f95e166 fix signature of OrthancPluginReceivedInstanceCallback for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4900
diff changeset
825 {
c1b19f95e166 fix signature of OrthancPluginReceivedInstanceCallback for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4900
diff changeset
826 throw OrthancException(ErrorCode_Plugin, "The ReceivedInstanceCallback plugin is not returning a modified buffer while it has modified the instance");
c1b19f95e166 fix signature of OrthancPluginReceivedInstanceCallback for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4900
diff changeset
827 }
c1b19f95e166 fix signature of OrthancPluginReceivedInstanceCallback for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4900
diff changeset
828 break;
c1b19f95e166 fix signature of OrthancPluginReceivedInstanceCallback for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4900
diff changeset
829
c1b19f95e166 fix signature of OrthancPluginReceivedInstanceCallback for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4900
diff changeset
830 default:
c1b19f95e166 fix signature of OrthancPluginReceivedInstanceCallback for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4900
diff changeset
831 throw OrthancException(ErrorCode_Plugin, "The ReceivedInstanceCallback has returned an invalid value");
4845
02d77189d8ba added ReceivedInstanceCallback + sample C++ plugin
Alain Mazy <am@osimis.io>
parents: 4831
diff changeset
832 }
02d77189d8ba added ReceivedInstanceCallback + sample C++ plugin
Alain Mazy <am@osimis.io>
parents: 4831
diff changeset
833 }
02d77189d8ba added ReceivedInstanceCallback + sample C++ plugin
Alain Mazy <am@osimis.io>
parents: 4831
diff changeset
834 #endif
02d77189d8ba added ReceivedInstanceCallback + sample C++ plugin
Alain Mazy <am@osimis.io>
parents: 4831
diff changeset
835
4988
8fba26292a9f Housekeeper plugin: finalizing + integration tests ok
Alain Mazy <am@osimis.io>
parents: 4984
diff changeset
836 return TranscodeAndStore(resultPublicId, dicom, mode);
8fba26292a9f Housekeeper plugin: finalizing + integration tests ok
Alain Mazy <am@osimis.io>
parents: 4984
diff changeset
837 }
8fba26292a9f Housekeeper plugin: finalizing + integration tests ok
Alain Mazy <am@osimis.io>
parents: 4984
diff changeset
838
8fba26292a9f Housekeeper plugin: finalizing + integration tests ok
Alain Mazy <am@osimis.io>
parents: 4984
diff changeset
839 ServerContext::StoreResult ServerContext::TranscodeAndStore(std::string& resultPublicId,
8fba26292a9f Housekeeper plugin: finalizing + integration tests ok
Alain Mazy <am@osimis.io>
parents: 4984
diff changeset
840 DicomInstanceToStore* dicom,
8fba26292a9f Housekeeper plugin: finalizing + integration tests ok
Alain Mazy <am@osimis.io>
parents: 4984
diff changeset
841 StoreInstanceMode mode,
8fba26292a9f Housekeeper plugin: finalizing + integration tests ok
Alain Mazy <am@osimis.io>
parents: 4984
diff changeset
842 bool isReconstruct)
8fba26292a9f Housekeeper plugin: finalizing + integration tests ok
Alain Mazy <am@osimis.io>
parents: 4984
diff changeset
843 {
8fba26292a9f Housekeeper plugin: finalizing + integration tests ok
Alain Mazy <am@osimis.io>
parents: 4984
diff changeset
844
5148
2df546a76e17 If specifying 'Transcode' option to /modify or /anonymize, this value will take over the 'IngestTranscoding' global configuration
Alain Mazy <am@osimis.io>
parents: 5147
diff changeset
845 if (!isIngestTranscoding_ || dicom->SkipIngestTranscoding())
3912
7610af1532c3 prototyping automated transcoding of incoming DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3911
diff changeset
846 {
3941
771dbd9eb3bd class CleaningInstancesJob to share cleaning code by merge/split jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3939
diff changeset
847 // No automated transcoding. This was the only path in Orthanc <= 1.6.1.
4988
8fba26292a9f Housekeeper plugin: finalizing + integration tests ok
Alain Mazy <am@osimis.io>
parents: 4984
diff changeset
848 return StoreAfterTranscoding(resultPublicId, *dicom, mode, isReconstruct);
3912
7610af1532c3 prototyping automated transcoding of incoming DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3911
diff changeset
849 }
7610af1532c3 prototyping automated transcoding of incoming DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3911
diff changeset
850 else
7610af1532c3 prototyping automated transcoding of incoming DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3911
diff changeset
851 {
4384
7e0d015ad109 new configuration options IngestTranscodingOfUncompressed and IngestTranscodingOfCompressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4376
diff changeset
852 // Automated transcoding of incoming DICOM instance
7e0d015ad109 new configuration options IngestTranscodingOfUncompressed and IngestTranscodingOfCompressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4376
diff changeset
853
7e0d015ad109 new configuration options IngestTranscodingOfUncompressed and IngestTranscodingOfCompressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4376
diff changeset
854 bool transcode = false;
3945
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
855
3912
7610af1532c3 prototyping automated transcoding of incoming DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3911
diff changeset
856 DicomTransferSyntax sourceSyntax;
4845
02d77189d8ba added ReceivedInstanceCallback + sample C++ plugin
Alain Mazy <am@osimis.io>
parents: 4831
diff changeset
857 if (!dicom->LookupTransferSyntax(sourceSyntax) ||
3939
c205f670098e new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3938
diff changeset
858 sourceSyntax == ingestTransferSyntax_)
3912
7610af1532c3 prototyping automated transcoding of incoming DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3911
diff changeset
859 {
4384
7e0d015ad109 new configuration options IngestTranscodingOfUncompressed and IngestTranscodingOfCompressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4376
diff changeset
860 // Don't transcode if the incoming DICOM is already in the proper transfer syntax
7e0d015ad109 new configuration options IngestTranscodingOfUncompressed and IngestTranscodingOfCompressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4376
diff changeset
861 transcode = false;
7e0d015ad109 new configuration options IngestTranscodingOfUncompressed and IngestTranscodingOfCompressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4376
diff changeset
862 }
7e0d015ad109 new configuration options IngestTranscodingOfUncompressed and IngestTranscodingOfCompressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4376
diff changeset
863 else if (!IsTranscodableTransferSyntax(sourceSyntax))
7e0d015ad109 new configuration options IngestTranscodingOfUncompressed and IngestTranscodingOfCompressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4376
diff changeset
864 {
7e0d015ad109 new configuration options IngestTranscodingOfUncompressed and IngestTranscodingOfCompressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4376
diff changeset
865 // Don't try to transcode video files, this is useless (new in
7e0d015ad109 new configuration options IngestTranscodingOfUncompressed and IngestTranscodingOfCompressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4376
diff changeset
866 // Orthanc 1.8.2). This could be accepted in the future if
7e0d015ad109 new configuration options IngestTranscodingOfUncompressed and IngestTranscodingOfCompressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4376
diff changeset
867 // video transcoding gets implemented.
7e0d015ad109 new configuration options IngestTranscodingOfUncompressed and IngestTranscodingOfCompressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4376
diff changeset
868 transcode = false;
7e0d015ad109 new configuration options IngestTranscodingOfUncompressed and IngestTranscodingOfCompressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4376
diff changeset
869 }
7e0d015ad109 new configuration options IngestTranscodingOfUncompressed and IngestTranscodingOfCompressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4376
diff changeset
870 else if (IsUncompressedTransferSyntax(sourceSyntax))
7e0d015ad109 new configuration options IngestTranscodingOfUncompressed and IngestTranscodingOfCompressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4376
diff changeset
871 {
7e0d015ad109 new configuration options IngestTranscodingOfUncompressed and IngestTranscodingOfCompressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4376
diff changeset
872 // This is an uncompressed transfer syntax (new in Orthanc 1.8.2)
7e0d015ad109 new configuration options IngestTranscodingOfUncompressed and IngestTranscodingOfCompressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4376
diff changeset
873 transcode = ingestTranscodingOfUncompressed_;
7e0d015ad109 new configuration options IngestTranscodingOfUncompressed and IngestTranscodingOfCompressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4376
diff changeset
874 }
7e0d015ad109 new configuration options IngestTranscodingOfUncompressed and IngestTranscodingOfCompressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4376
diff changeset
875 else
7e0d015ad109 new configuration options IngestTranscodingOfUncompressed and IngestTranscodingOfCompressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4376
diff changeset
876 {
7e0d015ad109 new configuration options IngestTranscodingOfUncompressed and IngestTranscodingOfCompressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4376
diff changeset
877 // This is an compressed transfer syntax (new in Orthanc 1.8.2)
7e0d015ad109 new configuration options IngestTranscodingOfUncompressed and IngestTranscodingOfCompressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4376
diff changeset
878 transcode = ingestTranscodingOfCompressed_;
7e0d015ad109 new configuration options IngestTranscodingOfUncompressed and IngestTranscodingOfCompressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4376
diff changeset
879 }
7e0d015ad109 new configuration options IngestTranscodingOfUncompressed and IngestTranscodingOfCompressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4376
diff changeset
880
7e0d015ad109 new configuration options IngestTranscodingOfUncompressed and IngestTranscodingOfCompressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4376
diff changeset
881 if (!transcode)
7e0d015ad109 new configuration options IngestTranscodingOfUncompressed and IngestTranscodingOfCompressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4376
diff changeset
882 {
3912
7610af1532c3 prototyping automated transcoding of incoming DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3911
diff changeset
883 // No transcoding
4988
8fba26292a9f Housekeeper plugin: finalizing + integration tests ok
Alain Mazy <am@osimis.io>
parents: 4984
diff changeset
884 return StoreAfterTranscoding(resultPublicId, *dicom, mode, isReconstruct);
3912
7610af1532c3 prototyping automated transcoding of incoming DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3911
diff changeset
885 }
7610af1532c3 prototyping automated transcoding of incoming DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3911
diff changeset
886 else
4384
7e0d015ad109 new configuration options IngestTranscodingOfUncompressed and IngestTranscodingOfCompressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4376
diff changeset
887 {
7e0d015ad109 new configuration options IngestTranscodingOfUncompressed and IngestTranscodingOfCompressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4376
diff changeset
888 // Trancoding
3912
7610af1532c3 prototyping automated transcoding of incoming DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3911
diff changeset
889 std::set<DicomTransferSyntax> syntaxes;
3939
c205f670098e new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3938
diff changeset
890 syntaxes.insert(ingestTransferSyntax_);
4384
7e0d015ad109 new configuration options IngestTranscodingOfUncompressed and IngestTranscodingOfCompressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4376
diff changeset
891
3945
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
892 IDicomTranscoder::DicomImage source;
4845
02d77189d8ba added ReceivedInstanceCallback + sample C++ plugin
Alain Mazy <am@osimis.io>
parents: 4831
diff changeset
893 source.SetExternalBuffer(dicom->GetBufferData(), dicom->GetBufferSize());
4384
7e0d015ad109 new configuration options IngestTranscodingOfUncompressed and IngestTranscodingOfCompressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4376
diff changeset
894
3945
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
895 IDicomTranscoder::DicomImage transcoded;
3951
5fe8c6d3212e removed useless information "hasSopInstanceUidChanged"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3947
diff changeset
896 if (Transcode(transcoded, source, syntaxes, true /* allow new SOP instance UID */))
3912
7610af1532c3 prototyping automated transcoding of incoming DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3911
diff changeset
897 {
3945
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
898 std::unique_ptr<ParsedDicomFile> tmp(transcoded.ReleaseAsParsedDicomFile());
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
899
4508
8f9090b137f1 Optimization in C-STORE SCP by avoiding an unnecessary DICOM parsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4507
diff changeset
900 std::unique_ptr<DicomInstanceToStore> toStore(DicomInstanceToStore::CreateFromParsedDicomFile(*tmp));
4845
02d77189d8ba added ReceivedInstanceCallback + sample C++ plugin
Alain Mazy <am@osimis.io>
parents: 4831
diff changeset
901 toStore->SetOrigin(dicom->GetOrigin());
5147
19ccae2e0371 Fix issue #212 (Anonymization process transcodes data and loses resource link)
Alain Mazy <am@osimis.io>
parents: 5111
diff changeset
902 toStore->CopyMetadata(dicom->GetMetadata());
4988
8fba26292a9f Housekeeper plugin: finalizing + integration tests ok
Alain Mazy <am@osimis.io>
parents: 4984
diff changeset
903
8fba26292a9f Housekeeper plugin: finalizing + integration tests ok
Alain Mazy <am@osimis.io>
parents: 4984
diff changeset
904 StoreResult result = StoreAfterTranscoding(resultPublicId, *toStore, mode, isReconstruct);
3938
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3931
diff changeset
905 assert(resultPublicId == tmp->GetHasher().HashInstance());
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3931
diff changeset
906
4796
94616af363ec added ReceivedCStoreInstanceFilter lua callback + OrthancPluginRegisterIncomingCStoreInstanceFilter in sdk
Alain Mazy <am@osimis.io>
parents: 4789
diff changeset
907 return result;
3912
7610af1532c3 prototyping automated transcoding of incoming DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3911
diff changeset
908 }
3945
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
909 else
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
910 {
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
911 // Cannot transcode => store the original file
4988
8fba26292a9f Housekeeper plugin: finalizing + integration tests ok
Alain Mazy <am@osimis.io>
parents: 4984
diff changeset
912 return StoreAfterTranscoding(resultPublicId, *dicom, mode, isReconstruct);
3945
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3944
diff changeset
913 }
3912
7610af1532c3 prototyping automated transcoding of incoming DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3911
diff changeset
914 }
7610af1532c3 prototyping automated transcoding of incoming DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3911
diff changeset
915 }
7610af1532c3 prototyping automated transcoding of incoming DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3911
diff changeset
916 }
7610af1532c3 prototyping automated transcoding of incoming DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3911
diff changeset
917
7610af1532c3 prototyping automated transcoding of incoming DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3911
diff changeset
918
1146
200fcac0deb4 optimization for access to attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
919 void ServerContext::AnswerAttachment(RestApiOutput& output,
1700
f5ddbd9239dd New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1632
diff changeset
920 const std::string& resourceId,
1146
200fcac0deb4 optimization for access to attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1145
diff changeset
921 FileContentType content)
226
8a26a8e85edf refactoring to read files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 224
diff changeset
922 {
232
5368bbe813cf refactoring of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 227
diff changeset
923 FileInfo attachment;
4627
f7d5372b59b3 handling revisions of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4623
diff changeset
924 int64_t revision;
f7d5372b59b3 handling revisions of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4623
diff changeset
925 if (!index_.LookupAttachment(attachment, revision, resourceId, content))
232
5368bbe813cf refactoring of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 227
diff changeset
926 {
1700
f5ddbd9239dd New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1632
diff changeset
927 throw OrthancException(ErrorCode_UnknownResource);
236
6d9be2b470b4 compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 233
diff changeset
928 }
4627
f7d5372b59b3 handling revisions of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4623
diff changeset
929 else
f7d5372b59b3 handling revisions of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4623
diff changeset
930 {
5184
dd085f7e7e71 cleaning new constructors of StorageAccessor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5183
diff changeset
931 StorageAccessor accessor(area_, storageCache_, GetMetricsRegistry());
4627
f7d5372b59b3 handling revisions of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4623
diff changeset
932 accessor.AnswerFile(output, attachment, GetFileContentMime(content));
f7d5372b59b3 handling revisions of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4623
diff changeset
933 }
226
8a26a8e85edf refactoring to read files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 224
diff changeset
934 }
8a26a8e85edf refactoring to read files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 224
diff changeset
935
8a26a8e85edf refactoring to read files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 224
diff changeset
936
1700
f5ddbd9239dd New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1632
diff changeset
937 void ServerContext::ChangeAttachmentCompression(const std::string& resourceId,
f5ddbd9239dd New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1632
diff changeset
938 FileContentType attachmentType,
f5ddbd9239dd New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1632
diff changeset
939 CompressionType compression)
f5ddbd9239dd New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1632
diff changeset
940 {
f5ddbd9239dd New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1632
diff changeset
941 LOG(INFO) << "Changing compression type for attachment "
f5ddbd9239dd New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1632
diff changeset
942 << EnumerationToString(attachmentType)
f5ddbd9239dd New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1632
diff changeset
943 << " of resource " << resourceId << " to "
f5ddbd9239dd New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1632
diff changeset
944 << compression;
f5ddbd9239dd New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1632
diff changeset
945
f5ddbd9239dd New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1632
diff changeset
946 FileInfo attachment;
4627
f7d5372b59b3 handling revisions of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4623
diff changeset
947 int64_t revision;
f7d5372b59b3 handling revisions of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4623
diff changeset
948 if (!index_.LookupAttachment(attachment, revision, resourceId, attachmentType))
1700
f5ddbd9239dd New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1632
diff changeset
949 {
f5ddbd9239dd New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1632
diff changeset
950 throw OrthancException(ErrorCode_UnknownResource);
f5ddbd9239dd New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1632
diff changeset
951 }
f5ddbd9239dd New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1632
diff changeset
952
f5ddbd9239dd New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1632
diff changeset
953 if (attachment.GetCompressionType() == compression)
f5ddbd9239dd New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1632
diff changeset
954 {
f5ddbd9239dd New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1632
diff changeset
955 // Nothing to do
f5ddbd9239dd New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1632
diff changeset
956 return;
f5ddbd9239dd New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1632
diff changeset
957 }
f5ddbd9239dd New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1632
diff changeset
958
f5ddbd9239dd New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1632
diff changeset
959 std::string content;
f5ddbd9239dd New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1632
diff changeset
960
5184
dd085f7e7e71 cleaning new constructors of StorageAccessor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5183
diff changeset
961 StorageAccessor accessor(area_, storageCache_, GetMetricsRegistry());
1700
f5ddbd9239dd New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1632
diff changeset
962 accessor.Read(content, attachment);
f5ddbd9239dd New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1632
diff changeset
963
f5ddbd9239dd New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1632
diff changeset
964 FileInfo modified = accessor.Write(content.empty() ? NULL : content.c_str(),
f5ddbd9239dd New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1632
diff changeset
965 content.size(), attachmentType, compression, storeMD5_);
f5ddbd9239dd New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1632
diff changeset
966
f5ddbd9239dd New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1632
diff changeset
967 try
f5ddbd9239dd New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1632
diff changeset
968 {
4627
f7d5372b59b3 handling revisions of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4623
diff changeset
969 int64_t newRevision; // ignored
4640
66109d24d26e "ETag" headers for metadata and attachments now allow strong comparison (MD5 is included)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4629
diff changeset
970 StoreStatus status = index_.AddAttachment(newRevision, modified, resourceId,
66109d24d26e "ETag" headers for metadata and attachments now allow strong comparison (MD5 is included)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4629
diff changeset
971 true, revision, modified.GetUncompressedMD5());
1700
f5ddbd9239dd New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1632
diff changeset
972 if (status != StoreStatus_Success)
f5ddbd9239dd New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1632
diff changeset
973 {
f5ddbd9239dd New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1632
diff changeset
974 accessor.Remove(modified);
f5ddbd9239dd New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1632
diff changeset
975 throw OrthancException(ErrorCode_Database);
f5ddbd9239dd New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1632
diff changeset
976 }
f5ddbd9239dd New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1632
diff changeset
977 }
f5ddbd9239dd New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1632
diff changeset
978 catch (OrthancException&)
f5ddbd9239dd New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1632
diff changeset
979 {
f5ddbd9239dd New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1632
diff changeset
980 accessor.Remove(modified);
f5ddbd9239dd New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1632
diff changeset
981 throw;
f5ddbd9239dd New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1632
diff changeset
982 }
f5ddbd9239dd New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1632
diff changeset
983 }
f5ddbd9239dd New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1632
diff changeset
984
f5ddbd9239dd New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1632
diff changeset
985
4514
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
986 static void InjectEmptyPixelData(Json::Value& dicomAsJson)
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
987 {
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
988 // This is for backward compatibility with Orthanc <= 1.9.0
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
989 Json::Value pixelData = Json::objectValue;
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
990 pixelData["Name"] = "PixelData";
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
991 pixelData["Type"] = "Null";
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
992 pixelData["Value"] = Json::nullValue;
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
993
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
994 dicomAsJson["7fe0,0010"] = pixelData;
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
995 }
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
996
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
997
2124
2b1520efa282 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2122
diff changeset
998 void ServerContext::ReadDicomAsJson(Json::Value& result,
2409
e4045b3c9772 ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
999 const std::string& instancePublicId,
e4045b3c9772 ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
1000 const std::set<DicomTag>& ignoreTagLength)
226
8a26a8e85edf refactoring to read files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 224
diff changeset
1001 {
4514
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
1002 /**
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
1003 * CASE 1: The DICOM file, truncated at pixel data, is available
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
1004 * as an attachment (it was created either because the storage
4666
Alain Mazy <am@osimis.io>
parents: 4640
diff changeset
1005 * area does not support range reads, or if "StorageCompression"
4514
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
1006 * is enabled). Simply return this attachment.
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
1007 **/
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
1008
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
1009 FileInfo attachment;
4629
88e892e25a51 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4627
diff changeset
1010 int64_t revision; // Ignored
4514
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
1011
4627
f7d5372b59b3 handling revisions of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4623
diff changeset
1012 if (index_.LookupAttachment(attachment, revision, instancePublicId, FileContentType_DicomUntilPixelData))
2409
e4045b3c9772 ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
1013 {
4514
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
1014 std::string dicom;
4513
1f455b86b054 simplification in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4511
diff changeset
1015
1f455b86b054 simplification in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4511
diff changeset
1016 {
5184
dd085f7e7e71 cleaning new constructors of StorageAccessor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5183
diff changeset
1017 StorageAccessor accessor(area_, storageCache_, GetMetricsRegistry());
4514
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
1018 accessor.Read(dicom, attachment);
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
1019 }
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
1020
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
1021 ParsedDicomFile parsed(dicom);
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
1022 OrthancConfiguration::DefaultDicomDatasetToJson(result, parsed, ignoreTagLength);
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
1023 InjectEmptyPixelData(result);
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
1024 }
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
1025 else
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
1026 {
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
1027 /**
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
1028 * The truncated DICOM file is not stored as a standalone
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
1029 * attachment. Lookup whether the pixel data offset has already
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
1030 * been computed for this instance.
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
1031 **/
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
1032
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
1033 bool hasPixelDataOffset;
4519
a3c6678aa7b1 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4514
diff changeset
1034 uint64_t pixelDataOffset = 0; // dummy initialization
4514
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
1035
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
1036 {
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
1037 std::string s;
4623
95ffe3b6ef7c handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4607
diff changeset
1038 if (index_.LookupMetadata(s, revision, instancePublicId, ResourceType_Instance,
4514
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
1039 MetadataType_Instance_PixelDataOffset))
4513
1f455b86b054 simplification in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4511
diff changeset
1040 {
4514
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
1041 hasPixelDataOffset = false;
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
1042
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
1043 if (!s.empty())
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
1044 {
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
1045 try
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
1046 {
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
1047 pixelDataOffset = boost::lexical_cast<uint64_t>(s);
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
1048 hasPixelDataOffset = true;
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
1049 }
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
1050 catch (boost::bad_lexical_cast&)
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
1051 {
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
1052 }
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
1053 }
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
1054
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
1055 if (!hasPixelDataOffset)
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
1056 {
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
1057 LOG(ERROR) << "Metadata \"PixelDataOffset\" is corrupted for instance: " << instancePublicId;
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
1058 }
4513
1f455b86b054 simplification in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4511
diff changeset
1059 }
1f455b86b054 simplification in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4511
diff changeset
1060 else
1f455b86b054 simplification in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4511
diff changeset
1061 {
4514
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
1062 // This instance was created by a version of Orthanc <= 1.9.0
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
1063 hasPixelDataOffset = false;
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
1064 }
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
1065 }
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
1066
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
1067
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
1068 if (hasPixelDataOffset &&
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
1069 area_.HasReadRange() &&
4627
f7d5372b59b3 handling revisions of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4623
diff changeset
1070 index_.LookupAttachment(attachment, revision, instancePublicId, FileContentType_Dicom) &&
4514
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
1071 attachment.GetCompressionType() == CompressionType_None)
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
1072 {
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
1073 /**
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
1074 * CASE 2: The pixel data offset is known, AND that a range read
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
1075 * can be used to retrieve the truncated DICOM file. Note that
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
1076 * this case cannot be used if "StorageCompression" option is
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
1077 * "true".
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
1078 **/
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
1079
4900
ea5f1c6ed07e fix cache of storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4892
diff changeset
1080 std::string dicom;
ea5f1c6ed07e fix cache of storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4892
diff changeset
1081
4519
a3c6678aa7b1 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4514
diff changeset
1082 {
5184
dd085f7e7e71 cleaning new constructors of StorageAccessor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5183
diff changeset
1083 StorageAccessor accessor(area_, storageCache_, GetMetricsRegistry());
5420
d37dff2c0028 Optimized the MemoryStringCache to prevent loading the same file multiple times if multiple users request the same file at the same time
Alain Mazy <am@osimis.io>
parents: 5410
diff changeset
1084 accessor.ReadStartRange(dicom, attachment, pixelDataOffset);
4514
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
1085 }
4900
ea5f1c6ed07e fix cache of storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4892
diff changeset
1086
ea5f1c6ed07e fix cache of storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4892
diff changeset
1087 assert(dicom.size() == pixelDataOffset);
ea5f1c6ed07e fix cache of storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4892
diff changeset
1088 ParsedDicomFile parsed(dicom);
ea5f1c6ed07e fix cache of storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4892
diff changeset
1089 OrthancConfiguration::DefaultDicomDatasetToJson(result, parsed, ignoreTagLength);
ea5f1c6ed07e fix cache of storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4892
diff changeset
1090 InjectEmptyPixelData(result);
4514
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
1091 }
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
1092 else if (ignoreTagLength.empty() &&
4627
f7d5372b59b3 handling revisions of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4623
diff changeset
1093 index_.LookupAttachment(attachment, revision, instancePublicId, FileContentType_DicomAsJson))
4514
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
1094 {
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
1095 /**
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
1096 * CASE 3: This instance was created using Orthanc <=
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
1097 * 1.9.0. Reuse the old "DICOM-as-JSON" attachment if available.
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
1098 * This is for backward compatibility: A call to
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
1099 * "/tools/invalidate-tags" or to one flavors of
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
1100 * "/.../.../reconstruct" will disable this case.
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
1101 **/
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
1102
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
1103 std::string dicomAsJson;
4513
1f455b86b054 simplification in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4511
diff changeset
1104
4514
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
1105 {
5184
dd085f7e7e71 cleaning new constructors of StorageAccessor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5183
diff changeset
1106 StorageAccessor accessor(area_, storageCache_, GetMetricsRegistry());
4514
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
1107 accessor.Read(dicomAsJson, attachment);
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
1108 }
4513
1f455b86b054 simplification in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4511
diff changeset
1109
4514
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
1110 if (!Toolbox::ReadJson(result, dicomAsJson))
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
1111 {
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
1112 throw OrthancException(ErrorCode_CorruptedFile,
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
1113 "Corrupted DICOM-as-JSON attachment of instance: " + instancePublicId);
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
1114 }
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
1115 }
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
1116 else
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
1117 {
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
1118 /**
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
1119 * CASE 4: Neither the truncated DICOM file is accessible, nor
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
1120 * the DICOM-as-JSON summary. We have to retrieve the full DICOM
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
1121 * file from the storage area.
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
1122 **/
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
1123
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
1124 std::string dicom;
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
1125 ReadDicom(dicom, instancePublicId);
4513
1f455b86b054 simplification in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4511
diff changeset
1126
4514
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
1127 ParsedDicomFile parsed(dicom);
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
1128 OrthancConfiguration::DefaultDicomDatasetToJson(result, parsed, ignoreTagLength);
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
1129
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
1130 if (!hasPixelDataOffset)
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
1131 {
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
1132 /**
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
1133 * The pixel data offset was never computed for this
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
1134 * instance, which indicates that it was created using
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
1135 * Orthanc <= 1.9.0, or that calls to
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
1136 * "LookupPixelDataOffset()" from earlier versions of
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
1137 * Orthanc have failed. Try again this precomputation now
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
1138 * for future calls.
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
1139 **/
5316
03501a258d9e added instance metadata "PixelDataVR"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5296
diff changeset
1140 ValueRepresentation pixelDataVR;
03501a258d9e added instance metadata "PixelDataVR"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5296
diff changeset
1141 if (DicomStreamReader::LookupPixelDataOffset(pixelDataOffset, pixelDataVR, dicom) &&
4514
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
1142 pixelDataOffset < dicom.size())
4513
1f455b86b054 simplification in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4511
diff changeset
1143 {
4623
95ffe3b6ef7c handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4607
diff changeset
1144 index_.OverwriteMetadata(instancePublicId, MetadataType_Instance_PixelDataOffset,
95ffe3b6ef7c handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4607
diff changeset
1145 boost::lexical_cast<std::string>(pixelDataOffset));
4514
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
1146
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
1147 if (!area_.HasReadRange() ||
4519
a3c6678aa7b1 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4514
diff changeset
1148 compressionEnabled_)
4514
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
1149 {
4627
f7d5372b59b3 handling revisions of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4623
diff changeset
1150 int64_t newRevision;
f7d5372b59b3 handling revisions of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4623
diff changeset
1151 AddAttachment(newRevision, instancePublicId, FileContentType_DicomUntilPixelData,
f7d5372b59b3 handling revisions of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4623
diff changeset
1152 dicom.empty() ? NULL: dicom.c_str(), pixelDataOffset,
4640
66109d24d26e "ETag" headers for metadata and attachments now allow strong comparison (MD5 is included)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4629
diff changeset
1153 false /* no old revision */, -1 /* dummy revision */, "" /* dummy MD5 */);
4514
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4513
diff changeset
1154 }
4513
1f455b86b054 simplification in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4511
diff changeset
1155 }
1f455b86b054 simplification in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4511
diff changeset
1156 }
1f455b86b054 simplification in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4511
diff changeset
1157 }
226
8a26a8e85edf refactoring to read files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 224
diff changeset
1158 }
8a26a8e85edf refactoring to read files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 224
diff changeset
1159 }
227
209ca3f6db62 dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 226
diff changeset
1160
209ca3f6db62 dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 226
diff changeset
1161
4511
1ec156a0da38 ServerContext::ReadDicomUntilPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4509
diff changeset
1162 void ServerContext::ReadDicomAsJson(Json::Value& result,
1ec156a0da38 ServerContext::ReadDicomUntilPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4509
diff changeset
1163 const std::string& instancePublicId)
1ec156a0da38 ServerContext::ReadDicomUntilPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4509
diff changeset
1164 {
1ec156a0da38 ServerContext::ReadDicomUntilPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4509
diff changeset
1165 std::set<DicomTag> ignoreTagLength;
1ec156a0da38 ServerContext::ReadDicomUntilPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4509
diff changeset
1166 ReadDicomAsJson(result, instancePublicId, ignoreTagLength);
1ec156a0da38 ServerContext::ReadDicomUntilPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4509
diff changeset
1167 }
1ec156a0da38 ServerContext::ReadDicomUntilPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4509
diff changeset
1168
1ec156a0da38 ServerContext::ReadDicomUntilPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4509
diff changeset
1169
4509
98b7b9d21d83 removed ServerContext::ReadAttachment()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
1170 void ServerContext::ReadDicom(std::string& dicom,
5427
111e21b4f8bc fix transcoded instance caching
Alain Mazy <am@osimis.io>
parents: 5426
diff changeset
1171 std::string& attachmentId,
4509
98b7b9d21d83 removed ServerContext::ReadAttachment()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
1172 const std::string& instancePublicId)
98b7b9d21d83 removed ServerContext::ReadAttachment()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
1173 {
4627
f7d5372b59b3 handling revisions of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4623
diff changeset
1174 int64_t revision;
5427
111e21b4f8bc fix transcoded instance caching
Alain Mazy <am@osimis.io>
parents: 5426
diff changeset
1175 ReadAttachment(dicom, revision, attachmentId, instancePublicId, FileContentType_Dicom, true /* uncompress */);
111e21b4f8bc fix transcoded instance caching
Alain Mazy <am@osimis.io>
parents: 5426
diff changeset
1176 }
111e21b4f8bc fix transcoded instance caching
Alain Mazy <am@osimis.io>
parents: 5426
diff changeset
1177
111e21b4f8bc fix transcoded instance caching
Alain Mazy <am@osimis.io>
parents: 5426
diff changeset
1178
111e21b4f8bc fix transcoded instance caching
Alain Mazy <am@osimis.io>
parents: 5426
diff changeset
1179 void ServerContext::ReadDicom(std::string& dicom,
111e21b4f8bc fix transcoded instance caching
Alain Mazy <am@osimis.io>
parents: 5426
diff changeset
1180 const std::string& instancePublicId)
111e21b4f8bc fix transcoded instance caching
Alain Mazy <am@osimis.io>
parents: 5426
diff changeset
1181 {
111e21b4f8bc fix transcoded instance caching
Alain Mazy <am@osimis.io>
parents: 5426
diff changeset
1182 std::string attachmentId;
111e21b4f8bc fix transcoded instance caching
Alain Mazy <am@osimis.io>
parents: 5426
diff changeset
1183 ReadDicom(dicom, attachmentId, instancePublicId);
4509
98b7b9d21d83 removed ServerContext::ReadAttachment()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
1184 }
4792
434843934307 Added a StorageCache in the StorageAccessor
Alain Mazy <am@osimis.io>
parents: 4789
diff changeset
1185
434843934307 Added a StorageCache in the StorageAccessor
Alain Mazy <am@osimis.io>
parents: 4789
diff changeset
1186 void ServerContext::ReadDicomForHeader(std::string& dicom,
434843934307 Added a StorageCache in the StorageAccessor
Alain Mazy <am@osimis.io>
parents: 4789
diff changeset
1187 const std::string& instancePublicId)
434843934307 Added a StorageCache in the StorageAccessor
Alain Mazy <am@osimis.io>
parents: 4789
diff changeset
1188 {
434843934307 Added a StorageCache in the StorageAccessor
Alain Mazy <am@osimis.io>
parents: 4789
diff changeset
1189 if (!ReadDicomUntilPixelData(dicom, instancePublicId))
434843934307 Added a StorageCache in the StorageAccessor
Alain Mazy <am@osimis.io>
parents: 4789
diff changeset
1190 {
434843934307 Added a StorageCache in the StorageAccessor
Alain Mazy <am@osimis.io>
parents: 4789
diff changeset
1191 ReadDicom(dicom, instancePublicId);
434843934307 Added a StorageCache in the StorageAccessor
Alain Mazy <am@osimis.io>
parents: 4789
diff changeset
1192 }
434843934307 Added a StorageCache in the StorageAccessor
Alain Mazy <am@osimis.io>
parents: 4789
diff changeset
1193 }
4509
98b7b9d21d83 removed ServerContext::ReadAttachment()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
1194
4511
1ec156a0da38 ServerContext::ReadDicomUntilPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4509
diff changeset
1195 bool ServerContext::ReadDicomUntilPixelData(std::string& dicom,
1ec156a0da38 ServerContext::ReadDicomUntilPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4509
diff changeset
1196 const std::string& instancePublicId)
1ec156a0da38 ServerContext::ReadDicomUntilPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4509
diff changeset
1197 {
5333
816968b5a031 speeded up ServerContext::ReadDicomUntilPixelData() if storage compression is on
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5330
diff changeset
1198 FileInfo attachment;
816968b5a031 speeded up ServerContext::ReadDicomUntilPixelData() if storage compression is on
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5330
diff changeset
1199 int64_t revision; // Ignored
816968b5a031 speeded up ServerContext::ReadDicomUntilPixelData() if storage compression is on
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5330
diff changeset
1200 if (index_.LookupAttachment(attachment, revision, instancePublicId, FileContentType_DicomUntilPixelData))
816968b5a031 speeded up ServerContext::ReadDicomUntilPixelData() if storage compression is on
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5330
diff changeset
1201 {
816968b5a031 speeded up ServerContext::ReadDicomUntilPixelData() if storage compression is on
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5330
diff changeset
1202 StorageAccessor accessor(area_, storageCache_, GetMetricsRegistry());
816968b5a031 speeded up ServerContext::ReadDicomUntilPixelData() if storage compression is on
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5330
diff changeset
1203
816968b5a031 speeded up ServerContext::ReadDicomUntilPixelData() if storage compression is on
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5330
diff changeset
1204 accessor.Read(dicom, attachment);
816968b5a031 speeded up ServerContext::ReadDicomUntilPixelData() if storage compression is on
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5330
diff changeset
1205 assert(dicom.size() == attachment.GetUncompressedSize());
816968b5a031 speeded up ServerContext::ReadDicomUntilPixelData() if storage compression is on
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5330
diff changeset
1206
816968b5a031 speeded up ServerContext::ReadDicomUntilPixelData() if storage compression is on
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5330
diff changeset
1207 return true;
816968b5a031 speeded up ServerContext::ReadDicomUntilPixelData() if storage compression is on
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5330
diff changeset
1208 }
816968b5a031 speeded up ServerContext::ReadDicomUntilPixelData() if storage compression is on
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5330
diff changeset
1209
4511
1ec156a0da38 ServerContext::ReadDicomUntilPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4509
diff changeset
1210 if (!area_.HasReadRange())
1ec156a0da38 ServerContext::ReadDicomUntilPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4509
diff changeset
1211 {
1ec156a0da38 ServerContext::ReadDicomUntilPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4509
diff changeset
1212 return false;
1ec156a0da38 ServerContext::ReadDicomUntilPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4509
diff changeset
1213 }
1ec156a0da38 ServerContext::ReadDicomUntilPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4509
diff changeset
1214
4627
f7d5372b59b3 handling revisions of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4623
diff changeset
1215 if (!index_.LookupAttachment(attachment, revision, instancePublicId, FileContentType_Dicom))
4511
1ec156a0da38 ServerContext::ReadDicomUntilPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4509
diff changeset
1216 {
1ec156a0da38 ServerContext::ReadDicomUntilPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4509
diff changeset
1217 throw OrthancException(ErrorCode_InternalError,
1ec156a0da38 ServerContext::ReadDicomUntilPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4509
diff changeset
1218 "Unable to read the DICOM file of instance " + instancePublicId);
1ec156a0da38 ServerContext::ReadDicomUntilPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4509
diff changeset
1219 }
1ec156a0da38 ServerContext::ReadDicomUntilPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4509
diff changeset
1220
1ec156a0da38 ServerContext::ReadDicomUntilPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4509
diff changeset
1221 std::string s;
1ec156a0da38 ServerContext::ReadDicomUntilPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4509
diff changeset
1222
1ec156a0da38 ServerContext::ReadDicomUntilPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4509
diff changeset
1223 if (attachment.GetCompressionType() == CompressionType_None &&
4623
95ffe3b6ef7c handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4607
diff changeset
1224 index_.LookupMetadata(s, revision, instancePublicId, ResourceType_Instance,
4511
1ec156a0da38 ServerContext::ReadDicomUntilPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4509
diff changeset
1225 MetadataType_Instance_PixelDataOffset) &&
1ec156a0da38 ServerContext::ReadDicomUntilPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4509
diff changeset
1226 !s.empty())
1ec156a0da38 ServerContext::ReadDicomUntilPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4509
diff changeset
1227 {
1ec156a0da38 ServerContext::ReadDicomUntilPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4509
diff changeset
1228 try
1ec156a0da38 ServerContext::ReadDicomUntilPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4509
diff changeset
1229 {
1ec156a0da38 ServerContext::ReadDicomUntilPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4509
diff changeset
1230 uint64_t pixelDataOffset = boost::lexical_cast<uint64_t>(s);
1ec156a0da38 ServerContext::ReadDicomUntilPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4509
diff changeset
1231
5184
dd085f7e7e71 cleaning new constructors of StorageAccessor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5183
diff changeset
1232 StorageAccessor accessor(area_, storageCache_, GetMetricsRegistry());
4792
434843934307 Added a StorageCache in the StorageAccessor
Alain Mazy <am@osimis.io>
parents: 4789
diff changeset
1233
5420
d37dff2c0028 Optimized the MemoryStringCache to prevent loading the same file multiple times if multiple users request the same file at the same time
Alain Mazy <am@osimis.io>
parents: 5410
diff changeset
1234 accessor.ReadStartRange(dicom, attachment, pixelDataOffset);
4900
ea5f1c6ed07e fix cache of storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4892
diff changeset
1235 assert(dicom.size() == pixelDataOffset);
ea5f1c6ed07e fix cache of storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4892
diff changeset
1236
4511
1ec156a0da38 ServerContext::ReadDicomUntilPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4509
diff changeset
1237 return true; // Success
1ec156a0da38 ServerContext::ReadDicomUntilPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4509
diff changeset
1238 }
1ec156a0da38 ServerContext::ReadDicomUntilPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4509
diff changeset
1239 catch (boost::bad_lexical_cast&)
1ec156a0da38 ServerContext::ReadDicomUntilPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4509
diff changeset
1240 {
1ec156a0da38 ServerContext::ReadDicomUntilPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4509
diff changeset
1241 LOG(ERROR) << "Metadata \"PixelDataOffset\" is corrupted for instance: " << instancePublicId;
1ec156a0da38 ServerContext::ReadDicomUntilPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4509
diff changeset
1242 }
1ec156a0da38 ServerContext::ReadDicomUntilPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4509
diff changeset
1243 }
1ec156a0da38 ServerContext::ReadDicomUntilPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4509
diff changeset
1244
1ec156a0da38 ServerContext::ReadDicomUntilPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4509
diff changeset
1245 return false;
1ec156a0da38 ServerContext::ReadDicomUntilPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4509
diff changeset
1246 }
1ec156a0da38 ServerContext::ReadDicomUntilPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4509
diff changeset
1247
1ec156a0da38 ServerContext::ReadDicomUntilPixelData()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4509
diff changeset
1248
2128
9329ba17a069 Possibility to DELETE "dicom-as-json" attachments to reconstruct them
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2127
diff changeset
1249 void ServerContext::ReadAttachment(std::string& result,
4627
f7d5372b59b3 handling revisions of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4623
diff changeset
1250 int64_t& revision,
5427
111e21b4f8bc fix transcoded instance caching
Alain Mazy <am@osimis.io>
parents: 5426
diff changeset
1251 std::string& attachmentId,
2128
9329ba17a069 Possibility to DELETE "dicom-as-json" attachments to reconstruct them
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2127
diff changeset
1252 const std::string& instancePublicId,
9329ba17a069 Possibility to DELETE "dicom-as-json" attachments to reconstruct them
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2127
diff changeset
1253 FileContentType content,
5048
22966345eaba skip StorageCache when verifying md5 or when re-compressing attachments
Alain Mazy <am@osimis.io>
parents: 5044
diff changeset
1254 bool uncompressIfNeeded,
22966345eaba skip StorageCache when verifying md5 or when re-compressing attachments
Alain Mazy <am@osimis.io>
parents: 5044
diff changeset
1255 bool skipCache)
227
209ca3f6db62 dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 226
diff changeset
1256 {
232
5368bbe813cf refactoring of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 227
diff changeset
1257 FileInfo attachment;
4627
f7d5372b59b3 handling revisions of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4623
diff changeset
1258 if (!index_.LookupAttachment(attachment, revision, instancePublicId, content))
227
209ca3f6db62 dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 226
diff changeset
1259 {
2956
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2950
diff changeset
1260 throw OrthancException(ErrorCode_InternalError,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2950
diff changeset
1261 "Unable to read attachment " + EnumerationToString(content) +
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2950
diff changeset
1262 " of instance " + instancePublicId);
227
209ca3f6db62 dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 226
diff changeset
1263 }
1550
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1549
diff changeset
1264
3175
574890d14c92 new metrics: orthanc_store_dicom_duration_ms, orthanc_storage_[create|read|remove]_duration_ms
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3174
diff changeset
1265 assert(attachment.GetContentType() == content);
5427
111e21b4f8bc fix transcoded instance caching
Alain Mazy <am@osimis.io>
parents: 5426
diff changeset
1266 attachmentId = attachment.GetUuid();
111e21b4f8bc fix transcoded instance caching
Alain Mazy <am@osimis.io>
parents: 5426
diff changeset
1267
1550
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1549
diff changeset
1268 {
5184
dd085f7e7e71 cleaning new constructors of StorageAccessor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5183
diff changeset
1269 std::unique_ptr<StorageAccessor> accessor;
dd085f7e7e71 cleaning new constructors of StorageAccessor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5183
diff changeset
1270
dd085f7e7e71 cleaning new constructors of StorageAccessor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5183
diff changeset
1271 if (skipCache)
5048
22966345eaba skip StorageCache when verifying md5 or when re-compressing attachments
Alain Mazy <am@osimis.io>
parents: 5044
diff changeset
1272 {
5184
dd085f7e7e71 cleaning new constructors of StorageAccessor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5183
diff changeset
1273 accessor.reset(new StorageAccessor(area_, GetMetricsRegistry()));
5048
22966345eaba skip StorageCache when verifying md5 or when re-compressing attachments
Alain Mazy <am@osimis.io>
parents: 5044
diff changeset
1274 }
5184
dd085f7e7e71 cleaning new constructors of StorageAccessor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5183
diff changeset
1275 else
dd085f7e7e71 cleaning new constructors of StorageAccessor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5183
diff changeset
1276 {
dd085f7e7e71 cleaning new constructors of StorageAccessor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5183
diff changeset
1277 accessor.reset(new StorageAccessor(area_, storageCache_, GetMetricsRegistry()));
dd085f7e7e71 cleaning new constructors of StorageAccessor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5183
diff changeset
1278 }
4509
98b7b9d21d83 removed ServerContext::ReadAttachment()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
1279
98b7b9d21d83 removed ServerContext::ReadAttachment()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
1280 if (uncompressIfNeeded)
98b7b9d21d83 removed ServerContext::ReadAttachment()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
1281 {
5184
dd085f7e7e71 cleaning new constructors of StorageAccessor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5183
diff changeset
1282 accessor->Read(result, attachment);
4509
98b7b9d21d83 removed ServerContext::ReadAttachment()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
1283 }
98b7b9d21d83 removed ServerContext::ReadAttachment()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
1284 else
98b7b9d21d83 removed ServerContext::ReadAttachment()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
1285 {
98b7b9d21d83 removed ServerContext::ReadAttachment()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
1286 // Do not uncompress the content of the storage area, return the
98b7b9d21d83 removed ServerContext::ReadAttachment()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
1287 // raw data
5184
dd085f7e7e71 cleaning new constructors of StorageAccessor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5183
diff changeset
1288 accessor->ReadRaw(result, attachment);
4509
98b7b9d21d83 removed ServerContext::ReadAttachment()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
1289 }
1550
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1549
diff changeset
1290 }
227
209ca3f6db62 dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 226
diff changeset
1291 }
285
4031f73fe0e4 access to the raw dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 269
diff changeset
1292
4031f73fe0e4 access to the raw dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 269
diff changeset
1293
4457
789676a8c96a Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1294 ServerContext::DicomCacheLocker::DicomCacheLocker(ServerContext& context,
789676a8c96a Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1295 const std::string& instancePublicId) :
789676a8c96a Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1296 context_(context),
789676a8c96a Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1297 instancePublicId_(instancePublicId)
285
4031f73fe0e4 access to the raw dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 269
diff changeset
1298 {
4457
789676a8c96a Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1299 accessor_.reset(new ParsedDicomCache::Accessor(context_.dicomCache_, instancePublicId));
789676a8c96a Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1300
789676a8c96a Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1301 if (!accessor_->IsValid())
789676a8c96a Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1302 {
789676a8c96a Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1303 accessor_.reset(NULL);
285
4031f73fe0e4 access to the raw dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 269
diff changeset
1304
4457
789676a8c96a Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1305 // Throttle to avoid loading several large DICOM files simultaneously
789676a8c96a Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1306 largeDicomLocker_.reset(new Semaphore::Locker(context.largeDicomThrottler_));
789676a8c96a Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1307
789676a8c96a Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1308 std::string content;
789676a8c96a Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1309 context_.ReadDicom(content, instancePublicId);
789676a8c96a Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1310
789676a8c96a Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1311 // Release the throttle if loading "small" DICOM files (under
789676a8c96a Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1312 // 50MB, which is an arbitrary value)
789676a8c96a Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1313 if (content.size() < 50 * 1024 * 1024)
789676a8c96a Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1314 {
789676a8c96a Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1315 largeDicomLocker_.reset(NULL);
789676a8c96a Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1316 }
789676a8c96a Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1317
789676a8c96a Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1318 dicom_.reset(new ParsedDicomFile(content));
789676a8c96a Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1319 dicomSize_ = content.size();
789676a8c96a Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1320 }
789676a8c96a Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1321
789676a8c96a Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1322 assert(accessor_.get() != NULL ||
789676a8c96a Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1323 dicom_.get() != NULL);
778
aebf0071020e refactoring of the mutex for the dicom cache
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 774
diff changeset
1324 }
aebf0071020e refactoring of the mutex for the dicom cache
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 774
diff changeset
1325
aebf0071020e refactoring of the mutex for the dicom cache
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 774
diff changeset
1326
aebf0071020e refactoring of the mutex for the dicom cache
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 774
diff changeset
1327 ServerContext::DicomCacheLocker::~DicomCacheLocker()
aebf0071020e refactoring of the mutex for the dicom cache
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 774
diff changeset
1328 {
4457
789676a8c96a Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1329 if (dicom_.get() != NULL)
789676a8c96a Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1330 {
789676a8c96a Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1331 try
789676a8c96a Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1332 {
789676a8c96a Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1333 context_.dicomCache_.Acquire(instancePublicId_, dicom_.release(), dicomSize_);
789676a8c96a Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1334 }
789676a8c96a Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1335 catch (OrthancException&)
789676a8c96a Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1336 {
789676a8c96a Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1337 }
789676a8c96a Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1338 }
285
4031f73fe0e4 access to the raw dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 269
diff changeset
1339 }
304
4eea080e6e7a refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 291
diff changeset
1340
4eea080e6e7a refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 291
diff changeset
1341
4457
789676a8c96a Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1342 ParsedDicomFile& ServerContext::DicomCacheLocker::GetDicom() const
789676a8c96a Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1343 {
789676a8c96a Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1344 if (dicom_.get() != NULL)
789676a8c96a Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1345 {
789676a8c96a Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1346 return *dicom_;
789676a8c96a Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1347 }
789676a8c96a Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1348 else
789676a8c96a Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1349 {
789676a8c96a Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1350 assert(accessor_.get() != NULL);
789676a8c96a Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1351 return accessor_->GetDicom();
789676a8c96a Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1352 }
789676a8c96a Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1353 }
789676a8c96a Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1354
789676a8c96a Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1355
695
c59bc408fb10 parameter to disable the computation of the MD5
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 689
diff changeset
1356 void ServerContext::SetStoreMD5ForAttachments(bool storeMD5)
c59bc408fb10 parameter to disable the computation of the MD5
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 689
diff changeset
1357 {
c59bc408fb10 parameter to disable the computation of the MD5
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 689
diff changeset
1358 LOG(INFO) << "Storing MD5 for attachments: " << (storeMD5 ? "yes" : "no");
1549
e5e975e9b738 refactoring and simplification of StorageAccessor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1548
diff changeset
1359 storeMD5_ = storeMD5;
695
c59bc408fb10 parameter to disable the computation of the MD5
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 689
diff changeset
1360 }
c59bc408fb10 parameter to disable the computation of the MD5
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 689
diff changeset
1361
699
2929e17f8447 add attachments to resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 697
diff changeset
1362
4627
f7d5372b59b3 handling revisions of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4623
diff changeset
1363 bool ServerContext::AddAttachment(int64_t& newRevision,
f7d5372b59b3 handling revisions of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4623
diff changeset
1364 const std::string& resourceId,
699
2929e17f8447 add attachments to resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 697
diff changeset
1365 FileContentType attachmentType,
2929e17f8447 add attachments to resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 697
diff changeset
1366 const void* data,
4627
f7d5372b59b3 handling revisions of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4623
diff changeset
1367 size_t size,
f7d5372b59b3 handling revisions of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4623
diff changeset
1368 bool hasOldRevision,
4640
66109d24d26e "ETag" headers for metadata and attachments now allow strong comparison (MD5 is included)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4629
diff changeset
1369 int64_t oldRevision,
66109d24d26e "ETag" headers for metadata and attachments now allow strong comparison (MD5 is included)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4629
diff changeset
1370 const std::string& oldMD5)
699
2929e17f8447 add attachments to resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 697
diff changeset
1371 {
2929e17f8447 add attachments to resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 697
diff changeset
1372 LOG(INFO) << "Adding attachment " << EnumerationToString(attachmentType) << " to resource " << resourceId;
2929e17f8447 add attachments to resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 697
diff changeset
1373
1549
e5e975e9b738 refactoring and simplification of StorageAccessor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1548
diff changeset
1374 // TODO Should we use "gzip" instead?
e5e975e9b738 refactoring and simplification of StorageAccessor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1548
diff changeset
1375 CompressionType compression = (compressionEnabled_ ? CompressionType_ZlibWithSize : CompressionType_None);
699
2929e17f8447 add attachments to resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 697
diff changeset
1376
5184
dd085f7e7e71 cleaning new constructors of StorageAccessor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5183
diff changeset
1377 StorageAccessor accessor(area_, storageCache_, GetMetricsRegistry());
1549
e5e975e9b738 refactoring and simplification of StorageAccessor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1548
diff changeset
1378 FileInfo attachment = accessor.Write(data, size, attachmentType, compression, storeMD5_);
699
2929e17f8447 add attachments to resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 697
diff changeset
1379
4752
2f35e6b765e5 Fix orphaned attachments if bad revision number is provided
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4694
diff changeset
1380 try
699
2929e17f8447 add attachments to resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 697
diff changeset
1381 {
4752
2f35e6b765e5 Fix orphaned attachments if bad revision number is provided
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4694
diff changeset
1382 StoreStatus status = index_.AddAttachment(
2f35e6b765e5 Fix orphaned attachments if bad revision number is provided
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4694
diff changeset
1383 newRevision, attachment, resourceId, hasOldRevision, oldRevision, oldMD5);
2f35e6b765e5 Fix orphaned attachments if bad revision number is provided
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4694
diff changeset
1384 if (status != StoreStatus_Success)
2f35e6b765e5 Fix orphaned attachments if bad revision number is provided
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4694
diff changeset
1385 {
2f35e6b765e5 Fix orphaned attachments if bad revision number is provided
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4694
diff changeset
1386 accessor.Remove(attachment);
2f35e6b765e5 Fix orphaned attachments if bad revision number is provided
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4694
diff changeset
1387 return false;
2f35e6b765e5 Fix orphaned attachments if bad revision number is provided
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4694
diff changeset
1388 }
2f35e6b765e5 Fix orphaned attachments if bad revision number is provided
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4694
diff changeset
1389 else
2f35e6b765e5 Fix orphaned attachments if bad revision number is provided
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4694
diff changeset
1390 {
2f35e6b765e5 Fix orphaned attachments if bad revision number is provided
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4694
diff changeset
1391 return true;
2f35e6b765e5 Fix orphaned attachments if bad revision number is provided
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4694
diff changeset
1392 }
2f35e6b765e5 Fix orphaned attachments if bad revision number is provided
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4694
diff changeset
1393 }
2f35e6b765e5 Fix orphaned attachments if bad revision number is provided
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4694
diff changeset
1394 catch (OrthancException&)
2f35e6b765e5 Fix orphaned attachments if bad revision number is provided
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4694
diff changeset
1395 {
2f35e6b765e5 Fix orphaned attachments if bad revision number is provided
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4694
diff changeset
1396 // Fixed in Orthanc 1.9.6
1549
e5e975e9b738 refactoring and simplification of StorageAccessor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1548
diff changeset
1397 accessor.Remove(attachment);
4752
2f35e6b765e5 Fix orphaned attachments if bad revision number is provided
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4694
diff changeset
1398 throw;
699
2929e17f8447 add attachments to resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 697
diff changeset
1399 }
2929e17f8447 add attachments to resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 697
diff changeset
1400 }
1145
0479d02c6778 Plugins can retrieve the path to Orthanc and to its configuration file
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1134
diff changeset
1401
0479d02c6778 Plugins can retrieve the path to Orthanc and to its configuration file
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1134
diff changeset
1402
4694
da1edb7d6332 "/tools/bulk-delete" to delete a group of multiple, unrelated resources at once
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4677
diff changeset
1403 bool ServerContext::DeleteResource(Json::Value& remainingAncestor,
1145
0479d02c6778 Plugins can retrieve the path to Orthanc and to its configuration file
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1134
diff changeset
1404 const std::string& uuid,
0479d02c6778 Plugins can retrieve the path to Orthanc and to its configuration file
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1134
diff changeset
1405 ResourceType expectedType)
0479d02c6778 Plugins can retrieve the path to Orthanc and to its configuration file
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1134
diff changeset
1406 {
2507
99116ed6f38c invalidate DicomCache when deleting instance
amazy
parents: 2447
diff changeset
1407 if (expectedType == ResourceType_Instance)
99116ed6f38c invalidate DicomCache when deleting instance
amazy
parents: 2447
diff changeset
1408 {
99116ed6f38c invalidate DicomCache when deleting instance
amazy
parents: 2447
diff changeset
1409 // remove the file from the DicomCache
99116ed6f38c invalidate DicomCache when deleting instance
amazy
parents: 2447
diff changeset
1410 dicomCache_.Invalidate(uuid);
99116ed6f38c invalidate DicomCache when deleting instance
amazy
parents: 2447
diff changeset
1411 }
99116ed6f38c invalidate DicomCache when deleting instance
amazy
parents: 2447
diff changeset
1412
4694
da1edb7d6332 "/tools/bulk-delete" to delete a group of multiple, unrelated resources at once
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4677
diff changeset
1413 return index_.DeleteResource(remainingAncestor, uuid, expectedType);
1145
0479d02c6778 Plugins can retrieve the path to Orthanc and to its configuration file
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1134
diff changeset
1414 }
1189
6b9b02a16e99 NewChildInstance change type
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1165
diff changeset
1415
6b9b02a16e99 NewChildInstance change type
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1165
diff changeset
1416
1198
1169528a9a5f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1189
diff changeset
1417 void ServerContext::SignalChange(const ServerIndexChange& change)
1189
6b9b02a16e99 NewChildInstance change type
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1165
diff changeset
1418 {
4457
789676a8c96a Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1419 if (change.GetResourceType() == ResourceType_Instance &&
789676a8c96a Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1420 change.GetChangeType() == ChangeType_Deleted)
789676a8c96a Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1421 {
789676a8c96a Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1422 dicomCache_.Invalidate(change.GetPublicId());
789676a8c96a Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1423 }
789676a8c96a Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1424
1436
0a3e3be59094 uncoupling of SignalChange for Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1434
diff changeset
1425 pendingChanges_.Enqueue(change.Clone());
1189
6b9b02a16e99 NewChildInstance change type
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1165
diff changeset
1426 }
1232
f1c01451a8ee Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
1427
f1c01451a8ee Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
1428
2136
dd609a99d39a uniformization of the macro naming
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2135
diff changeset
1429 #if ORTHANC_ENABLE_PLUGINS == 1
1434
f9cd40166269 refactoring of OrthancPlugins, improvement in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1433
diff changeset
1430 void ServerContext::SetPlugins(OrthancPlugins& plugins)
1232
f1c01451a8ee Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
1431 {
3947
cf6eb4fc6841 fix issue 179: use a shared mutex to avoid deadlock in python plugins
Alain Mazy <alain@mazy.be>
parents: 3945
diff changeset
1432 boost::unique_lock<boost::shared_mutex> lock(listenersMutex_);
1459
040d58493998 security
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1456
diff changeset
1433
1434
f9cd40166269 refactoring of OrthancPlugins, improvement in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1433
diff changeset
1434 plugins_ = &plugins;
f9cd40166269 refactoring of OrthancPlugins, improvement in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1433
diff changeset
1435
f9cd40166269 refactoring of OrthancPlugins, improvement in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1433
diff changeset
1436 // TODO REFACTOR THIS
f9cd40166269 refactoring of OrthancPlugins, improvement in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1433
diff changeset
1437 listeners_.clear();
2738
3a55b77339ff fix deadlock in Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2716
diff changeset
1438 listeners_.push_back(ServerListener(luaListener_, "Lua"));
1434
f9cd40166269 refactoring of OrthancPlugins, improvement in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1433
diff changeset
1439 listeners_.push_back(ServerListener(plugins, "plugin"));
1232
f1c01451a8ee Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
1440 }
f1c01451a8ee Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
1441
f1c01451a8ee Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
1442
1434
f9cd40166269 refactoring of OrthancPlugins, improvement in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1433
diff changeset
1443 void ServerContext::ResetPlugins()
1232
f1c01451a8ee Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
1444 {
3947
cf6eb4fc6841 fix issue 179: use a shared mutex to avoid deadlock in python plugins
Alain Mazy <alain@mazy.be>
parents: 3945
diff changeset
1445 boost::unique_lock<boost::shared_mutex> lock(listenersMutex_);
1459
040d58493998 security
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1456
diff changeset
1446
1434
f9cd40166269 refactoring of OrthancPlugins, improvement in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1433
diff changeset
1447 plugins_ = NULL;
f9cd40166269 refactoring of OrthancPlugins, improvement in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1433
diff changeset
1448
f9cd40166269 refactoring of OrthancPlugins, improvement in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1433
diff changeset
1449 // TODO REFACTOR THIS
f9cd40166269 refactoring of OrthancPlugins, improvement in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1433
diff changeset
1450 listeners_.clear();
2738
3a55b77339ff fix deadlock in Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2716
diff changeset
1451 listeners_.push_back(ServerListener(luaListener_, "Lua"));
1232
f1c01451a8ee Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
1452 }
f1c01451a8ee Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
1453
f1c01451a8ee Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
1454
1434
f9cd40166269 refactoring of OrthancPlugins, improvement in ServeFolders
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1433
diff changeset
1455 const OrthancPlugins& ServerContext::GetPlugins() const
1232
f1c01451a8ee Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
1456 {
f1c01451a8ee Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
1457 if (HasPlugins())
f1c01451a8ee Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
1458 {
f1c01451a8ee Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
1459 return *plugins_;
f1c01451a8ee Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
1460 }
f1c01451a8ee Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
1461 else
f1c01451a8ee Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
1462 {
f1c01451a8ee Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
1463 throw OrthancException(ErrorCode_InternalError);
f1c01451a8ee Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
1464 }
f1c01451a8ee Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1198
diff changeset
1465 }
1632
eb8fbcf008b5 fix build with plugins disabled
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1582
diff changeset
1466
1741
06addfcd1d4c OrthancStarted and OrthancStopped events in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1701
diff changeset
1467 OrthancPlugins& ServerContext::GetPlugins()
06addfcd1d4c OrthancStarted and OrthancStopped events in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1701
diff changeset
1468 {
06addfcd1d4c OrthancStarted and OrthancStopped events in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1701
diff changeset
1469 if (HasPlugins())
06addfcd1d4c OrthancStarted and OrthancStopped events in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1701
diff changeset
1470 {
06addfcd1d4c OrthancStarted and OrthancStopped events in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1701
diff changeset
1471 return *plugins_;
06addfcd1d4c OrthancStarted and OrthancStopped events in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1701
diff changeset
1472 }
06addfcd1d4c OrthancStarted and OrthancStopped events in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1701
diff changeset
1473 else
06addfcd1d4c OrthancStarted and OrthancStopped events in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1701
diff changeset
1474 {
06addfcd1d4c OrthancStarted and OrthancStopped events in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1701
diff changeset
1475 throw OrthancException(ErrorCode_InternalError);
06addfcd1d4c OrthancStarted and OrthancStopped events in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1701
diff changeset
1476 }
06addfcd1d4c OrthancStarted and OrthancStopped events in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1701
diff changeset
1477 }
06addfcd1d4c OrthancStarted and OrthancStopped events in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1701
diff changeset
1478
1632
eb8fbcf008b5 fix build with plugins disabled
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1582
diff changeset
1479 #endif
eb8fbcf008b5 fix build with plugins disabled
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1582
diff changeset
1480
eb8fbcf008b5 fix build with plugins disabled
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1582
diff changeset
1481
eb8fbcf008b5 fix build with plugins disabled
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1582
diff changeset
1482 bool ServerContext::HasPlugins() const
eb8fbcf008b5 fix build with plugins disabled
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1582
diff changeset
1483 {
2136
dd609a99d39a uniformization of the macro naming
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2135
diff changeset
1484 #if ORTHANC_ENABLE_PLUGINS == 1
1632
eb8fbcf008b5 fix build with plugins disabled
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1582
diff changeset
1485 return (plugins_ != NULL);
eb8fbcf008b5 fix build with plugins disabled
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1582
diff changeset
1486 #else
eb8fbcf008b5 fix build with plugins disabled
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1582
diff changeset
1487 return false;
eb8fbcf008b5 fix build with plugins disabled
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1582
diff changeset
1488 #endif
eb8fbcf008b5 fix build with plugins disabled
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1582
diff changeset
1489 }
1757
98abb8d7f905 ServerContext::Apply lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1741
diff changeset
1490
98abb8d7f905 ServerContext::Apply lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1741
diff changeset
1491
4978
2cfa50d8eb60 Speed-up handling of DicomModalitiesInStudy in C-Find and tools/find queries
Alain Mazy <am@osimis.io>
parents: 4977
diff changeset
1492 void ServerContext::Apply(ILookupVisitor& visitor,
2cfa50d8eb60 Speed-up handling of DicomModalitiesInStudy in C-Find and tools/find queries
Alain Mazy <am@osimis.io>
parents: 4977
diff changeset
1493 const DatabaseLookup& lookup,
2cfa50d8eb60 Speed-up handling of DicomModalitiesInStudy in C-Find and tools/find queries
Alain Mazy <am@osimis.io>
parents: 4977
diff changeset
1494 ResourceType queryLevel,
2cfa50d8eb60 Speed-up handling of DicomModalitiesInStudy in C-Find and tools/find queries
Alain Mazy <am@osimis.io>
parents: 4977
diff changeset
1495 size_t since,
2cfa50d8eb60 Speed-up handling of DicomModalitiesInStudy in C-Find and tools/find queries
Alain Mazy <am@osimis.io>
parents: 4977
diff changeset
1496 size_t limit)
4196
37310bb1cd30 Fix handling of "ModalitiesInStudy" (0008,0061) in C-FIND and "/tools/find"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4143
diff changeset
1497 {
3679
6358923d3ced C-FIND: forbid wildcard matching on some VRs, ignore main tags below the queried level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3677
diff changeset
1498 unsigned int databaseLimit = (queryLevel == ResourceType_Instance ?
6358923d3ced C-FIND: forbid wildcard matching on some VRs, ignore main tags below the queried level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3677
diff changeset
1499 limitFindInstances_ : limitFindResults_);
3015
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
1500
1757
98abb8d7f905 ServerContext::Apply lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1741
diff changeset
1501 std::vector<std::string> resources, instances;
4978
2cfa50d8eb60 Speed-up handling of DicomModalitiesInStudy in C-Find and tools/find queries
Alain Mazy <am@osimis.io>
parents: 4977
diff changeset
1502 const DicomTagConstraint* dicomModalitiesConstraint = NULL;
2cfa50d8eb60 Speed-up handling of DicomModalitiesInStudy in C-Find and tools/find queries
Alain Mazy <am@osimis.io>
parents: 4977
diff changeset
1503
2cfa50d8eb60 Speed-up handling of DicomModalitiesInStudy in C-Find and tools/find queries
Alain Mazy <am@osimis.io>
parents: 4977
diff changeset
1504 bool hasModalitiesInStudyLookup = (queryLevel == ResourceType_Study &&
2cfa50d8eb60 Speed-up handling of DicomModalitiesInStudy in C-Find and tools/find queries
Alain Mazy <am@osimis.io>
parents: 4977
diff changeset
1505 lookup.GetConstraint(dicomModalitiesConstraint, DICOM_TAG_MODALITIES_IN_STUDY) &&
2cfa50d8eb60 Speed-up handling of DicomModalitiesInStudy in C-Find and tools/find queries
Alain Mazy <am@osimis.io>
parents: 4977
diff changeset
1506 ((dicomModalitiesConstraint->GetConstraintType() == ConstraintType_Equal && !dicomModalitiesConstraint->GetValue().empty()) ||
2cfa50d8eb60 Speed-up handling of DicomModalitiesInStudy in C-Find and tools/find queries
Alain Mazy <am@osimis.io>
parents: 4977
diff changeset
1507 (dicomModalitiesConstraint->GetConstraintType() == ConstraintType_List && !dicomModalitiesConstraint->GetValues().empty())));
2cfa50d8eb60 Speed-up handling of DicomModalitiesInStudy in C-Find and tools/find queries
Alain Mazy <am@osimis.io>
parents: 4977
diff changeset
1508
2cfa50d8eb60 Speed-up handling of DicomModalitiesInStudy in C-Find and tools/find queries
Alain Mazy <am@osimis.io>
parents: 4977
diff changeset
1509 std::unique_ptr<DatabaseLookup> fastLookup(lookup.Clone());
2cfa50d8eb60 Speed-up handling of DicomModalitiesInStudy in C-Find and tools/find queries
Alain Mazy <am@osimis.io>
parents: 4977
diff changeset
1510
2cfa50d8eb60 Speed-up handling of DicomModalitiesInStudy in C-Find and tools/find queries
Alain Mazy <am@osimis.io>
parents: 4977
diff changeset
1511 if (hasModalitiesInStudyLookup)
2cfa50d8eb60 Speed-up handling of DicomModalitiesInStudy in C-Find and tools/find queries
Alain Mazy <am@osimis.io>
parents: 4977
diff changeset
1512 {
2cfa50d8eb60 Speed-up handling of DicomModalitiesInStudy in C-Find and tools/find queries
Alain Mazy <am@osimis.io>
parents: 4977
diff changeset
1513 fastLookup->RemoveConstraint(DICOM_TAG_MODALITIES_IN_STUDY);
2cfa50d8eb60 Speed-up handling of DicomModalitiesInStudy in C-Find and tools/find queries
Alain Mazy <am@osimis.io>
parents: 4977
diff changeset
1514 }
3015
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
1515
3204
8792867b739a fix incorrect "too many results"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3175
diff changeset
1516 {
5220
df39c7583a49 preparing virtual methods for labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5200
diff changeset
1517 const size_t lookupLimit = (databaseLimit == 0 ? 0 : databaseLimit + 1);
df39c7583a49 preparing virtual methods for labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5200
diff changeset
1518 GetIndex().ApplyLookupResources(resources, &instances, *fastLookup, queryLevel,
5248
a7d95f951f8a replaced "WithLabels" and "WithoutLabels", by "Labels" and "LabelsConstraint"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5222
diff changeset
1519 lookup.GetLabels(), lookup.GetLabelsConstraint(), lookupLimit);
3204
8792867b739a fix incorrect "too many results"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3175
diff changeset
1520 }
3025
039a9d262d64 preparing to speed up find in databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3021
diff changeset
1521
3033
5da6d1063d8f effectively replacing LookupResource by DatabaseLookup in searches
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3031
diff changeset
1522 bool complete = (databaseLimit == 0 ||
3204
8792867b739a fix incorrect "too many results"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3175
diff changeset
1523 resources.size() <= databaseLimit);
1757
98abb8d7f905 ServerContext::Apply lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1741
diff changeset
1524
3005
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3003
diff changeset
1525 LOG(INFO) << "Number of candidate resources after fast DB filtering on main DICOM tags: " << resources.size();
3003
5ae3ff2398e9 refactoring OrthancFindRequestHandler using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3001
diff changeset
1526
3679
6358923d3ced C-FIND: forbid wildcard matching on some VRs, ignore main tags below the queried level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3677
diff changeset
1527 /**
6358923d3ced C-FIND: forbid wildcard matching on some VRs, ignore main tags below the queried level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3677
diff changeset
1528 * "resources" contains the Orthanc ID of the resource at level
6358923d3ced C-FIND: forbid wildcard matching on some VRs, ignore main tags below the queried level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3677
diff changeset
1529 * "queryLevel", "instances" contains one the Orthanc ID of one
6358923d3ced C-FIND: forbid wildcard matching on some VRs, ignore main tags below the queried level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3677
diff changeset
1530 * sample instance from this resource.
6358923d3ced C-FIND: forbid wildcard matching on some VRs, ignore main tags below the queried level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3677
diff changeset
1531 **/
1757
98abb8d7f905 ServerContext::Apply lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1741
diff changeset
1532 assert(resources.size() == instances.size());
98abb8d7f905 ServerContext::Apply lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1741
diff changeset
1533
3001
7695a9c81099 refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2965
diff changeset
1534 size_t countResults = 0;
2304
563bf878407a Argument "Since" in URI "/tools/find" (related to issue 53)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1535 size_t skipped = 0;
3015
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
1536
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
1537 const bool isDicomAsJsonNeeded = visitor.IsDicomAsJsonNeeded();
3012
af1530b45290 Optimization: On finds, do not read JSON (disk) if main DICOM tags (DB) are sufficient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
1538
1757
98abb8d7f905 ServerContext::Apply lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1741
diff changeset
1539 for (size_t i = 0; i < instances.size(); i++)
98abb8d7f905 ServerContext::Apply lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1741
diff changeset
1540 {
3012
af1530b45290 Optimization: On finds, do not read JSON (disk) if main DICOM tags (DB) are sufficient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
1541 // Optimization in Orthanc 1.5.1 - Don't read the full JSON from
af1530b45290 Optimization: On finds, do not read JSON (disk) if main DICOM tags (DB) are sufficient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
1542 // the disk if only "main DICOM tags" are to be returned
af1530b45290 Optimization: On finds, do not read JSON (disk) if main DICOM tags (DB) are sufficient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
1543
5058
d4e5ca0c9307 Fix the "Never" option of the "StorageAccessOnFind" that was sill accessing files (bug introduced in 1.11.0)
Alain Mazy <am@osimis.io>
parents: 5048
diff changeset
1544 boost::shared_ptr<Json::Value> dicomAsJson;
3012
af1530b45290 Optimization: On finds, do not read JSON (disk) if main DICOM tags (DB) are sufficient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
1545
af1530b45290 Optimization: On finds, do not read JSON (disk) if main DICOM tags (DB) are sufficient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
1546 bool hasOnlyMainDicomTags;
af1530b45290 Optimization: On finds, do not read JSON (disk) if main DICOM tags (DB) are sufficient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
1547 DicomMap dicom;
4937
3f9b9865c8cc include requested tags from storage if needed
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
1548 DicomMap allMainDicomTagsFromDB;
3012
af1530b45290 Optimization: On finds, do not read JSON (disk) if main DICOM tags (DB) are sufficient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
1549
5058
d4e5ca0c9307 Fix the "Never" option of the "StorageAccessOnFind" that was sill accessing files (bug introduced in 1.11.0)
Alain Mazy <am@osimis.io>
parents: 5048
diff changeset
1550 if (!IsStorageAccessAllowedForAnswers(findStorageAccessMode_)
d4e5ca0c9307 Fix the "Never" option of the "StorageAccessOnFind" that was sill accessing files (bug introduced in 1.11.0)
Alain Mazy <am@osimis.io>
parents: 5048
diff changeset
1551 || fastLookup->HasOnlyMainDicomTags())
3012
af1530b45290 Optimization: On finds, do not read JSON (disk) if main DICOM tags (DB) are sufficient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
1552 {
af1530b45290 Optimization: On finds, do not read JSON (disk) if main DICOM tags (DB) are sufficient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
1553 // Case (1): The main DICOM tags, as stored in the database,
af1530b45290 Optimization: On finds, do not read JSON (disk) if main DICOM tags (DB) are sufficient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
1554 // are sufficient to look for match
3015
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
1555
4944
f377d5643538 new Warnings configuration + InstanceAvailability tag
Alain Mazy <am@osimis.io>
parents: 4941
diff changeset
1556 if (!GetIndex().GetAllMainDicomTags(allMainDicomTagsFromDB, instances[i]))
3015
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
1557 {
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
1558 // The instance has been removed during the execution of the
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
1559 // lookup, ignore it
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
1560 continue;
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
1561 }
3679
6358923d3ced C-FIND: forbid wildcard matching on some VRs, ignore main tags below the queried level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3677
diff changeset
1562
6358923d3ced C-FIND: forbid wildcard matching on some VRs, ignore main tags below the queried level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3677
diff changeset
1563 // New in Orthanc 1.6.0: Only keep the main DICOM tags at the
6358923d3ced C-FIND: forbid wildcard matching on some VRs, ignore main tags below the queried level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3677
diff changeset
1564 // level of interest for the query
6358923d3ced C-FIND: forbid wildcard matching on some VRs, ignore main tags below the queried level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3677
diff changeset
1565 switch (queryLevel)
6358923d3ced C-FIND: forbid wildcard matching on some VRs, ignore main tags below the queried level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3677
diff changeset
1566 {
6358923d3ced C-FIND: forbid wildcard matching on some VRs, ignore main tags below the queried level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3677
diff changeset
1567 // WARNING: Don't reorder cases below, and don't add "break"
6358923d3ced C-FIND: forbid wildcard matching on some VRs, ignore main tags below the queried level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3677
diff changeset
1568 case ResourceType_Instance:
4937
3f9b9865c8cc include requested tags from storage if needed
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
1569 dicom.MergeMainDicomTags(allMainDicomTagsFromDB, ResourceType_Instance);
3679
6358923d3ced C-FIND: forbid wildcard matching on some VRs, ignore main tags below the queried level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3677
diff changeset
1570
6358923d3ced C-FIND: forbid wildcard matching on some VRs, ignore main tags below the queried level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3677
diff changeset
1571 case ResourceType_Series:
4937
3f9b9865c8cc include requested tags from storage if needed
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
1572 dicom.MergeMainDicomTags(allMainDicomTagsFromDB, ResourceType_Series);
3679
6358923d3ced C-FIND: forbid wildcard matching on some VRs, ignore main tags below the queried level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3677
diff changeset
1573
6358923d3ced C-FIND: forbid wildcard matching on some VRs, ignore main tags below the queried level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3677
diff changeset
1574 case ResourceType_Study:
4937
3f9b9865c8cc include requested tags from storage if needed
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
1575 dicom.MergeMainDicomTags(allMainDicomTagsFromDB, ResourceType_Study);
3679
6358923d3ced C-FIND: forbid wildcard matching on some VRs, ignore main tags below the queried level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3677
diff changeset
1576
6358923d3ced C-FIND: forbid wildcard matching on some VRs, ignore main tags below the queried level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3677
diff changeset
1577 case ResourceType_Patient:
4937
3f9b9865c8cc include requested tags from storage if needed
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
1578 dicom.MergeMainDicomTags(allMainDicomTagsFromDB, ResourceType_Patient);
3679
6358923d3ced C-FIND: forbid wildcard matching on some VRs, ignore main tags below the queried level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3677
diff changeset
1579 break;
6358923d3ced C-FIND: forbid wildcard matching on some VRs, ignore main tags below the queried level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3677
diff changeset
1580
6358923d3ced C-FIND: forbid wildcard matching on some VRs, ignore main tags below the queried level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3677
diff changeset
1581 default:
6358923d3ced C-FIND: forbid wildcard matching on some VRs, ignore main tags below the queried level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3677
diff changeset
1582 throw OrthancException(ErrorCode_InternalError);
6358923d3ced C-FIND: forbid wildcard matching on some VRs, ignore main tags below the queried level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3677
diff changeset
1583 }
3015
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
1584
3012
af1530b45290 Optimization: On finds, do not read JSON (disk) if main DICOM tags (DB) are sufficient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
1585 hasOnlyMainDicomTags = true;
af1530b45290 Optimization: On finds, do not read JSON (disk) if main DICOM tags (DB) are sufficient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
1586 }
af1530b45290 Optimization: On finds, do not read JSON (disk) if main DICOM tags (DB) are sufficient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
1587 else
af1530b45290 Optimization: On finds, do not read JSON (disk) if main DICOM tags (DB) are sufficient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
1588 {
af1530b45290 Optimization: On finds, do not read JSON (disk) if main DICOM tags (DB) are sufficient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
1589 // Case (2): Need to read the "DICOM-as-JSON" attachment from
af1530b45290 Optimization: On finds, do not read JSON (disk) if main DICOM tags (DB) are sufficient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
1590 // the storage area
af1530b45290 Optimization: On finds, do not read JSON (disk) if main DICOM tags (DB) are sufficient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
1591 dicomAsJson.reset(new Json::Value);
af1530b45290 Optimization: On finds, do not read JSON (disk) if main DICOM tags (DB) are sufficient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
1592 ReadDicomAsJson(*dicomAsJson, instances[i]);
af1530b45290 Optimization: On finds, do not read JSON (disk) if main DICOM tags (DB) are sufficient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
1593
af1530b45290 Optimization: On finds, do not read JSON (disk) if main DICOM tags (DB) are sufficient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
1594 dicom.FromDicomAsJson(*dicomAsJson);
af1530b45290 Optimization: On finds, do not read JSON (disk) if main DICOM tags (DB) are sufficient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
1595
af1530b45290 Optimization: On finds, do not read JSON (disk) if main DICOM tags (DB) are sufficient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
1596 // This map contains the entire JSON, i.e. more than the main DICOM tags
af1530b45290 Optimization: On finds, do not read JSON (disk) if main DICOM tags (DB) are sufficient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
1597 hasOnlyMainDicomTags = false;
af1530b45290 Optimization: On finds, do not read JSON (disk) if main DICOM tags (DB) are sufficient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
1598 }
1757
98abb8d7f905 ServerContext::Apply lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1741
diff changeset
1599
4978
2cfa50d8eb60 Speed-up handling of DicomModalitiesInStudy in C-Find and tools/find queries
Alain Mazy <am@osimis.io>
parents: 4977
diff changeset
1600 if (fastLookup->IsMatch(dicom))
1757
98abb8d7f905 ServerContext::Apply lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1741
diff changeset
1601 {
4978
2cfa50d8eb60 Speed-up handling of DicomModalitiesInStudy in C-Find and tools/find queries
Alain Mazy <am@osimis.io>
parents: 4977
diff changeset
1602 bool isMatch = true;
2cfa50d8eb60 Speed-up handling of DicomModalitiesInStudy in C-Find and tools/find queries
Alain Mazy <am@osimis.io>
parents: 4977
diff changeset
1603
2cfa50d8eb60 Speed-up handling of DicomModalitiesInStudy in C-Find and tools/find queries
Alain Mazy <am@osimis.io>
parents: 4977
diff changeset
1604 if (hasModalitiesInStudyLookup)
2304
563bf878407a Argument "Since" in URI "/tools/find" (related to issue 53)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1605 {
4978
2cfa50d8eb60 Speed-up handling of DicomModalitiesInStudy in C-Find and tools/find queries
Alain Mazy <am@osimis.io>
parents: 4977
diff changeset
1606 std::set<DicomTag> requestedTags;
2cfa50d8eb60 Speed-up handling of DicomModalitiesInStudy in C-Find and tools/find queries
Alain Mazy <am@osimis.io>
parents: 4977
diff changeset
1607 requestedTags.insert(DICOM_TAG_MODALITIES_IN_STUDY);
2cfa50d8eb60 Speed-up handling of DicomModalitiesInStudy in C-Find and tools/find queries
Alain Mazy <am@osimis.io>
parents: 4977
diff changeset
1608 ExpandedResource resource;
2cfa50d8eb60 Speed-up handling of DicomModalitiesInStudy in C-Find and tools/find queries
Alain Mazy <am@osimis.io>
parents: 4977
diff changeset
1609 ComputeStudyTags(resource, *this, resources[i], requestedTags);
2cfa50d8eb60 Speed-up handling of DicomModalitiesInStudy in C-Find and tools/find queries
Alain Mazy <am@osimis.io>
parents: 4977
diff changeset
1610
2cfa50d8eb60 Speed-up handling of DicomModalitiesInStudy in C-Find and tools/find queries
Alain Mazy <am@osimis.io>
parents: 4977
diff changeset
1611 std::vector<std::string> modalities;
5222
3a61fd50f804 starting refactoring ExpandedResource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5221
diff changeset
1612 Toolbox::TokenizeString(modalities, resource.GetMainDicomTags().GetValue(DICOM_TAG_MODALITIES_IN_STUDY).GetContent(), '\\');
4978
2cfa50d8eb60 Speed-up handling of DicomModalitiesInStudy in C-Find and tools/find queries
Alain Mazy <am@osimis.io>
parents: 4977
diff changeset
1613 bool hasAtLeastOneModalityMatching = false;
2cfa50d8eb60 Speed-up handling of DicomModalitiesInStudy in C-Find and tools/find queries
Alain Mazy <am@osimis.io>
parents: 4977
diff changeset
1614 for (size_t m = 0; m < modalities.size(); m++)
3012
af1530b45290 Optimization: On finds, do not read JSON (disk) if main DICOM tags (DB) are sufficient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
1615 {
4978
2cfa50d8eb60 Speed-up handling of DicomModalitiesInStudy in C-Find and tools/find queries
Alain Mazy <am@osimis.io>
parents: 4977
diff changeset
1616 hasAtLeastOneModalityMatching |= dicomModalitiesConstraint->IsMatch(modalities[m]);
3012
af1530b45290 Optimization: On finds, do not read JSON (disk) if main DICOM tags (DB) are sufficient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
1617 }
af1530b45290 Optimization: On finds, do not read JSON (disk) if main DICOM tags (DB) are sufficient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
1618
4978
2cfa50d8eb60 Speed-up handling of DicomModalitiesInStudy in C-Find and tools/find queries
Alain Mazy <am@osimis.io>
parents: 4977
diff changeset
1619 isMatch = isMatch && hasAtLeastOneModalityMatching;
2cfa50d8eb60 Speed-up handling of DicomModalitiesInStudy in C-Find and tools/find queries
Alain Mazy <am@osimis.io>
parents: 4977
diff changeset
1620 // copy the value of ModalitiesInStudy such that it can be reused to build the answer
5222
3a61fd50f804 starting refactoring ExpandedResource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5221
diff changeset
1621 allMainDicomTagsFromDB.SetValue(DICOM_TAG_MODALITIES_IN_STUDY, resource.GetMainDicomTags().GetValue(DICOM_TAG_MODALITIES_IN_STUDY));
4978
2cfa50d8eb60 Speed-up handling of DicomModalitiesInStudy in C-Find and tools/find queries
Alain Mazy <am@osimis.io>
parents: 4977
diff changeset
1622 }
2cfa50d8eb60 Speed-up handling of DicomModalitiesInStudy in C-Find and tools/find queries
Alain Mazy <am@osimis.io>
parents: 4977
diff changeset
1623
2cfa50d8eb60 Speed-up handling of DicomModalitiesInStudy in C-Find and tools/find queries
Alain Mazy <am@osimis.io>
parents: 4977
diff changeset
1624 if (isMatch)
2cfa50d8eb60 Speed-up handling of DicomModalitiesInStudy in C-Find and tools/find queries
Alain Mazy <am@osimis.io>
parents: 4977
diff changeset
1625 {
2cfa50d8eb60 Speed-up handling of DicomModalitiesInStudy in C-Find and tools/find queries
Alain Mazy <am@osimis.io>
parents: 4977
diff changeset
1626 if (skipped < since)
3012
af1530b45290 Optimization: On finds, do not read JSON (disk) if main DICOM tags (DB) are sufficient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
1627 {
4978
2cfa50d8eb60 Speed-up handling of DicomModalitiesInStudy in C-Find and tools/find queries
Alain Mazy <am@osimis.io>
parents: 4977
diff changeset
1628 skipped++;
2cfa50d8eb60 Speed-up handling of DicomModalitiesInStudy in C-Find and tools/find queries
Alain Mazy <am@osimis.io>
parents: 4977
diff changeset
1629 }
2cfa50d8eb60 Speed-up handling of DicomModalitiesInStudy in C-Find and tools/find queries
Alain Mazy <am@osimis.io>
parents: 4977
diff changeset
1630 else if (limit != 0 &&
2cfa50d8eb60 Speed-up handling of DicomModalitiesInStudy in C-Find and tools/find queries
Alain Mazy <am@osimis.io>
parents: 4977
diff changeset
1631 countResults >= limit)
2cfa50d8eb60 Speed-up handling of DicomModalitiesInStudy in C-Find and tools/find queries
Alain Mazy <am@osimis.io>
parents: 4977
diff changeset
1632 {
2cfa50d8eb60 Speed-up handling of DicomModalitiesInStudy in C-Find and tools/find queries
Alain Mazy <am@osimis.io>
parents: 4977
diff changeset
1633 // Too many results, don't mark as complete
2cfa50d8eb60 Speed-up handling of DicomModalitiesInStudy in C-Find and tools/find queries
Alain Mazy <am@osimis.io>
parents: 4977
diff changeset
1634 complete = false;
2cfa50d8eb60 Speed-up handling of DicomModalitiesInStudy in C-Find and tools/find queries
Alain Mazy <am@osimis.io>
parents: 4977
diff changeset
1635 break;
3012
af1530b45290 Optimization: On finds, do not read JSON (disk) if main DICOM tags (DB) are sufficient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
1636 }
af1530b45290 Optimization: On finds, do not read JSON (disk) if main DICOM tags (DB) are sufficient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
1637 else
af1530b45290 Optimization: On finds, do not read JSON (disk) if main DICOM tags (DB) are sufficient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
1638 {
5058
d4e5ca0c9307 Fix the "Never" option of the "StorageAccessOnFind" that was sill accessing files (bug introduced in 1.11.0)
Alain Mazy <am@osimis.io>
parents: 5048
diff changeset
1639 if (IsStorageAccessAllowedForAnswers(findStorageAccessMode_) &&
4978
2cfa50d8eb60 Speed-up handling of DicomModalitiesInStudy in C-Find and tools/find queries
Alain Mazy <am@osimis.io>
parents: 4977
diff changeset
1640 dicomAsJson.get() == NULL &&
2cfa50d8eb60 Speed-up handling of DicomModalitiesInStudy in C-Find and tools/find queries
Alain Mazy <am@osimis.io>
parents: 4977
diff changeset
1641 isDicomAsJsonNeeded)
2cfa50d8eb60 Speed-up handling of DicomModalitiesInStudy in C-Find and tools/find queries
Alain Mazy <am@osimis.io>
parents: 4977
diff changeset
1642 {
2cfa50d8eb60 Speed-up handling of DicomModalitiesInStudy in C-Find and tools/find queries
Alain Mazy <am@osimis.io>
parents: 4977
diff changeset
1643 dicomAsJson.reset(new Json::Value);
2cfa50d8eb60 Speed-up handling of DicomModalitiesInStudy in C-Find and tools/find queries
Alain Mazy <am@osimis.io>
parents: 4977
diff changeset
1644 ReadDicomAsJson(*dicomAsJson, instances[i]);
2cfa50d8eb60 Speed-up handling of DicomModalitiesInStudy in C-Find and tools/find queries
Alain Mazy <am@osimis.io>
parents: 4977
diff changeset
1645 }
3012
af1530b45290 Optimization: On finds, do not read JSON (disk) if main DICOM tags (DB) are sufficient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
1646
4978
2cfa50d8eb60 Speed-up handling of DicomModalitiesInStudy in C-Find and tools/find queries
Alain Mazy <am@osimis.io>
parents: 4977
diff changeset
1647 if (hasOnlyMainDicomTags)
2cfa50d8eb60 Speed-up handling of DicomModalitiesInStudy in C-Find and tools/find queries
Alain Mazy <am@osimis.io>
parents: 4977
diff changeset
1648 {
2cfa50d8eb60 Speed-up handling of DicomModalitiesInStudy in C-Find and tools/find queries
Alain Mazy <am@osimis.io>
parents: 4977
diff changeset
1649 // This is Case (1): The variable "dicom" only contains the main DICOM tags
2cfa50d8eb60 Speed-up handling of DicomModalitiesInStudy in C-Find and tools/find queries
Alain Mazy <am@osimis.io>
parents: 4977
diff changeset
1650 visitor.Visit(resources[i], instances[i], allMainDicomTagsFromDB, dicomAsJson.get());
2cfa50d8eb60 Speed-up handling of DicomModalitiesInStudy in C-Find and tools/find queries
Alain Mazy <am@osimis.io>
parents: 4977
diff changeset
1651 }
2cfa50d8eb60 Speed-up handling of DicomModalitiesInStudy in C-Find and tools/find queries
Alain Mazy <am@osimis.io>
parents: 4977
diff changeset
1652 else
2cfa50d8eb60 Speed-up handling of DicomModalitiesInStudy in C-Find and tools/find queries
Alain Mazy <am@osimis.io>
parents: 4977
diff changeset
1653 {
2cfa50d8eb60 Speed-up handling of DicomModalitiesInStudy in C-Find and tools/find queries
Alain Mazy <am@osimis.io>
parents: 4977
diff changeset
1654 // Remove the non-main DICOM tags from "dicom" if Case (2)
2cfa50d8eb60 Speed-up handling of DicomModalitiesInStudy in C-Find and tools/find queries
Alain Mazy <am@osimis.io>
parents: 4977
diff changeset
1655 // was used, for consistency with Case (1)
2cfa50d8eb60 Speed-up handling of DicomModalitiesInStudy in C-Find and tools/find queries
Alain Mazy <am@osimis.io>
parents: 4977
diff changeset
1656
2cfa50d8eb60 Speed-up handling of DicomModalitiesInStudy in C-Find and tools/find queries
Alain Mazy <am@osimis.io>
parents: 4977
diff changeset
1657 DicomMap mainDicomTags;
2cfa50d8eb60 Speed-up handling of DicomModalitiesInStudy in C-Find and tools/find queries
Alain Mazy <am@osimis.io>
parents: 4977
diff changeset
1658 mainDicomTags.ExtractMainDicomTags(dicom);
2cfa50d8eb60 Speed-up handling of DicomModalitiesInStudy in C-Find and tools/find queries
Alain Mazy <am@osimis.io>
parents: 4977
diff changeset
1659 visitor.Visit(resources[i], instances[i], mainDicomTags, dicomAsJson.get());
2cfa50d8eb60 Speed-up handling of DicomModalitiesInStudy in C-Find and tools/find queries
Alain Mazy <am@osimis.io>
parents: 4977
diff changeset
1660 }
2cfa50d8eb60 Speed-up handling of DicomModalitiesInStudy in C-Find and tools/find queries
Alain Mazy <am@osimis.io>
parents: 4977
diff changeset
1661
2cfa50d8eb60 Speed-up handling of DicomModalitiesInStudy in C-Find and tools/find queries
Alain Mazy <am@osimis.io>
parents: 4977
diff changeset
1662 countResults ++;
3012
af1530b45290 Optimization: On finds, do not read JSON (disk) if main DICOM tags (DB) are sufficient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
1663 }
1757
98abb8d7f905 ServerContext::Apply lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1741
diff changeset
1664 }
98abb8d7f905 ServerContext::Apply lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1741
diff changeset
1665 }
98abb8d7f905 ServerContext::Apply lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1741
diff changeset
1666 }
3001
7695a9c81099 refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2965
diff changeset
1667
3003
5ae3ff2398e9 refactoring OrthancFindRequestHandler using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3001
diff changeset
1668 if (complete)
5ae3ff2398e9 refactoring OrthancFindRequestHandler using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3001
diff changeset
1669 {
5ae3ff2398e9 refactoring OrthancFindRequestHandler using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3001
diff changeset
1670 visitor.MarkAsComplete();
5ae3ff2398e9 refactoring OrthancFindRequestHandler using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3001
diff changeset
1671 }
5ae3ff2398e9 refactoring OrthancFindRequestHandler using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3001
diff changeset
1672
5ae3ff2398e9 refactoring OrthancFindRequestHandler using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3001
diff changeset
1673 LOG(INFO) << "Number of matching resources: " << countResults;
1757
98abb8d7f905 ServerContext::Apply lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1741
diff changeset
1674 }
98abb8d7f905 ServerContext::Apply lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1741
diff changeset
1675
3015
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
1676 bool ServerContext::LookupOrReconstructMetadata(std::string& target,
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
1677 const std::string& publicId,
4460
6831de40acd9 New metadata automatically computed at the series level: "RemoteAET"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4457
diff changeset
1678 ResourceType level,
3015
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
1679 MetadataType metadata)
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
1680 {
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
1681 // This is a backwards-compatibility function, that can
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
1682 // reconstruct metadata that were not generated by an older
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
1683 // release of Orthanc
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
1684
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
1685 if (metadata == MetadataType_Instance_SopClassUid ||
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
1686 metadata == MetadataType_Instance_TransferSyntax)
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
1687 {
4623
95ffe3b6ef7c handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4607
diff changeset
1688 int64_t revision; // Ignored
95ffe3b6ef7c handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4607
diff changeset
1689 if (index_.LookupMetadata(target, revision, publicId, level, metadata))
3015
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
1690 {
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
1691 return true;
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
1692 }
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
1693 else
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
1694 {
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
1695 // These metadata are mandatory in DICOM instances, and were
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
1696 // introduced in Orthanc 1.2.0. The fact that
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
1697 // "LookupMetadata()" has failed indicates that this database
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
1698 // comes from an older release of Orthanc.
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
1699
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
1700 DicomTag tag(0, 0);
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
1701
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
1702 switch (metadata)
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
1703 {
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
1704 case MetadataType_Instance_SopClassUid:
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
1705 tag = DICOM_TAG_SOP_CLASS_UID;
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
1706 break;
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
1707
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
1708 case MetadataType_Instance_TransferSyntax:
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
1709 tag = DICOM_TAG_TRANSFER_SYNTAX_UID;
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
1710 break;
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
1711
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
1712 default:
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
1713 throw OrthancException(ErrorCode_InternalError);
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
1714 }
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
1715
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
1716 Json::Value dicomAsJson;
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
1717 ReadDicomAsJson(dicomAsJson, publicId);
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
1718
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
1719 DicomMap tags;
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
1720 tags.FromDicomAsJson(dicomAsJson);
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
1721
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
1722 const DicomValue* value = tags.TestAndGetValue(tag);
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
1723
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
1724 if (value != NULL &&
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
1725 !value->IsNull() &&
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
1726 !value->IsBinary())
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
1727 {
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
1728 target = value->GetContent();
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
1729
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
1730 // Store for reuse
4623
95ffe3b6ef7c handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4607
diff changeset
1731 index_.OverwriteMetadata(publicId, metadata, target);
3015
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
1732 return true;
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
1733 }
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
1734 else
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
1735 {
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
1736 // Should never happen
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
1737 return false;
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
1738 }
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
1739 }
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
1740 }
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
1741 else
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
1742 {
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
1743 // No backward
4623
95ffe3b6ef7c handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4607
diff changeset
1744 int64_t revision; // Ignored
95ffe3b6ef7c handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4607
diff changeset
1745 return index_.LookupMetadata(target, revision, publicId, level, metadata);
3015
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
1746 }
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
1747 }
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
1748
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
1749
2626
e09021ddc00d cleanup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2617
diff changeset
1750 void ServerContext::AddChildInstances(SetOfInstancesJob& job,
e09021ddc00d cleanup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2617
diff changeset
1751 const std::string& publicId)
e09021ddc00d cleanup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2617
diff changeset
1752 {
e09021ddc00d cleanup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2617
diff changeset
1753 std::list<std::string> instances;
e09021ddc00d cleanup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2617
diff changeset
1754 GetIndex().GetChildInstances(instances, publicId);
e09021ddc00d cleanup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2617
diff changeset
1755
e09021ddc00d cleanup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2617
diff changeset
1756 job.Reserve(job.GetInstancesCount() + instances.size());
e09021ddc00d cleanup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2617
diff changeset
1757
e09021ddc00d cleanup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2617
diff changeset
1758 for (std::list<std::string>::const_iterator
e09021ddc00d cleanup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2617
diff changeset
1759 it = instances.begin(); it != instances.end(); ++it)
e09021ddc00d cleanup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2617
diff changeset
1760 {
e09021ddc00d cleanup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2617
diff changeset
1761 job.AddInstance(*it);
e09021ddc00d cleanup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2617
diff changeset
1762 }
e09021ddc00d cleanup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2617
diff changeset
1763 }
2940
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2925
diff changeset
1764
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2925
diff changeset
1765
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2925
diff changeset
1766 void ServerContext::SignalUpdatedModalities()
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2925
diff changeset
1767 {
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2925
diff changeset
1768 #if ORTHANC_ENABLE_PLUGINS == 1
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2925
diff changeset
1769 if (HasPlugins())
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2925
diff changeset
1770 {
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2925
diff changeset
1771 GetPlugins().SignalUpdatedModalities();
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2925
diff changeset
1772 }
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2925
diff changeset
1773 #endif
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2925
diff changeset
1774 }
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2925
diff changeset
1775
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2925
diff changeset
1776
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2925
diff changeset
1777 void ServerContext::SignalUpdatedPeers()
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2925
diff changeset
1778 {
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2925
diff changeset
1779 #if ORTHANC_ENABLE_PLUGINS == 1
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2925
diff changeset
1780 if (HasPlugins())
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2925
diff changeset
1781 {
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2925
diff changeset
1782 GetPlugins().SignalUpdatedPeers();
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2925
diff changeset
1783 }
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2925
diff changeset
1784 #endif
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2925
diff changeset
1785 }
3660
f159b731c47d IStorageCommitmentFactory
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1786
f159b731c47d IStorageCommitmentFactory
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1787
f159b731c47d IStorageCommitmentFactory
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1788 IStorageCommitmentFactory::ILookupHandler*
f159b731c47d IStorageCommitmentFactory
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1789 ServerContext::CreateStorageCommitment(const std::string& jobId,
f159b731c47d IStorageCommitmentFactory
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1790 const std::string& transactionUid,
f159b731c47d IStorageCommitmentFactory
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1791 const std::vector<std::string>& sopClassUids,
3662
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3660
diff changeset
1792 const std::vector<std::string>& sopInstanceUids,
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3660
diff changeset
1793 const std::string& remoteAet,
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3660
diff changeset
1794 const std::string& calledAet)
3660
f159b731c47d IStorageCommitmentFactory
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1795 {
f159b731c47d IStorageCommitmentFactory
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1796 #if ORTHANC_ENABLE_PLUGINS == 1
f159b731c47d IStorageCommitmentFactory
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1797 if (HasPlugins())
f159b731c47d IStorageCommitmentFactory
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1798 {
3662
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3660
diff changeset
1799 return GetPlugins().CreateStorageCommitment(
d8371b4302ff OrthancPluginRegisterStorageCommitmentScpCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3660
diff changeset
1800 jobId, transactionUid, sopClassUids, sopInstanceUids, remoteAet, calledAet);
3660
f159b731c47d IStorageCommitmentFactory
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1801 }
f159b731c47d IStorageCommitmentFactory
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1802 #endif
f159b731c47d IStorageCommitmentFactory
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1803
f159b731c47d IStorageCommitmentFactory
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1804 return NULL;
f159b731c47d IStorageCommitmentFactory
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1805 }
3894
8f7ad4989fec transcoding to uncompressed transfer syntaxes over DICOM protocol is implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3839
diff changeset
1806
8f7ad4989fec transcoding to uncompressed transfer syntaxes over DICOM protocol is implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3839
diff changeset
1807
3928
4cdc875510d1 ServerContext::DecodeDicomFrame()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3913
diff changeset
1808 ImageAccessor* ServerContext::DecodeDicomFrame(const std::string& publicId,
4cdc875510d1 ServerContext::DecodeDicomFrame()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3913
diff changeset
1809 unsigned int frameIndex)
4cdc875510d1 ServerContext::DecodeDicomFrame()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3913
diff changeset
1810 {
3931
e6606d3ec892 new configuration option: BuiltinDecoderTranscoderOrder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3930
diff changeset
1811 if (builtinDecoderTranscoderOrder_ == BuiltinDecoderTranscoderOrder_Before)
e6606d3ec892 new configuration option: BuiltinDecoderTranscoderOrder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3930
diff changeset
1812 {
e6606d3ec892 new configuration option: BuiltinDecoderTranscoderOrder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3930
diff changeset
1813 // Use Orthanc's built-in decoder, using the cache to speed-up
e6606d3ec892 new configuration option: BuiltinDecoderTranscoderOrder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3930
diff changeset
1814 // things on multi-frame images
4265
f9eaf14d3d19 Fix decoding sequence if "BuiltinDecoderTranscoderOrder" is "Before"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4218
diff changeset
1815
f9eaf14d3d19 Fix decoding sequence if "BuiltinDecoderTranscoderOrder" is "Before"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4218
diff changeset
1816 std::unique_ptr<ImageAccessor> decoded;
f9eaf14d3d19 Fix decoding sequence if "BuiltinDecoderTranscoderOrder" is "Before"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4218
diff changeset
1817 try
f9eaf14d3d19 Fix decoding sequence if "BuiltinDecoderTranscoderOrder" is "Before"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4218
diff changeset
1818 {
4274
09ed936fd381 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4268
diff changeset
1819 ServerContext::DicomCacheLocker locker(*this, publicId);
4265
f9eaf14d3d19 Fix decoding sequence if "BuiltinDecoderTranscoderOrder" is "Before"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4218
diff changeset
1820 decoded.reset(locker.GetDicom().DecodeFrame(frameIndex));
f9eaf14d3d19 Fix decoding sequence if "BuiltinDecoderTranscoderOrder" is "Before"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4218
diff changeset
1821 }
f9eaf14d3d19 Fix decoding sequence if "BuiltinDecoderTranscoderOrder" is "Before"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4218
diff changeset
1822 catch (OrthancException& e)
f9eaf14d3d19 Fix decoding sequence if "BuiltinDecoderTranscoderOrder" is "Before"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4218
diff changeset
1823 {
f9eaf14d3d19 Fix decoding sequence if "BuiltinDecoderTranscoderOrder" is "Before"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4218
diff changeset
1824 }
f9eaf14d3d19 Fix decoding sequence if "BuiltinDecoderTranscoderOrder" is "Before"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4218
diff changeset
1825
3931
e6606d3ec892 new configuration option: BuiltinDecoderTranscoderOrder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3930
diff changeset
1826 if (decoded.get() != NULL)
e6606d3ec892 new configuration option: BuiltinDecoderTranscoderOrder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3930
diff changeset
1827 {
e6606d3ec892 new configuration option: BuiltinDecoderTranscoderOrder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3930
diff changeset
1828 return decoded.release();
e6606d3ec892 new configuration option: BuiltinDecoderTranscoderOrder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3930
diff changeset
1829 }
e6606d3ec892 new configuration option: BuiltinDecoderTranscoderOrder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3930
diff changeset
1830 }
3928
4cdc875510d1 ServerContext::DecodeDicomFrame()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3913
diff changeset
1831
4cdc875510d1 ServerContext::DecodeDicomFrame()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3913
diff changeset
1832 #if ORTHANC_ENABLE_PLUGINS == 1
4cdc875510d1 ServerContext::DecodeDicomFrame()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3913
diff changeset
1833 if (HasPlugins() &&
4cdc875510d1 ServerContext::DecodeDicomFrame()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3913
diff changeset
1834 GetPlugins().HasCustomImageDecoder())
4cdc875510d1 ServerContext::DecodeDicomFrame()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3913
diff changeset
1835 {
4cdc875510d1 ServerContext::DecodeDicomFrame()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3913
diff changeset
1836 // TODO: Store the raw buffer in the DicomCacheLocker
4cdc875510d1 ServerContext::DecodeDicomFrame()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3913
diff changeset
1837 std::string dicomContent;
4cdc875510d1 ServerContext::DecodeDicomFrame()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3913
diff changeset
1838 ReadDicom(dicomContent, publicId);
4265
f9eaf14d3d19 Fix decoding sequence if "BuiltinDecoderTranscoderOrder" is "Before"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4218
diff changeset
1839
f9eaf14d3d19 Fix decoding sequence if "BuiltinDecoderTranscoderOrder" is "Before"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4218
diff changeset
1840 std::unique_ptr<ImageAccessor> decoded;
f9eaf14d3d19 Fix decoding sequence if "BuiltinDecoderTranscoderOrder" is "Before"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4218
diff changeset
1841 try
f9eaf14d3d19 Fix decoding sequence if "BuiltinDecoderTranscoderOrder" is "Before"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4218
diff changeset
1842 {
f9eaf14d3d19 Fix decoding sequence if "BuiltinDecoderTranscoderOrder" is "Before"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4218
diff changeset
1843 decoded.reset(GetPlugins().Decode(dicomContent.c_str(), dicomContent.size(), frameIndex));
f9eaf14d3d19 Fix decoding sequence if "BuiltinDecoderTranscoderOrder" is "Before"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4218
diff changeset
1844 }
f9eaf14d3d19 Fix decoding sequence if "BuiltinDecoderTranscoderOrder" is "Before"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4218
diff changeset
1845 catch (OrthancException& e)
f9eaf14d3d19 Fix decoding sequence if "BuiltinDecoderTranscoderOrder" is "Before"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4218
diff changeset
1846 {
f9eaf14d3d19 Fix decoding sequence if "BuiltinDecoderTranscoderOrder" is "Before"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4218
diff changeset
1847 }
f9eaf14d3d19 Fix decoding sequence if "BuiltinDecoderTranscoderOrder" is "Before"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4218
diff changeset
1848
3928
4cdc875510d1 ServerContext::DecodeDicomFrame()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3913
diff changeset
1849 if (decoded.get() != NULL)
4cdc875510d1 ServerContext::DecodeDicomFrame()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3913
diff changeset
1850 {
4cdc875510d1 ServerContext::DecodeDicomFrame()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3913
diff changeset
1851 return decoded.release();
4cdc875510d1 ServerContext::DecodeDicomFrame()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3913
diff changeset
1852 }
3931
e6606d3ec892 new configuration option: BuiltinDecoderTranscoderOrder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3930
diff changeset
1853 else if (builtinDecoderTranscoderOrder_ == BuiltinDecoderTranscoderOrder_After)
3928
4cdc875510d1 ServerContext::DecodeDicomFrame()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3913
diff changeset
1854 {
4cdc875510d1 ServerContext::DecodeDicomFrame()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3913
diff changeset
1855 LOG(INFO) << "The installed image decoding plugins cannot handle an image, "
3930
b99acc213937 transcoder plugins and GDCM transcoding are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3928
diff changeset
1856 << "fallback to the built-in DCMTK decoder";
3928
4cdc875510d1 ServerContext::DecodeDicomFrame()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3913
diff changeset
1857 }
4cdc875510d1 ServerContext::DecodeDicomFrame()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3913
diff changeset
1858 }
4cdc875510d1 ServerContext::DecodeDicomFrame()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3913
diff changeset
1859 #endif
4cdc875510d1 ServerContext::DecodeDicomFrame()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3913
diff changeset
1860
3931
e6606d3ec892 new configuration option: BuiltinDecoderTranscoderOrder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3930
diff changeset
1861 if (builtinDecoderTranscoderOrder_ == BuiltinDecoderTranscoderOrder_After)
3928
4cdc875510d1 ServerContext::DecodeDicomFrame()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3913
diff changeset
1862 {
4cdc875510d1 ServerContext::DecodeDicomFrame()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3913
diff changeset
1863 ServerContext::DicomCacheLocker locker(*this, publicId);
4203
4d42408da117 improving const-correctness in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4196
diff changeset
1864 return locker.GetDicom().DecodeFrame(frameIndex);
3928
4cdc875510d1 ServerContext::DecodeDicomFrame()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3913
diff changeset
1865 }
3931
e6606d3ec892 new configuration option: BuiltinDecoderTranscoderOrder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3930
diff changeset
1866 else
e6606d3ec892 new configuration option: BuiltinDecoderTranscoderOrder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3930
diff changeset
1867 {
e6606d3ec892 new configuration option: BuiltinDecoderTranscoderOrder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3930
diff changeset
1868 return NULL; // Built-in decoder is disabled
e6606d3ec892 new configuration option: BuiltinDecoderTranscoderOrder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3930
diff changeset
1869 }
3928
4cdc875510d1 ServerContext::DecodeDicomFrame()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3913
diff changeset
1870 }
4cdc875510d1 ServerContext::DecodeDicomFrame()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3913
diff changeset
1871
4cdc875510d1 ServerContext::DecodeDicomFrame()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3913
diff changeset
1872
4cdc875510d1 ServerContext::DecodeDicomFrame()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3913
diff changeset
1873 ImageAccessor* ServerContext::DecodeDicomFrame(const DicomInstanceToStore& dicom,
4cdc875510d1 ServerContext::DecodeDicomFrame()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3913
diff changeset
1874 unsigned int frameIndex)
4cdc875510d1 ServerContext::DecodeDicomFrame()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3913
diff changeset
1875 {
3931
e6606d3ec892 new configuration option: BuiltinDecoderTranscoderOrder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3930
diff changeset
1876 if (builtinDecoderTranscoderOrder_ == BuiltinDecoderTranscoderOrder_Before)
e6606d3ec892 new configuration option: BuiltinDecoderTranscoderOrder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3930
diff changeset
1877 {
4265
f9eaf14d3d19 Fix decoding sequence if "BuiltinDecoderTranscoderOrder" is "Before"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4218
diff changeset
1878 std::unique_ptr<ImageAccessor> decoded;
f9eaf14d3d19 Fix decoding sequence if "BuiltinDecoderTranscoderOrder" is "Before"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4218
diff changeset
1879 try
f9eaf14d3d19 Fix decoding sequence if "BuiltinDecoderTranscoderOrder" is "Before"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4218
diff changeset
1880 {
4507
b4c58795f3a8 widening the use of DicomTransferSyntax enum
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4506
diff changeset
1881 decoded.reset(dicom.DecodeFrame(frameIndex));
4265
f9eaf14d3d19 Fix decoding sequence if "BuiltinDecoderTranscoderOrder" is "Before"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4218
diff changeset
1882 }
f9eaf14d3d19 Fix decoding sequence if "BuiltinDecoderTranscoderOrder" is "Before"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4218
diff changeset
1883 catch (OrthancException& e)
f9eaf14d3d19 Fix decoding sequence if "BuiltinDecoderTranscoderOrder" is "Before"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4218
diff changeset
1884 {
f9eaf14d3d19 Fix decoding sequence if "BuiltinDecoderTranscoderOrder" is "Before"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4218
diff changeset
1885 }
f9eaf14d3d19 Fix decoding sequence if "BuiltinDecoderTranscoderOrder" is "Before"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4218
diff changeset
1886
3931
e6606d3ec892 new configuration option: BuiltinDecoderTranscoderOrder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3930
diff changeset
1887 if (decoded.get() != NULL)
e6606d3ec892 new configuration option: BuiltinDecoderTranscoderOrder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3930
diff changeset
1888 {
e6606d3ec892 new configuration option: BuiltinDecoderTranscoderOrder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3930
diff changeset
1889 return decoded.release();
e6606d3ec892 new configuration option: BuiltinDecoderTranscoderOrder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3930
diff changeset
1890 }
e6606d3ec892 new configuration option: BuiltinDecoderTranscoderOrder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3930
diff changeset
1891 }
3928
4cdc875510d1 ServerContext::DecodeDicomFrame()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3913
diff changeset
1892
4cdc875510d1 ServerContext::DecodeDicomFrame()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3913
diff changeset
1893 #if ORTHANC_ENABLE_PLUGINS == 1
4cdc875510d1 ServerContext::DecodeDicomFrame()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3913
diff changeset
1894 if (HasPlugins() &&
4cdc875510d1 ServerContext::DecodeDicomFrame()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3913
diff changeset
1895 GetPlugins().HasCustomImageDecoder())
4cdc875510d1 ServerContext::DecodeDicomFrame()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3913
diff changeset
1896 {
4265
f9eaf14d3d19 Fix decoding sequence if "BuiltinDecoderTranscoderOrder" is "Before"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4218
diff changeset
1897 std::unique_ptr<ImageAccessor> decoded;
f9eaf14d3d19 Fix decoding sequence if "BuiltinDecoderTranscoderOrder" is "Before"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4218
diff changeset
1898 try
f9eaf14d3d19 Fix decoding sequence if "BuiltinDecoderTranscoderOrder" is "Before"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4218
diff changeset
1899 {
f9eaf14d3d19 Fix decoding sequence if "BuiltinDecoderTranscoderOrder" is "Before"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4218
diff changeset
1900 decoded.reset(GetPlugins().Decode(dicom.GetBufferData(), dicom.GetBufferSize(), frameIndex));
f9eaf14d3d19 Fix decoding sequence if "BuiltinDecoderTranscoderOrder" is "Before"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4218
diff changeset
1901 }
f9eaf14d3d19 Fix decoding sequence if "BuiltinDecoderTranscoderOrder" is "Before"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4218
diff changeset
1902 catch (OrthancException& e)
f9eaf14d3d19 Fix decoding sequence if "BuiltinDecoderTranscoderOrder" is "Before"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4218
diff changeset
1903 {
f9eaf14d3d19 Fix decoding sequence if "BuiltinDecoderTranscoderOrder" is "Before"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4218
diff changeset
1904 }
f9eaf14d3d19 Fix decoding sequence if "BuiltinDecoderTranscoderOrder" is "Before"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4218
diff changeset
1905
3928
4cdc875510d1 ServerContext::DecodeDicomFrame()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3913
diff changeset
1906 if (decoded.get() != NULL)
4cdc875510d1 ServerContext::DecodeDicomFrame()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3913
diff changeset
1907 {
4cdc875510d1 ServerContext::DecodeDicomFrame()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3913
diff changeset
1908 return decoded.release();
4cdc875510d1 ServerContext::DecodeDicomFrame()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3913
diff changeset
1909 }
3931
e6606d3ec892 new configuration option: BuiltinDecoderTranscoderOrder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3930
diff changeset
1910 else if (builtinDecoderTranscoderOrder_ == BuiltinDecoderTranscoderOrder_After)
3928
4cdc875510d1 ServerContext::DecodeDicomFrame()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3913
diff changeset
1911 {
4cdc875510d1 ServerContext::DecodeDicomFrame()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3913
diff changeset
1912 LOG(INFO) << "The installed image decoding plugins cannot handle an image, "
3930
b99acc213937 transcoder plugins and GDCM transcoding are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3928
diff changeset
1913 << "fallback to the built-in DCMTK decoder";
3928
4cdc875510d1 ServerContext::DecodeDicomFrame()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3913
diff changeset
1914 }
4cdc875510d1 ServerContext::DecodeDicomFrame()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3913
diff changeset
1915 }
4cdc875510d1 ServerContext::DecodeDicomFrame()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3913
diff changeset
1916 #endif
4cdc875510d1 ServerContext::DecodeDicomFrame()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3913
diff changeset
1917
3931
e6606d3ec892 new configuration option: BuiltinDecoderTranscoderOrder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3930
diff changeset
1918 if (builtinDecoderTranscoderOrder_ == BuiltinDecoderTranscoderOrder_After)
e6606d3ec892 new configuration option: BuiltinDecoderTranscoderOrder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3930
diff changeset
1919 {
4507
b4c58795f3a8 widening the use of DicomTransferSyntax enum
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4506
diff changeset
1920 return dicom.DecodeFrame(frameIndex);
3931
e6606d3ec892 new configuration option: BuiltinDecoderTranscoderOrder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3930
diff changeset
1921 }
e6606d3ec892 new configuration option: BuiltinDecoderTranscoderOrder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3930
diff changeset
1922 else
e6606d3ec892 new configuration option: BuiltinDecoderTranscoderOrder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3930
diff changeset
1923 {
e6606d3ec892 new configuration option: BuiltinDecoderTranscoderOrder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3930
diff changeset
1924 return NULL;
e6606d3ec892 new configuration option: BuiltinDecoderTranscoderOrder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3930
diff changeset
1925 }
3928
4cdc875510d1 ServerContext::DecodeDicomFrame()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3913
diff changeset
1926 }
4cdc875510d1 ServerContext::DecodeDicomFrame()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3913
diff changeset
1927
4cdc875510d1 ServerContext::DecodeDicomFrame()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3913
diff changeset
1928
3980
e42f5445d20d Fix decoding of DICOM images for plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3951
diff changeset
1929 ImageAccessor* ServerContext::DecodeDicomFrame(const void* dicom,
e42f5445d20d Fix decoding of DICOM images for plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3951
diff changeset
1930 size_t size,
e42f5445d20d Fix decoding of DICOM images for plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3951
diff changeset
1931 unsigned int frameIndex)
e42f5445d20d Fix decoding of DICOM images for plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3951
diff changeset
1932 {
4508
8f9090b137f1 Optimization in C-STORE SCP by avoiding an unnecessary DICOM parsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4507
diff changeset
1933 std::unique_ptr<DicomInstanceToStore> instance(DicomInstanceToStore::CreateFromBuffer(dicom, size));
8f9090b137f1 Optimization in C-STORE SCP by avoiding an unnecessary DICOM parsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4507
diff changeset
1934 return DecodeDicomFrame(*instance, frameIndex);
3980
e42f5445d20d Fix decoding of DICOM images for plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3951
diff changeset
1935 }
e42f5445d20d Fix decoding of DICOM images for plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3951
diff changeset
1936
e42f5445d20d Fix decoding of DICOM images for plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3951
diff changeset
1937
3894
8f7ad4989fec transcoding to uncompressed transfer syntaxes over DICOM protocol is implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3839
diff changeset
1938 void ServerContext::StoreWithTranscoding(std::string& sopClassUid,
8f7ad4989fec transcoding to uncompressed transfer syntaxes over DICOM protocol is implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3839
diff changeset
1939 std::string& sopInstanceUid,
8f7ad4989fec transcoding to uncompressed transfer syntaxes over DICOM protocol is implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3839
diff changeset
1940 DicomStoreUserConnection& connection,
8f7ad4989fec transcoding to uncompressed transfer syntaxes over DICOM protocol is implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3839
diff changeset
1941 const std::string& dicom,
8f7ad4989fec transcoding to uncompressed transfer syntaxes over DICOM protocol is implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3839
diff changeset
1942 bool hasMoveOriginator,
8f7ad4989fec transcoding to uncompressed transfer syntaxes over DICOM protocol is implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3839
diff changeset
1943 const std::string& moveOriginatorAet,
8f7ad4989fec transcoding to uncompressed transfer syntaxes over DICOM protocol is implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3839
diff changeset
1944 uint16_t moveOriginatorId)
8f7ad4989fec transcoding to uncompressed transfer syntaxes over DICOM protocol is implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3839
diff changeset
1945 {
8f7ad4989fec transcoding to uncompressed transfer syntaxes over DICOM protocol is implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3839
diff changeset
1946 const void* data = dicom.empty() ? NULL : dicom.c_str();
8f7ad4989fec transcoding to uncompressed transfer syntaxes over DICOM protocol is implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3839
diff changeset
1947
3911
0ef7f4528be2 renamed option TranscodingEnabled to TranscodeDicomProtocol
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3910
diff changeset
1948 if (!transcodeDicomProtocol_ ||
3894
8f7ad4989fec transcoding to uncompressed transfer syntaxes over DICOM protocol is implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3839
diff changeset
1949 !connection.GetParameters().GetRemoteModality().IsTranscodingAllowed())
8f7ad4989fec transcoding to uncompressed transfer syntaxes over DICOM protocol is implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3839
diff changeset
1950 {
8f7ad4989fec transcoding to uncompressed transfer syntaxes over DICOM protocol is implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3839
diff changeset
1951 connection.Store(sopClassUid, sopInstanceUid, data, dicom.size(),
8f7ad4989fec transcoding to uncompressed transfer syntaxes over DICOM protocol is implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3839
diff changeset
1952 hasMoveOriginator, moveOriginatorAet, moveOriginatorId);
8f7ad4989fec transcoding to uncompressed transfer syntaxes over DICOM protocol is implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3839
diff changeset
1953 }
8f7ad4989fec transcoding to uncompressed transfer syntaxes over DICOM protocol is implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3839
diff changeset
1954 else
8f7ad4989fec transcoding to uncompressed transfer syntaxes over DICOM protocol is implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3839
diff changeset
1955 {
4465
fe774d8e904b New configuration option: "DicomScuPreferredTransferSyntax" to control transcoding in C-STORE SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4460
diff changeset
1956 connection.Transcode(sopClassUid, sopInstanceUid, *this, data, dicom.size(), preferredTransferSyntax_,
3912
7610af1532c3 prototyping automated transcoding of incoming DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3911
diff changeset
1957 hasMoveOriginator, moveOriginatorAet, moveOriginatorId);
3894
8f7ad4989fec transcoding to uncompressed transfer syntaxes over DICOM protocol is implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3839
diff changeset
1958 }
8f7ad4989fec transcoding to uncompressed transfer syntaxes over DICOM protocol is implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3839
diff changeset
1959 }
3930
b99acc213937 transcoder plugins and GDCM transcoding are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3928
diff changeset
1960
b99acc213937 transcoder plugins and GDCM transcoding are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3928
diff changeset
1961
5426
c65e036d649b StorageCache is now storing transcoded instances + added ?transcode=... option to the /file route.
Alain Mazy <am@osimis.io>
parents: 5420
diff changeset
1962 bool ServerContext::TranscodeWithCache(std::string& target,
c65e036d649b StorageCache is now storing transcoded instances + added ?transcode=... option to the /file route.
Alain Mazy <am@osimis.io>
parents: 5420
diff changeset
1963 const std::string& source,
c65e036d649b StorageCache is now storing transcoded instances + added ?transcode=... option to the /file route.
Alain Mazy <am@osimis.io>
parents: 5420
diff changeset
1964 const std::string& sourceInstanceId,
5427
111e21b4f8bc fix transcoded instance caching
Alain Mazy <am@osimis.io>
parents: 5426
diff changeset
1965 const std::string& attachmentId,
5426
c65e036d649b StorageCache is now storing transcoded instances + added ?transcode=... option to the /file route.
Alain Mazy <am@osimis.io>
parents: 5420
diff changeset
1966 DicomTransferSyntax targetSyntax)
c65e036d649b StorageCache is now storing transcoded instances + added ?transcode=... option to the /file route.
Alain Mazy <am@osimis.io>
parents: 5420
diff changeset
1967 {
c65e036d649b StorageCache is now storing transcoded instances + added ?transcode=... option to the /file route.
Alain Mazy <am@osimis.io>
parents: 5420
diff changeset
1968 StorageCache::Accessor cacheAccessor(storageCache_);
c65e036d649b StorageCache is now storing transcoded instances + added ?transcode=... option to the /file route.
Alain Mazy <am@osimis.io>
parents: 5420
diff changeset
1969
5427
111e21b4f8bc fix transcoded instance caching
Alain Mazy <am@osimis.io>
parents: 5426
diff changeset
1970 if (!cacheAccessor.FetchTranscodedInstance(target, attachmentId, targetSyntax))
5426
c65e036d649b StorageCache is now storing transcoded instances + added ?transcode=... option to the /file route.
Alain Mazy <am@osimis.io>
parents: 5420
diff changeset
1971 {
c65e036d649b StorageCache is now storing transcoded instances + added ?transcode=... option to the /file route.
Alain Mazy <am@osimis.io>
parents: 5420
diff changeset
1972 IDicomTranscoder::DicomImage sourceDicom;
c65e036d649b StorageCache is now storing transcoded instances + added ?transcode=... option to the /file route.
Alain Mazy <am@osimis.io>
parents: 5420
diff changeset
1973 sourceDicom.SetExternalBuffer(source);
c65e036d649b StorageCache is now storing transcoded instances + added ?transcode=... option to the /file route.
Alain Mazy <am@osimis.io>
parents: 5420
diff changeset
1974
c65e036d649b StorageCache is now storing transcoded instances + added ?transcode=... option to the /file route.
Alain Mazy <am@osimis.io>
parents: 5420
diff changeset
1975 IDicomTranscoder::DicomImage targetDicom;
c65e036d649b StorageCache is now storing transcoded instances + added ?transcode=... option to the /file route.
Alain Mazy <am@osimis.io>
parents: 5420
diff changeset
1976 std::set<DicomTransferSyntax> syntaxes;
c65e036d649b StorageCache is now storing transcoded instances + added ?transcode=... option to the /file route.
Alain Mazy <am@osimis.io>
parents: 5420
diff changeset
1977 syntaxes.insert(targetSyntax);
c65e036d649b StorageCache is now storing transcoded instances + added ?transcode=... option to the /file route.
Alain Mazy <am@osimis.io>
parents: 5420
diff changeset
1978
c65e036d649b StorageCache is now storing transcoded instances + added ?transcode=... option to the /file route.
Alain Mazy <am@osimis.io>
parents: 5420
diff changeset
1979 if (Transcode(targetDicom, sourceDicom, syntaxes, true))
c65e036d649b StorageCache is now storing transcoded instances + added ?transcode=... option to the /file route.
Alain Mazy <am@osimis.io>
parents: 5420
diff changeset
1980 {
5427
111e21b4f8bc fix transcoded instance caching
Alain Mazy <am@osimis.io>
parents: 5426
diff changeset
1981 cacheAccessor.AddTranscodedInstance(attachmentId, targetSyntax, reinterpret_cast<const char*>(targetDicom.GetBufferData()), targetDicom.GetBufferSize());
5426
c65e036d649b StorageCache is now storing transcoded instances + added ?transcode=... option to the /file route.
Alain Mazy <am@osimis.io>
parents: 5420
diff changeset
1982 target = std::string(reinterpret_cast<const char*>(targetDicom.GetBufferData()), targetDicom.GetBufferSize());
c65e036d649b StorageCache is now storing transcoded instances + added ?transcode=... option to the /file route.
Alain Mazy <am@osimis.io>
parents: 5420
diff changeset
1983 return true;
c65e036d649b StorageCache is now storing transcoded instances + added ?transcode=... option to the /file route.
Alain Mazy <am@osimis.io>
parents: 5420
diff changeset
1984 }
c65e036d649b StorageCache is now storing transcoded instances + added ?transcode=... option to the /file route.
Alain Mazy <am@osimis.io>
parents: 5420
diff changeset
1985
c65e036d649b StorageCache is now storing transcoded instances + added ?transcode=... option to the /file route.
Alain Mazy <am@osimis.io>
parents: 5420
diff changeset
1986 return false;
c65e036d649b StorageCache is now storing transcoded instances + added ?transcode=... option to the /file route.
Alain Mazy <am@osimis.io>
parents: 5420
diff changeset
1987 }
c65e036d649b StorageCache is now storing transcoded instances + added ?transcode=... option to the /file route.
Alain Mazy <am@osimis.io>
parents: 5420
diff changeset
1988
c65e036d649b StorageCache is now storing transcoded instances + added ?transcode=... option to the /file route.
Alain Mazy <am@osimis.io>
parents: 5420
diff changeset
1989 return true;
c65e036d649b StorageCache is now storing transcoded instances + added ?transcode=... option to the /file route.
Alain Mazy <am@osimis.io>
parents: 5420
diff changeset
1990 }
c65e036d649b StorageCache is now storing transcoded instances + added ?transcode=... option to the /file route.
Alain Mazy <am@osimis.io>
parents: 5420
diff changeset
1991
c65e036d649b StorageCache is now storing transcoded instances + added ?transcode=... option to the /file route.
Alain Mazy <am@osimis.io>
parents: 5420
diff changeset
1992
3944
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3941
diff changeset
1993 bool ServerContext::Transcode(DicomImage& target,
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3941
diff changeset
1994 DicomImage& source /* in, "GetParsed()" possibly modified */,
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3941
diff changeset
1995 const std::set<DicomTransferSyntax>& allowedSyntaxes,
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3941
diff changeset
1996 bool allowNewSopInstanceUid)
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3941
diff changeset
1997 {
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3941
diff changeset
1998 if (builtinDecoderTranscoderOrder_ == BuiltinDecoderTranscoderOrder_Before)
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3941
diff changeset
1999 {
3951
5fe8c6d3212e removed useless information "hasSopInstanceUidChanged"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3947
diff changeset
2000 if (dcmtkTranscoder_->Transcode(target, source, allowedSyntaxes, allowNewSopInstanceUid))
3944
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3941
diff changeset
2001 {
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3941
diff changeset
2002 return true;
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3941
diff changeset
2003 }
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3941
diff changeset
2004 }
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3941
diff changeset
2005
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3941
diff changeset
2006 #if ORTHANC_ENABLE_PLUGINS == 1
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3941
diff changeset
2007 if (HasPlugins() &&
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3941
diff changeset
2008 GetPlugins().HasCustomTranscoder())
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3941
diff changeset
2009 {
3951
5fe8c6d3212e removed useless information "hasSopInstanceUidChanged"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3947
diff changeset
2010 if (GetPlugins().Transcode(target, source, allowedSyntaxes, allowNewSopInstanceUid))
3944
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3941
diff changeset
2011 {
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3941
diff changeset
2012 return true;
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3941
diff changeset
2013 }
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3941
diff changeset
2014 else if (builtinDecoderTranscoderOrder_ == BuiltinDecoderTranscoderOrder_After)
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3941
diff changeset
2015 {
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3941
diff changeset
2016 LOG(INFO) << "The installed transcoding plugins cannot handle an image, "
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3941
diff changeset
2017 << "fallback to the built-in DCMTK transcoder";
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3941
diff changeset
2018 }
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3941
diff changeset
2019 }
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3941
diff changeset
2020 #endif
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3941
diff changeset
2021
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3941
diff changeset
2022 if (builtinDecoderTranscoderOrder_ == BuiltinDecoderTranscoderOrder_After)
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3941
diff changeset
2023 {
3951
5fe8c6d3212e removed useless information "hasSopInstanceUidChanged"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3947
diff changeset
2024 return dcmtkTranscoder_->Transcode(target, source, allowedSyntaxes, allowNewSopInstanceUid);
3944
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3941
diff changeset
2025 }
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3941
diff changeset
2026 else
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3941
diff changeset
2027 {
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3941
diff changeset
2028 return false;
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3941
diff changeset
2029 }
aae045f802f4 preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3941
diff changeset
2030 }
4375
208029732d51 New config option "DeidentifyDimseQueryLogs"
Mark Poscablo <Mark.Poscablo@varian.com>
parents: 4274
diff changeset
2031
4376
b002f9abe802 review of changeset 4375:208029732d51
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4375
diff changeset
2032 const std::string& ServerContext::GetDeidentifiedContent(const DicomElement &element) const
4375
208029732d51 New config option "DeidentifyDimseQueryLogs"
Mark Poscablo <Mark.Poscablo@varian.com>
parents: 4274
diff changeset
2033 {
208029732d51 New config option "DeidentifyDimseQueryLogs"
Mark Poscablo <Mark.Poscablo@varian.com>
parents: 4274
diff changeset
2034 static const std::string redactedContent = "*** POTENTIAL PHI ***";
5044
6fed78e13233 Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents: 5043
diff changeset
2035 static const std::string emptyContent = "";
4375
208029732d51 New config option "DeidentifyDimseQueryLogs"
Mark Poscablo <Mark.Poscablo@varian.com>
parents: 4274
diff changeset
2036
208029732d51 New config option "DeidentifyDimseQueryLogs"
Mark Poscablo <Mark.Poscablo@varian.com>
parents: 4274
diff changeset
2037 const DicomTag& tag = element.GetTag();
5044
6fed78e13233 Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents: 5043
diff changeset
2038 if (element.GetValue().IsSequence())
6fed78e13233 Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents: 5043
diff changeset
2039 {
6fed78e13233 Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents: 5043
diff changeset
2040 return emptyContent;
6fed78e13233 Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents: 5043
diff changeset
2041 }
6fed78e13233 Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents: 5043
diff changeset
2042
4789
51ec061516c9 Fix handling of option "DeidentifyLogs", notably for tags (0010,0010) and (0010,0020)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4752
diff changeset
2043 if (deidentifyLogs_ &&
51ec061516c9 Fix handling of option "DeidentifyLogs", notably for tags (0010,0010) and (0010,0020)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4752
diff changeset
2044 !element.GetValue().GetContent().empty() &&
51ec061516c9 Fix handling of option "DeidentifyLogs", notably for tags (0010,0010) and (0010,0020)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4752
diff changeset
2045 logsDeidentifierRules_.IsAlteredTag(tag))
4375
208029732d51 New config option "DeidentifyDimseQueryLogs"
Mark Poscablo <Mark.Poscablo@varian.com>
parents: 4274
diff changeset
2046 {
208029732d51 New config option "DeidentifyDimseQueryLogs"
Mark Poscablo <Mark.Poscablo@varian.com>
parents: 4274
diff changeset
2047 return redactedContent;
208029732d51 New config option "DeidentifyDimseQueryLogs"
Mark Poscablo <Mark.Poscablo@varian.com>
parents: 4274
diff changeset
2048 }
208029732d51 New config option "DeidentifyDimseQueryLogs"
Mark Poscablo <Mark.Poscablo@varian.com>
parents: 4274
diff changeset
2049 else
208029732d51 New config option "DeidentifyDimseQueryLogs"
Mark Poscablo <Mark.Poscablo@varian.com>
parents: 4274
diff changeset
2050 {
208029732d51 New config option "DeidentifyDimseQueryLogs"
Mark Poscablo <Mark.Poscablo@varian.com>
parents: 4274
diff changeset
2051 return element.GetValue().GetContent();
208029732d51 New config option "DeidentifyDimseQueryLogs"
Mark Poscablo <Mark.Poscablo@varian.com>
parents: 4274
diff changeset
2052 }
208029732d51 New config option "DeidentifyDimseQueryLogs"
Mark Poscablo <Mark.Poscablo@varian.com>
parents: 4274
diff changeset
2053 }
4473
68f52897c119 new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4465
diff changeset
2054
68f52897c119 new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4465
diff changeset
2055
68f52897c119 new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4465
diff changeset
2056 void ServerContext::GetAcceptedTransferSyntaxes(std::set<DicomTransferSyntax>& syntaxes)
68f52897c119 new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4465
diff changeset
2057 {
68f52897c119 new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4465
diff changeset
2058 boost::mutex::scoped_lock lock(dynamicOptionsMutex_);
68f52897c119 new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4465
diff changeset
2059 syntaxes = acceptedTransferSyntaxes_;
68f52897c119 new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4465
diff changeset
2060 }
68f52897c119 new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4465
diff changeset
2061
68f52897c119 new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4465
diff changeset
2062
68f52897c119 new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4465
diff changeset
2063 void ServerContext::SetAcceptedTransferSyntaxes(const std::set<DicomTransferSyntax>& syntaxes)
68f52897c119 new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4465
diff changeset
2064 {
68f52897c119 new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4465
diff changeset
2065 boost::mutex::scoped_lock lock(dynamicOptionsMutex_);
68f52897c119 new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4465
diff changeset
2066 acceptedTransferSyntaxes_ = syntaxes;
68f52897c119 new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4465
diff changeset
2067 }
68f52897c119 new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4465
diff changeset
2068
68f52897c119 new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4465
diff changeset
2069
68f52897c119 new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4465
diff changeset
2070 bool ServerContext::IsUnknownSopClassAccepted()
68f52897c119 new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4465
diff changeset
2071 {
68f52897c119 new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4465
diff changeset
2072 boost::mutex::scoped_lock lock(dynamicOptionsMutex_);
68f52897c119 new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4465
diff changeset
2073 return isUnknownSopClassAccepted_;
68f52897c119 new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4465
diff changeset
2074 }
68f52897c119 new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4465
diff changeset
2075
68f52897c119 new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4465
diff changeset
2076
68f52897c119 new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4465
diff changeset
2077 void ServerContext::SetUnknownSopClassAccepted(bool accepted)
68f52897c119 new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4465
diff changeset
2078 {
68f52897c119 new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4465
diff changeset
2079 boost::mutex::scoped_lock lock(dynamicOptionsMutex_);
68f52897c119 new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4465
diff changeset
2080 isUnknownSopClassAccepted_ = accepted;
68f52897c119 new URIs: /tools/accepted-transfer-syntaxes and /tools/unknown-sop-class-accepted to replace Lua callbacks for transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4465
diff changeset
2081 }
4935
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4921
diff changeset
2082
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4921
diff changeset
2083
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4921
diff changeset
2084 static void SerializeExpandedResource(Json::Value& target,
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4921
diff changeset
2085 const ExpandedResource& resource,
4936
8422e4f99a18 Handling RequestedTags in ExpandResource -> read parent main dicom tags if required. Not yet getting missing tags from file. Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4935
diff changeset
2086 DicomToJsonFormat format,
8422e4f99a18 Handling RequestedTags in ExpandResource -> read parent main dicom tags if required. Not yet getting missing tags from file. Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4935
diff changeset
2087 const std::set<DicomTag>& requestedTags)
4935
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4921
diff changeset
2088 {
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4921
diff changeset
2089 target = Json::objectValue;
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4921
diff changeset
2090
5222
3a61fd50f804 starting refactoring ExpandedResource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5221
diff changeset
2091 target["Type"] = GetResourceTypeText(resource.GetLevel(), false, true);
3a61fd50f804 starting refactoring ExpandedResource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5221
diff changeset
2092 target["ID"] = resource.GetPublicId();
4935
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4921
diff changeset
2093
5222
3a61fd50f804 starting refactoring ExpandedResource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5221
diff changeset
2094 switch (resource.GetLevel())
4935
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4921
diff changeset
2095 {
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4921
diff changeset
2096 case ResourceType_Patient:
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4921
diff changeset
2097 break;
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4921
diff changeset
2098
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4921
diff changeset
2099 case ResourceType_Study:
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4921
diff changeset
2100 target["ParentPatient"] = resource.parentId_;
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4921
diff changeset
2101 break;
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4921
diff changeset
2102
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4921
diff changeset
2103 case ResourceType_Series:
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4921
diff changeset
2104 target["ParentStudy"] = resource.parentId_;
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4921
diff changeset
2105 break;
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4921
diff changeset
2106
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4921
diff changeset
2107 case ResourceType_Instance:
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4921
diff changeset
2108 target["ParentSeries"] = resource.parentId_;
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4921
diff changeset
2109 break;
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4921
diff changeset
2110
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4921
diff changeset
2111 default:
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4921
diff changeset
2112 throw OrthancException(ErrorCode_InternalError);
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4921
diff changeset
2113 }
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4921
diff changeset
2114
5222
3a61fd50f804 starting refactoring ExpandedResource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5221
diff changeset
2115 switch (resource.GetLevel())
4935
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4921
diff changeset
2116 {
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4921
diff changeset
2117 case ResourceType_Patient:
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4921
diff changeset
2118 case ResourceType_Study:
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4921
diff changeset
2119 case ResourceType_Series:
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4921
diff changeset
2120 {
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4921
diff changeset
2121 Json::Value c = Json::arrayValue;
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4921
diff changeset
2122
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4921
diff changeset
2123 for (std::list<std::string>::const_iterator
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4921
diff changeset
2124 it = resource.childrenIds_.begin(); it != resource.childrenIds_.end(); ++it)
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4921
diff changeset
2125 {
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4921
diff changeset
2126 c.append(*it);
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4921
diff changeset
2127 }
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4921
diff changeset
2128
5222
3a61fd50f804 starting refactoring ExpandedResource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5221
diff changeset
2129 if (resource.GetLevel() == ResourceType_Patient)
4935
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4921
diff changeset
2130 {
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4921
diff changeset
2131 target["Studies"] = c;
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4921
diff changeset
2132 }
5222
3a61fd50f804 starting refactoring ExpandedResource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5221
diff changeset
2133 else if (resource.GetLevel() == ResourceType_Study)
4935
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4921
diff changeset
2134 {
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4921
diff changeset
2135 target["Series"] = c;
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4921
diff changeset
2136 }
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4921
diff changeset
2137 else
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4921
diff changeset
2138 {
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4921
diff changeset
2139 target["Instances"] = c;
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4921
diff changeset
2140 }
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4921
diff changeset
2141 break;
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4921
diff changeset
2142 }
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4921
diff changeset
2143
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4921
diff changeset
2144 case ResourceType_Instance:
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4921
diff changeset
2145 break;
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4921
diff changeset
2146
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4921
diff changeset
2147 default:
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4921
diff changeset
2148 throw OrthancException(ErrorCode_InternalError);
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4921
diff changeset
2149 }
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4921
diff changeset
2150
5222
3a61fd50f804 starting refactoring ExpandedResource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5221
diff changeset
2151 switch (resource.GetLevel())
4935
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4921
diff changeset
2152 {
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4921
diff changeset
2153 case ResourceType_Patient:
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4921
diff changeset
2154 case ResourceType_Study:
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4921
diff changeset
2155 break;
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4921
diff changeset
2156
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4921
diff changeset
2157 case ResourceType_Series:
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4921
diff changeset
2158 if (resource.expectedNumberOfInstances_ < 0)
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4921
diff changeset
2159 {
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4921
diff changeset
2160 target["ExpectedNumberOfInstances"] = Json::nullValue;
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4921
diff changeset
2161 }
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4921
diff changeset
2162 else
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4921
diff changeset
2163 {
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4921
diff changeset
2164 target["ExpectedNumberOfInstances"] = resource.expectedNumberOfInstances_;
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4921
diff changeset
2165 }
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4921
diff changeset
2166 target["Status"] = resource.status_;
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4921
diff changeset
2167 break;
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4921
diff changeset
2168
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4921
diff changeset
2169 case ResourceType_Instance:
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4921
diff changeset
2170 {
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4921
diff changeset
2171 target["FileSize"] = static_cast<unsigned int>(resource.fileSize_);
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4921
diff changeset
2172 target["FileUuid"] = resource.fileUuid_;
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4921
diff changeset
2173
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4921
diff changeset
2174 if (resource.indexInSeries_ < 0)
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4921
diff changeset
2175 {
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4921
diff changeset
2176 target["IndexInSeries"] = Json::nullValue;
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4921
diff changeset
2177 }
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4921
diff changeset
2178 else
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4921
diff changeset
2179 {
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4921
diff changeset
2180 target["IndexInSeries"] = resource.indexInSeries_;
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4921
diff changeset
2181 }
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4921
diff changeset
2182
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4921
diff changeset
2183 break;
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4921
diff changeset
2184 }
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4921
diff changeset
2185
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4921
diff changeset
2186 default:
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4921
diff changeset
2187 throw OrthancException(ErrorCode_InternalError);
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4921
diff changeset
2188 }
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4921
diff changeset
2189
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4921
diff changeset
2190 if (!resource.anonymizedFrom_.empty())
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4921
diff changeset
2191 {
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4921
diff changeset
2192 target["AnonymizedFrom"] = resource.anonymizedFrom_;
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4921
diff changeset
2193 }
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4921
diff changeset
2194
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4921
diff changeset
2195 if (!resource.modifiedFrom_.empty())
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4921
diff changeset
2196 {
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4921
diff changeset
2197 target["ModifiedFrom"] = resource.modifiedFrom_;
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4921
diff changeset
2198 }
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4921
diff changeset
2199
5222
3a61fd50f804 starting refactoring ExpandedResource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5221
diff changeset
2200 if (resource.GetLevel() == ResourceType_Patient ||
3a61fd50f804 starting refactoring ExpandedResource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5221
diff changeset
2201 resource.GetLevel() == ResourceType_Study ||
3a61fd50f804 starting refactoring ExpandedResource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5221
diff changeset
2202 resource.GetLevel() == ResourceType_Series)
4935
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4921
diff changeset
2203 {
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4921
diff changeset
2204 target["IsStable"] = resource.isStable_;
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4921
diff changeset
2205
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4921
diff changeset
2206 if (!resource.lastUpdate_.empty())
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4921
diff changeset
2207 {
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4921
diff changeset
2208 target["LastUpdate"] = resource.lastUpdate_;
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4921
diff changeset
2209 }
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4921
diff changeset
2210 }
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4921
diff changeset
2211
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4921
diff changeset
2212 // serialize tags
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4921
diff changeset
2213
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4921
diff changeset
2214 static const char* const MAIN_DICOM_TAGS = "MainDicomTags";
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4921
diff changeset
2215 static const char* const PATIENT_MAIN_DICOM_TAGS = "PatientMainDicomTags";
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4921
diff changeset
2216
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4921
diff changeset
2217 DicomMap mainDicomTags;
5222
3a61fd50f804 starting refactoring ExpandedResource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5221
diff changeset
2218 resource.GetMainDicomTags().ExtractResourceInformation(mainDicomTags, resource.GetLevel());
4935
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4921
diff changeset
2219
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4921
diff changeset
2220 target[MAIN_DICOM_TAGS] = Json::objectValue;
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4921
diff changeset
2221 FromDcmtkBridge::ToJson(target[MAIN_DICOM_TAGS], mainDicomTags, format);
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4921
diff changeset
2222
5222
3a61fd50f804 starting refactoring ExpandedResource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5221
diff changeset
2223 if (resource.GetLevel() == ResourceType_Study)
4935
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4921
diff changeset
2224 {
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4921
diff changeset
2225 DicomMap patientMainDicomTags;
5222
3a61fd50f804 starting refactoring ExpandedResource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5221
diff changeset
2226 resource.GetMainDicomTags().ExtractPatientInformation(patientMainDicomTags);
4935
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4921
diff changeset
2227
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4921
diff changeset
2228 target[PATIENT_MAIN_DICOM_TAGS] = Json::objectValue;
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4921
diff changeset
2229 FromDcmtkBridge::ToJson(target[PATIENT_MAIN_DICOM_TAGS], patientMainDicomTags, format);
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4921
diff changeset
2230 }
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4921
diff changeset
2231
4936
8422e4f99a18 Handling RequestedTags in ExpandResource -> read parent main dicom tags if required. Not yet getting missing tags from file. Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4935
diff changeset
2232 if (requestedTags.size() > 0)
8422e4f99a18 Handling RequestedTags in ExpandResource -> read parent main dicom tags if required. Not yet getting missing tags from file. Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4935
diff changeset
2233 {
8422e4f99a18 Handling RequestedTags in ExpandResource -> read parent main dicom tags if required. Not yet getting missing tags from file. Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4935
diff changeset
2234 static const char* const REQUESTED_TAGS = "RequestedTags";
8422e4f99a18 Handling RequestedTags in ExpandResource -> read parent main dicom tags if required. Not yet getting missing tags from file. Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4935
diff changeset
2235
8422e4f99a18 Handling RequestedTags in ExpandResource -> read parent main dicom tags if required. Not yet getting missing tags from file. Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4935
diff changeset
2236 DicomMap tags;
5222
3a61fd50f804 starting refactoring ExpandedResource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5221
diff changeset
2237 resource.GetMainDicomTags().ExtractTags(tags, requestedTags);
4936
8422e4f99a18 Handling RequestedTags in ExpandResource -> read parent main dicom tags if required. Not yet getting missing tags from file. Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4935
diff changeset
2238
8422e4f99a18 Handling RequestedTags in ExpandResource -> read parent main dicom tags if required. Not yet getting missing tags from file. Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4935
diff changeset
2239 target[REQUESTED_TAGS] = Json::objectValue;
8422e4f99a18 Handling RequestedTags in ExpandResource -> read parent main dicom tags if required. Not yet getting missing tags from file. Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4935
diff changeset
2240 FromDcmtkBridge::ToJson(target[REQUESTED_TAGS], tags, format);
5036
877bc3b96476 Handle Dicom sequences in ExtraMainDicomTags and save them in the 'MainDicomSequences' metadata
Alain Mazy <am@osimis.io>
parents: 4994
diff changeset
2241
4936
8422e4f99a18 Handling RequestedTags in ExpandResource -> read parent main dicom tags if required. Not yet getting missing tags from file. Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4935
diff changeset
2242 }
8422e4f99a18 Handling RequestedTags in ExpandResource -> read parent main dicom tags if required. Not yet getting missing tags from file. Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4935
diff changeset
2243
5221
d0f7c742d397 started implementation of labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5220
diff changeset
2244 {
d0f7c742d397 started implementation of labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5220
diff changeset
2245 Json::Value labels = Json::arrayValue;
d0f7c742d397 started implementation of labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5220
diff changeset
2246
d0f7c742d397 started implementation of labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5220
diff changeset
2247 for (std::set<std::string>::const_iterator it = resource.labels_.begin(); it != resource.labels_.end(); ++it)
d0f7c742d397 started implementation of labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5220
diff changeset
2248 {
d0f7c742d397 started implementation of labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5220
diff changeset
2249 labels.append(*it);
d0f7c742d397 started implementation of labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5220
diff changeset
2250 }
d0f7c742d397 started implementation of labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5220
diff changeset
2251
d0f7c742d397 started implementation of labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5220
diff changeset
2252 target["Labels"] = labels;
d0f7c742d397 started implementation of labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5220
diff changeset
2253 }
4935
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4921
diff changeset
2254 }
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4921
diff changeset
2255
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4921
diff changeset
2256
4944
f377d5643538 new Warnings configuration + InstanceAvailability tag
Alain Mazy <am@osimis.io>
parents: 4941
diff changeset
2257 static void ComputeInstanceTags(ExpandedResource& resource,
f377d5643538 new Warnings configuration + InstanceAvailability tag
Alain Mazy <am@osimis.io>
parents: 4941
diff changeset
2258 ServerContext& context,
f377d5643538 new Warnings configuration + InstanceAvailability tag
Alain Mazy <am@osimis.io>
parents: 4941
diff changeset
2259 const std::string& instancePublicId,
f377d5643538 new Warnings configuration + InstanceAvailability tag
Alain Mazy <am@osimis.io>
parents: 4941
diff changeset
2260 const std::set<DicomTag>& requestedTags)
f377d5643538 new Warnings configuration + InstanceAvailability tag
Alain Mazy <am@osimis.io>
parents: 4941
diff changeset
2261 {
f377d5643538 new Warnings configuration + InstanceAvailability tag
Alain Mazy <am@osimis.io>
parents: 4941
diff changeset
2262 if (requestedTags.count(DICOM_TAG_INSTANCE_AVAILABILITY) > 0)
f377d5643538 new Warnings configuration + InstanceAvailability tag
Alain Mazy <am@osimis.io>
parents: 4941
diff changeset
2263 {
5222
3a61fd50f804 starting refactoring ExpandedResource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5221
diff changeset
2264 resource.GetMainDicomTags().SetValue(DICOM_TAG_INSTANCE_AVAILABILITY, "ONLINE", false);
4944
f377d5643538 new Warnings configuration + InstanceAvailability tag
Alain Mazy <am@osimis.io>
parents: 4941
diff changeset
2265 resource.missingRequestedTags_.erase(DICOM_TAG_INSTANCE_AVAILABILITY);
f377d5643538 new Warnings configuration + InstanceAvailability tag
Alain Mazy <am@osimis.io>
parents: 4941
diff changeset
2266 }
f377d5643538 new Warnings configuration + InstanceAvailability tag
Alain Mazy <am@osimis.io>
parents: 4941
diff changeset
2267 }
f377d5643538 new Warnings configuration + InstanceAvailability tag
Alain Mazy <am@osimis.io>
parents: 4941
diff changeset
2268
f377d5643538 new Warnings configuration + InstanceAvailability tag
Alain Mazy <am@osimis.io>
parents: 4941
diff changeset
2269
4940
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2270 static void ComputeSeriesTags(ExpandedResource& resource,
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2271 ServerContext& context,
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2272 const std::string& seriesPublicId,
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2273 const std::set<DicomTag>& requestedTags)
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2274 {
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2275 if (requestedTags.count(DICOM_TAG_NUMBER_OF_SERIES_RELATED_INSTANCES) > 0)
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2276 {
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2277 ServerIndex& index = context.GetIndex();
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2278 std::list<std::string> instances;
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2279
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2280 index.GetChildren(instances, seriesPublicId);
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2281
5222
3a61fd50f804 starting refactoring ExpandedResource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5221
diff changeset
2282 resource.GetMainDicomTags().SetValue(DICOM_TAG_NUMBER_OF_SERIES_RELATED_INSTANCES,
4940
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2283 boost::lexical_cast<std::string>(instances.size()), false);
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2284 resource.missingRequestedTags_.erase(DICOM_TAG_NUMBER_OF_SERIES_RELATED_INSTANCES);
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2285 }
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2286 }
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2287
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2288 static void ComputeStudyTags(ExpandedResource& resource,
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2289 ServerContext& context,
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2290 const std::string& studyPublicId,
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2291 const std::set<DicomTag>& requestedTags)
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2292 {
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2293 ServerIndex& index = context.GetIndex();
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2294 std::list<std::string> series;
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2295 std::list<std::string> instances;
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2296
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2297 bool hasNbRelatedSeries = requestedTags.count(DICOM_TAG_NUMBER_OF_STUDY_RELATED_SERIES) > 0;
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2298 bool hasNbRelatedInstances = requestedTags.count(DICOM_TAG_NUMBER_OF_STUDY_RELATED_INSTANCES) > 0;
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2299 bool hasModalitiesInStudy = requestedTags.count(DICOM_TAG_MODALITIES_IN_STUDY) > 0;
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2300 bool hasSopClassesInStudy = requestedTags.count(DICOM_TAG_SOP_CLASSES_IN_STUDY) > 0;
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2301
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2302 index.GetChildren(series, studyPublicId);
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2303
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2304 if (hasModalitiesInStudy)
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2305 {
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2306 std::set<std::string> values;
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2307
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2308 for (std::list<std::string>::const_iterator
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2309 it = series.begin(); it != series.end(); ++it)
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2310 {
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2311 DicomMap tags;
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2312 index.GetMainDicomTags(tags, *it, ResourceType_Series, ResourceType_Series);
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2313
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2314 const DicomValue* value = tags.TestAndGetValue(DICOM_TAG_MODALITY);
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2315
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2316 if (value != NULL &&
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2317 !value->IsNull() &&
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2318 !value->IsBinary())
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2319 {
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2320 values.insert(value->GetContent());
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2321 }
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2322 }
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2323
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2324 std::string modalities;
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2325 Toolbox::JoinStrings(modalities, values, "\\");
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2326
5222
3a61fd50f804 starting refactoring ExpandedResource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5221
diff changeset
2327 resource.GetMainDicomTags().SetValue(DICOM_TAG_MODALITIES_IN_STUDY, modalities, false);
4940
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2328 resource.missingRequestedTags_.erase(DICOM_TAG_MODALITIES_IN_STUDY);
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2329 }
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2330
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2331 if (hasNbRelatedSeries)
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2332 {
5222
3a61fd50f804 starting refactoring ExpandedResource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5221
diff changeset
2333 resource.GetMainDicomTags().SetValue(DICOM_TAG_NUMBER_OF_STUDY_RELATED_SERIES,
4940
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2334 boost::lexical_cast<std::string>(series.size()), false);
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2335 resource.missingRequestedTags_.erase(DICOM_TAG_NUMBER_OF_STUDY_RELATED_SERIES);
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2336 }
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2337
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2338 if (hasNbRelatedInstances || hasSopClassesInStudy)
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2339 {
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2340 for (std::list<std::string>::const_iterator
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2341 it = series.begin(); it != series.end(); ++it)
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2342 {
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2343 std::list<std::string> seriesInstancesIds;
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2344 index.GetChildren(seriesInstancesIds, *it);
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2345
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2346 instances.splice(instances.end(), seriesInstancesIds);
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2347 }
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2348
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2349 if (hasNbRelatedInstances)
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2350 {
5222
3a61fd50f804 starting refactoring ExpandedResource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5221
diff changeset
2351 resource.GetMainDicomTags().SetValue(DICOM_TAG_NUMBER_OF_STUDY_RELATED_INSTANCES,
4940
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2352 boost::lexical_cast<std::string>(instances.size()), false);
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2353 resource.missingRequestedTags_.erase(DICOM_TAG_NUMBER_OF_STUDY_RELATED_INSTANCES);
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2354 }
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2355
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2356 if (hasSopClassesInStudy)
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2357 {
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2358 std::set<std::string> values;
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2359
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2360 for (std::list<std::string>::const_iterator
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2361 it = instances.begin(); it != instances.end(); ++it)
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2362 {
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2363 std::string value;
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2364
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2365 if (context.LookupOrReconstructMetadata(value, *it, ResourceType_Instance, MetadataType_Instance_SopClassUid))
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2366 {
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2367 values.insert(value);
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2368 }
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2369 }
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2370
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2371 if (values.size() > 0)
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2372 {
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2373 std::string sopClassUids;
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2374 Toolbox::JoinStrings(sopClassUids, values, "\\");
5222
3a61fd50f804 starting refactoring ExpandedResource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5221
diff changeset
2375 resource.GetMainDicomTags().SetValue(DICOM_TAG_SOP_CLASSES_IN_STUDY, sopClassUids, false);
4940
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2376 }
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2377
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2378 resource.missingRequestedTags_.erase(DICOM_TAG_SOP_CLASSES_IN_STUDY);
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2379 }
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2380 }
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2381 }
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2382
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2383 static void ComputePatientTags(ExpandedResource& resource,
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2384 ServerContext& context,
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2385 const std::string& patientPublicId,
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2386 const std::set<DicomTag>& requestedTags)
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2387 {
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2388 ServerIndex& index = context.GetIndex();
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2389
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2390 std::list<std::string> studies;
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2391 std::list<std::string> series;
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2392 std::list<std::string> instances;
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2393
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2394 bool hasNbRelatedStudies = requestedTags.count(DICOM_TAG_NUMBER_OF_PATIENT_RELATED_STUDIES) > 0;
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2395 bool hasNbRelatedSeries = requestedTags.count(DICOM_TAG_NUMBER_OF_PATIENT_RELATED_SERIES) > 0;
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2396 bool hasNbRelatedInstances = requestedTags.count(DICOM_TAG_NUMBER_OF_PATIENT_RELATED_INSTANCES) > 0;
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2397
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2398 index.GetChildren(studies, patientPublicId);
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2399
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2400 if (hasNbRelatedStudies)
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2401 {
5222
3a61fd50f804 starting refactoring ExpandedResource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5221
diff changeset
2402 resource.GetMainDicomTags().SetValue(DICOM_TAG_NUMBER_OF_PATIENT_RELATED_STUDIES,
4940
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2403 boost::lexical_cast<std::string>(studies.size()), false);
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2404 resource.missingRequestedTags_.erase(DICOM_TAG_NUMBER_OF_PATIENT_RELATED_STUDIES);
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2405 }
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2406
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2407 if (hasNbRelatedSeries || hasNbRelatedInstances)
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2408 {
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2409 for (std::list<std::string>::const_iterator
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2410 it = studies.begin(); it != studies.end(); ++it)
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2411 {
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2412 std::list<std::string> thisSeriesIds;
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2413 index.GetChildren(thisSeriesIds, *it);
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2414 series.splice(series.end(), thisSeriesIds);
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2415 }
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2416
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2417 if (hasNbRelatedSeries)
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2418 {
5222
3a61fd50f804 starting refactoring ExpandedResource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5221
diff changeset
2419 resource.GetMainDicomTags().SetValue(DICOM_TAG_NUMBER_OF_PATIENT_RELATED_SERIES,
4940
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2420 boost::lexical_cast<std::string>(series.size()), false);
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2421 resource.missingRequestedTags_.erase(DICOM_TAG_NUMBER_OF_PATIENT_RELATED_SERIES);
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2422 }
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2423 }
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2424
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2425 if (hasNbRelatedInstances)
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2426 {
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2427 for (std::list<std::string>::const_iterator
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2428 it = series.begin(); it != series.end(); ++it)
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2429 {
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2430 std::list<std::string> thisInstancesIds;
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2431 index.GetChildren(thisInstancesIds, *it);
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2432 instances.splice(instances.end(), thisInstancesIds);
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2433 }
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2434
5222
3a61fd50f804 starting refactoring ExpandedResource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5221
diff changeset
2435 resource.GetMainDicomTags().SetValue(DICOM_TAG_NUMBER_OF_PATIENT_RELATED_INSTANCES,
4940
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2436 boost::lexical_cast<std::string>(instances.size()), false);
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2437 resource.missingRequestedTags_.erase(DICOM_TAG_NUMBER_OF_PATIENT_RELATED_INSTANCES);
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2438 }
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2439 }
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2440
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2441
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2442 static void ComputeTags(ExpandedResource& resource,
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2443 ServerContext& context,
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2444 const std::string& resourceId,
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2445 ResourceType level,
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2446 const std::set<DicomTag>& requestedTags)
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2447 {
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2448 if (level == ResourceType_Patient
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2449 && DicomMap::HasComputedTags(resource.missingRequestedTags_, ResourceType_Patient))
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2450 {
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2451 ComputePatientTags(resource, context, resourceId, requestedTags);
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2452 }
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2453
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2454 if (level == ResourceType_Study
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2455 && DicomMap::HasComputedTags(resource.missingRequestedTags_, ResourceType_Study))
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2456 {
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2457 ComputeStudyTags(resource, context, resourceId, requestedTags);
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2458 }
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2459
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2460 if (level == ResourceType_Series
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2461 && DicomMap::HasComputedTags(resource.missingRequestedTags_, ResourceType_Series))
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2462 {
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2463 ComputeSeriesTags(resource, context, resourceId, requestedTags);
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2464 }
4944
f377d5643538 new Warnings configuration + InstanceAvailability tag
Alain Mazy <am@osimis.io>
parents: 4941
diff changeset
2465
f377d5643538 new Warnings configuration + InstanceAvailability tag
Alain Mazy <am@osimis.io>
parents: 4941
diff changeset
2466 if (level == ResourceType_Instance
f377d5643538 new Warnings configuration + InstanceAvailability tag
Alain Mazy <am@osimis.io>
parents: 4941
diff changeset
2467 && DicomMap::HasComputedTags(resource.missingRequestedTags_, ResourceType_Instance))
f377d5643538 new Warnings configuration + InstanceAvailability tag
Alain Mazy <am@osimis.io>
parents: 4941
diff changeset
2468 {
f377d5643538 new Warnings configuration + InstanceAvailability tag
Alain Mazy <am@osimis.io>
parents: 4941
diff changeset
2469 ComputeInstanceTags(resource, context, resourceId, requestedTags);
f377d5643538 new Warnings configuration + InstanceAvailability tag
Alain Mazy <am@osimis.io>
parents: 4941
diff changeset
2470 }
4940
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2471 }
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2472
4935
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4921
diff changeset
2473 bool ServerContext::ExpandResource(Json::Value& target,
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4921
diff changeset
2474 const std::string& publicId,
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4921
diff changeset
2475 ResourceType level,
4936
8422e4f99a18 Handling RequestedTags in ExpandResource -> read parent main dicom tags if required. Not yet getting missing tags from file. Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4935
diff changeset
2476 DicomToJsonFormat format,
5058
d4e5ca0c9307 Fix the "Never" option of the "StorageAccessOnFind" that was sill accessing files (bug introduced in 1.11.0)
Alain Mazy <am@osimis.io>
parents: 5048
diff changeset
2477 const std::set<DicomTag>& requestedTags,
d4e5ca0c9307 Fix the "Never" option of the "StorageAccessOnFind" that was sill accessing files (bug introduced in 1.11.0)
Alain Mazy <am@osimis.io>
parents: 5048
diff changeset
2478 bool allowStorageAccess)
4935
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4921
diff changeset
2479 {
4937
3f9b9865c8cc include requested tags from storage if needed
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
2480 std::string unusedInstanceId;
4940
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2481 Json::Value* unusedDicomAsJson = NULL;
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2482 DicomMap unusedMainDicomTags;
4937
3f9b9865c8cc include requested tags from storage if needed
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
2483
5058
d4e5ca0c9307 Fix the "Never" option of the "StorageAccessOnFind" that was sill accessing files (bug introduced in 1.11.0)
Alain Mazy <am@osimis.io>
parents: 5048
diff changeset
2484 return ExpandResource(target, publicId, unusedMainDicomTags, unusedInstanceId, unusedDicomAsJson, level, format, requestedTags, allowStorageAccess);
4937
3f9b9865c8cc include requested tags from storage if needed
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
2485 }
3f9b9865c8cc include requested tags from storage if needed
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
2486
3f9b9865c8cc include requested tags from storage if needed
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
2487 bool ServerContext::ExpandResource(Json::Value& target,
3f9b9865c8cc include requested tags from storage if needed
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
2488 const std::string& publicId,
4940
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2489 const DicomMap& mainDicomTags, // optional: the main dicom tags for the resource (if already available)
4939
e8a2e145c80e cleanup
Alain Mazy <am@osimis.io>
parents: 4937
diff changeset
2490 const std::string& instanceId, // optional: the id of an instance for the resource (if already available)
5060
e69a3ff39bc5 fix reuse of DicomAsJson between lookup and answers
Alain Mazy <am@osimis.io>
parents: 5058
diff changeset
2491 const Json::Value* dicomAsJson, // optional: the dicom-as-json for the resource (if already available)
4937
3f9b9865c8cc include requested tags from storage if needed
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
2492 ResourceType level,
3f9b9865c8cc include requested tags from storage if needed
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
2493 DicomToJsonFormat format,
5058
d4e5ca0c9307 Fix the "Never" option of the "StorageAccessOnFind" that was sill accessing files (bug introduced in 1.11.0)
Alain Mazy <am@osimis.io>
parents: 5048
diff changeset
2494 const std::set<DicomTag>& requestedTags,
d4e5ca0c9307 Fix the "Never" option of the "StorageAccessOnFind" that was sill accessing files (bug introduced in 1.11.0)
Alain Mazy <am@osimis.io>
parents: 5048
diff changeset
2495 bool allowStorageAccess)
4937
3f9b9865c8cc include requested tags from storage if needed
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
2496 {
4935
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4921
diff changeset
2497 ExpandedResource resource;
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4921
diff changeset
2498
5222
3a61fd50f804 starting refactoring ExpandedResource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5221
diff changeset
2499 if (ExpandResource(resource, publicId, mainDicomTags, instanceId, dicomAsJson, level, requestedTags, ExpandResourceFlags_Default, allowStorageAccess))
4939
e8a2e145c80e cleanup
Alain Mazy <am@osimis.io>
parents: 4937
diff changeset
2500 {
e8a2e145c80e cleanup
Alain Mazy <am@osimis.io>
parents: 4937
diff changeset
2501 SerializeExpandedResource(target, resource, format, requestedTags);
e8a2e145c80e cleanup
Alain Mazy <am@osimis.io>
parents: 4937
diff changeset
2502 return true;
e8a2e145c80e cleanup
Alain Mazy <am@osimis.io>
parents: 4937
diff changeset
2503 }
e8a2e145c80e cleanup
Alain Mazy <am@osimis.io>
parents: 4937
diff changeset
2504
e8a2e145c80e cleanup
Alain Mazy <am@osimis.io>
parents: 4937
diff changeset
2505 return false;
e8a2e145c80e cleanup
Alain Mazy <am@osimis.io>
parents: 4937
diff changeset
2506 }
e8a2e145c80e cleanup
Alain Mazy <am@osimis.io>
parents: 4937
diff changeset
2507
e8a2e145c80e cleanup
Alain Mazy <am@osimis.io>
parents: 4937
diff changeset
2508 bool ServerContext::ExpandResource(ExpandedResource& resource,
e8a2e145c80e cleanup
Alain Mazy <am@osimis.io>
parents: 4937
diff changeset
2509 const std::string& publicId,
4940
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2510 const DicomMap& mainDicomTags, // optional: the main dicom tags for the resource (if already available)
4939
e8a2e145c80e cleanup
Alain Mazy <am@osimis.io>
parents: 4937
diff changeset
2511 const std::string& instanceId, // optional: the id of an instance for the resource (if already available)
4940
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2512 const Json::Value* dicomAsJson, // optional: the dicom-as-json for the resource (if already available)
4939
e8a2e145c80e cleanup
Alain Mazy <am@osimis.io>
parents: 4937
diff changeset
2513 ResourceType level,
4940
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2514 const std::set<DicomTag>& requestedTags,
5222
3a61fd50f804 starting refactoring ExpandedResource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5221
diff changeset
2515 ExpandResourceFlags expandFlags,
5058
d4e5ca0c9307 Fix the "Never" option of the "StorageAccessOnFind" that was sill accessing files (bug introduced in 1.11.0)
Alain Mazy <am@osimis.io>
parents: 5048
diff changeset
2516 bool allowStorageAccess)
4939
e8a2e145c80e cleanup
Alain Mazy <am@osimis.io>
parents: 4937
diff changeset
2517 {
4940
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2518 // first try to get the tags from what is already available
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2519
5222
3a61fd50f804 starting refactoring ExpandedResource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5221
diff changeset
2520 if ((expandFlags & ExpandResourceFlags_IncludeMainDicomTags) &&
3a61fd50f804 starting refactoring ExpandedResource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5221
diff changeset
2521 mainDicomTags.GetSize() > 0 &&
3a61fd50f804 starting refactoring ExpandedResource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5221
diff changeset
2522 dicomAsJson != NULL)
4940
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2523 {
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2524
5222
3a61fd50f804 starting refactoring ExpandedResource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5221
diff changeset
2525 resource.GetMainDicomTags().Merge(mainDicomTags);
4940
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2526
4984
c8cdf5163cd2 cppcheck
Alain Mazy <am@osimis.io>
parents: 4981
diff changeset
2527 if (dicomAsJson->isObject())
4940
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2528 {
5222
3a61fd50f804 starting refactoring ExpandedResource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5221
diff changeset
2529 resource.GetMainDicomTags().FromDicomAsJson(*dicomAsJson);
4940
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2530 }
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2531
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2532 std::set<DicomTag> retrievedTags;
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2533 std::set<DicomTag> missingTags;
5222
3a61fd50f804 starting refactoring ExpandedResource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5221
diff changeset
2534 resource.GetMainDicomTags().GetTags(retrievedTags);
4940
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2535
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2536 Toolbox::GetMissingsFromSet(missingTags, requestedTags, retrievedTags);
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2537
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2538 // if all possible tags have been read, no need to get them from DB anymore
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2539 if (missingTags.size() == 0 || DicomMap::HasOnlyComputedTags(missingTags))
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2540 {
5222
3a61fd50f804 starting refactoring ExpandedResource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5221
diff changeset
2541 expandFlags = static_cast<ExpandResourceFlags>(expandFlags & ~ExpandResourceFlags_IncludeMainDicomTags);
4940
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2542 }
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2543
5222
3a61fd50f804 starting refactoring ExpandedResource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5221
diff changeset
2544 if (missingTags.size() == 0 && expandFlags == ExpandResourceFlags_None) // we have already retrieved anything we need
4940
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2545 {
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2546 return true;
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2547 }
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2548 }
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2549
5222
3a61fd50f804 starting refactoring ExpandedResource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5221
diff changeset
2550 if (expandFlags != ExpandResourceFlags_None &&
3a61fd50f804 starting refactoring ExpandedResource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5221
diff changeset
2551 GetIndex().ExpandResource(resource, publicId, level, requestedTags,
3a61fd50f804 starting refactoring ExpandedResource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5221
diff changeset
2552 static_cast<ExpandResourceFlags>(expandFlags | ExpandResourceFlags_IncludeMetadata))) // we always need the metadata to get the mainDicomTagsSignature
4935
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4921
diff changeset
2553 {
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4921
diff changeset
2554 // check the main dicom tags list has not changed since the resource was stored
5222
3a61fd50f804 starting refactoring ExpandedResource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5221
diff changeset
2555 if (resource.mainDicomTagsSignature_ != DicomMap::GetMainDicomTagsSignature(resource.GetLevel()))
4935
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4921
diff changeset
2556 {
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4921
diff changeset
2557 OrthancConfiguration::ReaderLock lock;
4944
f377d5643538 new Warnings configuration + InstanceAvailability tag
Alain Mazy <am@osimis.io>
parents: 4941
diff changeset
2558 if (lock.GetConfiguration().IsWarningEnabled(Warnings_002_InconsistentDicomTagsInDb))
4935
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4921
diff changeset
2559 {
5222
3a61fd50f804 starting refactoring ExpandedResource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5221
diff changeset
2560 LOG(WARNING) << "W002: " << Orthanc::GetResourceTypeText(resource.GetLevel(), false , false)
3a61fd50f804 starting refactoring ExpandedResource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5221
diff changeset
2561 << " has been stored with another version of Main Dicom Tags list, you should POST to /"
3a61fd50f804 starting refactoring ExpandedResource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5221
diff changeset
2562 << Orthanc::GetResourceTypeText(resource.GetLevel(), true, false)
3a61fd50f804 starting refactoring ExpandedResource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5221
diff changeset
2563 << "/" << resource.GetPublicId()
3a61fd50f804 starting refactoring ExpandedResource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5221
diff changeset
2564 << "/reconstruct to update the list of tags saved in DB. Some MainDicomTags might be missing from this answer.";
4935
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4921
diff changeset
2565 }
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4921
diff changeset
2566 }
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4921
diff changeset
2567
4937
3f9b9865c8cc include requested tags from storage if needed
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
2568 // possibly merge missing requested tags from dicom-as-json
5222
3a61fd50f804 starting refactoring ExpandedResource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5221
diff changeset
2569 if (allowStorageAccess &&
3a61fd50f804 starting refactoring ExpandedResource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5221
diff changeset
2570 !resource.missingRequestedTags_.empty() &&
3a61fd50f804 starting refactoring ExpandedResource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5221
diff changeset
2571 !DicomMap::HasOnlyComputedTags(resource.missingRequestedTags_))
4937
3f9b9865c8cc include requested tags from storage if needed
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
2572 {
4941
96a3e81eba90 performance warning
Alain Mazy <am@osimis.io>
parents: 4940
diff changeset
2573 OrthancConfiguration::ReaderLock lock;
4944
f377d5643538 new Warnings configuration + InstanceAvailability tag
Alain Mazy <am@osimis.io>
parents: 4941
diff changeset
2574 if (lock.GetConfiguration().IsWarningEnabled(Warnings_001_TagsBeingReadFromStorage))
4941
96a3e81eba90 performance warning
Alain Mazy <am@osimis.io>
parents: 4940
diff changeset
2575 {
96a3e81eba90 performance warning
Alain Mazy <am@osimis.io>
parents: 4940
diff changeset
2576 std::set<DicomTag> missingTags;
96a3e81eba90 performance warning
Alain Mazy <am@osimis.io>
parents: 4940
diff changeset
2577 Toolbox::AppendSets(missingTags, resource.missingRequestedTags_);
4981
d0c34145320c cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4978
diff changeset
2578 for (std::set<DicomTag>::const_iterator it = resource.missingRequestedTags_.begin(); it != resource.missingRequestedTags_.end(); ++it)
4941
96a3e81eba90 performance warning
Alain Mazy <am@osimis.io>
parents: 4940
diff changeset
2579 {
96a3e81eba90 performance warning
Alain Mazy <am@osimis.io>
parents: 4940
diff changeset
2580 if (DicomMap::IsComputedTag(*it))
96a3e81eba90 performance warning
Alain Mazy <am@osimis.io>
parents: 4940
diff changeset
2581 {
96a3e81eba90 performance warning
Alain Mazy <am@osimis.io>
parents: 4940
diff changeset
2582 missingTags.erase(*it);
96a3e81eba90 performance warning
Alain Mazy <am@osimis.io>
parents: 4940
diff changeset
2583 }
96a3e81eba90 performance warning
Alain Mazy <am@osimis.io>
parents: 4940
diff changeset
2584 }
96a3e81eba90 performance warning
Alain Mazy <am@osimis.io>
parents: 4940
diff changeset
2585
96a3e81eba90 performance warning
Alain Mazy <am@osimis.io>
parents: 4940
diff changeset
2586 std::string missings;
96a3e81eba90 performance warning
Alain Mazy <am@osimis.io>
parents: 4940
diff changeset
2587 FromDcmtkBridge::FormatListOfTags(missings, missingTags);
96a3e81eba90 performance warning
Alain Mazy <am@osimis.io>
parents: 4940
diff changeset
2588
5222
3a61fd50f804 starting refactoring ExpandedResource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5221
diff changeset
2589 LOG(WARNING) << "W001: Accessing Dicom tags from storage when accessing "
3a61fd50f804 starting refactoring ExpandedResource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5221
diff changeset
2590 << Orthanc::GetResourceTypeText(resource.GetLevel(), false, false)
3a61fd50f804 starting refactoring ExpandedResource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5221
diff changeset
2591 << " : " << missings;
4941
96a3e81eba90 performance warning
Alain Mazy <am@osimis.io>
parents: 4940
diff changeset
2592 }
96a3e81eba90 performance warning
Alain Mazy <am@osimis.io>
parents: 4940
diff changeset
2593
96a3e81eba90 performance warning
Alain Mazy <am@osimis.io>
parents: 4940
diff changeset
2594
4937
3f9b9865c8cc include requested tags from storage if needed
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
2595 std::string instanceId_ = instanceId;
4940
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2596 DicomMap tagsFromJson;
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2597
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2598 if (dicomAsJson == NULL)
4937
3f9b9865c8cc include requested tags from storage if needed
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
2599 {
3f9b9865c8cc include requested tags from storage if needed
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
2600 if (instanceId_.empty())
3f9b9865c8cc include requested tags from storage if needed
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
2601 {
3f9b9865c8cc include requested tags from storage if needed
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
2602 if (level == ResourceType_Instance)
3f9b9865c8cc include requested tags from storage if needed
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
2603 {
3f9b9865c8cc include requested tags from storage if needed
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
2604 instanceId_ = publicId;
3f9b9865c8cc include requested tags from storage if needed
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
2605 }
3f9b9865c8cc include requested tags from storage if needed
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
2606 else
3f9b9865c8cc include requested tags from storage if needed
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
2607 {
3f9b9865c8cc include requested tags from storage if needed
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
2608 std::list<std::string> instancesIds;
3f9b9865c8cc include requested tags from storage if needed
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
2609 GetIndex().GetChildInstances(instancesIds, publicId);
3f9b9865c8cc include requested tags from storage if needed
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
2610 if (instancesIds.size() < 1)
3f9b9865c8cc include requested tags from storage if needed
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
2611 {
3f9b9865c8cc include requested tags from storage if needed
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
2612 throw OrthancException(ErrorCode_InternalError, "ExpandResource: no instances found");
3f9b9865c8cc include requested tags from storage if needed
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
2613 }
3f9b9865c8cc include requested tags from storage if needed
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
2614 instanceId_ = instancesIds.front();
3f9b9865c8cc include requested tags from storage if needed
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
2615 }
3f9b9865c8cc include requested tags from storage if needed
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
2616 }
3f9b9865c8cc include requested tags from storage if needed
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
2617
4940
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2618 Json::Value tmpDicomAsJson;
5036
877bc3b96476 Handle Dicom sequences in ExtraMainDicomTags and save them in the 'MainDicomSequences' metadata
Alain Mazy <am@osimis.io>
parents: 4994
diff changeset
2619 ReadDicomAsJson(tmpDicomAsJson, instanceId_, resource.missingRequestedTags_ /* ignoreTagLength */); // read all tags from DICOM and avoid cropping requested tags
5044
6fed78e13233 Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents: 5043
diff changeset
2620 tagsFromJson.FromDicomAsJson(tmpDicomAsJson, false /* append */, true /* parseSequences*/);
4940
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2621 }
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2622 else
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2623 {
5044
6fed78e13233 Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents: 5043
diff changeset
2624 tagsFromJson.FromDicomAsJson(*dicomAsJson, false /* append */, true /* parseSequences*/);
4937
3f9b9865c8cc include requested tags from storage if needed
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
2625 }
3f9b9865c8cc include requested tags from storage if needed
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
2626
5222
3a61fd50f804 starting refactoring ExpandedResource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5221
diff changeset
2627 resource.GetMainDicomTags().Merge(tagsFromJson);
4937
3f9b9865c8cc include requested tags from storage if needed
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
2628 }
4935
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4921
diff changeset
2629
4940
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2630 // compute the requested tags
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2631 ComputeTags(resource, *this, publicId, level, requestedTags);
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2632 }
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2633 else
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2634 {
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2635 return false;
4935
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4921
diff changeset
2636 }
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4921
diff changeset
2637
4940
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4939
diff changeset
2638 return true;
4935
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4921
diff changeset
2639 }
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4921
diff changeset
2640
5111
7547c7dfd017 /tools/metrics-prometheus: added orthanc_last_change and orthanc_up_time_s
Alain Mazy <am@osimis.io>
parents: 5060
diff changeset
2641 int64_t ServerContext::GetServerUpTime() const
7547c7dfd017 /tools/metrics-prometheus: added orthanc_last_change and orthanc_up_time_s
Alain Mazy <am@osimis.io>
parents: 5060
diff changeset
2642 {
7547c7dfd017 /tools/metrics-prometheus: added orthanc_last_change and orthanc_up_time_s
Alain Mazy <am@osimis.io>
parents: 5060
diff changeset
2643 boost::posix_time::ptime nowUtc = boost::posix_time::second_clock::universal_time();
7547c7dfd017 /tools/metrics-prometheus: added orthanc_last_change and orthanc_up_time_s
Alain Mazy <am@osimis.io>
parents: 5060
diff changeset
2644 boost::posix_time::time_duration elapsed = nowUtc - serverStartTimeUtc_;
7547c7dfd017 /tools/metrics-prometheus: added orthanc_last_change and orthanc_up_time_s
Alain Mazy <am@osimis.io>
parents: 5060
diff changeset
2645
7547c7dfd017 /tools/metrics-prometheus: added orthanc_last_change and orthanc_up_time_s
Alain Mazy <am@osimis.io>
parents: 5060
diff changeset
2646 return elapsed.total_seconds();
7547c7dfd017 /tools/metrics-prometheus: added orthanc_last_change and orthanc_up_time_s
Alain Mazy <am@osimis.io>
parents: 5060
diff changeset
2647 }
7547c7dfd017 /tools/metrics-prometheus: added orthanc_last_change and orthanc_up_time_s
Alain Mazy <am@osimis.io>
parents: 5060
diff changeset
2648
224
4eb0c7ce86c9 refactoring for store
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2649 }