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 29 30 31 32 40 public abstract class BasePaymentItem extends BaseObject 41 implements org.apache.turbine.om.Retrievable 42 { 43 44 private static final PaymentItemPeer peer = 45 new PaymentItemPeer(); 46 47 48 49 private int paymentItemId; 50 51 52 private int paymentId = 1000; 53 54 55 private int sorderId = 1000; 56 57 58 private int customerId = 1000; 59 60 61 private int projectId = 1000; 62 63 64 private int productId = 1000; 65 66 67 private String description; 68 69 70 private BigDecimal unitPrice= new BigDecimal (0); 71 72 73 private int quantity = 1; 74 75 76 private int currencyId = 1000; 77 78 79 private BigDecimal itemCurrTotal= new BigDecimal (0); 80 81 82 private BigDecimal itemTotal= new BigDecimal (0); 83 84 85 90 public int getPaymentItemId() 91 { 92 return paymentItemId; 93 } 94 95 96 101 public void setPaymentItemId(int v) 102 { 103 104 if (this.paymentItemId != v) 105 { 106 this.paymentItemId = v; 107 setModified(true); 108 } 109 110 111 } 112 113 118 public int getPaymentId() 119 { 120 return paymentId; 121 } 122 123 124 129 public void setPaymentId(int v) throws TorqueException 130 { 131 132 if (this.paymentId != v) 133 { 134 this.paymentId = v; 135 setModified(true); 136 } 137 138 139 if (aPayment != null && !(aPayment.getPaymentId() == v)) 140 { 141 aPayment = null; 142 } 143 144 } 145 146 151 public int getSorderId() 152 { 153 return sorderId; 154 } 155 156 157 162 public void setSorderId(int v) throws TorqueException 163 { 164 165 if (this.sorderId != v) 166 { 167 this.sorderId = v; 168 setModified(true); 169 } 170 171 172 if (aSorder != null && !(aSorder.getSorderId() == v)) 173 { 174 aSorder = null; 175 } 176 177 } 178 179 184 public int getCustomerId() 185 { 186 return customerId; 187 } 188 189 190 195 public void setCustomerId(int v) throws TorqueException 196 { 197 198 if (this.customerId != v) 199 { 200 this.customerId = v; 201 setModified(true); 202 } 203 204 205 if (aCustomer != null && !(aCustomer.getCustomerId() == v)) 206 { 207 aCustomer = null; 208 } 209 210 } 211 212 217 public int getProjectId() 218 { 219 return projectId; 220 } 221 222 223 228 public void setProjectId(int v) throws TorqueException 229 { 230 231 if (this.projectId != v) 232 { 233 this.projectId = v; 234 setModified(true); 235 } 236 237 238 if (aProject != null && !(aProject.getProjectId() == v)) 239 { 240 aProject = null; 241 } 242 243 } 244 245 250 public int getProductId() 251 { 252 return productId; 253 } 254 255 256 261 public void setProductId(int v) throws TorqueException 262 { 263 264 if (this.productId != v) 265 { 266 this.productId = v; 267 setModified(true); 268 } 269 270 271 if (aProduct != null && !(aProduct.getProductId() == v)) 272 { 273 aProduct = null; 274 } 275 276 } 277 278 283 public String getDescription() 284 { 285 return description; 286 } 287 288 289 294 public void setDescription(String v) 295 { 296 297 if (!ObjectUtils.equals(this.description, v)) 298 { 299 this.description = v; 300 setModified(true); 301 } 302 303 304 } 305 306 311 public BigDecimal getUnitPrice() 312 { 313 return unitPrice; 314 } 315 316 317 322 public void setUnitPrice(BigDecimal v) 323 { 324 325 if (!ObjectUtils.equals(this.unitPrice, v)) 326 { 327 this.unitPrice = v; 328 setModified(true); 329 } 330 331 332 } 333 334 339 public int getQuantity() 340 { 341 return quantity; 342 } 343 344 345 350 public void setQuantity(int v) 351 { 352 353 if (this.quantity != v) 354 { 355 this.quantity = v; 356 setModified(true); 357 } 358 359 360 } 361 362 367 public int getCurrencyId() 368 { 369 return currencyId; 370 } 371 372 373 378 public void setCurrencyId(int v) throws TorqueException 379 { 380 381 if (this.currencyId != v) 382 { 383 this.currencyId = v; 384 setModified(true); 385 } 386 387 388 if (aCurrency != null && !(aCurrency.getCurrencyId() == v)) 389 { 390 aCurrency = null; 391 } 392 393 } 394 395 400 public BigDecimal getItemCurrTotal() 401 { 402 return itemCurrTotal; 403 } 404 405 406 411 public void setItemCurrTotal(BigDecimal v) 412 { 413 414 if (!ObjectUtils.equals(this.itemCurrTotal, v)) 415 { 416 this.itemCurrTotal = v; 417 setModified(true); 418 } 419 420 421 } 422 423 428 public BigDecimal getItemTotal() 429 { 430 return itemTotal; 431 } 432 433 434 439 public void setItemTotal(BigDecimal v) 440 { 441 442 if (!ObjectUtils.equals(this.itemTotal, v)) 443 { 444 this.itemTotal = v; 445 setModified(true); 446 } 447 448 449 } 450 451 452 453 454 455 private Payment aPayment; 456 457 463 public void setPayment(Payment v) throws TorqueException 464 { 465 if (v == null) 466 { 467 setPaymentId( 1000); 468 } 469 else 470 { 471 setPaymentId(v.getPaymentId()); 472 } 473 aPayment = v; 474 } 475 476 477 483 public Payment getPayment() throws TorqueException 484 { 485 if (aPayment == null && (this.paymentId != 0)) 486 { 487 aPayment = PaymentPeer.retrieveByPK(SimpleKey.keyFor(this.paymentId)); 488 489 498 } 499 return aPayment; 500 } 501 502 508 public void setPaymentKey(ObjectKey key) throws TorqueException 509 { 510 511 setPaymentId(((NumberKey) key).intValue()); 512 } 513 514 515 516 517 private Sorder aSorder; 518 519 525 public void setSorder(Sorder v) throws TorqueException 526 { 527 if (v == null) 528 { 529 setSorderId( 1000); 530 } 531 else 532 { 533 setSorderId(v.getSorderId()); 534 } 535 aSorder = v; 536 } 537 538 539 545 public Sorder getSorder() throws TorqueException 546 { 547 if (aSorder == null && (this.sorderId != 0)) 548 { 549 aSorder = SorderPeer.retrieveByPK(SimpleKey.keyFor(this.sorderId)); 550 551 560 } 561 return aSorder; 562 } 563 564 570 public void setSorderKey(ObjectKey key) throws TorqueException 571 { 572 573 setSorderId(((NumberKey) key).intValue()); 574 } 575 576 577 578 579 private Product aProduct; 580 581 587 public void setProduct(Product v) throws TorqueException 588 { 589 if (v == null) 590 { 591 setProductId( 1000); 592 } 593 else 594 { 595 setProductId(v.getProductId()); 596 } 597 aProduct = v; 598 } 599 600 601 607 public Product getProduct() throws TorqueException 608 { 609 if (aProduct == null && (this.productId != 0)) 610 { 611 aProduct = ProductPeer.retrieveByPK(SimpleKey.keyFor(this.productId)); 612 613 622 } 623 return aProduct; 624 } 625 626 632 public void setProductKey(ObjectKey key) throws TorqueException 633 { 634 635 setProductId(((NumberKey) key).intValue()); 636 } 637 638 639 640 641 private Currency aCurrency; 642 643 649 public void setCurrency(Currency v) throws TorqueException 650 { 651 if (v == null) 652 { 653 setCurrencyId( 1000); 654 } 655 else 656 { 657 setCurrencyId(v.getCurrencyId()); 658 } 659 aCurrency = v; 660 } 661 662 663 669 public Currency getCurrency() throws TorqueException 670 { 671 if (aCurrency == null && (this.currencyId != 0)) 672 { 673 aCurrency = CurrencyPeer.retrieveByPK(SimpleKey.keyFor(this.currencyId)); 674 675 684 } 685 return aCurrency; 686 } 687 688 694 public void setCurrencyKey(ObjectKey key) throws TorqueException 695 { 696 697 setCurrencyId(((NumberKey) key).intValue()); 698 } 699 700 701 702 703 private Customer aCustomer; 704 705 711 public void setCustomer(Customer v) throws TorqueException 712 { 713 if (v == null) 714 { 715 setCustomerId( 1000); 716 } 717 else 718 { 719 setCustomerId(v.getCustomerId()); 720 } 721 aCustomer = v; 722 } 723 724 725 731 public Customer getCustomer() throws TorqueException 732 { 733 if (aCustomer == null && (this.customerId != 0)) 734 { 735 aCustomer = CustomerPeer.retrieveByPK(SimpleKey.keyFor(this.customerId)); 736 737 746 } 747 return aCustomer; 748 } 749 750 756 public void setCustomerKey(ObjectKey key) throws TorqueException 757 { 758 759 setCustomerId(((NumberKey) key).intValue()); 760 } 761 762 763 764 765 private Project aProject; 766 767 773 public void setProject(Project v) throws TorqueException 774 { 775 if (v == null) 776 { 777 setProjectId( 1000); 778 } 779 else 780 { 781 setProjectId(v.getProjectId()); 782 } 783 aProject = v; 784 } 785 786 787 793 public Project getProject() throws TorqueException 794 { 795 if (aProject == null && (this.projectId != 0)) 796 { 797 aProject = ProjectPeer.retrieveByPK(SimpleKey.keyFor(this.projectId)); 798 799 808 } 809 return aProject; 810 } 811 812 818 public void setProjectKey(ObjectKey key) throws TorqueException 819 { 820 821 setProjectId(((NumberKey) key).intValue()); 822 } 823 824 825 private static List fieldNames = null; 826 827 832 public static synchronized List getFieldNames() 833 { 834 if (fieldNames == null) 835 { 836 fieldNames = new ArrayList (); 837 fieldNames.add("PaymentItemId"); 838 fieldNames.add("PaymentId"); 839 fieldNames.add("SorderId"); 840 fieldNames.add("CustomerId"); 841 fieldNames.add("ProjectId"); 842 fieldNames.add("ProductId"); 843 fieldNames.add("Description"); 844 fieldNames.add("UnitPrice"); 845 fieldNames.add("Quantity"); 846 fieldNames.add("CurrencyId"); 847 fieldNames.add("ItemCurrTotal"); 848 fieldNames.add("ItemTotal"); 849 fieldNames = Collections.unmodifiableList(fieldNames); 850 } 851 return fieldNames; 852 } 853 854 860 public Object getByName(String name) 861 { 862 if (name.equals("PaymentItemId")) 863 { 864 return new Integer (getPaymentItemId()); 865 } 866 if (name.equals("PaymentId")) 867 { 868 return new Integer (getPaymentId()); 869 } 870 if (name.equals("SorderId")) 871 { 872 return new Integer (getSorderId()); 873 } 874 if (name.equals("CustomerId")) 875 { 876 return new Integer (getCustomerId()); 877 } 878 if (name.equals("ProjectId")) 879 { 880 return new Integer (getProjectId()); 881 } 882 if (name.equals("ProductId")) 883 { 884 return new Integer (getProductId()); 885 } 886 if (name.equals("Description")) 887 { 888 return getDescription(); 889 } 890 if (name.equals("UnitPrice")) 891 { 892 return getUnitPrice(); 893 } 894 if (name.equals("Quantity")) 895 { 896 return new Integer (getQuantity()); 897 } 898 if (name.equals("CurrencyId")) 899 { 900 return new Integer (getCurrencyId()); 901 } 902 if (name.equals("ItemCurrTotal")) 903 { 904 return getItemCurrTotal(); 905 } 906 if (name.equals("ItemTotal")) 907 { 908 return getItemTotal(); 909 } 910 return null; 911 } 912 913 921 public Object getByPeerName(String name) 922 { 923 if (name.equals(PaymentItemPeer.PAYMENT_ITEM_ID)) 924 { 925 return new Integer (getPaymentItemId()); 926 } 927 if (name.equals(PaymentItemPeer.PAYMENT_ID)) 928 { 929 return new Integer (getPaymentId()); 930 } 931 if (name.equals(PaymentItemPeer.SORDER_ID)) 932 { 933 return new Integer (getSorderId()); 934 } 935 if (name.equals(PaymentItemPeer.CUSTOMER_ID)) 936 { 937 return new Integer (getCustomerId()); 938 } 939 if (name.equals(PaymentItemPeer.PROJECT_ID)) 940 { 941 return new Integer (getProjectId()); 942 } 943 if (name.equals(PaymentItemPeer.PRODUCT_ID)) 944 { 945 return new Integer (getProductId()); 946 } 947 if (name.equals(PaymentItemPeer.DESCRIPTION)) 948 { 949 return getDescription(); 950 } 951 if (name.equals(PaymentItemPeer.UNIT_PRICE)) 952 { 953 return getUnitPrice(); 954 } 955 if (name.equals(PaymentItemPeer.QUANTITY)) 956 { 957 return new Integer (getQuantity()); 958 } 959 if (name.equals(PaymentItemPeer.CURRENCY_ID)) 960 { 961 return new Integer (getCurrencyId()); 962 } 963 if (name.equals(PaymentItemPeer.ITEM_CURR_TOTAL)) 964 { 965 return getItemCurrTotal(); 966 } 967 if (name.equals(PaymentItemPeer.ITEM_TOTAL)) 968 { 969 return getItemTotal(); 970 } 971 return null; 972 } 973 974 981 public Object getByPosition(int pos) 982 { 983 if (pos == 0) 984 { 985 return new Integer (getPaymentItemId()); 986 } 987 if (pos == 1) 988 { 989 return new Integer (getPaymentId()); 990 } 991 if (pos == 2) 992 { 993 return new Integer (getSorderId()); 994 } 995 if (pos == 3) 996 { 997 return new Integer (getCustomerId()); 998 } 999 if (pos == 4) 1000 { 1001 return new Integer (getProjectId()); 1002 } 1003 if (pos == 5) 1004 { 1005 return new Integer (getProductId()); 1006 } 1007 if (pos == 6) 1008 { 1009 return getDescription(); 1010 } 1011 if (pos == 7) 1012 { 1013 return getUnitPrice(); 1014 } 1015 if (pos == 8) 1016 { 1017 return new Integer (getQuantity()); 1018 } 1019 if (pos == 9) 1020 { 1021 return new Integer (getCurrencyId()); 1022 } 1023 if (pos == 10) 1024 { 1025 return getItemCurrTotal(); 1026 } 1027 if (pos == 11) 1028 { 1029 return getItemTotal(); 1030 } 1031 return null; 1032 } 1033 1034 1040 public void save() throws Exception  1041 { 1042 save(PaymentItemPeer.getMapBuilder() 1043 .getDatabaseMap().getName()); 1044 } 1045 1046 1056 public void save(String dbName) throws TorqueException 1057 { 1058 Connection con = null; 1059 try 1060 { 1061 con = Transaction.begin(dbName); 1062 save(con); 1063 Transaction.commit(con); 1064 } 1065 catch(TorqueException e) 1066 { 1067 Transaction.safeRollback(con); 1068 throw e; 1069 } 1070 } 1071 1072 1074 private boolean alreadyInSave = false; 1075 1085 public void save(Connection con) throws TorqueException 1086 { 1087 if (!alreadyInSave) 1088 { 1089 alreadyInSave = true; 1090 1091 1092 1093 if (isModified()) 1095 { 1096 if (isNew()) 1097 { 1098 PaymentItemPeer.doInsert((PaymentItem) this, con); 1099 setNew(false); 1100 } 1101 else 1102 { 1103 PaymentItemPeer.doUpdate((PaymentItem) this, con); 1104 } 1105 } 1106 1107 alreadyInSave = false; 1108 } 1109 } 1110 1111 1112 1117 public void setPrimaryKey(ObjectKey key) 1118 1119 { 1120 setPaymentItemId(((NumberKey) key).intValue()); 1121 } 1122 1123 1128 public void setPrimaryKey(String key) 1129 { 1130 setPaymentItemId(Integer.parseInt(key)); 1131 } 1132 1133 1134 1138 public ObjectKey getPrimaryKey() 1139 { 1140 return SimpleKey.keyFor(getPaymentItemId()); 1141 } 1142 1143 1147 public String getQueryKey() 1148 { 1149 if (getPrimaryKey() == null) 1150 { 1151 return ""; 1152 } 1153 else 1154 { 1155 return getPrimaryKey().toString(); 1156 } 1157 } 1158 1159 1163 public void setQueryKey(String key) 1164 throws TorqueException 1165 { 1166 setPrimaryKey(key); 1167 } 1168 1169 1175 public PaymentItem copy() throws TorqueException 1176 { 1177 return copyInto(new PaymentItem()); 1178 } 1179 1180 protected PaymentItem copyInto(PaymentItem copyObj) throws TorqueException 1181 { 1182 copyObj.setPaymentItemId(paymentItemId); 1183 copyObj.setPaymentId(paymentId); 1184 copyObj.setSorderId(sorderId); 1185 copyObj.setCustomerId(customerId); 1186 copyObj.setProjectId(projectId); 1187 copyObj.setProductId(productId); 1188 copyObj.setDescription(description); 1189 copyObj.setUnitPrice(unitPrice); 1190 copyObj.setQuantity(quantity); 1191 copyObj.setCurrencyId(currencyId); 1192 copyObj.setItemCurrTotal(itemCurrTotal); 1193 copyObj.setItemTotal(itemTotal); 1194 1195 copyObj.setPaymentItemId( 0); 1196 1197 return copyObj; 1198 } 1199 1200 1206 public PaymentItemPeer getPeer() 1207 { 1208 return peer; 1209 } 1210 1211 public String toString() 1212 { 1213 StringBuffer str = new StringBuffer (); 1214 str.append("PaymentItem:\n"); 1215 str.append("PaymentItemId = ") 1216 .append(getPaymentItemId()) 1217 .append("\n"); 1218 str.append("PaymentId = ") 1219 .append(getPaymentId()) 1220 .append("\n"); 1221 str.append("SorderId = ") 1222 .append(getSorderId()) 1223 .append("\n"); 1224 str.append("CustomerId = ") 1225 .append(getCustomerId()) 1226 .append("\n"); 1227 str.append("ProjectId = ") 1228 .append(getProjectId()) 1229 .append("\n"); 1230 str.append("ProductId = ") 1231 .append(getProductId()) 1232 .append("\n"); 1233 str.append("Description = ") 1234 .append(getDescription()) 1235 .append("\n"); 1236 str.append("UnitPrice = ") 1237 .append(getUnitPrice()) 1238 .append("\n"); 1239 str.append("Quantity = ") 1240 .append(getQuantity()) 1241 .append("\n"); 1242 str.append("CurrencyId = ") 1243 .append(getCurrencyId()) 1244 .append("\n"); 1245 str.append("ItemCurrTotal = ") 1246 .append(getItemCurrTotal()) 1247 .append("\n"); 1248 str.append("ItemTotal = ") 1249 .append(getItemTotal()) 1250 .append("\n"); 1251 return(str.toString()); 1252 } 1253} 1254
| Popular Tags
|