Use absolute path in CSV reader now.

This commit is contained in:
Andrew Lalis 2018-09-08 16:50:18 +02:00
parent f39f5da407
commit b54b1fe32d
5 changed files with 23 additions and 2 deletions

View File

@ -44,6 +44,7 @@ public class Main {
executor.registerCommand("list_errors", new ListErrors());
executor.registerCommand("delete_repos", new DeleteRepos());
executor.registerCommand("delegate_student_teams", new DelegateStudentTeams(app));
executor.registerCommand("setup_student_repos", new SetupStudentRepos());
logger.info("GithubManager for Github Repositories in Educational Organizations.\n" +
"© Andrew Lalis (2018), All rights reserved.\n" +

View File

@ -1,13 +1,23 @@
package nl.andrewlalis.model;
import nl.andrewlalis.model.error.Error;
import nl.andrewlalis.model.error.Severity;
import nl.andrewlalis.ui.view.InitializerApp;
import java.util.List;
import java.util.Map;
import java.util.logging.Logger;
/**
* Represents one student's github information.
*/
public class Student extends Person {
private static final Logger logger = Logger.getLogger(Student.class.getName());
static {
logger.setParent(Logger.getGlobal());
}
/**
* A list of partners that the student has said that they would like to be partners with.
*/
@ -39,8 +49,13 @@ public class Student extends Person {
public StudentTeam getPreferredTeam(Map<Integer, Student> studentMap) {
StudentTeam t = new StudentTeam();
for (int partnerNumber : this.getPreferredPartners()) {
if (!studentMap.containsKey(partnerNumber)) {
InitializerApp.organization.addError(new Error(Severity.MEDIUM, "Student " + this.getNumber() + " has non-existent preferred partner with id: " + partnerNumber));
logger.warning("Student has non-existent partner id: " + partnerNumber + '\n' + this);
} else {
t.addMember(studentMap.get(partnerNumber));
}
}
t.addMember(this);
return t;
}

View File

@ -44,7 +44,7 @@ public class ReadStudentsFileListener extends ExecutableListener {
String teamSizeString = JOptionPane.showInputDialog(this.app, "Enter the student team size.", "Team Size", JOptionPane.QUESTION_MESSAGE);
if (teamSizeString != null) {
this.executor.executeCommand("read_students", new String[]{
chooser.getSelectedFile().getName(),
chooser.getSelectedFile().getAbsolutePath(),
teamSizeString
});
}

View File

@ -54,6 +54,7 @@ public class FileUtils {
return studentTeams;
} catch (IOException | ArrayIndexOutOfBoundsException e) {
logger.severe("Unable to generate studentTeams from CSV file, exiting. " + e.getMessage());
e.printStackTrace();
return null;
}
}

View File

@ -155,6 +155,10 @@ public class TeamGenerator {
}
}
Student s = new Student(Integer.parseInt(record.get(3)), record.get(2), record.get(1), record.get(4), preferredIds);
if (studentMap.containsValue(s)) {
InitializerApp.organization.addError(new Error(Severity.HIGH, "Duplicate entries for student:\n" + s + "\nSince records are in chronological order, this more recent duplicate will override the previous value."));
logger.warning("Duplicate entry found for student: " + s + "\nOverwriting previous value.");
}
studentMap.put(s.getNumber(), s);
}
logger.fine("Read " + studentMap.size() + " students from records.");