Started with the separated DB with the given code
[RRRRHHHH_Code] / ruralHouses / src / businessLogic / BookingManager.java
index f0d0a54..f5b993d 100644 (file)
@@ -7,13 +7,12 @@ import java.util.Vector;
 
 import javax.mail.MessagingException;
 
-import com.db4o.ObjectContainer;
-import com.db4o.ObjectSet;
 import common.BookingInterface;
 
 import dataAccess.DB4oManager;
 import domain.Booking;
 import domain.Client;
+import domain.Offer;
 import domain.RuralHouse;
 import exceptions.OfferCanNotBeBooked;
 
@@ -25,10 +24,8 @@ public final class BookingManager extends UnicastRemoteObject implements Booking
         * 
         */
        private static final long serialVersionUID = 1L;
-       private int bookingNumber = 0;
        dataAccess.DB4oManager dbMngr;
 
-       private static BookingManager theBookingManager;
 
        public BookingManager() throws RemoteException {
                super();
@@ -39,42 +36,15 @@ public final class BookingManager extends UnicastRemoteObject implements Booking
                }
        }
 
-       /**
-        * This method returns the next Booking number
-        * 
-        * @return the book number
-        */
-
-    public int getNumber() throws RemoteException{
-               ObjectContainer db=DB4oManager.getContainer();
-       BookingManager b=getInstance();
-       b.bookingNumber++;
-       db.store(b);
-       db.commit();
-       return b.bookingNumber;
-    }
        
-       /**
-        * This method returns the instance of the BookingManager class
-        * 
-        * @return the booking manager
-        * @throws RemoteException 
-        */
-
-       public BookingManager getInstance() throws RemoteException  {
-               ObjectContainer db=DB4oManager.getContainer();
-           BookingManager b = new BookingManager();
-           ObjectSet<BookingManager> result = db.queryByExample(b);
-           if (!result.hasNext()){
-               theBookingManager = new BookingManager();
-               db.store(theBookingManager);
-               db.commit();
-           } else theBookingManager=(BookingManager)result.next();
-               return theBookingManager;
-       }
 
        public void denyBooking(Booking b) throws RemoteException{
                                this.dbMngr.removeBooking(b);
+                               try {
+                                       MailManager.getInstance().Send(b.getClient().getMailAccount(), "Your booking has not been accepted","We are sorry");
+                               } catch (MessagingException e) {
+                                       e.printStackTrace();
+                               }
        }
 
 
@@ -105,4 +75,11 @@ public final class BookingManager extends UnicastRemoteObject implements Booking
                                client);
        }
 
+
+
+       @Override
+       public Vector<Booking> getOffersbookings(Offer o) throws RemoteException {
+               return dbMngr.getOfBok(o);
+       }
+
 }
\ No newline at end of file