##### Coverage Report - org.apache.turbine.services.security.torque.om.BaseTurbineGroup

Classes in this File | Line Coverage | Branch Coverage | Complexity
BaseTurbineGroup |
0% | 0/190
0% | 0/104
| 2.789473684210526;2,789

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.map.TableMap;
14 |  |
     import org.apache.torque.om.BaseObject;
15 |  |
     import org.apache.torque.om.ComboKey;
16 |  |
     import org.apache.torque.om.DateKey;
17 |  |
     import org.apache.torque.om.NumberKey;
18 |  |
     import org.apache.torque.om.ObjectKey;
19 |  |
     import org.apache.torque.om.SimpleKey;
20 |  |
     import org.apache.torque.om.StringKey;
21 |  |
     import org.apache.torque.om.Persistent;
22 |  |
     import org.apache.torque.util.Criteria;
23 |  |
     import org.apache.torque.util.Transaction;
24 |  |
25 |  |
26 |  |
27 |  |
28 |  |
29 |  |
     /**
30 |  |
      * This class was autogenerated by Torque on:
31 |  |
      *
32 |  |
      * [Thu Jun 23 17:25:46 CEST 2011]
33 |  |
      *
34 |  |
      * You should not use this class directly.  It should not even be
35 |  |
      * extended all references should be to TurbineGroup
36 |  |
      */
37 | 0 |
     public abstract class BaseTurbineGroup extends BaseObject
38 |  |
     {
39 |  |
         /** Serial version */
40 |  |
         private static final long serialVersionUID = 1308842746584L;
41 |  |
42 |  |
         /** The Peer class */
43 | 0 |
         private static final TurbineGroupPeer peer =
44 |  |
             new TurbineGroupPeer();
45 |  |
46 |  |
47 |  |
         /** The value for the groupId field */
48 |  |
         private int groupId;
49 |  |
50 |  |
         /** The value for the name field */
51 |  |
         private String name;
52 |  |
53 |  |
54 |  |
         /**
55 |  |
          * Get the GroupId
56 |  |
          *
57 |  |
          * @return int
58 |  |
          */
59 |  |
         public int getGroupId()
60 |  |
         {
61 | 0 |
             return groupId;
62 |  |
         }
63 |  |
64 |  |
65 |  |
         /**
66 |  |
          * Set the value of GroupId
67 |  |
          *
68 |  |
          * @param v new value
69 |  |
          */
70 |  |
         public void setGroupId(int v) throws TorqueException
71 |  |
         {
72 |  |
73 | 0 |
             if (this.groupId != v)
74 |  |
             {
75 | 0 |
                 this.groupId = v;
76 | 0 |
                 setModified(true);
77 |  |
             }
78 |  |
79 |  |
80 |  |
81 |  |
             // update associated TurbineUserGroupRole
82 | 0 |
             if (collTurbineUserGroupRoles != null)
83 |  |
             {
84 | 0 |
                 for (int i = 0; i < collTurbineUserGroupRoles.size(); i++)
85 |  |
                 {
86 | 0 |
                     ((TurbineUserGroupRole) collTurbineUserGroupRoles.get(i))
87 |  |
                             .setGroupId(v);
88 |  |
                 }
89 |  |
             }
90 | 0 |
         }
91 |  |
92 |  |
         /**
93 |  |
          * Get the Name
94 |  |
          *
95 |  |
          * @return String
96 |  |
          */
97 |  |
         public String getName()
98 |  |
         {
99 | 0 |
             return name;
100 |  |
         }
101 |  |
102 |  |
103 |  |
         /**
104 |  |
          * Set the value of Name
105 |  |
          *
106 |  |
          * @param v new value
107 |  |
          */
108 |  |
         public void setName(String v)
109 |  |
         {
110 |  |
111 | 0 |
             if (!ObjectUtils.equals(this.name, v))
112 |  |
             {
113 | 0 |
                 this.name = v;
114 | 0 |
                 setModified(true);
115 |  |
             }
116 |  |
117 |  |
118 | 0 |
         }
119 |  |
120 |  |
121 |  |
122 |  |
123 |  |
         /**
124 |  |
          * Collection to store aggregation of collTurbineUserGroupRoles
125 |  |
          */
126 |  |
         protected List<TurbineUserGroupRole> collTurbineUserGroupRoles;
127 |  |
128 |  |
         /**
129 |  |
          * Temporary storage of collTurbineUserGroupRoles to save a possible db hit in
130 |  |
          * the event objects are add to the collection, but the
131 |  |
          * complete collection is never requested.
132 |  |
          */
133 |  |
         protected void initTurbineUserGroupRoles()
134 |  |
         {
135 | 0 |
             if (collTurbineUserGroupRoles == null)
136 |  |
             {
137 | 0 |
                 collTurbineUserGroupRoles = new ArrayList<TurbineUserGroupRole>();
138 |  |
             }
139 | 0 |
         }
140 |  |
141 |  |
142 |  |
         /**
143 |  |
          * Method called to associate a TurbineUserGroupRole object to this object
144 |  |
          * through the TurbineUserGroupRole foreign key attribute
145 |  |
          *
146 |  |
          * @param l TurbineUserGroupRole
147 |  |
          * @throws TorqueException
148 |  |
          */
149 |  |
         public void addTurbineUserGroupRole(TurbineUserGroupRole l) throws TorqueException
150 |  |
         {
151 | 0 |
             getTurbineUserGroupRoles().add(l);
152 | 0 |
             l.setTurbineGroup((TurbineGroup) this);
153 | 0 |
         }
154 |  |
155 |  |
         /**
156 |  |
          * Method called to associate a TurbineUserGroupRole object to this object
157 |  |
          * through the TurbineUserGroupRole foreign key attribute using connection.
158 |  |
          *
159 |  |
          * @param l TurbineUserGroupRole
160 |  |
          * @throws TorqueException
161 |  |
          */
162 |  |
         public void addTurbineUserGroupRole(TurbineUserGroupRole l, Connection con) throws TorqueException
163 |  |
         {
164 | 0 |
             getTurbineUserGroupRoles(con).add(l);
165 | 0 |
             l.setTurbineGroup((TurbineGroup) this);
166 | 0 |
         }
167 |  |
168 |  |
         /**
169 |  |
          * The criteria used to select the current contents of collTurbineUserGroupRoles
170 |  |
          */
171 | 0 |
         private Criteria lastTurbineUserGroupRolesCriteria = null;
172 |  |
173 |  |
         /**
174 |  |
          * If this collection has already been initialized, returns
175 |  |
          * the collection. Otherwise returns the results of
176 |  |
          * getTurbineUserGroupRoles(new Criteria())
177 |  |
          *
178 |  |
          * @return the collection of associated objects
179 |  |
          * @throws TorqueException
180 |  |
          */
181 |  |
         public List<TurbineUserGroupRole> getTurbineUserGroupRoles()
182 |  |
             throws TorqueException
183 |  |
         {
184 | 0 |
             if (collTurbineUserGroupRoles == null)
185 |  |
             {
186 | 0 |
                 collTurbineUserGroupRoles = getTurbineUserGroupRoles(new Criteria(10));
187 |  |
             }
188 | 0 |
             return collTurbineUserGroupRoles;
189 |  |
         }
190 |  |
191 |  |
         /**
192 |  |
          * If this collection has already been initialized with
193 |  |
          * an identical criteria, it returns the collection.
194 |  |
          * Otherwise if this TurbineGroup has previously
195 |  |
          * been saved, it will retrieve related TurbineUserGroupRoles from storage.
196 |  |
          * If this TurbineGroup is new, it will return
197 |  |
          * an empty collection or the current collection, the criteria
198 |  |
          * is ignored on a new object.
199 |  |
          *
200 |  |
          * @throws TorqueException
201 |  |
          */
202 |  |
         public List<TurbineUserGroupRole> getTurbineUserGroupRoles(Criteria criteria) throws TorqueException
203 |  |
         {
204 | 0 |
             if (collTurbineUserGroupRoles == null)
205 |  |
             {
206 | 0 |
                 if (isNew())
207 |  |
                 {
208 | 0 |
                    collTurbineUserGroupRoles = new ArrayList<TurbineUserGroupRole>();
209 |  |
                 }
210 |  |
                 else
211 |  |
                 {
212 | 0 |
                     criteria.add(TurbineUserGroupRolePeer.GROUP_ID, getGroupId() );
213 | 0 |
                     collTurbineUserGroupRoles = TurbineUserGroupRolePeer.doSelect(criteria);
214 |  |
                 }
215 |  |
             }
216 |  |
             else
217 |  |
             {
218 |  |
                 // criteria has no effect for a new object
219 | 0 |
                 if (!isNew())
220 |  |
                 {
221 |  |
                     // the following code is to determine if a new query is
222 |  |
                     // called for.  If the criteria is the same as the last
223 |  |
                     // one, just return the collection.
224 | 0 |
                     criteria.add(TurbineUserGroupRolePeer.GROUP_ID, getGroupId());
225 | 0 |
                     if (!lastTurbineUserGroupRolesCriteria.equals(criteria))
226 |  |
                     {
227 | 0 |
                         collTurbineUserGroupRoles = TurbineUserGroupRolePeer.doSelect(criteria);
228 |  |
                     }
229 |  |
                 }
230 |  |
             }
231 | 0 |
             lastTurbineUserGroupRolesCriteria = criteria;
232 |  |
233 | 0 |
             return collTurbineUserGroupRoles;
234 |  |
         }
235 |  |
236 |  |
         /**
237 |  |
          * If this collection has already been initialized, returns
238 |  |
          * the collection. Otherwise returns the results of
239 |  |
          * getTurbineUserGroupRoles(new Criteria(),Connection)
240 |  |
          * This method takes in the Connection also as input so that
241 |  |
          * referenced objects can also be obtained using a Connection
242 |  |
          * that is taken as input
243 |  |
          */
244 |  |
         public List<TurbineUserGroupRole> getTurbineUserGroupRoles(Connection con) throws TorqueException
245 |  |
         {
246 | 0 |
             if (collTurbineUserGroupRoles == null)
247 |  |
             {
248 | 0 |
                 collTurbineUserGroupRoles = getTurbineUserGroupRoles(new Criteria(10), con);
249 |  |
             }
250 | 0 |
             return collTurbineUserGroupRoles;
251 |  |
         }
252 |  |
253 |  |
         /**
254 |  |
          * If this collection has already been initialized with
255 |  |
          * an identical criteria, it returns the collection.
256 |  |
          * Otherwise if this TurbineGroup has previously
257 |  |
          * been saved, it will retrieve related TurbineUserGroupRoles from storage.
258 |  |
          * If this TurbineGroup is new, it will return
259 |  |
          * an empty collection or the current collection, the criteria
260 |  |
          * is ignored on a new object.
261 |  |
          * This method takes in the Connection also as input so that
262 |  |
          * referenced objects can also be obtained using a Connection
263 |  |
          * that is taken as input
264 |  |
          */
265 |  |
         public List<TurbineUserGroupRole> getTurbineUserGroupRoles(Criteria criteria, Connection con)
266 |  |
                 throws TorqueException
267 |  |
         {
268 | 0 |
             if (collTurbineUserGroupRoles == null)
269 |  |
             {
270 | 0 |
                 if (isNew())
271 |  |
                 {
272 | 0 |
                    collTurbineUserGroupRoles = new ArrayList<TurbineUserGroupRole>();
273 |  |
                 }
274 |  |
                 else
275 |  |
                 {
276 | 0 |
                      criteria.add(TurbineUserGroupRolePeer.GROUP_ID, getGroupId());
277 | 0 |
                      collTurbineUserGroupRoles = TurbineUserGroupRolePeer.doSelect(criteria, con);
278 |  |
                  }
279 |  |
              }
280 |  |
              else
281 |  |
              {
282 |  |
                  // criteria has no effect for a new object
283 | 0 |
                  if (!isNew())
284 |  |
                  {
285 |  |
                      // the following code is to determine if a new query is
286 |  |
                      // called for.  If the criteria is the same as the last
287 |  |
                      // one, just return the collection.
288 | 0 |
                      criteria.add(TurbineUserGroupRolePeer.GROUP_ID, getGroupId());
289 | 0 |
                      if (!lastTurbineUserGroupRolesCriteria.equals(criteria))
290 |  |
                      {
291 | 0 |
                          collTurbineUserGroupRoles = TurbineUserGroupRolePeer.doSelect(criteria, con);
292 |  |
                      }
293 |  |
                  }
294 |  |
              }
295 | 0 |
              lastTurbineUserGroupRolesCriteria = criteria;
296 |  |
297 | 0 |
              return collTurbineUserGroupRoles;
298 |  |
          }
299 |  |
300 |  |
301 |  |
302 |  |
303 |  |
304 |  |
305 |  |
306 |  |
307 |  |
308 |  |
309 |  |
310 |  |
         /**
311 |  |
          * If this collection has already been initialized with
312 |  |
          * an identical criteria, it returns the collection.
313 |  |
          * Otherwise if this TurbineGroup is new, it will return
314 |  |
          * an empty collection; or if this TurbineGroup has previously
315 |  |
          * been saved, it will retrieve related TurbineUserGroupRoles from storage.
316 |  |
          *
317 |  |
          * This method is protected by default in order to keep the public
318 |  |
          * api reasonable.  You can provide public methods for those you
319 |  |
          * actually need in TurbineGroup.
320 |  |
          */
321 |  |
         protected List<TurbineUserGroupRole> getTurbineUserGroupRolesJoinTurbineUser(Criteria criteria)
322 |  |
             throws TorqueException
323 |  |
         {
324 | 0 |
             if (collTurbineUserGroupRoles == null)
325 |  |
             {
326 | 0 |
                 if (isNew())
327 |  |
                 {
328 | 0 |
                    collTurbineUserGroupRoles = new ArrayList<TurbineUserGroupRole>();
329 |  |
                 }
330 |  |
                 else
331 |  |
                 {
332 | 0 |
                     criteria.add(TurbineUserGroupRolePeer.GROUP_ID, getGroupId());
333 | 0 |
                     collTurbineUserGroupRoles = TurbineUserGroupRolePeer.doSelectJoinTurbineUser(criteria);
334 |  |
                 }
335 |  |
             }
336 |  |
             else
337 |  |
             {
338 |  |
                 // the following code is to determine if a new query is
339 |  |
                 // called for.  If the criteria is the same as the last
340 |  |
                 // one, just return the collection.
341 | 0 |
                 criteria.add(TurbineUserGroupRolePeer.GROUP_ID, getGroupId());
342 | 0 |
                 if (!lastTurbineUserGroupRolesCriteria.equals(criteria))
343 |  |
                 {
344 | 0 |
                     collTurbineUserGroupRoles = TurbineUserGroupRolePeer.doSelectJoinTurbineUser(criteria);
345 |  |
                 }
346 |  |
             }
347 | 0 |
             lastTurbineUserGroupRolesCriteria = criteria;
348 |  |
349 | 0 |
             return collTurbineUserGroupRoles;
350 |  |
         }
351 |  |
352 |  |
353 |  |
354 |  |
355 |  |
356 |  |
357 |  |
358 |  |
359 |  |
360 |  |
         /**
361 |  |
          * If this collection has already been initialized with
362 |  |
          * an identical criteria, it returns the collection.
363 |  |
          * Otherwise if this TurbineGroup is new, it will return
364 |  |
          * an empty collection; or if this TurbineGroup has previously
365 |  |
          * been saved, it will retrieve related TurbineUserGroupRoles from storage.
366 |  |
          *
367 |  |
          * This method is protected by default in order to keep the public
368 |  |
          * api reasonable.  You can provide public methods for those you
369 |  |
          * actually need in TurbineGroup.
370 |  |
          */
371 |  |
         protected List<TurbineUserGroupRole> getTurbineUserGroupRolesJoinTurbineGroup(Criteria criteria)
372 |  |
             throws TorqueException
373 |  |
         {
374 | 0 |
             if (collTurbineUserGroupRoles == null)
375 |  |
             {
376 | 0 |
                 if (isNew())
377 |  |
                 {
378 | 0 |
                    collTurbineUserGroupRoles = new ArrayList<TurbineUserGroupRole>();
379 |  |
                 }
380 |  |
                 else
381 |  |
                 {
382 | 0 |
                     criteria.add(TurbineUserGroupRolePeer.GROUP_ID, getGroupId());
383 | 0 |
                     collTurbineUserGroupRoles = TurbineUserGroupRolePeer.doSelectJoinTurbineGroup(criteria);
384 |  |
                 }
385 |  |
             }
386 |  |
             else
387 |  |
             {
388 |  |
                 // the following code is to determine if a new query is
389 |  |
                 // called for.  If the criteria is the same as the last
390 |  |
                 // one, just return the collection.
391 | 0 |
                 criteria.add(TurbineUserGroupRolePeer.GROUP_ID, getGroupId());
392 | 0 |
                 if (!lastTurbineUserGroupRolesCriteria.equals(criteria))
393 |  |
                 {
394 | 0 |
                     collTurbineUserGroupRoles = TurbineUserGroupRolePeer.doSelectJoinTurbineGroup(criteria);
395 |  |
                 }
396 |  |
             }
397 | 0 |
             lastTurbineUserGroupRolesCriteria = criteria;
398 |  |
399 | 0 |
             return collTurbineUserGroupRoles;
400 |  |
         }
401 |  |
402 |  |
403 |  |
404 |  |
405 |  |
406 |  |
407 |  |
408 |  |
409 |  |
410 |  |
         /**
411 |  |
          * If this collection has already been initialized with
412 |  |
          * an identical criteria, it returns the collection.
413 |  |
          * Otherwise if this TurbineGroup is new, it will return
414 |  |
          * an empty collection; or if this TurbineGroup has previously
415 |  |
          * been saved, it will retrieve related TurbineUserGroupRoles from storage.
416 |  |
          *
417 |  |
          * This method is protected by default in order to keep the public
418 |  |
          * api reasonable.  You can provide public methods for those you
419 |  |
          * actually need in TurbineGroup.
420 |  |
          */
421 |  |
         protected List<TurbineUserGroupRole> getTurbineUserGroupRolesJoinTurbineRole(Criteria criteria)
422 |  |
             throws TorqueException
423 |  |
         {
424 | 0 |
             if (collTurbineUserGroupRoles == null)
425 |  |
             {
426 | 0 |
                 if (isNew())
427 |  |
                 {
428 | 0 |
                    collTurbineUserGroupRoles = new ArrayList<TurbineUserGroupRole>();
429 |  |
                 }
430 |  |
                 else
431 |  |
                 {
432 | 0 |
                     criteria.add(TurbineUserGroupRolePeer.GROUP_ID, getGroupId());
433 | 0 |
                     collTurbineUserGroupRoles = TurbineUserGroupRolePeer.doSelectJoinTurbineRole(criteria);
434 |  |
                 }
435 |  |
             }
436 |  |
             else
437 |  |
             {
438 |  |
                 // the following code is to determine if a new query is
439 |  |
                 // called for.  If the criteria is the same as the last
440 |  |
                 // one, just return the collection.
441 | 0 |
                 criteria.add(TurbineUserGroupRolePeer.GROUP_ID, getGroupId());
442 | 0 |
                 if (!lastTurbineUserGroupRolesCriteria.equals(criteria))
443 |  |
                 {
444 | 0 |
                     collTurbineUserGroupRoles = TurbineUserGroupRolePeer.doSelectJoinTurbineRole(criteria);
445 |  |
                 }
446 |  |
             }
447 | 0 |
             lastTurbineUserGroupRolesCriteria = criteria;
448 |  |
449 | 0 |
             return collTurbineUserGroupRoles;
450 |  |
         }
451 |  |
452 |  |
453 |  |
454 |  |
455 | 0 |
         private static List<String> fieldNames = null;
456 |  |
457 |  |
         /**
458 |  |
          * Generate a list of field names.
459 |  |
          *
460 |  |
          * @return a list of field names
461 |  |
          */
462 |  |
         public static synchronized List<String> getFieldNames()
463 |  |
         {
464 | 0 |
             if (fieldNames == null)
465 |  |
             {
466 | 0 |
                 fieldNames = new ArrayList<String>();
467 | 0 |
                 fieldNames.add("GroupId");
468 | 0 |
                 fieldNames.add("Name");
469 | 0 |
                 fieldNames = Collections.unmodifiableList(fieldNames);
470 |  |
             }
471 | 0 |
             return fieldNames;
472 |  |
         }
473 |  |
474 |  |
         /**
475 |  |
          * Retrieves a field from the object by field (Java) name passed in as a String.
476 |  |
          *
477 |  |
          * @param name field name
478 |  |
          * @return value
479 |  |
          */
480 |  |
         public Object getByName(String name)
481 |  |
         {
482 | 0 |
             if (name.equals("GroupId"))
483 |  |
             {
484 | 0 |
                 return new Integer(getGroupId());
485 |  |
             }
486 | 0 |
             if (name.equals("Name"))
487 |  |
             {
488 | 0 |
                 return getName();
489 |  |
             }
490 | 0 |
             return null;
491 |  |
         }
492 |  |
493 |  |
         /**
494 |  |
          * Set a field in the object by field (Java) name.
495 |  |
          *
496 |  |
          * @param name field name
497 |  |
          * @param value field value
498 |  |
          * @return True if value was set, false if not (invalid name / protected field).
499 |  |
          * @throws IllegalArgumentException if object type of value does not match field object type.
500 |  |
          * @throws TorqueException If a problem occurs with the set[Field] method.
501 |  |
          */
502 |  |
         public boolean setByName(String name, Object value )
503 |  |
             throws TorqueException, IllegalArgumentException
504 |  |
         {
505 | 0 |
             if (name.equals("GroupId"))
506 |  |
             {
507 | 0 |
                 if (value == null || ! (Integer.class.isInstance(value)))
508 |  |
                 {
509 | 0 |
                     throw new IllegalArgumentException("setByName: value parameter was null or not an Integer object.");
510 |  |
                 }
511 | 0 |
                 setGroupId(((Integer) value).intValue());
512 | 0 |
                 return true;
513 |  |
             }
514 | 0 |
             if (name.equals("Name"))
515 |  |
             {
516 |  |
                 // Object fields can be null
517 | 0 |
                 if (value != null && ! String.class.isInstance(value))
518 |  |
                 {
519 | 0 |
                     throw new IllegalArgumentException("Invalid type of object specified for value in setByName");
520 |  |
                 }
521 | 0 |
                 setName((String) value);
522 | 0 |
                 return true;
523 |  |
             }
524 | 0 |
             return false;
525 |  |
         }
526 |  |
527 |  |
         /**
528 |  |
          * Retrieves a field from the object by name passed in
529 |  |
          * as a String.  The String must be one of the static
530 |  |
          * Strings defined in this Class' Peer.
531 |  |
          *
532 |  |
          * @param name peer name
533 |  |
          * @return value
534 |  |
          */
535 |  |
         public Object getByPeerName(String name)
536 |  |
         {
537 | 0 |
             if (name.equals(TurbineGroupPeer.GROUP_ID))
538 |  |
             {
539 | 0 |
                 return new Integer(getGroupId());
540 |  |
             }
541 | 0 |
             if (name.equals(TurbineGroupPeer.GROUP_NAME))
542 |  |
             {
543 | 0 |
                 return getName();
544 |  |
             }
545 | 0 |
             return null;
546 |  |
         }
547 |  |
548 |  |
         /**
549 |  |
          * Set field values by Peer Field Name
550 |  |
          *
551 |  |
          * @param name field name
552 |  |
          * @param value field value
553 |  |
          * @return True if value was set, false if not (invalid name / protected field).
554 |  |
          * @throws IllegalArgumentException if object type of value does not match field object type.
555 |  |
          * @throws TorqueException If a problem occurs with the set[Field] method.
556 |  |
          */
557 |  |
         public boolean setByPeerName(String name, Object value)
558 |  |
             throws TorqueException, IllegalArgumentException
559 |  |
         {
560 | 0 |
           if (TurbineGroupPeer.GROUP_ID.equals(name))
561 |  |
             {
562 | 0 |
                 return setByName("GroupId", value);
563 |  |
             }
564 | 0 |
           if (TurbineGroupPeer.GROUP_NAME.equals(name))
565 |  |
             {
566 | 0 |
                 return setByName("Name", value);
567 |  |
             }
568 | 0 |
             return false;
569 |  |
         }
570 |  |
571 |  |
         /**
572 |  |
          * Retrieves a field from the object by Position as specified
573 |  |
          * in the xml schema.  Zero-based.
574 |  |
          *
575 |  |
          * @param pos position in xml schema
576 |  |
          * @return value
577 |  |
          */
578 |  |
         public Object getByPosition(int pos)
579 |  |
         {
580 | 0 |
             if (pos == 0)
581 |  |
             {
582 | 0 |
                 return new Integer(getGroupId());
583 |  |
             }
584 | 0 |
             if (pos == 1)
585 |  |
             {
586 | 0 |
                 return getName();
587 |  |
             }
588 | 0 |
             return null;
589 |  |
         }
590 |  |
591 |  |
         /**
592 |  |
          * Set field values by its position (zero based) in the XML schema.
593 |  |
          *
594 |  |
          * @param position The field position
595 |  |
          * @param value field value
596 |  |
          * @return True if value was set, false if not (invalid position / protected field).
597 |  |
          * @throws IllegalArgumentException if object type of value does not match field object type.
598 |  |
          * @throws TorqueException If a problem occurs with the set[Field] method.
599 |  |
          */
600 |  |
         public boolean setByPosition(int position, Object value)
601 |  |
             throws TorqueException, IllegalArgumentException
602 |  |
         {
603 | 0 |
         if (position == 0)
604 |  |
             {
605 | 0 |
                 return setByName("GroupId", value);
606 |  |
             }
607 | 0 |
         if (position == 1)
608 |  |
             {
609 | 0 |
                 return setByName("Name", value);
610 |  |
             }
611 | 0 |
             return false;
612 |  |
         }
613 |  |
614 |  |
         /**
615 |  |
          * Stores the object in the database.  If the object is new,
616 |  |
          * it inserts it; otherwise an update is performed.
617 |  |
          *
618 |  |
          * @throws Exception
619 |  |
          */
620 |  |
         public void save() throws Exception
621 |  |
         {
622 | 0 |
             save(TurbineGroupPeer.DATABASE_NAME);
623 | 0 |
         }
624 |  |
625 |  |
         /**
626 |  |
          * Stores the object in the database.  If the object is new,
627 |  |
          * it inserts it; otherwise an update is performed.
628 |  |
          * Note: this code is here because the method body is
629 |  |
          * auto-generated conditionally and therefore needs to be
630 |  |
          * in this file instead of in the super class, BaseObject.
631 |  |
          *
632 |  |
          * @param dbName
633 |  |
          * @throws TorqueException
634 |  |
          */
635 |  |
         public void save(String dbName) throws TorqueException
636 |  |
         {
637 | 0 |
             Connection con = null;
638 |  |
             try
639 |  |
             {
640 | 0 |
                 con = Transaction.begin(dbName);
641 | 0 |
                 save(con);
642 | 0 |
                 Transaction.commit(con);
643 |  |
             }
644 | 0 |
             catch(TorqueException e)
645 |  |
             {
646 | 0 |
                 Transaction.safeRollback(con);
647 | 0 |
                 throw e;
648 | 0 |
             }
649 | 0 |
         }
650 |  |
651 |  |
         /** flag to prevent endless save loop, if this object is referenced
652 |  |
             by another object which falls in this transaction. */
653 | 0 |
         private boolean alreadyInSave = false;
654 |  |
         /**
655 |  |
          * Stores the object in the database.  If the object is new,
656 |  |
          * it inserts it; otherwise an update is performed.  This method
657 |  |
          * is meant to be used as part of a transaction, otherwise use
658 |  |
          * the save() method and the connection details will be handled
659 |  |
          * internally
660 |  |
          *
661 |  |
          * @param con
662 |  |
          * @throws TorqueException
663 |  |
          */
664 |  |
         public void save(Connection con) throws TorqueException
665 |  |
         {
666 | 0 |
             if (!alreadyInSave)
667 |  |
             {
668 | 0 |
                 alreadyInSave = true;
669 |  |
670 |  |
671 |  |
672 |  |
                 // If this object has been modified, then save it to the database.
673 | 0 |
                 if (isModified())
674 |  |
                 {
675 | 0 |
                     if (isNew())
676 |  |
                     {
677 | 0 |
                         TurbineGroupPeer.doInsert((TurbineGroup) this, con);
678 | 0 |
                         setNew(false);
679 |  |
                     }
680 |  |
                     else
681 |  |
                     {
682 | 0 |
                         TurbineGroupPeer.doUpdate((TurbineGroup) this, con);
683 |  |
                     }
684 |  |
                 }
685 |  |
686 |  |
687 | 0 |
                 if (collTurbineUserGroupRoles != null)
688 |  |
                 {
689 | 0 |
                     for (int i = 0; i < collTurbineUserGroupRoles.size(); i++)
690 |  |
                     {
691 | 0 |
                         ((TurbineUserGroupRole) collTurbineUserGroupRoles.get(i)).save(con);
692 |  |
                     }
693 |  |
                 }
694 | 0 |
                 alreadyInSave = false;
695 |  |
             }
696 | 0 |
         }
697 |  |
698 |  |
699 |  |
         /**
700 |  |
          * Set the PrimaryKey using ObjectKey.
701 |  |
          *
702 |  |
          * @param key groupId ObjectKey
703 |  |
          */
704 |  |
         public void setPrimaryKey(ObjectKey key)
705 |  |
             throws TorqueException
706 |  |
         {
707 | 0 |
             setGroupId(((NumberKey) key).intValue());
708 | 0 |
         }
709 |  |
710 |  |
         /**
711 |  |
          * Set the PrimaryKey using a String.
712 |  |
          *
713 |  |
          * @param key
714 |  |
          */
715 |  |
         public void setPrimaryKey(String key) throws TorqueException
716 |  |
         {
717 | 0 |
             setGroupId(Integer.parseInt(key));
718 | 0 |
         }
719 |  |
720 |  |
721 |  |
         /**
722 |  |
          * returns an id that differentiates this object from others
723 |  |
          * of its class.
724 |  |
          */
725 |  |
         public ObjectKey getPrimaryKey()
726 |  |
         {
727 | 0 |
             return SimpleKey.keyFor(getGroupId());
728 |  |
         }
729 |  |
730 |  |
731 |  |
         /**
732 |  |
          * Makes a copy of this object.
733 |  |
          * It creates a new object filling in the simple attributes.
734 |  |
          * It then fills all the association collections and sets the
735 |  |
          * related objects to isNew=true.
736 |  |
          */
737 |  |
         public TurbineGroup copy() throws TorqueException
738 |  |
         {
739 | 0 |
             return copy(true);
740 |  |
         }
741 |  |
742 |  |
         /**
743 |  |
          * Makes a copy of this object using connection.
744 |  |
          * It creates a new object filling in the simple attributes.
745 |  |
          * It then fills all the association collections and sets the
746 |  |
          * related objects to isNew=true.
747 |  |
          *
748 |  |
          * @param con the database connection to read associated objects.
749 |  |
          */
750 |  |
         public TurbineGroup copy(Connection con) throws TorqueException
751 |  |
         {
752 | 0 |
             return copy(true, con);
753 |  |
         }
754 |  |
755 |  |
         /**
756 |  |
          * Makes a copy of this object.
757 |  |
          * It creates a new object filling in the simple attributes.
758 |  |
          * If the parameter deepcopy is true, it then fills all the
759 |  |
          * association collections and sets the related objects to
760 |  |
          * isNew=true.
761 |  |
          *
762 |  |
          * @param deepcopy whether to copy the associated objects.
763 |  |
          */
764 |  |
         public TurbineGroup copy(boolean deepcopy) throws TorqueException
765 |  |
         {
766 | 0 |
             return copyInto(new TurbineGroup(), deepcopy);
767 |  |
         }
768 |  |
769 |  |
         /**
770 |  |
          * Makes a copy of this object using connection.
771 |  |
          * It creates a new object filling in the simple attributes.
772 |  |
          * If the parameter deepcopy is true, it then fills all the
773 |  |
          * association collections and sets the related objects to
774 |  |
          * isNew=true.
775 |  |
          *
776 |  |
          * @param deepcopy whether to copy the associated objects.
777 |  |
          * @param con the database connection to read associated objects.
778 |  |
          */
779 |  |
         public TurbineGroup copy(boolean deepcopy, Connection con) throws TorqueException
780 |  |
         {
781 | 0 |
             return copyInto(new TurbineGroup(), deepcopy, con);
782 |  |
         }
783 |  |
784 |  |
         /**
785 |  |
          * Fills the copyObj with the contents of this object.
786 |  |
          * The associated objects are also copied and treated as new objects.
787 |  |
          *
788 |  |
          * @param copyObj the object to fill.
789 |  |
          */
790 |  |
         protected TurbineGroup copyInto(TurbineGroup copyObj) throws TorqueException
791 |  |
         {
792 | 0 |
             return copyInto(copyObj, true);
793 |  |
         }
794 |  |
795 |  |
796 |  |
         /**
797 |  |
          * Fills the copyObj with the contents of this object using connection.
798 |  |
          * The associated objects are also copied and treated as new objects.
799 |  |
          *
800 |  |
          * @param copyObj the object to fill.
801 |  |
          * @param con the database connection to read associated objects.
802 |  |
          */
803 |  |
         protected TurbineGroup copyInto(TurbineGroup copyObj, Connection con) throws TorqueException
804 |  |
         {
805 | 0 |
             return copyInto(copyObj, true, con);
806 |  |
         }
807 |  |
808 |  |
         /**
809 |  |
          * Fills the copyObj with the contents of this object.
810 |  |
          * If deepcopy is true, The associated objects are also copied
811 |  |
          * and treated as new objects.
812 |  |
          *
813 |  |
          * @param copyObj the object to fill.
814 |  |
          * @param deepcopy whether the associated objects should be copied.
815 |  |
          */
816 |  |
         protected TurbineGroup copyInto(TurbineGroup copyObj, boolean deepcopy) throws TorqueException
817 |  |
         {
818 | 0 |
             copyObj.setGroupId(groupId);
819 | 0 |
             copyObj.setName(name);
820 |  |
821 | 0 |
             copyObj.setGroupId( 0);
822 |  |
823 | 0 |
             if (deepcopy)
824 |  |
             {
825 |  |
826 |  |
827 | 0 |
             List<TurbineUserGroupRole> vTurbineUserGroupRoles = getTurbineUserGroupRoles();
828 | 0 |
             if (vTurbineUserGroupRoles != null)
829 |  |
             {
830 | 0 |
                 for (int i = 0; i < vTurbineUserGroupRoles.size(); i++)
831 |  |
                 {
832 | 0 |
                     TurbineUserGroupRole obj =  vTurbineUserGroupRoles.get(i);
833 | 0 |
                     copyObj.addTurbineUserGroupRole(obj.copy());
834 |  |
                 }
835 |  |
             }
836 |  |
             else
837 |  |
             {
838 | 0 |
                 copyObj.collTurbineUserGroupRoles = null;
839 |  |
             }
840 |  |
             }
841 | 0 |
             return copyObj;
842 |  |
         }
843 |  |
844 |  |
845 |  |
         /**
846 |  |
          * Fills the copyObj with the contents of this object using connection.
847 |  |
          * If deepcopy is true, The associated objects are also copied
848 |  |
          * and treated as new objects.
849 |  |
          *
850 |  |
          * @param copyObj the object to fill.
851 |  |
          * @param deepcopy whether the associated objects should be copied.
852 |  |
          * @param con the database connection to read associated objects.
853 |  |
          */
854 |  |
         protected TurbineGroup copyInto(TurbineGroup copyObj, boolean deepcopy, Connection con) throws TorqueException
855 |  |
         {
856 | 0 |
             copyObj.setGroupId(groupId);
857 | 0 |
             copyObj.setName(name);
858 |  |
859 | 0 |
             copyObj.setGroupId( 0);
860 |  |
861 | 0 |
             if (deepcopy)
862 |  |
             {
863 |  |
864 |  |
865 | 0 |
             List<TurbineUserGroupRole> vTurbineUserGroupRoles = getTurbineUserGroupRoles(con);
866 | 0 |
             if (vTurbineUserGroupRoles != null)
867 |  |
             {
868 | 0 |
                 for (int i = 0; i < vTurbineUserGroupRoles.size(); i++)
869 |  |
                 {
870 | 0 |
                     TurbineUserGroupRole obj =  vTurbineUserGroupRoles.get(i);
871 | 0 |
                     copyObj.addTurbineUserGroupRole(obj.copy(con), con);
872 |  |
                 }
873 |  |
             }
874 |  |
             else
875 |  |
             {
876 | 0 |
                 copyObj.collTurbineUserGroupRoles = null;
877 |  |
             }
878 |  |
             }
879 | 0 |
             return copyObj;
880 |  |
         }
881 |  |
882 |  |
883 |  |
884 |  |
         /**
885 |  |
          * returns a peer instance associated with this om.  Since Peer classes
886 |  |
          * are not to have any instance attributes, this method returns the
887 |  |
          * same instance for all member of this class. The method could therefore
888 |  |
          * be static, but this would prevent one from overriding the behavior.
889 |  |
          */
890 |  |
         public TurbineGroupPeer getPeer()
891 |  |
         {
892 | 0 |
             return peer;
893 |  |
         }
894 |  |
895 |  |
         /**
896 |  |
          * Retrieves the TableMap object related to this Table data without
897 |  |
          * compiler warnings of using getPeer().getTableMap().
898 |  |
          *
899 |  |
          * @return The associated TableMap object.
900 |  |
          */
901 |  |
         public TableMap getTableMap() throws TorqueException
902 |  |
         {
903 | 0 |
             return TurbineGroupPeer.getTableMap();
904 |  |
         }
905 |  |
906 |  |
907 |  |
         public String toString()
908 |  |
         {
909 | 0 |
             StringBuffer str = new StringBuffer();
910 | 0 |
             str.append("TurbineGroup:\n");
911 | 0 |
             str.append("GroupId = ")
912 |  |
                .append(getGroupId())
913 |  |
                .append("\n");
914 | 0 |
             str.append("Name = ")
915 |  |
                .append(getName())
916 |  |
                .append("\n");
917 | 0 |
             return(str.toString());
918 |  |
         }
919 |  |
     }