public static BookingManager getInstance() {
ObjectContainer db=DB4oManager.getContainer();
BookingManager b = new BookingManager();
- ObjectSet result = db.queryByExample(b);
+ ObjectSet<BookingManager> result = db.queryByExample(b);
if (!result.hasNext()){
theBookingManager = new BookingManager();
db.store(theBookingManager);
import java.util.Vector;
import dataAccess.DB4oManager;
-import domain.HouseFeatures;
import domain.Owner;
import domain.RuralHouse;
import dataAccess.DB4oManager;
import domain.Account;
-import domain.Owner;
public class LoginManager implements LoginManagerInterface {
package businessLogic;
import domain.Account;
-import domain.Owner;
public interface LoginManagerInterface {
import java.rmi.RemoteException;
import java.sql.Date;
-import com.db4o.ObjectContainer;
-import com.db4o.ObjectSet;
-
import dataAccess.DB4oManager;
import domain.Offer;
import domain.RuralHouse;
private int offerNumber = 0;
dataAccess.DB4oManager dbMngr;
- private static OfferManager theOfferManager;
public OfferManager() {
try {
}
}
- public static int getNumber() {
- ObjectContainer db=DB4oManager.getContainer();
- OfferManager o=getInstance();
- o.offerNumber++;
- db.store(o);
- db.commit();
- return o.offerNumber;
- }
-
- /**
- * This method returns the instance of the OfferManager class
- *
- * @return the offer manager
- */
- public static OfferManager getInstance() {
- ObjectContainer db=DB4oManager.getContainer();
- OfferManager b = new OfferManager();
- ObjectSet result = db.queryByExample(b);
- if (!result.hasNext()){
- theOfferManager = new OfferManager();
- db.store(theOfferManager);
- db.commit();
- } else theOfferManager=(OfferManager)result.next();
- return theOfferManager;
- }
/**
* This method creates an offer with a house number, first day, last day and price
boolean b = dbMngr.existsOverlappingOffer(ruralHouse,firstDay,lastDay); // The ruralHouse object in the client may not be updated
if (!b) {
- ruralHouse.createOffer(offerNumber, firstDay, lastDay, price);
- return dbMngr.createOffer(ruralHouse,firstDay,lastDay,price);
+ dbMngr.createOffer(ruralHouse,firstDay,lastDay,price);
+ return ruralHouse.createOffer(offerNumber, firstDay, lastDay, price);
}
return null;
}
//import java.util.Enumeration;
//import java.util.Vector;
import java.rmi.RemoteException;
-
-
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;
} else // c.getDataBaseOpenMode().equals("open")
{
- ObjectSet res = db.queryByExample(DB4oManagerAux.class);
- ListIterator listIter = res.listIterator();
+ ObjectSet<DB4oManagerAux> res = db.queryByExample(DB4oManagerAux.class);
+ ListIterator<DB4oManagerAux> listIter = res.listIterator();
if (listIter.hasNext())
theDB4oManagerAux = (DB4oManagerAux) res.next();
}
try {
Owner proto = new Owner(null, null);
- ObjectSet result = db.queryByExample(proto);
- Vector<Owner> owners = new Vector<Owner>();
+ ObjectSet<Owner> result = db.queryByExample(proto);
while (result.hasNext()) {
Owner o = (Owner) result.next();
System.out.println("Deleted owner: " + o.toString());
}
+ @SuppressWarnings("static-access")
public LinkedList<RuralHouse>[] getAdminData(){
if (c.isDatabaseLocal() == false)
openSDB();
else
openDB();
+ @SuppressWarnings("unchecked")
LinkedList<RuralHouse>[] ret = new LinkedList[2];
try {
List<Administrator> admL = db.query(new Predicate<Administrator>(){
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+
public boolean match(Administrator admin){
return true;
}
}
+ @SuppressWarnings("static-access")
public void storeAdmin() {
if (c.isDatabaseLocal() == false)
openSDB();
try {
List<Administrator> admL = db.query(new Predicate<Administrator>(){
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+
public boolean match(Administrator admin){
return true;
}
RuralHouse proto = new RuralHouse(ruralHouse.getHouseName(), null,
ruralHouse.getDescription(), ruralHouse.getDistrict(), null);
- ObjectSet result = db.queryByExample(proto);
+ ObjectSet<RuralHouse> result = db.queryByExample(proto);
RuralHouse rh = (RuralHouse) result.next();
Offer offer;
try {
RuralHouse proto = new RuralHouse(null, null, null, null, null);
- ObjectSet result = db.queryByExample(proto);
+ ObjectSet<RuralHouse> result = db.queryByExample(proto);
Vector<RuralHouse> ruralHouses = new Vector<RuralHouse>();
while (result.hasNext())
ruralHouses.add((RuralHouse) result.next());
public class DB4oManagerServer extends JDialog {
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
private final JPanel contentPanel = new JPanel();
JTextArea textArea;
ObjectServer server;
import com.toedter.calendar.JCalendar;
-import domain.Offer;
import domain.RuralHouse;
import exceptions.BadDates;
import exceptions.OverlappingOfferExists;
private static final long serialVersionUID = 1L;
- private JComboBox jComboBox1;
+ private JComboBox<RuralHouse> jComboBox1;
private JLabel jLabel1 = new JLabel();
private JLabel jLabel2 = new JLabel();
private JTextField jTextField1 = new JTextField();
this.setTitle("Set availability");
- jComboBox1 = new JComboBox(v);
+ jComboBox1 = new JComboBox<RuralHouse>(v);
jComboBox1.setBounds(new Rectangle(115, 30, 115, 20));
jLabel1.setText("List of houses:");
jLabel1.setBounds(new Rectangle(25, 30, 95, 20));
import java.awt.event.ItemListener;
import java.util.Vector;
-import javax.swing.GroupLayout;
-import javax.swing.GroupLayout.Alignment;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import domain.Offer;
import domain.Owner;
import domain.RuralHouse;
-import javax.swing.LayoutStyle.ComponentPlacement;
-import javax.swing.JTextField;
public class DeleteOfferGUI extends JFrame {
}
JRadioButton rdbtnIAmSure = new JRadioButton("I am sure");
- rdbtnIAmSure.setBounds(101, 134, 71, 23);
+ rdbtnIAmSure.setBounds(101, 134, 108, 23);
btnDelete = new JButton("DELETE");
- btnDelete.setBounds(92, 226, 69, 23);
+ btnDelete.setBounds(92, 226, 117, 23);
btnDelete.setEnabled(false);
comboBox.addItemListener(new ItemListener() {
contentPane.add(comboBox_1);
feedback = new JLabel("");
- feedback.setBounds(140, 178, 155, 23);
+ feedback.setBounds(140, 178, 202, 23);
contentPane.add(feedback);
btnDelete.addActionListener(new ActionListener() {
import java.util.Date;
import java.util.Enumeration;
import java.util.Vector;
-
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
private RuralHouse rh;
private JTextField telIn;
private int row;
+ private JLabel labelPhone;
/**
* Create the frame.
telIn.setBounds(99, 505, 129, 20);
contentPane.add(telIn);
telIn.setColumns(10);
+
+ labelPhone = new JLabel("");
+ labelPhone.setBounds(238, 252, 178, 14);
+ contentPane.add(labelPhone);
table.addMouseListener( new MouseAdapter(){
@Override
public void mouseClicked(MouseEvent arg0) {
}
table.setDefaultRenderer(Object.class, new DefaultTableCellRenderer() {
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+
@Override
public Component getTableCellRendererComponent(JTable table,
Object value, boolean isSelected, boolean hasFocus,
private void jButton_ActionPerformed(ActionEvent arg0) {
BookingManager bookingM = new BookingManager();
//RegExp to see if telephone number is correct??TODO
- Booking book = null;
- try {
- if (table.getRowCount()!=0)
- book = bookingM.createBooking(rh, rh.offers.get(row).getFirstDay(), rh.offers.get(row).getLastDay(), telIn.getText());
- } catch (Exception e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- if (book != null) {
- BookRuralHouseConfirmationWindow confirmWindow = new BookRuralHouseConfirmationWindow(
- book);
- confirmWindow.setVisible(true);
+ if (telIn.getText().matches("[976]\\d{2}[.\\- ]?\\d{3}[.\\- ]?\\d{3}")) {
+ Booking book = null;
+ try {
+ if (table.getRowCount()!=0)
+ book = bookingM.createBooking(rh, rh.offers.get(row).getFirstDay(), rh.offers.get(row).getLastDay(), telIn.getText());
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ if (book != null) {
+ BookRuralHouseConfirmationWindow confirmWindow = new BookRuralHouseConfirmationWindow(
+ book);
+ confirmWindow.setVisible(true);
+ }
+ } else {
+ labelPhone.setText("Phone format is wrong");
}
}
}
import businessLogic.LoginManager;
import businessLogic.LoginManagerInterface;
import domain.Account;
-import domain.Owner;
-
-import javax.swing.JRadioButton;
-import javax.swing.ButtonGroup;
public class LoginGUI extends JFrame {
private JPasswordField passwordField;
private LoginManagerInterface loginManager = new LoginManager();
private JLabel loginFeedback;
- private final ButtonGroup buttonGroup = new ButtonGroup();
public LoginGUI() {
super();
initialize();
private void jButton_ActionPerformed(ActionEvent e){
Account acc = loginManager.checkCredentials(usernameField.getText(),new String(passwordField.getPassword()));
- if (acc.getAdmin()) {
+ if (acc == null) loginFeedback.setText("Incorrect username or password");
+ else if( acc.getAdmin()) {
this.setVisible(false);
Frame a = new AdminMenuGUI();
a.setVisible(true);
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
-
import javax.swing.DefaultComboBoxModel;
import javax.swing.JButton;
import javax.swing.JComboBox;
private JButton btnConfirm;
private JComboBox<RuralHouse> houseBox;
private RuralHouse rh;
+ private JComboBox<String> comboBox;
/**
* Create the frame.
*/
- public ModifyHouseGUI(Owner o) {
+ public ModifyHouseGUI(final Owner o) {
this.distric=Districs.longNames();
- JComboBox<String> comboBox = new JComboBox<String>(new DefaultComboBoxModel<String>(
+ comboBox = new JComboBox<String>(new DefaultComboBoxModel<String>(
this.distric));
this.getContentPane().setLayout(null);
owner = o;
import domain.Offer;
import domain.RuralHouse;
import exceptions.BadDates;
-import exceptions.OverlappingOfferExists;
public class ModifyOfferGUI extends JFrame {
public class QueryAvailabilityGUI2 extends JFrame {
private static final long serialVersionUID = 1L;
- private JComboBox jComboBox1;
+ private JComboBox<String> jComboBox1;
private JLabel jLabel2 = new JLabel();
private JTextField jTextField1 = new JTextField();
private JLabel jLabel3 = new JLabel();
this.setSize(new Dimension(550, 500));
this.setTitle("Query Availability");
- jComboBox1 = new JComboBox(new DefaultComboBoxModel(
+ jComboBox1 = new JComboBox<String>(new DefaultComboBoxModel<String>(
Districs.longNames()));
jComboBox1.setEnabled(false);
jComboBox1.setBounds(new Rectangle(115, 30, 115, 20));
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
-import javax.swing.GroupLayout;
-import javax.swing.GroupLayout.Alignment;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
+import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.border.EmptyBorder;
import businessLogic.AdminManager;
import domain.Owner;
import domain.RuralHouse;
-import javax.swing.JLabel;
-import javax.swing.LayoutStyle.ComponentPlacement;
public class RequestDeleteHouseGUI extends JFrame {
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
private JPanel contentPane;
private Owner owner;
private JComboBox<RuralHouse> comboBox;
JRadioButton rdbtnIAmSure = new JRadioButton("I am sure");
- rdbtnIAmSure.setBounds(90, 154, 71, 23);
+ rdbtnIAmSure.setBounds(90, 154, 90, 23);
btnDelete = new JButton("REQUEST");
btnDelete.setBounds(90, 213, 90, 23);
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
+import javax.swing.DefaultComboBoxModel;
import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
-import javax.swing.DefaultComboBoxModel;
import javax.swing.JButton;
+import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import domain.Owner;
import domain.RuralHouse;
-import javax.swing.JComboBox;
-
public class RequestNewHouseGUI extends JFrame {
/**
private JTextField baths_f;
private JButton btnRegister;
private AdminManager am;
- private JComboBox comboBox;
+ private JComboBox<String> comboBox;
/**
* Create the frame.
*/
public RequestNewHouseGUI(Owner o) {
- JComboBox<String> comboBox = new JComboBox<String>(new DefaultComboBoxModel<String>(
+ comboBox = new JComboBox<String>(new DefaultComboBoxModel<String>(
Districs.longNames()));
am = new AdminManager();
this.setTitle("New House");
import javax.swing.UIManager;
import configuration.ConfigXML;
-import domain.Administrator;
+@SuppressWarnings("deprecation")
public class StartWindow extends JFrame {
private static final long serialVersionUID = 1L;
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
c=configuration.ConfigXML.getInstance();
- if (c.isBusinessLogicLocal()){
- //facadeInterface=new FacadeImplementation();
- }
- else {
-
- final String businessLogicNode = c.getBusinessLogicNode();
- // Remote service name
- String serviceName = "/"+c.getServiceRMI();
- // RMI server port number
- int portNumber = Integer.parseInt(c.getPortRMI());
- // RMI server host IP IP
- /*facadeInterface = (ApplicationFacadeInterface) Naming.lookup("rmi://"
- + businessLogicNode + ":" + portNumber + serviceName);*/
- }
-
- }/* catch (java.rmi.ConnectException e) {
- a.lblNewLabel.setText("No business logic: Run BusinessLogicServer first!!");
- a.lblNewLabel.setForeground(Color.RED);
- System.out.println("Error in StartWindow: "+e.toString());
- } catch (java.rmi.NotBoundException e) {
- a.lblNewLabel.setText("No business logic: Maybe problems running BusinessLogicServer");
- a.lblNewLabel.setForeground(Color.RED);
- System.out.println("Error in StartWindow: "+e.toString());
- } */catch (com.db4o.ext.DatabaseFileLockedException e) {
+
+ }catch (com.db4o.ext.DatabaseFileLockedException e) {
a.lblNewLabel.setText("Database locked: Do not run BusinessLogicServer or BusinessLogicServer!!");
a.lblNewLabel.setForeground(Color.RED);
System.out.println("Error in StartWindow: "+e.toString());
a.lblNewLabel.setForeground(Color.RED);
System.out.println("Error in StartWindow: "+e.toString());
}
- //a.pack();
public class listOfAdditionRequestsGUI extends JFrame {
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
private JPanel contentPane;
private JTable table;
private DefaultTableModel tableModel;
public class listOfHousesGUI extends JFrame {
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
private JPanel contentPane;
private JTable table;
private DefaultTableModel tableModel;
public class listOfRemovalRequestsGUI extends JFrame {
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
private JPanel contentPane;
private JTable table;
private DefaultTableModel tableModel;