debugging
[RRRRHHHH_Code] / ruralHouses / src / businessLogic / HouseManager.java
index a876bcd..aca30dc 100644 (file)
@@ -1,81 +1,83 @@
 package businessLogic;
 
-import java.util.Date;
+import java.rmi.RemoteException;
+import java.rmi.server.UnicastRemoteObject;
 import java.util.Vector;
 
+import common.HouseInterface;
+
 import dataAccess.DB4oManager;
-import domain.Account;
-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) {
-                       // 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
+
+       private boolean suitsRegulations(int nKitchens, int nBaths, int nLivings) {
                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;
-
+               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
-               if (nKitchens < 1 || nLivings < 3 || nBaths < 2)
+       public boolean registerNewHouse(RuralHouse rh) {
+
+               boolean stored = false;
+               if (!suitsRegulations(rh.getFeatures().getnKitchens(), rh.getFeatures()
+                               .getnBaths(), rh.getFeatures().getnKitchens()))
                        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;
+               stored = this.dbMngr.storeRuralHouses(rh);
+               return stored;
        }
 
-       @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 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);
        }
-       
-       //Maybe returning the offer is not necessary. Depends on GUI implementation.
+
        @Override
-       public Offer setOffers(RuralHouse ruralHouse, Date firstDay, Date lastDay,
-                       float price) {
-               // 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;
+       public Vector<RuralHouse> getAllRuralHouses() throws RemoteException,
+                       Exception {
+               return dbMngr.getAllRuralHouses();
        }
 
+
+
+       // 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.
+
 }