Half of features implemented #2
			
				
			
		
		
		
	| 
						 | 
					@ -87,7 +87,7 @@ public class GithubManager {
 | 
				
			||||||
     * @param allTeachingAssistants A team consisting of all teaching assistants.
 | 
					     * @param allTeachingAssistants A team consisting of all teaching assistants.
 | 
				
			||||||
     * @throws IOException If an HTTP request failed.
 | 
					     * @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.
 | 
					        // Check if the repository already exists.
 | 
				
			||||||
        GHRepository existingRepo = this.organization.getRepository(assignmentsRepoName);
 | 
					        GHRepository existingRepo = this.organization.getRepository(assignmentsRepoName);
 | 
				
			||||||
        if (existingRepo != null) {
 | 
					        if (existingRepo != null) {
 | 
				
			||||||
| 
						 | 
					@ -128,7 +128,7 @@ public class GithubManager {
 | 
				
			||||||
     * @param prefix The prefix to append to the front of the repo name.
 | 
					     * @param prefix The prefix to append to the front of the repo name.
 | 
				
			||||||
     * @throws IOException If an HTTP request fails.
 | 
					     * @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.
 | 
					        // First check that the assignments repo exists, otherwise no invitations can be sent.
 | 
				
			||||||
        if (this.assignmentsRepo == null) {
 | 
					        if (this.assignmentsRepo == null) {
 | 
				
			||||||
            logger.warning("Assignments repository must be created before student repositories.");
 | 
					            logger.warning("Assignments repository must be created before student repositories.");
 | 
				
			||||||
| 
						 | 
					@ -219,6 +219,7 @@ public class GithubManager {
 | 
				
			||||||
            protectionBuilder.enable();
 | 
					            protectionBuilder.enable();
 | 
				
			||||||
            logger.fine("Protected master branch of repository: " + repo.getName());
 | 
					            logger.fine("Protected master branch of repository: " + repo.getName());
 | 
				
			||||||
        } catch (IOException e) {
 | 
					        } catch (IOException e) {
 | 
				
			||||||
 | 
					            logger.severe("Could not protect master branch of repository: " + repo.getName());
 | 
				
			||||||
            e.printStackTrace();
 | 
					            e.printStackTrace();
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -2,10 +2,7 @@ package nl.andrewlalis.model.database;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import nl.andrewlalis.model.*;
 | 
					import nl.andrewlalis.model.*;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import java.sql.Connection;
 | 
					import java.sql.*;
 | 
				
			||||||
import java.sql.DriverManager;
 | 
					 | 
				
			||||||
import java.sql.PreparedStatement;
 | 
					 | 
				
			||||||
import java.sql.SQLException;
 | 
					 | 
				
			||||||
import java.util.List;
 | 
					import java.util.List;
 | 
				
			||||||
import java.util.logging.Logger;
 | 
					import java.util.logging.Logger;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -60,7 +57,7 @@ public class Database {
 | 
				
			||||||
            try {
 | 
					            try {
 | 
				
			||||||
                statement.execute();
 | 
					                statement.execute();
 | 
				
			||||||
            } catch (SQLException e) {
 | 
					            } 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;
 | 
					                return false;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
| 
						 | 
					@ -70,7 +67,7 @@ public class Database {
 | 
				
			||||||
            try {
 | 
					            try {
 | 
				
			||||||
                statement.execute();
 | 
					                statement.execute();
 | 
				
			||||||
            } catch (SQLException e) {
 | 
					            } 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;
 | 
					                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.
 | 
					     * Stores a teaching assistant without a team.
 | 
				
			||||||
     * @param ta The teaching assistant to store.
 | 
					     * @param ta The teaching assistant to store.
 | 
				
			||||||
| 
						 | 
					@ -129,6 +145,7 @@ public class Database {
 | 
				
			||||||
            stmt.execute();
 | 
					            stmt.execute();
 | 
				
			||||||
            return true;
 | 
					            return true;
 | 
				
			||||||
        } catch (SQLException e) {
 | 
					        } catch (SQLException e) {
 | 
				
			||||||
 | 
					            logger.severe("SQL Exception while inserting TeachingAssistant.\n" + e.getMessage());
 | 
				
			||||||
            e.printStackTrace();
 | 
					            e.printStackTrace();
 | 
				
			||||||
            return false;
 | 
					            return false;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
| 
						 | 
					@ -202,6 +219,7 @@ public class Database {
 | 
				
			||||||
            stmt.execute();
 | 
					            stmt.execute();
 | 
				
			||||||
            return true;
 | 
					            return true;
 | 
				
			||||||
        } catch (SQLException e) {
 | 
					        } catch (SQLException e) {
 | 
				
			||||||
 | 
					            logger.severe("SQL Exception while inserting Student into database.\n" + e.getMessage());
 | 
				
			||||||
            e.printStackTrace();
 | 
					            e.printStackTrace();
 | 
				
			||||||
            return false;
 | 
					            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 assignmentsRepoField = new JTextField();
 | 
				
			||||||
    private JTextField teachingAssistantsField = new JTextField();
 | 
					    private JTextField teachingAssistantsField = new JTextField();
 | 
				
			||||||
    private JTextField studentRepoField = new JTextField();
 | 
					    private JTextField studentRepoField = new JTextField();
 | 
				
			||||||
    private JTextField teamSizeField = new JTextField();
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * The executor responsible for performing meaningful actions.
 | 
					     * The executor responsible for performing meaningful actions.
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue