Validate ADL 2.4 at-coded archetypes#799
Conversation
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 Report❌ Patch coverage is 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. 🚀 New features to boost your workflow:
|
Because that is more correct
VeraPrinsen
left a comment
There was a problem hiding this comment.
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)*")) { |
There was a problem hiding this comment.
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)) { |
There was a problem hiding this comment.
| } 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) { |
There was a problem hiding this comment.
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.
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
atprefix (e.g.at0000,at0000.1) instead ofid(id1,id1.1). Builds on the existing ADL 2.4grammar (#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.nodeIdCodeSystemValidationoption controls whichnode-id code system is accepted:
ID_CODED(default)AT_CODEDAUTO_DETECTNew 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
NodeIdCodeSystemValidationenum + setting (defaultID_CODED).ArchetypeValidationBase:expectsAtCodedNodeIds()resolver (auto-detect fromroot 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)*vsid1(.1)*).CodeValidation/BasicTerminologyValidation: terminology lookups andcode-format/term-binding checks no longer assume the
idprefix.AOMUtils(codesConformant,pathAtSpecializationLevel): accept thezero-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 iswhat makes at-coded flattening and specialization validation work.
ErrorType.INVALID_NODE_ID_CODE_SYSTEMadded.Tests
AtCodedArchetypeValidationTest(13 tests): at-coded passes underAT_CODED/AUTO_DETECTand is rejected under the defaultID_CODED(incl. via the no-settingsdefault validator); id-coded vice-versa; mixed systems rejected (both
AUTO_DETECTand 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
ID_CODED, so existing behaviour is unchanged; full:aom/:toolssuites pass.
VARCNis 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.ArchetypeTerminology.idCodes(),hasIdCodeInAllLanguages()) still assume id-coded forms but aren't on the validationpath; can be revisited if at-coded OPT generation needs them later.