@Override public List<Event> getEventsByYear(int year) { JdbcTemplate select = new JdbcTemplate(dataSource); Date start = DateUtils.getStartOfYear(year); Date end = DateUtils.getEndOfYear(year); return select.query( "select event.id, event.title, event.description, event.island, event.location, event.content_source_id, event.url, event.start_datetime, event.end_datetime from event, content_source where start_datetime between ? and ? and event.content_source_id = content_source.id order by start_datetime desc", new Object[] {start, end}, new EventRowMapper()); }
@Override public List<Talk> getTalksByYear(int year) { JdbcTemplate select = new JdbcTemplate(dataSource); Date start = DateUtils.getStartOfYear(year); Date end = DateUtils.getEndOfYear(year); return select.query( "select id, name, description, type, event_name, city, country, content_source_id, url, talk_date, slides_url, video_url from talk where talk_date between ? and ? order by talk_date desc", new Object[] {start, end}, new TalkRowMapper()); }
@Override public List<Event> getFutureEvents(int pageSize) { Date today = DateUtils.getToday(); JdbcTemplate select = new JdbcTemplate(dataSource); List<Event> events = select.query( "select event.id, event.title, event.description, event.island, event.location, event.content_source_id, event.url, event.start_datetime, event.end_datetime from event, content_source where event.start_datetime > ? and event.content_source_id = content_source.id order by start_datetime asc limit 0,?", new Object[] {today, pageSize}, new EventRowMapper()); Collections.reverse(events); // reverse order because we want the latest event, first return events; }