3 import java.rmi.RemoteException;
6 import dataAccess.DB4oManager;
8 import domain.RuralHouse;
9 import exceptions.BadDates;
10 import exceptions.OverlappingOfferExists;
12 public final class OfferManager {
14 private int offerNumber = 0;
15 dataAccess.DB4oManager dbMngr;
17 public OfferManager() {
19 this.dbMngr = DB4oManager.getInstance();
20 } catch (Exception e) {
28 * This method creates an offer with a house number, first day, last day and price
31 * number, start day, last day and price
32 * @return the created offer, or null, or an exception
34 public Offer createOffer(RuralHouse ruralHouse, Date firstDay, Date lastDay,
35 float price) throws OverlappingOfferExists, BadDates, RemoteException, Exception {
36 if (firstDay.after(lastDay)||firstDay==null||lastDay==null)
39 boolean b = dbMngr.existsOverlappingOffer(ruralHouse,firstDay,lastDay); // The ruralHouse object in the client may not be updated
41 dbMngr.createOffer(ruralHouse,firstDay,lastDay,price);
42 return ruralHouse.createOffer(offerNumber, firstDay, lastDay, price);
48 public void deleteOffer(RuralHouse rh, Offer o) throws RemoteException, Exception{
49 rh.offers.removeElement(o);
50 dbMngr.deleteOffer( o);