annotate OrthancServer/Sources/Database/Compatibility/GenericFind.cpp @ 5595:a87f2a56257d find-refactoring

implemented FindRequest::retrieveChildrenMetadata_
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 07 May 2024 12:53:12 +0200
parents a906dc19264c
children 81a29ad7fb4b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5554
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 /**
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2 * Orthanc - A Lightweight, RESTful DICOM Store
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
4 * Department, University Hospital of Liege, Belgium
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
5 * Copyright (C) 2017-2024 Osimis S.A., Belgium
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6 * Copyright (C) 2021-2024 Sebastien Jodogne, ICTEAM UCLouvain, Belgium
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 *
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 * This program is free software: you can redistribute it and/or
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 * modify it under the terms of the GNU General Public License as
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 * published by the Free Software Foundation, either version 3 of the
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 * License, or (at your option) any later version.
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 *
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 * This program is distributed in the hope that it will be useful, but
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16 * General Public License for more details.
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17 *
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18 * You should have received a copy of the GNU General Public License
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20 **/
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23 #include "GenericFind.h"
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24
5592
1e2631b8b9af GenericFind::Execute() is working for a basic request
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5590
diff changeset
25 #include "../../../../OrthancFramework/Sources/DicomFormat/DicomArray.h"
5554
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26 #include "../../../../OrthancFramework/Sources/OrthancException.h"
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29 namespace Orthanc
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30 {
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31 namespace Compatibility
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32 {
5593
862b54b4cfe2 implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5592
diff changeset
33 void GenericFind::ExecuteFind(std::list<std::string>& identifiers,
862b54b4cfe2 implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5592
diff changeset
34 const FindRequest& request,
862b54b4cfe2 implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5592
diff changeset
35 const std::vector<DatabaseConstraint>& normalized)
5554
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
36 {
5590
8b32213af23e replaced FindRequest::ResponseContent by booleans
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5589
diff changeset
37 if (!request.GetOrthancIdentifiers().HasPatientId() &&
5554
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
38 !request.GetOrthancIdentifiers().HasStudyId() &&
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
39 !request.GetOrthancIdentifiers().HasSeriesId() &&
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
40 !request.GetOrthancIdentifiers().HasInstanceId() &&
5568
b0b5546f1b9f find refactor: re-use existing code. /studies?expand is almost fully implemented with new code
Alain Mazy <am@orthanc.team>
parents: 5567
diff changeset
41 request.GetDicomTagConstraintsCount() == 0 &&
b0b5546f1b9f find refactor: re-use existing code. /studies?expand is almost fully implemented with new code
Alain Mazy <am@orthanc.team>
parents: 5567
diff changeset
42 request.GetMetadataConstraintsCount() == 0 &&
5594
a906dc19264c created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5593
diff changeset
43 request.GetLabels().empty() &&
a906dc19264c created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5593
diff changeset
44 request.GetOrdering().empty())
5554
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
45 {
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
46 if (request.HasLimits())
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
47 {
5593
862b54b4cfe2 implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5592
diff changeset
48 transaction_.GetAllPublicIds(identifiers, request.GetLevel(), request.GetLimitsSince(), request.GetLimitsCount());
5554
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
49 }
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
50 else
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
51 {
5593
862b54b4cfe2 implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5592
diff changeset
52 transaction_.GetAllPublicIds(identifiers, request.GetLevel());
5554
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
53 }
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
54 }
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
55 else
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
56 {
5593
862b54b4cfe2 implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5592
diff changeset
57 throw OrthancException(ErrorCode_NotImplemented); // Not supported
862b54b4cfe2 implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5592
diff changeset
58 }
862b54b4cfe2 implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5592
diff changeset
59 }
862b54b4cfe2 implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5592
diff changeset
60
862b54b4cfe2 implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5592
diff changeset
61
862b54b4cfe2 implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5592
diff changeset
62 void GenericFind::ExecuteExpand(FindResponse& response,
862b54b4cfe2 implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5592
diff changeset
63 const FindRequest& request,
862b54b4cfe2 implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5592
diff changeset
64 const std::string& identifier)
862b54b4cfe2 implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5592
diff changeset
65 {
862b54b4cfe2 implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5592
diff changeset
66 int64_t internalId;
5594
a906dc19264c created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5593
diff changeset
67 ResourceType level;
5595
a87f2a56257d implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5594
diff changeset
68 std::string parent;
a87f2a56257d implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5594
diff changeset
69
a87f2a56257d implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5594
diff changeset
70 if (request.IsRetrieveParentIdentifier())
5593
862b54b4cfe2 implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5592
diff changeset
71 {
5595
a87f2a56257d implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5594
diff changeset
72 if (!transaction_.LookupResourceAndParent(internalId, level, parent, identifier))
a87f2a56257d implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5594
diff changeset
73 {
a87f2a56257d implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5594
diff changeset
74 return; // The resource is not available anymore
a87f2a56257d implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5594
diff changeset
75 }
a87f2a56257d implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5594
diff changeset
76
a87f2a56257d implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5594
diff changeset
77 if (level == ResourceType_Patient)
a87f2a56257d implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5594
diff changeset
78 {
a87f2a56257d implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5594
diff changeset
79 if (!parent.empty())
a87f2a56257d implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5594
diff changeset
80 {
a87f2a56257d implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5594
diff changeset
81 throw OrthancException(ErrorCode_DatabasePlugin);
a87f2a56257d implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5594
diff changeset
82 }
a87f2a56257d implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5594
diff changeset
83 }
a87f2a56257d implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5594
diff changeset
84 else
a87f2a56257d implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5594
diff changeset
85 {
a87f2a56257d implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5594
diff changeset
86 if (parent.empty())
a87f2a56257d implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5594
diff changeset
87 {
a87f2a56257d implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5594
diff changeset
88 throw OrthancException(ErrorCode_DatabasePlugin);
a87f2a56257d implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5594
diff changeset
89 }
a87f2a56257d implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5594
diff changeset
90 }
a87f2a56257d implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5594
diff changeset
91 }
a87f2a56257d implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5594
diff changeset
92 else
a87f2a56257d implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5594
diff changeset
93 {
a87f2a56257d implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5594
diff changeset
94 if (!transaction_.LookupResource(internalId, level, identifier))
a87f2a56257d implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5594
diff changeset
95 {
a87f2a56257d implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5594
diff changeset
96 return; // The resource is not available anymore
a87f2a56257d implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5594
diff changeset
97 }
a87f2a56257d implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5594
diff changeset
98 }
a87f2a56257d implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5594
diff changeset
99
a87f2a56257d implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5594
diff changeset
100 if (level != request.GetLevel())
a87f2a56257d implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5594
diff changeset
101 {
a87f2a56257d implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5594
diff changeset
102 throw OrthancException(ErrorCode_DatabasePlugin);
5554
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
103 }
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
104
5593
862b54b4cfe2 implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5592
diff changeset
105 std::unique_ptr<FindResponse::Resource> resource(new FindResponse::Resource(request.GetLevel(), identifier));
862b54b4cfe2 implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5592
diff changeset
106
5595
a87f2a56257d implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5594
diff changeset
107 if (request.IsRetrieveParentIdentifier())
a87f2a56257d implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5594
diff changeset
108 {
a87f2a56257d implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5594
diff changeset
109 assert(!parent.empty());
a87f2a56257d implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5594
diff changeset
110 resource->SetParentIdentifier(parent);
a87f2a56257d implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5594
diff changeset
111 }
a87f2a56257d implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5594
diff changeset
112
5593
862b54b4cfe2 implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5592
diff changeset
113 if (request.IsRetrieveMainDicomTags())
862b54b4cfe2 implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5592
diff changeset
114 {
862b54b4cfe2 implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5592
diff changeset
115 DicomMap m;
862b54b4cfe2 implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5592
diff changeset
116 transaction_.GetMainDicomTags(m, internalId);
862b54b4cfe2 implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5592
diff changeset
117
862b54b4cfe2 implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5592
diff changeset
118 DicomArray a(m);
862b54b4cfe2 implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5592
diff changeset
119 for (size_t i = 0; i < a.GetSize(); i++)
862b54b4cfe2 implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5592
diff changeset
120 {
862b54b4cfe2 implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5592
diff changeset
121 const DicomElement& element = a.GetElement(i);
862b54b4cfe2 implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5592
diff changeset
122 if (element.GetValue().IsString())
862b54b4cfe2 implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5592
diff changeset
123 {
862b54b4cfe2 implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5592
diff changeset
124 resource->AddStringDicomTag(element.GetTag().GetGroup(), element.GetTag().GetElement(),
862b54b4cfe2 implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5592
diff changeset
125 element.GetValue().GetContent());
862b54b4cfe2 implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5592
diff changeset
126 }
862b54b4cfe2 implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5592
diff changeset
127 else
862b54b4cfe2 implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5592
diff changeset
128 {
862b54b4cfe2 implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5592
diff changeset
129 throw OrthancException(ErrorCode_BadParameterType);
862b54b4cfe2 implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5592
diff changeset
130 }
862b54b4cfe2 implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5592
diff changeset
131 }
862b54b4cfe2 implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5592
diff changeset
132 }
862b54b4cfe2 implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5592
diff changeset
133
5594
a906dc19264c created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5593
diff changeset
134 if (request.IsRetrieveMetadata())
a906dc19264c created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5593
diff changeset
135 {
a906dc19264c created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5593
diff changeset
136 transaction_.GetAllMetadata(resource->GetMetadata(), internalId);
a906dc19264c created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5593
diff changeset
137 }
a906dc19264c created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5593
diff changeset
138
a906dc19264c created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5593
diff changeset
139 if (request.IsRetrieveLabels())
a906dc19264c created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5593
diff changeset
140 {
a906dc19264c created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5593
diff changeset
141 transaction_.ListLabels(resource->GetLabels(), internalId);
a906dc19264c created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5593
diff changeset
142 }
a906dc19264c created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5593
diff changeset
143
a906dc19264c created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5593
diff changeset
144 if (request.IsRetrieveAttachments())
a906dc19264c created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5593
diff changeset
145 {
a906dc19264c created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5593
diff changeset
146 std::set<FileContentType> attachments;
a906dc19264c created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5593
diff changeset
147 transaction_.ListAvailableAttachments(attachments, internalId);
a906dc19264c created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5593
diff changeset
148
a906dc19264c created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5593
diff changeset
149 for (std::set<FileContentType>::const_iterator it = attachments.begin(); it != attachments.end(); ++it)
a906dc19264c created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5593
diff changeset
150 {
a906dc19264c created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5593
diff changeset
151 FileInfo info;
a906dc19264c created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5593
diff changeset
152 int64_t revision;
a906dc19264c created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5593
diff changeset
153 if (transaction_.LookupAttachment(info, revision, internalId, *it) &&
a906dc19264c created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5593
diff changeset
154 info.GetContentType() == *it)
a906dc19264c created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5593
diff changeset
155 {
a906dc19264c created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5593
diff changeset
156 resource->AddAttachment(info);
a906dc19264c created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5593
diff changeset
157 }
a906dc19264c created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5593
diff changeset
158 else
a906dc19264c created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5593
diff changeset
159 {
5595
a87f2a56257d implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5594
diff changeset
160 throw OrthancException(ErrorCode_DatabasePlugin);
5594
a906dc19264c created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5593
diff changeset
161 }
a906dc19264c created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5593
diff changeset
162 }
a906dc19264c created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5593
diff changeset
163 }
a906dc19264c created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5593
diff changeset
164
a906dc19264c created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5593
diff changeset
165 if (request.IsRetrieveChildrenIdentifiers())
a906dc19264c created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5593
diff changeset
166 {
a906dc19264c created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5593
diff changeset
167 std::list<std::string> children;
a906dc19264c created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5593
diff changeset
168 transaction_.GetChildrenPublicId(children, internalId);
5554
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
169
5594
a906dc19264c created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5593
diff changeset
170 for (std::list<std::string>::const_iterator it = children.begin(); it != children.end(); ++it)
5554
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
171 {
5594
a906dc19264c created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5593
diff changeset
172 resource->AddChildIdentifier(GetChildResourceType(level), *it);
5565
def06a42e5ef Updated FindRequest & FindResponse definitions
Alain Mazy <am@orthanc.team>
parents: 5554
diff changeset
173 }
5593
862b54b4cfe2 implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5592
diff changeset
174 }
5554
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
175
5595
a87f2a56257d implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5594
diff changeset
176 for (std::set<MetadataType>::const_iterator it = request.GetRetrieveChildrenMetadata().begin();
a87f2a56257d implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5594
diff changeset
177 it != request.GetRetrieveChildrenMetadata().end(); ++it)
5594
a906dc19264c created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5593
diff changeset
178 {
5595
a87f2a56257d implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5594
diff changeset
179 std::list<std::string> values;
a87f2a56257d implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5594
diff changeset
180 transaction_.GetChildrenMetadata(values, internalId, *it);
a87f2a56257d implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5594
diff changeset
181 resource->AddChildrenMetadata(*it, values);
5594
a906dc19264c created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5593
diff changeset
182 }
5593
862b54b4cfe2 implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5592
diff changeset
183
862b54b4cfe2 implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5592
diff changeset
184 response.Add(resource.release());
5554
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
185 }
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
186 }
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
187 }