-
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 #54 from Group-5/feat/connectfrontback
Merge Feat/connectfrontback into workaround/ntnu-git-is-suboptimal
- Loading branch information
Showing
27 changed files
with
876 additions
and
156 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,25 +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 extends Application { | ||
| DbWrapper dbWrapper; | ||
| UserRepository userRepository; | ||
| DonationRepository donationRepository; | ||
| private Logger logger; | ||
| private MainController controller; | ||
| private Scene scene; | ||
|
|
||
| @Override | ||
| public void start(Stage stage) { | ||
| MainController controller = new MainController(); | ||
| 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); | ||
|
|
||
| Scene scene = controller.getMainView().getScene(); | ||
| controller.showLoginPage(); | ||
| 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(scene); | ||
| 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); | ||
| } | ||
| } |
6 changes: 4 additions & 2 deletions
6
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 |
|---|---|---|
| @@ -1,14 +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() { | ||
| System.out.println("Browse Card Clicked"); | ||
| public void handleCardClick(Organization organization) { | ||
| controller.setCurrentOrganization(organization); | ||
| controller.showOrganizationPage(); | ||
| } | ||
| } |
33 changes: 32 additions & 1 deletion
33
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
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
47 changes: 44 additions & 3 deletions
47
src/main/java/edu/group5/app/control/SignInPageController.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
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
Oops, something went wrong.