Skip to content

[MODEUS-220] Use order-insensitive comparison for R5.0 pipe-delimited report attribute values#212

Merged
alb3rtino merged 1 commit into
masterfrom
MODEUS-220
Feb 26, 2026
Merged

[MODEUS-220] Use order-insensitive comparison for R5.0 pipe-delimited report attribute values#212
alb3rtino merged 1 commit into
masterfrom
MODEUS-220

Conversation

@alb3rtino
Copy link
Copy Markdown
Contributor

https://folio-org.atlassian.net/browse/MODEUS-220

Purpose

R5.0 COUNTER reports include pipe-delimited attribute values such as Data_Type|Section_Type|YOP|Access_Type|Access_Method. The previous validation logic compared these values as plain strings, which caused valid reports to be rejected when a provider returned the same attributes in a different order within the pipe-delimited string.

Approach

  • Extracted the attribute matching logic from the inline HashSet.containsAll() check into dedicated allAttributesMatch and attributesMatch methods in ProcessorHelper.
  • For Attributes_To_Show values, the comparison now splits on | and compares the resulting elements as sets, making the check order-independent.
  • Added test cases for reordered attribute values and for duplicate elements (which should be rejected).

@alb3rtino alb3rtino requested a review from slaemmer February 25, 2026 11:08
@alb3rtino alb3rtino changed the title [MODEUS-220] Compare pipe-delimited R5.0 report attribute values as sets [MODEUS-220] Use order-insensitive comparison for R5.0 pipe-delimited report attribute values Feb 25, 2026
R5.0 report validation rejected valid reports when providers returned pipe-delimited attribute values in a different order than expected.
@sonarqubecloud
Copy link
Copy Markdown

@alb3rtino alb3rtino merged commit 375f3b5 into master Feb 26, 2026
28 checks passed
@alb3rtino alb3rtino deleted the MODEUS-220 branch February 26, 2026 19:45
alb3rtino added a commit to folio-org/mod-erm-usage-counter that referenced this pull request Mar 11, 2026
…ic (#105)

https://folio-org.atlassian.net/browse/MODEUSCNT-70

## Purpose

The report merging logic in both COUNTER 5.0 and 5.1 modules performs
order-sensitive comparisons on report header attributes. This causes
merge failures when attribute arrays or pipe-delimited values appear in
different orders across reports that are otherwise equivalent. The
validation code paths were already fixed in #103 and
[mod-erm-usage#212](folio-org/mod-erm-usage#212),
but the merging code paths were not covered.

## Approach

- COUNTER 5.1 `ReportMerger`: Apply `ReportValidator.normalize()` to
report headers before the distinctness check during merge validation.
Made `normalize()` package-private and added recursion into nested
objects so it handles the full header structure.
- COUNTER 5.0 `ReportsMerger`: Replace `distinct()` with a
`distinctByNormalized()` predicate that normalizes pipe-delimited values
(split, sort, rejoin) before deduplication, applied to both report
attributes and report filters.
- Added tests in both modules covering merge scenarios with reordered
attributes.
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.

2 participants