1 package sellwin.domain; 2 3 import java.util.*; 4 import java.io.*; 5 6 10 11 16 public class Customer implements Serializable { 17 18 public final static String UNASSIGNED = "Unassigned"; 19 20 private long pk; private String name; private Address shipAddress; 23 private Address billAddress; 24 private int annualSales; 25 private String industry; 26 private String channel; 27 private Address contact; 28 private String modifiedBy; 29 private Date modifiedDate; 30 private boolean updatedLocally=false; 31 private boolean addedLocally=false; 32 private ArrayList inventory = new ArrayList(); 34 public Customer() { 35 annualSales = 0; 36 industry=""; 37 channel=""; 38 modifiedDate = new Date(); 39 shipAddress = new Address(); 40 billAddress = new Address(); 41 contact = new Address(); 42 } 43 44 public final void clear() { 45 name = UNASSIGNED; 46 annualSales = 0; 47 industry = ""; 48 channel = ""; 49 for (int i = 0; i < inventory.size(); i++) { 50 inventory.remove(i); 51 } 52 } 53 54 public final void setPK(long l) { pk = l; } 55 public final long getPK() { return pk; } 56 57 public final void setBillAddress(Address a) { billAddress = a; } 58 public final Address getBillAddress() { return billAddress; } 59 public final void setShipAddress(Address a) { shipAddress = a; } 60 public final Address getShipAddress() { return shipAddress; } 61 62 public final void setModifiedDate(Date d) { 63 modifiedDate = d; 64 getBillAddress().setModifiedDate(d); 65 getShipAddress().setModifiedDate(d); 66 getContact().setModifiedDate(d); 67 } 68 public final Date getModifiedDate() { return modifiedDate; } 69 70 public final void setModifiedBy(String b) { 71 modifiedBy = b; 72 getBillAddress().setModifiedBy(b); 73 getShipAddress().setModifiedBy(b); 74 getContact().setModifiedBy(b); 75 } 76 public final String getModifiedBy() { return modifiedBy; } 77 78 public final void addInventory(CustomerInventory inv) { 79 inventory.add(inv); 80 } 81 82 public final ArrayList getInventory() { return inventory; } 83 84 public final void setName(String name) { 85 this.name = name; 86 } 87 88 public final String getName() { return name; } 89 90 public final void setAnnualSales(int x) { 91 annualSales = x; 92 } 93 94 public final int getAnnualSales() { return annualSales; } 95 96 public final void setChannel(String s) { 97 channel = s; 98 } 99 100 public final String getChannel() { return channel; } 101 102 public final void setIndustry(String s) { 103 industry = s; 104 } 105 106 public final String getIndustry() { return industry; } 107 108 public final void setContact(Address s) { 109 contact = s; 110 } 111 112 public final Address getContact() { return contact; } 113 114 public final void setInventory(ArrayList p) { 115 inventory = p; 116 } 117 118 public final void setUpdatedLocally(boolean b) { updatedLocally=b; } 119 public final void setAddedLocally(boolean b) { addedLocally=b; } 120 public final boolean getUpdatedLocally() { return updatedLocally; } 121 public final boolean getAddedLocally() { return addedLocally; } 122 123 public final Customer copy() { 124 Customer copy = new Customer(); 125 126 copy.pk = pk; 127 128 if (billAddress != null) 129 copy.billAddress = billAddress.copy(); 130 if (shipAddress != null) 131 copy.shipAddress = shipAddress.copy(); 132 if (name != null) 133 copy.name = new String (name); 134 copy.annualSales = annualSales; 135 if (industry != null) 136 copy.industry = new String (industry); 137 if (channel != null) 138 copy.channel = new String (channel); 139 if (contact != null) 140 copy.contact = contact.copy(); 141 142 CustomerInventory product, productCopy; 143 ArrayList inventory = getInventory(); 144 for (int i=0;i<inventory.size();i++) { 145 product = (CustomerInventory)inventory.get(i); 146 productCopy = product.copy(); 147 copy.addInventory(productCopy); 148 } 149 return copy; 150 } 151 152 public final void print() { 153 System.out.println("<<CUSTOMER"+name+">>"); 154 System.out.println("pk ="+ pk); 155 System.out.println("Annual Sales="+ annualSales); 156 System.out.println("Industry="+industry); 157 System.out.println("Channel="+channel); 158 CustomerInventory inv=null; 159 for (int i=0;i<inventory.size();i++) { 160 inv = (CustomerInventory)inventory.get(i); 161 inv.print(); 162 } 163 } 164 } 165 | Popular Tags |