Mercurial > hg > orthanc-databases
annotate PostgreSQL/Plugins/PostgreSQLIndex.h @ 493:0a8168522165
news
author | Alain Mazy <am@osimis.io> |
---|---|
date | Fri, 22 Mar 2024 15:27:59 +0100 |
parents | f0976163dbe1 |
children | 4a76aca03774 |
rev | line source |
---|---|
0 | 1 /** |
2 * Orthanc - A Lightweight, RESTful DICOM Store | |
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics | |
4 * Department, University Hospital of Liege, Belgium | |
459
ecd0b719cff5
update year to 2024
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
403
diff
changeset
|
5 * Copyright (C) 2017-2024 Osimis S.A., Belgium |
ecd0b719cff5
update year to 2024
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
403
diff
changeset
|
6 * Copyright (C) 2021-2024 Sebastien Jodogne, ICTEAM UCLouvain, Belgium |
0 | 7 * |
8 * This program is free software: you can redistribute it and/or | |
9 * modify it under the terms of the GNU Affero General Public License | |
10 * as published by the Free Software Foundation, either version 3 of | |
11 * the 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 * Affero General Public License for more details. | |
17 * | |
18 * You should have received a copy of the GNU Affero General Public License | |
19 * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
20 **/ | |
21 | |
22 | |
23 #pragma once | |
24 | |
25 #include "../../Framework/Plugins/IndexBackend.h" | |
26 #include "../../Framework/PostgreSQL/PostgreSQLParameters.h" | |
27 | |
28 namespace OrthancDatabases | |
29 { | |
30 class PostgreSQLIndex : public IndexBackend | |
31 { | |
32 private: | |
33 PostgreSQLParameters parameters_; | |
34 bool clearAll_; | |
35 | |
433
5964ce6385a5
use temporary tables for DeletedFiles, RemainingAncestor and DeletedResources
Alain Mazy <am@osimis.io>
parents:
431
diff
changeset
|
36 protected: |
5964ce6385a5
use temporary tables for DeletedFiles, RemainingAncestor and DeletedResources
Alain Mazy <am@osimis.io>
parents:
431
diff
changeset
|
37 virtual void ClearDeletedFiles(DatabaseManager& manager); |
5964ce6385a5
use temporary tables for DeletedFiles, RemainingAncestor and DeletedResources
Alain Mazy <am@osimis.io>
parents:
431
diff
changeset
|
38 |
5964ce6385a5
use temporary tables for DeletedFiles, RemainingAncestor and DeletedResources
Alain Mazy <am@osimis.io>
parents:
431
diff
changeset
|
39 virtual void ClearDeletedResources(DatabaseManager& manager); |
5964ce6385a5
use temporary tables for DeletedFiles, RemainingAncestor and DeletedResources
Alain Mazy <am@osimis.io>
parents:
431
diff
changeset
|
40 |
5964ce6385a5
use temporary tables for DeletedFiles, RemainingAncestor and DeletedResources
Alain Mazy <am@osimis.io>
parents:
431
diff
changeset
|
41 virtual void ClearRemainingAncestor(DatabaseManager& manager); |
5964ce6385a5
use temporary tables for DeletedFiles, RemainingAncestor and DeletedResources
Alain Mazy <am@osimis.io>
parents:
431
diff
changeset
|
42 |
437
d979f25e60cf
Re-organized DB creation/upgrade into standalone files
Alain Mazy <am@osimis.io>
parents:
436
diff
changeset
|
43 void ApplyPrepareIndex(DatabaseManager::Transaction& t, DatabaseManager& manager); |
433
5964ce6385a5
use temporary tables for DeletedFiles, RemainingAncestor and DeletedResources
Alain Mazy <am@osimis.io>
parents:
431
diff
changeset
|
44 |
0 | 45 public: |
201
42990b2dd51b
create IDatabaseBackendOutput only if needed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
199
diff
changeset
|
46 PostgreSQLIndex(OrthancPluginContext* context, |
42990b2dd51b
create IDatabaseBackendOutput only if needed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
199
diff
changeset
|
47 const PostgreSQLParameters& parameters); |
0 | 48 |
49 void SetClearAll(bool clear) | |
50 { | |
51 clearAll_ = clear; | |
52 } | |
53 | |
255
d663d9e44f8d
reintroduction of IDatabaseFactory into DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
54 virtual IDatabaseFactory* CreateDatabaseFactory() ORTHANC_OVERRIDE; |
226
a4918d57435c
DatabaseManager doesn't IDatabaseFactory anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
225
diff
changeset
|
55 |
403
91124cc8a8c7
database plugins are informed about the identifier tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
396
diff
changeset
|
56 virtual void ConfigureDatabase(DatabaseManager& manager, |
91124cc8a8c7
database plugins are informed about the identifier tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
396
diff
changeset
|
57 bool hasIdentifierTags, |
91124cc8a8c7
database plugins are informed about the identifier tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
396
diff
changeset
|
58 const std::list<IdentifierTag>& identifierTags) ORTHANC_OVERRIDE; |
224
61c309e06797
added internal class DatabaseBackendAdapterV2::Adapter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
209
diff
changeset
|
59 |
260
793bbbe11287
IDatabaseBackend::HasRevisionsSupport()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
255
diff
changeset
|
60 virtual bool HasRevisionsSupport() const ORTHANC_OVERRIDE |
793bbbe11287
IDatabaseBackend::HasRevisionsSupport()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
255
diff
changeset
|
61 { |
266
cc7af42d4f23
Store revisions for metadata and attachments in PostgreSQL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
260
diff
changeset
|
62 return true; |
260
793bbbe11287
IDatabaseBackend::HasRevisionsSupport()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
255
diff
changeset
|
63 } |
793bbbe11287
IDatabaseBackend::HasRevisionsSupport()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
255
diff
changeset
|
64 |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
224
diff
changeset
|
65 virtual int64_t CreateResource(DatabaseManager& manager, |
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
224
diff
changeset
|
66 const char* publicId, |
434
23c7af6f671a
DeleteResource does not need the RemainingAncestor table anymore
Alain Mazy <am@osimis.io>
parents:
433
diff
changeset
|
67 OrthancPluginResourceType type) ORTHANC_OVERRIDE; |
23c7af6f671a
DeleteResource does not need the RemainingAncestor table anymore
Alain Mazy <am@osimis.io>
parents:
433
diff
changeset
|
68 |
23c7af6f671a
DeleteResource does not need the RemainingAncestor table anymore
Alain Mazy <am@osimis.io>
parents:
433
diff
changeset
|
69 virtual void DeleteResource(IDatabaseBackendOutput& output, |
23c7af6f671a
DeleteResource does not need the RemainingAncestor table anymore
Alain Mazy <am@osimis.io>
parents:
433
diff
changeset
|
70 DatabaseManager& manager, |
23c7af6f671a
DeleteResource does not need the RemainingAncestor table anymore
Alain Mazy <am@osimis.io>
parents:
433
diff
changeset
|
71 int64_t id) ORTHANC_OVERRIDE; |
71
d40c5fecd160
new extension implemented for PostgreSQL: CreateInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
72 |
436
f16faa1fdc46
InsertOrUpdateMetadata function + UpdateAndGetStatistics
Alain Mazy <am@osimis.io>
parents:
434
diff
changeset
|
73 virtual void SetResourcesContent(DatabaseManager& manager, |
f16faa1fdc46
InsertOrUpdateMetadata function + UpdateAndGetStatistics
Alain Mazy <am@osimis.io>
parents:
434
diff
changeset
|
74 uint32_t countIdentifierTags, |
f16faa1fdc46
InsertOrUpdateMetadata function + UpdateAndGetStatistics
Alain Mazy <am@osimis.io>
parents:
434
diff
changeset
|
75 const OrthancPluginResourcesContentTags* identifierTags, |
f16faa1fdc46
InsertOrUpdateMetadata function + UpdateAndGetStatistics
Alain Mazy <am@osimis.io>
parents:
434
diff
changeset
|
76 uint32_t countMainDicomTags, |
f16faa1fdc46
InsertOrUpdateMetadata function + UpdateAndGetStatistics
Alain Mazy <am@osimis.io>
parents:
434
diff
changeset
|
77 const OrthancPluginResourcesContentTags* mainDicomTags, |
f16faa1fdc46
InsertOrUpdateMetadata function + UpdateAndGetStatistics
Alain Mazy <am@osimis.io>
parents:
434
diff
changeset
|
78 uint32_t countMetadata, |
f16faa1fdc46
InsertOrUpdateMetadata function + UpdateAndGetStatistics
Alain Mazy <am@osimis.io>
parents:
434
diff
changeset
|
79 const OrthancPluginResourcesContentMetadata* metadata) ORTHANC_OVERRIDE; |
71
d40c5fecd160
new extension implemented for PostgreSQL: CreateInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
80 |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
224
diff
changeset
|
81 virtual uint64_t GetTotalCompressedSize(DatabaseManager& manager) ORTHANC_OVERRIDE; |
72
8dd29af7c844
new extension: FastTotalSize
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
71
diff
changeset
|
82 |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
224
diff
changeset
|
83 virtual uint64_t GetTotalUncompressedSize(DatabaseManager& manager) ORTHANC_OVERRIDE; |
72
8dd29af7c844
new extension: FastTotalSize
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
71
diff
changeset
|
84 |
8dd29af7c844
new extension: FastTotalSize
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
71
diff
changeset
|
85 virtual bool HasCreateInstance() const ORTHANC_OVERRIDE |
71
d40c5fecd160
new extension implemented for PostgreSQL: CreateInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
86 { |
d40c5fecd160
new extension implemented for PostgreSQL: CreateInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
87 return true; |
d40c5fecd160
new extension implemented for PostgreSQL: CreateInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
88 } |
d40c5fecd160
new extension implemented for PostgreSQL: CreateInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
89 |
78 | 90 #if ORTHANC_PLUGINS_HAS_DATABASE_CONSTRAINT == 1 |
71
d40c5fecd160
new extension implemented for PostgreSQL: CreateInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
91 virtual void CreateInstance(OrthancPluginCreateInstanceResult& result, |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
224
diff
changeset
|
92 DatabaseManager& manager, |
71
d40c5fecd160
new extension implemented for PostgreSQL: CreateInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
93 const char* hashPatient, |
d40c5fecd160
new extension implemented for PostgreSQL: CreateInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
94 const char* hashStudy, |
d40c5fecd160
new extension implemented for PostgreSQL: CreateInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
95 const char* hashSeries, |
72
8dd29af7c844
new extension: FastTotalSize
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
71
diff
changeset
|
96 const char* hashInstance) |
8dd29af7c844
new extension: FastTotalSize
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
71
diff
changeset
|
97 ORTHANC_OVERRIDE; |
71
d40c5fecd160
new extension implemented for PostgreSQL: CreateInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
98 #endif |
79
cb0aac9bbada
optimization for /statistics URI
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
78
diff
changeset
|
99 |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
224
diff
changeset
|
100 virtual uint64_t GetResourcesCount(DatabaseManager& manager, |
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
224
diff
changeset
|
101 OrthancPluginResourceType resourceType) ORTHANC_OVERRIDE; |
85
1012fe77241c
new extension implemented for PostgreSQL and SQLite: GetLastChangeIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
79
diff
changeset
|
102 |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
224
diff
changeset
|
103 virtual int64_t GetLastChangeIndex(DatabaseManager& manager) ORTHANC_OVERRIDE; |
90
e61587582cef
moved extension TagMostRecentPatient into stored procedure CreateInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
85
diff
changeset
|
104 |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
224
diff
changeset
|
105 virtual void TagMostRecentPatient(DatabaseManager& manager, |
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
224
diff
changeset
|
106 int64_t patient) ORTHANC_OVERRIDE; |
391
d14e6ff04a5c
added primitives to handle labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
389
diff
changeset
|
107 |
d14e6ff04a5c
added primitives to handle labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
389
diff
changeset
|
108 // New primitive since Orthanc 1.12.0 |
d14e6ff04a5c
added primitives to handle labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
389
diff
changeset
|
109 virtual bool HasLabelsSupport() const ORTHANC_OVERRIDE |
d14e6ff04a5c
added primitives to handle labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
389
diff
changeset
|
110 { |
396
7b3acfa95bd8
implementation of list/add/remove labels in postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
391
diff
changeset
|
111 return true; |
391
d14e6ff04a5c
added primitives to handle labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
389
diff
changeset
|
112 } |
431 | 113 |
114 virtual bool HasAtomicIncrementGlobalProperty() ORTHANC_OVERRIDE | |
115 { | |
116 return true; | |
117 } | |
118 | |
119 virtual int64_t IncrementGlobalProperty(DatabaseManager& manager, | |
120 const char* serverIdentifier, | |
121 int32_t property, | |
122 int64_t increment) ORTHANC_OVERRIDE; | |
123 | |
436
f16faa1fdc46
InsertOrUpdateMetadata function + UpdateAndGetStatistics
Alain Mazy <am@osimis.io>
parents:
434
diff
changeset
|
124 virtual bool HasUpdateAndGetStatistics() ORTHANC_OVERRIDE |
f16faa1fdc46
InsertOrUpdateMetadata function + UpdateAndGetStatistics
Alain Mazy <am@osimis.io>
parents:
434
diff
changeset
|
125 { |
f16faa1fdc46
InsertOrUpdateMetadata function + UpdateAndGetStatistics
Alain Mazy <am@osimis.io>
parents:
434
diff
changeset
|
126 return true; |
f16faa1fdc46
InsertOrUpdateMetadata function + UpdateAndGetStatistics
Alain Mazy <am@osimis.io>
parents:
434
diff
changeset
|
127 } |
f16faa1fdc46
InsertOrUpdateMetadata function + UpdateAndGetStatistics
Alain Mazy <am@osimis.io>
parents:
434
diff
changeset
|
128 |
f16faa1fdc46
InsertOrUpdateMetadata function + UpdateAndGetStatistics
Alain Mazy <am@osimis.io>
parents:
434
diff
changeset
|
129 virtual void UpdateAndGetStatistics(DatabaseManager& manager, |
f16faa1fdc46
InsertOrUpdateMetadata function + UpdateAndGetStatistics
Alain Mazy <am@osimis.io>
parents:
434
diff
changeset
|
130 int64_t& patientsCount, |
f16faa1fdc46
InsertOrUpdateMetadata function + UpdateAndGetStatistics
Alain Mazy <am@osimis.io>
parents:
434
diff
changeset
|
131 int64_t& studiesCount, |
f16faa1fdc46
InsertOrUpdateMetadata function + UpdateAndGetStatistics
Alain Mazy <am@osimis.io>
parents:
434
diff
changeset
|
132 int64_t& seriesCount, |
f16faa1fdc46
InsertOrUpdateMetadata function + UpdateAndGetStatistics
Alain Mazy <am@osimis.io>
parents:
434
diff
changeset
|
133 int64_t& instancesCount, |
f16faa1fdc46
InsertOrUpdateMetadata function + UpdateAndGetStatistics
Alain Mazy <am@osimis.io>
parents:
434
diff
changeset
|
134 int64_t& compressedSize, |
f16faa1fdc46
InsertOrUpdateMetadata function + UpdateAndGetStatistics
Alain Mazy <am@osimis.io>
parents:
434
diff
changeset
|
135 int64_t& uncompressedSize) ORTHANC_OVERRIDE; |
f16faa1fdc46
InsertOrUpdateMetadata function + UpdateAndGetStatistics
Alain Mazy <am@osimis.io>
parents:
434
diff
changeset
|
136 |
0 | 137 }; |
138 } |