Skip to content

Commit

Permalink
update[]: add more JavaDoc to the rest of th ecodebase
Browse files Browse the repository at this point in the history
  • Loading branch information
Fredrik Marjoni committed Apr 16, 2026
1 parent b91eecd commit 996e43e
Show file tree
Hide file tree
Showing 8 changed files with 111 additions and 11 deletions.
3 changes: 0 additions & 3 deletions src/main/java/edu/group5/app/control/AuthController.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand Down
43 changes: 42 additions & 1 deletion src/main/java/edu/group5/app/control/NavigationController.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.
* <p>
* 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.
* </p>
*/
public class NavigationController {
private final BorderPane root;
Expand Down Expand Up @@ -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));
Expand All @@ -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));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
* <p>
* Coordinates with {@link OrganizationService} to:
* <ul>
* <li>Retrieve organization information by ID</li>
* <li>Retrieve all trusted organizations</li>
* </ul>
* </p>
*/
public class OrganizationController {
private final OrganizationService service;
Expand Down
43 changes: 42 additions & 1 deletion src/main/java/edu/group5/app/model/AppState.java
Original file line number Diff line number Diff line change
Expand Up @@ -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:
* <li> the current user</li>
* <li> the selected organization</li>
* <li> current donation amount</li>
* <li> current payment method</li>
* <br>
* 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;
}
Expand Down
11 changes: 11 additions & 0 deletions src/main/java/edu/group5/app/model/DBRepository.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,19 @@ protected DBRepository(Map<K, V> 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);

/**
Expand Down
11 changes: 8 additions & 3 deletions src/main/java/edu/group5/app/model/Repository.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@
import edu.group5.app.utils.ParameterValidator;

/**
* Represents a repository.
* Abstract base class for repositories.
* <p>
* 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.
* </p>
*/
public abstract class Repository<K, V> {
protected final Map<K, V> content;
Expand All @@ -20,8 +25,8 @@ protected Repository(Map<K, V> 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<K, V> getContent() {
return content;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 996e43e

Please sign in to comment.