Mercurial > hg > orthanc
annotate OrthancServer/Sources/Database/ResourcesContent.h @ 5432:59e3b6f8c5be
migration to UCLouvain servers
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 21 Nov 2023 18:16:31 +0100 |
parents | 8b6da4fdf9fe |
children | 48b8dae6dc77 |
rev | line source |
---|---|
3094 | 1 /** |
2 * Orthanc - A Lightweight, RESTful DICOM Store | |
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics | |
4 * Department, University Hospital of Liege, Belgium | |
5185
0ea402b4d901
upgrade to year 2023
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4892
diff
changeset
|
5 * Copyright (C) 2017-2023 Osimis S.A., Belgium |
0ea402b4d901
upgrade to year 2023
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4892
diff
changeset
|
6 * Copyright (C) 2021-2023 Sebastien Jodogne, ICTEAM UCLouvain, Belgium |
3094 | 7 * |
8 * This program is free software: you can redistribute it and/or | |
9 * modify it under the terms of the GNU General Public License as | |
10 * published by the Free Software Foundation, either version 3 of the | |
11 * License, or (at your option) any later version. | |
12 * | |
13 * This program is distributed in the hope that it will be useful, but | |
14 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
16 * General Public License for more details. | |
17 * | |
18 * You should have received a copy of the GNU General Public License | |
19 * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
20 **/ | |
21 | |
22 | |
23 #pragma once | |
24 | |
4045 | 25 #include "../../../OrthancFramework/Sources/DicomFormat/DicomMap.h" |
3094 | 26 #include "../ServerEnumerations.h" |
27 | |
28 #include <boost/noncopyable.hpp> | |
29 #include <list> | |
30 | |
3099
9c71abbff70f
removing build dependency on plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3094
diff
changeset
|
31 |
3094 | 32 namespace Orthanc |
33 { | |
34 namespace Compatibility | |
35 { | |
36 class ISetResourcesContent; | |
37 } | |
38 | |
39 class ResourcesContent : public boost::noncopyable | |
40 { | |
3099
9c71abbff70f
removing build dependency on plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3094
diff
changeset
|
41 public: |
5215
8b6da4fdf9fe
cleaning ResourcesContent::TagValue and ResourcesContent::Metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
42 class TagValue |
3094 | 43 { |
5215
8b6da4fdf9fe
cleaning ResourcesContent::TagValue and ResourcesContent::Metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
44 private: |
3094 | 45 int64_t resourceId_; |
46 bool isIdentifier_; | |
47 DicomTag tag_; | |
48 std::string value_; | |
49 | |
5215
8b6da4fdf9fe
cleaning ResourcesContent::TagValue and ResourcesContent::Metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
50 public: |
3094 | 51 TagValue(int64_t resourceId, |
52 bool isIdentifier, | |
53 const DicomTag& tag, | |
54 const std::string& value) : | |
55 resourceId_(resourceId), | |
56 isIdentifier_(isIdentifier), | |
57 tag_(tag), | |
58 value_(value) | |
59 { | |
60 } | |
5215
8b6da4fdf9fe
cleaning ResourcesContent::TagValue and ResourcesContent::Metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
61 |
8b6da4fdf9fe
cleaning ResourcesContent::TagValue and ResourcesContent::Metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
62 int64_t GetResourceId() const |
8b6da4fdf9fe
cleaning ResourcesContent::TagValue and ResourcesContent::Metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
63 { |
8b6da4fdf9fe
cleaning ResourcesContent::TagValue and ResourcesContent::Metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
64 return resourceId_; |
8b6da4fdf9fe
cleaning ResourcesContent::TagValue and ResourcesContent::Metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
65 } |
8b6da4fdf9fe
cleaning ResourcesContent::TagValue and ResourcesContent::Metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
66 |
8b6da4fdf9fe
cleaning ResourcesContent::TagValue and ResourcesContent::Metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
67 bool IsIdentifier() const |
8b6da4fdf9fe
cleaning ResourcesContent::TagValue and ResourcesContent::Metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
68 { |
8b6da4fdf9fe
cleaning ResourcesContent::TagValue and ResourcesContent::Metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
69 return isIdentifier_; |
8b6da4fdf9fe
cleaning ResourcesContent::TagValue and ResourcesContent::Metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
70 } |
8b6da4fdf9fe
cleaning ResourcesContent::TagValue and ResourcesContent::Metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
71 |
8b6da4fdf9fe
cleaning ResourcesContent::TagValue and ResourcesContent::Metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
72 const DicomTag& GetTag() const |
8b6da4fdf9fe
cleaning ResourcesContent::TagValue and ResourcesContent::Metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
73 { |
8b6da4fdf9fe
cleaning ResourcesContent::TagValue and ResourcesContent::Metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
74 return tag_; |
8b6da4fdf9fe
cleaning ResourcesContent::TagValue and ResourcesContent::Metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
75 } |
8b6da4fdf9fe
cleaning ResourcesContent::TagValue and ResourcesContent::Metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
76 |
8b6da4fdf9fe
cleaning ResourcesContent::TagValue and ResourcesContent::Metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
77 const std::string& GetValue() const |
8b6da4fdf9fe
cleaning ResourcesContent::TagValue and ResourcesContent::Metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
78 { |
8b6da4fdf9fe
cleaning ResourcesContent::TagValue and ResourcesContent::Metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
79 return value_; |
8b6da4fdf9fe
cleaning ResourcesContent::TagValue and ResourcesContent::Metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
80 } |
3094 | 81 }; |
82 | |
5215
8b6da4fdf9fe
cleaning ResourcesContent::TagValue and ResourcesContent::Metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
83 class Metadata |
3094 | 84 { |
5215
8b6da4fdf9fe
cleaning ResourcesContent::TagValue and ResourcesContent::Metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
85 private: |
3094 | 86 int64_t resourceId_; |
5215
8b6da4fdf9fe
cleaning ResourcesContent::TagValue and ResourcesContent::Metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
87 MetadataType type_; |
3094 | 88 std::string value_; |
89 | |
5215
8b6da4fdf9fe
cleaning ResourcesContent::TagValue and ResourcesContent::Metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
90 public: |
3094 | 91 Metadata(int64_t resourceId, |
5215
8b6da4fdf9fe
cleaning ResourcesContent::TagValue and ResourcesContent::Metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
92 MetadataType type, |
3094 | 93 const std::string& value) : |
94 resourceId_(resourceId), | |
5215
8b6da4fdf9fe
cleaning ResourcesContent::TagValue and ResourcesContent::Metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
95 type_(type), |
3094 | 96 value_(value) |
97 { | |
98 } | |
5215
8b6da4fdf9fe
cleaning ResourcesContent::TagValue and ResourcesContent::Metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
99 |
8b6da4fdf9fe
cleaning ResourcesContent::TagValue and ResourcesContent::Metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
100 int64_t GetResourceId() const |
8b6da4fdf9fe
cleaning ResourcesContent::TagValue and ResourcesContent::Metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
101 { |
8b6da4fdf9fe
cleaning ResourcesContent::TagValue and ResourcesContent::Metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
102 return resourceId_; |
8b6da4fdf9fe
cleaning ResourcesContent::TagValue and ResourcesContent::Metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
103 } |
8b6da4fdf9fe
cleaning ResourcesContent::TagValue and ResourcesContent::Metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
104 |
8b6da4fdf9fe
cleaning ResourcesContent::TagValue and ResourcesContent::Metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
105 MetadataType GetType() const |
8b6da4fdf9fe
cleaning ResourcesContent::TagValue and ResourcesContent::Metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
106 { |
8b6da4fdf9fe
cleaning ResourcesContent::TagValue and ResourcesContent::Metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
107 return type_; |
8b6da4fdf9fe
cleaning ResourcesContent::TagValue and ResourcesContent::Metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
108 } |
8b6da4fdf9fe
cleaning ResourcesContent::TagValue and ResourcesContent::Metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
109 |
8b6da4fdf9fe
cleaning ResourcesContent::TagValue and ResourcesContent::Metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
110 const std::string& GetValue() const |
8b6da4fdf9fe
cleaning ResourcesContent::TagValue and ResourcesContent::Metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
111 { |
8b6da4fdf9fe
cleaning ResourcesContent::TagValue and ResourcesContent::Metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
112 return value_; |
8b6da4fdf9fe
cleaning ResourcesContent::TagValue and ResourcesContent::Metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
113 } |
3094 | 114 }; |
115 | |
3099
9c71abbff70f
removing build dependency on plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3094
diff
changeset
|
116 typedef std::list<TagValue> ListTags; |
9c71abbff70f
removing build dependency on plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3094
diff
changeset
|
117 typedef std::list<Metadata> ListMetadata; |
9c71abbff70f
removing build dependency on plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3094
diff
changeset
|
118 |
9c71abbff70f
removing build dependency on plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3094
diff
changeset
|
119 private: |
4623
95ffe3b6ef7c
handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
120 bool isNewResource_; |
3099
9c71abbff70f
removing build dependency on plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3094
diff
changeset
|
121 ListTags tags_; |
9c71abbff70f
removing build dependency on plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3094
diff
changeset
|
122 ListMetadata metadata_; |
3094 | 123 |
124 public: | |
4623
95ffe3b6ef7c
handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
125 explicit ResourcesContent(bool isNewResource) : |
95ffe3b6ef7c
handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
126 isNewResource_(isNewResource) |
95ffe3b6ef7c
handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
127 { |
95ffe3b6ef7c
handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
128 } |
95ffe3b6ef7c
handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
129 |
3094 | 130 void AddMainDicomTag(int64_t resourceId, |
131 const DicomTag& tag, | |
132 const std::string& value) | |
133 { | |
134 tags_.push_back(TagValue(resourceId, false, tag, value)); | |
135 } | |
136 | |
137 void AddIdentifierTag(int64_t resourceId, | |
138 const DicomTag& tag, | |
139 const std::string& value) | |
140 { | |
141 tags_.push_back(TagValue(resourceId, true, tag, value)); | |
142 } | |
143 | |
144 void AddMetadata(int64_t resourceId, | |
145 MetadataType metadata, | |
4623
95ffe3b6ef7c
handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
146 const std::string& value); |
3094 | 147 |
148 void AddResource(int64_t resource, | |
149 ResourceType level, | |
150 const DicomMap& dicomSummary); | |
151 | |
152 // WARNING: The database should be locked with a transaction! | |
153 void Store(Compatibility::ISetResourcesContent& target) const; | |
154 | |
3099
9c71abbff70f
removing build dependency on plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3094
diff
changeset
|
155 const ListTags& GetListTags() const |
9c71abbff70f
removing build dependency on plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3094
diff
changeset
|
156 { |
9c71abbff70f
removing build dependency on plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3094
diff
changeset
|
157 return tags_; |
9c71abbff70f
removing build dependency on plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3094
diff
changeset
|
158 } |
9c71abbff70f
removing build dependency on plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3094
diff
changeset
|
159 |
9c71abbff70f
removing build dependency on plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3094
diff
changeset
|
160 const ListMetadata& GetListMetadata() const |
9c71abbff70f
removing build dependency on plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3094
diff
changeset
|
161 { |
9c71abbff70f
removing build dependency on plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3094
diff
changeset
|
162 return metadata_; |
9c71abbff70f
removing build dependency on plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3094
diff
changeset
|
163 } |
3094 | 164 }; |
165 } |