#14084 - Ensure default values for customizable fields #14129
Conversation
…ntact entities #14086 - Added better handling for default value edit and validations
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughDefault customizable-field values are now created during backend saves for cases, contacts, epi data, and exposures, with disease-aware visibility filtering. The UI field-group component also now initializes and exports values using metadata defaults, and tests cover the new behaviors. ChangesDefault Customizable Field Values
Estimated code review effort: 4 (Complex) | ~45 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In
`@sormas-backend/src/main/java/de/symeda/sormas/backend/customizablefield/CustomizableFieldValueService.java`:
- Around line 109-130: `ensureDefaultValuesForEntity` is creating defaults for
fields that may be hidden by disease-specific visibility rules. Update this
method to apply the same `CustomizableFieldVisibilityContext`/visibility check
used by the UI before calling `createNewValue` and `ensurePersisted`, so only
visible `CustomizableFieldMetadata` entries from `getActiveFieldsForContext` are
persisted. Use the existing metadata visibility restrictions in
`CustomizableFieldValueService` and `CustomizableFieldMetadataService` to skip
fields that are not visible for the entity’s disease.
In
`@sormas-ui/src/main/java/de/symeda/sormas/ui/configuration/customizablefield/CustomizableFieldEditForm.java`:
- Around line 184-186: The default value validation in CustomizableFieldEditForm
is using dto.getFieldType(), which can be stale before binder.writeBean(dto)
runs. Update the validator for the default value field to validate against the
currently selected field type from the bound form value/component state instead
of the DTO, and use the same selected type when building
getDefaultValueErrorMessage so NUMBER/DECIMAL defaults are checked correctly
before save.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 580384d7-5c94-4d80-9400-912caac0b135
📒 Files selected for processing (8)
sormas-backend/src/main/java/de/symeda/sormas/backend/caze/CaseFacadeEjb.javasormas-backend/src/main/java/de/symeda/sormas/backend/contact/ContactFacadeEjb.javasormas-backend/src/main/java/de/symeda/sormas/backend/customizablefield/CustomizableFieldValueService.javasormas-backend/src/main/java/de/symeda/sormas/backend/epidata/EpiDataFacadeEjb.javasormas-backend/src/test/java/de/symeda/sormas/backend/customizablefield/CustomizableFieldFacadeEjbTest.javasormas-ui/src/main/java/de/symeda/sormas/ui/configuration/customizablefield/CustomizableFieldEditForm.javasormas-ui/src/main/java/de/symeda/sormas/ui/utils/components/CustomizableFieldsGroup.javasormas-ui/src/test/java/de/symeda/sormas/ui/utils/components/CustomizableFieldsGroupTest.java
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In
`@sormas-backend/src/main/java/de/symeda/sormas/backend/customizablefield/CustomizableFieldValueService.java`:
- Around line 149-156: The visibility filtering in CustomizableFieldValueService
is inverted, so the default-value creation loop skips visible fields and
persists hidden ones. Update the check around parseVisibilityRestrictions and
matches(visibilityContext) so the flow continues only when the restrictions do
not match the current context, and add a null guard for the parsed
CustomizableFieldVisibilityRestrictions since blank visibility strings can
return null. Keep the fix localized to the metadata visibility handling in the
default-value generation path.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 1302ed65-810d-44d3-93a1-bb5515858385
📒 Files selected for processing (5)
sormas-backend/src/main/java/de/symeda/sormas/backend/caze/CaseFacadeEjb.javasormas-backend/src/main/java/de/symeda/sormas/backend/contact/ContactFacadeEjb.javasormas-backend/src/main/java/de/symeda/sormas/backend/customizablefield/CustomizableFieldMetadataFacadeEjb.javasormas-backend/src/main/java/de/symeda/sormas/backend/customizablefield/CustomizableFieldValueService.javasormas-backend/src/main/java/de/symeda/sormas/backend/epidata/EpiDataFacadeEjb.java
🚧 Files skipped from review as they are similar to previous changes (2)
- sormas-backend/src/main/java/de/symeda/sormas/backend/contact/ContactFacadeEjb.java
- sormas-backend/src/main/java/de/symeda/sormas/backend/caze/CaseFacadeEjb.java
…sibility restriction checks
#14086 - Added better handling for default value edit and validations
Summary by CodeRabbit
null.