From 0968117a97443dad7b60e370010184c389eae73f Mon Sep 17 00:00:00 2001 From: "Donald F. Coffin" Date: Tue, 13 Jan 2026 22:53:02 -0500 Subject: [PATCH] feat: ESPI 4.0 Schema Compliance - Phase 12: ElectricPowerQualitySummary Aligned ElectricPowerQualitySummaryEntity field order with ESPI 4.0 XSD schema specification (espi.xsd). Moved summaryInterval field to correct position between shortInterruptions and supplyVoltageDips to match schema sequence. Changes: - ElectricPowerQualitySummaryEntity: Reordered summaryInterval field to match XSD element sequence (lines 121-139) - V3__Create_additiional_Base_Tables.sql: Updated table column order to match XSD schema (summary_interval columns now between short_interruptions and supply_voltage_dips) Validation: - ElectricPowerQualitySummaryDto already compliant with XSD propOrder - ElectricPowerQualitySummaryMapper uses default MapStruct field mapping - All repository queries preserved for test usage - All 533 tests passing (unit + integration with H2, MySQL, PostgreSQL) Schema Element Order (ESPI 4.0 espi.xsd): 1. flickerPlt 2. flickerPst 3. harmonicVoltage 4. longInterruptions 5. mainsVoltage 6. measurementProtocol 7. powerFrequency 8. rapidVoltageChanges 9. shortInterruptions 10. summaryInterval (DateTimeInterval - REQUIRED) 11. supplyVoltageDips 12. supplyVoltageImbalance 13. supplyVoltageVariations 14. tempOvervoltage References: - ESPI 4.0 XSD: espi.xsd ElectricPowerQualitySummary complexType - Phase plan: Issue #28 Phase 12 - Related: Phase 11 (UsageSummary) Co-Authored-By: Claude Sonnet 4.5 --- .../ElectricPowerQualitySummaryEntity.java | 22 +++++++++---------- .../V3__Create_additiional_Base_Tables.sql | 9 ++++---- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/openespi-common/src/main/java/org/greenbuttonalliance/espi/common/domain/usage/ElectricPowerQualitySummaryEntity.java b/openespi-common/src/main/java/org/greenbuttonalliance/espi/common/domain/usage/ElectricPowerQualitySummaryEntity.java index 79e66554..ee0f0a1d 100644 --- a/openespi-common/src/main/java/org/greenbuttonalliance/espi/common/domain/usage/ElectricPowerQualitySummaryEntity.java +++ b/openespi-common/src/main/java/org/greenbuttonalliance/espi/common/domain/usage/ElectricPowerQualitySummaryEntity.java @@ -113,6 +113,17 @@ public class ElectricPowerQualitySummaryEntity extends IdentifiedObject { @Column(name = "short_interruptions") private Long shortInterruptions; + /** + * Summary interval for this power quality summary. + * Time period covered by these measurements. + */ + @Embedded + @AttributeOverrides({ + @AttributeOverride(name = "start", column = @Column(name = "summary_interval_start")), + @AttributeOverride(name = "duration", column = @Column(name = "summary_interval_duration")) + }) + private DateTimeInterval summaryInterval; + /** * Number of supply voltage dips during the summary period. * Temporary reductions in RMS voltage. @@ -142,17 +153,6 @@ public class ElectricPowerQualitySummaryEntity extends IdentifiedObject { @Column(name = "temp_overvoltage") private Long tempOvervoltage; - /** - * Summary interval for this power quality summary. - * Time period covered by these measurements. - */ - @Embedded - @AttributeOverrides({ - @AttributeOverride(name = "start", column = @Column(name = "summary_interval_start")), - @AttributeOverride(name = "duration", column = @Column(name = "summary_interval_duration")) - }) - private DateTimeInterval summaryInterval; - /** * Usage point that this power quality summary belongs to. * Many summaries can belong to one usage point. diff --git a/openespi-common/src/main/resources/db/migration/V3__Create_additiional_Base_Tables.sql b/openespi-common/src/main/resources/db/migration/V3__Create_additiional_Base_Tables.sql index da1bad5e..a3b96706 100644 --- a/openespi-common/src/main/resources/db/migration/V3__Create_additiional_Base_Tables.sql +++ b/openespi-common/src/main/resources/db/migration/V3__Create_additiional_Base_Tables.sql @@ -340,15 +340,16 @@ CREATE TABLE electric_power_quality_summaries power_frequency BIGINT, rapid_voltage_changes BIGINT, short_interruptions BIGINT, - supply_voltage_dips BIGINT, - supply_voltage_imbalance BIGINT, - supply_voltage_variations BIGINT, - temp_overvoltage BIGINT, -- Embedded DateTimeInterval: summaryInterval summary_interval_start BIGINT, summary_interval_duration BIGINT, + supply_voltage_dips BIGINT, + supply_voltage_imbalance BIGINT, + supply_voltage_variations BIGINT, + temp_overvoltage BIGINT, + -- Foreign key relationships usage_point_id CHAR(36),