RRRRHHHH_Code
e2ae30e55bc2a997923463dd2a1274c67fdc73a6
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 |
package businessLogic; import java.rmi.RemoteException; import java.rmi.server.UnicastRemoteObject; import java.sql.Date; import java.sql.SQLException; import java.util.Vector; import dataAccess.DB4oManager; import domain.Booking; import domain.Offer; import domain.Owner; import domain.RuralHouse; import exceptions.BadDates; import exceptions.DB4oManagerCreationException; import exceptions.OfferCanNotBeBooked; import exceptions.OverlappingOfferExists; public class __FacadeImplementation extends UnicastRemoteObject implements __ApplicationFacadeInterface { /** * */ private static final long serialVersionUID = 1L; Vector<Owner> owners; Vector<RuralHouse> ruralHouses; DB4oManager dB4oManager; public __FacadeImplementation() throws RemoteException, InstantiationException, IllegalAccessException, ClassNotFoundException, SQLException, DB4oManagerCreationException { owners=null; ruralHouses=null; try{ dB4oManager=DB4oManager.getInstance(); } catch (com.db4o.ext.DatabaseFileLockedException e) { System.out.println("Error in FacadeImplementation: "+e.toString()); throw e; } catch (Exception e) { System.out.println("Error in FacadeImplementation: "+e.toString()); throw new DB4oManagerCreationException(); } } /** * This method creates an offer with a house number, first day, last day and price * * @param House * number, start day, last day and price * @return the created offer, or null, or an exception */ public Offer createOffer(RuralHouse ruralHouse, Date firstDay, Date lastDay, float price) throws OverlappingOfferExists, BadDates, RemoteException, Exception { if (firstDay.compareTo(lastDay)>=0) throw new BadDates(); ruralHouses=null; owners=null; boolean b = dB4oManager.existsOverlappingOffer(ruralHouse,firstDay,lastDay); // The ruralHouse object in the client may not be updated if (!b) return dB4oManager.createOffer(ruralHouse,firstDay,lastDay,price); return null; } /** * This method creates a book with a corresponding parameters * * @param First * day, last day, house number and telephone * @return a book */ public Booking createBooking(RuralHouse ruralHouse, Date firstDate, Date lastDate, String bookTelephoneNumber) throws OfferCanNotBeBooked { ruralHouses=null; owners=null; return dB4oManager.createBooking(ruralHouse,firstDate,lastDate,bookTelephoneNumber); } /** * This method existing owners * */ public Vector<Owner> getOwners() throws RemoteException, Exception { if (owners!=null) { System.out.println("Owners obtained directly from business logic layer"); return owners; } else return owners=dB4oManager.getOwners(); } public Vector<RuralHouse> getAllRuralHouses() throws RemoteException, Exception { if (ruralHouses!=null) { System.out.println("RuralHouses obtained directly from business logic layer"); return ruralHouses; } else return ruralHouses=dB4oManager.getAllRuralHouses(); } public void close() throws RemoteException{ dB4oManager.close(); } } |
Commits for RRRRHHHH_CoderuralHouses/src/businessLogic/__FacadeImplementation.java
Revision | Author | Commited | Message |
---|---|---|---|
e2ae30 ... Diff | Eneko Pinzolas Murua | Tue 14 Apr, 2015 15:07:35 +0000 | imports leaned |
e16868 ... | Eneko Pinzolas Murua | Mon 09 Mar, 2015 13:02:33 +0000 | deleted aplicationFacade and imported it’s functions to specific business logics. |