capella2polarion.elements package¶
Objects for synchronization of capella objects to polarion workitems.
Submodules¶
capella2polarion.elements.capella_object_renderer module¶
Provides Capella object specific rendering functionalities.
- class capella2polarion.elements.capella_object_renderer.CapellaObjectRenderer(model: MelodyModel, generate_figure_captions: bool, generate_attachments: bool, capella_polarion_mapping: PolarionDataRepository)¶
Bases:
JinjaRendererMixin
A class for work item generating plugins and generators.
- draw_diagram_svg(diagram: AbstractDiagram, file_name: str, title: str, max_width: int, cls: str, render_params: dict[str, Any] | None = None, caption: str | None = None) tuple[str, CapellaDiagramAttachment | None] ¶
Return the provided diagram as attachment and HTML.
- static get_requirement_types_text(obj: ModelElement | DRepresentationDescriptor, errors: set[str]) dict[str, HtmlContent] ¶
Get the requirement texts and return them.
- render_jinja_template(template_folder: str | Path, template_path: str | Path, capella_element: ModelElement | DRepresentationDescriptor, errors: set[str], work_item: CapellaWorkItem | None = None, render_params: dict[str, Any] | None = None) tuple[list[str], Markup, list[Capella2PolarionAttachment]] ¶
Render jinja template for model element and return polarion text.
- replace_markup(match: Match, referenced_uuids: list[str], errors: set[str], default_group: int = 1) str ¶
Replace UUID references in a
match
with a work item link.If the UUID doesn’t correspond to an existing work item the original text is returned.
- sanitize_linked_text(obj: ModelElement | DRepresentationDescriptor, errors: set[str]) tuple[list[str], Markup, list[Capella2PolarionAttachment]] ¶
Get the linked text and return it sanitized.
capella2polarion.elements.converter_config module¶
Module providing capella2polarion config class.
- class capella2polarion.elements.converter_config.CapellaTypeConfig(p_type: str | None = None, converters: dict[str, dict[str, ~typing.Any]] | None = None, links: list[~capella2polarion.elements.converter_config.LinkConfig] = <factory>, is_actor: bool | None = None, nature: str | None = None)¶
Bases:
object
A single Capella Type configuration.
- links: list[LinkConfig]¶
- class capella2polarion.elements.converter_config.ConverterConfig¶
Bases:
object
The overall Config for capella2polarion.
- get_type_config(layer: str, c_type: str, **attributes: Any) CapellaTypeConfig | None ¶
Get the type config for a given layer and capella_type.
- read_config_file(synchronize_config: TextIO | str, type_prefix: str = '', role_prefix: str = '') None ¶
Read a given yaml file as config.
- set_diagram_config(diagram_config: dict[str, Any], type_prefix: str = '', role_prefix: str = '') None ¶
Set the diagram config.
- class capella2polarion.elements.converter_config.LinkConfig(capella_attr: str, polarion_role: str, include: dict[str, str] = <factory>, link_field: str = '', reverse_field: str = '')¶
Bases:
object
A single Capella Link configuration.
- static generate_links_configs(links: list[str | dict[str, Any]], role_prefix: str = '') list[LinkConfig] ¶
Generate LinkConfigs based on a list dict.
- include: dict[str, str]¶
A list of identifiers that are attribute names on the Capella objects link targets.
The requested objects are then included in the list display in the grouped link custom field as nested lists. They also need be migrated for working references.
- capella2polarion.elements.converter_config.add_prefix(polarion_type: str, prefix: str) str ¶
Add a prefix to the given
polarion_type
.
- capella2polarion.elements.converter_config.config_matches(config: CapellaTypeConfig | None, **kwargs: Any) bool ¶
Check whether the given
config
matches the givenkwargs
.
capella2polarion.elements.data_session module¶
A module to store data during the conversion process.
- class capella2polarion.elements.data_session.ConverterData(layer: str, type_config: ~capella2polarion.elements.converter_config.CapellaTypeConfig, capella_element: ~capellambse.model._obj.ModelElement | ~capellambse.model.diagram.DRepresentationDescriptor, work_item: ~capella2polarion.data_model.work_items.CapellaWorkItem | None = None, description_references: list[str] = <factory>, errors: set[str] = <factory>)¶
Bases:
object
Data class holding all information needed during Conversion.
- capella_element: ModelElement | DRepresentationDescriptor¶
- type_config: CapellaTypeConfig¶
- work_item: CapellaWorkItem | None = None¶
capella2polarion.elements.element_converter module¶
Objects for serialization of capella objects to workitems.
- class capella2polarion.elements.element_converter.CapellaWorkItemSerializer(model: MelodyModel, capella_polarion_mapping: PolarionDataRepository, converter_session: dict[str, ConverterData], generate_attachments: bool, generate_figure_captions: bool = False)¶
Bases:
object
The general serializer class for CapellaWorkItems.
- serialize(uuid: str) CapellaWorkItem | None ¶
Return a CapellaWorkItem for the given diagram or element.
- serialize_all() list[CapellaWorkItem] ¶
Serialize all items of the converter_session.
capella2polarion.elements.link_converter module¶
Objects for synchronization of Capella model objects to Polarion.
- class capella2polarion.elements.link_converter.LinkSerializer(capella_polarion_mapping: PolarionDataRepository, converter_session: dict[str, ConverterData], project_id: str, model: MelodyModel)¶
Bases:
object
A converter for capella element links and description references.
- create_grouped_back_link_fields(work_item: CapellaWorkItem, links: dict[str, list[WorkItemLink]]) None ¶
Create fields for the given WorkItem using a list of backlinks.
- Parameters:
work_item – The ConverterData that stores the WorkItem to create the fields for.
links – Dict of field names and links referencing work_item as secondary.
- create_grouped_link_fields(data: ConverterData, back_links: dict[str, dict[str, list[WorkItemLink]]] | None = None) None ¶
Create the grouped link fields from the primary work item.
- Parameters:
data – The ConverterData that stores the WorkItem to create the fields for.
back_links – A dictionary of secondary WorkItem IDs to links to create backlinks later.
- capella2polarion.elements.link_converter.find_link_config(data: ConverterData, role: str) LinkConfig | None ¶
Search for LinkConfig with matching polarion_role in
data
.
capella2polarion.elements.model_converter module¶
A module containing the overall model conversion class.
- class capella2polarion.elements.model_converter.ModelConverter(model: MelodyModel, project_id: str)¶
Bases:
object
Class to convert elements of a model and store related data.
- generate_work_item_links(polarion_data_repo: PolarionDataRepository, generate_grouped_links_custom_fields: bool) None ¶
Generate links for all work items and add custom fields for them.
- generate_work_items(polarion_data_repo: PolarionDataRepository, generate_links: bool = False, generate_attachments: bool = False, generate_grouped_links_custom_fields: bool = False, generate_figure_captions: bool = False) dict[str, CapellaWorkItem] ¶
Return a work items mapping from model elements for Polarion.
The dictionary maps Capella UUIDs to
CapellaWorkItem
s. In addition, it is ensured that neither title nor type are None, Links are not created in this step by default.- Parameters:
polarion_data_repo – The PolarionDataRepository object storing current work item data.
generate_links – A boolean flag to control linked work item generation.
generate_attachments – A boolean flag to control attachments generation. For SVG attachments, PNGs are generated and attached automatically.
generate_grouped_links_custom_fields – A boolean flag to control grouped links custom fields generation.
generate_figure_captions – A boolean flag to enable the generation of figure captions
- read_model(config: ConverterConfig) None ¶
Read the model using a given config and diagram_idx.