Class SerieClientController

java.lang.Object
com.esprit.controllers.series.SerieClientController

public class SerieClientController extends Object
Is a controller for a series client application. It manages the display of a list of series in a JavaFX ListView and provides functionalities such as loading the series list, filtering the list based on user input, and displaying additional information about each series. The class also handles menu events for categories, episodes, and series.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private javafx.scene.control.ComboBox<Category>
     
    private List<Category>
     
    private javafx.scene.layout.HBox
     
    private List<Series>
     
    private javafx.scene.control.ListView<Series>
     
    private List<Series>
     
    private static final Logger
     
    private javafx.scene.control.TextField
     
    private javafx.scene.control.Label
     
    private final javafx.collections.ObservableList<String>
     
    (package private) javafx.scene.control.Button
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Retrieves a list of categories from an implementation of the `IServiceCategorieImpl` interface.
    (package private) void
    AfficherFavList(javafx.event.ActionEvent event)
    Loads a FXML file named `ListFavoris.fxml`, creates a new stage with the loaded scene, and displays it in the stage.
    void
    Displays a list of series from an API, along with buttons to watch or dislike each series, and a separator line after every element except the last one.
    private javafx.scene.layout.VBox
    Creates a Box object with a layout that displays an image and text information for a series.
    void
    Initializes the JavaFX controller and sets up UI components.
    private void
    Retrieves a list of series from a database using an implementation of `IServiceSerie`, then displays the list in a `ListView`.
    (package private) void
    Ocategories(javafx.event.ActionEvent event)
    Loads and displays a FXML file named "/ui//ui/CategorieClient.fxml" using the `FXMLLoader` class.
    (package private) void
    Oepisode(javafx.event.ActionEvent event)
    Loads an FXML file, creates a scene, sets it as the scene of a stage, and displays the stage.
    (package private) void
    onWatch(javafx.event.ActionEvent event)
    Loads an FXML file, `EpisodeClient.fxml`, and creates a new stage with its scene.
    (package private) void
    Oseries(javafx.event.ActionEvent event)
    Loads a FXML file, creates a scene and sets it as the scene of a stage, showing the stage.
    static List<Series>
    rechercher(List<Series> liste, String recherche)
    Searches for Series in a list based on a specified search term and returns a list of matching Series.
    private void
    Sorts a list of `Serie` objects based on their `nom` attribute, using a custom comparison method that ignores case and returns an integer value indicating the result of the comparison.

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

      private final javafx.collections.ObservableList<String> selectedCategories
    • watchEpisode

      javafx.scene.control.Button watchEpisode
    • resultatLabel

      private javafx.scene.control.Label resultatLabel
    • CamboxCategorie

      private javafx.scene.control.ComboBox<Category> CamboxCategorie
    • listeSerie

      private javafx.scene.control.ListView<Series> listeSerie
    • categorieList

      private List<Category> categorieList
    • listerecherche

      private List<Series> listerecherche
    • listeTop3

      private List<Series> listeTop3
    • recherchefld

      private javafx.scene.control.TextField recherchefld
    • hboxTop3

      private javafx.scene.layout.HBox hboxTop3
  • Constructor Details

    • SerieClientController

      public SerieClientController()
  • Method Details

    • rechercher

      public static List<Series> rechercher(List<Series> liste, String recherche)
      Searches for Series in a list based on a specified search term and returns a list of matching Series.
      Parameters:
      liste - list of series that is searched for matches in the `recherche` string.

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

      recherche - search query, which is used to filter the list of series and return only the matches.
    • onWatch

      void onWatch(javafx.event.ActionEvent event) throws IOException
      Loads an FXML file, `EpisodeClient.fxml`, and creates a new stage with its scene.
      Parameters:
      event - event that triggered the function, specifically an action event related to the `watchEpisode` button.

      Event: ActionEvent

      - Target: The object that triggered the event (not shown)

      Throws:
      IOException
    • createSeriesVBox

      private javafx.scene.layout.VBox createSeriesVBox(Series serie)
      Creates a Box object with a layout that displays an image and text information for a series. It takes a serie object as input, generates a VBox object with appropriate spacing, alignment, and padding, and adds three children to it: an ImageView with the series' image, a Label with the series' name, and another Label with the number of likes. The function then styles the Box and returns it.
      Parameters:
      serie - data structure containing information about a specific series, which is used to create a graphical representation of the series within the `VBox`.

      - `nom`: The name of the series. - `image`: The path to the image associated with the series. - `nbLikes`: The number of likes for the series.

    • afficher

      public void afficher() throws SQLException
      Retrieves a list of categories from an implementation of the `IServiceCategorieImpl` interface.
      Throws:
      SQLException
    • trierParNom

      private void trierParNom(List<Series> series)
      Sorts a list of `Serie` objects based on their `nom` attribute, using a custom comparison method that ignores case and returns an integer value indicating the result of the comparison.
      Parameters:
      series - list of series to be sorted, which is passed through the `Collections.sort()` method using a custom comparison algorithm based on the nomenclature of each series.
    • afficherliste

      public void afficherliste(List<Series> series)
      Displays a list of series from an API, along with buttons to watch or dislike each series, and a separator line after every element except the last one.
      Parameters:
      series - list of series that will be displayed in the client's profile, and it is used to populate the `listeSerie` observable list which is then passed as an argument to the `FXMLLoader` constructor to load the FXML file.

      - `id_serie`: an integer representing the ID of the series. - `name`: a string representing the name of the series. - `description`: a string representing the description of the series. - `director`: a string representing the director of the series. - `country`: a string representing the country where the series is from. - `year`: an integer representing the year the series was released. - `poster_path`: a string representing the path to the poster image of the series. - `clicks`: an integer representing the number of clicks on the series. - `favoris`: an integer representing the number of favorites for the series. - `nb_dislikes`: an integer representing the number of dislikes for the series.

    • AfficherFavList

      void AfficherFavList(javafx.event.ActionEvent event)
      Loads a FXML file named `ListFavoris.fxml`, creates a new stage with the loaded scene, and displays it in the stage.
      Parameters:
      event - event of the button click that triggered the function execution.

      - Event type: `ActionEvent` - Target object: none (the function is called directly without any target object)

    • initialize

      public void initialize() throws SQLException
      Initializes the JavaFX controller and sets up UI components. This method is called automatically by JavaFX after loading the FXML file.
      Throws:
      SQLException
    • Ocategories

      void Ocategories(javafx.event.ActionEvent event) throws IOException
      Loads and displays a FXML file named "/ui//ui/CategorieClient.fxml" using the `FXMLLoader` class.
      Parameters:
      event - event that triggered the function execution, which in this case is a button click event.

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

      Throws:
      IOException
    • Oseries

      void Oseries(javafx.event.ActionEvent event) throws IOException
      Loads a FXML file, creates a scene and sets it as the scene of a stage, showing the stage.
      Parameters:
      event - event that triggered the function execution, which in this case is a button click.

      - `event` represents an action event generated by the user's interaction with the application. - `getSource()` returns the source of the event, which is typically a button or other control in the user interface.

      Throws:
      IOException
    • Oepisode

      void Oepisode(javafx.event.ActionEvent event) throws IOException
      Loads an FXML file, creates a scene, sets it as the scene of a stage, and displays the stage.
      Parameters:
      event - event that triggered the execution of the `Oepisode` method, providing the necessary information for the method to perform its intended action.

      Event: An instance of the `ActionEvent` class, representing an action event generated by the user through mouse clicks or keyboard inputs.

      Properties:

      - `getSource()`: Returns the source of the event, which is usually a button or a menu item that was clicked/selected.

      Throws:
      IOException
    • loadSeriesList

      private void loadSeriesList() throws SQLException
      Retrieves a list of series from a database using an implementation of `IServiceSerie`, then displays the list in a `ListView`. It also calls another method, `findMostLiked`, on the same implementation to retrieve a list of top-rated series and adds them to the `ListView`.
      Throws:
      SQLException