e7b38c92783ae1a8c41368c65f3a29caba12c37d
[RRRRHHHH_Code] / ruralHouses / src / businessLogic / AdminManager.java
1 package businessLogic;
2
3 import java.rmi.RemoteException;
4 import java.rmi.server.UnicastRemoteObject;
5 import java.util.Vector;
6
7 import common.AdminInterface;
8
9 import domain.Account;
10 import domain.Administrator;
11 import domain.Owner;
12 import domain.RuralHouse;
13
14 public class AdminManager extends UnicastRemoteObject implements AdminInterface {
15         /**
16          * 
17          */
18         private static final long serialVersionUID = 1L;
19
20
21
22
23         public AdminManager() throws RemoteException {
24
25         }
26
27         public Vector<RuralHouse> getAdditionRequests() throws RemoteException {
28                 return new Vector<RuralHouse>(Administrator.getInstance()
29                                 .getAddRequest());
30         }
31
32         public Vector<RuralHouse> getDeletionRequests() throws RemoteException {
33                 return new Vector<RuralHouse>(Administrator.getInstance()
34                                 .getRemoveRequest());
35         }
36
37         public Vector<Account> getOwnerAdditionRequests() throws RemoteException {
38                 return new Vector<Account>(Administrator.getInstance()
39                                 .getNewOwnerRequest());
40         }
41         
42         public void removeHouseAdditionRequests(RuralHouse house) throws RemoteException {
43                 Administrator.getInstance().getAddRequest().remove(house);
44         }
45
46         public void removeHouseDeletionRequests(RuralHouse house) throws RemoteException {
47                 Administrator.getInstance().getRemoveRequest().remove(house);
48         }
49         
50         public void removeOwnerAdditionRequests(int index) throws RemoteException {
51                 Administrator.getInstance().getNewOwnerRequest().remove(index);
52         }
53         
54         public boolean addAdditionRequest(RuralHouse rh) throws RemoteException {
55                 if (this.getAdditionRequests().contains(rh)) {
56                         return false;
57                 }
58                 return Administrator.getInstance().getAddRequest().add(rh);
59
60         }
61
62         public boolean addDeletionRequest(RuralHouse rh) throws RemoteException {
63                 if (this.getDeletionRequests().contains(rh))
64                         return false;
65
66                 return Administrator.getInstance().getRemoveRequest().add(rh);
67
68         }
69         
70
71         
72         public boolean addAccountRequest(String usr,
73                         String pss, Owner ow) throws RemoteException {
74                 
75                 Account acc = new Account (usr, pss,  ow);
76                 if (this.getOwnerAdditionRequests().contains(acc)) {
77                         return false;
78                 }
79                 return Administrator.getInstance().getNewOwnerRequest().add(acc);
80         }
81
82         @Override
83         public void saveInstance() throws RemoteException {
84                 Administrator.saveInstance();
85                 
86         }
87
88
89
90
91 //      public boolean removeAccount(Account acc) {
92 //              if (this.getDeletionRequests().contains(acc))
93 //                      return false;
94 //              return Administrator.getInstance().getNewOwnerRequest().add(acc);
95 //      }
96 }