cleaning
[RRRRHHHH_Code] / ruralHouses / src / businessLogic / BookingManager.java
1 package businessLogic;
2
3 import java.rmi.RemoteException;
4 import java.rmi.server.UnicastRemoteObject;
5 import java.util.Date;
6 import java.util.Vector;
7
8 import com.db4o.ObjectContainer;
9 import com.db4o.ObjectSet;
10 import common.BookingInterface;
11
12 import dataAccess.DB4oManager;
13 import domain.Booking;
14 import domain.Client;
15 import domain.RuralHouse;
16 import exceptions.OfferCanNotBeBooked;
17
18
19
20 public final class BookingManager extends UnicastRemoteObject implements BookingInterface {
21
22         /**
23          * 
24          */
25         private static final long serialVersionUID = 1L;
26         dataAccess.DB4oManager dbMngr;
27
28
29         public BookingManager() throws RemoteException {
30                 super();
31                 try {
32                         this.dbMngr = DB4oManager.getInstance();
33                 } catch (Exception e) {
34                         e.printStackTrace();
35                 }
36         }
37
38         
39
40         public void removeDenyBooking(Booking b) throws RemoteException{
41                                 b.getOffer().getBookings().remove(b);
42                                 this.dbMngr.removeBooking(b);
43         }
44
45
46         public void acceptBooking(Booking b) throws RemoteException{
47                 b.getOffer().setBooked(true);
48                 for(Booking boo : b.getOffer().getBookings()){
49                         if(!boo.equals(b))
50                                 b.getOffer().getBookings().remove(b);
51                 }
52                 this.dbMngr.acceptBooking(b.getOffer());
53                 /*try {
54                         MailManager.getInstance().Send(b.getClient().getMailAccount(), "Your booking has been accepted","Here should be the bill");
55                 } catch (MessagingException e) {
56                         // TODO Auto-generated catch block
57                         e.printStackTrace();
58                 }*/
59                 
60         }
61         /**
62          * This method creates a book with a corresponding parameters
63          * 
64          * @param First
65          *            day, last day, house number and telephone
66          * @return a book
67          */
68         public Vector<Booking> createBooking(RuralHouse ruralHouse, Date firstDate,
69                         Date lastDate, Client client)
70                         throws OfferCanNotBeBooked,RemoteException {
71
72                 return dbMngr.createBooking(ruralHouse, firstDate, lastDate,
73                                 client);
74         }
75
76 }