-
Notifications
You must be signed in to change notification settings - Fork 39
Capture warnings as well as errors from CQL evaluation results. #840
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
base: master
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,6 +23,8 @@ public class CompositeEvaluationResultsPerMeasure { | |
| private final Map<MeasureDef, Map<String, EvaluationResult>> resultsPerMeasure; | ||
| // We may get several errors for a given measure | ||
| private final Map<MeasureDef, List<String>> errorsPerMeasure; | ||
| // We may get several warnings for a given measure | ||
| private final Map<MeasureDef, List<String>> warningsPerMeasure; | ||
|
|
||
| private CompositeEvaluationResultsPerMeasure(Builder builder) { | ||
|
|
||
|
|
@@ -33,6 +35,10 @@ private CompositeEvaluationResultsPerMeasure(Builder builder) { | |
| var errorsBuilder = ImmutableMap.<MeasureDef, List<String>>builder(); | ||
| builder.errorsPerMeasure.forEach((key, value) -> errorsBuilder.put(key, List.copyOf(value))); | ||
| errorsPerMeasure = errorsBuilder.build(); | ||
|
|
||
| var warningsBuilder = ImmutableMap.<MeasureDef, List<String>>builder(); | ||
| builder.warningsPerMeasure.forEach((key, value) -> warningsBuilder.put(key, List.copyOf(value))); | ||
| warningsPerMeasure = warningsBuilder.build(); | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -70,13 +76,23 @@ public Map<MeasureDef, List<String>> getErrorsPerMeasure() { | |
| return this.errorsPerMeasure; | ||
| } | ||
|
|
||
| /** | ||
| * Expose method to allow retrieval of captured warnings or infos produced from evaluated cql per Measure. | ||
| * When a warning or info is produced while evaluating, we capture the errors generated in this object, which can be rendered per Measure evaluated. | ||
| * @return {@code Map<IIdType, List<String>>} | ||
| */ | ||
| public Map<MeasureDef, List<String>> getWarningsPerMeasure() { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The documentation says this is capturing warnings or infos, but that distinction is not preserved, is this intentional? Should there be a way to indicate warning vs info?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not without CQL changes. I'm fine to go ahead and do that, but what's the use case?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you mean CQL engine changes, or CQL content changes? We're reworking the engine APIs now, so if you mean that this would be good feedback. :)
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What Bryn is asking for is not possible without CQL changes to pass down infos separately to the multi-lib CQL evaluation result class.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Right, so can we do that? It would be wrong (imo) to return as a "warning" something that was an "info", and vice versa. |
||
| return this.warningsPerMeasure; | ||
| } | ||
|
|
||
| public static Builder builder() { | ||
| return new Builder(); | ||
| } | ||
|
|
||
| public static class Builder { | ||
| private final Map<MeasureDef, Map<String, EvaluationResult>> resultsPerMeasure = new HashMap<>(); | ||
| private final Map<MeasureDef, List<String>> errorsPerMeasure = new HashMap<>(); | ||
| private final Map<MeasureDef, List<String>> warningsPerMeasure = new HashMap<>(); | ||
|
|
||
| public CompositeEvaluationResultsPerMeasure build() { | ||
| return new CompositeEvaluationResultsPerMeasure(this); | ||
|
|
@@ -129,6 +145,26 @@ public void addError(MeasureDef measureDef, String error) { | |
| errorsPerMeasure.computeIfAbsent(measureDef, k -> new ArrayList<>()).add(error); | ||
| } | ||
|
|
||
| public void addWarnings(List<MeasureDef> measureDefs, String error) { | ||
lukedegruchy marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| if (error == null || error.isEmpty()) { | ||
| return; | ||
| } | ||
|
|
||
| for (MeasureDef measureDef : measureDefs) { | ||
| addWarning(measureDef, error); | ||
| } | ||
| } | ||
|
|
||
| public void addWarning(MeasureDef measureDef, String error) { | ||
| if (error == null || error.isBlank()) { | ||
| return; | ||
| } | ||
|
|
||
| warningsPerMeasure | ||
| .computeIfAbsent(measureDef, k -> new ArrayList<>()) | ||
| .add(error); | ||
| } | ||
|
|
||
| private EvaluationResult mergeEvaluationResults( | ||
| EvaluationResult origEvaluationResult, List<EvaluationResult> measureObservationResults) { | ||
| final EvaluationResult evaluationResult = new EvaluationResult(); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There can be more information coming back from a message in CQL than just the message, it may have additional information, should we also expose that information?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't expose it for errors either, and this will require CQL changes. What are you looking to capture?