Skip to content

Commit

Permalink
chore: Rename organisation name in license header and license files
Browse files Browse the repository at this point in the history
`DB Netz AG` > `DB InfraGo AG`
  • Loading branch information
ewuerger committed Jan 3, 2024
1 parent 308175f commit 1862c3c
Show file tree
Hide file tree
Showing 53 changed files with 245 additions and 57 deletions.
2 changes: 1 addition & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: 2022 Copyright DB Netz AG and the capellambse-context-diagrams contributors
# SPDX-FileCopyrightText: 2022 Copyright DB InfraGO AG and the capellambse-context-diagrams contributors
# SPDX-License-Identifier: CC0-1.0

# “.gitattributes Best Practices - Muhammad Rehan Saeed” {{{
Expand Down
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: 2022 Copyright DB Netz AG and the capellambse-context-diagrams contributors
# SPDX-FileCopyrightText: 2022 Copyright DB InfraGO AG and the capellambse-context-diagrams contributors
# SPDX-License-Identifier: CC0-1.0

* @ewuerger @vik378
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build-test-publish.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: 2022 Copyright DB Netz AG and the capellambse-context-diagrams contributors
# SPDX-FileCopyrightText: 2022 Copyright DB InfraGO AG and the capellambse-context-diagrams contributors
# SPDX-License-Identifier: Apache-2.0

name: Build
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: 2022 Copyright DB Netz AG and the capellambse-context-diagrams contributors
# SPDX-FileCopyrightText: 2022 Copyright DB InfraGO AG and the capellambse-context-diagrams contributors
# SPDX-License-Identifier: Apache-2.0

name: Docs
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: 2022 Copyright DB Netz AG and the capellambse-context-diagrams contributors
# SPDX-FileCopyrightText: 2022 Copyright DB InfraGO AG and the capellambse-context-diagrams contributors
# SPDX-License-Identifier: Apache-2.0

name: Lint
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: 2022 Copyright DB Netz AG and the capellambse-context-diagrams contributors
# SPDX-FileCopyrightText: 2022 Copyright DB InfraGO AG and the capellambse-context-diagrams contributors
# SPDX-License-Identifier: CC0-1.0

# Templates from <https://github.com/github/gitignore>
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: 2022 Copyright DB Netz AG and the capellambse-context-diagrams contributors
# SPDX-FileCopyrightText: 2022 Copyright DB InfraGO AG and the capellambse-context-diagrams contributors
# SPDX-License-Identifier: CC0-1.0

exclude: '^(versioneer\.py|.*/_version\.py)$'
Expand Down
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!--
~ SPDX-FileCopyrightText: 2022 Copyright DB Netz AG and the capellambse-context-diagrams contributors
~ SPDX-FileCopyrightText: 2022 Copyright DB InfraGO AG and the capellambse-context-diagrams contributors
~ SPDX-License-Identifier: Apache-2.0
-->

Expand Down Expand Up @@ -110,7 +110,7 @@ Example:
> Integration test for capability context diagrams seen in `tests/test_capability_diagrams.py`:
>
> ```python
> # SPDX-FileCopyrightText: 2022 Copyright DB Netz AG and the capellambse-context-diagrams contributors
> # SPDX-FileCopyrightText: 2022 Copyright DB InfraGO AG and the capellambse-context-diagrams contributors
> # SPDX-License-Identifier: Apache-2.0
>
> import capellambse
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!--
~ SPDX-FileCopyrightText: 2022 Copyright DB Netz AG and the capellambse-context-diagrams contributors
~ SPDX-FileCopyrightText: 2022 Copyright DB InfraGO AG and the capellambse-context-diagrams contributors
~ SPDX-License-Identifier: Apache-2.0
-->

Expand Down Expand Up @@ -35,7 +35,7 @@ Special thanks goes to the developers and maintainers of [Eclipse Layout Kernel

Copyright and license information added and maintained via the reuse tool from [Reuse Software](https://reuse.software/).

***Copyright 2022 DB Netz AG, own contributions licensed under Apache 2.0 (see full text in [LICENSES/Apache-2.0](https://github.com/DSD-DBS/capellambse-context-diagrams/blob/master/LICENSES/Apache-2.0.txt))***
***Copyright 2022 DB InfraGO AG, own contributions licensed under Apache 2.0 (see full text in [LICENSES/Apache-2.0](https://github.com/DSD-DBS/capellambse-context-diagrams/blob/master/LICENSES/Apache-2.0.txt))***

***Copyright (c) 2021 Kiel University and others, ELK/Sprotty contributions ([elkgraph-json.js](https://github.com/DSD-DBS/capellambse-context-diagrams/blob/master/capellambse_context_diagrams/elkgraph-json.js) & [elkgraph-to-sprotty.js](https://github.com/DSD-DBS/capellambse-context-diagrams/blob/master/capellambse_context_diagrams/elkgraph-to-sprotty.js)) licensed under EPL-2.0***

Expand Down
2 changes: 1 addition & 1 deletion capellambse_context_diagrams/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: 2022 Copyright DB Netz AG and the capellambse-context-diagrams contributors
# SPDX-FileCopyrightText: 2022 Copyright DB InfraGO AG and the capellambse-context-diagrams contributors
# SPDX-License-Identifier: Apache-2.0

"""The Context Diagrams model extension.
Expand Down
2 changes: 1 addition & 1 deletion capellambse_context_diagrams/_elkjs.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: 2022 Copyright DB Netz AG and the capellambse-context-diagrams contributors
# SPDX-FileCopyrightText: 2022 Copyright DB InfraGO AG and the capellambse-context-diagrams contributors
# SPDX-License-Identifier: Apache-2.0

"""
Expand Down
2 changes: 1 addition & 1 deletion capellambse_context_diagrams/collectors/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: 2022 Copyright DB Netz AG and the capellambse-context-diagrams contributors
# SPDX-FileCopyrightText: 2022 Copyright DB InfraGO AG and the capellambse-context-diagrams contributors
# SPDX-License-Identifier: Apache-2.0

"""
Expand Down
2 changes: 1 addition & 1 deletion capellambse_context_diagrams/collectors/default.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: 2022 Copyright DB Netz AG and the capellambse-context-diagrams contributors
# SPDX-FileCopyrightText: 2022 Copyright DB InfraGO AG and the capellambse-context-diagrams contributors
# SPDX-License-Identifier: Apache-2.0
"""
Collection of [`ELKInputData`][capellambse_context_diagrams._elkjs.ELKInputData]
Expand Down
2 changes: 1 addition & 1 deletion capellambse_context_diagrams/collectors/exchanges.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: 2022 Copyright DB Netz AG and the capellambse-context-diagrams contributors
# SPDX-FileCopyrightText: 2022 Copyright DB InfraGO AG and the capellambse-context-diagrams contributors
# SPDX-License-Identifier: Apache-2.0

from __future__ import annotations
Expand Down
2 changes: 1 addition & 1 deletion capellambse_context_diagrams/collectors/generic.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: 2022 Copyright DB Netz AG and the capellambse-context-diagrams contributors
# SPDX-FileCopyrightText: 2022 Copyright DB InfraGO AG and the capellambse-context-diagrams contributors
# SPDX-License-Identifier: Apache-2.0
"""
Functionality for collection of model data from an instance of [`MelodyModel`][capellambse.model.MelodyModel]
Expand Down
2 changes: 1 addition & 1 deletion capellambse_context_diagrams/collectors/makers.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: 2022 Copyright DB Netz AG and the capellambse-context-diagrams contributors
# SPDX-FileCopyrightText: 2022 Copyright DB InfraGO AG and the capellambse-context-diagrams contributors
# SPDX-License-Identifier: Apache-2.0

from __future__ import annotations
Expand Down
2 changes: 1 addition & 1 deletion capellambse_context_diagrams/collectors/portless.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: 2022 Copyright DB Netz AG and the capellambse-context-diagrams contributors
# SPDX-FileCopyrightText: 2022 Copyright DB InfraGO AG and the capellambse-context-diagrams contributors
# SPDX-License-Identifier: Apache-2.0

"""
Expand Down
188 changes: 188 additions & 0 deletions capellambse_context_diagrams/collectors/realization_view.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,188 @@
# SPDX-FileCopyrightText: 2022 Copyright DB InfraGO AG and the capellambse-context-diagrams contributors
# SPDX-License-Identifier: Apache-2.0
"""This submodule defines the collector for the RealizationView diagram."""
from __future__ import annotations

import collections.abc as cabc
import copy
import re
import typing as t

from capellambse.model import common, crosslayer
from capellambse.model.crosslayer import cs, fa

from .. import _elkjs, context
from . import makers

RE_LAYER_PTRN = re.compile(r"([A-Z]?[a-z]+)")


def collector(
diagram: context.ContextDiagram, params: dict[str, t.Any]
) -> tuple[_elkjs.ELKInputData, list[_elkjs.ELKInputEdge]]:
"""Return the class tree data for ELK."""
data = makers.make_diagram(diagram)
layout_options: _elkjs.LayoutOptions = copy.deepcopy(
_elkjs.RECT_PACKING_LAYOUT_OPTIONS # type:ignore[arg-type]
)
layout_options["elk.contentAlignment"] = "V_CENTER H_CENTER"
del layout_options["widthApproximation.targetWidth"]
data["layoutOptions"] = layout_options
_collector = COLLECTORS[params.get("search_direction", "ALL")]
lay_to_els = _collector(diagram.target, params.get("depth", 1))
layer_layout_options: _elkjs.LayoutOptions = layout_options | { # type: ignore[operator]
"nodeSize.constraints": "[NODE_LABELS,MINIMUM_SIZE]",
} # type: ignore[assignment]
edges: list[_elkjs.ELKInputEdge] = []
for layer, elements in lay_to_els.items():
labels = [makers.make_label(layer)]
width, height = makers.calculate_height_and_width(labels)
layer_box: _elkjs.ELKInputChild = {
"id": elements[0]["layer"].uuid,
"children": [],
"height": width,
"width": height,
"layoutOptions": layer_layout_options,
}
children: dict[str, _elkjs.ELKInputChild] = {}
for elt in elements:
if elt["origin"] is not None:
edges.append(
{
"id": f'{elt["origin"].uuid}_{elt["element"].uuid}',
"sources": [elt["origin"].uuid],
"targets": [elt["element"].uuid],
}
)

if not (element_box := children.get(elt["element"].uuid)):
element_box = makers.make_box(elt["element"], no_symbol=True)
children[elt["element"].uuid] = element_box
layer_box["children"].append(element_box)
index = len(layer_box["children"]) - 1

if params.get("show_owners"):
owner = elt["element"].owner
if not isinstance(owner, (fa.Function, cs.Component)):
continue

if not (owner_box := children.get(owner.uuid)):
owner_box = makers.make_box(owner, no_symbol=True)
owner_box["height"] += element_box["height"]
children[owner.uuid] = owner_box
layer_box["children"].append(owner_box)

del layer_box["children"][index]
owner_box.setdefault("children", []).append(element_box)
owner_box["width"] += element_box["width"]
if (
elt["origin"] is not None
and elt["origin"].owner.uuid in children
and owner.uuid in children
):
eid = f'{elt["origin"].owner.uuid}_{owner.uuid}'
edges.append(
{
"id": eid,
"sources": [elt["origin"].owner.uuid],
"targets": [owner.uuid],
}
)

data["children"].append(layer_box)
data["children"] = data["children"][::-1]
return data, edges


def collect_realized(
start: common.GenericElement, depth: int
) -> dict[LayerLiteral, list[dict[str, t.Any]]]:
"""Collect all elements from ``realized_`` attributes up to depth."""
return collect_elements(start, depth, "ABOVE", "realized")


def collect_realizing(
start: common.GenericElement, depth: int
) -> dict[LayerLiteral, list[dict[str, t.Any]]]:
"""Collect all elements from ``realizing_`` attributes down to depth."""
return collect_elements(start, depth, "BELOW", "realizing")


def collect_all(
start: common.GenericElement, depth: int
) -> dict[LayerLiteral, list[common.GenericElement]]:
"""Collect all elements in both ABOVE and BELOW directions."""
above = collect_realized(start, depth)
below = collect_realizing(start, depth)
return above | below


def collect_elements(
start: common.GenericElement,
depth: int,
direction: str,
attribute_prefix: str,
origin: common.GenericElement = None,
) -> dict[LayerLiteral, list[dict[str, t.Any]]]:
"""Collect elements based on the specified direction and attribute name."""
layer_obj, layer = find_layer(start)
collected_elements: dict[LayerLiteral, list[dict[str, t.Any]]] = {
layer: [{"element": start, "origin": origin, "layer": layer_obj}]
}
if (
(direction == "ABOVE" and layer == "Operational")
or (direction == "BELOW" and layer == "Physical")
or depth == 0
):
return collected_elements

if isinstance(start, fa.Function):
attribute_name = f"{attribute_prefix}_functions"
else:
assert isinstance(start, cs.Component)
attribute_name = f"{attribute_prefix}_components"

for element in getattr(start, attribute_name, []):
sub_collected = collect_elements(
element, depth - 1, direction, attribute_prefix, origin=start
)
for sub_layer, sub_elements in sub_collected.items():
collected_elements.setdefault(sub_layer, []).extend(sub_elements)
return collected_elements


LayerLiteral = t.Union[
t.Literal["Operational"],
t.Literal["System"],
t.Literal["Logical"],
t.Literal["Physical"],
]


def find_layer(
obj: common.GenericElement,
) -> tuple[crosslayer.BaseArchitectureLayer, LayerLiteral]:
"""Return the layer object and its literal.
Return either one of the following:
* ``Operational``
* ``System``
* ``Logical``
* ``Physical``
"""
parent = obj
while not isinstance(parent, crosslayer.BaseArchitectureLayer):
parent = parent.parent
if not (match := RE_LAYER_PTRN.match(type(parent).__name__)):
raise ValueError("No layer was found.")
return parent, match.group(1) # type:ignore[return-value]


Collector = cabc.Callable[
[common.GenericElement, int], dict[LayerLiteral, list[dict[str, t.Any]]]
]
COLLECTORS: dict[str, Collector] = {
"ALL": collect_all,
"ABOVE": collect_realized,
"BELOW": collect_realizing,
}
2 changes: 1 addition & 1 deletion capellambse_context_diagrams/collectors/tree_view.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: 2022 Copyright DB Netz AG and the capellambse-context-diagrams contributors
# SPDX-FileCopyrightText: 2022 Copyright DB InfraGO AG and the capellambse-context-diagrams contributors
# SPDX-License-Identifier: Apache-2.0
"""This submodule defines the collector for the Class-Tree diagram."""
from __future__ import annotations
Expand Down
2 changes: 1 addition & 1 deletion capellambse_context_diagrams/context.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: 2022 Copyright DB Netz AG and the capellambse-context-diagrams contributors
# SPDX-FileCopyrightText: 2022 Copyright DB InfraGO AG and the capellambse-context-diagrams contributors
# SPDX-License-Identifier: Apache-2.0
"""
Definitions of Custom Accessor- and Diagram-Classtypes based on
Expand Down
2 changes: 1 addition & 1 deletion capellambse_context_diagrams/elk.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2022 Copyright DB Netz AG and the capellambse-context-diagrams contributors
// SPDX-FileCopyrightText: 2022 Copyright DB InfraGO AG and the capellambse-context-diagrams contributors
// SPDX-License-Identifier: Apache-2.0

const elkgraphsprotty = require("./elkgraph-to-sprotty");
Expand Down
2 changes: 1 addition & 1 deletion capellambse_context_diagrams/filters.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: 2022 Copyright DB Netz AG and the capellambse-context-diagrams contributors
# SPDX-FileCopyrightText: 2022 Copyright DB InfraGO AG and the capellambse-context-diagrams contributors
# SPDX-License-Identifier: Apache-2.0
"""Functions and registry for filter functionality."""
from __future__ import annotations
Expand Down
2 changes: 1 addition & 1 deletion capellambse_context_diagrams/serializers.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: 2022 Copyright DB Netz AG and the capellambse-context-diagrams contributors
# SPDX-FileCopyrightText: 2022 Copyright DB InfraGO AG and the capellambse-context-diagrams contributors
# SPDX-License-Identifier: Apache-2.0

"""This submodule provides a serializer that transforms data from an ELK-
Expand Down
2 changes: 1 addition & 1 deletion capellambse_context_diagrams/styling.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: 2022 Copyright DB Netz AG and the capellambse-context-diagrams contributors
# SPDX-FileCopyrightText: 2022 Copyright DB InfraGO AG and the capellambse-context-diagrams contributors
# SPDX-License-Identifier: Apache-2.0
"""Functions for style overrides of diagram elements."""
from __future__ import annotations
Expand Down
2 changes: 1 addition & 1 deletion docs/assets/images/Context of Left.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion docs/assets/images/Interface Context of Left to right.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion docs/assets/images/favicon.ico.license
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
SPDX-FileCopyrightText: 2022 Copyright DB Netz AG and the capellambse-context-diagrams contributors
SPDX-FileCopyrightText: 2022 Copyright DB InfraGO AG and the capellambse-context-diagrams contributors
SPDX-License-Identifier: Apache-2.0
2 changes: 1 addition & 1 deletion docs/assets/images/favicon.png.license
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
SPDX-FileCopyrightText: 2022 Copyright DB Netz AG and the capellambse-context-diagrams contributors
SPDX-FileCopyrightText: 2022 Copyright DB InfraGO AG and the capellambse-context-diagrams contributors
SPDX-License-Identifier: Apache-2.0
2 changes: 1 addition & 1 deletion docs/credits.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ hide:
---

<!--
~ SPDX-FileCopyrightText: 2022 Copyright DB Netz AG and the capellambse-context-diagrams contributors
~ SPDX-FileCopyrightText: 2022 Copyright DB InfraGO AG and the capellambse-context-diagrams contributors
~ SPDX-License-Identifier: Apache-2.0
-->

Expand Down
2 changes: 1 addition & 1 deletion docs/css/base.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2022 Copyright DB Netz AG and the capellambse-context-diagrams contributors
* SPDX-FileCopyrightText: 2022 Copyright DB InfraGO AG and the capellambse-context-diagrams contributors
* SPDX-License-Identifier: Apache-2.0
*/

Expand Down
2 changes: 1 addition & 1 deletion docs/extras/filters.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!--
~ SPDX-FileCopyrightText: 2022 Copyright DB Netz AG and the capellambse-context-diagrams contributors
~ SPDX-FileCopyrightText: 2022 Copyright DB InfraGO AG and the capellambse-context-diagrams contributors
~ SPDX-License-Identifier: Apache-2.0
-->

Expand Down
2 changes: 1 addition & 1 deletion docs/extras/styling.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!--
~ SPDX-FileCopyrightText: 2022 Copyright DB Netz AG and the capellambse-context-diagrams contributors
~ SPDX-FileCopyrightText: 2022 Copyright DB InfraGO AG and the capellambse-context-diagrams contributors
~ SPDX-License-Identifier: Apache-2.0
-->

Expand Down
Loading

0 comments on commit 1862c3c

Please sign in to comment.