Subversion Repositories SmartDukaan

Rev

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