- Pages:
- PageManager:
- Stores pages from all the user in hashmaps where the key is the username and the value is the page
- Has methods for updating the pages in the maps
- Uses the PrintCurrentPage visitor to call the specific methods to print pages.
- Content:
- HomePage:
- Implements visitable.
- Constructor for this class sorts the lists before adding them.
- Contains implementation for the recommendations.
- ArtistPage, HostPage and LikedContentPage: implement visitable and retain information about the specific pages.
- HomePage:
- PrintCurrentPage: Implements visitor, has the prints for all the specific pages.
- Invoker: used in the command pattern.
- ChangePageCommand: implementation for page navigation functionality.
- PageManager:
- user package:
- Artist: extends user and contains lists for albums, events and merchandise
- Host: extend user and contains lists for podcasts and announcements
- Monetization: class that contains information used for the endProgram statistic.
- wrapped:
- Abstract Wrapped class that defines the getSortedWrapped method used to get the wrapped with all the information sorted.
- UserWrapped stores user wrapped. Also calculates ad and premium revenue for the monetization.
- ArtistWrapped stores artist wrapped.
- HostWrapped stores host wrapped.
- Notifications:
- Notification has information about the notification.
- NotificationObserver interface used for Observer pattern, implemented by User.
- Singleton:
- Used for the CommandRunner class. This class has the get instance method.
- Visitor:
- Used for the PrintPage command.
- PrintCurrentPage implements the visitor interface and the Page classes in the content package implement visitable.
- The PageManager calls the accept methods int the printCurrentPage method.
- Observer:
- Used for the notification system.
- The User class implements the NotificationObserver interface
- The updateNotifications method is called for all the specific users when there is a change made in the Artist class.
- Command:
- Used for navigating through the page system. (nextPage, previousPage commands)
- The PageCommand interface has the execute and undo methods that are implemented by the ChangePageCommand class.
- The ChangePageCommand class retains information ont the old page so that the undo can be performed.
- Every user has an Invoker which contains the stack for the current and previous commands. The Invoker is the the one who calls the execute and undo methods for the command.
- Besides the nextPage and previousPage an execute is also called on the changePage method.
- The hashmaps in the PageManager are updated every time a new command is executed.
- When deleting users or removing albums or podcasts all the other users need to be checked so that they don't interact with the deleted content.
- The checks performed are: playlist checks to see if the users don't follow playlist from the deleted user, player checks to see if nothing from the deleted user runs for other users.
- CommandRunner class has new methods to check if a user can perform the specific actions. It makes sure the user exists and that they are online for the specific commands.
- Wrapped:
- Whenever a library entry is loaded into the player and when the next audio file plays the wrapped for the user is updated.
- In the update method multiple Maps are updated, the albums, the songs, the genres, etc.
- Some Maps have as key a string pair that contains the name of the song and the artist. These are used later to crate the artist wrapped and to calculate the monetization.
- Artist and Host wrapped are generated by looking through the user Wrapped statistics in the Maps that also contain song - artist keys.
- User wrapped also calculates the revenue while the program is running, more precisely when an ad is loaded in the player and when a user cancels their premium.
- This is done by going through the Maps that have the saved the listens (as free or as premium) adding them up and then calculating the revenue for each artist with the specified formula.
- Monetization:
- All the monetization calculated in userWrapped is added to a final Map. Then the rest of the premium listens that are left at the end of the program are calculated. This s done in a similar way to the one in userWrapped.
- Merch revenue is then added, by getting it from the artist that were added at the previous step.
- The final map is then sorted and the values are rounded.
- Notifications:
- Notifications are done by using the observer pattern. Every time an artist performs an action that requires a notification the users kept in the subscribers list are updated by using the updatedNotifications method.
- The user stores a list with these notifications and once the get notifications command is made, the list is cleared.
- Recommendations:
- For updateRecommendations, PageManager gets the specific users homePage and then adds the recommendation to the homePage. The last recommendation is also saved on the homePage to be later used for load.
- For loadRecommendations we take the last recommendation from the home page and then search, select and load it into the player.
- Page navigation:
- Page navigation is done with the Command pattern.
- Each user has an invoker with keeps information about the previous commands executed. The invoker also calls the execute and undo methods for the command.
- The only class that implements the PageCommand interface is the ChangePageCommand, which on execute changes the fields in the user for the new page and adds a new page to the PageManger Maps if it's needed.
- Invoker methods are called in the PageManager on changePage and on next and prev page.
