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 27 28 36 public abstract class BaseNewsSubscription extends BaseObject 37 implements org.apache.turbine.om.Retrievable 38 { 39 40 private static final NewsSubscriptionPeer peer = 41 new NewsSubscriptionPeer(); 42 43 44 45 private int newsSubsId; 46 47 48 private String newsSubsCode = "AUTO"; 49 50 51 private int status = 30; 52 53 54 private int priority = 30; 55 56 57 private Date issuedDate; 58 59 60 private Date closedDate; 61 62 63 private String email; 64 65 66 private int projectId = 1000; 67 68 69 private int productId = 1000; 70 71 72 private String subject = "---"; 73 74 75 private String notes; 76 77 78 private Date created; 79 80 81 private Date modified; 82 83 84 private String createdBy; 85 86 87 private String modifiedBy; 88 89 90 95 public int getNewsSubsId() 96 { 97 return newsSubsId; 98 } 99 100 101 106 public void setNewsSubsId(int v) 107 { 108 109 if (this.newsSubsId != v) 110 { 111 this.newsSubsId = v; 112 setModified(true); 113 } 114 115 116 } 117 118 123 public String getNewsSubsCode() 124 { 125 return newsSubsCode; 126 } 127 128 129 134 public void setNewsSubsCode(String v) 135 { 136 137 if (!ObjectUtils.equals(this.newsSubsCode, v)) 138 { 139 this.newsSubsCode = v; 140 setModified(true); 141 } 142 143 144 } 145 146 151 public int getStatus() 152 { 153 return status; 154 } 155 156 157 162 public void setStatus(int v) 163 { 164 165 if (this.status != v) 166 { 167 this.status = v; 168 setModified(true); 169 } 170 171 172 } 173 174 179 public int getPriority() 180 { 181 return priority; 182 } 183 184 185 190 public void setPriority(int v) 191 { 192 193 if (this.priority != v) 194 { 195 this.priority = v; 196 setModified(true); 197 } 198 199 200 } 201 202 207 public Date getIssuedDate() 208 { 209 return issuedDate; 210 } 211 212 213 218 public void setIssuedDate(Date v) 219 { 220 221 if (!ObjectUtils.equals(this.issuedDate, v)) 222 { 223 this.issuedDate = v; 224 setModified(true); 225 } 226 227 228 } 229 230 235 public Date getClosedDate() 236 { 237 return closedDate; 238 } 239 240 241 246 public void setClosedDate(Date v) 247 { 248 249 if (!ObjectUtils.equals(this.closedDate, v)) 250 { 251 this.closedDate = v; 252 setModified(true); 253 } 254 255 256 } 257 258 263 public String getEmail() 264 { 265 return email; 266 } 267 268 269 274 public void setEmail(String v) 275 { 276 277 if (!ObjectUtils.equals(this.email, v)) 278 { 279 this.email = v; 280 setModified(true); 281 } 282 283 284 } 285 286 291 public int getProjectId() 292 { 293 return projectId; 294 } 295 296 297 302 public void setProjectId(int v) throws TorqueException 303 { 304 305 if (this.projectId != v) 306 { 307 this.projectId = v; 308 setModified(true); 309 } 310 311 312 if (aProject != null && !(aProject.getProjectId() == v)) 313 { 314 aProject = null; 315 } 316 317 } 318 319 324 public int getProductId() 325 { 326 return productId; 327 } 328 329 330 335 public void setProductId(int v) throws TorqueException 336 { 337 338 if (this.productId != v) 339 { 340 this.productId = v; 341 setModified(true); 342 } 343 344 345 if (aProduct != null && !(aProduct.getProductId() == v)) 346 { 347 aProduct = null; 348 } 349 350 } 351 352 357 public String getSubject() 358 { 359 return subject; 360 } 361 362 363 368 public void setSubject(String v) 369 { 370 371 if (!ObjectUtils.equals(this.subject, v)) 372 { 373 this.subject = v; 374 setModified(true); 375 } 376 377 378 } 379 380 385 public String getNotes() 386 { 387 return notes; 388 } 389 390 391 396 public void setNotes(String v) 397 { 398 399 if (!ObjectUtils.equals(this.notes, v)) 400 { 401 this.notes = v; 402 setModified(true); 403 } 404 405 406 } 407 408 413 public Date getCreated() 414 { 415 return created; 416 } 417 418 419 424 public void setCreated(Date v) 425 { 426 427 if (!ObjectUtils.equals(this.created, v)) 428 { 429 this.created = v; 430 setModified(true); 431 } 432 433 434 } 435 436 441 public Date getModified() 442 { 443 return modified; 444 } 445 446 447 452 public void setModified(Date v) 453 { 454 455 if (!ObjectUtils.equals(this.modified, v)) 456 { 457 this.modified = v; 458 setModified(true); 459 } 460 461 462 } 463 464 469 public String getCreatedBy() 470 { 471 return createdBy; 472 } 473 474 475 480 public void setCreatedBy(String v) 481 { 482 483 if (!ObjectUtils.equals(this.createdBy, v)) 484 { 485 this.createdBy = v; 486 setModified(true); 487 } 488 489 490 } 491 492 497 public String getModifiedBy() 498 { 499 return modifiedBy; 500 } 501 502 503 508 public void setModifiedBy(String v) 509 { 510 511 if (!ObjectUtils.equals(this.modifiedBy, v)) 512 { 513 this.modifiedBy = v; 514 setModified(true); 515 } 516 517 518 } 519 520 521 522 523 524 private Project aProject; 525 526 532 public void setProject(Project v) throws TorqueException 533 { 534 if (v == null) 535 { 536 setProjectId( 1000); 537 } 538 else 539 { 540 setProjectId(v.getProjectId()); 541 } 542 aProject = v; 543 } 544 545 546 552 public Project getProject() throws TorqueException 553 { 554 if (aProject == null && (this.projectId != 0)) 555 { 556 aProject = ProjectPeer.retrieveByPK(SimpleKey.keyFor(this.projectId)); 557 558 567 } 568 return aProject; 569 } 570 571 577 public void setProjectKey(ObjectKey key) throws TorqueException 578 { 579 580 setProjectId(((NumberKey) key).intValue()); 581 } 582 583 584 585 586 private Product aProduct; 587 588 594 public void setProduct(Product v) throws TorqueException 595 { 596 if (v == null) 597 { 598 setProductId( 1000); 599 } 600 else 601 { 602 setProductId(v.getProductId()); 603 } 604 aProduct = v; 605 } 606 607 608 614 public Product getProduct() throws TorqueException 615 { 616 if (aProduct == null && (this.productId != 0)) 617 { 618 aProduct = ProductPeer.retrieveByPK(SimpleKey.keyFor(this.productId)); 619 620 629 } 630 return aProduct; 631 } 632 633 639 public void setProductKey(ObjectKey key) throws TorqueException 640 { 641 642 setProductId(((NumberKey) key).intValue()); 643 } 644 645 646 private static List fieldNames = null; 647 648 653 public static synchronized List getFieldNames() 654 { 655 if (fieldNames == null) 656 { 657 fieldNames = new ArrayList (); 658 fieldNames.add("NewsSubsId"); 659 fieldNames.add("NewsSubsCode"); 660 fieldNames.add("Status"); 661 fieldNames.add("Priority"); 662 fieldNames.add("IssuedDate"); 663 fieldNames.add("ClosedDate"); 664 fieldNames.add("Email"); 665 fieldNames.add("ProjectId"); 666 fieldNames.add("ProductId"); 667 fieldNames.add("Subject"); 668 fieldNames.add("Notes"); 669 fieldNames.add("Created"); 670 fieldNames.add("Modified"); 671 fieldNames.add("CreatedBy"); 672 fieldNames.add("ModifiedBy"); 673 fieldNames = Collections.unmodifiableList(fieldNames); 674 } 675 return fieldNames; 676 } 677 678 684 public Object getByName(String name) 685 { 686 if (name.equals("NewsSubsId")) 687 { 688 return new Integer (getNewsSubsId()); 689 } 690 if (name.equals("NewsSubsCode")) 691 { 692 return getNewsSubsCode(); 693 } 694 if (name.equals("Status")) 695 { 696 return new Integer (getStatus()); 697 } 698 if (name.equals("Priority")) 699 { 700 return new Integer (getPriority()); 701 } 702 if (name.equals("IssuedDate")) 703 { 704 return getIssuedDate(); 705 } 706 if (name.equals("ClosedDate")) 707 { 708 return getClosedDate(); 709 } 710 if (name.equals("Email")) 711 { 712 return getEmail(); 713 } 714 if (name.equals("ProjectId")) 715 { 716 return new Integer (getProjectId()); 717 } 718 if (name.equals("ProductId")) 719 { 720 return new Integer (getProductId()); 721 } 722 if (name.equals("Subject")) 723 { 724 return getSubject(); 725 } 726 if (name.equals("Notes")) 727 { 728 return getNotes(); 729 } 730 if (name.equals("Created")) 731 { 732 return getCreated(); 733 } 734 if (name.equals("Modified")) 735 { 736 return getModified(); 737 } 738 if (name.equals("CreatedBy")) 739 { 740 return getCreatedBy(); 741 } 742 if (name.equals("ModifiedBy")) 743 { 744 return getModifiedBy(); 745 } 746 return null; 747 } 748 749 757 public Object getByPeerName(String name) 758 { 759 if (name.equals(NewsSubscriptionPeer.NEWS_SUBS_ID)) 760 { 761 return new Integer (getNewsSubsId()); 762 } 763 if (name.equals(NewsSubscriptionPeer.NEWS_SUBS_CODE)) 764 { 765 return getNewsSubsCode(); 766 } 767 if (name.equals(NewsSubscriptionPeer.STATUS)) 768 { 769 return new Integer (getStatus()); 770 } 771 if (name.equals(NewsSubscriptionPeer.PRIORITY)) 772 { 773 return new Integer (getPriority()); 774 } 775 if (name.equals(NewsSubscriptionPeer.ISSUED_DATE)) 776 { 777 return getIssuedDate(); 778 } 779 if (name.equals(NewsSubscriptionPeer.CLOSED_DATE)) 780 { 781 return getClosedDate(); 782 } 783 if (name.equals(NewsSubscriptionPeer.EMAIL)) 784 { 785 return getEmail(); 786 } 787 if (name.equals(NewsSubscriptionPeer.PROJECT_ID)) 788 { 789 return new Integer (getProjectId()); 790 } 791 if (name.equals(NewsSubscriptionPeer.PRODUCT_ID)) 792 { 793 return new Integer (getProductId()); 794 } 795 if (name.equals(NewsSubscriptionPeer.SUBJECT)) 796 { 797 return getSubject(); 798 } 799 if (name.equals(NewsSubscriptionPeer.NOTES)) 800 { 801 return getNotes(); 802 } 803 if (name.equals(NewsSubscriptionPeer.CREATED)) 804 { 805 return getCreated(); 806 } 807 if (name.equals(NewsSubscriptionPeer.MODIFIED)) 808 { 809 return getModified(); 810 } 811 if (name.equals(NewsSubscriptionPeer.CREATED_BY)) 812 { 813 return getCreatedBy(); 814 } 815 if (name.equals(NewsSubscriptionPeer.MODIFIED_BY)) 816 { 817 return getModifiedBy(); 818 } 819 return null; 820 } 821 822 829 public Object getByPosition(int pos) 830 { 831 if (pos == 0) 832 { 833 return new Integer (getNewsSubsId()); 834 } 835 if (pos == 1) 836 { 837 return getNewsSubsCode(); 838 } 839 if (pos == 2) 840 { 841 return new Integer (getStatus()); 842 } 843 if (pos == 3) 844 { 845 return new Integer (getPriority()); 846 } 847 if (pos == 4) 848 { 849 return getIssuedDate(); 850 } 851 if (pos == 5) 852 { 853 return getClosedDate(); 854 } 855 if (pos == 6) 856 { 857 return getEmail(); 858 } 859 if (pos == 7) 860 { 861 return new Integer (getProjectId()); 862 } 863 if (pos == 8) 864 { 865 return new Integer (getProductId()); 866 } 867 if (pos == 9) 868 { 869 return getSubject(); 870 } 871 if (pos == 10) 872 { 873 return getNotes(); 874 } 875 if (pos == 11) 876 { 877 return getCreated(); 878 } 879 if (pos == 12) 880 { 881 return getModified(); 882 } 883 if (pos == 13) 884 { 885 return getCreatedBy(); 886 } 887 if (pos == 14) 888 { 889 return getModifiedBy(); 890 } 891 return null; 892 } 893 894 900 public void save() throws Exception  901 { 902 save(NewsSubscriptionPeer.getMapBuilder() 903 .getDatabaseMap().getName()); 904 } 905 906 916 public void save(String dbName) throws TorqueException 917 { 918 Connection con = null; 919 try 920 { 921 con = Transaction.begin(dbName); 922 save(con); 923 Transaction.commit(con); 924 } 925 catch(TorqueException e) 926 { 927 Transaction.safeRollback(con); 928 throw e; 929 } 930 } 931 932 934 private boolean alreadyInSave = false; 935 945 public void save(Connection con) throws TorqueException 946 { 947 if (!alreadyInSave) 948 { 949 alreadyInSave = true; 950 951 952 953 if (isModified()) 955 { 956 if (isNew()) 957 { 958 NewsSubscriptionPeer.doInsert((NewsSubscription) this, con); 959 setNew(false); 960 } 961 else 962 { 963 NewsSubscriptionPeer.doUpdate((NewsSubscription) this, con); 964 } 965 } 966 967 alreadyInSave = false; 968 } 969 } 970 971 972 977 public void setPrimaryKey(ObjectKey key) 978 979 { 980 setNewsSubsId(((NumberKey) key).intValue()); 981 } 982 983 988 public void setPrimaryKey(String key) 989 { 990 setNewsSubsId(Integer.parseInt(key)); 991 } 992 993 994 998 public ObjectKey getPrimaryKey() 999 { 1000 return SimpleKey.keyFor(getNewsSubsId()); 1001 } 1002 1003 1007 public String getQueryKey() 1008 { 1009 if (getPrimaryKey() == null) 1010 { 1011 return ""; 1012 } 1013 else 1014 { 1015 return getPrimaryKey().toString(); 1016 } 1017 } 1018 1019 1023 public void setQueryKey(String key) 1024 throws TorqueException 1025 { 1026 setPrimaryKey(key); 1027 } 1028 1029 1035 public NewsSubscription copy() throws TorqueException 1036 { 1037 return copyInto(new NewsSubscription()); 1038 } 1039 1040 protected NewsSubscription copyInto(NewsSubscription copyObj) throws TorqueException 1041 { 1042 copyObj.setNewsSubsId(newsSubsId); 1043 copyObj.setNewsSubsCode(newsSubsCode); 1044 copyObj.setStatus(status); 1045 copyObj.setPriority(priority); 1046 copyObj.setIssuedDate(issuedDate); 1047 copyObj.setClosedDate(closedDate); 1048 copyObj.setEmail(email); 1049 copyObj.setProjectId(projectId); 1050 copyObj.setProductId(productId); 1051 copyObj.setSubject(subject); 1052 copyObj.setNotes(notes); 1053 copyObj.setCreated(created); 1054 copyObj.setModified(modified); 1055 copyObj.setCreatedBy(createdBy); 1056 copyObj.setModifiedBy(modifiedBy); 1057 1058 copyObj.setNewsSubsId( 0); 1059 1060 return copyObj; 1061 } 1062 1063 1069 public NewsSubscriptionPeer getPeer() 1070 { 1071 return peer; 1072 } 1073 1074 public String toString() 1075 { 1076 StringBuffer str = new StringBuffer (); 1077 str.append("NewsSubscription:\n"); 1078 str.append("NewsSubsId = ") 1079 .append(getNewsSubsId()) 1080 .append("\n"); 1081 str.append("NewsSubsCode = ") 1082 .append(getNewsSubsCode()) 1083 .append("\n"); 1084 str.append("Status = ") 1085 .append(getStatus()) 1086 .append("\n"); 1087 str.append("Priority = ") 1088 .append(getPriority()) 1089 .append("\n"); 1090 str.append("IssuedDate = ") 1091 .append(getIssuedDate()) 1092 .append("\n"); 1093 str.append("ClosedDate = ") 1094 .append(getClosedDate()) 1095 .append("\n"); 1096 str.append("Email = ") 1097 .append(getEmail()) 1098 .append("\n"); 1099 str.append("ProjectId = ") 1100 .append(getProjectId()) 1101 .append("\n"); 1102 str.append("ProductId = ") 1103 .append(getProductId()) 1104 .append("\n"); 1105 str.append("Subject = ") 1106 .append(getSubject()) 1107 .append("\n"); 1108 str.append("Notes = ") 1109 .append(getNotes()) 1110 .append("\n"); 1111 str.append("Created = ") 1112 .append(getCreated()) 1113 .append("\n"); 1114 str.append("Modified = ") 1115 .append(getModified()) 1116 .append("\n"); 1117 str.append("CreatedBy = ") 1118 .append(getCreatedBy()) 1119 .append("\n"); 1120 str.append("ModifiedBy = ") 1121 .append(getModifiedBy()) 1122 .append("\n"); 1123 return(str.toString()); 1124 } 1125} 1126
| Popular Tags
|