|
2 | 2 | general data models for migrations |
3 | 3 | """ |
4 | 4 |
|
5 | | -import enum |
6 | 5 | import uuid |
7 | 6 | from abc import ABC |
8 | | -from typing import TypeVar, Union |
9 | 7 |
|
10 | | -from bo4e.bo.geschaeftsobjekt import Geschaeftsobjekt |
11 | | -from bo4e.com.com import COM |
12 | 8 | from pydantic import BaseModel, Field # pylint: disable=no-name-in-module |
13 | 9 |
|
14 | | -_SpecificBusinessObject = TypeVar("_SpecificBusinessObject", bound=Geschaeftsobjekt) |
15 | | -""" |
16 | | -an arbitrary but fixed business object type |
17 | | -""" |
18 | | - |
19 | | -_SpecificCom = TypeVar("_SpecificCom", bound=COM) |
20 | | -""" |
21 | | -an arbitrary but fixed COM type |
22 | | -""" |
23 | | - |
24 | | -Bo4eTyp = Union[_SpecificBusinessObject, _SpecificCom] # pylint: disable=invalid-name |
25 | | - |
26 | | - |
27 | | -# pylint:disable=too-few-public-methods |
28 | | -class BusinessObjectRelation(BaseModel): |
29 | | - """ |
30 | | - A business object relation describes the relation between two business object. |
31 | | - E.g. a relation could have the type "has_melo" where relation_part_a is a bo4e.bo.Vertrag |
32 | | - and relation_part_b is a bo4e.bo.Messlokation. Some relations are already defined in BO4E itself (e.g MaLo/MeLo) |
33 | | - or MeLo/Address. |
34 | | - The idea is to not enforce too much of a structure to the downstream code but still push coders to think about |
35 | | - necessary relation information. |
36 | | - """ |
37 | | - |
38 | | - relation_type: enum.Enum |
39 | | - """ |
40 | | - The relation type describes how two business objects relate to each other. |
41 | | - This is not (only) about cardinality. It's about being able to model different relations between objects. |
42 | | - Think about e.g. a business partner and an address: The relation could be: |
43 | | - - the address is the residential address of the business partner |
44 | | - - the address is the invoice address of the business partner |
45 | | - - the address is the place where the business partner was born |
46 | | - All these relation types are 1:1 relations between business partners and adresses, yet they all carry different |
47 | | - meaning which we'd like to distinguish in our data. |
48 | | - """ |
49 | | - relation_part_a: Bo4eTyp |
50 | | - """ |
51 | | - one Business Object or COM |
52 | | - """ |
53 | | - |
54 | | - relation_part_b: Bo4eTyp |
55 | | - """ |
56 | | - another Business Object or COM |
57 | | - """ |
58 | | - |
59 | 10 |
|
60 | 11 | class Bo4eDataSet(BaseModel, ABC): |
61 | 12 | """ |
|
0 commit comments