1 | |
package org.paneris.jammyjoes.model; |
2 | |
|
3 | |
import org.melati.poem.AccessToken; |
4 | |
import org.melati.poem.Capability; |
5 | |
import org.melati.poem.PoemTask; |
6 | |
import org.melati.poem.Setting; |
7 | |
import org.paneris.jammyjoes.model.generated.JammyjoesDatabaseBase; |
8 | |
|
9 | 0 | public class JammyjoesDatabase extends JammyjoesDatabaseBase implements JammyjoesDatabaseTables { |
10 | |
|
11 | |
public static final String defaultOrderEmailTo = "orders@jammyjoes.com"; |
12 | |
public static final String defaultReminderEmailFrom = "reminder@jammyjoes.com"; |
13 | |
public static final int defaultDefaultAffiliatePercentage = 5; |
14 | |
public static final int defaultDefaultCookiedays = 45; |
15 | |
private Setting orderEmailTo, reminderEmailFrom, defaultAffiliatePercentage, defaultCookiedays; |
16 | |
private Capability _operatorCapability; |
17 | |
private Capability _affiliateCapability; |
18 | |
|
19 | |
public boolean logSQL() { |
20 | 0 | return false; |
21 | |
} |
22 | |
|
23 | |
public void connect( |
24 | |
String name, |
25 | |
String dbmsclass, |
26 | |
String url, |
27 | |
String username, |
28 | |
String password, |
29 | |
int maxConnections) { |
30 | 0 | super.connect(name, dbmsclass, url, username, password, maxConnections); |
31 | |
|
32 | 0 | inSession(AccessToken.root, new PoemTask() { |
33 | 0 | public void run() { |
34 | 0 | orderEmailTo = |
35 | |
getSettingTable().ensure( |
36 | |
"OrderEmailTo", |
37 | |
defaultOrderEmailTo, |
38 | |
"Order Email `To:'", |
39 | |
"The address to send orders to"); |
40 | 0 | reminderEmailFrom = |
41 | |
getSettingTable().ensure( |
42 | |
"ReminderEmailFrom", |
43 | |
defaultReminderEmailFrom, |
44 | |
"Reminder Email `To:'", |
45 | |
"The address from which password reminders are sent from"); |
46 | 0 | defaultAffiliatePercentage = |
47 | |
getSettingTable().ensure( |
48 | |
"DefaultAffiliatePercentage", |
49 | |
defaultDefaultAffiliatePercentage, |
50 | |
"Default Affiliate Percentage", |
51 | |
"The percentage to pay Affiliates"); |
52 | 0 | defaultCookiedays = |
53 | |
getSettingTable().ensure( |
54 | |
"DefaultCookiedays", |
55 | |
defaultDefaultCookiedays, |
56 | |
"Default Cookie Days", |
57 | |
"The number of cookie days for Affiliates"); |
58 | 0 | _operatorCapability = getCapabilityTable().ensure("Phone Operator"); |
59 | 0 | _affiliateCapability = getCapabilityTable().ensure("Affiliate"); |
60 | 0 | } |
61 | |
}); |
62 | 0 | } |
63 | |
|
64 | |
public String getOrderEmailTo() { |
65 | 0 | return orderEmailTo.getStringCooked(); |
66 | |
} |
67 | |
|
68 | |
public String getReminderEmailFrom() { |
69 | 0 | return reminderEmailFrom.getStringCooked(); |
70 | |
} |
71 | |
|
72 | |
public Integer getDefaultAffiliatePercentage() { |
73 | 0 | return (Integer) defaultAffiliatePercentage.getCooked(); |
74 | |
} |
75 | |
|
76 | |
public Integer getDefaultCookiedays() { |
77 | 0 | return (Integer) defaultCookiedays.getCooked(); |
78 | |
} |
79 | |
|
80 | |
public Capability getCanAdminister() { |
81 | 0 | return administerCapability(); |
82 | |
} |
83 | |
|
84 | |
public Capability getOperatorCapability() { |
85 | 0 | return _operatorCapability; |
86 | |
} |
87 | |
|
88 | |
public Capability getAffiliateCapability() { |
89 | 0 | return _affiliateCapability; |
90 | |
} |
91 | |
} |