@EventHandler public void handle(TransactionStartedEvent event) { LOG.debug("TransactionStartedEvent for [{}] received!", event.getChargingStationId()); StartTransactionInfo startTransactionInfo = event.getStartTransactionInfo(); IdentifyingToken identifyingToken = startTransactionInfo.getIdentifyingToken(); Transaction transaction = new Transaction(event.getChargingStationId().getId(), event.getTransactionId().getId(), startTransactionInfo.getEvseId(), identifyingToken.getToken(), startTransactionInfo.getMeterStart(), startTransactionInfo.getTimestamp(), identifyingToken.getMobilityServiceProvider(), identifyingToken.getVisibleId()); repository.createOrUpdate(transaction); }
@EventHandler protected void onEvent(TransactionStartedEvent event) { LOG.info("Sending notifyRequestResult for a TransactionStartedEvent to the source PMS"); String authorizationIdentifier = event.getStartTransactionInfo().getIdentifyingToken().getToken(); Integer transactionId = ((NumberedTransactionId) event.getTransactionId()).getNumber(); SessionInfo sessionInfo = destinationSessionRepository.findSessionInfoByAuthorizationId(authorizationIdentifier); sessionInfo.setTransactionId(transactionId); sessionInfo.getSessionStateMachine().eventStartOk(); sessionInfo.setMeterStart(event.getStartTransactionInfo().getMeterStart()); sessionInfo.setStartTimestamp(event.getStartTransactionInfo().getTimestamp()); destinationSessionRepository.insertOrUpdateSessionInfo(sessionInfo); String requestIdentifier = sessionInfo.getRequestIdentifier(); SourceEndpoint sourceEndpoint = sourceEndpointRepository.findSourceEndpointByPmsIdentifier(sessionInfo.getPmsIdentifier()); SourceClient sourceClient = new SourceClient(sourceEndpoint.getSourceEndpointUrl()); DestinationNotifyRequestResultRequest destinationNotifyRequestResultRequest = new DestinationNotifyRequestResultRequest(requestIdentifier); sourceClient.notifyRequestResult(destinationNotifyRequestResultRequest); LOG.info("Received a notifyRequestResultResponse from the source PMS"); }
/** * Handles a {@link StartTransactionCommand}. * * @param command the command which needs to be applied to the ChargingStation. */ @CommandHandler public void handle(StartTransactionCommand command, MetaData metaData) { if (command.getStartTransactionInfo().getEvseId().getNumberedId() > numberOfEvses) { apply(new EvseNotFoundEvent(id, command.getStartTransactionInfo().getEvseId(), command.getIdentityContext()), metaData); return; } apply(new TransactionStartedEvent(command.getChargingStationId(), command.getTransactionId(), command.getStartTransactionInfo(), command.getIdentityContext()), metaData); }