KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > sellwin > domain > CustomerInventory


1 package sellwin.domain;
2
3 import java.math.*;
4 import java.util.*;
5 import java.io.*;
6
7 // SellWin http://sourceforge.net/projects/sellwincrm
8
//Contact support@open-app.com for commercial help with SellWin
9
//This software is provided "AS IS", without a warranty of any kind.
10

11
12 /**
13  * This class represents product inventory that is known to be
14  * owned by a customer. This info might be derived from previous
15  * sales to a customer. This class holds column values found in the
16  * database table 'customer_inventory'.
17  */

18 public class CustomerInventory implements Serializable {
19     private long pk;
20     private Product product;
21     private Integer JavaDoc cnt;
22     private String JavaDoc modifiedBy;
23     private Date modifiedDate;
24     private boolean addedLocally=false;
25
26     //next attribute is a convient way to get the parent
27
private long customerPK; //pointer to parent
28

29     public CustomerInventory() {
30         product = null; //null cuz it is illogical to have a dummy prod
31
cnt = new Integer JavaDoc(0);
32         modifiedDate = new Date();
33         customerPK = 0;
34     }
35
36     public CustomerInventory(Product n, Integer JavaDoc ct) {
37         product = n;
38         cnt = ct;
39     }
40
41     public final void setPK(long pk) { this.pk = pk; }
42     public final void setCustomerPK(long pk) { this.customerPK = pk; }
43     public final void setProduct(Product n) { product = n; }
44     public final void setCount(Integer JavaDoc i) { cnt = i; }
45     public final void setModifiedBy(String JavaDoc s) { modifiedBy = s; }
46     public final void setModifiedDate(Date d) { modifiedDate = d; }
47     public final void setAddedLocally(boolean t) { addedLocally = t; }
48
49     public final long getPK() { return pk; }
50     public final long getCustomerPK() { return customerPK; }
51     public final Product getProduct() { return product; }
52     public final Integer JavaDoc getCount() { return cnt; }
53     public final Date getModifiedDate() { return modifiedDate; }
54     public final String JavaDoc getModifiedBy() { return modifiedBy; }
55     public final boolean getAddedLocally() { return addedLocally; }
56
57     public final CustomerInventory copy() {
58         Product copyProd = getProduct().copy();
59         Integer JavaDoc copyCnt = new Integer JavaDoc(getCount().intValue());
60         CustomerInventory copy = new CustomerInventory(copyProd, copyCnt);
61         copy.modifiedBy = new String JavaDoc(modifiedBy);
62         copy.modifiedDate = new Date(modifiedDate.getTime());
63         copy.customerPK = customerPK;
64         return copy;
65     }
66
67     public final void print() {
68         System.out.println("<<Customer Inventory>>");
69         System.out.println("pk=["+getPK()+"]");
70         getProduct().print();
71         System.out.println("Count="+getCount());
72         System.out.println("ModifiedDate="+getModifiedDate());
73         System.out.println("ModifiedBy="+getModifiedBy());
74     }
75 }
76
Popular Tags