/**
 * Copyright (c) 2004 Red Hat, Inc. All rights reserved.
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
 * USA
 *
 * Component of: Red Hat Application Server
 * 
 * Initial Developers: Aizaz Ahmed
 *                     Vivek Lakshmanan
 *                     Andrew Overholt
 *                     Matthew Wringe
 *
 */
/*
 * ItemBean.java
 * 
 * Created on Aug 16, 2004
 *
 */
package olstore.entity;

import javax.ejb.EntityBean;

import olstore.entity.TypeLocal;

import java.util.Collection;
import java.math.BigDecimal;

/**
 * @ejb.bean name="Item"
 *  description="This bean is used to store information about sales items."
 *	type="CMP"
 *  schema="olstore_item"
 *  primkey-field="itemId"
 *  reentrant="false"
 *  cmp-version="2.x"
 *  view-type="local"
 *  local-jndi-name="ItemLocal_L"
 * 
 * @ejb.relation
 *  name="User-Item"
 *  role-name="Items-belong-to-Users"
 *  target-ejb="User"
 *  target-multiple="yes"
 * 
 * @ejb.relation
 *  name="Order-Item"
 *  role-name="Items-belong-to-Orders"
 *  target-ejb="Order"
 *
 * @ejb.transaction
 *  type="Required"
 *
 *--
 * This is needed for JOnAS.
 * If you are not using JOnAS you can safely remove the tags below.
 * @jonas.bean ejb-name="Item"
 * jndi-name="ItemLocal"
 * @jonas.jdbc-mapping  jndi-name="jdbc_1" jdbc-table-name="olstore_item"
 *  automatic-pk="true" 
 * --
 *
 * @ejb.persistence
 *
 * @ejb.finder 
 *    query="SELECT OBJECT(a) FROM olstore_item as a"  
 *    signature="java.util.Collection findAll()"  
 * 
 * @ejb.finder
 *    query="SELECT OBJECT(c) FROM olstore_item AS c WHERE c.name = ?1"
 *    signature="java.util.Collection findByName(java.lang.String name)"
 * 
 * @ejb.finder
 *    query="SELECT OBJECT(c) FROM olstore_item AS c WHERE c.itemId = ?1"
 *    signature="olstore.entity.Item findByPrimaryKey(java.lang.Integer itemId)"
 *
 * @ejb.finder
 *    query="SELECT OBJECT(c) FROM olstore_item AS c WHERE c.mainPage = 'true'"
 *    signature="java.util.Collection findByMainPage()"
 *
 * @ejb.finder
 *    query="SELECT OBJECT(c) FROM olstore_item AS c WHERE c.specialOffer = 'true' AND c.mainPage = 'true'"
 *    signature="java.util.Collection findByMainPageAndSpecialOffer()"
 *
 * @ejb.finder
 *    query="SELECT OBJECT(c) FROM olstore_item AS c WHERE c.typeId.name = ?1"
 *    signature="java.util.Collection findByType(java.lang.String type)"
 *
 * @ejb.finder
 *    query="SELECT OBJECT(c) FROM olstore_item AS c WHERE c.typeId.name = ?1 AND c.specialOffer = 'true'"
 *    signature="java.util.Collection findByTypeAndSpecialOffer(java.lang.String typeIdName)"
 *
 * @ejb.finder
 *    query="SELECT DISTINCT OBJECT(p) FROM olstore_user u, IN ( u.friends ) AS f, IN ( f.user.purchased ) AS p WHERE u.username = ?2 AND p.typeId.name = ?1"
 *    signature="java.util.Collection findByTypeAndFriendsOf(java.lang.String typeIdName, java.lang.String username)"
 *
 * @ejb.finder
 *    query="SELECT DISTINCT OBJECT(p) FROM olstore_user u, IN ( u.friends ) AS f, IN ( f.user.purchased ) AS p WHERE u.username = ?1 AND p.mainPage = 'true'"
 *    signature="java.util.Collection findByMainPageAndFriendsOf(java.lang.String username)"
 * 
 * @ejb.finder
 *	  query="SELECT OBJECT(c) FROM olstore_item AS c WHERE c.specialOffer = 'true'"
 *	  signature="java.util.Collection findBySpecialOffer()"
 * 
 * 
 *--
 * This is needed for JOnAS.
 * If you are not using JOnAS you can safely remove the tags below.
 * @jonas.finder-method-jdbc-mapping  method-name="findAll"
 *	jdbc-where-clause=""
 * @jonas.jdbc-mapping  jndi-name="jdbc_1"
 *	jdbc-table-name="olstore_item"
 * 
 *--
 *  
 **/

public abstract class ItemBean implements EntityBean {
    
    /**
     * The  ejbCreate method.
     * 
     * @ejb.create-method 
     */
    public java.lang.Integer ejbCreate(String name, BigDecimal price) throws javax.ejb.CreateException {
        setName(name);
        setPrice(price);
        return null;
    }
    
    /**
     * The container invokes this method immediately after it calls ejbCreate.
     * 
     */
    public void ejbPostCreate(String name, BigDecimal price) throws javax.ejb.CreateException {
    }
    
    /**
     * Returns the name
     * @return the name
     * 
     * @ejb.persistent-field 
     * @ejb.persistence
     *    column-name="name"
     *     sql-type="VARCHAR"
     *  
     * @ejb.interface-method
     * 
     * 
     */
    public abstract java.lang.String getName();
    
    /**
     * Sets the name
     * 
     * @param java.lang.String the new name value
     * 
     * @ejb.interface-method
     */
    public abstract void setName(java.lang.String name);
    
    /**
     * Returns the shortDesc
     * @return the shortDesc
     * 
     * @ejb.persistent-field 
     * @ejb.persistence
     *    column-name="shortDesc"
     *     sql-type="VARCHAR"
     *  
     * @ejb.interface-method
     * 
     */
    public abstract java.lang.String getShortDesc();
    
    /**
     * Sets the shortDesc
     * 
     * @param java.lang.String the new shortDesc value
     * 
     * @ejb.interface-method
     */
    public abstract void setShortDesc(java.lang.String shortDesc);
    
    /**
     * Returns the longDesc
     * @return the longDesc
     * 
     * @ejb.persistent-field 
     * @ejb.persistence
     *    column-name="longDesc"
     *     sql-type="VARCHAR"
     *  
     * @ejb.interface-method
     * 
     */
    public abstract java.lang.String getLongDesc();
    
    /**
     * Sets the longDesc
     * 
     * @param java.lang.String the new longDesc value
     * 
     * @ejb.interface-method
     */
    public abstract void setLongDesc(java.lang.String longDesc);
    
    /**
     * Returns whether or not the item should appear on the main page
     * @return the mainPage
     * 
     * @ejb.persistent-field 
     * @ejb.persistence
     *    column-name="mainPage"
     *     sql-type="BOOLEAN"
     *  
     * @ejb.interface-method
     * 
     */
    public abstract java.lang.Boolean getMainPage();
    
    /**
     * Sets whether or not the item should appear on the main page
     * 
     * @param java.lang.Boolean mainPage
     * 
     * @ejb.interface-method
     */
    public abstract void setMainPage(java.lang.Boolean mainPage);
    
    /**
     * Returns whether or not the item is a special offer.
     * @return specialOffer
     * 
     * @ejb.persistent-field 
     * @ejb.persistence
     *    column-name="specialOffer"
     *     sql-type="BOOLEAN"
     *  
     * @ejb.interface-method
     * 
     */
    public abstract java.lang.Boolean getSpecialOffer();
    
    /**
     * Sets whether or not the item should appear on the main page
     * 
     * @param java.lang.Boolean the new specialOffer value
     * 
     * @ejb.interface-method
     */
    public abstract void setSpecialOffer(java.lang.Boolean specialOffer);
    
    /**
     * Returns the itemId
     * @return the itemId
     * 
     * @ejb.persistent-field 
     * @ejb.persistence
     *    column-name="itemId"
     *     sql-type="INTEGER"
     * @ejb.pk-field 
     * @ejb.interface-method
     * 
     */
    public abstract java.lang.Integer getItemId();
    
    /**
     * Sets the itemId
     * 
     * @param java.lang.Integer the new itemId value
     * 
     * @ejb.interface-method
     */
    public abstract void setItemId(java.lang.Integer itemId);
    
    /**
     * Returns the price
     * @return the price
     * 
     * @ejb.persistent-field 
     * @ejb.persistence
     *    column-name="price"
     *     sql-type="NUMERIC"
     *  
     * @ejb.interface-method
     * 
     */
    public abstract BigDecimal getPrice();
    
    /**
     * Sets the price
     * 
     * @param BigDecimal the new price value
     * 
     * @ejb.interface-method
     */
    public abstract void setPrice(BigDecimal price);
    
    /**
     * Returns the typeId of the item
     * 
     * @return TypeId
     * 
     * @ejb.interface-method
     * 
     * @ejb.relation
     *  name="Item-Type"
     *  target-ejb="Type"
     *  role-name="Item-belongs-to-Type"
     *  target-multiple="yes"
     * 
     */
    
    public abstract TypeLocal getTypeId ();
    
    /**
     * Sets the TypeId
     * 
     * @param type
     * 
     * @ejb.interface-method
     */
    
    public abstract void setTypeId (TypeLocal type);
    
    /**
     * Returns the properties of the item
     * 
     * @return Properties
     * 
     * @ejb.interface-method
     * 
     * @ejb.relation
     *  name="Item-Property"
     *  target-ejb="Property"
     *  role-name="Item-has-many-Properties"
     * 
     */
    
    public abstract Collection getProperties ();
    
    /**
     * 
     * @param properties
     * 
     * @ejb.interface-method
     * 
     */
    
    public abstract void setProperties (Collection properties);
    
    /**
     * Returns the pictures of the item
     * 
     * @return Pictures
     * 
     * @ejb.interface-method
     * 
     * @ejb.relation
     *  name="Item-Picture"
     *  target-ejb="Picture"
     *  role-name="Item-has-many-Pictures"
     * 
     */
    
    public abstract Collection getPictures ();
    
    /**
     * 
     * @param pictures
     * 
     * @ejb.interface-method
     * 
     */
    
    public abstract void setPictures (Collection pictures);
           
}
