Adds more than just a TA dialog #4

Merged
andrewlalis merged 14 commits from ta_dialog into master 2018-09-08 15:39:30 +00:00
2 changed files with 12 additions and 17 deletions
Showing only changes of commit 6d7efbe97f - Show all commits

View File

@ -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.");
}

View File

@ -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;
}
}