Skip to content

Commit

Permalink
feat(capella2polarion): Add jinja descriptions for LogicalComponent
Browse files Browse the repository at this point in the history
… and `ComponentExchange`
  • Loading branch information
ewuerger committed Sep 20, 2024
1 parent d894510 commit 5c29980
Show file tree
Hide file tree
Showing 3 changed files with 93 additions and 2 deletions.
16 changes: 14 additions & 2 deletions capella2polarion_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,13 @@ la:
LogicalComponent:
- links:
- allocated_functions
serializer: add_context_diagram
serializer:
jinja_as_description:
template_folder: jinja/element_templates
template_path: logical_component.html.j2
add_context_diagram:
filters:
- SHOW_EX_ITEMS
- is_actor: true
polarion_type: logicalActor
- is_actor: false
Expand All @@ -106,7 +112,13 @@ la:
Exchange Items: exchange_items
- realized_functions
ComponentExchange:
serializer: add_context_diagram
serializer:
jinja_as_description:
template_folder: jinja/element_templates
template_path: component_exchange.html.j2
add_context_diagram:
filters:
- SHOW_EX_ITEMS
links:
- allocated_functional_exchanges
FunctionalExchange:
Expand Down
53 changes: 53 additions & 0 deletions jinja/element_templates/component_exchange.html.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{#
Copyright DB InfraGO AG and contributors
SPDX-License-Identifier: Apache-2.0
#}

{% from 'common_macros.html.j2' import linked_name, description %}
{% from 'polarion_props.j2' import table_attributes, th_attributes, td_attributes %}

{% macro describe_exchange(object) %}
{%- set source_function = object.source.owner -%}
{%- set target_function = object.target.owner -%}
{%- set source = source_function.owner -%}
{%- set target = target_function.owner -%}
The {{ source | link_work_item }} shall provide {{ object | link_work_item }} to {{ target | link_work_item }} so that the {{ target | link_work_item }} could {{ target_function | link_work_item }}.
{% endmacro %}

<h1>Logical Interface {{ object.name }}</h1>
<h2>Interface Partners</h2>
<p>This logical interface connects between {{ object.source.owner | link_work_item}} and {{ object.target.owner | link_work_item}}.</p>
<p>The need for the interface is explained and requirements are provided so that the interface partners could find an appropriate interface definition (solution).</p>
<h2>Enabled interactions</h2>
<p>The figure below provides an overview of the behaviors that depend on this interface:</p>
{{ object.context_diagram.as_svg | safe }}
<p>This interface enables the following interactions:</p>
<table {{table_attributes}}>
<thead>
<tr>
<th {{th_attributes}}>ID</th>
<th {{th_attributes}}>Interaction description</th>
</tr>
</thead>
<tbody>
{% for exchange in object.allocated_functional_exchanges %}
<tr>
<td {{td_attributes}}>{{ exchange | link_work_item }}</td>
<td {{td_attributes}}>
{{ describe_exchange(exchange) | safe }}
{% if exchange.exchange_itemslength > 1 %}
<p>{{ exchange.name }} is further specified via the following Exchange Items:</p>
<ul>
{% for item in exchange.exchange_items %}
<li>{{ item | link_work_item }}</li>
{% endfor %}
</ul>
{% elif exchange.exchange_items %}
<p>This interaction is further specified via {{ exchange.exchange_items[0] | link_work_item}}.</p>
{% endif %}
</td>
</tr>
{% endfor %}
</tbody>
</table>

26 changes: 26 additions & 0 deletions jinja/element_templates/logical_component.html.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{#
Copyright DB InfraGO AG and contributors
SPDX-License-Identifier: Apache-2.0
#}

{% from 'common_macros.html.j2' import show_other_attributes, description %}

<h1>{{ object.name }}</h1>

{{ description(object) | safe }}

<p>
The figure below provides an overview of the logical subsystem and external entities that either require the functionality of <b>{{ object.name }}</b> (expect outputs) or enable it (provide inputs). The figure also identifies the interfaces between the subsystem and its environment.
</p>

{{- object.context_diagram.as_svg | safe -}}


{%- for fnc in object.allocated_functions -%}
{%- if loop.first -%}
<h1>Allocated functions</h1>
{%- endif -%}

<h2>{{ fnc.name }}</h2>
{{ description(fnc) | safe }}
{%- endfor -%}

0 comments on commit 5c29980

Please sign in to comment.