Subversion Repositories SmartDukaan

Rev

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

Rev 3234 Rev 3269
Line 31... Line 31...
31
     * 
31
     * 
32
     */
32
     */
33
    private static final long   serialVersionUID = 1L;
33
    private static final long   serialVersionUID = 1L;
34
 
34
 
35
    private Map<Long, Activity> activities       = new LinkedHashMap<Long, Activity>();
35
    private Map<Long, Activity> activities       = new LinkedHashMap<Long, Activity>();
-
 
36
 
36
    private long                userId;
37
    private String              userId;
37
    private String              description;
38
    private String              description;
38
    private User                user;
39
    private User                user;
39
    private String              type;
40
    private String              type;
40
    private String              subject;
41
    private String              subject;
41
    private String              body;
42
    private String              body;
42
    private String              userEmailId;
43
    private String              userEmailId;
-
 
44
    private String              customerMobileNumber;
43
 
45
 
44
    public String index() throws TException, UserContextException {
46
    public String index() throws TException, UserContextException {
45
        createServiceClients();
47
        createServiceClients();
46
        List<Activity> activityList = crmServiceClient.getActivities(userId);
48
        List<Activity> activityList = crmServiceClient.getActivities(Long.parseLong(userId));
47
        if (activityList != null) {
49
        if (activityList != null) {
48
            for (Activity activity : activityList) {
50
            for (Activity activity : activityList) {
49
                activities.put(activity.getId(), activity);
51
                activities.put(activity.getId(), activity);
50
            }
52
            }
51
        }
53
        }
52
 
54
 
53
        user = userContextServiceClient.getUserById(userId);
55
        user = userContextServiceClient.getUserById(Long.parseLong(userId));
54
 
56
 
55
        return INDEX;
57
        return INDEX;
56
    }
58
    }
57
 
59
 
58
    public String editNew() {
60
    public String editNew() {
59
        createServiceClients();
61
        createServiceClients();
60
 
62
 
61
        try {
63
        try {
-
 
64
            if (user != null && !userId.isEmpty()) {
62
            user = userContextServiceClient.getUserById(userId);
65
                user = userContextServiceClient.getUserById(Long.parseLong(userId));
-
 
66
            }
63
            subject = "";
67
            subject = "";
64
        } catch (UserContextException e) {
68
        } catch (UserContextException e) {
65
            String errorMessage = "Could not fetch user for " + userId;
69
            String errorMessage = "Could not fetch user for " + userId;
66
            addActionError(errorMessage);
70
            addActionError(errorMessage);
67
            log.error(errorMessage, e);
71
            log.error(errorMessage, e);
Line 110... Line 114...
110
 
114
 
111
    public String create() throws Exception {
115
    public String create() throws Exception {
112
        createServiceClients();
116
        createServiceClients();
113
 
117
 
114
        Activity activity = new Activity();
118
        Activity activity = new Activity();
115
        activity.setCustomerId(userId);
-
 
116
        activity.setDescription(description);
119
        activity.setDescription(description);
117
        activity.setType(ActivityType.valueOf(type));
120
        activity.setType(ActivityType.valueOf(type));
118
        activity.setCreatorId(crmServiceClient.getAgentByEmailId(
121
        activity.setCreatorId(crmServiceClient.getAgentByEmailId(
119
                currentAgentEmailId).getId());
122
                currentAgentEmailId).getId());
120
 
123
 
-
 
124
        if (userId != null && !userId.isEmpty()) {
-
 
125
            activity.setCustomerId(Long.parseLong(userId));
-
 
126
        }
-
 
127
 
-
 
128
        if (customerMobileNumber != null && !customerMobileNumber.isEmpty()) {
-
 
129
            activity.setCustomerMobileNumber(customerMobileNumber);
-
 
130
        }
-
 
131
 
121
        if (ActivityType.EMAIL_CUSTOMER.equals(activity.getType())) {
132
        if (ActivityType.SEND_EMAIL_TO_CUSTOMER.equals(activity.getType())) {
122
            log.info("Sending mail");
133
            log.info("Sending mail");
123
            Client helperClient = new HelperClient().getClient();
134
            Client helperClient = new HelperClient().getClient();
124
            activity.setEmailId(helperClient.saveUserEmailForSending(
135
            activity.setEmailId(helperClient.saveUserEmailForSending(
125
                    userEmailId, CRMConstants.CRM_EMAIL_SENDOR, subject,
136
                    userEmailId, CRMConstants.CRM_EMAIL_SENDOR, subject,
126
                    body, null, CRMConstants.CRM_EMAIL_TYPE));
137
                    body, null, CRMConstants.CRM_EMAIL_TYPE));
Line 148... Line 159...
148
 
159
 
149
    public Agent getAgent(long agentId) throws TException {
160
    public Agent getAgent(long agentId) throws TException {
150
        return crmServiceClient.getAgent(agentId);
161
        return crmServiceClient.getAgent(agentId);
151
    }
162
    }
152
 
163
 
153
    public void setUserId(String userId) {
-
 
154
        this.userId = Long.parseLong(userId);
-
 
155
    }
-
 
156
 
-
 
157
    public void setDescription(String description) {
164
    public void setDescription(String description) {
158
        this.description = description;
165
        this.description = description;
159
    }
166
    }
160
 
167
 
161
    public long getUserId() {
168
    public String getUserId() {
162
        return userId;
169
        return userId;
163
    }
170
    }
164
 
171
 
165
    public String getType() {
172
    public String getType() {
166
        return type;
173
        return type;
Line 176... Line 183...
176
 
183
 
177
    public void setActivities(Map<Long, Activity> activities) {
184
    public void setActivities(Map<Long, Activity> activities) {
178
        this.activities = activities;
185
        this.activities = activities;
179
    }
186
    }
180
 
187
 
181
    public void setUserId(long userId) {
188
    public void setUserId(String userId) {
182
        this.userId = userId;
189
        this.userId = userId;
183
    }
190
    }
184
 
191
 
185
    public String getSubject() {
192
    public String getSubject() {
186
        return subject;
193
        return subject;
Line 203... Line 210...
203
    }
210
    }
204
 
211
 
205
    public void setUserEmailId(String userEmailId) {
212
    public void setUserEmailId(String userEmailId) {
206
        this.userEmailId = userEmailId;
213
        this.userEmailId = userEmailId;
207
    }
214
    }
-
 
215
 
-
 
216
    public String getCustomerMobileNumber() {
-
 
217
        return customerMobileNumber;
-
 
218
    }
-
 
219
 
-
 
220
    public void setCustomerMobileNumber(String customerMobileNumber) {
-
 
221
        this.customerMobileNumber = customerMobileNumber;
-
 
222
    }
208
}
223
}