Subversion Repositories SmartDukaan

Rev

Rev 3090 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

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