The bug found in the presentation that we forgot to review has been fixed
[RRRRHHHH_Code] / ruralHouses / src / businessLogic / AdminManager.java
index f2790a9..0d8d152 100644 (file)
@@ -6,8 +6,10 @@ import java.util.Vector;
 
 import common.AdminInterface;
 
+import dataAccess.DB4oManager;
 import domain.Account;
 import domain.Administrator;
+import domain.Owner;
 import domain.RuralHouse;
 
 public class AdminManager extends UnicastRemoteObject implements AdminInterface {
@@ -16,9 +18,6 @@ public class AdminManager extends UnicastRemoteObject implements AdminInterface
         */
        private static final long serialVersionUID = 1L;
 
-
-
-
        public AdminManager() throws RemoteException {
 
        }
@@ -37,21 +36,35 @@ public class AdminManager extends UnicastRemoteObject implements AdminInterface
                return new Vector<Account>(Administrator.getInstance()
                                .getNewOwnerRequest());
        }
-       
-       public void removeHouseAdditionRequests(RuralHouse house) throws RemoteException {
+
+       public Vector<Owner> getAllOwners() throws RemoteException {
+               try {
+                       return new Vector<Owner>(DB4oManager.getInstance().getOwners());
+               } catch (Exception e) {
+                       e.printStackTrace();
+               }
+               return null;
+       }
+
+       public void removeHouseAdditionRequests(RuralHouse house)
+                       throws RemoteException {
                Administrator.getInstance().getAddRequest().remove(house);
        }
 
-       public void removeHouseDeletionRequests(RuralHouse house) throws RemoteException {
+       public void removeHouseDeletionRequests(RuralHouse house)
+                       throws RemoteException {
                Administrator.getInstance().getRemoveRequest().remove(house);
        }
-       
-       public void removeOwnerAdditionRequests(Account acc) throws RemoteException {
-               Administrator.getInstance().getNewOwnerRequest().remove(acc);
+
+       public void removeOwnerAdditionRequests(int index) throws RemoteException {
+               Administrator.getInstance().getNewOwnerRequest().remove(index);
        }
-       
+
        public boolean addAdditionRequest(RuralHouse rh) throws RemoteException {
-               if (this.getAdditionRequests().contains(rh)) {
+               if (this.getAdditionRequests().contains(rh)
+                               || !suitsRegulations(rh.getFeatures().getnKitchens(), rh
+                                               .getFeatures().getnBaths(),rh
+                                               .getFeatures().getnLivings())) {
                        return false;
                }
                return Administrator.getInstance().getAddRequest().add(rh);
@@ -65,11 +78,11 @@ public class AdminManager extends UnicastRemoteObject implements AdminInterface
                return Administrator.getInstance().getRemoveRequest().add(rh);
 
        }
-       
-       
 
-       
-       public boolean addAccount(Account acc) throws RemoteException {
+       public boolean addAccountRequest(String usr, String pss, Owner ow)
+                       throws RemoteException {
+
+               Account acc = new Account(usr, pss, ow);
                if (this.getOwnerAdditionRequests().contains(acc)) {
                        return false;
                }
@@ -79,14 +92,19 @@ public class AdminManager extends UnicastRemoteObject implements AdminInterface
        @Override
        public void saveInstance() throws RemoteException {
                Administrator.saveInstance();
-               
-       }
 
+       }
 
+       private boolean suitsRegulations(int nKitchens, int nBaths, int nLivings) {
+               if (nKitchens < 1 || nLivings < 3 || nBaths < 2)
+                       return false;
+               else
+                       return true;
+       }
 
-//     public boolean removeAccount(Account acc) {
-//             if (this.getDeletionRequests().contains(acc))
-//                     return false;
-//             return Administrator.getInstance().getNewOwnerRequest().add(acc);
-//     }
+       // public boolean removeAccount(Account acc) {
+       // if (this.getDeletionRequests().contains(acc))
+       // return false;
+       // return Administrator.getInstance().getNewOwnerRequest().add(acc);
+       // }
 }