import java.util.Vector;
import common.AdminInterface;
+
+import dataAccess.DB4oManager;
import domain.Account;
import domain.Administrator;
import domain.Owner;
*/
private static final long serialVersionUID = 1L;
-
-
-
public AdminManager() throws RemoteException {
}
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);
return Administrator.getInstance().getRemoveRequest().add(rh);
}
-
-
- public boolean addAccountRequest(String usr,
- String pss, Owner ow) throws RemoteException {
-
- Account acc = new Account (usr, pss, ow);
+ 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;
}
@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);
+ // }
}