Ejemplo n.º 1
0
 /**
  * This adds/saves the current transaction to the database.
  *
  * @throws IllegalStateException if the transaction has not been paid for.
  *     <dt><b>Precondition:</b>
  *     <dd>
  *         <ul>
  *           <li>Payment for the transaction has been made.
  *         </ul>
  */
 public void process()
     throws IllegalStateException, SQLException, ClassNotFoundException, MovieNotFoundException,
         Exception {
   if (myTransaction.isPaid() == false) {
     throw new IllegalStateException("The invoice has not been paid, not saving info.");
   }
   // mySQLhelper.insertInvoiceTable(myTransaction);
   RentalMovieManagement rentalManager = new RentalMovieManagement();
   SaleMovieManagement saleManager = new SaleMovieManagement();
   for (int i = 1; i <= myTransaction.getNumberOfItems(); i++) {
     TransactionItem item = myTransaction.getItem(i);
     if (item.getType().equals("for sale")) {
       saleManager.sell(item.getBarcode());
     } else if (item.getType().trim().toLowerCase().equals("new release")
         || item.getType().trim().toLowerCase().equals("7 day")) {
       rentalManager.checkOut(
           myTransaction.getCustomerID(), item.getBarcode(), new JDBCConnection());
     }
   }
 }