import java.io.Serializable;
import java.util.LinkedList;
-import configuration.ConfigXML;
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;
- static ConfigXML c;
private Administrator() {
addRequest = new LinkedList<RuralHouse>();
import javax.swing.SwingConstants;
import javax.swing.UIManager;
-import configuration.ConfigXML;
@SuppressWarnings("deprecation")
public class StartWindow extends JFrame {
private JPanel jContentPane = null;
private JButton boton2 = null;
private JButton boton3 = null;
- private static configuration.ConfigXML c;
private JLabel lblNewLabel;
public static void main(String[] args) {
try {
- c = ConfigXML.getInstance();
-
- System.setProperty("java.security.policy", c.getJavaPolicyPath());
+ System.setProperty("java.security.policy", "java.policy");
System.setSecurityManager(new RMISecurityManager());
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
- c = configuration.ConfigXML.getInstance();
-
} catch (com.db4o.ext.DatabaseFileLockedException e) {
a.lblNewLabel
.setText("Database locked: Do not run BusinessLogicServer or BusinessLogicServer!!");
import javax.swing.table.DefaultTableModel;
import common.BookingInterface;
-import common.HouseInterface;
-import common.OfferInterface;
+
import configuration.___IntNames;
import domain.Booking;
import domain.Offer;
<portRMI>1099</portRMI>
<serviceRMI>RuralHouses</serviceRMI>
</businessLogic>
- <database local="true">
+ <database local="false">
<databaseNode>localhost</databaseNode>
<db4oFilename>db/casas.db4o</db4oFilename>
<dataBaseOpenMode>initialize</dataBaseOpenMode>
import javax.mail.MessagingException;
import common.AccountInterface;
+
import dataAccess.DB4oManager;
import domain.Account;
import domain.Administrator;
import javax.mail.MessagingException;
-import com.db4o.ObjectContainer;
-import com.db4o.ObjectSet;
-
import common.BookingInterface;
+
import dataAccess.DB4oManager;
import domain.Booking;
import domain.Client;
configurationCS.common().activationDepth(c.getActivationDepth());
configurationCS.common().updateDepth(c.getUpdateDepth());
configurationCS.common().objectClass(Owner.class).cascadeOnDelete(true);
+ configurationCS.common().objectClass(Booking.class).cascadeOnDelete(true);
+ configurationCS.common().objectClass(RuralHouse.class)
+ .cascadeOnDelete(true);
+ configurationCS.common().objectClass(Account.class).cascadeOnDelete(true);
+ configurationCS.common().objectClass(Offer.class).cascadeOnDelete(true);
+ configurationCS.common().objectClass(Owner.class).cascadeOnUpdate(true);
+ configurationCS.common().objectClass(Booking.class).cascadeOnUpdate(true);
+ configurationCS.common().objectClass(RuralHouse.class)
+ .cascadeOnUpdate(true);
+ configurationCS.common().objectClass(Account.class).cascadeOnUpdate(true);
+ configurationCS.common().objectClass(Offer.class).cascadeOnUpdate(true);
+ configurationCS.common().objectClass(Account.class).cascadeOnUpdate(true);
db = Db4oClientServer.openClient(configurationCS, c.getDatabaseNode(),
c.getDatabasePort(), c.getUser(), c.getPassword());
openDB();
try {
- ObjectSet<Account> result = db.queryByExample(new Account(null,null,own));
+ ObjectSet<Account> result = db.queryByExample(new Account(own));
if (!result.isEmpty()) {
db.delete(result.get(0));
db.commit();
import java.io.Serializable;
import java.util.Arrays;
+
import businessLogic.SecurityManager;
private byte[] username;
private byte[] password;
private byte[] salt;
-
-
private Owner owner;
private boolean admin = false;
+
public Account(byte[] usr){
this.username = usr;
this.salt =null;
this.password = null;
this.owner = null;
-
}
public Account(String usr, String pass, boolean isAdmin) {
this.username = SecurityManager.getInstance().calculateHash(usr);
this.password = SecurityManager.getInstance().calculateSaltedHash(pass.toCharArray(), this.salt);
this.owner = null;
this.admin = isAdmin;
-
+ }
+
+ public Account(Owner own){
+ this.username = null;
+ this.salt =null;
+ this.password = null;
+ this.owner = own;
}
public Account(String usr, String pass, Owner ow) {
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="lib" path="lib/additionalLibs/jcalendar.jar"/>
+ <classpathentry kind="lib" path="lib/db4o/lib/db4o-8.0.249.16098-all-java5.jar"/>
+ <classpathentry kind="lib" path="lib/mail/javax.mail.jar"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
--- /dev/null
+/bin
+/lib
+!lib/mail/
+/db
+/src/*/*.class
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>ruralHousesDB</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
<?xml version="1.0" encoding="UTF-8"?>
<config>
- <businessLogic local="true">
- <businessLogicNode>localhost</businessLogicNode>
- <portRMI>1099</portRMI>
- <serviceRMI>RuralHouses</serviceRMI>
- </businessLogic>
+<businessLogic local="true">
+ <businessLogicNode>localhost</businessLogicNode>
+ <portRMI>1099</portRMI>
+ <serviceRMI>RuralHouses</serviceRMI>
+</businessLogic>
<database local="true">
-
<databaseNode>localhost</databaseNode>
<db4oFilename>db/casas.db4o</db4oFilename>
<dataBaseOpenMode>initialize</dataBaseOpenMode>
<password>i4softwEngin2matx</password>
</database>
<javaPolicyPath>java.policy</javaPolicyPath>
-
</config>
\ No newline at end of file
--- /dev/null
+grant {
+permission java.security.AllPermission;
+};
+// If there problems with permissions:
+// permission java.security.AllPermission;
+//permission java.net.SocketPermission "localhost:1099", "connect,resolve";
+//permission java.net.SocketPermission "*", "accept,resolve";
+//permission java.io.FilePermission "casas.db4o", "delete,read,write";
+//permission java.util.PropertyPermission "*", "read";
\ No newline at end of file
--- /dev/null
+package dataAccess;
+
+import java.awt.BorderLayout;
+import java.awt.FlowLayout;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.io.File;
+
+import javax.swing.JButton;
+import javax.swing.JDialog;
+import javax.swing.JPanel;
+import javax.swing.JTextArea;
+import javax.swing.border.EmptyBorder;
+
+import com.db4o.ObjectServer;
+import com.db4o.cs.Db4oClientServer;
+import com.db4o.cs.config.ServerConfiguration;
+
+import configuration.ConfigXML;
+import domain.Account;
+import domain.Booking;
+import domain.Offer;
+import domain.Owner;
+import domain.RuralHouse;
+
+public class DB4oServerManager extends JDialog {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+ private final JPanel contentPanel = new JPanel();
+ JTextArea textArea;
+ ObjectServer server;
+ private ServerConfiguration configurationCS;
+
+ /**
+ * Launch the application.
+ */
+ public static void main(String[] args) {
+ try {
+ DB4oServerManager dialog = new DB4oServerManager ();
+ dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
+ dialog.setVisible(true);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * Create the dialog.
+ */
+ public DB4oServerManager () {
+ setTitle("DB4oManagerServer: running the database server");
+ setBounds(100, 100, 486, 180);
+ getContentPane().setLayout(new BorderLayout());
+ contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
+ getContentPane().add(contentPanel, BorderLayout.CENTER);
+ contentPanel.setLayout(new BorderLayout(0, 0));
+ {
+ textArea = new JTextArea();
+ contentPanel.add(textArea);
+ }
+ {
+ JPanel buttonPane = new JPanel();
+ buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
+ getContentPane().add(buttonPane, BorderLayout.SOUTH);
+ {
+ JButton okButton = new JButton("OK");
+ okButton.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ textArea.append("\n\n\nClosing the database... ");
+ try {
+ server.close();
+ } catch (Exception e1) {
+ }
+ System.exit(1);
+ }
+ });
+ okButton.setActionCommand("OK");
+ buttonPane.add(okButton);
+ getRootPane().setDefaultButton(okButton);
+ }
+ {
+ JButton cancelButton = new JButton("Cancel");
+ cancelButton.setActionCommand("Cancel");
+ buttonPane.add(cancelButton);
+ }
+ }
+
+ ConfigXML c=ConfigXML.getInstance();
+
+
+ try{
+
+ if (c.getDataBaseOpenMode().equals("initialize")) new File(c.getDb4oFilename()).delete();
+
+ configurationCS = Db4oClientServer.newServerConfiguration();
+ configurationCS.common().activationDepth(c.getActivationDepth());
+ configurationCS.common().updateDepth(c.getUpdateDepth());
+ configurationCS.common().objectClass(Owner.class).cascadeOnDelete(true);
+ configurationCS.common().objectClass(Booking.class).cascadeOnUpdate(true);
+ configurationCS.common().objectClass(RuralHouse.class)
+ .cascadeOnUpdate(true);
+ configurationCS.common().objectClass(Account.class).cascadeOnUpdate(true);
+ configurationCS.common().objectClass(Offer.class).cascadeOnUpdate(true);
+ configurationCS.common().objectClass(Account.class).cascadeOnUpdate(true);
+
+ server = Db4oClientServer.openServer(configurationCS,
+ c.getDb4oFilename(),c.getDatabasePort());
+
+ textArea.append("\nConnection to the database '"+c.getDb4oFilename()+"' opened in port "+c.getDatabasePort());
+
+ server.grantAccess(c.getUser(),c.getPassword());
+
+ textArea.append("\nAccess granted to: "+c.getUser());
+
+
+
+ textArea.append("\nPress button to exit this database server... ");
+
+ } catch (Exception e) {
+ textArea.append("Something has happened in DB4oManagerServer: "+e.toString());
+
+ }
+ }
+}
+
--- /dev/null
+package domain;
+
+import java.io.Serializable;
+import java.util.Arrays;
+
+
+public class Account implements Serializable {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+
+
+ private byte[] username;
+ private byte[] password;
+ private byte[] salt;
+
+
+ private Owner owner;
+ private boolean admin = false;
+
+ public Account(byte[] usr){
+
+
+ }
+ public Account(String usr, String pass, boolean isAdmin) {
+
+
+ }
+
+ public Account(String usr, String pass, Owner ow) {
+
+
+ }
+
+
+
+
+ public byte[] getUsername() {
+ return username;
+ }
+
+ public byte[] getPassword() {
+ return password;
+ }
+
+ public Owner getOwner() {
+ return owner;
+ }
+
+ public boolean getAdmin() {
+ return admin;
+ }
+
+
+ public void setAdmin(boolean admin) {
+ this.admin = admin;
+ }
+
+ public byte[] getSalt() {
+ return salt;
+ }
+
+ public void setSalt(byte[] salt) {
+ this.salt = salt;
+ }
+
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ Account other = (Account) obj;
+ if (!Arrays.equals(username, other.username))
+ return false;
+ return true;
+ }
+
+}
--- /dev/null
+package domain;
+
+import java.io.Serializable;
+import java.util.LinkedList;
+
+import configuration.ConfigXML;
+
+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;
+ static ConfigXML c;
+
+ private Administrator() {
+ addRequest = new LinkedList<RuralHouse>();
+ removeRequest = new LinkedList<RuralHouse>();
+ newOwnerRequest = new LinkedList<Account>();
+ }
+
+ public static Administrator getInstance() {
+
+ return admin;
+
+ }
+
+ public static void saveInstance() {
+ }
+
+ public LinkedList<RuralHouse> getAddRequest() {
+ return addRequest;
+ }
+
+ public LinkedList<RuralHouse> getRemoveRequest() {
+ return removeRequest;
+ }
+
+ public void setAddRequest(LinkedList<RuralHouse> addRequest) {
+ Administrator.addRequest = addRequest;
+ }
+
+ public void setRemoveRequest(LinkedList<RuralHouse> removeRequest) {
+ Administrator.removeRequest = removeRequest;
+
+ }
+
+ public LinkedList<Account> getNewOwnerRequest() {
+ return newOwnerRequest;
+ }
+
+ public void setNewOwnerRequest(LinkedList<Account> newOwnerRequest) {
+ Administrator.newOwnerRequest = newOwnerRequest;
+ }
+
+}
--- /dev/null
+package domain;
+
+import java.io.Serializable;
+import java.util.Date;
+
+public class Booking implements Serializable {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+ private int bookingNumber;
+ private Date bookingDate;
+ private Client client;
+ private Offer offer;
+
+
+
+ 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());
+ }
+
+
+ public Booking(int bN , Offer offer,Client client, Date bookDate) {
+ this.bookingNumber = bN;
+ this.offer = offer;
+ this.client=client;
+ this.bookingDate= bookDate; }
+
+
+ public int getBookNumber() {
+ return this.bookingNumber;
+ }
+
+ public void setOffer(Offer offer) {
+ this.offer = offer;
+ }
+
+ public Offer getOffer() {
+ return this.offer;
+ }
+
+
+ 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
--- /dev/null
+package domain;
+
+import java.io.Serializable;
+
+public class Client implements Serializable{
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+ private String name;
+ private String mailAccount;
+ private String telephone;
+
+ public Client(String name, String mailAccount, String telephone) {
+ super();
+ this.name = name;
+ this.mailAccount = mailAccount;
+ this.telephone = telephone;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getMailAccount() {
+ return mailAccount;
+ }
+
+ public void setMailAccount(String mailAccount) {
+ this.mailAccount = mailAccount;
+ }
+
+ public String getTelephone() {
+ return telephone;
+ }
+
+ public void setTelephone(String telephone) {
+ this.telephone = telephone;
+ }
+
+}
--- /dev/null
+package domain;
+
+import java.io.Serializable;
+
+public enum Districs implements Serializable {
+
+ /**
+ *
+ */
+ BEA("Beatriz"), GUA("Guazate"), VEG("Vegas"), FAR("Farallón"), CED("Cedro"), MOT(
+ "Monte LLano"), RIN("Rincón"), PUE("Pueblo"), QUA("Quebrada Arriba"), QEB(
+ "Quebrada Abajo"), TOI("Toita"), MAB("Matón Abajo"), MAA(
+ "Matón Arriba"), PIE("Piedras"), PAV("Pasto Viejo"), PEA(
+ "PedroAvila"), SUM("Sumido"), LAP("Lapa"), CER("Cercadillo"), JAJ(
+ "JójomeAlto"), CUL("CulebrasAbajo");
+
+ private static final long serialVersionUID = 1L;
+
+
+ private final String longName;
+
+ Districs(String longName) {
+ this.longName = longName;
+ }
+
+ public static String[] longNames() {
+ String[] result = new String[Districs.values().length];
+ for (Districs d : Districs.values()) {
+ result[d.ordinal()] = d.longName;
+ }
+ return result;
+
+ }
+}
--- /dev/null
+package domain;
+
+import java.io.Serializable;
+
+public class HouseFeatures implements Serializable {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+ private int nRooms;
+ private int nKitchens;
+ private int nBaths;
+ private int nLivings;
+ private int nParkings;
+
+ public HouseFeatures(int nRooms, int nKitchens, int nBaths, int nLivings,
+ int nParkings) {
+ super();
+ this.nRooms = nRooms;
+ this.nKitchens = nKitchens;
+ this.nBaths = nBaths;
+ this.nLivings = nLivings;
+ this.nParkings = nParkings;
+ }
+
+ public int getnRooms() {
+ return nRooms;
+ }
+
+
+
+ public int getnKitchens() {
+ return nKitchens;
+ }
+
+
+
+ public int getnBaths() {
+ return nBaths;
+ }
+
+
+
+ public int getnLivings() {
+ return nLivings;
+ }
+
+
+
+ public int getnParkings() {
+ return nParkings;
+ }
+
+
+}
--- /dev/null
+package domain;
+
+import java.io.Serializable;
+import java.util.Date;
+import java.util.Vector;
+
+
+@SuppressWarnings("serial")
+public class Offer implements Serializable {
+
+
+ private int offerNumber;
+ private Date firstDay; // Dates are stored as java.util.Date objects instead of java.sql.Date objects
+ private Date lastDay; // because, they are not well stored in db4o as java.util.Date objects
+ private float price; // This is coherent because objects of java.sql.Date are objects of java.util.Date ç
+ private boolean isBooked;
+ private Vector<Booking> bookings = new Vector<Booking>(); // That is: java.sql.Date is a subclass (or extends) java.util.Date
+ private RuralHouse ruralHouse;
+
+
+ public Offer(int offerNumber,RuralHouse ruralHouse, Date firstDay, Date lastDay, float price){
+ this.firstDay=firstDay;
+ this.lastDay=lastDay;
+ this.price=price;
+ this.ruralHouse=ruralHouse;
+ this.offerNumber=offerNumber;
+ }
+ /**
+ * Get the house number of the offer
+ *
+ * @return the house number
+ */
+ public RuralHouse getRuralHouse() {
+ return this.ruralHouse;
+ }
+
+ /**
+ * Set the house number to a offer
+ *
+ * @param house number
+ */
+ public void setRuralHouse(RuralHouse ruralHouse) {
+ this.ruralHouse = ruralHouse;
+ }
+
+
+ /**
+ * Get the offer number
+ *
+ * @return offer number
+ */
+ public int getOfferNumber() {
+ return this.offerNumber;
+ }
+
+
+
+ /**
+ * Get the first day of the offer
+ *
+ * @return the first day
+ */
+ public Date getFirstDay() {
+ return this.firstDay;
+ }
+
+ /**
+ * Set the first day of the offer
+ *
+ * @param firstDay
+ * The first day
+ */
+ public void setFirstDay(Date firstDay) {
+ this.firstDay = firstDay;
+ }
+
+ /**
+ * Get the last day of the offer
+ *
+ * @return the last day
+ */
+ public Date getLastDay() {
+ return this.lastDay;
+ }
+
+ /**
+ * Set the last day of the offer
+ *
+ * @param lastDay
+ * The last day
+ */
+ public void setLastDay(Date lastDay) {
+ this.lastDay = lastDay;
+ }
+
+ /**
+ * Get the price
+ *
+ * @return price
+ */
+ public float getPrice() {
+ return this.price;
+ }
+
+ /**
+ * Set the price
+ *
+ * @param price
+ */
+ public void setPrice(float price) {
+ this.price = price;
+ }
+
+
+ /**
+ * This method creates a book with a corresponding parameters
+ *
+ * @param First day, last day, house number and telephone
+ * @return a book
+ */
+ public Vector<Booking> createBooking(int numBooking,Client client) {
+ Booking b = new Booking(numBooking,this,client);
+ this.bookings.add(b);
+ return this.bookings;
+
+ }
+
+ public String toString(){
+ return firstDay.toString()+", "+lastDay.toString()+", "+price;
+ }
+ public Vector<Booking> getBookings() {
+ return bookings;
+ }
+ public void setBookings(Vector<Booking> bookings) {
+ this.bookings = bookings;
+ }
+ public boolean isBooked() {
+ return isBooked;
+ }
+ public void setBooked(boolean isBooked) {
+ this.isBooked = isBooked;
+ }
+}
\ No newline at end of file
--- /dev/null
+package domain;
+
+import java.io.Serializable;
+import java.util.Vector;
+
+public class Owner implements Serializable {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+ private String bankAccount = "";
+ private String name = "";
+ private String mailAccount = "";
+ private Vector<RuralHouse> ruralHouses;
+
+
+ public Owner(String name, String bankAccount,String mail) {
+ this.bankAccount = bankAccount;
+ this.name = name;
+ this.mailAccount = mail;
+ ruralHouses = new Vector<RuralHouse>();
+ }
+
+ public String getName() {
+ return this.name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getBankAccount() {
+ return this.bankAccount;
+ }
+
+ public void setBankAccount(String bankAccount) {
+ this.bankAccount = bankAccount;
+ }
+
+ public Vector<RuralHouse> getRuralHouses(){
+ return this.ruralHouses;
+ }
+
+
+
+ public RuralHouse addRuralHouse(String houseName, String description,
+ String town, int nRooms, int nKitchens, int nBaths, int nLivings,
+ int nParkings) {
+ HouseFeatures feature = new HouseFeatures(nRooms, nKitchens, nBaths, nLivings, nParkings);
+ RuralHouse rh = new RuralHouse(houseName, this, description, town,feature);
+ ruralHouses.add(rh);
+ return rh;
+ }
+
+ public RuralHouse addRuralHouse(RuralHouse rh) {
+ ruralHouses.add(rh);
+ return rh;
+ }
+
+ public String toString() {
+ return name;
+ }
+
+ public String getMailAccount() {
+ return mailAccount;
+ }
+
+ public void setMailAccount(String mailAccount) {
+ this.mailAccount = mailAccount;
+ }
+
+
+
+}
\ No newline at end of file
--- /dev/null
+package domain;
+
+import java.io.Serializable;
+import java.util.Date;
+import java.util.Iterator;
+import java.util.Vector;
+
+public class RuralHouse implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ private String houseName;
+ private String description;
+ private Owner owner;
+ private String district;
+ private HouseFeatures features;
+ public Vector<Offer> offers;
+
+
+ public RuralHouse() {
+ super();
+ }
+
+ public RuralHouse(String houseName, Owner owner, String description,
+ String ds, HouseFeatures features) {
+ this.houseName = houseName;
+ this.description = description;
+ this.owner = owner;
+ this.district = ds;
+ this.features = features;
+ offers = new Vector<Offer>();
+ }
+
+ public String getHouseName() {
+ return houseName;
+ }
+
+ public void setHouseName(String houseName) {
+ this.houseName = houseName;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public Owner getOwner() {
+ return owner;
+ }
+
+ public void setOwner(Owner owner) {
+ this.owner = owner;
+ }
+
+ public String getDistrict() {
+ return district;
+ }
+
+ public void setDistrict(String ds) {
+ this.district = ds;
+ }
+
+ public HouseFeatures getFeatures() {
+ return features;
+ }
+
+ public void setFeatures(HouseFeatures features) {
+ this.features = features;
+ }
+
+ public String toString() {
+ return this.houseName + ": " + this.district;
+ }
+
+ public Offer createOffer(int offerNumber, Date firstDay, Date lastDay,
+ float price) {
+ Offer off = new Offer(offerNumber, this, firstDay, lastDay, price);
+ offers.add(off);
+ return off;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ RuralHouse other = (RuralHouse) obj;
+ if (houseName == null) {
+ if (other.houseName != null)
+ return false;
+ } else if (!houseName.equals(other.houseName))
+ return false;
+ return true;
+ }
+
+
+
+ public Offer overlapsWith(Date firstDay, Date lastDay) {
+
+ Iterator<Offer> e = offers.iterator();
+ Offer offer = null;
+ while (e.hasNext()) {
+ offer = e.next();
+ if ((offer.getFirstDay().compareTo(lastDay) < 0)
+ && (offer.getLastDay().compareTo(firstDay) > 0))
+ return offer;
+ }
+ return null;
+
+ }
+
+
+ public Vector<Offer> getAllOffers() {
+
+ return this.offers;
+ }
+
+
+}
--- /dev/null
+package exceptions;
+public class BadDates extends Exception {
+ private static final long serialVersionUID = 1L;
+
+ public BadDates()
+ {
+ super();
+ }
+ /**This exception is triggered if first date is greater than last date in offers
+ *@param String
+ *@return None
+ */
+ public BadDates(String s)
+ {
+ super(s);
+ }
+}
\ No newline at end of file
--- /dev/null
+package exceptions;
+public class DB4oManagerCreationException extends Exception {
+ private static final long serialVersionUID = 1L;
+
+ public DB4oManagerCreationException()
+ {
+ super();
+ }
+ /**This exception is triggered if there is a problem when constructor of DB4oManager is executed
+ *@param String
+ *@return None
+ */
+ public DB4oManagerCreationException(String s)
+ {
+ super(s);
+ }
+}
\ No newline at end of file
--- /dev/null
+package exceptions;
+public class OfferCanNotBeBooked extends Exception {
+ private static final long serialVersionUID = 1L;
+
+ public OfferCanNotBeBooked() {
+ super();
+ }
+
+ /**This exception is triggered if an offer cannot be booked
+ *@param String
+ *@return None
+ */
+ public OfferCanNotBeBooked(String s)
+ {
+ super(s);
+ }
+}
\ No newline at end of file
--- /dev/null
+package exceptions;
+public class OverlappingOfferExists extends Exception {
+ private static final long serialVersionUID = 1L;
+
+ public OverlappingOfferExists()
+ {
+ super();
+ }
+ /**This exception is triggered if there exists an overlapping offer
+ *@param String
+ *@return None
+ */
+ public OverlappingOfferExists(String s)
+ {
+ super(s);
+ }
+}
\ No newline at end of file