diff --git a/src/main/java/nl/andrewlalis/Main.java b/src/main/java/nl/andrewlalis/Main.java index a1c4d51..ad2a75b 100644 --- a/src/main/java/nl/andrewlalis/Main.java +++ b/src/main/java/nl/andrewlalis/Main.java @@ -1,12 +1,11 @@ package nl.andrewlalis; import nl.andrewlalis.model.Organization; -import nl.andrewlalis.model.database.Database; import nl.andrewlalis.ui.control.command.CommandExecutor; import nl.andrewlalis.ui.control.command.executables.ArchiveRepos; import nl.andrewlalis.ui.control.command.executables.DefineTaTeams; import nl.andrewlalis.ui.control.command.executables.GenerateAssignmentsRepo; -import nl.andrewlalis.ui.control.command.executables.ReadStudentsFileToDB; +import nl.andrewlalis.ui.control.command.executables.ReadStudentsFile; import nl.andrewlalis.ui.view.InitializerApp; import nl.andrewlalis.util.CommandLine; import nl.andrewlalis.util.Logging; @@ -40,16 +39,12 @@ public class Main { app.begin(); app.setAccessToken(userOptions.get("token")); - Database db = new Database("database/initializer.sqlite"); - - - executor.registerCommand("read_students", new ReadStudentsFileToDB(db)); + // Initialize executable commands. + executor.registerCommand("read_students", new ReadStudentsFile(organization)); executor.registerCommand("archive_all", new ArchiveRepos()); executor.registerCommand("generate_assignments", new GenerateAssignmentsRepo()); executor.registerCommand("define_ta_teams", new DefineTaTeams(app)); - db.initialize(); - logger.info("GithubManager for Github Repositories in Educational Organizations. Program initialized."); } diff --git a/src/main/java/nl/andrewlalis/ui/control/command/executables/ReadStudentsFileToDB.java b/src/main/java/nl/andrewlalis/ui/control/command/executables/ReadStudentsFile.java similarity index 65% rename from src/main/java/nl/andrewlalis/ui/control/command/executables/ReadStudentsFileToDB.java rename to src/main/java/nl/andrewlalis/ui/control/command/executables/ReadStudentsFile.java index 664f7bd..f275885 100644 --- a/src/main/java/nl/andrewlalis/ui/control/command/executables/ReadStudentsFileToDB.java +++ b/src/main/java/nl/andrewlalis/ui/control/command/executables/ReadStudentsFile.java @@ -1,7 +1,7 @@ package nl.andrewlalis.ui.control.command.executables; +import nl.andrewlalis.model.Organization; import nl.andrewlalis.model.StudentTeam; -import nl.andrewlalis.model.database.Database; import nl.andrewlalis.ui.control.command.Executable; import nl.andrewlalis.util.FileUtils; @@ -9,24 +9,23 @@ import java.util.List; /** * Execute this class to read students from a supplied filename and teamsize, and store their - * information in the database. + * information in the application's organization model. * Requires the following arguments: * * 1. filename * 2. teamsize */ -public class ReadStudentsFileToDB implements Executable { +public class ReadStudentsFile implements Executable { /** - * The database used to store the students. + * A reference to the application's organization model. */ - private Database db; + private Organization organization; - public ReadStudentsFileToDB(Database db) { - this.db = db; + public ReadStudentsFile(Organization organization) { + this.organization = organization; } - @Override public boolean execute(String[] args) { if (args.length < 2) { @@ -38,6 +37,7 @@ public class ReadStudentsFileToDB implements Executable { if (teams == null) { return false; } - return this.db.storeStudentTeams(teams); + this.organization.setStudentTeams(teams); + return true; } }