Administrator class created delete debbuging started
[RRRRHHHH_Code] / ruralHouses / src / businessLogic / HouseManager.java
index a876bcd..a962603 100644 (file)
@@ -1,10 +1,12 @@
 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;
@@ -16,66 +18,70 @@ 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
-               if (nKitchens < 1 || nLivings < 3 || nBaths < 2)
-                       return false;
-               try {
-                       this.dbMngr.storeRuralHouses(new RuralHouse(houseNumber, owner,
-                                       town, nRooms, nKitchens, nBaths, nLivings, nParkings));
-               } catch (Exception e) {
-                       // TODO Auto-generated catch block
-                       e.printStackTrace();
-               }
-               return true;
 
-       }
 
        @Override
-       public boolean registerNewHouse(int houseNumber, Owner owner,
-                       String description, String town, int nRooms, int nKitchens,
+       public boolean registerNewHouse(String houseName, Owner owner,
+                       String description, String district, int nRooms, int nKitchens,
                        int nBaths, int nLivings, int nParkings) {
-               // TODO Auto-generated method stub
+               
+               boolean stored = false;
                if (nKitchens < 1 || nLivings < 3 || nBaths < 2)
                        return false;
-               try {
-                       this.dbMngr.storeRuralHouses(new RuralHouse(houseNumber, owner,
-                                       description, town, nRooms, nKitchens, nBaths, nLivings,
-                                       nParkings));
-               } catch (Exception e) {
-                       // TODO Auto-generated catch block
-                       e.printStackTrace();
-               }
-               return true;
+               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(RuralHouse rh) {
+               this.dbMngr.removeHouse(rh);
        }
 
+
+
        @Override
-       public void modifyHouse(int houseNumber, Owner owner, String description,
-                       String town, int nRooms, int nKitchens, int nBaths, int nLivings,
-                       int nParkings) {
-               // TODO Auto-generated method stub
+       public Vector<RuralHouse> getHousesByDistrict(String town) {
                
+               return this.dbMngr.getRuralHousesByTown(town);
        }
-       
-       //Maybe returning the offer is not necessary. Depends on GUI implementation.
+
+
+
        @Override
-       public Offer setOffers(RuralHouse ruralHouse, Date firstDay, Date lastDay,
-                       float price) {
+       public Vector<RuralHouse> getAllRuralHouses() throws RemoteException,
+                       Exception {
                // TODO Auto-generated method stub
-               try {
-                       return this.dbMngr.createOffer(ruralHouse, firstDay, lastDay, price);
-               } catch (Exception e) {
-                       // TODO Auto-generated catch block
-                       e.printStackTrace();
-               }
-               return null;
+               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,
+       // String town, int nRooms, int nKitchens, int nBaths, int nLivings,
+       // int nParkings) {
+       // // TODO Auto-generated method stub
+       //
+       // }
+
+       // Maybe returning the offer is not necessary. Depends on GUI
+       // implementation.
+
 }