WeatherForecastPrediction[] getForecastArray () { WeatherForecast forecast = weatherForecastRepo.currentWeatherForecast(); List<WeatherForecastPrediction> fcsts = forecast.getPredictions(); WeatherForecastPrediction[] result = new WeatherForecastPrediction[fcsts.size()]; fcsts.forEach(fcst -> result[fcst.getForecastTime() - 1] = fcst); return result; }
private void processForecastData (Data data) throws Exception { int timeIndex = getTimeIndex(requestDate); List<WeatherForecastPrediction> currentPredictions = new ArrayList<WeatherForecastPrediction>(); for (WeatherForecastPrediction prediction : data.getWeatherForecasts()) { currentPredictions.add(prediction); if (currentPredictions.size() == forecastHorizon) { // Add a forecast to the repo, increment to the next timeslot WeatherForecast newForecast = new WeatherForecast(timeIndex++, currentPredictions); weatherForecastRepo.add(newForecast); currentPredictions = new ArrayList<WeatherForecastPrediction>(); } } log.info(data.getWeatherForecasts().size() + " WeatherForecasts fetched from xml response."); } }
private void broadcastWeatherForecasts () { WeatherForecast forecast = null; try { forecast = weatherForecastRepo.currentWeatherForecast(); } catch (PowerTacException e) { log.error("Weather Service reports Weather Forecast Repo emtpy"); } if (forecast == null) { log.error("null weather-forecast for : " + timeslotRepo.currentSerialNumber() +" " + timeslotRepo.currentTimeslot()); // In the event of an error return a default List<WeatherForecastPrediction> currentPredictions = new ArrayList<WeatherForecastPrediction>(); for (int j = 1; j <= getForecastHorizon(); j++) { currentPredictions.add( new WeatherForecastPrediction(j, 0.0, 0.0, 0.0, 0.0)); } brokerProxyService.broadcastMessage(new WeatherForecast( timeslotRepo.currentSerialNumber(), currentPredictions)); } else { brokerProxyService.broadcastMessage(forecast); } }
WeatherForecast forecast = weatherForecastRepo.currentWeatherForecast(); List<WeatherForecastPrediction> predictions = forecast.getPredictions(); for (WeatherForecastPrediction prediction : predictions) {