annotate OrthancServer/Sources/ResourceFinder.cpp @ 5714:2b05428843d2 find-refactoring

removed dangerous overload of ResourceFinder::Execute()
author Sebastien Jodogne <s.jodogne@gmail.com>
date Sat, 13 Jul 2024 00:20:33 +0200
parents d851a54e49b7
children 717acb0ea546
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5608
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 /**
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2 * Orthanc - A Lightweight, RESTful DICOM Store
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
4 * Department, University Hospital of Liege, Belgium
5641
3f13db27b399 integration mainline->find-refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5621
diff changeset
5 * Copyright (C) 2017-2023 Osimis S.A., Belgium
3f13db27b399 integration mainline->find-refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5621
diff changeset
6 * Copyright (C) 2024-2024 Orthanc Team SRL, Belgium
5608
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 * Copyright (C) 2021-2024 Sebastien Jodogne, ICTEAM UCLouvain, Belgium
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 *
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 * This program is free software: you can redistribute it and/or
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 * modify it under the terms of the GNU General Public License as
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 * published by the Free Software Foundation, either version 3 of the
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 * License, or (at your option) any later version.
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 *
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 * This program is distributed in the hope that it will be useful, but
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 * WITHOUT ANY WARRANTY; without even the implied warranty of
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17 * General Public License for more details.
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18 *
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
19 * You should have received a copy of the GNU General Public License
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20 * along with this program. If not, see <http://www.gnu.org/licenses/>.
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21 **/
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24 #include "PrecompiledHeadersServer.h"
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25 #include "ResourceFinder.h"
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27 #include "../../OrthancFramework/Sources/DicomParsing/FromDcmtkBridge.h"
5609
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
28 #include "../../OrthancFramework/Sources/Logging.h"
5608
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29 #include "../../OrthancFramework/Sources/OrthancException.h"
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30 #include "../../OrthancFramework/Sources/SerializationToolbox.h"
5609
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
31 #include "OrthancConfiguration.h"
5682
fd4c5e064cbe started refactoring of ServerContext::Apply()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5676
diff changeset
32 #include "Search/DatabaseLookup.h"
5608
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
33 #include "ServerContext.h"
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
34 #include "ServerIndex.h"
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
35
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
36
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
37 namespace Orthanc
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
38 {
5686
11575590e493 integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5682
diff changeset
39 static bool IsComputedTag(const DicomTag& tag)
11575590e493 integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5682
diff changeset
40 {
11575590e493 integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5682
diff changeset
41 return (tag == DICOM_TAG_NUMBER_OF_PATIENT_RELATED_STUDIES ||
11575590e493 integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5682
diff changeset
42 tag == DICOM_TAG_NUMBER_OF_PATIENT_RELATED_SERIES ||
11575590e493 integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5682
diff changeset
43 tag == DICOM_TAG_NUMBER_OF_PATIENT_RELATED_INSTANCES ||
11575590e493 integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5682
diff changeset
44 tag == DICOM_TAG_NUMBER_OF_STUDY_RELATED_SERIES ||
11575590e493 integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5682
diff changeset
45 tag == DICOM_TAG_NUMBER_OF_STUDY_RELATED_INSTANCES ||
11575590e493 integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5682
diff changeset
46 tag == DICOM_TAG_NUMBER_OF_SERIES_RELATED_INSTANCES ||
11575590e493 integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5682
diff changeset
47 tag == DICOM_TAG_SOP_CLASSES_IN_STUDY ||
11575590e493 integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5682
diff changeset
48 tag == DICOM_TAG_MODALITIES_IN_STUDY ||
11575590e493 integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5682
diff changeset
49 tag == DICOM_TAG_INSTANCE_AVAILABILITY);
11575590e493 integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5682
diff changeset
50 }
11575590e493 integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5682
diff changeset
51
5666
aa231c18b9d2 adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5665
diff changeset
52 void ResourceFinder::ConfigureChildrenCountComputedTag(DicomTag tag,
aa231c18b9d2 adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5665
diff changeset
53 ResourceType parentLevel,
aa231c18b9d2 adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5665
diff changeset
54 ResourceType childLevel)
aa231c18b9d2 adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5665
diff changeset
55 {
aa231c18b9d2 adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5665
diff changeset
56 if (request_.GetLevel() == parentLevel)
aa231c18b9d2 adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5665
diff changeset
57 {
aa231c18b9d2 adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5665
diff changeset
58 requestedComputedTags_.insert(tag);
aa231c18b9d2 adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5665
diff changeset
59 hasRequestedTags_ = true;
5676
b744a2cf408a shorten ParentRetrieveSpecification/ChildrenRetrieveSpecification as ParentSpecification/ChildrenSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5674
diff changeset
60 request_.GetChildrenSpecification(childLevel).SetRetrieveIdentifiers(true);
5666
aa231c18b9d2 adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5665
diff changeset
61 }
aa231c18b9d2 adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5665
diff changeset
62 }
aa231c18b9d2 adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5665
diff changeset
63
aa231c18b9d2 adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5665
diff changeset
64
aa231c18b9d2 adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5665
diff changeset
65 void ResourceFinder::InjectChildrenCountComputedTag(DicomMap& requestedTags,
aa231c18b9d2 adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5665
diff changeset
66 DicomTag tag,
aa231c18b9d2 adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5665
diff changeset
67 const FindResponse::Resource& resource,
aa231c18b9d2 adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5665
diff changeset
68 ResourceType level) const
aa231c18b9d2 adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5665
diff changeset
69 {
aa231c18b9d2 adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5665
diff changeset
70 if (IsRequestedComputedTag(tag))
aa231c18b9d2 adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5665
diff changeset
71 {
aa231c18b9d2 adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5665
diff changeset
72 const std::set<std::string>& children = resource.GetChildrenIdentifiers(level);
aa231c18b9d2 adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5665
diff changeset
73 requestedTags.SetValue(tag, boost::lexical_cast<std::string>(children.size()), false);
aa231c18b9d2 adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5665
diff changeset
74 }
aa231c18b9d2 adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5665
diff changeset
75 }
aa231c18b9d2 adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5665
diff changeset
76
aa231c18b9d2 adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5665
diff changeset
77
aa231c18b9d2 adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5665
diff changeset
78 void ResourceFinder::InjectComputedTags(DicomMap& requestedTags,
aa231c18b9d2 adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5665
diff changeset
79 const FindResponse::Resource& resource) const
aa231c18b9d2 adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5665
diff changeset
80 {
aa231c18b9d2 adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5665
diff changeset
81 switch (resource.GetLevel())
aa231c18b9d2 adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5665
diff changeset
82 {
aa231c18b9d2 adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5665
diff changeset
83 case ResourceType_Patient:
aa231c18b9d2 adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5665
diff changeset
84 InjectChildrenCountComputedTag(requestedTags, DICOM_TAG_NUMBER_OF_PATIENT_RELATED_STUDIES, resource, ResourceType_Study);
aa231c18b9d2 adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5665
diff changeset
85 InjectChildrenCountComputedTag(requestedTags, DICOM_TAG_NUMBER_OF_PATIENT_RELATED_SERIES, resource, ResourceType_Series);
aa231c18b9d2 adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5665
diff changeset
86 InjectChildrenCountComputedTag(requestedTags, DICOM_TAG_NUMBER_OF_PATIENT_RELATED_INSTANCES, resource, ResourceType_Instance);
aa231c18b9d2 adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5665
diff changeset
87 break;
aa231c18b9d2 adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5665
diff changeset
88
aa231c18b9d2 adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5665
diff changeset
89 case ResourceType_Study:
aa231c18b9d2 adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5665
diff changeset
90 InjectChildrenCountComputedTag(requestedTags, DICOM_TAG_NUMBER_OF_STUDY_RELATED_SERIES, resource, ResourceType_Series);
aa231c18b9d2 adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5665
diff changeset
91 InjectChildrenCountComputedTag(requestedTags, DICOM_TAG_NUMBER_OF_STUDY_RELATED_INSTANCES, resource, ResourceType_Instance);
5672
e300f22a46f0 implemented computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5668
diff changeset
92
e300f22a46f0 implemented computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5668
diff changeset
93 if (IsRequestedComputedTag(DICOM_TAG_MODALITIES_IN_STUDY))
e300f22a46f0 implemented computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5668
diff changeset
94 {
e300f22a46f0 implemented computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5668
diff changeset
95 std::set<std::string> modalities;
e300f22a46f0 implemented computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5668
diff changeset
96 resource.GetChildrenMainDicomTagValues(modalities, ResourceType_Series, DICOM_TAG_MODALITY);
e300f22a46f0 implemented computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5668
diff changeset
97
e300f22a46f0 implemented computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5668
diff changeset
98 std::string s;
e300f22a46f0 implemented computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5668
diff changeset
99 Toolbox::JoinStrings(s, modalities, "\\");
e300f22a46f0 implemented computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5668
diff changeset
100
e300f22a46f0 implemented computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5668
diff changeset
101 requestedTags.SetValue(DICOM_TAG_MODALITIES_IN_STUDY, s, false);
e300f22a46f0 implemented computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5668
diff changeset
102 }
e300f22a46f0 implemented computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5668
diff changeset
103
e300f22a46f0 implemented computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5668
diff changeset
104 if (IsRequestedComputedTag(DICOM_TAG_SOP_CLASSES_IN_STUDY))
e300f22a46f0 implemented computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5668
diff changeset
105 {
e300f22a46f0 implemented computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5668
diff changeset
106 std::set<std::string> classes;
e300f22a46f0 implemented computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5668
diff changeset
107 resource.GetChildrenMetadataValues(classes, ResourceType_Instance, MetadataType_Instance_SopClassUid);
e300f22a46f0 implemented computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5668
diff changeset
108
e300f22a46f0 implemented computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5668
diff changeset
109 std::string s;
e300f22a46f0 implemented computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5668
diff changeset
110 Toolbox::JoinStrings(s, classes, "\\");
e300f22a46f0 implemented computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5668
diff changeset
111
e300f22a46f0 implemented computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5668
diff changeset
112 requestedTags.SetValue(DICOM_TAG_SOP_CLASSES_IN_STUDY, s, false);
e300f22a46f0 implemented computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5668
diff changeset
113 }
e300f22a46f0 implemented computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5668
diff changeset
114
5666
aa231c18b9d2 adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5665
diff changeset
115 break;
aa231c18b9d2 adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5665
diff changeset
116
aa231c18b9d2 adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5665
diff changeset
117 case ResourceType_Series:
aa231c18b9d2 adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5665
diff changeset
118 InjectChildrenCountComputedTag(requestedTags, DICOM_TAG_NUMBER_OF_SERIES_RELATED_INSTANCES, resource, ResourceType_Instance);
aa231c18b9d2 adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5665
diff changeset
119 break;
aa231c18b9d2 adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5665
diff changeset
120
aa231c18b9d2 adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5665
diff changeset
121 case ResourceType_Instance:
aa231c18b9d2 adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5665
diff changeset
122 if (IsRequestedComputedTag(DICOM_TAG_INSTANCE_AVAILABILITY))
aa231c18b9d2 adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5665
diff changeset
123 {
aa231c18b9d2 adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5665
diff changeset
124 requestedTags.SetValue(DICOM_TAG_INSTANCE_AVAILABILITY, "ONLINE", false);
aa231c18b9d2 adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5665
diff changeset
125 }
aa231c18b9d2 adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5665
diff changeset
126 break;
aa231c18b9d2 adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5665
diff changeset
127
aa231c18b9d2 adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5665
diff changeset
128 default:
aa231c18b9d2 adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5665
diff changeset
129 throw OrthancException(ErrorCode_InternalError);
aa231c18b9d2 adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5665
diff changeset
130 }
aa231c18b9d2 adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5665
diff changeset
131 }
aa231c18b9d2 adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5665
diff changeset
132
aa231c18b9d2 adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5665
diff changeset
133
5608
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
134 SeriesStatus ResourceFinder::GetSeriesStatus(uint32_t& expectedNumberOfInstances,
5689
c14776d25491 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5688
diff changeset
135 const FindResponse::Resource& resource)
5608
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
136 {
5689
c14776d25491 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5688
diff changeset
137 if (resource.GetLevel() != ResourceType_Series)
5608
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
138 {
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
139 throw OrthancException(ErrorCode_BadParameterType);
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
140 }
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
141
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
142 std::string s;
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
143 if (!resource.LookupMetadata(s, ResourceType_Series, MetadataType_Series_ExpectedNumberOfInstances) ||
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
144 !SerializationToolbox::ParseUnsignedInteger32(expectedNumberOfInstances, s))
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
145 {
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
146 return SeriesStatus_Unknown;
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
147 }
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
148
5674
74f3aab95886 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5672
diff changeset
149 std::set<std::string> values;
74f3aab95886 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5672
diff changeset
150 resource.GetChildrenMetadataValues(values, ResourceType_Instance, MetadataType_Instance_IndexInSeries);
5608
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
151
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
152 std::set<int64_t> instances;
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
153
5674
74f3aab95886 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5672
diff changeset
154 for (std::set<std::string>::const_iterator
5608
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
155 it = values.begin(); it != values.end(); ++it)
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
156 {
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
157 int64_t index;
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
158
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
159 if (!SerializationToolbox::ParseInteger64(index, *it))
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
160 {
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
161 return SeriesStatus_Unknown;
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
162 }
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
163
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
164 if (index <= 0 ||
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
165 index > static_cast<int64_t>(expectedNumberOfInstances))
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
166 {
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
167 // Out-of-range instance index
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
168 return SeriesStatus_Inconsistent;
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
169 }
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
170
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
171 if (instances.find(index) != instances.end())
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
172 {
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
173 // Twice the same instance index
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
174 return SeriesStatus_Inconsistent;
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
175 }
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
176
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
177 instances.insert(index);
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
178 }
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
179
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
180 if (instances.size() == static_cast<size_t>(expectedNumberOfInstances))
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
181 {
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
182 return SeriesStatus_Complete;
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
183 }
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
184 else
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
185 {
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
186 return SeriesStatus_Missing;
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
187 }
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
188 }
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
189
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
190
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
191 void ResourceFinder::Expand(Json::Value& target,
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
192 const FindResponse::Resource& resource,
5709
476b1db52110 removed the "format_" member from ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5702
diff changeset
193 ServerIndex& index,
5713
d851a54e49b7 removed "includeAllMetadata_" member from ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5709
diff changeset
194 DicomToJsonFormat format,
d851a54e49b7 removed "includeAllMetadata_" member from ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5709
diff changeset
195 bool includeAllMetadata) const
5608
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
196 {
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
197 /**
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
198 * This method closely follows "SerializeExpandedResource()" in
5689
c14776d25491 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5688
diff changeset
199 * "ServerContext.cpp" from Orthanc 1.12.4.
5608
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
200 **/
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
201
5713
d851a54e49b7 removed "includeAllMetadata_" member from ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5709
diff changeset
202 if (!expand_)
d851a54e49b7 removed "includeAllMetadata_" member from ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5709
diff changeset
203 {
d851a54e49b7 removed "includeAllMetadata_" member from ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5709
diff changeset
204 throw OrthancException(ErrorCode_BadSequenceOfCalls);
d851a54e49b7 removed "includeAllMetadata_" member from ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5709
diff changeset
205 }
d851a54e49b7 removed "includeAllMetadata_" member from ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5709
diff changeset
206
5608
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
207 if (resource.GetLevel() != request_.GetLevel())
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
208 {
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
209 throw OrthancException(ErrorCode_InternalError);
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
210 }
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
211
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
212 target = Json::objectValue;
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
213
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
214 target["Type"] = GetResourceTypeText(resource.GetLevel(), false, true);
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
215 target["ID"] = resource.GetIdentifier();
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
216
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
217 switch (resource.GetLevel())
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
218 {
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
219 case ResourceType_Patient:
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
220 break;
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
221
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
222 case ResourceType_Study:
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
223 target["ParentPatient"] = resource.GetParentIdentifier();
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
224 break;
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
225
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
226 case ResourceType_Series:
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
227 target["ParentStudy"] = resource.GetParentIdentifier();
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
228 break;
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
229
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
230 case ResourceType_Instance:
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
231 target["ParentSeries"] = resource.GetParentIdentifier();
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
232 break;
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
233
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
234 default:
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
235 throw OrthancException(ErrorCode_InternalError);
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
236 }
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
237
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
238 if (resource.GetLevel() != ResourceType_Instance)
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
239 {
5666
aa231c18b9d2 adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5665
diff changeset
240 const std::set<std::string>& children = resource.GetChildrenIdentifiers(GetChildResourceType(resource.GetLevel()));
5608
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
241
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
242 Json::Value c = Json::arrayValue;
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
243 for (std::set<std::string>::const_iterator
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
244 it = children.begin(); it != children.end(); ++it)
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
245 {
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
246 c.append(*it);
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
247 }
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
248
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
249 switch (resource.GetLevel())
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
250 {
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
251 case ResourceType_Patient:
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
252 target["Studies"] = c;
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
253 break;
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
254
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
255 case ResourceType_Study:
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
256 target["Series"] = c;
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
257 break;
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
258
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
259 case ResourceType_Series:
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
260 target["Instances"] = c;
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
261 break;
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
262
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
263 default:
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
264 throw OrthancException(ErrorCode_InternalError);
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
265 }
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
266 }
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
267
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
268 switch (resource.GetLevel())
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
269 {
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
270 case ResourceType_Patient:
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
271 case ResourceType_Study:
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
272 break;
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
273
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
274 case ResourceType_Series:
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
275 {
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
276 uint32_t expectedNumberOfInstances;
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
277 SeriesStatus status = GetSeriesStatus(expectedNumberOfInstances, resource);
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
278
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
279 target["Status"] = EnumerationToString(status);
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
280
5609
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
281 static const char* const EXPECTED_NUMBER_OF_INSTANCES = "ExpectedNumberOfInstances";
5608
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
282
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
283 if (status == SeriesStatus_Unknown)
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
284 {
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
285 target[EXPECTED_NUMBER_OF_INSTANCES] = Json::nullValue;
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
286 }
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
287 else
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
288 {
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
289 target[EXPECTED_NUMBER_OF_INSTANCES] = expectedNumberOfInstances;
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
290 }
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
291
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
292 break;
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
293 }
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
294
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
295 case ResourceType_Instance:
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
296 {
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
297 FileInfo info;
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
298 if (resource.LookupAttachment(info, FileContentType_Dicom))
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
299 {
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
300 target["FileSize"] = static_cast<Json::UInt64>(info.GetUncompressedSize());
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
301 target["FileUuid"] = info.GetUuid();
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
302 }
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
303 else
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
304 {
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
305 throw OrthancException(ErrorCode_InternalError);
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
306 }
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
307
5609
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
308 static const char* const INDEX_IN_SERIES = "IndexInSeries";
5608
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
309
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
310 std::string s;
5702
359a8adb3802 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5701
diff changeset
311 uint32_t indexInSeries;
5608
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
312 if (resource.LookupMetadata(s, ResourceType_Instance, MetadataType_Instance_IndexInSeries) &&
5702
359a8adb3802 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5701
diff changeset
313 SerializationToolbox::ParseUnsignedInteger32(indexInSeries, s))
5608
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
314 {
5702
359a8adb3802 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5701
diff changeset
315 target[INDEX_IN_SERIES] = indexInSeries;
5608
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
316 }
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
317 else
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
318 {
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
319 target[INDEX_IN_SERIES] = Json::nullValue;
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
320 }
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
321
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
322 break;
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
323 }
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
324
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
325 default:
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
326 throw OrthancException(ErrorCode_InternalError);
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
327 }
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
328
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
329 std::string s;
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
330 if (resource.LookupMetadata(s, resource.GetLevel(), MetadataType_AnonymizedFrom))
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
331 {
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
332 target["AnonymizedFrom"] = s;
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
333 }
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
334
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
335 if (resource.LookupMetadata(s, resource.GetLevel(), MetadataType_ModifiedFrom))
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
336 {
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
337 target["ModifiedFrom"] = s;
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
338 }
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
339
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
340 if (resource.GetLevel() == ResourceType_Patient ||
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
341 resource.GetLevel() == ResourceType_Study ||
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
342 resource.GetLevel() == ResourceType_Series)
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
343 {
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
344 target["IsStable"] = !index.IsUnstableResource(resource.GetLevel(), resource.GetInternalId());
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
345
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
346 if (resource.LookupMetadata(s, resource.GetLevel(), MetadataType_LastUpdate))
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
347 {
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
348 target["LastUpdate"] = s;
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
349 }
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
350 }
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
351
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
352 {
5609
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
353 DicomMap allMainDicomTags;
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
354 resource.GetMainDicomTags(allMainDicomTags, resource.GetLevel());
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
355
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
356 /**
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
357 * This section was part of "StatelessDatabaseOperations::ExpandResource()"
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
358 * in Orthanc <= 1.12.3
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
359 **/
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
360
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
361 // read all main sequences from DB
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
362 std::string serializedSequences;
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
363 if (resource.LookupMetadata(serializedSequences, resource.GetLevel(), MetadataType_MainDicomSequences))
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
364 {
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
365 Json::Value jsonMetadata;
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
366 Toolbox::ReadJson(jsonMetadata, serializedSequences);
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
367
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
368 if (jsonMetadata["Version"].asInt() == 1)
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
369 {
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
370 allMainDicomTags.FromDicomAsJson(jsonMetadata["Sequences"], true /* append */, true /* parseSequences */);
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
371 }
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
372 else
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
373 {
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
374 throw OrthancException(ErrorCode_NotImplemented);
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
375 }
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
376 }
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
377
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
378 /**
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
379 * End of section from StatelessDatabaseOperations
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
380 **/
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
381
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
382
5608
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
383 static const char* const MAIN_DICOM_TAGS = "MainDicomTags";
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
384 static const char* const PATIENT_MAIN_DICOM_TAGS = "PatientMainDicomTags";
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
385
5609
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
386 // TODO-FIND : Ignore "null" values
5608
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
387
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
388 DicomMap levelMainDicomTags;
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
389 allMainDicomTags.ExtractResourceInformation(levelMainDicomTags, resource.GetLevel());
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
390
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
391 target[MAIN_DICOM_TAGS] = Json::objectValue;
5709
476b1db52110 removed the "format_" member from ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5702
diff changeset
392 FromDcmtkBridge::ToJson(target[MAIN_DICOM_TAGS], levelMainDicomTags, format);
5608
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
393
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
394 if (resource.GetLevel() == ResourceType_Study)
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
395 {
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
396 DicomMap patientMainDicomTags;
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
397 allMainDicomTags.ExtractPatientInformation(patientMainDicomTags);
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
398
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
399 target[PATIENT_MAIN_DICOM_TAGS] = Json::objectValue;
5709
476b1db52110 removed the "format_" member from ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5702
diff changeset
400 FromDcmtkBridge::ToJson(target[PATIENT_MAIN_DICOM_TAGS], patientMainDicomTags, format);
5608
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
401 }
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
402 }
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
403
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
404 {
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
405 Json::Value labels = Json::arrayValue;
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
406
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
407 for (std::set<std::string>::const_iterator
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
408 it = resource.GetLabels().begin(); it != resource.GetLabels().end(); ++it)
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
409 {
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
410 labels.append(*it);
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
411 }
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
412
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
413 target["Labels"] = labels;
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
414 }
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
415
5713
d851a54e49b7 removed "includeAllMetadata_" member from ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5709
diff changeset
416 if (includeAllMetadata) // new in Orthanc 1.12.4
5608
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
417 {
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
418 const std::map<MetadataType, std::string>& m = resource.GetMetadata(resource.GetLevel());
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
419
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
420 Json::Value metadata = Json::objectValue;
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
421
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
422 for (std::map<MetadataType, std::string>::const_iterator it = m.begin(); it != m.end(); ++it)
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
423 {
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
424 metadata[EnumerationToString(it->first)] = it->second;
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
425 }
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
426
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
427 target["Metadata"] = metadata;
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
428 }
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
429 }
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
430
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
431
5688
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
432 void ResourceFinder::UpdateRequestLimits()
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
433 {
5690
708952bd869c integration tests are passing with ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5689
diff changeset
434 // By default, use manual paging
5693
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5692
diff changeset
435 pagingMode_ = PagingMode_FullManual;
5690
708952bd869c integration tests are passing with ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5689
diff changeset
436
708952bd869c integration tests are passing with ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5689
diff changeset
437 if (databaseLimits_ != 0)
708952bd869c integration tests are passing with ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5689
diff changeset
438 {
708952bd869c integration tests are passing with ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5689
diff changeset
439 request_.SetLimits(0, databaseLimits_ + 1);
708952bd869c integration tests are passing with ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5689
diff changeset
440 }
5692
7c11a71927a9 improved handling of limits
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5690
diff changeset
441 else
5688
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
442 {
5692
7c11a71927a9 improved handling of limits
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5690
diff changeset
443 request_.ClearLimits();
7c11a71927a9 improved handling of limits
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5690
diff changeset
444 }
5688
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
445
5693
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5692
diff changeset
446 if (lookup_.get() == NULL &&
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5692
diff changeset
447 (hasLimitsSince_ || hasLimitsCount_))
5692
7c11a71927a9 improved handling of limits
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5690
diff changeset
448 {
5693
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5692
diff changeset
449 pagingMode_ = PagingMode_FullDatabase;
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5692
diff changeset
450 request_.SetLimits(limitsSince_, limitsCount_);
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5692
diff changeset
451 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5692
diff changeset
452
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5692
diff changeset
453 if (lookup_.get() != NULL &&
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5692
diff changeset
454 isSimpleLookup_ &&
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5692
diff changeset
455 (hasLimitsSince_ || hasLimitsCount_))
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5692
diff changeset
456 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5692
diff changeset
457 /**
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5692
diff changeset
458 * TODO-FIND: "IDatabaseWrapper::ApplyLookupResources()" only
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5692
diff changeset
459 * accept the "limit" argument. The "since" must be implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5692
diff changeset
460 * manually.
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5692
diff changeset
461 **/
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5692
diff changeset
462
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5692
diff changeset
463 if (hasLimitsSince_ &&
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5692
diff changeset
464 limitsSince_ != 0)
5688
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
465 {
5693
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5692
diff changeset
466 pagingMode_ = PagingMode_ManualSkip;
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5692
diff changeset
467 request_.SetLimits(0, limitsCount_ + limitsSince_);
5692
7c11a71927a9 improved handling of limits
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5690
diff changeset
468 }
5693
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5692
diff changeset
469 else
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5692
diff changeset
470 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5692
diff changeset
471 pagingMode_ = PagingMode_FullDatabase;
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5692
diff changeset
472 request_.SetLimits(0, limitsCount_);
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5692
diff changeset
473 }
5688
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
474 }
5690
708952bd869c integration tests are passing with ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5689
diff changeset
475
708952bd869c integration tests are passing with ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5689
diff changeset
476 // TODO-FIND: More cases could be added, depending on "GetDatabaseCapabilities()"
5688
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
477 }
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
478
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
479
5608
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
480 ResourceFinder::ResourceFinder(ResourceType level,
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
481 bool expand) :
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
482 request_(level),
5688
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
483 databaseLimits_(0),
5693
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5692
diff changeset
484 isSimpleLookup_(true),
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5692
diff changeset
485 pagingMode_(PagingMode_FullManual),
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5692
diff changeset
486 hasLimitsSince_(false),
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5692
diff changeset
487 hasLimitsCount_(false),
5688
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
488 limitsSince_(0),
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
489 limitsCount_(0),
5608
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
490 expand_(expand),
5617
8905ffa45fc2 started listing of children resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5616
diff changeset
491 allowStorageAccess_(true),
5713
d851a54e49b7 removed "includeAllMetadata_" member from ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5709
diff changeset
492 hasRequestedTags_(false)
5608
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
493 {
5688
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
494 UpdateRequestLimits();
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
495
5608
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
496 if (expand)
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
497 {
5619
1864b16bc7b1 added FindRequest::ParentRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5617
diff changeset
498 request_.SetRetrieveMainDicomTags(true);
1864b16bc7b1 added FindRequest::ParentRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5617
diff changeset
499 request_.SetRetrieveMetadata(true);
5608
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
500 request_.SetRetrieveLabels(true);
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
501
5621
732ec9feeea8 introduction of FindRequest::ChildrenRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5620
diff changeset
502 switch (level)
5608
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
503 {
5621
732ec9feeea8 introduction of FindRequest::ChildrenRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5620
diff changeset
504 case ResourceType_Patient:
5676
b744a2cf408a shorten ParentRetrieveSpecification/ChildrenRetrieveSpecification as ParentSpecification/ChildrenSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5674
diff changeset
505 request_.GetChildrenSpecification(ResourceType_Study).SetRetrieveIdentifiers(true);
5621
732ec9feeea8 introduction of FindRequest::ChildrenRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5620
diff changeset
506 break;
732ec9feeea8 introduction of FindRequest::ChildrenRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5620
diff changeset
507
732ec9feeea8 introduction of FindRequest::ChildrenRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5620
diff changeset
508 case ResourceType_Study:
5676
b744a2cf408a shorten ParentRetrieveSpecification/ChildrenRetrieveSpecification as ParentSpecification/ChildrenSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5674
diff changeset
509 request_.GetChildrenSpecification(ResourceType_Series).SetRetrieveIdentifiers(true);
5621
732ec9feeea8 introduction of FindRequest::ChildrenRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5620
diff changeset
510 request_.SetRetrieveParentIdentifier(true);
732ec9feeea8 introduction of FindRequest::ChildrenRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5620
diff changeset
511 break;
5608
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
512
5621
732ec9feeea8 introduction of FindRequest::ChildrenRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5620
diff changeset
513 case ResourceType_Series:
5676
b744a2cf408a shorten ParentRetrieveSpecification/ChildrenRetrieveSpecification as ParentSpecification/ChildrenSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5674
diff changeset
514 request_.GetChildrenSpecification(ResourceType_Instance).AddMetadata(MetadataType_Instance_IndexInSeries); // required for the SeriesStatus
b744a2cf408a shorten ParentRetrieveSpecification/ChildrenRetrieveSpecification as ParentSpecification/ChildrenSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5674
diff changeset
515 request_.GetChildrenSpecification(ResourceType_Instance).SetRetrieveIdentifiers(true);
5621
732ec9feeea8 introduction of FindRequest::ChildrenRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5620
diff changeset
516 request_.SetRetrieveParentIdentifier(true);
732ec9feeea8 introduction of FindRequest::ChildrenRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5620
diff changeset
517 break;
732ec9feeea8 introduction of FindRequest::ChildrenRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5620
diff changeset
518
732ec9feeea8 introduction of FindRequest::ChildrenRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5620
diff changeset
519 case ResourceType_Instance:
732ec9feeea8 introduction of FindRequest::ChildrenRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5620
diff changeset
520 request_.SetRetrieveAttachments(true); // for FileSize & FileUuid
732ec9feeea8 introduction of FindRequest::ChildrenRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5620
diff changeset
521 request_.SetRetrieveParentIdentifier(true);
732ec9feeea8 introduction of FindRequest::ChildrenRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5620
diff changeset
522 break;
732ec9feeea8 introduction of FindRequest::ChildrenRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5620
diff changeset
523
732ec9feeea8 introduction of FindRequest::ChildrenRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5620
diff changeset
524 default:
732ec9feeea8 introduction of FindRequest::ChildrenRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5620
diff changeset
525 throw OrthancException(ErrorCode_ParameterOutOfRange);
5608
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
526 }
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
527 }
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
528 }
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
529
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
530
5688
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
531 void ResourceFinder::SetDatabaseLimits(uint64_t limits)
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
532 {
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
533 databaseLimits_ = limits;
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
534 UpdateRequestLimits();
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
535 }
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
536
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
537
5693
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5692
diff changeset
538 void ResourceFinder::SetLimitsSince(uint64_t since)
5688
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
539 {
5693
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5692
diff changeset
540 if (hasLimitsSince_)
5688
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
541 {
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
542 throw OrthancException(ErrorCode_BadSequenceOfCalls);
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
543 }
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
544 else
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
545 {
5693
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5692
diff changeset
546 hasLimitsSince_ = true;
5688
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
547 limitsSince_ = since;
5693
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5692
diff changeset
548 UpdateRequestLimits();
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5692
diff changeset
549 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5692
diff changeset
550 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5692
diff changeset
551
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5692
diff changeset
552
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5692
diff changeset
553 void ResourceFinder::SetLimitsCount(uint64_t count)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5692
diff changeset
554 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5692
diff changeset
555 if (hasLimitsCount_)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5692
diff changeset
556 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5692
diff changeset
557 throw OrthancException(ErrorCode_BadSequenceOfCalls);
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5692
diff changeset
558 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5692
diff changeset
559 else
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5692
diff changeset
560 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5692
diff changeset
561 hasLimitsCount_ = true;
5688
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
562 limitsCount_ = count;
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
563 UpdateRequestLimits();
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
564 }
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
565 }
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
566
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
567
5682
fd4c5e064cbe started refactoring of ServerContext::Apply()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5676
diff changeset
568 void ResourceFinder::SetDatabaseLookup(const DatabaseLookup& lookup)
fd4c5e064cbe started refactoring of ServerContext::Apply()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5676
diff changeset
569 {
5694
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5693
diff changeset
570 MainDicomTagsRegistry registry;
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5693
diff changeset
571
5686
11575590e493 integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5682
diff changeset
572 lookup_.reset(lookup.Clone());
11575590e493 integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5682
diff changeset
573
11575590e493 integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5682
diff changeset
574 for (size_t i = 0; i < lookup.GetConstraintsCount(); i++)
11575590e493 integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5682
diff changeset
575 {
11575590e493 integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5682
diff changeset
576 DicomTag tag = lookup.GetConstraint(i).GetTag();
11575590e493 integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5682
diff changeset
577 if (IsComputedTag(tag))
11575590e493 integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5682
diff changeset
578 {
11575590e493 integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5682
diff changeset
579 AddRequestedTag(tag);
11575590e493 integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5682
diff changeset
580 }
5694
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5693
diff changeset
581 else
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5693
diff changeset
582 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5693
diff changeset
583 ResourceType level;
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5693
diff changeset
584 DicomTagType tagType;
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5693
diff changeset
585 registry.LookupTag(level, tagType, tag);
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5693
diff changeset
586 if (tagType == DicomTagType_Generic)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5693
diff changeset
587 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5693
diff changeset
588 AddRequestedTag(tag);
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5693
diff changeset
589 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5693
diff changeset
590 }
5686
11575590e493 integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5682
diff changeset
591 }
11575590e493 integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5682
diff changeset
592
5693
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5692
diff changeset
593 isSimpleLookup_ = registry.NormalizeLookup(request_.GetDicomTagConstraints(), lookup, request_.GetLevel());
5686
11575590e493 integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5682
diff changeset
594
5690
708952bd869c integration tests are passing with ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5689
diff changeset
595 // "request_.GetDicomTagConstraints()" only contains constraints on main DICOM tags
708952bd869c integration tests are passing with ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5689
diff changeset
596
5686
11575590e493 integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5682
diff changeset
597 for (size_t i = 0; i < request_.GetDicomTagConstraints().GetSize(); i++)
11575590e493 integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5682
diff changeset
598 {
5690
708952bd869c integration tests are passing with ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5689
diff changeset
599 const DatabaseConstraint& constraint = request_.GetDicomTagConstraints().GetConstraint(i);
708952bd869c integration tests are passing with ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5689
diff changeset
600 if (constraint.GetLevel() == request_.GetLevel())
708952bd869c integration tests are passing with ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5689
diff changeset
601 {
708952bd869c integration tests are passing with ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5689
diff changeset
602 request_.SetRetrieveMainDicomTags(true);
708952bd869c integration tests are passing with ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5689
diff changeset
603 }
708952bd869c integration tests are passing with ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5689
diff changeset
604 else if (IsResourceLevelAboveOrEqual(constraint.GetLevel(), request_.GetLevel()))
5686
11575590e493 integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5682
diff changeset
605 {
5690
708952bd869c integration tests are passing with ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5689
diff changeset
606 request_.GetParentSpecification(constraint.GetLevel()).SetRetrieveMainDicomTags(true);
708952bd869c integration tests are passing with ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5689
diff changeset
607 }
708952bd869c integration tests are passing with ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5689
diff changeset
608 else
708952bd869c integration tests are passing with ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5689
diff changeset
609 {
708952bd869c integration tests are passing with ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5689
diff changeset
610 LOG(WARNING) << "Executing a database lookup at level " << EnumerationToString(request_.GetLevel())
708952bd869c integration tests are passing with ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5689
diff changeset
611 << " on main DICOM tag " << constraint.GetTag().Format() << " from an inferior level ("
708952bd869c integration tests are passing with ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5689
diff changeset
612 << EnumerationToString(constraint.GetLevel()) << "), this will return no result";
708952bd869c integration tests are passing with ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5689
diff changeset
613 }
708952bd869c integration tests are passing with ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5689
diff changeset
614
708952bd869c integration tests are passing with ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5689
diff changeset
615 if (IsComputedTag(constraint.GetTag()))
708952bd869c integration tests are passing with ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5689
diff changeset
616 {
708952bd869c integration tests are passing with ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5689
diff changeset
617 // Sanity check
5686
11575590e493 integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5682
diff changeset
618 throw OrthancException(ErrorCode_InternalError);
11575590e493 integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5682
diff changeset
619 }
11575590e493 integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5682
diff changeset
620 }
5692
7c11a71927a9 improved handling of limits
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5690
diff changeset
621
7c11a71927a9 improved handling of limits
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5690
diff changeset
622 UpdateRequestLimits();
5682
fd4c5e064cbe started refactoring of ServerContext::Apply()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5676
diff changeset
623 }
fd4c5e064cbe started refactoring of ServerContext::Apply()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5676
diff changeset
624
fd4c5e064cbe started refactoring of ServerContext::Apply()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5676
diff changeset
625
5686
11575590e493 integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5682
diff changeset
626 void ResourceFinder::AddRequestedTag(const DicomTag& tag)
5609
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
627 {
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
628 if (DicomMap::IsMainDicomTag(tag, ResourceType_Patient))
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
629 {
5620
4bfd885fb45f optimization as patient-level tags are copied at study level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5619
diff changeset
630 if (request_.GetLevel() == ResourceType_Patient)
4bfd885fb45f optimization as patient-level tags are copied at study level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5619
diff changeset
631 {
5697
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5696
diff changeset
632 request_.SetRetrieveMainDicomTags(true);
5620
4bfd885fb45f optimization as patient-level tags are copied at study level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5619
diff changeset
633 requestedPatientTags_.insert(tag);
4bfd885fb45f optimization as patient-level tags are copied at study level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5619
diff changeset
634 }
4bfd885fb45f optimization as patient-level tags are copied at study level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5619
diff changeset
635 else
4bfd885fb45f optimization as patient-level tags are copied at study level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5619
diff changeset
636 {
4bfd885fb45f optimization as patient-level tags are copied at study level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5619
diff changeset
637 /**
4bfd885fb45f optimization as patient-level tags are copied at study level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5619
diff changeset
638 * This comes from the fact that patient-level tags are copied
4bfd885fb45f optimization as patient-level tags are copied at study level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5619
diff changeset
639 * at the study level, as implemented by "ResourcesContent::AddResource()".
4bfd885fb45f optimization as patient-level tags are copied at study level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5619
diff changeset
640 **/
5697
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5696
diff changeset
641 requestedStudyTags_.insert(tag);
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5696
diff changeset
642
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5696
diff changeset
643 if (request_.GetLevel() == ResourceType_Study)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5696
diff changeset
644 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5696
diff changeset
645 request_.SetRetrieveMainDicomTags(true);
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5696
diff changeset
646 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5696
diff changeset
647 else
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5696
diff changeset
648 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5696
diff changeset
649 request_.GetParentSpecification(ResourceType_Study).SetRetrieveMainDicomTags(true);
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5696
diff changeset
650 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5696
diff changeset
651
5620
4bfd885fb45f optimization as patient-level tags are copied at study level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5619
diff changeset
652 requestedStudyTags_.insert(tag);
4bfd885fb45f optimization as patient-level tags are copied at study level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5619
diff changeset
653 }
5665
d8c86698110c implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
654
d8c86698110c implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
655 hasRequestedTags_ = true;
5609
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
656 }
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
657 else if (DicomMap::IsMainDicomTag(tag, ResourceType_Study))
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
658 {
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
659 if (request_.GetLevel() == ResourceType_Patient)
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
660 {
5612
599ce5ed126c added more tolerance to behave like previous releases
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5610
diff changeset
661 LOG(WARNING) << "Requested tag " << tag.Format()
599ce5ed126c added more tolerance to behave like previous releases
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5610
diff changeset
662 << " should only be read at the study, series, or instance level";
599ce5ed126c added more tolerance to behave like previous releases
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5610
diff changeset
663 requestedTagsFromFileStorage_.insert(tag);
599ce5ed126c added more tolerance to behave like previous releases
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5610
diff changeset
664 request_.SetRetrieveOneInstanceIdentifier(true);
5609
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
665 }
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
666 else
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
667 {
5697
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5696
diff changeset
668 if (request_.GetLevel() == ResourceType_Study)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5696
diff changeset
669 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5696
diff changeset
670 request_.SetRetrieveMainDicomTags(true);
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5696
diff changeset
671 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5696
diff changeset
672 else
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5696
diff changeset
673 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5696
diff changeset
674 request_.GetParentSpecification(ResourceType_Study).SetRetrieveMainDicomTags(true);
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5696
diff changeset
675 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5696
diff changeset
676
5609
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
677 requestedStudyTags_.insert(tag);
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
678 }
5665
d8c86698110c implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
679
d8c86698110c implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
680 hasRequestedTags_ = true;
5609
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
681 }
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
682 else if (DicomMap::IsMainDicomTag(tag, ResourceType_Series))
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
683 {
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
684 if (request_.GetLevel() == ResourceType_Patient ||
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
685 request_.GetLevel() == ResourceType_Study)
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
686 {
5612
599ce5ed126c added more tolerance to behave like previous releases
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5610
diff changeset
687 LOG(WARNING) << "Requested tag " << tag.Format()
599ce5ed126c added more tolerance to behave like previous releases
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5610
diff changeset
688 << " should only be read at the series or instance level";
599ce5ed126c added more tolerance to behave like previous releases
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5610
diff changeset
689 requestedTagsFromFileStorage_.insert(tag);
599ce5ed126c added more tolerance to behave like previous releases
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5610
diff changeset
690 request_.SetRetrieveOneInstanceIdentifier(true);
5609
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
691 }
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
692 else
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
693 {
5697
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5696
diff changeset
694 if (request_.GetLevel() == ResourceType_Series)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5696
diff changeset
695 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5696
diff changeset
696 request_.SetRetrieveMainDicomTags(true);
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5696
diff changeset
697 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5696
diff changeset
698 else
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5696
diff changeset
699 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5696
diff changeset
700 request_.GetParentSpecification(ResourceType_Series).SetRetrieveMainDicomTags(true);
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5696
diff changeset
701 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5696
diff changeset
702
5609
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
703 requestedSeriesTags_.insert(tag);
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
704 }
5665
d8c86698110c implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
705
d8c86698110c implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
706 hasRequestedTags_ = true;
5609
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
707 }
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
708 else if (DicomMap::IsMainDicomTag(tag, ResourceType_Instance))
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
709 {
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
710 if (request_.GetLevel() == ResourceType_Patient ||
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
711 request_.GetLevel() == ResourceType_Study ||
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
712 request_.GetLevel() == ResourceType_Series)
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
713 {
5612
599ce5ed126c added more tolerance to behave like previous releases
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5610
diff changeset
714 LOG(WARNING) << "Requested tag " << tag.Format()
599ce5ed126c added more tolerance to behave like previous releases
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5610
diff changeset
715 << " should only be read at the instance level";
599ce5ed126c added more tolerance to behave like previous releases
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5610
diff changeset
716 requestedTagsFromFileStorage_.insert(tag);
599ce5ed126c added more tolerance to behave like previous releases
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5610
diff changeset
717 request_.SetRetrieveOneInstanceIdentifier(true);
5609
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
718 }
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
719 else
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
720 {
5699
e8e028aed89f c-find tests pass using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5697
diff changeset
721 request_.SetRetrieveMainDicomTags(true);
5609
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
722 requestedInstanceTags_.insert(tag);
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
723 }
5665
d8c86698110c implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
724
d8c86698110c implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
725 hasRequestedTags_ = true;
d8c86698110c implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
726 }
5666
aa231c18b9d2 adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5665
diff changeset
727 else if (tag == DICOM_TAG_NUMBER_OF_PATIENT_RELATED_STUDIES)
aa231c18b9d2 adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5665
diff changeset
728 {
aa231c18b9d2 adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5665
diff changeset
729 ConfigureChildrenCountComputedTag(tag, ResourceType_Patient, ResourceType_Study);
aa231c18b9d2 adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5665
diff changeset
730 }
aa231c18b9d2 adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5665
diff changeset
731 else if (tag == DICOM_TAG_NUMBER_OF_PATIENT_RELATED_SERIES)
aa231c18b9d2 adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5665
diff changeset
732 {
aa231c18b9d2 adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5665
diff changeset
733 ConfigureChildrenCountComputedTag(tag, ResourceType_Patient, ResourceType_Series);
aa231c18b9d2 adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5665
diff changeset
734 }
aa231c18b9d2 adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5665
diff changeset
735 else if (tag == DICOM_TAG_NUMBER_OF_PATIENT_RELATED_INSTANCES)
aa231c18b9d2 adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5665
diff changeset
736 {
aa231c18b9d2 adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5665
diff changeset
737 ConfigureChildrenCountComputedTag(tag, ResourceType_Patient, ResourceType_Instance);
aa231c18b9d2 adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5665
diff changeset
738 }
aa231c18b9d2 adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5665
diff changeset
739 else if (tag == DICOM_TAG_NUMBER_OF_STUDY_RELATED_SERIES)
aa231c18b9d2 adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5665
diff changeset
740 {
aa231c18b9d2 adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5665
diff changeset
741 ConfigureChildrenCountComputedTag(tag, ResourceType_Study, ResourceType_Series);
aa231c18b9d2 adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5665
diff changeset
742 }
aa231c18b9d2 adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5665
diff changeset
743 else if (tag == DICOM_TAG_NUMBER_OF_STUDY_RELATED_INSTANCES)
aa231c18b9d2 adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5665
diff changeset
744 {
aa231c18b9d2 adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5665
diff changeset
745 ConfigureChildrenCountComputedTag(tag, ResourceType_Study, ResourceType_Instance);
aa231c18b9d2 adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5665
diff changeset
746 }
aa231c18b9d2 adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5665
diff changeset
747 else if (tag == DICOM_TAG_NUMBER_OF_SERIES_RELATED_INSTANCES)
aa231c18b9d2 adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5665
diff changeset
748 {
aa231c18b9d2 adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5665
diff changeset
749 ConfigureChildrenCountComputedTag(tag, ResourceType_Series, ResourceType_Instance);
aa231c18b9d2 adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5665
diff changeset
750 }
5668
bd1352bd9d82 configuring requests for ModalitiesInStudy and SOPClassesInStudy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5667
diff changeset
751 else if (tag == DICOM_TAG_SOP_CLASSES_IN_STUDY)
bd1352bd9d82 configuring requests for ModalitiesInStudy and SOPClassesInStudy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5667
diff changeset
752 {
bd1352bd9d82 configuring requests for ModalitiesInStudy and SOPClassesInStudy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5667
diff changeset
753 requestedComputedTags_.insert(tag);
bd1352bd9d82 configuring requests for ModalitiesInStudy and SOPClassesInStudy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5667
diff changeset
754 hasRequestedTags_ = true;
5676
b744a2cf408a shorten ParentRetrieveSpecification/ChildrenRetrieveSpecification as ParentSpecification/ChildrenSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5674
diff changeset
755 request_.GetChildrenSpecification(ResourceType_Instance).AddMetadata(MetadataType_Instance_SopClassUid);
5668
bd1352bd9d82 configuring requests for ModalitiesInStudy and SOPClassesInStudy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5667
diff changeset
756 }
bd1352bd9d82 configuring requests for ModalitiesInStudy and SOPClassesInStudy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5667
diff changeset
757 else if (tag == DICOM_TAG_MODALITIES_IN_STUDY)
bd1352bd9d82 configuring requests for ModalitiesInStudy and SOPClassesInStudy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5667
diff changeset
758 {
bd1352bd9d82 configuring requests for ModalitiesInStudy and SOPClassesInStudy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5667
diff changeset
759 requestedComputedTags_.insert(tag);
bd1352bd9d82 configuring requests for ModalitiesInStudy and SOPClassesInStudy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5667
diff changeset
760 hasRequestedTags_ = true;
5676
b744a2cf408a shorten ParentRetrieveSpecification/ChildrenRetrieveSpecification as ParentSpecification/ChildrenSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5674
diff changeset
761 request_.GetChildrenSpecification(ResourceType_Series).AddMainDicomTag(DICOM_TAG_MODALITY);
5668
bd1352bd9d82 configuring requests for ModalitiesInStudy and SOPClassesInStudy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5667
diff changeset
762 }
5665
d8c86698110c implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
763 else if (tag == DICOM_TAG_INSTANCE_AVAILABILITY)
d8c86698110c implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
764 {
d8c86698110c implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
765 requestedComputedTags_.insert(tag);
d8c86698110c implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
766 hasRequestedTags_ = true;
d8c86698110c implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
767 }
5609
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
768 else
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
769 {
5665
d8c86698110c implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
770 // This is neither a main DICOM tag, nor a computed DICOM tag:
d8c86698110c implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
771 // We will be forced to access the DICOM file anyway
5609
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
772 requestedTagsFromFileStorage_.insert(tag);
5610
d4b570834d3a adding safeguards around FindRequest::SetRetrieveOneInstanceIdentifier()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5609
diff changeset
773
d4b570834d3a adding safeguards around FindRequest::SetRetrieveOneInstanceIdentifier()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5609
diff changeset
774 if (request_.GetLevel() != ResourceType_Instance)
d4b570834d3a adding safeguards around FindRequest::SetRetrieveOneInstanceIdentifier()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5609
diff changeset
775 {
d4b570834d3a adding safeguards around FindRequest::SetRetrieveOneInstanceIdentifier()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5609
diff changeset
776 request_.SetRetrieveOneInstanceIdentifier(true);
d4b570834d3a adding safeguards around FindRequest::SetRetrieveOneInstanceIdentifier()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5609
diff changeset
777 }
5665
d8c86698110c implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
778
d8c86698110c implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
779 hasRequestedTags_ = true;
5609
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
780 }
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
781 }
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
782
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
783
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
784 void ResourceFinder::AddRequestedTags(const std::set<DicomTag>& tags)
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
785 {
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
786 for (std::set<DicomTag>::const_iterator it = tags.begin(); it != tags.end(); ++it)
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
787 {
5686
11575590e493 integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5682
diff changeset
788 AddRequestedTag(*it);
5609
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
789 }
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
790 }
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
791
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
792
5666
aa231c18b9d2 adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5665
diff changeset
793 static void InjectRequestedTags(DicomMap& requestedTags,
aa231c18b9d2 adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5665
diff changeset
794 std::set<DicomTag>& missingTags /* out */,
aa231c18b9d2 adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5665
diff changeset
795 const FindResponse::Resource& resource,
aa231c18b9d2 adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5665
diff changeset
796 ResourceType level,
aa231c18b9d2 adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5665
diff changeset
797 const std::set<DicomTag>& tags)
5665
d8c86698110c implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
798 {
5666
aa231c18b9d2 adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5665
diff changeset
799 if (!tags.empty())
5665
d8c86698110c implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
800 {
5666
aa231c18b9d2 adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5665
diff changeset
801 DicomMap m;
aa231c18b9d2 adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5665
diff changeset
802 resource.GetMainDicomTags(m, level);
5665
d8c86698110c implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
803
5666
aa231c18b9d2 adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5665
diff changeset
804 for (std::set<DicomTag>::const_iterator it = tags.begin(); it != tags.end(); ++it)
aa231c18b9d2 adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5665
diff changeset
805 {
aa231c18b9d2 adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5665
diff changeset
806 std::string value;
aa231c18b9d2 adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5665
diff changeset
807 if (m.LookupStringValue(value, *it, false /* not binary */))
5665
d8c86698110c implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
808 {
5666
aa231c18b9d2 adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5665
diff changeset
809 requestedTags.SetValue(*it, value, false /* not binary */);
5665
d8c86698110c implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
810 }
5666
aa231c18b9d2 adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5665
diff changeset
811 else
5665
d8c86698110c implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
812 {
5666
aa231c18b9d2 adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5665
diff changeset
813 // This is the case where the Housekeeper should be run
aa231c18b9d2 adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5665
diff changeset
814 missingTags.insert(*it);
5665
d8c86698110c implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
815 }
5666
aa231c18b9d2 adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5665
diff changeset
816 }
5665
d8c86698110c implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
817 }
d8c86698110c implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
818 }
d8c86698110c implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
819
d8c86698110c implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
820
d8c86698110c implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
821 static void ReadMissingTagsFromStorageArea(DicomMap& requestedTags,
d8c86698110c implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
822 ServerContext& context,
d8c86698110c implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
823 const FindRequest& request,
d8c86698110c implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
824 const FindResponse::Resource& resource,
d8c86698110c implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
825 const std::set<DicomTag>& missingTags)
d8c86698110c implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
826 {
d8c86698110c implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
827 OrthancConfiguration::ReaderLock lock;
d8c86698110c implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
828 if (lock.GetConfiguration().IsWarningEnabled(Warnings_001_TagsBeingReadFromStorage))
d8c86698110c implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
829 {
d8c86698110c implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
830 std::string missings;
d8c86698110c implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
831 FromDcmtkBridge::FormatListOfTags(missings, missingTags);
d8c86698110c implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
832
5699
e8e028aed89f c-find tests pass using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5697
diff changeset
833 LOG(WARNING) << "W001: Accessing DICOM tags from storage when accessing "
5665
d8c86698110c implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
834 << Orthanc::GetResourceTypeText(resource.GetLevel(), false, false)
d8c86698110c implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
835 << ": " << missings;
d8c86698110c implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
836 }
d8c86698110c implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
837
d8c86698110c implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
838 std::string instancePublicId;
d8c86698110c implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
839
d8c86698110c implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
840 if (request.IsRetrieveOneInstanceIdentifier())
d8c86698110c implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
841 {
d8c86698110c implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
842 instancePublicId = resource.GetOneInstanceIdentifier();
d8c86698110c implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
843 }
d8c86698110c implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
844 else if (request.GetLevel() == ResourceType_Instance)
d8c86698110c implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
845 {
d8c86698110c implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
846 instancePublicId = resource.GetIdentifier();
d8c86698110c implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
847 }
d8c86698110c implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
848 else
d8c86698110c implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
849 {
d8c86698110c implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
850 FindRequest requestDicomAttachment(request.GetLevel());
d8c86698110c implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
851 requestDicomAttachment.SetOrthancId(request.GetLevel(), resource.GetIdentifier());
d8c86698110c implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
852 requestDicomAttachment.SetRetrieveOneInstanceIdentifier(true);
d8c86698110c implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
853
d8c86698110c implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
854 FindResponse responseDicomAttachment;
d8c86698110c implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
855 context.GetIndex().ExecuteFind(responseDicomAttachment, requestDicomAttachment);
d8c86698110c implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
856
d8c86698110c implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
857 if (responseDicomAttachment.GetSize() != 1 ||
d8c86698110c implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
858 !responseDicomAttachment.GetResourceByIndex(0).HasOneInstanceIdentifier())
d8c86698110c implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
859 {
d8c86698110c implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
860 throw OrthancException(ErrorCode_InexistentFile);
d8c86698110c implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
861 }
d8c86698110c implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
862 else
d8c86698110c implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
863 {
d8c86698110c implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
864 instancePublicId = responseDicomAttachment.GetResourceByIndex(0).GetOneInstanceIdentifier();
d8c86698110c implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
865 }
d8c86698110c implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
866 }
d8c86698110c implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
867
d8c86698110c implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
868 LOG(INFO) << "Will retrieve missing DICOM tags from instance: " << instancePublicId;
d8c86698110c implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
869
d8c86698110c implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
870 // TODO-FIND: What do we do if the DICOM has been removed since the request?
d8c86698110c implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
871 // Do we fail, or do we skip the resource?
d8c86698110c implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
872
d8c86698110c implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
873 Json::Value tmpDicomAsJson;
d8c86698110c implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
874 context.ReadDicomAsJson(tmpDicomAsJson, instancePublicId, missingTags /* ignoreTagLength */);
d8c86698110c implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
875
d8c86698110c implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
876 DicomMap tmpDicomMap;
d8c86698110c implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
877 tmpDicomMap.FromDicomAsJson(tmpDicomAsJson, false /* append */, true /* parseSequences*/);
d8c86698110c implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
878
d8c86698110c implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
879 for (std::set<DicomTag>::const_iterator it = missingTags.begin(); it != missingTags.end(); ++it)
d8c86698110c implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
880 {
d8c86698110c implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
881 assert(!requestedTags.HasTag(*it));
d8c86698110c implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
882 if (tmpDicomMap.HasTag(*it))
d8c86698110c implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
883 {
d8c86698110c implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
884 requestedTags.SetValue(*it, tmpDicomMap.GetValue(*it));
d8c86698110c implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
885 }
d8c86698110c implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
886 else
d8c86698110c implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
887 {
d8c86698110c implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
888 requestedTags.SetNullValue(*it); // TODO-FIND: Is this compatible with Orthanc <= 1.12.3?
d8c86698110c implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
889 }
d8c86698110c implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
890 }
d8c86698110c implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
891 }
d8c86698110c implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
892
d8c86698110c implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
893
5688
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
894 void ResourceFinder::Execute(IVisitor& visitor,
5621
732ec9feeea8 introduction of FindRequest::ChildrenRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5620
diff changeset
895 ServerContext& context) const
5608
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
896 {
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
897 FindResponse response;
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
898 context.GetIndex().ExecuteFind(response, request_);
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
899
5688
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
900 bool complete;
5693
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5692
diff changeset
901
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5692
diff changeset
902 switch (pagingMode_)
5688
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
903 {
5693
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5692
diff changeset
904 case PagingMode_FullDatabase:
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5692
diff changeset
905 case PagingMode_ManualSkip:
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5692
diff changeset
906 complete = true;
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5692
diff changeset
907 break;
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5692
diff changeset
908
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5692
diff changeset
909 case PagingMode_FullManual:
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5692
diff changeset
910 complete = (databaseLimits_ == 0 ||
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5692
diff changeset
911 response.GetSize() <= databaseLimits_);
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5692
diff changeset
912 break;
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5692
diff changeset
913
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5692
diff changeset
914 default:
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5692
diff changeset
915 throw OrthancException(ErrorCode_InternalError);
5688
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
916 }
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
917
5690
708952bd869c integration tests are passing with ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5689
diff changeset
918 if (lookup_.get() != NULL)
5688
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
919 {
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
920 LOG(INFO) << "Number of candidate resources after fast DB filtering on main DICOM tags: " << response.GetSize();
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
921 }
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
922
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
923 size_t countResults = 0;
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
924 size_t skipped = 0;
5608
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
925
5609
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
926 for (size_t i = 0; i < response.GetSize(); i++)
5608
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
927 {
5609
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
928 const FindResponse::Resource& resource = response.GetResourceByIndex(i);
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
929
5686
11575590e493 integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5682
diff changeset
930 DicomMap requestedTags;
11575590e493 integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5682
diff changeset
931
11575590e493 integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5682
diff changeset
932 if (hasRequestedTags_)
5608
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
933 {
5686
11575590e493 integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5682
diff changeset
934 InjectComputedTags(requestedTags, resource);
5609
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
935
5686
11575590e493 integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5682
diff changeset
936 std::set<DicomTag> missingTags = requestedTagsFromFileStorage_;
11575590e493 integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5682
diff changeset
937 InjectRequestedTags(requestedTags, missingTags, resource, ResourceType_Patient, requestedPatientTags_);
11575590e493 integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5682
diff changeset
938 InjectRequestedTags(requestedTags, missingTags, resource, ResourceType_Study, requestedStudyTags_);
11575590e493 integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5682
diff changeset
939 InjectRequestedTags(requestedTags, missingTags, resource, ResourceType_Series, requestedSeriesTags_);
11575590e493 integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5682
diff changeset
940 InjectRequestedTags(requestedTags, missingTags, resource, ResourceType_Instance, requestedInstanceTags_);
5609
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
941
5686
11575590e493 integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5682
diff changeset
942 if (!missingTags.empty())
11575590e493 integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5682
diff changeset
943 {
11575590e493 integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5682
diff changeset
944 if (!allowStorageAccess_)
11575590e493 integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5682
diff changeset
945 {
11575590e493 integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5682
diff changeset
946 throw OrthancException(ErrorCode_BadSequenceOfCalls,
11575590e493 integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5682
diff changeset
947 "Cannot add missing requested tags, as access to file storage is disallowed");
11575590e493 integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5682
diff changeset
948 }
11575590e493 integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5682
diff changeset
949 else
5610
d4b570834d3a adding safeguards around FindRequest::SetRetrieveOneInstanceIdentifier()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5609
diff changeset
950 {
5686
11575590e493 integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5682
diff changeset
951 ReadMissingTagsFromStorageArea(requestedTags, context, request_, resource, missingTags);
11575590e493 integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5682
diff changeset
952 }
11575590e493 integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5682
diff changeset
953 }
11575590e493 integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5682
diff changeset
954 }
11575590e493 integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5682
diff changeset
955
11575590e493 integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5682
diff changeset
956 bool match = true;
11575590e493 integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5682
diff changeset
957
11575590e493 integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5682
diff changeset
958 if (lookup_.get() != NULL)
11575590e493 integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5682
diff changeset
959 {
11575590e493 integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5682
diff changeset
960 DicomMap tags;
5690
708952bd869c integration tests are passing with ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5689
diff changeset
961 resource.GetAllMainDicomTags(tags);
5686
11575590e493 integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5682
diff changeset
962 tags.Merge(requestedTags);
11575590e493 integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5682
diff changeset
963 match = lookup_->IsMatch(tags);
11575590e493 integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5682
diff changeset
964 }
11575590e493 integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5682
diff changeset
965
11575590e493 integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5682
diff changeset
966 if (match)
11575590e493 integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5682
diff changeset
967 {
5693
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5692
diff changeset
968 if (pagingMode_ == PagingMode_FullDatabase)
5688
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
969 {
5696
0f8b6214308a preparing to use ResourceFinder in OrthancFindRequestHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5694
diff changeset
970 visitor.Apply(resource, requestedTags);
5688
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
971 }
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
972 else
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
973 {
5693
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5692
diff changeset
974 if (hasLimitsSince_ &&
5688
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
975 skipped < limitsSince_)
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
976 {
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
977 skipped++;
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
978 }
5693
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5692
diff changeset
979 else if (hasLimitsCount_ &&
5688
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
980 countResults >= limitsCount_)
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
981 {
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
982 // Too many results, don't mark as complete
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
983 complete = false;
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
984 break;
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
985 }
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
986 else
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
987 {
5696
0f8b6214308a preparing to use ResourceFinder in OrthancFindRequestHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5694
diff changeset
988 visitor.Apply(resource, requestedTags);
5688
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
989 countResults++;
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
990 }
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
991 }
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
992 }
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
993 }
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
994
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
995 if (complete)
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
996 {
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
997 visitor.MarkAsComplete();
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
998 }
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
999 }
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
1000
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
1001
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
1002 void ResourceFinder::Execute(Json::Value& target,
5709
476b1db52110 removed the "format_" member from ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5702
diff changeset
1003 ServerContext& context,
5713
d851a54e49b7 removed "includeAllMetadata_" member from ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5709
diff changeset
1004 DicomToJsonFormat format,
d851a54e49b7 removed "includeAllMetadata_" member from ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5709
diff changeset
1005 bool includeAllMetadata) const
5688
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
1006 {
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
1007 class Visitor : public IVisitor
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
1008 {
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
1009 private:
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
1010 const ResourceFinder& that_;
5709
476b1db52110 removed the "format_" member from ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5702
diff changeset
1011 ServerIndex& index_;
476b1db52110 removed the "format_" member from ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5702
diff changeset
1012 Json::Value& target_;
476b1db52110 removed the "format_" member from ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5702
diff changeset
1013 DicomToJsonFormat format_;
476b1db52110 removed the "format_" member from ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5702
diff changeset
1014 bool hasRequestedTags_;
5713
d851a54e49b7 removed "includeAllMetadata_" member from ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5709
diff changeset
1015 bool includeAllMetadata_;
5688
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
1016
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
1017 public:
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
1018 Visitor(const ResourceFinder& that,
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
1019 ServerIndex& index,
5696
0f8b6214308a preparing to use ResourceFinder in OrthancFindRequestHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5694
diff changeset
1020 Json::Value& target,
5709
476b1db52110 removed the "format_" member from ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5702
diff changeset
1021 DicomToJsonFormat format,
5713
d851a54e49b7 removed "includeAllMetadata_" member from ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5709
diff changeset
1022 bool hasRequestedTags,
d851a54e49b7 removed "includeAllMetadata_" member from ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5709
diff changeset
1023 bool includeAllMetadata) :
5688
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
1024 that_(that),
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
1025 index_(index),
5696
0f8b6214308a preparing to use ResourceFinder in OrthancFindRequestHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5694
diff changeset
1026 target_(target),
5709
476b1db52110 removed the "format_" member from ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5702
diff changeset
1027 format_(format),
5713
d851a54e49b7 removed "includeAllMetadata_" member from ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5709
diff changeset
1028 hasRequestedTags_(hasRequestedTags),
d851a54e49b7 removed "includeAllMetadata_" member from ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5709
diff changeset
1029 includeAllMetadata_(includeAllMetadata)
5688
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
1030 {
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
1031 }
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
1032
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
1033 virtual void Apply(const FindResponse::Resource& resource,
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
1034 const DicomMap& requestedTags) ORTHANC_OVERRIDE
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
1035 {
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
1036 if (that_.expand_)
5686
11575590e493 integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5682
diff changeset
1037 {
11575590e493 integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5682
diff changeset
1038 Json::Value item;
5713
d851a54e49b7 removed "includeAllMetadata_" member from ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5709
diff changeset
1039 that_.Expand(item, resource, index_, format_, includeAllMetadata_);
5686
11575590e493 integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5682
diff changeset
1040
5696
0f8b6214308a preparing to use ResourceFinder in OrthancFindRequestHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5694
diff changeset
1041 if (hasRequestedTags_)
5686
11575590e493 integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5682
diff changeset
1042 {
11575590e493 integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5682
diff changeset
1043 static const char* const REQUESTED_TAGS = "RequestedTags";
11575590e493 integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5682
diff changeset
1044 item[REQUESTED_TAGS] = Json::objectValue;
5709
476b1db52110 removed the "format_" member from ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5702
diff changeset
1045 FromDcmtkBridge::ToJson(item[REQUESTED_TAGS], requestedTags, format_);
5609
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
1046 }
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
1047
5688
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
1048 target_.append(item);
5609
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
1049 }
5686
11575590e493 integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5682
diff changeset
1050 else
11575590e493 integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5682
diff changeset
1051 {
5688
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
1052 target_.append(resource.GetIdentifier());
5686
11575590e493 integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5682
diff changeset
1053 }
5608
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1054 }
5688
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
1055
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
1056 virtual void MarkAsComplete() ORTHANC_OVERRIDE
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
1057 {
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
1058 }
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
1059 };
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
1060
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
1061 target = Json::arrayValue;
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
1062
5713
d851a54e49b7 removed "includeAllMetadata_" member from ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5709
diff changeset
1063 Visitor visitor(*this, context.GetIndex(), target, format, hasRequestedTags_, includeAllMetadata);
5688
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
1064 Execute(visitor, context);
5608
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1065 }
5615
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5612
diff changeset
1066
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5612
diff changeset
1067
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5612
diff changeset
1068 bool ResourceFinder::ExecuteOneResource(Json::Value& target,
5709
476b1db52110 removed the "format_" member from ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5702
diff changeset
1069 ServerContext& context,
5713
d851a54e49b7 removed "includeAllMetadata_" member from ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5709
diff changeset
1070 DicomToJsonFormat format,
d851a54e49b7 removed "includeAllMetadata_" member from ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5709
diff changeset
1071 bool includeAllMetadata) const
5615
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5612
diff changeset
1072 {
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5612
diff changeset
1073 Json::Value answer;
5713
d851a54e49b7 removed "includeAllMetadata_" member from ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5709
diff changeset
1074 Execute(answer, context, format, includeAllMetadata);
5615
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5612
diff changeset
1075
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5612
diff changeset
1076 if (answer.type() != Json::arrayValue)
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5612
diff changeset
1077 {
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5612
diff changeset
1078 throw OrthancException(ErrorCode_InternalError);
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5612
diff changeset
1079 }
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5612
diff changeset
1080 else if (answer.size() > 1)
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5612
diff changeset
1081 {
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5612
diff changeset
1082 throw OrthancException(ErrorCode_DatabasePlugin);
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5612
diff changeset
1083 }
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5612
diff changeset
1084 else if (answer.empty())
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5612
diff changeset
1085 {
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5612
diff changeset
1086 // Inexistent resource (or was deleted between the first and second phases)
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5612
diff changeset
1087 return false;
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5612
diff changeset
1088 }
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5612
diff changeset
1089 else
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5612
diff changeset
1090 {
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5612
diff changeset
1091 target = answer[0];
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5612
diff changeset
1092 return true;
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5612
diff changeset
1093 }
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5612
diff changeset
1094 }
5608
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1095 }