@Override public Iterable<T> toIterable() throws QueryException { return Iterables.limit( limit, Iterables.skip( skip, iterable ) ); } }
@Override public T single() throws QueryException { return Iterables.single( Iterables.limit( limit, Iterables.skip( skip, iterable ) ) ); }
@Override public long count() { return Iterables.count( Iterables.limit( limit, Iterables.skip( skip, iterable ) ) ); }
@Override public T first() { return Iterables.first( Iterables.limit( limit, Iterables.skip( skip, iterable ) ) ); }
@Override public Iterable<TimelineRecord> getNextRecords( int maxResults ) { SortedSet<TimelineRecord> result = new TreeSet<>(); UnitOfWork uow = module.currentUnitOfWork(); String schedulesName = SchedulerMixin.getSchedulesIdentity( scheduler ); Schedules schedules = uow.get( Schedules.class, schedulesName ); for( Schedule schedule : schedules.schedules() ) { Timeline timeline = (Timeline) schedule; Iterable<TimelineRecord> lastRecords = timeline.getNextRecords( maxResults ); Iterables.addAll( result, lastRecords ); } return Iterables.limit( maxResults, result ); }
@Override public Iterable<TimelineRecord> getLastRecords( int maxResults ) { SortedSet<TimelineRecord> result = new TreeSet<>(); UnitOfWork uow = module.currentUnitOfWork(); String schedulesName = SchedulerMixin.getSchedulesIdentity( scheduler ); Schedules schedules = uow.get( Schedules.class, schedulesName ); for( Schedule schedule : schedules.schedules() ) { Timeline timeline = (Timeline) schedule; Iterable<TimelineRecord> lastRecords = timeline.getLastRecords( maxResults ); Iterables.addAll( result, lastRecords ); } return Iterables.limit( maxResults, Iterables.reverse( result ) ); }