Use absolute path in CSV reader now.
This commit is contained in:
parent
f39f5da407
commit
b54b1fe32d
|
@ -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" +
|
||||
|
|
|
@ -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,7 +49,12 @@ public class Student extends Person {
|
|||
public StudentTeam getPreferredTeam(Map<Integer, Student> studentMap) {
|
||||
StudentTeam t = new StudentTeam();
|
||||
for (int partnerNumber : this.getPreferredPartners()) {
|
||||
t.addMember(studentMap.get(partnerNumber));
|
||||
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;
|
||||
|
|
|
@ -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
|
||||
});
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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.");
|
||||
|
|
Loading…
Reference in New Issue