Ejemplo n.º 1
0
  /**
   * Gets the category map.
   *
   * @return Mapping of subcategories by name of rootcategory
   */
  public Map<String, List<Category>> getCategoryMap() {
    Map<String, List<Category>> toReturn = new HashMap<String, List<Category>>();

    for (Category s : this.categories.findAll()) {
      long currCat = s.getId();
      LinkedList<Category> putList = getChildren(currCat);
      toReturn.put(s.getName(), putList);
    }

    return toReturn;
  }
Ejemplo 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;
  }