Skip to content

Validate ADL 2.4 at-coded archetypes#799

Open
MattijsK wants to merge 8 commits into
adl_2.4_supportfrom
791_validate_2.4_at_coded_adl
Open

Validate ADL 2.4 at-coded archetypes#799
MattijsK wants to merge 8 commits into
adl_2.4_supportfrom
791_validate_2.4_at_coded_adl

Conversation

@MattijsK

@MattijsK MattijsK commented Jun 18, 2026

Copy link
Copy Markdown
Collaborator

Fixes #791

Validate ADL 2.4 at-coded archetypes

Summary

Teaches the archetype validator to validate ADL 2.4 at-coded archetypes —
those whose structural node identifiers use the at prefix (e.g. at0000,
at0000.1) instead of id (id1, id1.1). Builds on the existing ADL 2.4
grammar (#659) and ADL 1.4 → ADL 2.4 at-coded converter (#658); this PR makes the
converter's output (and hand-written at-coded archetypes) pass validation,
including flattening and specialization.

Behaviour / configuration

A new ArchetypeValidationSettings.nodeIdCodeSystemValidation option controls which
node-id code system is accepted:

Value Meaning
ID_CODED (default) Only id-coded archetypes — fully backwards compatible
AT_CODED Only at-coded archetypes
AUTO_DETECT Detect the code system from the root node id and validate the rest against it

New rule: an archetype must use a single, consistent node-id code system, and
it must match the configured/detected one. Violations (mixed systems, or wrong
system for the configuration) are reported via a new error type
INVALID_NODE_ID_CODE_SYSTEM.

Changes

  • NodeIdCodeSystemValidation enum + setting (default ID_CODED).
  • ArchetypeValidationBase: expectsAtCodedNodeIds() resolver (auto-detect from
    root prefix) and a code-system-aware code-format check.
  • CodeSystemValidation (new, phase 0): enforces the single/consistent code-system rule.
  • BasicChecks: root-node pattern is code-system-aware (at0000(.1)* vs id1(.1)*).
  • CodeValidation / BasicTerminologyValidation: terminology lookups and
    code-format/term-binding checks no longer assume the id prefix.
  • AOMUtils (codesConformant, pathAtSpecializationLevel): accept the
    zero-padded codes at-coded ADL 2.4 retains from ADL 1.4 (uses isValidADL14Code,
    a strict superset of isValidCode, so id-coded behaviour is unchanged). This is
    what makes at-coded flattening and specialization validation work.
  • ErrorType.INVALID_NODE_ID_CODE_SYSTEM added.
  • i18n: English/Dutch messages for the new strings.

Tests

  • AtCodedArchetypeValidationTest (13 tests): at-coded passes under AT_CODED /
    AUTO_DETECT and is rejected under the default ID_CODED (incl. via the no-settings
    default validator); id-coded vice-versa; mixed systems rejected (both AUTO_DETECT
    and explicit modes); malformed at-coded root; and a specialized at-coded archetype
    that validates and flattens
    end-to-end (OBSERVATION + CLUSTER fixtures).
  • AOMUtilsTest.codesConformant: direct unit test of the core conformance change
    (id-coded, zero-padded at-coded, and prefix-collision non-conformance).

Compatibility & scope notes

  • Default is ID_CODED, so existing behaviour is unchanged; full :aom/:tools
    suites pass.
  • VARCN is retained for the root-node-form check (with an at-coded message variant);
    the new code-system-consistency rule uses the dedicated INVALID_NODE_ID_CODE_SYSTEM.
  • A few seldom-used helpers (ArchetypeTerminology.idCodes(),
    hasIdCodeInAllLanguages()) still assume id-coded forms but aren't on the validation
    path; can be revisited if at-coded OPT generation needs them later.

MattijsK added 2 commits June 18, 2026 16:57
Add support for validating at-coded ADL 2.4 archetypes, where structural
node identifiers use the 'at' prefix (e.g. at0000) instead of 'id'.

- Add NodeIdCodeSystemValidation setting {ID_CODED, AT_CODED, AUTO_DETECT},
  defaulting to ID_CODED for backwards compatibility. AUTO_DETECT picks the
  code system from the root node id.
- Add CodeSystemValidation enforcing a single, consistent node-id code system
  that matches the configured/detected one, reported via the new
  INVALID_NODE_ID_CODE_SYSTEM error type.
- Make BasicChecks root-node pattern and CodeValidation terminology lookup
  code-system aware.
- Accept zero-padded at-coded codes (retained from ADL 1.4) in the structural
  conformance/path helpers codesConformant and pathAtSpecializationLevel, so
  flattening and specialization validation work for at-coded archetypes.
- Add Dutch translations for the new messages.
@codecov

codecov Bot commented Jun 22, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 88.52459% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 72.34%. Comparing base (be6de6a) to head (a5b9814).

Files with missing lines Patch % Lines
...ypevalidator/validations/CodeSystemValidation.java 88.00% 1 Missing and 2 partials ⚠️
...ie/archetypevalidator/ArchetypeValidationBase.java 66.66% 0 Missing and 2 partials ⚠️
...main/java/com/nedap/archie/aom/utils/AOMUtils.java 87.50% 0 Missing and 1 partial ⚠️
...archetypevalidator/validations/CodeValidation.java 66.66% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@                  Coverage Diff                  @@
##             adl_2.4_support     #799      +/-   ##
=====================================================
+ Coverage              72.28%   72.34%   +0.06%     
- Complexity              7234     7267      +33     
=====================================================
  Files                    680      682       +2     
  Lines                  23420    23471      +51     
  Branches                3796     3805       +9     
=====================================================
+ Hits                   16929    16981      +52     
+ Misses                  4753     4752       -1     
  Partials                1738     1738              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@MattijsK
MattijsK marked this pull request as ready for review June 23, 2026 08:54
@VeraPrinsen
VeraPrinsen self-requested a review June 25, 2026 06:36

@VeraPrinsen VeraPrinsen left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

As discussed, the only thing not so clear in this PR is the naming of certain (old) variables and methods that should be updated (in another PR).

For example:

  • AOMUtils
    • idCodePattern -> rename to something like nonZeroPaddedCodePattern
    • isValidCode() -> Deprecate this and use the isValidNonZeroPaddedCode instead
    • adl14CodePattern -> Is the generic pattern that matches all codes (zero padded and non zero padded), rename to something like nodeCodePattern
    • isValueCode -> Is not only a code for values of valueSets anymore, also for generic nodes in the zero-padded archetypes, maybe rename to isAtCode

If public methods need to be renamed, instead create a new method and deprecate the old method.

I18n.t("The node id is not in the form at0000.1....1: {0}", archetype.getDefinition().getNodeId())
);
}
} else if(!archetype.getDefinition().getNodeId().matches("id1(\\.1)*")) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Can rootNodeId be null (which returns false for expectsAtCodedNodeIds())? What if it is, won't this check throw a NullPointerException? Or can we assume the rootNodeId is never null, because otherwise it wouldn't be a valid archetype?

}
if (AOMUtils.isIdCode(nodeId)) {
idCodedNodeIdSeen = true;
} else if (nodeId.startsWith(AdlCodeDefinitions.VALUE_CODE_LEADER)) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
} else if (nodeId.startsWith(AdlCodeDefinitions.VALUE_CODE_LEADER)) {
} else if (AOMUtils.isValueCode(nodeId)) {

I think this method still can be used here, as we probably are going to change it's name in a future PR

* id-code; for at-coded archetypes the node id is an at-code, which shares its prefix with value codes, so a plain
* code lookup is used.
*/
private boolean hasNodeId(ArchetypeTerminology terminology, String nodeId) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Is this extra check needed as in the CodeSystemValidation it is already checked that an non-at-coded archetype only has id codes. I feel like the new CodeSystemValidation has taken over that check from this validation and that this validation file only needs to check if all codes are also in the terminology.

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