Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement data storage #10

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion src/main/java/APP_Business_Rules/FlagReview.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import Entities.Account;
import Entities.FlaggedReview;
import Entities.Review;
import APP_Business_Rules.DataAccessStorageInterface;

public class FlagReview {

Expand All @@ -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);
Expand All @@ -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);
}
}
4 changes: 4 additions & 0 deletions src/main/java/Entities/Dish.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,8 @@ public void newAverage(){
}
this.rating = total/reviews.size();
}

public void removeReview(Review review){
reviews.remove(review);
}
}
4 changes: 4 additions & 0 deletions src/main/java/Entities/Review.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,8 @@ public void addVote(){
//Adds a vote to upVotes.
this.upVotes += 1;
}

public Dish getDishReviewed() {
return dishReviewed;
}
}