-
Notifications
You must be signed in to change notification settings - Fork 162
RSV bug fixes and other minor issues #13630
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
Changes from all commits
e7496af
922b704
cb73faf
d0c47e4
f09355c
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 |
|---|---|---|
|
|
@@ -41,6 +41,11 @@ public ClassificationExposureCriteriaDto() { | |
| super(); | ||
| } | ||
|
|
||
| public ClassificationExposureCriteriaDto(ExposureType exposureType) { | ||
| super(); | ||
| this.exposureType = exposureType; | ||
| } | ||
|
|
||
| public ClassificationExposureCriteriaDto(String propertyId, ExposureType exposureType, Object... propertyValues) { | ||
|
|
||
| super(propertyId, propertyValues); | ||
|
|
@@ -56,30 +61,35 @@ protected Class<? extends EntityDto> getInvokeClass() { | |
| public boolean eval(CaseDataDto caze, PersonDto person, List<PathogenTestDto> pathogenTests, List<EventDto> events, Date lastVaccinationDate) { | ||
|
|
||
| for (ExposureDto exposure : caze.getEpiData().getExposures()) { | ||
| if (exposureType != null && exposure.getExposureType() != exposureType) { | ||
| continue; | ||
| } | ||
|
|
||
| Method method; | ||
| try { | ||
| method = getInvokeClass().getMethod("get" + propertyId.substring(0, 1).toUpperCase() + propertyId.substring(1)); | ||
| } catch (NoSuchMethodException e) { | ||
| // To handle a case, like an exposure type present in the case, we should return true | ||
| // This case is to handle the Giardiasis and Cryptosporidiosis diseases where only the exposure available but not its related property. | ||
| if (propertyId == null && exposure.getExposureType() == exposureType) { | ||
| return true; | ||
| } else { | ||
| if (exposureType != null && exposure.getExposureType() != exposureType) { | ||
| continue; | ||
| } | ||
| Method method; | ||
| try { | ||
| method = getInvokeClass().getMethod("is" + propertyId.substring(0, 1).toUpperCase() + propertyId.substring(1)); | ||
| } catch (NoSuchMethodException newE) { | ||
| throw new RuntimeException(newE); | ||
| method = getInvokeClass().getMethod("get" + propertyId.substring(0, 1).toUpperCase() + propertyId.substring(1)); | ||
| } catch (NoSuchMethodException e) { | ||
| try { | ||
| method = getInvokeClass().getMethod("is" + propertyId.substring(0, 1).toUpperCase() + propertyId.substring(1)); | ||
| } catch (NoSuchMethodException newE) { | ||
| throw new RuntimeException(newE); | ||
| } | ||
| } catch (SecurityException e) { | ||
| throw new RuntimeException(e); | ||
| } | ||
| } catch (SecurityException e) { | ||
| throw new RuntimeException(e); | ||
| } | ||
|
|
||
| try { | ||
| Object value = method.invoke(exposure); | ||
| if (propertyValues.contains(value) || CollectionUtils.isEmpty(propertyValues) && YesNoUnknown.YES.equals(value)) { | ||
| return true; | ||
| try { | ||
| Object value = method.invoke(exposure); | ||
| if (propertyValues.contains(value) || CollectionUtils.isEmpty(propertyValues) && YesNoUnknown.YES.equals(value)) { | ||
| return true; | ||
| } | ||
| } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException | SecurityException e) { | ||
| throw new RuntimeException(e); | ||
| } | ||
| } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException | SecurityException e) { | ||
| throw new RuntimeException(e); | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -90,9 +100,16 @@ public boolean eval(CaseDataDto caze, PersonDto person, List<PathogenTestDto> pa | |
| public String buildDescription() { | ||
|
|
||
| StringBuilder sb = new StringBuilder(); | ||
| sb.append(I18nProperties.getPrefixCaption(ExposureDto.I18N_PREFIX, propertyId)); | ||
| if (exposureType != null) { | ||
| sb.append(" ").append(I18nProperties.getString(Strings.classificationCriteriaForExposureType)).append(exposureType.toString()); | ||
| if (propertyId != null) { | ||
| sb.append(I18nProperties.getPrefixCaption(ExposureDto.I18N_PREFIX, propertyId)); | ||
| sb.append(" ").append(I18nProperties.getString(Strings.classificationCriteriaForExposureType)).append(exposureType.toString()); | ||
| } else { | ||
| sb.append(I18nProperties.getString(Strings.classificationCriteriaRestrictedToExposureType)) | ||
| .append(" ") | ||
| .append(exposureType.toString()); | ||
| } | ||
|
Comment on lines
+104
to
+111
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. 🧩 Analysis chainVerify i18n string keys exist in resource files. The description logic correctly handles both cases (with and without
🏁 Script executed: #!/bin/bash
# Verify the i18n string keys exist in the codebase
echo "Searching for classificationCriteriaForExposureType..."
rg -n "classificationCriteriaForExposureType" --type java --type properties
echo -e "\nSearching for classificationCriteriaRestrictedToExposureType..."
rg -n "classificationCriteriaRestrictedToExposureType" --type java --type propertiesLength of output: 189 🏁 Script executed: #!/bin/bash
# Find properties files and search for the i18n keys
echo "Finding all .properties files..."
fd -e properties
echo -e "\n=== Searching for classificationCriteriaForExposureType ==="
rg -n "classificationCriteriaForExposureType"
echo -e "\n=== Searching for classificationCriteriaRestrictedToExposureType ==="
rg -n "classificationCriteriaRestrictedToExposureType"
echo -e "\n=== Checking Strings enum definitions ==="
rg -n "classificationCriteria" --type java -A 1 -B 1 | head -50Length of output: 38589 🏁 Script executed: #!/bin/bash
# Verify classificationCriteriaRestrictedToExposureType exists in all language property files
echo "=== Searching for classificationCriteriaRestrictedToExposureType in language files ==="
rg -c "classificationCriteriaRestrictedToExposureType" sormas-api/src/main/resources/strings*.properties
echo -e "\n=== Total count ==="
rg "classificationCriteriaRestrictedToExposureType" sormas-api/src/main/resources/ | wc -l
echo -e "\n=== Files WITH the key ==="
fd "strings.*properties" sormas-api/src/main/resources/ --exec rg -l "classificationCriteriaRestrictedToExposureType" {} \; | wc -lLength of output: 190 Add translations for The verification reveals a critical i18n gap: Add the key and its translations to each 🤖 Prompt for AI Agents |
||
|
|
||
| } | ||
|
|
||
| return sb.toString(); | ||
|
|
||
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.
Potential NullPointerException when both propertyId and exposureType are null.
The code assumes
propertyIdis non-null when reaching line 74, but this isn't guaranteed. If an instance is created using the default constructor (line 40) or with both fields null, and the exposure has a non-null type, the code will throw a NullPointerException when attemptingpropertyId.substring(...).Trace:
propertyIdandexposureTypeare nullpropertyId.substring(...)→ NPEConsider adding a validation check:
} else { if (exposureType != null && exposure.getExposureType() != exposureType) { continue; } + if (propertyId == null) { + continue; // or throw IllegalStateException + } Method method; try {Alternatively, validate in constructors that at least one of
propertyIdorexposureTypeis non-null.🤖 Prompt for AI Agents