@@ -155,54 +155,50 @@ public void insertMeterValues(String chargeBoxIdentity, List<MeterValue> list, i
155155
156156 @ Override
157157 public Integer insertTransaction (InsertTransactionParams p ) {
158- return ctx .transactionResult (configuration -> {
159- DSLContext ctx = DSL .using (configuration );
160-
161- insertIgnoreConnector (ctx , p .getChargeBoxId (), p .getConnectorId ());
158+ insertIgnoreConnector (ctx , p .getChargeBoxId (), p .getConnectorId ());
162159
163- // it is important to insert idTag before transaction, since the transaction table references it
164- boolean unknownTagInserted = insertIgnoreIdTag (ctx , p );
160+ // it is important to insert idTag before transaction, since the transaction table references it
161+ boolean unknownTagInserted = insertIgnoreIdTag (ctx , p );
165162
166- SelectConditionStep <Record1 <Integer >> connectorPkQuery =
167- DSL .select (CONNECTOR .CONNECTOR_PK )
168- .from (CONNECTOR )
169- .where (CONNECTOR .CHARGE_BOX_ID .equal (p .getChargeBoxId ()))
170- .and (CONNECTOR .CONNECTOR_ID .equal (p .getConnectorId ()));
171-
172- // -------------------------------------------------------------------------
173- // Step 1: Insert transaction
174- // -------------------------------------------------------------------------
163+ SelectConditionStep <Record1 <Integer >> connectorPkQuery =
164+ DSL .select (CONNECTOR .CONNECTOR_PK )
165+ .from (CONNECTOR )
166+ .where (CONNECTOR .CHARGE_BOX_ID .equal (p .getChargeBoxId ()))
167+ .and (CONNECTOR .CONNECTOR_ID .equal (p .getConnectorId ()));
175168
176- int transactionId = ctx .insertInto (TRANSACTION )
177- .set (CONNECTOR_STATUS .CONNECTOR_PK , connectorPkQuery )
178- .set (TRANSACTION .ID_TAG , p .getIdTag ())
179- .set (TRANSACTION .START_TIMESTAMP , p .getStartTimestamp ())
180- .set (TRANSACTION .START_VALUE , p .getStartMeterValue ())
181- .returning (TRANSACTION .TRANSACTION_PK )
182- .fetchOne ()
183- .getTransactionPk ();
169+ // -------------------------------------------------------------------------
170+ // Step 1: Insert transaction
171+ // -------------------------------------------------------------------------
184172
185- if (unknownTagInserted ) {
186- log .warn ("The transaction '{}' contains an unknown idTag '{}' which was inserted into DB "
187- + "to prevent information loss and has been blocked" , transactionId , p .getIdTag ());
188- }
173+ int transactionId = ctx .insertInto (TRANSACTION )
174+ .set (CONNECTOR_STATUS .CONNECTOR_PK , connectorPkQuery )
175+ .set (TRANSACTION .ID_TAG , p .getIdTag ())
176+ .set (TRANSACTION .START_TIMESTAMP , p .getStartTimestamp ())
177+ .set (TRANSACTION .START_VALUE , p .getStartMeterValue ())
178+ .returning (TRANSACTION .TRANSACTION_PK )
179+ .fetchOne ()
180+ .getTransactionPk ();
181+
182+ if (unknownTagInserted ) {
183+ log .warn ("The transaction '{}' contains an unknown idTag '{}' which was inserted into DB "
184+ + "to prevent information loss and has been blocked" , transactionId , p .getIdTag ());
185+ }
189186
190- // -------------------------------------------------------------------------
191- // Step 2 for OCPP 1.5: A startTransaction may be related to a reservation
192- // -------------------------------------------------------------------------
187+ // -------------------------------------------------------------------------
188+ // Step 2 for OCPP 1.5: A startTransaction may be related to a reservation
189+ // -------------------------------------------------------------------------
193190
194- if (p .isSetReservationId ()) {
195- reservationRepository .used (ctx , connectorPkQuery , p .getIdTag (), p .getReservationId (), transactionId );
196- }
191+ if (p .isSetReservationId ()) {
192+ reservationRepository .used (connectorPkQuery , p .getIdTag (), p .getReservationId (), transactionId );
193+ }
197194
198- // -------------------------------------------------------------------------
199- // Step 3: Set connector status to "Occupied"
200- // -------------------------------------------------------------------------
195+ // -------------------------------------------------------------------------
196+ // Step 3: Set connector status to "Occupied"
197+ // -------------------------------------------------------------------------
201198
202- insertConnectorStatus (ctx , connectorPkQuery , p .getStartTimestamp (), p .getStatusUpdate ());
199+ insertConnectorStatus (ctx , connectorPkQuery , p .getStartTimestamp (), p .getStatusUpdate ());
203200
204- return transactionId ;
205- });
201+ return transactionId ;
206202 }
207203
208204 @ Override
0 commit comments