private void findChildren() { childList.clear(); try (Connection con = ds.getConnection()) { // Student student = studentdao.findByID(selectedStudent); Map<String, List<String>> map = savaildao.findByID(selectedStudent); String sql = findChildrenSQL(); try (PreparedStatement find = con.prepareStatement(sql)) { // Map<String, List<String>> map = student.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()) { Child child = childdao.findByID(rs.getLong("childid")); // make sure it's not already a part of the list if (childList.isEmpty()) { childList.add(child); } else for (int j = 0; j < childList.size(); j++) { if (childList.get(j).getChildID() == child.getChildID()) break; if (j == childList.size() - 1) { childList.add(child); break; } } } } } } } } catch (SQLException ex) { Logger.getLogger(AdminPairing.class.getName()).log(Level.SEVERE, null, ex); System.err.println(ex.getMessage()); } }
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(); }