Adding retrieval methods.
This commit is contained in:
parent
8c8ddb60cf
commit
0233221c8d
|
@ -87,7 +87,7 @@ public class GithubManager {
|
|||
* @param allTeachingAssistants A team consisting of all teaching assistants.
|
||||
* @throws IOException If an HTTP request failed.
|
||||
*/
|
||||
private void setupAssignmentsRepo(String assignmentsRepoName, String description, TATeam allTeachingAssistants) throws IOException {
|
||||
public void setupAssignmentsRepo(String assignmentsRepoName, String description, TATeam allTeachingAssistants) throws IOException {
|
||||
// Check if the repository already exists.
|
||||
GHRepository existingRepo = this.organization.getRepository(assignmentsRepoName);
|
||||
if (existingRepo != null) {
|
||||
|
@ -128,7 +128,7 @@ public class GithubManager {
|
|||
* @param prefix The prefix to append to the front of the repo name.
|
||||
* @throws IOException If an HTTP request fails.
|
||||
*/
|
||||
private void setupStudentTeam(StudentTeam team, TATeam taTeam, String prefix) throws IOException {
|
||||
public void setupStudentTeam(StudentTeam team, TATeam taTeam, String prefix) throws IOException {
|
||||
// First check that the assignments repo exists, otherwise no invitations can be sent.
|
||||
if (this.assignmentsRepo == null) {
|
||||
logger.warning("Assignments repository must be created before student repositories.");
|
||||
|
@ -219,6 +219,7 @@ public class GithubManager {
|
|||
protectionBuilder.enable();
|
||||
logger.fine("Protected master branch of repository: " + repo.getName());
|
||||
} catch (IOException e) {
|
||||
logger.severe("Could not protect master branch of repository: " + repo.getName());
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,10 +2,7 @@ package nl.andrewlalis.model.database;
|
|||
|
||||
import nl.andrewlalis.model.*;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.*;
|
||||
import java.util.List;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
|
@ -60,7 +57,7 @@ public class Database {
|
|||
try {
|
||||
statement.execute();
|
||||
} catch (SQLException e) {
|
||||
logger.severe("SQLException while executing prepared statement: " + statement.toString() + ". Code: " + e.getErrorCode());
|
||||
logger.severe("SQLException while executing prepared statement:\n" + statement.toString() + "\nCode: " + e.getErrorCode());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -70,7 +67,7 @@ public class Database {
|
|||
try {
|
||||
statement.execute();
|
||||
} catch (SQLException e) {
|
||||
logger.severe("SQLException while inserting into table: " + statement.toString() + ". Code: " + e.getErrorCode());
|
||||
logger.severe("SQLException while inserting into table:\n" + statement.toString() + "\nCode: " + e.getErrorCode());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -102,6 +99,25 @@ public class Database {
|
|||
}
|
||||
}
|
||||
|
||||
private Student retrieveStudent(int id) {
|
||||
|
||||
}
|
||||
|
||||
private Person retrievePerson(int id) {
|
||||
try {
|
||||
logger.finest("Retrieving person (id=" + id + ").");
|
||||
String sql = "SELECT * FROM persons WHERE id=?";
|
||||
PreparedStatement stmt = this.connection.prepareStatement(sql);
|
||||
stmt.setInt(1, id);
|
||||
ResultSet result = stmt.executeQuery();
|
||||
Person p = new Person(id, result.getString("name"), result.getString("email_address"), result.getString("github_username"));
|
||||
} catch (SQLException e) {
|
||||
logger.severe("SQL Exception while retrieving Person.\n" + e.getMessage());
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Stores a teaching assistant without a team.
|
||||
* @param ta The teaching assistant to store.
|
||||
|
@ -129,6 +145,7 @@ public class Database {
|
|||
stmt.execute();
|
||||
return true;
|
||||
} catch (SQLException e) {
|
||||
logger.severe("SQL Exception while inserting TeachingAssistant.\n" + e.getMessage());
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
|
@ -202,6 +219,7 @@ public class Database {
|
|||
stmt.execute();
|
||||
return true;
|
||||
} catch (SQLException e) {
|
||||
logger.severe("SQL Exception while inserting Student into database.\n" + e.getMessage());
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
package nl.andrewlalis.ui.control.command.executables;
|
||||
|
||||
import nl.andrewlalis.git_api.GithubManager;
|
||||
|
||||
/**
|
||||
* Generates the assignments repository, with the supplied github manager, as well as the following extra arguments:
|
||||
*/
|
||||
public class GenerateAssignmentsRepo extends GithubExecutable {
|
||||
|
||||
@Override
|
||||
protected boolean executeWithManager(GithubManager manager, String[] args) {
|
||||
|
||||
manager.setupAssignmentsRepo(args[0], args[1], );
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
package nl.andrewlalis.ui.control.command.executables;
|
||||
|
||||
import nl.andrewlalis.git_api.GithubManager;
|
||||
|
||||
public class GenerateStudentRepos extends GithubExecutable {
|
||||
|
||||
@Override
|
||||
protected boolean executeWithManager(GithubManager manager, String[] args) {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
|
@ -37,7 +37,6 @@ public class InitializerApp extends JFrame {
|
|||
private JTextField assignmentsRepoField = new JTextField();
|
||||
private JTextField teachingAssistantsField = new JTextField();
|
||||
private JTextField studentRepoField = new JTextField();
|
||||
private JTextField teamSizeField = new JTextField();
|
||||
|
||||
/**
|
||||
* The executor responsible for performing meaningful actions.
|
||||
|
|
Loading…
Reference in New Issue