no warnings
[RRRRHHHH_Code] / ruralHouses / src / businessLogic / HouseManager.java
index 21b8925..7de62a4 100644 (file)
@@ -1,13 +1,9 @@
 package businessLogic;
 
 import java.rmi.RemoteException;
-import java.util.Date;
 import java.util.Vector;
 
 import dataAccess.DB4oManager;
-import domain.Account;
-import domain.HouseFeatures;
-import domain.Offer;
 import domain.Owner;
 import domain.RuralHouse;
 
@@ -18,48 +14,56 @@ public class HouseManager implements HouseManagerInterface {
                try {
                        dbMngr = DB4oManager.getInstance();
                } catch (Exception e) {
-                       // TODO Auto-generated catch block
+
                        e.printStackTrace();
                }
        }
 
-       @Override
-       public boolean registerNewHouse(int houseNumber, Owner owner, String town,
-                       int nRooms, int nKitchens, int nBaths, int nLivings, int nParkings) {
-               // TODO Auto-generated method stub
-               boolean stored = false;
+
+       private boolean suitsRegulations(int nKitchens, int nBaths, int nLivings) {
                if (nKitchens < 1 || nLivings < 3 || nBaths < 2)
                        return false;
-               HouseFeatures feature = new HouseFeatures(nRooms, nKitchens, nBaths,
-                               nLivings, nParkings);
-               stored = this.dbMngr.storeRuralHouses(new RuralHouse(houseNumber,
-                               owner, town, feature));
-               return stored;
-
+               else
+                       return true;
        }
 
        @Override
-       public boolean registerNewHouse(int houseNumber, Owner owner,
-                       String description, String town, int nRooms, int nKitchens,
-                       int nBaths, int nLivings, int nParkings) {
-               // TODO Auto-generated method stub
+       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);
-               stored = this.dbMngr.storeRuralHouses(new RuralHouse(houseNumber,
-                               owner, description, town, feature));
+               rh.getOwner().getRuralHouses().add(rh);
+               stored = this.dbMngr.storeRuralHouses(rh);
                return stored;
        }
 
-       public void removeHouse(int houseNumber) {
-               this.dbMngr.removeHouse(houseNumber);
+       public void removeHouse(RuralHouse rh, Owner owner) {
+               Vector<RuralHouse> temp = owner.getRuralHouses();
+               temp.remove(rh);
+               this.dbMngr.removeHouse(rh, owner);
+       }
+
+
+
+       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 {
+               return dbMngr.getAllRuralHouses();
+       }
+
+
+
        // For future implementation
        // @Override
-       // public void modifyHouse(int houseNumber, Owner owner, String description,
+       // public void modifyHouse(int houseName, Owner owner, String description,
        // String town, int nRooms, int nKitchens, int nBaths, int nLivings,
        // int nParkings) {
        // // TODO Auto-generated method stub