Skip to content

#13883 - Fixed IGRA inputs value change listeners#13884

Open
raulbob wants to merge 3 commits intodevelopmentfrom
bugfix-13883-pathogentestform_igra_values_listeners
Open

#13883 - Fixed IGRA inputs value change listeners#13884
raulbob wants to merge 3 commits intodevelopmentfrom
bugfix-13883-pathogentestform_igra_values_listeners

Conversation

@raulbob
Copy link
Contributor

@raulbob raulbob commented Mar 16, 2026

Fixes #13883 :

  • Refactored duplicated listeners for IGRA inputs into two listeners
  • Fixed error caused by locale conversions with IGRA numeric inputs

Summary by CodeRabbit

  • Refactor

    • Consolidated IGRA numeric-to-boolean synchronization into reusable listeners for consistent form behavior.
    • Threshold (>10) now reliably derives GT10 indicators when not explicitly set.
  • Bug Fixes

    • Added validation and error handling for invalid numeric input to prevent inconsistent values and clear invalid entries safely.
  • Documentation

    • Added comments describing listener behavior and usage.

- Refactored duplicated listeners for IGRA inputs into two listeners
- Fixed error caused by locale conversions with IGRA numeric inputs
@coderabbitai
Copy link

coderabbitai bot commented Mar 16, 2026

📝 Walkthrough

Walkthrough

Replaces inline ValueChangeListener lambdas in PathogenTestForm with two new protected static inner listeners to centralize numeric-to-boolean synchronization for Tuberculosis IGRA fields, add numeric validation/conversion, derive GT10 when unset, and handle invalid input and ReadOnlyException cases. (34 words)

Changes

Cohort / File(s) Summary
PathogenTestForm — Tuberculosis IGRA listeners & wiring
sormas-ui/src/main/java/de/symeda/sormas/ui/samples/PathogenTestForm.java
Added two protected static inner classes (TuberculosisIGRAInputValueChangeListener, TuberculosisIGRAGT10InputValueChangeListener), replaced inline value-change lambdas for IGRA numeric fields and GT10 checkboxes with these listeners, implemented numeric conversion/validation, GT10 ↔ input synchronization (derive GT10 if unset), input clearing with ReadOnlyException handling, and added related imports.

Sequence Diagram(s)

(Skipped — changes are localized UI listener refactors and do not introduce a multi-component sequential flow that meets diagram criteria.)

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Suggested reviewers

  • obinna-h-n
  • KarnaiahPesula
  • roldy

Poem

🐰 I hopped through fields where numbers hide,
Tubes and GT10 now walk side by side.
Listeners tidy the value-bright night,
No more disappearing tens in sight. ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: refactoring and fixing IGRA input value change listeners, which matches the primary objective of the PR.
Description check ✅ Passed The description includes the linked issue number and explains both the refactoring and the bug fix, matching the template requirement and providing sufficient context.
Linked Issues check ✅ Passed The code changes directly address issue #13883 by refactoring listeners to fix the error caused by locale conversions with IGRA numeric inputs that was clearing the value 10.
Out of Scope Changes check ✅ Passed All changes are scoped to PathogenTestForm.java and focus exclusively on the IGRA listener refactoring and bug fix specified in issue #13883.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch bugfix-13883-pathogentestform_igra_values_listeners
📝 Coding Plan
  • Generate coding plan for human review comments

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@sormas-ui/src/main/java/de/symeda/sormas/ui/samples/PathogenTestForm.java`:
- Around line 1067-1081: The backing GT10 fields are tri-state and null must be
preserved, so do not derive/write a boolean back when the numeric "checked"
value is null; in both branches around igraGT10Field (the primitive-branch using
Boolean.TRUE.equals(igraGT10Field.getValue()) and the collection-branch using
currentSet.contains(Boolean.TRUE)), add an early guard so you only
compute/compare/set the GT10 field when checked != null, otherwise leave
igraGT10Field untouched; ensure the collection-branch still constructs a
HashSet<Boolean> and sets it only when checked is non-null and differs from the
current state (same change needed at the other occurrence around lines
1158-1171).
- Around line 1036-1044: In PathogenTestForm, update the numeric conversion
logic that builds a converter via ConverterUtil.getConverter and calls
convertToModel so it passes the field/UI locale (e.g., use
igraInputField.getLocale() or the UI locale) instead of null, and wrap the
convertToModel call in a try/catch for ConversionException to translate
conversion failures into a validation error on igraInputField (or add the error
to igraValueProp) so exceptions do not escape the listener; apply the same
change to the identical block around lines 1128-1134.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 0f887afd-9bb4-402b-b27c-bf692c1c7b2f

📥 Commits

Reviewing files that changed from the base of the PR and between a3b69fb and 19a3e00.

📒 Files selected for processing (1)
  • sormas-ui/src/main/java/de/symeda/sormas/ui/samples/PathogenTestForm.java

@sormas-vitagroup
Copy link
Contributor

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@sormas-ui/src/main/java/de/symeda/sormas/ui/samples/PathogenTestForm.java`:
- Around line 46-52: The class uses the nested type Property.ValueChangeListener
but only imports Property, so add an explicit import for the nested interface
(import com.vaadin.v7.data.Property.ValueChangeListener;) to PathogenTestForm so
references to ValueChangeListener compile; update imports at the top of
PathogenTestForm.java next to the other com.vaadin.v7.data imports (used by
BeanFieldGroup, BeanItem, Converter, etc.).

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: c3ef9b0d-be35-45ce-907d-b658c92e5759

📥 Commits

Reviewing files that changed from the base of the PR and between 19a3e00 and fa77747.

📒 Files selected for processing (1)
  • sormas-ui/src/main/java/de/symeda/sormas/ui/samples/PathogenTestForm.java

@sormas-vitagroup
Copy link
Contributor

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (2)
sormas-ui/src/main/java/de/symeda/sormas/ui/samples/PathogenTestForm.java (2)

1208-1210: Minor typo in comment.

Line 1209: "an greater" → "and greater".

-			|| (!checked && igraNewValue != null && igraNewValue.floatValue() > 10) // not checked but value is filled in an greater than 10
+			|| (!checked && igraNewValue != null && igraNewValue.floatValue() > 10) // not checked but value is filled in and greater than 10
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@sormas-ui/src/main/java/de/symeda/sormas/ui/samples/PathogenTestForm.java`
around lines 1208 - 1210, Fix the typo in the inline comment inside
PathogenTestForm near the conditional using variables checked and igraNewValue:
change "an greater" to "and greater" so the comment reads "...not checked but
value is filled in and greater than 10)". Ensure you update only the comment
text adjacent to that if condition in the method containing this conditional.

1181-1190: Consider initializing checked to null for clarity.

The initialization to false on line 1181 is immediately overwritten, but null better represents the "unknown" semantic before the field value is examined.

Suggested improvement
-		Boolean checked = false;
+		Boolean checked = null;
 
 		// value can be true or false/null(presumed false)
 		if (!isCollection) {
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@sormas-ui/src/main/java/de/symeda/sormas/ui/samples/PathogenTestForm.java`
around lines 1181 - 1190, The local variable checked in PathogenTestForm (inside
the block handling igraGT10Field) should be initialized to null rather than
false to reflect the "unknown" semantic before reading the field; change the
declaration of checked to Boolean checked = null and keep the existing branches
that assign null/Boolean.TRUE/Boolean.FALSE based on igr aGT10Field.getValue()
(refer to the igraGT10Field handling code and the Collection<?> set branch) so
the initial value is not misleading or overwritten.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@sormas-ui/src/main/java/de/symeda/sormas/ui/samples/PathogenTestForm.java`:
- Around line 1208-1210: Fix the typo in the inline comment inside
PathogenTestForm near the conditional using variables checked and igraNewValue:
change "an greater" to "and greater" so the comment reads "...not checked but
value is filled in and greater than 10)". Ensure you update only the comment
text adjacent to that if condition in the method containing this conditional.
- Around line 1181-1190: The local variable checked in PathogenTestForm (inside
the block handling igraGT10Field) should be initialized to null rather than
false to reflect the "unknown" semantic before reading the field; change the
declaration of checked to Boolean checked = null and keep the existing branches
that assign null/Boolean.TRUE/Boolean.FALSE based on igr aGT10Field.getValue()
(refer to the igraGT10Field handling code and the Collection<?> set branch) so
the initial value is not misleading or overwritten.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 398b353a-f44d-44af-ab9b-450032a15dbd

📥 Commits

Reviewing files that changed from the base of the PR and between fa77747 and b34f40c.

📒 Files selected for processing (1)
  • sormas-ui/src/main/java/de/symeda/sormas/ui/samples/PathogenTestForm.java

@sormas-vitagroup
Copy link
Contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PathogenTestForm IGRA TubeNil 10 causes input box to be cleared - PathogenTestForm

2 participants