Example #1
0
 /** Write the list of event favorites to the body of the response. */
 @RequestMapping(
     value = "/events/{eventId}/favorites",
     method = RequestMethod.GET,
     produces = "application/json")
 public @ResponseBody List<EventSession> favorites(@PathVariable Long eventId, Account account) {
   return eventRepository.findEventFavorites(eventId, account.getId());
 }
Example #2
0
 /**
  * Toggle a session as an attendee favorite. Write the new favorite status to the body of the
  * response.
  */
 @RequestMapping(
     value = "/events/{eventId}/sessions/{sessionId}/favorite",
     method = RequestMethod.PUT)
 public @ResponseBody Boolean toggleFavorite(
     @PathVariable Long eventId, @PathVariable Integer sessionId, Account account) {
   return eventRepository.toggleFavorite(eventId, sessionId, account.getId());
 }
Example #3
0
 /** Write the sessions scheduled for the day to the body of the response. */
 @RequestMapping(
     value = "/events/{eventId}/sessions/{day}",
     method = RequestMethod.GET,
     produces = "application/json")
 public @ResponseBody List<EventSession> sessionsOnDay(
     @PathVariable Long eventId,
     @PathVariable @DateTimeFormat(iso = ISO.DATE) LocalDate day,
     Account account) {
   return eventRepository.findSessionsOnDay(eventId, day, account.getId());
 }
Example #4
0
 /**
  * Add or update the rating given to the session by the attendee. Write the new average rating for
  * the session to the body of the response.
  */
 @RequestMapping(
     value = "/events/{eventId}/sessions/{sessionId}/rating",
     method = RequestMethod.POST)
 public @ResponseBody Float updateRating(
     @PathVariable Long eventId,
     @PathVariable Integer sessionId,
     Account account,
     @RequestParam Short value,
     @RequestParam String comment)
     throws RatingPeriodClosedException {
   return eventRepository.rate(eventId, sessionId, account.getId(), new Rating(value, comment));
 }
  public ConnectionEvent createConnectionEvent(
      final URI connectionURI,
      final URI originator,
      final ConnectionEventType connectionEventType) {
    ConnectionEvent event = new ConnectionEvent();
    event.setConnectionURI(connectionURI);
    event.setType(connectionEventType);
    event.setOriginatorUri(originator);
    eventRepository.saveAndFlush(event);

    return event;
  }
Example #6
0
 /**
  * Write a page of event tweet search results to the body of the response. The page number and
  * size may be provided by the client. If not specified, defaults to the first page of ten
  * results.
  */
 @RequestMapping(
     value = "/events/{eventId}/tweets",
     method = RequestMethod.GET,
     produces = "application/json")
 public @ResponseBody SearchResults tweets(
     @PathVariable Long eventId,
     @RequestParam(defaultValue = "1") Integer page,
     @RequestParam(defaultValue = "10") Integer pageSize) {
   String searchString = eventRepository.findEventSearchString(eventId);
   return searchString != null && searchString.length() > 0
       ? twitter.searchOperations().search(searchString, page, pageSize)
       : null;
 }
Example #7
0
 public List<User> getConnectionsNotInvited(String email, Integer eventId) {
   List<User> list = connectionRepository.getConnectionsByEmail(email);
   Event event = eventRepository.findOne(eventId);
   for (EventInvite invite : event.getEventInvites()) {
     if (list.contains(invite.getUserInvited())) {
       list.remove(invite.getUserInvited());
     }
   }
   if (list.contains(event.getCreator())) {
     list.remove(event.getCreator());
   }
   return list;
 }
  @Test
  public void shouldUpdateEvent() {
    @SuppressWarnings("unchecked")
    Set<Student> newAttendees = new HashSet();
    newAttendees.add(pat);
    newAttendees.add(jim);

    EventForm updateParameter =
        new EventUpdateParameterBuilder()
            .id(1)
            .title("Spice Girls")
            .date(new Date(12, 12, 2011))
            .time("10:10")
            .description("Spice Girls 4 Lyf")
            .venue("P-81")
            .coordinator("Joel Tellez")
            .notes("Sick as party")
            .attendees(newAttendees)
            .build();

    Event newEvent =
        new EventBuilder()
            .title("Spice Girls")
            .attendees(newAttendees)
            .date(new Date(12, 12, 2011))
            .description("Spice Girls 4 Lyf")
            .venue("P-81")
            .coordinator("Joel Tellez")
            .notes("Sick as party")
            .build();

    when(eventRepository.load(1)).thenReturn(sportsEvent);
    when(service.update(updateParameter)).thenReturn(newEvent);
    Event updatedEvent = service.update(updateParameter);
    assertEquals(newEvent, updatedEvent);
  }
 @Test
 public void shouldListAllEvents() {
   when(eventRepository.list()).thenReturn(events);
   assertThat(service.list(), hasItems(sportsEvent, annualEvent));
 }
Example #10
0
 /**
  * Write the list of upcoming events to the body of the response. Only matches 'GET /events'
  * requests for JSON content; a 404 is sent otherwise. TODO send a 406 if an unsupported
  * representation, such as XML, is requested. See SPR-7353.
  */
 @RequestMapping(value = "/events", method = RequestMethod.GET, produces = "application/json")
 public @ResponseBody List<Event> upcomingEvents(
     @RequestParam(value = "after", required = false) @DateTimeFormat(iso = ISO.DATE_TIME)
         Long afterMillis) {
   return eventRepository.findUpcomingEvents(afterMillis);
 }
Example #11
0
 /** Render the list of upcoming events as HTML in the client's web browser. */
 @RequestMapping(value = "/events", method = RequestMethod.GET, produces = "text/html")
 public String upcomingEventsView(Model model, DateTimeZone timeZone) {
   model.addAttribute(eventRepository.findUpcomingEvents(new DateTime(timeZone).getMillis()));
   return "events/list";
 }