Class DashboardClientController

java.lang.Object
com.esprit.controllers.cinemas.DashboardClientController

public class DashboardClientController extends Object
Is responsible for handling user interactions related to the cinema dashboard. It provides methods for displaying all comments, adding new comments, and closing the comment section. The class also includes a scroll pane for displaying all comments for a given cinema ID. Additionally, it includes an HBox for each comment, which contains an image of the user who made the comment, their name, and the comment itself.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final List<javafx.scene.control.CheckBox>
     
    private javafx.scene.layout.AnchorPane
     
    private javafx.scene.layout.AnchorPane
     
    private Cinema
     
    private javafx.scene.layout.FlowPane
     
    private Long
     
    private javafx.scene.control.Button
     
    private javafx.scene.layout.AnchorPane
     
    private List<Cinema>
     
    private LocalDate
     
    private javafx.scene.layout.AnchorPane
     
    private static final Logger
     
    private final List<javafx.scene.layout.VBox>
     
    private final List<javafx.scene.control.CheckBox>
     
    private javafx.scene.layout.FlowPane
     
    private javafx.scene.layout.FlowPane
     
    private javafx.scene.layout.AnchorPane
     
    private javafx.scene.control.ScrollPane
     
    private javafx.scene.control.TextField
     
    private javafx.scene.layout.TilePane
     
    private javafx.scene.control.ComboBox<String>
     
    private javafx.scene.control.TextArea
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    (package private) void
    AddComment(javafx.scene.input.MouseEvent event)
    Adds a comment to a cinema and displays all comments for that cinema when the event is triggered.
    (package private) void
    Allows users to add comments to a cinema.
    private javafx.scene.layout.HBox
    Creates a container for displaying a user's comment and image, with a transparent background and padding.
    (package private) void
    afficherEventsClient(javafx.event.ActionEvent event)
    Loads an fxml file and displays a stage with the content from the loaded fxml.
    (package private) void
    afficherMoviesClient(javafx.event.ActionEvent event)
    Displays a FXML user interface for managing movies using an FXMLLoader and a Stage object.
    (package private) void
    afficherProductsClient(javafx.event.ActionEvent event)
    Loads an FXML file to display a product client interface, creates a new stage for the interface, and closes the previous stage.
    (package private) void
    afficherSeriesClient(javafx.event.ActionEvent event)
    Loads a FXML file "/ui/series/SeriesClient.fxml" and displays it on a new stage, replacing the current stage.
    (package private) void
    closeCommets(javafx.scene.input.MouseEvent event)
    Sets the opacity of a component to 1, makes an component invisible and another visible.
    private javafx.scene.layout.HBox
    Creates a card container and adds various components to it, including an image view for the cinema logo, labels for the name and address, a vertical line, buttons for showing movies and planning, and a rating component.
    private void
    Creates film cards for a list of cinemas and adds them to a pane containing the film cards.
    private javafx.scene.layout.StackPane
    Generates a stack pane containing a card with information about a moviesession, including the film's name, cinema hall, screening time, and price.
    void
    createTopRatedCinemaCards(javafx.scene.layout.AnchorPane Anchortop3)
    Creates and positions top-rated cinema cards within an `AnchorPane`.
    private void
    Displays all comments associated with a particular cinema ID in a scroll pane.
    private void
    Loads the current week's planning data, displays it in a VBox, and adds an event listener to display more detailed moviesession information when a date is clicked.
    (package private) void
    filtrer(javafx.event.ActionEvent event)
    Updates the visibility of the `filterAnchor` pane and adds two VBoxes containing check boxes for addresses and names to the pane.
    (package private) void
    filtrercinema(javafx.event.ActionEvent event)
    Filters a list of cinemas based on selected addresses and/or names, and displays the filtered list in a flow pane.
    private void
    Geocodes a given address by sending a GET request to the OpenStreetMap Nominatim API and retrieving the lat and lon coordinates for the address.
    private List<Cinema>
    Retrieves a list of cinemas through a call to the ` CinemaService`.
    getAllComment(Long cinemaId)
    Retrieves all comments related to a specific cinema, using a service to read the comments and then filtering them based on the cinema ID.
    Retrieves all cinemas from a database, extracts unique addresses from them using Stream API, and returns a list of those addresses.
    Retrieves a list of unique cinema names from a database by mapping and collecting the `nom` attributes of each `Cinema` object in the list.
    private List<String>
    Streams, filters, and collects the selected addresses from the `addressCheckBoxes` array, returning a list of strings representing the selected addresses.
    private List<String>
    In Java code returns a list of selected names from an `AnchorPane` of filtering by streaming, filtering, and mapping the values of `CheckBox` objects.
    void
    Sets up the user interface and connects it to a `CinemaService` for movie data retrieval.
    private HashSet<Cinema>
    Loads a set of cinemas from a service, filters them based on their status, and returns a HashSet of accepted cinemas to be displayed in a user interface.
    Loads the planning for the current week (Sunday to Saturday) for a given cinema using MovieSessionService.
    private void
    openMapDialog(double lat, double lon)
    Creates a new dialog, loads a map into a WebView, updates the marker position using JavaScript, and displays the dialog with a close button.
    (package private) void
    Planninggclose(javafx.event.ActionEvent event)
    Sets the visibility of a pane and two lists to false and true, respectively, upon an action event.
    static List<Cinema>
    rechercher(List<Cinema> liste, String recherche)
    Searches for Cinema objects in a list based on a search term and returns a list of matching objects.
    private void
    showAlert(String message)
    Creates an Alert object with a title, header text, and content text.
    (package private) void
    showListCinema(javafx.event.ActionEvent event)
    Clears the children of a `FlowPane`, loads and displays a list of accepted cinemas, and sets the visibility of the `listCinemaClient` and `PlanningPane` to `true` and `false`, respectively.
    void
    Displays a planning page for a cinema, consisting of 7 days of the week, each day represented by a label with the date and a button to display moviesessions for that date.

    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
    • addressCheckBoxes

      private final List<javafx.scene.control.CheckBox> addressCheckBoxes
    • namesCheckBoxes

      private final List<javafx.scene.control.CheckBox> namesCheckBoxes
    • moviesessionsVBoxList

      private final List<javafx.scene.layout.VBox> moviesessionsVBoxList
    • cinemaFlowPane

      private javafx.scene.layout.FlowPane cinemaFlowPane
    • listCinemaClient

      private javafx.scene.layout.AnchorPane listCinemaClient
    • PlanningPane

      private javafx.scene.layout.AnchorPane PlanningPane
    • planningFlowPane

      private javafx.scene.layout.FlowPane planningFlowPane
    • parentContainer

      private javafx.scene.layout.FlowPane parentContainer
    • searchbar1

      private javafx.scene.control.TextField searchbar1
    • filterAnchor

      private javafx.scene.layout.AnchorPane filterAnchor
    • txtAreaComments

      private javafx.scene.control.TextArea txtAreaComments
    • ScrollPaneComments

      private javafx.scene.control.ScrollPane ScrollPaneComments
    • AnchorComments

      private javafx.scene.layout.AnchorPane AnchorComments
    • closeDetailFilm

      private javafx.scene.control.Button closeDetailFilm
    • cinema

      private Cinema cinema
    • tilePane

      private javafx.scene.layout.TilePane tilePane
    • cinemaId

      private Long cinemaId
    • l1

      private List<Cinema> l1
    • tricomboBox

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

      private LocalDate lastSelectedDate
    • Anchortop3

      private javafx.scene.layout.AnchorPane Anchortop3
  • Constructor Details

    • DashboardClientController

      public DashboardClientController()
  • Method Details

    • rechercher

      public static List<Cinema> rechercher(List<Cinema> liste, String recherche)
      Searches for Cinema objects in a list based on a search term and returns a list of matching objects.
      Parameters:
      liste - list of cinemas to search in.

      - `liste` is a list of `Cinema` objects.

      recherche - search query used to filter the list of cinemas returned by the function.
    • Planninggclose

      void Planninggclose(javafx.event.ActionEvent event)
      Sets the visibility of a pane and two lists to false and true, respectively, upon an action event.
      Parameters:
      event - event that triggered the `Planninggclose()` method to be called, providing the necessary context for the method to perform its intended action.

      Event: `ActionEvent`

      - `target`: Reference to the component that triggered the event (in this case, `PlanningPane`) - `code`: The action that was performed (in this case, `setVisible(false)`)

    • showListCinema

      void showListCinema(javafx.event.ActionEvent event)
      Clears the children of a `FlowPane`, loads and displays a list of accepted cinemas, and sets the visibility of the `listCinemaClient` and `PlanningPane` to `true` and `false`, respectively.
      Parameters:
      event - user's action of clicking the "Show List Cinema" button, which triggers the function to clear the content of the `cinemaFlowPane`, load the accepted cinemas, and set the visibility of the `listCinemaClient` and `PlanningPane`.

      Event: An action event object representing a user interaction.

    • loadAcceptedCinemas

      private HashSet<Cinema> loadAcceptedCinemas()
      Loads a set of cinemas from a service, filters them based on their status, and returns a HashSet of accepted cinemas to be displayed in a user interface.
    • showAlert

      private void showAlert(String message)
      Creates an Alert object with a title, header text, and content text. It then shows the Alert to the user.
      Parameters:
      message - text to be displayed as an information alert when the `showAlert()` method is called.
    • createCinemaCard

      private javafx.scene.layout.HBox createCinemaCard(Cinema cinema)
      Creates a card container and adds various components to it, including an image view for the cinema logo, labels for the name and address, a vertical line, buttons for showing movies and planning, and a rating component.
      Parameters:
      cinema - Cinema object that provides the necessary information for creating the cinema card, such as name, logo, address, and rating.

      - `getLogo()`: returns the cinema's logo as a string - `getName()`: returns the cinema's name - `getAdresse()`: returns the cinema's address - `getId_cinema()`: returns the cinema's ID

      These properties are used to create and display a card for the cinema.

    • createTopRatedCinemaCards

      public void createTopRatedCinemaCards(javafx.scene.layout.AnchorPane Anchortop3)
      Creates and positions top-rated cinema cards within an `AnchorPane`. Each card displays the cinema's name, address, and logo, and is spaced apart by a fixed distance. The position of the next card is updated after each card is added.
      Parameters:
      Anchortop3 - `AnchorPane` where the top-rated cinema cards will be added.

      - `Anchortop3`: Anchor pane where the cinema cards will be added. - `topRatedCinemas`: List of top-rated cinemas to create cards for. - `cardHeight`: Height of each cinema card. - `cardSpacing`: Spacing between each cinema card. - `currentY`: Position Y of the first cinema card.

    • geocodeAddress

      private void geocodeAddress(String address)
      Geocodes a given address by sending a GET request to the OpenStreetMap Nominatim API and retrieving the lat and lon coordinates for the address. It then opens a map dialog with the retrieved coordinates.
      Parameters:
      address - address to be geocoded, which is sent as a query to the Nominatim API to retrieve the latitude and longitude coordinates for the location.
    • openMapDialog

      private void openMapDialog(double lat, double lon)
      Creates a new dialog, loads a map into a WebView, updates the marker position using JavaScript, and displays the dialog with a close button.
      Parameters:
      lat - latitude coordinate of the map location, which is used to load the appropriate map and place a marker at the corresponding position on the map.
      lon - longitude coordinate of the location where the map should be displayed, which is used to load the appropriate map and place a marker at the specified position.
    • showPlanning

      public void showPlanning(Cinema cinema)
      Displays a planning page for a cinema, consisting of 7 days of the week, each day represented by a label with the date and a button to display moviesessions for that date.
      Parameters:
      cinema - Cinema object that contains information about the cinema and its scheduling.

      - `listCinemaClient`: A visible container for cinema client listings (set to `false`). - `PlanningPane`: Visible pane displaying the planning schedule (set to `true`). - `tilePane`: A container for displaying individual days of the week in a tile format (created and added to `planningContent`).

    • loadCurrentWeekPlanning

      private Map<LocalDate,List<MovieSession>> loadCurrentWeekPlanning(LocalDate startDate, Cinema cinema)
      Loads the planning for the current week (Sunday to Saturday) for a given cinema using MovieSessionService.
      Parameters:
      startDate - starting date of the current week for which the planning is being loaded.

      - LocalDate representing the start date of the current week - Can be modified or manipulated within the function

      Please provide the Java code for which you would like a summary.

      cinema - cinemas for which the moviesession is being planned.

      - Cinema is an object representing a cinema with unknown details.

    • displayMovieSessionsForDate

      private void displayMovieSessionsForDate(LocalDate date, Cinema cinema)
      Loads the current week's planning data, displays it in a VBox, and adds an event listener to display more detailed moviesession information when a date is clicked.
      Parameters:
      date - LocalDate for which to display the cinema moviesessions, and it is used to load the relevant planning data from the database or API.

      - `LocalDate date`: represents a specific date in the format `YYYY-MM-DD`. - ` cinema`: represents the cinema for which the seating plan is being generated.

      cinema - cinema for which the moviesessions are being displayed, and is used to load the relevant planning data into the function.

      - `cinema`: A `Cinema` object representing the cinema for which the moviesessions are being displayed. Its main properties include the cinema's name and address.

    • createMovieSessionCard

      private javafx.scene.layout.StackPane createMovieSessionCard(MovieSession moviesession)
      Generates a stack pane containing a card with information about a moviesession, including the film's name, cinema hall, screening time, and price.
      Parameters:
      moviesession - MovieSession object that contains information about the film, cinemahall, and time of the screening, which is used to populate the card with relevant labels.

      - `moviesession.getFilmcinema()`: Returns an instance of `Filmcinema` containing information about the film showing at the moviesession. - `moviesession.getName_cinemahall()`: Returns the name of the hall where the moviesession is taking place. - `moviesession.getHD()` and `moviesession.getHF()`: Return the starting time and ending time of the moviesession, respectively. - `moviesession.getPrice()`: Returns the price of the moviesession.

    • initialize

      public void initialize()
      Sets up the user interface and connects it to a `CinemaService` for movie data retrieval. It listens for text changes in a search bar, queries the service for relevant movies, and displays them on a pane. Additionally, it sorts and displays top-rated movies based on a predetermined criterion.
    • createCinemaCards

      private void createCinemaCards(List<Cinema> cinemas)
      Creates film cards for a list of cinemas and adds them to a pane containing the film cards.
      Parameters:
      cinemas - List of cinemas for which film cards are to be created and added to the pane.
    • getAllCinemas

      private List<Cinema> getAllCinemas()
      Retrieves a list of cinemas through a call to the ` CinemaService`. It then returns the list of cinemas.
    • filtrer

      void filtrer(javafx.event.ActionEvent event)
      Updates the visibility of the `filterAnchor` pane and adds two VBoxes containing check boxes for addresses and names to the pane.
      Parameters:
      event - Anchor Button's event that triggered the filtration process.

      - `event`: An `ActionEvent` object representing the triggered action. - `listCinemaClient`: A `VBox` container for displaying the cinema client list. - `filterAnchor`: A `Region` component for hosting the filtering controls.

    • filtrercinema

      void filtrercinema(javafx.event.ActionEvent event)
      Filters a list of cinemas based on selected addresses and/or names, and displays the filtered list in a flow pane.
      Parameters:
      event - occurrence of an action event, triggering the function to execute and filter the cinemas based on the selected addresses and/or names.

      - `listCinemaClient`: A reference to an observable list of cinemas. - `filterAnchor`: A reference to a component that displays a filter option. - `getSelectedAddresses()` and `getSelectedNames()`: Methods that return lists of selected addresses and names, respectively.

    • getSelectedAddresses

      private List<String> getSelectedAddresses()
      Streams, filters, and collects the selected addresses from the `addressCheckBoxes` array, returning a list of strings representing the selected addresses.
    • getSelectedNames

      private List<String> getSelectedNames()
      In Java code returns a list of selected names from an `AnchorPane` of filtering by streaming, filtering, and mapping the values of `CheckBox` objects.
    • getCinemaAddresses

      public List<String> getCinemaAddresses()
      Retrieves all cinemas from a database, extracts unique addresses from them using Stream API, and returns a list of those addresses.
    • getCinemaNames

      public List<String> getCinemaNames()
      Retrieves a list of unique cinema names from a database by mapping and collecting the `nom` attributes of each `Cinema` object in the list.
    • afficherEventsClient

      void afficherEventsClient(javafx.event.ActionEvent event) throws IOException
      Loads an fxml file and displays a stage with the content from the loaded fxml.
      Parameters:
      event - Event Object that triggered the function, providing information about the event that occurred, such as the source of the event and the type of event.

      Event type: The type of event that triggered the function execution, which could be any of the possible types recognized by the application.

      Throws:
      IOException
    • afficherMoviesClient

      void afficherMoviesClient(javafx.event.ActionEvent event) throws IOException
      Displays a FXML user interface for managing movies using an FXMLLoader and a Stage object.
      Parameters:
      event - an action event that triggered the function execution, providing the necessary context for the code to perform its intended task.

      - `event` is an `ActionEvent`, indicating that the function was triggered by user action.

      Throws:
      IOException
    • afficherProductsClient

      void afficherProductsClient(javafx.event.ActionEvent event) throws IOException
      Loads an FXML file to display a product client interface, creates a new stage for the interface, and closes the previous stage.
      Parameters:
      event - event that triggered the function, specifically the button click event that activates the function to display the product client interface.

      - `event`: An `ActionEvent` object representing a user action that triggered the function execution.

      Throws:
      IOException
    • afficherSeriesClient

      void afficherSeriesClient(javafx.event.ActionEvent event) throws IOException
      Loads a FXML file "/ui/series/SeriesClient.fxml" and displays it on a new stage, replacing the current stage.
      Parameters:
      event - event that triggered the execution of the `afficherSeriesClient()` method, specifically the button click event on the client series view.

      - Event type: `ActionEvent` - Source object: (`Node`) reference to the element that triggered the event

      Throws:
      IOException
    • addCommentaire

      void addCommentaire()
      Allows users to add comments to a cinema. When a user clicks on the "Add Comment" button, the function takes the user's comment and analyzes its sentiment using a sentiment analysis controller. If the comment is not empty, the function creates a new `CinemaComment` object with the cinema ID, user ID, message, and sentiment result, and saves it to the database using the `CommentaireCinamaService`.
    • AddComment

      void AddComment(javafx.scene.input.MouseEvent event)
      Adds a comment to a cinema and displays all comments for that cinema when the event is triggered.
      Parameters:
      event - user's click on the "Add Comment" button, which triggers the execution of the `addCommentaire()` method and the display of all comments for the specified `cinemaId`.
    • getAllComment

      private List<CinemaComment> getAllComment(Long cinemaId)
      Retrieves all comments related to a specific cinema, using a service to read the comments and then filtering them based on the cinema ID.
      Parameters:
      cinemaId - Id of the cinema for which the comments are to be retrieved.
    • addCommentToView

      private javafx.scene.layout.HBox addCommentToView(CinemaComment commentaire)
      Creates a container for displaying a user's comment and image, with a transparent background and padding. It also sets the image view's position to center the image within the circle.
      Parameters:
      commentaire - CinemaComment object passed to the function, containing information about the user's comment and image.

      - `client`: contains information about the user who made the comment + `getPhotoDeProfil()`: the URL of the user's profile picture - `getCommentaire()`: the actual comment made by the user

      Both properties are used to generate the image and text display for the comment.

    • displayAllComments

      private void displayAllComments(Long cinemaId)
      Displays all comments associated with a particular cinema ID in a scroll pane.
      Parameters:
      cinemaId - identity of the cinema for which all comments are to be displayed.
    • closeCommets

      void closeCommets(javafx.scene.input.MouseEvent event)
      Sets the opacity of a component to 1, makes an component invisible and another visible.
      Parameters:
      event - mouse event that triggered the execution of the `closeCommets()` method.

      Event type: MouseEvent Target element: AnchorComments Current state: Visible