debugging
[RRRRHHHH_Code] / ruralHouses / src / businessLogic / HouseManager.java
index 4cb6254..aca30dc 100644 (file)
@@ -1,20 +1,24 @@
 package businessLogic;
 
 import java.rmi.RemoteException;
-import java.util.Date;
+import java.rmi.server.UnicastRemoteObject;
 import java.util.Vector;
 
+import common.HouseInterface;
+
 import dataAccess.DB4oManager;
-import domain.Account;
-import domain.HouseFeatures;
-import domain.Offer;
 import domain.Owner;
 import domain.RuralHouse;
 
-public class HouseManager implements HouseManagerInterface {
-       DB4oManager dbMngr;
 
-       public HouseManager() {
+public class HouseManager extends UnicastRemoteObject implements HouseInterface {
+       /**
+        * 
+        */
+       private static final long serialVersionUID = 1L;
+       DB4oManager dbMngr;
+       public HouseManager() throws RemoteException {
+               super();
                try {
                        dbMngr = DB4oManager.getInstance();
                } catch (Exception e) {
@@ -24,54 +28,46 @@ public class HouseManager implements HouseManagerInterface {
        }
 
 
+       private boolean suitsRegulations(int nKitchens, int nBaths, int nLivings) {
+               if (nKitchens < 1 || nLivings < 3 || nBaths < 2)
+                       return false;
+               else
+                       return true;
+       }
 
        @Override
-       public boolean registerNewHouse(String houseName, Owner owner,
-                       String description, String district, int nRooms, int nKitchens,
-                       int nBaths, int nLivings, int nParkings) {
-               
+       public boolean registerNewHouse(RuralHouse rh) {
+
                boolean stored = false;
-               if (nKitchens < 1 || nLivings < 3 || nBaths < 2)
+               if (!suitsRegulations(rh.getFeatures().getnKitchens(), rh.getFeatures()
+                               .getnBaths(), rh.getFeatures().getnKitchens()))
                        return false;
-               HouseFeatures feature = new HouseFeatures(nRooms, nKitchens, nBaths,
-                               nLivings, nParkings);
-               RuralHouse rh = new RuralHouse(houseName,
-                               owner, description, district, feature);
-               owner.getRuralHouses().add(rh);
                stored = this.dbMngr.storeRuralHouses(rh);
                return stored;
        }
 
-       
-       
-       public void removeHouse(String houseName) {
-               this.dbMngr.removeHouse(houseName);
+       public void removeHouse(RuralHouse rh, Owner owner) {
+               Vector<RuralHouse> temp = owner.getRuralHouses();
+               temp.remove(rh);
+               this.dbMngr.removeHouse(rh, owner);
        }
 
 
 
-       @Override
-       public Vector<RuralHouse> getHousesByDistrict(String town) {
-               
-               return this.dbMngr.getRuralHousesByTown(town);
-       }
-
+       public Vector<RuralHouse> getHouses(String name,String town, int nBed, int nKit,
+                       int nBath, int nPark, int nLiv) {
 
+               return this.dbMngr.getRuralHouses( name ,town, nBed, nKit, nBath, nPark, nLiv);
+       }
 
        @Override
        public Vector<RuralHouse> getAllRuralHouses() throws RemoteException,
                        Exception {
-               // TODO Auto-generated method stub
                return dbMngr.getAllRuralHouses();
        }
 
 
 
-       @Override
-       public RuralHouse getHouseByName(String Name) {
-               return this.dbMngr.getRuralHouseByName(Name);
-       }
-
        // For future implementation
        // @Override
        // public void modifyHouse(int houseName, Owner owner, String description,