Ensure CustomerEntity and all related components strictly comply with ESPI 4.0 customer.xsd schema definition.
Branch: feature/schema-compliance-phase-20-customer
Dependencies:
- TimeConfiguration (via bidirectional Atom rel='related' links)
- Statement (via bidirectional Atom rel='related' links)
- CustomerAccount (via bidirectional Atom rel='related' links)
Referenced By: None
Location: openespi-common/src/main/java/org/greenbuttonalliance/espi/common/domain/customer/entity/CustomerEntity.java
Current Field Order:
- ✅ organisation (embedded Organisation) - From OrganisationRole
- ✅ kind (CustomerKind enum)
- ✅ specialNeed (String)
- ✅ vip (Boolean)
- ✅ pucNumber (String)
- ✅ status (embedded Status)
- ✅ priority (embedded Priority)
- ✅ locale (String)
- ✅ customerName (String)
- customerAccounts (OneToMany relationship)
- timeConfiguration (OneToOne relationship)
- statements (OneToMany relationship)
- phoneNumbers (OneToMany relationship)
Customer extends OrganisationRole extends IdentifiedObject
XSD Element Sequence:
- IdentifiedObject fields (mRID, description)
- Organisation (from OrganisationRole)
- kind (CustomerKind enum)
- specialNeed (String256)
- vip (boolean)
- pucNumber (String256)
- status (Status)
- priority (Priority)
- locale (String256)
- customerName (String256)
Status Structure (embedded):
- value (String256)
- dateTime (DateTimeInterval)
- reason (String256)
Priority Structure (embedded):
- value (Integer)
- rank (Integer)
- type (String256)
Organisation Structure (embedded):
- organisationName (String256)
- streetAddress (StreetAddress)
- postalAddress (StreetAddress)
- electronicAddress (ElectronicAddress)
✅ COMPLIANT: Field order matches customer.xsd sequence ✅ COMPLIANT: All required embedded classes present ✅ COMPLIANT: Extends IdentifiedObject (correct per XSD) ✅ COMPLIANT: Relationships defined (CustomerAccount, TimeConfiguration, Statement)
Minor Issues to Address:
⚠️ Verify Organisation embedded field structure matches XSD exactly⚠️ Verify Status embedded class matches XSD (dateTime type)⚠️ Verify Priority embedded class matches XSD⚠️ Check Flyway migration column order matches XSD sequence⚠️ Review CustomerDto field order⚠️ Review CustomerMapper mappings⚠️ Review CustomerRepository for non-indexed queries⚠️ Add XML marshalling tests
Status: ✅ Mostly Complete - Verify Only
Actions:
- ✅ Verify field order matches customer.xsd sequence (appears correct)
⚠️ Verify Organisation embedded class structure:- Check streetAddress and postalAddress field mapping
- Check electronicAddress field mapping
- Verify column name prefixes are consistent
⚠️ Verify Status embedded class:- Confirm dateTime uses OffsetDateTime (correct type)
- Verify column names
⚠️ Verify Priority embedded class:- Confirm all three fields present (value, rank, type)
- Verify column names
- ✅ Relationships look correct (CustomerAccount, TimeConfiguration, Statement)
⚠️ Check phoneNumbers relationship - ensure it's handled correctly
Files to Review:
CustomerEntity.javaOrganisation.java(if separate embeddable)Status.java(inner class)Priority.java(inner class)
Status:
Actions:
- Read CustomerDto and verify field order matches customer.xsd
- Ensure Organisation DTO structure matches XSD
- Ensure Status DTO structure matches XSD
- Ensure Priority DTO structure matches XSD
- Verify JAXB annotations for XML marshalling
- Ensure namespace is "http://naesb.org/espi/customer"
Files to Review:
openespi-common/src/main/java/org/greenbuttonalliance/espi/common/dto/customer/CustomerDto.java
Status:
Actions:
- Review CustomerMapper interface
- Verify Entity-to-DTO conversion mappings
- Verify DTO-to-Entity conversion mappings
- Ensure embedded Organisation mapping is correct
- Ensure embedded Status mapping is correct
- Ensure embedded Priority mapping is correct
- Handle relationship mappings (ignore or separate methods)
- Remove any IdentifiedObject field mappings (handled by base)
Files to Review:
openespi-common/src/main/java/org/greenbuttonalliance/espi/common/mapper/customer/CustomerMapper.java
Status:
Actions:
- Review CustomerRepository interface
- Keep ONLY queries on indexed fields:
- id (primary key)
- created, updated (likely indexed)
- kind (likely indexed)
- Any other explicitly indexed fields
- Remove queries on non-indexed fields
- Review test requirements and ensure indexed queries support them
Files to Review:
openespi-common/src/main/java/org/greenbuttonalliance/espi/common/repositories/customer/CustomerRepository.java
Status:
Actions:
- Review CustomerService interface
- Review CustomerServiceImpl implementation
- Verify service methods support schema-compliant operations
- Ensure proper relationship handling (CustomerAccount, TimeConfiguration, Statement)
- Check for any legacy patterns that need updating
Files to Review:
openespi-common/src/main/java/org/greenbuttonalliance/espi/common/service/customer/CustomerService.javaopenespi-common/src/main/java/org/greenbuttonalliance/espi/common/service/customer/CustomerServiceImpl.java(if exists)
Status:
Actions:
- Locate Customer table creation in Flyway migrations
- Verify column order matches customer.xsd element sequence
- Check Organisation embedded fields have correct column names
- Check Status embedded fields have correct column names
- Check Priority embedded fields have correct column names
- Verify foreign key relationships (time_configuration_id)
- Verify indexes on commonly queried fields
Files to Locate:
openespi-common/src/main/resources/db/migration/V*.sql(Customer table)openespi-common/src/main/resources/db/vendor/*/V*.sql(vendor-specific)
Status:
Actions:
-
Unit Tests:
- Review CustomerRepositoryTest
- Add tests for all indexed query methods
- Test embedded Organisation fields
- Test embedded Status fields
- Test embedded Priority fields
- Test relationship loading (CustomerAccount, TimeConfiguration, Statement)
-
Integration Tests:
- Add TestContainers-based integration tests
- Test full CRUD operations
- Test relationship persistence
-
XML Marshalling Tests:
- Add XML marshalling test for CustomerEntity → CustomerDto → XML
- Add XML unmarshalling test for XML → CustomerDto → CustomerEntity
- Validate generated XML against customer.xsd schema
- Test embedded Organisation serialization
- Test embedded Status serialization
- Test embedded Priority serialization
- Verify namespace is "http://naesb.org/espi/customer"
-
Migration Tests:
- Use MigrationVerificationTest pattern
- Verify Customer table structure matches XSD
Files to Review/Create:
openespi-common/src/test/java/org/greenbuttonalliance/espi/common/repositories/customer/CustomerRepositoryTest.java- Create:
CustomerIntegrationTest.java - Create:
CustomerXmlMarshallingTest.java
Actions:
- Create feature branch:
feature/schema-compliance-phase-20-customer - Stage all changes
- Commit with message:
feat: Phase 20 - Customer ESPI 4.0 Schema Compliance Ensured CustomerEntity and related components comply with customer.xsd. Changes: - Verified CustomerEntity field order matches customer.xsd - Updated CustomerDto field order and JAXB annotations - Updated CustomerMapper mappings - Cleaned up CustomerRepository (removed non-indexed queries) - Verified/updated Flyway migrations - Added XML marshalling tests - Updated unit and integration tests Customer is now 100% ESPI 4.0 customer.xsd compliant. Co-Authored-By: Claude Sonnet 4.5 <[email protected]> - Push branch to remote
- Create PR with comprehensive description
- Wait for CI/CD checks to pass
- Request review
Based on complexity, Phase 20 can be broken into:
- Review and verify CustomerEntity field order
- Review and verify embedded classes (Organisation, Status, Priority)
- Review and verify CustomerDto structure
- Update JAXB annotations if needed
- Review and update CustomerMapper
- Clean up CustomerRepository (remove non-indexed queries)
- Update service layer if needed
- Locate and review Customer table migrations
- Verify column order matches XSD
- Add migration script if changes needed
- Add/update unit tests
- Add integration tests
- Add XML marshalling/unmarshalling tests
- Verify schema validation
✅ CustomerEntity field order matches customer.xsd sequence exactly ✅ CustomerDto field order matches customer.xsd sequence exactly ✅ All embedded classes (Organisation, Status, Priority) match XSD ✅ CustomerMapper correctly maps all fields ✅ CustomerRepository contains only indexed field queries ✅ Flyway migration column order matches XSD ✅ All unit tests pass ✅ Integration tests pass with TestContainers ✅ XML marshalling tests validate against customer.xsd ✅ CI/CD pipeline passes all checks ✅ PR approved and merged
Low Risk:
- Entity structure appears correct
- DTO and Mapper infrastructure exists
- Service layer exists
Medium Risk:
- Flyway migrations may need column reordering
- Repository may have non-indexed queries to remove
- XML marshalling tests need to be created
High Risk:
- None identified
Dependencies:
- TimeConfiguration must be schema-compliant (already done in earlier phases)
- Statement entity must exist (verify)
- CustomerAccount entity must exist (verify)
Blockers:
- None identified
After completing Phase 20 (Customer), proceed to:
- Phase 21: ServiceSupplier
- Phase 22: Asset
- Phase 23: ServiceLocation
- Phase 24: CustomerAgreement
These phases will complete the customer.xsd schema compliance work.
- Customer is a PII (Personally Identifiable Information) entity in the customer.xsd namespace
- Customer extends OrganisationRole which extends IdentifiedObject
- Customer has multiple embedded complex types (Organisation, Status, Priority)
- Customer has relationships to TimeConfiguration, Statement, and CustomerAccount
- The entity appears well-structured and mostly compliant already
- Main work will be verification, testing, and documentation
Created: 2026-01-16 Phase: 20 Entity: Customer Schema: customer.xsd Status: Ready for Implementation