/**
 * 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
 *
 */
/*
 * OrderBean.java
 * 
 * Created on Aug 16, 2004
 *
 */
package olstore.entity;

import javax.ejb.EntityBean;

import olstore.entity.ItemLocal;
import olstore.entity.UserLocal;

import java.math.BigDecimal;

/**
 * @ejb.bean name="Order"
 *  description="This bean is used to store information about an order."
 *	type="CMP"
 *  schema="olstore_order"
 *  primkey-field="orderId"
 *  reentrant="false"
 *  cmp-version="2.x"
 *  view-type="local"
 *  local-jndi-name="OrderLocal_L"
 * 
 * @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="Order"
 * jndi-name="OrderLocal"
 * @jonas.jdbc-mapping  jndi-name="jdbc_1" jdbc-table-name="olstore_order"
 *  automatic-pk="true" 
 * --
 * 
 *  @ejb.persistence
 * 
 * @ejb.finder 
 *    query="SELECT OBJECT(a) FROM olstore_order as a"  
 *    signature="java.util.Collection findAll()"  
 * 
 * @ejb.finder 
 *    query="SELECT OBJECT(a) FROM olstore_order as a WHERE NOT (a.status = ?1)"  
 *    signature="java.util.Collection findByStatus(java.lang.String status)"
 * 
 * @ejb.finder 
 *    query="SELECT OBJECT(a) FROM olstore_order as a WHERE a.orderId = ?1"  
 *    signature="olstore.entity.Order findByPrimaryKey(java.lang.Integer orderId)"
 * 
 *--
 * 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_order"
 * 
 *--
 *  
 **/

public abstract class OrderBean implements EntityBean {
    
    /**
     * The  ejbCreate method.
     * 
     * @ejb.create-method 
     */
    public java.lang.Integer ejbCreate(UserLocal user, ItemLocal item, Integer quantity, String status, String dateReceived,  BigDecimal pricePaid) throws javax.ejb.CreateException {
        setQuantity (quantity);
        setStatus (status);
        setDateReceived (dateReceived);
        setPricePaid (pricePaid);
        
        return null;
    }
    
    /**
     * The container invokes this method immediately after it calls ejbCreate.
     * 
     */
    public void ejbPostCreate(UserLocal user, ItemLocal item, Integer quantity, String status, String dateReceived, BigDecimal pricePaid) throws javax.ejb.CreateException {
        setUser (user);
        setItem(item);
    }
    
    /**
     * Returns the orderId
     * @return the orderId
     * 
     * @ejb.persistent-field 
     * @ejb.persistence
     *    column-name="orderId"
     *     sql-type="INTEGER"
     * @ejb.pk-field 
     * @ejb.interface-method
     * 
     */
    public abstract java.lang.Integer getOrderId();
    
    /**
     * Sets the orderId
     * 
     * @param java.lang.Integer the new orderId value
     * 
     * @ejb.interface-method
     */
    public abstract void setOrderId(java.lang.Integer orderId);
    
    /**
     * Returns the quantity
     * @return the quantity
     * 
     * @ejb.persistent-field 
     * @ejb.persistence
     *    column-name="quantity"
     *     sql-type="INTEGER"
     *  
     * @ejb.interface-method
     * 
     */
    public abstract java.lang.Integer getQuantity();
    
    /**
     * Sets the quantity
     * 
     * @param java.lang.Integer the new quantity value
     * 
     * @ejb.interface-method
     */
    public abstract void setQuantity(java.lang.Integer quantity);
    
    /**
     * Returns the status
     * @return the status
     * 
     * @ejb.persistent-field 
     * @ejb.persistence
     *    column-name="status"
     *     sql-type="VARCHAR"
     *  
     * @ejb.interface-method
     * 
     */
    public abstract java.lang.String getStatus();
    
    /**
     * Sets the status
     * 
     * @param java.lang.String the new status value
     * 
     * @ejb.interface-method
     */
    public abstract void setStatus(java.lang.String status);
    
    /**
     * Returns the dateReceived
     * @return the dateReceived
     * 
     * @ejb.persistent-field 
     * @ejb.persistence
     *    column-name="dateReceived"
     *     sql-type="VARCHAR"
     *  
     * @ejb.interface-method
     * 
     */
    public abstract java.lang.String getDateReceived();
    
    /**
     * Sets the dateReceived
     * 
     * @param java.lang.String the new dateReceived value
     * 
     * @ejb.interface-method
     */
    public abstract void setDateReceived(java.lang.String dateReceived);
    
    /**
     * Returns the pricePaid
     * @return the pricePaid
     * 
     * @ejb.persistent-field 
     * @ejb.persistence
     *    column-name="pricePaid"
     *     sql-type="NUMERIC"
     *  
     * @ejb.interface-method
     * 
     */
    public abstract BigDecimal getPricePaid();
    
    /**
     * Sets the pricePaid
     * 
     * @param java.lang.Float the new pricePaid value
     * 
     * @ejb.interface-method
     */
    public abstract void setPricePaid(BigDecimal pricePaid);
    
    /**
     * Returns the User for this Order
     * 
     * @return the User for this Order
     * 
     * @ejb.relation
     *  name="User-Order"
     *  role-name="Order-has-a-User"
     *  target-ejb="User"
     * @ejb.interface-method
     * 
     */
    
    public abstract UserLocal getUser();
    public abstract void setUser (UserLocal user);
    
    /**
     * Returns the item for this Order
     * 
     * @return the item for this Order
     * 
     * @ejb.relation
     *  name="Order-Item"
     *  role-name="Order-has-many-Items"
     *  target-ejb="Item"
     *  target-multiple="yes"
     * 
     * @ejb.interface-method
     */
    
    public abstract ItemLocal getItem();
    public abstract void setItem (ItemLocal user);
    
}
