コード例 #1
0
  @GET
  @Path("/api/sessions/{id}")
  public RestSession getSession(@PathParam("id") long id) throws ResourceNotFoundException {
    StoredSessionWithLastAttempt session = sm.getSessionStore(getSiteId()).getSessionById(id);

    StoredProject proj = rm.getProjectStore(getSiteId()).getProjectById(session.getProjectId());

    return RestModels.session(session, proj.getName());
  }
コード例 #2
0
  @GET
  @Path("/api/sessions/{id}/attempts")
  public RestSessionAttemptCollection getSessionAttempts(
      @PathParam("id") long id, @QueryParam("last_id") Long lastId)
      throws ResourceNotFoundException {

    ProjectStore rs = rm.getProjectStore(getSiteId());
    SessionStore ss = sm.getSessionStore(getSiteId());

    StoredSession session = ss.getSessionById(id);
    StoredProject project = rs.getProjectById(session.getProjectId());
    List<StoredSessionAttempt> attempts =
        ss.getAttemptsOfSession(id, 100, Optional.fromNullable(lastId));

    List<RestSessionAttempt> collection =
        attempts
            .stream()
            .map(attempt -> RestModels.attempt(session, attempt, project.getName()))
            .collect(Collectors.toList());

    return RestModels.attemptCollection(collection);
  }