1 // Do not edit this file! It was generated by Melati POEM's DSD preprocessor.
2
3 package org.paneris.bibliomania.generated;
4
5
6 import java.util.Collections;
7 import java.util.Enumeration;
8 import java.util.List;
9 import org.melati.poem.AccessPoemException;
10 import org.melati.poem.CachedSelection;
11 import org.melati.poem.Column;
12 import org.melati.poem.Field;
13 import org.melati.poem.JdbcPersistent;
14 import org.melati.poem.ValidationPoemException;
15 import org.melati.poem.util.EmptyEnumeration;
16 import org.paneris.bibliomania.BibliomaniaDatabaseTables;
17 import org.paneris.bibliomania.Download;
18 import org.paneris.bibliomania.DownloadEvent;
19 import org.paneris.bibliomania.DownloadTable;
20 import org.paneris.bibliomania.Product;
21
22
23 /**
24 * Melati POEM generated abstract base class for a <code>Persistent</code>
25 * <code>Download</code> Object.
26 *
27 * see org.melati.poem.prepro.TableDef#generatePersistentBaseJava
28 */
29 public abstract class DownloadBase extends JdbcPersistent {
30
31
32 /**
33 * Retrieves the Database object.
34 *
35 * see org.melati.poem.prepro.TableDef#generatePersistentBaseJava
36 * @return the database
37 */
38 public BibliomaniaDatabaseTables getBibliomaniaDatabaseTables() {
39 return (BibliomaniaDatabaseTables)getDatabase();
40 }
41
42
43 /**
44 * Retrieves the <code>DownloadTable</code> table
45 * which this <code>Persistent</code> is from.
46 *
47 * see org.melati.poem.prepro.TableDef#generatePersistentBaseJava
48 * @return the DownloadTable
49 */
50 @SuppressWarnings("unchecked")
51 public DownloadTable<Download> getDownloadTable() {
52 return (DownloadTable<Download>)getTable();
53 }
54
55 @SuppressWarnings("unchecked")
56 private DownloadTable<Download> _getDownloadTable() {
57 return (DownloadTable<Download>)getTable();
58 }
59
60 // Fields in this table
61 /**
62 * id
63 */
64 protected Integer id;
65 /**
66 * File Name - A file which can be downloaded
67 */
68 protected String filename;
69
70
71 /**
72 * Retrieves the <code>Id</code> value, without locking,
73 * for this <code>Download</code> <code>Persistent</code>.
74 *
75 * see org.melati.poem.prepro.FieldDef#generateBaseMethods
76 * @return the Integer id
77 */
78 public Integer getId_unsafe() {
79 return id;
80 }
81
82
83 /**
84 * Sets the <code>Id</code> value directly, without checking,
85 * for this Download <code>Persistent</code>.
86 *
87 * see org.melati.poem.prepro.FieldDef#generateBaseMethods
88 * @param cooked the pre-validated value to set
89 */
90 public void setId_unsafe(Integer cooked) {
91 id = cooked;
92 }
93
94 /**
95 * Retrieves the Id value, with locking, for this
96 * <code>Download</code> <code>Persistent</code>.
97 *
98 * Generated by org.melati.poem.prepro.AtomFieldDef#generateBaseMethods
99 * @throws AccessPoemException
100 * if the current <code>AccessToken</code>
101 * does not confer write access rights
102 * @return the value of the field <code>Id</code> for this
103 * <code>Download</code> <code>Persistent</code>
104 */
105
106 public Integer getId()
107 throws AccessPoemException {
108 readLock();
109 return getId_unsafe();
110 }
111
112
113 /**
114 * Sets the <code>Id</code> value, with checking, for this
115 * <code>Download</code> <code>Persistent</code>.
116 *
117 * Generated by org.melati.poem.prepro.AtomFieldDef#generateBaseMethods
118 * @param cooked a validated <code>int</code>
119 * @throws AccessPoemException
120 * if the current <code>AccessToken</code>
121 * does not confer write access rights
122 * @throws ValidationPoemException
123 * if the value is not valid
124 */
125 public void setId(Integer cooked)
126 throws AccessPoemException, ValidationPoemException {
127 _getDownloadTable().getIdColumn().
128 getType().assertValidCooked(cooked);
129 writeLock();
130 setId_unsafe(cooked);
131 }
132
133 /**
134 * Sets the <code>Id</code> value, with checking, for this
135 * <code>Download</code> <code>Persistent</code>.
136 *
137 * Generated by org.melati.poem.prepro.IntegerFieldDef#generateBaseMethods
138 * @param cooked a validated <code>int</code>
139 * @throws AccessPoemException
140 * if the current <code>AccessToken</code>
141 * does not confer write access rights
142 * @throws ValidationPoemException
143 * if the value is not valid
144 */
145
146 public final void setId(int cooked)
147 throws AccessPoemException, ValidationPoemException {
148 setId(new Integer(cooked));
149 }
150
151
152 /**
153 * Retrieves the <code>Id</code> value as a <code>Field</code>
154 * from this <code>Download</code> <code>Persistent</code>.
155 *
156 * see org.melati.poem.prepro.FieldDef#generateFieldCreator
157 * @throws AccessPoemException
158 * if the current <code>AccessToken</code>
159 * does not confer write access rights
160 * @return the Integer id
161 */
162 public Field<Integer> getIdField() throws AccessPoemException {
163 Column<Integer> c = _getDownloadTable().getIdColumn();
164 return new Field<Integer>((Integer)c.getRaw(this), c);
165 }
166
167
168 /**
169 * Retrieves the <code>Filename</code> value, without locking,
170 * for this <code>Download</code> <code>Persistent</code>.
171 *
172 * see org.melati.poem.prepro.FieldDef#generateBaseMethods
173 * @return the String filename
174 */
175 public String getFilename_unsafe() {
176 return filename;
177 }
178
179
180 /**
181 * Sets the <code>Filename</code> value directly, without checking,
182 * for this Download <code>Persistent</code>.
183 *
184 * see org.melati.poem.prepro.FieldDef#generateBaseMethods
185 * @param cooked the pre-validated value to set
186 */
187 public void setFilename_unsafe(String cooked) {
188 filename = cooked;
189 }
190
191 /**
192 * Retrieves the Filename value, with locking, for this
193 * <code>Download</code> <code>Persistent</code>.
194 * Field description:
195 * A file which can be downloaded
196 *
197 * Generated by org.melati.poem.prepro.AtomFieldDef#generateBaseMethods
198 * @throws AccessPoemException
199 * if the current <code>AccessToken</code>
200 * does not confer write access rights
201 * @return the value of the field <code>Filename</code> for this
202 * <code>Download</code> <code>Persistent</code>
203 */
204
205 public String getFilename()
206 throws AccessPoemException {
207 readLock();
208 return getFilename_unsafe();
209 }
210
211
212 /**
213 * Sets the <code>Filename</code> value, with checking, for this
214 * <code>Download</code> <code>Persistent</code>.
215 * Field description:
216 * A file which can be downloaded
217 *
218 * Generated by org.melati.poem.prepro.AtomFieldDef#generateBaseMethods
219 * @param cooked a validated <code>int</code>
220 * @throws AccessPoemException
221 * if the current <code>AccessToken</code>
222 * does not confer write access rights
223 * @throws ValidationPoemException
224 * if the value is not valid
225 */
226 public void setFilename(String cooked)
227 throws AccessPoemException, ValidationPoemException {
228 _getDownloadTable().getFilenameColumn().
229 getType().assertValidCooked(cooked);
230 writeLock();
231 setFilename_unsafe(cooked);
232 }
233
234
235 /**
236 * Retrieves the <code>Filename</code> value as a <code>Field</code>
237 * from this <code>Download</code> <code>Persistent</code>.
238 *
239 * see org.melati.poem.prepro.FieldDef#generateFieldCreator
240 * @throws AccessPoemException
241 * if the current <code>AccessToken</code>
242 * does not confer write access rights
243 * @return the String filename
244 */
245 public Field<String> getFilenameField() throws AccessPoemException {
246 Column<String> c = _getDownloadTable().getFilenameColumn();
247 return new Field<String>((String)c.getRaw(this), c);
248 }
249
250 private CachedSelection<Product> downloadProducts = null;
251 /** References to this Download in the Product table via its download field.*/
252 @SuppressWarnings("unchecked")
253 public Enumeration<Product> getDownloadProducts() {
254 if (getTroid() == null)
255 return new EmptyEnumeration<Product>();
256 else {
257 if (downloadProducts == null)
258 downloadProducts =
259 getBibliomaniaDatabaseTables().getProductTable().getDownloadColumn().cachedSelectionWhereEq(getTroid());
260 return downloadProducts.objects();
261 }
262 }
263
264
265 /** References to this Download in the Product table via its download field, as a List.*/
266 public List<Product> getDownloadProductList() {
267 return Collections.list(getDownloadProducts());
268 }
269
270
271
272 private CachedSelection<DownloadEvent> documentDownloadEvents = null;
273 /** References to this Download in the DownloadEvent table via its document field.*/
274 @SuppressWarnings("unchecked")
275 public Enumeration<DownloadEvent> getDocumentDownloadEvents() {
276 if (getTroid() == null)
277 return new EmptyEnumeration<DownloadEvent>();
278 else {
279 if (documentDownloadEvents == null)
280 documentDownloadEvents =
281 getBibliomaniaDatabaseTables().getDownloadEventTable().getDocumentColumn().cachedSelectionWhereEq(getTroid());
282 return documentDownloadEvents.objects();
283 }
284 }
285
286
287 /** References to this Download in the DownloadEvent table via its document field, as a List.*/
288 public List<DownloadEvent> getDocumentDownloadEventList() {
289 return Collections.list(getDocumentDownloadEvents());
290 }
291
292
293
294 }
295