コード例 #1
0
  /** {@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);
  }
コード例 #2
0
  public void cancel(int eventID) throws BusinessException {
    Event e = eventDAO.retrieve(eventID);

    e.cancel();

    notificationFacade.createNotificationForEventCancel(eventID);
  }
コード例 #3
0
  private boolean updateScheduling(Event e, LocalDateTime start, LocalDateTime end)
      throws InvalidInputException, NotFoundException {
    boolean schedulingChanged = false;
    Event.validateScheduling(start, end);

    if (e.setScheduling(start, end)) {
      schedulingChanged = true;

      eventDAO.update(e);
      eventDAO.flush();

      updateWeatherForecastsAsync(e);
    }

    return schedulingChanged;
  }
コード例 #4
0
  @Override
  public boolean isParticipant(int eventID, int userID) throws NotFoundException {
    Event e = eventDAO.findAndRefresh(eventID);

    if (e == null) throw new NotFoundException();

    return e.isParticipant(userID);
  }
コード例 #5
0
  @Override
  public void addInvited(int eventID, int userID) throws BusinessException {
    Event e = eventDAO.retrieve(eventID);
    User u = userDAO.retrieve(userID);

    if (!e.addInvited(u)) {
      throw new BusinessException(InvalidInputException.USER_ALREADY_INVITED);
    }
  }
コード例 #6
0
  @Override
  public void checkEventsSchedule() {
    List<Event> events = eventDAO.findPlanned();

    for (Event e : events) {
      if (e.getStart().isBefore(LocalDateTime.now())) {
        e.setStatus(EventStatus.CONCLUDED);
      }
    }
  }
コード例 #7
0
  public void toggleParticipant(int eventID, int userID) throws BusinessException {
    Event e = eventDAO.retrieve(eventID);
    User u = userDAO.retrieve(userID);

    if (e.isParticipant(u)) {
      e.removeParticipant(u);
    } else {
      e.addParticipant(u);
    }
  }
コード例 #8
0
  @Override
  public void addInvitedList(int eventID, String listInvited) throws BusinessException {
    List<String> usernames =
        RegExUtils.decomposeMultiple(
            listInvited, REXEX_PATTERN_INVITED_USER, REXEX_PATTERN_INVITED_USER_GROUP);

    Event e = eventDAO.retrieve(eventID);

    for (String username : usernames) {
      addInvited(e, username);
    }
  }
コード例 #9
0
  public List<Event> mask(List<Event> events) {
    List<Event> result = new ArrayList<Event>();

    // Make sure the events are detached
    for (Event e : events) {
      eventDAO.detach(e);

      result.add(mask(e));
    }

    return result;
  }
コード例 #10
0
  @Override
  public List<Event> search(String eventName) {
    List<Event> events = new ArrayList<Event>();

    // TODO implement properly
    Event found = eventDAO.findByName(eventName);
    if (found != null) {
      events.add(found);
    }

    return events;
  }
コード例 #11
0
  public Event create(Event e, int userID) throws InvalidInputException, NotFoundException {
    User creator = userDAO.retrieve(userID);

    Event toSave = new Event(e);

    toSave.setCreator(creator);
    creator.getCreatedEvents().add(toSave);

    if (!toSave.validForSave()) {
      throw new InvalidInputException(InvalidInputException.EVENT_CREATION_INVALID);
    }

    eventDAO.save(toSave);
    return toSave;
  }
コード例 #12
0
  @Override
  public List<WeatherForecastBase> askSuggestedChange(int eventID) throws NotFoundException {
    Event e = eventDAO.retrieve(eventID);

    if (!needsSuggestedScheduling(e)) {
      return null;
    }

    try {
      return weatherForecastFacade.askSuggestion(eventID);
    } catch (InvalidInputException ex) {
      Logger.getLogger(EventFacadeImplementation.class.getName()).log(Level.SEVERE, null, ex);
    }

    return null;
  }
コード例 #13
0
  public Event create(Event e) throws BusinessException {
    User creator = userManager.getLoggedUser();
    Event savedEvent;

    if (creator == null) {
      throw new InvalidInputException(InvalidInputException.EVENT_CREATION_NO_LOGGED_USER);
    }

    try {
      savedEvent = create(e, creator.getId());
      eventDAO.flush();

      updateWeatherForecastsAsync(savedEvent);
    } catch (NotFoundException notFoundException) {
      throw new BusinessException(BusinessException.EVENT_CREATION_INTERNAL_PROCESSING);
    }

    return savedEvent;
  }
コード例 #14
0
  /** {@inheritDoc} */
  public UserEventVisibility getVisibilityOverEvent(int userID, int eventID)
      throws NotFoundException {
    Event event = eventDAO.retrieve(eventID);
    User user = userDAO.retrieve(userID);

    if (event.getCreator().getId() == user.getId()) {
      return UserEventVisibility.CREATOR;
    }

    if (event.isInvited(user)) {
      return UserEventVisibility.VIEWER;
    }

    if (event.isPrivateEvent()) {
      return UserEventVisibility.NO_VISIBILITY;
    } else {
      return UserEventVisibility.VIEWER;
    }
  }
コード例 #15
0
  public void addParticipant(int eventID, int userID) throws BusinessException {
    Event e = eventDAO.retrieve(eventID);
    User u = userDAO.retrieve(userID);

    e.addParticipant(u);
  }
コード例 #16
0
 public Event find(int eventID) {
   return eventDAO.findAndRefresh(eventID);
 }
コード例 #17
0
  @Override
  public void addInvited(int eventID, String username) throws BusinessException {
    Event e = eventDAO.retrieve(eventID);

    addInvited(e, username);
  }
コード例 #18
0
  @Override
  public boolean isSuggestedChangeAvailable(int eventID) throws NotFoundException {
    Event e = eventDAO.retrieve(eventID);

    return isInSuggestedChangeRange(e) && e.isSuggestedChangeAvailable();
  }
コード例 #19
0
 private List<Event> getPlannedEvents() {
   return eventDAO.findPlanned();
 }
コード例 #20
0
  /** {@inheritDoc} */
  public boolean updateScheduling(int eventID, LocalDateTime start, LocalDateTime end)
      throws BusinessException {
    Event e = eventDAO.retrieve(eventID);

    return updateScheduling(e, start, end);
  }
コード例 #21
0
  public void updateWeatherForecasts(int eventID) throws InvalidInputException, NotFoundException {
    Event e = eventDAO.retrieve(eventID);

    updateWeatherForecasts(e);
  }