Class FilmUserController

java.lang.Object
javafx.application.Application
com.esprit.controllers.films.FilmUserController

public class FilmUserController extends javafx.application.Application
Is responsible for handling user interactions related to viewing and commenting on films within a cinema website. It displays a scrolling pane containing all comments for a given film, and allows users to add new comments or view previous comments by clicking buttons in the interface. The controller also provides methods for retrieving all comments for a specific film and displaying them in the scrolling pane.
  • Nested Class Summary

    Nested classes/interfaces inherited from class javafx.application.Application

    javafx.application.Application.Parameters
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private javafx.scene.layout.AnchorPane
     
    private javafx.scene.layout.AnchorPane
     
    private javafx.scene.layout.AnchorPane
     
    private javafx.scene.layout.AnchorPane
     
    private javafx.scene.control.Button
     
    private javafx.scene.control.Button
     
    private javafx.scene.control.Button
     
    javafx.scene.control.Button
     
    private javafx.scene.control.TextArea
     
    private javafx.scene.layout.AnchorPane
     
    private javafx.scene.control.Button
     
    private Long
     
    private javafx.scene.control.Label
     
    private org.controlsfx.control.Rating
     
    private javafx.scene.control.ScrollPane
     
    (package private) javafx.scene.layout.FlowPane
     
    (package private) javafx.scene.layout.FlowPane
     
    private javafx.scene.image.ImageView
     
    private List<Film>
     
    private javafx.scene.control.Label
     
    private static final Logger
     
    private MovieSession
     
    private javafx.scene.control.Button
     
    private javafx.scene.image.ImageView
     
    private javafx.scene.control.Button
     
    private javafx.scene.control.ScrollPane
     
    private javafx.scene.control.TextField
     
    private javafx.scene.control.Button
     
    private javafx.scene.control.ComboBox<String>
     
    private javafx.scene.layout.VBox
     
    private javafx.scene.layout.VBox
     
    private javafx.scene.control.Button
     
    private javafx.scene.control.ComboBox<String>
     
    private javafx.scene.control.TextField
     
    private final List<javafx.scene.control.CheckBox>
     

    Fields inherited from class javafx.application.Application

    STYLESHEET_CASPIAN, STYLESHEET_MODENA
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    (package private) void
    AddComment(javafx.scene.input.MouseEvent event)
     
    (package private) void
    Allows users to add comments to a film by providing a text input, displaying an alert if the comment is empty, and then creating a new FilmComment object with the provided message, user ID, and film ID using the FilmCommentService.
    private javafx.scene.layout.HBox
    Creates an HBox containing an ImageView and a VBox with text, image and card container.
    (package private) void
    afficherAnchorComment(javafx.scene.input.MouseEvent event)
     
    private double
    calculateSimilarityScore(Film film, Map<String,Double> userPreferences)
     
    void
    Performs close operation.
    (package private) void
    closercommets(javafx.event.ActionEvent event)
    Sets the opacity and visibility of an AnchorPane, and also makes a different AnchorPane visible.
    javafx.scene.layout.AnchorPane
    createActorDetails(int actorPlacement)
    Performs createActorDetails operation.
    private javafx.scene.layout.AnchorPane
    Creates a UI component representing a movie card with various details and ratings.
    private void
    Creates film cards for a list of films by creating an AnchorPane container for each card and adding it to a `FlowPane` containing other cards.
    javafx.scene.layout.AnchorPane
    createtopthree(int filmRank)
    Performs createtopthree operation.
    private void
    Displays all comments associated with a specific film ID in a scroll pane.
    private void
    Filters a `Flowpane` of `AnchorPane` elements based on the text content of a `.nomFilm` label, making the visible or invisible elements dependent on the keyword search result.
    (package private) void
    filtrer(javafx.event.ActionEvent event)
    Sets the opacity of a panel to 0.5 and makes a pane visible, clears a list of checkboxes, recieves unique cinema years from a database, creates a VBox for each year, adds the VBox to an anchor pane, and makes the anchor pane visible.
    (package private) void
    filtrercinema(javafx.event.ActionEvent event)
    Filters a list of cinemas based on user-selected years of release and displays the filtered cinemas in a flow pane.
    private List<FilmComment>
    getAllComment(int filmId)
    Retrieves all comments for a given film ID and filters them to only include those that belong to the corresponding cinema.
    private List<FilmComment>
     
    private List<Integer>
    Retrieves a list of unique film release years from a database using `FilmService`.
    private long
     
    private List<Film>
    getRecommendations(long userId)
     
    private List<Film>
     
    private List<Integer>
    Retrieves the selected years from an `AnchorPane` widget, filters out non-selected years using `filter`, maps the selected check boxes to their corresponding integers using `map`, and collects the list of integers representing the selected years.
    void
    Sets up the user interface for a film application, including creating a flow pane to display films and three combos to display top actors or directors.
    private void
     
    private void
     
    static List<Film>
    rechercher(List<Film> liste, String recherche)
    Queries a list of films for any that contain a specified search term in their name, and returns a list of matches.
    private void
     
    private void
    setupDragAndDrop(javafx.scene.layout.AnchorPane filmCard, Film film)
     
    private void
     
    private void
     
    private void
    showError(String title, String message)
     
    void
    start(javafx.stage.Stage stage)
    Is called when the Java application begins and sets up the Stage for further interaction.
    void
    switchtcinemaaa(javafx.event.ActionEvent event)
    Loads a FXML file using the `FXMLLoader` class, creates a new `AnchorPane` root element, sets it as the scene of a stage, and displays the stage in a window with a specified size.
    void
    switchtevent(javafx.event.ActionEvent event)
    Loads and displays a FXML file using the `FXMLLoader` class, replacing the current scene with the new one.
    void
    switchtoajouterCinema(javafx.event.ActionEvent event)
    Loads a FXML file "/ui/series/SeriesClient.fxml" into a stage, replacing the current scene.
    void
    switchtoajouterproduct(javafx.event.ActionEvent event)
    Loads an FXML file, creates a Stage and sets the Scene for displaying a user interface.
    void
    Loads an FXML user interface from a resource file, sets data for the controller, and displays the stage with the loaded scene.
    void
    switchtoSerie(javafx.event.ActionEvent event)
    Loads and displays a FXML file using the `FXMLLoader` class, replacing the current scene with the new one.

    Methods inherited from class javafx.application.Application

    getHostServices, getParameters, getUserAgentStylesheet, init, launch, launch, notifyPreloader, setUserAgentStylesheet, stop

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • LOGGER

      private static final Logger LOGGER
    • yearsCheckBoxes

      private final List<javafx.scene.control.CheckBox> yearsCheckBoxes
    • closeDetailFilm2

      public javafx.scene.control.Button closeDetailFilm2
    • flowpaneFilm

      javafx.scene.layout.FlowPane flowpaneFilm
    • flowPaneactors

      javafx.scene.layout.FlowPane flowPaneactors
    • closeDetailFilm1

      private javafx.scene.control.Button closeDetailFilm1
    • AnchorComments

      private javafx.scene.layout.AnchorPane AnchorComments
    • l1

      private List<Film> l1
    • filmRate

      private org.controlsfx.control.Rating filmRate
    • Cinema_Button

      private javafx.scene.control.Button Cinema_Button
    • event_button

      private javafx.scene.control.Button event_button
    • product

      private javafx.scene.control.Button product
    • trailer_Button

      private javafx.scene.control.Button trailer_Button
    • anchorPane_Trailer

      private javafx.scene.layout.AnchorPane anchorPane_Trailer
    • labelavregeRate

      private javafx.scene.control.Label labelavregeRate
    • anchorPaneFilm

      private javafx.scene.layout.AnchorPane anchorPaneFilm
    • ScrollPaneComments

      private javafx.scene.control.ScrollPane ScrollPaneComments
    • txtAreaComments

      private javafx.scene.control.TextField txtAreaComments
    • Anchore_Pane_filtrage

      private javafx.scene.layout.AnchorPane Anchore_Pane_filtrage
    • detalAnchorPane

      private javafx.scene.layout.AnchorPane detalAnchorPane
    • closeDetailFilm

      private javafx.scene.control.Button closeDetailFilm
    • descriptionDETAILfilm

      private javafx.scene.control.TextArea descriptionDETAILfilm
    • imagefilmDetail

      private javafx.scene.image.ImageView imagefilmDetail
    • filmNomDetail

      private javafx.scene.control.Label filmNomDetail
    • topthreeVbox

      private javafx.scene.layout.VBox topthreeVbox
    • filmScrollPane

      private javafx.scene.control.ScrollPane filmScrollPane
    • serach_film_user

      private javafx.scene.control.TextField serach_film_user
    • reserver_Film

      private javafx.scene.control.Button reserver_Film
    • SerieButton

      private javafx.scene.control.Button SerieButton
    • qrcode

      private javafx.scene.image.ImageView qrcode
    • top3combobox

      private javafx.scene.control.ComboBox<String> top3combobox
    • topthreeVbox1

      private javafx.scene.layout.VBox topthreeVbox1
    • tricomboBox

      private javafx.scene.control.ComboBox<String> tricomboBox
    • filmId

      private Long filmId
    • moviesession

      private MovieSession moviesession
  • Constructor Details

    • FilmUserController

      public FilmUserController()
  • Method Details

    • rechercher

      public static List<Film> rechercher(List<Film> liste, String recherche)
      Queries a list of films for any that contain a specified search term in their name, and returns a list of matches.
      Parameters:
      liste - list of films that will be searched for matching titles within the provided `recherche` parameter.

      - It is a list of `Film` objects - Each element in the list has a `nom` attribute that can contain the search query

      recherche - search query, which is used to filter the list of films in the function.
    • switchtopayment

      public void switchtopayment(String nom) throws IOException
      Loads an FXML user interface from a resource file, sets data for the controller, and displays the stage with the loaded scene.
      Parameters:
      nom - name of the client for which the payment user interface is to be displayed.
      Throws:
      IOException
    • showError

      private void showError(String title, String message)
    • createfilmCards

      private void createfilmCards(List<Film> Films)
      Creates film cards for a list of films by creating an AnchorPane container for each card and adding it to a `FlowPane` containing other cards.
      Parameters:
      Films - list of films to create film cards for, which are then added as children of the `flowpaneFilm`.

      - `Film` objects are contained in the list. - Each `Film` object has various attributes, such as title, director, year of release, etc.

    • initialize

      public void initialize()
      Sets up the user interface for a film application, including creating a flow pane to display films and three combos to display top actors or directors.
    • setupBasicUI

      private void setupBasicUI()
    • setupRecommendations

      private void setupRecommendations()
    • filterByName

      private void filterByName(String keyword)
      Filters a `Flowpane` of `AnchorPane` elements based on the text content of a `.nomFilm` label, making the visible or invisible elements dependent on the keyword search result.
      Parameters:
      keyword - search term used to filter the film cards, and its value determines whether or not a card is visible and managed.
    • createFilmCard

      private javafx.scene.layout.AnchorPane createFilmCard(Film film)
      Creates a UI component representing a movie card with various details and ratings. It generates a QR code for the movie's IMDB page, which can be scanned to open the page in a browser. The function also adds event listeners to handle clicks on the movie card and the QR code.
      Parameters:
      film - film object that will be displayed in the anchor pane, and is used to retrieve the film's information such as title, image, rating, and trailer link.

      - `id`: a unique identifier for the film - `nom`: the film's title - `description`: a brief description of the film - `duree`: the film's duration - `annderalisation`: the film's release date - `categories`: an array of categories the film belongs to - `actors`: an array of actors appearing in the film.

    • createActorDetails

      public javafx.scene.layout.AnchorPane createActorDetails(int actorPlacement)
      Performs createActorDetails operation.
      Returns:
      the result of the operation
    • createtopthree

      public javafx.scene.layout.AnchorPane createtopthree(int filmRank)
      Performs createtopthree operation.
      Returns:
      the result of the operation
    • getCinemaYears

      private List<Integer> getCinemaYears()
      Retrieves a list of unique film release years from a database using `FilmService`.
    • filtrer

      void filtrer(javafx.event.ActionEvent event)
      Sets the opacity of a panel to 0.5 and makes a pane visible, clears a list of checkboxes, recieves unique cinema years from a database, creates a VBox for each year, adds the VBox to an anchor pane, and makes the anchor pane visible.
      Parameters:
      event - action event that triggered the filtration process.

      - Event type: `ActionEvent` - Target: `Anchore_Pane_filtrage` (a pane in the scene) - Command: Unspecified (as the function does not use a specific command)

    • closercommets

      void closercommets(javafx.event.ActionEvent event)
      Sets the opacity and visibility of an AnchorPane, and also makes a different AnchorPane visible.
      Parameters:
      event - user interaction that triggered the execution of the `closercommets` method.

      - Target: detalAnchorPane - Action: setOpacity() and setVisible() methods

    • filtrercinema

      void filtrercinema(javafx.event.ActionEvent event)
      Filters a list of cinemas based on user-selected years of release and displays the filtered cinemas in a flow pane.
      Parameters:
      event - occurrence of an action event, such as clicking on the "Filtrer" button, that triggers the execution of the `filtrercinema()` method.

      - `event` is an `ActionEvent`, indicating that the function was called as a result of user action. - The `event` object contains information about the source of the action, such as the button or link that was clicked.

    • getSelectedYears

      private List<Integer> getSelectedYears()
      Retrieves the selected years from an `AnchorPane` widget, filters out non-selected years using `filter`, maps the selected check boxes to their corresponding integers using `map`, and collects the list of integers representing the selected years.
    • switchtoajouterCinema

      public void switchtoajouterCinema(javafx.event.ActionEvent event)
      Loads a FXML file "/ui/series/SeriesClient.fxml" into a stage, replacing the current scene.
      Parameters:
      event - event that triggered the execution of the `switchtoajouterCinema()` method.

      - `event`: An `ActionEvent` object representing a user action.

    • switchtevent

      public void switchtevent(javafx.event.ActionEvent event)
      Loads and displays a FXML file using the `FXMLLoader` class, replacing the current scene with the new one.
      Parameters:
      event - ActionEvent that triggered the call to the `switchtevent()` method.

      - Type: ActionEvent - indicates that the event was triggered by an action (e.g., button click) - Target: null - indicates that the event did not originate from a specific component or element - Code: 0 - no code is provided with this event

    • switchtcinemaaa

      public void switchtcinemaaa(javafx.event.ActionEvent event)
      Loads a FXML file using the `FXMLLoader` class, creates a new `AnchorPane` root element, sets it as the scene of a stage, and displays the stage in a window with a specified size.
      Parameters:
      event - ActionEvent that triggered the call to the `switchtcinemaaa()` method.

      - `ActionEvent event`: Represents an action that occurred in the application, carrying information about the source of the action and the type of action performed.

    • switchtoajouterproduct

      public void switchtoajouterproduct(javafx.event.ActionEvent event)
      Loads an FXML file, creates a Stage and sets the Scene for displaying a user interface.
      Parameters:
      event - event that triggered the call to the `switchtoajouterproduct()` method.

      - Type: ActionEvent - indicates that the event was triggered by an action (e.g., button click) - Target: null - indicates that the event did not originate from a specific component or element - Code: 0 - no code is provided with this event

    • switchtoSerie

      public void switchtoSerie(javafx.event.ActionEvent event)
      Loads and displays a FXML file using the `FXMLLoader` class, replacing the current scene with the new one.
      Parameters:
      event - ActionEvent that triggered the call to the `switchtoSerie()` method.

      - Type: ActionEvent, indicating that the event was triggered by a user action.

    • addCommentaire

      void addCommentaire()
      Allows users to add comments to a film by providing a text input, displaying an alert if the comment is empty, and then creating a new FilmComment object with the provided message, user ID, and film ID using the FilmCommentService.
    • AddComment

      void AddComment(javafx.scene.input.MouseEvent event)
    • getAllComment

      private List<FilmComment> getAllComment(Long filmId)
    • getCurrentUserId

      private long getCurrentUserId()
    • getRecommendations

      private List<Film> getRecommendations(long userId)
    • afficherAnchorComment

      void afficherAnchorComment(javafx.scene.input.MouseEvent event)
    • addCommentToView

      private javafx.scene.layout.HBox addCommentToView(FilmComment commentaire)
      Creates an HBox containing an ImageView and a VBox with text, image and card container. It adds the HBox to a ScrollPaneComments.
      Parameters:
      commentaire - FilmComment object containing information about a comment made by a user on a film, which is used to display the commenter's name and comment text in the function's output.

      - `commentaire`: an object of class `FilmComment`, which contains information about a user's comment on a film. - `User_id`: a field in the `FilmComment` class that represents the user who made the comment. - `Photo_de_profil`: a field in the `FilmComment` class that represents the user's profile picture URL.

    • getAllComment

      private List<FilmComment> getAllComment(int filmId)
      Retrieves all comments for a given film ID and filters them to only include those that belong to the corresponding cinema.
      Parameters:
      filmId - id of the film for which the comments are to be retrieved.
    • displayAllComments

      private void displayAllComments(Long filmId)
      Displays all comments associated with a specific film ID in a scroll pane.
      Parameters:
      filmId - identifier of the film to display all comments for.
    • start

      public void start(javafx.stage.Stage stage) throws Exception
      Is called when the Java application begins and sets up the Stage for further interaction.
      Specified by:
      start in class javafx.application.Application
      Parameters:
      stage - Stage object that serves as the root of the JavaFX application's event handling and visual representation, and it is used to initialize the application's UI components and layout when the `start()` method is called.
      Throws:
      Exception
    • setupDragAndDrop

      private void setupDragAndDrop(javafx.scene.layout.AnchorPane filmCard, Film film)
    • getRecommendations

      private List<Film> getRecommendations(Long userId)
    • calculateSimilarityScore

      private double calculateSimilarityScore(Film film, Map<String,Double> userPreferences)
    • shareToSocial

      private void shareToSocial(Film film)
    • openTwitterShare

      private void openTwitterShare(String text)
    • openFacebookShare

      private void openFacebookShare(String text)
    • close

      public void close()
      Performs close operation.