RRRRHHHH_Code
Diff Revisions
ccac99 ...
vs
e3043c ...
for ruralHouses/src/businessLogic/BookingManager.java
|
@@ -25,8 +25,10 @@ |
25 |
25 |
|
* |
26 |
26 |
|
*/ |
27 |
27 |
|
private static final long serialVersionUID = 1L; |
|
28 |
+ |
private int bookingNumber = 0; |
28 |
29 |
|
dataAccess.DB4oManager dbMngr; |
29 |
30 |
|
|
|
31 |
+ |
private static BookingManager theBookingManager; |
30 |
32 |
|
|
31 |
33 |
|
public BookingManager() throws RemoteException { |
32 |
34 |
|
super(); |
|
@@ -37,10 +39,47 @@ |
37 |
39 |
|
} |
38 |
40 |
|
} |
39 |
41 |
|
|
|
42 |
+ |
/** |
|
43 |
+ |
* This method returns the next Booking number |
|
44 |
+ |
* |
|
45 |
+ |
* @return the book number |
|
46 |
+ |
*/ |
|
47 |
+ |
|
|
48 |
+ |
public int getNumber() throws RemoteException{ |
|
49 |
+ |
ObjectContainer db=DB4oManager.getContainer(); |
|
50 |
+ |
BookingManager b=getInstance(); |
|
51 |
+ |
b.bookingNumber++; |
|
52 |
+ |
db.store(b); |
|
53 |
+ |
db.commit(); |
|
54 |
+ |
return b.bookingNumber; |
|
55 |
+ |
} |
40 |
56 |
|
|
|
57 |
+ |
/** |
|
58 |
+ |
* This method returns the instance of the BookingManager class |
|
59 |
+ |
* |
|
60 |
+ |
* @return the booking manager |
|
61 |
+ |
* @throws RemoteException |
|
62 |
+ |
*/ |
|
63 |
+ |
|
|
64 |
+ |
public BookingManager getInstance() throws RemoteException { |
|
65 |
+ |
ObjectContainer db=DB4oManager.getContainer(); |
|
66 |
+ |
BookingManager b = new BookingManager(); |
|
67 |
+ |
ObjectSet<BookingManager> result = db.queryByExample(b); |
|
68 |
+ |
if (!result.hasNext()){ |
|
69 |
+ |
theBookingManager = new BookingManager(); |
|
70 |
+ |
db.store(theBookingManager); |
|
71 |
+ |
db.commit(); |
|
72 |
+ |
} else theBookingManager=(BookingManager)result.next(); |
|
73 |
+ |
return theBookingManager; |
|
74 |
+ |
} |
41 |
75 |
|
|
42 |
76 |
|
public void denyBooking(Booking b) throws RemoteException{ |
43 |
77 |
|
this.dbMngr.removeBooking(b); |
|
78 |
+ |
try { |
|
79 |
+ |
MailManager.getInstance().Send(b.getClient().getMailAccount(), "Your booking has not been accepted","We are sorry"); |
|
80 |
+ |
} catch (MessagingException e) { |
|
81 |
+ |
e.printStackTrace(); |
|
82 |
+ |
} |
44 |
83 |
|
} |
45 |
84 |
|
|
46 |
85 |
|
|