Administrator class created delete debbuging started
authorcamjan <jcampos004@ikasle.ehu.es>
Tue, 10 Mar 2015 13:06:22 +0000 (14:06 +0100)
committercamjan <jcampos004@ikasle.ehu.es>
Tue, 10 Mar 2015 13:06:22 +0000 (14:06 +0100)
ruralHouses/src/businessLogic/HouseManager.java
ruralHouses/src/businessLogic/HouseManagerInterface.java
ruralHouses/src/dataAccess/DB4oManager.java
ruralHouses/src/domain/Account.java
ruralHouses/src/gui/DeleteHouseGUI.java
ruralHouses/src/gui/HousesRelatedOwnerGUI.java

index 4cb6254..a962603 100644 (file)
@@ -44,8 +44,8 @@ public class HouseManager implements HouseManagerInterface {
 
        
        
-       public void removeHouse(String houseName) {
-               this.dbMngr.removeHouse(houseName);
+       public void removeHouse(RuralHouse rh) {
+               this.dbMngr.removeHouse(rh);
        }
 
 
index 5e56aed..ee528cc 100644 (file)
@@ -21,7 +21,7 @@ public interface HouseManagerInterface {
        // String description, String town, int nRooms, int nKitchens,
        // int nBaths, int nLivings, int nParkings);
 
-       public void removeHouse(String houseName);
+       public void removeHouse(RuralHouse rh);
 
 
        /**
index b46eafa..8ab8d83 100644 (file)
@@ -369,15 +369,14 @@ public class DB4oManager {
                return stored;
        }
 
-       public void removeHouse(String houseName) {
+       public void removeHouse(RuralHouse rh) {
 
                if (c.isDatabaseLocal() == false)
                        openSDB();
                else
                        openDB();               
-               RuralHouse house = new RuralHouse(houseName, null, null, null, null);
                try {
-                       ObjectSet<RuralHouse> result = db.queryByExample(house);
+                       ObjectSet<RuralHouse> result = db.queryByExample(rh);
                        if (!result.isEmpty()) {
                                RuralHouse found = (RuralHouse) result.get(0);
                                db.delete(found);
index f6f6460..795f739 100644 (file)
@@ -2,17 +2,25 @@ package domain;
 
 public class Account {
 
-       
-
-       private String username="";
-       private String password="";
+       private String username = "";
+       private String password = "";
        private Owner owner;
-       
-       public Account (String usr, String pass, Owner ow){
+       private Administrator admin;
+
+       public Account(String usr, String pass, Administrator admin) {
                this.username = usr;
-               this.password= pass;
-               this.owner= ow;
-               
+               this.password = pass;
+               this.owner = null;
+               this.admin = admin;
+
+       }
+
+       public Account(String usr, String pass, Owner ow) {
+               this.username = usr;
+               this.password = pass;
+               this.owner = ow;
+               this.admin = null;
+
        }
 
        public String getUsername() {
@@ -26,7 +34,13 @@ public class Account {
        public Owner getOwner() {
                return owner;
        }
-       
 
-       
+       public Administrator getAdmin() {
+               return admin;
+       }
+
+       public void setAdmin(Administrator admin) {
+               this.admin = admin;
+       }
+
 }
index 52c73a0..776cc51 100644 (file)
@@ -4,6 +4,7 @@ import java.awt.BorderLayout;
 import java.awt.EventQueue;
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
+import java.util.Vector;
 
 import javax.swing.JFrame;
 import javax.swing.JPanel;
@@ -31,16 +32,15 @@ public class DeleteHouseGUI extends JFrame {
         * Create the frame.
         */
        public DeleteHouseGUI(Owner o) {
-               o = owner;
+               this.owner = o;
                setBounds(100, 100, 450, 300);
                contentPane = new JPanel();
                contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
                setContentPane(contentPane);
+                       
+               comboBox = new JComboBox(this.owner.getRuralHouses());
                
                
-               
-               comboBox = new JComboBox();
-               
                JRadioButton rdbtnIAmSure = new JRadioButton("I am sure");
                
                JButton btnDelete = new JButton("DELETE");
@@ -85,6 +85,6 @@ public class DeleteHouseGUI extends JFrame {
        private void actionListenerButton(ActionEvent e){
                RuralHouse toDel = (RuralHouse)comboBox.getSelectedItem();
                HouseManagerInterface hm = new HouseManager();
-               hm.removeHouse(toDel.getHouseName());
+               hm.removeHouse(toDel);
        }
 }
index 656d76f..0045177 100644 (file)
@@ -61,7 +61,6 @@ public class HousesRelatedOwnerGUI extends JFrame {
                });
                
                JButton btnDeleteHouses = new JButton("Delete Houses");
-               btnDeleteHouses.setEnabled(false);
                btnDeleteHouses.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent e) {
                                Frame a = new DeleteHouseGUI(owner);