Skip to content

Commit

Permalink
refactor ChargePointSelect to use OcppProtocol
Browse files Browse the repository at this point in the history
this DTO should include the protocol which contains transport and version info.
this would enable to unify some logic wrt. Invoker and Client classes.
  • Loading branch information
goekay committed Jan 5, 2025
1 parent 415e1d5 commit 48a57c9
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
*/
package de.rwth.idsg.steve.repository.dto;

import de.rwth.idsg.steve.ocpp.OcppProtocol;
import de.rwth.idsg.steve.ocpp.OcppTransport;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
Expand All @@ -29,21 +30,21 @@
@RequiredArgsConstructor
@Getter
public final class ChargePointSelect {
private final OcppTransport ocppTransport;
private final OcppProtocol ocppProtocol;
private final String chargeBoxId;
private final String endpointAddress;

public ChargePointSelect(OcppTransport ocppTransport, String chargeBoxId) {
public ChargePointSelect(OcppProtocol ocppProtocol, String chargeBoxId) {
// Provide a non-null value (or placeholder if you will) to frontend for JSON charge points.
// This is clearly a hack. Not my proudest moment.
this(ocppTransport, chargeBoxId, "-");
this(ocppProtocol, chargeBoxId, "-");
}

public boolean isEndpointAddressSet() {
return !("-".equals(endpointAddress));
}

public boolean isSoap() {
return OcppTransport.SOAP == ocppTransport;
return OcppTransport.SOAP == ocppProtocol.getTransport();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public List<ChargePointSelect> getChargePointSelect(OcppProtocol protocol, List<
.and(CHARGE_BOX.REGISTRATION_STATUS.in(inStatusFilter))
.and(chargeBoxIdCondition)
.fetch()
.map(r -> new ChargePointSelect(protocol.getTransport(), r.value1(), r.value2()));
.map(r -> new ChargePointSelect(protocol, r.value1(), r.value2()));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/
package de.rwth.idsg.steve.web;

import de.rwth.idsg.steve.ocpp.OcppTransport;
import de.rwth.idsg.steve.ocpp.OcppProtocol;
import de.rwth.idsg.steve.repository.dto.ChargePointSelect;

import java.beans.PropertyEditorSupport;
Expand All @@ -34,11 +34,11 @@ public void setAsText(String text) {
if (!text.isEmpty()) {
String[] chargePointItem = text.split(";");

// chargePointItem[0] : ocpp transport type
// chargePointItem[0] : ocpp protocol
// chargePointItem[1] : chargebox id
// chargePointItem[2] : endpoint (IP) address
ChargePointSelect cps = new ChargePointSelect(
OcppTransport.fromName(chargePointItem[0]),
OcppProtocol.fromCompositeValue(chargePointItem[0]),
chargePointItem[1],
chargePointItem[2]
);
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/webapp/WEB-INF/views/00-cp-multiple.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<td>
<form:select path="chargePointSelectList" size="5" multiple="true">
<c:forEach items="${cpList}" var="cp">
<form:option value="${cp.ocppTransport};${cp.chargeBoxId};${cp.endpointAddress}" label="${cp.chargeBoxId}"/>
<form:option value="${cp.ocppProtocol};${cp.chargeBoxId};${cp.endpointAddress}" label="${cp.chargeBoxId}"/>
</c:forEach>
</form:select>
</td>
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/webapp/WEB-INF/views/00-cp-single.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<td>
<form:select path="chargePointSelectList" size="5" multiple="false">
<c:forEach items="${cpList}" var="cp">
<form:option value="${cp.ocppTransport};${cp.chargeBoxId};${cp.endpointAddress}" label="${cp.chargeBoxId}"/>
<form:option value="${cp.ocppProtocol};${cp.chargeBoxId};${cp.endpointAddress}" label="${cp.chargeBoxId}"/>
</c:forEach>
</form:select>
</td>
Expand Down

0 comments on commit 48a57c9

Please sign in to comment.