1 package org.campware.cream.om; 2 3 4 import java.math.BigDecimal ; 5 import java.sql.Connection ; 6 import java.util.ArrayList ; 7 import java.util.Collections ; 8 import java.util.Date ; 9 import java.util.List ; 10 11 import org.apache.commons.lang.ObjectUtils; 12 import org.apache.turbine.om.Retrievable; 13 import org.apache.torque.TorqueException; 14 import org.apache.torque.om.BaseObject; 15 import org.apache.torque.om.ComboKey; 16 import org.apache.torque.om.DateKey; 17 import org.apache.torque.om.NumberKey; 18 import org.apache.torque.om.ObjectKey; 19 import org.apache.torque.om.SimpleKey; 20 import org.apache.torque.om.StringKey; 21 import org.apache.torque.om.Persistent; 22 import org.apache.torque.util.Criteria; 23 import org.apache.torque.util.Transaction; 24 25 26 27 28 29 30 31 32 40 public abstract class BaseShipmentItem extends BaseObject 41 implements org.apache.turbine.om.Retrievable 42 { 43 44 private static final ShipmentItemPeer peer = 45 new ShipmentItemPeer(); 46 47 48 49 private int shipmentItemId; 50 51 52 private int shipmentId = 1000; 53 54 55 private int sorderId = 1000; 56 57 58 private int customerId = 1000; 59 60 61 private int recipientId = 1000; 62 63 64 private int projectId = 1000; 65 66 67 private int productId = 1000; 68 69 70 private String description; 71 72 73 private int quantity = 1; 74 75 76 81 public int getShipmentItemId() 82 { 83 return shipmentItemId; 84 } 85 86 87 92 public void setShipmentItemId(int v) 93 { 94 95 if (this.shipmentItemId != v) 96 { 97 this.shipmentItemId = v; 98 setModified(true); 99 } 100 101 102 } 103 104 109 public int getShipmentId() 110 { 111 return shipmentId; 112 } 113 114 115 120 public void setShipmentId(int v) throws TorqueException 121 { 122 123 if (this.shipmentId != v) 124 { 125 this.shipmentId = v; 126 setModified(true); 127 } 128 129 130 if (aShipment != null && !(aShipment.getShipmentId() == v)) 131 { 132 aShipment = null; 133 } 134 135 } 136 137 142 public int getSorderId() 143 { 144 return sorderId; 145 } 146 147 148 153 public void setSorderId(int v) throws TorqueException 154 { 155 156 if (this.sorderId != v) 157 { 158 this.sorderId = v; 159 setModified(true); 160 } 161 162 163 if (aSorder != null && !(aSorder.getSorderId() == v)) 164 { 165 aSorder = null; 166 } 167 168 } 169 170 175 public int getCustomerId() 176 { 177 return customerId; 178 } 179 180 181 186 public void setCustomerId(int v) throws TorqueException 187 { 188 189 if (this.customerId != v) 190 { 191 this.customerId = v; 192 setModified(true); 193 } 194 195 196 if (aCustomerRelatedByCustomerId != null && !(aCustomerRelatedByCustomerId.getCustomerId() == v)) 197 { 198 aCustomerRelatedByCustomerId = null; 199 } 200 201 } 202 203 208 public int getRecipientId() 209 { 210 return recipientId; 211 } 212 213 214 219 public void setRecipientId(int v) throws TorqueException 220 { 221 222 if (this.recipientId != v) 223 { 224 this.recipientId = v; 225 setModified(true); 226 } 227 228 229 if (aCustomerRelatedByRecipientId != null && !(aCustomerRelatedByRecipientId.getCustomerId() == v)) 230 { 231 aCustomerRelatedByRecipientId = null; 232 } 233 234 } 235 236 241 public int getProjectId() 242 { 243 return projectId; 244 } 245 246 247 252 public void setProjectId(int v) throws TorqueException 253 { 254 255 if (this.projectId != v) 256 { 257 this.projectId = v; 258 setModified(true); 259 } 260 261 262 if (aProject != null && !(aProject.getProjectId() == v)) 263 { 264 aProject = null; 265 } 266 267 } 268 269 274 public int getProductId() 275 { 276 return productId; 277 } 278 279 280 285 public void setProductId(int v) throws TorqueException 286 { 287 288 if (this.productId != v) 289 { 290 this.productId = v; 291 setModified(true); 292 } 293 294 295 if (aProduct != null && !(aProduct.getProductId() == v)) 296 { 297 aProduct = null; 298 } 299 300 } 301 302 307 public String getDescription() 308 { 309 return description; 310 } 311 312 313 318 public void setDescription(String v) 319 { 320 321 if (!ObjectUtils.equals(this.description, v)) 322 { 323 this.description = v; 324 setModified(true); 325 } 326 327 328 } 329 330 335 public int getQuantity() 336 { 337 return quantity; 338 } 339 340 341 346 public void setQuantity(int v) 347 { 348 349 if (this.quantity != v) 350 { 351 this.quantity = v; 352 setModified(true); 353 } 354 355 356 } 357 358 359 360 361 362 private Shipment aShipment; 363 364 370 public void setShipment(Shipment v) throws TorqueException 371 { 372 if (v == null) 373 { 374 setShipmentId( 1000); 375 } 376 else 377 { 378 setShipmentId(v.getShipmentId()); 379 } 380 aShipment = v; 381 } 382 383 384 390 public Shipment getShipment() throws TorqueException 391 { 392 if (aShipment == null && (this.shipmentId != 0)) 393 { 394 aShipment = ShipmentPeer.retrieveByPK(SimpleKey.keyFor(this.shipmentId)); 395 396 405 } 406 return aShipment; 407 } 408 409 415 public void setShipmentKey(ObjectKey key) throws TorqueException 416 { 417 418 setShipmentId(((NumberKey) key).intValue()); 419 } 420 421 422 423 424 private Sorder aSorder; 425 426 432 public void setSorder(Sorder v) throws TorqueException 433 { 434 if (v == null) 435 { 436 setSorderId( 1000); 437 } 438 else 439 { 440 setSorderId(v.getSorderId()); 441 } 442 aSorder = v; 443 } 444 445 446 452 public Sorder getSorder() throws TorqueException 453 { 454 if (aSorder == null && (this.sorderId != 0)) 455 { 456 aSorder = SorderPeer.retrieveByPK(SimpleKey.keyFor(this.sorderId)); 457 458 467 } 468 return aSorder; 469 } 470 471 477 public void setSorderKey(ObjectKey key) throws TorqueException 478 { 479 480 setSorderId(((NumberKey) key).intValue()); 481 } 482 483 484 485 486 private Product aProduct; 487 488 494 public void setProduct(Product v) throws TorqueException 495 { 496 if (v == null) 497 { 498 setProductId( 1000); 499 } 500 else 501 { 502 setProductId(v.getProductId()); 503 } 504 aProduct = v; 505 } 506 507 508 514 public Product getProduct() throws TorqueException 515 { 516 if (aProduct == null && (this.productId != 0)) 517 { 518 aProduct = ProductPeer.retrieveByPK(SimpleKey.keyFor(this.productId)); 519 520 529 } 530 return aProduct; 531 } 532 533 539 public void setProductKey(ObjectKey key) throws TorqueException 540 { 541 542 setProductId(((NumberKey) key).intValue()); 543 } 544 545 546 547 548 private Customer aCustomerRelatedByCustomerId; 549 550 556 public void setCustomerRelatedByCustomerId(Customer v) throws TorqueException 557 { 558 if (v == null) 559 { 560 setCustomerId( 1000); 561 } 562 else 563 { 564 setCustomerId(v.getCustomerId()); 565 } 566 aCustomerRelatedByCustomerId = v; 567 } 568 569 570 576 public Customer getCustomerRelatedByCustomerId() throws TorqueException 577 { 578 if (aCustomerRelatedByCustomerId == null && (this.customerId != 0)) 579 { 580 aCustomerRelatedByCustomerId = CustomerPeer.retrieveByPK(SimpleKey.keyFor(this.customerId)); 581 582 591 } 592 return aCustomerRelatedByCustomerId; 593 } 594 595 601 public void setCustomerRelatedByCustomerIdKey(ObjectKey key) throws TorqueException 602 { 603 604 setCustomerId(((NumberKey) key).intValue()); 605 } 606 607 608 609 610 private Customer aCustomerRelatedByRecipientId; 611 612 618 public void setCustomerRelatedByRecipientId(Customer v) throws TorqueException 619 { 620 if (v == null) 621 { 622 setRecipientId( 1000); 623 } 624 else 625 { 626 setRecipientId(v.getCustomerId()); 627 } 628 aCustomerRelatedByRecipientId = v; 629 } 630 631 632 638 public Customer getCustomerRelatedByRecipientId() throws TorqueException 639 { 640 if (aCustomerRelatedByRecipientId == null && (this.recipientId != 0)) 641 { 642 aCustomerRelatedByRecipientId = CustomerPeer.retrieveByPK(SimpleKey.keyFor(this.recipientId)); 643 644 653 } 654 return aCustomerRelatedByRecipientId; 655 } 656 657 663 public void setCustomerRelatedByRecipientIdKey(ObjectKey key) throws TorqueException 664 { 665 666 setRecipientId(((NumberKey) key).intValue()); 667 } 668 669 670 671 672 private Project aProject; 673 674 680 public void setProject(Project v) throws TorqueException 681 { 682 if (v == null) 683 { 684 setProjectId( 1000); 685 } 686 else 687 { 688 setProjectId(v.getProjectId()); 689 } 690 aProject = v; 691 } 692 693 694 700 public Project getProject() throws TorqueException 701 { 702 if (aProject == null && (this.projectId != 0)) 703 { 704 aProject = ProjectPeer.retrieveByPK(SimpleKey.keyFor(this.projectId)); 705 706 715 } 716 return aProject; 717 } 718 719 725 public void setProjectKey(ObjectKey key) throws TorqueException 726 { 727 728 setProjectId(((NumberKey) key).intValue()); 729 } 730 731 732 private static List fieldNames = null; 733 734 739 public static synchronized List getFieldNames() 740 { 741 if (fieldNames == null) 742 { 743 fieldNames = new ArrayList (); 744 fieldNames.add("ShipmentItemId"); 745 fieldNames.add("ShipmentId"); 746 fieldNames.add("SorderId"); 747 fieldNames.add("CustomerId"); 748 fieldNames.add("RecipientId"); 749 fieldNames.add("ProjectId"); 750 fieldNames.add("ProductId"); 751 fieldNames.add("Description"); 752 fieldNames.add("Quantity"); 753 fieldNames = Collections.unmodifiableList(fieldNames); 754 } 755 return fieldNames; 756 } 757 758 764 public Object getByName(String name) 765 { 766 if (name.equals("ShipmentItemId")) 767 { 768 return new Integer (getShipmentItemId()); 769 } 770 if (name.equals("ShipmentId")) 771 { 772 return new Integer (getShipmentId()); 773 } 774 if (name.equals("SorderId")) 775 { 776 return new Integer (getSorderId()); 777 } 778 if (name.equals("CustomerId")) 779 { 780 return new Integer (getCustomerId()); 781 } 782 if (name.equals("RecipientId")) 783 { 784 return new Integer (getRecipientId()); 785 } 786 if (name.equals("ProjectId")) 787 { 788 return new Integer (getProjectId()); 789 } 790 if (name.equals("ProductId")) 791 { 792 return new Integer (getProductId()); 793 } 794 if (name.equals("Description")) 795 { 796 return getDescription(); 797 } 798 if (name.equals("Quantity")) 799 { 800 return new Integer (getQuantity()); 801 } 802 return null; 803 } 804 805 813 public Object getByPeerName(String name) 814 { 815 if (name.equals(ShipmentItemPeer.SHIPMENT_ITEM_ID)) 816 { 817 return new Integer (getShipmentItemId()); 818 } 819 if (name.equals(ShipmentItemPeer.SHIPMENT_ID)) 820 { 821 return new Integer (getShipmentId()); 822 } 823 if (name.equals(ShipmentItemPeer.SORDER_ID)) 824 { 825 return new Integer (getSorderId()); 826 } 827 if (name.equals(ShipmentItemPeer.CUSTOMER_ID)) 828 { 829 return new Integer (getCustomerId()); 830 } 831 if (name.equals(ShipmentItemPeer.RECIPIENT_ID)) 832 { 833 return new Integer (getRecipientId()); 834 } 835 if (name.equals(ShipmentItemPeer.PROJECT_ID)) 836 { 837 return new Integer (getProjectId()); 838 } 839 if (name.equals(ShipmentItemPeer.PRODUCT_ID)) 840 { 841 return new Integer (getProductId()); 842 } 843 if (name.equals(ShipmentItemPeer.DESCRIPTION)) 844 { 845 return getDescription(); 846 } 847 if (name.equals(ShipmentItemPeer.QUANTITY)) 848 { 849 return new Integer (getQuantity()); 850 } 851 return null; 852 } 853 854 861 public Object getByPosition(int pos) 862 { 863 if (pos == 0) 864 { 865 return new Integer (getShipmentItemId()); 866 } 867 if (pos == 1) 868 { 869 return new Integer (getShipmentId()); 870 } 871 if (pos == 2) 872 { 873 return new Integer (getSorderId()); 874 } 875 if (pos == 3) 876 { 877 return new Integer (getCustomerId()); 878 } 879 if (pos == 4) 880 { 881 return new Integer (getRecipientId()); 882 } 883 if (pos == 5) 884 { 885 return new Integer (getProjectId()); 886 } 887 if (pos == 6) 888 { 889 return new Integer (getProductId()); 890 } 891 if (pos == 7) 892 { 893 return getDescription(); 894 } 895 if (pos == 8) 896 { 897 return new Integer (getQuantity()); 898 } 899 return null; 900 } 901 902 908 public void save() throws Exception  909 { 910 save(ShipmentItemPeer.getMapBuilder() 911 .getDatabaseMap().getName()); 912 } 913 914 924 public void save(String dbName) throws TorqueException 925 { 926 Connection con = null; 927 try 928 { 929 con = Transaction.begin(dbName); 930 save(con); 931 Transaction.commit(con); 932 } 933 catch(TorqueException e) 934 { 935 Transaction.safeRollback(con); 936 throw e; 937 } 938 } 939 940 942 private boolean alreadyInSave = false; 943 953 public void save(Connection con) throws TorqueException 954 { 955 if (!alreadyInSave) 956 { 957 alreadyInSave = true; 958 959 960 961 if (isModified()) 963 { 964 if (isNew()) 965 { 966 ShipmentItemPeer.doInsert((ShipmentItem) this, con); 967 setNew(false); 968 } 969 else 970 { 971 ShipmentItemPeer.doUpdate((ShipmentItem) this, con); 972 } 973 } 974 975 alreadyInSave = false; 976 } 977 } 978 979 980 985 public void setPrimaryKey(ObjectKey key) 986 987 { 988 setShipmentItemId(((NumberKey) key).intValue()); 989 } 990 991 996 public void setPrimaryKey(String key) 997 { 998 setShipmentItemId(Integer.parseInt(key)); 999 } 1000 1001 1002 1006 public ObjectKey getPrimaryKey() 1007 { 1008 return SimpleKey.keyFor(getShipmentItemId()); 1009 } 1010 1011 1015 public String getQueryKey() 1016 { 1017 if (getPrimaryKey() == null) 1018 { 1019 return ""; 1020 } 1021 else 1022 { 1023 return getPrimaryKey().toString(); 1024 } 1025 } 1026 1027 1031 public void setQueryKey(String key) 1032 throws TorqueException 1033 { 1034 setPrimaryKey(key); 1035 } 1036 1037 1043 public ShipmentItem copy() throws TorqueException 1044 { 1045 return copyInto(new ShipmentItem()); 1046 } 1047 1048 protected ShipmentItem copyInto(ShipmentItem copyObj) throws TorqueException 1049 { 1050 copyObj.setShipmentItemId(shipmentItemId); 1051 copyObj.setShipmentId(shipmentId); 1052 copyObj.setSorderId(sorderId); 1053 copyObj.setCustomerId(customerId); 1054 copyObj.setRecipientId(recipientId); 1055 copyObj.setProjectId(projectId); 1056 copyObj.setProductId(productId); 1057 copyObj.setDescription(description); 1058 copyObj.setQuantity(quantity); 1059 1060 copyObj.setShipmentItemId( 0); 1061 1062 return copyObj; 1063 } 1064 1065 1071 public ShipmentItemPeer getPeer() 1072 { 1073 return peer; 1074 } 1075 1076 public String toString() 1077 { 1078 StringBuffer str = new StringBuffer (); 1079 str.append("ShipmentItem:\n"); 1080 str.append("ShipmentItemId = ") 1081 .append(getShipmentItemId()) 1082 .append("\n"); 1083 str.append("ShipmentId = ") 1084 .append(getShipmentId()) 1085 .append("\n"); 1086 str.append("SorderId = ") 1087 .append(getSorderId()) 1088 .append("\n"); 1089 str.append("CustomerId = ") 1090 .append(getCustomerId()) 1091 .append("\n"); 1092 str.append("RecipientId = ") 1093 .append(getRecipientId()) 1094 .append("\n"); 1095 str.append("ProjectId = ") 1096 .append(getProjectId()) 1097 .append("\n"); 1098 str.append("ProductId = ") 1099 .append(getProductId()) 1100 .append("\n"); 1101 str.append("Description = ") 1102 .append(getDescription()) 1103 .append("\n"); 1104 str.append("Quantity = ") 1105 .append(getQuantity()) 1106 .append("\n"); 1107 return(str.toString()); 1108 } 1109} 1110
| Popular Tags
|