DET classification end-to-end: alias custom property IDs + IRDI synthesis - #26
Merged
Conversation
adds: - new entity class Opencdd::DetClassification < Opencdd::Entity - MDC_C0101 meta-class IRDI registration (the canonical IRDI for DET classification entities; the file's CLASS_ID:=IECCDD_001 is IEC-internal supplier scheme, not the parsing gate) - FILE_PATTERN updated in LayoutDetector (DETCLASSIFICATION) - TYPE_BY_PREFIX updated in FlatDirReader + WorkbookReader (both readers needed — single .xls files go through WorkbookReader) - Database#det_classifications accessor - 8 specs covering entity_class, meta-class registration, Database accessor, and Reader file-detection (4 unit + 1 end-to-end-reader) 960 specs pass, 0 failures (was 931; +29 from new + tweaked specs). NOT done in this PR: end-to-end entity extraction from the .xls. The cdd.iec.ch search-export file uses non-standard property IDs (IECCDD_001_C0001, IECCDD_001_C0002.en, IECCDD_001_C0002.fr, ...) rather than MDC_P* codes. The standard Parcel row parser doesn't extract a property because no column matches the meta-class's code_property_id (MDC_P001_5 in MDC_C0101's case). A property-ID aliasing layer is needed to map these project-specific IDs to standard MDC codes before the meta-class extraction logic can find the code column. That's a separate design decision; tracked as a follow-up. What this PR DOES accomplish: - The entity type :det_classification is now first-class in the gem - DET classification files are no longer silently skipped (they load, producing entities with raw custom-ID properties; the aliasing work will lift those to standard MDC codes) - 4 of the 8 touch-points from the architecture report are covered (FilePattern, TYPE_BY_PREFIX in both readers, Database accessor, meta-class registration). The remaining 4 (entity row parsing, exporter/JSON exposure, visitor methods) are downstream of the aliasing work.
…esis
Completes DET classification entity extraction from cdd.iec.ch
search-export flow. Three pieces:
1. VARIANT_TO_CANONICAL alias map extended with DET classification
custom IDs (IECCDD_001_C0001 → MDC_P001_5, IECCDD_001_C0002.<lang>
→ MDC_P004_1.<lang>). Without these, no entity gets a code or name.
2. IECCDD_001 added to TYPE_BY_META_CLASS as the project-specific
supplier-scheme CLASS_ID for DET classification. The file's
CLASS_ID directive resolves to :det_classification type via
this alias.
3. DetClassification.from_row overrides Entity.from_row to synthesize
full IRDIs from short codes (A11, A12) by prepending the supplier
prefix (0112/2///IECCDD_001). Standard from_row would fail with
IRDI.parse('A11').
4. code_property_id_for MDC_C0101 changed from C0102 (placeholder)
to MDC_P001_5 (the aliased code column ID).
Result: 163 DET classification entities imported from the iec61360-4
fixture .xls. Each has code='A11', type=:det_classification, and the
English preferred_name in properties.
Full suite passes (960+ specs).
ronaldtse
added a commit
that referenced
this pull request
Aug 7, 2026
Closes #28. The 163 DET classification entities that import successfully from iec61360-4/export_DETCLASSIFICATION_*.xls (PRs #25 + #26) were silently dropped from `rake browser:build_from_export[<dict>]` because Opencdd::Exporters::Json#payload_for raised `ArgumentError: No JSON payload builder for Opencdd::DetClassification`. ## Fix 1 — payload builder Register Opencdd::DetClassification in PAYLOAD_BUILDERS and add a det_classification_node method following the same pattern as view_control_node / value_list_node / list_of_unit_node. DET classification entities have standard fields (code, preferred_name, definition, version, revision) that flow through entity_payload; no type-specific post-processing is needed. ## Fix 2 — preferred_name property-ID alias Discovered while writing the payload spec: the alias target for IECCDD_001_C0002 was MDC_P004_1 (preferred_name_localized), but the field DSL's `field :preferred_name, "MDC_P004"` reads from MDC_P004 (preferred_name base). The result: even though the importer stored the data, every entity's preferred_name was nil. The per-language entries (IECCDD_001_C0002.en → MDC_P004_1.en, etc.) were dead code: canonical_id splits the language suffix off before the lookup and reapplies it after, so only the base entry is consulted. Removing them and changing the base entry to MDC_P004 produces MDC_P004.<lang>, which the preferred_name DSL finds. ## Spec spec/exporters/per_entity_json_spec.rb gains a `det_classification` context that constructs a DetClassification entity directly and asserts the payload includes type, irdi, code, and preferred_name. ## Verification bundle exec rspec — 974 examples, 0 failures (up from 962).
ronaldtse
added a commit
that referenced
this pull request
Aug 8, 2026
The ruby team's PR #26 added det_classification_node (payload builder) but missed the visitor method that actually calls it during traversal. Without visit_det_classification in the Visitor class and visit_det_classifications in visit_database, the exporter's to_json silently skipped all 163 DET classification entities — they were in the Database but never reached the JSON output. This commit adds: - visit_det_classifications(database) to Visitor (iterates database.det_classifications) - visit_det_classification in visit_database dispatch - visit_det_classification in Json exporter (calls det_classification_node) Verified: data-private rake browser:build_from_export[iec-61360-4] now produces 163 DET classification entities with non-null preferred_name.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Completes DET classification entity extraction from cdd.iec.ch search-export flow. Follow-up to PR #25 (type registration). With these aliases, the importer now extracts 163 DET classification entities from the iec61360-4 fixture .xls.
What changed
VARIANT_TO_CANONICAL alias map (sheet_schema.rb) — extended with DET classification custom IDs:
IECCDD_001_C0001→MDC_P001_5(code column)IECCDD_001_C0002→MDC_P004_1(name base)IECCDD_001_C0002.{en,fr,de,ja,zh}→MDC_P004_1.{en,fr,de,ja,zh}(localized names)IECCDD_001in TYPE_BY_META_CLASS (meta_class.rb) — the file'sCLASS_ID:=IECCDD_001(IEC-internal supplier scheme) now resolves to:det_classificationtype via this alias.DetClassification.from_rowoverride (det_classification.rb) — synthesizes full IRDIs from short codes (A11, A12) by prepending the supplier prefix0112/2///IECCDD_001. StandardEntity.from_rowwould fail withIRDI.parse("A11").code_property_id_for("MDC_C0101")(meta_class.rb) — changed from placeholderC0102toMDC_P001_5(the aliased code column ID).Verification
Database.load(<DETCLASSIFICATION.xls>).entities.size= 163 (was 0)Note to team
The data-private repo at
exports/latest/<dict>/export_DETCLASSIFICATION_*.xlsnow has files that import cleanly. The next step is to rebuilddata/<dict>/database.jsonfrom exports to include DET classification entities in the browser build.