Beispiel #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);
   }
 }
Beispiel #2
0
 public ItemPresentation(Item item, String previous, Boolean loadParents) {
   this.uri = item.getUri();
   this.content = item.getTaggedContent();
   this.previous = previous;
   number = item.getNumber();
   next = item.getNext();
   parents = loadParents ? getParents(item.getNumber()) : null;
 }
Beispiel #3
0
 @RequestMapping("{number}/content")
 @ResponseBody
 public String getContent(@PathVariable String number) {
   Item item = itemDao.getByNumber(number);
   if (item != null) {
     return item.getTaggedContent();
   }
   return null;
 }
Beispiel #4
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);
  }
Beispiel #5
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;
  }