16
16
"""Provide a superclass for all views."""
17
17
18
18
19
- from abc import ABC
20
19
from typing import Any , Dict , Iterable , List , Optional , Set
21
20
22
21
from pydantic import Field
23
22
24
- from ..abstract_base import AbstractBase
25
- from ..base_model import BaseModel
26
- from ..mixin import ViewSetRefMixin
23
+ from .abstract_view import AbstractView , AbstractViewIO
27
24
from ..model import Element , Model , Relationship , SoftwareSystem
28
25
from .automatic_layout import AutomaticLayout , AutomaticLayoutIO
29
26
from .element_view import ElementView , ElementViewIO
34
31
__all__ = ("View" , "ViewIO" )
35
32
36
33
37
- class ViewIO (BaseModel , ABC ):
34
+ class ViewIO (AbstractViewIO ):
38
35
"""
39
- Define an abstract base class for all views.
36
+ Define a base class for non-filtered views.
40
37
41
38
Views include static views, dynamic views and deployment views.
42
39
"""
43
40
44
- key : str
45
- description : str = ""
46
41
software_system_id : Optional [str ] = Field (default = None , alias = "softwareSystemId" )
47
42
paper_size : Optional [PaperSize ] = Field (default = None , alias = "paperSize" )
48
43
automatic_layout : Optional [AutomaticLayoutIO ] = Field (
49
44
default = None , alias = "automaticLayout"
50
45
)
51
- title : str = ""
52
46
53
47
element_views : List [ElementViewIO ] = Field (default = (), alias = "elements" )
54
48
relationship_views : List [RelationshipViewIO ] = Field (
@@ -61,9 +55,9 @@ class ViewIO(BaseModel, ABC):
61
55
# )
62
56
63
57
64
- class View (ViewSetRefMixin , AbstractBase , ABC ):
58
+ class View (AbstractView ):
65
59
"""
66
- Define an abstract base class for all views.
60
+ Define a base class for non-filtered views.
67
61
68
62
Views include static views, dynamic views and deployment views.
69
63
@@ -73,11 +67,8 @@ def __init__(
73
67
self ,
74
68
* ,
75
69
software_system : Optional [SoftwareSystem ] = None ,
76
- key : str = None ,
77
- description : str ,
78
70
paper_size : Optional [PaperSize ] = None ,
79
71
automatic_layout : Optional [AutomaticLayout ] = None ,
80
- title : str = "" ,
81
72
element_views : Optional [Iterable [ElementView ]] = (),
82
73
relationship_views : Optional [Iterable [RelationshipView ]] = (),
83
74
layout_merge_strategy : Optional [Any ] = None ,
@@ -87,33 +78,24 @@ def __init__(
87
78
super ().__init__ (** kwargs )
88
79
self .software_system = software_system
89
80
self .software_system_id = software_system .id if software_system else None
90
- self .key = key
91
- self .description = description
92
81
self .paper_size = paper_size
93
82
self .automatic_layout = automatic_layout
94
- self .title = title
95
83
self .element_views : Set [ElementView ] = set (element_views )
96
84
self ._relationship_views : Set [RelationshipView ] = set (relationship_views )
97
85
98
86
# TODO
99
87
self .layout_merge_strategy = layout_merge_strategy
100
88
101
- def __repr__ (self ) -> str :
102
- """Return repr(self)."""
103
- return f"{ type (self ).__name__ } (key={ self .key } )"
104
-
105
89
@classmethod
106
90
def hydrate_arguments (cls , view_io : ViewIO ) -> Dict :
107
91
"""Hydrate a ViewIO into the constructor arguments for View."""
108
92
return {
93
+ ** super ().hydrate_arguments (view_io ),
109
94
# TODO: should we add this here? probably not: "software_system"
110
- "key" : view_io .key ,
111
- "description" : view_io .description ,
112
95
"paper_size" : view_io .paper_size ,
113
96
"automatic_layout" : AutomaticLayout .hydrate (view_io .automatic_layout )
114
97
if view_io .automatic_layout
115
98
else None ,
116
- "title" : view_io .title ,
117
99
"element_views" : map (ElementView .hydrate , view_io .element_views ),
118
100
"relationship_views" : map (
119
101
RelationshipView .hydrate , view_io .relationship_views
0 commit comments