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