Skip to content

Commit

Permalink
Fix: Maven Clean.
Browse files Browse the repository at this point in the history
  • Loading branch information
AdrianBalunan committed Mar 12, 2026
1 parent c756c1c commit fc85476
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 89 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
package ntnu.systemutvikling.team6.DAO;

public class DonationDAO {
}
public class DonationDAO {}
Original file line number Diff line number Diff line change
@@ -1,43 +1,39 @@
package ntnu.systemutvikling.team6;

import static javafx.application.Application.launch;

import java.net.http.HttpClient;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
import javafx.stage.Stage;
import ntnu.systemutvikling.team6.database.DatabaseConnection;
import ntnu.systemutvikling.team6.database.DatabaseManager;
import ntnu.systemutvikling.team6.models.Charity;
import ntnu.systemutvikling.team6.models.CharityRegistry;
import ntnu.systemutvikling.team6.scraper.APICharityScraper;

import java.io.IOException;
import java.net.URISyntaxException;
import java.net.http.HttpClient;

import static javafx.application.Application.launch;

public class HmHApplication extends Application {
@Override
public void start(Stage stage) throws Exception {
FXMLLoader fxmlLoader = new FXMLLoader(Main.class.getResource("/fxml/frontPage.fxml"));
FXMLLoader fxmlLoader =
new FXMLLoader(HmHApplication.class.getResource("/fxml/frontPage.fxml"));
Scene scene = new Scene(fxmlLoader.load());
stage.setTitle("Help Me Help");
stage.setScene(scene);

stage.setMinHeight(700);
stage.setMinWidth(1100);
stage.setFullScreen(true);

stage.show();
}

@Override
public void init(){
public void init() {
/* Test and create tables to MySQL if ain't any */
try {
DatabaseManager db = new DatabaseManager();
db.testConnection();
db.createTables();
} catch (Exception e){
} catch (Exception e) {
e.printStackTrace();
}
/* Test and get data from Innsamlingkontrollen API */
Expand All @@ -46,17 +42,18 @@ public void init(){
APICharityScraper scraper = new APICharityScraper(https);
DatabaseManager db = new DatabaseManager();

if (scraper.checkConnection()){
if (scraper.checkConnection()) {
CharityRegistry charityRegistry = scraper.parseJSON(scraper.getJSONData());
for (Charity charity : charityRegistry.getAllCharities()){
System.out.println(charity.toString());
for (Charity charity : charityRegistry.getAllCharities()) {
System.out.println(charity.getName());
}
db.addAPIDataToTable(charityRegistry.getAllCharities());
}
} catch (Exception e){
} catch (Exception e) {
e.printStackTrace();
}
}

public static void main(String[] args) {
System.out.println("Hello world!");
launch(args);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
package ntnu.systemutvikling.team6;

import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
import javafx.stage.Stage;

public class Main {
public static void main(String[] args) {
HmHApplication.main(args);
}
public class Main {
public static void main(String[] args) {
HmHApplication.main(args);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,80 +4,77 @@
import java.sql.DriverManager;
import java.sql.SQLException;

/**
* Represents a reusable database connection through enviroment variables.
*/

/** Represents a reusable database connection through enviroment variables. */
public class DatabaseConnection {
private final String databaseURL;
private final String username;
private final String password;
/**
* Constructs a new {@code DatabaseConnection} using database credentials
* retrieved from system environment variables.
*
* @throws IllegalStateException if either databaseURL, username, or password is {@code null} or blank
*/

// Values stored in system environment variables for security (using ntnu's phpmyadmin for this project)
public DatabaseConnection(){
this.databaseURL = "jdbc:mysql://namox.idi.ntnu.no:3306/apbaluna?useSSL=false&serverTimezone=UTC";
this.username = "apbaluna";
this.password = "GYntUFPG";
private final String databaseURL;
private final String username;
private final String password;

if (this.databaseURL == null || this.databaseURL.isBlank()) {
throw new IllegalStateException("Database environment variable URL has not been set");
}
/**
* Constructs a new {@code DatabaseConnection} using database credentials retrieved from system
* environment variables.
*
* @throws IllegalStateException if either databaseURL, username, or password is {@code null} or
* blank
*/

if (this.username == null || this.username.isBlank()) {
throw new IllegalStateException("Username environment variable has not been set");
}
// Values stored in system environment variables for security (using ntnu's phpmyadmin for this
// project)
public DatabaseConnection() {
this.databaseURL =
"jdbc:mysql://namox.idi.ntnu.no:3306/apbaluna?useSSL=false&serverTimezone=UTC";
this.username = "apbaluna";
this.password = "GYntUFPG";

if (this.password == null || this.password.isBlank()) {
throw new IllegalStateException("Password environment variable has not been set");
}
if (this.databaseURL == null || this.databaseURL.isBlank()) {
throw new IllegalStateException("Database environment variable URL has not been set");
}

/**
* Constructs a new {@code DatabaseConnection} using database credentials
* <p>
* Used primarily for JUnit tests. Production should use the constructor
* using environment variables.
* </p>
*
* @param databaseURL the url to the database
* @param username the username used to log in to the database
* @param password the password used to log in to the database
* @throws IllegalArgumentException if databaseURL, username, or password is
* {@code null} or blank
*/

public DatabaseConnection(String databaseURL, String username, String password) {
this.databaseURL = databaseURL;
this.username = username;
this.password = password;
if (this.username == null || this.username.isBlank()) {
throw new IllegalStateException("Username environment variable has not been set");
}

if (this.databaseURL == null || this.databaseURL.isBlank()) {
throw new IllegalArgumentException("Database environment variable URL has not been set");
}
if (this.password == null || this.password.isBlank()) {
throw new IllegalStateException("Password environment variable has not been set");
}
}

if (this.username == null || this.username.isBlank()) {
throw new IllegalArgumentException("Username environment variable has not been set");
}
/**
* Constructs a new {@code DatabaseConnection} using database credentials
*
* <p>Used primarily for JUnit tests. Production should use the constructor using environment
* variables.
*
* @param databaseURL the url to the database
* @param username the username used to log in to the database
* @param password the password used to log in to the database
* @throws IllegalArgumentException if databaseURL, username, or password is {@code null} or blank
*/
public DatabaseConnection(String databaseURL, String username, String password) {
this.databaseURL = databaseURL;
this.username = username;
this.password = password;

if (this.password == null || this.password.isBlank()) {
throw new IllegalArgumentException("Password environment variable has not been set");
}
if (this.databaseURL == null || this.databaseURL.isBlank()) {
throw new IllegalArgumentException("Database environment variable URL has not been set");
}

if (this.username == null || this.username.isBlank()) {
throw new IllegalArgumentException("Username environment variable has not been set");
}

/**
* Creates and returns a new MySQL database connection.
*
* @return a {@link Connection} to the database
* @throws SQLException if the connection cannot be established
*/
public Connection getMySqlConnection() throws SQLException {
return DriverManager.getConnection(databaseURL, username, password);
if (this.password == null || this.password.isBlank()) {
throw new IllegalArgumentException("Password environment variable has not been set");
}
}

/**
* Creates and returns a new MySQL database connection.
*
* @return a {@link Connection} to the database
* @throws SQLException if the connection cannot be established
*/
public Connection getMySqlConnection() throws SQLException {
return DriverManager.getConnection(databaseURL, username, password);
}
}

0 comments on commit fc85476

Please sign in to comment.