// 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:   ProductTemplate.java

package com.keyshop.shop.product.model;

import com.keyshop.pub.model.PubOneToManyBean;
import com.keyshop.pub.util.StringUtil;
import java.util.*;

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

public class ProductTemplate extends PubOneToManyBean
{

    private String name;
    private String description;
    Map fields;

    public ProductTemplate()
    {
        name = "";
        description = "";
        fields = new HashMap();
    }

    public String getName()
    {
        return name;
    }

    public String getDescription()
    {
        return description;
    }

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

    public void setName(String name)
    {
        this.name = name;
    }

    public void clear()
    {
        super.clear();
        setId("");
        name = "";
        description = "";
    }

    public List getFields(String fieldType)
        throws Exception
    {
        if(StringUtil.isEmpty(id))
            return null;
        if(fields == null || fields.size() <= 0)
            filterFields();
        if(fields.get(fieldType) != null)
            return (List)fields.get(fieldType);
        else
            return null;
    }

    public void filterFields()
        throws Exception
    {
        if(StringUtil.isEmpty(id))
            return;
        if(getChildList() == null)
            return;
        for(Iterator it = getChildList().iterator(); it.hasNext();)
        {
            ProductTemplateFields field = (ProductTemplateFields)it.next();
            List t = (List)fields.get(field.getType());
            if(t != null)
            {
                t.add(field);
            } else
            {
                t = new ArrayList();
                t.add(field);
                fields.put(field.getType(), t);
            }
        }

    }
}
