<commit_before>package edu.oregonstate.mist.restpr.resources

import com.google.common.base.Optional

import edu.oregonstate.mist.restpr.api.ErrorPOJO
import edu.oregonstate.mist.restpr.api.Season
import edu.oregonstate.mist.restpr.api.User
import edu.oregonstate.mist.restpr.db.SeasonDAO;
import edu.oregonstate.mist.restpr.db.UserDAO

import javax.validation.constraints.NotNull

import javax.ws.rs.Consumes
import javax.ws.rs.DELETE;
import javax.ws.rs.GET
import javax.ws.rs.POST
import javax.ws.rs.PUT;
import javax.ws.rs.Path
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam
import javax.ws.rs.core.MediaType
import javax.ws.rs.core.Response;

/**
 * Created by georgecrary on 7/13/15.
 */

@Path("/season")
@Produces(MediaType.APPLICATION_JSON)
class SeasonResource {
  private final SeasonDAO seasonDAO;

  SeasonResource(SeasonDAO seasonDAO) {
    this.seasonDAO = seasonDAO
  }

  @Path("/all")
  @GET
  @Produces(MediaType.APPLICATION_JSON)
  //Entity Type: List<Season>
  public Response getAll(){
    List<Season> returnList = seasonDAO.allSeasons()

    //TODO make debug print season method
    //returnList.each { debugPrintSeason(it) }

    def returnResponse = Response.ok(returnList).build()
    return returnResponse;
  }

  @Path("/{season_id}")
  @GET
  @Produces(MediaType.APPLICATION_JSON)
  //Entity Type: Season
  public Response getSeasonById(@NotNull Integer season_id){
    Season returnSeason = seasonDAO.getSeasonById(season_id)
    def returnResponse
<commit_msg>Add GET season method to Season Resource with response codes to spec<commit_after>package edu.oregonstate.mist.restpr.resources

import com.google.common.base.Optional

import edu.oregonstate.mist.restpr.api.ErrorPOJO
import edu.oregonstate.mist.restpr.api.Season
import edu.oregonstate.mist.restpr.api.User
import edu.oregonstate.mist.restpr.db.SeasonDAO;
import edu.oregonstate.mist.restpr.db.UserDAO

import javax.validation.constraints.NotNull

import javax.ws.rs.Consumes
import javax.ws.rs.DELETE;
import javax.ws.rs.GET
import javax.ws.rs.POST
import javax.ws.rs.PUT;
import javax.ws.rs.Path
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam
import javax.ws.rs.core.MediaType
import javax.ws.rs.core.Response;

/**
 * Created by georgecrary on 7/13/15.
 */

@Path("/season")
@Produces(MediaType.APPLICATION_JSON)
class SeasonResource {
  private final SeasonDAO seasonDAO;

  SeasonResource(SeasonDAO seasonDAO) {
    this.seasonDAO = seasonDAO
  }

  @GET
  @Produces(MediaType.APPLICATION_JSON)
  //Entity Type: List<Season>
  public Response getSeasons(@QueryParam("community_name") Optional<String> community_name,
                             @QueryParam("cycle_format") Optional<String> cycle_format,
                             @QueryParam("cycle_count") Optional<String> cycle_count,
                             @QueryParam("elo_default_seed") Integer year){

    def yearQueryString = (year == null) ? "" : year.toString();

    List<Season> returnList = seasonDAO.getSeasonMatch(community_name.or(""),cycle_format.or(""),
            cycle_count.or(""),yearQueryString)

    return Response.ok(returnList).build()
  }

  @Path("/all")
  @GET
  @Produces(MediaType.APPLICATION_JSON)
  //Entity Type: List<Season>
  public Response getAll(){
    List<Season> returnList = seasonDAO.allSeasons()

    //TODO make debug print season method
    //returnList.each { debugPrintSeason(it) }

    def returnResponse = Response.ok(returnList).build()
    return returnResponse;
  }

  @Path("/{season_id}")
  @GET
  @Produces(MediaType.APPLICATION_JSON)
  //Entity Type: Season
  public Response getSeasonById(@NotNull Integer season_id){
    Season returnSeason = seasonDAO.getSeasonById(season_id)
    def returnResponse

{'fraction_non_alphanumeric': 0.11403047819232791, 'fraction_numerical': 0.002627430373095113, 'mean_word_length': 4.144594594594595, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 12, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '421133', 'n_tokens_mistral': 1289, 'n_tokens_neox': 1237, 'n_words': 233}