Skip to content

Conversation

@dfcoffin
Copy link
Contributor

@dfcoffin dfcoffin commented Jan 9, 2026

Summary

Phase 8 of Issue #28: Aligns PnodeRef mapper, repository, and tests with ESPI 4.0 XSD specification.

Key Finding: Per ESPI 4.0 specification (espi.xsd), PnodeRef extends Object (not IdentifiedObject), so it has NO id/uuid/mRID fields or Atom metadata. Entity and DTO were already correctly implemented.

Changes Made

Mapper Updates (PnodeRefMapper)

  • ✅ Removed updateEntity() method (read-only operations only)
  • ✅ Removed unused MappingTarget import
  • ✅ Kept explicit XSD element mappings for clarity (apnodeType, ref, startEffectiveDate, endEffectiveDate)

Repository Updates (PnodeRefRepository)

  • ✅ Added indexed query: findAllIds() (primary key index)
  • ✅ Renamed findByUsagePointId()findAllByUsagePointId() (foreign key index)
  • ✅ Removed 9 non-indexed custom queries:
    • findByUsagePoint
    • findByApnodeType
    • findByUsagePointAndApnodeType
    • findByRef
    • findValidByUsagePointId
    • findValidByApnodeType
    • deleteByUsagePoint
    • deleteByUsagePointId
  • ✅ Removed unused UsagePointEntity import

Test Updates (PnodeRefRepositoryTest)

  • ✅ Added test for findAllIds()
  • ✅ Updated test for renamed findAllByUsagePointId()
  • ✅ Removed 9 test methods for deleted repository queries
  • ✅ Kept relationship and validation tests intact
  • ✅ All 529 remaining tests pass successfully

Verification

Entity & DTO Verification

PnodeRefEntity already matches XSD correctly:

  • Uses Long id (BIGINT primary key)
  • Has apnodeType, ref, startEffectiveDate, endEffectiveDate fields
  • Does NOT extend IdentifiedObject (correct per XSD)
  • Field order matches XSD element sequence

PnodeRefDto already matches XSD correctly:

  • NO id/uuid fields (Object type has no mRID)
  • propOrder matches XSD: apnodeType → ref → startEffectiveDate → endEffectiveDate
  • Has all 4 XSD elements, nothing extra

Database Verification

✅ Flyway migrations verified in all vendor-specific V2 scripts:

  • db/vendor/mysql/V2__MySQL_Specific_Tables.sql
  • db/vendor/postgres/V2__PostgreSQL_Specific_Tables.sql
  • db/vendor/h2/V2__H2_Specific_Tables.sql

All scripts create pnode_refs table with:

  • id BIGINT primary key
  • apnode_type VARCHAR(64)
  • ref VARCHAR(256) NOT NULL
  • start_effective_date BIGINT
  • end_effective_date BIGINT
  • usage_point_id CHAR(36) NOT NULL with foreign key
  • Indexes on apnode_type, ref, and usage_point_id

Test Results

Tests run: 529, Failures: 0, Errors: 0, Skipped: 0

✅ All tests pass (PnodeRefRepositoryTest: 7 tests down to 2 indexed query tests)
✅ MySQL TestContainer integration tests pass
✅ H2 integration tests pass

Technical Notes

XSD Compliance

Per espi.xsd line ~1539:

<xs:complexType name="PnodeRef">
  <xs:complexContent>
    <xs:extension base="Object">
      <xs:sequence>
        <xs:element name="apnodeType" type="ApnodeType"/>
        <xs:element name="ref" type="String256"/>
        <xs:element name="startEffectiveDate" type="TimeType" minOccurs="0"/>
        <xs:element name="endEffectiveDate" type="TimeType" minOccurs="0"/>
      </xs:sequence>
    </xs:extension>
  </xs:complexContent>
</xs:complexType>

Object base type has NO mRID attribute (unlike IdentifiedObject). This is consistent with other Object-based types like IntervalReading, ReadingQuality, and ServiceDeliveryPoint (Phase 7).

Repository Query Removal Rationale

Removed non-indexed queries following read-only CRUD pattern from Phases 5-7:

  • Applications only support read operations via indexed lookups
  • Complex validation queries (findValidBy*) and type-based queries were not indexed
  • Kept only findAllIds() (PK index) and findAllByUsagePointId() (FK index)

Pattern Consistency

Phase 8 follows the exact same pattern as:

  • Phase 5 (IntervalBlock)
  • Phase 6 (MeterReading)
  • Phase 7 (ServiceDeliveryPoint)

All Object-based entities (not IdentifiedObject) have:

  • NO id/uuid fields in DTO
  • NO Atom metadata fields
  • Read-only mapper (no updateEntity)
  • Minimal indexed queries only in repository

Related Issues

Testing Checklist

  • Unit tests pass (2/2 PnodeRef repository tests)
  • Integration tests pass (MySQL TestContainer)
  • Integration tests pass (H2)
  • All 529 tests in openespi-common pass
  • Entity structure verified against XSD
  • DTO structure verified against XSD
  • Flyway migrations verified (all vendors)
  • No compilation warnings for PnodeRef files

🤖 Generated with Claude Code

Per ESPI 4.0 specification, PnodeRef extends Object (not IdentifiedObject),
so it has NO Atom metadata fields. This phase aligns the mapper, repository,
and tests with the XSD definition. Entity and DTO were already compliant.

Changes:
- PnodeRefMapper: Remove updateEntity method (read-only operations)
- PnodeRefMapper: Remove MappingTarget import
- PnodeRefRepository: Keep only indexed queries (findAllIds, findAllByUsagePointId)
- PnodeRefRepository: Remove 9 non-indexed custom queries
- PnodeRefRepository: Remove unused UsagePointEntity import
- PnodeRefRepositoryTest: Add test for findAllIds()
- PnodeRefRepositoryTest: Update test for renamed findAllByUsagePointId
- PnodeRefRepositoryTest: Remove 9 tests for deleted queries

All 529 tests pass. Entity and DTO already match XSD structure correctly.

Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
@dfcoffin dfcoffin merged commit 041a213 into main Jan 9, 2026
5 checks passed
@dfcoffin dfcoffin deleted the feature/schema-compliance-phase-8-pnode-ref branch January 9, 2026 21:45
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