1 package org.paneris.bibliomania;
2
3 import java.sql.Timestamp;
4 import java.util.Enumeration;
5
6 import org.melati.poem.AccessPoemException;
7 import org.paneris.bibliomania.generated.ShopOrderBase;
8
9 public class ShopOrder extends ShopOrderBase {
10 public ShopOrder() {}
11
12
13
14 public BibliomaniaDatabase getBibliomaniaDatabase () {
15 return (BibliomaniaDatabase)getDatabase();
16 }
17
18 public Enumeration<ShopOrderItem> getItems() {
19 return getOrderShopOrderItems();
20
21 }
22
23
24
25
26 public void removeItems() {
27 if (troid() != null) {
28 for (ShopOrderItem i : getOrderShopOrderItemList()) {
29 i.deleteAndCommit();
30 }
31
32
33
34
35
36
37
38
39
40
41 }
42 }
43
44
45
46
47 public void setStatus(OrderStatus cooked) throws AccessPoemException {
48 BibliomaniaDatabase db = (BibliomaniaDatabase)getDatabase();
49 if (getFufilleddate_unsafe() == null &&
50 cooked == db.getOrderStatusTable().getFufilled()) {
51 setFufilleddate_unsafe(now());
52 }
53 super.setStatus(cooked);
54 }
55
56 public void setFufilleddate_unsafe(Timestamp cooked) {
57
58 BibliomaniaDatabase db = (BibliomaniaDatabase)getDatabase();
59 if (getStatus() != db.getOrderStatusTable().getFufilled() || cooked != null) {
60 super.setFufilleddate_unsafe(cooked);
61 }
62 }
63
64 protected void writeLock() {
65 super.writeLock();
66 if (getDate_unsafe() == null) {
67 setDate_unsafe(now());
68 }
69 }
70
71 private static java.sql.Timestamp now() {
72 return new java.sql.Timestamp(new java.util.Date().getTime());
73 }
74
75
76 }