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
2 parents f9ece73 + ac927d2 commit ffd78e7
Show file tree
Hide file tree
Showing 62 changed files with 1,321 additions and 1,031 deletions.
Binary file added docs/Domenemodell/Domene Diagram 2.pdf
Binary file not shown.
Binary file added docs/Manuals/Installation Guide HmH.pdf
Binary file not shown.
Binary file added docs/Manuals/media/image1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/Manuals/media/image2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/Manuals/media/image3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/Manuals/media/image4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/Manuals/media/image5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/Manuals/media/image6.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file added docs/SqlDatabase/ER-Diagram v5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/SqlDatabase/ER-DiagramFile.mwb
Binary file not shown.
Binary file modified docs/SqlDatabase/ER-DiagramFile.mwb.bak
Binary file not shown.
Binary file added docs/design/Universal Design.pdf
Binary file not shown.
Binary file added docs/persistence/Persistence.pdf
Binary file not shown.
324 changes: 324 additions & 0 deletions etUUID(uuid);

Large diffs are not rendered by default.

Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,23 @@
import static javafx.application.Application.launch;

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

import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
import javafx.scene.image.Image;
import javafx.stage.Stage;
import ntnu.systemutvikling.team6.database.DatabaseConnection;
import ntnu.systemutvikling.team6.database.DatabaseSetup;
import ntnu.systemutvikling.team6.models.Charity;
import ntnu.systemutvikling.team6.models.registry.CharityRegistry;
import ntnu.systemutvikling.team6.scraper.APICharityScraper;
import ntnu.systemutvikling.team6.scraper.scraperComponents.APICharityScraper;
import ntnu.systemutvikling.team6.service.APIToDatabaseService;

public class HmHApplication extends Application {
@Override
public void start(Stage stage) throws Exception {
/*
FXMLLoader fxmlLoader =
new FXMLLoader(HmHApplication.class.getResource("/fxml/frontPage.fxml"));
Scene scene = new Scene(fxmlLoader.load());
Expand All @@ -30,8 +34,6 @@ public void start(Stage stage) throws Exception {
stage.setFullScreen(true);

stage.show();
*/

}

@Override
Expand All @@ -49,6 +51,7 @@ public void init() {
try {
HttpClient https = HttpClient.newHttpClient();
APICharityScraper scraper = new APICharityScraper(https);

DatabaseConnection conn = new DatabaseConnection();
APIToDatabaseService db = new APIToDatabaseService(conn);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
import javafx.scene.Parent;
import javafx.scene.control.TextField;
import javafx.scene.layout.FlowPane;
import ntnu.systemutvikling.team6.controller.components.BaseController;
import ntnu.systemutvikling.team6.controller.components.LoaderScene;
import ntnu.systemutvikling.team6.controller.components.NavbarFooterController;
import ntnu.systemutvikling.team6.controller.components.OrganizationCardController;
import ntnu.systemutvikling.team6.database.DatabaseConnection;
import ntnu.systemutvikling.team6.database.Readers.CharitySelect;
import ntnu.systemutvikling.team6.models.Charity;
Expand All @@ -22,7 +26,7 @@
* 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 {
public class AvailableOrganizationController extends BaseController implements NavbarFooterController {

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

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

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

/**
* This method is used to switch to the front page.
*
* @param event action event from button click
*/
@FXML
public void switchToFrontPage(ActionEvent event) {
LoaderScene.LoadScene("FrontPage", event, charity, null);
}

/**
* 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 @@ -4,6 +4,7 @@
import javafx.fxml.FXML;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;
import ntnu.systemutvikling.team6.controller.components.LoaderScene;
import ntnu.systemutvikling.team6.models.Charity;

/**
Expand Down Expand Up @@ -40,16 +41,6 @@ public void setCharity(Charity charity) {
CharityName.setText(charity.getName());
}

/**
* This method is used to switch to the front page.
*
* @param event
*/
@FXML
public void switchToFrontPage(ActionEvent event) {
System.out.println("Click");
LoaderScene.LoadScene("FrontPage", event, charity, null);
}

/**
* This method is used to switch to the donation page.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,11 @@
import javafx.scene.control.ButtonType;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;
import ntnu.systemutvikling.team6.DAO.DonationDAO;
import ntnu.systemutvikling.team6.controller.components.LoaderScene;
import ntnu.systemutvikling.team6.database.DAO.DonationDAO;
import ntnu.systemutvikling.team6.database.DatabaseConnection;
import ntnu.systemutvikling.team6.models.Charity;
import ntnu.systemutvikling.team6.models.user.User;

/**
* This controller represents the donation page, where the user can enter a donation amount and
Expand All @@ -23,6 +26,8 @@ public class DonationPageController {

@FXML private TextField donationSearchField;

private DonationDAO donationSender = new DonationDAO(new DatabaseConnection());

/**
* Initialize method for the donation page. Sets the charity name label to the name of the charity
* that is being donated to. The charity is set from the original page it was called from when the
Expand Down Expand Up @@ -97,7 +102,7 @@ public void Donate(ActionEvent event) {

if (result.isPresent() && result.get() == ButtonType.OK) {
// Process donation
processDonation(charity, amount);
//processDonation(charity, user, amount);
showAlert(
Alert.AlertType.INFORMATION,
"Thank you!",
Expand All @@ -114,8 +119,8 @@ public void Donate(ActionEvent event) {
* @param charity
* @param amount
*/
public void processDonation(Charity charity, double amount) {
DonationDAO.addDonation(charity, amount);
public void processDonation(Charity charity, User user, double amount) {
donationSender.addDonation(charity, user, amount);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,16 @@
import javafx.scene.control.Label;
import javafx.scene.control.TextField;
import javafx.scene.layout.FlowPane;
import ntnu.systemutvikling.team6.controller.components.BaseController;
import ntnu.systemutvikling.team6.controller.components.LoaderScene;
import ntnu.systemutvikling.team6.controller.components.NavbarFooterController;
import ntnu.systemutvikling.team6.controller.components.OrganizationCardController;
import ntnu.systemutvikling.team6.database.DatabaseConnection;
import ntnu.systemutvikling.team6.database.Readers.CharitySelect;
import ntnu.systemutvikling.team6.database.Readers.DonationSelect;
import ntnu.systemutvikling.team6.models.Charity;
import ntnu.systemutvikling.team6.models.registry.CharityRegistry;
import ntnu.systemutvikling.team6.models.Donation;
import ntnu.systemutvikling.team6.models.registry.CharityRegistry;
import ntnu.systemutvikling.team6.models.registry.DonationRegistry;

/**
Expand All @@ -27,7 +31,7 @@
* it, or click on the featured charity to see more details about it. It also has buttons to switch
* to the charity page and the donation page for the featured charity
*/
public class FrontpageController {
public class FrontpageController extends BaseController implements NavbarFooterController {
@FXML private Charity featuredCharity;
@FXML private FlowPane cardsContainer;
@FXML private Label Carosel_Organisasjon;
Expand All @@ -43,6 +47,11 @@ public class FrontpageController {

private List<Charity> allCharities = new ArrayList<>();

@Override
protected void authTokenisSet(){

}

/**
* Initialize method for the front page. This method is called when the front page is loaded. It
* retrieves the list of charities and donations from the database. The list of charities is
Expand Down Expand Up @@ -88,6 +97,7 @@ public void initialize() {
}
}


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

for (Charity charity : charities) {
try {
FXMLLoader loader = new FXMLLoader(getClass().getResource("/fxml/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
@@ -0,0 +1,17 @@
package ntnu.systemutvikling.team6.controller.components;

import ntnu.systemutvikling.team6.service.AuthenticationService;

public abstract class BaseController {
protected AuthenticationService authToken;

public void setAuthToken(AuthenticationService authToken){
this.authToken = authToken;
authTokenisSet();
};
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,4 +1,4 @@
package ntnu.systemutvikling.team6.controller;
package ntnu.systemutvikling.team6.controller.components;

import java.io.IOException;
import java.util.Objects;
Expand All @@ -10,6 +10,9 @@
import javafx.scene.image.Image;
import javafx.stage.Stage;
import ntnu.systemutvikling.team6.HmHApplication;
import ntnu.systemutvikling.team6.controller.AvailableOrganizationController;
import ntnu.systemutvikling.team6.controller.CharityPageController;
import ntnu.systemutvikling.team6.controller.DonationPageController;
import ntnu.systemutvikling.team6.models.Charity;

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
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 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 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);
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package ntnu.systemutvikling.team6.controller;
package ntnu.systemutvikling.team6.controller.components;

import javafx.event.ActionEvent;
import javafx.fxml.FXML;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,29 +1,34 @@
package ntnu.systemutvikling.team6.DAO;
package ntnu.systemutvikling.team6.database.DAO;

import java.sql.*;
import java.util.UUID;
import ntnu.systemutvikling.team6.database.DatabaseConnection;
import ntnu.systemutvikling.team6.models.Charity;
import ntnu.systemutvikling.team6.models.user.User;

/**
* This class is responsible for sending concurrent information about the donation to the Donation
* Database. Usally called from the DonationPageController, where the user confirms their donation.
*/
public class DonationDAO {
private static final DatabaseConnection connection = new DatabaseConnection();
private final DatabaseConnection 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.
*
* @param charity
* @param amount
*/
public static void addDonation(Charity charity, double amount) {
public void addDonation(Charity charity, User user, double amount) {
String sql_query =
"""
INSERT INTO Donations (UUID_Donations, amount, date, Charities_UUID_charities)
VALUES (?, ?, ?, ?)
INSERT INTO Donations (UUID_Donations, amount, date, charity_id, user_id)
VALUES (?, ?, ?, ?, ?)
""";
try (Connection conn = connection.getMySqlConnection();
PreparedStatement ps = conn.prepareStatement(sql_query)) {
Expand All @@ -33,6 +38,8 @@ INSERT INTO Donations (UUID_Donations, amount, date, Charities_UUID_charities)
ps.setDouble(2, amount);
ps.setDate(3, new Date(System.currentTimeMillis()));
ps.setString(4, charity.getUUID().toString());
ps.setString(5, user.getId().toString());


ps.executeUpdate();
conn.commit();
Expand Down
Loading

0 comments on commit ffd78e7

Please sign in to comment.