buildzr 0.0.10__tar.gz → 0.0.12__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {buildzr-0.0.10 → buildzr-0.0.12}/PKG-INFO +1 -1
- buildzr-0.0.12/buildzr/__about__.py +1 -0
- {buildzr-0.0.10 → buildzr-0.0.12}/buildzr/dsl/dsl.py +51 -114
- {buildzr-0.0.10 → buildzr-0.0.12}/buildzr/dsl/explorer.py +7 -2
- {buildzr-0.0.10 → buildzr-0.0.12}/buildzr/dsl/expression.py +1 -1
- {buildzr-0.0.10 → buildzr-0.0.12}/buildzr/dsl/interfaces/__init__.py +0 -1
- {buildzr-0.0.10 → buildzr-0.0.12}/buildzr/dsl/interfaces/interfaces.py +0 -27
- {buildzr-0.0.10 → buildzr-0.0.12}/tests/samples/component_view.py +1 -1
- {buildzr-0.0.10 → buildzr-0.0.12}/tests/samples/container_view.py +1 -1
- buildzr-0.0.12/tests/samples/groups.py +44 -0
- {buildzr-0.0.10 → buildzr-0.0.12}/tests/samples/implied_relationships.py +1 -1
- {buildzr-0.0.10 → buildzr-0.0.12}/tests/samples/nested_groups.py +0 -2
- {buildzr-0.0.10 → buildzr-0.0.12}/tests/samples/system_context_view.py +1 -1
- {buildzr-0.0.10 → buildzr-0.0.12}/tests/samples/system_landscape_view.py +1 -1
- {buildzr-0.0.10 → buildzr-0.0.12}/tests/test_views.py +86 -23
- buildzr-0.0.10/buildzr/__about__.py +0 -1
- buildzr-0.0.10/tests/samples/groups.py +0 -44
- {buildzr-0.0.10 → buildzr-0.0.12}/.gitignore +0 -0
- {buildzr-0.0.10 → buildzr-0.0.12}/CONTRIBUTING.md +0 -0
- {buildzr-0.0.10 → buildzr-0.0.12}/LICENSE.md +0 -0
- {buildzr-0.0.10 → buildzr-0.0.12}/README.md +0 -0
- {buildzr-0.0.10 → buildzr-0.0.12}/buildzr/__init__.py +0 -0
- {buildzr-0.0.10 → buildzr-0.0.12}/buildzr/dsl/__init__.py +0 -0
- {buildzr-0.0.10 → buildzr-0.0.12}/buildzr/dsl/color.py +0 -0
- {buildzr-0.0.10 → buildzr-0.0.12}/buildzr/dsl/factory/__init__.py +0 -0
- {buildzr-0.0.10 → buildzr-0.0.12}/buildzr/dsl/factory/gen_id.py +0 -0
- {buildzr-0.0.10 → buildzr-0.0.12}/buildzr/dsl/relations.py +0 -0
- {buildzr-0.0.10 → buildzr-0.0.12}/buildzr/encoders/__init__.py +0 -0
- {buildzr-0.0.10 → buildzr-0.0.12}/buildzr/encoders/encoder.py +0 -0
- {buildzr-0.0.10 → buildzr-0.0.12}/buildzr/models/__init__.py +0 -0
- {buildzr-0.0.10 → buildzr-0.0.12}/buildzr/models/generate.sh +0 -0
- {buildzr-0.0.10 → buildzr-0.0.12}/buildzr/models/models.py +0 -0
- {buildzr-0.0.10 → buildzr-0.0.12}/buildzr/sinks/__init__.py +0 -0
- {buildzr-0.0.10 → buildzr-0.0.12}/buildzr/sinks/interfaces.py +0 -0
- {buildzr-0.0.10 → buildzr-0.0.12}/buildzr/sinks/json_sink.py +0 -0
- {buildzr-0.0.10 → buildzr-0.0.12}/pyproject.toml +0 -0
- {buildzr-0.0.10 → buildzr-0.0.12}/tests/__init__.py +0 -0
- {buildzr-0.0.10 → buildzr-0.0.12}/tests/abstract_builder.py +0 -0
- {buildzr-0.0.10 → buildzr-0.0.12}/tests/samples/__init__.py +0 -0
- {buildzr-0.0.10 → buildzr-0.0.12}/tests/samples/container_view_sugar.py +0 -0
- {buildzr-0.0.10 → buildzr-0.0.12}/tests/samples/simple.py +0 -0
- {buildzr-0.0.10 → buildzr-0.0.12}/tests/samples/simple_dsl.py +0 -0
- {buildzr-0.0.10 → buildzr-0.0.12}/tests/test_dsl.py +0 -0
- {buildzr-0.0.10 → buildzr-0.0.12}/tests/test_explorer.py +0 -0
- {buildzr-0.0.10 → buildzr-0.0.12}/tests/test_expression.py +0 -0
- {buildzr-0.0.10 → buildzr-0.0.12}/tests/test_typehints.py +0 -0
- {buildzr-0.0.10 → buildzr-0.0.12}/tests/test_workspaces.py +0 -0
@@ -0,0 +1 @@
|
|
1
|
+
VERSION = "0.0.12"
|
@@ -29,7 +29,6 @@ from buildzr.dsl.interfaces import (
|
|
29
29
|
DslWorkspaceElement,
|
30
30
|
DslElement,
|
31
31
|
DslViewElement,
|
32
|
-
DslViewsElement,
|
33
32
|
)
|
34
33
|
from buildzr.dsl.relations import (
|
35
34
|
DslElementRelationOverrides,
|
@@ -181,13 +180,43 @@ class Workspace(DslWorkspaceElement):
|
|
181
180
|
else:
|
182
181
|
raise ValueError('Invalid element type: Trying to add an element of type {} to a workspace.'.format(type(model)))
|
183
182
|
|
184
|
-
def
|
183
|
+
def apply_view(
|
184
|
+
self,
|
185
|
+
view: Union[
|
186
|
+
'SystemLandscapeView',
|
185
187
|
'SystemContextView',
|
186
188
|
'ContainerView',
|
187
189
|
'ComponentView',
|
188
190
|
]
|
189
191
|
) -> None:
|
190
|
-
|
192
|
+
|
193
|
+
view._on_added(self)
|
194
|
+
|
195
|
+
if not self.model.views:
|
196
|
+
self.model.views = buildzr.models.Views()
|
197
|
+
|
198
|
+
if isinstance(view, SystemLandscapeView):
|
199
|
+
if not self.model.views.systemLandscapeViews:
|
200
|
+
self.model.views.systemLandscapeViews = [view.model]
|
201
|
+
else:
|
202
|
+
self.model.views.systemLandscapeViews.append(view.model)
|
203
|
+
elif isinstance(view, SystemContextView):
|
204
|
+
if not self.model.views.systemContextViews:
|
205
|
+
self.model.views.systemContextViews = [view.model]
|
206
|
+
else:
|
207
|
+
self.model.views.systemContextViews.append(view.model)
|
208
|
+
elif isinstance(view, ContainerView):
|
209
|
+
if not self.model.views.containerViews:
|
210
|
+
self.model.views.containerViews = [view.model]
|
211
|
+
else:
|
212
|
+
self.model.views.containerViews.append(view.model)
|
213
|
+
elif isinstance(view, ComponentView):
|
214
|
+
if not self.model.views.componentViews:
|
215
|
+
self.model.views.componentViews = [view.model]
|
216
|
+
else:
|
217
|
+
self.model.views.componentViews.append(view.model)
|
218
|
+
else:
|
219
|
+
raise NotImplementedError("The view {0} is currently not supported", type(view))
|
191
220
|
|
192
221
|
def apply_style( self,
|
193
222
|
style: Union['StyleElements', 'StyleRelationships'],
|
@@ -273,7 +302,7 @@ class SoftwareSystem(DslElementRelationOverrides[
|
|
273
302
|
return self._destinations
|
274
303
|
|
275
304
|
@property
|
276
|
-
def relationships(self) -> Set[
|
305
|
+
def relationships(self) -> Set[DslRelationship]:
|
277
306
|
return self._relationships
|
278
307
|
|
279
308
|
@property
|
@@ -287,7 +316,7 @@ class SoftwareSystem(DslElementRelationOverrides[
|
|
287
316
|
self._children: Optional[List['Container']] = []
|
288
317
|
self._sources: List[DslElement] = []
|
289
318
|
self._destinations: List[DslElement] = []
|
290
|
-
self._relationships: Set[
|
319
|
+
self._relationships: Set[DslRelationship] = set()
|
291
320
|
self._tags = {'Element', 'Software System'}.union(tags)
|
292
321
|
self._dynamic_attrs: Dict[str, 'Container'] = {}
|
293
322
|
self._label: Optional[str] = None
|
@@ -387,7 +416,7 @@ class Person(DslElementRelationOverrides[
|
|
387
416
|
return self._destinations
|
388
417
|
|
389
418
|
@property
|
390
|
-
def relationships(self) -> Set[
|
419
|
+
def relationships(self) -> Set[DslRelationship]:
|
391
420
|
return self._relationships
|
392
421
|
|
393
422
|
@property
|
@@ -399,7 +428,7 @@ class Person(DslElementRelationOverrides[
|
|
399
428
|
self._parent: Optional[Workspace] = None
|
400
429
|
self._sources: List[DslElement] = []
|
401
430
|
self._destinations: List[DslElement] = []
|
402
|
-
self._relationships: Set[
|
431
|
+
self._relationships: Set[DslRelationship] = set()
|
403
432
|
self._tags = {'Element', 'Person'}.union(tags)
|
404
433
|
self._label: Optional[str] = None
|
405
434
|
self.model.id = GenerateId.for_element()
|
@@ -458,7 +487,7 @@ class Container(DslElementRelationOverrides[
|
|
458
487
|
return self._destinations
|
459
488
|
|
460
489
|
@property
|
461
|
-
def relationships(self) -> Set[
|
490
|
+
def relationships(self) -> Set[DslRelationship]:
|
462
491
|
return self._relationships
|
463
492
|
|
464
493
|
@property
|
@@ -472,7 +501,7 @@ class Container(DslElementRelationOverrides[
|
|
472
501
|
self._children: Optional[List['Component']] = []
|
473
502
|
self._sources: List[DslElement] = []
|
474
503
|
self._destinations: List[DslElement] = []
|
475
|
-
self._relationships: Set[
|
504
|
+
self._relationships: Set[DslRelationship] = set()
|
476
505
|
self._tags = {'Element', 'Container'}.union(tags)
|
477
506
|
self._dynamic_attrs: Dict[str, 'Component'] = {}
|
478
507
|
self._label: Optional[str] = None
|
@@ -570,7 +599,7 @@ class Component(DslElementRelationOverrides[
|
|
570
599
|
return self._destinations
|
571
600
|
|
572
601
|
@property
|
573
|
-
def relationships(self) -> Set[
|
602
|
+
def relationships(self) -> Set[DslRelationship]:
|
574
603
|
return self._relationships
|
575
604
|
|
576
605
|
@property
|
@@ -582,7 +611,7 @@ class Component(DslElementRelationOverrides[
|
|
582
611
|
self._parent: Optional[Container] = None
|
583
612
|
self._sources: List[DslElement] = []
|
584
613
|
self._destinations: List[DslElement] = []
|
585
|
-
self._relationships: Set[
|
614
|
+
self._relationships: Set[DslRelationship] = set()
|
586
615
|
self._tags = {'Element', 'Component'}.union(tags)
|
587
616
|
self._label: Optional[str] = None
|
588
617
|
self.model.id = GenerateId.for_element()
|
@@ -744,10 +773,6 @@ class SystemLandscapeView(DslViewElement):
|
|
744
773
|
def model(self) -> buildzr.models.SystemLandscapeView:
|
745
774
|
return self._m
|
746
775
|
|
747
|
-
@property
|
748
|
-
def parent(self) -> Optional['Views']:
|
749
|
-
return self._parent
|
750
|
-
|
751
776
|
def __init__(
|
752
777
|
self,
|
753
778
|
key: str,
|
@@ -761,7 +786,6 @@ class SystemLandscapeView(DslViewElement):
|
|
761
786
|
properties: Optional[Dict[str, str]]=None,
|
762
787
|
) -> None:
|
763
788
|
self._m = buildzr.models.SystemLandscapeView()
|
764
|
-
self._parent: Optional['Views'] = None
|
765
789
|
|
766
790
|
self._m.key = key
|
767
791
|
self._m.description = description
|
@@ -777,9 +801,9 @@ class SystemLandscapeView(DslViewElement):
|
|
777
801
|
|
778
802
|
workspace = _current_workspace.get()
|
779
803
|
if workspace is not None:
|
780
|
-
workspace.
|
804
|
+
workspace.apply_view(self)
|
781
805
|
|
782
|
-
def _on_added(self) -> None:
|
806
|
+
def _on_added(self, workspace: Workspace) -> None:
|
783
807
|
|
784
808
|
from buildzr.dsl.expression import Expression, Element, Relationship
|
785
809
|
from buildzr.models import ElementView, RelationshipView
|
@@ -791,8 +815,6 @@ class SystemLandscapeView(DslViewElement):
|
|
791
815
|
exclude_relationships=self._exclude_relationships,
|
792
816
|
)
|
793
817
|
|
794
|
-
workspace = self._parent._parent
|
795
|
-
|
796
818
|
include_view_elements_filter: List[Union[DslElement, Callable[[Workspace, Element], bool]]] = [
|
797
819
|
lambda w, e: e.type == Person,
|
798
820
|
lambda w, e: e.type == SoftwareSystem
|
@@ -848,10 +870,6 @@ class SystemContextView(DslViewElement):
|
|
848
870
|
def model(self) -> buildzr.models.SystemContextView:
|
849
871
|
return self._m
|
850
872
|
|
851
|
-
@property
|
852
|
-
def parent(self) -> Optional['Views']:
|
853
|
-
return self._parent
|
854
|
-
|
855
873
|
def __init__(
|
856
874
|
self,
|
857
875
|
software_system_selector: Union[SoftwareSystem, Callable[[Workspace], SoftwareSystem]],
|
@@ -866,7 +884,6 @@ class SystemContextView(DslViewElement):
|
|
866
884
|
properties: Optional[Dict[str, str]]=None,
|
867
885
|
) -> None:
|
868
886
|
self._m = buildzr.models.SystemContextView()
|
869
|
-
self._parent: Optional['Views'] = None
|
870
887
|
|
871
888
|
self._m.key = key
|
872
889
|
self._m.description = description
|
@@ -883,9 +900,9 @@ class SystemContextView(DslViewElement):
|
|
883
900
|
|
884
901
|
workspace = _current_workspace.get()
|
885
902
|
if workspace is not None:
|
886
|
-
workspace.
|
903
|
+
workspace.apply_view(self)
|
887
904
|
|
888
|
-
def _on_added(self) -> None:
|
905
|
+
def _on_added(self, workspace: Workspace) -> None:
|
889
906
|
|
890
907
|
from buildzr.dsl.expression import Expression, Element, Relationship
|
891
908
|
from buildzr.models import ElementView, RelationshipView
|
@@ -893,7 +910,7 @@ class SystemContextView(DslViewElement):
|
|
893
910
|
if isinstance(self._selector, SoftwareSystem):
|
894
911
|
software_system = self._selector
|
895
912
|
else:
|
896
|
-
software_system = self._selector(
|
913
|
+
software_system = self._selector(workspace)
|
897
914
|
self._m.softwareSystemId = software_system.model.id
|
898
915
|
view_elements_filter: List[Union[DslElement, Callable[[Workspace, Element], bool]]] = [
|
899
916
|
lambda w, e: e == software_system,
|
@@ -913,8 +930,6 @@ class SystemContextView(DslViewElement):
|
|
913
930
|
exclude_relationships=self._exclude_relationships,
|
914
931
|
)
|
915
932
|
|
916
|
-
workspace = self._parent._parent
|
917
|
-
|
918
933
|
element_ids = map(
|
919
934
|
lambda x: str(x.model.id),
|
920
935
|
expression.elements(workspace)
|
@@ -941,10 +956,6 @@ class ContainerView(DslViewElement):
|
|
941
956
|
def model(self) -> buildzr.models.ContainerView:
|
942
957
|
return self._m
|
943
958
|
|
944
|
-
@property
|
945
|
-
def parent(self) -> Optional['Views']:
|
946
|
-
return self._parent
|
947
|
-
|
948
959
|
def __init__(
|
949
960
|
self,
|
950
961
|
software_system_selector: Union[SoftwareSystem, Callable[[Workspace], SoftwareSystem]],
|
@@ -959,7 +970,6 @@ class ContainerView(DslViewElement):
|
|
959
970
|
properties: Optional[Dict[str, str]]=None,
|
960
971
|
) -> None:
|
961
972
|
self._m = buildzr.models.ContainerView()
|
962
|
-
self._parent: Optional['Views'] = None
|
963
973
|
|
964
974
|
self._m.key = key
|
965
975
|
self._m.description = description
|
@@ -976,9 +986,9 @@ class ContainerView(DslViewElement):
|
|
976
986
|
|
977
987
|
workspace = _current_workspace.get()
|
978
988
|
if workspace is not None:
|
979
|
-
workspace.
|
989
|
+
workspace.apply_view(self)
|
980
990
|
|
981
|
-
def _on_added(self) -> None:
|
991
|
+
def _on_added(self, workspace: Workspace) -> None:
|
982
992
|
|
983
993
|
from buildzr.dsl.expression import Expression, Element, Relationship
|
984
994
|
from buildzr.models import ElementView, RelationshipView
|
@@ -986,7 +996,7 @@ class ContainerView(DslViewElement):
|
|
986
996
|
if isinstance(self._selector, SoftwareSystem):
|
987
997
|
software_system = self._selector
|
988
998
|
else:
|
989
|
-
software_system = self._selector(
|
999
|
+
software_system = self._selector(workspace)
|
990
1000
|
self._m.softwareSystemId = software_system.model.id
|
991
1001
|
|
992
1002
|
container_ids = { container.model.id for container in software_system.children}
|
@@ -1009,8 +1019,6 @@ class ContainerView(DslViewElement):
|
|
1009
1019
|
exclude_relationships=self._exclude_relationships,
|
1010
1020
|
)
|
1011
1021
|
|
1012
|
-
workspace = self._parent._parent
|
1013
|
-
|
1014
1022
|
element_ids = map(
|
1015
1023
|
lambda x: str(x.model.id),
|
1016
1024
|
expression.elements(workspace)
|
@@ -1037,10 +1045,6 @@ class ComponentView(DslViewElement):
|
|
1037
1045
|
def model(self) -> buildzr.models.ComponentView:
|
1038
1046
|
return self._m
|
1039
1047
|
|
1040
|
-
@property
|
1041
|
-
def parent(self) -> Optional['Views']:
|
1042
|
-
return self._parent
|
1043
|
-
|
1044
1048
|
def __init__(
|
1045
1049
|
self,
|
1046
1050
|
container_selector: Union[Container, Callable[[Workspace], Container]],
|
@@ -1055,7 +1059,6 @@ class ComponentView(DslViewElement):
|
|
1055
1059
|
properties: Optional[Dict[str, str]]=None,
|
1056
1060
|
) -> None:
|
1057
1061
|
self._m = buildzr.models.ComponentView()
|
1058
|
-
self._parent: Optional['Views'] = None
|
1059
1062
|
|
1060
1063
|
self._m.key = key
|
1061
1064
|
self._m.description = description
|
@@ -1072,9 +1075,9 @@ class ComponentView(DslViewElement):
|
|
1072
1075
|
|
1073
1076
|
workspace = _current_workspace.get()
|
1074
1077
|
if workspace is not None:
|
1075
|
-
workspace.
|
1078
|
+
workspace.apply_view(self)
|
1076
1079
|
|
1077
|
-
def _on_added(self) -> None:
|
1080
|
+
def _on_added(self, workspace: Workspace) -> None:
|
1078
1081
|
|
1079
1082
|
from buildzr.dsl.expression import Expression, Element, Relationship
|
1080
1083
|
from buildzr.models import ElementView, RelationshipView
|
@@ -1082,7 +1085,7 @@ class ComponentView(DslViewElement):
|
|
1082
1085
|
if isinstance(self._selector, Container):
|
1083
1086
|
container = self._selector
|
1084
1087
|
else:
|
1085
|
-
container = self._selector(
|
1088
|
+
container = self._selector(workspace)
|
1086
1089
|
self._m.containerId = container.model.id
|
1087
1090
|
|
1088
1091
|
component_ids = { component.model.id for component in container.children }
|
@@ -1105,8 +1108,6 @@ class ComponentView(DslViewElement):
|
|
1105
1108
|
exclude_relationships=self._exclude_relationships,
|
1106
1109
|
)
|
1107
1110
|
|
1108
|
-
workspace = self._parent._parent
|
1109
|
-
|
1110
1111
|
element_ids = map(
|
1111
1112
|
lambda x: str(x.model.id),
|
1112
1113
|
expression.elements(workspace)
|
@@ -1125,70 +1126,6 @@ class ComponentView(DslViewElement):
|
|
1125
1126
|
for relationship_id in relationship_ids:
|
1126
1127
|
self._m.relationships.append(RelationshipView(id=relationship_id))
|
1127
1128
|
|
1128
|
-
class Views(DslViewsElement):
|
1129
|
-
|
1130
|
-
# TODO: Make this view a "hidden" class -- it's not a "first class citizen"
|
1131
|
-
# in buildzr DSL.
|
1132
|
-
|
1133
|
-
@property
|
1134
|
-
def model(self) -> buildzr.models.Views:
|
1135
|
-
return self._m
|
1136
|
-
|
1137
|
-
@property
|
1138
|
-
def parent(self) -> Optional[Workspace]:
|
1139
|
-
return self._parent
|
1140
|
-
|
1141
|
-
def __init__(
|
1142
|
-
self,
|
1143
|
-
workspace: Workspace,
|
1144
|
-
) -> None:
|
1145
|
-
self._m = buildzr.models.Views()
|
1146
|
-
self._parent = workspace
|
1147
|
-
self._parent._m.views = self._m
|
1148
|
-
|
1149
|
-
def add_views(
|
1150
|
-
self,
|
1151
|
-
*views: DslViewElement
|
1152
|
-
) -> None:
|
1153
|
-
|
1154
|
-
for view in views:
|
1155
|
-
if isinstance(view, SystemLandscapeView):
|
1156
|
-
view._parent = self
|
1157
|
-
view._on_added()
|
1158
|
-
if self._m.systemLandscapeViews:
|
1159
|
-
self._m.systemLandscapeViews.append(view.model)
|
1160
|
-
else:
|
1161
|
-
self._m.systemLandscapeViews = [view.model]
|
1162
|
-
elif isinstance(view, SystemContextView):
|
1163
|
-
view._parent = self
|
1164
|
-
view._on_added()
|
1165
|
-
if self._m.systemContextViews:
|
1166
|
-
self._m.systemContextViews.append(view.model)
|
1167
|
-
else:
|
1168
|
-
self._m.systemContextViews = [view.model]
|
1169
|
-
elif isinstance(view, ContainerView):
|
1170
|
-
view._parent = self
|
1171
|
-
view._on_added()
|
1172
|
-
if self._m.containerViews:
|
1173
|
-
self._m.containerViews.append(view.model)
|
1174
|
-
else:
|
1175
|
-
self._m.containerViews = [view.model]
|
1176
|
-
elif isinstance(view, ComponentView):
|
1177
|
-
view._parent = self
|
1178
|
-
view._on_added()
|
1179
|
-
if self._m.componentViews:
|
1180
|
-
self._m.componentViews.append(view.model)
|
1181
|
-
else:
|
1182
|
-
self._m.componentViews = [view.model]
|
1183
|
-
else:
|
1184
|
-
raise NotImplementedError("The view {0} is currently not supported", type(view))
|
1185
|
-
|
1186
|
-
def get_workspace(self) -> Workspace:
|
1187
|
-
"""
|
1188
|
-
Get the `Workspace` which contain this views definition.
|
1189
|
-
"""
|
1190
|
-
return self._parent
|
1191
|
-
|
1192
1129
|
class StyleElements:
|
1193
1130
|
|
1194
1131
|
from buildzr.dsl.expression import Element
|
@@ -14,12 +14,17 @@ from typing import (
|
|
14
14
|
Union,
|
15
15
|
Generator,
|
16
16
|
Iterable,
|
17
|
+
cast,
|
17
18
|
)
|
18
19
|
|
19
20
|
from buildzr.dsl.dsl import (
|
20
21
|
Workspace,
|
21
22
|
)
|
22
23
|
|
24
|
+
from buildzr.dsl.interfaces import (
|
25
|
+
DslRelationship,
|
26
|
+
)
|
27
|
+
|
23
28
|
class Explorer:
|
24
29
|
|
25
30
|
def __init__(self, workspace_or_element: Union[Workspace, Person, SoftwareSystem, Container, Component]):
|
@@ -32,7 +37,7 @@ class Explorer:
|
|
32
37
|
yield child
|
33
38
|
yield from explorer
|
34
39
|
|
35
|
-
def walk_relationships(self) -> Generator[
|
40
|
+
def walk_relationships(self) -> Generator[DslRelationship, None, None]:
|
36
41
|
|
37
42
|
if self._workspace_or_element.children:
|
38
43
|
|
@@ -40,7 +45,7 @@ class Explorer:
|
|
40
45
|
|
41
46
|
if child.relationships:
|
42
47
|
for relationship in child.relationships:
|
43
|
-
yield relationship
|
48
|
+
yield cast(_Relationship, relationship) # TODO: Temporary fix. Use a better approach - Generics?
|
44
49
|
|
45
50
|
explorer = Explorer(child).walk_relationships()
|
46
51
|
yield from explorer
|
@@ -104,7 +104,7 @@ class Element:
|
|
104
104
|
|
105
105
|
class Relationship:
|
106
106
|
|
107
|
-
def __init__(self, relationship:
|
107
|
+
def __init__(self, relationship: DslRelationship):
|
108
108
|
self._relationship = relationship
|
109
109
|
|
110
110
|
# TODO: Make a test for this in `tests/test_expression.py`
|
@@ -205,31 +205,4 @@ class DslViewElement(ABC):
|
|
205
205
|
@property
|
206
206
|
@abstractmethod
|
207
207
|
def model(self) -> ViewModel:
|
208
|
-
pass
|
209
|
-
|
210
|
-
@property
|
211
|
-
@abstractmethod
|
212
|
-
def parent(self) -> 'DslViewsElement':
|
213
|
-
pass
|
214
|
-
|
215
|
-
def _on_added(self) -> None:
|
216
|
-
pass
|
217
|
-
|
218
|
-
class DslViewsElement(ABC):
|
219
|
-
|
220
|
-
@property
|
221
|
-
@abstractmethod
|
222
|
-
def model(self) -> buildzr.models.Views:
|
223
|
-
pass
|
224
|
-
|
225
|
-
@property
|
226
|
-
@abstractmethod
|
227
|
-
def parent(self) -> DslWorkspaceElement:
|
228
|
-
pass
|
229
|
-
|
230
|
-
@abstractmethod
|
231
|
-
def add_views(
|
232
|
-
self,
|
233
|
-
*views: Union[DslViewElement],
|
234
|
-
) -> None:
|
235
208
|
pass
|
@@ -20,7 +20,7 @@ class SampleComponentView(AbstractBuilder):
|
|
20
20
|
db = Container("Database")
|
21
21
|
web_app.component_2 >> "Reads from and writes to" >> db
|
22
22
|
user >> "Uses" >> c1
|
23
|
-
w.
|
23
|
+
w.apply_view(
|
24
24
|
ComponentView(
|
25
25
|
container_selector=lambda w: w.software_system().software_system.web_application,
|
26
26
|
key="web_application_container_00",
|
@@ -19,7 +19,7 @@ class SampleContainerView(AbstractBuilder):
|
|
19
19
|
user >> "Uses" >> web_application
|
20
20
|
user >> "Hacks" >> git_repo
|
21
21
|
git_repo >> "Uses" >> external_system
|
22
|
-
w.
|
22
|
+
w.apply_view(
|
23
23
|
ContainerView(
|
24
24
|
software_system_selector=lambda w: w.software_system().app,
|
25
25
|
key="ss_business_app",
|
@@ -0,0 +1,44 @@
|
|
1
|
+
import buildzr
|
2
|
+
from buildzr.dsl import *
|
3
|
+
from typing import cast
|
4
|
+
from ..abstract_builder import AbstractBuilder
|
5
|
+
|
6
|
+
class GroupsSample(AbstractBuilder):
|
7
|
+
|
8
|
+
def build(self) -> buildzr.models.Workspace:
|
9
|
+
with Workspace("w", scope=None) as w:
|
10
|
+
with Group("Company 1"):
|
11
|
+
with SoftwareSystem("A") as a:
|
12
|
+
Container("a1")
|
13
|
+
Container("a2")
|
14
|
+
with Group("Company 2"):
|
15
|
+
with SoftwareSystem("B") as b:
|
16
|
+
Container("b1")
|
17
|
+
with Container("b2") as b2:
|
18
|
+
Component("c1")
|
19
|
+
c = SoftwareSystem("C")
|
20
|
+
a >> "Uses" >> b
|
21
|
+
a.a1 >> "Uses" >> b.b1
|
22
|
+
a >> "Uses" >> c
|
23
|
+
|
24
|
+
SystemLandscapeView(
|
25
|
+
key='groups-sample',
|
26
|
+
description="Groups Sample"
|
27
|
+
)
|
28
|
+
SystemContextView(
|
29
|
+
key='groups-sample-a',
|
30
|
+
software_system_selector=lambda w: cast(SoftwareSystem, w.a),
|
31
|
+
description="Groups Sample - Software System A"
|
32
|
+
)
|
33
|
+
SystemContextView(
|
34
|
+
key='groups-sample-b',
|
35
|
+
software_system_selector=lambda w: cast(SoftwareSystem, w.b),
|
36
|
+
description="Groups Sample - Software System B"
|
37
|
+
)
|
38
|
+
ContainerView(
|
39
|
+
key='groups-sample-b2',
|
40
|
+
software_system_selector=lambda w: w.software_system().b,
|
41
|
+
description="Groups Sample - Container B2"
|
42
|
+
)
|
43
|
+
|
44
|
+
return w.model
|
@@ -21,7 +21,7 @@ class SampleImpliedRelationships(AbstractBuilder):
|
|
21
21
|
database = Container("database")
|
22
22
|
ui_layer >> "Uses" >> database
|
23
23
|
u >> "Runs SQL queries" >> database
|
24
|
-
w.
|
24
|
+
w.apply_view(
|
25
25
|
SystemContextView(
|
26
26
|
key='sample-implied-relationships',
|
27
27
|
software_system_selector=lambda w: cast(SoftwareSystem, w.s),
|
@@ -19,7 +19,7 @@ class SystemContextViewSample(AbstractBuilder):
|
|
19
19
|
email_system = SoftwareSystem('email_system')
|
20
20
|
user >> "uses" >> web_app
|
21
21
|
web_app >> "sends notification using" >> email_system
|
22
|
-
w.
|
22
|
+
w.apply_view(
|
23
23
|
SystemContextView(
|
24
24
|
lambda w: w.software_system().web_app,
|
25
25
|
key='web_app_system_context_00',
|
@@ -32,7 +32,7 @@ class SystemLandscapeViewSample(AbstractBuilder):
|
|
32
32
|
internet_banking_system >> "Gets account information from, and makes payments using" >> mainframe_banking_system
|
33
33
|
internet_banking_system >> "Sends e-mail using" >> email_system
|
34
34
|
|
35
|
-
w.
|
35
|
+
w.apply_view(
|
36
36
|
SystemLandscapeView(
|
37
37
|
key='landscape_00',
|
38
38
|
description="System Landscape",
|
@@ -34,7 +34,7 @@ def test_system_landscape_view(use_context: bool) -> Optional[None]:
|
|
34
34
|
)
|
35
35
|
|
36
36
|
if not use_context:
|
37
|
-
w.
|
37
|
+
w.apply_view(
|
38
38
|
SystemLandscapeView(
|
39
39
|
key="system_landscape_view_00",
|
40
40
|
description="System Landscape View Test",
|
@@ -48,8 +48,8 @@ def test_system_landscape_view(use_context: bool) -> Optional[None]:
|
|
48
48
|
system_a = w.software_system().system_a
|
49
49
|
system_b = w.software_system().system_b
|
50
50
|
|
51
|
-
element_ids =
|
52
|
-
relationship_ids =
|
51
|
+
element_ids = [x.id for x in w.model.views.systemLandscapeViews[0].elements]
|
52
|
+
relationship_ids = [x.id for x in w.model.views.systemLandscapeViews[0].relationships]
|
53
53
|
|
54
54
|
assert len(element_ids) == 3
|
55
55
|
assert {
|
@@ -91,7 +91,7 @@ def test_system_context_view(use_context: bool) -> Optional[None]:
|
|
91
91
|
)
|
92
92
|
|
93
93
|
if not use_context:
|
94
|
-
w.
|
94
|
+
w.apply_view(
|
95
95
|
SystemContextView(
|
96
96
|
software_system_selector=lambda w: w.software_system().business_app,
|
97
97
|
key="ss_business_app",
|
@@ -99,8 +99,8 @@ def test_system_context_view(use_context: bool) -> Optional[None]:
|
|
99
99
|
)
|
100
100
|
)
|
101
101
|
|
102
|
-
element_ids =
|
103
|
-
relationship_ids =
|
102
|
+
element_ids = [x.id for x in w.model.views.systemContextViews[0].elements]
|
103
|
+
relationship_ids = [x.id for x in w.model.views.systemContextViews[0].relationships]
|
104
104
|
|
105
105
|
print('element ids:', element_ids)
|
106
106
|
print('person id:', w.person().u.model.id)
|
@@ -157,7 +157,7 @@ def test_system_context_view_with_exclude_user(use_context: bool) -> Optional[No
|
|
157
157
|
)
|
158
158
|
|
159
159
|
if not use_context:
|
160
|
-
w.
|
160
|
+
w.apply_view(
|
161
161
|
SystemContextView(
|
162
162
|
software_system_selector=lambda w: w.software_system().business_app,
|
163
163
|
key="ss_business_app",
|
@@ -168,8 +168,8 @@ def test_system_context_view_with_exclude_user(use_context: bool) -> Optional[No
|
|
168
168
|
)
|
169
169
|
)
|
170
170
|
|
171
|
-
element_ids =
|
172
|
-
relationship_ids =
|
171
|
+
element_ids = [x.id for x in w.model.views.systemContextViews[0].elements]
|
172
|
+
relationship_ids = [x.id for x in w.model.views.systemContextViews[0].relationships]
|
173
173
|
|
174
174
|
print('element ids:', element_ids)
|
175
175
|
print('person id:', w.person().u.model.id)
|
@@ -221,7 +221,7 @@ def test_container_view(use_context: bool) -> Optional[None]:
|
|
221
221
|
)
|
222
222
|
|
223
223
|
if not use_context:
|
224
|
-
w.
|
224
|
+
w.apply_view(
|
225
225
|
ContainerView(
|
226
226
|
software_system_selector=lambda w: w.software_system().app,
|
227
227
|
key="ss_business_app",
|
@@ -229,8 +229,8 @@ def test_container_view(use_context: bool) -> Optional[None]:
|
|
229
229
|
)
|
230
230
|
)
|
231
231
|
|
232
|
-
element_ids =
|
233
|
-
relationship_ids =
|
232
|
+
element_ids = [x.id for x in w.model.views.containerViews[0].elements]
|
233
|
+
relationship_ids = [x.id for x in w.model.views.containerViews[0].relationships]
|
234
234
|
|
235
235
|
print('element ids:', element_ids)
|
236
236
|
print('person id:', w.person().user.model.id)
|
@@ -272,7 +272,7 @@ def test_component_view(use_context: bool) -> Optional[None]:
|
|
272
272
|
)
|
273
273
|
|
274
274
|
if not use_context:
|
275
|
-
w.
|
275
|
+
w.apply_view(
|
276
276
|
ComponentView(
|
277
277
|
container_selector=lambda w: w.software_system().software_system.web_application,
|
278
278
|
key="web_application_container_00",
|
@@ -280,8 +280,8 @@ def test_component_view(use_context: bool) -> Optional[None]:
|
|
280
280
|
)
|
281
281
|
)
|
282
282
|
|
283
|
-
element_ids =
|
284
|
-
relationship_ids =
|
283
|
+
element_ids = [x.id for x in w.model.views.componentViews[0].elements]
|
284
|
+
relationship_ids = [x.id for x in w.model.views.componentViews[0].relationships]
|
285
285
|
|
286
286
|
print("user id:", w.person().user.model.id)
|
287
287
|
print("software system id", w.software_system().software_system.model.id)
|
@@ -330,7 +330,7 @@ def test_component_view_with_exclude_user(use_context: bool) -> Optional[None]:
|
|
330
330
|
)
|
331
331
|
|
332
332
|
if not use_context:
|
333
|
-
w.
|
333
|
+
w.apply_view(
|
334
334
|
ComponentView(
|
335
335
|
container_selector=lambda w: w.software_system().software_system.web_application,
|
336
336
|
key="web_application_container_00",
|
@@ -341,8 +341,8 @@ def test_component_view_with_exclude_user(use_context: bool) -> Optional[None]:
|
|
341
341
|
)
|
342
342
|
)
|
343
343
|
|
344
|
-
element_ids =
|
345
|
-
relationship_ids =
|
344
|
+
element_ids = [x.id for x in w.model.views.componentViews[0].elements]
|
345
|
+
relationship_ids = [x.id for x in w.model.views.componentViews[0].relationships]
|
346
346
|
|
347
347
|
print("user id:", w.person().user.model.id)
|
348
348
|
print("software system id", w.software_system().software_system.model.id)
|
@@ -384,7 +384,7 @@ def test_container_view_with_multiple_software_systems(use_context: bool) -> Opt
|
|
384
384
|
)
|
385
385
|
|
386
386
|
if not use_context:
|
387
|
-
w.
|
387
|
+
w.apply_view(
|
388
388
|
ContainerView(
|
389
389
|
key="container_view_00",
|
390
390
|
description="Container View Test",
|
@@ -400,8 +400,8 @@ def test_container_view_with_multiple_software_systems(use_context: bool) -> Opt
|
|
400
400
|
c1 = app1.c1
|
401
401
|
c2 = app2.c2
|
402
402
|
|
403
|
-
element_ids =
|
404
|
-
relationship_ids =
|
403
|
+
element_ids = [x.id for x in w.model.views.containerViews[0].elements]
|
404
|
+
relationship_ids = [x.id for x in w.model.views.containerViews[0].relationships]
|
405
405
|
|
406
406
|
assert len(element_ids) == 2
|
407
407
|
assert {
|
@@ -414,9 +414,72 @@ def test_container_view_with_multiple_software_systems(use_context: bool) -> Opt
|
|
414
414
|
c1.model.relationships[0].id,
|
415
415
|
}.issubset(set(relationship_ids))
|
416
416
|
|
417
|
-
# TODO: Soon.
|
418
417
|
def test_multiple_views() -> Optional[None]:
|
419
|
-
|
418
|
+
|
419
|
+
with Workspace("w", scope='landscape', group_separator="/") as w:
|
420
|
+
with Group("Company 1") as company1:
|
421
|
+
with Group("Department 1"):
|
422
|
+
a = SoftwareSystem("A")
|
423
|
+
with Group("Department 2") as c1d2:
|
424
|
+
b = SoftwareSystem("B")
|
425
|
+
with Group("Company 2") as company2:
|
426
|
+
with Group("Department 1"):
|
427
|
+
c = SoftwareSystem("C")
|
428
|
+
with Group("Department 2") as c2d2:
|
429
|
+
d = SoftwareSystem("D")
|
430
|
+
a >> b
|
431
|
+
c >> d
|
432
|
+
b >> c
|
433
|
+
|
434
|
+
SystemLandscapeView(
|
435
|
+
key='nested-groups',
|
436
|
+
description="Nested Groups Sample"
|
437
|
+
)
|
438
|
+
|
439
|
+
SystemContextView(
|
440
|
+
software_system_selector=b,
|
441
|
+
key='nested-groups-context-0',
|
442
|
+
description="Nested Groups Sample Context",
|
443
|
+
include_elements=[c, d],
|
444
|
+
)
|
445
|
+
|
446
|
+
SystemContextView(
|
447
|
+
software_system_selector=c,
|
448
|
+
key='nested-groups-context-1',
|
449
|
+
description="Nested Groups Sample Context",
|
450
|
+
include_elements=[b, d],
|
451
|
+
)
|
452
|
+
|
453
|
+
StyleElements(
|
454
|
+
on=[a, b],
|
455
|
+
shape='Box',
|
456
|
+
)
|
457
|
+
|
458
|
+
StyleElements(
|
459
|
+
on=[c, d],
|
460
|
+
shape='RoundedBox',
|
461
|
+
)
|
462
|
+
|
463
|
+
StyleElements(
|
464
|
+
on=[company1],
|
465
|
+
stroke='yellow',
|
466
|
+
border='dotted',
|
467
|
+
)
|
468
|
+
|
469
|
+
StyleElements(
|
470
|
+
on=[c1d2, c2d2],
|
471
|
+
color='green',
|
472
|
+
)
|
473
|
+
|
474
|
+
assert w.model.views.systemLandscapeViews is not None
|
475
|
+
assert w.model.views.systemContextViews is not None
|
476
|
+
|
477
|
+
assert len(w.model.views.systemLandscapeViews) == 1
|
478
|
+
assert len(w.model.views.systemContextViews) == 2
|
479
|
+
|
480
|
+
assert w.model.views.systemLandscapeViews[0].key == 'nested-groups'
|
481
|
+
assert w.model.views.systemContextViews[0].key == 'nested-groups-context-0'
|
482
|
+
assert w.model.views.systemContextViews[1].key == 'nested-groups-context-1'
|
420
483
|
|
421
484
|
def test_style_elements_on_dslelements() -> Optional[None]:
|
422
485
|
|
@@ -1 +0,0 @@
|
|
1
|
-
VERSION = "0.0.10"
|
@@ -1,44 +0,0 @@
|
|
1
|
-
import buildzr
|
2
|
-
from buildzr.dsl import *
|
3
|
-
from typing import cast
|
4
|
-
from ..abstract_builder import AbstractBuilder
|
5
|
-
|
6
|
-
class GroupsSample(AbstractBuilder):
|
7
|
-
|
8
|
-
def build(self) -> buildzr.models.Workspace:
|
9
|
-
with Workspace("w", scope=None) as w:
|
10
|
-
with Group("Company 1"):
|
11
|
-
with SoftwareSystem("A") as a:
|
12
|
-
Container("a1")
|
13
|
-
Container("a2")
|
14
|
-
with Group("Company 2"):
|
15
|
-
with SoftwareSystem("B") as b:
|
16
|
-
Container("b1")
|
17
|
-
with Container("b2") as b2:
|
18
|
-
Component("c1")
|
19
|
-
c = SoftwareSystem("C")
|
20
|
-
a >> "Uses" >> b
|
21
|
-
a.a1 >> "Uses" >> b.b1
|
22
|
-
a >> "Uses" >> c
|
23
|
-
w.apply_views(
|
24
|
-
SystemLandscapeView(
|
25
|
-
key='groups-sample',
|
26
|
-
description="Groups Sample"
|
27
|
-
),
|
28
|
-
SystemContextView(
|
29
|
-
key='groups-sample-a',
|
30
|
-
software_system_selector=lambda w: cast(SoftwareSystem, w.a),
|
31
|
-
description="Groups Sample - Software System A"
|
32
|
-
),
|
33
|
-
SystemContextView(
|
34
|
-
key='groups-sample-b',
|
35
|
-
software_system_selector=lambda w: cast(SoftwareSystem, w.b),
|
36
|
-
description="Groups Sample - Software System B"
|
37
|
-
),
|
38
|
-
ContainerView(
|
39
|
-
key='groups-sample-b2',
|
40
|
-
software_system_selector=lambda w: w.software_system().b,
|
41
|
-
description="Groups Sample - Container B2"
|
42
|
-
),
|
43
|
-
)
|
44
|
-
return w.model
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|