com.ibm.websphere.samples.plantsbywebsphereclient
Class PBWSBusinessObjects

java.lang.Object
  extended by com.ibm.websphere.samples.plantsbywebsphereclient.PBWSBusinessObjects

public class PBWSBusinessObjects
extends java.lang.Object

Layer that retrieves information from the Business Object layer.


Field Summary
static java.lang.String Report_TopSellersForDates
           
static java.lang.String Report_TopSellingZipsForDates
           
 
Constructor Summary
PBWSBusinessObjects()
          Default Constructor
 
Method Summary
static boolean assignInvItemToPerson(java.lang.String itemID, java.lang.String person)
          Assign a given inventory item to the specified person.
static boolean clearInventoryQueue()
          Clear-out the JMS Inventory Queue
static boolean clearInventoryQueueforItem(java.lang.String itemID)
          Clear-out the JMS Inventory Queue for an Item.
static boolean completeInvItem(java.lang.String itemID)
          Complete the inventory item
static boolean createUnassignedInvItem(java.lang.String itemID, int categoryID)
          Add a new Unassigned Item to the inventory queue.
static java.util.Vector getAssignedInvItemsByPerson(java.lang.String person)
          Retrieve all assigned items for a given person.
static com.ibm.websphere.samples.plantsbywebsphereejb.Catalog getCatalog()
           
static com.ibm.websphere.samples.plantsbywebsphereejb.StoreItem getCatalogItem(java.lang.String itemID)
          Retrieve an item from the catalog from it's Item ID
static void getCatalogItemImageByFile(java.lang.String itemID, java.io.File imgDestFile)
          Retrieves a catalog item's image for a given item and places it into a file with the specified name and path on the local hard drive.
static byte[] getCatalogItemImageBytes(java.lang.String itemID)
          Retrieves a catalog item's image for a given item into an array of bytes.
static java.util.Vector getCategories()
          Returns a vector of Category objects for each available category.
static java.lang.String getCategoryNameFromID(int catID)
          Retrieves the Category Name from a Category ID.
static int getCatIdFromName(java.lang.String catName)
          Retrieves the Category ID from a Category Name.
static java.lang.String[] getInvPersonnel()
          Get a list of Inventory Personnel names.
static com.ibm.websphere.samples.plantsbywebsphereejb.ReportGenerator getReportGenerator()
          Retrieves a ReportGenerator remote object.
static java.util.Vector getUnassignedInvItemsByCategory(int categoryID)
          Retrieve all of the unassigned inventory items for the given category.
static void init()
          Initializes the Business Objects by finding the EJB home objects.
static void init(java.lang.String userId, java.lang.String passWord)
          Initializes the Business Objects by finding the EJB home objects.
static com.ibm.websphere.samples.plantsbywebsphereejb.Report runReport(java.lang.String rptName, java.util.Date fromDate, java.util.Date toDate, int maxRows, java.io.File outFile)
          Run a report and store the results in an input file.
static void sendEmail(java.lang.String toAddr, java.lang.String fromAddr, java.lang.String subject, java.lang.String message, java.util.Vector vItemIDs)
          Send an email to the designated email address.
static void setCatalogItemImageByFile(java.lang.String itemID, java.io.File imgFile)
          Sets a catalog item's image for a given item for an input file on the local user's hard drive.
static void setCatalogItemImageBytes(java.lang.String itemID, byte[] imgBytes)
          Sets a catalog item's image for a given item to an array of bytes.
static boolean unassignInvItem(java.lang.String itemID)
          Unassign the given item from whomever it's current assigned to.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

Report_TopSellersForDates

public static final java.lang.String Report_TopSellersForDates

Report_TopSellingZipsForDates

public static final java.lang.String Report_TopSellingZipsForDates
Constructor Detail

PBWSBusinessObjects

public PBWSBusinessObjects()
Default Constructor

Method Detail

init

public static void init()
Initializes the Business Objects by finding the EJB home objects.


init

public static void init(java.lang.String userId,
                        java.lang.String passWord)
Initializes the Business Objects by finding the EJB home objects.


getCategories

public static java.util.Vector getCategories()
Returns a vector of Category objects for each available category.

Returns:
Vector Vector of Category objects

getCatIdFromName

public static int getCatIdFromName(java.lang.String catName)
Retrieves the Category ID from a Category Name. Returns -1 if the Category Name is invalid or does not exist.

Parameters:
String - Category Name
Returns:
int Category ID or -1

getCategoryNameFromID

public static java.lang.String getCategoryNameFromID(int catID)
Retrieves the Category Name from a Category ID. Returns an empty String if the Category ID is invalid or does not exist.

Parameters:
int - Category ID
Returns:
String Category Name or Empty String

sendEmail

public static void sendEmail(java.lang.String toAddr,
                             java.lang.String fromAddr,
                             java.lang.String subject,
                             java.lang.String message,
                             java.util.Vector vItemIDs)
                      throws javax.mail.MessagingException
Send an email to the designated email address. Send a message as well as information of specific Catalog Items.

Parameters:
String - Email Address of the recipient.
String - Email Address of the sender.
String - Additional message text to send to the recipient.
Vector - Item ID's of the catalog items to send to the recipient.
Throws:
javax.mail.MessagingException

getInvPersonnel

public static java.lang.String[] getInvPersonnel()
Get a list of Inventory Personnel names. These are stored in a properties file: pbws.properties.

Returns:
String[] An array of user id's.

createUnassignedInvItem

public static boolean createUnassignedInvItem(java.lang.String itemID,
                                              int categoryID)
Add a new Unassigned Item to the inventory queue.

Parameters:
String - The Catalog item ID to create.
String - The Category ID of the item.
Returns:
boolean True if successful.

unassignInvItem

public static boolean unassignInvItem(java.lang.String itemID)
Unassign the given item from whomever it's current assigned to.

Parameters:
String - The Catalog item ID to unassign.
Returns:
boolean True if successful.

assignInvItemToPerson

public static boolean assignInvItemToPerson(java.lang.String itemID,
                                            java.lang.String person)
Assign a given inventory item to the specified person.

Parameters:
String - The Catalog item ID to assign.
String - The user id of the person to assign to.
Returns:
boolean True if successful.

getUnassignedInvItemsByCategory

public static java.util.Vector getUnassignedInvItemsByCategory(int categoryID)
Retrieve all of the unassigned inventory items for the given category.

Parameters:
int - The category to retrieve unassigned items for.
Returns:
Vector A vector of PBWSInvItemMsg objects.

getAssignedInvItemsByPerson

public static java.util.Vector getAssignedInvItemsByPerson(java.lang.String person)
Retrieve all assigned items for a given person.

Parameters:
String - The id of the person to retreive the assigned items for.
Returns:
Vector A vector of PBWSInvItemMsg objects.

completeInvItem

public static boolean completeInvItem(java.lang.String itemID)
Complete the inventory item

Parameters:
String - The Catalog item ID
Returns:
boolean True if the the item was completed.

clearInventoryQueueforItem

public static boolean clearInventoryQueueforItem(java.lang.String itemID)
Clear-out the JMS Inventory Queue for an Item.

Parameters:
String - The Catalog item ID
Returns:
boolean True if the the item was cleared from the queue.

clearInventoryQueue

public static boolean clearInventoryQueue()
Clear-out the JMS Inventory Queue


getCatalog

public static com.ibm.websphere.samples.plantsbywebsphereejb.Catalog getCatalog()
                                                                         throws javax.ejb.CreateException,
                                                                                java.rmi.RemoteException
Throws:
javax.ejb.CreateException
java.rmi.RemoteException

getCatalogItem

public static com.ibm.websphere.samples.plantsbywebsphereejb.StoreItem getCatalogItem(java.lang.String itemID)
Retrieve an item from the catalog from it's Item ID


setCatalogItemImageBytes

public static void setCatalogItemImageBytes(java.lang.String itemID,
                                            byte[] imgBytes)
Sets a catalog item's image for a given item to an array of bytes.

Parameters:
String - The catalog Item ID
byte[] - An array of bytes representing the image.

getCatalogItemImageBytes

public static byte[] getCatalogItemImageBytes(java.lang.String itemID)
Retrieves a catalog item's image for a given item into an array of bytes.

Parameters:
String - The catalog Item ID
Returns:
byte[] An array of bytes representing the image.

setCatalogItemImageByFile

public static void setCatalogItemImageByFile(java.lang.String itemID,
                                             java.io.File imgFile)
                                      throws java.io.FileNotFoundException,
                                             java.io.IOException
Sets a catalog item's image for a given item for an input file on the local user's hard drive.

Parameters:
String - The catalog Item ID
File - An existing image file.
Throws:
java.io.FileNotFoundException
java.io.IOException

getCatalogItemImageByFile

public static void getCatalogItemImageByFile(java.lang.String itemID,
                                             java.io.File imgDestFile)
                                      throws java.io.FileNotFoundException,
                                             java.io.IOException
Retrieves a catalog item's image for a given item and places it into a file with the specified name and path on the local hard drive.

Parameters:
String - The catalog Item ID
File - The image file to create
Throws:
java.io.FileNotFoundException
java.io.IOException

getReportGenerator

public static com.ibm.websphere.samples.plantsbywebsphereejb.ReportGenerator getReportGenerator()
                                                                                         throws javax.ejb.CreateException,
                                                                                                java.rmi.RemoteException
Retrieves a ReportGenerator remote object.

Returns:
ReportGenerator A ReportGenerator EJB.
Throws:
javax.ejb.CreateException
java.rmi.RemoteException

runReport

public static com.ibm.websphere.samples.plantsbywebsphereejb.Report runReport(java.lang.String rptName,
                                                                              java.util.Date fromDate,
                                                                              java.util.Date toDate,
                                                                              int maxRows,
                                                                              java.io.File outFile)
                                                                       throws java.io.IOException,
                                                                              java.lang.Throwable
Run a report and store the results in an input file. The resulting report is returned to the user when complete.

Parameters:
rptName - The name of the report to run.
fromDate - The beginning date to run from.
toDate - The end date to run to.
maxRows - The maximum number of rows of data to return.
outFile - The file to write the report results to.
Returns:
Report The Report object that contains the report results.
Throws:
java.io.IOException
java.lang.Throwable