Subversion Repositories SmartDukaan

Rev

Rev 3137 | Rev 3206 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 3137 Rev 3168
Line 25... Line 25...
25
 * 
25
 * 
26
 * @author mandeep
26
 * @author mandeep
27
 */
27
 */
28
@Service
28
@Service
29
public class CRMServiceHandler implements Iface {
29
public class CRMServiceHandler implements Iface {
30
    ApplicationContext context         = new ClassPathXmlApplicationContext("context.xml");
30
    ApplicationContext context         = new ClassPathXmlApplicationContext(
-
 
31
                                               "context.xml");
31
    TicketHandler      ticketHandler   = context.getBean(TicketHandler.class);
32
    TicketHandler      ticketHandler   = context.getBean(TicketHandler.class);
32
    ActivityHandler    activityHandler = context.getBean(ActivityHandler.class);
33
    ActivityHandler    activityHandler = context.getBean(ActivityHandler.class);
33
    AgentHandler       agentHandler    = context.getBean(AgentHandler.class);
34
    AgentHandler       agentHandler    = context.getBean(AgentHandler.class);
34
 
35
 
35
    public List<Ticket> getTickets(long customerId) throws TException {
36
    public List<Ticket> getTickets(long customerId) throws TException {
Line 61... Line 62...
61
        }
62
        }
62
    }
63
    }
63
 
64
 
64
    public List<Activity> getActivities(long customerId) throws TException {
65
    public List<Activity> getActivities(long customerId) throws TException {
65
        List<Activity> tactivities = new ArrayList<Activity>();
66
        List<Activity> tactivities = new ArrayList<Activity>();
66
        for (in.shop2020.crm.domain.Activity ticket : activityHandler
67
        List<in.shop2020.crm.domain.Activity> activities = activityHandler
67
                .getActivities(customerId)) {
68
                .getActivities(customerId);
-
 
69
        if (activities != null) {
-
 
70
            for (in.shop2020.crm.domain.Activity ticket : activities) {
68
            tactivities.add(ticket.getThriftActivity());
71
                tactivities.add(ticket.getThriftActivity());
-
 
72
            }
69
        }
73
        }
70
        return tactivities;
74
        return tactivities;
71
    }
75
    }
72
 
76
 
73
    public void insertActivity(Activity activity) throws TException {
77
    public void insertActivity(Activity activity) throws TException {
Line 78... Line 82...
78
            throw new TException("Could not insert " + activity, e);
82
            throw new TException("Could not insert " + activity, e);
79
        }
83
        }
80
    }
84
    }
81
 
85
 
82
    public Ticket getTicket(long ticketId) throws TException {
86
    public Ticket getTicket(long ticketId) throws TException {
-
 
87
        Ticket thriftTicket = null;
-
 
88
 
-
 
89
        in.shop2020.crm.domain.Ticket ticket = ticketHandler
-
 
90
                .getTicket(ticketId);
-
 
91
 
-
 
92
        if (ticket != null) {
83
        return ticketHandler.getTicket(ticketId).getThriftTicket();
93
            thriftTicket = ticket.getThriftTicket();
-
 
94
        }
-
 
95
 
-
 
96
        return thriftTicket;
84
    }
97
    }
85
 
98
 
86
    public Activity getActivity(long activityId) throws TException {
99
    public Activity getActivity(long activityId) throws TException {
-
 
100
        in.shop2020.crm.domain.Activity activity = activityHandler
-
 
101
                .getActivity(activityId);
-
 
102
        Activity thriftActivity = null;
-
 
103
 
-
 
104
        if (activity != null) {
87
        return activityHandler.getActivity(activityId).getThriftActivity();
105
            thriftActivity = activity.getThriftActivity();
-
 
106
        }
-
 
107
 
-
 
108
        return thriftActivity;
88
    }
109
    }
89
 
110
 
90
    public Activity getLastActivity(long ticketId) throws TException {
111
    public Activity getLastActivity(long ticketId) throws TException {
91
        in.shop2020.crm.domain.Activity lastActivity = activityHandler
112
        in.shop2020.crm.domain.Activity lastActivity = activityHandler
92
                .getLastActivity(ticketId);
113
                .getLastActivity(ticketId);
Line 110... Line 131...
110
 
131
 
111
        return tactivities;
132
        return tactivities;
112
    }
133
    }
113
 
134
 
114
    public Agent getAgent(long agentId) throws TException {
135
    public Agent getAgent(long agentId) throws TException {
-
 
136
        in.shop2020.crm.domain.Agent agent = agentHandler.getAgent(agentId);
-
 
137
        Agent thriftAgent = null;
-
 
138
 
-
 
139
        if (agent != null) {
115
        return agentHandler.getAgent(agentId).getThriftAgent();
140
            thriftAgent = agent.getThriftAgent();
-
 
141
        }
-
 
142
 
-
 
143
        return thriftAgent;
116
    }
144
    }
117
 
145
 
118
    public Agent getAgentByEmailId(String agentEmailId) throws TException {
146
    public Agent getAgentByEmailId(String agentEmailId) throws TException {
-
 
147
        in.shop2020.crm.domain.Agent agentByEmail = agentHandler.getAgentByEmail(agentEmailId);
-
 
148
        Agent thriftAgent = null;
-
 
149
 
-
 
150
        if (agentByEmail != null) {
119
        return agentHandler.getAgentByEmail(agentEmailId).getThriftAgent();
151
            thriftAgent = agentByEmail.getThriftAgent();
-
 
152
        }
-
 
153
 
-
 
154
        return thriftAgent;
120
    }
155
    }
121
 
156
 
122
    public List<String> getRoleNamesForAgent(String agentEmailId)
157
    public List<String> getRoleNamesForAgent(String agentEmailId)
123
            throws TException
158
            throws TException {
124
    {
-
 
125
        return agentHandler.getRoleNamesForAgent(agentEmailId);
159
        return agentHandler.getRoleNamesForAgent(agentEmailId);
126
    }
160
    }
127
 
161
 
128
    public List<String> getPermissionsForRoleName(String roleName)
162
    public List<String> getPermissionsForRoleName(String roleName)
129
            throws TException
163
            throws TException {
130
    {
-
 
131
        return agentHandler.getPermissionsForRoleName(roleName);
164
        return agentHandler.getPermissionsForRoleName(roleName);
132
    }
165
    }
133
 
166
 
134
    public List<Ticket> getAssignedTickets(long agentId) throws TException {
167
    public List<Ticket> getAssignedTickets(long agentId) throws TException {
135
        List<Ticket> tickets = new ArrayList<Ticket>();
168
        List<Ticket> tickets = new ArrayList<Ticket>();
136
 
169
 
137
        for (in.shop2020.crm.domain.Ticket ticket : ticketHandler.getAssignedTickets(agentId)) {
170
        for (in.shop2020.crm.domain.Ticket ticket : ticketHandler
-
 
171
                .getAssignedTickets(agentId)) {
138
            tickets.add(ticket.getThriftTicket());
172
            tickets.add(ticket.getThriftTicket());
139
        }
173
        }
140
 
174
 
141
        return tickets;
175
        return tickets;
142
    }
176
    }
Line 150... Line 184...
150
 
184
 
151
        return agents;
185
        return agents;
152
    }
186
    }
153
 
187
 
154
    public void updatePasswordForAgent(String agentEmailId, String password)
188
    public void updatePasswordForAgent(String agentEmailId, String password)
155
            throws TException
189
            throws TException {
156
    {
-
 
157
        agentHandler.updatePasswordForAgent(agentEmailId, password);
190
        agentHandler.updatePasswordForAgent(agentEmailId, password);
158
    }
191
    }
159
 
192
 
160
    public List<Ticket> getUnassignedTickets() throws TException {
193
    public List<Ticket> getUnassignedTickets() throws TException {
161
        List<Ticket> tickets = new ArrayList<Ticket>();
194
        List<Ticket> tickets = new ArrayList<Ticket>();
162
 
195
 
163
        for (in.shop2020.crm.domain.Ticket ticket : ticketHandler.getUnassignedTickets()) {
196
        for (in.shop2020.crm.domain.Ticket ticket : ticketHandler
-
 
197
                .getUnassignedTickets()) {
164
            tickets.add(ticket.getThriftTicket());
198
            tickets.add(ticket.getThriftTicket());
165
        }
199
        }
166
 
200
 
167
        return tickets;
201
        return tickets;
168
    }
202
    }
169
 
203
 
170
    public List<Ticket> getAllTickets(long agentId) throws TException {
204
    public List<Ticket> getAllTickets(long agentId) throws TException {
171
        List<in.shop2020.crm.domain.Ticket> tickets = ticketHandler.getAssignedTickets(agentId);
205
        List<in.shop2020.crm.domain.Ticket> tickets = ticketHandler
-
 
206
                .getAssignedTickets(agentId);
172
 
207
 
173
        for (in.shop2020.crm.domain.Agent agent : agentHandler.getReportees(agentId)) {
208
        for (in.shop2020.crm.domain.Agent agent : agentHandler
-
 
209
                .getReportees(agentId)) {
174
            tickets.addAll(ticketHandler.getAssignedTickets(agent.getId()));
210
            tickets.addAll(ticketHandler.getAssignedTickets(agent.getId()));
175
        }
211
        }
176
 
212
 
177
        List<Ticket> ttickets = new ArrayList<Ticket>();
213
        List<Ticket> ttickets = new ArrayList<Ticket>();
178
 
214