コード例 #1
0
  // analyze and store a new reddit comment thread
  @RequestMapping(value = "frequency/new", method = RequestMethod.POST)
  public Map<String, String> createNewFrequency(@RequestParam("url") String url)
      throws IOException {
    Map<String, Long> wordCountMap = null;

    wordCountMap = redditWordCountService.getWordCount(new URL(url));
    String runid = UUID.randomUUID().toString();

    List<WordCount> wcs = new ArrayList<WordCount>();
    for (Map.Entry<String, Long> wordEntry : wordCountMap.entrySet()) {
      wcs.add(new WordCount(null, runid, wordEntry.getKey(), wordEntry.getValue()));
    }
    redditWordCountService.saveAll(wcs);

    return Maps.newHashMap(ImmutableMap.of("runid", runid));
  }
コード例 #2
0
 // return the word counts for a run in order with a limit
 @RequestMapping(value = "frequency/{runid}", method = RequestMethod.GET)
 public List<WordCount> listWordCountsForRunId(
     @PathVariable("runid") String runid, @RequestParam("count") Integer limit) {
   return redditWordCountService.getListForRunid(runid, limit);
 }
コード例 #3
0
 // A bad idea in general to just return all the records, but in this case of a small demo project
 // it's ok
 @RequestMapping(value = "frequency/all", method = RequestMethod.GET)
 public List<WordCount> listWordCounts() {
   return redditWordCountService.getList();
 }