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

Commit 07269e0

Browse files
dfcoffinclaude
andcommitted
Step 1: Create MapStruct mappers for Entity-DTO conversion
- Add 13 MapStruct mappers for core Green Button resources - Usage mappers: UsagePoint, MeterReading, IntervalBlock, IntervalReading, ReadingType, etc. - Customer mappers: Customer, CustomerAccount, CustomerAgreement - Central GreenButtonMapper for unified access - Add missing DTOs: IntervalReadingDto, ReadingQualityDto - All mappers support bidirectional Entity ↔ DTO conversion - Ignore JPA-specific fields during DTO mapping - Support update operations for merge scenarios 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent d2d71b3 commit 07269e0

16 files changed

+1628
-0
lines changed
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
/*
2+
*
3+
* Copyright (c) 2018-2025 Green Button Alliance, Inc.
4+
*
5+
* Portions (c) 2013-2018 EnergyOS.org
6+
*
7+
* Licensed under the Apache License, Version 2.0 (the "License");
8+
* you may not use this file except in compliance with the License.
9+
* You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software
14+
* distributed under the License is distributed on an "AS IS" BASIS,
15+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
* See the License for the specific language governing permissions and
17+
* limitations under the License.
18+
*
19+
*/
20+
21+
package org.greenbuttonalliance.espi.common.dto.usage;
22+
23+
import org.greenbuttonalliance.espi.common.dto.atom.LinkDto;
24+
25+
import jakarta.xml.bind.annotation.*;
26+
import java.time.OffsetDateTime;
27+
import java.util.List;
28+
29+
/**
30+
* IntervalReading DTO record for JAXB XML marshalling/unmarshalling.
31+
*
32+
* Represents specific readings of a measurement within an interval block.
33+
* Contains the actual energy values, costs, and reading quality information.
34+
*/
35+
@XmlRootElement(name = "IntervalReading", namespace = "http://naesb.org/espi")
36+
@XmlAccessorType(XmlAccessType.FIELD)
37+
@XmlType(name = "IntervalReading", namespace = "http://naesb.org/espi", propOrder = {
38+
"uuid", "published", "updated", "selfLink", "upLink", "relatedLinks",
39+
"description", "cost", "currency", "value", "timePeriod", "readingQualities",
40+
"consumptionTier", "tou", "cpp"
41+
})
42+
public record IntervalReadingDto(
43+
44+
@XmlAttribute(name = "mRID")
45+
String uuid,
46+
47+
@XmlElement(name = "published")
48+
OffsetDateTime published,
49+
50+
@XmlElement(name = "updated")
51+
OffsetDateTime updated,
52+
53+
@XmlElement(name = "link", namespace = "http://www.w3.org/2005/Atom")
54+
@XmlElementWrapper(name = "links", namespace = "http://www.w3.org/2005/Atom")
55+
List<LinkDto> relatedLinks,
56+
57+
@XmlElement(name = "link", namespace = "http://www.w3.org/2005/Atom")
58+
LinkDto selfLink,
59+
60+
@XmlElement(name = "link", namespace = "http://www.w3.org/2005/Atom")
61+
LinkDto upLink,
62+
63+
@XmlElement(name = "description")
64+
String description,
65+
66+
@XmlElement(name = "cost")
67+
Long cost,
68+
69+
@XmlElement(name = "currency")
70+
Integer currency,
71+
72+
@XmlElement(name = "value")
73+
Long value,
74+
75+
@XmlElement(name = "timePeriod")
76+
DateTimeIntervalDto timePeriod,
77+
78+
@XmlElement(name = "ReadingQuality")
79+
@XmlElementWrapper(name = "ReadingQualities")
80+
List<ReadingQualityDto> readingQualities,
81+
82+
@XmlElement(name = "consumptionTier")
83+
Integer consumptionTier,
84+
85+
@XmlElement(name = "tou")
86+
Integer tou,
87+
88+
@XmlElement(name = "cpp")
89+
Integer cpp
90+
) {
91+
92+
/**
93+
* Default constructor for JAXB.
94+
*/
95+
public IntervalReadingDto() {
96+
this(null, null, null, null, null, null, null, null, null, null, null, null, null, null, null);
97+
}
98+
99+
/**
100+
* Minimal constructor for basic interval reading data.
101+
*/
102+
public IntervalReadingDto(String uuid, Long value, DateTimeIntervalDto timePeriod) {
103+
this(uuid, null, null, null, null, null, null, null, null, value, timePeriod, null, null, null, null);
104+
}
105+
106+
/**
107+
* Constructor for interval reading with cost information.
108+
*/
109+
public IntervalReadingDto(String uuid, Long value, Long cost, Integer currency, DateTimeIntervalDto timePeriod) {
110+
this(uuid, null, null, null, null, null, null, cost, currency, value, timePeriod, null, null, null, null);
111+
}
112+
}
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
/*
2+
*
3+
* Copyright (c) 2018-2025 Green Button Alliance, Inc.
4+
*
5+
* Portions (c) 2013-2018 EnergyOS.org
6+
*
7+
* Licensed under the Apache License, Version 2.0 (the "License");
8+
* you may not use this file except in compliance with the License.
9+
* You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software
14+
* distributed under the License is distributed on an "AS IS" BASIS,
15+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
* See the License for the specific language governing permissions and
17+
* limitations under the License.
18+
*
19+
*/
20+
21+
package org.greenbuttonalliance.espi.common.dto.usage;
22+
23+
import org.greenbuttonalliance.espi.common.dto.atom.LinkDto;
24+
25+
import jakarta.xml.bind.annotation.*;
26+
import java.time.OffsetDateTime;
27+
import java.util.List;
28+
29+
/**
30+
* ReadingQuality DTO record for JAXB XML marshalling/unmarshalling.
31+
*
32+
* Represents quality indicators for readings, providing information about
33+
* the accuracy, validation status, and reliability of meter readings.
34+
*/
35+
@XmlRootElement(name = "ReadingQuality", namespace = "http://naesb.org/espi")
36+
@XmlAccessorType(XmlAccessType.FIELD)
37+
@XmlType(name = "ReadingQuality", namespace = "http://naesb.org/espi", propOrder = {
38+
"uuid", "published", "updated", "selfLink", "upLink", "relatedLinks",
39+
"description", "quality"
40+
})
41+
public record ReadingQualityDto(
42+
43+
@XmlAttribute(name = "mRID")
44+
String uuid,
45+
46+
@XmlElement(name = "published")
47+
OffsetDateTime published,
48+
49+
@XmlElement(name = "updated")
50+
OffsetDateTime updated,
51+
52+
@XmlElement(name = "link", namespace = "http://www.w3.org/2005/Atom")
53+
@XmlElementWrapper(name = "links", namespace = "http://www.w3.org/2005/Atom")
54+
List<LinkDto> relatedLinks,
55+
56+
@XmlElement(name = "link", namespace = "http://www.w3.org/2005/Atom")
57+
LinkDto selfLink,
58+
59+
@XmlElement(name = "link", namespace = "http://www.w3.org/2005/Atom")
60+
LinkDto upLink,
61+
62+
@XmlElement(name = "description")
63+
String description,
64+
65+
@XmlElement(name = "quality")
66+
String quality
67+
) {
68+
69+
/**
70+
* Default constructor for JAXB.
71+
*/
72+
public ReadingQualityDto() {
73+
this(null, null, null, null, null, null, null, null);
74+
}
75+
76+
/**
77+
* Minimal constructor for basic reading quality data.
78+
*/
79+
public ReadingQualityDto(String uuid, String quality) {
80+
this(uuid, null, null, null, null, null, null, quality);
81+
}
82+
83+
/**
84+
* Constructor with description.
85+
*/
86+
public ReadingQualityDto(String uuid, String description, String quality) {
87+
this(uuid, null, null, null, null, null, description, quality);
88+
}
89+
}
Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
/*
2+
*
3+
* Copyright (c) 2018-2025 Green Button Alliance, Inc.
4+
*
5+
* Portions (c) 2013-2018 EnergyOS.org
6+
*
7+
* Licensed under the Apache License, Version 2.0 (the "License");
8+
* you may not use this file except in compliance with the License.
9+
* You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software
14+
* distributed under the License is distributed on an "AS IS" BASIS,
15+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
* See the License for the specific language governing permissions and
17+
* limitations under the License.
18+
*
19+
*/
20+
21+
package org.greenbuttonalliance.espi.common.mapper;
22+
23+
import org.greenbuttonalliance.espi.common.mapper.customer.CustomerMapper;
24+
import org.greenbuttonalliance.espi.common.mapper.customer.CustomerAccountMapper;
25+
import org.greenbuttonalliance.espi.common.mapper.customer.CustomerAgreementMapper;
26+
import org.greenbuttonalliance.espi.common.mapper.usage.*;
27+
import org.mapstruct.Mapper;
28+
29+
/**
30+
* Comprehensive MapStruct mapper that aggregates all entity-DTO mappers.
31+
*
32+
* This central mapper provides access to all Green Button resource mappers
33+
* and is designed to be injected as a single Spring component for use
34+
* in services and controllers.
35+
*/
36+
@Mapper(componentModel = "spring", uses = {
37+
// Usage mappers
38+
UsagePointMapper.class,
39+
MeterReadingMapper.class,
40+
IntervalBlockMapper.class,
41+
IntervalReadingMapper.class,
42+
ReadingTypeMapper.class,
43+
ReadingQualityMapper.class,
44+
UsageSummaryMapper.class,
45+
ElectricPowerQualitySummaryMapper.class,
46+
ServiceDeliveryPointMapper.class,
47+
DateTimeIntervalMapper.class,
48+
49+
// Customer mappers
50+
CustomerMapper.class,
51+
CustomerAccountMapper.class,
52+
CustomerAgreementMapper.class
53+
})
54+
public interface GreenButtonMapper {
55+
56+
/**
57+
* Get the usage point mapper.
58+
*
59+
* @return usage point mapper instance
60+
*/
61+
UsagePointMapper usagePoint();
62+
63+
/**
64+
* Get the meter reading mapper.
65+
*
66+
* @return meter reading mapper instance
67+
*/
68+
MeterReadingMapper meterReading();
69+
70+
/**
71+
* Get the interval block mapper.
72+
*
73+
* @return interval block mapper instance
74+
*/
75+
IntervalBlockMapper intervalBlock();
76+
77+
/**
78+
* Get the interval reading mapper.
79+
*
80+
* @return interval reading mapper instance
81+
*/
82+
IntervalReadingMapper intervalReading();
83+
84+
/**
85+
* Get the reading type mapper.
86+
*
87+
* @return reading type mapper instance
88+
*/
89+
ReadingTypeMapper readingType();
90+
91+
/**
92+
* Get the reading quality mapper.
93+
*
94+
* @return reading quality mapper instance
95+
*/
96+
ReadingQualityMapper readingQuality();
97+
98+
/**
99+
* Get the usage summary mapper.
100+
*
101+
* @return usage summary mapper instance
102+
*/
103+
UsageSummaryMapper usageSummary();
104+
105+
/**
106+
* Get the electric power quality summary mapper.
107+
*
108+
* @return electric power quality summary mapper instance
109+
*/
110+
ElectricPowerQualitySummaryMapper electricPowerQualitySummary();
111+
112+
/**
113+
* Get the service delivery point mapper.
114+
*
115+
* @return service delivery point mapper instance
116+
*/
117+
ServiceDeliveryPointMapper serviceDeliveryPoint();
118+
119+
/**
120+
* Get the date/time interval mapper.
121+
*
122+
* @return date/time interval mapper instance
123+
*/
124+
DateTimeIntervalMapper dateTimeInterval();
125+
126+
/**
127+
* Get the customer mapper.
128+
*
129+
* @return customer mapper instance
130+
*/
131+
CustomerMapper customer();
132+
133+
/**
134+
* Get the customer account mapper.
135+
*
136+
* @return customer account mapper instance
137+
*/
138+
CustomerAccountMapper customerAccount();
139+
140+
/**
141+
* Get the customer agreement mapper.
142+
*
143+
* @return customer agreement mapper instance
144+
*/
145+
CustomerAgreementMapper customerAgreement();
146+
}

0 commit comments

Comments
 (0)