Skip to content

Commit 2f07d19

Browse files
dfcoffinclaude
andauthored
refactor: Phase 16d - Remove IdentifiedObject mappings from MapStruct mappers (#86)
* refactor: Phase 16d - Remove IdentifiedObject mappings from MapStruct mappers Remove IdentifiedObject field mappings and updateEntity() methods from all MapStruct mappers. The Atom protocol layer now exclusively handles IdentifiedObject metadata (id, uuid, description, published, updated, selfLink, upLink, relatedLinks). Mapper Changes: - Remove all IdentifiedObject field mappings (id, uuid, description, published, updated, links) - Remove updateEntity() methods from all mappers - Add @mapping(target = "id", ignore = true) to prevent UUID→Long type conflicts - Mappers now only handle XSD-defined fields DTO Changes: - UsageSummaryDto: Remove Atom metadata fields (published, updated, selfLink, upLink, relatedLinks, description) - ElectricPowerQualitySummaryDto: Remove description field - Update @XmlType propOrder to match reduced field sets - Fix convenience constructors to match canonical constructor parameters Test Enhancements: - Fix DtoExportServiceImplTest reflection setup (remove obsolete dateTimeMapper) - Add TimeConfiguration, UsageSummary, and ElectricPowerQualitySummary entries to export test - Populate all test DTOs with comprehensive meaningful data instead of nulls - Add assertions to validate XML serialization of all populated fields - All 6 DtoExportServiceImplTest tests pass Test Results: - 580 tests run, 571 pass - 9 pre-existing Jackson3XmlMarshallingTest failures (AtomContent deserialization - unrelated) - DtoExportServiceImplTest: 6/6 pass with comprehensive field validation This completes the separation of concerns between MapStruct mapping (XSD fields only) and Atom protocol handling (metadata fields). Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> * refactor: Remove deprecated AtomContentDto and fix Jackson deserialization - Removed deprecated AtomContentDto class - Updated AtomEntryDto to handle content directly (payload moved to AtomEntryDto) - Fixed MigrationVerificationTest to use correct AtomEntryDto constructor - Added local element names to @JsonSubTypes for Jackson deserialization compatibility - Updated DtoExportServiceImpl to use EspiIdGeneratorService for UUID5 generation - Fixed all Jackson3XmlMarshallingTest deserialization issues - All 580 tests passing with 0 failures and 0 errors Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent 948ed09 commit 2f07d19

26 files changed

Lines changed: 618 additions & 723 deletions

openespi-common/src/main/java/org/greenbuttonalliance/espi/common/dto/atom/AtomContentDto.java

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

openespi-common/src/main/java/org/greenbuttonalliance/espi/common/dto/atom/AtomEntryDto.java

Lines changed: 31 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public record AtomEntryDto(
6363
include = JsonTypeInfo.As.WRAPPER_OBJECT,
6464
property = "type")
6565
@JsonSubTypes({
66-
// ESPI Usage resources (espi: namespace - top-level IdentifiedObject-based)
66+
// Namespace-prefixed names (kept for compatibility)
6767
@JsonSubTypes.Type(value = ApplicationInformationDto.class, name = "espi:ApplicationInformation"),
6868
@JsonSubTypes.Type(value = AuthorizationDto.class, name = "espi:Authorization"),
6969
@JsonSubTypes.Type(value = ElectricPowerQualitySummaryDto.class, name = "espi:ElectricPowerQualitySummary"),
@@ -73,19 +73,35 @@ public record AtomEntryDto(
7373
@JsonSubTypes.Type(value = TimeConfigurationDto.class, name = "espi:TimeConfiguration"),
7474
@JsonSubTypes.Type(value = UsagePointDto.class, name = "espi:UsagePoint"),
7575
@JsonSubTypes.Type(value = UsageSummaryDto.class, name = "espi:UsageSummary"),
76-
// ESPI Customer resources (cust: namespace - top-level IdentifiedObject-based)
7776
@JsonSubTypes.Type(value = CustomerDto.class, name = "cust:Customer"),
7877
@JsonSubTypes.Type(value = CustomerAccountDto.class, name = "cust:CustomerAccount"),
7978
@JsonSubTypes.Type(value = CustomerAgreementDto.class, name = "cust:CustomerAgreement"),
8079
@JsonSubTypes.Type(value = EndDeviceDto.class, name = "cust:EndDevice"),
8180
@JsonSubTypes.Type(value = MeterDto.class, name = "cust:Meter"),
8281
@JsonSubTypes.Type(value = ProgramDateIdMappingsDto.class, name = "cust:ProgramDateIdMappings"),
83-
// Note: TimeConfigurationDto supports BOTH espi: and cust: namespaces (same type in both schemas)
8482
@JsonSubTypes.Type(value = TimeConfigurationDto.class, name = "cust:TimeConfiguration"),
8583
@JsonSubTypes.Type(value = ServiceLocationDto.class, name = "cust:ServiceLocation"),
86-
@JsonSubTypes.Type(value = StatementDto.class, name = "cust:Statement")
84+
@JsonSubTypes.Type(value = StatementDto.class, name = "cust:Statement"),
85+
// Local element names (for Jackson deserialization which uses local name without prefix)
86+
@JsonSubTypes.Type(value = ApplicationInformationDto.class, name = "ApplicationInformation"),
87+
@JsonSubTypes.Type(value = AuthorizationDto.class, name = "Authorization"),
88+
@JsonSubTypes.Type(value = ElectricPowerQualitySummaryDto.class, name = "ElectricPowerQualitySummary"),
89+
@JsonSubTypes.Type(value = IntervalBlockDto.class, name = "IntervalBlock"),
90+
@JsonSubTypes.Type(value = MeterReadingDto.class, name = "MeterReading"),
91+
@JsonSubTypes.Type(value = ReadingTypeDto.class, name = "ReadingType"),
92+
@JsonSubTypes.Type(value = TimeConfigurationDto.class, name = "TimeConfiguration"),
93+
@JsonSubTypes.Type(value = UsagePointDto.class, name = "UsagePoint"),
94+
@JsonSubTypes.Type(value = UsageSummaryDto.class, name = "UsageSummary"),
95+
@JsonSubTypes.Type(value = CustomerDto.class, name = "Customer"),
96+
@JsonSubTypes.Type(value = CustomerAccountDto.class, name = "CustomerAccount"),
97+
@JsonSubTypes.Type(value = CustomerAgreementDto.class, name = "CustomerAgreement"),
98+
@JsonSubTypes.Type(value = EndDeviceDto.class, name = "EndDevice"),
99+
@JsonSubTypes.Type(value = MeterDto.class, name = "Meter"),
100+
@JsonSubTypes.Type(value = ProgramDateIdMappingsDto.class, name = "ProgramDateIdMappings"),
101+
@JsonSubTypes.Type(value = ServiceLocationDto.class, name = "ServiceLocation"),
102+
@JsonSubTypes.Type(value = StatementDto.class, name = "Statement")
87103
// TODO: Add when ServiceSupplierDto is implemented:
88-
// @JsonSubTypes.Type(value = ServiceSupplierDto.class, name = "cust:ServiceSupplier")
104+
// @JsonSubTypes.Type(value = ServiceSupplierDto.class, name = "ServiceSupplier")
89105
})
90106
@XmlAnyElement(lax = true)
91107
@XmlElement(name = "content", namespace = "http://www.w3.org/2005/Atom")
@@ -122,16 +138,20 @@ public AtomEntryDto(String id, String title, OffsetDateTime published,
122138
}
123139

124140
/**
125-
* Constructor for basic entry data with auto-generated timestamps.
141+
* Convenience constructor for testing with auto-generated timestamps.
142+
* Creates an AtomEntryDto with current timestamp and no links.
143+
*
144+
* @param id the entry identifier (urn:uuid:xxx format)
145+
* @param title the entry title
146+
* @param content the resource content (payload moved directly to AtomEntryDto)
126147
*/
127-
public AtomEntryDto(String id, String title, Object resource) {
148+
public AtomEntryDto(String id, String title, Object content) {
128149
LocalDateTime localDateTime = LocalDateTime.now().truncatedTo(java.time.temporal.ChronoUnit.SECONDS);
129150
OffsetDateTime now = localDateTime.atOffset(ZoneOffset.UTC).toZonedDateTime().toOffsetDateTime();
130-
131-
this(id, title, now, now, null,
132-
new AtomContentDto("application/xml", resource), null, null);
151+
this(id, title, now, now, null, content, null, null);
133152
}
134-
153+
154+
135155
/**
136156
* Gets the self link from the entry links.
137157
*

openespi-common/src/main/java/org/greenbuttonalliance/espi/common/dto/usage/ElectricPowerQualitySummaryDto.java

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -34,22 +34,19 @@
3434
@XmlRootElement(name = "ElectricPowerQualitySummary", namespace = "http://naesb.org/espi")
3535
@XmlAccessorType(XmlAccessType.FIELD)
3636
@XmlType(name = "ElectricPowerQualitySummary", namespace = "http://naesb.org/espi", propOrder = {
37-
"description", "flickerPlt", "flickerPst", "harmonicVoltage", "longInterruptions",
38-
"mainsVoltage", "measurementProtocol", "powerFrequency", "rapidVoltageChanges",
39-
"shortInterruptions", "summaryInterval", "supplyVoltageDips", "supplyVoltageImbalance",
40-
"supplyVoltageVariations", "tempOvervoltage", "usagePointId"
37+
"flickerPlt", "flickerPst", "harmonicVoltage", "longInterruptions",
38+
"mainsVoltage", "measurementProtocol", "powerFrequency", "rapidVoltageChanges",
39+
"shortInterruptions", "summaryInterval", "supplyVoltageDips", "supplyVoltageImbalance",
40+
"supplyVoltageVariations", "tempOvervoltage"
4141
})
4242
public record ElectricPowerQualitySummaryDto(
43-
43+
4444
@XmlTransient
4545
Long id,
46-
46+
4747
@XmlAttribute(name = "mRID")
4848
String uuid,
4949

50-
@XmlElement(name = "description")
51-
String description,
52-
5350
/**
5451
* Flicker PLT (Long-term) measurement.
5552
* Represents long-term flicker severity as per IEC 61000-4-15.
@@ -181,19 +178,18 @@ public record ElectricPowerQualitySummaryDto(
181178
* Default constructor for JAXB.
182179
*/
183180
public ElectricPowerQualitySummaryDto() {
184-
this(null, null, null, null, null, null, null, null, null, null, null, null, null,
185-
null, null, null, null, null);
181+
this(null, null, null, null, null, null, null, null, null, null, null,
182+
null, null, null, null, null, null);
186183
}
187-
184+
188185
/**
189186
* Constructor with basic identification.
190-
*
187+
*
191188
* @param id the database identifier
192189
* @param uuid the unique resource identifier
193-
* @param description human-readable description
194190
*/
195-
public ElectricPowerQualitySummaryDto(Long id, String uuid, String description) {
196-
this(id, uuid, description, null, null, null, null, null, null, null, null, null,
191+
public ElectricPowerQualitySummaryDto(Long id, String uuid) {
192+
this(id, uuid, null, null, null, null, null, null, null, null, null,
197193
null, null, null, null, null, null);
198194
}
199195

0 commit comments

Comments
 (0)