%line | %branch | |||||||||
---|---|---|---|---|---|---|---|---|---|---|
org.apache.turbine.services.security.torque.om.BaseTurbinePermission |
|
|
1 | package org.apache.turbine.services.security.torque.om; |
|
2 | ||
3 | ||
4 | import java.math.BigDecimal; |
|
5 | import java.sql.Connection; |
|
6 | import java.util.ArrayList; |
|
7 | import java.util.Collections; |
|
8 | import java.util.Date; |
|
9 | import java.util.List; |
|
10 | ||
11 | import org.apache.commons.lang.ObjectUtils; |
|
12 | import org.apache.torque.TorqueException; |
|
13 | import org.apache.torque.om.BaseObject; |
|
14 | import org.apache.torque.om.ComboKey; |
|
15 | import org.apache.torque.om.DateKey; |
|
16 | import org.apache.torque.om.NumberKey; |
|
17 | import org.apache.torque.om.ObjectKey; |
|
18 | import org.apache.torque.om.SimpleKey; |
|
19 | import org.apache.torque.om.StringKey; |
|
20 | import org.apache.torque.om.Persistent; |
|
21 | import org.apache.torque.util.Criteria; |
|
22 | import org.apache.torque.util.Transaction; |
|
23 | ||
24 | ||
25 | /** |
|
26 | * This class was autogenerated by Torque on: |
|
27 | * |
|
28 | * [Mon Oct 03 14:24:58 CEST 2005] |
|
29 | * |
|
30 | * You should not use this class directly. It should not even be |
|
31 | * extended all references should be to TurbinePermission |
|
32 | */ |
|
33 | 468 | public abstract class BaseTurbinePermission extends BaseObject |
34 | { |
|
35 | /** The Peer class */ |
|
36 | 24 | private static final TurbinePermissionPeer peer = |
37 | new TurbinePermissionPeer(); |
|
38 | ||
39 | ||
40 | /** The value for the permissionId field */ |
|
41 | private int permissionId; |
|
42 | ||
43 | /** The value for the name field */ |
|
44 | private String name; |
|
45 | ||
46 | ||
47 | /** |
|
48 | * Get the PermissionId |
|
49 | * |
|
50 | * @return int |
|
51 | */ |
|
52 | public int getPermissionId() |
|
53 | { |
|
54 | 1650 | return permissionId; |
55 | } |
|
56 | ||
57 | ||
58 | /** |
|
59 | * Set the value of PermissionId |
|
60 | * |
|
61 | * @param v new value |
|
62 | */ |
|
63 | public void setPermissionId(int v) throws TorqueException |
|
64 | { |
|
65 | ||
66 | 298 | if (this.permissionId != v) |
67 | { |
|
68 | 298 | this.permissionId = v; |
69 | 298 | setModified(true); |
70 | } |
|
71 | ||
72 | ||
73 | ||
74 | // update associated TurbineRolePermission |
|
75 | 298 | if (collTurbineRolePermissions != null) |
76 | { |
|
77 | 0 | for (int i = 0; i < collTurbineRolePermissions.size(); i++) |
78 | { |
|
79 | 0 | ((TurbineRolePermission) collTurbineRolePermissions.get(i)) |
80 | .setPermissionId(v); |
|
81 | } |
|
82 | } |
|
83 | 298 | } |
84 | ||
85 | /** |
|
86 | * Get the Name |
|
87 | * |
|
88 | * @return String |
|
89 | */ |
|
90 | public String getName() |
|
91 | { |
|
92 | 384 | return name; |
93 | } |
|
94 | ||
95 | ||
96 | /** |
|
97 | * Set the value of Name |
|
98 | * |
|
99 | * @param v new value |
|
100 | */ |
|
101 | public void setName(String v) |
|
102 | { |
|
103 | ||
104 | 312 | if (!ObjectUtils.equals(this.name, v)) |
105 | { |
|
106 | 312 | this.name = v; |
107 | 312 | setModified(true); |
108 | } |
|
109 | ||
110 | ||
111 | 312 | } |
112 | ||
113 | ||
114 | ||
115 | ||
116 | /** |
|
117 | * Collection to store aggregation of collTurbineRolePermissions |
|
118 | */ |
|
119 | protected List collTurbineRolePermissions; |
|
120 | ||
121 | /** |
|
122 | * Temporary storage of collTurbineRolePermissions to save a possible db hit in |
|
123 | * the event objects are add to the collection, but the |
|
124 | * complete collection is never requested. |
|
125 | */ |
|
126 | protected void initTurbineRolePermissions() |
|
127 | { |
|
128 | 0 | if (collTurbineRolePermissions == null) |
129 | { |
|
130 | 0 | collTurbineRolePermissions = new ArrayList(); |
131 | } |
|
132 | 0 | } |
133 | ||
134 | /** |
|
135 | * Method called to associate a TurbineRolePermission object to this object |
|
136 | * through the TurbineRolePermission foreign key attribute |
|
137 | * |
|
138 | * @param l TurbineRolePermission |
|
139 | * @throws TorqueException |
|
140 | */ |
|
141 | public void addTurbineRolePermission(TurbineRolePermission l) throws TorqueException |
|
142 | { |
|
143 | 0 | getTurbineRolePermissions().add(l); |
144 | 0 | l.setTurbinePermission((TurbinePermission) this); |
145 | 0 | } |
146 | ||
147 | /** |
|
148 | * The criteria used to select the current contents of collTurbineRolePermissions |
|
149 | */ |
|
150 | 312 | private Criteria lastTurbineRolePermissionsCriteria = null; |
151 | ||
152 | /** |
|
153 | * If this collection has already been initialized, returns |
|
154 | * the collection. Otherwise returns the results of |
|
155 | * getTurbineRolePermissions(new Criteria()) |
|
156 | * |
|
157 | * @throws TorqueException |
|
158 | */ |
|
159 | public List getTurbineRolePermissions() throws TorqueException |
|
160 | { |
|
161 | 0 | if (collTurbineRolePermissions == null) |
162 | { |
|
163 | 0 | collTurbineRolePermissions = getTurbineRolePermissions(new Criteria(10)); |
164 | } |
|
165 | 0 | return collTurbineRolePermissions; |
166 | } |
|
167 | ||
168 | /** |
|
169 | * If this collection has already been initialized with |
|
170 | * an identical criteria, it returns the collection. |
|
171 | * Otherwise if this TurbinePermission has previously |
|
172 | * been saved, it will retrieve related TurbineRolePermissions from storage. |
|
173 | * If this TurbinePermission is new, it will return |
|
174 | * an empty collection or the current collection, the criteria |
|
175 | * is ignored on a new object. |
|
176 | * |
|
177 | * @throws TorqueException |
|
178 | */ |
|
179 | public List getTurbineRolePermissions(Criteria criteria) throws TorqueException |
|
180 | { |
|
181 | 0 | if (collTurbineRolePermissions == null) |
182 | { |
|
183 | 0 | if (isNew()) |
184 | { |
|
185 | 0 | collTurbineRolePermissions = new ArrayList(); |
186 | } |
|
187 | else |
|
188 | { |
|
189 | 0 | criteria.add(TurbineRolePermissionPeer.PERMISSION_ID, getPermissionId() ); |
190 | 0 | collTurbineRolePermissions = TurbineRolePermissionPeer.doSelect(criteria); |
191 | } |
|
192 | } |
|
193 | else |
|
194 | { |
|
195 | // criteria has no effect for a new object |
|
196 | 0 | if (!isNew()) |
197 | { |
|
198 | // the following code is to determine if a new query is |
|
199 | // called for. If the criteria is the same as the last |
|
200 | // one, just return the collection. |
|
201 | 0 | criteria.add(TurbineRolePermissionPeer.PERMISSION_ID, getPermissionId()); |
202 | 0 | if (!lastTurbineRolePermissionsCriteria.equals(criteria)) |
203 | { |
|
204 | 0 | collTurbineRolePermissions = TurbineRolePermissionPeer.doSelect(criteria); |
205 | } |
|
206 | } |
|
207 | } |
|
208 | 0 | lastTurbineRolePermissionsCriteria = criteria; |
209 | ||
210 | 0 | return collTurbineRolePermissions; |
211 | } |
|
212 | ||
213 | /** |
|
214 | * If this collection has already been initialized, returns |
|
215 | * the collection. Otherwise returns the results of |
|
216 | * getTurbineRolePermissions(new Criteria(),Connection) |
|
217 | * This method takes in the Connection also as input so that |
|
218 | * referenced objects can also be obtained using a Connection |
|
219 | * that is taken as input |
|
220 | */ |
|
221 | public List getTurbineRolePermissions(Connection con) throws TorqueException |
|
222 | { |
|
223 | 0 | if (collTurbineRolePermissions == null) |
224 | { |
|
225 | 0 | collTurbineRolePermissions = getTurbineRolePermissions(new Criteria(10), con); |
226 | } |
|
227 | 0 | return collTurbineRolePermissions; |
228 | } |
|
229 | ||
230 | /** |
|
231 | * If this collection has already been initialized with |
|
232 | * an identical criteria, it returns the collection. |
|
233 | * Otherwise if this TurbinePermission has previously |
|
234 | * been saved, it will retrieve related TurbineRolePermissions from storage. |
|
235 | * If this TurbinePermission is new, it will return |
|
236 | * an empty collection or the current collection, the criteria |
|
237 | * is ignored on a new object. |
|
238 | * This method takes in the Connection also as input so that |
|
239 | * referenced objects can also be obtained using a Connection |
|
240 | * that is taken as input |
|
241 | */ |
|
242 | public List getTurbineRolePermissions(Criteria criteria, Connection con) |
|
243 | throws TorqueException |
|
244 | { |
|
245 | 0 | if (collTurbineRolePermissions == null) |
246 | { |
|
247 | 0 | if (isNew()) |
248 | { |
|
249 | 0 | collTurbineRolePermissions = new ArrayList(); |
250 | } |
|
251 | else |
|
252 | { |
|
253 | 0 | criteria.add(TurbineRolePermissionPeer.PERMISSION_ID, getPermissionId()); |
254 | 0 | collTurbineRolePermissions = TurbineRolePermissionPeer.doSelect(criteria, con); |
255 | } |
|
256 | } |
|
257 | else |
|
258 | { |
|
259 | // criteria has no effect for a new object |
|
260 | 0 | if (!isNew()) |
261 | { |
|
262 | // the following code is to determine if a new query is |
|
263 | // called for. If the criteria is the same as the last |
|
264 | // one, just return the collection. |
|
265 | 0 | criteria.add(TurbineRolePermissionPeer.PERMISSION_ID, getPermissionId()); |
266 | 0 | if (!lastTurbineRolePermissionsCriteria.equals(criteria)) |
267 | { |
|
268 | 0 | collTurbineRolePermissions = TurbineRolePermissionPeer.doSelect(criteria, con); |
269 | } |
|
270 | } |
|
271 | } |
|
272 | 0 | lastTurbineRolePermissionsCriteria = criteria; |
273 | ||
274 | 0 | return collTurbineRolePermissions; |
275 | } |
|
276 | ||
277 | ||
278 | ||
279 | ||
280 | ||
281 | ||
282 | ||
283 | ||
284 | ||
285 | ||
286 | ||
287 | /** |
|
288 | * If this collection has already been initialized with |
|
289 | * an identical criteria, it returns the collection. |
|
290 | * Otherwise if this TurbinePermission is new, it will return |
|
291 | * an empty collection; or if this TurbinePermission has previously |
|
292 | * been saved, it will retrieve related TurbineRolePermissions from storage. |
|
293 | * |
|
294 | * This method is protected by default in order to keep the public |
|
295 | * api reasonable. You can provide public methods for those you |
|
296 | * actually need in TurbinePermission. |
|
297 | */ |
|
298 | protected List getTurbineRolePermissionsJoinTurbineRole(Criteria criteria) |
|
299 | throws TorqueException |
|
300 | { |
|
301 | 0 | if (collTurbineRolePermissions == null) |
302 | { |
|
303 | 0 | if (isNew()) |
304 | { |
|
305 | 0 | collTurbineRolePermissions = new ArrayList(); |
306 | } |
|
307 | else |
|
308 | { |
|
309 | 0 | criteria.add(TurbineRolePermissionPeer.PERMISSION_ID, getPermissionId()); |
310 | 0 | collTurbineRolePermissions = TurbineRolePermissionPeer.doSelectJoinTurbineRole(criteria); |
311 | } |
|
312 | } |
|
313 | else |
|
314 | { |
|
315 | // the following code is to determine if a new query is |
|
316 | // called for. If the criteria is the same as the last |
|
317 | // one, just return the collection. |
|
318 | ||
319 | 0 | criteria.add(TurbineRolePermissionPeer.PERMISSION_ID, getPermissionId()); |
320 | 0 | if (!lastTurbineRolePermissionsCriteria.equals(criteria)) |
321 | { |
|
322 | 0 | collTurbineRolePermissions = TurbineRolePermissionPeer.doSelectJoinTurbineRole(criteria); |
323 | } |
|
324 | } |
|
325 | 0 | lastTurbineRolePermissionsCriteria = criteria; |
326 | ||
327 | 0 | return collTurbineRolePermissions; |
328 | } |
|
329 | ||
330 | ||
331 | ||
332 | ||
333 | ||
334 | ||
335 | ||
336 | ||
337 | ||
338 | /** |
|
339 | * If this collection has already been initialized with |
|
340 | * an identical criteria, it returns the collection. |
|
341 | * Otherwise if this TurbinePermission is new, it will return |
|
342 | * an empty collection; or if this TurbinePermission has previously |
|
343 | * been saved, it will retrieve related TurbineRolePermissions from storage. |
|
344 | * |
|
345 | * This method is protected by default in order to keep the public |
|
346 | * api reasonable. You can provide public methods for those you |
|
347 | * actually need in TurbinePermission. |
|
348 | */ |
|
349 | protected List getTurbineRolePermissionsJoinTurbinePermission(Criteria criteria) |
|
350 | throws TorqueException |
|
351 | { |
|
352 | 0 | if (collTurbineRolePermissions == null) |
353 | { |
|
354 | 0 | if (isNew()) |
355 | { |
|
356 | 0 | collTurbineRolePermissions = new ArrayList(); |
357 | } |
|
358 | else |
|
359 | { |
|
360 | 0 | criteria.add(TurbineRolePermissionPeer.PERMISSION_ID, getPermissionId()); |
361 | 0 | collTurbineRolePermissions = TurbineRolePermissionPeer.doSelectJoinTurbinePermission(criteria); |
362 | } |
|
363 | } |
|
364 | else |
|
365 | { |
|
366 | // the following code is to determine if a new query is |
|
367 | // called for. If the criteria is the same as the last |
|
368 | // one, just return the collection. |
|
369 | ||
370 | 0 | criteria.add(TurbineRolePermissionPeer.PERMISSION_ID, getPermissionId()); |
371 | 0 | if (!lastTurbineRolePermissionsCriteria.equals(criteria)) |
372 | { |
|
373 | 0 | collTurbineRolePermissions = TurbineRolePermissionPeer.doSelectJoinTurbinePermission(criteria); |
374 | } |
|
375 | } |
|
376 | 0 | lastTurbineRolePermissionsCriteria = criteria; |
377 | ||
378 | 0 | return collTurbineRolePermissions; |
379 | } |
|
380 | ||
381 | ||
382 | ||
383 | ||
384 | 16 | private static List fieldNames = null; |
385 | ||
386 | /** |
|
387 | * Generate a list of field names. |
|
388 | * |
|
389 | * @return a list of field names |
|
390 | */ |
|
391 | public static synchronized List getFieldNames() |
|
392 | { |
|
393 | 0 | if (fieldNames == null) |
394 | { |
|
395 | 0 | fieldNames = new ArrayList(); |
396 | 0 | fieldNames.add("PermissionId"); |
397 | 0 | fieldNames.add("Name"); |
398 | 0 | fieldNames = Collections.unmodifiableList(fieldNames); |
399 | } |
|
400 | 0 | return fieldNames; |
401 | } |
|
402 | ||
403 | /** |
|
404 | * Retrieves a field from the object by name passed in as a String. |
|
405 | * |
|
406 | * @param name field name |
|
407 | * @return value |
|
408 | */ |
|
409 | public Object getByName(String name) |
|
410 | { |
|
411 | 0 | if (name.equals("PermissionId")) |
412 | { |
|
413 | 0 | return new Integer(getPermissionId()); |
414 | } |
|
415 | 0 | if (name.equals("Name")) |
416 | { |
|
417 | 0 | return getName(); |
418 | } |
|
419 | 0 | return null; |
420 | } |
|
421 | ||
422 | /** |
|
423 | * Retrieves a field from the object by name passed in |
|
424 | * as a String. The String must be one of the static |
|
425 | * Strings defined in this Class' Peer. |
|
426 | * |
|
427 | * @param name peer name |
|
428 | * @return value |
|
429 | */ |
|
430 | public Object getByPeerName(String name) |
|
431 | { |
|
432 | 0 | if (name.equals(TurbinePermissionPeer.PERMISSION_ID)) |
433 | { |
|
434 | 0 | return new Integer(getPermissionId()); |
435 | } |
|
436 | 0 | if (name.equals(TurbinePermissionPeer.PERMISSION_NAME)) |
437 | { |
|
438 | 0 | return getName(); |
439 | } |
|
440 | 0 | return null; |
441 | } |
|
442 | ||
443 | /** |
|
444 | * Retrieves a field from the object by Position as specified |
|
445 | * in the xml schema. Zero-based. |
|
446 | * |
|
447 | * @param pos position in xml schema |
|
448 | * @return value |
|
449 | */ |
|
450 | public Object getByPosition(int pos) |
|
451 | { |
|
452 | 0 | if (pos == 0) |
453 | { |
|
454 | 0 | return new Integer(getPermissionId()); |
455 | } |
|
456 | 0 | if (pos == 1) |
457 | { |
|
458 | 0 | return getName(); |
459 | } |
|
460 | 0 | return null; |
461 | } |
|
462 | ||
463 | /** |
|
464 | * Stores the object in the database. If the object is new, |
|
465 | * it inserts it; otherwise an update is performed. |
|
466 | * |
|
467 | * @throws Exception |
|
468 | */ |
|
469 | public void save() throws Exception |
|
470 | { |
|
471 | 0 | save(TurbinePermissionPeer.getMapBuilder() |
472 | .getDatabaseMap().getName()); |
|
473 | 0 | } |
474 | ||
475 | /** |
|
476 | * Stores the object in the database. If the object is new, |
|
477 | * it inserts it; otherwise an update is performed. |
|
478 | * Note: this code is here because the method body is |
|
479 | * auto-generated conditionally and therefore needs to be |
|
480 | * in this file instead of in the super class, BaseObject. |
|
481 | * |
|
482 | * @param dbName |
|
483 | * @throws TorqueException |
|
484 | */ |
|
485 | public void save(String dbName) throws TorqueException |
|
486 | { |
|
487 | 0 | Connection con = null; |
488 | try |
|
489 | { |
|
490 | 0 | con = Transaction.begin(dbName); |
491 | 0 | save(con); |
492 | 0 | Transaction.commit(con); |
493 | } |
|
494 | 0 | catch(TorqueException e) |
495 | { |
|
496 | 0 | Transaction.safeRollback(con); |
497 | 0 | throw e; |
498 | 0 | } |
499 | 0 | } |
500 | ||
501 | /** flag to prevent endless save loop, if this object is referenced |
|
502 | by another object which falls in this transaction. */ |
|
503 | 312 | private boolean alreadyInSave = false; |
504 | /** |
|
505 | * Stores the object in the database. If the object is new, |
|
506 | * it inserts it; otherwise an update is performed. This method |
|
507 | * is meant to be used as part of a transaction, otherwise use |
|
508 | * the save() method and the connection details will be handled |
|
509 | * internally |
|
510 | * |
|
511 | * @param con |
|
512 | * @throws TorqueException |
|
513 | */ |
|
514 | public void save(Connection con) throws TorqueException |
|
515 | { |
|
516 | 0 | if (!alreadyInSave) |
517 | { |
|
518 | 0 | alreadyInSave = true; |
519 | ||
520 | ||
521 | ||
522 | // If this object has been modified, then save it to the database. |
|
523 | 0 | if (isModclass="keyword">ified()) |
524 | { |
|
525 | 0 | if (isNew()) |
526 | { |
|
527 | 0 | TurbinePermissionPeer.doInsert((TurbinePermission) this, con); |
528 | 0 | setNew(false); |
529 | } |
|
530 | else |
|
531 | { |
|
532 | 0 | TurbinePermissionPeer.doUpdate((TurbinePermission) this, con); |
533 | } |
|
534 | } |
|
535 | ||
536 | ||
537 | ||
538 | 0 | if (collTurbineRolePermissions != null) |
539 | { |
|
540 | 0 | for (int i = 0; i < collTurbineRolePermissions.size(); i++) |
541 | { |
|
542 | 0 | ((TurbineRolePermission) collTurbineRolePermissions.get(i)).save(con); |
543 | } |
|
544 | } |
|
545 | 0 | alreadyInSave = false; |
546 | } |
|
547 | 0 | } |
548 | ||
549 | ||
550 | /** |
|
551 | * Set the PrimaryKey using ObjectKey. |
|
552 | * |
|
553 | * @param key permissionId ObjectKey |
|
554 | */ |
|
555 | public void setPrimaryKey(ObjectKey key) |
|
556 | throws TorqueException |
|
557 | { |
|
558 | 0 | setPermissionId(((NumberKey) key).intValue()); |
559 | 0 | } |
560 | ||
561 | /** |
|
562 | * Set the PrimaryKey using a String. |
|
563 | * |
|
564 | * @param key |
|
565 | */ |
|
566 | public void setPrimaryKey(String key) throws TorqueException |
|
567 | { |
|
568 | 0 | setPermissionId(Integer.parseInt(key)); |
569 | 0 | } |
570 | ||
571 | ||
572 | /** |
|
573 | * returns an id that differentiates this object from others |
|
574 | * of its class. |
|
575 | */ |
|
576 | public ObjectKey getPrimaryKey() |
|
577 | { |
|
578 | 1316 | return SimpleKey.keyFor(getPermissionId()); |
579 | } |
|
580 | ||
581 | ||
582 | /** |
|
583 | * Makes a copy of this object. |
|
584 | * It creates a new object filling in the simple attributes. |
|
585 | * It then fills all the association collections and sets the |
|
586 | * related objects to isNew=true. |
|
587 | */ |
|
588 | public TurbinePermission copy() throws TorqueException |
|
589 | { |
|
590 | 0 | return copyInto(new TurbinePermission()); |
591 | } |
|
592 | ||
593 | protected TurbinePermission copyInto(TurbinePermission copyObj) throws TorqueException |
|
594 | { |
|
595 | 0 | copyObj.setPermissionId(permissionId); |
596 | 0 | copyObj.setName(name); |
597 | ||
598 | 0 | copyObj.setPermissionId( 0); |
599 | ||
600 | ||
601 | ||
602 | 0 | List v = getTurbineRolePermissions(); |
603 | 0 | for (int i = 0; i < v.size(); i++) |
604 | { |
|
605 | 0 | TurbineRolePermission obj = (TurbineRolePermission) v.get(i); |
606 | 0 | copyObj.addTurbineRolePermission(obj.copy()); |
607 | } |
|
608 | 0 | return copyObj; |
609 | } |
|
610 | ||
611 | /** |
|
612 | * returns a peer instance associated with this om. Since Peer classes |
|
613 | * are not to have any instance attributes, this method returns the |
|
614 | * same instance for all member of this class. The method could therefore |
|
615 | * be static, but this would prevent one from overriding the behavior. |
|
616 | */ |
|
617 | public TurbinePermissionPeer getPeer() |
|
618 | { |
|
619 | 0 | return peer; |
620 | } |
|
621 | ||
622 | public String toString() |
|
623 | { |
|
624 | 0 | StringBuffer str = new StringBuffer(); |
625 | 0 | str.append("TurbinePermission:\n"); |
626 | 0 | str.append("PermissionId = ") |
627 | .append(getPermissionId()) |
|
628 | .append("\n"); |
|
629 | 0 | str.append("Name = ") |
630 | .append(getName()) |
|
631 | .append("\n"); |
|
632 | 0 | return(str.toString()); |
633 | } |
|
634 | } |
This report is generated by jcoverage, Maven and Maven JCoverage Plugin. |