From 996e43ecba33fd11993c2405702a0ba4929d9ceb Mon Sep 17 00:00:00 2001
From: Fredrik Marjoni
Date: Thu, 16 Apr 2026 14:02:36 +0200
Subject: [PATCH] update[]: add more JavaDoc to the rest of th ecodebase
---
.../group5/app/control/AuthController.java | 3 --
.../app/control/NavigationController.java | 43 ++++++++++++++++++-
.../app/control/OrganizationController.java | 9 +++-
.../java/edu/group5/app/model/AppState.java | 43 ++++++++++++++++++-
.../edu/group5/app/model/DBRepository.java | 11 +++++
.../java/edu/group5/app/model/Repository.java | 11 +++--
.../organization/OrganizationService.java | 1 -
.../OrganizationPageView.java | 1 -
8 files changed, 111 insertions(+), 11 deletions(-)
diff --git a/src/main/java/edu/group5/app/control/AuthController.java b/src/main/java/edu/group5/app/control/AuthController.java
index 4911a3b..291e0df 100644
--- a/src/main/java/edu/group5/app/control/AuthController.java
+++ b/src/main/java/edu/group5/app/control/AuthController.java
@@ -7,11 +7,8 @@
import edu.group5.app.view.loginpage.LoginPageView;
import edu.group5.app.view.loginpage.SignUpPageView;
import javafx.scene.control.Alert;
-import javafx.scene.control.Button;
import javafx.scene.control.ButtonType;
-import java.util.Arrays;
-
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
/**
diff --git a/src/main/java/edu/group5/app/control/NavigationController.java b/src/main/java/edu/group5/app/control/NavigationController.java
index 326389b..d94bb53 100644
--- a/src/main/java/edu/group5/app/control/NavigationController.java
+++ b/src/main/java/edu/group5/app/control/NavigationController.java
@@ -18,7 +18,14 @@
import javafx.scene.layout.BorderPane;
/**
- * Controller responsible for navigating between views within the root node.
+ * Controller responsible for handling navigation between different pages of the application.
+ * Coordinates between {@link AppState}, {@link AuthController}, {@link DonationController},
+ * {@link OrganizationController} and the various views to manage page transitions and state updates.
+ *
+ * Provides methods to navigate to the home page, login page, sign-up page, causes page,
+ * organization page, donation page, payment complete page and user profile page. Each method updates the
+ * top header and center content of the main application layout accordingly.
+ *
*/
public class NavigationController {
private final BorderPane root;
@@ -50,36 +57,65 @@ public NavigationController(BorderPane root, AppState appState, UserService user
this.organizationController = new OrganizationController(organizationService);
}
+ /**
+ * Navigates to the home page by setting the top header and center content of the main layout.
+ * The home page serves as the landing page of the application, providing an overview and access to various features.
+ */
public void showHomePage() {
root.setTop(header);
root.setCenter(new HomePageView(appState, this));
}
+ /**
+ * Navigates to the login page by setting the top header and center content of the main layout.
+ * The login page allows existing users to enter their credentials and access their account.
+ */
public void showLoginPage() {
root.setTop(loginHeader);
root.setCenter(new LoginPageView(appState, this, authController));
}
+ /**
+ * Navigates to the sign-up page by setting the top header and center content of the main layout.
+ * The sign-up page allows new users to create an account by providing their details.
+ */
public void showSignUpPage() {
root.setTop(loginHeader);
root.setCenter(new SignUpPageView(appState, this, authController));
}
+ /**
+ * Navigates to the payment complete page by setting the top header and center content of the main layout.
+ * The payment complete page confirms the successful completion of a donation transaction.
+ */
public void showPaymentCompletePage() {
root.setTop(header);
root.setCenter(new PaymentCompletePageView(this));
}
+ /**
+ * Navigates to the causes page by setting the top header and center content of the main layout.
+ * The causes page allows users to browse and search for organizations they may want to donate to.
+ */
public void showCausesPage() {
root.setTop(header);
root.setCenter(new CausesPageView(appState, this, organizationController));
}
+ /**
+ * Navigates to the organization page by setting the top header and center content of the main layout.
+ * The organization page provides detailed information about a specific organization, including its mission,
+ * impact, and donation options, allowing users to learn more before making a donation.
+ */
public void showOrganizationPage() {
root.setTop(header);
root.setCenter(new OrganizationPageView(appState, this, donationController));
}
+ /**
+ * Navigates to the donation page by setting the top header and center content of the main layout.
+ * The donation page allows users to make new donations to selected organizations.
+ */
public void showDonationPage() {
root.setTop(header);
root.setCenter(new DonationPageView(appState, this, donationController));
@@ -89,6 +125,11 @@ public void showAboutUsPage() {
root.setTop(header);
}
+ /**
+ * Navigates to the user profile page by setting the top header and center content of the main layout.
+ * The user profile page allows users to view and manage their account information,
+ * donation history, and other personalized features.
+ */
public void showUserPage() {
root.setTop(header);
root.setCenter(new UserPageView(appState, this, authController, donationController, organizationController));
diff --git a/src/main/java/edu/group5/app/control/OrganizationController.java b/src/main/java/edu/group5/app/control/OrganizationController.java
index fc1252f..064aab2 100644
--- a/src/main/java/edu/group5/app/control/OrganizationController.java
+++ b/src/main/java/edu/group5/app/control/OrganizationController.java
@@ -3,13 +3,20 @@
import edu.group5.app.model.organization.Organization;
import edu.group5.app.model.organization.OrganizationService;
import edu.group5.app.utils.ParameterValidator;
-import tools.jackson.databind.deser.bean.CreatorCandidate.Param;
import java.util.Map;
import java.util.concurrent.CompletableFuture;
/**
* Controller responsible for organization-related operations.
+ *
+ *
+ * Coordinates with {@link OrganizationService} to:
+ *
+ * - Retrieve organization information by ID
+ * - Retrieve all trusted organizations
+ *
+ *
*/
public class OrganizationController {
private final OrganizationService service;
diff --git a/src/main/java/edu/group5/app/model/AppState.java b/src/main/java/edu/group5/app/model/AppState.java
index 73d5cfc..bd56ba0 100644
--- a/src/main/java/edu/group5/app/model/AppState.java
+++ b/src/main/java/edu/group5/app/model/AppState.java
@@ -4,41 +4,82 @@
import edu.group5.app.model.user.User;
import java.math.BigDecimal;
-
+/**
+ * AppState class represents the current state of the application, including:
+ * the current user
+ * the selected organization
+ * current donation amount
+ * current payment method
+ *
+ * It serves as a centralized data store for the application's
+ * stateful information, allowing different components of the application to access and modify this information as needed.
+ */
public class AppState {
private User currentUser;
private BigDecimal currentDonationAmount;
private Organization currentOrganization;
private String currentDonation;
+ /**
+ * Gets the current user of the application.
+ * @return the current user
+ */
public User getCurrentUser() {
return this.currentUser;
}
+ /**
+ * Sets the current user of the application.
+ * @param user the user to set as the current user
+ */
public void setCurrentUser(User user) {
this.currentUser = user;
}
+ /**
+ * Gets the selected organization.
+ * @return the selected organization
+ */
public Organization getCurrentOrganization() {
return this.currentOrganization;
}
+ /**
+ * Sets the selected organization.
+ * @param organization the organization to set as the current organization
+ */
public void setCurrentOrganization(Organization organization) {
this.currentOrganization = organization;
}
+ /**
+ * Gets the current donation amount.
+ * @return the current donation amount
+ */
public BigDecimal getCurrentDonationAmount() {
return this.currentDonationAmount;
}
+ /**
+ * Sets the current donation amount.
+ * @param amount the amount to set as the current donation amount
+ */
public void setCurrentDonationAmount(BigDecimal amount) {
this.currentDonationAmount = amount;
}
+ /**
+ * Gets the current payment method.
+ * @return the current payment method
+ */
public String getCurrentPaymentMethod() {
return this.currentDonation;
}
+ /**
+ * Sets the current payment method.
+ * @param paymentMethod the payment method to set as the current payment method
+ */
public void setCurrentPaymentMethod(String paymentMethod){
this.currentDonation = paymentMethod;
}
diff --git a/src/main/java/edu/group5/app/model/DBRepository.java b/src/main/java/edu/group5/app/model/DBRepository.java
index 88ac3d9..d36d0e2 100644
--- a/src/main/java/edu/group5/app/model/DBRepository.java
+++ b/src/main/java/edu/group5/app/model/DBRepository.java
@@ -30,8 +30,19 @@ protected DBRepository(Map content) {
this.contentLock = new HashMap<>();
}
+ /**
+ * Updates the content lock with the current state of the content.
+ * This method should be called whenever the content is modified to ensure
+ * that the content lock reflects the latest state of the repository.
+ */
protected abstract void updateContentLock();
+ /**
+ * Adds a new entity to the repository content.
+ * @param value the entity to be added to the repository
+ * @return true if the entity was successfully added, false otherwise
+ * @throws IllegalArgumentException if the value is null
+ */
public abstract boolean addContent(V value);
/**
diff --git a/src/main/java/edu/group5/app/model/Repository.java b/src/main/java/edu/group5/app/model/Repository.java
index 64d4b90..6dd425e 100644
--- a/src/main/java/edu/group5/app/model/Repository.java
+++ b/src/main/java/edu/group5/app/model/Repository.java
@@ -5,7 +5,12 @@
import edu.group5.app.utils.ParameterValidator;
/**
- * Represents a repository.
+ * Abstract base class for repositories.
+ *
+ * Repositories are responsible for managing collections of entities, providing
+ * basic operations for accessing and manipulating these entities. The specific
+ * type of entities and the underlying data structure are defined by subclasses.
+ *
*/
public abstract class Repository {
protected final Map content;
@@ -20,8 +25,8 @@ protected Repository(Map content) {
}
/**
- * Gets the content of the repo
- * @return content of the repo
+ * Gets the content of the repository.
+ * @return the content of the repository
*/
public Map getContent() {
return content;
diff --git a/src/main/java/edu/group5/app/model/organization/OrganizationService.java b/src/main/java/edu/group5/app/model/organization/OrganizationService.java
index acb1110..d0c84a3 100644
--- a/src/main/java/edu/group5/app/model/organization/OrganizationService.java
+++ b/src/main/java/edu/group5/app/model/organization/OrganizationService.java
@@ -3,7 +3,6 @@
import java.util.stream.Collectors;
import edu.group5.app.utils.ParameterValidator;
-import tools.jackson.databind.deser.bean.CreatorCandidate.Param;
import java.util.Comparator;
import java.util.LinkedHashMap;
diff --git a/src/main/java/edu/group5/app/view/organizationpage/OrganizationPageView.java b/src/main/java/edu/group5/app/view/organizationpage/OrganizationPageView.java
index 53c623b..2268d4d 100644
--- a/src/main/java/edu/group5/app/view/organizationpage/OrganizationPageView.java
+++ b/src/main/java/edu/group5/app/view/organizationpage/OrganizationPageView.java
@@ -9,7 +9,6 @@
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.ScrollPane;
-import javafx.scene.control.TextArea;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.BorderPane;