|
| 1 | +# Copyright (c) 2020, Moritz E. Beber. |
| 2 | +# |
| 3 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +# you may not use this file except in compliance with the License. |
| 5 | +# You may obtain a copy of the License at |
| 6 | +# |
| 7 | +# https://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +# |
| 9 | +# Unless required by applicable law or agreed to in writing, software |
| 10 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +# See the License for the specific language governing permissions and |
| 13 | +# limitations under the License. |
| 14 | + |
| 15 | + |
| 16 | +"""Provide a system landscape view.""" |
| 17 | + |
| 18 | + |
| 19 | +from pydantic import Field |
| 20 | + |
| 21 | +from ..mixin import ModelRefMixin |
| 22 | +from ..model import Model |
| 23 | +from .static_view import StaticView, StaticViewIO |
| 24 | + |
| 25 | + |
| 26 | +__all__ = ("SystemLandscapeView", "SystemLandscapeViewIO") |
| 27 | + |
| 28 | + |
| 29 | +class SystemLandscapeViewIO(StaticViewIO): |
| 30 | + """ |
| 31 | + Represent a system landscape view that sits above the C4 model. |
| 32 | +
|
| 33 | + This is the "big picture" view, showing the software systems and people in a given |
| 34 | + environment. The permitted elements in this view are software systems and people. |
| 35 | +
|
| 36 | + Attributes: |
| 37 | + enterprise_boundary_visible (bool): Determines whether the enterprise boundary |
| 38 | + (to differentiate "internal" elements from "external" elements") should be |
| 39 | + visible on the resulting diagram. |
| 40 | +
|
| 41 | + """ |
| 42 | + |
| 43 | + enterprise_boundary_visible: bool = Field(True, alias="enterpriseBoundaryVisible") |
| 44 | + |
| 45 | + |
| 46 | +class SystemLandscapeView(ModelRefMixin, StaticView): |
| 47 | + """ |
| 48 | + Represent a system landscape view that sits above the C4 model. |
| 49 | +
|
| 50 | + This is the "big picture" view, showing the software systems and people in a given |
| 51 | + environment. The permitted elements in this view are software systems and people. |
| 52 | +
|
| 53 | + Attributes: |
| 54 | + enterprise_boundary_visible (bool): |
| 55 | +
|
| 56 | + """ |
| 57 | + |
| 58 | + def __init__( |
| 59 | + self, *, model: Model, enterprise_boundary_visible: bool = True, **kwargs |
| 60 | + ) -> None: |
| 61 | + """Initialize a system landscape view.""" |
| 62 | + super().__init__(**kwargs) |
| 63 | + self.enterprise_boundary_visible = enterprise_boundary_visible |
| 64 | + self.set_model(model) |
| 65 | + |
| 66 | + def add_all_elements(self) -> None: |
| 67 | + """Add all software systems and all people to this view.""" |
| 68 | + self.add_all_software_systems() |
| 69 | + self.add_all_people() |
| 70 | + |
| 71 | + @classmethod |
| 72 | + def hydrate( |
| 73 | + cls, system_landscape_view_io: SystemLandscapeViewIO |
| 74 | + ) -> "SystemLandscapeView": |
| 75 | + """""" |
| 76 | + return cls( |
| 77 | + # TODO (midnighter): Set the model somehow. |
| 78 | + # model=..., |
| 79 | + key=system_landscape_view_io.key, |
| 80 | + description=system_landscape_view_io.description, |
| 81 | + enterprise_boundary_visible=( |
| 82 | + system_landscape_view_io.enterprise_boundary_visible |
| 83 | + ), |
| 84 | + ) |
0 commit comments