Mercurial > hg > orthanc-databases
annotate Framework/Plugins/IndexUnitTests.h @ 395:a7a029043670 db-protobuf
integration mainline->db-protobuf
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 05 Apr 2023 14:53:57 +0200 |
parents | 3d6886f3e5b3 |
children | 91124cc8a8c7 |
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 | |
389
3d6886f3e5b3
upgrade to year 2023
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
378
diff
changeset
|
5 * Copyright (C) 2017-2023 Osimis S.A., Belgium |
3d6886f3e5b3
upgrade to year 2023
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
378
diff
changeset
|
6 * Copyright (C) 2021-2023 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 | |
28
c0cb5d2cd696
checks depending on Orthanc version
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
27
diff
changeset
|
25 #include "../Common/ImplicitTransaction.h" |
213
c2e4a909de0e
added IndexBackend::Register() to be used in all the index plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
209
diff
changeset
|
26 #include "DatabaseBackendAdapterV2.h" |
152 | 27 #include "GlobalProperties.h" |
28
c0cb5d2cd696
checks depending on Orthanc version
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
27
diff
changeset
|
28 |
157
275e14f57f1e
replacing deprecated std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
152
diff
changeset
|
29 #include <Compatibility.h> // For std::unique_ptr<> |
275e14f57f1e
replacing deprecated std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
152
diff
changeset
|
30 |
0 | 31 #include <orthanc/OrthancCDatabasePlugin.h> |
32 | |
33 #include <gtest/gtest.h> | |
34 #include <list> | |
35 | |
273
07881ac5404b
fix build against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
266
diff
changeset
|
36 #if !defined(ORTHANC_DATABASE_VERSION) |
07881ac5404b
fix build against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
266
diff
changeset
|
37 // This happens if using the Orthanc framework system-wide library |
07881ac5404b
fix build against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
266
diff
changeset
|
38 # define ORTHANC_DATABASE_VERSION 6 |
07881ac5404b
fix build against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
266
diff
changeset
|
39 #endif |
07881ac5404b
fix build against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
266
diff
changeset
|
40 |
0 | 41 |
266
cc7af42d4f23
Store revisions for metadata and attachments in PostgreSQL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
42 #if ORTHANC_ENABLE_POSTGRESQL == 1 |
cc7af42d4f23
Store revisions for metadata and attachments in PostgreSQL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
43 # define HAS_REVISIONS 1 |
cc7af42d4f23
Store revisions for metadata and attachments in PostgreSQL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
44 #elif ORTHANC_ENABLE_MYSQL == 1 |
cc7af42d4f23
Store revisions for metadata and attachments in PostgreSQL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
45 # define HAS_REVISIONS 0 |
cc7af42d4f23
Store revisions for metadata and attachments in PostgreSQL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
46 #elif ORTHANC_ENABLE_SQLITE == 1 |
cc7af42d4f23
Store revisions for metadata and attachments in PostgreSQL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
47 # define HAS_REVISIONS 1 |
309
d192bfd0e752
tagging globalParameters_ as static in MySQL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
307
diff
changeset
|
48 #elif ORTHANC_ENABLE_ODBC == 1 |
d192bfd0e752
tagging globalParameters_ as static in MySQL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
307
diff
changeset
|
49 # define HAS_REVISIONS 1 |
266
cc7af42d4f23
Store revisions for metadata and attachments in PostgreSQL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
50 #else |
cc7af42d4f23
Store revisions for metadata and attachments in PostgreSQL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
51 # error Unknown database backend |
cc7af42d4f23
Store revisions for metadata and attachments in PostgreSQL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
52 #endif |
cc7af42d4f23
Store revisions for metadata and attachments in PostgreSQL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
53 |
cc7af42d4f23
Store revisions for metadata and attachments in PostgreSQL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
54 |
152 | 55 namespace Orthanc |
56 { | |
57 /** | |
58 * Mock enumeration inspired from the source code of Orthanc... only | |
59 * for use in the unit tests! | |
60 * https://hg.orthanc-server.com/orthanc/file/default/OrthancServer/Sources/ServerEnumerations.h | |
61 **/ | |
62 enum MetadataType | |
63 { | |
64 MetadataType_ModifiedFrom, | |
65 MetadataType_LastUpdate | |
66 }; | |
67 } | |
68 | |
69 | |
335
7ec461718edb
unit test of metadata and tags in UTF8
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
321
diff
changeset
|
70 /** |
7ec461718edb
unit test of metadata and tags in UTF8
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
321
diff
changeset
|
71 * This is a sample UTF8 string that is the concatenation of a Korean |
7ec461718edb
unit test of metadata and tags in UTF8
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
321
diff
changeset
|
72 * and a Kanji text. Check out "utf8raw" in |
7ec461718edb
unit test of metadata and tags in UTF8
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
321
diff
changeset
|
73 * "OrthancFramework/UnitTestsSources/FromDcmtkTests.cpp" for the |
7ec461718edb
unit test of metadata and tags in UTF8
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
321
diff
changeset
|
74 * sources of these binary values. |
7ec461718edb
unit test of metadata and tags in UTF8
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
321
diff
changeset
|
75 **/ |
7ec461718edb
unit test of metadata and tags in UTF8
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
321
diff
changeset
|
76 static const uint8_t UTF8[] = { |
7ec461718edb
unit test of metadata and tags in UTF8
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
321
diff
changeset
|
77 // cf. TEST(Toolbox, EncodingsKorean) |
7ec461718edb
unit test of metadata and tags in UTF8
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
321
diff
changeset
|
78 0x48, 0x6f, 0x6e, 0x67, 0x5e, 0x47, 0x69, 0x6c, 0x64, 0x6f, 0x6e, 0x67, 0x3d, 0xe6, |
7ec461718edb
unit test of metadata and tags in UTF8
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
321
diff
changeset
|
79 0xb4, 0xaa, 0x5e, 0xe5, 0x90, 0x89, 0xe6, 0xb4, 0x9e, 0x3d, 0xed, 0x99, 0x8d, 0x5e, |
7ec461718edb
unit test of metadata and tags in UTF8
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
321
diff
changeset
|
80 0xea, 0xb8, 0xb8, 0xeb, 0x8f, 0x99, |
7ec461718edb
unit test of metadata and tags in UTF8
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
321
diff
changeset
|
81 |
7ec461718edb
unit test of metadata and tags in UTF8
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
321
diff
changeset
|
82 // cf. TEST(Toolbox, EncodingsJapaneseKanji) |
7ec461718edb
unit test of metadata and tags in UTF8
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
321
diff
changeset
|
83 0x59, 0x61, 0x6d, 0x61, 0x64, 0x61, 0x5e, 0x54, 0x61, 0x72, 0x6f, 0x75, 0x3d, 0xe5, |
7ec461718edb
unit test of metadata and tags in UTF8
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
321
diff
changeset
|
84 0xb1, 0xb1, 0xe7, 0x94, 0xb0, 0x5e, 0xe5, 0xa4, 0xaa, 0xe9, 0x83, 0x8e, 0x3d, 0xe3, |
7ec461718edb
unit test of metadata and tags in UTF8
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
321
diff
changeset
|
85 0x82, 0x84, 0xe3, 0x81, 0xbe, 0xe3, 0x81, 0xa0, 0x5e, 0xe3, 0x81, 0x9f, 0xe3, 0x82, |
7ec461718edb
unit test of metadata and tags in UTF8
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
321
diff
changeset
|
86 0x8d, 0xe3, 0x81, 0x86, |
7ec461718edb
unit test of metadata and tags in UTF8
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
321
diff
changeset
|
87 |
7ec461718edb
unit test of metadata and tags in UTF8
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
321
diff
changeset
|
88 // End of text |
7ec461718edb
unit test of metadata and tags in UTF8
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
321
diff
changeset
|
89 0x00 |
7ec461718edb
unit test of metadata and tags in UTF8
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
321
diff
changeset
|
90 }; |
7ec461718edb
unit test of metadata and tags in UTF8
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
321
diff
changeset
|
91 |
7ec461718edb
unit test of metadata and tags in UTF8
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
321
diff
changeset
|
92 |
157
275e14f57f1e
replacing deprecated std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
152
diff
changeset
|
93 static std::unique_ptr<OrthancPluginAttachment> expectedAttachment; |
0 | 94 static std::list<OrthancPluginDicomTag> expectedDicomTags; |
157
275e14f57f1e
replacing deprecated std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
152
diff
changeset
|
95 static std::unique_ptr<OrthancPluginExportedResource> expectedExported; |
0 | 96 |
307
8de3a1ecac11
MySQL: Added missing calls to OrthancPluginDatabaseSignalDeletedResource()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
301
diff
changeset
|
97 static std::map<std::string, OrthancPluginResourceType> deletedResources; |
8de3a1ecac11
MySQL: Added missing calls to OrthancPluginDatabaseSignalDeletedResource()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
301
diff
changeset
|
98 static std::unique_ptr< std::pair<std::string, OrthancPluginResourceType> > remainingAncestor; |
8de3a1ecac11
MySQL: Added missing calls to OrthancPluginDatabaseSignalDeletedResource()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
301
diff
changeset
|
99 static std::set<std::string> deletedAttachments; |
335
7ec461718edb
unit test of metadata and tags in UTF8
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
321
diff
changeset
|
100 static unsigned int countDicomTags = 0; |
307
8de3a1ecac11
MySQL: Added missing calls to OrthancPluginDatabaseSignalDeletedResource()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
301
diff
changeset
|
101 |
8de3a1ecac11
MySQL: Added missing calls to OrthancPluginDatabaseSignalDeletedResource()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
301
diff
changeset
|
102 |
0 | 103 static void CheckAttachment(const OrthancPluginAttachment& attachment) |
104 { | |
105 ASSERT_STREQ(expectedAttachment->uuid, attachment.uuid); | |
106 ASSERT_EQ(expectedAttachment->contentType, attachment.contentType); | |
107 ASSERT_EQ(expectedAttachment->uncompressedSize, attachment.uncompressedSize); | |
108 ASSERT_STREQ(expectedAttachment->uncompressedHash, attachment.uncompressedHash); | |
109 ASSERT_EQ(expectedAttachment->compressionType, attachment.compressionType); | |
110 ASSERT_EQ(expectedAttachment->compressedSize, attachment.compressedSize); | |
111 ASSERT_STREQ(expectedAttachment->compressedHash, attachment.compressedHash); | |
112 } | |
113 | |
114 static void CheckExportedResource(const OrthancPluginExportedResource& exported) | |
115 { | |
311
5f0d5f849944
fix unit tests if resuning the same database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
309
diff
changeset
|
116 // ASSERT_EQ(expectedExported->seq, exported.seq); |
0 | 117 ASSERT_EQ(expectedExported->resourceType, exported.resourceType); |
118 ASSERT_STREQ(expectedExported->publicId, exported.publicId); | |
119 ASSERT_STREQ(expectedExported->modality, exported.modality); | |
120 ASSERT_STREQ(expectedExported->date, exported.date); | |
121 ASSERT_STREQ(expectedExported->patientId, exported.patientId); | |
122 ASSERT_STREQ(expectedExported->studyInstanceUid, exported.studyInstanceUid); | |
123 ASSERT_STREQ(expectedExported->seriesInstanceUid, exported.seriesInstanceUid); | |
124 ASSERT_STREQ(expectedExported->sopInstanceUid, exported.sopInstanceUid); | |
125 } | |
126 | |
127 static void CheckDicomTag(const OrthancPluginDicomTag& tag) | |
128 { | |
129 for (std::list<OrthancPluginDicomTag>::const_iterator | |
130 it = expectedDicomTags.begin(); it != expectedDicomTags.end(); ++it) | |
131 { | |
132 if (it->group == tag.group && | |
133 it->element == tag.element && | |
134 !strcmp(it->value, tag.value)) | |
135 { | |
136 // OK, match | |
137 return; | |
138 } | |
139 } | |
140 | |
141 ASSERT_TRUE(0); // Error | |
142 } | |
143 | |
144 | |
145 | |
146 static OrthancPluginErrorCode InvokeService(struct _OrthancPluginContext_t* context, | |
147 _OrthancPluginService service, | |
148 const void* params) | |
149 { | |
199 | 150 switch (service) |
0 | 151 { |
199 | 152 case _OrthancPluginService_DatabaseAnswer: |
0 | 153 { |
199 | 154 const _OrthancPluginDatabaseAnswer& answer = |
155 *reinterpret_cast<const _OrthancPluginDatabaseAnswer*>(params); | |
156 | |
157 switch (answer.type) | |
0 | 158 { |
199 | 159 case _OrthancPluginDatabaseAnswerType_Attachment: |
160 { | |
161 const OrthancPluginAttachment& attachment = | |
162 *reinterpret_cast<const OrthancPluginAttachment*>(answer.valueGeneric); | |
163 CheckAttachment(attachment); | |
164 break; | |
165 } | |
166 | |
167 case _OrthancPluginDatabaseAnswerType_ExportedResource: | |
168 { | |
169 const OrthancPluginExportedResource& attachment = | |
170 *reinterpret_cast<const OrthancPluginExportedResource*>(answer.valueGeneric); | |
171 CheckExportedResource(attachment); | |
172 break; | |
173 } | |
174 | |
175 case _OrthancPluginDatabaseAnswerType_DicomTag: | |
176 { | |
177 const OrthancPluginDicomTag& tag = | |
178 *reinterpret_cast<const OrthancPluginDicomTag*>(answer.valueGeneric); | |
179 CheckDicomTag(tag); | |
335
7ec461718edb
unit test of metadata and tags in UTF8
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
321
diff
changeset
|
180 countDicomTags++; |
199 | 181 break; |
182 } | |
183 | |
307
8de3a1ecac11
MySQL: Added missing calls to OrthancPluginDatabaseSignalDeletedResource()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
301
diff
changeset
|
184 case _OrthancPluginDatabaseAnswerType_DeletedResource: |
8de3a1ecac11
MySQL: Added missing calls to OrthancPluginDatabaseSignalDeletedResource()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
301
diff
changeset
|
185 deletedResources[answer.valueString] = static_cast<OrthancPluginResourceType>(answer.valueInt32); |
8de3a1ecac11
MySQL: Added missing calls to OrthancPluginDatabaseSignalDeletedResource()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
301
diff
changeset
|
186 break; |
8de3a1ecac11
MySQL: Added missing calls to OrthancPluginDatabaseSignalDeletedResource()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
301
diff
changeset
|
187 |
8de3a1ecac11
MySQL: Added missing calls to OrthancPluginDatabaseSignalDeletedResource()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
301
diff
changeset
|
188 case _OrthancPluginDatabaseAnswerType_RemainingAncestor: |
8de3a1ecac11
MySQL: Added missing calls to OrthancPluginDatabaseSignalDeletedResource()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
301
diff
changeset
|
189 remainingAncestor.reset(new std::pair<std::string, OrthancPluginResourceType>()); |
8de3a1ecac11
MySQL: Added missing calls to OrthancPluginDatabaseSignalDeletedResource()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
301
diff
changeset
|
190 *remainingAncestor = std::make_pair(answer.valueString, static_cast<OrthancPluginResourceType>(answer.valueInt32)); |
8de3a1ecac11
MySQL: Added missing calls to OrthancPluginDatabaseSignalDeletedResource()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
301
diff
changeset
|
191 break; |
8de3a1ecac11
MySQL: Added missing calls to OrthancPluginDatabaseSignalDeletedResource()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
301
diff
changeset
|
192 |
8de3a1ecac11
MySQL: Added missing calls to OrthancPluginDatabaseSignalDeletedResource()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
301
diff
changeset
|
193 case _OrthancPluginDatabaseAnswerType_DeletedAttachment: |
8de3a1ecac11
MySQL: Added missing calls to OrthancPluginDatabaseSignalDeletedResource()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
301
diff
changeset
|
194 deletedAttachments.insert(reinterpret_cast<const OrthancPluginAttachment*>(answer.valueGeneric)->uuid); |
8de3a1ecac11
MySQL: Added missing calls to OrthancPluginDatabaseSignalDeletedResource()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
301
diff
changeset
|
195 break; |
8de3a1ecac11
MySQL: Added missing calls to OrthancPluginDatabaseSignalDeletedResource()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
301
diff
changeset
|
196 |
199 | 197 default: |
198 printf("Unhandled message: %d\n", answer.type); | |
199 break; | |
0 | 200 } |
201 | |
199 | 202 return OrthancPluginErrorCode_Success; |
203 } | |
0 | 204 |
199 | 205 case _OrthancPluginService_GetExpectedDatabaseVersion: |
206 { | |
207 const _OrthancPluginReturnSingleValue& p = | |
208 *reinterpret_cast<const _OrthancPluginReturnSingleValue*>(params); | |
209 *(p.resultUint32) = ORTHANC_DATABASE_VERSION; | |
210 return OrthancPluginErrorCode_Success; | |
211 } | |
0 | 212 |
199 | 213 default: |
214 assert(0); | |
215 printf("Service not emulated: %d\n", service); | |
216 return OrthancPluginErrorCode_NotImplemented; | |
0 | 217 } |
218 } | |
219 | |
220 | |
221 TEST(IndexBackend, Basic) | |
222 { | |
223 using namespace OrthancDatabases; | |
224 | |
225 OrthancPluginContext context; | |
226 context.pluginsManager = NULL; | |
227 context.orthancVersion = "mainline"; | |
228 context.Free = ::free; | |
229 context.InvokeService = InvokeService; | |
230 | |
28
c0cb5d2cd696
checks depending on Orthanc version
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
27
diff
changeset
|
231 ImplicitTransaction::SetErrorOnDoubleExecution(true); |
c0cb5d2cd696
checks depending on Orthanc version
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
27
diff
changeset
|
232 |
0 | 233 #if ORTHANC_ENABLE_POSTGRESQL == 1 |
201
42990b2dd51b
create IDatabaseBackendOutput only if needed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
200
diff
changeset
|
234 PostgreSQLIndex db(&context, globalParameters_); |
0 | 235 db.SetClearAll(true); |
236 #elif ORTHANC_ENABLE_MYSQL == 1 | |
201
42990b2dd51b
create IDatabaseBackendOutput only if needed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
200
diff
changeset
|
237 MySQLIndex db(&context, globalParameters_); |
0 | 238 db.SetClearAll(true); |
309
d192bfd0e752
tagging globalParameters_ as static in MySQL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
307
diff
changeset
|
239 #elif ORTHANC_ENABLE_ODBC == 1 |
d192bfd0e752
tagging globalParameters_ as static in MySQL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
307
diff
changeset
|
240 OdbcIndex db(&context, connectionString_); |
319 | 241 #elif ORTHANC_ENABLE_SQLITE == 1 // Must be the last one |
242 SQLiteIndex db(&context); // Open in memory | |
0 | 243 #else |
244 # error Unsupported database backend | |
245 #endif | |
246 | |
204 | 247 db.SetOutputFactory(new DatabaseBackendAdapterV2::Factory(&context, NULL)); |
201
42990b2dd51b
create IDatabaseBackendOutput only if needed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
200
diff
changeset
|
248 |
226
a4918d57435c
DatabaseManager doesn't IDatabaseFactory anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
225
diff
changeset
|
249 std::unique_ptr<DatabaseManager> manager(IndexBackend::CreateSingleDatabaseManager(db)); |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
221
diff
changeset
|
250 |
203
2089d4071408
moving classes out of OrthancPlugins namespace, to OrthancDatabases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
201
diff
changeset
|
251 std::unique_ptr<IDatabaseBackendOutput> output(db.CreateOutput()); |
0 | 252 |
253 std::string s; | |
226
a4918d57435c
DatabaseManager doesn't IDatabaseFactory anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
225
diff
changeset
|
254 ASSERT_TRUE(db.LookupGlobalProperty(s, *manager, MISSING_SERVER_IDENTIFIER, Orthanc::GlobalProperty_DatabaseSchemaVersion)); |
0 | 255 ASSERT_EQ("6", s); |
256 | |
239
e9ba888f371b
fix IndexBackend::SetGlobalProperty(), lighten GlobalProperty enum
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
257 db.SetGlobalProperty(*manager, MISSING_SERVER_IDENTIFIER, Orthanc::GlobalProperty_DatabaseInternal9, "Hello"); |
e9ba888f371b
fix IndexBackend::SetGlobalProperty(), lighten GlobalProperty enum
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
258 ASSERT_TRUE(db.LookupGlobalProperty(s, *manager, MISSING_SERVER_IDENTIFIER, Orthanc::GlobalProperty_DatabaseInternal9)); |
0 | 259 ASSERT_EQ("Hello", s); |
239
e9ba888f371b
fix IndexBackend::SetGlobalProperty(), lighten GlobalProperty enum
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
260 db.SetGlobalProperty(*manager, MISSING_SERVER_IDENTIFIER, Orthanc::GlobalProperty_DatabaseInternal9, "HelloWorld"); |
e9ba888f371b
fix IndexBackend::SetGlobalProperty(), lighten GlobalProperty enum
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
261 ASSERT_TRUE(db.LookupGlobalProperty(s, *manager, MISSING_SERVER_IDENTIFIER, Orthanc::GlobalProperty_DatabaseInternal9)); |
0 | 262 ASSERT_EQ("HelloWorld", s); |
263 | |
301 | 264 ASSERT_EQ(0u, db.GetAllResourcesCount(*manager)); |
265 ASSERT_EQ(0u, db.GetResourcesCount(*manager, OrthancPluginResourceType_Patient)); | |
266 ASSERT_EQ(0u, db.GetResourcesCount(*manager, OrthancPluginResourceType_Study)); | |
267 ASSERT_EQ(0u, db.GetResourcesCount(*manager, OrthancPluginResourceType_Series)); | |
268 | |
226
a4918d57435c
DatabaseManager doesn't IDatabaseFactory anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
225
diff
changeset
|
269 int64_t a = db.CreateResource(*manager, "study", OrthancPluginResourceType_Study); |
a4918d57435c
DatabaseManager doesn't IDatabaseFactory anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
225
diff
changeset
|
270 ASSERT_TRUE(db.IsExistingResource(*manager, a)); |
a4918d57435c
DatabaseManager doesn't IDatabaseFactory anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
225
diff
changeset
|
271 ASSERT_FALSE(db.IsExistingResource(*manager, a + 1)); |
0 | 272 |
273 int64_t b; | |
274 OrthancPluginResourceType t; | |
226
a4918d57435c
DatabaseManager doesn't IDatabaseFactory anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
225
diff
changeset
|
275 ASSERT_FALSE(db.LookupResource(b, t, *manager, "world")); |
a4918d57435c
DatabaseManager doesn't IDatabaseFactory anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
225
diff
changeset
|
276 ASSERT_TRUE(db.LookupResource(b, t, *manager, "study")); |
0 | 277 ASSERT_EQ(a, b); |
278 ASSERT_EQ(OrthancPluginResourceType_Study, t); | |
279 | |
226
a4918d57435c
DatabaseManager doesn't IDatabaseFactory anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
225
diff
changeset
|
280 b = db.CreateResource(*manager, "series", OrthancPluginResourceType_Series); |
0 | 281 ASSERT_NE(a, b); |
282 | |
226
a4918d57435c
DatabaseManager doesn't IDatabaseFactory anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
225
diff
changeset
|
283 ASSERT_EQ("study", db.GetPublicId(*manager, a)); |
a4918d57435c
DatabaseManager doesn't IDatabaseFactory anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
225
diff
changeset
|
284 ASSERT_EQ("series", db.GetPublicId(*manager, b)); |
a4918d57435c
DatabaseManager doesn't IDatabaseFactory anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
225
diff
changeset
|
285 ASSERT_EQ(OrthancPluginResourceType_Study, db.GetResourceType(*manager, a)); |
a4918d57435c
DatabaseManager doesn't IDatabaseFactory anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
225
diff
changeset
|
286 ASSERT_EQ(OrthancPluginResourceType_Series, db.GetResourceType(*manager, b)); |
0 | 287 |
226
a4918d57435c
DatabaseManager doesn't IDatabaseFactory anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
225
diff
changeset
|
288 db.AttachChild(*manager, a, b); |
0 | 289 |
290 int64_t c; | |
226
a4918d57435c
DatabaseManager doesn't IDatabaseFactory anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
225
diff
changeset
|
291 ASSERT_FALSE(db.LookupParent(c, *manager, a)); |
a4918d57435c
DatabaseManager doesn't IDatabaseFactory anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
225
diff
changeset
|
292 ASSERT_TRUE(db.LookupParent(c, *manager, b)); |
0 | 293 ASSERT_EQ(a, c); |
294 | |
226
a4918d57435c
DatabaseManager doesn't IDatabaseFactory anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
225
diff
changeset
|
295 c = db.CreateResource(*manager, "series2", OrthancPluginResourceType_Series); |
a4918d57435c
DatabaseManager doesn't IDatabaseFactory anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
225
diff
changeset
|
296 db.AttachChild(*manager, a, c); |
0 | 297 |
226
a4918d57435c
DatabaseManager doesn't IDatabaseFactory anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
225
diff
changeset
|
298 ASSERT_EQ(3u, db.GetAllResourcesCount(*manager)); |
a4918d57435c
DatabaseManager doesn't IDatabaseFactory anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
225
diff
changeset
|
299 ASSERT_EQ(0u, db.GetResourcesCount(*manager, OrthancPluginResourceType_Patient)); |
a4918d57435c
DatabaseManager doesn't IDatabaseFactory anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
225
diff
changeset
|
300 ASSERT_EQ(1u, db.GetResourcesCount(*manager, OrthancPluginResourceType_Study)); |
a4918d57435c
DatabaseManager doesn't IDatabaseFactory anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
225
diff
changeset
|
301 ASSERT_EQ(2u, db.GetResourcesCount(*manager, OrthancPluginResourceType_Series)); |
0 | 302 |
226
a4918d57435c
DatabaseManager doesn't IDatabaseFactory anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
225
diff
changeset
|
303 ASSERT_FALSE(db.GetParentPublicId(s, *manager, a)); |
a4918d57435c
DatabaseManager doesn't IDatabaseFactory anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
225
diff
changeset
|
304 ASSERT_TRUE(db.GetParentPublicId(s, *manager, b)); ASSERT_EQ("study", s); |
a4918d57435c
DatabaseManager doesn't IDatabaseFactory anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
225
diff
changeset
|
305 ASSERT_TRUE(db.GetParentPublicId(s, *manager, c)); ASSERT_EQ("study", s); |
0 | 306 |
307 std::list<std::string> children; | |
226
a4918d57435c
DatabaseManager doesn't IDatabaseFactory anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
225
diff
changeset
|
308 db.GetChildren(children, *manager, a); |
0 | 309 ASSERT_EQ(2u, children.size()); |
226
a4918d57435c
DatabaseManager doesn't IDatabaseFactory anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
225
diff
changeset
|
310 db.GetChildren(children, *manager, b); |
0 | 311 ASSERT_EQ(0u, children.size()); |
226
a4918d57435c
DatabaseManager doesn't IDatabaseFactory anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
225
diff
changeset
|
312 db.GetChildren(children, *manager, c); |
0 | 313 ASSERT_EQ(0u, children.size()); |
314 | |
315 std::list<std::string> cp; | |
226
a4918d57435c
DatabaseManager doesn't IDatabaseFactory anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
225
diff
changeset
|
316 db.GetChildrenPublicId(cp, *manager, a); |
0 | 317 ASSERT_EQ(2u, cp.size()); |
318 ASSERT_TRUE(cp.front() == "series" || cp.front() == "series2"); | |
319 ASSERT_TRUE(cp.back() == "series" || cp.back() == "series2"); | |
320 ASSERT_NE(cp.front(), cp.back()); | |
321 | |
322 std::list<std::string> pub; | |
226
a4918d57435c
DatabaseManager doesn't IDatabaseFactory anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
225
diff
changeset
|
323 db.GetAllPublicIds(pub, *manager, OrthancPluginResourceType_Patient); |
0 | 324 ASSERT_EQ(0u, pub.size()); |
226
a4918d57435c
DatabaseManager doesn't IDatabaseFactory anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
225
diff
changeset
|
325 db.GetAllPublicIds(pub, *manager, OrthancPluginResourceType_Study); |
0 | 326 ASSERT_EQ(1u, pub.size()); |
327 ASSERT_EQ("study", pub.front()); | |
226
a4918d57435c
DatabaseManager doesn't IDatabaseFactory anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
225
diff
changeset
|
328 db.GetAllPublicIds(pub, *manager, OrthancPluginResourceType_Series); |
0 | 329 ASSERT_EQ(2u, pub.size()); |
330 ASSERT_TRUE(pub.front() == "series" || pub.front() == "series2"); | |
331 ASSERT_TRUE(pub.back() == "series" || pub.back() == "series2"); | |
332 ASSERT_NE(pub.front(), pub.back()); | |
333 | |
334 std::list<int64_t> ci; | |
226
a4918d57435c
DatabaseManager doesn't IDatabaseFactory anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
225
diff
changeset
|
335 db.GetChildrenInternalId(ci, *manager, a); |
0 | 336 ASSERT_EQ(2u, ci.size()); |
337 ASSERT_TRUE(ci.front() == b || ci.front() == c); | |
338 ASSERT_TRUE(ci.back() == b || ci.back() == c); | |
339 ASSERT_NE(ci.front(), ci.back()); | |
340 | |
256
e184dcadf163
handling of revisions in metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
239
diff
changeset
|
341 db.SetMetadata(*manager, a, Orthanc::MetadataType_ModifiedFrom, "modified", 42); |
e184dcadf163
handling of revisions in metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
239
diff
changeset
|
342 db.SetMetadata(*manager, a, Orthanc::MetadataType_LastUpdate, "update2", 43); |
e184dcadf163
handling of revisions in metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
239
diff
changeset
|
343 int64_t revision = -1; |
e184dcadf163
handling of revisions in metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
239
diff
changeset
|
344 ASSERT_FALSE(db.LookupMetadata(s, revision, *manager, b, Orthanc::MetadataType_LastUpdate)); |
e184dcadf163
handling of revisions in metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
239
diff
changeset
|
345 ASSERT_TRUE(db.LookupMetadata(s, revision, *manager, a, Orthanc::MetadataType_LastUpdate)); |
0 | 346 ASSERT_EQ("update2", s); |
256
e184dcadf163
handling of revisions in metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
239
diff
changeset
|
347 |
266
cc7af42d4f23
Store revisions for metadata and attachments in PostgreSQL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
348 #if HAS_REVISIONS == 1 |
cc7af42d4f23
Store revisions for metadata and attachments in PostgreSQL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
349 ASSERT_EQ(43, revision); |
256
e184dcadf163
handling of revisions in metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
239
diff
changeset
|
350 #else |
e184dcadf163
handling of revisions in metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
239
diff
changeset
|
351 ASSERT_EQ(0, revision); |
e184dcadf163
handling of revisions in metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
239
diff
changeset
|
352 #endif |
e184dcadf163
handling of revisions in metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
239
diff
changeset
|
353 |
335
7ec461718edb
unit test of metadata and tags in UTF8
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
321
diff
changeset
|
354 db.SetMetadata(*manager, a, Orthanc::MetadataType_LastUpdate, reinterpret_cast<const char*>(UTF8), 44); |
256
e184dcadf163
handling of revisions in metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
239
diff
changeset
|
355 ASSERT_TRUE(db.LookupMetadata(s, revision, *manager, a, Orthanc::MetadataType_LastUpdate)); |
335
7ec461718edb
unit test of metadata and tags in UTF8
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
321
diff
changeset
|
356 ASSERT_STREQ(reinterpret_cast<const char*>(UTF8), s.c_str()); |
0 | 357 |
266
cc7af42d4f23
Store revisions for metadata and attachments in PostgreSQL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
358 #if HAS_REVISIONS == 1 |
cc7af42d4f23
Store revisions for metadata and attachments in PostgreSQL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
359 ASSERT_EQ(44, revision); |
256
e184dcadf163
handling of revisions in metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
239
diff
changeset
|
360 #else |
e184dcadf163
handling of revisions in metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
239
diff
changeset
|
361 ASSERT_EQ(0, revision); |
e184dcadf163
handling of revisions in metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
239
diff
changeset
|
362 #endif |
e184dcadf163
handling of revisions in metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
239
diff
changeset
|
363 |
0 | 364 std::list<int32_t> md; |
226
a4918d57435c
DatabaseManager doesn't IDatabaseFactory anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
225
diff
changeset
|
365 db.ListAvailableMetadata(md, *manager, a); |
0 | 366 ASSERT_EQ(2u, md.size()); |
367 ASSERT_TRUE(md.front() == Orthanc::MetadataType_ModifiedFrom || md.back() == Orthanc::MetadataType_ModifiedFrom); | |
368 ASSERT_TRUE(md.front() == Orthanc::MetadataType_LastUpdate || md.back() == Orthanc::MetadataType_LastUpdate); | |
369 std::string mdd; | |
256
e184dcadf163
handling of revisions in metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
239
diff
changeset
|
370 ASSERT_TRUE(db.LookupMetadata(mdd, revision, *manager, a, Orthanc::MetadataType_ModifiedFrom)); |
0 | 371 ASSERT_EQ("modified", mdd); |
256
e184dcadf163
handling of revisions in metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
239
diff
changeset
|
372 |
266
cc7af42d4f23
Store revisions for metadata and attachments in PostgreSQL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
373 #if HAS_REVISIONS == 1 |
cc7af42d4f23
Store revisions for metadata and attachments in PostgreSQL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
374 ASSERT_EQ(42, revision); |
256
e184dcadf163
handling of revisions in metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
239
diff
changeset
|
375 #else |
e184dcadf163
handling of revisions in metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
239
diff
changeset
|
376 ASSERT_EQ(0, revision); |
e184dcadf163
handling of revisions in metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
239
diff
changeset
|
377 #endif |
e184dcadf163
handling of revisions in metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
239
diff
changeset
|
378 |
e184dcadf163
handling of revisions in metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
239
diff
changeset
|
379 ASSERT_TRUE(db.LookupMetadata(mdd, revision, *manager, a, Orthanc::MetadataType_LastUpdate)); |
335
7ec461718edb
unit test of metadata and tags in UTF8
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
321
diff
changeset
|
380 ASSERT_EQ(reinterpret_cast<const char*>(UTF8), mdd); |
0 | 381 |
266
cc7af42d4f23
Store revisions for metadata and attachments in PostgreSQL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
382 #if HAS_REVISIONS == 1 |
cc7af42d4f23
Store revisions for metadata and attachments in PostgreSQL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
383 ASSERT_EQ(44, revision); |
256
e184dcadf163
handling of revisions in metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
239
diff
changeset
|
384 #else |
e184dcadf163
handling of revisions in metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
239
diff
changeset
|
385 ASSERT_EQ(0, revision); |
e184dcadf163
handling of revisions in metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
239
diff
changeset
|
386 #endif |
e184dcadf163
handling of revisions in metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
239
diff
changeset
|
387 |
226
a4918d57435c
DatabaseManager doesn't IDatabaseFactory anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
225
diff
changeset
|
388 db.ListAvailableMetadata(md, *manager, b); |
0 | 389 ASSERT_EQ(0u, md.size()); |
390 | |
256
e184dcadf163
handling of revisions in metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
239
diff
changeset
|
391 ASSERT_TRUE(db.LookupMetadata(s, revision, *manager, a, Orthanc::MetadataType_LastUpdate)); |
226
a4918d57435c
DatabaseManager doesn't IDatabaseFactory anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
225
diff
changeset
|
392 db.DeleteMetadata(*manager, a, Orthanc::MetadataType_LastUpdate); |
256
e184dcadf163
handling of revisions in metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
239
diff
changeset
|
393 ASSERT_FALSE(db.LookupMetadata(s, revision, *manager, a, Orthanc::MetadataType_LastUpdate)); |
226
a4918d57435c
DatabaseManager doesn't IDatabaseFactory anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
225
diff
changeset
|
394 db.DeleteMetadata(*manager, b, Orthanc::MetadataType_LastUpdate); |
256
e184dcadf163
handling of revisions in metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
239
diff
changeset
|
395 ASSERT_FALSE(db.LookupMetadata(s, revision, *manager, a, Orthanc::MetadataType_LastUpdate)); |
0 | 396 |
226
a4918d57435c
DatabaseManager doesn't IDatabaseFactory anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
225
diff
changeset
|
397 db.ListAvailableMetadata(md, *manager, a); |
0 | 398 ASSERT_EQ(1u, md.size()); |
399 ASSERT_EQ(Orthanc::MetadataType_ModifiedFrom, md.front()); | |
400 | |
226
a4918d57435c
DatabaseManager doesn't IDatabaseFactory anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
225
diff
changeset
|
401 ASSERT_EQ(0u, db.GetTotalCompressedSize(*manager)); |
a4918d57435c
DatabaseManager doesn't IDatabaseFactory anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
225
diff
changeset
|
402 ASSERT_EQ(0u, db.GetTotalUncompressedSize(*manager)); |
0 | 403 |
404 | |
405 std::list<int32_t> fc; | |
406 | |
407 OrthancPluginAttachment a1; | |
408 a1.uuid = "uuid1"; | |
409 a1.contentType = Orthanc::FileContentType_Dicom; | |
410 a1.uncompressedSize = 42; | |
411 a1.uncompressedHash = "md5_1"; | |
412 a1.compressionType = Orthanc::CompressionType_None; | |
413 a1.compressedSize = 42; | |
414 a1.compressedHash = "md5_1"; | |
415 | |
416 OrthancPluginAttachment a2; | |
417 a2.uuid = "uuid2"; | |
418 a2.contentType = Orthanc::FileContentType_DicomAsJson; | |
419 a2.uncompressedSize = 4242; | |
420 a2.uncompressedHash = "md5_2"; | |
421 a2.compressionType = Orthanc::CompressionType_None; | |
422 a2.compressedSize = 4242; | |
423 a2.compressedHash = "md5_2"; | |
424 | |
261
34e2b93a7ac1
implementing interface for revisions in attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
256
diff
changeset
|
425 db.AddAttachment(*manager, a, a1, 42); |
226
a4918d57435c
DatabaseManager doesn't IDatabaseFactory anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
225
diff
changeset
|
426 db.ListAvailableAttachments(fc, *manager, a); |
0 | 427 ASSERT_EQ(1u, fc.size()); |
428 ASSERT_EQ(Orthanc::FileContentType_Dicom, fc.front()); | |
261
34e2b93a7ac1
implementing interface for revisions in attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
256
diff
changeset
|
429 db.AddAttachment(*manager, a, a2, 43); |
226
a4918d57435c
DatabaseManager doesn't IDatabaseFactory anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
225
diff
changeset
|
430 db.ListAvailableAttachments(fc, *manager, a); |
0 | 431 ASSERT_EQ(2u, fc.size()); |
261
34e2b93a7ac1
implementing interface for revisions in attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
256
diff
changeset
|
432 ASSERT_FALSE(db.LookupAttachment(*output, revision, *manager, b, Orthanc::FileContentType_Dicom)); |
0 | 433 |
226
a4918d57435c
DatabaseManager doesn't IDatabaseFactory anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
225
diff
changeset
|
434 ASSERT_EQ(4284u, db.GetTotalCompressedSize(*manager)); |
a4918d57435c
DatabaseManager doesn't IDatabaseFactory anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
225
diff
changeset
|
435 ASSERT_EQ(4284u, db.GetTotalUncompressedSize(*manager)); |
0 | 436 |
437 expectedAttachment.reset(new OrthancPluginAttachment); | |
438 expectedAttachment->uuid = "uuid1"; | |
439 expectedAttachment->contentType = Orthanc::FileContentType_Dicom; | |
440 expectedAttachment->uncompressedSize = 42; | |
441 expectedAttachment->uncompressedHash = "md5_1"; | |
442 expectedAttachment->compressionType = Orthanc::CompressionType_None; | |
443 expectedAttachment->compressedSize = 42; | |
444 expectedAttachment->compressedHash = "md5_1"; | |
261
34e2b93a7ac1
implementing interface for revisions in attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
256
diff
changeset
|
445 ASSERT_TRUE(db.LookupAttachment(*output, revision, *manager, a, Orthanc::FileContentType_Dicom)); |
262
b0c65094b299
adding support for revisions in attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
261
diff
changeset
|
446 |
266
cc7af42d4f23
Store revisions for metadata and attachments in PostgreSQL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
447 #if HAS_REVISIONS == 1 |
cc7af42d4f23
Store revisions for metadata and attachments in PostgreSQL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
448 ASSERT_EQ(42, revision); |
262
b0c65094b299
adding support for revisions in attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
261
diff
changeset
|
449 #else |
b0c65094b299
adding support for revisions in attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
261
diff
changeset
|
450 ASSERT_EQ(0, revision); |
b0c65094b299
adding support for revisions in attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
261
diff
changeset
|
451 #endif |
0 | 452 |
453 expectedAttachment.reset(new OrthancPluginAttachment); | |
454 expectedAttachment->uuid = "uuid2"; | |
455 expectedAttachment->contentType = Orthanc::FileContentType_DicomAsJson; | |
456 expectedAttachment->uncompressedSize = 4242; | |
457 expectedAttachment->uncompressedHash = "md5_2"; | |
458 expectedAttachment->compressionType = Orthanc::CompressionType_None; | |
459 expectedAttachment->compressedSize = 4242; | |
460 expectedAttachment->compressedHash = "md5_2"; | |
261
34e2b93a7ac1
implementing interface for revisions in attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
256
diff
changeset
|
461 revision = -1; |
34e2b93a7ac1
implementing interface for revisions in attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
256
diff
changeset
|
462 ASSERT_TRUE(db.LookupAttachment(*output, revision, *manager, a, Orthanc::FileContentType_DicomAsJson)); |
262
b0c65094b299
adding support for revisions in attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
261
diff
changeset
|
463 |
266
cc7af42d4f23
Store revisions for metadata and attachments in PostgreSQL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
464 #if HAS_REVISIONS == 1 |
cc7af42d4f23
Store revisions for metadata and attachments in PostgreSQL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
465 ASSERT_EQ(43, revision); |
262
b0c65094b299
adding support for revisions in attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
261
diff
changeset
|
466 #else |
b0c65094b299
adding support for revisions in attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
261
diff
changeset
|
467 ASSERT_EQ(0, revision); |
b0c65094b299
adding support for revisions in attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
261
diff
changeset
|
468 #endif |
0 | 469 |
226
a4918d57435c
DatabaseManager doesn't IDatabaseFactory anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
225
diff
changeset
|
470 db.ListAvailableAttachments(fc, *manager, b); |
0 | 471 ASSERT_EQ(0u, fc.size()); |
226
a4918d57435c
DatabaseManager doesn't IDatabaseFactory anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
225
diff
changeset
|
472 db.DeleteAttachment(*output, *manager, a, Orthanc::FileContentType_Dicom); |
a4918d57435c
DatabaseManager doesn't IDatabaseFactory anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
225
diff
changeset
|
473 db.ListAvailableAttachments(fc, *manager, a); |
0 | 474 ASSERT_EQ(1u, fc.size()); |
475 ASSERT_EQ(Orthanc::FileContentType_DicomAsJson, fc.front()); | |
226
a4918d57435c
DatabaseManager doesn't IDatabaseFactory anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
225
diff
changeset
|
476 db.DeleteAttachment(*output, *manager, a, Orthanc::FileContentType_DicomAsJson); |
a4918d57435c
DatabaseManager doesn't IDatabaseFactory anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
225
diff
changeset
|
477 db.ListAvailableAttachments(fc, *manager, a); |
0 | 478 ASSERT_EQ(0u, fc.size()); |
479 | |
226
a4918d57435c
DatabaseManager doesn't IDatabaseFactory anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
225
diff
changeset
|
480 db.SetIdentifierTag(*manager, a, 0x0010, 0x0020, "patient"); |
a4918d57435c
DatabaseManager doesn't IDatabaseFactory anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
225
diff
changeset
|
481 db.SetIdentifierTag(*manager, a, 0x0020, 0x000d, "study"); |
335
7ec461718edb
unit test of metadata and tags in UTF8
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
321
diff
changeset
|
482 db.SetMainDicomTag(*manager, a, 0x0010, 0x0020, "patient"); |
7ec461718edb
unit test of metadata and tags in UTF8
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
321
diff
changeset
|
483 db.SetMainDicomTag(*manager, a, 0x0020, 0x000d, "study"); |
7ec461718edb
unit test of metadata and tags in UTF8
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
321
diff
changeset
|
484 db.SetMainDicomTag(*manager, a, 0x0008, 0x1030, reinterpret_cast<const char*>(UTF8)); |
0 | 485 |
486 expectedDicomTags.clear(); | |
487 expectedDicomTags.push_back(OrthancPluginDicomTag()); | |
335
7ec461718edb
unit test of metadata and tags in UTF8
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
321
diff
changeset
|
488 expectedDicomTags.back().group = 0x0010; |
7ec461718edb
unit test of metadata and tags in UTF8
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
321
diff
changeset
|
489 expectedDicomTags.back().element = 0x0020; |
7ec461718edb
unit test of metadata and tags in UTF8
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
321
diff
changeset
|
490 expectedDicomTags.back().value = "patient"; |
0 | 491 expectedDicomTags.push_back(OrthancPluginDicomTag()); |
492 expectedDicomTags.back().group = 0x0020; | |
493 expectedDicomTags.back().element = 0x000d; | |
494 expectedDicomTags.back().value = "study"; | |
335
7ec461718edb
unit test of metadata and tags in UTF8
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
321
diff
changeset
|
495 expectedDicomTags.push_back(OrthancPluginDicomTag()); |
7ec461718edb
unit test of metadata and tags in UTF8
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
321
diff
changeset
|
496 expectedDicomTags.back().group = 0x0008; |
7ec461718edb
unit test of metadata and tags in UTF8
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
321
diff
changeset
|
497 expectedDicomTags.back().element = 0x1030; |
7ec461718edb
unit test of metadata and tags in UTF8
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
321
diff
changeset
|
498 expectedDicomTags.back().value = reinterpret_cast<const char*>(UTF8); |
7ec461718edb
unit test of metadata and tags in UTF8
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
321
diff
changeset
|
499 |
7ec461718edb
unit test of metadata and tags in UTF8
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
321
diff
changeset
|
500 countDicomTags = 0; |
226
a4918d57435c
DatabaseManager doesn't IDatabaseFactory anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
225
diff
changeset
|
501 db.GetMainDicomTags(*output, *manager, a); |
335
7ec461718edb
unit test of metadata and tags in UTF8
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
321
diff
changeset
|
502 ASSERT_EQ(3u, countDicomTags); |
0 | 503 |
226
a4918d57435c
DatabaseManager doesn't IDatabaseFactory anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
225
diff
changeset
|
504 db.LookupIdentifier(ci, *manager, OrthancPluginResourceType_Study, 0x0010, 0x0020, |
0 | 505 OrthancPluginIdentifierConstraint_Equal, "patient"); |
506 ASSERT_EQ(1u, ci.size()); | |
507 ASSERT_EQ(a, ci.front()); | |
226
a4918d57435c
DatabaseManager doesn't IDatabaseFactory anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
225
diff
changeset
|
508 db.LookupIdentifier(ci, *manager, OrthancPluginResourceType_Study, 0x0010, 0x0020, |
0 | 509 OrthancPluginIdentifierConstraint_Equal, "study"); |
510 ASSERT_EQ(0u, ci.size()); | |
511 | |
512 | |
378
9db9e0275ec0
refactoring IndexBackend::LogExportedResource()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
359
diff
changeset
|
513 db.LogExportedResource(*manager, OrthancPluginResourceType_Study, "id", "remote", "date", |
9db9e0275ec0
refactoring IndexBackend::LogExportedResource()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
359
diff
changeset
|
514 "patient", "study", "series", "instance"); |
0 | 515 |
516 expectedExported.reset(new OrthancPluginExportedResource()); | |
378
9db9e0275ec0
refactoring IndexBackend::LogExportedResource()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
359
diff
changeset
|
517 expectedExported->seq = -1; |
9db9e0275ec0
refactoring IndexBackend::LogExportedResource()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
359
diff
changeset
|
518 expectedExported->resourceType = OrthancPluginResourceType_Study; |
9db9e0275ec0
refactoring IndexBackend::LogExportedResource()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
359
diff
changeset
|
519 expectedExported->publicId = "id"; |
9db9e0275ec0
refactoring IndexBackend::LogExportedResource()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
359
diff
changeset
|
520 expectedExported->modality = "remote"; |
9db9e0275ec0
refactoring IndexBackend::LogExportedResource()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
359
diff
changeset
|
521 expectedExported->date = "date"; |
9db9e0275ec0
refactoring IndexBackend::LogExportedResource()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
359
diff
changeset
|
522 expectedExported->patientId = "patient"; |
9db9e0275ec0
refactoring IndexBackend::LogExportedResource()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
359
diff
changeset
|
523 expectedExported->studyInstanceUid = "study"; |
9db9e0275ec0
refactoring IndexBackend::LogExportedResource()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
359
diff
changeset
|
524 expectedExported->seriesInstanceUid = "series"; |
9db9e0275ec0
refactoring IndexBackend::LogExportedResource()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
359
diff
changeset
|
525 expectedExported->sopInstanceUid = "instance"; |
0 | 526 |
527 bool done; | |
226
a4918d57435c
DatabaseManager doesn't IDatabaseFactory anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
225
diff
changeset
|
528 db.GetExportedResources(*output, done, *manager, 0, 10); |
0 | 529 |
530 | |
226
a4918d57435c
DatabaseManager doesn't IDatabaseFactory anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
225
diff
changeset
|
531 db.GetAllPublicIds(pub, *manager, OrthancPluginResourceType_Patient); ASSERT_EQ(0u, pub.size()); |
a4918d57435c
DatabaseManager doesn't IDatabaseFactory anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
225
diff
changeset
|
532 db.GetAllPublicIds(pub, *manager, OrthancPluginResourceType_Study); ASSERT_EQ(1u, pub.size()); |
a4918d57435c
DatabaseManager doesn't IDatabaseFactory anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
225
diff
changeset
|
533 db.GetAllPublicIds(pub, *manager, OrthancPluginResourceType_Series); ASSERT_EQ(2u, pub.size()); |
a4918d57435c
DatabaseManager doesn't IDatabaseFactory anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
225
diff
changeset
|
534 db.GetAllPublicIds(pub, *manager, OrthancPluginResourceType_Instance); ASSERT_EQ(0u, pub.size()); |
a4918d57435c
DatabaseManager doesn't IDatabaseFactory anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
225
diff
changeset
|
535 ASSERT_EQ(3u, db.GetAllResourcesCount(*manager)); |
0 | 536 |
226
a4918d57435c
DatabaseManager doesn't IDatabaseFactory anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
225
diff
changeset
|
537 ASSERT_EQ(0u, db.GetUnprotectedPatientsCount(*manager)); // No patient was inserted |
a4918d57435c
DatabaseManager doesn't IDatabaseFactory anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
225
diff
changeset
|
538 ASSERT_TRUE(db.IsExistingResource(*manager, c)); |
27
173176f8cef2
jobs branch has disappeared in orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
26
diff
changeset
|
539 |
173176f8cef2
jobs branch has disappeared in orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
26
diff
changeset
|
540 { |
173176f8cef2
jobs branch has disappeared in orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
26
diff
changeset
|
541 // A transaction is needed here for MySQL, as it was not possible |
173176f8cef2
jobs branch has disappeared in orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
26
diff
changeset
|
542 // to implement recursive deletion of resources using pure SQL |
173176f8cef2
jobs branch has disappeared in orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
26
diff
changeset
|
543 // statements |
307
8de3a1ecac11
MySQL: Added missing calls to OrthancPluginDatabaseSignalDeletedResource()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
301
diff
changeset
|
544 manager->StartTransaction(TransactionType_ReadWrite); |
8de3a1ecac11
MySQL: Added missing calls to OrthancPluginDatabaseSignalDeletedResource()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
301
diff
changeset
|
545 |
8de3a1ecac11
MySQL: Added missing calls to OrthancPluginDatabaseSignalDeletedResource()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
301
diff
changeset
|
546 deletedAttachments.clear(); |
8de3a1ecac11
MySQL: Added missing calls to OrthancPluginDatabaseSignalDeletedResource()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
301
diff
changeset
|
547 deletedResources.clear(); |
8de3a1ecac11
MySQL: Added missing calls to OrthancPluginDatabaseSignalDeletedResource()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
301
diff
changeset
|
548 remainingAncestor.reset(); |
8de3a1ecac11
MySQL: Added missing calls to OrthancPluginDatabaseSignalDeletedResource()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
301
diff
changeset
|
549 |
226
a4918d57435c
DatabaseManager doesn't IDatabaseFactory anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
225
diff
changeset
|
550 db.DeleteResource(*output, *manager, c); |
307
8de3a1ecac11
MySQL: Added missing calls to OrthancPluginDatabaseSignalDeletedResource()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
301
diff
changeset
|
551 |
8de3a1ecac11
MySQL: Added missing calls to OrthancPluginDatabaseSignalDeletedResource()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
301
diff
changeset
|
552 ASSERT_EQ(0u, deletedAttachments.size()); |
8de3a1ecac11
MySQL: Added missing calls to OrthancPluginDatabaseSignalDeletedResource()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
301
diff
changeset
|
553 ASSERT_EQ(1u, deletedResources.size()); |
8de3a1ecac11
MySQL: Added missing calls to OrthancPluginDatabaseSignalDeletedResource()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
301
diff
changeset
|
554 ASSERT_EQ(OrthancPluginResourceType_Series, deletedResources["series2"]); |
8de3a1ecac11
MySQL: Added missing calls to OrthancPluginDatabaseSignalDeletedResource()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
301
diff
changeset
|
555 ASSERT_TRUE(remainingAncestor.get() != NULL); |
8de3a1ecac11
MySQL: Added missing calls to OrthancPluginDatabaseSignalDeletedResource()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
301
diff
changeset
|
556 ASSERT_EQ("study", remainingAncestor->first); |
8de3a1ecac11
MySQL: Added missing calls to OrthancPluginDatabaseSignalDeletedResource()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
301
diff
changeset
|
557 ASSERT_EQ(OrthancPluginResourceType_Study, remainingAncestor->second); |
8de3a1ecac11
MySQL: Added missing calls to OrthancPluginDatabaseSignalDeletedResource()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
301
diff
changeset
|
558 |
226
a4918d57435c
DatabaseManager doesn't IDatabaseFactory anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
225
diff
changeset
|
559 manager->CommitTransaction(); |
27
173176f8cef2
jobs branch has disappeared in orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
26
diff
changeset
|
560 } |
173176f8cef2
jobs branch has disappeared in orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
26
diff
changeset
|
561 |
307
8de3a1ecac11
MySQL: Added missing calls to OrthancPluginDatabaseSignalDeletedResource()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
301
diff
changeset
|
562 deletedAttachments.clear(); |
8de3a1ecac11
MySQL: Added missing calls to OrthancPluginDatabaseSignalDeletedResource()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
301
diff
changeset
|
563 deletedResources.clear(); |
8de3a1ecac11
MySQL: Added missing calls to OrthancPluginDatabaseSignalDeletedResource()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
301
diff
changeset
|
564 remainingAncestor.reset(); |
8de3a1ecac11
MySQL: Added missing calls to OrthancPluginDatabaseSignalDeletedResource()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
301
diff
changeset
|
565 |
226
a4918d57435c
DatabaseManager doesn't IDatabaseFactory anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
225
diff
changeset
|
566 ASSERT_FALSE(db.IsExistingResource(*manager, c)); |
a4918d57435c
DatabaseManager doesn't IDatabaseFactory anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
225
diff
changeset
|
567 ASSERT_TRUE(db.IsExistingResource(*manager, a)); |
a4918d57435c
DatabaseManager doesn't IDatabaseFactory anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
225
diff
changeset
|
568 ASSERT_TRUE(db.IsExistingResource(*manager, b)); |
a4918d57435c
DatabaseManager doesn't IDatabaseFactory anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
225
diff
changeset
|
569 ASSERT_EQ(2u, db.GetAllResourcesCount(*manager)); |
a4918d57435c
DatabaseManager doesn't IDatabaseFactory anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
225
diff
changeset
|
570 db.DeleteResource(*output, *manager, a); |
a4918d57435c
DatabaseManager doesn't IDatabaseFactory anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
225
diff
changeset
|
571 ASSERT_EQ(0u, db.GetAllResourcesCount(*manager)); |
a4918d57435c
DatabaseManager doesn't IDatabaseFactory anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
225
diff
changeset
|
572 ASSERT_FALSE(db.IsExistingResource(*manager, a)); |
a4918d57435c
DatabaseManager doesn't IDatabaseFactory anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
225
diff
changeset
|
573 ASSERT_FALSE(db.IsExistingResource(*manager, b)); |
a4918d57435c
DatabaseManager doesn't IDatabaseFactory anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
225
diff
changeset
|
574 ASSERT_FALSE(db.IsExistingResource(*manager, c)); |
0 | 575 |
307
8de3a1ecac11
MySQL: Added missing calls to OrthancPluginDatabaseSignalDeletedResource()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
301
diff
changeset
|
576 ASSERT_EQ(0u, deletedAttachments.size()); |
8de3a1ecac11
MySQL: Added missing calls to OrthancPluginDatabaseSignalDeletedResource()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
301
diff
changeset
|
577 ASSERT_EQ(2u, deletedResources.size()); |
8de3a1ecac11
MySQL: Added missing calls to OrthancPluginDatabaseSignalDeletedResource()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
301
diff
changeset
|
578 ASSERT_EQ(OrthancPluginResourceType_Series, deletedResources["series"]); |
8de3a1ecac11
MySQL: Added missing calls to OrthancPluginDatabaseSignalDeletedResource()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
301
diff
changeset
|
579 ASSERT_EQ(OrthancPluginResourceType_Study, deletedResources["study"]); |
8de3a1ecac11
MySQL: Added missing calls to OrthancPluginDatabaseSignalDeletedResource()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
301
diff
changeset
|
580 ASSERT_FALSE(remainingAncestor.get() != NULL); |
8de3a1ecac11
MySQL: Added missing calls to OrthancPluginDatabaseSignalDeletedResource()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
301
diff
changeset
|
581 |
226
a4918d57435c
DatabaseManager doesn't IDatabaseFactory anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
225
diff
changeset
|
582 ASSERT_EQ(0u, db.GetAllResourcesCount(*manager)); |
a4918d57435c
DatabaseManager doesn't IDatabaseFactory anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
225
diff
changeset
|
583 ASSERT_EQ(0u, db.GetUnprotectedPatientsCount(*manager)); |
a4918d57435c
DatabaseManager doesn't IDatabaseFactory anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
225
diff
changeset
|
584 int64_t p1 = db.CreateResource(*manager, "patient1", OrthancPluginResourceType_Patient); |
a4918d57435c
DatabaseManager doesn't IDatabaseFactory anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
225
diff
changeset
|
585 int64_t p2 = db.CreateResource(*manager, "patient2", OrthancPluginResourceType_Patient); |
a4918d57435c
DatabaseManager doesn't IDatabaseFactory anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
225
diff
changeset
|
586 int64_t p3 = db.CreateResource(*manager, "patient3", OrthancPluginResourceType_Patient); |
a4918d57435c
DatabaseManager doesn't IDatabaseFactory anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
225
diff
changeset
|
587 ASSERT_EQ(3u, db.GetUnprotectedPatientsCount(*manager)); |
0 | 588 int64_t r; |
226
a4918d57435c
DatabaseManager doesn't IDatabaseFactory anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
225
diff
changeset
|
589 ASSERT_TRUE(db.SelectPatientToRecycle(r, *manager)); |
0 | 590 ASSERT_EQ(p1, r); |
226
a4918d57435c
DatabaseManager doesn't IDatabaseFactory anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
225
diff
changeset
|
591 ASSERT_TRUE(db.SelectPatientToRecycle(r, *manager, p1)); |
0 | 592 ASSERT_EQ(p2, r); |
226
a4918d57435c
DatabaseManager doesn't IDatabaseFactory anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
225
diff
changeset
|
593 ASSERT_FALSE(db.IsProtectedPatient(*manager, p1)); |
a4918d57435c
DatabaseManager doesn't IDatabaseFactory anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
225
diff
changeset
|
594 db.SetProtectedPatient(*manager, p1, true); |
a4918d57435c
DatabaseManager doesn't IDatabaseFactory anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
225
diff
changeset
|
595 ASSERT_TRUE(db.IsProtectedPatient(*manager, p1)); |
a4918d57435c
DatabaseManager doesn't IDatabaseFactory anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
225
diff
changeset
|
596 ASSERT_TRUE(db.SelectPatientToRecycle(r, *manager)); |
0 | 597 ASSERT_EQ(p2, r); |
226
a4918d57435c
DatabaseManager doesn't IDatabaseFactory anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
225
diff
changeset
|
598 db.SetProtectedPatient(*manager, p1, false); |
a4918d57435c
DatabaseManager doesn't IDatabaseFactory anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
225
diff
changeset
|
599 ASSERT_FALSE(db.IsProtectedPatient(*manager, p1)); |
a4918d57435c
DatabaseManager doesn't IDatabaseFactory anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
225
diff
changeset
|
600 ASSERT_TRUE(db.SelectPatientToRecycle(r, *manager)); |
0 | 601 ASSERT_EQ(p2, r); |
226
a4918d57435c
DatabaseManager doesn't IDatabaseFactory anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
225
diff
changeset
|
602 db.DeleteResource(*output, *manager, p2); |
a4918d57435c
DatabaseManager doesn't IDatabaseFactory anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
225
diff
changeset
|
603 ASSERT_TRUE(db.SelectPatientToRecycle(r, *manager, p3)); |
0 | 604 ASSERT_EQ(p1, r); |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
221
diff
changeset
|
605 |
288
6d4d413a8797
unit test for large properties
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
273
diff
changeset
|
606 { |
289
0868500060f3
Fix serialization of large jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
288
diff
changeset
|
607 // Test creating a large property of 16MB (large properties are |
0868500060f3
Fix serialization of large jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
288
diff
changeset
|
608 // notably necessary to serialize jobs) |
288
6d4d413a8797
unit test for large properties
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
273
diff
changeset
|
609 // https://groups.google.com/g/orthanc-users/c/1Y3nTBdr0uE/m/K7PA5pboAgAJ |
6d4d413a8797
unit test for large properties
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
273
diff
changeset
|
610 std::string longProperty; |
6d4d413a8797
unit test for large properties
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
273
diff
changeset
|
611 longProperty.resize(16 * 1024 * 1024); |
6d4d413a8797
unit test for large properties
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
273
diff
changeset
|
612 for (size_t i = 0; i < longProperty.size(); i++) |
6d4d413a8797
unit test for large properties
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
273
diff
changeset
|
613 { |
6d4d413a8797
unit test for large properties
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
273
diff
changeset
|
614 longProperty[i] = 'A' + (i % 26); |
6d4d413a8797
unit test for large properties
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
273
diff
changeset
|
615 } |
6d4d413a8797
unit test for large properties
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
273
diff
changeset
|
616 |
6d4d413a8797
unit test for large properties
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
273
diff
changeset
|
617 db.SetGlobalProperty(*manager, MISSING_SERVER_IDENTIFIER, Orthanc::GlobalProperty_DatabaseInternal8, longProperty.c_str()); |
6d4d413a8797
unit test for large properties
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
273
diff
changeset
|
618 |
289
0868500060f3
Fix serialization of large jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
288
diff
changeset
|
619 // The following line fails on MySQL 4.0 because the "value" |
0868500060f3
Fix serialization of large jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
288
diff
changeset
|
620 // column in "ServerProperties" is "TEXT" instead of "LONGTEXT" |
0868500060f3
Fix serialization of large jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
288
diff
changeset
|
621 db.SetGlobalProperty(*manager, "some-server", Orthanc::GlobalProperty_DatabaseInternal8, longProperty.c_str()); |
0868500060f3
Fix serialization of large jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
288
diff
changeset
|
622 |
288
6d4d413a8797
unit test for large properties
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
273
diff
changeset
|
623 std::string tmp; |
6d4d413a8797
unit test for large properties
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
273
diff
changeset
|
624 ASSERT_TRUE(db.LookupGlobalProperty(tmp, *manager, MISSING_SERVER_IDENTIFIER, Orthanc::GlobalProperty_DatabaseInternal8)); |
6d4d413a8797
unit test for large properties
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
273
diff
changeset
|
625 ASSERT_EQ(longProperty, tmp); |
289
0868500060f3
Fix serialization of large jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
288
diff
changeset
|
626 |
0868500060f3
Fix serialization of large jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
288
diff
changeset
|
627 tmp.clear(); |
0868500060f3
Fix serialization of large jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
288
diff
changeset
|
628 ASSERT_TRUE(db.LookupGlobalProperty(tmp, *manager, "some-server", Orthanc::GlobalProperty_DatabaseInternal8)); |
0868500060f3
Fix serialization of large jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
288
diff
changeset
|
629 ASSERT_EQ(longProperty, tmp); |
288
6d4d413a8797
unit test for large properties
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
273
diff
changeset
|
630 } |
6d4d413a8797
unit test for large properties
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
273
diff
changeset
|
631 |
307
8de3a1ecac11
MySQL: Added missing calls to OrthancPluginDatabaseSignalDeletedResource()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
301
diff
changeset
|
632 db.DeleteResource(*output, *manager, p1); |
8de3a1ecac11
MySQL: Added missing calls to OrthancPluginDatabaseSignalDeletedResource()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
301
diff
changeset
|
633 db.DeleteResource(*output, *manager, p3); |
8de3a1ecac11
MySQL: Added missing calls to OrthancPluginDatabaseSignalDeletedResource()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
301
diff
changeset
|
634 |
8de3a1ecac11
MySQL: Added missing calls to OrthancPluginDatabaseSignalDeletedResource()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
301
diff
changeset
|
635 for (size_t level = 0; level < 4; level++) |
8de3a1ecac11
MySQL: Added missing calls to OrthancPluginDatabaseSignalDeletedResource()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
301
diff
changeset
|
636 { |
312 | 637 for (size_t attachmentLevel = 0; attachmentLevel < 4; attachmentLevel++) |
638 { | |
639 // Test cascade up to the "patient" level | |
640 ASSERT_EQ(0u, db.GetAllResourcesCount(*manager)); | |
307
8de3a1ecac11
MySQL: Added missing calls to OrthancPluginDatabaseSignalDeletedResource()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
301
diff
changeset
|
641 |
312 | 642 std::vector<int64_t> resources; |
643 resources.push_back(db.CreateResource(*manager, "patient", OrthancPluginResourceType_Patient)); | |
644 resources.push_back(db.CreateResource(*manager, "study", OrthancPluginResourceType_Study)); | |
645 resources.push_back(db.CreateResource(*manager, "series", OrthancPluginResourceType_Series)); | |
646 resources.push_back(db.CreateResource(*manager, "instance", OrthancPluginResourceType_Instance)); | |
647 | |
321 | 648 OrthancPluginAttachment d; |
649 d.uuid = "attachment"; | |
650 d.contentType = Orthanc::FileContentType_DicomAsJson; | |
651 d.uncompressedSize = 4242; | |
652 d.uncompressedHash = "md5"; | |
653 d.compressionType = Orthanc::CompressionType_None; | |
654 d.compressedSize = 4242; | |
655 d.compressedHash = "md5"; | |
656 db.AddAttachment(*manager, resources[attachmentLevel], d, 42); | |
307
8de3a1ecac11
MySQL: Added missing calls to OrthancPluginDatabaseSignalDeletedResource()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
301
diff
changeset
|
657 |
312 | 658 db.AttachChild(*manager, resources[0], resources[1]); |
659 db.AttachChild(*manager, resources[1], resources[2]); | |
660 db.AttachChild(*manager, resources[2], resources[3]); | |
661 ASSERT_EQ(4u, db.GetAllResourcesCount(*manager)); | |
307
8de3a1ecac11
MySQL: Added missing calls to OrthancPluginDatabaseSignalDeletedResource()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
301
diff
changeset
|
662 |
312 | 663 deletedAttachments.clear(); |
664 deletedResources.clear(); | |
665 remainingAncestor.reset(); | |
307
8de3a1ecac11
MySQL: Added missing calls to OrthancPluginDatabaseSignalDeletedResource()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
301
diff
changeset
|
666 |
312 | 667 db.DeleteResource(*output, *manager, resources[level]); |
307
8de3a1ecac11
MySQL: Added missing calls to OrthancPluginDatabaseSignalDeletedResource()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
301
diff
changeset
|
668 |
312 | 669 ASSERT_EQ(1u, deletedAttachments.size()); |
670 ASSERT_EQ("attachment", *deletedAttachments.begin()); | |
671 ASSERT_EQ(4u, deletedResources.size()); | |
672 ASSERT_EQ(OrthancPluginResourceType_Patient, deletedResources["patient"]); | |
673 ASSERT_EQ(OrthancPluginResourceType_Study, deletedResources["study"]); | |
674 ASSERT_EQ(OrthancPluginResourceType_Series, deletedResources["series"]); | |
675 ASSERT_EQ(OrthancPluginResourceType_Instance, deletedResources["instance"]); | |
676 ASSERT_TRUE(remainingAncestor.get() == NULL); | |
677 } | |
307
8de3a1ecac11
MySQL: Added missing calls to OrthancPluginDatabaseSignalDeletedResource()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
301
diff
changeset
|
678 } |
8de3a1ecac11
MySQL: Added missing calls to OrthancPluginDatabaseSignalDeletedResource()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
301
diff
changeset
|
679 |
8de3a1ecac11
MySQL: Added missing calls to OrthancPluginDatabaseSignalDeletedResource()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
301
diff
changeset
|
680 for (size_t level = 1; level < 4; level++) |
8de3a1ecac11
MySQL: Added missing calls to OrthancPluginDatabaseSignalDeletedResource()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
301
diff
changeset
|
681 { |
312 | 682 for (size_t attachmentLevel = 0; attachmentLevel < 4; attachmentLevel++) |
683 { | |
684 // Test remaining ancestor | |
685 ASSERT_EQ(0u, db.GetAllResourcesCount(*manager)); | |
307
8de3a1ecac11
MySQL: Added missing calls to OrthancPluginDatabaseSignalDeletedResource()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
301
diff
changeset
|
686 |
312 | 687 std::vector<int64_t> resources; |
688 resources.push_back(db.CreateResource(*manager, "patient", OrthancPluginResourceType_Patient)); | |
689 resources.push_back(db.CreateResource(*manager, "study", OrthancPluginResourceType_Study)); | |
690 resources.push_back(db.CreateResource(*manager, "series", OrthancPluginResourceType_Series)); | |
691 resources.push_back(db.CreateResource(*manager, "instance", OrthancPluginResourceType_Instance)); | |
307
8de3a1ecac11
MySQL: Added missing calls to OrthancPluginDatabaseSignalDeletedResource()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
301
diff
changeset
|
692 |
312 | 693 int64_t unrelated = db.CreateResource(*manager, "unrelated", OrthancPluginResourceType_Patient); |
694 int64_t remaining = db.CreateResource(*manager, "remaining", static_cast<OrthancPluginResourceType>(level)); | |
307
8de3a1ecac11
MySQL: Added missing calls to OrthancPluginDatabaseSignalDeletedResource()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
301
diff
changeset
|
695 |
312 | 696 db.AttachChild(*manager, resources[0], resources[1]); |
697 db.AttachChild(*manager, resources[1], resources[2]); | |
698 db.AttachChild(*manager, resources[2], resources[3]); | |
699 db.AttachChild(*manager, resources[level - 1], remaining); | |
700 ASSERT_EQ(6u, db.GetAllResourcesCount(*manager)); | |
701 | |
321 | 702 OrthancPluginAttachment d; |
703 d.uuid = "attachment"; | |
704 d.contentType = Orthanc::FileContentType_DicomAsJson; | |
705 d.uncompressedSize = 4242; | |
706 d.uncompressedHash = "md5"; | |
707 d.compressionType = Orthanc::CompressionType_None; | |
708 d.compressedSize = 4242; | |
709 d.compressedHash = "md5"; | |
710 db.AddAttachment(*manager, resources[attachmentLevel], d, 42); | |
314
64763998cdff
clarification in IndexBackend::SignalDeletedFiles()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
313
diff
changeset
|
711 |
313 | 712 deletedAttachments.clear(); |
321 | 713 d.uuid = "attachment2"; |
313 | 714 db.DeleteAttachment(*output, *manager, resources[attachmentLevel], Orthanc::FileContentType_DicomAsJson); |
715 ASSERT_EQ(1u, deletedAttachments.size()); | |
716 ASSERT_EQ("attachment", *deletedAttachments.begin()); | |
717 | |
321 | 718 db.AddAttachment(*manager, resources[attachmentLevel], d, 43); |
313 | 719 |
312 | 720 deletedAttachments.clear(); |
721 deletedResources.clear(); | |
722 remainingAncestor.reset(); | |
307
8de3a1ecac11
MySQL: Added missing calls to OrthancPluginDatabaseSignalDeletedResource()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
301
diff
changeset
|
723 |
312 | 724 db.DeleteResource(*output, *manager, resources[3]); // delete instance |
307
8de3a1ecac11
MySQL: Added missing calls to OrthancPluginDatabaseSignalDeletedResource()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
301
diff
changeset
|
725 |
312 | 726 if (attachmentLevel < level) |
727 { | |
728 ASSERT_EQ(0u, deletedAttachments.size()); | |
729 } | |
730 else | |
731 { | |
732 ASSERT_EQ(1u, deletedAttachments.size()); | |
313 | 733 ASSERT_EQ("attachment2", *deletedAttachments.begin()); |
312 | 734 } |
735 | |
736 ASSERT_EQ(OrthancPluginResourceType_Instance, deletedResources["instance"]); | |
737 | |
738 ASSERT_TRUE(remainingAncestor.get() != NULL); | |
739 | |
740 switch (level) | |
741 { | |
742 case 1: | |
743 ASSERT_EQ(3u, deletedResources.size()); | |
744 ASSERT_EQ(OrthancPluginResourceType_Study, deletedResources["study"]); | |
745 ASSERT_EQ(OrthancPluginResourceType_Series, deletedResources["series"]); | |
746 ASSERT_EQ("patient", remainingAncestor->first); | |
747 ASSERT_EQ(OrthancPluginResourceType_Patient, remainingAncestor->second); | |
748 break; | |
307
8de3a1ecac11
MySQL: Added missing calls to OrthancPluginDatabaseSignalDeletedResource()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
301
diff
changeset
|
749 |
312 | 750 case 2: |
751 ASSERT_EQ(2u, deletedResources.size()); | |
752 ASSERT_EQ(OrthancPluginResourceType_Series, deletedResources["series"]); | |
753 ASSERT_EQ("study", remainingAncestor->first); | |
754 ASSERT_EQ(OrthancPluginResourceType_Study, remainingAncestor->second); | |
755 break; | |
307
8de3a1ecac11
MySQL: Added missing calls to OrthancPluginDatabaseSignalDeletedResource()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
301
diff
changeset
|
756 |
312 | 757 case 3: |
758 ASSERT_EQ(1u, deletedResources.size()); | |
759 ASSERT_EQ("series", remainingAncestor->first); | |
760 ASSERT_EQ(OrthancPluginResourceType_Series, remainingAncestor->second); | |
761 break; | |
762 | |
763 default: | |
764 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError); | |
765 } | |
766 | |
767 db.DeleteResource(*output, *manager, resources[0]); | |
768 db.DeleteResource(*output, *manager, unrelated); | |
307
8de3a1ecac11
MySQL: Added missing calls to OrthancPluginDatabaseSignalDeletedResource()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
301
diff
changeset
|
769 } |
8de3a1ecac11
MySQL: Added missing calls to OrthancPluginDatabaseSignalDeletedResource()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
301
diff
changeset
|
770 } |
8de3a1ecac11
MySQL: Added missing calls to OrthancPluginDatabaseSignalDeletedResource()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
301
diff
changeset
|
771 |
226
a4918d57435c
DatabaseManager doesn't IDatabaseFactory anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
225
diff
changeset
|
772 manager->Close(); |
0 | 773 } |