3 import java.rmi.RemoteException;
4 import java.rmi.server.UnicastRemoteObject;
6 import java.util.Vector;
8 import common.OfferInterface;
9 import dataAccess.DB4oManager;
11 import domain.RuralHouse;
12 import exceptions.BadDates;
13 import exceptions.OverlappingOfferExists;
15 public final class OfferManager extends UnicastRemoteObject implements OfferInterface{
20 private static final long serialVersionUID = 1L;
22 private int offerNumber = 0;
23 dataAccess.DB4oManager dbMngr;
25 public OfferManager() throws RemoteException {
28 this.dbMngr = DB4oManager.getInstance();
29 } catch (Exception e) {
37 * This method creates an offer with a house number, first day, last day and price
40 * number, start day, last day and price
41 * @return the created offer, or null, or an exception
43 public Offer createOffer(RuralHouse ruralHouse, Date firstDay, Date lastDay,
44 float price) throws OverlappingOfferExists, BadDates, RemoteException, Exception {
45 if (firstDay.after(lastDay)||firstDay==null||lastDay==null)
48 boolean b = dbMngr.existsOverlappingOffer(ruralHouse,firstDay,lastDay); // The ruralHouse object in the client may not be updated
50 dbMngr.createOffer(ruralHouse,firstDay,lastDay,price);
51 return ruralHouse.createOffer(offerNumber, firstDay, lastDay, price);
57 public void deleteOffer(RuralHouse rh, Offer o) throws RemoteException, Exception{
58 rh.offers.removeElement(o);
59 dbMngr.deleteOffer( o);
65 public Vector<RuralHouse> getRuralHouseOffers(RuralHouse rh)
66 throws RemoteException {
67 // TODO Auto-generated method stub