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.JButton;
import javax.swing.JRadioButton;
import javax.swing.border.EmptyBorder;
+import common.HouseInterface;
import common.OfferInterface;
-
import configuration.___IntNames;
import domain.Offer;
import domain.Owner;
*/
private static final long serialVersionUID = 1L;
private JPanel contentPane;
- private Owner owner;
private JLabel feedback;
private JComboBox<RuralHouse> comboBox;
private JComboBox<Offer> comboBox_1;
private JButton btnDelete;
+ private Vector<RuralHouse> Hlist = null;
+ private HouseInterface hm = null;
/**
* Create the frame.
*/
public DeleteOfferGUI(Owner o) {
- this.owner = o;
+ try {
+ 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();
+ }
setBounds(100, 100, 450, 300);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
- comboBox = new JComboBox<RuralHouse>(this.owner.getRuralHouses());
+ comboBox = new JComboBox<RuralHouse>(this.Hlist);
comboBox.setBounds(101, 38, 314, 20);
comboBox_1 = new JComboBox<Offer>();
lblNewLabel.setFont(new Font("Tahoma", Font.PLAIN, 27));
lblNewLabel.setBounds(23, 41, 536, 33);
contentPane.add(lblNewLabel);
- if (bookings.isEmpty())
- lblNewLabel
- .setText("There are not bookings to be confirmed or denied");
- else
- lblNewLabel.setText("List of bookings:");
JScrollPane scrollPane = new JScrollPane();
scrollPane.setBounds(new Rectangle(45, 305, 320, 116));
scrollPane.setBounds(23, 113, 536, 271);
}
((DefaultTableModel) table.getModel()).removeRow(table
.getSelectedRow());
+ bookings.remove(book);
}
}
});
-
- if (this.bookings.get(0).getOffer().isBooked()) {
- btnDenyAddition.setEnabled(false);
- btnNewButton.setEnabled(false);
+ if (bookings.isEmpty())
+ lblNewLabel
+ .setText("There are not bookings to be confirmed or denied");
+ else {
+ lblNewLabel.setText("List of bookings:");
+ if (this.bookings.get(0).getOffer().isBooked()) {
+ btnDenyAddition.setEnabled(false);
+ btnNewButton.setEnabled(false);
+ }
}
-
+
btnDenyAddition.setBounds(390, 395, 169, 25);
contentPane.add(btnDenyAddition);
}
((DefaultTableModel)table.getModel()).removeRow(table.getSelectedRow());
+
}
}
});
am.removeHouseDeletionRequests(rh);
am.saveInstance();
} catch (RemoteException e1) {
- // TODO Auto-generated catch block
e1.printStackTrace();
}
((DefaultTableModel) table.getModel()).removeRow(houses
.indexOf(rh));
+ houses.remove(rh);
}
}
try {
dbMngr = DB4oManager.getInstance();
} catch (Exception e) {
- // TODO Auto-generated catch block
e.printStackTrace();
}
}
configuration.common().objectClass(Booking.class).cascadeOnDelete(true);
configuration.common().objectClass(RuralHouse.class)
.cascadeOnDelete(true);
- configuration.common().objectClass(Account.class)
- .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());
}
}
- public Vector<Offer> getRHsOffer(String name){
+ 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);
+ 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);
db.close();
}
}
-
- public Administrator getAdminData(){
+
+ public Administrator getAdminData() {
if (c.isDatabaseLocal() == false)
openSDB();
}
}
-
public Vector<RuralHouse> getAllRuralHouses() throws RemoteException,
Exception {
}
- public Vector<RuralHouse> getRuralHouses(Owner ow, String name, String town,
- int nBed, int nKit, int nBath, int nPark, int nLiv) {
+ 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, ow, null, town, fea);
if (c.isDatabaseLocal() == false)
else
openDB();
try {
- ObjectSet<Booking> result = db.queryByExample(b);
- result.get(0).getOffer().getBookings().remove(b);
- db.store(result.get(0).getOffer());
- db.delete(result.get(0));
+ Booking book = new Booking(b.getBookNumber(), new Offer(b
+ .getOffer().getOfferNumber(), new RuralHouse(b.getOffer()
+ .getRuralHouse().getHouseName(), null, null, null, null),
+ null, null, 0), b.getClient(), b.getBookDate());
+
+ ObjectSet<Booking> result = db.queryByExample(book);
+ Offer of = result.get(0).getOffer();
+ of.getBookings().remove(result.get(0));
+ db.store(of);
db.commit();
} catch (Exception e) {
e.printStackTrace();
import java.io.Serializable;
import java.util.Date;
-public class Booking implements Serializable {
+public class Booking implements Serializable {
/**
*
private Date bookingDate;
private Client client;
private Offer offer;
-
-
- public Booking() {
+
+ public Booking(int bN, Offer offer, Client client, Date date) {
+ this.bookingNumber = bN;
+ this.offer = offer;
+ this.client = client;
+ // Booking date is assigned to actual date
+ this.bookingDate = date;
}
- public Booking(int bN , Offer offer,Client client) {
-
+ public Booking(int bN, Offer offer, Client client) {
+
this.bookingNumber = bN;
this.offer = offer;
- this.client=client;
- //Booking date is assigned to actual date
- this.bookingDate= new java.util.Date(System.currentTimeMillis());
+ this.client = client;
+ // Booking date is assigned to actual date
+ this.bookingDate = new java.util.Date(System.currentTimeMillis());
}
-
- public void imprimete(){
+
+ public void imprimete() {
System.out.println(bookingNumber);
System.out.println(bookingDate);
System.out.println(client.toString());
- System.out.println(offer);
+ System.out.println(offer);
}
public int getBookNumber() {
public float getPrice() {
return this.offer.getPrice();
}
-
+
public void setBookDate(Date bookDate) {
this.bookingDate = bookDate;
}
public Date getBookDate() {
return this.bookingDate;
}
-
+
public Client getClient() {
return client;
}
public void setClient(Client client) {
this.client = client;
}
-
+
}
\ No newline at end of file