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 BaseCurrency extends BaseObject 35 implements org.apache.turbine.om.Retrievable 36 { 37 38 private static final CurrencyPeer peer = 39 new CurrencyPeer(); 40 41 42 43 private int currencyId; 44 45 46 private String currencyName; 47 48 49 private String currencyCode; 50 51 52 private BigDecimal currencyRate= new BigDecimal (1); 53 54 55 60 public int getCurrencyId() 61 { 62 return currencyId; 63 } 64 65 66 71 public void setCurrencyId(int v) throws TorqueException 72 { 73 74 if (this.currencyId != v) 75 { 76 this.currencyId = v; 77 setModified(true); 78 } 79 80 81 82 if (collSorders != null) 84 { 85 for (int i = 0; i < collSorders.size(); i++) 86 { 87 ((Sorder) collSorders.get(i)) 88 .setCurrencyId(v); 89 } 90 } 91 92 if (collPayments != null) 94 { 95 for (int i = 0; i < collPayments.size(); i++) 96 { 97 ((Payment) collPayments.get(i)) 98 .setCurrencyId(v); 99 } 100 } 101 102 if (collSorderItems != null) 104 { 105 for (int i = 0; i < collSorderItems.size(); i++) 106 { 107 ((SorderItem) collSorderItems.get(i)) 108 .setCurrencyId(v); 109 } 110 } 111 112 if (collPaymentItems != null) 114 { 115 for (int i = 0; i < collPaymentItems.size(); i++) 116 { 117 ((PaymentItem) collPaymentItems.get(i)) 118 .setCurrencyId(v); 119 } 120 } 121 } 122 123 128 public String getCurrencyName() 129 { 130 return currencyName; 131 } 132 133 134 139 public void setCurrencyName(String v) 140 { 141 142 if (!ObjectUtils.equals(this.currencyName, v)) 143 { 144 this.currencyName = v; 145 setModified(true); 146 } 147 148 149 } 150 151 156 public String getCurrencyCode() 157 { 158 return currencyCode; 159 } 160 161 162 167 public void setCurrencyCode(String v) 168 { 169 170 if (!ObjectUtils.equals(this.currencyCode, v)) 171 { 172 this.currencyCode = v; 173 setModified(true); 174 } 175 176 177 } 178 179 184 public BigDecimal getCurrencyRate() 185 { 186 return currencyRate; 187 } 188 189 190 195 public void setCurrencyRate(BigDecimal v) 196 { 197 198 if (!ObjectUtils.equals(this.currencyRate, v)) 199 { 200 this.currencyRate = v; 201 setModified(true); 202 } 203 204 205 } 206 207 208 209 210 213 protected List collSorders; 214 215 220 protected void initSorders() 221 { 222 if (collSorders == null) 223 { 224 collSorders = new ArrayList (); 225 } 226 } 227 228 235 public void addSorder(Sorder l) throws TorqueException 236 { 237 getSorders().add(l); 238 l.setCurrency((Currency) this); 239 } 240 241 244 private Criteria lastSordersCriteria = null; 245 246 253 public List getSorders() throws TorqueException 254 { 255 if (collSorders == null) 256 { 257 collSorders = getSorders(new Criteria(10)); 258 } 259 return collSorders; 260 } 261 262 273 public List getSorders(Criteria criteria) throws TorqueException 274 { 275 if (collSorders == null) 276 { 277 if (isNew()) 278 { 279 collSorders = new ArrayList (); 280 } 281 else 282 { 283 criteria.add(SorderPeer.CURRENCY_ID, getCurrencyId() ); 284 collSorders = SorderPeer.doSelect(criteria); 285 } 286 } 287 else 288 { 289 if (!isNew()) 291 { 292 criteria.add(SorderPeer.CURRENCY_ID, getCurrencyId()); 296 if (!lastSordersCriteria.equals(criteria)) 297 { 298 collSorders = SorderPeer.doSelect(criteria); 299 } 300 } 301 } 302 lastSordersCriteria = criteria; 303 304 return collSorders; 305 } 306 307 315 public List getSorders(Connection con) throws TorqueException 316 { 317 if (collSorders == null) 318 { 319 collSorders = getSorders(new Criteria(10), con); 320 } 321 return collSorders; 322 } 323 324 336 public List getSorders(Criteria criteria, Connection con) 337 throws TorqueException 338 { 339 if (collSorders == null) 340 { 341 if (isNew()) 342 { 343 collSorders = new ArrayList (); 344 } 345 else 346 { 347 criteria.add(SorderPeer.CURRENCY_ID, getCurrencyId()); 348 collSorders = SorderPeer.doSelect(criteria, con); 349 } 350 } 351 else 352 { 353 if (!isNew()) 355 { 356 criteria.add(SorderPeer.CURRENCY_ID, getCurrencyId()); 360 if (!lastSordersCriteria.equals(criteria)) 361 { 362 collSorders = SorderPeer.doSelect(criteria, con); 363 } 364 } 365 } 366 lastSordersCriteria = criteria; 367 368 return collSorders; 369 } 370 371 372 373 374 375 376 377 378 379 380 381 392 protected List getSordersJoinCustomerRelatedByCustomerId(Criteria criteria) 393 throws TorqueException 394 { 395 if (collSorders == null) 396 { 397 if (isNew()) 398 { 399 collSorders = new ArrayList (); 400 } 401 else 402 { 403 criteria.add(SorderPeer.CURRENCY_ID, getCurrencyId()); 404 collSorders = SorderPeer.doSelectJoinCustomerRelatedByCustomerId(criteria); 405 } 406 } 407 else 408 { 409 413 criteria.add(SorderPeer.CURRENCY_ID, getCurrencyId()); 414 if (!lastSordersCriteria.equals(criteria)) 415 { 416 collSorders = SorderPeer.doSelectJoinCustomerRelatedByCustomerId(criteria); 417 } 418 } 419 lastSordersCriteria = criteria; 420 421 return collSorders; 422 } 423 424 425 426 427 428 429 430 431 432 443 protected List getSordersJoinCustomerRelatedByRecipientId(Criteria criteria) 444 throws TorqueException 445 { 446 if (collSorders == null) 447 { 448 if (isNew()) 449 { 450 collSorders = new ArrayList (); 451 } 452 else 453 { 454 criteria.add(SorderPeer.CURRENCY_ID, getCurrencyId()); 455 collSorders = SorderPeer.doSelectJoinCustomerRelatedByRecipientId(criteria); 456 } 457 } 458 else 459 { 460 464 criteria.add(SorderPeer.CURRENCY_ID, getCurrencyId()); 465 if (!lastSordersCriteria.equals(criteria)) 466 { 467 collSorders = SorderPeer.doSelectJoinCustomerRelatedByRecipientId(criteria); 468 } 469 } 470 lastSordersCriteria = criteria; 471 472 return collSorders; 473 } 474 475 476 477 478 479 480 481 482 483 494 protected List getSordersJoinProject(Criteria criteria) 495 throws TorqueException 496 { 497 if (collSorders == null) 498 { 499 if (isNew()) 500 { 501 collSorders = new ArrayList (); 502 } 503 else 504 { 505 criteria.add(SorderPeer.CURRENCY_ID, getCurrencyId()); 506 collSorders = SorderPeer.doSelectJoinProject(criteria); 507 } 508 } 509 else 510 { 511 515 criteria.add(SorderPeer.CURRENCY_ID, getCurrencyId()); 516 if (!lastSordersCriteria.equals(criteria)) 517 { 518 collSorders = SorderPeer.doSelectJoinProject(criteria); 519 } 520 } 521 lastSordersCriteria = criteria; 522 523 return collSorders; 524 } 525 526 527 528 529 530 531 532 533 534 545 protected List getSordersJoinCarrier(Criteria criteria) 546 throws TorqueException 547 { 548 if (collSorders == null) 549 { 550 if (isNew()) 551 { 552 collSorders = new ArrayList (); 553 } 554 else 555 { 556 criteria.add(SorderPeer.CURRENCY_ID, getCurrencyId()); 557 collSorders = SorderPeer.doSelectJoinCarrier(criteria); 558 } 559 } 560 else 561 { 562 566 criteria.add(SorderPeer.CURRENCY_ID, getCurrencyId()); 567 if (!lastSordersCriteria.equals(criteria)) 568 { 569 collSorders = SorderPeer.doSelectJoinCarrier(criteria); 570 } 571 } 572 lastSordersCriteria = criteria; 573 574 return collSorders; 575 } 576 577 578 579 580 581 582 583 584 585 596 protected List getSordersJoinCurrency(Criteria criteria) 597 throws TorqueException 598 { 599 if (collSorders == null) 600 { 601 if (isNew()) 602 { 603 collSorders = new ArrayList (); 604 } 605 else 606 { 607 criteria.add(SorderPeer.CURRENCY_ID, getCurrencyId()); 608 collSorders = SorderPeer.doSelectJoinCurrency(criteria); 609 } 610 } 611 else 612 { 613 617 criteria.add(SorderPeer.CURRENCY_ID, getCurrencyId()); 618 if (!lastSordersCriteria.equals(criteria)) 619 { 620 collSorders = SorderPeer.doSelectJoinCurrency(criteria); 621 } 622 } 623 lastSordersCriteria = criteria; 624 625 return collSorders; 626 } 627 628 629 630 631 632 635 protected List collPayments; 636 637 642 protected void initPayments() 643 { 644 if (collPayments == null) 645 { 646 collPayments = new ArrayList (); 647 } 648 } 649 650 657 public void addPayment(Payment l) throws TorqueException 658 { 659 getPayments().add(l); 660 l.setCurrency((Currency) this); 661 } 662 663 666 private Criteria lastPaymentsCriteria = null; 667 668 675 public List getPayments() throws TorqueException 676 { 677 if (collPayments == null) 678 { 679 collPayments = getPayments(new Criteria(10)); 680 } 681 return collPayments; 682 } 683 684 695 public List getPayments(Criteria criteria) throws TorqueException 696 { 697 if (collPayments == null) 698 { 699 if (isNew()) 700 { 701 collPayments = new ArrayList (); 702 } 703 else 704 { 705 criteria.add(PaymentPeer.CURRENCY_ID, getCurrencyId() ); 706 collPayments = PaymentPeer.doSelect(criteria); 707 } 708 } 709 else 710 { 711 if (!isNew()) 713 { 714 criteria.add(PaymentPeer.CURRENCY_ID, getCurrencyId()); 718 if (!lastPaymentsCriteria.equals(criteria)) 719 { 720 collPayments = PaymentPeer.doSelect(criteria); 721 } 722 } 723 } 724 lastPaymentsCriteria = criteria; 725 726 return collPayments; 727 } 728 729 737 public List getPayments(Connection con) throws TorqueException 738 { 739 if (collPayments == null) 740 { 741 collPayments = getPayments(new Criteria(10), con); 742 } 743 return collPayments; 744 } 745 746 758 public List getPayments(Criteria criteria, Connection con) 759 throws TorqueException 760 { 761 if (collPayments == null) 762 { 763 if (isNew()) 764 { 765 collPayments = new ArrayList (); 766 } 767 else 768 { 769 criteria.add(PaymentPeer.CURRENCY_ID, getCurrencyId()); 770 collPayments = PaymentPeer.doSelect(criteria, con); 771 } 772 } 773 else 774 { 775 if (!isNew()) 777 { 778 criteria.add(PaymentPeer.CURRENCY_ID, getCurrencyId()); 782 if (!lastPaymentsCriteria.equals(criteria)) 783 { 784 collPayments = PaymentPeer.doSelect(criteria, con); 785 } 786 } 787 } 788 lastPaymentsCriteria = criteria; 789 790 return collPayments; 791 } 792 793 794 795 796 797 798 799 800 801 802 803 814 protected List getPaymentsJoinCustomer(Criteria criteria) 815 throws TorqueException 816 { 817 if (collPayments == null) 818 { 819 if (isNew()) 820 { 821 collPayments = new ArrayList (); 822 } 823 else 824 { 825 criteria.add(PaymentPeer.CURRENCY_ID, getCurrencyId()); 826 collPayments = PaymentPeer.doSelectJoinCustomer(criteria); 827 } 828 } 829 else 830 { 831 835 criteria.add(PaymentPeer.CURRENCY_ID, getCurrencyId()); 836 if (!lastPaymentsCriteria.equals(criteria)) 837 { 838 collPayments = PaymentPeer.doSelectJoinCustomer(criteria); 839 } 840 } 841 lastPaymentsCriteria = criteria; 842 843 return collPayments; 844 } 845 846 847 848 849 850 851 852 853 854 865 protected List getPaymentsJoinProject(Criteria criteria) 866 throws TorqueException 867 { 868 if (collPayments == null) 869 { 870 if (isNew()) 871 { 872 collPayments = new ArrayList (); 873 } 874 else 875 { 876 criteria.add(PaymentPeer.CURRENCY_ID, getCurrencyId()); 877 collPayments = PaymentPeer.doSelectJoinProject(criteria); 878 } 879 } 880 else 881 { 882 886 criteria.add(PaymentPeer.CURRENCY_ID, getCurrencyId()); 887 if (!lastPaymentsCriteria.equals(criteria)) 888 { 889 collPayments = PaymentPeer.doSelectJoinProject(criteria); 890 } 891 } 892 lastPaymentsCriteria = criteria; 893 894 return collPayments; 895 } 896 897 898 899 900 901 902 903 904 905 916 protected List getPaymentsJoinSorder(Criteria criteria) 917 throws TorqueException 918 { 919 if (collPayments == null) 920 { 921 if (isNew()) 922 { 923 collPayments = new ArrayList (); 924 } 925 else 926 { 927 criteria.add(PaymentPeer.CURRENCY_ID, getCurrencyId()); 928 collPayments = PaymentPeer.doSelectJoinSorder(criteria); 929 } 930 } 931 else 932 { 933 937 criteria.add(PaymentPeer.CURRENCY_ID, getCurrencyId()); 938 if (!lastPaymentsCriteria.equals(criteria)) 939 { 940 collPayments = PaymentPeer.doSelectJoinSorder(criteria); 941 } 942 } 943 lastPaymentsCriteria = criteria; 944 945 return collPayments; 946 } 947 948 949 950 951 952 953 954 955 956 967 protected List getPaymentsJoinCurrency(Criteria criteria) 968 throws TorqueException 969 { 970 if (collPayments == null) 971 { 972 if (isNew()) 973 { 974 collPayments = new ArrayList (); 975 } 976 else 977 { 978 criteria.add(PaymentPeer.CURRENCY_ID, getCurrencyId()); 979 collPayments = PaymentPeer.doSelectJoinCurrency(criteria); 980 } 981 } 982 else 983 { 984 988 criteria.add(PaymentPeer.CURRENCY_ID, getCurrencyId()); 989 if (!lastPaymentsCriteria.equals(criteria)) 990 { 991 collPayments = PaymentPeer.doSelectJoinCurrency(criteria); 992 } 993 } 994 lastPaymentsCriteria = criteria; 995 996 return collPayments; 997 } 998 999 1000 1001 1002 1003 1006 protected List collSorderItems; 1007 1008 1013 protected void initSorderItems() 1014 { 1015 if (collSorderItems == null) 1016 { 1017 collSorderItems = new ArrayList (); 1018 } 1019 } 1020 1021 1028 public void addSorderItem(SorderItem l) throws TorqueException 1029 { 1030 getSorderItems().add(l); 1031 l.setCurrency((Currency) this); 1032 } 1033 1034 1037 private Criteria lastSorderItemsCriteria = null; 1038 1039 1046 public List getSorderItems() throws TorqueException 1047 { 1048 if (collSorderItems == null) 1049 { 1050 collSorderItems = getSorderItems(new Criteria(10)); 1051 } 1052 return collSorderItems; 1053 } 1054 1055 1066 public List getSorderItems(Criteria criteria) throws TorqueException 1067 { 1068 if (collSorderItems == null) 1069 { 1070 if (isNew()) 1071 { 1072 collSorderItems = new ArrayList (); 1073 } 1074 else 1075 { 1076 criteria.add(SorderItemPeer.CURRENCY_ID, getCurrencyId() ); 1077 collSorderItems = SorderItemPeer.doSelect(criteria); 1078 } 1079 } 1080 else 1081 { 1082 if (!isNew()) 1084 { 1085 criteria.add(SorderItemPeer.CURRENCY_ID, getCurrencyId()); 1089 if (!lastSorderItemsCriteria.equals(criteria)) 1090 { 1091 collSorderItems = SorderItemPeer.doSelect(criteria); 1092 } 1093 } 1094 } 1095 lastSorderItemsCriteria = criteria; 1096 1097 return collSorderItems; 1098 } 1099 1100 1108 public List getSorderItems(Connection con) throws TorqueException 1109 { 1110 if (collSorderItems == null) 1111 { 1112 collSorderItems = getSorderItems(new Criteria(10), con); 1113 } 1114 return collSorderItems; 1115 } 1116 1117 1129 public List getSorderItems(Criteria criteria, Connection con) 1130 throws TorqueException 1131 { 1132 if (collSorderItems == null) 1133 { 1134 if (isNew()) 1135 { 1136 collSorderItems = new ArrayList (); 1137 } 1138 else 1139 { 1140 criteria.add(SorderItemPeer.CURRENCY_ID, getCurrencyId()); 1141 collSorderItems = SorderItemPeer.doSelect(criteria, con); 1142 } 1143 } 1144 else 1145 { 1146 if (!isNew()) 1148 { 1149 criteria.add(SorderItemPeer.CURRENCY_ID, getCurrencyId()); 1153 if (!lastSorderItemsCriteria.equals(criteria)) 1154 { 1155 collSorderItems = SorderItemPeer.doSelect(criteria, con); 1156 } 1157 } 1158 } 1159 lastSorderItemsCriteria = criteria; 1160 1161 return collSorderItems; 1162 } 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1185 protected List getSorderItemsJoinSorder(Criteria criteria) 1186 throws TorqueException 1187 { 1188 if (collSorderItems == null) 1189 { 1190 if (isNew()) 1191 { 1192 collSorderItems = new ArrayList (); 1193 } 1194 else 1195 { 1196 criteria.add(SorderItemPeer.CURRENCY_ID, getCurrencyId()); 1197 collSorderItems = SorderItemPeer.doSelectJoinSorder(criteria); 1198 } 1199 } 1200 else 1201 { 1202 1206 criteria.add(SorderItemPeer.CURRENCY_ID, getCurrencyId()); 1207 if (!lastSorderItemsCriteria.equals(criteria)) 1208 { 1209 collSorderItems = SorderItemPeer.doSelectJoinSorder(criteria); 1210 } 1211 } 1212 lastSorderItemsCriteria = criteria; 1213 1214 return collSorderItems; 1215 } 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1236 protected List getSorderItemsJoinProduct(Criteria criteria) 1237 throws TorqueException 1238 { 1239 if (collSorderItems == null) 1240 { 1241 if (isNew()) 1242 { 1243 collSorderItems = new ArrayList (); 1244 } 1245 else 1246 { 1247 criteria.add(SorderItemPeer.CURRENCY_ID, getCurrencyId()); 1248 collSorderItems = SorderItemPeer.doSelectJoinProduct(criteria); 1249 } 1250 } 1251 else 1252 { 1253 1257 criteria.add(SorderItemPeer.CURRENCY_ID, getCurrencyId()); 1258 if (!lastSorderItemsCriteria.equals(criteria)) 1259 { 1260 collSorderItems = SorderItemPeer.doSelectJoinProduct(criteria); 1261 } 1262 } 1263 lastSorderItemsCriteria = criteria; 1264 1265 return collSorderItems; 1266 } 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1287 protected List getSorderItemsJoinCustomerRelatedByCustomerId(Criteria criteria) 1288 throws TorqueException 1289 { 1290 if (collSorderItems == null) 1291 { 1292 if (isNew()) 1293 { 1294 collSorderItems = new ArrayList (); 1295 } 1296 else 1297 { 1298 criteria.add(SorderItemPeer.CURRENCY_ID, getCurrencyId()); 1299 collSorderItems = SorderItemPeer.doSelectJoinCustomerRelatedByCustomerId(criteria); 1300 } 1301 } 1302 else 1303 { 1304 1308 criteria.add(SorderItemPeer.CURRENCY_ID, getCurrencyId()); 1309 if (!lastSorderItemsCriteria.equals(criteria)) 1310 { 1311 collSorderItems = SorderItemPeer.doSelectJoinCustomerRelatedByCustomerId(criteria); 1312 } 1313 } 1314 lastSorderItemsCriteria = criteria; 1315 1316 return collSorderItems; 1317 } 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1338 protected List getSorderItemsJoinCustomerRelatedByRecipientId(Criteria criteria) 1339 throws TorqueException 1340 { 1341 if (collSorderItems == null) 1342 { 1343 if (isNew()) 1344 { 1345 collSorderItems = new ArrayList (); 1346 } 1347 else 1348 { 1349 criteria.add(SorderItemPeer.CURRENCY_ID, getCurrencyId()); 1350 collSorderItems = SorderItemPeer.doSelectJoinCustomerRelatedByRecipientId(criteria); 1351 } 1352 } 1353 else 1354 { 1355 1359 criteria.add(SorderItemPeer.CURRENCY_ID, getCurrencyId()); 1360 if (!lastSorderItemsCriteria.equals(criteria)) 1361 { 1362 collSorderItems = SorderItemPeer.doSelectJoinCustomerRelatedByRecipientId(criteria); 1363 } 1364 } 1365 lastSorderItemsCriteria = criteria; 1366 1367 return collSorderItems; 1368 } 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1389 protected List getSorderItemsJoinProject(Criteria criteria) 1390 throws TorqueException 1391 { 1392 if (collSorderItems == null) 1393 { 1394 if (isNew()) 1395 { 1396 collSorderItems = new ArrayList (); 1397 } 1398 else 1399 { 1400 criteria.add(SorderItemPeer.CURRENCY_ID, getCurrencyId()); 1401 collSorderItems = SorderItemPeer.doSelectJoinProject(criteria); 1402 } 1403 } 1404 else 1405 { 1406 1410 criteria.add(SorderItemPeer.CURRENCY_ID, getCurrencyId()); 1411 if (!lastSorderItemsCriteria.equals(criteria)) 1412 { 1413 collSorderItems = SorderItemPeer.doSelectJoinProject(criteria); 1414 } 1415 } 1416 lastSorderItemsCriteria = criteria; 1417 1418 return collSorderItems; 1419 } 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1440 protected List getSorderItemsJoinCurrency(Criteria criteria) 1441 throws TorqueException 1442 { 1443 if (collSorderItems == null) 1444 { 1445 if (isNew()) 1446 { 1447 collSorderItems = new ArrayList (); 1448 } 1449 else 1450 { 1451 criteria.add(SorderItemPeer.CURRENCY_ID, getCurrencyId()); 1452 collSorderItems = SorderItemPeer.doSelectJoinCurrency(criteria); 1453 } 1454 } 1455 else 1456 { 1457 1461 criteria.add(SorderItemPeer.CURRENCY_ID, getCurrencyId()); 1462 if (!lastSorderItemsCriteria.equals(criteria)) 1463 { 1464 collSorderItems = SorderItemPeer.doSelectJoinCurrency(criteria); 1465 } 1466 } 1467 lastSorderItemsCriteria = criteria; 1468 1469 return collSorderItems; 1470 } 1471 1472 1473 1474 1475 1476 1479 protected List collPaymentItems; 1480 1481 1486 protected void initPaymentItems() 1487 { 1488 if (collPaymentItems == null) 1489 { 1490 collPaymentItems = new ArrayList (); 1491 } 1492 } 1493 1494 1501 public void addPaymentItem(PaymentItem l) throws TorqueException 1502 { 1503 getPaymentItems().add(l); 1504 l.setCurrency((Currency) this); 1505 } 1506 1507 1510 private Criteria lastPaymentItemsCriteria = null; 1511 1512 1519 public List getPaymentItems() throws TorqueException 1520 { 1521 if (collPaymentItems == null) 1522 { 1523 collPaymentItems = getPaymentItems(new Criteria(10)); 1524 } 1525 return collPaymentItems; 1526 } 1527 1528 1539 public List getPaymentItems(Criteria criteria) throws TorqueException 1540 { 1541 if (collPaymentItems == null) 1542 { 1543 if (isNew()) 1544 { 1545 collPaymentItems = new ArrayList (); 1546 } 1547 else 1548 { 1549 criteria.add(PaymentItemPeer.CURRENCY_ID, getCurrencyId() ); 1550 collPaymentItems = PaymentItemPeer.doSelect(criteria); 1551 } 1552 } 1553 else 1554 { 1555 if (!isNew()) 1557 { 1558 criteria.add(PaymentItemPeer.CURRENCY_ID, getCurrencyId()); 1562 if (!lastPaymentItemsCriteria.equals(criteria)) 1563 { 1564 collPaymentItems = PaymentItemPeer.doSelect(criteria); 1565 } 1566 } 1567 } 1568 lastPaymentItemsCriteria = criteria; 1569 1570 return collPaymentItems; 1571 } 1572 1573 1581 public List getPaymentItems(Connection con) throws TorqueException 1582 { 1583 if (collPaymentItems == null) 1584 { 1585 collPaymentItems = getPaymentItems(new Criteria(10), con); 1586 } 1587 return collPaymentItems; 1588 } 1589 1590 1602 public List getPaymentItems(Criteria criteria, Connection con) 1603 throws TorqueException 1604 { 1605 if (collPaymentItems == null) 1606 { 1607 if (isNew()) 1608 { 1609 collPaymentItems = new ArrayList (); 1610 } 1611 else 1612 { 1613 criteria.add(PaymentItemPeer.CURRENCY_ID, getCurrencyId()); 1614 collPaymentItems = PaymentItemPeer.doSelect(criteria, con); 1615 } 1616 } 1617 else 1618 { 1619 if (!isNew()) 1621 { 1622 criteria.add(PaymentItemPeer.CURRENCY_ID, getCurrencyId()); 1626 if (!lastPaymentItemsCriteria.equals(criteria)) 1627 { 1628 collPaymentItems = PaymentItemPeer.doSelect(criteria, con); 1629 } 1630 } 1631 } 1632 lastPaymentItemsCriteria = criteria; 1633 1634 return collPaymentItems; 1635 } 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1658 protected List getPaymentItemsJoinPayment(Criteria criteria) 1659 throws TorqueException 1660 { 1661 if (collPaymentItems == null) 1662 { 1663 if (isNew()) 1664 { 1665 collPaymentItems = new ArrayList (); 1666 } 1667 else 1668 { 1669 criteria.add(PaymentItemPeer.CURRENCY_ID, getCurrencyId()); 1670 collPaymentItems = PaymentItemPeer.doSelectJoinPayment(criteria); 1671 } 1672 } 1673 else 1674 { 1675 1679 criteria.add(PaymentItemPeer.CURRENCY_ID, getCurrencyId()); 1680 if (!lastPaymentItemsCriteria.equals(criteria)) 1681 { 1682 collPaymentItems = PaymentItemPeer.doSelectJoinPayment(criteria); 1683 } 1684 } 1685 lastPaymentItemsCriteria = criteria; 1686 1687 return collPaymentItems; 1688 } 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1709 protected List getPaymentItemsJoinSorder(Criteria criteria) 1710 throws TorqueException 1711 { 1712 if (collPaymentItems == null) 1713 { 1714 if (isNew()) 1715 { 1716 collPaymentItems = new ArrayList (); 1717 } 1718 else 1719 { 1720 criteria.add(PaymentItemPeer.CURRENCY_ID, getCurrencyId()); 1721 collPaymentItems = PaymentItemPeer.doSelectJoinSorder(criteria); 1722 } 1723 } 1724 else 1725 { 1726 1730 criteria.add(PaymentItemPeer.CURRENCY_ID, getCurrencyId()); 1731 if (!lastPaymentItemsCriteria.equals(criteria)) 1732 { 1733 collPaymentItems = PaymentItemPeer.doSelectJoinSorder(criteria); 1734 } 1735 } 1736 lastPaymentItemsCriteria = criteria; 1737 1738 return collPaymentItems; 1739 } 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1760 protected List getPaymentItemsJoinProduct(Criteria criteria) 1761 throws TorqueException 1762 { 1763 if (collPaymentItems == null) 1764 { 1765 if (isNew()) 1766 { 1767 collPaymentItems = new ArrayList (); 1768 } 1769 else 1770 { 1771 criteria.add(PaymentItemPeer.CURRENCY_ID, getCurrencyId()); 1772 collPaymentItems = PaymentItemPeer.doSelectJoinProduct(criteria); 1773 } 1774 } 1775 else 1776 { 1777 1781 criteria.add(PaymentItemPeer.CURRENCY_ID, getCurrencyId()); 1782 if (!lastPaymentItemsCriteria.equals(criteria)) 1783 { 1784 collPaymentItems = PaymentItemPeer.doSelectJoinProduct(criteria); 1785 } 1786 } 1787 lastPaymentItemsCriteria = criteria; 1788 1789 return collPaymentItems; 1790 } 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1811 protected List getPaymentItemsJoinCurrency(Criteria criteria) 1812 throws TorqueException 1813 { 1814 if (collPaymentItems == null) 1815 { 1816 if (isNew()) 1817 { 1818 collPaymentItems = new ArrayList (); 1819 } 1820 else 1821 { 1822 criteria.add(PaymentItemPeer.CURRENCY_ID, getCurrencyId()); 1823 collPaymentItems = PaymentItemPeer.doSelectJoinCurrency(criteria); 1824 } 1825 } 1826 else 1827 { 1828 1832 criteria.add(PaymentItemPeer.CURRENCY_ID, getCurrencyId()); 1833 if (!lastPaymentItemsCriteria.equals(criteria)) 1834 { 1835 collPaymentItems = PaymentItemPeer.doSelectJoinCurrency(criteria); 1836 } 1837 } 1838 lastPaymentItemsCriteria = criteria; 1839 1840 return collPaymentItems; 1841 } 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1862 protected List getPaymentItemsJoinCustomer(Criteria criteria) 1863 throws TorqueException 1864 { 1865 if (collPaymentItems == null) 1866 { 1867 if (isNew()) 1868 { 1869 collPaymentItems = new ArrayList (); 1870 } 1871 else 1872 { 1873 criteria.add(PaymentItemPeer.CURRENCY_ID, getCurrencyId()); 1874 collPaymentItems = PaymentItemPeer.doSelectJoinCustomer(criteria); 1875 } 1876 } 1877 else 1878 { 1879 1883 criteria.add(PaymentItemPeer.CURRENCY_ID, getCurrencyId()); 1884 if (!lastPaymentItemsCriteria.equals(criteria)) 1885 { 1886 collPaymentItems = PaymentItemPeer.doSelectJoinCustomer(criteria); 1887 } 1888 } 1889 lastPaymentItemsCriteria = criteria; 1890 1891 return collPaymentItems; 1892 } 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1913 protected List getPaymentItemsJoinProject(Criteria criteria) 1914 throws TorqueException 1915 { 1916 if (collPaymentItems == null) 1917 { 1918 if (isNew()) 1919 { 1920 collPaymentItems = new ArrayList (); 1921 } 1922 else 1923 { 1924 criteria.add(PaymentItemPeer.CURRENCY_ID, getCurrencyId()); 1925 collPaymentItems = PaymentItemPeer.doSelectJoinProject(criteria); 1926 } 1927 } 1928 else 1929 { 1930 1934 criteria.add(PaymentItemPeer.CURRENCY_ID, getCurrencyId()); 1935 if (!lastPaymentItemsCriteria.equals(criteria)) 1936 { 1937 collPaymentItems = PaymentItemPeer.doSelectJoinProject(criteria); 1938 } 1939 } 1940 lastPaymentItemsCriteria = criteria; 1941 1942 return collPaymentItems; 1943 } 1944 1945 1946 1947 1948 private static List fieldNames = null; 1949 1950 1955 public static synchronized List getFieldNames() 1956 { 1957 if (fieldNames == null) 1958 { 1959 fieldNames = new ArrayList (); 1960 fieldNames.add("CurrencyId"); 1961 fieldNames.add("CurrencyName"); 1962 fieldNames.add("CurrencyCode"); 1963 fieldNames.add("CurrencyRate"); 1964 fieldNames = Collections.unmodifiableList(fieldNames); 1965 } 1966 return fieldNames; 1967 } 1968 1969 1975 public Object getByName(String name) 1976 { 1977 if (name.equals("CurrencyId")) 1978 { 1979 return new Integer (getCurrencyId()); 1980 } 1981 if (name.equals("CurrencyName")) 1982 { 1983 return getCurrencyName(); 1984 } 1985 if (name.equals("CurrencyCode")) 1986 { 1987 return getCurrencyCode(); 1988 } 1989 if (name.equals("CurrencyRate")) 1990 { 1991 return getCurrencyRate(); 1992 } 1993 return null; 1994 } 1995 1996 2004 public Object getByPeerName(String name) 2005 { 2006 if (name.equals(CurrencyPeer.CURRENCY_ID)) 2007 { 2008 return new Integer (getCurrencyId()); 2009 } 2010 if (name.equals(CurrencyPeer.CURRENCY_NAME)) 2011 { 2012 return getCurrencyName(); 2013 } 2014 if (name.equals(CurrencyPeer.CURRENCY_CODE)) 2015 { 2016 return getCurrencyCode(); 2017 } 2018 if (name.equals(CurrencyPeer.CURRENCY_RATE)) 2019 { 2020 return getCurrencyRate(); 2021 } 2022 return null; 2023 } 2024 2025 2032 public Object getByPosition(int pos) 2033 { 2034 if (pos == 0) 2035 { 2036 return new Integer (getCurrencyId()); 2037 } 2038 if (pos == 1) 2039 { 2040 return getCurrencyName(); 2041 } 2042 if (pos == 2) 2043 { 2044 return getCurrencyCode(); 2045 } 2046 if (pos == 3) 2047 { 2048 return getCurrencyRate(); 2049 } 2050 return null; 2051 } 2052 2053 2059 public void save() throws Exception  2060 { 2061 save(CurrencyPeer.getMapBuilder() 2062 .getDatabaseMap().getName()); 2063 } 2064 2065 2075 public void save(String dbName) throws TorqueException 2076 { 2077 Connection con = null; 2078 try 2079 { 2080 con = Transaction.begin(dbName); 2081 save(con); 2082 Transaction.commit(con); 2083 } 2084 catch(TorqueException e) 2085 { 2086 Transaction.safeRollback(con); 2087 throw e; 2088 } 2089 } 2090 2091 2093 private boolean alreadyInSave = false; 2094 2104 public void save(Connection con) throws TorqueException 2105 { 2106 if (!alreadyInSave) 2107 { 2108 alreadyInSave = true; 2109 2110 2111 2112 if (isModified()) 2114 { 2115 if (isNew()) 2116 { 2117 CurrencyPeer.doInsert((Currency) this, con); 2118 setNew(false); 2119 } 2120 else 2121 { 2122 CurrencyPeer.doUpdate((Currency) this, con); 2123 } 2124 } 2125 2126 2127 2128 if (collSorders != null) 2129 { 2130 for (int i = 0; i < collSorders.size(); i++) 2131 { 2132 ((Sorder) collSorders.get(i)).save(con); 2133 } 2134 } 2135 2136 2137 if (collPayments != null) 2138 { 2139 for (int i = 0; i < collPayments.size(); i++) 2140 { 2141 ((Payment) collPayments.get(i)).save(con); 2142 } 2143 } 2144 2145 2146 if (collSorderItems != null) 2147 { 2148 for (int i = 0; i < collSorderItems.size(); i++) 2149 { 2150 ((SorderItem) collSorderItems.get(i)).save(con); 2151 } 2152 } 2153 2154 2155 if (collPaymentItems != null) 2156 { 2157 for (int i = 0; i < collPaymentItems.size(); i++) 2158 { 2159 ((PaymentItem) collPaymentItems.get(i)).save(con); 2160 } 2161 } 2162 alreadyInSave = false; 2163 } 2164 } 2165 2166 2167 2172 public void setPrimaryKey(ObjectKey key) 2173 throws TorqueException 2174 { 2175 setCurrencyId(((NumberKey) key).intValue()); 2176 } 2177 2178 2183 public void setPrimaryKey(String key) throws TorqueException 2184 { 2185 setCurrencyId(Integer.parseInt(key)); 2186 } 2187 2188 2189 2193 public ObjectKey getPrimaryKey() 2194 { 2195 return SimpleKey.keyFor(getCurrencyId()); 2196 } 2197 2198 2202 public String getQueryKey() 2203 { 2204 if (getPrimaryKey() == null) 2205 { 2206 return ""; 2207 } 2208 else 2209 { 2210 return getPrimaryKey().toString(); 2211 } 2212 } 2213 2214 2218 public void setQueryKey(String key) 2219 throws TorqueException 2220 { 2221 setPrimaryKey(key); 2222 } 2223 2224 2230 public Currency copy() throws TorqueException 2231 { 2232 return copyInto(new Currency()); 2233 } 2234 2235 protected Currency copyInto(Currency copyObj) throws TorqueException 2236 { 2237 copyObj.setCurrencyId(currencyId); 2238 copyObj.setCurrencyName(currencyName); 2239 copyObj.setCurrencyCode(currencyCode); 2240 copyObj.setCurrencyRate(currencyRate); 2241 2242 copyObj.setCurrencyId( 0); 2243 2244 2245 2246 List v = getSorders(); 2247 for (int i = 0; i < v.size(); i++) 2248 { 2249 Sorder obj = (Sorder) v.get(i); 2250 copyObj.addSorder(obj.copy()); 2251 } 2252 2253 2254 v = getPayments(); 2255 for (int i = 0; i < v.size(); i++) 2256 { 2257 Payment obj = (Payment) v.get(i); 2258 copyObj.addPayment(obj.copy()); 2259 } 2260 2261 2262 v = getSorderItems(); 2263 for (int i = 0; i < v.size(); i++) 2264 { 2265 SorderItem obj = (SorderItem) v.get(i); 2266 copyObj.addSorderItem(obj.copy()); 2267 } 2268 2269 2270 v = getPaymentItems(); 2271 for (int i = 0; i < v.size(); i++) 2272 { 2273 PaymentItem obj = (PaymentItem) v.get(i); 2274 copyObj.addPaymentItem(obj.copy()); 2275 } 2276 return copyObj; 2277 } 2278 2279 2285 public CurrencyPeer getPeer() 2286 { 2287 return peer; 2288 } 2289 2290 public String toString() 2291 { 2292 StringBuffer str = new StringBuffer (); 2293 str.append("Currency:\n"); 2294 str.append("CurrencyId = ") 2295 .append(getCurrencyId()) 2296 .append("\n"); 2297 str.append("CurrencyName = ") 2298 .append(getCurrencyName()) 2299 .append("\n"); 2300 str.append("CurrencyCode = ") 2301 .append(getCurrencyCode()) 2302 .append("\n"); 2303 str.append("CurrencyRate = ") 2304 .append(getCurrencyRate()) 2305 .append("\n"); 2306 return(str.toString()); 2307 } 2308} 2309
| Popular Tags
|