| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | // SPDX-FileCopyrightText: 2023 Carl Zeiss Microscopy GmbH | ||
| 2 | // | ||
| 3 | // SPDX-License-Identifier: MIT | ||
| 4 | |||
| 5 | #pragma once | ||
| 6 | |||
| 7 | #include <memory> | ||
| 8 | #include <utility> | ||
| 9 | #include <string> | ||
| 10 | #include <vector> | ||
| 11 | #include "IDocumentMetadata.h" | ||
| 12 | #include "documentMetadataBase.h" | ||
| 13 | #include "document.h" | ||
| 14 | |||
| 15 | class DocumentMetadataWriter : public DocumentMetadataBase, public imgdoc2::IDocumentMetadataWrite | ||
| 16 | { | ||
| 17 | public: | ||
| 18 | DocumentMetadataWriter() = delete; | ||
| 19 | 92 | explicit DocumentMetadataWriter(std::shared_ptr<Document> document) : DocumentMetadataBase(std::move(document)) {} | |
| 20 | 184 | ~DocumentMetadataWriter() override = default; | |
| 21 | |||
| 22 | imgdoc2::dbIndex UpdateOrCreateItem( | ||
| 23 | std::optional<imgdoc2::dbIndex> parent, | ||
| 24 | bool create_node_if_not_exists, | ||
| 25 | const std::string& name, | ||
| 26 | imgdoc2::DocumentMetadataType type, | ||
| 27 | const IDocumentMetadata::metadata_item_variant& value) override; | ||
| 28 | std::uint64_t DeleteItem( | ||
| 29 | std::optional<imgdoc2::dbIndex> primary_key, | ||
| 30 | bool recursively) override; | ||
| 31 | std::uint64_t DeleteItemForPath( | ||
| 32 | const std::string& path, | ||
| 33 | bool recursively) override; | ||
| 34 | imgdoc2::dbIndex UpdateOrCreateItemForPath( | ||
| 35 | bool create_path_if_not_exists, | ||
| 36 | bool create_node_if_not_exists, | ||
| 37 | const std::string& path, | ||
| 38 | imgdoc2::DocumentMetadataType type, | ||
| 39 | const IDocumentMetadata::metadata_item_variant& value) override; | ||
| 40 | private: | ||
| 41 | void CheckNodeNameAndThrowIfInvalid(const std::string& name); | ||
| 42 | std::shared_ptr<IDbStatement> CreateStatementForUpdateOrCreateItemAndBindData(bool create_node_if_not_exists, std::optional<imgdoc2::dbIndex> parent, const std::string& name, | ||
| 43 | DatabaseDataTypeValue database_data_type_value, | ||
| 44 | const IDocumentMetadata::metadata_item_variant& value); | ||
| 45 | std::shared_ptr<IDbStatement> CreateQueryForNameAndAncestorIdStatement(const std::string& name, std::optional<imgdoc2::dbIndex> parent); | ||
| 46 | |||
| 47 | void CreateMissingNodesOnPath(const std::vector<std::string_view>& path_parts, std::vector<imgdoc2::dbIndex>& pks_existing); | ||
| 48 | |||
| 49 | std::shared_ptr<IDbStatement> CreateStatementForDeleteItemAndBindData(bool recursively, std::optional<imgdoc2::dbIndex> parent); | ||
| 50 | }; | ||
| 51 |