Subversion Repositories SmartDukaan

Rev

Rev 3106 | Rev 3390 | 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;
23
    private String         customerEmailId;
3106 mandeep.dh 24
    private Date           openDate;
25
    private Date           closeDate;
26
    private long           creatorId;
27
    private String         description;
28
    private TicketStatus   status;
29
    private TicketPriority priority;
30
    private TicketCategory category;
31
    private Long           assigneeId;
3024 mandeep.dh 32
 
33
    // Fields from user communication
3106 mandeep.dh 34
    private Long           orderId;
35
    private String         airwayBillNo;
36
    private String         productName;
3024 mandeep.dh 37
 
38
    /**
39
     * Converts thrift ticket object representation to our domain object
3106 mandeep.dh 40
     * 
3024 mandeep.dh 41
     * @param tticket
42
     * @return
43
     * @throws ParseException
44
     */
45
    public static Ticket create(in.shop2020.crm.Ticket tticket)
46
            throws ParseException {
47
        Ticket ticket = new Ticket();
48
        ticket.id = tticket.getId();
49
        ticket.creatorId = tticket.getCreatorId();
3269 mandeep.dh 50
        ticket.category = tticket.getCategory();
51
        ticket.priority = tticket.getPriority();
52
        ticket.status = tticket.getStatus();
53
        ticket.airwayBillNo = tticket.getAirwayBillNo();
54
        ticket.productName = tticket.getProductName();
55
 
56
        if (tticket.isSetDescription()) {
57
            ticket.description = tticket.getDescription();
58
        }
59
 
60
        if (tticket.isSetCustomerId()) {
61
            ticket.customerId = tticket.getCustomerId();
62
        }
63
 
64
        if (tticket.isSetCustomerEmailId()) {
65
            ticket.customerEmailId = tticket.getCustomerEmailId();
66
        }
67
 
3106 mandeep.dh 68
        if (tticket.isSetAssigneeId()) {
69
            ticket.assigneeId = tticket.getAssigneeId();
70
        }
3024 mandeep.dh 71
 
72
        if (tticket.isSetOpenDate()) {
73
            ticket.openDate = new Date(tticket.getOpenDate());
74
        }
75
 
76
        // Trying to set close date as null in database!
3269 mandeep.dh 77
        if (tticket.isSetCloseDate()) {
3024 mandeep.dh 78
            ticket.closeDate = new Date(tticket.getCloseDate());
79
        }
80
 
3106 mandeep.dh 81
        if (tticket.isSetOrderId()) {
82
            ticket.orderId = tticket.getOrderId();
83
        }
84
 
3024 mandeep.dh 85
        return ticket;
86
    }
87
 
88
    /**
89
     * Converts this object to its corresponding thrift representation.
3106 mandeep.dh 90
     * 
3024 mandeep.dh 91
     * @return
92
     */
93
    public in.shop2020.crm.Ticket getThriftTicket() {
94
        in.shop2020.crm.Ticket tticket = new in.shop2020.crm.Ticket();
95
        tticket.setId(id);
96
        tticket.setCreatorId(creatorId);
3106 mandeep.dh 97
        tticket.setDescription(description);
3269 mandeep.dh 98
        tticket.setCategory(category);
99
        tticket.setPriority(priority);
100
        tticket.setStatus(status);
101
        tticket.setAirwayBillNo(airwayBillNo);
102
        tticket.setProductName(productName);
3106 mandeep.dh 103
 
3269 mandeep.dh 104
        if (customerId != null) {
105
            tticket.setCustomerId(customerId);
106
        }
107
 
108
        if (customerEmailId != null) {
109
            tticket.setCustomerEmailId(customerEmailId);
110
        }
111
 
3106 mandeep.dh 112
        if (assigneeId != null) {
113
            tticket.setAssigneeId(assigneeId);
114
        }
115
 
116
        if (orderId != null) {
117
            tticket.setOrderId(orderId);
118
        }
119
 
3024 mandeep.dh 120
        if (openDate != null) {
121
            tticket.setOpenDate(openDate.getTime());
122
        }
123
 
124
        if (closeDate != null) {
125
            tticket.setCloseDate(closeDate.getTime());
126
        }
127
 
128
        return tticket;
129
    }
130
 
131
    public long getId() {
132
        return id;
133
    }
134
 
135
    public void setId(long id) {
136
        this.id = id;
137
    }
138
 
3269 mandeep.dh 139
    public Long getCustomerId() {
3024 mandeep.dh 140
        return customerId;
141
    }
142
 
3269 mandeep.dh 143
    public void setCustomerId(Long customerId) {
3024 mandeep.dh 144
        this.customerId = customerId;
145
    }
146
 
147
    public Date getOpenDate() {
148
        return openDate;
149
    }
150
 
151
    public void setOpenDate(Date openDate) {
152
        this.openDate = openDate;
153
    }
154
 
155
    public Date getCloseDate() {
156
        return closeDate;
157
    }
158
 
159
    public void setCloseDate(Date closeDate) {
160
        this.closeDate = closeDate;
161
    }
162
 
163
    public long getCreatorId() {
164
        return creatorId;
165
    }
166
 
167
    public void setCreatorId(long creatorId) {
168
        this.creatorId = creatorId;
169
    }
170
 
3106 mandeep.dh 171
    public Long getOrderId() {
3024 mandeep.dh 172
        return orderId;
173
    }
174
 
3106 mandeep.dh 175
    public void setOrderId(Long orderId) {
3024 mandeep.dh 176
        this.orderId = orderId;
177
    }
178
 
179
    public String getAirwayBillNo() {
180
        return airwayBillNo;
181
    }
182
 
183
    public void setAirwayBillNo(String airwayBillNo) {
184
        this.airwayBillNo = airwayBillNo;
185
    }
186
 
187
    public String getProductName() {
188
        return productName;
189
    }
190
 
191
    public void setProductName(String productName) {
192
        this.productName = productName;
193
    }
3106 mandeep.dh 194
 
195
    public String getDescription() {
196
        return description;
197
    }
198
 
199
    public void setDescription(String description) {
200
        this.description = description;
201
    }
202
 
203
    public TicketStatus getStatus() {
204
        return status;
205
    }
206
 
207
    public void setStatus(TicketStatus status) {
208
        this.status = status;
209
    }
210
 
211
    public TicketPriority getPriority() {
212
        return priority;
213
    }
214
 
215
    public void setPriority(TicketPriority priority) {
216
        this.priority = priority;
217
    }
218
 
219
    public TicketCategory getCategory() {
220
        return category;
221
    }
222
 
223
    public void setCategory(TicketCategory category) {
224
        this.category = category;
225
    }
226
 
227
    public Long getAssigneeId() {
228
        return assigneeId;
229
    }
230
 
231
    public void setAssigneeId(Long assigneeId) {
232
        this.assigneeId = assigneeId;
233
    }
3269 mandeep.dh 234
 
235
    public String getCustomerEmailId() {
236
        return customerEmailId;
237
    }
238
 
239
    public void setCustomerEmailId(String customerEmailId) {
240
        this.customerEmailId = customerEmailId;
241
    }
3024 mandeep.dh 242
}