/** * Converts a {@code Set} of {@code ConfigurationItem}s to a {@code Map} of {@code String} and {@code String}. * * @param configurationItems a {@code Set} of {@code ConfigurationItem}s. * @return a {@code Map} of {@code String} and {@code String}. */ private Map<String, String> toConfigurationItemMap(Set<ConfigurationItem> configurationItems) { Map<String, String> map = new HashMap<>(configurationItems.size()); for (ConfigurationItem configurationItem : configurationItems) { map.put(configurationItem.getKey(), configurationItem.getValue()); } return map; } }
/** * {@inheritDoc} */ @Override public void handle(ChargingStationId chargingStationId, WampMessage wampMessage, Gson gson, DomainService domainService, AddOnIdentity addOnIdentity) { ChangeconfigurationResponse response = gson.fromJson(wampMessage.getPayloadAsString(), ChangeconfigurationResponse.class); switch (response.getStatus()) { case ACCEPTED: LOG.info("Configuration change of {} on {} has been accepted", configurationItem.getKey(), configurationItem.getValue()); domainService.changeConfiguration(chargingStationId, configurationItem, getCorrelationToken(), addOnIdentity); break; case REJECTED: LOG.info("Configuration change of {} on {} was rejected", configurationItem.getKey(), configurationItem.getValue()); break; case NOT_SUPPORTED: LOG.info("Configuration change of {} on {} was not supported", configurationItem.getKey(), configurationItem.getValue()); break; default: throw new AssertionError("Configuration change returned unknown response status " + response.getStatus()); } } }
checkNotNull(configurationItem); final String key = configurationItem.getKey(); final String value = configurationItem.getValue();
checkNotNull(configurationItem); final String key = configurationItem.getKey(); final String value = configurationItem.getValue();
/** * Send a request to a charging station to change a configuration item. * * @param chargingStationId the charging station's id. * @param configurationItem the configuration item to change. * @param correlationToken the token to correlate commands and events that belong together. */ public void changeConfiguration(ChargingStationId chargingStationId, ConfigurationItem configurationItem, CorrelationToken correlationToken) { Changeconfiguration changeConfigurationRequest = new Changeconfiguration(); changeConfigurationRequest.setKey(configurationItem.getKey()); changeConfigurationRequest.setValue(configurationItem.getValue()); responseHandlers.put(correlationToken.getToken(), new ChangeConfigurationResponseHandler(configurationItem, correlationToken)); WampMessage wampMessage = new WampMessage(WampMessage.CALL, correlationToken.getToken(), MessageProcUri.CHANGE_CONFIGURATION, changeConfigurationRequest); sendWampMessage(wampMessage, chargingStationId); }
boolean keyFound = false; for (ConfigurationItem confItem : event.getConfigurationItems()) { if (key.equals(confItem.getKey())) { LOG.debug("Updating configuration key [{}] with value [{}]", key, confItem.getValue()); confItems.put(key, confItem.getValue());