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) {
27 * This method creates an offer with a house number, first day, last day and price
30 * number, start day, last day and price
31 * @return the created offer, or null, or an exception
33 public Offer createOffer(RuralHouse ruralHouse, Date firstDay, Date lastDay,
34 float price) throws OverlappingOfferExists, BadDates, RemoteException, Exception {
35 if (firstDay.after(lastDay)||firstDay==null||lastDay==null)
38 boolean b = dbMngr.existsOverlappingOffer(ruralHouse,firstDay,lastDay); // The ruralHouse object in the client may not be updated
40 dbMngr.createOffer(ruralHouse,firstDay,lastDay,price);
41 return ruralHouse.createOffer(offerNumber, firstDay, lastDay, price);
47 public void deleteOffer(RuralHouse rh, Offer o) throws RemoteException, Exception{
48 rh.offers.removeElement(o);
49 dbMngr.deleteOffer( o);