/** * Gets the textual representation of the transaction identifier. * <p/> * The textual representation is formed by concatenating the charging station identifier, protocol identifier, and * the transaction number. * * @return the textual representation of the transaction identifier. */ @Override public String getId() { return String.format("%s_%s_%s", chargingStationId.getId(), protocol, number); }
@Override public int getAuthorizationListVersion(ChargingStationId id) { ChargePointService chargePointService = this.createChargingStationService(id); GetLocalListVersionResponse response = chargePointService.getLocalListVersion(new GetLocalListVersionRequest(), id.getId()); int currentWhitelistVersion = response.getListVersion(); LOG.info("At the moment {} has authorizationlist version {}", id.getId(), currentWhitelistVersion); return currentWhitelistVersion; }
protected void checkAuthorization(ChargingStationId chargingStationId, UserIdentity userIdentity, Class commandClass) throws UserIdentityUnauthorizedException { if (!commandAuthorizationService.isAuthorized(chargingStationId, userIdentity, commandClass)) { throw new UserIdentityUnauthorizedException(chargingStationId.getId(), userIdentity, commandClass); } }
@Override public void onSuccess(Object o) { chargingStationRepository.createOrUpdate(new ChargingStation(chargingStationId.getId())); domainService.bootChargingStation(chargingStationId, protocol, attributes, addOnIdentity); }
private void createReservation(ChargingStationId chargingStationId, ReservationStatus status, String reservationId, UserIdentity userId, EvseId evseId, Date expiryDate) { Reservation reservation = new Reservation(chargingStationId.getId(), status, reservationId, userId.getId(), evseId, expiryDate); repository.createOrUpdate(reservation); }
public Map<String, String> getConfiguration(ChargingStationId id, Set<String> keys) { LOG.info("Retrieving configuration for {}", id); ChargePointService chargePointService = this.createChargingStationService(id); GetConfigurationRequest getConfigurationRequest = new GetConfigurationRequest(); getConfigurationRequest.getKey().addAll(keys); GetConfigurationResponse response = chargePointService.getConfiguration(getConfigurationRequest, id.getId()); Map<String, String> configurationItems = Maps.newHashMap(); for (KeyValue keyValue : response.getConfigurationKey()) { configurationItems.put(keyValue.getKey(), keyValue.getValue()); } return configurationItems; }
@Override public void updateFirmware(ChargingStationId id, String downloadLocation, Date retrieveDate, Integer numRetries, Integer retryInterval) { ChargePointService chargePointService = this.createChargingStationService(id); UpdateFirmwareRequest request = new UpdateFirmwareRequest(); request.setLocation(downloadLocation); request.setRetrieveDate(retrieveDate); request.setRetries(numRetries); request.setRetryInterval(retryInterval); chargePointService.updateFirmware(request, id.getId()); //The charging station will respond with an async 'firmware status update' message LOG.info("Update firmware on {} has been requested", id.getId()); }
@EventHandler public void handle(ChargingStationCreatedEvent event) { LOG.debug("ChargingStationCreatedEvent creates [{}] in operator api repo", event.getChargingStationId()); ChargingStation station = new ChargingStation(event.getChargingStationId().getId()); repository.createOrUpdate(station); }
@EventHandler public void handle(ChargingStationCreatedEvent event) { LOG.info("Handling ChargingStationCreatedEvent"); String chargingStationId = event.getChargingStationId().getId(); ChargingStation chargingStation = chargingStationRepository.findOne(chargingStationId); if (chargingStation == null) { chargingStation = new ChargingStation(chargingStationId); } chargingStationRepository.createOrUpdate(chargingStation); }
@EventHandler public void handle(ChargingStationConfiguredEvent event) { LOG.info("ChargingStationConfiguredEvent"); String chargingStationId = event.getChargingStationId().getId(); ChargingStation chargingStation = chargingStationRepository.findOne(chargingStationId); if (chargingStation == null) { LOG.info("Received a ChargingStationConfiguredEvent for unknown charging station. Creating the chargingStation."); chargingStation = new ChargingStation(chargingStationId); } chargingStation.setNumberOfEvses(event.getEvses().size()); chargingStation.setConfigured(true); chargingStationRepository.createOrUpdate(chargingStation); }
@EventHandler public void handle(ChargingStationBootedEvent event) { LOG.info("Handling ChargingStationBootedEvent"); ChargingStation chargingStation = chargingStationRepository.findOne(event.getChargingStationId().getId()); if (chargingStation != null) { chargingStation.setProtocol(event.getProtocol()); chargingStationRepository.createOrUpdate(chargingStation); } else { LOG.info("OCPP module repo could not find charging station {} and set the protocol", event.getChargingStationId()); } }
@EventHandler public void handle(ChargingStationAcceptedEvent event) { LOG.debug("ChargingStationAcceptedEvent for [{}] received!", event.getChargingStationId()); ChargingStation chargingStation = chargingStationRepository.findOne(event.getChargingStationId().getId()); if (chargingStation != null) { chargingStation.setRegistered(true); chargingStationRepository.createOrUpdate(chargingStation); } else { LOG.info("OCPP module repo COULD NOT FIND CHARGEPOINT {} and mark it as registered", event.getChargingStationId()); } }
/** * Handles {@code ChargingStationCreatedEvent} which contains the initial authorizations. Initial authorizations * are updated in the command authorization repository. * * @param event contains information about command authorization. */ @EventHandler public void handle(ChargingStationCreatedEvent event) { for (UserIdentity userIdentity : event.getUserIdentitiesWithAllPermissions()) { commandAuthorizationRepository.createOrUpdate(event.getChargingStationId().getId(), userIdentity.getId(), AllPermissions.class); } }
@EventHandler void onEvent(ChargingStationCreatedEvent event) { String chargingStationId = event.getChargingStationId().getId(); LocalAuthChargingStation chargingStation = chargingStationRepository.findOne(chargingStationId); if (chargingStation == null) { chargingStationRepository.createOrUpdate(new LocalAuthChargingStation(chargingStationId)); } }
@EventHandler void onEvent(ChargingStationCreatedEvent event) { String chargingStationId = event.getChargingStationId().getId(); ChargingStation chargingStation = repository.findOne(chargingStationId); if (chargingStation == null) { repository.createOrUpdate(new ChargingStation(chargingStationId, defaultAuthorizationProviders)); } }
@EventHandler public void handle(ChargingStationBootedEvent event) { LOG.debug("ChargingStationBootedEvent for [{}] received!", event.getChargingStationId()); ChargingStation chargingStation = repository.findOne(event.getChargingStationId().getId()); if (chargingStation != null) { chargingStation.setProtocol(event.getProtocol()); chargingStation.setAttributes(event.getAttributes()); repository.createOrUpdate(chargingStation); } else { LOG.error("operator api repo COULD NOT FIND CHARGEPOINT {} and mark it as booted", event.getChargingStationId()); } }
/** * Handles {@code PermissionRevokedEvent} by calling repository to remove the command authorization. * * @param event contains information about command authorization. */ @EventHandler public void handle(PermissionRevokedEvent event) { commandAuthorizationRepository.remove(event.getChargingStationId().getId(), event.getUserIdentity().getId(), event.getCommandClass()); }
/** * Handles {@code PermissionGrantedEvent} by calling repository to create or update the command authorization. * * @param event contains information about command authorization. */ @EventHandler public void handle(PermissionGrantedEvent event) { commandAuthorizationRepository.createOrUpdate(event.getChargingStationId().getId(), event.getUserIdentity().getId(), event.getCommandClass()); }
private RequestResult changeAvailability(ChargingStationId id, EvseId evseId, AvailabilityType type) { ChargePointService chargePointService = this.createChargingStationService(id); ChangeAvailabilityRequest request = new ChangeAvailabilityRequest(); request.setConnectorId(evseId.getNumberedId()); request.setType(type); ChangeAvailabilityResponse response = chargePointService.changeAvailability(request, id.getId()); if (AvailabilityStatus.ACCEPTED.equals(response.getStatus()) || AvailabilityStatus.SCHEDULED.equals(response.getStatus())) { return RequestResult.SUCCESS; } else { return RequestResult.FAILURE; } }
@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); }