Skip to content

Add JSON payload builder for DetClassification (163 entities silently dropped) #28

Description

@ronaldtse

Proposal: Add JSON payload builder for DetClassification

For: opencdd-ruby team
From: data-private session 2026-08-07
Depends on: PRs #25 (DET type registration) + #26 (DET aliasing) — both merged

Problem

Opencdd::Exporters::Json#payload_for has no builder for Opencdd::DetClassification. When data-private runs rake browser:build_from_export[iec-61360-4], the exporter raises:

ArgumentError: No JSON payload builder for Opencdd::DetClassification

The 163 DET classification entities that now import successfully (PRs #25+#26) are silently dropped from the browser JSON build. They exist in the Database but never reach data/<dict>/database.json.

What's needed

Add a payload builder entry for :det_classification in lib/opencdd/exporters/json.rb. The simplest approach: reuse the generic entity builder (same as ValueList / ViewControl) — DET classification entities have code + preferred_name properties that map to the standard fields.

Proposed code (add to lib/opencdd/exporters/json.rb)

Find the PAYLOAD_BUILDERS hash (or equivalent dispatch) and add:

when Opencdd::DetClassification
  build_generic_entity_payload(entity, database: database)

Or if the dispatch uses type symbols:

:det_classification => :build_generic_entity_payload

The generic builder already exists for entities that don't need type-specific post-processing (ViewControl uses it). DetClassification should too — it has the standard code, preferred_name, definition, version, revision fields that the generic builder handles.

Expected JSON shape

{
  "irdi": "0112/2///IECCDD_001#A11",
  "code": "A11",
  "type": "det_classification",
  "preferred_name": "geographical unit (greater than a place)",
  "preferred_name_ml": { "en": "geographical unit (greater than a place)" },
  "version": null,
  "revision": null,
  "raw_properties": { ... }
}

Verification

After implementing:

# In data-private:
bundle exec rake browser:build_from_export[iec-61360-4]
python3 -c "
import json
db = json.load(open('data/iec-61360-4/database.json'))
det = [e for e in db if e.get('type') == 'det_classification']
print(f'DET classification entities in browser JSON: {len(det)}')
print(f'Sample: {det[0][\"code\"]} - {det[0].get(\"preferred_name\")}'[:80])
"
# Expected: 163 DET classification entities, first code="A11"

Why this matters

Without the exporter, the browser can't display DET classification data. The 163 entities are in the import pipeline but never reach the end user. This is the last gap in the DET classification end-to-end flow.

Context

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions