Skip to content

Commit

Permalink
changes
Browse files Browse the repository at this point in the history
  • Loading branch information
meenakshijay1005-netizen committed Apr 16, 2026
1 parent ffd78e7 commit 4f8984c
Show file tree
Hide file tree
Showing 26 changed files with 241 additions and 240 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

import java.net.http.HttpClient;
import java.util.Objects;

import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
* on the featured charity to see more details about it. The user can also switch to the charity
* page or donation page for the selected charity.
*/
public class AvailableOrganizationController extends BaseController implements NavbarFooterController {
public class AvailableOrganizationController extends BaseController
implements NavbarFooterController {

@FXML private TextField searchField;
@FXML private FlowPane cardsContainer;
Expand Down Expand Up @@ -92,7 +93,8 @@ private void displayCharities(List<Charity> charities) {

for (Charity charity : charities) {
try {
FXMLLoader loader = new FXMLLoader(getClass().getResource("/fxml/components/organizationCard.fxml"));
FXMLLoader loader =
new FXMLLoader(getClass().getResource("/fxml/components/organizationCard.fxml"));
Parent card = loader.load();

OrganizationCardController cardController = loader.getController();
Expand All @@ -119,7 +121,6 @@ public void setInitialSearch(String query) {
searchField.setText(query);
}


/**
* This method is used to switch to the charity page for the selected charity.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ public void setCharity(Charity charity) {
CharityName.setText(charity.getName());
}


/**
* This method is used to switch to the donation page.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public void Donate(ActionEvent event) {

if (result.isPresent() && result.get() == ButtonType.OK) {
// Process donation
//processDonation(charity, user, amount);
// processDonation(charity, user, amount);
showAlert(
Alert.AlertType.INFORMATION,
"Thank you!",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,7 @@ public class FrontpageController extends BaseController implements NavbarFooterC
private List<Charity> allCharities = new ArrayList<>();

@Override
protected void authTokenisSet(){

}
protected void authTokenisSet() {}

/**
* Initialize method for the front page. This method is called when the front page is loaded. It
Expand Down Expand Up @@ -97,7 +95,6 @@ public void initialize() {
}
}


/**
* This method is used to switch to the charity page for the selected charity
*
Expand Down Expand Up @@ -220,7 +217,8 @@ private void displayCharities(List<Charity> charities) {

for (Charity charity : charities) {
try {
FXMLLoader loader = new FXMLLoader(getClass().getResource("/fxml/components/organizationCard.fxml"));
FXMLLoader loader =
new FXMLLoader(getClass().getResource("/fxml/components/organizationCard.fxml"));
Parent card = loader.load();
OrganizationCardController cardController = loader.getController();
cardController.setOrganization(charity);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,17 @@
import ntnu.systemutvikling.team6.service.AuthenticationService;

public abstract class BaseController {
protected AuthenticationService authToken;
protected AuthenticationService authToken;

public void setAuthToken(AuthenticationService authToken){
this.authToken = authToken;
authTokenisSet();
};
protected void authTokenisSet(){} // Do stuff after authtoken is set, on each controller
public void setAuthToken(AuthenticationService authToken) {
this.authToken = authToken;
authTokenisSet();
}
;

protected boolean isLoggedin(){
return authToken.isLoggedin() && authToken != null;
}
protected void authTokenisSet() {} // Do stuff after authtoken is set, on each controller

protected boolean isLoggedin() {
return authToken.isLoggedin() && authToken != null;
}
}
Original file line number Diff line number Diff line change
@@ -1,33 +1,31 @@
package ntnu.systemutvikling.team6.controller.components;

import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.scene.control.TextField;

public interface NavbarFooterController {

default void switchToFrontPage(ActionEvent event) {
System.out.println("Click!");
LoaderScene.LoadScene("FrontPage", event, null, null);
}
default void switchToFrontPage(ActionEvent event) {
System.out.println("Click!");
LoaderScene.LoadScene("FrontPage", event, null, null);
}

default void switchToAboutPage(ActionEvent event) {
System.out.println("Click!");
LoaderScene.LoadScene("aboutPage", event, null, null);
}
default void switchToAboutPage(ActionEvent event) {
System.out.println("Click!");
LoaderScene.LoadScene("aboutPage", event, null, null);
}

default void switchToProfilePage(ActionEvent event) {
System.out.println("Click!");
LoaderScene.LoadScene("aboutPage", event, null, null);
}
default void switchToProfilePage(ActionEvent event) {
System.out.println("Click!");
LoaderScene.LoadScene("aboutPage", event, null, null);
}

default void handleSearch(ActionEvent event) {
System.out.println("Click!");
LoaderScene.LoadScene("aboutPage", event, null, null);
}
default void handleSearch(ActionEvent event) {
System.out.println("Click!");
LoaderScene.LoadScene("aboutPage", event, null, null);
}

default void switchToLoginPage(ActionEvent event) {
System.out.println("Click!");
LoaderScene.LoadScene("aboutPage", event, null, null);
}
default void switchToLoginPage(ActionEvent event) {
System.out.println("Click!");
LoaderScene.LoadScene("aboutPage", event, null, null);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
public class DonationDAO {
private final DatabaseConnection connection;

public DonationDAO(DatabaseConnection connection) {
this.connection = connection;
}
public DonationDAO(DatabaseConnection connection) {
this.connection = connection;
}

/**
/**
* Gets the total ammount of donations for a given charity, and sends it to the database throught
* MySQL.
*
Expand All @@ -40,7 +40,6 @@ INSERT INTO Donations (UUID_Donations, amount, date, charity_id, user_id)
ps.setString(4, charity.getUUID().toString());
ps.setString(5, user.getId().toString());


ps.executeUpdate();
conn.commit();
} catch (SQLException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,13 @@ public class UserDAO {

private final DatabaseConnection connection;

public UserDAO(DatabaseConnection connection) {
this.connection = connection;
}
public UserDAO(DatabaseConnection connection) {
this.connection = connection;
}

/**
/**
* Gets the user and settings information and sends it to the database through MySQL.
*
*
* @param user the user to be saved in the database.
* @throws RuntimeException if a database error occurs during the operation
* @return true or false based on if the register is a success or not
Expand Down Expand Up @@ -80,7 +79,6 @@ INSERT INTO Settings (
psSettings.setBoolean(4, user.getSettings().isLightMode());

psSettingsRows = psSettings.executeUpdate();

}

conn.commit();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public CharityRegistry getCharitiesFromDB() {
rs.getString("user_email"),
rs.getString("user_password"),
rs.getString("role"));
userWithMinimalSettingsAndInbox.setSettings(new Settings(false, Language.ENGLISH, false));
userWithMinimalSettingsAndInbox.setSettings(new Settings(false, Language.ENGLISH, false));

Feedback feedback =
new Feedback(
Expand Down Expand Up @@ -181,7 +181,7 @@ public ArrayList<Feedback> getFeedbackforCharityUUID(String charity_uuid) {
Feedback feedback =
new Feedback(
rs.getString("UUID_feedback"),
userWithSettingsAndNoInbox,
userWithSettingsAndNoInbox,
rs.getString("feedback_comment"),
LocalDate.parse(rs.getString("feedback_date")));
Feedbacks.add(feedback);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ public UserSelect(DatabaseConnection connection) {
this.connection = connection;
}

public boolean isUsernameTaken(String username){
public boolean isUsernameTaken(String username) {
try (Connection conn = connection.getMySqlConnection();
Statement stmt = conn.createStatement()) {
Statement stmt = conn.createStatement()) {

String mysql =
"""
"""
SELECT UUID_User FROM User WHERE user_name = ?
""";
PreparedStatement statement = conn.prepareStatement(mysql);
Expand All @@ -53,7 +53,6 @@ public boolean isUsernameTaken(String username){
return false;
}


/**
* Retrieves a single {@link User} from the database matching the given username and password.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,7 @@ public void setFeedbacks(ArrayList<Feedback> feedbacks) {
this.feedbacks = feedbacks;
}

public void setUUIDFromString(String uuid){
public void setUUIDFromString(String uuid) {
this.UUID = java.util.UUID.fromString(uuid);
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,14 @@ public class User {
* @throws IllegalArgumentException if any required argument is invalid.
*/
public User(
String displayName, String username, String email, String password, Role role, Settings settings, Inbox inbox) {
if (displayName == null || username.isBlank()){
String displayName,
String username,
String email,
String password,
Role role,
Settings settings,
Inbox inbox) {
if (displayName == null || username.isBlank()) {
throw new IllegalArgumentException("displayName cannot be null or blank.");
}

Expand Down Expand Up @@ -86,7 +92,13 @@ public User(
* @param role users role
* @throws IllegalArgumentException if any required argument is invalid.
*/
public User(String uuid, String displayName, String username, String email, String password, String role) {
public User(
String uuid,
String displayName,
String username,
String email,
String password,
String role) {

if (uuid == null || uuid.isBlank()) {
throw new IllegalArgumentException("UUID cannot be null or blank.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;
import java.util.UUID;
Expand Down Expand Up @@ -41,15 +40,17 @@ public void addAPIDataToTable(List<Charity> charities) {
try {
conn = connection.getMySqlConnection();
conn.setAutoCommit(false);
String sql1 = """
String sql1 =
"""
INSERT INTO Charities (UUID_charities, org_number, pre_approved, status)
VALUES (?, ?, ?, ?)
ON DUPLICATE KEY UPDATE
pre_approved = VALUES(pre_approved),
status = VALUES(status);
""";

String sql2 = """
String sql2 =
"""
INSERT INTO CharityVanity (UUID_charity, charity_name, charity_link, description, logoURL, key_values, logoBlob)
VALUES (?, ?, ?, ?, ?, ?, ?)
ON DUPLICATE KEY UPDATE
Expand All @@ -62,7 +63,7 @@ INSERT INTO CharityVanity (UUID_charity, charity_name, charity_link, description
""";

try (PreparedStatement ps1 = conn.prepareStatement(sql1);
PreparedStatement ps2 = conn.prepareStatement(sql2)) {
PreparedStatement ps2 = conn.prepareStatement(sql2)) {

for (Charity charity : charities) {
String uuid;
Expand All @@ -88,7 +89,6 @@ INSERT INTO CharityVanity (UUID_charity, charity_name, charity_link, description
ps2.setString(6, charity.getKeyValues());
ps2.setBytes(7, charity.getLogoBlob());
ps2.executeUpdate();

}

} catch (Exception e) {
Expand Down
Loading

0 comments on commit 4f8984c

Please sign in to comment.