コード例 #1
0
 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);
   }
 }
コード例 #2
0
  public void changeChild() {
    try {
      pmap.clear();
      day = null;
      hour = null;

      if (command == 1) {
        studentList.clear();
        selectedStudent = -1;
        sdetail = null;
        searched = false;
      }
      cdetail = childdao.findByID(selectedChild);
      cmap = cavaildao.findByID(selectedChild);
      ckeys.clear();
      for (Map.Entry<String, List<String>> entry : cmap.entrySet()) {
        ckeys.add(entry.getKey());
      }
      if (selectedStudent != -1) this.findDaysAndHours();
    } catch (SQLException ex) {
      Logger.getLogger(AdminPairing.class.getName()).log(Level.SEVERE, null, ex);
    }
  }