File size: 2,363 Bytes
b4f2238
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
"""Module for documents generation."""

from __future__ import annotations

from typing import cast

from apps.core.protocols import (
    IContractFolderBindingService,
    IContractGenerationService,
    IContractService,
    IGenerationTaskService,
    ISupplementaryAgreementGenerationService,
)


def build_generation_task_service() -> IGenerationTaskService:
    from apps.documents.services.generation.generation_task_service import GenerationTaskService

    return cast(IGenerationTaskService, GenerationTaskService())


def build_contract_generation_service_with_deps(
    *,
    contract_service: IContractService,
    folder_binding_service: IContractFolderBindingService,
) -> IContractGenerationService:
    from apps.documents.services.generation.contract_generation_service import ContractGenerationService

    return cast(
        IContractGenerationService,
        ContractGenerationService(
            contract_service=contract_service,
            folder_binding_service=folder_binding_service,
        ),
    )


def build_contract_generation_service() -> IContractGenerationService:
    from apps.core.interfaces import ServiceLocator

    return build_contract_generation_service_with_deps(
        contract_service=ServiceLocator.get_contract_service(),
        folder_binding_service=ServiceLocator.get_contract_folder_binding_service(),
    )


def build_supplementary_agreement_generation_service_with_deps(
    *,
    contract_service: IContractService,
    folder_binding_service: IContractFolderBindingService,
) -> ISupplementaryAgreementGenerationService:
    from apps.documents.services.generation.supplementary_agreement_generation_service import (
        SupplementaryAgreementGenerationService,
    )

    return cast(
        ISupplementaryAgreementGenerationService,
        SupplementaryAgreementGenerationService(
            contract_service=contract_service,
            folder_binding_service=folder_binding_service,
        ),
    )


def build_supplementary_agreement_generation_service() -> ISupplementaryAgreementGenerationService:
    from apps.core.interfaces import ServiceLocator

    return build_supplementary_agreement_generation_service_with_deps(
        contract_service=ServiceLocator.get_contract_service(),
        folder_binding_service=ServiceLocator.get_contract_folder_binding_service(),
    )