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 BaseCarrier extends BaseObject 35 implements org.apache.turbine.om.Retrievable 36 { 37 38 private static final CarrierPeer peer = 39 new CarrierPeer(); 40 41 42 43 private int carrierId; 44 45 46 private String carrierName; 47 48 49 54 public int getCarrierId() 55 { 56 return carrierId; 57 } 58 59 60 65 public void setCarrierId(int v) throws TorqueException 66 { 67 68 if (this.carrierId != v) 69 { 70 this.carrierId = v; 71 setModified(true); 72 } 73 74 75 76 if (collSorders != null) 78 { 79 for (int i = 0; i < collSorders.size(); i++) 80 { 81 ((Sorder) collSorders.get(i)) 82 .setCarrierId(v); 83 } 84 } 85 86 if (collShipments != null) 88 { 89 for (int i = 0; i < collShipments.size(); i++) 90 { 91 ((Shipment) collShipments.get(i)) 92 .setCarrierId(v); 93 } 94 } 95 96 if (collPrintSubscriptions != null) 98 { 99 for (int i = 0; i < collPrintSubscriptions.size(); i++) 100 { 101 ((PrintSubscription) collPrintSubscriptions.get(i)) 102 .setCarrierId(v); 103 } 104 } 105 } 106 107 112 public String getCarrierName() 113 { 114 return carrierName; 115 } 116 117 118 123 public void setCarrierName(String v) 124 { 125 126 if (!ObjectUtils.equals(this.carrierName, v)) 127 { 128 this.carrierName = v; 129 setModified(true); 130 } 131 132 133 } 134 135 136 137 138 141 protected List collSorders; 142 143 148 protected void initSorders() 149 { 150 if (collSorders == null) 151 { 152 collSorders = new ArrayList (); 153 } 154 } 155 156 163 public void addSorder(Sorder l) throws TorqueException 164 { 165 getSorders().add(l); 166 l.setCarrier((Carrier) this); 167 } 168 169 172 private Criteria lastSordersCriteria = null; 173 174 181 public List getSorders() throws TorqueException 182 { 183 if (collSorders == null) 184 { 185 collSorders = getSorders(new Criteria(10)); 186 } 187 return collSorders; 188 } 189 190 201 public List getSorders(Criteria criteria) throws TorqueException 202 { 203 if (collSorders == null) 204 { 205 if (isNew()) 206 { 207 collSorders = new ArrayList (); 208 } 209 else 210 { 211 criteria.add(SorderPeer.CARRIER_ID, getCarrierId() ); 212 collSorders = SorderPeer.doSelect(criteria); 213 } 214 } 215 else 216 { 217 if (!isNew()) 219 { 220 criteria.add(SorderPeer.CARRIER_ID, getCarrierId()); 224 if (!lastSordersCriteria.equals(criteria)) 225 { 226 collSorders = SorderPeer.doSelect(criteria); 227 } 228 } 229 } 230 lastSordersCriteria = criteria; 231 232 return collSorders; 233 } 234 235 243 public List getSorders(Connection con) throws TorqueException 244 { 245 if (collSorders == null) 246 { 247 collSorders = getSorders(new Criteria(10), con); 248 } 249 return collSorders; 250 } 251 252 264 public List getSorders(Criteria criteria, Connection con) 265 throws TorqueException 266 { 267 if (collSorders == null) 268 { 269 if (isNew()) 270 { 271 collSorders = new ArrayList (); 272 } 273 else 274 { 275 criteria.add(SorderPeer.CARRIER_ID, getCarrierId()); 276 collSorders = SorderPeer.doSelect(criteria, con); 277 } 278 } 279 else 280 { 281 if (!isNew()) 283 { 284 criteria.add(SorderPeer.CARRIER_ID, getCarrierId()); 288 if (!lastSordersCriteria.equals(criteria)) 289 { 290 collSorders = SorderPeer.doSelect(criteria, con); 291 } 292 } 293 } 294 lastSordersCriteria = criteria; 295 296 return collSorders; 297 } 298 299 300 301 302 303 304 305 306 307 308 309 320 protected List getSordersJoinCustomerRelatedByCustomerId(Criteria criteria) 321 throws TorqueException 322 { 323 if (collSorders == null) 324 { 325 if (isNew()) 326 { 327 collSorders = new ArrayList (); 328 } 329 else 330 { 331 criteria.add(SorderPeer.CARRIER_ID, getCarrierId()); 332 collSorders = SorderPeer.doSelectJoinCustomerRelatedByCustomerId(criteria); 333 } 334 } 335 else 336 { 337 341 criteria.add(SorderPeer.CARRIER_ID, getCarrierId()); 342 if (!lastSordersCriteria.equals(criteria)) 343 { 344 collSorders = SorderPeer.doSelectJoinCustomerRelatedByCustomerId(criteria); 345 } 346 } 347 lastSordersCriteria = criteria; 348 349 return collSorders; 350 } 351 352 353 354 355 356 357 358 359 360 371 protected List getSordersJoinCustomerRelatedByRecipientId(Criteria criteria) 372 throws TorqueException 373 { 374 if (collSorders == null) 375 { 376 if (isNew()) 377 { 378 collSorders = new ArrayList (); 379 } 380 else 381 { 382 criteria.add(SorderPeer.CARRIER_ID, getCarrierId()); 383 collSorders = SorderPeer.doSelectJoinCustomerRelatedByRecipientId(criteria); 384 } 385 } 386 else 387 { 388 392 criteria.add(SorderPeer.CARRIER_ID, getCarrierId()); 393 if (!lastSordersCriteria.equals(criteria)) 394 { 395 collSorders = SorderPeer.doSelectJoinCustomerRelatedByRecipientId(criteria); 396 } 397 } 398 lastSordersCriteria = criteria; 399 400 return collSorders; 401 } 402 403 404 405 406 407 408 409 410 411 422 protected List getSordersJoinProject(Criteria criteria) 423 throws TorqueException 424 { 425 if (collSorders == null) 426 { 427 if (isNew()) 428 { 429 collSorders = new ArrayList (); 430 } 431 else 432 { 433 criteria.add(SorderPeer.CARRIER_ID, getCarrierId()); 434 collSorders = SorderPeer.doSelectJoinProject(criteria); 435 } 436 } 437 else 438 { 439 443 criteria.add(SorderPeer.CARRIER_ID, getCarrierId()); 444 if (!lastSordersCriteria.equals(criteria)) 445 { 446 collSorders = SorderPeer.doSelectJoinProject(criteria); 447 } 448 } 449 lastSordersCriteria = criteria; 450 451 return collSorders; 452 } 453 454 455 456 457 458 459 460 461 462 473 protected List getSordersJoinCarrier(Criteria criteria) 474 throws TorqueException 475 { 476 if (collSorders == null) 477 { 478 if (isNew()) 479 { 480 collSorders = new ArrayList (); 481 } 482 else 483 { 484 criteria.add(SorderPeer.CARRIER_ID, getCarrierId()); 485 collSorders = SorderPeer.doSelectJoinCarrier(criteria); 486 } 487 } 488 else 489 { 490 494 criteria.add(SorderPeer.CARRIER_ID, getCarrierId()); 495 if (!lastSordersCriteria.equals(criteria)) 496 { 497 collSorders = SorderPeer.doSelectJoinCarrier(criteria); 498 } 499 } 500 lastSordersCriteria = criteria; 501 502 return collSorders; 503 } 504 505 506 507 508 509 510 511 512 513 524 protected List getSordersJoinCurrency(Criteria criteria) 525 throws TorqueException 526 { 527 if (collSorders == null) 528 { 529 if (isNew()) 530 { 531 collSorders = new ArrayList (); 532 } 533 else 534 { 535 criteria.add(SorderPeer.CARRIER_ID, getCarrierId()); 536 collSorders = SorderPeer.doSelectJoinCurrency(criteria); 537 } 538 } 539 else 540 { 541 545 criteria.add(SorderPeer.CARRIER_ID, getCarrierId()); 546 if (!lastSordersCriteria.equals(criteria)) 547 { 548 collSorders = SorderPeer.doSelectJoinCurrency(criteria); 549 } 550 } 551 lastSordersCriteria = criteria; 552 553 return collSorders; 554 } 555 556 557 558 559 560 563 protected List collShipments; 564 565 570 protected void initShipments() 571 { 572 if (collShipments == null) 573 { 574 collShipments = new ArrayList (); 575 } 576 } 577 578 585 public void addShipment(Shipment l) throws TorqueException 586 { 587 getShipments().add(l); 588 l.setCarrier((Carrier) this); 589 } 590 591 594 private Criteria lastShipmentsCriteria = null; 595 596 603 public List getShipments() throws TorqueException 604 { 605 if (collShipments == null) 606 { 607 collShipments = getShipments(new Criteria(10)); 608 } 609 return collShipments; 610 } 611 612 623 public List getShipments(Criteria criteria) throws TorqueException 624 { 625 if (collShipments == null) 626 { 627 if (isNew()) 628 { 629 collShipments = new ArrayList (); 630 } 631 else 632 { 633 criteria.add(ShipmentPeer.CARRIER_ID, getCarrierId() ); 634 collShipments = ShipmentPeer.doSelect(criteria); 635 } 636 } 637 else 638 { 639 if (!isNew()) 641 { 642 criteria.add(ShipmentPeer.CARRIER_ID, getCarrierId()); 646 if (!lastShipmentsCriteria.equals(criteria)) 647 { 648 collShipments = ShipmentPeer.doSelect(criteria); 649 } 650 } 651 } 652 lastShipmentsCriteria = criteria; 653 654 return collShipments; 655 } 656 657 665 public List getShipments(Connection con) throws TorqueException 666 { 667 if (collShipments == null) 668 { 669 collShipments = getShipments(new Criteria(10), con); 670 } 671 return collShipments; 672 } 673 674 686 public List getShipments(Criteria criteria, Connection con) 687 throws TorqueException 688 { 689 if (collShipments == null) 690 { 691 if (isNew()) 692 { 693 collShipments = new ArrayList (); 694 } 695 else 696 { 697 criteria.add(ShipmentPeer.CARRIER_ID, getCarrierId()); 698 collShipments = ShipmentPeer.doSelect(criteria, con); 699 } 700 } 701 else 702 { 703 if (!isNew()) 705 { 706 criteria.add(ShipmentPeer.CARRIER_ID, getCarrierId()); 710 if (!lastShipmentsCriteria.equals(criteria)) 711 { 712 collShipments = ShipmentPeer.doSelect(criteria, con); 713 } 714 } 715 } 716 lastShipmentsCriteria = criteria; 717 718 return collShipments; 719 } 720 721 722 723 724 725 726 727 728 729 730 731 742 protected List getShipmentsJoinCustomerRelatedByCustomerId(Criteria criteria) 743 throws TorqueException 744 { 745 if (collShipments == null) 746 { 747 if (isNew()) 748 { 749 collShipments = new ArrayList (); 750 } 751 else 752 { 753 criteria.add(ShipmentPeer.CARRIER_ID, getCarrierId()); 754 collShipments = ShipmentPeer.doSelectJoinCustomerRelatedByCustomerId(criteria); 755 } 756 } 757 else 758 { 759 763 criteria.add(ShipmentPeer.CARRIER_ID, getCarrierId()); 764 if (!lastShipmentsCriteria.equals(criteria)) 765 { 766 collShipments = ShipmentPeer.doSelectJoinCustomerRelatedByCustomerId(criteria); 767 } 768 } 769 lastShipmentsCriteria = criteria; 770 771 return collShipments; 772 } 773 774 775 776 777 778 779 780 781 782 793 protected List getShipmentsJoinCustomerRelatedByRecipientId(Criteria criteria) 794 throws TorqueException 795 { 796 if (collShipments == null) 797 { 798 if (isNew()) 799 { 800 collShipments = new ArrayList (); 801 } 802 else 803 { 804 criteria.add(ShipmentPeer.CARRIER_ID, getCarrierId()); 805 collShipments = ShipmentPeer.doSelectJoinCustomerRelatedByRecipientId(criteria); 806 } 807 } 808 else 809 { 810 814 criteria.add(ShipmentPeer.CARRIER_ID, getCarrierId()); 815 if (!lastShipmentsCriteria.equals(criteria)) 816 { 817 collShipments = ShipmentPeer.doSelectJoinCustomerRelatedByRecipientId(criteria); 818 } 819 } 820 lastShipmentsCriteria = criteria; 821 822 return collShipments; 823 } 824 825 826 827 828 829 830 831 832 833 844 protected List getShipmentsJoinProject(Criteria criteria) 845 throws TorqueException 846 { 847 if (collShipments == null) 848 { 849 if (isNew()) 850 { 851 collShipments = new ArrayList (); 852 } 853 else 854 { 855 criteria.add(ShipmentPeer.CARRIER_ID, getCarrierId()); 856 collShipments = ShipmentPeer.doSelectJoinProject(criteria); 857 } 858 } 859 else 860 { 861 865 criteria.add(ShipmentPeer.CARRIER_ID, getCarrierId()); 866 if (!lastShipmentsCriteria.equals(criteria)) 867 { 868 collShipments = ShipmentPeer.doSelectJoinProject(criteria); 869 } 870 } 871 lastShipmentsCriteria = criteria; 872 873 return collShipments; 874 } 875 876 877 878 879 880 881 882 883 884 895 protected List getShipmentsJoinSorder(Criteria criteria) 896 throws TorqueException 897 { 898 if (collShipments == null) 899 { 900 if (isNew()) 901 { 902 collShipments = new ArrayList (); 903 } 904 else 905 { 906 criteria.add(ShipmentPeer.CARRIER_ID, getCarrierId()); 907 collShipments = ShipmentPeer.doSelectJoinSorder(criteria); 908 } 909 } 910 else 911 { 912 916 criteria.add(ShipmentPeer.CARRIER_ID, getCarrierId()); 917 if (!lastShipmentsCriteria.equals(criteria)) 918 { 919 collShipments = ShipmentPeer.doSelectJoinSorder(criteria); 920 } 921 } 922 lastShipmentsCriteria = criteria; 923 924 return collShipments; 925 } 926 927 928 929 930 931 932 933 934 935 946 protected List getShipmentsJoinCarrier(Criteria criteria) 947 throws TorqueException 948 { 949 if (collShipments == null) 950 { 951 if (isNew()) 952 { 953 collShipments = new ArrayList (); 954 } 955 else 956 { 957 criteria.add(ShipmentPeer.CARRIER_ID, getCarrierId()); 958 collShipments = ShipmentPeer.doSelectJoinCarrier(criteria); 959 } 960 } 961 else 962 { 963 967 criteria.add(ShipmentPeer.CARRIER_ID, getCarrierId()); 968 if (!lastShipmentsCriteria.equals(criteria)) 969 { 970 collShipments = ShipmentPeer.doSelectJoinCarrier(criteria); 971 } 972 } 973 lastShipmentsCriteria = criteria; 974 975 return collShipments; 976 } 977 978 979 980 981 982 985 protected List collPrintSubscriptions; 986 987 992 protected void initPrintSubscriptions() 993 { 994 if (collPrintSubscriptions == null) 995 { 996 collPrintSubscriptions = new ArrayList (); 997 } 998 } 999 1000 1007 public void addPrintSubscription(PrintSubscription l) throws TorqueException 1008 { 1009 getPrintSubscriptions().add(l); 1010 l.setCarrier((Carrier) this); 1011 } 1012 1013 1016 private Criteria lastPrintSubscriptionsCriteria = null; 1017 1018 1025 public List getPrintSubscriptions() throws TorqueException 1026 { 1027 if (collPrintSubscriptions == null) 1028 { 1029 collPrintSubscriptions = getPrintSubscriptions(new Criteria(10)); 1030 } 1031 return collPrintSubscriptions; 1032 } 1033 1034 1045 public List getPrintSubscriptions(Criteria criteria) throws TorqueException 1046 { 1047 if (collPrintSubscriptions == null) 1048 { 1049 if (isNew()) 1050 { 1051 collPrintSubscriptions = new ArrayList (); 1052 } 1053 else 1054 { 1055 criteria.add(PrintSubscriptionPeer.CARRIER_ID, getCarrierId() ); 1056 collPrintSubscriptions = PrintSubscriptionPeer.doSelect(criteria); 1057 } 1058 } 1059 else 1060 { 1061 if (!isNew()) 1063 { 1064 criteria.add(PrintSubscriptionPeer.CARRIER_ID, getCarrierId()); 1068 if (!lastPrintSubscriptionsCriteria.equals(criteria)) 1069 { 1070 collPrintSubscriptions = PrintSubscriptionPeer.doSelect(criteria); 1071 } 1072 } 1073 } 1074 lastPrintSubscriptionsCriteria = criteria; 1075 1076 return collPrintSubscriptions; 1077 } 1078 1079 1087 public List getPrintSubscriptions(Connection con) throws TorqueException 1088 { 1089 if (collPrintSubscriptions == null) 1090 { 1091 collPrintSubscriptions = getPrintSubscriptions(new Criteria(10), con); 1092 } 1093 return collPrintSubscriptions; 1094 } 1095 1096 1108 public List getPrintSubscriptions(Criteria criteria, Connection con) 1109 throws TorqueException 1110 { 1111 if (collPrintSubscriptions == null) 1112 { 1113 if (isNew()) 1114 { 1115 collPrintSubscriptions = new ArrayList (); 1116 } 1117 else 1118 { 1119 criteria.add(PrintSubscriptionPeer.CARRIER_ID, getCarrierId()); 1120 collPrintSubscriptions = PrintSubscriptionPeer.doSelect(criteria, con); 1121 } 1122 } 1123 else 1124 { 1125 if (!isNew()) 1127 { 1128 criteria.add(PrintSubscriptionPeer.CARRIER_ID, getCarrierId()); 1132 if (!lastPrintSubscriptionsCriteria.equals(criteria)) 1133 { 1134 collPrintSubscriptions = PrintSubscriptionPeer.doSelect(criteria, con); 1135 } 1136 } 1137 } 1138 lastPrintSubscriptionsCriteria = criteria; 1139 1140 return collPrintSubscriptions; 1141 } 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1164 protected List getPrintSubscriptionsJoinCustomerRelatedByCustomerId(Criteria criteria) 1165 throws TorqueException 1166 { 1167 if (collPrintSubscriptions == null) 1168 { 1169 if (isNew()) 1170 { 1171 collPrintSubscriptions = new ArrayList (); 1172 } 1173 else 1174 { 1175 criteria.add(PrintSubscriptionPeer.CARRIER_ID, getCarrierId()); 1176 collPrintSubscriptions = PrintSubscriptionPeer.doSelectJoinCustomerRelatedByCustomerId(criteria); 1177 } 1178 } 1179 else 1180 { 1181 1185 criteria.add(PrintSubscriptionPeer.CARRIER_ID, getCarrierId()); 1186 if (!lastPrintSubscriptionsCriteria.equals(criteria)) 1187 { 1188 collPrintSubscriptions = PrintSubscriptionPeer.doSelectJoinCustomerRelatedByCustomerId(criteria); 1189 } 1190 } 1191 lastPrintSubscriptionsCriteria = criteria; 1192 1193 return collPrintSubscriptions; 1194 } 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1215 protected List getPrintSubscriptionsJoinCustomerRelatedByRecipientId(Criteria criteria) 1216 throws TorqueException 1217 { 1218 if (collPrintSubscriptions == null) 1219 { 1220 if (isNew()) 1221 { 1222 collPrintSubscriptions = new ArrayList (); 1223 } 1224 else 1225 { 1226 criteria.add(PrintSubscriptionPeer.CARRIER_ID, getCarrierId()); 1227 collPrintSubscriptions = PrintSubscriptionPeer.doSelectJoinCustomerRelatedByRecipientId(criteria); 1228 } 1229 } 1230 else 1231 { 1232 1236 criteria.add(PrintSubscriptionPeer.CARRIER_ID, getCarrierId()); 1237 if (!lastPrintSubscriptionsCriteria.equals(criteria)) 1238 { 1239 collPrintSubscriptions = PrintSubscriptionPeer.doSelectJoinCustomerRelatedByRecipientId(criteria); 1240 } 1241 } 1242 lastPrintSubscriptionsCriteria = criteria; 1243 1244 return collPrintSubscriptions; 1245 } 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1266 protected List getPrintSubscriptionsJoinCarrier(Criteria criteria) 1267 throws TorqueException 1268 { 1269 if (collPrintSubscriptions == null) 1270 { 1271 if (isNew()) 1272 { 1273 collPrintSubscriptions = new ArrayList (); 1274 } 1275 else 1276 { 1277 criteria.add(PrintSubscriptionPeer.CARRIER_ID, getCarrierId()); 1278 collPrintSubscriptions = PrintSubscriptionPeer.doSelectJoinCarrier(criteria); 1279 } 1280 } 1281 else 1282 { 1283 1287 criteria.add(PrintSubscriptionPeer.CARRIER_ID, getCarrierId()); 1288 if (!lastPrintSubscriptionsCriteria.equals(criteria)) 1289 { 1290 collPrintSubscriptions = PrintSubscriptionPeer.doSelectJoinCarrier(criteria); 1291 } 1292 } 1293 lastPrintSubscriptionsCriteria = criteria; 1294 1295 return collPrintSubscriptions; 1296 } 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1317 protected List getPrintSubscriptionsJoinProject(Criteria criteria) 1318 throws TorqueException 1319 { 1320 if (collPrintSubscriptions == null) 1321 { 1322 if (isNew()) 1323 { 1324 collPrintSubscriptions = new ArrayList (); 1325 } 1326 else 1327 { 1328 criteria.add(PrintSubscriptionPeer.CARRIER_ID, getCarrierId()); 1329 collPrintSubscriptions = PrintSubscriptionPeer.doSelectJoinProject(criteria); 1330 } 1331 } 1332 else 1333 { 1334 1338 criteria.add(PrintSubscriptionPeer.CARRIER_ID, getCarrierId()); 1339 if (!lastPrintSubscriptionsCriteria.equals(criteria)) 1340 { 1341 collPrintSubscriptions = PrintSubscriptionPeer.doSelectJoinProject(criteria); 1342 } 1343 } 1344 lastPrintSubscriptionsCriteria = criteria; 1345 1346 return collPrintSubscriptions; 1347 } 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1368 protected List getPrintSubscriptionsJoinProduct(Criteria criteria) 1369 throws TorqueException 1370 { 1371 if (collPrintSubscriptions == null) 1372 { 1373 if (isNew()) 1374 { 1375 collPrintSubscriptions = new ArrayList (); 1376 } 1377 else 1378 { 1379 criteria.add(PrintSubscriptionPeer.CARRIER_ID, getCarrierId()); 1380 collPrintSubscriptions = PrintSubscriptionPeer.doSelectJoinProduct(criteria); 1381 } 1382 } 1383 else 1384 { 1385 1389 criteria.add(PrintSubscriptionPeer.CARRIER_ID, getCarrierId()); 1390 if (!lastPrintSubscriptionsCriteria.equals(criteria)) 1391 { 1392 collPrintSubscriptions = PrintSubscriptionPeer.doSelectJoinProduct(criteria); 1393 } 1394 } 1395 lastPrintSubscriptionsCriteria = criteria; 1396 1397 return collPrintSubscriptions; 1398 } 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1419 protected List getPrintSubscriptionsJoinSorder(Criteria criteria) 1420 throws TorqueException 1421 { 1422 if (collPrintSubscriptions == null) 1423 { 1424 if (isNew()) 1425 { 1426 collPrintSubscriptions = new ArrayList (); 1427 } 1428 else 1429 { 1430 criteria.add(PrintSubscriptionPeer.CARRIER_ID, getCarrierId()); 1431 collPrintSubscriptions = PrintSubscriptionPeer.doSelectJoinSorder(criteria); 1432 } 1433 } 1434 else 1435 { 1436 1440 criteria.add(PrintSubscriptionPeer.CARRIER_ID, getCarrierId()); 1441 if (!lastPrintSubscriptionsCriteria.equals(criteria)) 1442 { 1443 collPrintSubscriptions = PrintSubscriptionPeer.doSelectJoinSorder(criteria); 1444 } 1445 } 1446 lastPrintSubscriptionsCriteria = criteria; 1447 1448 return collPrintSubscriptions; 1449 } 1450 1451 1452 1453 1454 private static List fieldNames = null; 1455 1456 1461 public static synchronized List getFieldNames() 1462 { 1463 if (fieldNames == null) 1464 { 1465 fieldNames = new ArrayList (); 1466 fieldNames.add("CarrierId"); 1467 fieldNames.add("CarrierName"); 1468 fieldNames = Collections.unmodifiableList(fieldNames); 1469 } 1470 return fieldNames; 1471 } 1472 1473 1479 public Object getByName(String name) 1480 { 1481 if (name.equals("CarrierId")) 1482 { 1483 return new Integer (getCarrierId()); 1484 } 1485 if (name.equals("CarrierName")) 1486 { 1487 return getCarrierName(); 1488 } 1489 return null; 1490 } 1491 1492 1500 public Object getByPeerName(String name) 1501 { 1502 if (name.equals(CarrierPeer.CARRIER_ID)) 1503 { 1504 return new Integer (getCarrierId()); 1505 } 1506 if (name.equals(CarrierPeer.CARRIER_NAME)) 1507 { 1508 return getCarrierName(); 1509 } 1510 return null; 1511 } 1512 1513 1520 public Object getByPosition(int pos) 1521 { 1522 if (pos == 0) 1523 { 1524 return new Integer (getCarrierId()); 1525 } 1526 if (pos == 1) 1527 { 1528 return getCarrierName(); 1529 } 1530 return null; 1531 } 1532 1533 1539 public void save() throws Exception 1540 { 1541 save(CarrierPeer.getMapBuilder() 1542 .getDatabaseMap().getName()); 1543 } 1544 1545 1555 public void save(String dbName) throws TorqueException 1556 { 1557 Connection con = null; 1558 try 1559 { 1560 con = Transaction.begin(dbName); 1561 save(con); 1562 Transaction.commit(con); 1563 } 1564 catch(TorqueException e) 1565 { 1566 Transaction.safeRollback(con); 1567 throw e; 1568 } 1569 } 1570 1571 1573 private boolean alreadyInSave = false; 1574 1584 public void save(Connection con) throws TorqueException 1585 { 1586 if (!alreadyInSave) 1587 { 1588 alreadyInSave = true; 1589 1590 1591 1592 if (isModified()) 1594 { 1595 if (isNew()) 1596 { 1597 CarrierPeer.doInsert((Carrier) this, con); 1598 setNew(false); 1599 } 1600 else 1601 { 1602 CarrierPeer.doUpdate((Carrier) this, con); 1603 } 1604 } 1605 1606 1607 1608 if (collSorders != null) 1609 { 1610 for (int i = 0; i < collSorders.size(); i++) 1611 { 1612 ((Sorder) collSorders.get(i)).save(con); 1613 } 1614 } 1615 1616 1617 if (collShipments != null) 1618 { 1619 for (int i = 0; i < collShipments.size(); i++) 1620 { 1621 ((Shipment) collShipments.get(i)).save(con); 1622 } 1623 } 1624 1625 1626 if (collPrintSubscriptions != null) 1627 { 1628 for (int i = 0; i < collPrintSubscriptions.size(); i++) 1629 { 1630 ((PrintSubscription) collPrintSubscriptions.get(i)).save(con); 1631 } 1632 } 1633 alreadyInSave = false; 1634 } 1635 } 1636 1637 1638 1643 public void setPrimaryKey(ObjectKey key) 1644 throws TorqueException 1645 { 1646 setCarrierId(((NumberKey) key).intValue()); 1647 } 1648 1649 1654 public void setPrimaryKey(String key) throws TorqueException 1655 { 1656 setCarrierId(Integer.parseInt(key)); 1657 } 1658 1659 1660 1664 public ObjectKey getPrimaryKey() 1665 { 1666 return SimpleKey.keyFor(getCarrierId()); 1667 } 1668 1669 1673 public String getQueryKey() 1674 { 1675 if (getPrimaryKey() == null) 1676 { 1677 return ""; 1678 } 1679 else 1680 { 1681 return getPrimaryKey().toString(); 1682 } 1683 } 1684 1685 1689 public void setQueryKey(String key) 1690 throws TorqueException 1691 { 1692 setPrimaryKey(key); 1693 } 1694 1695 1701 public Carrier copy() throws TorqueException 1702 { 1703 return copyInto(new Carrier()); 1704 } 1705 1706 protected Carrier copyInto(Carrier copyObj) throws TorqueException 1707 { 1708 copyObj.setCarrierId(carrierId); 1709 copyObj.setCarrierName(carrierName); 1710 1711 copyObj.setCarrierId( 0); 1712 1713 1714 1715 List v = getSorders(); 1716 for (int i = 0; i < v.size(); i++) 1717 { 1718 Sorder obj = (Sorder) v.get(i); 1719 copyObj.addSorder(obj.copy()); 1720 } 1721 1722 1723 v = getShipments(); 1724 for (int i = 0; i < v.size(); i++) 1725 { 1726 Shipment obj = (Shipment) v.get(i); 1727 copyObj.addShipment(obj.copy()); 1728 } 1729 1730 1731 v = getPrintSubscriptions(); 1732 for (int i = 0; i < v.size(); i++) 1733 { 1734 PrintSubscription obj = (PrintSubscription) v.get(i); 1735 copyObj.addPrintSubscription(obj.copy()); 1736 } 1737 return copyObj; 1738 } 1739 1740 1746 public CarrierPeer getPeer() 1747 { 1748 return peer; 1749 } 1750 1751 public String toString() 1752 { 1753 StringBuffer str = new StringBuffer (); 1754 str.append("Carrier:\n"); 1755 str.append("CarrierId = ") 1756 .append(getCarrierId()) 1757 .append("\n"); 1758 str.append("CarrierName = ") 1759 .append(getCarrierName()) 1760 .append("\n"); 1761 return(str.toString()); 1762 } 1763} 1764 | Popular Tags |