Improvements and new version in development #5
			
				
			
		
		
		
	| 
						 | 
					@ -60,6 +60,7 @@ public class Main {
 | 
				
			||||||
    private static void initializeTestingData() {
 | 
					    private static void initializeTestingData() {
 | 
				
			||||||
        try {
 | 
					        try {
 | 
				
			||||||
            List<StudentTeam> teams = TeamGenerator.generateFromCSV("/home/andrew/Documents/School/ta/GithubInitializer/sampleAOOP.csv", 2);
 | 
					            List<StudentTeam> teams = TeamGenerator.generateFromCSV("/home/andrew/Documents/School/ta/GithubInitializer/sampleAOOP.csv", 2);
 | 
				
			||||||
 | 
					            System.out.println(teams);
 | 
				
			||||||
            DbHelper.saveStudentTeams(teams);
 | 
					            DbHelper.saveStudentTeams(teams);
 | 
				
			||||||
            managementView.updateModels();
 | 
					            managementView.updateModels();
 | 
				
			||||||
        } catch (IOException e) {
 | 
					        } catch (IOException e) {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,5 +1,7 @@
 | 
				
			||||||
package nl.andrewlalis.model;
 | 
					package nl.andrewlalis.model;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import nl.andrewlalis.util.Pair;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import javax.persistence.*;
 | 
					import javax.persistence.*;
 | 
				
			||||||
import java.util.ArrayList;
 | 
					import java.util.ArrayList;
 | 
				
			||||||
import java.util.List;
 | 
					import java.util.List;
 | 
				
			||||||
| 
						 | 
					@ -20,7 +22,7 @@ public class Student extends Person {
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * A list of partners that the student has said that they would like to be partners with.
 | 
					     * A list of partners that the student has said that they would like to be partners with.
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    @ManyToMany
 | 
					    @ManyToMany(fetch = FetchType.EAGER)
 | 
				
			||||||
    @JoinTable(
 | 
					    @JoinTable(
 | 
				
			||||||
            name = "student_preferred_partners",
 | 
					            name = "student_preferred_partners",
 | 
				
			||||||
            joinColumns = { @JoinColumn(name = "student_id")},
 | 
					            joinColumns = { @JoinColumn(name = "student_id")},
 | 
				
			||||||
| 
						 | 
					@ -95,4 +97,20 @@ public class Student extends Person {
 | 
				
			||||||
    public StudentTeam getAssignedTeam() {
 | 
					    public StudentTeam getAssignedTeam() {
 | 
				
			||||||
        return this.team;
 | 
					        return this.team;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public List<Pair<String, String>> getDetailPairs() {
 | 
				
			||||||
 | 
					        List<Pair<String, String>> pairs = super.getDetailPairs();
 | 
				
			||||||
 | 
					        String teamNumber = "None";
 | 
				
			||||||
 | 
					        if (this.getAssignedTeam() != null) {
 | 
				
			||||||
 | 
					            teamNumber = String.valueOf(this.getAssignedTeam().getNumber());
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        pairs.add(new Pair<>("Team Number", teamNumber));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        for (int i = 0; i < this.preferredPartners.size(); i++) {
 | 
				
			||||||
 | 
					            pairs.add(new Pair<>("Preferred partner " + (i + 1), this.preferredPartners.get(i).getDetailName()));
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        return pairs;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -54,7 +54,7 @@ public class StudentTeam extends Team {
 | 
				
			||||||
                // If the student doesn't have an preferred partners, then assume that this is valid.
 | 
					                // If the student doesn't have an preferred partners, then assume that this is valid.
 | 
				
			||||||
                if (!studentA.getPreferredPartners().isEmpty()) {
 | 
					                if (!studentA.getPreferredPartners().isEmpty()) {
 | 
				
			||||||
                    for (Student studentB : this.getStudents()) {
 | 
					                    for (Student studentB : this.getStudents()) {
 | 
				
			||||||
                        if (!studentA.equals(studentB) && !studentA.getPreferredPartners().contains(studentB.getNumber())) {
 | 
					                        if (!studentA.equals(studentB) && !studentA.getPreferredPartners().contains(studentB)) {
 | 
				
			||||||
                            return false;
 | 
					                            return false;
 | 
				
			||||||
                        }
 | 
					                        }
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -43,8 +43,11 @@ public class StudentTableModel extends AbstractTableModel {
 | 
				
			||||||
     * @return The student object at the specified row, or null if none is found.
 | 
					     * @return The student object at the specified row, or null if none is found.
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    public Student getStudentAt(int row) {
 | 
					    public Student getStudentAt(int row) {
 | 
				
			||||||
 | 
					        if (row >= 0 && row < this.studentsList.size()) {
 | 
				
			||||||
            return this.studentsList.get(row);
 | 
					            return this.studentsList.get(row);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					        return null;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public int getRowCount() {
 | 
					    public int getRowCount() {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,7 +1,10 @@
 | 
				
			||||||
package nl.andrewlalis.util;
 | 
					package nl.andrewlalis.util;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import java.io.IOException;
 | 
					import java.io.IOException;
 | 
				
			||||||
import java.util.logging.*;
 | 
					import java.util.logging.FileHandler;
 | 
				
			||||||
 | 
					import java.util.logging.Level;
 | 
				
			||||||
 | 
					import java.util.logging.Logger;
 | 
				
			||||||
 | 
					import java.util.logging.SimpleFormatter;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * Responsible for creating logs to standard output and writing to files.
 | 
					 * Responsible for creating logs to standard output and writing to files.
 | 
				
			||||||
| 
						 | 
					@ -25,7 +28,7 @@ public class Logging {
 | 
				
			||||||
            e.printStackTrace();
 | 
					            e.printStackTrace();
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        logger.setLevel(Level.ALL);
 | 
					        logger.setLevel(Level.FINEST);
 | 
				
			||||||
        Logger.getLogger("").setLevel(Level.OFF);
 | 
					        Logger.getLogger("").setLevel(Level.OFF);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -91,12 +91,14 @@ public class TeamGenerator {
 | 
				
			||||||
                for (StudentTeam team : studentTeams) {
 | 
					                for (StudentTeam team : studentTeams) {
 | 
				
			||||||
                    if (newTeam.hasSameMembers(team)) {
 | 
					                    if (newTeam.hasSameMembers(team)) {
 | 
				
			||||||
                        matchFound = true;
 | 
					                        matchFound = true;
 | 
				
			||||||
 | 
					                        logger.finest("A team was found with the same members: " + team.getId());
 | 
				
			||||||
                        break;
 | 
					                        break;
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
                if (!matchFound) {
 | 
					                if (!matchFound) {
 | 
				
			||||||
                    // Once we know this team is completely valid, we remove all the students in it from the list of singles.
 | 
					                    // Once we know this team is completely valid, we remove all the students in it from the list of singles.
 | 
				
			||||||
                    newTeam.setNumber(teamCount++);
 | 
					                    newTeam.setNumber(teamCount++);
 | 
				
			||||||
 | 
					                    studentTeams.add(newTeam);
 | 
				
			||||||
                    singleStudents.removeAll(Arrays.asList(newTeam.getStudents()));
 | 
					                    singleStudents.removeAll(Arrays.asList(newTeam.getStudents()));
 | 
				
			||||||
                    assignStudentsToTeam(newTeam);
 | 
					                    assignStudentsToTeam(newTeam);
 | 
				
			||||||
                    logger.fine("Created team:\n" + newTeam);
 | 
					                    logger.fine("Created team:\n" + newTeam);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue