001package org.apache.fulcrum.security.torque.om; 002 003import java.io.Serializable; 004import java.sql.Connection; 005import java.util.ArrayList; 006import java.util.List; 007import java.util.Objects; 008 009import org.apache.torque.TorqueException; 010import org.apache.torque.map.TableMap; 011import org.apache.torque.om.NumberKey; 012import org.apache.torque.om.ObjectKey; 013import org.apache.torque.om.SimpleKey; 014import org.apache.torque.om.Persistent; 015import org.apache.torque.criteria.Criteria; 016import org.apache.torque.util.TorqueConnection; 017import org.apache.torque.util.Transaction; 018 019/** 020 * This class was autogenerated by Torque on: 021 * 022 * [Thu Nov 04 13:34:21 CET 2021] 023 * 024 * You should not use this class directly. It should not even be 025 * extended; all references should be to TorqueDynamicRole 026 */ 027@SuppressWarnings("unused") 028public abstract class BaseTorqueDynamicRole extends org.apache.fulcrum.security.torque.dynamic.TorqueAbstractDynamicRole 029 implements Persistent, Serializable 030{ 031 /** Serial version */ 032 private static final long serialVersionUID = 1636029261414L; 033 034 035 036 /** Defines the entityId field. */ 037 private Integer entityId = null; 038 039 /** Defines the entityName field. */ 040 private String entityName = null; 041 042 /** Whether this object was modified after loading or after last save. */ 043 private boolean modified = true; 044 045 /** 046 * Whether this object was loaded from the database or already saved 047 * (false) or whether it is not yet in the database(true). 048 */ 049 private boolean isNew = true; 050 051 /** Flag which indicates whether this object is currently saving. */ 052 private boolean saving = false; 053 054 /** 055 * Flag which indicates whether this object is currently loaded 056 * from the database. 057 */ 058 private boolean loading = false; 059 060 /** 061 * Flag which indicates whether this object was deleted from the database. 062 * Note that this flags does not always display the current database state, 063 * there is no magical connection between this flag and the database. 064 */ 065 private boolean deleted = false; 066 067 068 069 /** Defines the collTorqueDynamicRolePermissions field. */ 070 protected List<TorqueDynamicRolePermission> collTorqueDynamicRolePermissions = null; 071 072 /** Defines the collTorqueDynamicGroupRoles field. */ 073 protected List<TorqueDynamicGroupRole> collTorqueDynamicGroupRoles = null; 074 075 076 077 /** 078 * Get the value of entityId. 079 * 080 * @return the value of entityId as Integer 081 */ 082 public Integer getEntityId() 083 { 084 085 return entityId; 086 } 087 088 /** 089 * Set the value of entityId. 090 * 091 * @param v new value of entityId 092 */ 093 public void setEntityId(Integer v) 094 { 095 if (!Objects.equals(this.entityId, v)) 096 { 097 setModified(true); 098 } 099 100 this.entityId = v; 101 102 // update associated objects in collTorqueDynamicRolePermissions 103 if (collTorqueDynamicRolePermissions != null) 104 { 105 for (TorqueDynamicRolePermission element : collTorqueDynamicRolePermissions) 106 { 107 element.setRoleId(v); 108 } 109 } 110 // update associated objects in collTorqueDynamicGroupRoles 111 if (collTorqueDynamicGroupRoles != null) 112 { 113 for (TorqueDynamicGroupRole element : collTorqueDynamicGroupRoles) 114 { 115 element.setRoleId(v); 116 } 117 } 118 119 } 120 121 /** 122 * Get the value of entityName. 123 * 124 * @return the value of entityName as String 125 */ 126 public String getEntityName() 127 { 128 129 return entityName; 130 } 131 132 /** 133 * Set the value of entityName. 134 * 135 * @param v new value of entityName 136 */ 137 public void setEntityName(String v) 138 { 139 if (!Objects.equals(this.entityName, v)) 140 { 141 setModified(true); 142 } 143 144 this.entityName = v; 145 146 147 } 148 149 150 /** 151 * Returns whether the object has ever been saved. This will 152 * be false, if the object was retrieved from storage or was created 153 * and then saved. 154 * 155 * @return true, if the object has never been persisted. 156 */ 157 public boolean isNew() 158 { 159 return isNew; 160 } 161 162 /** 163 * Sets whether the object has ever been saved. 164 * 165 * @param isNew true if the object has never been saved, false otherwise. 166 */ 167 public void setNew(boolean isNew) 168 { 169 this.isNew = isNew; 170 } 171 172 /** 173 * Returns whether the object has been modified. 174 * 175 * @return True if the object has been modified. 176 */ 177 public boolean isModified() 178 { 179 return modified; 180 } 181 182 /** 183 * Sets whether the object has been modified. 184 * 185 * @param modified true if the object has been modified, false otherwise. 186 */ 187 public void setModified(boolean modified) 188 { 189 this.modified = modified; 190 } 191 192 /** 193 * Sets the modified state for the object to be false. 194 */ 195 public void resetModified() 196 { 197 modified = false; 198 } 199 200 201 /** 202 * Returns whether this object is currently saving. 203 * 204 * @return true if this object is currently saving, false otherwise. 205 */ 206 public boolean isSaving() 207 { 208 return saving; 209 } 210 211 /** 212 * Sets whether this object is currently saving. 213 * 214 * @param saving true if this object is currently saving, false otherwise. 215 */ 216 public void setSaving(boolean saving) 217 { 218 this.saving = saving; 219 } 220 221 222 /** 223 * Returns whether this object is currently being loaded from the database. 224 * 225 * @return true if this object is currently loading, false otherwise. 226 */ 227 public boolean isLoading() 228 { 229 return loading; 230 } 231 232 /** 233 * Sets whether this object is currently being loaded from the database. 234 * 235 * @param loading true if this object is currently loading, false otherwise. 236 */ 237 public void setLoading(boolean loading) 238 { 239 this.loading = loading; 240 } 241 242 243 /** 244 * Returns whether this object was deleted from the database. 245 * Note that this getter does not automatically reflect database state, 246 * it will be set to true by Torque if doDelete() was called with this 247 * object. Bulk deletes and deletes via primary key do not change 248 * this flag. Also, if doDelete() was called on an object which does 249 * not exist in the database, the deleted flag is set to true even if 250 * it was not deleted. 251 * 252 * @return true if this object was deleted, false otherwise. 253 */ 254 public boolean isDeleted() 255 { 256 return deleted; 257 } 258 259 /** 260 * Sets whether this object was deleted from the database. 261 * 262 * @param deleted true if this object was deleted, false otherwise. 263 */ 264 public void setDeleted(boolean deleted) 265 { 266 this.deleted = deleted; 267 } 268 269 270 271 272 /** 273 * Initializes the cache collTorqueDynamicRolePermissions for referenced objects. 274 * This, means, if collTorqueDynamicRolePermissions is null when this operation is called, it is 275 * initialized with an empty collection, otherwise it remains unchanged. 276 * 277 * @return the (possibly new) content of the field collTorqueDynamicRolePermissions, not null. 278 */ 279 public List<TorqueDynamicRolePermission> initTorqueDynamicRolePermissions() 280 { 281 if (collTorqueDynamicRolePermissions == null) 282 { 283 collTorqueDynamicRolePermissions = new ArrayList<TorqueDynamicRolePermission>(); 284 } 285 return collTorqueDynamicRolePermissions; 286 } 287 288 /** 289 * Checks whether the cache collTorqueDynamicRolePermissions for referenced objects has either been 290 * loaded from the database or has been manually initialized. 291 * 292 * @return boolean true if initialized 293 */ 294 public boolean isTorqueDynamicRolePermissionsInitialized() 295 { 296 return (collTorqueDynamicRolePermissions != null); 297 } 298 299 300 /** 301 * Method called to associate a TorqueDynamicRolePermission object to this object 302 * through the collTorqueDynamicRolePermissions foreign key attribute. 303 * If the associated objects were not retrieved before 304 * and this object is not new, the associated objects are retrieved 305 * from the database before adding the <code>toAdd</code> object. 306 * 307 * @param toAdd the object to add to the associated objects, not null. 308 * 309 * @throws TorqueException if retrieval of the associated objects fails. 310 * @throws NullPointerException if toAdd is null. 311 */ 312 public void addTorqueDynamicRolePermission(TorqueDynamicRolePermission toAdd) 313 throws TorqueException 314 { 315 toAdd.setTorqueDynamicRole((TorqueDynamicRole) this); 316 getTorqueDynamicRolePermissions().add(toAdd); 317 } 318 319 /** 320 * Method called to associate a TorqueDynamicRolePermission object to this object 321 * through the collTorqueDynamicRolePermissions foreign key attribute using connection. 322 * 323 * @param l TorqueDynamicRolePermission 324 * @throws TorqueException if retrieval of the associated objects fails. 325 */ 326 public void addTorqueDynamicRolePermission(TorqueDynamicRolePermission l, Connection con) throws TorqueException 327 { 328 getTorqueDynamicRolePermissions(con).add(l); 329 l.setTorqueDynamicRole((TorqueDynamicRole) this); 330 } 331 332 /** 333 * Method called to reset the cache of TorqueDynamicRolePermission objects 334 * which are related through the collTorqueDynamicRolePermissions foreign key attribute. 335 */ 336 public void resetTorqueDynamicRolePermission() 337 { 338 collTorqueDynamicRolePermissions = null; 339 } 340 341 342 /** 343 * The criteria used to select the current contents of collTorqueDynamicRolePermissions 344 */ 345 private Criteria lastTorqueDynamicRolePermissionCriteria = null; 346 347 /** 348 * If this collection has already been initialized, returns 349 * the collection. Otherwise returns the results of 350 * getTorqueDynamicRolePermissions(new Criteria()) 351 * 352 * @return the collection of associated objects 353 * @throws TorqueException 354 */ 355 public List<TorqueDynamicRolePermission> getTorqueDynamicRolePermissions() 356 throws TorqueException 357 { 358 if (collTorqueDynamicRolePermissions == null) 359 { 360 collTorqueDynamicRolePermissions = getTorqueDynamicRolePermissions(new Criteria()); 361 for (TorqueDynamicRolePermission torqueDynamicRolePermission : collTorqueDynamicRolePermissions) 362 { 363 torqueDynamicRolePermission.setTorqueDynamicRole((TorqueDynamicRole) this); 364 } 365 } 366 return collTorqueDynamicRolePermissions; 367 } 368 369 /** 370 * If this collection has already been initialized with 371 * an identical criteria, it returns the collection. 372 * Otherwise if this BaseTorqueDynamicRole has previously 373 * been saved, it will retrieve related collTorqueDynamicRolePermissions from storage. 374 * If this BaseTorqueDynamicRole is new, it will return 375 * an empty collection or the current collection, the criteria 376 * is ignored on a new object. 377 * 378 * @throws TorqueException If a problem occurs with the get[criteria] method. 379 */ 380 public List<TorqueDynamicRolePermission> getTorqueDynamicRolePermissions(Criteria criteria) throws TorqueException 381 { 382 if (collTorqueDynamicRolePermissions == null) 383 { 384 if (isNew()) 385 { 386 initTorqueDynamicRolePermissions(); 387 } 388 else 389 { 390 criteria.and(org.apache.fulcrum.security.torque.om.TorqueDynamicRolePermissionPeer.ROLE_ID, getEntityId()); 391 collTorqueDynamicRolePermissions = org.apache.fulcrum.security.torque.om.TorqueDynamicRolePermissionPeer.doSelect(criteria); 392 for (TorqueDynamicRolePermission torqueDynamicRolePermission : collTorqueDynamicRolePermissions) 393 { 394 torqueDynamicRolePermission.setTorqueDynamicRole((TorqueDynamicRole) this); 395 } 396 } 397 } 398 else 399 { 400 // criteria has no effect for a new object 401 if (!isNew()) 402 { 403 // the following code is to determine if a new query is 404 // called for. If the criteria is the same as the last 405 // one, just return the collection. 406 criteria.and(org.apache.fulcrum.security.torque.om.TorqueDynamicRolePermissionPeer.ROLE_ID, getEntityId()); 407 if (lastTorqueDynamicRolePermissionCriteria == null 408 || !lastTorqueDynamicRolePermissionCriteria.equals(criteria)) 409 { 410 collTorqueDynamicRolePermissions = org.apache.fulcrum.security.torque.om.TorqueDynamicRolePermissionPeer.doSelect(criteria); 411 for (TorqueDynamicRolePermission torqueDynamicRolePermission : collTorqueDynamicRolePermissions) 412 { 413 torqueDynamicRolePermission.setTorqueDynamicRole((TorqueDynamicRole) this); 414 } 415 } 416 } 417 } 418 lastTorqueDynamicRolePermissionCriteria = criteria; 419 return collTorqueDynamicRolePermissions; 420 } 421 422 /** 423 * If this collection has already been initialized, returns 424 * the collection. Otherwise returns the results of 425 * getTorqueDynamicRolePermissions(new Criteria(),Connection) 426 * This method takes in the Connection also as input so that 427 * referenced objects can also be obtained using a Connection 428 * that is taken as input 429 * 430 * @param con the Connection 431 * @return List<TorqueDynamicRolePermission> results of the collection 432 * @throws TorqueException If a problem occurs with the get[connection] method. 433 */ 434 public List<TorqueDynamicRolePermission> getTorqueDynamicRolePermissions(Connection con) throws TorqueException 435 { 436 if (collTorqueDynamicRolePermissions == null) 437 { 438 collTorqueDynamicRolePermissions = getTorqueDynamicRolePermissions(new Criteria(), con); 439 for (TorqueDynamicRolePermission torqueDynamicRolePermission : collTorqueDynamicRolePermissions) 440 { 441 torqueDynamicRolePermission.setTorqueDynamicRole((TorqueDynamicRole) this); 442 } 443 } 444 return collTorqueDynamicRolePermissions; 445 } 446 447 /** 448 * If this collection has already been initialized with 449 * an identical criteria, it returns the collection. 450 * Otherwise if this BaseTorqueDynamicRole has previously 451 * been saved, it will retrieve the related TorqueDynamicRolePermission Objects 452 * from storage. 453 * If this BaseTorqueDynamicRole is new, it will return 454 * an empty collection or the current collection, the criteria 455 * is ignored on a new object. 456 * This method takes in the Connection also as input so that 457 * referenced objects can also be obtained using a Connection 458 * that is taken as input 459 * 460 * @param con the Connection 461 * @return List<TorqueDynamicRolePermission> results of the collection 462 * @throws TorqueException If a problem occurs with the get[connection] method. 463 */ 464 public List<TorqueDynamicRolePermission> getTorqueDynamicRolePermissions(Criteria criteria, Connection con) 465 throws TorqueException 466 { 467 if (collTorqueDynamicRolePermissions == null) 468 { 469 if (isNew()) 470 { 471 initTorqueDynamicRolePermissions(); 472 } 473 else 474 { 475 criteria.and(org.apache.fulcrum.security.torque.om.TorqueDynamicRolePermissionPeer.ROLE_ID, getEntityId()); 476 collTorqueDynamicRolePermissions = org.apache.fulcrum.security.torque.om.TorqueDynamicRolePermissionPeer.doSelect(criteria, con); 477 for (TorqueDynamicRolePermission torqueDynamicRolePermission : collTorqueDynamicRolePermissions) 478 { 479 torqueDynamicRolePermission.setTorqueDynamicRole((TorqueDynamicRole) this); 480 } 481 } 482 } 483 else 484 { 485 // criteria has no effect for a new object 486 if (!isNew()) 487 { 488 // the following code is to determine if a new query is 489 // called for. If the criteria is the same as the last 490 // one, just return the collection. 491 criteria.and(org.apache.fulcrum.security.torque.om.TorqueDynamicRolePermissionPeer.ROLE_ID, getEntityId()); 492 if (lastTorqueDynamicRolePermissionCriteria == null 493 || !lastTorqueDynamicRolePermissionCriteria.equals(criteria)) 494 { 495 collTorqueDynamicRolePermissions = org.apache.fulcrum.security.torque.om.TorqueDynamicRolePermissionPeer.doSelect(criteria, con); 496 for (TorqueDynamicRolePermission torqueDynamicRolePermission : collTorqueDynamicRolePermissions) 497 { 498 torqueDynamicRolePermission.setTorqueDynamicRole((TorqueDynamicRole) this); 499 } 500 } 501 } 502 } 503 lastTorqueDynamicRolePermissionCriteria = criteria; 504 505 return collTorqueDynamicRolePermissions; 506 } 507 508 /** 509 * Initializes the cache collTorqueDynamicGroupRoles for referenced objects. 510 * This, means, if collTorqueDynamicGroupRoles is null when this operation is called, it is 511 * initialized with an empty collection, otherwise it remains unchanged. 512 * 513 * @return the (possibly new) content of the field collTorqueDynamicGroupRoles, not null. 514 */ 515 public List<TorqueDynamicGroupRole> initTorqueDynamicGroupRoles() 516 { 517 if (collTorqueDynamicGroupRoles == null) 518 { 519 collTorqueDynamicGroupRoles = new ArrayList<TorqueDynamicGroupRole>(); 520 } 521 return collTorqueDynamicGroupRoles; 522 } 523 524 /** 525 * Checks whether the cache collTorqueDynamicGroupRoles for referenced objects has either been 526 * loaded from the database or has been manually initialized. 527 * 528 * @return boolean true if initialized 529 */ 530 public boolean isTorqueDynamicGroupRolesInitialized() 531 { 532 return (collTorqueDynamicGroupRoles != null); 533 } 534 535 536 /** 537 * Method called to associate a TorqueDynamicGroupRole object to this object 538 * through the collTorqueDynamicGroupRoles foreign key attribute. 539 * If the associated objects were not retrieved before 540 * and this object is not new, the associated objects are retrieved 541 * from the database before adding the <code>toAdd</code> object. 542 * 543 * @param toAdd the object to add to the associated objects, not null. 544 * 545 * @throws TorqueException if retrieval of the associated objects fails. 546 * @throws NullPointerException if toAdd is null. 547 */ 548 public void addTorqueDynamicGroupRole(TorqueDynamicGroupRole toAdd) 549 throws TorqueException 550 { 551 toAdd.setTorqueDynamicRole((TorqueDynamicRole) this); 552 getTorqueDynamicGroupRoles().add(toAdd); 553 } 554 555 /** 556 * Method called to associate a TorqueDynamicGroupRole object to this object 557 * through the collTorqueDynamicGroupRoles foreign key attribute using connection. 558 * 559 * @param l TorqueDynamicGroupRole 560 * @throws TorqueException if retrieval of the associated objects fails. 561 */ 562 public void addTorqueDynamicGroupRole(TorqueDynamicGroupRole l, Connection con) throws TorqueException 563 { 564 getTorqueDynamicGroupRoles(con).add(l); 565 l.setTorqueDynamicRole((TorqueDynamicRole) this); 566 } 567 568 /** 569 * Method called to reset the cache of TorqueDynamicGroupRole objects 570 * which are related through the collTorqueDynamicGroupRoles foreign key attribute. 571 */ 572 public void resetTorqueDynamicGroupRole() 573 { 574 collTorqueDynamicGroupRoles = null; 575 } 576 577 578 /** 579 * The criteria used to select the current contents of collTorqueDynamicGroupRoles 580 */ 581 private Criteria lastTorqueDynamicGroupRoleCriteria = null; 582 583 /** 584 * If this collection has already been initialized, returns 585 * the collection. Otherwise returns the results of 586 * getTorqueDynamicGroupRoles(new Criteria()) 587 * 588 * @return the collection of associated objects 589 * @throws TorqueException 590 */ 591 public List<TorqueDynamicGroupRole> getTorqueDynamicGroupRoles() 592 throws TorqueException 593 { 594 if (collTorqueDynamicGroupRoles == null) 595 { 596 collTorqueDynamicGroupRoles = getTorqueDynamicGroupRoles(new Criteria()); 597 for (TorqueDynamicGroupRole torqueDynamicGroupRole : collTorqueDynamicGroupRoles) 598 { 599 torqueDynamicGroupRole.setTorqueDynamicRole((TorqueDynamicRole) this); 600 } 601 } 602 return collTorqueDynamicGroupRoles; 603 } 604 605 /** 606 * If this collection has already been initialized with 607 * an identical criteria, it returns the collection. 608 * Otherwise if this BaseTorqueDynamicRole has previously 609 * been saved, it will retrieve related collTorqueDynamicGroupRoles from storage. 610 * If this BaseTorqueDynamicRole is new, it will return 611 * an empty collection or the current collection, the criteria 612 * is ignored on a new object. 613 * 614 * @throws TorqueException If a problem occurs with the get[criteria] method. 615 */ 616 public List<TorqueDynamicGroupRole> getTorqueDynamicGroupRoles(Criteria criteria) throws TorqueException 617 { 618 if (collTorqueDynamicGroupRoles == null) 619 { 620 if (isNew()) 621 { 622 initTorqueDynamicGroupRoles(); 623 } 624 else 625 { 626 criteria.and(org.apache.fulcrum.security.torque.om.TorqueDynamicGroupRolePeer.ROLE_ID, getEntityId()); 627 collTorqueDynamicGroupRoles = org.apache.fulcrum.security.torque.om.TorqueDynamicGroupRolePeer.doSelect(criteria); 628 for (TorqueDynamicGroupRole torqueDynamicGroupRole : collTorqueDynamicGroupRoles) 629 { 630 torqueDynamicGroupRole.setTorqueDynamicRole((TorqueDynamicRole) this); 631 } 632 } 633 } 634 else 635 { 636 // criteria has no effect for a new object 637 if (!isNew()) 638 { 639 // the following code is to determine if a new query is 640 // called for. If the criteria is the same as the last 641 // one, just return the collection. 642 criteria.and(org.apache.fulcrum.security.torque.om.TorqueDynamicGroupRolePeer.ROLE_ID, getEntityId()); 643 if (lastTorqueDynamicGroupRoleCriteria == null 644 || !lastTorqueDynamicGroupRoleCriteria.equals(criteria)) 645 { 646 collTorqueDynamicGroupRoles = org.apache.fulcrum.security.torque.om.TorqueDynamicGroupRolePeer.doSelect(criteria); 647 for (TorqueDynamicGroupRole torqueDynamicGroupRole : collTorqueDynamicGroupRoles) 648 { 649 torqueDynamicGroupRole.setTorqueDynamicRole((TorqueDynamicRole) this); 650 } 651 } 652 } 653 } 654 lastTorqueDynamicGroupRoleCriteria = criteria; 655 return collTorqueDynamicGroupRoles; 656 } 657 658 /** 659 * If this collection has already been initialized, returns 660 * the collection. Otherwise returns the results of 661 * getTorqueDynamicGroupRoles(new Criteria(),Connection) 662 * This method takes in the Connection also as input so that 663 * referenced objects can also be obtained using a Connection 664 * that is taken as input 665 * 666 * @param con the Connection 667 * @return List<TorqueDynamicGroupRole> results of the collection 668 * @throws TorqueException If a problem occurs with the get[connection] method. 669 */ 670 public List<TorqueDynamicGroupRole> getTorqueDynamicGroupRoles(Connection con) throws TorqueException 671 { 672 if (collTorqueDynamicGroupRoles == null) 673 { 674 collTorqueDynamicGroupRoles = getTorqueDynamicGroupRoles(new Criteria(), con); 675 for (TorqueDynamicGroupRole torqueDynamicGroupRole : collTorqueDynamicGroupRoles) 676 { 677 torqueDynamicGroupRole.setTorqueDynamicRole((TorqueDynamicRole) this); 678 } 679 } 680 return collTorqueDynamicGroupRoles; 681 } 682 683 /** 684 * If this collection has already been initialized with 685 * an identical criteria, it returns the collection. 686 * Otherwise if this BaseTorqueDynamicRole has previously 687 * been saved, it will retrieve the related TorqueDynamicGroupRole Objects 688 * from storage. 689 * If this BaseTorqueDynamicRole is new, it will return 690 * an empty collection or the current collection, the criteria 691 * is ignored on a new object. 692 * This method takes in the Connection also as input so that 693 * referenced objects can also be obtained using a Connection 694 * that is taken as input 695 * 696 * @param con the Connection 697 * @return List<TorqueDynamicGroupRole> results of the collection 698 * @throws TorqueException If a problem occurs with the get[connection] method. 699 */ 700 public List<TorqueDynamicGroupRole> getTorqueDynamicGroupRoles(Criteria criteria, Connection con) 701 throws TorqueException 702 { 703 if (collTorqueDynamicGroupRoles == null) 704 { 705 if (isNew()) 706 { 707 initTorqueDynamicGroupRoles(); 708 } 709 else 710 { 711 criteria.and(org.apache.fulcrum.security.torque.om.TorqueDynamicGroupRolePeer.ROLE_ID, getEntityId()); 712 collTorqueDynamicGroupRoles = org.apache.fulcrum.security.torque.om.TorqueDynamicGroupRolePeer.doSelect(criteria, con); 713 for (TorqueDynamicGroupRole torqueDynamicGroupRole : collTorqueDynamicGroupRoles) 714 { 715 torqueDynamicGroupRole.setTorqueDynamicRole((TorqueDynamicRole) this); 716 } 717 } 718 } 719 else 720 { 721 // criteria has no effect for a new object 722 if (!isNew()) 723 { 724 // the following code is to determine if a new query is 725 // called for. If the criteria is the same as the last 726 // one, just return the collection. 727 criteria.and(org.apache.fulcrum.security.torque.om.TorqueDynamicGroupRolePeer.ROLE_ID, getEntityId()); 728 if (lastTorqueDynamicGroupRoleCriteria == null 729 || !lastTorqueDynamicGroupRoleCriteria.equals(criteria)) 730 { 731 collTorqueDynamicGroupRoles = org.apache.fulcrum.security.torque.om.TorqueDynamicGroupRolePeer.doSelect(criteria, con); 732 for (TorqueDynamicGroupRole torqueDynamicGroupRole : collTorqueDynamicGroupRoles) 733 { 734 torqueDynamicGroupRole.setTorqueDynamicRole((TorqueDynamicRole) this); 735 } 736 } 737 } 738 } 739 lastTorqueDynamicGroupRoleCriteria = criteria; 740 741 return collTorqueDynamicGroupRoles; 742 } 743 744 /** 745 * If this collection has already been initialized with 746 * an identical criteria, it returns the collection. 747 * Otherwise if this BaseTorqueDynamicRole is new, it will return 748 * an empty collection; or if this thisObjectClassName has previously 749 * been saved, it will retrieve the related objects from storage. 750 * 751 * This method is protected by default in order to keep the public 752 * api reasonable. You can change the access modifier to public 753 * by overriding this method in the child class. 754 * 755 * @return List<TorqueDynamicRolePermission> the collection 756 * @param criteria the criteria to use when filling the collection. 757 * @throws TorqueException if associated objects are not found 758 */ 759 protected List<TorqueDynamicRolePermission> getTorqueDynamicRolePermissionsJoinTorqueDynamicPermission(Criteria criteria) throws TorqueException 760 { 761 try (TorqueConnection connection = Transaction.begin(criteria.getDbName())) 762 { 763 List<TorqueDynamicRolePermission> result = getTorqueDynamicRolePermissionsJoinTorqueDynamicPermission(criteria, connection); 764 765 Transaction.commit(connection); 766 return result; 767 } 768 } 769 770 /** 771 * If this collection has already been initialized with 772 * an identical criteria, it returns the collection. 773 * Otherwise if this BaseTorqueDynamicRole is new, it will return 774 * an empty collection; or if this BaseTorqueDynamicRole has previously 775 * been saved, it will retrieve the related objects from storage. 776 * 777 * This method is protected by default in order to keep the public 778 * api reasonable. You can change the access modifier to public 779 * by overriding this method in the child class. 780 */ 781 protected List<TorqueDynamicRolePermission> getTorqueDynamicRolePermissionsJoinTorqueDynamicPermission(Criteria criteria, Connection connection) 782 throws TorqueException 783 { 784 if (collTorqueDynamicRolePermissions == null) 785 { 786 if (isNew()) 787 { 788 initTorqueDynamicRolePermissions(); 789 } 790 else 791 { 792 criteria.and(org.apache.fulcrum.security.torque.om.TorqueDynamicRolePermissionPeer.ROLE_ID, getEntityId()); 793 collTorqueDynamicRolePermissions = org.apache.fulcrum.security.torque.om.TorqueDynamicRolePermissionPeer.doSelectJoinTorqueDynamicPermission(criteria, connection); 794 for (TorqueDynamicRolePermission torqueDynamicRolePermission : collTorqueDynamicRolePermissions) 795 { 796 torqueDynamicRolePermission.setTorqueDynamicRole((TorqueDynamicRole) this); 797 } 798 } 799 } 800 else 801 { 802 // the following code is to determine if a new query is 803 // called for. If the criteria is the same as the last 804 // one, just return the collection. 805 criteria.and(org.apache.fulcrum.security.torque.om.TorqueDynamicRolePermissionPeer.ROLE_ID, getEntityId()); 806 if (lastTorqueDynamicRolePermissionCriteria == null 807 || !lastTorqueDynamicRolePermissionCriteria.equals(criteria)) 808 { 809 collTorqueDynamicRolePermissions = org.apache.fulcrum.security.torque.om.TorqueDynamicRolePermissionPeer.doSelectJoinTorqueDynamicPermission(criteria, connection); 810 for (TorqueDynamicRolePermission torqueDynamicRolePermission : collTorqueDynamicRolePermissions) 811 { 812 torqueDynamicRolePermission.setTorqueDynamicRole((TorqueDynamicRole) this); 813 } 814 } 815 } 816 lastTorqueDynamicRolePermissionCriteria = criteria; 817 818 return collTorqueDynamicRolePermissions; 819 } 820 821 /** 822 * If this collection has already been initialized with 823 * an identical criteria, it returns the collection. 824 * Otherwise if this BaseTorqueDynamicRole is new, it will return 825 * an empty collection; or if this thisObjectClassName has previously 826 * been saved, it will retrieve the related objects from storage. 827 * 828 * This method is protected by default in order to keep the public 829 * api reasonable. You can change the access modifier to public 830 * by overriding this method in the child class. 831 * 832 * @return List<TorqueDynamicGroupRole> the collection 833 * @param criteria the criteria to use when filling the collection. 834 * @throws TorqueException if associated objects are not found 835 */ 836 protected List<TorqueDynamicGroupRole> getTorqueDynamicGroupRolesJoinTorqueDynamicGroup(Criteria criteria) throws TorqueException 837 { 838 try (TorqueConnection connection = Transaction.begin(criteria.getDbName())) 839 { 840 List<TorqueDynamicGroupRole> result = getTorqueDynamicGroupRolesJoinTorqueDynamicGroup(criteria, connection); 841 842 Transaction.commit(connection); 843 return result; 844 } 845 } 846 847 /** 848 * If this collection has already been initialized with 849 * an identical criteria, it returns the collection. 850 * Otherwise if this BaseTorqueDynamicRole is new, it will return 851 * an empty collection; or if this BaseTorqueDynamicRole has previously 852 * been saved, it will retrieve the related objects from storage. 853 * 854 * This method is protected by default in order to keep the public 855 * api reasonable. You can change the access modifier to public 856 * by overriding this method in the child class. 857 */ 858 protected List<TorqueDynamicGroupRole> getTorqueDynamicGroupRolesJoinTorqueDynamicGroup(Criteria criteria, Connection connection) 859 throws TorqueException 860 { 861 if (collTorqueDynamicGroupRoles == null) 862 { 863 if (isNew()) 864 { 865 initTorqueDynamicGroupRoles(); 866 } 867 else 868 { 869 criteria.and(org.apache.fulcrum.security.torque.om.TorqueDynamicGroupRolePeer.ROLE_ID, getEntityId()); 870 collTorqueDynamicGroupRoles = org.apache.fulcrum.security.torque.om.TorqueDynamicGroupRolePeer.doSelectJoinTorqueDynamicGroup(criteria, connection); 871 for (TorqueDynamicGroupRole torqueDynamicGroupRole : collTorqueDynamicGroupRoles) 872 { 873 torqueDynamicGroupRole.setTorqueDynamicRole((TorqueDynamicRole) this); 874 } 875 } 876 } 877 else 878 { 879 // the following code is to determine if a new query is 880 // called for. If the criteria is the same as the last 881 // one, just return the collection. 882 criteria.and(org.apache.fulcrum.security.torque.om.TorqueDynamicGroupRolePeer.ROLE_ID, getEntityId()); 883 if (lastTorqueDynamicGroupRoleCriteria == null 884 || !lastTorqueDynamicGroupRoleCriteria.equals(criteria)) 885 { 886 collTorqueDynamicGroupRoles = org.apache.fulcrum.security.torque.om.TorqueDynamicGroupRolePeer.doSelectJoinTorqueDynamicGroup(criteria, connection); 887 for (TorqueDynamicGroupRole torqueDynamicGroupRole : collTorqueDynamicGroupRoles) 888 { 889 torqueDynamicGroupRole.setTorqueDynamicRole((TorqueDynamicRole) this); 890 } 891 } 892 } 893 lastTorqueDynamicGroupRoleCriteria = criteria; 894 895 return collTorqueDynamicGroupRoles; 896 } 897 898 899 900 901 902 /** 903 * Stores an object in the database. If the object is new, 904 * it is inserted; otherwise an update is performed. 905 * 906 * @throws TorqueException if an error occurs during saving. 907 */ 908 public void save() throws TorqueException 909 { 910 save(TorqueDynamicRolePeer.DATABASE_NAME); 911 } 912 913 /** 914 * Stores an object in the database. If the object is new, 915 * it is inserted; otherwise an update is performed. 916 * 917 * @param dbName the name of the database to which the object 918 * should be saved. 919 * 920 * @throws TorqueException if an error occurs during saving. 921 */ 922 public void save(String dbName) 923 throws TorqueException 924 { 925 try (TorqueConnection con = Transaction.begin(dbName)) 926 { 927 save(con); 928 Transaction.commit(con); 929 } 930 } 931 932 /** 933 * Stores an object in the database. If the object is new, 934 * it is inserted; otherwise an update is performed. This method 935 * is meant to be used as part of a transaction, otherwise use 936 * the save() method and the connection details will be handled 937 * internally. 938 * 939 * @param con the connection to use for saving the object, not null. 940 * 941 * @throws TorqueException if an error occurs during saving. 942 */ 943 public void save(Connection con) 944 throws TorqueException 945 { 946 if (isSaving()) 947 { 948 return; 949 } 950 try 951 { 952 setSaving(true); 953 // If this object has been modified, then save it to the database. 954 if (isModified()) 955 { 956 if (isNew()) 957 { 958 TorqueDynamicRolePeer.doInsert((TorqueDynamicRole) this, con); 959 setNew(false); 960 } 961 else 962 { 963 TorqueDynamicRolePeer.doUpdate((TorqueDynamicRole) this, con); 964 } 965 } 966 967 if (isTorqueDynamicRolePermissionsInitialized()) 968 { 969 for (TorqueDynamicRolePermission collTorqueDynamicRolePermissions : getTorqueDynamicRolePermissions()) 970 { 971 collTorqueDynamicRolePermissions.save(con); 972 } 973 } 974 if (isTorqueDynamicGroupRolesInitialized()) 975 { 976 for (TorqueDynamicGroupRole collTorqueDynamicGroupRoles : getTorqueDynamicGroupRoles()) 977 { 978 collTorqueDynamicGroupRoles.save(con); 979 } 980 } 981 } 982 finally 983 { 984 setSaving(false); 985 } 986 } 987 988 989 990 991 /** 992 * Set the PrimaryKey using ObjectKey. 993 * 994 * @param key entityId ObjectKey 995 */ 996 public void setPrimaryKey(ObjectKey<?> key) 997 998 { 999 setEntityId(Integer.valueOf(((NumberKey) key).intValue())); 1000 } 1001 1002 /** 1003 * Set the PrimaryKey using a String. 1004 * 1005 * @param key the primary key to set. 1006 */ 1007 public void setPrimaryKey(String key) 1008 { 1009 setEntityId(new Integer(key)); 1010 } 1011 1012 1013 /** 1014 * returns an id that differentiates this object from others 1015 * of its class. 1016 */ 1017 public ObjectKey<?> getPrimaryKey() 1018 { 1019 return SimpleKey.keyFor(getEntityId()); 1020 } 1021 1022 1023 1024 /** 1025 * Makes a copy of this object. 1026 * It creates a new object filling in the simple attributes. 1027 * It then fills all the association collections and sets the 1028 * related objects to isNew=true. 1029 * @throws TorqueException if retrieval of the associated objects fails 1030 */ 1031 public TorqueDynamicRole copy() throws TorqueException 1032 { 1033 return copy(true); 1034 } 1035 1036 /** 1037 * Makes a copy of this object using a connection. 1038 * It creates a new object filling in the simple attributes. 1039 * It then fills all the association collections and sets the 1040 * related objects to isNew=true. 1041 * 1042 * @param con the database connection to read associated objects. 1043 * @throws TorqueException if retrieval of the associated objects fails 1044 */ 1045 public TorqueDynamicRole copy(Connection con) throws TorqueException 1046 { 1047 return copy(true, con); 1048 } 1049 1050 /** 1051 * Makes a copy of this object. 1052 * It creates a new object filling in the simple attributes. 1053 * If the parameter deepcopy is true, it then fills all the 1054 * association collections and sets the related objects to 1055 * isNew=true. 1056 * 1057 * @param deepcopy whether to copy the associated objects. 1058 * @throws TorqueException if retrieval of the associated objects fails 1059 */ 1060 public TorqueDynamicRole copy(boolean deepcopy) throws TorqueException 1061 { 1062 TorqueDynamicRole torqueDynamicRole = new TorqueDynamicRole(); 1063 1064 return copyInto(torqueDynamicRole, deepcopy); 1065 } 1066 1067 /** 1068 * Makes a copy of this object using connection. 1069 * It creates a new object filling in the simple attributes. 1070 * If the parameter deepcopy is true, it then fills all the 1071 * association collections and sets the related objects to 1072 * isNew=true. 1073 * 1074 * @param deepcopy whether to copy the associated objects. 1075 * @param con the database connection to read associated objects. 1076 * @throws TorqueException if retrieval of the associated objects fails 1077 */ 1078 public TorqueDynamicRole copy(boolean deepcopy, Connection con) throws TorqueException 1079 { 1080 TorqueDynamicRole torqueDynamicRole = new TorqueDynamicRole(); 1081 1082 return copyInto(torqueDynamicRole, deepcopy, con); 1083 } 1084 1085 /** 1086 * Fills the copyObj with the contents of this object. 1087 * The associated objects are also copied and treated as new objects. 1088 * 1089 * @param copyObj the object to fill. 1090 * @throws TorqueException if retrieval of the associated objects fails 1091 */ 1092 public TorqueDynamicRole copyInto(TorqueDynamicRole copyObj) throws TorqueException 1093 { 1094 return copyInto(copyObj, true); 1095 } 1096 1097 /** 1098 * Fills the copyObj with the contents of this object using connection. 1099 * The associated objects are also copied and treated as new objects. 1100 * 1101 * @param copyObj the object to fill. 1102 * @param con the database connection to read associated objects. 1103 * @throws TorqueException if retrieval of the associated objects fails 1104 */ 1105 public TorqueDynamicRole copyInto(TorqueDynamicRole copyObj, Connection con) throws TorqueException 1106 { 1107 return copyInto(copyObj, true, con); 1108 } 1109 1110 /** 1111 * Fills the copyObj with the contents of this object. 1112 * If deepcopy is true, The associated objects are also copied 1113 * and treated as new objects. 1114 * 1115 * @param copyObj the object to fill. 1116 * @param deepcopy whether the associated objects should be copied. 1117 * @throws TorqueException if retrieval of the associated objects fails 1118 */ 1119 protected TorqueDynamicRole copyInto(TorqueDynamicRole copyObj, boolean deepcopy) throws TorqueException 1120 { 1121 copyObj.setEntityId((Integer) null); 1122 copyObj.setEntityName(entityName); 1123 1124 if (deepcopy) 1125 { 1126 if (collTorqueDynamicRolePermissions != null) 1127 { 1128 for (TorqueDynamicRolePermission obj : collTorqueDynamicRolePermissions) 1129 { 1130 copyObj.addTorqueDynamicRolePermission(obj.copy()); 1131 } 1132 } 1133 else 1134 { 1135 copyObj.collTorqueDynamicRolePermissions = null; 1136 } 1137 if (collTorqueDynamicGroupRoles != null) 1138 { 1139 for (TorqueDynamicGroupRole obj : collTorqueDynamicGroupRoles) 1140 { 1141 copyObj.addTorqueDynamicGroupRole(obj.copy()); 1142 } 1143 } 1144 else 1145 { 1146 copyObj.collTorqueDynamicGroupRoles = null; 1147 } 1148 } 1149 return copyObj; 1150 } 1151 1152 1153 /** 1154 * Fills the copyObj with the contents of this object using connection. 1155 * If deepcopy is true, The associated objects are also copied 1156 * and treated as new objects. 1157 * 1158 * @param copyObj the object to fill. 1159 * @param deepcopy whether the associated objects should be copied. 1160 * @param con the database connection to read associated objects. 1161 * @throws TorqueException if retrieval of the associated objects fails 1162 */ 1163 public TorqueDynamicRole copyInto(TorqueDynamicRole copyObj, boolean deepcopy, Connection con) throws TorqueException 1164 { 1165 copyObj.setEntityId((Integer) null); 1166 copyObj.setEntityName(entityName); 1167 1168 if (deepcopy) 1169 { 1170 for (TorqueDynamicRolePermission obj : getTorqueDynamicRolePermissions(con)) 1171 { 1172 copyObj.addTorqueDynamicRolePermission(obj.copy()); 1173 } 1174 for (TorqueDynamicGroupRole obj : getTorqueDynamicGroupRoles(con)) 1175 { 1176 copyObj.addTorqueDynamicGroupRole(obj.copy()); 1177 } 1178 } 1179 return copyObj; 1180 } 1181 1182 /** The Peer class */ 1183 private static final org.apache.fulcrum.security.torque.om.TorqueDynamicRolePeer peer 1184 = new org.apache.fulcrum.security.torque.om.TorqueDynamicRolePeer(); 1185 1186 /** 1187 * returns a peer instance associated with this om. Since Peer classes 1188 * are not to have any instance attributes, this method returns the 1189 * same instance for all member of this class. The method could therefore 1190 * be static, but this would prevent one from overriding the behavior. 1191 */ 1192 public org.apache.fulcrum.security.torque.om.TorqueDynamicRolePeer getPeer() 1193 { 1194 return peer; 1195 } 1196 1197 /** 1198 * Retrieves the TableMap object related to this Table data without 1199 * compiler warnings of using getPeer().getTableMap(). 1200 * 1201 * @return The associated TableMap object. 1202 * @throws TorqueException if associated objects are not found 1203 */ 1204 public TableMap getTableMap() throws TorqueException 1205 { 1206 return org.apache.fulcrum.security.torque.om.TorqueDynamicRolePeer.getTableMap(); 1207 } 1208 1209 1210 1211 public String toString() 1212 { 1213 StringBuffer str = new StringBuffer(); 1214 str.append("TorqueDynamicRole:\n"); 1215 str.append("entityId = ") 1216 .append(getEntityId()) 1217 .append("\n"); 1218 str.append("entityName = ") 1219 .append(getEntityName()) 1220 .append("\n"); 1221 return(str.toString()); 1222 } 1223 1224 /** 1225 * Compares the primary key of this instance with the key of another. 1226 * 1227 * @param toCompare The object to compare to. 1228 * @return Whether the primary keys are equal and the object have the 1229 * same class. 1230 */ 1231 public boolean equals(Object toCompare) 1232 { 1233 if (toCompare == null) 1234 { 1235 return false; 1236 } 1237 if (this == toCompare) 1238 { 1239 return true; 1240 } 1241 if (!getClass().equals(toCompare.getClass())) 1242 { 1243 return false; 1244 } 1245 TorqueDynamicRole other = (TorqueDynamicRole) toCompare; 1246 if (getPrimaryKey() == null || other.getPrimaryKey() == null) 1247 { 1248 return false; 1249 } 1250 return getPrimaryKey().equals(other.getPrimaryKey()); 1251 } 1252 1253 /** 1254 * If the primary key is not <code>null</code>, return the hashcode of the 1255 * primary key. Otherwise calls <code>Object.hashCode()</code>. 1256 * 1257 * @return an <code>int</code> value 1258 */ 1259 public int hashCode() 1260 { 1261 ObjectKey<?> ok = getPrimaryKey(); 1262 if (ok == null) 1263 { 1264 return super.hashCode(); 1265 } 1266 1267 return ok.hashCode(); 1268 } 1269 1270 1271 1272 /** 1273 * Compares the content of this object to another object 1274 * 1275 * @param toCompare The object to compare to. 1276 * @return true if all of the columns in the other object have 1277 * the same value as the objects in this class. 1278 */ 1279 public boolean valueEquals(TorqueDynamicRole toCompare) 1280 { 1281 if (toCompare == null) 1282 { 1283 return false; 1284 } 1285 if (this == toCompare) 1286 { 1287 return true; 1288 } 1289 if (!Objects.equals(this.entityId, toCompare.getEntityId())) 1290 { 1291 return false; 1292 } 1293 if (!Objects.equals(this.entityName, toCompare.getEntityName())) 1294 { 1295 return false; 1296 } 1297 return true; 1298 } 1299 1300 1301 1302}