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

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


    product.set("meta_description", "one two tree");
    product.set("enable_googlecheckout", 1);

    // add category
    List<Category> categorys = new ArrayList<Category>();
    categorys.add(new Category(2));
    product.setCategories(categorys);

    //product.set("options_container", "container2");

    return product;
View Full Code Here


    if (category.get("children") != null) {
      if (category.get("children").toString().length() > 0) {
        String str_children = (String) category.get("children");
        String[] arr_children = str_children.split(",");
        for (String str_child : arr_children) {
          Category child = getByIdClean(new Integer(str_child));
          if (child != null)
            category.addChild(child);
        }
      }
    }
View Full Code Here

   * @param category
   * @throws ServiceException
   */
  private void loadParent(Category category) throws ServiceException {
    if (category.get("parent_id") != null) {
      Category parent = getByIdClean((Integer) category.get("parent_id"));
      category.setParent(parent);
    }
  }
View Full Code Here

   * (java.lang.Integer)
   */
  @Override
  public Category getByIdClean(Integer id) throws ServiceException {

    Category category = new Category();

    if (id == null)
      return null;

    Map<String, Object> cat;

    try {
      cat = (Map<String, Object>) soapClient.call(
          ResourcePath.CategoryInfo, id);
    } catch (AxisFault e) {
      if (debug)
        e.printStackTrace();
      throw new ServiceException(e.getMessage());
    }

    if (cat == null)
      return null;

    for (Map.Entry<String, Object> attribute : cat.entrySet())
      category.set(attribute.getKey(), attribute.getValue());

    return category;
  }
View Full Code Here

   * getByIdWithChildren(java.lang.Integer)
   */
  @Override
  public Category getByIdWithChildren(Integer id) throws ServiceException {

    Category category = getByIdClean(id);

    // load category children
    loadChildren(category);

    return category;
View Full Code Here

   * getByIdWithParent(java.lang.Integer)
   */
  @Override
  public Category getByIdWithParent(Integer id) throws ServiceException {

    Category category = getByIdClean(id);

    // load category parent
    loadParent(category);

    return category;
View Full Code Here

   */
  @Override
  public Category getByIdWithParentAndChildren(Integer id)
      throws ServiceException {

    Category category = getByIdClean(id);

    // load category parent and children
    loadChildren(category);
    loadParent(category);

View Full Code Here

   * @throws ServiceException
   */
  @SuppressWarnings("unchecked")
  public Category getTree(Integer id) throws ServiceException {

    Category category = new Category();

    if (id == null)
      return null;

    Map<String, Object> cat;
View Full Code Here

   * @param Map
   *            <String, Object>
   */
  @SuppressWarnings("unchecked")
  private Category getCategoryFromMap(Map<String, Object> cat) {
    Category category = new Category();

    for (Map.Entry<String, Object> attribute : cat.entrySet()) {
      if (attribute.getKey().equals("children")) {
        List<Category> children = new ArrayList<Category>();

        List<Map<String, Object>> childrenList = (List<Map<String, Object>>) attribute
            .getValue();

        for (Map<String, Object> child : childrenList) {
          Category c = getCategoryFromMap(child);
          children.add(c);
        }

        category.setChildren(children);
      } else {
View Full Code Here

   * @param parent
   *            category id
   * @throws ServiceException
   */
  public void deleteAllChildren(Integer id) throws ServiceException {
    Category parent = getByIdWithChildren(id);
    List<Category> children = parent.getChildren();

    for (Category category : children) {
      delete(category.getId());
    }
  }
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.