| 3090 |
mandeep.dh |
1 |
/**
|
|
|
2 |
*
|
|
|
3 |
*/
|
|
|
4 |
package in.shop2020.serving.controllers;
|
|
|
5 |
|
|
|
6 |
import in.shop2020.crm.Activity;
|
|
|
7 |
import in.shop2020.crm.Agent;
|
|
|
8 |
import in.shop2020.crm.ContactMedium;
|
|
|
9 |
import in.shop2020.crm.Ticket;
|
|
|
10 |
import in.shop2020.crm.TicketCategory;
|
|
|
11 |
import in.shop2020.crm.TicketPriority;
|
|
|
12 |
import in.shop2020.crm.TicketStatus;
|
|
|
13 |
import in.shop2020.model.v1.user.User;
|
|
|
14 |
import in.shop2020.model.v1.user.UserContextException;
|
|
|
15 |
|
|
|
16 |
import java.util.Date;
|
|
|
17 |
import java.util.LinkedHashMap;
|
|
|
18 |
import java.util.List;
|
|
|
19 |
import java.util.Map;
|
|
|
20 |
|
|
|
21 |
import org.apache.thrift.TException;
|
|
|
22 |
|
|
|
23 |
/**
|
|
|
24 |
* Action class for activity pages in CRM.
|
|
|
25 |
*
|
|
|
26 |
* @author mandeep
|
|
|
27 |
*/
|
|
|
28 |
public class UserActivityController extends BaseController {
|
|
|
29 |
/**
|
|
|
30 |
*
|
|
|
31 |
*/
|
|
|
32 |
private static final long serialVersionUID = 1L;
|
|
|
33 |
|
|
|
34 |
private Map<Long, Activity> activities = new LinkedHashMap<Long, Activity>();
|
|
|
35 |
private long userId;
|
|
|
36 |
private String description;
|
|
|
37 |
private String contactMedium;
|
|
|
38 |
private String ticketAssigneeEmailId;
|
|
|
39 |
private String contactTimestamp;
|
|
|
40 |
private String contactingAgentEmailId;
|
|
|
41 |
private User user;
|
|
|
42 |
private String ticketCategory;
|
|
|
43 |
|
|
|
44 |
public String index() throws TException, UserContextException {
|
|
|
45 |
createServiceClients();
|
|
|
46 |
List<Activity> activityList = crmServiceClient.getActivities(userId);
|
|
|
47 |
if (activityList != null) {
|
|
|
48 |
for (Activity activity : activityList) {
|
|
|
49 |
activities.put(activity.getId(), activity);
|
|
|
50 |
}
|
|
|
51 |
}
|
|
|
52 |
|
|
|
53 |
user = userContextServiceClient.getUserById(userId);
|
|
|
54 |
|
|
|
55 |
return INDEX;
|
|
|
56 |
}
|
|
|
57 |
|
|
|
58 |
public String editNew() throws UserContextException, TException {
|
|
|
59 |
contactTimestamp = SDF.format(new Date());
|
|
|
60 |
return EDIT_NEW;
|
|
|
61 |
}
|
|
|
62 |
|
|
|
63 |
public Map<Long, Activity> getActivities() {
|
|
|
64 |
return activities;
|
|
|
65 |
}
|
|
|
66 |
|
|
|
67 |
public TicketStatus[] getTicketStatuses() {
|
|
|
68 |
return TicketStatus.values();
|
|
|
69 |
}
|
|
|
70 |
|
|
|
71 |
public TicketPriority[] getTicketPriorities() {
|
|
|
72 |
return TicketPriority.values();
|
|
|
73 |
}
|
|
|
74 |
|
|
|
75 |
public ContactMedium[] getContactMedia() {
|
|
|
76 |
return ContactMedium.values();
|
|
|
77 |
}
|
|
|
78 |
|
|
|
79 |
public User getUser() {
|
|
|
80 |
return user;
|
|
|
81 |
}
|
|
|
82 |
|
|
|
83 |
public Ticket getTicket(long activityId) throws TException {
|
|
|
84 |
Ticket ticket = null;
|
|
|
85 |
Activity activity = crmServiceClient.getActivity(activityId);
|
|
|
86 |
if (activity != null && activity.getTicketId() != 0) {
|
|
|
87 |
ticket = crmServiceClient.getTicket(activity.getTicketId());
|
|
|
88 |
}
|
|
|
89 |
else {
|
|
|
90 |
ticket = new Ticket();
|
|
|
91 |
}
|
|
|
92 |
|
|
|
93 |
return ticket;
|
|
|
94 |
}
|
|
|
95 |
|
|
|
96 |
public String create() throws Exception {
|
|
|
97 |
createServiceClients();
|
|
|
98 |
Activity activity = new Activity();
|
|
|
99 |
activity.setCustomerId(userId);
|
|
|
100 |
activity.setContactingAgentId(crmServiceClient.getAgentByEmailId(
|
|
|
101 |
currentAgentEmailId).getId());
|
|
|
102 |
activity.setDescription(description);
|
|
|
103 |
activity.setContactMedium(ContactMedium.valueOf(contactMedium));
|
|
|
104 |
activity.setTicketAssigneeId(crmServiceClient.getAgentByEmailId(
|
|
|
105 |
ticketAssigneeEmailId).getId());
|
|
|
106 |
activity.setTicketPriority(TicketPriority.MEDIUM);
|
|
|
107 |
activity.setTicketStatus(TicketStatus.CLOSED);
|
|
|
108 |
activity.setContactTimestamp(SDF.parse(contactTimestamp).getTime());
|
|
|
109 |
activity.setCreatorId(crmServiceClient.getAgentByEmailId(currentAgentEmailId).getId());
|
|
|
110 |
activity.setTicketCategory(TicketCategory.valueOf(ticketCategory));
|
|
|
111 |
|
|
|
112 |
crmServiceClient.insertActivity(activity);
|
|
|
113 |
|
|
|
114 |
return index();
|
|
|
115 |
}
|
|
|
116 |
|
|
|
117 |
public List<Agent> getAllAgents() throws TException
|
|
|
118 |
{
|
|
|
119 |
createServiceClients();
|
|
|
120 |
return crmServiceClient.getAllAgents();
|
|
|
121 |
}
|
|
|
122 |
|
|
|
123 |
public Agent getAgent(long agentId) throws TException {
|
|
|
124 |
return crmServiceClient.getAgent(agentId);
|
|
|
125 |
}
|
|
|
126 |
|
|
|
127 |
public void setUserId(String userId) {
|
|
|
128 |
this.userId = Long.parseLong(userId);
|
|
|
129 |
}
|
|
|
130 |
|
|
|
131 |
public void setDescription(String description) {
|
|
|
132 |
this.description = description;
|
|
|
133 |
}
|
|
|
134 |
|
|
|
135 |
public void setContactMedium(String contactMedium) {
|
|
|
136 |
this.contactMedium = contactMedium;
|
|
|
137 |
}
|
|
|
138 |
|
|
|
139 |
public void setTicketAssigneeEmailId(String ticketAssigneeEmailId) {
|
|
|
140 |
this.ticketAssigneeEmailId = ticketAssigneeEmailId;
|
|
|
141 |
}
|
|
|
142 |
|
|
|
143 |
public void setContactTimestamp(String contactTimestamp) {
|
|
|
144 |
this.contactTimestamp = contactTimestamp;
|
|
|
145 |
}
|
|
|
146 |
|
|
|
147 |
public void setContactingAgentEmailId(String contactingAgentEmailId) {
|
|
|
148 |
this.contactingAgentEmailId = contactingAgentEmailId;
|
|
|
149 |
}
|
|
|
150 |
|
|
|
151 |
public long getUserId() {
|
|
|
152 |
return userId;
|
|
|
153 |
}
|
|
|
154 |
|
|
|
155 |
public String getContactTimestamp() {
|
|
|
156 |
return contactTimestamp;
|
|
|
157 |
}
|
|
|
158 |
|
|
|
159 |
public String getTicketCategory() {
|
|
|
160 |
return ticketCategory;
|
|
|
161 |
}
|
|
|
162 |
|
|
|
163 |
public void setTicketCategory(String ticketCategory) {
|
|
|
164 |
this.ticketCategory = ticketCategory;
|
|
|
165 |
}
|
|
|
166 |
}
|