1 package org.campware.cream.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.turbine.om.Retrievable; 13 import org.apache.torque.TorqueException; 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 34 public abstract class BaseEducationCategory extends BaseObject 35 implements org.apache.turbine.om.Retrievable 36 { 37 38 private static final EducationCategoryPeer peer = 39 new EducationCategoryPeer(); 40 41 42 43 private int educationCatId; 44 45 46 private String educationCatName; 47 48 49 54 public int getEducationCatId() 55 { 56 return educationCatId; 57 } 58 59 60 65 public void setEducationCatId(int v) throws TorqueException 66 { 67 68 if (this.educationCatId != v) 69 { 70 this.educationCatId = v; 71 setModified(true); 72 } 73 74 75 76 if (collCustomers != null) 78 { 79 for (int i = 0; i < collCustomers.size(); i++) 80 { 81 ((Customer) collCustomers.get(i)) 82 .setEducationCatId(v); 83 } 84 } 85 } 86 87 92 public String getEducationCatName() 93 { 94 return educationCatName; 95 } 96 97 98 103 public void setEducationCatName(String v) 104 { 105 106 if (!ObjectUtils.equals(this.educationCatName, v)) 107 { 108 this.educationCatName = v; 109 setModified(true); 110 } 111 112 113 } 114 115 116 117 118 121 protected List collCustomers; 122 123 128 protected void initCustomers() 129 { 130 if (collCustomers == null) 131 { 132 collCustomers = new ArrayList (); 133 } 134 } 135 136 143 public void addCustomer(Customer l) throws TorqueException 144 { 145 getCustomers().add(l); 146 l.setEducationCategory((EducationCategory) this); 147 } 148 149 152 private Criteria lastCustomersCriteria = null; 153 154 161 public List getCustomers() throws TorqueException 162 { 163 if (collCustomers == null) 164 { 165 collCustomers = getCustomers(new Criteria(10)); 166 } 167 return collCustomers; 168 } 169 170 181 public List getCustomers(Criteria criteria) throws TorqueException 182 { 183 if (collCustomers == null) 184 { 185 if (isNew()) 186 { 187 collCustomers = new ArrayList (); 188 } 189 else 190 { 191 criteria.add(CustomerPeer.EDUCATION_CAT_ID, getEducationCatId() ); 192 collCustomers = CustomerPeer.doSelect(criteria); 193 } 194 } 195 else 196 { 197 if (!isNew()) 199 { 200 criteria.add(CustomerPeer.EDUCATION_CAT_ID, getEducationCatId()); 204 if (!lastCustomersCriteria.equals(criteria)) 205 { 206 collCustomers = CustomerPeer.doSelect(criteria); 207 } 208 } 209 } 210 lastCustomersCriteria = criteria; 211 212 return collCustomers; 213 } 214 215 223 public List getCustomers(Connection con) throws TorqueException 224 { 225 if (collCustomers == null) 226 { 227 collCustomers = getCustomers(new Criteria(10), con); 228 } 229 return collCustomers; 230 } 231 232 244 public List getCustomers(Criteria criteria, Connection con) 245 throws TorqueException 246 { 247 if (collCustomers == null) 248 { 249 if (isNew()) 250 { 251 collCustomers = new ArrayList (); 252 } 253 else 254 { 255 criteria.add(CustomerPeer.EDUCATION_CAT_ID, getEducationCatId()); 256 collCustomers = CustomerPeer.doSelect(criteria, con); 257 } 258 } 259 else 260 { 261 if (!isNew()) 263 { 264 criteria.add(CustomerPeer.EDUCATION_CAT_ID, getEducationCatId()); 268 if (!lastCustomersCriteria.equals(criteria)) 269 { 270 collCustomers = CustomerPeer.doSelect(criteria, con); 271 } 272 } 273 } 274 lastCustomersCriteria = criteria; 275 276 return collCustomers; 277 } 278 279 280 281 282 283 284 285 286 287 288 289 300 protected List getCustomersJoinCustomerCategory(Criteria criteria) 301 throws TorqueException 302 { 303 if (collCustomers == null) 304 { 305 if (isNew()) 306 { 307 collCustomers = new ArrayList (); 308 } 309 else 310 { 311 criteria.add(CustomerPeer.EDUCATION_CAT_ID, getEducationCatId()); 312 collCustomers = CustomerPeer.doSelectJoinCustomerCategory(criteria); 313 } 314 } 315 else 316 { 317 321 criteria.add(CustomerPeer.EDUCATION_CAT_ID, getEducationCatId()); 322 if (!lastCustomersCriteria.equals(criteria)) 323 { 324 collCustomers = CustomerPeer.doSelectJoinCustomerCategory(criteria); 325 } 326 } 327 lastCustomersCriteria = criteria; 328 329 return collCustomers; 330 } 331 332 333 334 335 336 337 338 339 340 351 protected List getCustomersJoinCountry(Criteria criteria) 352 throws TorqueException 353 { 354 if (collCustomers == null) 355 { 356 if (isNew()) 357 { 358 collCustomers = new ArrayList (); 359 } 360 else 361 { 362 criteria.add(CustomerPeer.EDUCATION_CAT_ID, getEducationCatId()); 363 collCustomers = CustomerPeer.doSelectJoinCountry(criteria); 364 } 365 } 366 else 367 { 368 372 criteria.add(CustomerPeer.EDUCATION_CAT_ID, getEducationCatId()); 373 if (!lastCustomersCriteria.equals(criteria)) 374 { 375 collCustomers = CustomerPeer.doSelectJoinCountry(criteria); 376 } 377 } 378 lastCustomersCriteria = criteria; 379 380 return collCustomers; 381 } 382 383 384 385 386 387 388 389 390 391 402 protected List getCustomersJoinRegion(Criteria criteria) 403 throws TorqueException 404 { 405 if (collCustomers == null) 406 { 407 if (isNew()) 408 { 409 collCustomers = new ArrayList (); 410 } 411 else 412 { 413 criteria.add(CustomerPeer.EDUCATION_CAT_ID, getEducationCatId()); 414 collCustomers = CustomerPeer.doSelectJoinRegion(criteria); 415 } 416 } 417 else 418 { 419 423 criteria.add(CustomerPeer.EDUCATION_CAT_ID, getEducationCatId()); 424 if (!lastCustomersCriteria.equals(criteria)) 425 { 426 collCustomers = CustomerPeer.doSelectJoinRegion(criteria); 427 } 428 } 429 lastCustomersCriteria = criteria; 430 431 return collCustomers; 432 } 433 434 435 436 437 438 439 440 441 442 453 protected List getCustomersJoinLanguage(Criteria criteria) 454 throws TorqueException 455 { 456 if (collCustomers == null) 457 { 458 if (isNew()) 459 { 460 collCustomers = new ArrayList (); 461 } 462 else 463 { 464 criteria.add(CustomerPeer.EDUCATION_CAT_ID, getEducationCatId()); 465 collCustomers = CustomerPeer.doSelectJoinLanguage(criteria); 466 } 467 } 468 else 469 { 470 474 criteria.add(CustomerPeer.EDUCATION_CAT_ID, getEducationCatId()); 475 if (!lastCustomersCriteria.equals(criteria)) 476 { 477 collCustomers = CustomerPeer.doSelectJoinLanguage(criteria); 478 } 479 } 480 lastCustomersCriteria = criteria; 481 482 return collCustomers; 483 } 484 485 486 487 488 489 490 491 492 493 504 protected List getCustomersJoinEducationCategory(Criteria criteria) 505 throws TorqueException 506 { 507 if (collCustomers == null) 508 { 509 if (isNew()) 510 { 511 collCustomers = new ArrayList (); 512 } 513 else 514 { 515 criteria.add(CustomerPeer.EDUCATION_CAT_ID, getEducationCatId()); 516 collCustomers = CustomerPeer.doSelectJoinEducationCategory(criteria); 517 } 518 } 519 else 520 { 521 525 criteria.add(CustomerPeer.EDUCATION_CAT_ID, getEducationCatId()); 526 if (!lastCustomersCriteria.equals(criteria)) 527 { 528 collCustomers = CustomerPeer.doSelectJoinEducationCategory(criteria); 529 } 530 } 531 lastCustomersCriteria = criteria; 532 533 return collCustomers; 534 } 535 536 537 538 539 540 541 542 543 544 555 protected List getCustomersJoinHouseholdCategory(Criteria criteria) 556 throws TorqueException 557 { 558 if (collCustomers == null) 559 { 560 if (isNew()) 561 { 562 collCustomers = new ArrayList (); 563 } 564 else 565 { 566 criteria.add(CustomerPeer.EDUCATION_CAT_ID, getEducationCatId()); 567 collCustomers = CustomerPeer.doSelectJoinHouseholdCategory(criteria); 568 } 569 } 570 else 571 { 572 576 criteria.add(CustomerPeer.EDUCATION_CAT_ID, getEducationCatId()); 577 if (!lastCustomersCriteria.equals(criteria)) 578 { 579 collCustomers = CustomerPeer.doSelectJoinHouseholdCategory(criteria); 580 } 581 } 582 lastCustomersCriteria = criteria; 583 584 return collCustomers; 585 } 586 587 588 589 590 private static List fieldNames = null; 591 592 597 public static synchronized List getFieldNames() 598 { 599 if (fieldNames == null) 600 { 601 fieldNames = new ArrayList (); 602 fieldNames.add("EducationCatId"); 603 fieldNames.add("EducationCatName"); 604 fieldNames = Collections.unmodifiableList(fieldNames); 605 } 606 return fieldNames; 607 } 608 609 615 public Object getByName(String name) 616 { 617 if (name.equals("EducationCatId")) 618 { 619 return new Integer (getEducationCatId()); 620 } 621 if (name.equals("EducationCatName")) 622 { 623 return getEducationCatName(); 624 } 625 return null; 626 } 627 628 636 public Object getByPeerName(String name) 637 { 638 if (name.equals(EducationCategoryPeer.EDUCATION_CAT_ID)) 639 { 640 return new Integer (getEducationCatId()); 641 } 642 if (name.equals(EducationCategoryPeer.EDUCATION_CAT_NAME)) 643 { 644 return getEducationCatName(); 645 } 646 return null; 647 } 648 649 656 public Object getByPosition(int pos) 657 { 658 if (pos == 0) 659 { 660 return new Integer (getEducationCatId()); 661 } 662 if (pos == 1) 663 { 664 return getEducationCatName(); 665 } 666 return null; 667 } 668 669 675 public void save() throws Exception  676 { 677 save(EducationCategoryPeer.getMapBuilder() 678 .getDatabaseMap().getName()); 679 } 680 681 691 public void save(String dbName) throws TorqueException 692 { 693 Connection con = null; 694 try 695 { 696 con = Transaction.begin(dbName); 697 save(con); 698 Transaction.commit(con); 699 } 700 catch(TorqueException e) 701 { 702 Transaction.safeRollback(con); 703 throw e; 704 } 705 } 706 707 709 private boolean alreadyInSave = false; 710 720 public void save(Connection con) throws TorqueException 721 { 722 if (!alreadyInSave) 723 { 724 alreadyInSave = true; 725 726 727 728 if (isModified()) 730 { 731 if (isNew()) 732 { 733 EducationCategoryPeer.doInsert((EducationCategory) this, con); 734 setNew(false); 735 } 736 else 737 { 738 EducationCategoryPeer.doUpdate((EducationCategory) this, con); 739 } 740 } 741 742 743 744 if (collCustomers != null) 745 { 746 for (int i = 0; i < collCustomers.size(); i++) 747 { 748 ((Customer) collCustomers.get(i)).save(con); 749 } 750 } 751 alreadyInSave = false; 752 } 753 } 754 755 756 761 public void setPrimaryKey(ObjectKey key) 762 throws TorqueException 763 { 764 setEducationCatId(((NumberKey) key).intValue()); 765 } 766 767 772 public void setPrimaryKey(String key) throws TorqueException 773 { 774 setEducationCatId(Integer.parseInt(key)); 775 } 776 777 778 782 public ObjectKey getPrimaryKey() 783 { 784 return SimpleKey.keyFor(getEducationCatId()); 785 } 786 787 791 public String getQueryKey() 792 { 793 if (getPrimaryKey() == null) 794 { 795 return ""; 796 } 797 else 798 { 799 return getPrimaryKey().toString(); 800 } 801 } 802 803 807 public void setQueryKey(String key) 808 throws TorqueException 809 { 810 setPrimaryKey(key); 811 } 812 813 819 public EducationCategory copy() throws TorqueException 820 { 821 return copyInto(new EducationCategory()); 822 } 823 824 protected EducationCategory copyInto(EducationCategory copyObj) throws TorqueException 825 { 826 copyObj.setEducationCatId(educationCatId); 827 copyObj.setEducationCatName(educationCatName); 828 829 copyObj.setEducationCatId( 0); 830 831 832 833 List v = getCustomers(); 834 for (int i = 0; i < v.size(); i++) 835 { 836 Customer obj = (Customer) v.get(i); 837 copyObj.addCustomer(obj.copy()); 838 } 839 return copyObj; 840 } 841 842 848 public EducationCategoryPeer getPeer() 849 { 850 return peer; 851 } 852 853 public String toString() 854 { 855 StringBuffer str = new StringBuffer (); 856 str.append("EducationCategory:\n"); 857 str.append("EducationCatId = ") 858 .append(getEducationCatId()) 859 .append("\n"); 860 str.append("EducationCatName = ") 861 .append(getEducationCatName()) 862 .append("\n"); 863 return(str.toString()); 864 } 865 } 866
| Popular Tags
|