private void update(ForecastReport forecastReport) throws Exception { findWeatherData(new LocationVO(forecastReport.place), -1, -1, true, null, false).join(); List results = validateRules(forecastReport); if (!results.isEmpty()) { ForecastReport fr = new ForecastReport(); fr.place = forecastReport.place; for (Object result : results) { if (result instanceof HourWeatherVO) { fr.hourlyWeatherList.add((HourWeatherVO) result); } else if (result instanceof DayWeatherVO) { fr.dailyWeatherList.add((DayWeatherVO) result); } } forecastReport.forecastMode = -1; sendResponse(fr, null, false, true); } }
private synchronized ForecastReport getForecastReport( LocationVO locationVO, long refreshTime, List<WeatherProposition> rules) { String place = locationVO.getSubArea() != null ? locationVO.getSubArea() : locationVO.getCity() != null ? locationVO.getCity() : locationVO.getWoeidVO() != null && locationVO.getWoeidVO().getName() != null ? locationVO.getWoeidVO().getName() : null; if (place == null) { mb.send( WeatherEvent.build() .setIsError(true) .setErrorMessage("A place is required in order to get the forecast report.")); return null; } ForecastReport forecastReport = forecastReports.get(place.replace(" ", "_")); if (forecastReport == null) { forecastReport = new ForecastReport(refreshTime); forecastReport.place = place; forecastReports.put(place, forecastReport); } if (locationVO == null) { locationVO = new LocationVO(place); } if (forecastReport.locationVO != null) { forecastReport.locationVO.mergeLocation(locationVO); } else { forecastReport.locationVO = locationVO; } if (refreshTime > 0 && refreshTime != forecastReport.refreshTime) { forecastReport.refreshTime = refreshTime; forecastReport.initTimer(); } if (rules != null && !rules.isEmpty()) { forecastReport.rules = rules; } return forecastReport; }