Package com.google.code.magja.model.category

Examples of com.google.code.magja.model.category.Category


   * Magento)
   */
  public Category getRequiredCategory(Integer parentId, String categoryName,
      String[] availableSortBy, String defaultSortBy, Boolean active,
      Boolean anchor) {
    Category parent = new Category(parentId);

    Category category = new Category(categoryName);
    category.setParent(parent);
    category.setAvailableSortBy(availableSortBy);
    category.setDefaultSortBy(defaultSortBy);
    category.setActive(active);
    category.setAnchor(anchor);

    return category;
  }
View Full Code Here


  public Category linkCategory(List<Category> categories) throws ServiceException {
    if (categories.size() > 0) {
      for (int i = 0; i < categories.size(); i++) {
        // set parent
        if(i > 0) {
          Category parent = categories.get(i - 1);
          categories.get(i).setParent(parent);
        }

        // set children
        if(i < categories.size() - 1) {
View Full Code Here

   */
  public List<Category> create(Integer parentId, Category category) throws ServiceException {
    if (parentId > 0 && category != null) {
      List<Category> categories = new ArrayList<Category>();

      Category parent = getTree(parentId);

      while(category != null) {
        try {
          // search for category
          Category child = searchChild(parent, category);

          // category exists already, set id from existing one
          category.setId(child.getId());

          // set values for next loop
          parent = child;
          parentId = parent.getId();
        } catch(Exception e) {
          parent = null;
        }

        // create / update category
        category.setParent(new Category(parentId));
        parentId = save(category);

        // add category to return list
        categories.add(category);

View Full Code Here

  /**
   * get list of last categories without products
   */
  public List<Category> findEmpty(Integer id) throws ServiceException {
    Category startCategory = getTree(id);

    List<Category> lastCategories = getLastCategories(startCategory);

    List<Category> emptyCategories = new ArrayList<Category>();
    for (Category category : lastCategories) {
View Full Code Here

   * delete delete recursive if empty
   */
  public void deleteEmptyRecursive(Category category) throws ServiceException {
    if (isEmpty(category)) {
      // get parent category
      Category parent = getByIdWithParent(category.getId()).getParent();

      // delete current empty category
      delete(category.getId());

      // delete parent category if empty
View Full Code Here

                .get("category_ids")));
      } else {
        List<Category> categories = new ArrayList<Category>();
        for (Object obj : (List<Object>) mpp.get("category_ids")) {
          Integer id = Integer.parseInt((String) obj);
          categories.add(new Category(id));
        }
        product.setCategories(categories);
      }
    }
View Full Code Here

  private List<Category> getCategoriesBasicInfo(List<Object> ids)
      throws ServiceException {
    List<Category> categories = new ArrayList<Category>();
    for (Object obj : ids) {
      Integer id = Integer.parseInt((String) obj);
      Category category = categoryRemoteService.getByIdClean(id);
      categories.add(category);
    }
    return categories;
  }
View Full Code Here

    /**
     * Test method for {@link com.google.code.magja.service.category.CategoryRemoteServiceImpl#getByIdClean(java.lang.Integer)}.
     */
    @Test
    public void testGetByIdClean() throws Exception {
        Category category = service.getByIdClean(new Integer(2));
        if(category != null) System.out.println(category.toString());
    }
View Full Code Here

    /**
     * Test method for {@link com.google.code.magja.service.category.CategoryRemoteServiceImpl#getByIdWithChildren(java.lang.Integer)}.
     */
    @Test
    public void testGetByIdWithChildren() throws Exception {
        Category category = service.getByIdWithChildren(new Integer(2));
        for (Category child : category.getChildren()) {
            assertTrue(child.getId() != null);
        }
    }
View Full Code Here

    /**
     * Test method for {@link com.google.code.magja.service.category.CategoryRemoteServiceImpl#getByIdWithParent(java.lang.Integer)}.
     */
    @Test
    public void testGetByIdWithParent() throws Exception {
        Category category = service.getByIdWithParent(new Integer(2));
        if (category != null) if (category.getParent() != null) System.out.println(category.getParent().toString());
    }
View Full Code Here

TOP

Related Classes of com.google.code.magja.model.category.Category

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.