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