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