Git Repository Public Repository

RRRRHHHH_Code

URLs

Copy to Clipboard

Diff Revisions 4bc36b ... vs d30bcc ... for ruralHouses/src/businessLogic/BookingManager.java

Diff revisions: vs.
  @@ -5,8 +5,6 @@
5 5 import java.util.Date;
6 6 import java.util.Vector;
7 7
8 - import javax.mail.MessagingException;
9 -
10 8 import com.db4o.ObjectContainer;
11 9 import com.db4o.ObjectSet;
12 10 import common.BookingInterface;
  @@ -25,10 +23,8 @@
25 23 *
26 24 */
27 25 private static final long serialVersionUID = 1L;
28 - private int bookingNumber = 0;
29 26 dataAccess.DB4oManager dbMngr;
30 27
31 - private static BookingManager theBookingManager;
32 28
33 29 public BookingManager() throws RemoteException {
34 30 super();
  @@ -39,55 +35,27 @@
39 35 }
40 36 }
41 37
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 - }
56 38
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 - }
75 39
76 - public void denyBooking(Booking b) throws RemoteException{
40 + public void removeDenyBooking(Booking b) throws RemoteException{
41 + b.getOffer().getBookings().remove(b);
77 42 this.dbMngr.removeBooking(b);
78 43 }
79 44
80 45
81 46 public void acceptBooking(Booking b) throws RemoteException{
82 47 b.getOffer().setBooked(true);
83 - b.getOffer().getBookings().clear();
84 - b.getOffer().getBookings().add(b);
48 + for(Booking boo : b.getOffer().getBookings()){
49 + if(!boo.equals(b))
50 + b.getOffer().getBookings().remove(b);
51 + }
85 52 this.dbMngr.acceptBooking(b.getOffer());
86 - try {
53 + /*try {
87 54 MailManager.getInstance().Send(b.getClient().getMailAccount(), "Your booking has been accepted","Here should be the bill");
88 55 } catch (MessagingException e) {
56 + // TODO Auto-generated catch block
89 57 e.printStackTrace();
90 - }
58 + }*/
91 59
92 60 }
93 61 /**