Merge branch 'master' of https://xp-dev.com/git/RRRRHHHH_Code
authorcamjan <jcampos004@ikasle.ehu.es>
Tue, 19 May 2015 23:23:13 +0000 (01:23 +0200)
committercamjan <jcampos004@ikasle.ehu.es>
Tue, 19 May 2015 23:23:13 +0000 (01:23 +0200)
Conflicts:
ruralHouses client/src/gui/HouseFeaturesGUI.java
ruralHouses client/src/gui/ModifyOfferGUI.java
ruralHouses/src/domain/RuralHouse.java

14 files changed:
1  2 
ruralHouses client/src/common/AccountInterface.java
ruralHouses client/src/gui/AdminMenuGUI.java
ruralHouses client/src/gui/DeleteOwnerGUI.java
ruralHouses client/src/gui/HouseFeaturesGUI.java
ruralHouses client/src/gui/ModifyHouseGUI.java
ruralHouses client/src/gui/ModifyOfferGUI.java
ruralHouses client/src/gui/listOfBookingRequestsGUI.java
ruralHouses/src/businessLogic/AccountManager.java
ruralHouses/src/businessLogic/BookingManager.java
ruralHouses/src/businessLogic/OfferManager.java
ruralHouses/src/common/AccountInterface.java
ruralHouses/src/dataAccess/DB4oManager.java
ruralHouses/src/domain/Account.java
ruralHouses/src/domain/RuralHouse.java

@@@ -3,12 -3,12 +3,10 @@@ package common
  import java.rmi.Remote;
  import java.rmi.RemoteException;
  
--import domain.Account;
--
  public interface AccountInterface extends Remote{
        
  
        public boolean addAccount(int index) throws RemoteException;
        
 -      public boolean removeAccount(Account ac) throws RemoteException;
 +      public boolean removeAccount(int index) throws RemoteException;
  }
@@@ -4,13 -4,12 +4,10 @@@ import java.awt.Frame
  import java.awt.event.ActionEvent;
  import java.awt.event.ActionListener;
  
--import javax.swing.GroupLayout;
--import javax.swing.GroupLayout.Alignment;
  import javax.swing.JButton;
  import javax.swing.JFrame;
  import javax.swing.JPanel;
  import javax.swing.border.EmptyBorder;
- import javax.swing.LayoutStyle.ComponentPlacement;
  
  public class AdminMenuGUI extends JFrame {
  
                
                this.setTitle("Administrator Menu");
                this.getContentPane().setLayout(null);
 -              setBounds(100, 100, 450, 473);
 +              setBounds(100, 100, 450, 500);
                contentPane = new JPanel();
                contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
                setContentPane(contentPane);
                //TODO BOTH BUTTONS ARE TO MODIFY
                JButton btnAdd = new JButton("Add requests");
 +              btnAdd.setBounds(120, 67, 164, 81);
                btnAdd.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent e) {
                                Frame a = new listOfAdditionRequestsGUI();
@@@ -45,7 -43,6 +42,7 @@@
                });
                
                JButton btnDel = new JButton("Delete Requests");
 +              btnDel.setBounds(120, 159, 164, 73);
                btnDel.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent e) {
                                Frame a = new listOfRemovalRequestsGUI();
                });
                
                JButton btnOwneraddition = new JButton("OwnerAddition");
 +              btnOwneraddition.setBounds(120, 243, 164, 73);
                btnOwneraddition.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent e) {
                                Frame a = new listOfOwnerAddittionRequests();
                                a.setVisible(true);
                        }
                });
 -              GroupLayout gl_contentPane = new GroupLayout(contentPane);
 -              gl_contentPane.setHorizontalGroup(
 -                      gl_contentPane.createParallelGroup(Alignment.LEADING)
 -                              .addGroup(gl_contentPane.createSequentialGroup()
 -                                      .addGap(115)
 -                                      .addGroup(gl_contentPane.createParallelGroup(Alignment.TRAILING, false)
 -                                              .addComponent(btnOwneraddition, Alignment.LEADING, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
 -                                              .addComponent(btnDel, Alignment.LEADING, GroupLayout.DEFAULT_SIZE, 164, Short.MAX_VALUE)
 -                                              .addComponent(btnAdd, Alignment.LEADING, GroupLayout.DEFAULT_SIZE, 164, Short.MAX_VALUE))
 -                                      .addContainerGap(145, Short.MAX_VALUE))
 -              );
 -              gl_contentPane.setVerticalGroup(
 -                      gl_contentPane.createParallelGroup(Alignment.LEADING)
 -                              .addGroup(gl_contentPane.createSequentialGroup()
 -                                      .addGap(62)
 -                                      .addComponent(btnAdd, GroupLayout.PREFERRED_SIZE, 81, GroupLayout.PREFERRED_SIZE)
 -                                      .addGap(58)
 -                                      .addComponent(btnDel, GroupLayout.PREFERRED_SIZE, 81, GroupLayout.PREFERRED_SIZE)
 -                                      .addGap(52)
 -                                      .addComponent(btnOwneraddition, GroupLayout.DEFAULT_SIZE, 79, Short.MAX_VALUE)
 -                                      .addContainerGap())
 -              );
 -              contentPane.setLayout(gl_contentPane);
 +              contentPane.setLayout(null);
 +              contentPane.add(btnOwneraddition);
 +              contentPane.add(btnDel);
 +              contentPane.add(btnAdd);
 +      
 +              JButton btnOwnerDeletion = new JButton("Owner Deletion");
 +              btnOwnerDeletion.setBounds(120, 331, 164, 73);
 +              btnOwnerDeletion.addActionListener(new ActionListener() {
 +                      public void actionPerformed(ActionEvent e) {
 +                              Frame a = new DeleteOwnerGUI();
 +                              a.setVisible(true);
 +                      }
 +              });
 +              contentPane.add(btnOwnerDeletion);
        }
  }
index 75305dc,0000000..fb2fcdb
mode 100644,000000..100644
--- /dev/null
@@@ -1,144 -1,0 +1,139 @@@
- import java.awt.Color;
- import java.awt.Component;
 +package gui;
 +
- import java.awt.event.MouseAdapter;
- import java.awt.event.MouseEvent;
 +import java.awt.Font;
 +import java.awt.Rectangle;
 +import java.awt.event.ActionEvent;
 +import java.awt.event.ActionListener;
 +import java.rmi.Naming;
 +import java.rmi.RemoteException;
 +import java.util.Enumeration;
 +import java.util.Vector;
 +
 +import javax.swing.JButton;
 +import javax.swing.JFrame;
 +import javax.swing.JLabel;
 +import javax.swing.JPanel;
 +import javax.swing.JScrollPane;
 +import javax.swing.JTable;
 +import javax.swing.border.EmptyBorder;
 +import javax.swing.table.DefaultTableModel;
 +
 +import common.AccountInterface;
 +import common.OwnerInterface;
++
 +import configuration.___IntNames;
 +import domain.Owner;
 +
 +public class DeleteOwnerGUI extends JFrame {
 +
 +      /**
 +       * 
 +       */
 +      private static final long serialVersionUID = 1L;
 +      private JPanel contentPane;
 +      private JTable table;
 +
 +      private DefaultTableModel tableModel;
 +      private OwnerInterface Own = null;
 +      private Vector<Owner> owners = new Vector<Owner>();
 +
 +      /**
 +       * Create the frame.
 +       */
 +      public DeleteOwnerGUI() {
 +              setTitle("Current owners:");
 +              try {
 +                      init();
 +              } catch (Exception e) {
 +                      e.printStackTrace();
 +              }
 +      }
 +
 +      private void init() throws Exception {
 +              setBounds(100, 100, 600, 500);
 +              contentPane = new JPanel();
 +              contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
 +              setContentPane(contentPane);
 +              contentPane.setLayout(null);
 +              try {
 +                      Own = (OwnerInterface) Naming
 +                                      .lookup(___IntNames.OwnerManager);
 +              } catch (Exception e1) {
 +                      System.out
 +                                      .println("Error accessing remote authentication: "
 +                                                      + e1.toString());
 +              }
 +              this.owners = Own.getOwners();
 +              JLabel lblNewLabel = new JLabel();
 +              lblNewLabel.setFont(new Font("Tahoma", Font.PLAIN, 27));
 +              lblNewLabel.setBounds(23, 41, 536, 33);
 +              contentPane.add(lblNewLabel);
 +              if (this.owners.isEmpty())
 +                      lblNewLabel
 +                                      .setText("There are not owners in the system");
 +              else
 +                      lblNewLabel.setText("List of owners:");
 +              JScrollPane scrollPane = new JScrollPane();
 +              scrollPane.setBounds(new Rectangle(45, 305, 320, 116));
 +              scrollPane.setBounds(23, 113, 536, 271);
 +              contentPane.add(scrollPane);
 +              JLabel feedback = new JLabel("");
 +              feedback.setBounds(134, 447, 307, 14);
 +              contentPane.add(feedback);
 +              JButton btnNewButton = new JButton("Delete from the system");
 +              btnNewButton.addActionListener(new ActionListener() {
 +                      public void actionPerformed(ActionEvent e) {
 +                              if (table.getRowCount()!=0 && table.getSelectedRow() != -1) {
 +                                      AccountInterface acm = null;
 +                                      
 +                                      try {
 +                                              acm = (AccountInterface) Naming
 +                                                              .lookup(___IntNames.AccountManager);
 +                                      } catch (Exception e1) {
 +                                              System.out.println("Error accessing remote authentication: "
 +                                                              + e1.toString());
 +                                      }
 +
 +                                      try {
 +                                              if(acm.removeAccount(table.getSelectedRow()))
 +                                                      {
 +                                                      feedback.setText("Deleted from the system");
 +                                                      }
 +                                      } catch (RemoteException e1) {
 +                                              e1.printStackTrace();
 +                                      }
 +                                      
 +                                      ((DefaultTableModel)table.getModel()).removeRow(table.getSelectedRow());
 +                              }
 +                      }
 +              });
 +              btnNewButton.setBounds(88, 396, 428, 40);
 +              contentPane.add(btnNewButton);
 +              table = new JTable() {
 +                      private static final long serialVersionUID = 1L;
 +
 +                      public boolean isCellEditable(int row, int column) {
 +                              return false;
 +                      };
 +              };
 +              
 +              scrollPane.setViewportView(table);      
 +              tableModel = new DefaultTableModel(null, new String[] {
 +                              "Name", "E-mail", "Bank Account" });
 +
 +              table.setModel(tableModel);
 +              
 +              
 +              Enumeration<Owner> rhs = this.owners.elements();
 +              while (rhs.hasMoreElements()) {
 +                      Owner own = rhs.nextElement();
 +                      Vector<Object> row = new Vector<Object>();
 +                      row.add(own.getName());
 +                      row.add(own.getMailAccount());
 +                      row.add(own.getBankAccount());
 +                      tableModel.addRow(row);
 +              }
 +              
 +              
 +      }
 +}
@@@ -55,7 -55,6 +55,7 @@@ public class HouseFeaturesGUI extends J
        private JTable table;
        private DefaultTableModel tableModel;
        private RuralHouse rh;
 +      private Vector<Offer> offers= new Vector<Offer>();
        private JTextField telIn;
        private int row;
        private JLabel labelPhone;
                Enumeration<Offer> rhs = rh.getAllOffers().elements();
                while (rhs.hasMoreElements()) {
                        Offer of = rhs.nextElement();
 -                      if (of.getBookings() != null) {
 +                      if (of.getBookings() == null
 +                                      || !of.isBooked()) {
 +                              offers.add(of);
                                Vector<Object> row = new Vector<Object>();
                                row.add(of.getOfferNumber());
                                row.add(of.getFirstDay());
                                        + e1.toString());
                }
                
-               //RegExp to see if telephone number is correct??TODO
                if (telIn.getText().matches("[976]\\d{2}[.\\- ]?\\d{3}[.\\- ]?\\d{3}")
                                && mailField
                                .getText()
                                if (table.getRowCount() != 0) {
                                        Client cl = new Client(nameField.getText(),
                                                        mailField.getText(), telIn.getText());
 -                                      book = bookingM.createBooking(rh, rh.offers.get(row)
 -                                                      .getFirstDay(), rh.offers.get(row).getLastDay(),cl);
 +                                      book = bookingM.createBooking(rh, offers.get(row)
 +                                                      .getFirstDay(), offers.get(row).getLastDay(),cl);
                                }
                        } catch (Exception e) {
                                e.printStackTrace();
@@@ -6,6 -6,7 +6,7 @@@ import java.awt.event.ItemEvent
  import java.awt.event.ItemListener;
  import java.rmi.Naming;
  import java.rmi.RemoteException;
+ import java.util.Vector;
  
  import javax.swing.DefaultComboBoxModel;
  import javax.swing.JButton;
@@@ -18,7 -19,6 +19,7 @@@ import javax.swing.SwingConstants
  import javax.swing.border.EmptyBorder;
  
  import common.HouseInterface;
 +
  import configuration.___IntNames;
  import domain.Districs;
  import domain.HouseFeatures;
@@@ -159,8 -159,22 +160,22 @@@ public class ModifyHouseGUI extends JFr
  
                        }
                });
-               houseBox = new JComboBox<RuralHouse>(o.getRuralHouses());
+               HouseInterface hm= null;
+               try {
+                       hm = (HouseInterface) Naming
+                                       .lookup(___IntNames.HouseManager);
+               } catch (Exception e1) {
+                       System.out.println("Error accessing remote authentication: "
+                                       + e1.toString());
+               }
+               Vector<RuralHouse> list = null;
+               try {
+                       list = hm.getHouses(o, null, null, 0, 0, 0, 0, 0);
+               } catch (RemoteException e1) {
+                       e1.printStackTrace();
+               }
+               
+               houseBox = new JComboBox<RuralHouse>(list);
                if (!o.getRuralHouses().isEmpty()) {
                        rh = (RuralHouse) houseBox.getSelectedItem();                   
                        comboBox.setSelectedItem(rh.getDistrict());             
@@@ -12,6 -12,7 +12,7 @@@ import java.awt.event.ItemListener
  import java.beans.PropertyChangeEvent;
  import java.beans.PropertyChangeListener;
  import java.rmi.Naming;
+ import java.rmi.RemoteException;
  import java.sql.Date;
  import java.text.DateFormat;
  import java.util.Calendar;
@@@ -25,10 -26,12 +26,12 @@@ import javax.swing.JLabel
  import javax.swing.JTextField;
  
  import com.toedter.calendar.JCalendar;
 -
+ import common.HouseInterface;
  import common.OfferInterface;
 +
  import configuration.___IntNames;
  import domain.Offer;
+ import domain.Owner;
  import domain.RuralHouse;
  import exceptions.BadDates;
  
@@@ -54,22 -57,44 +57,40 @@@ public class ModifyOfferGUI extends JFr
        private JLabel jLabel5 = new JLabel();
        private final JLabel jLabel1_o = new JLabel();
        private JComboBox<Offer> comboBox_o;
+       private Vector<RuralHouse> Hlist = null;
+       private OfferInterface  om = null;
+       private HouseInterface hm = null;
  
-       public ModifyOfferGUI(Vector<RuralHouse> v) {
+       public ModifyOfferGUI(Owner o) {
                try {
-                       jbInit(v);
+                       jbInit(o);
                } catch (Exception e) {
                        e.printStackTrace();
                }
        }
  
-       private void jbInit(Vector<RuralHouse> v) throws Exception {
+       private void jbInit(Owner o) throws Exception {
                this.getContentPane().setLayout(null);
                this.setSize(new Dimension(513, 433));
                this.setTitle("Set availability");
  
-               
-               jComboBox1 = new JComboBox<RuralHouse>(v);
 -<<<<<<< HEAD
+               try {
+                       om = (OfferInterface) Naming
+                                       .lookup(___IntNames.OfferManager);
+                       hm = (HouseInterface) Naming
+                                       .lookup(___IntNames.HouseManager);
+               } catch (Exception e1) {
+                       System.out.println("Error accessing remote authentication: "
+                                       + e1.toString());
+               }
+               try {
+                       Hlist = hm.getHouses(o, null, null, 0, 0, 0, 0, 0);
+               } catch (RemoteException e1) {
+                       e1.printStackTrace();
 -              }
 -=======
 ->>>>>>> 25898b619dd708c9f15a44200b545cac11404b73
 -              
++              }               
+               jComboBox1 = new JComboBox<RuralHouse>(Hlist);
  
                comboBox_o = new JComboBox<Offer>(
                                ((RuralHouse) jComboBox1.getSelectedItem()).getAllOffers());
  
                        @Override
                        public void itemStateChanged(ItemEvent arg0) {
-                               Vector<Offer> vo = ((RuralHouse) jComboBox1.getSelectedItem()).getAllOffers();
++
+                               Vector<Offer> vo= null;
+                               try {
+                                       vo = om.getRuralHouseOffers((RuralHouse) jComboBox1.getSelectedItem());
+                               } catch (RemoteException e) {
+                                       // TODO Auto-generated catch block
+                                       e.printStackTrace();
+                               }
                                comboBox_o.removeAllItems();
-                               if (!((RuralHouse) jComboBox1.getSelectedItem()).getAllOffers()
-                                               .isEmpty()) {
+                               if (!vo.isEmpty()) {
                                        jCalendar1.setEnabled(true);
                                        jCalendar2.setEnabled(true);
                                        jButton1.setEnabled(true);
@@@ -1,14 -1,10 +1,13 @@@
  package gui;
  
 +import java.awt.Color;
 +import java.awt.Component;
  import java.awt.Font;
  import java.awt.Rectangle;
  import java.awt.event.ActionEvent;
  import java.awt.event.ActionListener;
 +import java.rmi.Naming;
  import java.rmi.RemoteException;
- import java.util.Date;
  import java.util.Enumeration;
  import java.util.Vector;
  
@@@ -19,12 -15,10 +18,12 @@@ import javax.swing.JPanel
  import javax.swing.JScrollPane;
  import javax.swing.JTable;
  import javax.swing.border.EmptyBorder;
 +import javax.swing.table.DefaultTableCellRenderer;
  import javax.swing.table.DefaultTableModel;
  
  import common.BookingInterface;
- import common.OfferInterface;
 +import configuration.___IntNames;
  import domain.Booking;
  import domain.Offer;
  
@@@ -37,7 -31,7 +36,7 @@@ public class listOfBookingRequestsGUI e
        private JPanel contentPane;
        private JTable table;
        private Offer off;
 -      private BookingInterface bookM =null;
 +      private BookingInterface bookM = null;
        private DefaultTableModel tableModel;
        private Vector<Booking> bookings = new Vector<Booking>();
  
@@@ -62,8 -56,8 +61,8 @@@
                contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
                setContentPane(contentPane);
                contentPane.setLayout(null);
 -              
 -              this.bookings= this.off.getBookings();
 +
 +              this.bookings = this.off.getBookings();
                JLabel lblNewLabel = new JLabel();
                lblNewLabel.setFont(new Font("Tahoma", Font.PLAIN, 27));
                lblNewLabel.setBounds(23, 41, 536, 33);
                        };
                };
                scrollPane.setViewportView(table);
 -              tableModel = new DefaultTableModel(null, new String[] {
 -                              "Booking Number", "Booking Date","Name","E-mail", "Telephone" });
 +              tableModel = new DefaultTableModel(null,
 +                              new String[] { "Booking Number", "Booking Date", "Name",
 +                                              "E-mail", "Telephone" });
  
 -              // Maybe there is a better way to avoid interaction.
 -              // table.setEnabled(false);
                table.setModel(tableModel);
  
                JButton btnNewButton = new JButton("Confirm Booking");
                btnNewButton.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent e) {
 +                              try {
 +                                      bookM = (BookingInterface) Naming
 +                                                      .lookup(___IntNames.BookingManager);
 +                              } catch (Exception e1) {
 +                                      System.out
 +                                                      .println("Error accessing remote authentication: "
 +                                                                      + e1.toString());
 +                              }
                                if (table.getRowCount() != 0 && table.getSelectedRow() != -1) {
 -                                      if (table.getRowCount() != 0 && table.getSelectedRow() != -1) {
 +                                      if (table.getRowCount() != 0
 +                                                      && table.getSelectedRow() != -1) {
                                                Booking book = bookings.get(table.getSelectedRow());
                                                try {
                                                        bookM.acceptBooking(book);
                                                } catch (RemoteException e1) {
                                                        e1.printStackTrace();
                                                }
 +                                              contentPane.setVisible(false);
 +
                                        }
  
                                }
                JButton btnDenyAddition = new JButton("Deny Booking");
                btnDenyAddition.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent arg0) {
 +                              try {
 +                                      bookM = (BookingInterface) Naming
 +                                                      .lookup(___IntNames.BookingManager);
 +                              } catch (Exception e1) {
 +                                      System.out
 +                                                      .println("Error accessing remote authentication: "
 +                                                                      + e1.toString());
 +                              }
                                if (table.getRowCount() != 0 && table.getSelectedRow() != -1) {
                                        Booking book = bookings.get(table.getSelectedRow());
                                        try {
 -                                              bookM.removeDenyBooking(book);
 +                                              bookM.denyBooking(book);
                                        } catch (RemoteException e) {
                                                e.printStackTrace();
                                        }
 +                                      ((DefaultTableModel) table.getModel()).removeRow(table
 +                                                      .getSelectedRow());
  
                                }
                        }
                });
 +
 +              if (this.bookings.get(0).getOffer().isBooked()) {
 +                      btnDenyAddition.setEnabled(false);
 +                      btnNewButton.setEnabled(false);
 +              }
 +
                btnDenyAddition.setBounds(390, 395, 169, 25);
                contentPane.add(btnDenyAddition);
 -              
 +
                Enumeration<Booking> en = this.bookings.elements();
                Booking book;
                while (en.hasMoreElements()) {
                        row.add(book.getClient().getTelephone());
                        tableModel.addRow(row);
                }
 +              table.setDefaultRenderer(Object.class, new DefaultTableCellRenderer() {
 +                      /**
 +                       * 
 +                       */
 +                      private static final long serialVersionUID = 1L;
 +
 +                      @Override
 +                      public Component getTableCellRendererComponent(JTable table,
 +                                      Object value, boolean isSelected, boolean hasFocus,
 +                                      int row, int col) {
 +
 +                              super.getTableCellRendererComponent(table, value, isSelected,
 +                                              hasFocus, row, col);
 +
 +                              if (!bookings.get(row).getOffer().isBooked()) {
 +                                      setBackground(Color.RED);
 +                                      setForeground(Color.BLACK);
 +                              } else {
 +                                      setBackground(Color.GREEN);
 +                                      setForeground(Color.BLACK);
 +                              }
  
 +                              return this;
 +                      }
 +              });
        }
 +
  }
@@@ -6,6 -6,7 +6,7 @@@ import java.rmi.server.UnicastRemoteObj
  import javax.mail.MessagingException;
  
  import common.AccountInterface;
  import dataAccess.DB4oManager;
  import domain.Account;
  import domain.Administrator;
@@@ -42,15 -43,9 +43,15 @@@ public class AccountManager extends Uni
                
        }
        
 -      public boolean removeAccount(Account ac)throws RemoteException {
 -              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) {
 +                      // TODO Auto-generated catch block
 +                      e.printStackTrace();
 +              }
                return false;
                
        }
@@@ -5,12 -5,10 +5,12 @@@ import java.rmi.server.UnicastRemoteObj
  import java.util.Date;
  import java.util.Vector;
  
 +import javax.mail.MessagingException;
 +
  import com.db4o.ObjectContainer;
  import com.db4o.ObjectSet;
  import common.BookingInterface;
  import dataAccess.DB4oManager;
  import domain.Booking;
  import domain.Client;
@@@ -73,21 -71,25 +73,21 @@@ public final class BookingManager exten
                return theBookingManager;
        }
  
 -      public void removeDenyBooking(Booking b) throws RemoteException{
 -                              b.getOffer().getBookings().remove(b);
 +      public void denyBooking(Booking b) throws RemoteException{
                                this.dbMngr.removeBooking(b);
        }
  
  
        public void acceptBooking(Booking b) throws RemoteException{
                b.getOffer().setBooked(true);
 -              for(Booking boo : b.getOffer().getBookings()){
 -                      if(!boo.equals(b))
 -                              b.getOffer().getBookings().remove(b);
 -              }
 +              b.getOffer().getBookings().clear();
 +              b.getOffer().getBookings().add(b);
                this.dbMngr.acceptBooking(b.getOffer());
 -              /*try {
 +              try {
                        MailManager.getInstance().Send(b.getClient().getMailAccount(), "Your booking has been accepted","Here should be the bill");
                } catch (MessagingException e) {
 -                      // TODO Auto-generated catch block
                        e.printStackTrace();
 -              }*/
 +              }
                
        }
        /**
@@@ -56,17 -56,17 +56,17 @@@ public final class OfferManager extend
  
        
        public void deleteOffer(RuralHouse rh, Offer o) throws RemoteException, Exception{
 -              rh.offers.removeElement(o);
 +              rh.getAllOffers().removeElement(o);
                dbMngr.deleteOffer( o);
        }
  
  
  
        @Override
-       public Vector<RuralHouse> getRuralHouseOffers(RuralHouse rh)
+       public Vector<Offer> getRuralHouseOffers(RuralHouse rh)
                        throws RemoteException {
                // TODO Auto-generated method stub
-               return null;
+               return dbMngr.getRHsOffer(rh.getHouseName());
        }
  
  }
@@@ -3,12 -3,12 +3,10 @@@ package common
  import java.rmi.Remote;
  import java.rmi.RemoteException;
  
--import domain.Account;
--
  public interface AccountInterface extends Remote{
        
  
        public boolean addAccount(int index) throws RemoteException;
        
 -      public boolean removeAccount(Account ac) throws RemoteException;
 +      public boolean removeAccount(int index) throws RemoteException;
  }
@@@ -81,13 -81,10 +81,13 @@@ public class DB4oManager 
                configuration = Db4oEmbedded.newConfiguration();
                configuration.common().activationDepth(c.getActivationDepth());
                configuration.common().updateDepth(c.getUpdateDepth());
 -              configuration.common().objectClass(Owner.class).cascadeOnUpdate(true);
                configuration.common().objectClass(Owner.class).cascadeOnDelete(true);
 +              configuration.common().objectClass(Booking.class).cascadeOnDelete(true);
                configuration.common().objectClass(RuralHouse.class)
 -                              .cascadeOnUpdate(true);
 +                              .cascadeOnDelete(true);
 +              configuration.common().objectClass(Account.class)
 +              .cascadeOnDelete(true);
 +              configuration.common().objectClass(Offer.class).cascadeOnDelete(true);
                configuration.common().objectClass(Account.class).cascadeOnUpdate(true);
                db = Db4oEmbedded.openFile(configuration, c.getDb4oFilename());
        }
                try {
                        ObjectSet<Offer> of = db.queryByExample(offer);
                        RuralHouse rh = of.get(0).getRuralHouse();
 -                      System.out.println(rh.offers.remove(of.get(0)));
 +                      System.out.println(rh.getAllOffers().remove(of.get(0)));
                        db.store(rh);
                        db.commit();
  
                }
        }
  
-       public Administrator getAdminData() {
+       public Vector<Offer> getRHsOffer(String name){
+               if (c.isDatabaseLocal() == false)
+                       openSDB();
+               else
+                       openDB();
+               try {
+                       RuralHouse rh = (RuralHouse)db.queryByExample(new RuralHouse(name, null, null, null, null)).get(0);
+                       Offer proto = new Offer(0, rh, null, null, 0);
+                       ObjectSet<Offer> result = db.queryByExample(proto);
+                       return new Vector<Offer>(result);
+               } finally {
+                       db.close();
+               }
+       }
+       
+       public Administrator getAdminData(){
                if (c.isDatabaseLocal() == false)
                        openSDB();
                else
                }
        }
  
+       
        public Vector<RuralHouse> getAllRuralHouses() throws RemoteException,
                        Exception {
  
                try {
                        RuralHouse proto = new RuralHouse(null, null, null, null, null);
                        ObjectSet<RuralHouse> result = db.queryByExample(proto);
-                       Vector<RuralHouse> ruralHouses = new Vector<RuralHouse>();
-                       while (result.hasNext())
-                               ruralHouses.add((RuralHouse) result.next());
-                       return ruralHouses;
+                       return new Vector<RuralHouse>(result);
                } finally {
                        db.close();
                }
  
        }
  
-       public Vector<RuralHouse> getRuralHouses(String name, String town,
+       public Vector<RuralHouse> getRuralHouses(Owner ow, String name, String town,
                        int nBed, int nKit, int nBath, int nPark, int nLiv) {
                HouseFeatures fea = new HouseFeatures(nBed, nKit, nBath, nLiv, nPark);
-               RuralHouse rh = new RuralHouse(name, null, null, town, fea);
+               RuralHouse rh = new RuralHouse(name, ow, null, town, fea);
                if (c.isDatabaseLocal() == false)
                        openSDB();
                else
                return false;
        }
  
 -      // TODO remove account
 -
 -      public boolean removeAccount(Account acc) {
 +      public boolean removeAccount(Owner own) {
                if (c.isDatabaseLocal() == false)
                        openSDB();
                else
                        openDB();
  
                try {
 -                      ObjectSet<Account> result = db.queryByExample(new Account(acc
 -                                      .getUsername()));
 +                      ObjectSet<Account> result = db.queryByExample(new Account(own));
                        if (!result.isEmpty()) {
                                db.delete(result.get(0));
 -                              ;
                                db.commit();
                                return true;
                        }
                return false;
        }
  
 -      // TODO this method should be improved.
        public void acceptBooking(Offer of) {
 -              Offer off = new Offer(of.getOfferNumber(), of.getRuralHouse(),
 -                              of.getFirstDay(), of.getLastDay(), of.getPrice());
 +              Offer off = new Offer(of.getOfferNumber(), new RuralHouse(of
 +                              .getRuralHouse().getHouseName(), null, null, null, null), null,
 +                              null, 0);
                if (c.isDatabaseLocal() == false)
                        openSDB();
                else
  
                try {
                        ObjectSet<Offer> result = db.queryByExample(off);
 -                      this.deleteOffer(result.get(0));
 -                      db.store(of);
 +                      db.delete(result.get(0));
 +                      RuralHouse rh = result.get(0).getRuralHouse();
 +                      of.setRuralHouse(rh);
 +                      rh.getAllOffers().remove(result.get(0));
 +                      rh.getAllOffers().add(of);
 +                      db.store(rh);
                        db.close();
  
                } catch (Exception e) {
                        openDB();
                try {
                        ObjectSet<Booking> result = db.queryByExample(b);
 -                      ObjectSet<Client> result2 = db.queryByExample(b.getClient());
 +                      result.get(0).getOffer().getBookings().remove(b);
 +                      db.store(result.get(0).getOffer());
                        db.delete(result.get(0));
 -                      db.delete(result2.get(0));
                        db.commit();
                } catch (Exception e) {
                        e.printStackTrace();
 -                      ;
                } finally {
                        db.close();
                }
@@@ -28,13 -28,6 +28,13 @@@ public class Account implements Seriali
                this.password = null;
                this.owner = null;
                
 +      }
 +      public Account(Owner own){
 +              this.username = null;
 +              this.salt =null;
 +              this.password = null;
 +              this.owner = own;
 +              
        }
        public Account(String usr, String pass, boolean isAdmin) {
                this.username = SecurityManager.getInstance().calculateHash(usr);
@@@ -72,6 -65,7 +72,7 @@@
                return admin;
        }
  
+       
        public void setAdmin(boolean admin) {
                this.admin = admin;
        }
@@@ -14,9 -14,8 +14,10 @@@ public class RuralHouse implements Seri
        private Owner owner;
        private String district;
        private HouseFeatures features;
 -      public Vector<Offer> offers;
 +      private Vector<Offer> offers;
 +      private boolean isAccepted;
 +
        public RuralHouse() {
                super();
        }
  
        }
  
 +      public boolean isAccepted() {
 +              return isAccepted;
 +      }
 +
 +      public void setAccepted(boolean isAccepted) {
 +              this.isAccepted = isAccepted;
 +      }
 +
  }