Mercurial > hg > orthanc-databases
comparison Framework/Plugins/DatabaseBackendAdapterV2.cpp @ 569:f18e46d7dbf8 attach-custom-data
merged find-refactoring -> attach-custom-data
author | Alain Mazy <am@orthanc.team> |
---|---|
date | Tue, 24 Sep 2024 15:04:21 +0200 |
parents | cd9521e04249 1a23f1ce3b98 |
children |
comparison
equal
deleted
inserted
replaced
368:82f73188b58d | 569:f18e46d7dbf8 |
---|---|
1 /** | 1 /** |
2 * Orthanc - A Lightweight, RESTful DICOM Store | 2 * Orthanc - A Lightweight, RESTful DICOM Store |
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics | 3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics |
4 * Department, University Hospital of Liege, Belgium | 4 * Department, University Hospital of Liege, Belgium |
5 * Copyright (C) 2017-2021 Osimis S.A., Belgium | 5 * Copyright (C) 2017-2023 Osimis S.A., Belgium |
6 * Copyright (C) 2024-2024 Orthanc Team SRL, Belgium | |
7 * Copyright (C) 2021-2024 Sebastien Jodogne, ICTEAM UCLouvain, Belgium | |
6 * | 8 * |
7 * This program is free software: you can redistribute it and/or | 9 * This program is free software: you can redistribute it and/or |
8 * modify it under the terms of the GNU Affero General Public License | 10 * modify it under the terms of the GNU Affero General Public License |
9 * as published by the Free Software Foundation, either version 3 of | 11 * as published by the Free Software Foundation, either version 3 of |
10 * the License, or (at your option) any later version. | 12 * the License, or (at your option) any later version. |
87 { | 89 { |
88 boost::mutex::scoped_lock lock(managerMutex_); | 90 boost::mutex::scoped_lock lock(managerMutex_); |
89 | 91 |
90 if (manager_.get() == NULL) | 92 if (manager_.get() == NULL) |
91 { | 93 { |
92 manager_.reset(IndexBackend::CreateSingleDatabaseManager(*backend_)); | 94 std::list<IdentifierTag> identifierTags; |
95 manager_.reset(IndexBackend::CreateSingleDatabaseManager(*backend_, false, identifierTags)); | |
93 } | 96 } |
94 else | 97 else |
95 { | 98 { |
96 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); | 99 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); |
97 } | 100 } |
945 DatabaseBackendAdapterV2::Adapter* adapter = reinterpret_cast<DatabaseBackendAdapterV2::Adapter*>(payload); | 948 DatabaseBackendAdapterV2::Adapter* adapter = reinterpret_cast<DatabaseBackendAdapterV2::Adapter*>(payload); |
946 | 949 |
947 try | 950 try |
948 { | 951 { |
949 DatabaseBackendAdapterV2::Adapter::DatabaseAccessor accessor(*adapter); | 952 DatabaseBackendAdapterV2::Adapter::DatabaseAccessor accessor(*adapter); |
950 adapter->GetBackend().LogExportedResource(accessor.GetManager(), *exported); | 953 adapter->GetBackend().LogExportedResource(accessor.GetManager(), exported->resourceType, exported->publicId, |
954 exported->modality, exported->date, exported->patientId, | |
955 exported->studyInstanceUid, exported->seriesInstanceUid, exported->sopInstanceUid); | |
951 return OrthancPluginErrorCode_Success; | 956 return OrthancPluginErrorCode_Success; |
952 } | 957 } |
953 ORTHANC_PLUGINS_DATABASE_CATCH; | 958 ORTHANC_PLUGINS_DATABASE_CATCH; |
954 } | 959 } |
955 | 960 |
1408 | 1413 |
1409 try | 1414 try |
1410 { | 1415 { |
1411 DatabaseBackendAdapterV2::Adapter::DatabaseAccessor accessor(*adapter); | 1416 DatabaseBackendAdapterV2::Adapter::DatabaseAccessor accessor(*adapter); |
1412 | 1417 |
1413 std::vector<Orthanc::DatabaseConstraint> lookup; | 1418 DatabaseConstraints lookup; |
1414 lookup.reserve(constraintsCount); | |
1415 | 1419 |
1416 for (uint32_t i = 0; i < constraintsCount; i++) | 1420 for (uint32_t i = 0; i < constraintsCount; i++) |
1417 { | 1421 { |
1418 lookup.push_back(Orthanc::DatabaseConstraint(constraints[i])); | 1422 lookup.AddConstraint(new DatabaseConstraint(constraints[i])); |
1419 } | 1423 } |
1420 | 1424 |
1421 adapter->GetBackend().LookupResources(*output, accessor.GetManager(), lookup, queryLevel, limit, (requestSomeInstance != 0)); | 1425 std::set<std::string> noLabel; |
1426 adapter->GetBackend().LookupResources(*output, accessor.GetManager(), lookup, queryLevel, noLabel, | |
1427 LabelsConstraint_All, limit, (requestSomeInstance != 0)); | |
1428 | |
1422 return OrthancPluginErrorCode_Success; | 1429 return OrthancPluginErrorCode_Success; |
1423 } | 1430 } |
1424 ORTHANC_PLUGINS_DATABASE_CATCH; | 1431 ORTHANC_PLUGINS_DATABASE_CATCH; |
1425 } | 1432 } |
1426 #endif | 1433 #endif |
1631 | 1638 |
1632 static std::unique_ptr<DatabaseBackendAdapterV2::Adapter> adapter_; | 1639 static std::unique_ptr<DatabaseBackendAdapterV2::Adapter> adapter_; |
1633 | 1640 |
1634 void DatabaseBackendAdapterV2::Register(IDatabaseBackend* backend) | 1641 void DatabaseBackendAdapterV2::Register(IDatabaseBackend* backend) |
1635 { | 1642 { |
1636 if (backend == NULL) | 1643 { |
1637 { | 1644 std::unique_ptr<IDatabaseBackend> protection(backend); |
1638 throw Orthanc::OrthancException(Orthanc::ErrorCode_NullPointer); | 1645 |
1639 } | 1646 if (backend == NULL) |
1640 | 1647 { |
1641 if (adapter_.get() != NULL) | 1648 throw Orthanc::OrthancException(Orthanc::ErrorCode_NullPointer); |
1642 { | 1649 } |
1643 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); | 1650 |
1644 } | 1651 if (adapter_.get() != NULL) |
1645 | 1652 { |
1646 adapter_.reset(new Adapter(backend)); | 1653 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); |
1654 } | |
1655 | |
1656 adapter_.reset(new Adapter(protection.release())); | |
1657 } | |
1647 | 1658 |
1648 OrthancPluginDatabaseBackend params; | 1659 OrthancPluginDatabaseBackend params; |
1649 memset(¶ms, 0, sizeof(params)); | 1660 memset(¶ms, 0, sizeof(params)); |
1650 | 1661 |
1651 OrthancPluginDatabaseExtensions extensions; | 1662 OrthancPluginDatabaseExtensions extensions; |