Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add add_attributes serializer #139

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open

Conversation

ewuerger
Copy link
Member

Added layer custom field to generic and diagram serializer.

Added `layer` custom field to generic and diagram serializer.
@ewuerger ewuerger force-pushed the add-layer-and-nature branch 2 times, most recently from 182ce81 to fa8ffa6 Compare December 12, 2024 16:39
@ewuerger ewuerger force-pushed the add-layer-and-nature branch from fa8ffa6 to ee26a4f Compare December 12, 2024 16:41
For now this serializer is only supports adding
enum attributes as custom fields.
@ewuerger ewuerger changed the title feat: Add layer custom field feat: Add add_attributes serializer Dec 13, 2024
@ewuerger ewuerger force-pushed the add-layer-and-nature branch 2 times, most recently from 942c312 to 53a7186 Compare December 13, 2024 15:22
@ewuerger ewuerger force-pushed the add-layer-and-nature branch from 53a7186 to 20da2f4 Compare December 13, 2024 15:24
@ewuerger ewuerger requested a review from micha91 December 13, 2024 15:27
@ewuerger ewuerger self-assigned this Dec 13, 2024
@ewuerger ewuerger added documentation Improvements or additions to documentation enhancement New feature or request labels Dec 13, 2024
Copy link
Collaborator

@micha91 micha91 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review not finished yet, but I wanted to provide you with the first feedback asap

@@ -473,6 +528,7 @@ def _diagram(
uuid_capella=diagram.uuid,
description=polarion_api.HtmlContent(diagram_html),
status="open",
layer=layer,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So the layer will in the future always be part of a diagram workitem and this is not configurable. I think this is fine, but needs to be communicated as a change in the release notes

) -> polarion_api.TextContent:
value = getattr(element, attribute)
if isinstance(value, enum.Enum):
return polarion_api.TextContent(type="string", value=value.name)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we return TextContent for simple strings?

if isinstance(value, enum.Enum):
return polarion_api.TextContent(type="string", value=value.name)

raise ValueError(f"Unsupported attribute type: {value!r}")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should be more generic here. We could add an HTML-Flag to the config of an attribute. If this flag is set, we export the value of the attribute as HtmlContent. If not, we just cast the value to string and use the string

@@ -433,6 +457,7 @@ def __generic_work_item(
uuid_capella=obj.uuid,
description=polarion_api.HtmlContent(value),
status="open",
layer=layer,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought we would add the layer optional via the add_attributes serializer as we often already have the layer as part of the work item type

Comment on lines +38 to +45
ARCHITECTURE_LAYERS: dict[str, str] = {
"common": "Common",
"oa": "Operational Analysis",
"sa": "System Analysis",
"la": "Logical Architecture",
"pa": "Physical Architecture",
"epbs": "EPBS",
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be better to have this as enum defined in Polarion, wouldn't it? This way we could just post the actual values like oa to Polarion and there it can be handled including localization.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants