-
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.
- Loading branch information
Showing
28 changed files
with
308 additions
and
26 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 |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| # Adrian | ||
| .vscode/ | ||
| .idea/ | ||
| .target/ |
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.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 0 additions & 4 deletions
4
helpmehelpapplication/src/main/java/ntnu/sytemutvikling/team6/models/AnonymousDonation.java
This file was deleted.
Oops, something went wrong.
94 changes: 94 additions & 0 deletions
94
helpmehelpapplication/src/main/java/ntnu/sytemutvikling/team6/models/Charity.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,4 +1,98 @@ | ||
| /** | ||
| * This class represents a charity organization. It contains information about the charity such as its name, description, total donations, verification status, and category. | ||
| * | ||
| * @author Adrian Balunan | ||
| */ | ||
| package ntnu.sytemutvikling.team6.models; | ||
|
|
||
| import java.util.List; | ||
| import java.util.UUID; | ||
| import java.util.ArrayList; | ||
|
|
||
| abstract class Charity { | ||
| /* UUID for uniquely identifying each charity */ | ||
| private UUID id; | ||
|
|
||
| /* Name of the charity */ | ||
| private String name; | ||
|
|
||
| /* Description of the charity's mission and activities */ | ||
| private String description; | ||
|
|
||
| /* Total Donations received */ | ||
| private int totalDonations; | ||
|
|
||
| /* Is the charity verified? */ | ||
| private boolean isVerified; | ||
|
|
||
| /* Category for the charity */ | ||
| private String category; | ||
|
|
||
| /* List that contains the charity's Feedbacks */ | ||
| private List<Feedback> feedbacks; | ||
|
|
||
| /** | ||
| * Konstructor for creating a new charity. | ||
| * The ID is generated automatically using UUID. | ||
| * Total donations are initialized to 0. | ||
| * The charity is unverified by default. | ||
| * | ||
| * @param name | ||
| * @param description | ||
| * @param category | ||
| */ | ||
| public Charity(String name, String description, String category) { | ||
| this.id = UUID.randomUUID(); | ||
| this.name = name; | ||
| this.description = description; | ||
| this.totalDonations = 0; | ||
| this.isVerified = false; | ||
| this.feedbacks = new ArrayList<>(); | ||
| this.category = category; | ||
| } | ||
|
|
||
| /** | ||
| * Getters for the charity's attributes. | ||
| */ | ||
| public UUID getId() { | ||
| return id; | ||
| } | ||
| public String getCategory() { | ||
| return category; | ||
| } | ||
| public String getName() { | ||
| return name; | ||
| } | ||
| public String getDescription() { | ||
| return description; | ||
| } | ||
| public int getTotalDonations() { | ||
| return totalDonations; | ||
| } | ||
| public boolean isVerified() { | ||
| return isVerified; | ||
| } | ||
|
|
||
| /** | ||
| * Setter for verification status. | ||
| * This one sets the charity as verified. | ||
| */ | ||
| public void setVerified() { | ||
| this.isVerified = true; | ||
| } | ||
|
|
||
| /** | ||
| * Setter for verification status. | ||
| * This one sets the charity as unverified. | ||
| */ | ||
| public void setUnverified() { | ||
| this.isVerified = false; | ||
| } | ||
|
|
||
| /** | ||
| * Setter for total donations. This method is used to update the total donations when a new donation is made. | ||
| */ | ||
| public void setTotalDonations(int amount) { | ||
| this.totalDonations += amount; | ||
| } | ||
| } |
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,38 @@ | ||
| package ntnu.sytemutvikling.team6.models; | ||
|
|
||
| import java.util.*; | ||
|
|
||
| public class CharityRegistry{ | ||
| private final List<Charity> charities; | ||
|
|
||
| public CharityRegistry(){ | ||
| this.charities = new ArrayList<>(); | ||
| } | ||
|
|
||
| public List<Charity> getAllCharities(){ | ||
| return Collections.unmodifiableList(charities); | ||
| } | ||
|
|
||
| public Optional<Charity> findCharityById(UUID charityId){ | ||
| if(charityId == null){ | ||
| throw new IllegalArgumentException("CharityId can not be null."); | ||
| } | ||
| return charities.stream() | ||
| .filter(charity -> charityId.equals(charity.getId())) | ||
| .findFirst(); | ||
| } | ||
|
|
||
| public void addCharity(Charity charity){ | ||
| if(charity == null){ | ||
| throw new IllegalArgumentException("Charity can not be null."); | ||
| } | ||
| charities.add(charity); | ||
| } | ||
|
|
||
| public boolean removeCharity(UUID charityId){ | ||
| if(charityId == null){ | ||
| throw new IllegalArgumentException("CharityId can not be null."); | ||
| } | ||
| return charities.removeIf(charity -> charityId.equals(charity.getId())); | ||
| } | ||
| } |
75 changes: 75 additions & 0 deletions
75
helpmehelpapplication/src/main/java/ntnu/sytemutvikling/team6/models/Donation.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,4 +1,79 @@ | ||
| package ntnu.sytemutvikling.team6.models; | ||
|
|
||
| import java.time.LocalDateTime; | ||
| import java.util.UUID; | ||
|
|
||
| public class Donation { | ||
| /* UUID for uniquely identifying each donation */ | ||
| private UUID charityId; | ||
|
|
||
| /* Ammount of money donated */ | ||
| private double amount; | ||
|
|
||
| /* Date and time of the donation */ | ||
| private LocalDateTime date; | ||
|
|
||
| /* The charity that received the donation */ | ||
| private Charity charity; | ||
|
|
||
| /* The user/donor that made the donation */ | ||
| private User donor; | ||
|
|
||
| /** | ||
| * Is the donation made anonymously? | ||
| * This can be null if the donation was made anonymously. | ||
| * | ||
| */ | ||
| private boolean isAnonymous; | ||
|
|
||
| /** | ||
| * Constructor for creating a new donation. | ||
| * The charityId is generated automatically using UUID. | ||
| * If the donation is made anonymously, the isAnonymous parameter is set to true. | ||
| * @param amount | ||
| * @param date | ||
| * @param charity | ||
| * @param donor | ||
| */ | ||
| public Donation(double amount, LocalDateTime date, Charity charity, User donor) { | ||
| this.charityId = UUID.randomUUID(); | ||
| this.amount = amount; | ||
| this.date = date; | ||
| this.charity = charity; | ||
| this.donor = donor; | ||
|
|
||
|
|
||
| // ASSUMES that this is the way to get the anonymous setting from the user's settings. | ||
| if (donor.getSettings().getAnonymous() == false) { | ||
| this.isAnonymous = true; | ||
| } else { | ||
| this.isAnonymous = false; | ||
|
|
||
| } | ||
| } | ||
|
|
||
| /* Getters for the donation's attributes */ | ||
| public boolean isAnonymous() { | ||
| return isAnonymous; | ||
| } | ||
|
|
||
| public UUID getCharityId() { | ||
| return charityId; | ||
| } | ||
|
|
||
| public double getAmount() { | ||
| return amount; | ||
| } | ||
|
|
||
| public LocalDateTime getDate() { | ||
| return date; | ||
| } | ||
|
|
||
| public Charity getCharity() { | ||
| return charity; | ||
| } | ||
|
|
||
| public User getDonor() { | ||
| return donor; | ||
| } | ||
| } |
34 changes: 34 additions & 0 deletions
34
helpmehelpapplication/src/main/java/ntnu/sytemutvikling/team6/models/DonationRegistry.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,5 +1,39 @@ | ||
| package ntnu.sytemutvikling.team6.models; | ||
|
|
||
| import java.util.*; | ||
|
|
||
| public class DonationRegistry { | ||
| private final List<Donation> donations; | ||
|
|
||
| public DonationRegistry(){ | ||
| this.donations = new ArrayList<>(); | ||
| } | ||
|
|
||
| public List<Donation> getAllDonations(){ | ||
| return Collections.unmodifiableList(donations); | ||
| } | ||
|
|
||
| public Optional<Donation> findDonationById(UUID donationId){ | ||
| if(donationId == null){ | ||
| throw new IllegalArgumentException("DonationId can not be null."); | ||
| } | ||
| return donations.stream() | ||
| .filter(donations -> donationId.equals(donations.getCharityId())) | ||
| .findFirst(); | ||
| } | ||
|
|
||
| public void addDonation(Donation donation){ | ||
| if(donation == null){ | ||
| throw new IllegalArgumentException("Donation can not be null."); | ||
| } | ||
| donations.add(donation); | ||
| } | ||
|
|
||
| public boolean removeDonation(UUID donationId){ | ||
| if(donationId == null){ | ||
| throw new IllegalArgumentException("DonationId can not be null."); | ||
| } | ||
| return donations.removeIf(donation -> donationId.equals(donation.getCharityId())); | ||
| } | ||
|
|
||
| } |
61 changes: 61 additions & 0 deletions
61
helpmehelpapplication/src/main/java/ntnu/sytemutvikling/team6/models/Feedback.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,4 +1,65 @@ | ||
| package ntnu.sytemutvikling.team6.models; | ||
|
|
||
| import java.time.LocalDateTime; | ||
| import java.util.UUID; | ||
|
|
||
| public class Feedback { | ||
| /* Feedback id */ | ||
| private UUID feedbackId; | ||
|
|
||
| /** | ||
| * The author of the feedback | ||
| * If annonymous the presentation of the user will be "Anonymous". | ||
| */ | ||
| private User user; | ||
|
|
||
| /* The details of the feedback*/ | ||
| private String comment; | ||
|
|
||
| /* The date and time when the feedback was given */ | ||
| private LocalDateTime date; | ||
|
|
||
| /* Is the feedback given anonymously? */ | ||
| private boolean isAnonymous; | ||
|
|
||
| /** | ||
| * Constructor for creating a new feedback. | ||
| * | ||
| * @param user The user who gives the feedback. | ||
| * @param comment The content of the feedback. | ||
| */ | ||
| public Feedback(User user, String comment) { | ||
| this.feedbackId = UUID.randomUUID(); | ||
| this.user = user; | ||
| this.comment = comment; | ||
| this.date = LocalDateTime.now(); | ||
|
|
||
| // ASSUMES that this is the way to get the anonymous setting from the user's settings. | ||
| if (user.getSettings().getAnonymous() == false) { | ||
| this.isAnonymous = true; | ||
| } else { | ||
| this.isAnonymous = false; | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Getters for the feedback's attributes. | ||
| * | ||
| * @return The feedback's attributes. | ||
| */ | ||
| public UUID getFeedbackId() { | ||
| return feedbackId; | ||
| } | ||
| public String getComment() { | ||
| return comment; | ||
| } | ||
| public LocalDateTime getDate() { | ||
| return date; | ||
| } | ||
| public User getUser() { | ||
| return user; | ||
| } | ||
| public boolean isAnonymous() { | ||
| return isAnonymous; | ||
| } | ||
| } |
5 changes: 0 additions & 5 deletions
5
helpmehelpapplication/src/main/java/ntnu/sytemutvikling/team6/models/PublicDonation.java
This file was deleted.
Oops, something went wrong.
3 changes: 2 additions & 1 deletion
3
helpmehelpapplication/src/main/java/ntnu/sytemutvikling/team6/models/UserRegistry.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,5 +1,6 @@ | ||
| package ntnu.sytemutvikling.team6.models; | ||
|
|
||
| public class UserRegistry { | ||
|
|
||
|
|
||
|
|
||
| } |
4 changes: 0 additions & 4 deletions
4
...elpapplication/src/main/java/ntnu/sytemutvikling/team6/service/AuthenticationService.java
This file was deleted.
Oops, something went wrong.
4 changes: 0 additions & 4 deletions
4
helpmehelpapplication/src/main/java/ntnu/sytemutvikling/team6/service/CharityService.java
This file was deleted.
Oops, something went wrong.
4 changes: 0 additions & 4 deletions
4
helpmehelpapplication/src/main/java/ntnu/sytemutvikling/team6/service/DonationService.java
This file was deleted.
Oops, something went wrong.
4 changes: 0 additions & 4 deletions
4
helpmehelpapplication/src/main/java/ntnu/sytemutvikling/team6/service/FeedbackService.java
This file was deleted.
Oops, something went wrong.
Binary file removed
BIN
-568 Bytes
helpmehelpapplication/target/classes/ntnu/sytemutvikling/team6/Main.class
Binary file not shown.
Binary file removed
BIN
-367 Bytes
...mehelpapplication/target/classes/ntnu/sytemutvikling/team6/models/AnonymousDonation.class
Binary file not shown.
Binary file modified
BIN
+1.33 KB
(540%)
helpmehelpapplication/target/classes/ntnu/sytemutvikling/team6/models/Charity.class
Binary file not shown.
Binary file added
BIN
+2.83 KB
helpmehelpapplication/target/classes/ntnu/sytemutvikling/team6/models/CharityRegistry.class
Binary file not shown.
Binary file modified
BIN
+1.12 KB
(460%)
helpmehelpapplication/target/classes/ntnu/sytemutvikling/team6/models/Donation.class
Binary file not shown.
Binary file modified
BIN
+2.52 KB
(860%)
helpmehelpapplication/target/classes/ntnu/sytemutvikling/team6/models/DonationRegistry.class
Binary file not shown.
Binary file modified
BIN
+941 Bytes
(400%)
helpmehelpapplication/target/classes/ntnu/sytemutvikling/team6/models/Feedback.class
Binary file not shown.
Binary file removed
BIN
-358 Bytes
helpmehelpapplication/target/classes/ntnu/sytemutvikling/team6/models/PublicDonation.class
Binary file not shown.
Binary file removed
BIN
-356 Bytes
...papplication/target/classes/ntnu/sytemutvikling/team6/service/AuthenticationService.class
Binary file not shown.
Binary file removed
BIN
-335 Bytes
helpmehelpapplication/target/classes/ntnu/sytemutvikling/team6/service/CharityService.class
Binary file not shown.
Binary file removed
BIN
-338 Bytes
helpmehelpapplication/target/classes/ntnu/sytemutvikling/team6/service/DonationService.class
Binary file not shown.
Binary file removed
BIN
-338 Bytes
helpmehelpapplication/target/classes/ntnu/sytemutvikling/team6/service/FeedbackService.class
Binary file not shown.