Skip to content

Commit 410f4b5

Browse files
dfcoffinclaude
andauthored
feat: ESPI 4.0 Schema Compliance - Phase 21: ServiceSupplier Complete Implementation (#96)
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>
1 parent 4e48626 commit 410f4b5

34 files changed

+2136
-787
lines changed

openespi-common/PHASE_21_SERVICE_SUPPLIER_IMPLEMENTATION_PLAN.md

Lines changed: 669 additions & 0 deletions
Large diffs are not rendered by default.

openespi-common/src/main/java/org/greenbuttonalliance/espi/common/domain/customer/common/TelephoneNumber.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,28 +47,28 @@
4747
@AllArgsConstructor
4848
public class TelephoneNumber implements Serializable {
4949

50-
@Column(name = "country_code", length = 256)
50+
@Column(name = "country_code", length = 10)
5151
private String countryCode;
5252

53-
@Column(name = "area_code", length = 256)
53+
@Column(name = "area_code", length = 10)
5454
private String areaCode;
5555

56-
@Column(name = "city_code", length = 256)
56+
@Column(name = "city_code", length = 10)
5757
private String cityCode;
5858

59-
@Column(name = "local_number", length = 256)
59+
@Column(name = "local_number", length = 30)
6060
private String localNumber;
6161

62-
@Column(name = "ext", length = 256)
62+
@Column(name = "ext", length = 20)
6363
private String ext;
6464

65-
@Column(name = "dial_out", length = 256)
65+
@Column(name = "dial_out", length = 10)
6666
private String dialOut;
6767

68-
@Column(name = "international_prefix", length = 256)
68+
@Column(name = "international_prefix", length = 10)
6969
private String internationalPrefix;
7070

71-
@Column(name = "itu_phone", length = 256)
71+
@Column(name = "itu_phone", length = 50)
7272
private String ituPhone;
7373

7474
@Override

openespi-common/src/main/java/org/greenbuttonalliance/espi/common/domain/customer/entity/CustomerAccountEntity.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,22 @@ public class CustomerAccountEntity extends IdentifiedObject {
168168
@AttributeOverride(name = "postalAddress.stateOrProvince", column = @Column(name = "postal_state_or_province"))
169169
@AttributeOverride(name = "postalAddress.postalCode", column = @Column(name = "postal_postal_code"))
170170
@AttributeOverride(name = "postalAddress.country", column = @Column(name = "postal_country"))
171+
@AttributeOverride(name = "phone1.countryCode", column = @Column(name = "contact_phone1_country_code"))
172+
@AttributeOverride(name = "phone1.areaCode", column = @Column(name = "contact_phone1_area_code"))
173+
@AttributeOverride(name = "phone1.cityCode", column = @Column(name = "contact_phone1_city_code"))
174+
@AttributeOverride(name = "phone1.localNumber", column = @Column(name = "contact_phone1_local_number"))
175+
@AttributeOverride(name = "phone1.ext", column = @Column(name = "contact_phone1_ext"))
176+
@AttributeOverride(name = "phone1.dialOut", column = @Column(name = "contact_phone1_dial_out"))
177+
@AttributeOverride(name = "phone1.internationalPrefix", column = @Column(name = "contact_phone1_international_prefix"))
178+
@AttributeOverride(name = "phone1.ituPhone", column = @Column(name = "contact_phone1_itu_phone"))
179+
@AttributeOverride(name = "phone2.countryCode", column = @Column(name = "contact_phone2_country_code"))
180+
@AttributeOverride(name = "phone2.areaCode", column = @Column(name = "contact_phone2_area_code"))
181+
@AttributeOverride(name = "phone2.cityCode", column = @Column(name = "contact_phone2_city_code"))
182+
@AttributeOverride(name = "phone2.localNumber", column = @Column(name = "contact_phone2_local_number"))
183+
@AttributeOverride(name = "phone2.ext", column = @Column(name = "contact_phone2_ext"))
184+
@AttributeOverride(name = "phone2.dialOut", column = @Column(name = "contact_phone2_dial_out"))
185+
@AttributeOverride(name = "phone2.internationalPrefix", column = @Column(name = "contact_phone2_international_prefix"))
186+
@AttributeOverride(name = "phone2.ituPhone", column = @Column(name = "contact_phone2_itu_phone"))
171187
@AttributeOverride(name = "electronicAddress.lan", column = @Column(name = "contact_lan"))
172188
@AttributeOverride(name = "electronicAddress.mac", column = @Column(name = "contact_mac"))
173189
@AttributeOverride(name = "electronicAddress.email1", column = @Column(name = "contact_email1"))

openespi-common/src/main/java/org/greenbuttonalliance/espi/common/domain/customer/entity/CustomerEntity.java

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
import org.greenbuttonalliance.espi.common.domain.common.IdentifiedObject;
2828
import org.greenbuttonalliance.espi.common.domain.customer.enums.CustomerKind;
2929
import org.greenbuttonalliance.espi.common.domain.usage.TimeConfigurationEntity;
30-
import org.hibernate.annotations.SQLRestriction;
3130
import org.hibernate.proxy.HibernateProxy;
3231

3332
import java.time.OffsetDateTime;
@@ -69,6 +68,22 @@ public class CustomerEntity extends IdentifiedObject {
6968
@AttributeOverride(name = "postalAddress.stateOrProvince", column = @Column(name = "customer_postal_state_or_province"))
7069
@AttributeOverride(name = "postalAddress.postalCode", column = @Column(name = "customer_postal_postal_code"))
7170
@AttributeOverride(name = "postalAddress.country", column = @Column(name = "customer_postal_country"))
71+
@AttributeOverride(name = "phone1.countryCode", column = @Column(name = "customer_phone1_country_code"))
72+
@AttributeOverride(name = "phone1.areaCode", column = @Column(name = "customer_phone1_area_code"))
73+
@AttributeOverride(name = "phone1.cityCode", column = @Column(name = "customer_phone1_city_code"))
74+
@AttributeOverride(name = "phone1.localNumber", column = @Column(name = "customer_phone1_local_number"))
75+
@AttributeOverride(name = "phone1.ext", column = @Column(name = "customer_phone1_ext"))
76+
@AttributeOverride(name = "phone1.dialOut", column = @Column(name = "customer_phone1_dial_out"))
77+
@AttributeOverride(name = "phone1.internationalPrefix", column = @Column(name = "customer_phone1_international_prefix"))
78+
@AttributeOverride(name = "phone1.ituPhone", column = @Column(name = "customer_phone1_itu_phone"))
79+
@AttributeOverride(name = "phone2.countryCode", column = @Column(name = "customer_phone2_country_code"))
80+
@AttributeOverride(name = "phone2.areaCode", column = @Column(name = "customer_phone2_area_code"))
81+
@AttributeOverride(name = "phone2.cityCode", column = @Column(name = "customer_phone2_city_code"))
82+
@AttributeOverride(name = "phone2.localNumber", column = @Column(name = "customer_phone2_local_number"))
83+
@AttributeOverride(name = "phone2.ext", column = @Column(name = "customer_phone2_ext"))
84+
@AttributeOverride(name = "phone2.dialOut", column = @Column(name = "customer_phone2_dial_out"))
85+
@AttributeOverride(name = "phone2.internationalPrefix", column = @Column(name = "customer_phone2_international_prefix"))
86+
@AttributeOverride(name = "phone2.ituPhone", column = @Column(name = "customer_phone2_itu_phone"))
7287
@AttributeOverride(name = "electronicAddress.lan", column = @Column(name = "customer_lan"))
7388
@AttributeOverride(name = "electronicAddress.mac", column = @Column(name = "customer_mac"))
7489
@AttributeOverride(name = "electronicAddress.email1", column = @Column(name = "customer_email1"))
@@ -158,16 +173,6 @@ public class CustomerEntity extends IdentifiedObject {
158173
@OneToMany(mappedBy = "customer", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
159174
private List<StatementEntity> statements = new ArrayList<>();
160175

161-
/**
162-
* Phone numbers for this customer's organisation.
163-
* Managed via separate PhoneNumberEntity to avoid column conflicts.
164-
* Initialized to empty ArrayList to avoid null pointer exceptions.
165-
*/
166-
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
167-
@JoinColumn(name = "parent_entity_uuid", referencedColumnName = "id")
168-
@SQLRestriction("parent_entity_type = 'CustomerEntity'")
169-
private List<PhoneNumberEntity> phoneNumbers = new ArrayList<>();
170-
171176
/**
172177
* Embeddable class for Status
173178
*/

openespi-common/src/main/java/org/greenbuttonalliance/espi/common/domain/customer/entity/Organisation.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import lombok.*;
2626
import org.greenbuttonalliance.espi.common.domain.customer.common.ElectronicAddress;
2727
import org.greenbuttonalliance.espi.common.domain.customer.common.StreetAddress;
28+
import org.greenbuttonalliance.espi.common.domain.customer.common.TelephoneNumber;
2829

2930
import java.io.Serializable;
3031

@@ -59,8 +60,17 @@ public class Organisation implements Serializable {
5960
@Embedded
6061
private StreetAddress postalAddress;
6162

62-
// PhoneNumber fields removed - phone numbers are managed separately via PhoneNumberEntity
63-
// to avoid JPA column mapping conflicts in embedded contexts
63+
/**
64+
* Primary phone number for this organisation.
65+
*/
66+
@Embedded
67+
private TelephoneNumber phone1;
68+
69+
/**
70+
* Secondary phone number for this organisation.
71+
*/
72+
@Embedded
73+
private TelephoneNumber phone2;
6474

6575
/**
6676
* Electronic address for this organisation.

openespi-common/src/main/java/org/greenbuttonalliance/espi/common/domain/customer/entity/OrganisationRole.java

Lines changed: 0 additions & 63 deletions
This file was deleted.

openespi-common/src/main/java/org/greenbuttonalliance/espi/common/domain/customer/entity/PhoneNumberEntity.java

Lines changed: 0 additions & 164 deletions
This file was deleted.

0 commit comments

Comments
 (0)