Subversion Repositories SmartDukaan

Rev

Rev 3390 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
3024 mandeep.dh 1
/**
2
 * 
3
 */
4
package in.shop2020.crm.domain;
5
 
3106 mandeep.dh 6
import in.shop2020.crm.TicketCategory;
7
import in.shop2020.crm.TicketPriority;
8
import in.shop2020.crm.TicketStatus;
9
 
3024 mandeep.dh 10
import java.text.ParseException;
11
import java.util.Date;
12
 
13
/**
3106 mandeep.dh 14
 * Domain class for tickets in CRM. Many other fields of ticket are tracked via
15
 * activity. Especially the ones that can change through the lifetime of a
16
 * ticket. A ticket should be thought of as a series of activities.
17
 * 
3024 mandeep.dh 18
 * @author mandeep
19
 */
20
public class Ticket {
3106 mandeep.dh 21
    private long           id;
3269 mandeep.dh 22
    private Long           customerId;
3106 mandeep.dh 23
    private Date           openDate;
24
    private Date           closeDate;
25
    private long           creatorId;
26
    private String         description;
27
    private TicketStatus   status;
28
    private TicketPriority priority;
29
    private TicketCategory category;
30
    private Long           assigneeId;
3024 mandeep.dh 31
 
32
    // Fields from user communication
3106 mandeep.dh 33
    private Long           orderId;
34
    private String         airwayBillNo;
35
    private String         productName;
3024 mandeep.dh 36
 
3390 mandeep.dh 37
    // fields for unregistered users
38
    private String         customerEmailId;
39
    private String         customerMobileNumber;
40
    private String         customerName;
41
 
3024 mandeep.dh 42
    /**
43
     * Converts thrift ticket object representation to our domain object
3106 mandeep.dh 44
     * 
3024 mandeep.dh 45
     * @param tticket
46
     * @return
47
     * @throws ParseException
48
     */
49
    public static Ticket create(in.shop2020.crm.Ticket tticket)
50
            throws ParseException {
51
        Ticket ticket = new Ticket();
52
        ticket.id = tticket.getId();
53
        ticket.creatorId = tticket.getCreatorId();
3269 mandeep.dh 54
        ticket.category = tticket.getCategory();
55
        ticket.priority = tticket.getPriority();
56
        ticket.status = tticket.getStatus();
57
        ticket.airwayBillNo = tticket.getAirwayBillNo();
58
        ticket.productName = tticket.getProductName();
59
 
60
        if (tticket.isSetDescription()) {
61
            ticket.description = tticket.getDescription();
62
        }
63
 
64
        if (tticket.isSetCustomerId()) {
65
            ticket.customerId = tticket.getCustomerId();
66
        }
67
 
68
        if (tticket.isSetCustomerEmailId()) {
69
            ticket.customerEmailId = tticket.getCustomerEmailId();
70
        }
71
 
3106 mandeep.dh 72
        if (tticket.isSetAssigneeId()) {
73
            ticket.assigneeId = tticket.getAssigneeId();
74
        }
3024 mandeep.dh 75
 
76
        if (tticket.isSetOpenDate()) {
77
            ticket.openDate = new Date(tticket.getOpenDate());
78
        }
79
 
80
        // Trying to set close date as null in database!
3269 mandeep.dh 81
        if (tticket.isSetCloseDate()) {
3024 mandeep.dh 82
            ticket.closeDate = new Date(tticket.getCloseDate());
83
        }
84
 
3106 mandeep.dh 85
        if (tticket.isSetOrderId()) {
86
            ticket.orderId = tticket.getOrderId();
87
        }
88
 
3390 mandeep.dh 89
        if (tticket.isSetAirwayBillNo()) {
90
            ticket.airwayBillNo = tticket.getAirwayBillNo();
91
        }
92
 
93
        if (tticket.isSetProductName()) {
94
            ticket.productName = tticket.getProductName();
95
        }
96
 
97
        if (tticket.isSetCustomerMobileNumber()) {
98
            ticket.customerMobileNumber = tticket.getCustomerMobileNumber();
99
        }
100
 
101
        if (tticket.isSetCustomerName()) {
102
            ticket.customerName = tticket.getCustomerName();
103
        }
104
 
3024 mandeep.dh 105
        return ticket;
106
    }
107
 
108
    /**
109
     * Converts this object to its corresponding thrift representation.
3106 mandeep.dh 110
     * 
3024 mandeep.dh 111
     * @return
112
     */
113
    public in.shop2020.crm.Ticket getThriftTicket() {
114
        in.shop2020.crm.Ticket tticket = new in.shop2020.crm.Ticket();
115
        tticket.setId(id);
116
        tticket.setCreatorId(creatorId);
3106 mandeep.dh 117
        tticket.setDescription(description);
3269 mandeep.dh 118
        tticket.setCategory(category);
119
        tticket.setPriority(priority);
120
        tticket.setStatus(status);
121
        tticket.setAirwayBillNo(airwayBillNo);
122
        tticket.setProductName(productName);
3106 mandeep.dh 123
 
3269 mandeep.dh 124
        if (customerId != null) {
125
            tticket.setCustomerId(customerId);
126
        }
127
 
3106 mandeep.dh 128
        if (assigneeId != null) {
129
            tticket.setAssigneeId(assigneeId);
130
        }
131
 
132
        if (orderId != null) {
133
            tticket.setOrderId(orderId);
134
        }
135
 
3390 mandeep.dh 136
        if (airwayBillNo != null) {
137
            tticket.setAirwayBillNo(airwayBillNo);
138
        }
139
 
140
        if (productName != null) {
141
            tticket.setProductName(productName);
142
        }
143
 
3024 mandeep.dh 144
        if (openDate != null) {
145
            tticket.setOpenDate(openDate.getTime());
146
        }
147
 
148
        if (closeDate != null) {
149
            tticket.setCloseDate(closeDate.getTime());
150
        }
151
 
3390 mandeep.dh 152
        if (customerEmailId != null) {
153
            tticket.setCustomerEmailId(customerEmailId);
154
        }
155
 
156
        if (customerMobileNumber != null) {
157
            tticket.setCustomerMobileNumber(customerMobileNumber);
158
        }
159
 
160
        if (customerName != null) {
161
            tticket.setCustomerName(customerName);
162
        }
163
 
3024 mandeep.dh 164
        return tticket;
165
    }
166
 
167
    public long getId() {
168
        return id;
169
    }
170
 
171
    public void setId(long id) {
172
        this.id = id;
173
    }
174
 
3269 mandeep.dh 175
    public Long getCustomerId() {
3024 mandeep.dh 176
        return customerId;
177
    }
178
 
3269 mandeep.dh 179
    public void setCustomerId(Long customerId) {
3024 mandeep.dh 180
        this.customerId = customerId;
181
    }
182
 
183
    public Date getOpenDate() {
184
        return openDate;
185
    }
186
 
187
    public void setOpenDate(Date openDate) {
188
        this.openDate = openDate;
189
    }
190
 
191
    public Date getCloseDate() {
192
        return closeDate;
193
    }
194
 
195
    public void setCloseDate(Date closeDate) {
196
        this.closeDate = closeDate;
197
    }
198
 
199
    public long getCreatorId() {
200
        return creatorId;
201
    }
202
 
203
    public void setCreatorId(long creatorId) {
204
        this.creatorId = creatorId;
205
    }
206
 
3106 mandeep.dh 207
    public Long getOrderId() {
3024 mandeep.dh 208
        return orderId;
209
    }
210
 
3106 mandeep.dh 211
    public void setOrderId(Long orderId) {
3024 mandeep.dh 212
        this.orderId = orderId;
213
    }
214
 
215
    public String getAirwayBillNo() {
216
        return airwayBillNo;
217
    }
218
 
219
    public void setAirwayBillNo(String airwayBillNo) {
220
        this.airwayBillNo = airwayBillNo;
221
    }
222
 
223
    public String getProductName() {
224
        return productName;
225
    }
226
 
227
    public void setProductName(String productName) {
228
        this.productName = productName;
229
    }
3106 mandeep.dh 230
 
231
    public String getDescription() {
232
        return description;
233
    }
234
 
235
    public void setDescription(String description) {
236
        this.description = description;
237
    }
238
 
239
    public TicketStatus getStatus() {
240
        return status;
241
    }
242
 
243
    public void setStatus(TicketStatus status) {
244
        this.status = status;
245
    }
246
 
247
    public TicketPriority getPriority() {
248
        return priority;
249
    }
250
 
251
    public void setPriority(TicketPriority priority) {
252
        this.priority = priority;
253
    }
254
 
255
    public TicketCategory getCategory() {
256
        return category;
257
    }
258
 
259
    public void setCategory(TicketCategory category) {
260
        this.category = category;
261
    }
262
 
263
    public Long getAssigneeId() {
264
        return assigneeId;
265
    }
266
 
267
    public void setAssigneeId(Long assigneeId) {
268
        this.assigneeId = assigneeId;
269
    }
3269 mandeep.dh 270
 
271
    public String getCustomerEmailId() {
272
        return customerEmailId;
273
    }
274
 
275
    public void setCustomerEmailId(String customerEmailId) {
276
        this.customerEmailId = customerEmailId;
277
    }
3390 mandeep.dh 278
 
279
    public String getCustomerMobileNumber() {
280
        return customerMobileNumber;
281
    }
282
 
283
    public void setCustomerMobileNumber(String customerMobileNumber) {
284
        this.customerMobileNumber = customerMobileNumber;
285
    }
286
 
287
    public String getCustomerName() {
288
        return customerName;
289
    }
290
 
291
    public void setCustomerName(String customerName) {
292
        this.customerName = customerName;
293
    }
3024 mandeep.dh 294
}