for testing purpouses
[RRRRHHHH_Code] / ruralHouses / src / businessLogic / HouseManager.java
1 package businessLogic;
2
3 import java.rmi.RemoteException;
4 import java.util.Date;
5 import java.util.Vector;
6
7 import dataAccess.DB4oManager;
8 import domain.Account;
9 import domain.HouseFeatures;
10 import domain.Offer;
11 import domain.Owner;
12 import domain.RuralHouse;
13
14 public class HouseManager implements HouseManagerInterface {
15         DB4oManager dbMngr;
16
17         public HouseManager() {
18                 try {
19                         dbMngr = DB4oManager.getInstance();
20                 } catch (Exception e) {
21
22                         e.printStackTrace();
23                 }
24         }
25
26
27
28         @Override
29         public boolean registerNewHouse(String houseName, Owner owner,
30                         String description, String district, int nRooms, int nKitchens,
31                         int nBaths, int nLivings, int nParkings) {
32                 
33                 boolean stored = false;
34                 if (nKitchens < 1 || nLivings < 3 || nBaths < 2)
35                         return false;
36                 HouseFeatures feature = new HouseFeatures(nRooms, nKitchens, nBaths,
37                                 nLivings, nParkings);
38                 RuralHouse rh = new RuralHouse(houseName,
39                                 owner, description, district, feature);
40                 owner.getRuralHouses().add(rh);
41                 stored = this.dbMngr.storeRuralHouses(rh);
42                 return stored;
43         }
44
45         
46         
47         public void removeHouse(String houseName) {
48                 this.dbMngr.removeHouse(houseName);
49         }
50
51
52
53         @Override
54         public Vector<RuralHouse> getHousesByDistrict(String town) {
55                 
56                 return this.dbMngr.getRuralHousesByTown(town);
57         }
58
59
60
61         @Override
62         public Vector<RuralHouse> getAllRuralHouses() throws RemoteException,
63                         Exception {
64                 return dbMngr.getAllRuralHouses();
65         }
66
67
68
69         @Override
70         public RuralHouse getHouseByName(String Name) {
71                 return this.dbMngr.getRuralHouseByName(Name);
72         }
73
74         // For future implementation
75         // @Override
76         // public void modifyHouse(int houseName, Owner owner, String description,
77         // String town, int nRooms, int nKitchens, int nBaths, int nLivings,
78         // int nParkings) {
79         // // TODO Auto-generated method stub
80         //
81         // }
82
83         // Maybe returning the offer is not necessary. Depends on GUI
84         // implementation.
85
86 }