Exemple #1
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;
 }
Exemple #2
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);
  }
Exemple #3
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;
  }