Class OrderClientController

java.lang.Object
com.esprit.controllers.products.OrderClientController
All Implemented Interfaces:
javafx.fxml.Initializable

public class OrderClientController extends Object implements javafx.fxml.Initializable
Is responsible for handling user commands related to the cinema and event modules. It provides an interface for loading new fxml files based on user actions, such as showing a movie or an event. The controller also handles closing the current stage and displaying a new one. Additionally, it includes methods for handling Movie and Serie client interactions.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private javafx.scene.control.TextField
     
    private static final String
     
    private static final String
     
    private static final String
     
    private User
     
    private javafx.scene.control.Button
     
    private static final Logger
     
    private javafx.scene.control.TextField
     
    (package private) Order
     
    private final OrderService
     
    private javafx.scene.layout.AnchorPane
     
    private javafx.scene.layout.FlowPane
     
    private static final String
     
    (package private) double
     
    private final UserService
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    (package private) void
    cinemaclient(javafx.event.ActionEvent event)
    Charges a new `FXML` file, creates a new scene, and attaches it to a new stage, replacing the current stage.
    private void
    completePayment(String paymentId, String payerId)
    Executes a PayPal payment using the `execute()` method, checking the payment state and updating the order status accordingly.
    private javafx.scene.control.Label
    createPrixTotalLabel(double prixTotal)
    Creates a new `Label` component with a double value as its text and sets various styling properties to display the number in a specific format.
    private void
    decrementStock(Product produit, int quantity)
    Decrements the stock of a product in the database by subtracting the specified quantity from the product's current quantity, and updates the product record in the database using an instance of `ProductService`.
    (package private) void
    eventClient(javafx.event.ActionEvent event)
    Charges a new FXML file (`AffichageEvenementClient.fxml`) and creates a new scene, then attaches it to an existing stage and replaces the current stage with the new one, closing the original stage afterward.
    private String
    extractQueryParameter(String url, String parameterName)
    Parses a URL's query parameters and returns the value of a specified parameter name if it exists, or `null` otherwise.
    (package private) void
    initialize(Order orderselectionner)
    Sets the value of a `Order` object and runs a lambda action to retrieve and print the user's name, then creates a label with the total price and adds it to a `FlowPane`.
    void
    initialize(URL url, ResourceBundle resourceBundle)
    Is called when an URL and a resource bundle are provided to initialize the application.
    private boolean
    Verifies if a given string represents a valid phone number with exactly 8 digits and only containing numbers.
    (package private) void
    MovieClient(javafx.event.ActionEvent event)
    Loads a new FXML interface, creates a new scene with it, and attaches the scene to a new stage.
    (package private) void
    order(javafx.event.ActionEvent event)
    Validates input fields, creates a new command object, and calls a service method to create the command in the database.
    (package private) void
    payment(javafx.event.ActionEvent event)
    Creates a PayPal payment request and redirects the user to PayPal for approval.
    (package private) void
    produitClient(javafx.event.ActionEvent event)
    Loads a new FXML interface using `FXMLLoader`, creates a new scene with it, and attaches it to a new stage.
    (package private) void
    profilclient(javafx.event.ActionEvent event)
    Likely profiles a client-side application using Java's built-in profiling tools to gather performance data on various aspects of the application, such as CPU usage, memory allocation, and method execution time.
    private void
    redirectToPayPal(String approvalLink)
    Redirect users to PayPal's redirection page for successful payments, passing payment ID and payer ID as query parameters.
    (package private) void
    SerieClient(javafx.event.ActionEvent event)
    Loads a new FXML interface, creates a new scene, and attaches it to a new stage, while closing the current stage.
    (package private) void
    shoppingcart(javafx.scene.input.MouseEvent event)
    Loads a new UI scene from an FXML file, creates a new stage with the scene, and replaces the current stage with the new one, closing the original stage.
    private void
    showAlert(String title, String content)
    Creates an `Alert` object with specified title and content, then displays it using the `showAndWait()` method.
    (package private) void
    showcinema(javafx.event.ActionEvent event)
    Is triggered when the user clicks a button and displays a cinema-related interface.
    (package private) void
    showevenement(javafx.event.ActionEvent event)
    Is called when the `showEvenement` action is triggered and performs an unspecified action.
    (package private) void
    showmovie(javafx.event.ActionEvent event)
    Loads a new UI scene from an FXML file, creates a new stage with the scene, and replaces the current stage with the new one, closing the original stage.
    (package private) void
    showproduit(javafx.event.ActionEvent event)
    Is triggered by an ActionEvent and performs unspecified action related to showing a product.
    (package private) void
    showserie(javafx.event.ActionEvent event)
    Loads a new FXML file, creates a new scene and stage, and replaces the current stage with the new one.

    Methods inherited from class java.lang.Object

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

    • CLIENT_ID

      private static final String CLIENT_ID
    • CLIENT_SECRET

      private static final String CLIENT_SECRET
    • SUCCESS_URL

      private static final String SUCCESS_URL
    • CANCEL_URL

      private static final String CANCEL_URL
    • LOGGER

      private static final Logger LOGGER
    • orderService

      private final OrderService orderService
    • usersService

      private final UserService usersService
    • order

      Order order
    • totalPrix

      double totalPrix
    • adresseTextField

      private javafx.scene.control.TextField adresseTextField
    • numTelephoneTextField

      private javafx.scene.control.TextField numTelephoneTextField
    • paimenet

      private javafx.scene.layout.AnchorPane paimenet
    • connectedUser

      private User connectedUser
    • prixtotaleFlowPane

      private javafx.scene.layout.FlowPane prixtotaleFlowPane
    • idpaymentenligne

      private javafx.scene.control.Button idpaymentenligne
  • Constructor Details

    • OrderClientController

      public OrderClientController()
  • Method Details

    • initialize

      void initialize(Order orderselectionner)
      Sets the value of a `Order` object and runs a lambda action to retrieve and print the user's name, then creates a label with the total price and adds it to a `FlowPane`.
      Parameters:
      orderselectionner - selected command that triggers the function to execute, which is used to retrieve the total price from SharedData and create a label displaying the result.

      `orderselectionner`: An instance of `Order`, representing the selected command.

    • initialize

      public void initialize(URL url, ResourceBundle resourceBundle)
      Is called when an URL and a resource bundle are provided to initialize the application. It sets up the resources and prepares the application for usage.
      Specified by:
      initialize in interface javafx.fxml.Initializable
      Parameters:
      url - URL of the web application being initialized by the `initialize()` method.
      resourceBundle - collection of translated keys and their corresponding values
    • createPrixTotalLabel

      private javafx.scene.control.Label createPrixTotalLabel(double prixTotal)
      Creates a new `Label` component with a double value as its text and sets various styling properties to display the number in a specific format.
      Parameters:
      prixTotal - total price of an item, which is used to create a label with the value displayed.
    • order

      void order(javafx.event.ActionEvent event)
      Validates input fields, creates a new command object, and calls a service method to create the command in the database. It then iterates through each item in the command and creates a new item object, updates the inventory of the product, and sets the payment line visible.
      Parameters:
      event - action event triggered by clicking on the "Order" button, which initiates the processing of the command and calls the various methods to create and update objects and database records.

      - `event`: an ActionEvent object representing the user's action of clicking on the "Order" button.

    • showAlert

      private void showAlert(String title, String content)
      Creates an `Alert` object with specified title and content, then displays it using the `showAndWait()` method.
      Parameters:
      title - title of an alert message displayed by the `showAlert()` method.
      content - text to be displayed in the alert window.
    • isValidPhoneNumber

      private boolean isValidPhoneNumber(String phoneNumber)
      Verifies if a given string represents a valid phone number with exactly 8 digits and only containing numbers.
      Parameters:
      phoneNumber - 8-digit phone number to be validated for its correct format, consisting only of digits.
    • decrementStock

      private void decrementStock(Product produit, int quantity)
      Decrements the stock of a product in the database by subtracting the specified quantity from the product's current quantity, and updates the product record in the database using an instance of `ProductService`.
      Parameters:
      produit - product object whose stock is being decremented.

      - `produit`: A `Product` object representing a product. - `quantity`: An integer representing the quantity of the product to be decremented.

      quantity - amount of stock to be decremented from the product's current quantity in the database.
    • shoppingcart

      void shoppingcart(javafx.scene.input.MouseEvent event)
      Loads a new UI scene from an FXML file, creates a new stage with the scene, and replaces the current stage with the new one, closing the original stage.
      Parameters:
      event - MouseEvent object that triggered the function, providing information about the mouse button pressed, the screen position of the click, and other details.

      - Type: `MouseEvent` indicating that the event was triggered by a mouse action. - Source: The object that generated the event, which is typically a button or link in the user interface. - Event type: The specific type of event, such as `MOUSE_CLICKED` or `MOUSE_OVER`.

    • payment

      void payment(javafx.event.ActionEvent event)
      Creates a PayPal payment request and redirects the user to PayPal for approval. It retrieves the payment details and redirects the user to the appropriate URL based on the payment method.
      Parameters:
      event - event that triggered the `payment()` method and provides the necessary context for the payment creation process.

      - `event`: An ActionEvent object representing a payment action triggered by the user.

    • redirectToPayPal

      private void redirectToPayPal(String approvalLink)
      Redirect users to PayPal's redirection page for successful payments, passing payment ID and payer ID as query parameters.
      Parameters:
      approvalLink - URL of the PayPal approval page, which is loaded into a WebView component and monitored for the successful redirection to a predefined URL indicating the completion of the payment process.
    • extractQueryParameter

      private String extractQueryParameter(String url, String parameterName)
      Parses a URL's query parameters and returns the value of a specified parameter name if it exists, or `null` otherwise.
      Parameters:
      url - URL to be analyzed and is used to extract the query parameter value using `URLEncodedUtils.parse()`.
      parameterName - name of the query parameter to be extracted from the URL.
    • completePayment

      private void completePayment(String paymentId, String payerId)
      Executes a PayPal payment using the `execute()` method, checking the payment state and updating the order status accordingly.
      Parameters:
      paymentId - unique identifier of the payment to be executed.
      payerId - identifier of the payer in the PayPal payment execution, which is used to identify the user making the payment.
    • cinemaclient

      void cinemaclient(javafx.event.ActionEvent event)
      Charges a new `FXML` file, creates a new scene, and attaches it to a new stage, replacing the current stage.
      Parameters:
      event - ActionEvent that triggered the function execution and provides access to information about the event, such as the source of the event.

      - It is an `ActionEvent`, which means it carries information about the action that triggered the function. - The source of the event is a `Node`, which represents the element in the user interface that triggered the event.

    • eventClient

      void eventClient(javafx.event.ActionEvent event)
      Charges a new FXML file (`AffichageEvenementClient.fxml`) and creates a new scene, then attaches it to an existing stage and replaces the current stage with the new one, closing the original stage afterward.
      Parameters:
      event - ActionEvent object that triggered the event handler method, providing information about the action that was performed, such as the source of the event and the type of event.

      - It is an instance of `ActionEvent`, which indicates that the event was triggered by a user action (e.g., clicking a button).

    • produitClient

      void produitClient(javafx.event.ActionEvent event)
      Loads a new FXML interface using `FXMLLoader`, creates a new scene with it, and attaches it to a new stage. It then closes the current stage to display the new one.
      Parameters:
      event - ActionEvent object that triggered the function execution, providing the source of the event and allowing for handling the corresponding action.

      - `event`: an ActionEvent object representing a user action (e.g., mouse click or key press) that triggered the function execution.

    • profilclient

      void profilclient(javafx.event.ActionEvent event)
      Likely profiles a client-side application using Java's built-in profiling tools to gather performance data on various aspects of the application, such as CPU usage, memory allocation, and method execution time.
      Parameters:
      event - occurrence of an action event that triggered the function execution.
    • showcinema

      void showcinema(javafx.event.ActionEvent event)
      Is triggered when the user clicks a button and displays a cinema-related interface.
      Parameters:
      event - occurrence of a button click event that triggered the `showcinema()` method invocation.
    • showevenement

      void showevenement(javafx.event.ActionEvent event)
      Is called when the `showEvenement` action is triggered and performs an unspecified action.
      Parameters:
      event - AnimationEvent object that triggered the execution of the `showEvenement` method.
    • showmovie

      void showmovie(javafx.event.ActionEvent event)
      Loads a new UI scene from an FXML file, creates a new stage with the scene, and replaces the current stage with the new one, closing the original stage.
      Parameters:
      event - ActionEvent object that triggered the showmovie method, providing information about the source of the event and allowing the method to handle the appropriate action accordingly.

      - It is an instance of `ActionEvent`, which represents an action event occurred in the JavaFX application. - The source of the event is a `Node`, which can be any element in the FXML document, such as a button or a label.

    • showproduit

      void showproduit(javafx.event.ActionEvent event)
      Is triggered by an ActionEvent and performs unspecified action related to showing a product.
      Parameters:
      event - occurrence of an action, triggered by the user, that calls the `showproduit()` method.
    • showserie

      void showserie(javafx.event.ActionEvent event) throws IOException
      Loads a new FXML file, creates a new scene and stage, and replaces the current stage with the new one.
      Parameters:
      event - ActionEvent that triggered the function, providing the source of the event and allowing for proper handling of the action taken.

      - `event` represents an ActionEvent object containing information about the action that triggered the function's execution.

      Throws:
      IOException
    • MovieClient

      void MovieClient(javafx.event.ActionEvent event)
      Loads a new FXML interface, creates a new scene with it, and attaches the scene to a new stage. It also closes the current stage.
      Parameters:
      event - event that triggers the execution of the `MovieClient` method, which is an ActionEvent object containing information about the action that triggered the method call.

      - `event` is an `ActionEvent` object representing the user's action that triggered the function. - The source of the event is a `Node` object, which provides information about the element that was clicked or selected.

    • SerieClient

      void SerieClient(javafx.event.ActionEvent event)
      Loads a new FXML interface, creates a new scene, and attaches it to a new stage, while closing the current stage.
      Parameters:
      event - ActionEvent object that triggered the `SerieClient()` method to be called, providing the source of the event and any related data.

      - It is an instance of `ActionEvent`, representing an action performed on the JavaFX application. - Its source field references the object that triggered the event, which in this case is a `Node` (i.e., a FXML component).