public void changeStudent() { try { pmap.clear(); sessions.clear(); day = null; hour = null; if (command == 0) { childList.clear(); selectedChild = -1; cdetail = null; searched = false; } sdetail = studentdao.findByID(selectedStudent); smap = savaildao.findByID(selectedStudent); skeys.clear(); for (Map.Entry<String, List<String>> entry : smap.entrySet()) { skeys.add(entry.getKey()); } // get the number of pairs for this student pairsCount = getPairsCount(selectedStudent); if (pairsCount > 0) { Student student = new Student(); student.setStudentID(selectedStudent); for (Session pairing : padao.findByStudent(student)) sessions.add(pairing); for (Session pending : pedao.findByStudent(student)) sessions.add(pending); } // now populate days and hours in common if child is also selected if (selectedChild != -1) this.findDaysAndHours(); } catch (SQLException ex) { Logger.getLogger(AdminPairing.class.getName()).log(Level.SEVERE, null, ex); } }
public void sendConfirmation(Student pairedStudent, Child pairedChild) { String to = pairedStudent.getEmail() + "," + pairedChild.getEmail(); String subject = "Partners In Reading - You have been paired!"; String body = "<html>" + "<body><center>" + "<h3>Pairing Information</h3>" + "<p>Don't forget to contact each other for information</p>" + "<p>Student's Name: " + pairedStudent.getFirstname() + " " + pairedStudent.getLastname() + "<br/>" + "Student's email: " + pairedStudent.getEmail() + "<br/>" + "Student's cellphone: " + pairedStudent.getCellphone() + "<br/>" + "<br/>" + "Child's Name: " + pairedChild.getFirstname() + " " + pairedChild.getLastname() + "<br/>" + "Child's Parent's Name: " + pairedChild.getParent_one() + "<br/>" + "Child's email: " + pairedChild.getEmail() + "<br/>" + "Child's cellphone: " + pairedChild.getCellphone() + "<br/>" + "Child's homephone: " + pairedChild.getHomephone() + "</p>" + "Here is your session time:" + "<br/>" + "Day: " + day + "<br/>" + "Time: " + hour + "<br/>" + "Thanks for participating!<br/>" + "The Partners In Reading Team" + "</center></body>" + "</html>"; MailSender email = new MailSender(to, subject, body); email.send(); }
private void findStudents() { studentList.clear(); try (Connection con = ds.getConnection()) { // Child child = childdao.findByID(selectedChild); Map<String, List<String>> map = cavaildao.findByID(selectedChild); String sql; if (filters.contains("spec") && filters.contains("lang")) { sql = findSpecLangStudentsSQL(); } else if (filters.contains("spec")) { sql = findSpecStudentsSQL(); } else if (filters.contains("lang")) { sql = findLangStudentsSQL(); } else { sql = findStudentsSQL(); } try (PreparedStatement find = con.prepareStatement(sql)) { // Map<String, List<String>> map = child.getDaymap(); for (Map.Entry<String, List<String>> entry : map.entrySet()) { find.setString(1, entry.getKey()); List<String> list = entry.getValue(); // loop through the list for (int i = 0; i < list.size(); i++) { find.setString(2, list.get(i)); try (ResultSet rs = find.executeQuery()) { while (rs.next()) { Student student = studentdao.findByID(rs.getLong("studentid")); // make sure it's not already a part of the list if (studentList.isEmpty()) { studentList.add(student); } else for (int j = 0; j < studentList.size(); j++) { if (studentList.get(j).getStudentID() == student.getStudentID()) break; if (j == studentList.size() - 1) { studentList.add(student); break; } } } } } } } } catch (SQLException ex) { Logger.getLogger(AdminPairing.class.getName()).log(Level.SEVERE, null, ex); } }