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 39 public abstract class BaseShipment extends BaseObject 40 implements org.apache.turbine.om.Retrievable 41 { 42 43 private static final ShipmentPeer peer = 44 new ShipmentPeer(); 45 46 47 48 private int shipmentId; 49 50 51 private String shipmentCode = "AUTO"; 52 53 54 private int status = 30; 55 56 57 private int priority = 30; 58 59 60 private Date issuedDate; 61 62 63 private Date closedDate; 64 65 66 private int customerId = 1000; 67 68 69 private int recipientId = 1000; 70 71 72 private int projectId = 1000; 73 74 75 private int sorderId = 1000; 76 77 78 private String invoiceCode; 79 80 81 private int carrierId = 1000; 82 83 84 private String subject = "---"; 85 86 87 private String notes; 88 89 90 private Date created; 91 92 93 private Date modified; 94 95 96 private String createdBy; 97 98 99 private String modifiedBy; 100 101 102 107 public int getShipmentId() 108 { 109 return shipmentId; 110 } 111 112 113 118 public void setShipmentId(int v) throws TorqueException 119 { 120 121 if (this.shipmentId != v) 122 { 123 this.shipmentId = v; 124 setModified(true); 125 } 126 127 128 129 if (collShipmentItems != null) 131 { 132 for (int i = 0; i < collShipmentItems.size(); i++) 133 { 134 ((ShipmentItem) collShipmentItems.get(i)) 135 .setShipmentId(v); 136 } 137 } 138 } 139 140 145 public String getShipmentCode() 146 { 147 return shipmentCode; 148 } 149 150 151 156 public void setShipmentCode(String v) 157 { 158 159 if (!ObjectUtils.equals(this.shipmentCode, v)) 160 { 161 this.shipmentCode = v; 162 setModified(true); 163 } 164 165 166 } 167 168 173 public int getStatus() 174 { 175 return status; 176 } 177 178 179 184 public void setStatus(int v) 185 { 186 187 if (this.status != v) 188 { 189 this.status = v; 190 setModified(true); 191 } 192 193 194 } 195 196 201 public int getPriority() 202 { 203 return priority; 204 } 205 206 207 212 public void setPriority(int v) 213 { 214 215 if (this.priority != v) 216 { 217 this.priority = v; 218 setModified(true); 219 } 220 221 222 } 223 224 229 public Date getIssuedDate() 230 { 231 return issuedDate; 232 } 233 234 235 240 public void setIssuedDate(Date v) 241 { 242 243 if (!ObjectUtils.equals(this.issuedDate, v)) 244 { 245 this.issuedDate = v; 246 setModified(true); 247 } 248 249 250 } 251 252 257 public Date getClosedDate() 258 { 259 return closedDate; 260 } 261 262 263 268 public void setClosedDate(Date v) 269 { 270 271 if (!ObjectUtils.equals(this.closedDate, v)) 272 { 273 this.closedDate = v; 274 setModified(true); 275 } 276 277 278 } 279 280 285 public int getCustomerId() 286 { 287 return customerId; 288 } 289 290 291 296 public void setCustomerId(int v) throws TorqueException 297 { 298 299 if (this.customerId != v) 300 { 301 this.customerId = v; 302 setModified(true); 303 } 304 305 306 if (aCustomerRelatedByCustomerId != null && !(aCustomerRelatedByCustomerId.getCustomerId() == v)) 307 { 308 aCustomerRelatedByCustomerId = null; 309 } 310 311 } 312 313 318 public int getRecipientId() 319 { 320 return recipientId; 321 } 322 323 324 329 public void setRecipientId(int v) throws TorqueException 330 { 331 332 if (this.recipientId != v) 333 { 334 this.recipientId = v; 335 setModified(true); 336 } 337 338 339 if (aCustomerRelatedByRecipientId != null && !(aCustomerRelatedByRecipientId.getCustomerId() == v)) 340 { 341 aCustomerRelatedByRecipientId = null; 342 } 343 344 } 345 346 351 public int getProjectId() 352 { 353 return projectId; 354 } 355 356 357 362 public void setProjectId(int v) throws TorqueException 363 { 364 365 if (this.projectId != v) 366 { 367 this.projectId = v; 368 setModified(true); 369 } 370 371 372 if (aProject != null && !(aProject.getProjectId() == v)) 373 { 374 aProject = null; 375 } 376 377 } 378 379 384 public int getSorderId() 385 { 386 return sorderId; 387 } 388 389 390 395 public void setSorderId(int v) throws TorqueException 396 { 397 398 if (this.sorderId != v) 399 { 400 this.sorderId = v; 401 setModified(true); 402 } 403 404 405 if (aSorder != null && !(aSorder.getSorderId() == v)) 406 { 407 aSorder = null; 408 } 409 410 } 411 412 417 public String getInvoiceCode() 418 { 419 return invoiceCode; 420 } 421 422 423 428 public void setInvoiceCode(String v) 429 { 430 431 if (!ObjectUtils.equals(this.invoiceCode, v)) 432 { 433 this.invoiceCode = v; 434 setModified(true); 435 } 436 437 438 } 439 440 445 public int getCarrierId() 446 { 447 return carrierId; 448 } 449 450 451 456 public void setCarrierId(int v) throws TorqueException 457 { 458 459 if (this.carrierId != v) 460 { 461 this.carrierId = v; 462 setModified(true); 463 } 464 465 466 if (aCarrier != null && !(aCarrier.getCarrierId() == v)) 467 { 468 aCarrier = null; 469 } 470 471 } 472 473 478 public String getSubject() 479 { 480 return subject; 481 } 482 483 484 489 public void setSubject(String v) 490 { 491 492 if (!ObjectUtils.equals(this.subject, v)) 493 { 494 this.subject = v; 495 setModified(true); 496 } 497 498 499 } 500 501 506 public String getNotes() 507 { 508 return notes; 509 } 510 511 512 517 public void setNotes(String v) 518 { 519 520 if (!ObjectUtils.equals(this.notes, v)) 521 { 522 this.notes = v; 523 setModified(true); 524 } 525 526 527 } 528 529 534 public Date getCreated() 535 { 536 return created; 537 } 538 539 540 545 public void setCreated(Date v) 546 { 547 548 if (!ObjectUtils.equals(this.created, v)) 549 { 550 this.created = v; 551 setModified(true); 552 } 553 554 555 } 556 557 562 public Date getModified() 563 { 564 return modified; 565 } 566 567 568 573 public void setModified(Date v) 574 { 575 576 if (!ObjectUtils.equals(this.modified, v)) 577 { 578 this.modified = v; 579 setModified(true); 580 } 581 582 583 } 584 585 590 public String getCreatedBy() 591 { 592 return createdBy; 593 } 594 595 596 601 public void setCreatedBy(String v) 602 { 603 604 if (!ObjectUtils.equals(this.createdBy, v)) 605 { 606 this.createdBy = v; 607 setModified(true); 608 } 609 610 611 } 612 613 618 public String getModifiedBy() 619 { 620 return modifiedBy; 621 } 622 623 624 629 public void setModifiedBy(String v) 630 { 631 632 if (!ObjectUtils.equals(this.modifiedBy, v)) 633 { 634 this.modifiedBy = v; 635 setModified(true); 636 } 637 638 639 } 640 641 642 643 644 645 private Customer aCustomerRelatedByCustomerId; 646 647 653 public void setCustomerRelatedByCustomerId(Customer v) throws TorqueException 654 { 655 if (v == null) 656 { 657 setCustomerId( 1000); 658 } 659 else 660 { 661 setCustomerId(v.getCustomerId()); 662 } 663 aCustomerRelatedByCustomerId = v; 664 } 665 666 667 673 public Customer getCustomerRelatedByCustomerId() throws TorqueException 674 { 675 if (aCustomerRelatedByCustomerId == null && (this.customerId != 0)) 676 { 677 aCustomerRelatedByCustomerId = CustomerPeer.retrieveByPK(SimpleKey.keyFor(this.customerId)); 678 679 688 } 689 return aCustomerRelatedByCustomerId; 690 } 691 692 698 public void setCustomerRelatedByCustomerIdKey(ObjectKey key) throws TorqueException 699 { 700 701 setCustomerId(((NumberKey) key).intValue()); 702 } 703 704 705 706 707 private Customer aCustomerRelatedByRecipientId; 708 709 715 public void setCustomerRelatedByRecipientId(Customer v) throws TorqueException 716 { 717 if (v == null) 718 { 719 setRecipientId( 1000); 720 } 721 else 722 { 723 setRecipientId(v.getCustomerId()); 724 } 725 aCustomerRelatedByRecipientId = v; 726 } 727 728 729 735 public Customer getCustomerRelatedByRecipientId() throws TorqueException 736 { 737 if (aCustomerRelatedByRecipientId == null && (this.recipientId != 0)) 738 { 739 aCustomerRelatedByRecipientId = CustomerPeer.retrieveByPK(SimpleKey.keyFor(this.recipientId)); 740 741 750 } 751 return aCustomerRelatedByRecipientId; 752 } 753 754 760 public void setCustomerRelatedByRecipientIdKey(ObjectKey key) throws TorqueException 761 { 762 763 setRecipientId(((NumberKey) key).intValue()); 764 } 765 766 767 768 769 private Project aProject; 770 771 777 public void setProject(Project v) throws TorqueException 778 { 779 if (v == null) 780 { 781 setProjectId( 1000); 782 } 783 else 784 { 785 setProjectId(v.getProjectId()); 786 } 787 aProject = v; 788 } 789 790 791 797 public Project getProject() throws TorqueException 798 { 799 if (aProject == null && (this.projectId != 0)) 800 { 801 aProject = ProjectPeer.retrieveByPK(SimpleKey.keyFor(this.projectId)); 802 803 812 } 813 return aProject; 814 } 815 816 822 public void setProjectKey(ObjectKey key) throws TorqueException 823 { 824 825 setProjectId(((NumberKey) key).intValue()); 826 } 827 828 829 830 831 private Sorder aSorder; 832 833 839 public void setSorder(Sorder v) throws TorqueException 840 { 841 if (v == null) 842 { 843 setSorderId( 1000); 844 } 845 else 846 { 847 setSorderId(v.getSorderId()); 848 } 849 aSorder = v; 850 } 851 852 853 859 public Sorder getSorder() throws TorqueException 860 { 861 if (aSorder == null && (this.sorderId != 0)) 862 { 863 aSorder = SorderPeer.retrieveByPK(SimpleKey.keyFor(this.sorderId)); 864 865 874 } 875 return aSorder; 876 } 877 878 884 public void setSorderKey(ObjectKey key) throws TorqueException 885 { 886 887 setSorderId(((NumberKey) key).intValue()); 888 } 889 890 891 892 893 private Carrier aCarrier; 894 895 901 public void setCarrier(Carrier v) throws TorqueException 902 { 903 if (v == null) 904 { 905 setCarrierId( 1000); 906 } 907 else 908 { 909 setCarrierId(v.getCarrierId()); 910 } 911 aCarrier = v; 912 } 913 914 915 921 public Carrier getCarrier() throws TorqueException 922 { 923 if (aCarrier == null && (this.carrierId != 0)) 924 { 925 aCarrier = CarrierPeer.retrieveByPK(SimpleKey.keyFor(this.carrierId)); 926 927 936 } 937 return aCarrier; 938 } 939 940 946 public void setCarrierKey(ObjectKey key) throws TorqueException 947 { 948 949 setCarrierId(((NumberKey) key).intValue()); 950 } 951 952 953 954 957 protected List collShipmentItems; 958 959 964 protected void initShipmentItems() 965 { 966 if (collShipmentItems == null) 967 { 968 collShipmentItems = new ArrayList (); 969 } 970 } 971 972 979 public void addShipmentItem(ShipmentItem l) throws TorqueException 980 { 981 getShipmentItems().add(l); 982 l.setShipment((Shipment) this); 983 } 984 985 988 private Criteria lastShipmentItemsCriteria = null; 989 990 997 public List getShipmentItems() throws TorqueException 998 { 999 if (collShipmentItems == null) 1000 { 1001 collShipmentItems = getShipmentItems(new Criteria(10)); 1002 } 1003 return collShipmentItems; 1004 } 1005 1006 1017 public List getShipmentItems(Criteria criteria) throws TorqueException 1018 { 1019 if (collShipmentItems == null) 1020 { 1021 if (isNew()) 1022 { 1023 collShipmentItems = new ArrayList (); 1024 } 1025 else 1026 { 1027 criteria.add(ShipmentItemPeer.SHIPMENT_ID, getShipmentId() ); 1028 collShipmentItems = ShipmentItemPeer.doSelect(criteria); 1029 } 1030 } 1031 else 1032 { 1033 if (!isNew()) 1035 { 1036 criteria.add(ShipmentItemPeer.SHIPMENT_ID, getShipmentId()); 1040 if (!lastShipmentItemsCriteria.equals(criteria)) 1041 { 1042 collShipmentItems = ShipmentItemPeer.doSelect(criteria); 1043 } 1044 } 1045 } 1046 lastShipmentItemsCriteria = criteria; 1047 1048 return collShipmentItems; 1049 } 1050 1051 1059 public List getShipmentItems(Connection con) throws TorqueException 1060 { 1061 if (collShipmentItems == null) 1062 { 1063 collShipmentItems = getShipmentItems(new Criteria(10), con); 1064 } 1065 return collShipmentItems; 1066 } 1067 1068 1080 public List getShipmentItems(Criteria criteria, Connection con) 1081 throws TorqueException 1082 { 1083 if (collShipmentItems == null) 1084 { 1085 if (isNew()) 1086 { 1087 collShipmentItems = new ArrayList (); 1088 } 1089 else 1090 { 1091 criteria.add(ShipmentItemPeer.SHIPMENT_ID, getShipmentId()); 1092 collShipmentItems = ShipmentItemPeer.doSelect(criteria, con); 1093 } 1094 } 1095 else 1096 { 1097 if (!isNew()) 1099 { 1100 criteria.add(ShipmentItemPeer.SHIPMENT_ID, getShipmentId()); 1104 if (!lastShipmentItemsCriteria.equals(criteria)) 1105 { 1106 collShipmentItems = ShipmentItemPeer.doSelect(criteria, con); 1107 } 1108 } 1109 } 1110 lastShipmentItemsCriteria = criteria; 1111 1112 return collShipmentItems; 1113 } 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1136 protected List getShipmentItemsJoinShipment(Criteria criteria) 1137 throws TorqueException 1138 { 1139 if (collShipmentItems == null) 1140 { 1141 if (isNew()) 1142 { 1143 collShipmentItems = new ArrayList (); 1144 } 1145 else 1146 { 1147 criteria.add(ShipmentItemPeer.SHIPMENT_ID, getShipmentId()); 1148 collShipmentItems = ShipmentItemPeer.doSelectJoinShipment(criteria); 1149 } 1150 } 1151 else 1152 { 1153 1157 criteria.add(ShipmentItemPeer.SHIPMENT_ID, getShipmentId()); 1158 if (!lastShipmentItemsCriteria.equals(criteria)) 1159 { 1160 collShipmentItems = ShipmentItemPeer.doSelectJoinShipment(criteria); 1161 } 1162 } 1163 lastShipmentItemsCriteria = criteria; 1164 1165 return collShipmentItems; 1166 } 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1187 protected List getShipmentItemsJoinSorder(Criteria criteria) 1188 throws TorqueException 1189 { 1190 if (collShipmentItems == null) 1191 { 1192 if (isNew()) 1193 { 1194 collShipmentItems = new ArrayList (); 1195 } 1196 else 1197 { 1198 criteria.add(ShipmentItemPeer.SHIPMENT_ID, getShipmentId()); 1199 collShipmentItems = ShipmentItemPeer.doSelectJoinSorder(criteria); 1200 } 1201 } 1202 else 1203 { 1204 1208 criteria.add(ShipmentItemPeer.SHIPMENT_ID, getShipmentId()); 1209 if (!lastShipmentItemsCriteria.equals(criteria)) 1210 { 1211 collShipmentItems = ShipmentItemPeer.doSelectJoinSorder(criteria); 1212 } 1213 } 1214 lastShipmentItemsCriteria = criteria; 1215 1216 return collShipmentItems; 1217 } 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1238 protected List getShipmentItemsJoinProduct(Criteria criteria) 1239 throws TorqueException 1240 { 1241 if (collShipmentItems == null) 1242 { 1243 if (isNew()) 1244 { 1245 collShipmentItems = new ArrayList (); 1246 } 1247 else 1248 { 1249 criteria.add(ShipmentItemPeer.SHIPMENT_ID, getShipmentId()); 1250 collShipmentItems = ShipmentItemPeer.doSelectJoinProduct(criteria); 1251 } 1252 } 1253 else 1254 { 1255 1259 criteria.add(ShipmentItemPeer.SHIPMENT_ID, getShipmentId()); 1260 if (!lastShipmentItemsCriteria.equals(criteria)) 1261 { 1262 collShipmentItems = ShipmentItemPeer.doSelectJoinProduct(criteria); 1263 } 1264 } 1265 lastShipmentItemsCriteria = criteria; 1266 1267 return collShipmentItems; 1268 } 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1289 protected List getShipmentItemsJoinCustomerRelatedByCustomerId(Criteria criteria) 1290 throws TorqueException 1291 { 1292 if (collShipmentItems == null) 1293 { 1294 if (isNew()) 1295 { 1296 collShipmentItems = new ArrayList (); 1297 } 1298 else 1299 { 1300 criteria.add(ShipmentItemPeer.SHIPMENT_ID, getShipmentId()); 1301 collShipmentItems = ShipmentItemPeer.doSelectJoinCustomerRelatedByCustomerId(criteria); 1302 } 1303 } 1304 else 1305 { 1306 1310 criteria.add(ShipmentItemPeer.SHIPMENT_ID, getShipmentId()); 1311 if (!lastShipmentItemsCriteria.equals(criteria)) 1312 { 1313 collShipmentItems = ShipmentItemPeer.doSelectJoinCustomerRelatedByCustomerId(criteria); 1314 } 1315 } 1316 lastShipmentItemsCriteria = criteria; 1317 1318 return collShipmentItems; 1319 } 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1340 protected List getShipmentItemsJoinCustomerRelatedByRecipientId(Criteria criteria) 1341 throws TorqueException 1342 { 1343 if (collShipmentItems == null) 1344 { 1345 if (isNew()) 1346 { 1347 collShipmentItems = new ArrayList (); 1348 } 1349 else 1350 { 1351 criteria.add(ShipmentItemPeer.SHIPMENT_ID, getShipmentId()); 1352 collShipmentItems = ShipmentItemPeer.doSelectJoinCustomerRelatedByRecipientId(criteria); 1353 } 1354 } 1355 else 1356 { 1357 1361 criteria.add(ShipmentItemPeer.SHIPMENT_ID, getShipmentId()); 1362 if (!lastShipmentItemsCriteria.equals(criteria)) 1363 { 1364 collShipmentItems = ShipmentItemPeer.doSelectJoinCustomerRelatedByRecipientId(criteria); 1365 } 1366 } 1367 lastShipmentItemsCriteria = criteria; 1368 1369 return collShipmentItems; 1370 } 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1391 protected List getShipmentItemsJoinProject(Criteria criteria) 1392 throws TorqueException 1393 { 1394 if (collShipmentItems == null) 1395 { 1396 if (isNew()) 1397 { 1398 collShipmentItems = new ArrayList (); 1399 } 1400 else 1401 { 1402 criteria.add(ShipmentItemPeer.SHIPMENT_ID, getShipmentId()); 1403 collShipmentItems = ShipmentItemPeer.doSelectJoinProject(criteria); 1404 } 1405 } 1406 else 1407 { 1408 1412 criteria.add(ShipmentItemPeer.SHIPMENT_ID, getShipmentId()); 1413 if (!lastShipmentItemsCriteria.equals(criteria)) 1414 { 1415 collShipmentItems = ShipmentItemPeer.doSelectJoinProject(criteria); 1416 } 1417 } 1418 lastShipmentItemsCriteria = criteria; 1419 1420 return collShipmentItems; 1421 } 1422 1423 1424 1425 1426 private static List fieldNames = null; 1427 1428 1433 public static synchronized List getFieldNames() 1434 { 1435 if (fieldNames == null) 1436 { 1437 fieldNames = new ArrayList (); 1438 fieldNames.add("ShipmentId"); 1439 fieldNames.add("ShipmentCode"); 1440 fieldNames.add("Status"); 1441 fieldNames.add("Priority"); 1442 fieldNames.add("IssuedDate"); 1443 fieldNames.add("ClosedDate"); 1444 fieldNames.add("CustomerId"); 1445 fieldNames.add("RecipientId"); 1446 fieldNames.add("ProjectId"); 1447 fieldNames.add("SorderId"); 1448 fieldNames.add("InvoiceCode"); 1449 fieldNames.add("CarrierId"); 1450 fieldNames.add("Subject"); 1451 fieldNames.add("Notes"); 1452 fieldNames.add("Created"); 1453 fieldNames.add("Modified"); 1454 fieldNames.add("CreatedBy"); 1455 fieldNames.add("ModifiedBy"); 1456 fieldNames = Collections.unmodifiableList(fieldNames); 1457 } 1458 return fieldNames; 1459 } 1460 1461 1467 public Object getByName(String name) 1468 { 1469 if (name.equals("ShipmentId")) 1470 { 1471 return new Integer (getShipmentId()); 1472 } 1473 if (name.equals("ShipmentCode")) 1474 { 1475 return getShipmentCode(); 1476 } 1477 if (name.equals("Status")) 1478 { 1479 return new Integer (getStatus()); 1480 } 1481 if (name.equals("Priority")) 1482 { 1483 return new Integer (getPriority()); 1484 } 1485 if (name.equals("IssuedDate")) 1486 { 1487 return getIssuedDate(); 1488 } 1489 if (name.equals("ClosedDate")) 1490 { 1491 return getClosedDate(); 1492 } 1493 if (name.equals("CustomerId")) 1494 { 1495 return new Integer (getCustomerId()); 1496 } 1497 if (name.equals("RecipientId")) 1498 { 1499 return new Integer (getRecipientId()); 1500 } 1501 if (name.equals("ProjectId")) 1502 { 1503 return new Integer (getProjectId()); 1504 } 1505 if (name.equals("SorderId")) 1506 { 1507 return new Integer (getSorderId()); 1508 } 1509 if (name.equals("InvoiceCode")) 1510 { 1511 return getInvoiceCode(); 1512 } 1513 if (name.equals("CarrierId")) 1514 { 1515 return new Integer (getCarrierId()); 1516 } 1517 if (name.equals("Subject")) 1518 { 1519 return getSubject(); 1520 } 1521 if (name.equals("Notes")) 1522 { 1523 return getNotes(); 1524 } 1525 if (name.equals("Created")) 1526 { 1527 return getCreated(); 1528 } 1529 if (name.equals("Modified")) 1530 { 1531 return getModified(); 1532 } 1533 if (name.equals("CreatedBy")) 1534 { 1535 return getCreatedBy(); 1536 } 1537 if (name.equals("ModifiedBy")) 1538 { 1539 return getModifiedBy(); 1540 } 1541 return null; 1542 } 1543 1544 1552 public Object getByPeerName(String name) 1553 { 1554 if (name.equals(ShipmentPeer.SHIPMENT_ID)) 1555 { 1556 return new Integer (getShipmentId()); 1557 } 1558 if (name.equals(ShipmentPeer.SHIPMENT_CODE)) 1559 { 1560 return getShipmentCode(); 1561 } 1562 if (name.equals(ShipmentPeer.STATUS)) 1563 { 1564 return new Integer (getStatus()); 1565 } 1566 if (name.equals(ShipmentPeer.PRIORITY)) 1567 { 1568 return new Integer (getPriority()); 1569 } 1570 if (name.equals(ShipmentPeer.ISSUED_DATE)) 1571 { 1572 return getIssuedDate(); 1573 } 1574 if (name.equals(ShipmentPeer.CLOSED_DATE)) 1575 { 1576 return getClosedDate(); 1577 } 1578 if (name.equals(ShipmentPeer.CUSTOMER_ID)) 1579 { 1580 return new Integer (getCustomerId()); 1581 } 1582 if (name.equals(ShipmentPeer.RECIPIENT_ID)) 1583 { 1584 return new Integer (getRecipientId()); 1585 } 1586 if (name.equals(ShipmentPeer.PROJECT_ID)) 1587 { 1588 return new Integer (getProjectId()); 1589 } 1590 if (name.equals(ShipmentPeer.SORDER_ID)) 1591 { 1592 return new Integer (getSorderId()); 1593 } 1594 if (name.equals(ShipmentPeer.INVOICE_CODE)) 1595 { 1596 return getInvoiceCode(); 1597 } 1598 if (name.equals(ShipmentPeer.CARRIER_ID)) 1599 { 1600 return new Integer (getCarrierId()); 1601 } 1602 if (name.equals(ShipmentPeer.SUBJECT)) 1603 { 1604 return getSubject(); 1605 } 1606 if (name.equals(ShipmentPeer.NOTES)) 1607 { 1608 return getNotes(); 1609 } 1610 if (name.equals(ShipmentPeer.CREATED)) 1611 { 1612 return getCreated(); 1613 } 1614 if (name.equals(ShipmentPeer.MODIFIED)) 1615 { 1616 return getModified(); 1617 } 1618 if (name.equals(ShipmentPeer.CREATED_BY)) 1619 { 1620 return getCreatedBy(); 1621 } 1622 if (name.equals(ShipmentPeer.MODIFIED_BY)) 1623 { 1624 return getModifiedBy(); 1625 } 1626 return null; 1627 } 1628 1629 1636 public Object getByPosition(int pos) 1637 { 1638 if (pos == 0) 1639 { 1640 return new Integer (getShipmentId()); 1641 } 1642 if (pos == 1) 1643 { 1644 return getShipmentCode(); 1645 } 1646 if (pos == 2) 1647 { 1648 return new Integer (getStatus()); 1649 } 1650 if (pos == 3) 1651 { 1652 return new Integer (getPriority()); 1653 } 1654 if (pos == 4) 1655 { 1656 return getIssuedDate(); 1657 } 1658 if (pos == 5) 1659 { 1660 return getClosedDate(); 1661 } 1662 if (pos == 6) 1663 { 1664 return new Integer (getCustomerId()); 1665 } 1666 if (pos == 7) 1667 { 1668 return new Integer (getRecipientId()); 1669 } 1670 if (pos == 8) 1671 { 1672 return new Integer (getProjectId()); 1673 } 1674 if (pos == 9) 1675 { 1676 return new Integer (getSorderId()); 1677 } 1678 if (pos == 10) 1679 { 1680 return getInvoiceCode(); 1681 } 1682 if (pos == 11) 1683 { 1684 return new Integer (getCarrierId()); 1685 } 1686 if (pos == 12) 1687 { 1688 return getSubject(); 1689 } 1690 if (pos == 13) 1691 { 1692 return getNotes(); 1693 } 1694 if (pos == 14) 1695 { 1696 return getCreated(); 1697 } 1698 if (pos == 15) 1699 { 1700 return getModified(); 1701 } 1702 if (pos == 16) 1703 { 1704 return getCreatedBy(); 1705 } 1706 if (pos == 17) 1707 { 1708 return getModifiedBy(); 1709 } 1710 return null; 1711 } 1712 1713 1719 public void save() throws Exception  1720 { 1721 save(ShipmentPeer.getMapBuilder() 1722 .getDatabaseMap().getName()); 1723 } 1724 1725 1735 public void save(String dbName) throws TorqueException 1736 { 1737 Connection con = null; 1738 try 1739 { 1740 con = Transaction.begin(dbName); 1741 save(con); 1742 Transaction.commit(con); 1743 } 1744 catch(TorqueException e) 1745 { 1746 Transaction.safeRollback(con); 1747 throw e; 1748 } 1749 } 1750 1751 1753 private boolean alreadyInSave = false; 1754 1764 public void save(Connection con) throws TorqueException 1765 { 1766 if (!alreadyInSave) 1767 { 1768 alreadyInSave = true; 1769 1770 1771 1772 if (isModified()) 1774 { 1775 if (isNew()) 1776 { 1777 ShipmentPeer.doInsert((Shipment) this, con); 1778 setNew(false); 1779 } 1780 else 1781 { 1782 ShipmentPeer.doUpdate((Shipment) this, con); 1783 } 1784 } 1785 1786 1787 1788 if (collShipmentItems != null) 1789 { 1790 for (int i = 0; i < collShipmentItems.size(); i++) 1791 { 1792 ((ShipmentItem) collShipmentItems.get(i)).save(con); 1793 } 1794 } 1795 alreadyInSave = false; 1796 } 1797 } 1798 1799 1800 1805 public void setPrimaryKey(ObjectKey key) 1806 throws TorqueException 1807 { 1808 setShipmentId(((NumberKey) key).intValue()); 1809 } 1810 1811 1816 public void setPrimaryKey(String key) throws TorqueException 1817 { 1818 setShipmentId(Integer.parseInt(key)); 1819 } 1820 1821 1822 1826 public ObjectKey getPrimaryKey() 1827 { 1828 return SimpleKey.keyFor(getShipmentId()); 1829 } 1830 1831 1835 public String getQueryKey() 1836 { 1837 if (getPrimaryKey() == null) 1838 { 1839 return ""; 1840 } 1841 else 1842 { 1843 return getPrimaryKey().toString(); 1844 } 1845 } 1846 1847 1851 public void setQueryKey(String key) 1852 throws TorqueException 1853 { 1854 setPrimaryKey(key); 1855 } 1856 1857 1863 public Shipment copy() throws TorqueException 1864 { 1865 return copyInto(new Shipment()); 1866 } 1867 1868 protected Shipment copyInto(Shipment copyObj) throws TorqueException 1869 { 1870 copyObj.setShipmentId(shipmentId); 1871 copyObj.setShipmentCode(shipmentCode); 1872 copyObj.setStatus(status); 1873 copyObj.setPriority(priority); 1874 copyObj.setIssuedDate(issuedDate); 1875 copyObj.setClosedDate(closedDate); 1876 copyObj.setCustomerId(customerId); 1877 copyObj.setRecipientId(recipientId); 1878 copyObj.setProjectId(projectId); 1879 copyObj.setSorderId(sorderId); 1880 copyObj.setInvoiceCode(invoiceCode); 1881 copyObj.setCarrierId(carrierId); 1882 copyObj.setSubject(subject); 1883 copyObj.setNotes(notes); 1884 copyObj.setCreated(created); 1885 copyObj.setModified(modified); 1886 copyObj.setCreatedBy(createdBy); 1887 copyObj.setModifiedBy(modifiedBy); 1888 1889 copyObj.setShipmentId( 0); 1890 1891 1892 1893 List v = getShipmentItems(); 1894 for (int i = 0; i < v.size(); i++) 1895 { 1896 ShipmentItem obj = (ShipmentItem) v.get(i); 1897 copyObj.addShipmentItem(obj.copy()); 1898 } 1899 return copyObj; 1900 } 1901 1902 1908 public ShipmentPeer getPeer() 1909 { 1910 return peer; 1911 } 1912 1913 public String toString() 1914 { 1915 StringBuffer str = new StringBuffer (); 1916 str.append("Shipment:\n"); 1917 str.append("ShipmentId = ") 1918 .append(getShipmentId()) 1919 .append("\n"); 1920 str.append("ShipmentCode = ") 1921 .append(getShipmentCode()) 1922 .append("\n"); 1923 str.append("Status = ") 1924 .append(getStatus()) 1925 .append("\n"); 1926 str.append("Priority = ") 1927 .append(getPriority()) 1928 .append("\n"); 1929 str.append("IssuedDate = ") 1930 .append(getIssuedDate()) 1931 .append("\n"); 1932 str.append("ClosedDate = ") 1933 .append(getClosedDate()) 1934 .append("\n"); 1935 str.append("CustomerId = ") 1936 .append(getCustomerId()) 1937 .append("\n"); 1938 str.append("RecipientId = ") 1939 .append(getRecipientId()) 1940 .append("\n"); 1941 str.append("ProjectId = ") 1942 .append(getProjectId()) 1943 .append("\n"); 1944 str.append("SorderId = ") 1945 .append(getSorderId()) 1946 .append("\n"); 1947 str.append("InvoiceCode = ") 1948 .append(getInvoiceCode()) 1949 .append("\n"); 1950 str.append("CarrierId = ") 1951 .append(getCarrierId()) 1952 .append("\n"); 1953 str.append("Subject = ") 1954 .append(getSubject()) 1955 .append("\n"); 1956 str.append("Notes = ") 1957 .append(getNotes()) 1958 .append("\n"); 1959 str.append("Created = ") 1960 .append(getCreated()) 1961 .append("\n"); 1962 str.append("Modified = ") 1963 .append(getModified()) 1964 .append("\n"); 1965 str.append("CreatedBy = ") 1966 .append(getCreatedBy()) 1967 .append("\n"); 1968 str.append("ModifiedBy = ") 1969 .append(getModifiedBy()) 1970 .append("\n"); 1971 return(str.toString()); 1972 } 1973} 1974
| Popular Tags
|