Skip to content

Conversation

@dfcoffin
Copy link
Contributor

@dfcoffin dfcoffin commented Jan 7, 2026

Summary

This PR implements Phase 0 of ESPI 4.0 schema compliance, fixing PnodeRefEntity and ServiceDeliveryPointEntity to correctly extend Object (not IdentifiedObject) per the ESPI 4.0 XSD specification.

Changes Made

Entity Updates

  • PnodeRefEntity: Removed IdentifiedObject inheritance, changed from UUID to Long ID
  • ServiceDeliveryPointEntity: Removed IdentifiedObject inheritance and mrid field, changed from UUID to Long ID
  • Both entities now use @GeneratedValue(strategy = GenerationType.IDENTITY) for Long IDs

Mapper Updates

  • PnodeRefMapper: Removed BaseIdentifiedObjectMapper inheritance
  • ServiceDeliveryPointMapper: Removed BaseIdentifiedObjectMapper inheritance, added ignore mappings for uuid and description

Repository Updates

  • Changed from JpaRepository<Entity, UUID> to JpaRepository<Entity, Long>
  • Updated method signatures to use Long instead of UUID for IDs
  • Note: UsagePoint relationships still use UUID (correct, as UsagePoint extends IdentifiedObject)

Database Migration Updates

  • Moved table creation to vendor-specific V2 files (was in V1/V3 base migrations)
  • Reason: Auto-increment syntax differs across databases
    • PostgreSQL: BIGSERIAL PRIMARY KEY
    • MySQL/H2: BIGINT AUTO_INCREMENT PRIMARY KEY
  • Updated aggregated_node_refs.pnode_ref_id and usage_points.service_delivery_point_id FK columns to BIGINT
  • Removed IdentifiedObject fields (timestamps, links, indexes)

Test Updates

  • ServiceDeliveryPointRepositoryTest: Complete rewrite (610 lines) removing all mRID and IdentifiedObject references
  • PnodeRefRepositoryTest: Updated to remove IdentifiedObject timestamp assertions
  • Both tests now focus on business data validation only

Test Results

All 550 tests passing (0 failures, 0 errors)

  • H2 tests: ✅ Passed
  • MySQL integration tests: ✅ 6/6 passed
  • PostgreSQL integration tests: ✅ 9/9 passed
  • PnodeRefRepositoryTest: ✅ 43/43 passed
  • ServiceDeliveryPointRepositoryTest: ✅ 43/43 passed

ESPI 4.0 XSD Compliance

Per ESPI 4.0 XSD specification:

  • PnodeRef (espi.xsd:1539): Extends Object, not IdentifiedObject
  • ServiceDeliveryPoint (espi.xsd:1161): Extends Object, not IdentifiedObject, has NO mRID field

Object-based entities:

  • Use Long IDs (48+ bits minimum)
  • Have NO Atom metadata (timestamps, self/up links, related_links)
  • Have NO UUID identifiers

Files Changed

14 files changed: 234 insertions(+), 280 deletions(-)

Core Entity Files

  • PnodeRefEntity.java
  • ServiceDeliveryPointEntity.java
  • PnodeRefMapper.java
  • ServiceDeliveryPointMapper.java
  • PnodeRefRepository.java
  • ServiceDeliveryPointRepository.java

Migration Files

  • V1__Create_Base_Tables.sql - Removed service_delivery_points table
  • V3__Create_additiional_Base_Tables.sql - Removed pnode_refs table, updated aggregated_node_refs FK
  • db/vendor/h2/V2__H2_Specific_Tables.sql - Added both tables with H2 syntax
  • db/vendor/mysql/V2__MySQL_Specific_Tables.sql - Added both tables with MySQL syntax
  • db/vendor/postgres/V2__PostgreSQL_Specific_Tables.sql - Added both tables with PostgreSQL syntax

Test Files

  • PnodeRefRepositoryTest.java
  • ServiceDeliveryPointRepositoryTest.java
  • application-test.yml - Updated Flyway test configuration

Breaking Changes

⚠️ Database schema changes: This PR modifies existing Flyway migrations.

Migration Strategy:

  • For new deployments: Migrations will apply cleanly
  • For existing databases: Tables will need to be recreated with new schema

Affected tables:

  • service_delivery_points - Changed from CHAR(36) to BIGINT, removed IdentifiedObject columns
  • pnode_refs - Changed from CHAR(36) to BIGINT, removed IdentifiedObject columns
  • aggregated_node_refs - FK column pnode_ref_id changed to BIGINT
  • usage_points - FK column service_delivery_point_id changed to BIGINT

Related Issues

Closes #28 (Phase 0)

Checklist

  • All tests pass locally
  • Database migrations tested on H2, MySQL, and PostgreSQL
  • Entity definitions match ESPI 4.0 XSD specification
  • Repository tests updated to remove IdentifiedObject references
  • Mapper configurations updated
  • No regression in existing functionality

🤖 Generated with Claude Code

dfcoffin and others added 2 commits January 6, 2026 23:43
This commit completes Phase A of ESPI 4.0 schema compliance by removing
11 database tables for related_links that were incorrectly created for
entities that either extend Object (not IdentifiedObject) or use direct
foreign key relationships instead of Atom links.

Changes:
- V1 migration: Removed 4 related_links tables
  - retail_customer_related_links (direct FK pattern)
  - service_delivery_point_related_links (extends Object)
  - subscription_related_links (direct FK for OAuth2)
  - batch_list_related_links (wrapper type, not IdentifiedObject)

- V3 migration: Removed 7 related_links tables
  - interval_reading_related_links (extends Object, espi.xsd:1016)
  - reading_quality_related_links (extends Object, espi.xsd:1062)
  - pnode_ref_related_links (extends Object, espi.xsd:1539)
  - aggregated_node_ref_related_links (extends Object, espi.xsd:1570)
  - line_item_related_links (extends Object, espi.xsd:1444)
  - phone_number_related_links (custom, not in XSD)
  - statement_ref_related_links (extends Object, customer.xsd:285)

- Vendor V2 files: Updated documentation comments to reflect that
  interval_reading and reading_quality do NOT have related_links tables

Documentation:
- PHASE_A_ANALYSIS_FINDINGS.md: Entity inheritance analysis
- Phase_A-DTO_Analysis.md: DTO Atom link analysis
- Phase_A-Flyway_Migration_Inventory.md: Migration inventory
- PHASE_A_COMPLETE_SUMMARY.md: Phase A completion summary

Testing:
All tests pass successfully across H2, MySQL, and PostgreSQL databases.
No side effects detected in dependent modules (datacustodian, thirdparty).

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
…ties (Issue #28)

This commit fixes PnodeRefEntity and ServiceDeliveryPointEntity to comply with
ESPI 4.0 XSD specification. Both entities extend Object (not IdentifiedObject)
and therefore should use Long IDs instead of UUID, and should not have Atom
metadata fields (timestamps, links, related_links tables).

Changes:
- PnodeRefEntity: Removed IdentifiedObject inheritance, changed from UUID to Long ID
- ServiceDeliveryPointEntity: Removed IdentifiedObject inheritance, mRID field,
  changed from UUID to Long ID
- PnodeRefMapper & ServiceDeliveryPointMapper: Removed BaseIdentifiedObjectMapper
- Repositories: Changed from JpaRepository<Entity, UUID> to <Entity, Long>
- Flyway migrations: Moved service_delivery_points and pnode_refs table creation
  from base migrations (V1, V3) to vendor-specific V2 files due to auto-increment
  syntax differences (H2/MySQL: AUTO_INCREMENT, PostgreSQL: BIGSERIAL)
- Tests: Updated to remove IdentifiedObject assertions and mRID references

All 550 tests passing.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
@dfcoffin dfcoffin changed the title ESPI 4.0 Schema Compliance - Phase 0: Fix Object-based entities refactor: ESPI 4.0 Schema Compliance - Phase 0: Fix Object-based entities Jan 7, 2026
@dfcoffin
Copy link
Contributor Author

dfcoffin commented Jan 7, 2026

Updated PR title with conventional commit prefix. Re-running checks.

@dfcoffin dfcoffin merged commit 701d407 into main Jan 7, 2026
6 of 7 checks passed
@dfcoffin dfcoffin deleted the fix/schema-compliance-analysis branch January 7, 2026 21:24
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.

Review Current Usage and Customer Entity Classes to ensure they match their ESPI Schema XSD files

2 participants