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

LCC & VSC : add escaped id in metadata #544

Merged
merged 3 commits into from
Aug 1, 2023
Merged

Conversation

tadam50
Copy link
Contributor

@tadam50 tadam50 commented Jul 31, 2023

Please check if the PR fulfills these requirements

  • The commit message follows our guidelines
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

Does this PR already have an issue describing the problem?
No

What kind of change does this PR introduce?
Feature

What is the current behavior?
In node metadata for VSC or LCC contains fields id & equipmentId.
But the field id is "ascii-encoded" & equipmentId is the HVDC line id.

What is the new behavior (if this is a feature change)?
Add in metadata the LCC or VSC id.

Copy link
Member

@So-Fras So-Fras left a comment

Choose a reason for hiding this comment

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

Thank you for working quickly and yet without very clear specifications (my bad!).
I have a few minor comments and something (what should we do about the existing NodeMetadata constructor) I would like to discuss further with you!

node instanceof EquipmentNode ? ((EquipmentNode) node).getEquipmentId() : null,
createNodeLabelMetadata(prefixId, node, nodeLabels)));

addInfoComponentMetadata(metadata, node.getComponentType());
}

private String getUnescapedId(Node node, String nodeEscapedId) {
String unescapedId = null;
if (node.getComponentType().compareTo(VSC_CONVERTER_STATION) == 0 ||
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
if (node.getComponentType().compareTo(VSC_CONVERTER_STATION) == 0 ||
if (node.getComponentType().equals(VSC_CONVERTER_STATION) ||

(same suggestion for the second part of the condition)

String unescapedId = null;
if (node.getComponentType().compareTo(VSC_CONVERTER_STATION) == 0 ||
node.getComponentType().compareTo(LCC_CONVERTER_STATION) == 0) {
unescapedId = IdUtil.unescapeId(nodeEscapedId);
Copy link
Member

Choose a reason for hiding this comment

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

The unescapedId is simply given by node.getId()! I don't think the "real" node id is rewritten after the escapeId operation.
Thus, the getUnescapedId(...) function may only have one parameter (Node node)

@@ -51,8 +53,21 @@ public static class NodeMetadata {

private final List<NodeLabelMetadata> labels;

public NodeMetadata(@JsonProperty("id") String escapedId,
Copy link
Member

Choose a reason for hiding this comment

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

True question: is there a need to keep this constructor? For example, for a Node that is not an EquipmentNode, the equipmentId is null and we do not have a specific method without the equipmentId.
Since the method is public, it would cause a breaking change to delete it.
Is deprecating it in the first place the right thing to do?

@@ -149,6 +149,7 @@ void test() throws IOException {
@Test
void testGraphMetadataWithLine() throws IOException {
GraphMetadata metadata = new GraphMetadata(new LayoutParameters());
metadata.addNodeMetadata(new GraphMetadata.NodeMetadata("STATION_EXEMPLE", "idSTATION_95_EXEMPLE", "vid1", null, LCC_CONVERTER_STATION, false, Direction.UNDEFINED, false, null, Collections.emptyList()));
Copy link
Member

Choose a reason for hiding this comment

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

EXEMPLE is a French word ;) I would suggest EXAMPLE instead!

tadam50 added 3 commits August 1, 2023 11:29
Signed-off-by: Thomas ADAM <tadam@silicom.fr>
Signed-off-by: Thomas ADAM <tadam@silicom.fr>
Signed-off-by: Thomas ADAM <tadam@silicom.fr>
@tadam50 tadam50 force-pushed the add-escaped-id-in-metadata branch from 7ae1383 to 9a8dd77 Compare August 1, 2023 09:29
@sonarqubecloud
Copy link

sonarqubecloud bot commented Aug 1, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 2 Code Smells

94.3% 94.3% Coverage
0.0% 0.0% Duplication

Copy link
Member

@So-Fras So-Fras left a comment

Choose a reason for hiding this comment

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

Thank you for your work!

@So-Fras So-Fras merged commit 36960bb into main Aug 1, 2023
@So-Fras So-Fras deleted the add-escaped-id-in-metadata branch August 1, 2023 10:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants