// Decompiled by Jad v1.5.7g. Copyright 2000 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/SiliconValley/Bridge/8617/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi 
// Source File Name:   ProductCategory.java

package com.keyshop.shop.product.model;

import com.keyshop.pub.model.PubBean;
import com.keyshop.pub.util.StringUtil;
import com.keyshop.shop.channel.bo.ChannelBO;
import com.keyshop.shop.channel.model.Channel;
import com.keyshop.shop.product.bo.ProductBO;
import com.keyshop.shop.product.bo.ProductCategoryBO;
import com.keyshop.shop.product.util.ProductHelper;
import java.util.List;

// Referenced classes of package com.keyshop.shop.product.model:
//            Product

public class ProductCategory extends PubBean
{

    String categoryName;
    String categoryEnName;
    String categoryLevel;
    String parentId;
    String type;
    String description;
    int index;
    String channelId;
    Channel channel;
    List subCategorys;
    String navImage;
    String popProduct;
    String linkUrl;
    Product popProductObject;
    ProductCategory parentCategory;

    public ProductCategory()
    {
        categoryName = "";
        categoryEnName = "";
        categoryLevel = "";
        parentId = "";
        type = "";
        description = "";
        index = 0;
        channelId = "";
        channel = null;
        subCategorys = null;
        navImage = "";
        popProduct = "";
        linkUrl = "";
        popProductObject = null;
        parentCategory = null;
    }

    public void clear()
    {
        super.clear();
        categoryName = "";
        categoryLevel = "";
        parentId = "";
        subCategorys = null;
        parentCategory = null;
        channelId = "";
        navImage = "";
        type = "";
        description = "";
    }

    public String getParentId()
    {
        return parentId;
    }

    public String getCategoryName()
    {
        return categoryName;
    }

    public String getCategoryLevel()
    {
        return categoryLevel;
    }

    public void setCategoryLevel(String categoryLevel)
    {
        this.categoryLevel = categoryLevel;
    }

    public void setCategoryName(String categoryName)
    {
        this.categoryName = categoryName;
    }

    public void setParentId(String parentId)
    {
        this.parentId = parentId;
    }

    public List getSubCategorys()
    {
        if(StringUtil.isEmpty(id))
            return null;
        if(subCategorys != null && subCategorys.size() > 0)
            return subCategorys;
        String sql = " from ProductCategory as productCategory where productCategory.parentId='" + id + "' order by productCategory.index";
        try
        {
            ProductCategoryBO productCategoryBO = new ProductCategoryBO();
            List list = productCategoryBO.list(sql);
            if(list != null)
            {
                subCategorys = list;
                return subCategorys;
            }
        }
        catch(Exception exception) { }
        return subCategorys;
    }

    public ProductCategory getParentCategory()
    {
        if(StringUtil.isEmpty(parentId))
            return null;
        try
        {
            ProductCategoryBO tradeCategoryBO = new ProductCategoryBO();
            ProductCategory category = (ProductCategory)tradeCategoryBO.get(parentId);
            parentCategory = category;
            if(category != null)
                return parentCategory;
        }
        catch(Exception exception) { }
        return parentCategory;
    }

    public Product getPopProductObject()
    {
        if(StringUtil.isEmpty(popProduct))
            return null;
        if(popProductObject != null && popProductObject.getId().equals(popProduct))
            return popProductObject;
        try
        {
            ProductBO productBO = new ProductBO();
            Product product = (Product)productBO.get(popProduct);
            popProductObject = product;
            return popProductObject;
        }
        catch(Exception exception)
        {
            return popProductObject;
        }
    }

    public void setParentCategory(ProductCategory parentCategory)
    {
        this.parentCategory = parentCategory;
    }

    public int getIndex()
    {
        return index;
    }

    public void setIndex(int index)
    {
        this.index = index;
    }

    public String getType()
    {
        return type;
    }

    public void setType(String type)
    {
        this.type = type;
    }

    public String getDescription()
    {
        return description;
    }

    public void setDescription(String description)
    {
        this.description = description;
    }

    public String getFullName()
    {
        if(!StringUtil.isEmpty(id))
            return ProductHelper.getProductCategoryFullName(id);
        else
            return "";
    }

    public String getChannelId()
    {
        return channelId;
    }

    public Channel getChannel()
    {
        if(StringUtil.isEmpty(channelId))
        {
            channel = null;
            return null;
        }
        if(channel != null)
            return channel;
        try
        {
            ChannelBO bo = new ChannelBO();
            channel = (Channel)bo.get(channelId);
            return channel;
        }
        catch(Exception ex)
        {
            ex.printStackTrace();
        }
        return null;
    }

    public void setChannelId(String channelId)
    {
        this.channelId = channelId;
    }

    public String getLinkUrl()
    {
        return linkUrl;
    }

    public String getNavImage()
    {
        return navImage;
    }

    public void setLinkUrl(String linkUrl)
    {
        this.linkUrl = linkUrl;
    }

    public void setNavImage(String navImage)
    {
        this.navImage = navImage;
    }

    public String getPopProduct()
    {
        return popProduct;
    }

    public void setPopProduct(String popProduct)
    {
        this.popProduct = popProduct;
    }

    public String getCategoryEnName()
    {
        return categoryEnName;
    }

    public void setCategoryEnName(String categoryEnName)
    {
        this.categoryEnName = categoryEnName;
    }
}
