Subversion Repositories SmartDukaan

Rev

Rev 3269 | Rev 3405 | 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();
3390 mandeep.dh 71
        activity.isRead = tactivity.isIsRead();
72
 
3269 mandeep.dh 73
        if (tactivity.isSetCustomerId()) {
74
            activity.customerId = tactivity.getCustomerId();
75
        }
3206 mandeep.dh 76
 
3390 mandeep.dh 77
        if (tactivity.isSetUserEmailId()) {
78
            activity.userEmailId = tactivity.getUserEmailId();
3206 mandeep.dh 79
        }
80
 
3390 mandeep.dh 81
        if (tactivity.isSetCustomerName()) {
82
            activity.customerName = tactivity.getCustomerName();
83
        }
84
 
85
        if (tactivity.isSetCustomerEmailId()) {
86
            activity.customerEmailId = tactivity.getCustomerEmailId();
87
        }
88
 
3269 mandeep.dh 89
        if (tactivity.isSetCustomerMobileNumber()) {
90
            activity.customerMobileNumber = tactivity.getCustomerMobileNumber();
91
        }
3024 mandeep.dh 92
 
3390 mandeep.dh 93
        if (tactivity.isSetTicketId()) {
3024 mandeep.dh 94
            activity.ticketId = tactivity.getTicketId();
95
        }
96
 
3390 mandeep.dh 97
        if (tactivity.isSetCreator()) {
98
            activity.creator = Agent.create(tactivity.getCreator());
99
        }
100
 
101
        if (tactivity.isSetTicketAssignee()) {
102
            activity.ticketAssignee = Agent.create(tactivity.getTicketAssignee());
103
        }
104
 
3106 mandeep.dh 105
        if (tactivity.isSetTicketAssigneeId()) {
106
            activity.ticketAssigneeId = tactivity.getTicketAssigneeId();
107
        }
108
 
3024 mandeep.dh 109
        return activity;
110
    }
111
 
112
    /**
113
     * Converts our domain object to its corresponding thrift model object.
3106 mandeep.dh 114
     * 
3024 mandeep.dh 115
     * @return
116
     */
117
    public in.shop2020.crm.Activity getThriftActivity() {
118
        in.shop2020.crm.Activity tactivity = new in.shop2020.crm.Activity();
119
        tactivity.setId(id);
120
        tactivity.setDescription(description);
3106 mandeep.dh 121
        tactivity.setType(type);
3269 mandeep.dh 122
        tactivity.setTicketPriority(ticketPriority);
123
        tactivity.setTicketStatus(ticketStatus);
124
        tactivity.setTicketCategory(ticketCategory);
125
        tactivity.setTicketDescription(ticketDescription);
126
        tactivity.setCreationTimestamp(creationTimestamp.getTime());
127
        tactivity.setCreatorId(creatorId);
3390 mandeep.dh 128
        tactivity.setIsRead(isRead);
3269 mandeep.dh 129
 
130
        if (customerId != null) {
131
            tactivity.setCustomerId(customerId);            
132
        }
133
 
3390 mandeep.dh 134
        if (userEmailId != null) {
135
            tactivity.setUserEmailId(userEmailId);
3269 mandeep.dh 136
        }
137
 
3024 mandeep.dh 138
        if (ticketId != null) {
139
            tactivity.setTicketId(ticketId);
140
        }
3106 mandeep.dh 141
 
142
        if (ticketAssigneeId != null) {
143
            tactivity.setTicketAssigneeId(ticketAssigneeId);
144
        }
145
 
3390 mandeep.dh 146
        if (customerMobileNumber != null) {
147
            tactivity.setCustomerMobileNumber(customerMobileNumber);
148
        }
149
 
150
        if (customerName != null) {
151
            tactivity.setCustomerName(customerName);
152
        }
153
 
154
        if (customerEmailId != null) {
155
            tactivity.setCustomerEmailId(customerEmailId);
156
        }
157
 
158
        if (creator != null) {
159
            tactivity.setCreator(creator.getThriftAgent());
160
        }
161
 
162
        if (ticketAssignee != null) {
163
            tactivity.setTicketAssignee(ticketAssignee.getThriftAgent());
164
        }
165
 
3024 mandeep.dh 166
        return tactivity;
167
    }
168
 
169
    public long getId() {
170
        return id;
171
    }
172
 
173
    public void setId(long id) {
174
        this.id = id;
175
    }
176
 
177
    public String getDescription() {
178
        return description;
179
    }
180
 
181
    public void setDescription(String description) {
182
        this.description = description;
183
    }
184
 
3106 mandeep.dh 185
    public Long getTicketAssigneeId() {
3024 mandeep.dh 186
        return ticketAssigneeId;
187
    }
188
 
3106 mandeep.dh 189
    public void setTicketAssigneeId(Long ticketAssigneeId) {
3024 mandeep.dh 190
        this.ticketAssigneeId = ticketAssigneeId;
191
    }
192
 
193
    public TicketPriority getTicketPriority() {
194
        return ticketPriority;
195
    }
196
 
197
    public void setTicketPriority(TicketPriority ticketPriority) {
198
        this.ticketPriority = ticketPriority;
199
    }
200
 
3269 mandeep.dh 201
    public Long getCustomerId() {
3024 mandeep.dh 202
        return customerId;
203
    }
204
 
3269 mandeep.dh 205
    public void setCustomerId(Long customerId) {
3024 mandeep.dh 206
        this.customerId = customerId;
207
    }
208
 
3088 mandeep.dh 209
    public Long getTicketId() {
3024 mandeep.dh 210
        return ticketId;
211
    }
212
 
3088 mandeep.dh 213
    public void setTicketId(Long ticketId) {
3024 mandeep.dh 214
        this.ticketId = ticketId;
215
    }
216
 
217
    public long getCreatorId() {
218
        return creatorId;
219
    }
220
 
221
    public void setCreatorId(long creatorId) {
222
        this.creatorId = creatorId;
223
    }
224
 
225
    public TicketStatus getTicketStatus() {
226
        return ticketStatus;
227
    }
228
 
229
    public void setTicketStatus(TicketStatus ticketStatus) {
230
        this.ticketStatus = ticketStatus;
231
    }
232
 
233
    public TicketCategory getTicketCategory() {
234
        return ticketCategory;
235
    }
236
 
237
    public void setTicketCategory(TicketCategory ticketCategory) {
238
        this.ticketCategory = ticketCategory;
239
    }
3106 mandeep.dh 240
 
241
    public Date getCreationTimestamp() {
242
        return creationTimestamp;
243
    }
244
 
245
    public void setCreationTimestamp(Date creationTimestamp) {
246
        this.creationTimestamp = creationTimestamp;
247
    }
248
 
249
    public String getTicketDescription() {
250
        return ticketDescription;
251
    }
252
 
253
    public void setTicketDescription(String ticketDescription) {
254
        this.ticketDescription = ticketDescription;
255
    }
256
 
257
    public ActivityType getType() {
258
        return type;
259
    }
260
 
261
    public void setType(ActivityType type) {
262
        this.type = type;
263
    }
3206 mandeep.dh 264
 
3390 mandeep.dh 265
    public Long getUserEmailId() {
266
        return userEmailId;
3206 mandeep.dh 267
    }
268
 
3390 mandeep.dh 269
    public void setUserEmailId(Long emailId) {
270
        this.userEmailId = emailId;
3206 mandeep.dh 271
    }
3269 mandeep.dh 272
 
273
    public String getCustomerMobileNumber() {
274
        return customerMobileNumber;
275
    }
276
 
277
    public void setCustomerMobileNumber(String customerMobileNumber) {
278
        this.customerMobileNumber = customerMobileNumber;
279
    }
3390 mandeep.dh 280
 
281
    public boolean isRead() {
282
        return isRead;
283
    }
284
 
285
    public void setRead(boolean isRead) {
286
        this.isRead = isRead;
287
    }
288
 
289
    public String getCustomerEmailId() {
290
        return customerEmailId;
291
    }
292
 
293
    public void setCustomerEmailId(String customerEmailId) {
294
        this.customerEmailId = customerEmailId;
295
    }
296
 
297
    public String getCustomerName() {
298
        return customerName;
299
    }
300
 
301
    public void setCustomerName(String customerName) {
302
        this.customerName = customerName;
303
    }
304
 
305
    public Agent getTicketAssignee() {
306
        return ticketAssignee;
307
    }
308
 
309
    public void setTicketAssignee(Agent ticketAssignee) {
310
        this.ticketAssignee = ticketAssignee;
311
    }
312
 
313
    public Agent getCreator() {
314
        return creator;
315
    }
316
 
317
    public void setCreator(Agent creator) {
318
        this.creator = creator;
319
    }
3024 mandeep.dh 320
}