1 package org.paneris.rimauresq.model;
2
3 import org.melati.poem.AccessToken;
4 import org.melati.poem.Capability;
5 import org.melati.poem.PoemTask;
6 import org.melati.util.StringUtils;
7 import org.paneris.melati.site.model.Div;
8 import org.paneris.melati.site.model.Page;
9 import org.paneris.melati.site.model.Template;
10 import org.paneris.melati.site.model.UploadedFileType;
11 import org.paneris.melati.site.model.UploadedImage;
12 import org.paneris.rimauresq.model.generated.RimauresqDatabaseBase;
13
14
15
16
17 public class RimauresqDatabase extends RimauresqDatabaseBase implements
18 RimauresqDatabaseTables {
19
20
21 private Page homePage, thanksPage;
22 private UploadedImage otherDbImage;
23 private Setting otherDbHomePageUrl;
24 private Setting thisDbName, otherDbName;
25 private Setting newsAdminName, newsAdminEmail;
26 private Setting salesAdminName, salesAdminEmail;
27 private Setting websiteFromName, websiteFromEmail;
28 private Setting quantity, edit, confirm;
29 private Setting description;
30 private Setting keywords;
31 private UploadedFileType pdf, wm, html, jpg, gif;
32 private Div colophon;
33 private Div comment;
34 private Template thanksTemplate;
35 private Div illogical;
36 private Div orderThanks;
37 private Div newsThanks;
38 private Div sent;
39 private Div duplicateLogin;
40
41
42
43 public Setting getSalesAdminEmail() {
44 return salesAdminEmail;
45 }
46
47
48
49
50 public Setting getSalesAdminName() {
51 return salesAdminName;
52 }
53
54
55
56
57 public Setting getWebsiteFromEmail() {
58 return websiteFromEmail;
59 }
60
61
62
63
64 public Setting getWebsiteFromName() {
65 return websiteFromName;
66 }
67
68 public void connect(
69 String name,
70 String dbmsclass,
71 String url,
72 String username,
73 String password,
74 int maxConnections) {
75 super.connect(name, dbmsclass, url, username, password, maxConnections);
76
77 inSession(AccessToken.root, new PoemTask() {
78 public void run() {
79 homePage = (Page)getPageTable().firstSelection("id=0");
80 if (homePage == null)
81 homePage = getPageTable().ensure("Home");
82 thanksTemplate = getTemplateTable().ensure("Thanks","thanks.wm");
83 thanksPage = (Page)getPageTable().getTemplateColumn().
84 firstWhereEq(thanksTemplate.troid());
85 if (thanksPage == null)
86 thanksPage = getPageTable().ensure("Thanks", thanksTemplate);
87 pdf = getUploadedFileTypeTable().ensure("pdf");
88 wm = getUploadedFileTypeTable().ensure("wm");
89 html = getUploadedFileTypeTable().ensure("html");
90 jpg = getUploadedFileTypeTable().ensure("jpg");
91 gif = getUploadedFileTypeTable().ensure("gif");
92 otherDbImage = getUploadedImageTable().
93 ensure("other","Francais","images/french_flag.gif",gif,
94 new Integer(25), new Integer(25));
95 thisDbName =
96 (Setting)getSettingTable().ensure(
97 "ThisDbName",
98 "en",
99 "English",
100 "Name of this database");
101 otherDbName =
102 (Setting)getSettingTable().ensure(
103 "OtherDbName",
104 "fr",
105 "Francais",
106 "Name of other database");
107 otherDbHomePageUrl =
108 (Setting)getSettingTable().ensure(
109 "OtherDbHomePageUrl",
110 "page/Home.html",
111 "Other DB Home Page",
112 "Home Page of other database");
113 newsAdminName =
114 (Setting)getSettingTable().ensure(
115 "NewsAdminName",
116 "News Admin Name",
117 "News Admin Name",
118 "Name of person who deals with administration of the newsletter");
119 newsAdminEmail =
120 (Setting)getSettingTable().ensure(
121 "NewsAdminEmail",
122 "rimauresq.NewsAdminEmail@context-computing.co.uk",
123 "News Admin Email",
124 "Email address of person responsible for newsletter administration");
125 salesAdminName =
126 (Setting)getSettingTable().ensure(
127 "SalesAdminName",
128 "Sales Admin Name",
129 "Sales Admin Name",
130 "Name of person who deals with administration of sales");
131 salesAdminEmail =
132 (Setting)getSettingTable().ensure(
133 "SalesAdminEmail",
134 "rimauresq.SalesAdminEmail@context-computing.co.uk",
135 "Sales Admin Email",
136 "Email address of person responsible for sales administration");
137 websiteFromName =
138 (Setting)getSettingTable().ensure(
139 "WebsiteFromName",
140 "Website From Name",
141 "Website From Name",
142 "Name of person used to send emails from the website");
143 websiteFromEmail =
144 (Setting)getSettingTable().ensure(
145 "WebsiteFromEmail",
146 "rimauresq.WebsiteEmail@context-computing.co.uk",
147 "Website From Email",
148 "Name of person used to send emails from the website");
149 quantity =
150 (Setting)getSettingTable().ensure(
151 "QuantityText",
152 "Quantity",
153 "Quantity Text",
154 "Text to appear where Quantity is in the English site.");
155 edit =
156 (Setting)getSettingTable().ensure(
157 "EditText",
158 "Edit",
159 "Edit Text",
160 "Text to appear where Edit is in the English site.");
161 confirm =
162 (Setting)getSettingTable().ensure(
163 "confirm",
164 "Confirm",
165 "Confirm Text",
166 "Text to appear where Confirm is in the English site.");
167
168 description =
169 (Setting)getSettingTable().ensure(
170 "description",
171 "A premium range of wines from Provence.",
172 "Site description",
173 "Descriptive text used in meta tags");
174 keywords =
175 (Setting)getSettingTable().ensure(
176 "keywords",
177 "French, wines, Provence, Rimauresq",
178 "Site keywords",
179 "Comma separated values for use in keywords meta tag");
180
181
182 colophon = getDivTable().ensure(null, "colophon", "Colophon",
183 "By Paneris using Melati");
184 comment = getDivTable().ensure(null, "comment", "Comment",
185 "Any additional comments or instructions");
186
187 illogical = getDivTable().ensure(null, "illogical", "illogical",
188 "<p>You appear not to have ordered anything nor to have " +
189 "subscribed to the newsletter.</p>" +
190 "<p>Please <a href=\"javascript:history.go(-1);\">" +
191 "try again</a></p>");
192 orderThanks = getDivTable().ensure(null, "orderThanks",
193 "Order Thanks",
194 "<p>Thank you for your order. " +
195 "We will be in touch shortly about payment and delivery.</p>");
196 newsThanks = getDivTable().ensure(null, "newsThanks",
197 "Registration Thanks",
198 "<p>Thank you for registering for Rimauresq News. " +
199 "We will keep you informed of the latest news and "+
200 "special offers.</p>");
201 sent = getDivTable().ensure(null, "sent", "Sent",
202 "<p>The following message has been sent to our offices.</p>");
203 duplicateLogin = getDivTable().ensure(null, "duplicateLogin",
204 "Duplicate User Name",
205 "<p>Your login name has already been used.</p>" +
206 "<p>Please choose another.</p>");
207
208 }
209 });
210
211 setDisplayName("Rimauresq");
212 }
213
214 public boolean logSQL() {
215 return false;
216 }
217
218 public Capability getCanAdminister() {
219 return administerCapability();
220 }
221
222
223
224
225 public Page getHomePage() {
226 return homePage;
227 }
228
229
230
231 public Page getThanksPage() {
232 return thanksPage;
233 }
234
235
236
237 public String getNewsAdminEmail() {
238 return newsAdminEmail.getValue();
239 }
240
241
242
243 public String getNewsAdminName() {
244 return newsAdminName.getValue();
245 }
246
247
248
249
250 public UploadedImage getOtherDbImage() {
251 return otherDbImage;
252 }
253
254
255
256
257 public String getOtherDbName() {
258 return otherDbName.getValue();
259 }
260
261
262
263
264 public String getThisDbName() {
265 return thisDbName.getValue();
266 }
267
268
269
270
271 public String getOtherDbHomePageUrl() {
272 return otherDbHomePageUrl.getValue();
273 }
274
275
276
277
278 public String getQuantityText() {
279 return quantity.getValue();
280 }
281
282
283
284 public String getEditText() {
285 return edit.getValue();
286 }
287
288
289
290
291
292
293
294
295 public String templateName(String key) {
296 String templateResourceName = "/org/paneris/rimauresq/view/" + getThisDbName() + "/" + key + ".wm";
297 if (this.getClass().getResource(templateResourceName) == null) {
298 templateResourceName = "/org/paneris/rimauresq/view/" + key + ".wm";
299 }
300
301 return templateResourceName;
302 }
303
304
305
306
307 public Div getColophon() {
308 return colophon;
309 }
310
311
312
313
314 public Div getComment() {
315 return comment;
316 }
317
318
319
320
321
322
323
324 public String getText(String settingName) {
325 Setting s = (Setting)getSettingTable().ensure(
326 settingName,
327 settingName,
328 settingName,
329 settingName);
330 return s.getValue();
331 }
332
333
334
335
336 public Template getThanksTemplate() {
337 return thanksTemplate;
338 }
339
340
341
342
343 public Div getIllogical() {
344 return illogical;
345 }
346
347
348
349
350 public Div getOrderThanks() {
351 return orderThanks;
352 }
353
354
355
356
357 public Div getNewsThanks() {
358 return newsThanks;
359 }
360
361
362
363
364 public Div getSent() {
365 return sent;
366 }
367
368
369
370
371 public Setting getConfirm() {
372 return confirm;
373 }
374
375
376
377
378 public UploadedFileType getHtml() {
379 return html;
380 }
381
382
383
384
385 public UploadedFileType getJpg() {
386 return jpg;
387 }
388
389
390
391
392 public UploadedFileType getWm() {
393 return wm;
394 }
395
396
397
398 public UploadedFileType getPdf() {
399 return pdf;
400 }
401
402
403
404
405 public Div getDuplicateLogin() {
406 return duplicateLogin;
407 }
408
409
410
411 public String getDescription() {
412 return description.getValue();
413 }
414
415
416
417 public String getKeywords() {
418 return keywords.getValue();
419 }
420
421 public String getJavaName() {
422 return StringUtils.capitalised(getName());
423 }
424 }