1 package org.melati.admin.test;
2
3 import org.melati.admin.test.generated.ChildTableBase;
4 import org.melati.poem.DefinitionSource;
5 import org.melati.poem.Database;
6 import org.melati.poem.PoemException;
7
8 /**
9 * Melati POEM generated, programmer modifiable stub
10 * for a <code>ChildTable</code> object.
11 *
12 *
13 * <table>
14 * <caption>
15 * Field summary for SQL table <code>Child</code>
16 * </caption>
17 * <tr><th>Name</th><th>Type</th><th>Description</th></tr>
18 * <tr><td> id </td><td> Integer </td><td> </td></tr>
19 * <tr><td> parent </td><td> Parent </td><td> </td></tr>
20 * <tr><td> name </td><td> String </td><td> The name </td></tr>
21 * <tr><td> image </td><td> UploadedImage </td><td> </td></tr>
22 * <tr><td> deleted </td><td> Boolean </td><td> </td></tr>
23 * </table>
24 *
25 * See org.melati.poem.prepro.TableDef#generateTableJava
26 */
27 public class ChildTable<T extends Child> extends ChildTableBase<Child> {
28
29 /**
30 * Constructor.
31 *
32 * @see org.melati.poem.prepro.TableDef#generateTableJava
33 * @param database the POEM database we are using
34 * @param name the name of this <code>Table</code>
35 * @param definitionSource which definition is being used
36 * @throws PoemException if anything goes wrong
37 */
38 public ChildTable(
39 Database database, String name,
40 DefinitionSource definitionSource) throws PoemException {
41 super(database, name, definitionSource);
42 }
43
44 // programmer's domain-specific code here
45
46 public Child ensure(Parent parent, String name) {
47 Child p = (Child)getNameColumn().firstWhereEq(name);
48 if (p == null) {
49 p = (Child)newPersistent();
50 p.setName(name);
51 p.setParent(parent);
52 p.setDeleted(Boolean.FALSE);
53 getNameColumn().ensure(p);
54 }
55 return p;
56 }
57
58 }
59