Exemplo n.º 1
0
 @RequestMapping("{number}/mark")
 public void mark(@PathVariable String number) {
   Item item = itemDao.getByNumber(number);
   if (item != null) {
     item.setTaggedContent(termsMarker.mark(item.getContent()));
     itemDao.save(item);
   }
 }
Exemplo n.º 2
0
 @RequestMapping("{number}/content")
 @ResponseBody
 public String getContent(@PathVariable String number) {
   Item item = itemDao.getByNumber(number);
   if (item != null) {
     return item.getTaggedContent();
   }
   return null;
 }
Exemplo n.º 3
0
  @RequestMapping("{number}/{more}more")
  @ResponseBody
  public List<ItemPresentation> getMore(@PathVariable String number, @PathVariable Integer more) {
    List<ItemPresentation> presentations = new ArrayList<ItemPresentation>();

    for (Item item : itemDao.getNext(number, more)) {
      presentations.add(new ItemPresentation(item));
    }
    return presentations;
  }
Exemplo n.º 4
0
  @RequestMapping("range")
  @ResponseBody
  public List<ItemPresentation> get(@RequestParam String from, @RequestParam String to) {
    Item item = itemDao.getByNumber(from);
    notNull(item, format("Item `%s` not found", from));
    notNull(itemDao.getByNumber(to), format("Item `%s` not found", to));

    List<ItemPresentation> items = new ArrayList<ItemPresentation>();

    final ItemPresentation itemPresentation = new ItemPresentation(item);
    //        itemPresentation.parents = getParents(item.getNumber());
    items.add(itemPresentation);

    while (!item.getNumber().equals(to)) {
      item = itemDao.get(item.getNext());
      items.add(new ItemPresentation(item));
      if (items.size() > MAXIMUM_RANGE_SIZE) {
        throw new RuntimeException(format("Maximum range size reached (from %s to %s)", from, to));
      }
    }

    return items;
  }
Exemplo n.º 5
0
  @RequestMapping
  @ResponseBody
  public ItemPresentation get(@RequestParam String number) {
    final Item item = itemDao.getByNumber(number);
    notNull(item, format("Item `%s` not found", number));

    if (item.getNext() != null) {
      taskExecutor.execute(
          new Runnable() {
            @Override
            public void run() {
              final Item nextItem = itemDao.get(item.getNext());
              taggingUpdater.update(nextItem);
            }
          });
    }

    return new ItemPresentation(item, generate(Item.class, getPrev(item.getNumber())), true);
  }