1 package com.instantbank.collections.creditInfo.web;
2
3 import java.io.IOException;
4 import java.io.PrintWriter;
5 import javax.servlet.RequestDispatcher;
6 import javax.servlet.ServletConfig;
7 import javax.servlet.ServletContext;
8 import javax.servlet.ServletException;
9 import javax.servlet.http.HttpServlet;
10 import javax.servlet.http.HttpServletRequest;
11 import javax.servlet.http.HttpServletResponse;
12 import javax.servlet.http.HttpSession;
13 import com.instantbank.collections.creditInfo.ejb.AccountInfoServices;
14 import com.instantbank.collections.creditInfo.ejb.AccountInfoServicesHome;
15 import com.instantbank.collections.util.FilterChain;
16 import com.instantbank.collections.util.InstantbankException;
17 import com.instantbank.collections.util.ServiceLocator;
18
19 public class StatusTabController extends HttpServlet {
20 AccountInfoServices accountInfoServices;
21 AccountInfoServicesHome ahome;
22 PrintWriter out;
23 HttpSession session;
24
25
26 public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
27 this.doPost(request, response);
28 }
29
30
31 public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
32 String action = "";
33 com.instantbank.collections.util.FilterChain chain;
34
35 try {
36 action = request.getParameter("action");
37 session = request.getSession(false);
38 try {
39
40 chain = new com.instantbank.collections.util.FilterChain(true, getServletConfig().getServletContext());
41 if(chain.processFilter(request, response)) {
42 return;
43 }
44 if(action.equals("initialize")) {
45 initialize(request, response);
46 }
47 else if(action.equals("save")) {
48 save(request, response);
49 }
50 else {
51 throw new InstantbankException("242001", "Action " + action + " not supported");
52 }
53 }
54 catch(Exception e) {
55 throw new InstantbankException(e, "242002", "Failed to execute controller action " + action);
56 }
57 }
58 catch(InstantbankException e) {
59 session.setAttribute("Exception", e);
60 response.sendRedirect("../main_web/ControllerError.jsp?showTechnical=0");
61 }
62 }
63
64
65 public String getServletInfo() {
66 return "com.instantbank.collections.creditInfo.web.StatusTabController Information";
67 }
68
69
70 public void init(ServletConfig config) throws ServletException {
71 try {
72 super.init(config);
73 ahome = (AccountInfoServicesHome)ServiceLocator.instance().createEJB("AccountInfoServicesHome", AccountInfoServicesHome.class, false);
74 accountInfoServices = ahome.create();
75 }
76 catch(Exception e) {
77 }
78 }
79
80
81 private void initialize(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException, InstantbankException {
82 Long agrmCode;
83 Long agrmId;
84 String customers;
85 Long companyId;
86 ServletContext sctx = getServletConfig().getServletContext();
87
88 agrmId = (Long)request.getAttribute("agrmId");
89 companyId = (Long)session.getAttribute("companyId");
90 customers = accountInfoServices.getStatusValues(companyId, agrmId);
91 request.setAttribute("data", customers);
92 request.setAttribute("parentController", request.getAttribute("parentController"));
93 RequestDispatcher rd = sctx.getRequestDispatcher("/creditInfo_web/AccountStatusView.jsp");
94 rd.forward(request, response);
95 }
96
97
98 private void save(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException, InstantbankException {
99
100 Long agrmCode;
101 Long agrmId;
102 String sagrmid;
103 Long Lagrmid;
104 Long companyId;
105 String data;
106 String parentController;
107 String mainData;
108 Long userId;
109 ServletContext sctx = getServletConfig().getServletContext();
110 String wrkiId;
111 String oldStatusValues;
112
113 sagrmid = request.getParameter("agrmid");
114 Lagrmid = Long.valueOf(sagrmid);
115 data = request.getParameter("data");
116 parentController = request.getParameter("parentController");
117 companyId = (Long)session.getAttribute("companyId");
118 userId = (Long)session.getAttribute("userId");
119 oldStatusValues = accountInfoServices.getStatusValues(companyId, Lagrmid);
120 agrmId = accountInfoServices.saveStatusValues(data, companyId, userId, oldStatusValues);
121 mainData = request.getParameter("mainData");
122 wrkiId = request.getParameter("wrki_id");
123 response.sendRedirect("/Instantbank/collectionsActivities_web/ReviewAccountController?action=changeTab&mainData=" + mainData + "&tab=Status&agrmId=" + agrmId + "&wrki_id=" + wrkiId);
124 }
125 }
126
127