Skip to main content

text_document_common/direct_access/use_cases/
get_relationship.rs

1// Generated by Qleany v1.4.8 from common_da_use_cases_get_relationship.tera
2
3use super::traits::ReadRelUoWFactory;
4use crate::types::EntityId;
5use anyhow::Result;
6
7pub struct GetRelationshipUseCase<RF, F: ReadRelUoWFactory<RF>> {
8    uow_factory: F,
9    _phantom: std::marker::PhantomData<RF>,
10}
11
12impl<RF, F: ReadRelUoWFactory<RF>> GetRelationshipUseCase<RF, F> {
13    pub fn new(uow_factory: F) -> Self {
14        GetRelationshipUseCase {
15            uow_factory,
16            _phantom: std::marker::PhantomData,
17        }
18    }
19
20    pub fn execute(&self, id: &EntityId, field: &RF) -> Result<Vec<EntityId>> {
21        let uow = self.uow_factory.create();
22        uow.begin_transaction()?;
23        let result = uow.get_relationship(id, field)?;
24        uow.end_transaction()?;
25        Ok(result)
26    }
27}