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

CGMES export: report multiple model identifiers #3093

Merged
merged 6 commits into from
Jul 11, 2024

Conversation

zamarrenolm
Copy link
Member

@zamarrenolm zamarrenolm commented Jul 8, 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)

What kind of change does this PR introduce?

Bug fix

What is the current behavior?

The identifier of the exported model was written in the Report under the key CgmesId.
After the recent refactoring of Report, only the first CgmesId key present in the report could be retrieved, because the exported model identifiers were written as message templates instead of values.

What is the new behavior (if this is a feature change)?
Allow for multiple CgmesId values to be present in the Report output.
The identifiers of the exported model must be retrieved by looking at the message of each report node, instead to its message template:

// Prepare a root report node
ReportNode report = ReportNode
        .newRootReportNode()
        .withMessageTemplate("rootKey", "")
        .build();

// Do the export using the report
cgmNetwork.write(new ExportersServiceLoader(), "CGMES", exportParams, dataSource, report);

// Retrieve all the exported model data from the report
Set<ExportedModel> exportedModelsFromReporter = new HashSet<>();
for (ReportNode n : report.getChildren()) {
    if (CgmesExportUtil.REPORT_NODE_KEY_EXPORTED_CGMES_ID.equals(n.getMessageKey())) {
        n.getValue(CgmesExportUtil.REPORT_VALUE_EXPORTED_CGMES_ID).ifPresent(v -> {
                String subset = n.getValue(CgmesExportUtil.REPORT_VALUE_EXPORTED_CGMES_SUBSET)
                        .map(TypedValue::getValue).map(Object::toString).orElse(null);
                String networkId = n.getValue(CgmesExportUtil.REPORT_VALUE_EXPORTED_CGMES_NETWORK_ID)
                        .map(TypedValue::getValue).map(Object::toString).orElse(null);
                exportedModelsFromReporter.add(new ExportedModel(v.getValue().toString(), subset, networkId));
            }
        );
    }
}

with

private record ExportedModel(String cgmesId, String subset, String networkId) {
}

Signed-off-by: Luma <zamarrenolm@aia.es>
Signed-off-by: Luma <zamarrenolm@aia.es>
@zamarrenolm zamarrenolm requested a review from flo-dup July 8, 2024 11:24
Signed-off-by: Luma <zamarrenolm@aia.es>
@olperr1
Copy link
Member

olperr1 commented Jul 10, 2024

@zamarrenolm: In the current state, the PR allows us to retrieve all the ids, but there is nothing to help us know which model they are corresponding to. It would be useful if some other data were also available on each ReportNode to identify its id.

@zamarrenolm
Copy link
Member Author

@zamarrenolm: In the current state, the PR allows us to retrieve all the ids, but there is nothing to help us know which model they are corresponding to. It would be useful if some other data were also available on each ReportNode to identify its id.

I think it would be relatively easy to report the network identifier (to be able to associate the exported uuid with a given network) and the instance file (EQ, SSH, ...). Let me try it ...

…es identifiers

Signed-off-by: Luma <zamarrenolm@aia.es>
@olperr1
Copy link
Member

olperr1 commented Jul 10, 2024

@zamarrenolm: Thanks for your additions.
It looks fine to me.

Copy link

sonarcloud bot commented Jul 10, 2024

@olperr1 olperr1 dismissed flo-dup’s stale review July 11, 2024 13:53

All the changes asked by flo-dup were made.

@olperr1 olperr1 merged commit 62d3644 into main Jul 11, 2024
7 checks passed
@olperr1 olperr1 deleted the cgmes_export_report_model_id branch July 11, 2024 13:56
@olperr1 olperr1 added the bug label Jul 11, 2024
olperr1 pushed a commit that referenced this pull request Jul 11, 2024
* CGMES export report model identifiers
* value of constant in message for easy reading
* add cgmes subset and network id to the report nodes with exported cgmes identifiers

Signed-off-by: Luma <zamarrenolm@aia.es>
(cherry picked from commit 62d3644)
geofjamg pushed a commit that referenced this pull request Sep 18, 2024
* CGMES export report model identifiers
* value of constant in message for easy reading
* add cgmes subset and network id to the report nodes with exported cgmes identifiers

Signed-off-by: Luma <zamarrenolm@aia.es>
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.

4 participants