From ea712a6d6d7d3e267dc9daf8b3e600dec3ce5b22 Mon Sep 17 00:00:00 2001 From: INCREDIJOSH Date: Sun, 13 Nov 2022 20:56:01 -0500 Subject: [PATCH] Implement data storage --- .../java/APP_Business_Rules/FlagReview.java | 17 ++++++++++++++++- src/main/java/Entities/Dish.java | 4 ++++ src/main/java/Entities/Review.java | 4 ++++ 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/src/main/java/APP_Business_Rules/FlagReview.java b/src/main/java/APP_Business_Rules/FlagReview.java index a84120a..f961050 100644 --- a/src/main/java/APP_Business_Rules/FlagReview.java +++ b/src/main/java/APP_Business_Rules/FlagReview.java @@ -3,6 +3,7 @@ import Entities.Account; import Entities.FlaggedReview; import Entities.Review; +import APP_Business_Rules.DataAccessStorageInterface; public class FlagReview { @@ -11,9 +12,12 @@ public void flagged(Review review, Account flagger){ review.flagReview(); FlaggedReview flrev = new FlaggedReview(review, flagger); //**Will add to a queue for admin review when data storage is finished. + List<> queue = accessData("FlaggedReviewQueue.ser"); + queue.add(flrev); + storeData("FlaggedReviewQueue.ser", queue); } - public void resolveFlag(Boolean determination, FlaggedReview review){ + public void resolveFlag(boolean determination, FlaggedReview review){ //Takes action based of the determination of the administrator regarding the reviews adherence to company // policy. true for the flagged reviews removal and false for the reversal of the flagged status. archiveFlaggedReview(review); @@ -29,8 +33,19 @@ public void resolveFlag(Boolean determination, FlaggedReview review){ public void deleteReview(FlaggedReview review){ //Deletes review from everywhere except the archive. + review.getFlagged().getDishReviewed().removeReview(review.getFlagged()); + review.getFlagger().removeReview(review.getFlagged()); + + List<> queue = accessData("FlaggedReviewQueue.ser"); + queue.remove(review); + storeData("FlaggedReviewQueue.ser", queue); + + } public void archiveFlaggedReview(FlaggedReview review){ //Adds flagged review to archive of previously flagged reviews. + List<> queue = accessData("FlaggedReviewArchive.ser"); + queue.add(review); + storeData("FlaggedReviewArchive.ser", queue); } } diff --git a/src/main/java/Entities/Dish.java b/src/main/java/Entities/Dish.java index 10a0ce4..5716d1c 100644 --- a/src/main/java/Entities/Dish.java +++ b/src/main/java/Entities/Dish.java @@ -50,4 +50,8 @@ public void newAverage(){ } this.rating = total/reviews.size(); } + + public void removeReview(Review review){ + reviews.remove(review); + } } diff --git a/src/main/java/Entities/Review.java b/src/main/java/Entities/Review.java index df97c6e..19a533f 100644 --- a/src/main/java/Entities/Review.java +++ b/src/main/java/Entities/Review.java @@ -56,4 +56,8 @@ public void addVote(){ //Adds a vote to upVotes. this.upVotes += 1; } + + public Dish getDishReviewed() { + return dishReviewed; + } }