Exemplo n.º 1
0
  /**
   * Gets the children.
   *
   * @param id category id
   * @return List of children of certain category
   */
  public LinkedList<Category> getChildren(long id) {
    LinkedList<Category> toReturn = new LinkedList<Category>();
    for (Category c : this.categories.findAll()) {
      if (c.getPredecessor() == id) toReturn.add(c);
    }

    return toReturn;
  }
Exemplo n.º 2
0
  /**
   * processes categories into hierarchical CategoryFirstTierObject.
   *
   * @return List of Hierarchical objects
   */
  public LinkedList<CategoryFirstTierObject> getProcessedCategories() {
    LinkedList<CategoryFirstTierObject> toReturn = new LinkedList<CategoryFirstTierObject>();
    Iterable<Category> foundCategories = categories.findAll();

    for (Category s : foundCategories) {
      if (s.getRoot()) {
        LinkedList<Category> subcats = new LinkedList<Category>();

        for (Category t : foundCategories) {
          if (t.getPredecessor() == s.getId()) {
            subcats.add(t);
          }
        }

        CategoryFirstTierObject toAdd = new CategoryFirstTierObject(s, subcats);
        toReturn.add(toAdd);
      }
    }
    return toReturn;
  }