Merge branch 'master' of https://xp-dev.com/git/RRRRHHHH_Code
authorcamjan <jcampos004@ikasle.ehu.es>
Wed, 15 Apr 2015 15:47:17 +0000 (17:47 +0200)
committercamjan <jcampos004@ikasle.ehu.es>
Wed, 15 Apr 2015 15:47:17 +0000 (17:47 +0200)
Conflicts:
ruralHouses/src/dataAccess/DB4oManager.java
ruralHouses/src/gui/ModifyHouseGUI.java

1  2 
ruralHouses/src/dataAccess/DB4oManager.java
ruralHouses/src/gui/ModifyHouseGUI.java

@@@ -4,8 -4,12 +4,15 @@@ import java.io.File
  //import java.util.Enumeration;
  //import java.util.Vector;
  import java.rmi.RemoteException;
- import java.util.*;
++
++
+ import java.util.Date;
+ import java.util.LinkedList;
+ import java.util.List;
+ import java.util.ListIterator;
+ import java.util.Vector;
 +
  import com.db4o.Db4oEmbedded;
  import com.db4o.ObjectContainer;
  import com.db4o.ObjectSet;
@@@ -124,11 -128,16 +132,17 @@@ public class DB4oManager 
                        Account jonAcc = new Account("userJon", "passJon", jon);
                        Account alfredoAcc = new Account("userAlfredo", "passAlfredo",
                                        alfredo);
++
+                       Account admin = new Account("admin","admin", true);
+                       db.store(Administrator.giveAdmin());
+                       db.store(jon);
+                       db.store(alfredo);
                        db.store(jonAcc);
                        db.store(alfredoAcc);
+                       db.store(admin);
                        db.commit();
                } finally {
-                       db.close();
+                       db.close();     
                }
        }
  
@@@ -59,142 -58,191 +59,143 @@@ public class ModifyHouseGUI extends JFr
                contentPane = new JPanel();
                contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
                setContentPane(contentPane);
 -              
 +
                JLabel lblCode = new JLabel("House Name:");
 +              lblCode.setBounds(15, 88, 64, 14);
                lblCode.setHorizontalAlignment(SwingConstants.RIGHT);
 -              
 +
                lblDistrict = new JLabel("District:");
 +              lblDistrict.setBounds(39, 119, 70, 14);
                lblDistrict.setHorizontalAlignment(SwingConstants.RIGHT);
 -              
 +
                District_f = new JTextField();
 +              District_f.setBounds(127, 116, 86, 20);
                District_f.setColumns(10);
 -              
 +
                lblDescription = new JLabel("Description:");
 +              lblDescription.setBounds(231, 88, 90, 14);
                lblDescription.setHorizontalAlignment(SwingConstants.RIGHT);
 -              
 +
                description_f = new JTextField();
 +              description_f.setBounds(241, 113, 178, 129);
                description_f.setColumns(10);
 -              
 +
                lblKitchen = new JLabel("Kitchens:");
 +              lblKitchen.setBounds(230, 316, 70, 14);
                lblKitchen.setHorizontalAlignment(SwingConstants.RIGHT);
 -              
 +
                kitchens_f = new JTextField();
 +              kitchens_f.setBounds(318, 313, 86, 20);
                kitchens_f.setColumns(10);
 -              
 +
                lblRooms = new JLabel("Rooms:");
 +              lblRooms.setBounds(39, 316, 70, 14);
                lblRooms.setHorizontalAlignment(SwingConstants.RIGHT);
 -              
 +
                rooms_f = new JTextField();
 +              rooms_f.setBounds(127, 313, 86, 20);
                rooms_f.setColumns(10);
 -              
 +
                lblLivings = new JLabel("Living rooms:");
 +              lblLivings.setBounds(237, 354, 63, 14);
                lblLivings.setHorizontalAlignment(SwingConstants.RIGHT);
 -              
 +
                lRooms_f = new JTextField();
 +              lRooms_f.setBounds(318, 351, 86, 20);
                lRooms_f.setColumns(10);
 -              
 +
                lblParkings = new JLabel("Parkings:");
 +              lblParkings.setBounds(39, 404, 70, 14);
                lblParkings.setHorizontalAlignment(SwingConstants.RIGHT);
 -              
 +
                parkings_f = new JTextField();
 +              parkings_f.setBounds(127, 401, 86, 20);
                parkings_f.setColumns(10);
 -              
 +
                lblBaths = new JLabel("Baths:");
 +              lblBaths.setBounds(39, 354, 70, 14);
                lblBaths.setHorizontalAlignment(SwingConstants.RIGHT);
 -              
 +
                baths_f = new JTextField();
 +              baths_f.setBounds(127, 351, 86, 20);
                baths_f.setColumns(10);
 -              
 +
                btnConfirm = new JButton("Confirm");
 +              btnConfirm.setBounds(145, 462, 69, 23);
                btnConfirm.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent arg0) {
 -                              
 -                              
 +
 +                              RuralHouse newRh = new RuralHouse(rh.getHouseName(), owner,
 +                                              description_f.getText(), District_f.getText(),
 +                                              new HouseFeatures(new Integer(rooms_f.getText()),
 +                                                              new Integer(kitchens_f.getText()), new Integer(
 +                                                                              baths_f.getText()), new Integer(
 +                                                                              lRooms_f.getText()), new Integer(
 +                                                                              parkings_f.getText())));
                                HouseManager hm = new HouseManager();
 -                              hm.removeHouse(rh, owner);
 -                              //TODO registernewhouse must check before if the house is created to delete it before creating it.
 -                              hm.registerNewHouse(rh.getHouseName(),
 -                                              owner,
 -                                              description_f.getText(),
 -                                              District_f.getText(),
 -                                              new Integer(rooms_f.getText()),
 -                                              new Integer(kitchens_f.getText()),
 -                                              new Integer(baths_f.getText()),
 -                                              new Integer(lRooms_f.getText()),
 -                                              new Integer(parkings_f.getText())
 -                              );
++
 +                              if (hm.registerNewHouse(newRh)) {
 +                                      feedback.setText("House properly modified");
 +                              } else
 +                                      feedback.setText("Imposible to modify the house");
 +
                        }
                });
 -              
 +
                houseBox = new JComboBox<RuralHouse>(o.getRuralHouses());
 -              
 +              if (!o.getRuralHouses().isEmpty()) {
 +                      rh = (RuralHouse) houseBox.getSelectedItem();
 +                      District_f.setText(rh.getDistrict());
 +                      description_f.setText(rh.getDescription());
 +                      kitchens_f.setText(Integer
 +                                      .toString(rh.getFeatures().getnKitchens()));
 +                      rooms_f.setText(Integer.toString(rh.getFeatures().getnRooms()));
 +                      lRooms_f.setText(Integer.toString(rh.getFeatures().getnLivings()));
 +                      parkings_f.setText(Integer
 +                                      .toString(rh.getFeatures().getnParkings()));
 +                      baths_f.setText(Integer.toString(rh.getFeatures().getnBaths()));
 +                      houseBox.setBounds(89, 85, 124, 20);
 +              }else{
 +                      feedback.setText("Not available houses");
 +              }
                houseBox.addItemListener(new ItemListener() {
 -            @Override
 -            public void itemStateChanged(ItemEvent e) {
 -                rh = (RuralHouse)houseBox.getSelectedItem();
 -                District_f.setText(rh.getDistrict());
 -                description_f.setText(rh.getDescription());
 -                kitchens_f.setText(Integer.toString(rh.getFeatures().getnKitchens()));
 -                rooms_f.setText(Integer.toString(rh.getFeatures().getnRooms()));
 -                lRooms_f.setText(Integer.toString(rh.getFeatures().getnLivings()));
 -                parkings_f.setText(Integer.toString(rh.getFeatures().getnParkings()));
 -                baths_f.setText(Integer.toString(rh.getFeatures().getnBaths()));
 -                
 -            }
 -        });
 -              
 -              GroupLayout gl_contentPane = new GroupLayout(contentPane);
 -              gl_contentPane.setHorizontalGroup(
 -                      gl_contentPane.createParallelGroup(Alignment.LEADING)
 -                              .addGroup(gl_contentPane.createSequentialGroup()
 -                                      .addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
 -                                              .addGroup(gl_contentPane.createSequentialGroup()
 -                                                      .addContainerGap()
 -                                                      .addGroup(gl_contentPane.createParallelGroup(Alignment.TRAILING)
 -                                                              .addGroup(gl_contentPane.createSequentialGroup()
 -                                                                      .addComponent(lblParkings, GroupLayout.PREFERRED_SIZE, 70, GroupLayout.PREFERRED_SIZE)
 -                                                                      .addGap(18)
 -                                                                      .addComponent(parkings_f, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
 -                                                              .addGroup(gl_contentPane.createSequentialGroup()
 -                                                                      .addComponent(lblRooms, GroupLayout.PREFERRED_SIZE, 70, GroupLayout.PREFERRED_SIZE)
 -                                                                      .addGap(18)
 -                                                                      .addComponent(rooms_f, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
 -                                                              .addGroup(gl_contentPane.createSequentialGroup()
 -                                                                      .addComponent(lblCode)
 -                                                                      .addPreferredGap(ComponentPlacement.UNRELATED)
 -                                                                      .addComponent(houseBox, GroupLayout.PREFERRED_SIZE, 124, GroupLayout.PREFERRED_SIZE))
 -                                                              .addGroup(gl_contentPane.createSequentialGroup()
 -                                                                      .addComponent(lblBaths, GroupLayout.PREFERRED_SIZE, 70, GroupLayout.PREFERRED_SIZE)
 -                                                                      .addGap(18)
 -                                                                      .addComponent(baths_f, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
 -                                                              .addGroup(gl_contentPane.createSequentialGroup()
 -                                                                      .addComponent(lblDistrict, GroupLayout.PREFERRED_SIZE, 70, GroupLayout.PREFERRED_SIZE)
 -                                                                      .addGap(18)
 -                                                                      .addComponent(District_f, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)))
 -                                                      .addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
 -                                                              .addGroup(gl_contentPane.createSequentialGroup()
 -                                                                      .addGap(17)
 -                                                                      .addGroup(gl_contentPane.createParallelGroup(Alignment.TRAILING)
 -                                                                              .addGroup(gl_contentPane.createSequentialGroup()
 -                                                                                      .addComponent(lblLivings)
 -                                                                                      .addGap(18)
 -                                                                                      .addComponent(lRooms_f, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
 -                                                                              .addGroup(gl_contentPane.createSequentialGroup()
 -                                                                                      .addComponent(lblKitchen, GroupLayout.PREFERRED_SIZE, 70, GroupLayout.PREFERRED_SIZE)
 -                                                                                      .addGap(18)
 -                                                                                      .addComponent(kitchens_f, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))))
 -                                                              .addGroup(gl_contentPane.createSequentialGroup()
 -                                                                      .addGap(18)
 -                                                                      .addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
 -                                                                              .addGroup(gl_contentPane.createSequentialGroup()
 -                                                                                      .addGap(10)
 -                                                                                      .addComponent(description_f, GroupLayout.PREFERRED_SIZE, 178, GroupLayout.PREFERRED_SIZE))
 -                                                                              .addComponent(lblDescription, GroupLayout.PREFERRED_SIZE, 90, GroupLayout.PREFERRED_SIZE)))))
 -                                              .addGroup(gl_contentPane.createSequentialGroup()
 -                                                      .addGap(140)
 -                                                      .addComponent(btnConfirm)))
 -                                      .addContainerGap())
 -              );
 -              gl_contentPane.setVerticalGroup(
 -                      gl_contentPane.createParallelGroup(Alignment.LEADING)
 -                              .addGroup(gl_contentPane.createSequentialGroup()
 -                                      .addGap(20)
 -                                      .addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
 -                                              .addGroup(gl_contentPane.createSequentialGroup()
 -                                                      .addGap(60)
 -                                                      .addGroup(gl_contentPane.createParallelGroup(Alignment.BASELINE)
 -                                                              .addComponent(lblCode)
 -                                                              .addComponent(houseBox, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
 -                                                      .addPreferredGap(ComponentPlacement.UNRELATED)
 -                                                      .addGroup(gl_contentPane.createParallelGroup(Alignment.BASELINE)
 -                                                              .addComponent(District_f, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
 -                                                              .addComponent(lblDistrict)))
 -                                              .addGroup(gl_contentPane.createSequentialGroup()
 -                                                      .addGap(63)
 -                                                      .addComponent(lblDescription)
 -                                                      .addPreferredGap(ComponentPlacement.UNRELATED)
 -                                                      .addComponent(description_f, GroupLayout.PREFERRED_SIZE, 129, GroupLayout.PREFERRED_SIZE)))
 -                                      .addGap(71)
 -                                      .addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
 -                                              .addGroup(gl_contentPane.createSequentialGroup()
 -                                                      .addGap(3)
 -                                                      .addComponent(lblRooms))
 -                                              .addComponent(rooms_f, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
 -                                              .addGroup(gl_contentPane.createSequentialGroup()
 -                                                      .addGap(3)
 -                                                      .addComponent(lblKitchen))
 -                                              .addComponent(kitchens_f, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
 -                                      .addGap(18)
 -                                      .addGroup(gl_contentPane.createParallelGroup(Alignment.TRAILING)
 -                                              .addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
 -                                                      .addGroup(gl_contentPane.createSequentialGroup()
 -                                                              .addGap(3)
 -                                                              .addComponent(lblBaths))
 -                                                      .addGroup(gl_contentPane.createParallelGroup(Alignment.BASELINE)
 -                                                              .addComponent(baths_f, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
 -                                                              .addComponent(lblLivings)))
 -                                              .addComponent(lRooms_f, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
 -                                      .addGap(30)
 -                                      .addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
 -                                              .addGroup(gl_contentPane.createSequentialGroup()
 -                                                      .addGap(3)
 -                                                      .addComponent(lblParkings))
 -                                              .addComponent(parkings_f, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
 -                                      .addGap(41)
 -                                      .addComponent(btnConfirm)
 -                                      .addGap(54))
 -              );
 -              contentPane.setLayout(gl_contentPane);
 +                      @Override
 +                      public void itemStateChanged(ItemEvent e) {
 +                              rh = (RuralHouse) houseBox.getSelectedItem();
 +                              District_f.setText(rh.getDistrict());
 +                              description_f.setText(rh.getDescription());
 +                              kitchens_f.setText(Integer.toString(rh.getFeatures()
 +                                              .getnKitchens()));
 +                              rooms_f.setText(Integer.toString(rh.getFeatures().getnRooms()));
 +                              lRooms_f.setText(Integer.toString(rh.getFeatures()
 +                                              .getnLivings()));
 +                              parkings_f.setText(Integer.toString(rh.getFeatures()
 +                                              .getnParkings()));
 +                              baths_f.setText(Integer.toString(rh.getFeatures().getnBaths()));
 +
 +                      }
 +              });
 +              contentPane.setLayout(null);
 +              contentPane.add(lblParkings);
 +              contentPane.add(parkings_f);
 +              contentPane.add(lblRooms);
 +              contentPane.add(rooms_f);
 +              contentPane.add(lblCode);
 +              contentPane.add(houseBox);
 +              contentPane.add(lblBaths);
 +              contentPane.add(baths_f);
 +              contentPane.add(lblDistrict);
 +              contentPane.add(District_f);
 +              contentPane.add(lblLivings);
 +              contentPane.add(lRooms_f);
 +              contentPane.add(lblKitchen);
 +              contentPane.add(kitchens_f);
 +              contentPane.add(description_f);
 +              contentPane.add(lblDescription);
 +              contentPane.add(btnConfirm);
 +
 +              feedback = new JLabel("");
 +              feedback.setBounds(189, 510, 195, 23);
 +              contentPane.add(feedback);
        }
  }