Skip to content
This repository was archived by the owner on Jul 1, 2025. It is now read-only.

Commit d2d71b3

Browse files
dfcoffinclaude
andcommitted
Complete Atom protocol implementation for DTO architecture
- Added missing 'published' field to AtomFeedDto for complete Atom feed compliance - Properly separated Atom protocol fields from business resource fields - AtomFeedDto and AtomEntryDto contain Atom metadata (id, title, published, updated) - Business DTOs (UsagePointDto, CustomerDto) contain only resource-specific data - Cleaned up unused imports and methods in refactored DTOs - Architecture now matches Green Button Atom XML structure with proper separation 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent 2e14064 commit d2d71b3

File tree

3 files changed

+12
-111
lines changed

3 files changed

+12
-111
lines changed

src/main/java/org/greenbuttonalliance/espi/common/dto/atom/AtomFeedDto.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
@XmlRootElement(name = "feed", namespace = "http://www.w3.org/2005/Atom")
3434
@XmlAccessorType(XmlAccessType.FIELD)
3535
@XmlType(name = "AtomFeed", namespace = "http://www.w3.org/2005/Atom", propOrder = {
36-
"id", "title", "updated", "links", "entries"
36+
"id", "title", "published", "updated", "links", "entries"
3737
})
3838
public record AtomFeedDto(
3939

@@ -43,6 +43,9 @@ public record AtomFeedDto(
4343
@XmlElement(name = "title", namespace = "http://www.w3.org/2005/Atom")
4444
String title,
4545

46+
@XmlElement(name = "published", namespace = "http://www.w3.org/2005/Atom")
47+
OffsetDateTime published,
48+
4649
@XmlElement(name = "updated", namespace = "http://www.w3.org/2005/Atom")
4750
OffsetDateTime updated,
4851

@@ -57,14 +60,14 @@ public record AtomFeedDto(
5760
* Default constructor for JAXB.
5861
*/
5962
public AtomFeedDto() {
60-
this(null, null, null, null, null);
63+
this(null, null, null, null, null, null);
6164
}
6265

6366
/**
6467
* Constructor for basic feed data.
6568
*/
6669
public AtomFeedDto(String id, String title) {
67-
this(id, title, OffsetDateTime.now(), null, null);
70+
this(id, title, OffsetDateTime.now(), OffsetDateTime.now(), null, null);
6871
}
6972

7073
/**

src/main/java/org/greenbuttonalliance/espi/common/dto/customer/CustomerDto.java

Lines changed: 3 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,8 @@
2121
package org.greenbuttonalliance.espi.common.dto.customer;
2222

2323
import org.greenbuttonalliance.espi.common.domain.customer.enums.CustomerKind;
24-
import org.greenbuttonalliance.espi.common.dto.atom.LinkDto;
2524

2625
import jakarta.xml.bind.annotation.*;
27-
import java.time.OffsetDateTime;
2826
import java.util.List;
2927

3028
/**
@@ -36,33 +34,13 @@
3634
@XmlRootElement(name = "Customer", namespace = "http://naesb.org/espi/customer")
3735
@XmlAccessorType(XmlAccessType.FIELD)
3836
@XmlType(name = "Customer", namespace = "http://naesb.org/espi/customer", propOrder = {
39-
"id", "uuid", "published", "updated", "selfLink", "upLink", "relatedLinks",
40-
"description", "kind", "specialNeed", "status", "pucNumber", "customerAccounts"
37+
"uuid", "description", "kind", "specialNeed", "status", "pucNumber", "customerAccounts"
4138
})
4239
public record CustomerDto(
4340

44-
@XmlTransient
45-
Long id,
46-
4741
@XmlAttribute(name = "mRID")
4842
String uuid,
4943

50-
@XmlElement(name = "published")
51-
OffsetDateTime published,
52-
53-
@XmlElement(name = "updated")
54-
OffsetDateTime updated,
55-
56-
@XmlElement(name = "link", namespace = "http://www.w3.org/2005/Atom")
57-
@XmlElementWrapper(name = "links", namespace = "http://www.w3.org/2005/Atom")
58-
List<LinkDto> relatedLinks,
59-
60-
@XmlElement(name = "link", namespace = "http://www.w3.org/2005/Atom")
61-
LinkDto selfLink,
62-
63-
@XmlElement(name = "link", namespace = "http://www.w3.org/2005/Atom")
64-
LinkDto upLink,
65-
6644
@XmlElement(name = "description")
6745
String description,
6846

@@ -87,51 +65,13 @@ public record CustomerDto(
8765
* Default constructor for JAXB.
8866
*/
8967
public CustomerDto() {
90-
this(null, null, null, null, null, null, null, null,
91-
null, null, null, null, null);
68+
this(null, null, null, null, null, null, null);
9269
}
9370

9471
/**
9572
* Minimal constructor for basic customer data.
9673
*/
9774
public CustomerDto(String uuid, CustomerKind kind) {
98-
this(null, uuid, null, null, null, null, null, null,
99-
kind, null, null, null, null);
100-
}
101-
102-
/**
103-
* Gets the self href for this customer.
104-
*
105-
* @return self href string
106-
*/
107-
public String getSelfHref() {
108-
return selfLink != null ? selfLink.href() : null;
109-
}
110-
111-
/**
112-
* Gets the up href for this customer.
113-
*
114-
* @return up href string
115-
*/
116-
public String getUpHref() {
117-
return upLink != null ? upLink.href() : null;
118-
}
119-
120-
/**
121-
* Generates the default self href for a customer.
122-
*
123-
* @return default self href
124-
*/
125-
public String generateSelfHref() {
126-
return uuid != null ? "/espi/1_1/resource/Customer/" + uuid : null;
127-
}
128-
129-
/**
130-
* Generates the default up href for a customer.
131-
*
132-
* @return default up href
133-
*/
134-
public String generateUpHref() {
135-
return "/espi/1_1/resource/Customer";
75+
this(uuid, null, kind, null, null, null, null);
13676
}
13777
}

src/main/java/org/greenbuttonalliance/espi/common/dto/usage/UsagePointDto.java

Lines changed: 3 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,10 @@
2121
package org.greenbuttonalliance.espi.common.dto.usage;
2222

2323
import org.greenbuttonalliance.espi.common.domain.ServiceCategory;
24-
import org.greenbuttonalliance.espi.common.dto.atom.LinkDto;
2524

2625
import jakarta.xml.bind.annotation.*;
2726
import jakarta.xml.bind.annotation.adapters.HexBinaryAdapter;
2827
import jakarta.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
29-
import java.time.OffsetDateTime;
3028
import java.util.List;
3129

3230
/**
@@ -39,34 +37,14 @@
3937
@XmlRootElement(name = "UsagePoint", namespace = "http://naesb.org/espi")
4038
@XmlAccessorType(XmlAccessType.FIELD)
4139
@XmlType(name = "UsagePoint", namespace = "http://naesb.org/espi", propOrder = {
42-
"id", "uuid", "published", "updated", "selfLink", "upLink", "relatedLinks",
43-
"description", "roleFlags", "serviceCategory", "status", "serviceDeliveryPoint",
40+
"uuid", "description", "roleFlags", "serviceCategory", "status", "serviceDeliveryPoint",
4441
"meterReadings", "usageSummaries", "electricPowerQualitySummaries"
4542
})
4643
public record UsagePointDto(
4744

48-
@XmlTransient
49-
Long id,
50-
5145
@XmlAttribute(name = "mRID")
5246
String uuid,
5347

54-
@XmlElement(name = "published")
55-
OffsetDateTime published,
56-
57-
@XmlElement(name = "updated")
58-
OffsetDateTime updated,
59-
60-
@XmlElement(name = "link", namespace = "http://www.w3.org/2005/Atom")
61-
@XmlElementWrapper(name = "links", namespace = "http://www.w3.org/2005/Atom")
62-
List<LinkDto> relatedLinks,
63-
64-
@XmlElement(name = "link", namespace = "http://www.w3.org/2005/Atom")
65-
LinkDto selfLink,
66-
67-
@XmlElement(name = "link", namespace = "http://www.w3.org/2005/Atom")
68-
LinkDto upLink,
69-
7048
@XmlElement(name = "description")
7149
String description,
7250

@@ -100,34 +78,14 @@ public record UsagePointDto(
10078
* Default constructor for JAXB.
10179
*/
10280
public UsagePointDto() {
103-
this(null, null, null, null, null, null, null, null,
104-
null, null, null, null, null, null, null);
81+
this(null, null, null, null, null, null, null, null, null);
10582
}
10683

10784
/**
10885
* Minimal constructor for basic usage point data.
10986
*/
11087
public UsagePointDto(String uuid, ServiceCategory serviceCategory) {
111-
this(null, uuid, null, null, null, null, null, null,
112-
null, serviceCategory, null, null, null, null, null);
113-
}
114-
115-
/**
116-
* Gets the self href for this usage point.
117-
*
118-
* @return self href string
119-
*/
120-
public String getSelfHref() {
121-
return selfLink != null ? selfLink.href() : null;
122-
}
123-
124-
/**
125-
* Gets the up href for this usage point.
126-
*
127-
* @return up href string
128-
*/
129-
public String getUpHref() {
130-
return upLink != null ? upLink.href() : null;
88+
this(uuid, null, null, serviceCategory, null, null, null, null, null);
13189
}
13290

13391
/**

0 commit comments

Comments
 (0)