annotate OrthancServer/Sources/ResourceFinder.h @ 5615:a10978a5e65c find-refactoring

expansion of single resources using ResourceFinder
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 09 May 2024 12:24:29 +0200
parents 4690a0d2b01e
children 8905ffa45fc2
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
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
5 * Copyright (C) 2017-2024 Osimis S.A., Belgium
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6 * Copyright (C) 2021-2024 Sebastien Jodogne, ICTEAM UCLouvain, Belgium
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 *
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 * This program is free software: you can redistribute it and/or
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 * modify it under the terms of the GNU General Public License as
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 * published by the Free Software Foundation, either version 3 of the
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 * License, or (at your option) any later version.
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 *
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 * This program is distributed in the hope that it will be useful, but
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16 * General Public License for more details.
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17 *
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18 * You should have received a copy of the GNU General Public License
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20 **/
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 #pragma once
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25 #include "Database/FindRequest.h"
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26 #include "Database/FindResponse.h"
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28 namespace Orthanc
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29 {
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30 class ServerContext;
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31 class ServerIndex;
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
33 class ResourceFinder : public boost::noncopyable
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
34 {
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
35 private:
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
36 FindRequest request_;
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
37 bool expand_;
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
38 DicomToJsonFormat format_;
5609
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
39 bool hasRequestedTags_;
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
40 std::set<DicomTag> requestedPatientTags_;
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
41 std::set<DicomTag> requestedStudyTags_;
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
42 std::set<DicomTag> requestedSeriesTags_;
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
43 std::set<DicomTag> requestedInstanceTags_;
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
44 std::set<DicomTag> requestedTagsFromFileStorage_;
5608
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
45 bool includeAllMetadata_; // Same as: ExpandResourceFlags_IncludeAllMetadata
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
46
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
47 SeriesStatus GetSeriesStatus(uint32_t& expectedNumberOfInstances,
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
48 const FindResponse::Resource& resource) const;
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
49
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
50 void Expand(Json::Value& target,
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
51 const FindResponse::Resource& resource,
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
52 ServerIndex& index) const;
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
53
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
54 public:
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
55 ResourceFinder(ResourceType level,
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
56 bool expand);
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
57
5615
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5609
diff changeset
58 void SetOrthancId(ResourceType level,
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5609
diff changeset
59 const std::string& id)
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5609
diff changeset
60 {
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5609
diff changeset
61 request_.SetOrthancId(level, id);
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5609
diff changeset
62 }
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5609
diff changeset
63
5608
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
64 void SetFormat(DicomToJsonFormat format)
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
65 {
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
66 format_ = format;
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
67 }
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
68
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
69 void SetLimits(uint64_t since,
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
70 uint64_t count)
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
71 {
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
72 request_.SetLimits(since, count);
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
73 }
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
74
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
75 void SetIncludeAllMetadata(bool include)
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
76 {
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
77 includeAllMetadata_ = include;
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
78 }
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
79
5609
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
80 void AddRequestedTags(const DicomTag& tag);
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
81
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
82 void AddRequestedTags(const std::set<DicomTag>& tags);
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
83
5608
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
84 void Execute(Json::Value& target,
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
85 ServerContext& context);
5615
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5609
diff changeset
86
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5609
diff changeset
87 bool ExecuteOneResource(Json::Value& target,
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5609
diff changeset
88 ServerContext& context);
5608
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
89 };
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
90 }