コード例 #1
0
ファイル: CategoryMethods.java プロジェクト: alex955/swt15w10
  /**
   * 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;
  }
コード例 #2
0
ファイル: CategoryMethods.java プロジェクト: alex955/swt15w10
  /**
   * 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;
  }