temp
[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, Owner owner) {
48                 Vector<RuralHouse>  temp = owner.getRuralHouses();
49                 temp.remove(temp.size() -1);
50                 this.dbMngr.removeHouse(houseName, owner);
51         }
52
53
54
55         @Override
56         public Vector<RuralHouse> getHousesByDistrict(String town) {
57                 
58                 return this.dbMngr.getRuralHousesByTown(town);
59         }
60
61
62
63         @Override
64         public Vector<RuralHouse> getAllRuralHouses() throws RemoteException,
65                         Exception {
66                 return dbMngr.getAllRuralHouses();
67         }
68
69
70
71         @Override
72         public RuralHouse getHouseByName(String Name) {
73                 return this.dbMngr.getRuralHouseByName(Name);
74         }
75
76         // For future implementation
77         // @Override
78         // public void modifyHouse(int houseName, Owner owner, String description,
79         // String town, int nRooms, int nKitchens, int nBaths, int nLivings,
80         // int nParkings) {
81         // // TODO Auto-generated method stub
82         //
83         // }
84
85         // Maybe returning the offer is not necessary. Depends on GUI
86         // implementation.
87
88 }