Subversion Repositories SmartDukaan

Rev

Rev 3390 | Rev 3546 | 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.ActivityType;
3024 mandeep.dh 7
import in.shop2020.crm.TicketCategory;
8
import in.shop2020.crm.TicketPriority;
9
import in.shop2020.crm.TicketStatus;
10
 
11
import java.text.ParseException;
12
import java.util.Date;
13
 
14
/**
15
 * Domain class for Activity.
16
 * 
17
 * @author mandeep
18
 */
19
public class Activity {
20
    // Basic attributes of activity
21
    private long           id;
22
    private String         description;
3106 mandeep.dh 23
    private ActivityType   type;
3269 mandeep.dh 24
    private Long           customerId;
3390 mandeep.dh 25
    private Long           userEmailId;
3024 mandeep.dh 26
 
3106 mandeep.dh 27
    // time at which the activity happened
28
    private Date           creationTimestamp;
3024 mandeep.dh 29
    private long           creatorId;
30
 
31
    // ticket attributes that can change with an activity
32
    private Long           ticketId;
33
    private TicketStatus   ticketStatus;
34
    private TicketCategory ticketCategory;
3106 mandeep.dh 35
    private Long           ticketAssigneeId;
3024 mandeep.dh 36
    private TicketPriority ticketPriority;
3106 mandeep.dh 37
    private String         ticketDescription;
3024 mandeep.dh 38
 
3390 mandeep.dh 39
    // relevant only for the activities generated by customer
40
    // tracks whether its being read by any agent or not
41
    private boolean        isRead = true;
42
 
43
    // fields for unregistered users
44
    private String         customerEmailId;
45
    private String         customerName;
46
    private String         customerMobileNumber;
47
 
48
    private Agent          ticketAssignee;
49
    private Agent          creator;
50
 
3024 mandeep.dh 51
    /**
52
     * Converts a thrift activity object to our domain object for activity
3106 mandeep.dh 53
     * 
3024 mandeep.dh 54
     * @param tactivity
55
     * @return
56
     * @throws ParseException
57
     */
58
    public static Activity create(in.shop2020.crm.Activity tactivity)
59
            throws ParseException {
60
        Activity activity = new Activity();
61
        activity.id = tactivity.getId();
3390 mandeep.dh 62
        activity.userEmailId = tactivity.getUserEmailId();
3269 mandeep.dh 63
        activity.creationTimestamp = new Date(tactivity.getCreationTimestamp());
64
        activity.creatorId = tactivity.getCreatorId();
65
        activity.ticketPriority = tactivity.getTicketPriority();
66
        activity.ticketStatus = tactivity.getTicketStatus();
67
        activity.ticketCategory = tactivity.getTicketCategory();
68
        activity.ticketDescription = tactivity.getTicketDescription();
3024 mandeep.dh 69
        activity.description = tactivity.getDescription();
3269 mandeep.dh 70
        activity.type = tactivity.getType();
3405 mandeep.dh 71
 
72
        if (tactivity.isSetIsRead()) {
73
            activity.isRead = tactivity.isIsRead();
74
        }
3390 mandeep.dh 75
 
3269 mandeep.dh 76
        if (tactivity.isSetCustomerId()) {
77
            activity.customerId = tactivity.getCustomerId();
78
        }
3206 mandeep.dh 79
 
3390 mandeep.dh 80
        if (tactivity.isSetUserEmailId()) {
81
            activity.userEmailId = tactivity.getUserEmailId();
3206 mandeep.dh 82
        }
83
 
3390 mandeep.dh 84
        if (tactivity.isSetCustomerName()) {
85
            activity.customerName = tactivity.getCustomerName();
86
        }
87
 
88
        if (tactivity.isSetCustomerEmailId()) {
89
            activity.customerEmailId = tactivity.getCustomerEmailId();
90
        }
91
 
3269 mandeep.dh 92
        if (tactivity.isSetCustomerMobileNumber()) {
93
            activity.customerMobileNumber = tactivity.getCustomerMobileNumber();
94
        }
3024 mandeep.dh 95
 
3390 mandeep.dh 96
        if (tactivity.isSetTicketId()) {
3024 mandeep.dh 97
            activity.ticketId = tactivity.getTicketId();
98
        }
99
 
3390 mandeep.dh 100
        if (tactivity.isSetCreator()) {
101
            activity.creator = Agent.create(tactivity.getCreator());
102
        }
103
 
104
        if (tactivity.isSetTicketAssignee()) {
105
            activity.ticketAssignee = Agent.create(tactivity.getTicketAssignee());
106
        }
107
 
3106 mandeep.dh 108
        if (tactivity.isSetTicketAssigneeId()) {
109
            activity.ticketAssigneeId = tactivity.getTicketAssigneeId();
110
        }
111
 
3024 mandeep.dh 112
        return activity;
113
    }
114
 
115
    /**
116
     * Converts our domain object to its corresponding thrift model object.
3106 mandeep.dh 117
     * 
3024 mandeep.dh 118
     * @return
119
     */
120
    public in.shop2020.crm.Activity getThriftActivity() {
121
        in.shop2020.crm.Activity tactivity = new in.shop2020.crm.Activity();
122
        tactivity.setId(id);
123
        tactivity.setDescription(description);
3106 mandeep.dh 124
        tactivity.setType(type);
3269 mandeep.dh 125
        tactivity.setTicketPriority(ticketPriority);
126
        tactivity.setTicketStatus(ticketStatus);
127
        tactivity.setTicketCategory(ticketCategory);
128
        tactivity.setTicketDescription(ticketDescription);
129
        tactivity.setCreationTimestamp(creationTimestamp.getTime());
130
        tactivity.setCreatorId(creatorId);
3390 mandeep.dh 131
        tactivity.setIsRead(isRead);
3269 mandeep.dh 132
 
133
        if (customerId != null) {
134
            tactivity.setCustomerId(customerId);            
135
        }
136
 
3390 mandeep.dh 137
        if (userEmailId != null) {
138
            tactivity.setUserEmailId(userEmailId);
3269 mandeep.dh 139
        }
140
 
3024 mandeep.dh 141
        if (ticketId != null) {
142
            tactivity.setTicketId(ticketId);
143
        }
3106 mandeep.dh 144
 
145
        if (ticketAssigneeId != null) {
146
            tactivity.setTicketAssigneeId(ticketAssigneeId);
147
        }
148
 
3390 mandeep.dh 149
        if (customerMobileNumber != null) {
150
            tactivity.setCustomerMobileNumber(customerMobileNumber);
151
        }
152
 
153
        if (customerName != null) {
154
            tactivity.setCustomerName(customerName);
155
        }
156
 
157
        if (customerEmailId != null) {
158
            tactivity.setCustomerEmailId(customerEmailId);
159
        }
160
 
161
        if (creator != null) {
162
            tactivity.setCreator(creator.getThriftAgent());
163
        }
164
 
165
        if (ticketAssignee != null) {
166
            tactivity.setTicketAssignee(ticketAssignee.getThriftAgent());
167
        }
168
 
3024 mandeep.dh 169
        return tactivity;
170
    }
171
 
172
    public long getId() {
173
        return id;
174
    }
175
 
176
    public void setId(long id) {
177
        this.id = id;
178
    }
179
 
180
    public String getDescription() {
181
        return description;
182
    }
183
 
184
    public void setDescription(String description) {
185
        this.description = description;
186
    }
187
 
3106 mandeep.dh 188
    public Long getTicketAssigneeId() {
3024 mandeep.dh 189
        return ticketAssigneeId;
190
    }
191
 
3106 mandeep.dh 192
    public void setTicketAssigneeId(Long ticketAssigneeId) {
3024 mandeep.dh 193
        this.ticketAssigneeId = ticketAssigneeId;
194
    }
195
 
196
    public TicketPriority getTicketPriority() {
197
        return ticketPriority;
198
    }
199
 
200
    public void setTicketPriority(TicketPriority ticketPriority) {
201
        this.ticketPriority = ticketPriority;
202
    }
203
 
3269 mandeep.dh 204
    public Long getCustomerId() {
3024 mandeep.dh 205
        return customerId;
206
    }
207
 
3269 mandeep.dh 208
    public void setCustomerId(Long customerId) {
3024 mandeep.dh 209
        this.customerId = customerId;
210
    }
211
 
3088 mandeep.dh 212
    public Long getTicketId() {
3024 mandeep.dh 213
        return ticketId;
214
    }
215
 
3088 mandeep.dh 216
    public void setTicketId(Long ticketId) {
3024 mandeep.dh 217
        this.ticketId = ticketId;
218
    }
219
 
220
    public long getCreatorId() {
221
        return creatorId;
222
    }
223
 
224
    public void setCreatorId(long creatorId) {
225
        this.creatorId = creatorId;
226
    }
227
 
228
    public TicketStatus getTicketStatus() {
229
        return ticketStatus;
230
    }
231
 
232
    public void setTicketStatus(TicketStatus ticketStatus) {
233
        this.ticketStatus = ticketStatus;
234
    }
235
 
236
    public TicketCategory getTicketCategory() {
237
        return ticketCategory;
238
    }
239
 
240
    public void setTicketCategory(TicketCategory ticketCategory) {
241
        this.ticketCategory = ticketCategory;
242
    }
3106 mandeep.dh 243
 
244
    public Date getCreationTimestamp() {
245
        return creationTimestamp;
246
    }
247
 
248
    public void setCreationTimestamp(Date creationTimestamp) {
249
        this.creationTimestamp = creationTimestamp;
250
    }
251
 
252
    public String getTicketDescription() {
253
        return ticketDescription;
254
    }
255
 
256
    public void setTicketDescription(String ticketDescription) {
257
        this.ticketDescription = ticketDescription;
258
    }
259
 
260
    public ActivityType getType() {
261
        return type;
262
    }
263
 
264
    public void setType(ActivityType type) {
265
        this.type = type;
266
    }
3206 mandeep.dh 267
 
3390 mandeep.dh 268
    public Long getUserEmailId() {
269
        return userEmailId;
3206 mandeep.dh 270
    }
271
 
3390 mandeep.dh 272
    public void setUserEmailId(Long emailId) {
273
        this.userEmailId = emailId;
3206 mandeep.dh 274
    }
3269 mandeep.dh 275
 
276
    public String getCustomerMobileNumber() {
277
        return customerMobileNumber;
278
    }
279
 
280
    public void setCustomerMobileNumber(String customerMobileNumber) {
281
        this.customerMobileNumber = customerMobileNumber;
282
    }
3390 mandeep.dh 283
 
284
    public boolean isRead() {
285
        return isRead;
286
    }
287
 
288
    public void setRead(boolean isRead) {
289
        this.isRead = isRead;
290
    }
291
 
292
    public String getCustomerEmailId() {
293
        return customerEmailId;
294
    }
295
 
296
    public void setCustomerEmailId(String customerEmailId) {
297
        this.customerEmailId = customerEmailId;
298
    }
299
 
300
    public String getCustomerName() {
301
        return customerName;
302
    }
303
 
304
    public void setCustomerName(String customerName) {
305
        this.customerName = customerName;
306
    }
307
 
308
    public Agent getTicketAssignee() {
309
        return ticketAssignee;
310
    }
311
 
312
    public void setTicketAssignee(Agent ticketAssignee) {
313
        this.ticketAssignee = ticketAssignee;
314
    }
315
 
316
    public Agent getCreator() {
317
        return creator;
318
    }
319
 
320
    public void setCreator(Agent creator) {
321
        this.creator = creator;
322
    }
3024 mandeep.dh 323
}