com.ibm.websphere.samples.pbw.war
Class ShoppingItem

java.lang.Object
  extended by com.ibm.websphere.samples.pbw.war.ShoppingItem
All Implemented Interfaces:
Serializable, Cloneable

public class ShoppingItem
extends Object
implements Cloneable, Serializable

ShoppingItem wraps the JPA Inventory entity class to provide additional methods needed by the web app.

See Also:
Serialized Form

Constructor Summary
ShoppingItem()
           
ShoppingItem(Inventory i)
           
ShoppingItem(String key, String name, String heading, String desc, String pkginfo, String image, float price, float cost, int quantity, int category, String notes, boolean isPublic)
           
 
Method Summary
 boolean equals(Object o)
           
 BackOrder getBackOrder()
           
 int getCategory()
           
 float getCost()
           
 String getDescription()
           
 String getHeading()
           
 String getID()
           
 String getImage()
           
 byte[] getImgbytes()
           
 String getInventoryId()
           
 int getMaxThreshold()
           
 int getMinThreshold()
           
 String getName()
           
 String getNotes()
           
 String getPkginfo()
           
 float getPrice()
           
 int getQuantity()
          Property accessor for quantity of items ordered.
 float getSubtotalPrice()
          Subtotal price calculates a cost based on price and quantity.
 int hashCode()
           
 void increaseInventory(int quantity)
           
 boolean isPublic()
           
 void setBackOrder(BackOrder backOrder)
           
 void setCategory(int category)
           
 void setCost(float cost)
           
 void setDescription(String description)
           
 void setHeading(String heading)
           
 void setID(String id)
           
 void setImage(String image)
           
 void setImgbytes(byte[] imgbytes)
           
 void setInventoryId(String id)
           
 void setIsPublic(boolean isPublic)
           
 void setMaxThreshold(int maxThreshold)
           
 void setMinThreshold(int minThreshold)
           
 void setName(String name)
           
 void setNotes(String notes)
           
 void setPkginfo(String pkginfo)
           
 void setPrice(float price)
           
 void setPrivacy(boolean isPublic)
           
 void setQuantity(int quantity)
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ShoppingItem

public ShoppingItem()

ShoppingItem

public ShoppingItem(Inventory i)

ShoppingItem

public ShoppingItem(String key,
                    String name,
                    String heading,
                    String desc,
                    String pkginfo,
                    String image,
                    float price,
                    float cost,
                    int quantity,
                    int category,
                    String notes,
                    boolean isPublic)
Method Detail

getSubtotalPrice

public float getSubtotalPrice()
Subtotal price calculates a cost based on price and quantity.


equals

public boolean equals(Object o)
Overrides:
equals in class Object
Parameters:
o -
Returns:
boolean true if object equals this
See Also:
Object.equals(java.lang.Object)

hashCode

public int hashCode()
Overrides:
hashCode in class Object
Returns:
int hashcode for this object
See Also:
Object.hashCode()

toString

public String toString()
Overrides:
toString in class Object
Returns:
String String representation of this object
See Also:
Object.toString()

increaseInventory

public void increaseInventory(int quantity)
Parameters:
quantity -
See Also:
Inventory.increaseInventory(int)

getCategory

public int getCategory()
Returns:
int category enum int value
See Also:
Inventory.getCategory()

setCategory

public void setCategory(int category)
Parameters:
category -
See Also:
Inventory.setCategory(int)

getCost

public float getCost()
Returns:
float cost of the item
See Also:
Inventory.getCost()

setCost

public void setCost(float cost)
Parameters:
cost -
See Also:
Inventory.setCost(float)

getDescription

public String getDescription()
Returns:
String description of the item
See Also:
Inventory.getDescription()

setDescription

public void setDescription(String description)
Parameters:
description -
See Also:
Inventory.setDescription(java.lang.String)

getHeading

public String getHeading()
Returns:
String item heading
See Also:
Inventory.getHeading()

setHeading

public void setHeading(String heading)
Parameters:
heading -
See Also:
Inventory.setHeading(java.lang.String)

getImage

public String getImage()
Returns:
String image URI
See Also:
Inventory.getImage()

setImage

public void setImage(String image)
Parameters:
image -
See Also:
Inventory.setImage(java.lang.String)

getName

public String getName()
Returns:
String name of the item
See Also:
Inventory.getName()

setName

public void setName(String name)
Parameters:
name -
See Also:
Inventory.setName(java.lang.String)

getNotes

public String getNotes()
Returns:
String item notes
See Also:
Inventory.getNotes()

setNotes

public void setNotes(String notes)
Parameters:
notes -
See Also:
Inventory.setNotes(java.lang.String)

getPkginfo

public String getPkginfo()
Returns:
String package information
See Also:
Inventory.getPkginfo()

setPkginfo

public void setPkginfo(String pkginfo)
Parameters:
pkginfo -
See Also:
Inventory.setPkginfo(java.lang.String)

getPrice

public float getPrice()
Returns:
float Price of the item
See Also:
Inventory.getPrice()

setPrice

public void setPrice(float price)
Parameters:
price -
See Also:
Inventory.setPrice(float)

getQuantity

@Min(value=0L,
     message="Quantity must be a number greater than or equal to zero.")
public int getQuantity()
Property accessor for quantity of items ordered. Quantity may not be less than zero. Bean Validation will ensure this is true.

Returns:
int quantity of items
See Also:
Inventory.getQuantity()

setQuantity

public void setQuantity(int quantity)
Parameters:
quantity -
See Also:
Inventory.setQuantity(int)

getMaxThreshold

public int getMaxThreshold()
Returns:
int maximum threshold
See Also:
Inventory.getMaxThreshold()

setMaxThreshold

public void setMaxThreshold(int maxThreshold)
Parameters:
maxThreshold -
See Also:
Inventory.setMaxThreshold(int)

getMinThreshold

public int getMinThreshold()
Returns:
int minimum threshold
See Also:
Inventory.getMinThreshold()

setMinThreshold

public void setMinThreshold(int minThreshold)
Parameters:
minThreshold -
See Also:
Inventory.setMinThreshold(int)

getInventoryId

public String getInventoryId()
Returns:
String item ID in the inventory
See Also:
Inventory.getInventoryId()

setInventoryId

public void setInventoryId(String id)
Parameters:
id -
See Also:
Inventory.setInventoryId(java.lang.String)

getID

public String getID()
Returns:
String item ID
See Also:
Inventory.getID()

setID

public void setID(String id)
Parameters:
id -
See Also:
Inventory.setID(java.lang.String)

isPublic

public boolean isPublic()
Returns:
boolean true if this is a public item
See Also:
Inventory.isPublic()

setIsPublic

public void setIsPublic(boolean isPublic)
Parameters:
isPublic -
See Also:
Inventory.setIsPublic(boolean)

setPrivacy

public void setPrivacy(boolean isPublic)
Parameters:
isPublic -
See Also:
Inventory.setPrivacy(boolean)

getImgbytes

public byte[] getImgbytes()
Returns:
byte[] item image as a byte array
See Also:
Inventory.getImgbytes()

setImgbytes

public void setImgbytes(byte[] imgbytes)
Parameters:
imgbytes -
See Also:
Inventory.setImgbytes(byte[])

getBackOrder

public BackOrder getBackOrder()
Returns:
BackOrder item is on back order
See Also:
Inventory.getBackOrder()

setBackOrder

public void setBackOrder(BackOrder backOrder)
Parameters:
backOrder -
See Also:
Inventory.setBackOrder(com.ibm.websphere.samples.pbw.jpa.BackOrder)


Copyright © 2011. All Rights Reserved.