RRRRHHHH_Code
Diff Revisions
837fab ...
vs
520867 ...
for ruralHouses/src/businessLogic/OfferManager.java
|
@@ -3,9 +3,6 @@ |
3 |
3 |
|
import java.rmi.RemoteException; |
4 |
4 |
|
import java.sql.Date; |
5 |
5 |
|
|
6 |
|
- |
import com.db4o.ObjectContainer; |
7 |
|
- |
import com.db4o.ObjectSet; |
8 |
|
- |
|
9 |
6 |
|
import dataAccess.DB4oManager; |
10 |
7 |
|
import domain.Offer; |
11 |
8 |
|
import domain.RuralHouse; |
|
@@ -16,7 +13,6 @@ |
16 |
13 |
|
|
17 |
14 |
|
private int offerNumber = 0; |
18 |
15 |
|
dataAccess.DB4oManager dbMngr; |
19 |
|
- |
private static OfferManager theOfferManager; |
20 |
16 |
|
|
21 |
17 |
|
public OfferManager() { |
22 |
18 |
|
try { |
|
@@ -26,31 +22,6 @@ |
26 |
22 |
|
} |
27 |
23 |
|
} |
28 |
24 |
|
|
29 |
|
- |
public static int getNumber() { |
30 |
|
- |
ObjectContainer db=DB4oManager.getContainer(); |
31 |
|
- |
OfferManager o=getInstance(); |
32 |
|
- |
o.offerNumber++; |
33 |
|
- |
db.store(o); |
34 |
|
- |
db.commit(); |
35 |
|
- |
return o.offerNumber; |
36 |
|
- |
} |
37 |
|
- |
|
38 |
|
- |
/** |
39 |
|
- |
* This method returns the instance of the OfferManager class |
40 |
|
- |
* |
41 |
|
- |
* @return the offer manager |
42 |
|
- |
*/ |
43 |
|
- |
public static OfferManager getInstance() { |
44 |
|
- |
ObjectContainer db=DB4oManager.getContainer(); |
45 |
|
- |
OfferManager b = new OfferManager(); |
46 |
|
- |
ObjectSet<OfferManager> result = db.queryByExample(b); |
47 |
|
- |
if (!result.hasNext()){ |
48 |
|
- |
theOfferManager = new OfferManager(); |
49 |
|
- |
db.store(theOfferManager); |
50 |
|
- |
db.commit(); |
51 |
|
- |
} else theOfferManager=(OfferManager)result.next(); |
52 |
|
- |
return theOfferManager; |
53 |
|
- |
} |
54 |
25 |
|
|
55 |
26 |
|
/** |
56 |
27 |
|
* This method creates an offer with a house number, first day, last day and price |
|
@@ -66,8 +37,8 @@ |
66 |
37 |
|
|
67 |
38 |
|
boolean b = dbMngr.existsOverlappingOffer(ruralHouse,firstDay,lastDay); // The ruralHouse object in the client may not be updated |
68 |
39 |
|
if (!b) { |
69 |
|
- |
ruralHouse.createOffer(offerNumber, firstDay, lastDay, price); |
70 |
|
- |
return dbMngr.createOffer(ruralHouse,firstDay,lastDay,price); |
|
40 |
+ |
dbMngr.createOffer(ruralHouse,firstDay,lastDay,price); |
|
41 |
+ |
return ruralHouse.createOffer(offerNumber, firstDay, lastDay, price); |
71 |
42 |
|
} |
72 |
43 |
|
return null; |
73 |
44 |
|
} |