Merge branch 'master' of ssh://xp-dev.com/RRRRHHHH_Code
authorpinene <epinzolas001@ikasle.ehu.eus>
Tue, 19 May 2015 19:44:47 +0000 (21:44 +0200)
committerpinene <epinzolas001@ikasle.ehu.eus>
Tue, 19 May 2015 19:44:47 +0000 (21:44 +0200)
Conflicts:
ruralHouses client/src/gui/ModifyOfferGUI.java
ruralHouses/src/dataAccess/DB4oManager.java

12 files changed:
ruralHouses client/src/domain/Administrator.java
ruralHouses client/src/domain/Booking.java
ruralHouses client/src/gui/ModifyOfferGUI.java
ruralHouses client/src/gui/OwnerRegistrationGUI.java
ruralHouses client/src/gui/StartWindow.java
ruralHouses client/src/gui/listOfBookingRequestsGUI.java
ruralHouses client/src/gui/listOfOwnerAddittionRequests.java
ruralHouses/src/businessLogic/LoginManager.java
ruralHouses/src/dataAccess/DB4oManager.java
ruralHouses/src/domain/Account.java
ruralHouses/src/domain/Booking.java
ruralHouses/src/launcher/RMILauncher.java

index d6e9d79..845d089 100644 (file)
@@ -12,7 +12,6 @@ public class Administrator implements Serializable {
         */
        private static final long serialVersionUID = 1L;
 
-       private static Administrator admin = null;
        private static LinkedList<RuralHouse> addRequest;
        private static LinkedList<RuralHouse> removeRequest;
        private static LinkedList<Account> newOwnerRequest;
index 0f72a6c..13bc007 100644 (file)
@@ -10,7 +10,6 @@ public class Booking implements Serializable  {
         */
        private static final long serialVersionUID = 1L;
        private int bookingNumber;
-       private boolean isPaid;
        private Date bookingDate;
        private Client client;
        private Offer offer;
@@ -26,12 +25,10 @@ public class Booking implements Serializable  {
                this.client=client;
                //Booking date is assigned to actual date
                this.bookingDate= new java.util.Date(System.currentTimeMillis());
-               this.isPaid=false;
        }
        
        public void imprimete(){
                System.out.println(bookingNumber);
-               System.out.println(isPaid);
                System.out.println(bookingDate);
                System.out.println(client.toString());
                System.out.println(offer);      
@@ -60,20 +57,6 @@ public class Booking implements Serializable  {
        public Date getBookDate() {
                return this.bookingDate;
        }
-       
-       public void paid() {
-               this.isPaid = true;
-       }
-
-       public void notPaid() {
-               this.isPaid=false;
-       }
-
-       public boolean isPaid() {
-               return isPaid;
-       }
-       
-
 
        public Client getClient() {
                return client;
index 82efb8d..9259130 100644 (file)
@@ -75,6 +75,7 @@ public class ModifyOfferGUI extends JFrame {
                this.setSize(new Dimension(513, 433));
                this.setTitle("Set availability");
 
+<<<<<<< HEAD
 
                try {
                        om = (OfferInterface) Naming
@@ -90,6 +91,8 @@ public class ModifyOfferGUI extends JFrame {
                } catch (RemoteException e1) {
                        e1.printStackTrace();
                }
+=======
+>>>>>>> 25898b619dd708c9f15a44200b545cac11404b73
                
                jComboBox1 = new JComboBox<RuralHouse>(Hlist);
 
index e0e5ff6..5a4ffe9 100644 (file)
@@ -20,6 +20,10 @@ import domain.Owner;
 
 public class OwnerRegistrationGUI extends JFrame {
 
+       /**
+        * 
+        */
+       private static final long serialVersionUID = 1L;
        private JPanel panel;
        private JTextField nameField;
        private JTextField userNameField;
index 5325d56..e938084 100644 (file)
@@ -30,8 +30,6 @@ public class StartWindow extends JFrame {
        private JButton boton2 = null;
        private JButton boton3 = null;
        private static configuration.ConfigXML c;
-
-       // public static ApplicationFacadeInterface facadeInterface;
        private JLabel lblNewLabel;
 
        public static void main(String[] args) {
index 1df8f2a..982d7f2 100644 (file)
@@ -81,7 +81,7 @@ public class listOfBookingRequestsGUI extends JFrame {
                };
                scrollPane.setViewportView(table);
                tableModel = new DefaultTableModel(null, new String[] {
-                               "Booking Number", "Is paid", "Booking Date","Name","E-mail", "Telephone" });
+                               "Booking Number", "Booking Date","Name","E-mail", "Telephone" });
 
                // Maybe there is a better way to avoid interaction.
                // table.setEnabled(false);
@@ -123,21 +123,12 @@ public class listOfBookingRequestsGUI extends JFrame {
                btnDenyAddition.setBounds(390, 395, 169, 25);
                contentPane.add(btnDenyAddition);
                
-               JButton btnSetAsPaid = new JButton("Set as paid");
-               btnSetAsPaid.setBounds(239, 395, 89, 23);
-               btnSetAsPaid.addActionListener(new ActionListener() {
-                       public void actionPerformed(ActionEvent arg0) {
-                               
-                       }
-               });
-               contentPane.add(btnSetAsPaid);
                Enumeration<Booking> en = this.bookings.elements();
                Booking book;
                while (en.hasMoreElements()) {
                        book = en.nextElement();
                        Vector<Object> row = new Vector<Object>();
                        row.add(book.getBookNumber());
-                       row.add(book.isPaid());
                        row.add(book.getBookDate());
                        row.add(book.getClient().getName());
                        row.add(book.getClient().getMailAccount());
index 1d78a53..01aaf8f 100644 (file)
@@ -94,8 +94,6 @@ public class listOfOwnerAddittionRequests extends JFrame {
                tableModel = new DefaultTableModel(null, new String[] {
                                "Name", "E-mail", "Bank Account" });
                
-               //Maybe there is a better way to avoid interaction.
-               //table.setEnabled(false);
                table.setModel(tableModel);
                
                JButton btnNewButton = new JButton("Confirm Addition");
@@ -117,7 +115,6 @@ public class listOfOwnerAddittionRequests extends JFrame {
                                                am.removeOwnerAdditionRequests(table.getSelectedRow());
                                                am.saveInstance();
                                        } catch (RemoteException e1) {
-                                               // TODO Auto-generated catch block
                                                e1.printStackTrace();
                                        }
                        
@@ -136,12 +133,10 @@ public class listOfOwnerAddittionRequests extends JFrame {
                                                am.removeOwnerAdditionRequests(table.getSelectedRow());
                                                am.saveInstance();
                                        } catch (RemoteException e) {
-                                               // TODO Auto-generated catch block
                                                e.printStackTrace();
                                        }
                                        
                                        ((DefaultTableModel)table.getModel()).removeRow(table.getSelectedRow());
-                                       accounts.remove(table.getSelectedRow());
                                }
                        }
                });
index 1f766a3..e0f0439 100644 (file)
@@ -31,7 +31,7 @@ public class LoginManager extends UnicastRemoteObject implements LoginInterface
 
        @Override
        public Account checkCredentials(String usr, String pwd) {
-               Account ac = new Account(usr);
+               Account ac = new Account(SecurityManager.getInstance().calculateHash(usr));
                try {
                        Vector<Account> account = dbMngr.getAccount(ac);
                        if (SecurityManager.getInstance().isExpectedPassword(pwd.toCharArray(), account
index 0fb0c74..d8a59f2 100644 (file)
@@ -135,7 +135,6 @@ public class DB4oManager {
                        Account alfredoAcc = new Account("userAlfredo", "passAlfredo",
                                        alfredo);
 
-
                        Account admin = new Account("admin", "admin", true);
                        db.store(Administrator.getInstance());
                        db.store(jonAcc);
@@ -237,6 +236,7 @@ public class DB4oManager {
        }
        
        public Administrator getAdminData(){
+
                if (c.isDatabaseLocal() == false)
                        openSDB();
                else
@@ -244,8 +244,7 @@ public class DB4oManager {
 
                try {
 
-                       
-                       List<Administrator> admL = db.query(new Predicate<Administrator>(){
+                       List<Administrator> admL = db.query(new Predicate<Administrator>() {
                                private static final long serialVersionUID = 1L;
 
                                public boolean match(Administrator admin) {
@@ -253,11 +252,8 @@ public class DB4oManager {
                                }
                        });
 
-                       
-                       
                        return admL.get(0);
-               }
-               finally {
+               } finally {
                        db.close();
 
                }
@@ -315,7 +311,7 @@ public class DB4oManager {
                else
                        openDB();
 
-               Vector<Booking> book = new Vector<Booking>() ;
+               Vector<Booking> book = new Vector<Booking>();
 
                try {
 
@@ -334,11 +330,11 @@ public class DB4oManager {
                                offer.createBooking(theDB4oManagerAux.bookingNumber++, cl);
                                db.store(theDB4oManagerAux); // To store the new value for
                                                                                                // bookingNumber
-                               
+
                                db.store(offer);
                                db.commit();
                                book = offer.getBookings();
-                               
+
                        }
 
                } catch (com.db4o.ext.ObjectNotStorableException e) {
@@ -541,27 +537,50 @@ public class DB4oManager {
                        openDB();
 
                try {
-                       // TODO realize if there is another account with same username.
-                       // Quite difficult with the f***ing salt
-                       db.store(acc);
-                       db.commit();
+                       ObjectSet<Account> result = db.queryByExample(new Account(acc
+                                       .getUsername()));
+                       if (result.isEmpty()) {
+                               db.store(acc);
+                               db.commit();
+                               return true;
+                       }
                } catch (Exception exc) {
                        exc.printStackTrace();
                } finally {
                        db.close();
                }
-               return true;
+               return false;
        }
 
        // TODO remove account
 
        public boolean removeAccount(Account acc) {
+               if (c.isDatabaseLocal() == false)
+                       openSDB();
+               else
+                       openDB();
+
+               try {
+                       ObjectSet<Account> result = db.queryByExample(new Account(acc
+                                       .getUsername()));
+                       if (!result.isEmpty()) {
+                               db.delete(result.get(0));
+                               ;
+                               db.commit();
+                               return true;
+                       }
+               } catch (Exception exc) {
+                       exc.printStackTrace();
+               } finally {
+                       db.close();
+               }
                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());
+
+       // 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());
                if (c.isDatabaseLocal() == false)
                        openSDB();
                else
@@ -572,29 +591,30 @@ public class DB4oManager {
                        this.deleteOffer(result.get(0));
                        db.store(of);
                        db.close();
-                       
+
                } catch (Exception e) {
-                       e.printStackTrace();;
-               }               
+                       e.printStackTrace();
+                       ;
+               }
        }
-       
-       public void removeBooking(Booking b){
+
+       public void removeBooking(Booking b) {
                if (c.isDatabaseLocal() == false)
                        openSDB();
                else
                        openDB();
                try {
                        ObjectSet<Booking> result = db.queryByExample(b);
-                       ObjectSet<Client> result2= db.queryByExample(b.getClient());
+                       ObjectSet<Client> result2 = db.queryByExample(b.getClient());
                        db.delete(result.get(0));
                        db.delete(result2.get(0));
                        db.commit();
                } catch (Exception e) {
-                       e.printStackTrace();;
-               }finally{
+                       e.printStackTrace();
+                       ;
+               } finally {
                        db.close();
                }
 
-               
        }
 }
index ce6bd9e..ff19267 100644 (file)
@@ -22,8 +22,8 @@ public class Account implements Serializable {
        private boolean admin = false;
 
        
-       public Account(String usr){
-               this.username = SecurityManager.getInstance().calculateHash(usr);
+       public Account(byte[] usr){
+               this.username = usr;
                this.salt =null;
                this.password = null;
                this.owner = null;
@@ -48,6 +48,7 @@ public class Account implements Serializable {
 
        }
 
+       
        public byte[] getUsername() {
                return username;
        }
@@ -87,8 +88,6 @@ public class Account implements Serializable {
                if (getClass() != obj.getClass())
                        return false;
                Account other = (Account) obj;
-               if (!Arrays.equals(password, other.password))
-                       return false;
                if (!Arrays.equals(username, other.username))
                        return false;
                return true;
index 0f72a6c..cdde621 100644 (file)
@@ -10,7 +10,6 @@ public class Booking implements Serializable  {
         */
        private static final long serialVersionUID = 1L;
        private int bookingNumber;
-       private boolean isPaid;
        private Date bookingDate;
        private Client client;
        private Offer offer;
@@ -26,12 +25,10 @@ public class Booking implements Serializable  {
                this.client=client;
                //Booking date is assigned to actual date
                this.bookingDate= new java.util.Date(System.currentTimeMillis());
-               this.isPaid=false;
        }
        
        public void imprimete(){
                System.out.println(bookingNumber);
-               System.out.println(isPaid);
                System.out.println(bookingDate);
                System.out.println(client.toString());
                System.out.println(offer);      
@@ -61,20 +58,6 @@ public class Booking implements Serializable  {
                return this.bookingDate;
        }
        
-       public void paid() {
-               this.isPaid = true;
-       }
-
-       public void notPaid() {
-               this.isPaid=false;
-       }
-
-       public boolean isPaid() {
-               return isPaid;
-       }
-       
-
-
        public Client getClient() {
                return client;
        }
index 167f1e0..008e371 100644 (file)
@@ -12,6 +12,7 @@ import businessLogic.LoginManager;
 import businessLogic.OfferManager;
 import businessLogic.OwnerManager;
 
+@SuppressWarnings("deprecation")
 public class RMILauncher {
 
        public static void main(String[] args) {