-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #56 from Group-5/release/v1.0.0
Merge Release/v1.0.0 into main
- Loading branch information
Showing
78 changed files
with
5,787 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1,100 @@ | ||
| package edu.group5.app; | ||
|
|
||
| import edu.group5.app.control.MainController; | ||
| import edu.group5.app.control.wrapper.DbWrapper; | ||
| import edu.group5.app.control.wrapper.OrgApiWrapper; | ||
| import edu.group5.app.model.donation.Donation; | ||
| import edu.group5.app.model.donation.DonationRepository; | ||
| import edu.group5.app.model.donation.DonationService; | ||
| import edu.group5.app.model.organization.OrganizationRepository; | ||
| import edu.group5.app.model.organization.OrganizationService; | ||
| import edu.group5.app.model.user.User; | ||
| import edu.group5.app.model.user.UserRepository; | ||
| import edu.group5.app.model.user.UserService; | ||
| import javafx.application.Application; | ||
| import javafx.scene.Scene; | ||
| import javafx.scene.image.Image; | ||
| import javafx.stage.Stage; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| import java.util.logging.Logger; | ||
|
|
||
| /** | ||
| * Hello world! | ||
| * Main entry point for the Help-Me-Help charity donation application. | ||
| * Handles database connection, data loading, and application setup. | ||
| */ | ||
| public class App { | ||
| public static void main(String[] args) { | ||
| System.out.println("Hello World!"); | ||
| public class App extends Application { | ||
| DbWrapper dbWrapper; | ||
| UserRepository userRepository; | ||
| DonationRepository donationRepository; | ||
| private Logger logger; | ||
| private MainController controller; | ||
| private Scene scene; | ||
|
|
||
| @Override | ||
| public void init() { | ||
| this.logger = Logger.getLogger(App.class.getName()); | ||
| this.logger.info("Application starting"); | ||
|
|
||
| this.dbWrapper = new DbWrapper(false); | ||
| OrgApiWrapper orgApiWrapper = new OrgApiWrapper("https://app.innsamlingskontrollen.no/api/public/v1/all"); | ||
|
|
||
| while (!dbWrapper.connect()) { | ||
| this.logger.warning("Failed to connect to database"); | ||
| } | ||
|
|
||
| // Load data from database | ||
| List<Object[]> userData = dbWrapper.importUsers(); | ||
| List<Object[]> donationData = dbWrapper.fetchAllDonations(); | ||
| dbWrapper.disconnect(); | ||
|
|
||
| // Load organizations from API | ||
| Object[] organizationData = new Object[0]; | ||
| try { | ||
| if (orgApiWrapper.importData()) { | ||
| organizationData = orgApiWrapper.getData(); | ||
| } | ||
| } catch (InterruptedException e) { | ||
| System.err.println("Failed to load organization data: " + e.getMessage()); | ||
| } | ||
|
|
||
| // Create repositories with fetched data | ||
| this.userRepository = new UserRepository(userData); | ||
| this.donationRepository = new DonationRepository(donationData); | ||
| OrganizationRepository organizationRepository = new OrganizationRepository(organizationData); | ||
|
|
||
| // Create services (backend wiring) | ||
| UserService userService = new UserService(this.userRepository); | ||
| DonationService donationService = new DonationService(this.donationRepository, organizationRepository); | ||
| OrganizationService organizationService = new OrganizationService(organizationRepository); | ||
|
|
||
| this.controller = new MainController(userService, donationService, organizationService); | ||
|
|
||
| this.scene = controller.getMainView().getScene(); | ||
| } | ||
|
|
||
| @Override | ||
| public void start(Stage stage) { | ||
| this.controller.showLoginPage(); | ||
|
|
||
| stage.getIcons().add(new Image(getClass().getResource("/header/images/hmh-logo.png").toExternalForm())); | ||
| stage.setTitle("Help-Me-Help"); | ||
| stage.setScene(this.scene); | ||
| stage.show(); | ||
| } | ||
|
|
||
| @Override | ||
| public void stop() throws Exception { | ||
| super.stop(); | ||
| this.logger.info("Application stopping"); | ||
| this.dbWrapper.connect(); | ||
| this.dbWrapper.exportUsers(this.userRepository.export()); | ||
| this.dbWrapper.exportDonations(this.donationRepository.export()); | ||
| this.dbWrapper.disconnect(); | ||
| } | ||
|
|
||
| public static void main(String[] args) { | ||
| launch(args); | ||
| } | ||
| } |
16 changes: 16 additions & 0 deletions
16
src/main/java/edu/group5/app/control/BrowseCardController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| package edu.group5.app.control; | ||
|
|
||
| import edu.group5.app.model.organization.Organization; | ||
|
|
||
| public class BrowseCardController { | ||
| private final MainController controller; | ||
|
|
||
| public BrowseCardController(MainController mainController) { | ||
| this.controller = mainController; | ||
| } | ||
|
|
||
| public void handleCardClick(Organization organization) { | ||
| controller.setCurrentOrganization(organization); | ||
| controller.showOrganizationPage(); | ||
| } | ||
| } |
9 changes: 9 additions & 0 deletions
9
src/main/java/edu/group5/app/control/BrowsePageController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| package edu.group5.app.control; | ||
|
|
||
| public class BrowsePageController { | ||
| private final MainController controller; | ||
|
|
||
| public BrowsePageController(MainController mainController) { | ||
| this.controller = mainController; | ||
| } | ||
| } |
28 changes: 28 additions & 0 deletions
28
src/main/java/edu/group5/app/control/HeaderController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| package edu.group5.app.control; | ||
|
|
||
| public class HeaderController { | ||
| private final MainController controller; | ||
|
|
||
| public HeaderController(MainController controller) { | ||
| this.controller = controller; | ||
| } | ||
|
|
||
| public void handleHomeBtn() { | ||
| System.out.println("Home button pressed"); | ||
| controller.showHomePage(); | ||
| } | ||
|
|
||
| public void handleCausesBtn() { | ||
| System.out.println("Causes button pressed"); | ||
| controller.showBrowsePage(); | ||
| } | ||
|
|
||
| public void handleAboutBtn() { | ||
| System.out.println("About button pressed"); | ||
| } | ||
|
|
||
| public void handleProfileBtn() { | ||
| System.out.println("profileSection"); | ||
| controller.showUserPage(); | ||
| } | ||
| } |
19 changes: 19 additions & 0 deletions
19
src/main/java/edu/group5/app/control/HomePageController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| package edu.group5.app.control; | ||
|
|
||
| public class HomePageController { | ||
| private final MainController controller; | ||
|
|
||
| public HomePageController(MainController controller) { | ||
| this.controller = controller; | ||
| } | ||
|
|
||
| public void handleDonateToACauseBtn() { | ||
| System.out.println("Donate to a cause button pressed"); | ||
| controller.showBrowsePage(); | ||
| } | ||
|
|
||
| public void handleAboutUsBtn() { | ||
| System.out.println("About us button pressed"); | ||
| controller.showAboutUsPage(); | ||
| } | ||
| } |
44 changes: 44 additions & 0 deletions
44
src/main/java/edu/group5/app/control/LoginPageController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| package edu.group5.app.control; | ||
|
|
||
| import edu.group5.app.model.user.User; | ||
| import edu.group5.app.model.user.UserService; | ||
| import edu.group5.app.view.loginpage.LoginPageView; | ||
|
|
||
| public class LoginPageController { | ||
| private final MainController controller; | ||
| private final UserService userService; | ||
| private LoginPageView view; | ||
|
|
||
| public LoginPageController(MainController controller, UserService userService) { | ||
| this.controller = controller; | ||
| this.userService = userService; | ||
| } | ||
|
|
||
| public void setView(LoginPageView view) { | ||
| this.view = view; | ||
| } | ||
|
|
||
| public void handleLoginBtn() { | ||
| String email = view.getEmail(); | ||
| char[] passwordChars = view.getPassword(); | ||
|
|
||
| if (email == null || email.trim().isEmpty() || passwordChars == null || passwordChars.length == 0) { | ||
| view.showError("Email and password are required"); | ||
| return; | ||
| } | ||
|
|
||
| User user = userService.login(email, passwordChars); | ||
|
|
||
| if (user != null) { | ||
| controller.setCurrentUser(user); | ||
| controller.showHomePage(); | ||
| } else { | ||
| view.showError("Invalid email or password"); | ||
| } | ||
| } | ||
|
|
||
| public void handleRegisterBtn() { | ||
| System.out.println("Sign in button pressed"); | ||
| controller.showSignInPage(); | ||
| } | ||
| } |
Oops, something went wrong.