Git Repository Public Repository

RRRRHHHH_Code

URLs

Copy to Clipboard

Diff Revisions 0f75b2 ... vs 7bf57b ... for ruralHouses/src/dataAccess/DB4oManager.java

Diff revisions: vs.
  @@ -119,18 +119,18 @@
119 119 public void initializeDB() {
120 120
121 121 try {
122 - Owner jon = new Owner("Jon");
123 - Owner alfredo = new Owner("Alfredo");
122 + Owner jon = new Owner("Jon", "1349 5677 21 2133567777",
123 + "Jon@gmail.com");
124 + Owner alfredo = new Owner("Alfredo", "4144 0087 23 9700002133",
125 + "alfredo@gmail.com");
124 126 jon.addRuralHouse("Ezkioko", "Ezkioko etxea", "Beatriz", 3, 3, 3,
125 127 3, 3);
126 128 jon.addRuralHouse("Eskiatze", "Eskiatzeko etxea", "Guazate", 4, 4,
127 129 4, 4, 4);
128 - jon.setBankAccount("1349 5677 21 2133567777");
129 130 alfredo.addRuralHouse("Aitonako", "Casa del abuelo", "Vegas", 5, 5,
130 131 5, 5, 5);
131 132
132 133 alfredo.addRuralHouse("Murgoitz", "", "Cedro", 6, 6, 6, 6, 6);
133 - alfredo.setBankAccount("4144 0087 23 9700002133");
134 134 Account jonAcc = new Account("1", "1", jon);
135 135 Account alfredoAcc = new Account("userAlfredo", "passAlfredo",
136 136 alfredo);
  @@ -154,7 +154,7 @@
154 154 openDB();
155 155
156 156 try {
157 - Owner proto = new Owner(null, null);
157 + Owner proto = new Owner(null, null, null);
158 158 ObjectSet<Owner> result = db.queryByExample(proto);
159 159 while (result.hasNext()) {
160 160 Owner o = (Owner) result.next();
  @@ -219,7 +219,6 @@
219 219 }
220 220 }
221 221
222 -
223 222 public Administrator getAdminData() {
224 223 if (c.isDatabaseLocal() == false)
225 224 openSDB();
  @@ -266,10 +265,12 @@
266 265 }
267 266 });
268 267
269 -
270 - admL.get(0).setAddRequest(Administrator.getInstance().getAddRequest());
271 - admL.get(0).setRemoveRequest(Administrator.getInstance().getRemoveRequest());
272 - admL.get(0).setNewOwnerRequest(Administrator.getInstance().getNewOwnerRequest());
268 + admL.get(0).setAddRequest(
269 + Administrator.getInstance().getAddRequest());
270 + admL.get(0).setRemoveRequest(
271 + Administrator.getInstance().getRemoveRequest());
272 + admL.get(0).setNewOwnerRequest(
273 + Administrator.getInstance().getNewOwnerRequest());
273 274 db.commit();
274 275
275 276 } catch (Exception e) {
  @@ -344,7 +345,7 @@
344 345 openDB();
345 346
346 347 try {
347 - Owner proto = new Owner(null, null);
348 + Owner proto = new Owner(null, null, null);
348 349 ObjectSet<Owner> result = db.queryByExample(proto);
349 350 Vector<Owner> owners = new Vector<Owner>();
350 351 while (result.hasNext())
  @@ -417,8 +418,8 @@
417 418 * @throws RemoteException
418 419 * @throws Exception
419 420 */
420 - public Vector<Account> getAccount(Account proto)
421 - throws RemoteException, Exception {
421 + public Vector<Account> getAccount(Account proto) throws RemoteException,
422 + Exception {
422 423
423 424 if (c.isDatabaseLocal() == false)
424 425 openSDB();
  @@ -516,4 +517,28 @@
516 517
517 518 }
518 519
520 + public boolean addAccount(Account acc) {
521 + if (c.isDatabaseLocal() == false)
522 + openSDB();
523 + else
524 + openDB();
525 +
526 + try {
527 + //TODO realize if there is another account with same username. Quite difficult with the f***ing salt
528 + db.store(acc);
529 + db.commit();
530 + } catch (Exception exc) {
531 + exc.printStackTrace();
532 + } finally {
533 + db.close();
534 + }
535 + return true;
536 + }
537 +
538 + //TODO remove account
539 +
540 + public boolean removeAccount(Account acc) {
541 + return false;
542 + }
543 +
519 544 }