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

[WIP] Parameters improvements #3032

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft

[WIP] Parameters improvements #3032

wants to merge 3 commits into from

Conversation

olperr1
Copy link
Member

@olperr1 olperr1 commented May 23, 2024

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?

What is the new behavior (if this is a feature change)?
The parameters now have new optional attributes:

  • categoryKey: a free-text attribute containing a business key to group together the parameters which concern a same topic;
  • usageRestrictions: an object indicating that the current parameter is used only when another parameters have a specific value. For instance, parameter p3 is used only when p1 have a value in { "value1", "value3"} AND p2 is true;
  • unitSymbol: a free-text attribute containing the unit of the expected values for the parameter. The most common units can be found in ParameterUnit.

To ease the parameters' creation, a builder was also introduced, but the existing methods were kept.

Does this PR introduce a breaking change or deprecate an API?

  • Yes
  • No

If yes, please check if the following requirements are fulfilled

  • The Breaking Change or Deprecated label has been added
  • The migration steps are described in the following section

What changes might users need to make in their application due to this PR? (migration steps)

  • Parameter.getPossibleValues() now returns an Optional<List<Object>> instead of a nullable List<Object>.
  • LoadFlowProvider implementation should implement the new method:
    • List<String> getUnsupportedGenericParameters();, which returns the ids of the generic parameters which are unsupported by the LoadFlow provider.

Other information:

For instance, you can create parameters with the given syntaxes:

// Old syntax: direct use of the constructor
Parameter param1 = new Parameter(key1, ParameterType.STRING, "a 1st param", "a", List.of("a", "b", "c"));

// New syntax: via the builder
Parameter param2 = Parameter.builder(key2, ParameterType.BOOLEAN, "a 2nd param", Boolean.FALSE)
        .withCategoryKey("Category")
        .build();

// Create a parameter depending on the values of param1 and param2
Parameter param3 = Parameter.builder(key3, ParameterType.STRING, "", "yes")
        .newUsageRestriction()
            .withRestriction(key1, Set.of("b", "c"))
            .withRestriction(key2, Boolean.FALSE)
        .add()
        .withCategoryKey("Category")
        .build();

Signed-off-by: Olivier Perrin <olivier.perrin@rte-france.com>
Signed-off-by: Olivier Perrin <olivier.perrin@rte-france.com>
@olperr1 olperr1 added the Breaking Change API is broken label May 23, 2024
Signed-off-by: Olivier Perrin <olivier.perrin@rte-france.com>
Copy link

sonarcloud bot commented May 24, 2024

@olperr1 olperr1 marked this pull request as ready for review May 24, 2024 09:13
@olperr1 olperr1 changed the title [WIP] Parameters improvements Parameters improvements May 24, 2024
@olperr1 olperr1 requested a review from flo-dup May 24, 2024 09:13
@olperr1 olperr1 self-assigned this May 28, 2024
@olperr1 olperr1 changed the title Parameters improvements [WIP] Parameters improvements May 31, 2024
@olperr1 olperr1 marked this pull request as draft May 31, 2024 12:59
@olperr1
Copy link
Member Author

olperr1 commented May 31, 2024

This PR was revert to draft as it needs to be reworked.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Breaking Change API is broken
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant