}
}
+ public void deleteDB() {
+
+ if (c.isDatabaseLocal() == false)
+ openSDB();
+ else
+ openDB();
+
+ try {
+ Owner proto = new Owner(null, null);
+ ObjectSet result = db.queryByExample(proto);
+ Vector<Owner> owners = new Vector<Owner>();
+ while (result.hasNext()) {
+ Owner o = (Owner) result.next();
+ System.out.println("Deleted owner: " + o.toString());
+ db.delete(o);
+ }
+ db.commit();
+ } finally {
+ db.close();
+ }
+ }
+
+
@SuppressWarnings("finally")
public Offer createOffer(RuralHouse ruralHouse, Date firstDay,
Date lastDay, float price) throws RemoteException, Exception {
return o;
}
- public void deleteDB() {
+ @SuppressWarnings("finally")
+ public Offer modifyOffer(Offer offer) throws RemoteException, Exception {
+ if (c.isDatabaseLocal() == false)
+ openSDB();
+ else
+ openDB();
+
+ try {
+
+ db.store(offer);
+ db.commit();
+
+ } catch (com.db4o.ext.ObjectNotStorableException e) {
+ System.out
+ .println("Error: com.db4o.ext.ObjectNotStorableException in createOffer");
+ } finally {
+ db.close();
+ }
+ return offer;
+ }
+
+ @SuppressWarnings("finally")
+ public void deleteOffer(RuralHouse rh, Offer offer) throws RemoteException, Exception {
if (c.isDatabaseLocal() == false)
openSDB();
else
openDB();
try {
- Owner proto = new Owner(null, null);
- ObjectSet result = db.queryByExample(proto);
- Vector<Owner> owners = new Vector<Owner>();
- while (result.hasNext()) {
- Owner o = (Owner) result.next();
- System.out.println("Deleted owner: " + o.toString());
- db.delete(o);
- }
+
+ db.store(rh);
+ db.delete(offer);
db.commit();
+
+ } catch (com.db4o.ext.ObjectNotStorableException e) {
+ System.out
+ .println("Error: com.db4o.ext.ObjectNotStorableException in createOffer");
} finally {
db.close();
}
}
+
/**
* This method creates a book with a corresponding parameters