deleted: ruralHouses/hs_err_pid6014.log
[RRRRHHHH_Code] / ruralHouses / src / dataAccess / DB4oManager.java
index 553d4dc..40fe83c 100644 (file)
@@ -130,6 +130,29 @@ public class DB4oManager {
                }
        }
 
+       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 {
@@ -162,27 +185,49 @@ public class DB4oManager {
                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
@@ -369,15 +414,15 @@ public class DB4oManager {
                return stored;
        }
 
-       public void removeHouse(String houseName, Owner owner) {
+
+       public void removeHouse(RuralHouse rh, Owner owner) {
 
                if (c.isDatabaseLocal() == false)
                        openSDB();
                else
                        openDB();               
-               RuralHouse house = new RuralHouse(houseName, null, null, null, null);
                try {
-                       ObjectSet<RuralHouse> result = db.queryByExample(house);
+                       ObjectSet<RuralHouse> result = db.queryByExample(rh);
                        if (!result.isEmpty()) {
                                RuralHouse found = (RuralHouse) result.get(0);
 //                             db.delete(found.getOwner());