private void updateWeatherForecasts(Event e) throws InvalidInputException, NotFoundException { if (e.getStatus() != EventStatus.PLANNED) { return; } // Ask new weather forecasts List<WeatherForecast> newForecasts = weatherForecastFacade.askWeatherForecasts(e.getId()); boolean newForecastsGood = e.areForecastsGood(newForecasts); if (e.getWeatherForecasts() != null && e.getWeatherForecasts().size() != 0) { // Check good/ bad boolean currentForecastsGood = e.areCurrentForecastsGood(); // Disable current weather forecasts disableWeatherForecasts(e); // Produce notification if good -> bad, bad -> good if (newForecastsGood != currentForecastsGood) { // Produce notification notificationFacade.createNotificationForWeatherConditions(e.getId(), newForecastsGood); } } else if (!newForecastsGood) { // Produce notification notificationFacade.createNotificationForWeatherConditions(e.getId(), newForecastsGood); } // Update event with new forecasts e.setWeatherForecasts(newForecasts); weatherForecastFacade.save(newForecasts); if (!newForecastsGood && needsSuggestedScheduling(e)) { // TODO check suggested scheduling updateSuggestedScheduling(e); } }
public void cancel(int eventID) throws BusinessException { Event e = eventDAO.retrieve(eventID); e.cancel(); notificationFacade.createNotificationForEventCancel(eventID); }
/** {@inheritDoc} */ public void updateData(Event e) throws BusinessException { Event dbEntry = eventDAO.retrieve(e.getId()); // Sets event data dbEntry.setEventData(e); notificationFacade.createNotificationForEventChange(e.getId()); // Updates scheduling and checks weather forecasts updateScheduling(dbEntry, e.getStart(), e.getEnd()); eventDAO.update(dbEntry); }
private void updateSuggestedScheduling(Event e) throws NotFoundException, InvalidInputException { List<WeatherForecastBase> suggestion = weatherForecastFacade.askSuggestion(e.getId()); if (suggestion != null) { e.setSuggestedChangeAvailable(true); if (!e.isSuggestedChangeProvided()) { notificationFacade.createNotificationForSuggestedChange(e.getId()); e.setSuggestedChangeProvided(true); } } else { e.setSuggestedChangeAvailable(false); } }