Skip to content

Conversation

@dfcoffin
Copy link
Contributor

Summary

This PR implements full ESPI 4.0 schema compliance for ServiceSupplier and refactors all Organisation phone number handling from the legacy PhoneNumberEntity table to embedded TelephoneNumber fields.

Key Changes

New DTOs (JAXB/XML)

  • ServiceSupplierDto - 4 fields (organisation, kind, issuerIdentificationNumber, effectiveDate)
  • OrganisationDto - 6 fields with phone1/phone2 embedded
  • TelephoneNumberDto - 8 fields per XSD specification

New Mappers

  • ServiceSupplierMapper - Entity ↔ DTO conversion
  • OrganisationMapper - Organisation entity ↔ DTO conversion
  • TelephoneNumberMapper - TelephoneNumber entity ↔ DTO conversion

Entity Updates

  • ✅ Fixed SupplierKind enum to match XSD (6 values in correct sequence: UTILITY, RETAILER, OTHER, LSE, MDMA, MSP)
  • ✅ Updated Organisation to use embedded phone1 and phone2 (TelephoneNumber)
  • ✅ Updated ServiceSupplierEntity with 16 phone @AttributeOverride annotations
  • ✅ Updated CustomerEntity with 16 phone @AttributeOverride annotations
  • ✅ Optimized TelephoneNumber column sizes to prevent MySQL row size limit
  • ✅ Updated CustomerMapper to remove PhoneNumberEntity logic
  • ✅ Updated ServiceLocationMapper to use TelephoneNumberMapper

Cleanup

  • ✅ Deleted OrganisationRole (unused wrapper)
  • ✅ Deleted PhoneNumberEntity (replaced with embedded TelephoneNumber)
  • ✅ Deleted PhoneNumberService (no longer needed)
  • ✅ Removed BaseMapperUtils inheritance from CustomerMapper and ServiceSupplierMapper (resolved bean conflicts)
  • ✅ Removed legacy usagePointId field from ElectricPowerQualitySummaryDto

Database Migration

  • ✅ Updated V3 Flyway migration with embedded phone columns for:
    • service_suppliers table (16 phone columns)
    • customers table (16 phone columns)
    • service_locations table (phone columns with optimized sizes)
    • customer_accounts table (16 phone columns)
  • ✅ Removed phone_numbers table (no longer needed)

Tests

  • ServiceSupplierDtoTest - 8 tests for XML marshalling and field validation
  • OrganisationDtoTest - 8 tests for Organisation DTO functionality
  • TelephoneNumberDtoTest - 8 tests for TelephoneNumber DTO functionality
  • ✅ Total: 24 new tests added

Test Results

Tests run: 760, Failures: 0, Errors: 0, Skipped: 0
BUILD SUCCESS

Integration Tests:

  • PostgreSQL TestContainer: 2/2 ✓
  • H2 In-Memory: 3/3 ✓
  • MySQL TestContainer: 2/2 ✓

Breaking Changes

⚠️ Database Schema Changes:

  • phone_numbers table removed
  • 16 phone columns added to service_suppliers, customers, service_locations, customer_accounts tables
  • Existing deployments will need to run Flyway migrations

⚠️ Code Changes:

  • PhoneNumberEntity, OrganisationRole, PhoneNumberService deleted
  • SupplierKind enum values changed to match XSD specification
  • Any code referencing these deleted classes will need updates

Related Issues

Closes portion of #28 (Phase 21: ServiceSupplier)

Note: Issue #28 should remain open - additional phases (Phase 22+) are pending.

Verification Steps

  1. Run full test suite: mvn clean test
  2. Run integration tests: mvn verify -Pintegration-tests
  3. Verify 760 tests pass with 0 failures
  4. Verify database migrations work on MySQL, PostgreSQL, H2

Files Changed

  • 34 files changed: 2,214 insertions(+), 865 deletions(-)
  • Created: 6 new files (DTOs, mappers, tests)
  • Deleted: 3 files (PhoneNumberEntity, OrganisationRole, PhoneNumberService)
  • Modified: 25 files (entities, DTOs, mappers, tests, migrations)

🤖 Generated with Claude Code

… Implementation

This phase implements full ESPI 4.0 compliance for ServiceSupplier and refactors
all Organisation phone number handling from PhoneNumberEntity table to embedded
TelephoneNumber fields.

Key Changes:
- Created ServiceSupplierDto, OrganisationDto, TelephoneNumberDto with JAXB annotations
- Implemented ServiceSupplierMapper, OrganisationMapper, TelephoneNumberMapper
- Fixed SupplierKind enum to match XSD (6 values: UTILITY, RETAILER, OTHER, LSE, MDMA, MSP)
- Refactored Organisation to use embedded phone1/phone2 (TelephoneNumber)
- Deleted PhoneNumberEntity, OrganisationRole, PhoneNumberService (no longer needed)
- Updated ServiceSupplierEntity and CustomerEntity with phone @AttributeOverride
- Optimized TelephoneNumber column sizes to prevent MySQL row size limit
- Updated V3 Flyway migration with embedded phone columns
- Resolved Spring bean conflicts (removed BaseMapperUtils inheritance)
- Removed legacy usagePointId field from ElectricPowerQualitySummaryDto
- Added 24 new DTO tests (ServiceSupplierDtoTest, OrganisationDtoTest, TelephoneNumberDtoTest)

Test Results:
- Total: 760 tests (all passing)
- Integration: PostgreSQL (2/2), H2 (3/3), MySQL (2/2)

Related Issue: #28 (Phase 21)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@dfcoffin dfcoffin merged commit 410f4b5 into main Jan 31, 2026
5 checks passed
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