Subversion Repositories SmartDukaan

Rev

Rev 3106 | Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
3024 mandeep.dh 1
/**
2
 * 
3
 */
4
package in.shop2020.crm.domain;
5
 
6
import java.text.ParseException;
7
import java.util.Date;
8
 
9
/**
10
 * Domain class for tickets in CRM. Many other fields of ticket are tracked via activity.
11
 * Especially the ones that can change through the lifetime of a ticket. A ticket should
12
 * be thought of as a series of activities.
13
 *
14
 * @author mandeep
15
 */
16
public class Ticket {
17
    private long   id;
18
    private long   customerId;
19
    private Date   openDate;
20
    private Date   closeDate;
21
    private long   creatorId;
22
    private String subject;
23
 
24
    // additional receipient of email notifications of the ticket
25
    private long   receipientId;
26
 
27
    // Fields from user communication
28
    private long   orderId;
29
    private String airwayBillNo;
30
    private String productName;
31
 
32
    /**
33
     * Converts thrift ticket object representation to our domain object
34
     *
35
     * @param tticket
36
     * @return
37
     * @throws ParseException
38
     */
39
    public static Ticket create(in.shop2020.crm.Ticket tticket)
40
            throws ParseException {
41
        Ticket ticket = new Ticket();
42
        ticket.id = tticket.getId();
43
        ticket.customerId = tticket.getCustomerId();
44
        ticket.receipientId = tticket.getReceipientId();
45
        ticket.creatorId = tticket.getCreatorId();
46
 
47
        if (tticket.isSetOpenDate()) {
48
            ticket.openDate = new Date(tticket.getOpenDate());
49
        }
50
 
51
        // Trying to set close date as null in database!
52
        if (tticket.isSetCloseDate() && tticket.getCloseDate() != 0) {
53
            ticket.closeDate = new Date(tticket.getCloseDate());
54
        }
55
 
56
        ticket.subject = tticket.getSubject();
57
        ticket.orderId = tticket.getOrderId();
58
        ticket.airwayBillNo = tticket.getAirwayBillNo();
59
        ticket.productName = tticket.getProductName();
60
        return ticket;
61
    }
62
 
63
    /**
64
     * Converts this object to its corresponding thrift representation.
65
     * @return
66
     */
67
    public in.shop2020.crm.Ticket getThriftTicket() {
68
        in.shop2020.crm.Ticket tticket = new in.shop2020.crm.Ticket();
69
        tticket.setId(id);
70
        tticket.setCustomerId(customerId);
71
        tticket.setCreatorId(creatorId);
72
        tticket.setReceipientId(receipientId);
73
        tticket.setSubject(subject);
74
        tticket.setOrderId(orderId);
75
        tticket.setAirwayBillNo(airwayBillNo);
76
        tticket.setProductName(productName);
77
 
78
        if (openDate != null) {
79
            tticket.setOpenDate(openDate.getTime());
80
        }
81
 
82
        if (closeDate != null) {
83
            tticket.setCloseDate(closeDate.getTime());
84
        }
85
 
86
        return tticket;
87
    }
88
 
89
    public long getId() {
90
        return id;
91
    }
92
 
93
    public void setId(long id) {
94
        this.id = id;
95
    }
96
 
97
    public long getCustomerId() {
98
        return customerId;
99
    }
100
 
101
    public void setCustomerId(long customerId) {
102
        this.customerId = customerId;
103
    }
104
 
105
    public Date getOpenDate() {
106
        return openDate;
107
    }
108
 
109
    public void setOpenDate(Date openDate) {
110
        this.openDate = openDate;
111
    }
112
 
113
    public Date getCloseDate() {
114
        return closeDate;
115
    }
116
 
117
    public void setCloseDate(Date closeDate) {
118
        this.closeDate = closeDate;
119
    }
120
 
121
    public long getReceipientId() {
122
        return receipientId;
123
    }
124
 
125
    public void setReceipientId(long receipientId) {
126
        this.receipientId = receipientId;
127
    }
128
 
129
    public long getCreatorId() {
130
        return creatorId;
131
    }
132
 
133
    public void setCreatorId(long creatorId) {
134
        this.creatorId = creatorId;
135
    }
136
 
137
    public String getSubject() {
138
        return subject;
139
    }
140
 
141
    public void setSubject(String subject) {
142
        this.subject = subject;
143
    }
144
 
145
    public long getOrderId() {
146
        return orderId;
147
    }
148
 
149
    public void setOrderId(long orderId) {
150
        this.orderId = orderId;
151
    }
152
 
153
    public String getAirwayBillNo() {
154
        return airwayBillNo;
155
    }
156
 
157
    public void setAirwayBillNo(String airwayBillNo) {
158
        this.airwayBillNo = airwayBillNo;
159
    }
160
 
161
    public String getProductName() {
162
        return productName;
163
    }
164
 
165
    public void setProductName(String productName) {
166
        this.productName = productName;
167
    }
168
}