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 38 public abstract class BasePayment extends BaseObject 39 implements org.apache.turbine.om.Retrievable 40 { 41 42 private static final PaymentPeer peer = 43 new PaymentPeer(); 44 45 46 47 private int paymentId; 48 49 50 private String paymentCode = "AUTO"; 51 52 53 private int status = 30; 54 55 56 private int priority = 30; 57 58 59 private Date issuedDate; 60 61 62 private Date closedDate; 63 64 65 private int customerId = 1000; 66 67 68 private int projectId = 1000; 69 70 71 private int sorderId = 1000; 72 73 74 private String invoiceCode; 75 76 77 private int payTerm = 10; 78 79 80 private int payMethod = 10; 81 82 83 private int currencyId = 1000; 84 85 86 private BigDecimal currencyRate= new BigDecimal (1); 87 88 89 private BigDecimal currencyAmount= new BigDecimal (0); 90 91 92 private BigDecimal totalAmount= new BigDecimal (0); 93 94 95 private String subject = "---"; 96 97 98 private String notes; 99 100 101 private Date created; 102 103 104 private Date modified; 105 106 107 private String createdBy; 108 109 110 private String modifiedBy; 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 140 if (collPaymentItems != null) 142 { 143 for (int i = 0; i < collPaymentItems.size(); i++) 144 { 145 ((PaymentItem) collPaymentItems.get(i)) 146 .setPaymentId(v); 147 } 148 } 149 } 150 151 156 public String getPaymentCode() 157 { 158 return paymentCode; 159 } 160 161 162 167 public void setPaymentCode(String v) 168 { 169 170 if (!ObjectUtils.equals(this.paymentCode, v)) 171 { 172 this.paymentCode = v; 173 setModified(true); 174 } 175 176 177 } 178 179 184 public int getStatus() 185 { 186 return status; 187 } 188 189 190 195 public void setStatus(int v) 196 { 197 198 if (this.status != v) 199 { 200 this.status = v; 201 setModified(true); 202 } 203 204 205 } 206 207 212 public int getPriority() 213 { 214 return priority; 215 } 216 217 218 223 public void setPriority(int v) 224 { 225 226 if (this.priority != v) 227 { 228 this.priority = v; 229 setModified(true); 230 } 231 232 233 } 234 235 240 public Date getIssuedDate() 241 { 242 return issuedDate; 243 } 244 245 246 251 public void setIssuedDate(Date v) 252 { 253 254 if (!ObjectUtils.equals(this.issuedDate, v)) 255 { 256 this.issuedDate = v; 257 setModified(true); 258 } 259 260 261 } 262 263 268 public Date getClosedDate() 269 { 270 return closedDate; 271 } 272 273 274 279 public void setClosedDate(Date v) 280 { 281 282 if (!ObjectUtils.equals(this.closedDate, v)) 283 { 284 this.closedDate = v; 285 setModified(true); 286 } 287 288 289 } 290 291 296 public int getCustomerId() 297 { 298 return customerId; 299 } 300 301 302 307 public void setCustomerId(int v) throws TorqueException 308 { 309 310 if (this.customerId != v) 311 { 312 this.customerId = v; 313 setModified(true); 314 } 315 316 317 if (aCustomer != null && !(aCustomer.getCustomerId() == v)) 318 { 319 aCustomer = null; 320 } 321 322 } 323 324 329 public int getProjectId() 330 { 331 return projectId; 332 } 333 334 335 340 public void setProjectId(int v) throws TorqueException 341 { 342 343 if (this.projectId != v) 344 { 345 this.projectId = v; 346 setModified(true); 347 } 348 349 350 if (aProject != null && !(aProject.getProjectId() == v)) 351 { 352 aProject = null; 353 } 354 355 } 356 357 362 public int getSorderId() 363 { 364 return sorderId; 365 } 366 367 368 373 public void setSorderId(int v) throws TorqueException 374 { 375 376 if (this.sorderId != v) 377 { 378 this.sorderId = v; 379 setModified(true); 380 } 381 382 383 if (aSorder != null && !(aSorder.getSorderId() == v)) 384 { 385 aSorder = null; 386 } 387 388 } 389 390 395 public String getInvoiceCode() 396 { 397 return invoiceCode; 398 } 399 400 401 406 public void setInvoiceCode(String v) 407 { 408 409 if (!ObjectUtils.equals(this.invoiceCode, v)) 410 { 411 this.invoiceCode = v; 412 setModified(true); 413 } 414 415 416 } 417 418 423 public int getPayTerm() 424 { 425 return payTerm; 426 } 427 428 429 434 public void setPayTerm(int v) 435 { 436 437 if (this.payTerm != v) 438 { 439 this.payTerm = v; 440 setModified(true); 441 } 442 443 444 } 445 446 451 public int getPayMethod() 452 { 453 return payMethod; 454 } 455 456 457 462 public void setPayMethod(int v) 463 { 464 465 if (this.payMethod != v) 466 { 467 this.payMethod = v; 468 setModified(true); 469 } 470 471 472 } 473 474 479 public int getCurrencyId() 480 { 481 return currencyId; 482 } 483 484 485 490 public void setCurrencyId(int v) throws TorqueException 491 { 492 493 if (this.currencyId != v) 494 { 495 this.currencyId = v; 496 setModified(true); 497 } 498 499 500 if (aCurrency != null && !(aCurrency.getCurrencyId() == v)) 501 { 502 aCurrency = null; 503 } 504 505 } 506 507 512 public BigDecimal getCurrencyRate() 513 { 514 return currencyRate; 515 } 516 517 518 523 public void setCurrencyRate(BigDecimal v) 524 { 525 526 if (!ObjectUtils.equals(this.currencyRate, v)) 527 { 528 this.currencyRate = v; 529 setModified(true); 530 } 531 532 533 } 534 535 540 public BigDecimal getCurrencyAmount() 541 { 542 return currencyAmount; 543 } 544 545 546 551 public void setCurrencyAmount(BigDecimal v) 552 { 553 554 if (!ObjectUtils.equals(this.currencyAmount, v)) 555 { 556 this.currencyAmount = v; 557 setModified(true); 558 } 559 560 561 } 562 563 568 public BigDecimal getTotalAmount() 569 { 570 return totalAmount; 571 } 572 573 574 579 public void setTotalAmount(BigDecimal v) 580 { 581 582 if (!ObjectUtils.equals(this.totalAmount, v)) 583 { 584 this.totalAmount = v; 585 setModified(true); 586 } 587 588 589 } 590 591 596 public String getSubject() 597 { 598 return subject; 599 } 600 601 602 607 public void setSubject(String v) 608 { 609 610 if (!ObjectUtils.equals(this.subject, v)) 611 { 612 this.subject = v; 613 setModified(true); 614 } 615 616 617 } 618 619 624 public String getNotes() 625 { 626 return notes; 627 } 628 629 630 635 public void setNotes(String v) 636 { 637 638 if (!ObjectUtils.equals(this.notes, v)) 639 { 640 this.notes = v; 641 setModified(true); 642 } 643 644 645 } 646 647 652 public Date getCreated() 653 { 654 return created; 655 } 656 657 658 663 public void setCreated(Date v) 664 { 665 666 if (!ObjectUtils.equals(this.created, v)) 667 { 668 this.created = v; 669 setModified(true); 670 } 671 672 673 } 674 675 680 public Date getModified() 681 { 682 return modified; 683 } 684 685 686 691 public void setModified(Date v) 692 { 693 694 if (!ObjectUtils.equals(this.modified, v)) 695 { 696 this.modified = v; 697 setModified(true); 698 } 699 700 701 } 702 703 708 public String getCreatedBy() 709 { 710 return createdBy; 711 } 712 713 714 719 public void setCreatedBy(String v) 720 { 721 722 if (!ObjectUtils.equals(this.createdBy, v)) 723 { 724 this.createdBy = v; 725 setModified(true); 726 } 727 728 729 } 730 731 736 public String getModifiedBy() 737 { 738 return modifiedBy; 739 } 740 741 742 747 public void setModifiedBy(String v) 748 { 749 750 if (!ObjectUtils.equals(this.modifiedBy, v)) 751 { 752 this.modifiedBy = v; 753 setModified(true); 754 } 755 756 757 } 758 759 760 761 762 763 private Customer aCustomer; 764 765 771 public void setCustomer(Customer v) throws TorqueException 772 { 773 if (v == null) 774 { 775 setCustomerId( 1000); 776 } 777 else 778 { 779 setCustomerId(v.getCustomerId()); 780 } 781 aCustomer = v; 782 } 783 784 785 791 public Customer getCustomer() throws TorqueException 792 { 793 if (aCustomer == null && (this.customerId != 0)) 794 { 795 aCustomer = CustomerPeer.retrieveByPK(SimpleKey.keyFor(this.customerId)); 796 797 806 } 807 return aCustomer; 808 } 809 810 816 public void setCustomerKey(ObjectKey key) throws TorqueException 817 { 818 819 setCustomerId(((NumberKey) key).intValue()); 820 } 821 822 823 824 825 private Project aProject; 826 827 833 public void setProject(Project v) throws TorqueException 834 { 835 if (v == null) 836 { 837 setProjectId( 1000); 838 } 839 else 840 { 841 setProjectId(v.getProjectId()); 842 } 843 aProject = v; 844 } 845 846 847 853 public Project getProject() throws TorqueException 854 { 855 if (aProject == null && (this.projectId != 0)) 856 { 857 aProject = ProjectPeer.retrieveByPK(SimpleKey.keyFor(this.projectId)); 858 859 868 } 869 return aProject; 870 } 871 872 878 public void setProjectKey(ObjectKey key) throws TorqueException 879 { 880 881 setProjectId(((NumberKey) key).intValue()); 882 } 883 884 885 886 887 private Sorder aSorder; 888 889 895 public void setSorder(Sorder v) throws TorqueException 896 { 897 if (v == null) 898 { 899 setSorderId( 1000); 900 } 901 else 902 { 903 setSorderId(v.getSorderId()); 904 } 905 aSorder = v; 906 } 907 908 909 915 public Sorder getSorder() throws TorqueException 916 { 917 if (aSorder == null && (this.sorderId != 0)) 918 { 919 aSorder = SorderPeer.retrieveByPK(SimpleKey.keyFor(this.sorderId)); 920 921 930 } 931 return aSorder; 932 } 933 934 940 public void setSorderKey(ObjectKey key) throws TorqueException 941 { 942 943 setSorderId(((NumberKey) key).intValue()); 944 } 945 946 947 948 949 private Currency aCurrency; 950 951 957 public void setCurrency(Currency v) throws TorqueException 958 { 959 if (v == null) 960 { 961 setCurrencyId( 1000); 962 } 963 else 964 { 965 setCurrencyId(v.getCurrencyId()); 966 } 967 aCurrency = v; 968 } 969 970 971 977 public Currency getCurrency() throws TorqueException 978 { 979 if (aCurrency == null && (this.currencyId != 0)) 980 { 981 aCurrency = CurrencyPeer.retrieveByPK(SimpleKey.keyFor(this.currencyId)); 982 983 992 } 993 return aCurrency; 994 } 995 996 1002 public void setCurrencyKey(ObjectKey key) throws TorqueException 1003 { 1004 1005 setCurrencyId(((NumberKey) key).intValue()); 1006 } 1007 1008 1009 1010 1013 protected List collPaymentItems; 1014 1015 1020 protected void initPaymentItems() 1021 { 1022 if (collPaymentItems == null) 1023 { 1024 collPaymentItems = new ArrayList (); 1025 } 1026 } 1027 1028 1035 public void addPaymentItem(PaymentItem l) throws TorqueException 1036 { 1037 getPaymentItems().add(l); 1038 l.setPayment((Payment) this); 1039 } 1040 1041 1044 private Criteria lastPaymentItemsCriteria = null; 1045 1046 1053 public List getPaymentItems() throws TorqueException 1054 { 1055 if (collPaymentItems == null) 1056 { 1057 collPaymentItems = getPaymentItems(new Criteria(10)); 1058 } 1059 return collPaymentItems; 1060 } 1061 1062 1073 public List getPaymentItems(Criteria criteria) throws TorqueException 1074 { 1075 if (collPaymentItems == null) 1076 { 1077 if (isNew()) 1078 { 1079 collPaymentItems = new ArrayList (); 1080 } 1081 else 1082 { 1083 criteria.add(PaymentItemPeer.PAYMENT_ID, getPaymentId() ); 1084 collPaymentItems = PaymentItemPeer.doSelect(criteria); 1085 } 1086 } 1087 else 1088 { 1089 if (!isNew()) 1091 { 1092 criteria.add(PaymentItemPeer.PAYMENT_ID, getPaymentId()); 1096 if (!lastPaymentItemsCriteria.equals(criteria)) 1097 { 1098 collPaymentItems = PaymentItemPeer.doSelect(criteria); 1099 } 1100 } 1101 } 1102 lastPaymentItemsCriteria = criteria; 1103 1104 return collPaymentItems; 1105 } 1106 1107 1115 public List getPaymentItems(Connection con) throws TorqueException 1116 { 1117 if (collPaymentItems == null) 1118 { 1119 collPaymentItems = getPaymentItems(new Criteria(10), con); 1120 } 1121 return collPaymentItems; 1122 } 1123 1124 1136 public List getPaymentItems(Criteria criteria, Connection con) 1137 throws TorqueException 1138 { 1139 if (collPaymentItems == null) 1140 { 1141 if (isNew()) 1142 { 1143 collPaymentItems = new ArrayList (); 1144 } 1145 else 1146 { 1147 criteria.add(PaymentItemPeer.PAYMENT_ID, getPaymentId()); 1148 collPaymentItems = PaymentItemPeer.doSelect(criteria, con); 1149 } 1150 } 1151 else 1152 { 1153 if (!isNew()) 1155 { 1156 criteria.add(PaymentItemPeer.PAYMENT_ID, getPaymentId()); 1160 if (!lastPaymentItemsCriteria.equals(criteria)) 1161 { 1162 collPaymentItems = PaymentItemPeer.doSelect(criteria, con); 1163 } 1164 } 1165 } 1166 lastPaymentItemsCriteria = criteria; 1167 1168 return collPaymentItems; 1169 } 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1192 protected List getPaymentItemsJoinPayment(Criteria criteria) 1193 throws TorqueException 1194 { 1195 if (collPaymentItems == null) 1196 { 1197 if (isNew()) 1198 { 1199 collPaymentItems = new ArrayList (); 1200 } 1201 else 1202 { 1203 criteria.add(PaymentItemPeer.PAYMENT_ID, getPaymentId()); 1204 collPaymentItems = PaymentItemPeer.doSelectJoinPayment(criteria); 1205 } 1206 } 1207 else 1208 { 1209 1213 criteria.add(PaymentItemPeer.PAYMENT_ID, getPaymentId()); 1214 if (!lastPaymentItemsCriteria.equals(criteria)) 1215 { 1216 collPaymentItems = PaymentItemPeer.doSelectJoinPayment(criteria); 1217 } 1218 } 1219 lastPaymentItemsCriteria = criteria; 1220 1221 return collPaymentItems; 1222 } 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1243 protected List getPaymentItemsJoinSorder(Criteria criteria) 1244 throws TorqueException 1245 { 1246 if (collPaymentItems == null) 1247 { 1248 if (isNew()) 1249 { 1250 collPaymentItems = new ArrayList (); 1251 } 1252 else 1253 { 1254 criteria.add(PaymentItemPeer.PAYMENT_ID, getPaymentId()); 1255 collPaymentItems = PaymentItemPeer.doSelectJoinSorder(criteria); 1256 } 1257 } 1258 else 1259 { 1260 1264 criteria.add(PaymentItemPeer.PAYMENT_ID, getPaymentId()); 1265 if (!lastPaymentItemsCriteria.equals(criteria)) 1266 { 1267 collPaymentItems = PaymentItemPeer.doSelectJoinSorder(criteria); 1268 } 1269 } 1270 lastPaymentItemsCriteria = criteria; 1271 1272 return collPaymentItems; 1273 } 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1294 protected List getPaymentItemsJoinProduct(Criteria criteria) 1295 throws TorqueException 1296 { 1297 if (collPaymentItems == null) 1298 { 1299 if (isNew()) 1300 { 1301 collPaymentItems = new ArrayList (); 1302 } 1303 else 1304 { 1305 criteria.add(PaymentItemPeer.PAYMENT_ID, getPaymentId()); 1306 collPaymentItems = PaymentItemPeer.doSelectJoinProduct(criteria); 1307 } 1308 } 1309 else 1310 { 1311 1315 criteria.add(PaymentItemPeer.PAYMENT_ID, getPaymentId()); 1316 if (!lastPaymentItemsCriteria.equals(criteria)) 1317 { 1318 collPaymentItems = PaymentItemPeer.doSelectJoinProduct(criteria); 1319 } 1320 } 1321 lastPaymentItemsCriteria = criteria; 1322 1323 return collPaymentItems; 1324 } 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1345 protected List getPaymentItemsJoinCurrency(Criteria criteria) 1346 throws TorqueException 1347 { 1348 if (collPaymentItems == null) 1349 { 1350 if (isNew()) 1351 { 1352 collPaymentItems = new ArrayList (); 1353 } 1354 else 1355 { 1356 criteria.add(PaymentItemPeer.PAYMENT_ID, getPaymentId()); 1357 collPaymentItems = PaymentItemPeer.doSelectJoinCurrency(criteria); 1358 } 1359 } 1360 else 1361 { 1362 1366 criteria.add(PaymentItemPeer.PAYMENT_ID, getPaymentId()); 1367 if (!lastPaymentItemsCriteria.equals(criteria)) 1368 { 1369 collPaymentItems = PaymentItemPeer.doSelectJoinCurrency(criteria); 1370 } 1371 } 1372 lastPaymentItemsCriteria = criteria; 1373 1374 return collPaymentItems; 1375 } 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1396 protected List getPaymentItemsJoinCustomer(Criteria criteria) 1397 throws TorqueException 1398 { 1399 if (collPaymentItems == null) 1400 { 1401 if (isNew()) 1402 { 1403 collPaymentItems = new ArrayList (); 1404 } 1405 else 1406 { 1407 criteria.add(PaymentItemPeer.PAYMENT_ID, getPaymentId()); 1408 collPaymentItems = PaymentItemPeer.doSelectJoinCustomer(criteria); 1409 } 1410 } 1411 else 1412 { 1413 1417 criteria.add(PaymentItemPeer.PAYMENT_ID, getPaymentId()); 1418 if (!lastPaymentItemsCriteria.equals(criteria)) 1419 { 1420 collPaymentItems = PaymentItemPeer.doSelectJoinCustomer(criteria); 1421 } 1422 } 1423 lastPaymentItemsCriteria = criteria; 1424 1425 return collPaymentItems; 1426 } 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1447 protected List getPaymentItemsJoinProject(Criteria criteria) 1448 throws TorqueException 1449 { 1450 if (collPaymentItems == null) 1451 { 1452 if (isNew()) 1453 { 1454 collPaymentItems = new ArrayList (); 1455 } 1456 else 1457 { 1458 criteria.add(PaymentItemPeer.PAYMENT_ID, getPaymentId()); 1459 collPaymentItems = PaymentItemPeer.doSelectJoinProject(criteria); 1460 } 1461 } 1462 else 1463 { 1464 1468 criteria.add(PaymentItemPeer.PAYMENT_ID, getPaymentId()); 1469 if (!lastPaymentItemsCriteria.equals(criteria)) 1470 { 1471 collPaymentItems = PaymentItemPeer.doSelectJoinProject(criteria); 1472 } 1473 } 1474 lastPaymentItemsCriteria = criteria; 1475 1476 return collPaymentItems; 1477 } 1478 1479 1480 1481 1482 private static List fieldNames = null; 1483 1484 1489 public static synchronized List getFieldNames() 1490 { 1491 if (fieldNames == null) 1492 { 1493 fieldNames = new ArrayList (); 1494 fieldNames.add("PaymentId"); 1495 fieldNames.add("PaymentCode"); 1496 fieldNames.add("Status"); 1497 fieldNames.add("Priority"); 1498 fieldNames.add("IssuedDate"); 1499 fieldNames.add("ClosedDate"); 1500 fieldNames.add("CustomerId"); 1501 fieldNames.add("ProjectId"); 1502 fieldNames.add("SorderId"); 1503 fieldNames.add("InvoiceCode"); 1504 fieldNames.add("PayTerm"); 1505 fieldNames.add("PayMethod"); 1506 fieldNames.add("CurrencyId"); 1507 fieldNames.add("CurrencyRate"); 1508 fieldNames.add("CurrencyAmount"); 1509 fieldNames.add("TotalAmount"); 1510 fieldNames.add("Subject"); 1511 fieldNames.add("Notes"); 1512 fieldNames.add("Created"); 1513 fieldNames.add("Modified"); 1514 fieldNames.add("CreatedBy"); 1515 fieldNames.add("ModifiedBy"); 1516 fieldNames = Collections.unmodifiableList(fieldNames); 1517 } 1518 return fieldNames; 1519 } 1520 1521 1527 public Object getByName(String name) 1528 { 1529 if (name.equals("PaymentId")) 1530 { 1531 return new Integer (getPaymentId()); 1532 } 1533 if (name.equals("PaymentCode")) 1534 { 1535 return getPaymentCode(); 1536 } 1537 if (name.equals("Status")) 1538 { 1539 return new Integer (getStatus()); 1540 } 1541 if (name.equals("Priority")) 1542 { 1543 return new Integer (getPriority()); 1544 } 1545 if (name.equals("IssuedDate")) 1546 { 1547 return getIssuedDate(); 1548 } 1549 if (name.equals("ClosedDate")) 1550 { 1551 return getClosedDate(); 1552 } 1553 if (name.equals("CustomerId")) 1554 { 1555 return new Integer (getCustomerId()); 1556 } 1557 if (name.equals("ProjectId")) 1558 { 1559 return new Integer (getProjectId()); 1560 } 1561 if (name.equals("SorderId")) 1562 { 1563 return new Integer (getSorderId()); 1564 } 1565 if (name.equals("InvoiceCode")) 1566 { 1567 return getInvoiceCode(); 1568 } 1569 if (name.equals("PayTerm")) 1570 { 1571 return new Integer (getPayTerm()); 1572 } 1573 if (name.equals("PayMethod")) 1574 { 1575 return new Integer (getPayMethod()); 1576 } 1577 if (name.equals("CurrencyId")) 1578 { 1579 return new Integer (getCurrencyId()); 1580 } 1581 if (name.equals("CurrencyRate")) 1582 { 1583 return getCurrencyRate(); 1584 } 1585 if (name.equals("CurrencyAmount")) 1586 { 1587 return getCurrencyAmount(); 1588 } 1589 if (name.equals("TotalAmount")) 1590 { 1591 return getTotalAmount(); 1592 } 1593 if (name.equals("Subject")) 1594 { 1595 return getSubject(); 1596 } 1597 if (name.equals("Notes")) 1598 { 1599 return getNotes(); 1600 } 1601 if (name.equals("Created")) 1602 { 1603 return getCreated(); 1604 } 1605 if (name.equals("Modified")) 1606 { 1607 return getModified(); 1608 } 1609 if (name.equals("CreatedBy")) 1610 { 1611 return getCreatedBy(); 1612 } 1613 if (name.equals("ModifiedBy")) 1614 { 1615 return getModifiedBy(); 1616 } 1617 return null; 1618 } 1619 1620 1628 public Object getByPeerName(String name) 1629 { 1630 if (name.equals(PaymentPeer.PAYMENT_ID)) 1631 { 1632 return new Integer (getPaymentId()); 1633 } 1634 if (name.equals(PaymentPeer.PAYMENT_CODE)) 1635 { 1636 return getPaymentCode(); 1637 } 1638 if (name.equals(PaymentPeer.STATUS)) 1639 { 1640 return new Integer (getStatus()); 1641 } 1642 if (name.equals(PaymentPeer.PRIORITY)) 1643 { 1644 return new Integer (getPriority()); 1645 } 1646 if (name.equals(PaymentPeer.ISSUED_DATE)) 1647 { 1648 return getIssuedDate(); 1649 } 1650 if (name.equals(PaymentPeer.CLOSED_DATE)) 1651 { 1652 return getClosedDate(); 1653 } 1654 if (name.equals(PaymentPeer.CUSTOMER_ID)) 1655 { 1656 return new Integer (getCustomerId()); 1657 } 1658 if (name.equals(PaymentPeer.PROJECT_ID)) 1659 { 1660 return new Integer (getProjectId()); 1661 } 1662 if (name.equals(PaymentPeer.SORDER_ID)) 1663 { 1664 return new Integer (getSorderId()); 1665 } 1666 if (name.equals(PaymentPeer.INVOICE_CODE)) 1667 { 1668 return getInvoiceCode(); 1669 } 1670 if (name.equals(PaymentPeer.PAY_TERM)) 1671 { 1672 return new Integer (getPayTerm()); 1673 } 1674 if (name.equals(PaymentPeer.PAY_METHOD)) 1675 { 1676 return new Integer (getPayMethod()); 1677 } 1678 if (name.equals(PaymentPeer.CURRENCY_ID)) 1679 { 1680 return new Integer (getCurrencyId()); 1681 } 1682 if (name.equals(PaymentPeer.CURRENCY_RATE)) 1683 { 1684 return getCurrencyRate(); 1685 } 1686 if (name.equals(PaymentPeer.CURRENCY_AMOUNT)) 1687 { 1688 return getCurrencyAmount(); 1689 } 1690 if (name.equals(PaymentPeer.TOTAL_AMOUNT)) 1691 { 1692 return getTotalAmount(); 1693 } 1694 if (name.equals(PaymentPeer.SUBJECT)) 1695 { 1696 return getSubject(); 1697 } 1698 if (name.equals(PaymentPeer.NOTES)) 1699 { 1700 return getNotes(); 1701 } 1702 if (name.equals(PaymentPeer.CREATED)) 1703 { 1704 return getCreated(); 1705 } 1706 if (name.equals(PaymentPeer.MODIFIED)) 1707 { 1708 return getModified(); 1709 } 1710 if (name.equals(PaymentPeer.CREATED_BY)) 1711 { 1712 return getCreatedBy(); 1713 } 1714 if (name.equals(PaymentPeer.MODIFIED_BY)) 1715 { 1716 return getModifiedBy(); 1717 } 1718 return null; 1719 } 1720 1721 1728 public Object getByPosition(int pos) 1729 { 1730 if (pos == 0) 1731 { 1732 return new Integer (getPaymentId()); 1733 } 1734 if (pos == 1) 1735 { 1736 return getPaymentCode(); 1737 } 1738 if (pos == 2) 1739 { 1740 return new Integer (getStatus()); 1741 } 1742 if (pos == 3) 1743 { 1744 return new Integer (getPriority()); 1745 } 1746 if (pos == 4) 1747 { 1748 return getIssuedDate(); 1749 } 1750 if (pos == 5) 1751 { 1752 return getClosedDate(); 1753 } 1754 if (pos == 6) 1755 { 1756 return new Integer (getCustomerId()); 1757 } 1758 if (pos == 7) 1759 { 1760 return new Integer (getProjectId()); 1761 } 1762 if (pos == 8) 1763 { 1764 return new Integer (getSorderId()); 1765 } 1766 if (pos == 9) 1767 { 1768 return getInvoiceCode(); 1769 } 1770 if (pos == 10) 1771 { 1772 return new Integer (getPayTerm()); 1773 } 1774 if (pos == 11) 1775 { 1776 return new Integer (getPayMethod()); 1777 } 1778 if (pos == 12) 1779 { 1780 return new Integer (getCurrencyId()); 1781 } 1782 if (pos == 13) 1783 { 1784 return getCurrencyRate(); 1785 } 1786 if (pos == 14) 1787 { 1788 return getCurrencyAmount(); 1789 } 1790 if (pos == 15) 1791 { 1792 return getTotalAmount(); 1793 } 1794 if (pos == 16) 1795 { 1796 return getSubject(); 1797 } 1798 if (pos == 17) 1799 { 1800 return getNotes(); 1801 } 1802 if (pos == 18) 1803 { 1804 return getCreated(); 1805 } 1806 if (pos == 19) 1807 { 1808 return getModified(); 1809 } 1810 if (pos == 20) 1811 { 1812 return getCreatedBy(); 1813 } 1814 if (pos == 21) 1815 { 1816 return getModifiedBy(); 1817 } 1818 return null; 1819 } 1820 1821 1827 public void save() throws Exception 1828 { 1829 save(PaymentPeer.getMapBuilder() 1830 .getDatabaseMap().getName()); 1831 } 1832 1833 1843 public void save(String dbName) throws TorqueException 1844 { 1845 Connection con = null; 1846 try 1847 { 1848 con = Transaction.begin(dbName); 1849 save(con); 1850 Transaction.commit(con); 1851 } 1852 catch(TorqueException e) 1853 { 1854 Transaction.safeRollback(con); 1855 throw e; 1856 } 1857 } 1858 1859 1861 private boolean alreadyInSave = false; 1862 1872 public void save(Connection con) throws TorqueException 1873 { 1874 if (!alreadyInSave) 1875 { 1876 alreadyInSave = true; 1877 1878 1879 1880 if (isModified()) 1882 { 1883 if (isNew()) 1884 { 1885 PaymentPeer.doInsert((Payment) this, con); 1886 setNew(false); 1887 } 1888 else 1889 { 1890 PaymentPeer.doUpdate((Payment) this, con); 1891 } 1892 } 1893 1894 1895 1896 if (collPaymentItems != null) 1897 { 1898 for (int i = 0; i < collPaymentItems.size(); i++) 1899 { 1900 ((PaymentItem) collPaymentItems.get(i)).save(con); 1901 } 1902 } 1903 alreadyInSave = false; 1904 } 1905 } 1906 1907 1908 1913 public void setPrimaryKey(ObjectKey key) 1914 throws TorqueException 1915 { 1916 setPaymentId(((NumberKey) key).intValue()); 1917 } 1918 1919 1924 public void setPrimaryKey(String key) throws TorqueException 1925 { 1926 setPaymentId(Integer.parseInt(key)); 1927 } 1928 1929 1930 1934 public ObjectKey getPrimaryKey() 1935 { 1936 return SimpleKey.keyFor(getPaymentId()); 1937 } 1938 1939 1943 public String getQueryKey() 1944 { 1945 if (getPrimaryKey() == null) 1946 { 1947 return ""; 1948 } 1949 else 1950 { 1951 return getPrimaryKey().toString(); 1952 } 1953 } 1954 1955 1959 public void setQueryKey(String key) 1960 throws TorqueException 1961 { 1962 setPrimaryKey(key); 1963 } 1964 1965 1971 public Payment copy() throws TorqueException 1972 { 1973 return copyInto(new Payment()); 1974 } 1975 1976 protected Payment copyInto(Payment copyObj) throws TorqueException 1977 { 1978 copyObj.setPaymentId(paymentId); 1979 copyObj.setPaymentCode(paymentCode); 1980 copyObj.setStatus(status); 1981 copyObj.setPriority(priority); 1982 copyObj.setIssuedDate(issuedDate); 1983 copyObj.setClosedDate(closedDate); 1984 copyObj.setCustomerId(customerId); 1985 copyObj.setProjectId(projectId); 1986 copyObj.setSorderId(sorderId); 1987 copyObj.setInvoiceCode(invoiceCode); 1988 copyObj.setPayTerm(payTerm); 1989 copyObj.setPayMethod(payMethod); 1990 copyObj.setCurrencyId(currencyId); 1991 copyObj.setCurrencyRate(currencyRate); 1992 copyObj.setCurrencyAmount(currencyAmount); 1993 copyObj.setTotalAmount(totalAmount); 1994 copyObj.setSubject(subject); 1995 copyObj.setNotes(notes); 1996 copyObj.setCreated(created); 1997 copyObj.setModified(modified); 1998 copyObj.setCreatedBy(createdBy); 1999 copyObj.setModifiedBy(modifiedBy); 2000 2001 copyObj.setPaymentId( 0); 2002 2003 2004 2005 List v = getPaymentItems(); 2006 for (int i = 0; i < v.size(); i++) 2007 { 2008 PaymentItem obj = (PaymentItem) v.get(i); 2009 copyObj.addPaymentItem(obj.copy()); 2010 } 2011 return copyObj; 2012 } 2013 2014 2020 public PaymentPeer getPeer() 2021 { 2022 return peer; 2023 } 2024 2025 public String toString() 2026 { 2027 StringBuffer str = new StringBuffer (); 2028 str.append("Payment:\n"); 2029 str.append("PaymentId = ") 2030 .append(getPaymentId()) 2031 .append("\n"); 2032 str.append("PaymentCode = ") 2033 .append(getPaymentCode()) 2034 .append("\n"); 2035 str.append("Status = ") 2036 .append(getStatus()) 2037 .append("\n"); 2038 str.append("Priority = ") 2039 .append(getPriority()) 2040 .append("\n"); 2041 str.append("IssuedDate = ") 2042 .append(getIssuedDate()) 2043 .append("\n"); 2044 str.append("ClosedDate = ") 2045 .append(getClosedDate()) 2046 .append("\n"); 2047 str.append("CustomerId = ") 2048 .append(getCustomerId()) 2049 .append("\n"); 2050 str.append("ProjectId = ") 2051 .append(getProjectId()) 2052 .append("\n"); 2053 str.append("SorderId = ") 2054 .append(getSorderId()) 2055 .append("\n"); 2056 str.append("InvoiceCode = ") 2057 .append(getInvoiceCode()) 2058 .append("\n"); 2059 str.append("PayTerm = ") 2060 .append(getPayTerm()) 2061 .append("\n"); 2062 str.append("PayMethod = ") 2063 .append(getPayMethod()) 2064 .append("\n"); 2065 str.append("CurrencyId = ") 2066 .append(getCurrencyId()) 2067 .append("\n"); 2068 str.append("CurrencyRate = ") 2069 .append(getCurrencyRate()) 2070 .append("\n"); 2071 str.append("CurrencyAmount = ") 2072 .append(getCurrencyAmount()) 2073 .append("\n"); 2074 str.append("TotalAmount = ") 2075 .append(getTotalAmount()) 2076 .append("\n"); 2077 str.append("Subject = ") 2078 .append(getSubject()) 2079 .append("\n"); 2080 str.append("Notes = ") 2081 .append(getNotes()) 2082 .append("\n"); 2083 str.append("Created = ") 2084 .append(getCreated()) 2085 .append("\n"); 2086 str.append("Modified = ") 2087 .append(getModified()) 2088 .append("\n"); 2089 str.append("CreatedBy = ") 2090 .append(getCreatedBy()) 2091 .append("\n"); 2092 str.append("ModifiedBy = ") 2093 .append(getModifiedBy()) 2094 .append("\n"); 2095 return(str.toString()); 2096 } 2097} 2098 | Popular Tags |