Subversion Repositories SmartDukaan

Rev

Rev 3269 | Go to most recent revision | 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
 
42
    // knitted fields
43
    private Agent          assignee;
44
    private Agent          creator;
45
 
3024 mandeep.dh 46
    /**
47
     * Converts thrift ticket object representation to our domain object
3106 mandeep.dh 48
     * 
3024 mandeep.dh 49
     * @param tticket
50
     * @return
51
     * @throws ParseException
52
     */
53
    public static Ticket create(in.shop2020.crm.Ticket tticket)
54
            throws ParseException {
55
        Ticket ticket = new Ticket();
56
        ticket.id = tticket.getId();
57
        ticket.creatorId = tticket.getCreatorId();
3269 mandeep.dh 58
        ticket.category = tticket.getCategory();
59
        ticket.priority = tticket.getPriority();
60
        ticket.status = tticket.getStatus();
61
        ticket.airwayBillNo = tticket.getAirwayBillNo();
62
        ticket.productName = tticket.getProductName();
63
 
64
        if (tticket.isSetDescription()) {
65
            ticket.description = tticket.getDescription();
66
        }
67
 
68
        if (tticket.isSetCustomerId()) {
69
            ticket.customerId = tticket.getCustomerId();
70
        }
71
 
72
        if (tticket.isSetCustomerEmailId()) {
73
            ticket.customerEmailId = tticket.getCustomerEmailId();
74
        }
75
 
3106 mandeep.dh 76
        if (tticket.isSetAssigneeId()) {
77
            ticket.assigneeId = tticket.getAssigneeId();
78
        }
3024 mandeep.dh 79
 
80
        if (tticket.isSetOpenDate()) {
81
            ticket.openDate = new Date(tticket.getOpenDate());
82
        }
83
 
84
        // Trying to set close date as null in database!
3269 mandeep.dh 85
        if (tticket.isSetCloseDate()) {
3024 mandeep.dh 86
            ticket.closeDate = new Date(tticket.getCloseDate());
87
        }
88
 
3106 mandeep.dh 89
        if (tticket.isSetOrderId()) {
90
            ticket.orderId = tticket.getOrderId();
91
        }
92
 
3390 mandeep.dh 93
        if (tticket.isSetAirwayBillNo()) {
94
            ticket.airwayBillNo = tticket.getAirwayBillNo();
95
        }
96
 
97
        if (tticket.isSetProductName()) {
98
            ticket.productName = tticket.getProductName();
99
        }
100
 
101
        if (tticket.isSetCustomerMobileNumber()) {
102
            ticket.customerMobileNumber = tticket.getCustomerMobileNumber();
103
        }
104
 
105
        if (tticket.isSetCustomerName()) {
106
            ticket.customerName = tticket.getCustomerName();
107
        }
108
 
109
        if (tticket.isSetAssignee()) {
110
            ticket.assignee = Agent.create(tticket.getAssignee());
111
        }
112
 
113
        if (tticket.isSetCreator()) {
114
            ticket.creator = Agent.create(tticket.getCreator());
115
        }
116
 
3024 mandeep.dh 117
        return ticket;
118
    }
119
 
120
    /**
121
     * Converts this object to its corresponding thrift representation.
3106 mandeep.dh 122
     * 
3024 mandeep.dh 123
     * @return
124
     */
125
    public in.shop2020.crm.Ticket getThriftTicket() {
126
        in.shop2020.crm.Ticket tticket = new in.shop2020.crm.Ticket();
127
        tticket.setId(id);
128
        tticket.setCreatorId(creatorId);
3106 mandeep.dh 129
        tticket.setDescription(description);
3269 mandeep.dh 130
        tticket.setCategory(category);
131
        tticket.setPriority(priority);
132
        tticket.setStatus(status);
133
        tticket.setAirwayBillNo(airwayBillNo);
134
        tticket.setProductName(productName);
3106 mandeep.dh 135
 
3269 mandeep.dh 136
        if (customerId != null) {
137
            tticket.setCustomerId(customerId);
138
        }
139
 
3106 mandeep.dh 140
        if (assigneeId != null) {
141
            tticket.setAssigneeId(assigneeId);
142
        }
143
 
144
        if (orderId != null) {
145
            tticket.setOrderId(orderId);
146
        }
147
 
3390 mandeep.dh 148
        if (airwayBillNo != null) {
149
            tticket.setAirwayBillNo(airwayBillNo);
150
        }
151
 
152
        if (productName != null) {
153
            tticket.setProductName(productName);
154
        }
155
 
3024 mandeep.dh 156
        if (openDate != null) {
157
            tticket.setOpenDate(openDate.getTime());
158
        }
159
 
160
        if (closeDate != null) {
161
            tticket.setCloseDate(closeDate.getTime());
162
        }
163
 
3390 mandeep.dh 164
        if (customerEmailId != null) {
165
            tticket.setCustomerEmailId(customerEmailId);
166
        }
167
 
168
        if (customerMobileNumber != null) {
169
            tticket.setCustomerMobileNumber(customerMobileNumber);
170
        }
171
 
172
        if (customerName != null) {
173
            tticket.setCustomerName(customerName);
174
        }
175
 
176
        if (assignee != null) {
177
            tticket.setAssignee(assignee.getThriftAgent());
178
        }
179
 
180
        if (creator != null) {
181
            tticket.setCreator(creator.getThriftAgent());
182
        }
183
 
3024 mandeep.dh 184
        return tticket;
185
    }
186
 
187
    public long getId() {
188
        return id;
189
    }
190
 
191
    public void setId(long id) {
192
        this.id = id;
193
    }
194
 
3269 mandeep.dh 195
    public Long getCustomerId() {
3024 mandeep.dh 196
        return customerId;
197
    }
198
 
3269 mandeep.dh 199
    public void setCustomerId(Long customerId) {
3024 mandeep.dh 200
        this.customerId = customerId;
201
    }
202
 
203
    public Date getOpenDate() {
204
        return openDate;
205
    }
206
 
207
    public void setOpenDate(Date openDate) {
208
        this.openDate = openDate;
209
    }
210
 
211
    public Date getCloseDate() {
212
        return closeDate;
213
    }
214
 
215
    public void setCloseDate(Date closeDate) {
216
        this.closeDate = closeDate;
217
    }
218
 
219
    public long getCreatorId() {
220
        return creatorId;
221
    }
222
 
223
    public void setCreatorId(long creatorId) {
224
        this.creatorId = creatorId;
225
    }
226
 
3106 mandeep.dh 227
    public Long getOrderId() {
3024 mandeep.dh 228
        return orderId;
229
    }
230
 
3106 mandeep.dh 231
    public void setOrderId(Long orderId) {
3024 mandeep.dh 232
        this.orderId = orderId;
233
    }
234
 
235
    public String getAirwayBillNo() {
236
        return airwayBillNo;
237
    }
238
 
239
    public void setAirwayBillNo(String airwayBillNo) {
240
        this.airwayBillNo = airwayBillNo;
241
    }
242
 
243
    public String getProductName() {
244
        return productName;
245
    }
246
 
247
    public void setProductName(String productName) {
248
        this.productName = productName;
249
    }
3106 mandeep.dh 250
 
251
    public String getDescription() {
252
        return description;
253
    }
254
 
255
    public void setDescription(String description) {
256
        this.description = description;
257
    }
258
 
259
    public TicketStatus getStatus() {
260
        return status;
261
    }
262
 
263
    public void setStatus(TicketStatus status) {
264
        this.status = status;
265
    }
266
 
267
    public TicketPriority getPriority() {
268
        return priority;
269
    }
270
 
271
    public void setPriority(TicketPriority priority) {
272
        this.priority = priority;
273
    }
274
 
275
    public TicketCategory getCategory() {
276
        return category;
277
    }
278
 
279
    public void setCategory(TicketCategory category) {
280
        this.category = category;
281
    }
282
 
283
    public Long getAssigneeId() {
284
        return assigneeId;
285
    }
286
 
287
    public void setAssigneeId(Long assigneeId) {
288
        this.assigneeId = assigneeId;
289
    }
3269 mandeep.dh 290
 
291
    public String getCustomerEmailId() {
292
        return customerEmailId;
293
    }
294
 
295
    public void setCustomerEmailId(String customerEmailId) {
296
        this.customerEmailId = customerEmailId;
297
    }
3390 mandeep.dh 298
 
299
    public String getCustomerMobileNumber() {
300
        return customerMobileNumber;
301
    }
302
 
303
    public void setCustomerMobileNumber(String customerMobileNumber) {
304
        this.customerMobileNumber = customerMobileNumber;
305
    }
306
 
307
    public String getCustomerName() {
308
        return customerName;
309
    }
310
 
311
    public void setCustomerName(String customerName) {
312
        this.customerName = customerName;
313
    }
314
 
315
    public Agent getAssignee() {
316
        return assignee;
317
    }
318
 
319
    public void setAssignee(Agent assignee) {
320
        this.assignee = assignee;
321
    }
322
 
323
    public Agent getCreator() {
324
        return creator;
325
    }
326
 
327
    public void setCreator(Agent creator) {
328
        this.creator = creator;
329
    }
3024 mandeep.dh 330
}