Skip to content

Commit e4c015d

Browse files
committed
explicit usage of reservation table fields in repository
1 parent 0c54cdf commit e4c015d

File tree

2 files changed

+22
-13
lines changed

2 files changed

+22
-13
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<modelVersion>4.0.0</modelVersion>
44
<groupId>de.rwth.idsg</groupId>
55
<artifactId>steve</artifactId>
6-
<version>1.1.0</version>
6+
<version>1.1.1</version>
77
<packaging>jar</packaging>
88

99
<developers>

src/main/java/de/rwth/idsg/steve/repository/ReservationRepositoryImpl.java

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
import de.rwth.idsg.steve.repository.dto.Reservation;
55
import de.rwth.idsg.steve.utils.DateTimeUtils;
66
import de.rwth.idsg.steve.web.dto.ReservationQueryForm;
7-
import jooq.steve.db.tables.records.ReservationRecord;
87
import lombok.extern.slf4j.Slf4j;
98
import org.jooq.Configuration;
9+
import org.jooq.Record7;
1010
import org.jooq.RecordMapper;
1111
import org.jooq.SelectQuery;
1212
import org.jooq.exception.DataAccessException;
@@ -38,7 +38,15 @@ public class ReservationRepositoryImpl implements ReservationRepository {
3838
public List<Reservation> getReservations(ReservationQueryForm form) {
3939
SelectQuery selectQuery = DSL.using(config).selectQuery();
4040
selectQuery.addFrom(RESERVATION);
41-
selectQuery.addSelect(RESERVATION.fields());
41+
selectQuery.addSelect(
42+
RESERVATION.RESERVATION_PK,
43+
RESERVATION.TRANSACTION_PK,
44+
RESERVATION.IDTAG,
45+
RESERVATION.CHARGEBOXID,
46+
RESERVATION.STARTDATETIME,
47+
RESERVATION.EXPIRYDATETIME,
48+
RESERVATION.STATUS
49+
);
4250

4351
if (form.isChargeBoxIdSet()) {
4452
selectQuery.addConditions(RESERVATION.CHARGEBOXID.eq(form.getChargeBoxId()));
@@ -162,18 +170,19 @@ private void internalUpdateReservation(int reservationId, ReservationStatus stat
162170
// Private helpers
163171
// -------------------------------------------------------------------------
164172

165-
private class ReservationMapper implements RecordMapper<ReservationRecord, Reservation> {
173+
private class ReservationMapper implements
174+
RecordMapper<Record7<Integer, Integer, String, String, Timestamp, Timestamp, String>, Reservation> {
166175
@Override
167-
public Reservation map(ReservationRecord r) {
176+
public Reservation map(Record7<Integer, Integer, String, String, Timestamp, Timestamp, String> r) {
168177
return Reservation.builder()
169-
.id(r.getReservationPk())
170-
.transactionId(r.getTransactionPk())
171-
.idTag(r.getIdtag())
172-
.chargeBoxId(r.getChargeboxid())
173-
.startDatetime(DateTimeUtils.humanize(r.getStartdatetime()))
174-
.expiryDatetime(DateTimeUtils.humanize(r.getExpirydatetime()))
175-
.status(r.getStatus())
176-
.build();
178+
.id(r.value1())
179+
.transactionId(r.value2())
180+
.idTag(r.value3())
181+
.chargeBoxId(r.value4())
182+
.startDatetime(DateTimeUtils.humanize(r.value5()))
183+
.expiryDatetime(DateTimeUtils.humanize(r.value6()))
184+
.status(r.value7())
185+
.build();
177186
}
178187
}
179188

0 commit comments

Comments
 (0)