// This function will get the advisor details from the database depending upon the username // entered by the advisor in the forgot password form public AdvisorProfileDTO getForgotPasswordDetails(String userName, String register) { logger.info("Entered getForgotPasswordDetails method of ForgotPasswordDAO"); PreparedStatement pstmt; ResultSet results = null; String query = ""; AdvisorProfileDTO profile = new AdvisorProfileDTO(); Boolean flag = true; try { conn = ConnectionFactory.getConnection(); conn.setAutoCommit(false); if (register.equals("true")) { query = "SELECT ADVISOR_ID,EMAIL FROM advisordetails WHERE EMAIL = ?"; } else { query = "SELECT ADVISOR_ID,EMAIL FROM advisordetails WHERE EMAIL = ? AND ISACTIVE= ?"; } pstmt = conn.prepareStatement(query); pstmt.setString(1, userName); if (!register.equals("true")) { pstmt.setBoolean(2, flag); } results = pstmt.executeQuery(); if (results.first()) { profile.setAdvisorId(results.getInt("ADVISOR_ID")); profile.setEmail(results.getString("EMAIL")); } logger.info("Entered getForgotPasswordDetails method of ForgotPasswordDAO"); } catch (SQLException e) { logger.error( "getForgotPasswordDetails method of ForgotPasswordDAO threw error:" + e.getMessage()); e.printStackTrace(); } catch (IOException e) { logger.error( "getForgotPasswordDetails method of ForgotPasswordDAO threw error:" + e.getMessage()); e.printStackTrace(); } catch (PropertyVetoException e) { logger.error( "getForgotPasswordDetails method of ForgotPasswordDAO threw error:" + e.getMessage()); e.printStackTrace(); } finally { try { conn.close(); } catch (SQLException e) { logger.error( "getForgotPasswordDetails method of ForgotPasswordDAO threw error:" + e.getMessage()); e.printStackTrace(); } } return profile; }
/** @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) */ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { logger.info("Entered doGet method of AdvisorMyAccountPreviousSessionViewDetailController"); logger.info("Entered doGet method of AdvisorMyAccountPreviousSessionViewDetailController"); int advisorId = 0; String username = ""; int userId = 0; String rId = ""; String advisorName = ""; String picture = ""; String relImage = ""; String userName = ""; String mode = ""; int sId = 0; FeedbackDTO feeds = new FeedbackDTO(); Boolean isFeedback = false; Timestamp acceptedDate = null; try { advisorId = (int) request.getSession().getAttribute("advisorId"); username = (String) request.getSession().getAttribute("username"); rId = (String) request.getParameter("rId"); } catch (Exception e) { response.sendRedirect("Error"); } List<SessionDTO> list = new ArrayList<SessionDTO>(); if (username != null && advisorId != 0 && !("").equals(username)) { List<UserDetailsDTO> list2 = new ArrayList<UserDetailsDTO>(); List<UserRequestDTO> list1 = new ArrayList<UserRequestDTO>(); List<AdvisorProfileDTO> list3 = new ArrayList<AdvisorProfileDTO>(); // Getting the session details AdvisorMyAccountSessionDAO session = new AdvisorMyAccountSessionDAO(); list = session.getSessionDetails(rId); for (SessionDTO SessionDTO : list) { sId = SessionDTO.getSessionId(); userId = SessionDTO.getUserId(); acceptedDate = SessionDTO.getAcceptedDate(); SessionDTO.setAcceptedDateString( new SimpleDateFormat("dd-MMM-yyyy' 'h:mm a") .format(new Date(SessionDTO.getAcceptedDate().getTime()))); } MyAccountRequestDAO name = new MyAccountRequestDAO(); list3 = name.getAdvisorName(advisorId); for (AdvisorProfileDTO advisorProfileDTO : list3) { advisorName = advisorProfileDTO.getName(); } MyAccountRequestDAO image = new MyAccountRequestDAO(); list2 = image.getUserImage(userId); for (UserDetailsDTO userDetailsDTO : list2) { userName = userDetailsDTO.getFullName(); picture = userDetailsDTO.getImage(); } if (!("").equals(picture)) { GetRelativeImageURL image1 = new GetRelativeImageURL(); relImage = image1.getImageURL(picture); } List<TimeDTO> difference = new ArrayList<TimeDTO>(); // After retrieving the user details, get the user request details MyAccountRequestDAO dao = new MyAccountRequestDAO(); list1 = dao.getUserRequestDetails(rId); GetTimeLeftForReply time = new GetTimeLeftForReply(); difference = time.getTimeLeftForSession(acceptedDate); for (UserRequestDTO userRequestDTO : list1) { mode = userRequestDTO.getMode(); if (userRequestDTO.getService().equals("cvcritique") || userRequestDTO.getService().equals("mockinterview")) { isFeedback = true; } if (difference.size() > 0) { for (TimeDTO timeDTO : difference) { userRequestDTO.setDays(timeDTO.getDay()); userRequestDTO.setHours(timeDTO.getHours()); userRequestDTO.setMinutes(timeDTO.getMinutes()); } } else { userRequestDTO.setDays(0); userRequestDTO.setHours(0); userRequestDTO.setMinutes(0); } } String sessionDate = ""; String date = ""; String time1 = ""; if (acceptedDate != null) { sessionDate = acceptedDate.toString(); Timestamp timestamp = new Timestamp(acceptedDate.getTime()); SimpleDateFormat simpleDateFormat = new SimpleDateFormat("dd-MMM-yyyy"); SimpleDateFormat simpleDateFormat1 = new SimpleDateFormat("h:mm a"); date = simpleDateFormat.format(timestamp); if (mode.equals("email")) { time1 = "N/A"; } else { time1 = simpleDateFormat1.format(timestamp); } } else { date = "NOT FIXED"; time1 = "NOT FIXED"; } // Check if the user has given any feedback SessionFeedBackDTO feedUser = new SessionFeedBackDTO(); SessionFeedBackDTO feedAdvisor = new SessionFeedBackDTO(); // Check if the user has given any feedback SessionFeedBackDAO feedback = new SessionFeedBackDAO(); feedUser = feedback.GetUserFeedBackDetailsForUser(sId); SessionFeedBackDAO feedbackAdvisor = new SessionFeedBackDAO(); feedAdvisor = feedbackAdvisor.GetAdvisorFeedbackDetailsForAdvisor(sId); if (isFeedback) { // Getting the FeedBack Form Path MyAccountRequestDAO form = new MyAccountRequestDAO(); feeds = form.GetFeedbackPath(sId); } // Check if the user has sent any mail SessionFeedBackDTO emailUser = new SessionFeedBackDTO(); SessionFeedBackDTO emailAdvisor = new SessionFeedBackDTO(); SessionFeedBackDAO mail = new SessionFeedBackDAO(); emailUser = mail.GetUserMailForAdvisor(sId); SessionFeedBackDAO mailAdvisor = new SessionFeedBackDAO(); emailAdvisor = mailAdvisor.GetAdvisorMailForAdvisor(sId); // Update Advisor's Notification String url = request.getRequestURI() + "?" + request.getQueryString(); url = url.substring(url.lastIndexOf('/') + 1); AdvisorNotificationDAO admin = new AdvisorNotificationDAO(); admin.SetNotificationRead(url, advisorId); if (list.size() > 0 && list1.size() > 0 && list2.size() > 0) { request.setAttribute("advisorname", advisorName); request.setAttribute("userName", userName); request.setAttribute("image", relImage); request.setAttribute("sessions", list); request.setAttribute("time", time1); request.setAttribute("date", date); request.setAttribute("feedUser", feedUser); request.setAttribute("feedAdvisor", feedAdvisor); request.setAttribute("emailUser", emailUser); request.setAttribute("emailAdvisor", emailAdvisor); request.setAttribute("isFromPreviousSession", true); request.setAttribute("requests", list1); request.setAttribute("userdetails", list2); request.setAttribute("sessionDate", sessionDate); request.setAttribute("feed", feeds); RequestDispatcher rd = getServletContext().getRequestDispatcher("/Session_ViewDetails.jsp"); rd.forward(request, response); } } logger.info("Exit doGet method of AdvisorMyAccountPreviousSessionViewDetailController"); }