minor changes
[RRRRHHHH_Code] / ruralHouses / src / businessLogic / AccountManager.java
index 7b5efe9..ab418c9 100644 (file)
@@ -1,16 +1,26 @@
 package businessLogic;
 
+import java.rmi.RemoteException;
+import java.rmi.server.UnicastRemoteObject;
+
 import javax.mail.MessagingException;
 
+import common.AccountInterface;
+
 import dataAccess.DB4oManager;
 import domain.Account;
+import domain.Administrator;
 
-public class AccountManager {
+public class AccountManager extends UnicastRemoteObject implements AccountInterface {
        
+       /**
+        * 
+        */
+       private static final long serialVersionUID = 1L;
        private DB4oManager dbMngr;
        
        
-       public AccountManager() {
+       public AccountManager() throws RemoteException {
                try {
                        dbMngr = DB4oManager.getInstance();
                } catch (Exception e) {
@@ -19,12 +29,12 @@ public class AccountManager {
                }
        }
        
-       public boolean addAccount(Account ac){
+       public boolean addAccount(int index) throws RemoteException {
+               Account ac = Administrator.getInstance().getNewOwnerRequest().get(index);
                if(this.dbMngr.addAccount(ac)){
                        try {
                                MailManager.getInstance().Send(ac.getOwner().getMailAccount(), "Entered into the system", "Congratulations");
                        } catch (MessagingException e) {
-                               // TODO Auto-generated catch block
                                e.printStackTrace();
                        }
                        return true;
@@ -33,9 +43,14 @@ public class AccountManager {
                
        }
        
-       public boolean removeAccount(Account ac){
-               if(this.dbMngr.removeAccount(ac))
-                       return true;
+       public boolean removeAccount(int index)throws RemoteException {
+               OwnerManager own = new OwnerManager();
+               try {
+                       if(this.dbMngr.removeAccount(own.getOwners().get(index)))
+                               return true;
+               } catch (Exception e) {
+                       e.printStackTrace();
+               }
                return false;
                
        }