text-document-io 1.10.2

Import/export for text-document: plain text, Markdown, HTML, LaTeX, DOCX
Documentation
// Generated by Qleany v1.4.8 from feature_use_case_uow.tera

use crate::use_cases::export_markdown_uc::{
    ExportMarkdownUnitOfWorkFactoryTrait, ExportMarkdownUnitOfWorkTrait,
};
use anyhow::{Ok, Result};
use common::database::QueryUnitOfWork;
use common::database::{db_context::DbContext, transactions::Transaction};
#[allow(unused_imports)]
use common::entities::{Block, Document, Frame, List, Root, Table, TableCell};
#[allow(unused_imports)]
use common::types;
#[allow(unused_imports)]
use common::types::EntityId;
use std::cell::RefCell;

// Unit of work for ExportMarkdown

pub struct ExportMarkdownUnitOfWork {
    context: DbContext,
    transaction: RefCell<Option<Transaction>>,
}

impl ExportMarkdownUnitOfWork {
    pub fn new(db_context: &DbContext) -> Self {
        ExportMarkdownUnitOfWork {
            context: db_context.clone(),
            transaction: RefCell::new(None),
        }
    }
}

impl QueryUnitOfWork for ExportMarkdownUnitOfWork {
    fn begin_transaction(&self) -> Result<()> {
        self.transaction
            .replace(Some(Transaction::begin_read_transaction(&self.context)?));
        Ok(())
    }

    fn end_transaction(&self) -> Result<()> {
        self.transaction.take().unwrap().end_read_transaction()?;
        Ok(())
    }

    fn store(&self) -> std::sync::Arc<common::database::Store> {
        self.context.get_store().clone()
    }
}

#[macros::uow_action(entity = "Root", action = "GetRO")]
#[macros::uow_action(entity = "Root", action = "GetRelationshipRO")]
#[macros::uow_action(entity = "Document", action = "GetRO")]
#[macros::uow_action(entity = "Document", action = "GetRelationshipRO")]
#[macros::uow_action(entity = "Frame", action = "GetRO")]
#[macros::uow_action(entity = "Frame", action = "GetMultiRO")]
#[macros::uow_action(entity = "Frame", action = "GetRelationshipRO")]
#[macros::uow_action(entity = "Block", action = "GetRO")]
#[macros::uow_action(entity = "Block", action = "GetMultiRO")]
#[macros::uow_action(entity = "Block", action = "GetRelationshipRO")]
#[macros::uow_action(entity = "List", action = "GetRO")]
#[macros::uow_action(entity = "Table", action = "GetRO")]
#[macros::uow_action(entity = "Table", action = "GetRelationshipRO")]
#[macros::uow_action(entity = "TableCell", action = "GetMultiRO")]
impl ExportMarkdownUnitOfWorkTrait for ExportMarkdownUnitOfWork {}

pub struct ExportMarkdownUnitOfWorkFactory {
    context: DbContext,
}

impl ExportMarkdownUnitOfWorkFactory {
    pub fn new(db_context: &DbContext) -> Self {
        ExportMarkdownUnitOfWorkFactory {
            context: db_context.clone(),
        }
    }
}

impl ExportMarkdownUnitOfWorkFactoryTrait for ExportMarkdownUnitOfWorkFactory {
    fn create(&self) -> Box<dyn ExportMarkdownUnitOfWorkTrait> {
        Box::new(ExportMarkdownUnitOfWork::new(&self.context))
    }
}