Class TaskAntsAppointmentService

    • Method Detail

      • createAntsAppointment

        public boolean createAntsAppointment​(javax.servlet.http.HttpServletRequest request,
                                             int idAppointment,
                                             int idTask,
                                             TaskAntsAppointmentHistory antsAppointmentHistory)
        Create an appointment in the ANTS database
        Specified by:
        createAntsAppointment in interface ITaskAntsAppointmentService
        Parameters:
        request - request to use
        idAppointment - ID of the appointment that will be processed
        idTask - ID of the workflow task calling this method
        antsAppointmentHistory - Instance of TaskAntsAppointmentHistory object used to save the task's history
        Returns:
        true if it was successfully created, returns false if it failed
      • deleteAntsAppointment

        public boolean deleteAntsAppointment​(javax.servlet.http.HttpServletRequest request,
                                             int idAppointment,
                                             int idTask,
                                             TaskAntsAppointmentHistory antsAppointmentHistory)
        Remove an appointment from the ANTS database
        Specified by:
        deleteAntsAppointment in interface ITaskAntsAppointmentService
        Parameters:
        request - request to use
        idAppointment - ID of the appointment that will be processed
        idTask - ID of the workflow task calling this method
        antsAppointmentHistory - Instance of TaskAntsAppointmentHistory object used to save the task's history
        Returns:
        true if it was successfully deleted, returns false if it failed
      • isAppointmentCreatedInFrontOffice

        public static boolean isAppointmentCreatedInFrontOffice​(fr.paris.lutece.plugins.appointment.business.appointment.Appointment appointment)
        Check if an appointment was created from the front office or from the back office
        Parameters:
        appointment - The appointment to check
        Returns:
        true if it was created by a user in the front office, returns false otherwise
      • buildAntsAddAppointmentUrl

        public static String buildAntsAddAppointmentUrl​(String baseUrl,
                                                        String addAppointmentUrl,
                                                        String applicationId,
                                                        String managementUrl,
                                                        String meetingPoint,
                                                        String dateTime)
        Build the URL used to add an appointment in the ANTS DB
        Parameters:
        baseUrl - The base URL of the ANTS API
        addAppointmentUrl - The ANTS API's endpoint used to add appointments
        applicationId - The ANTS application number used to create the appointment
        managementUrl - The URL used to access the appointment's web page
        meetingPoint - The location of the appointment
        dateTime - The date and time of the appointment
        Returns:
        The complete URL used to create this specific appointment in the ANTS database
      • addAntsAppointmentRestCall

        public static boolean addAntsAppointmentRestCall​(String antsUrl)
                                                  throws fr.paris.lutece.util.httpaccess.HttpAccessException,
                                                         IOException
        Use the ANTS API to add an appointment to their database
        Parameters:
        antsUrl - URL used to make the REST call
        Returns:
        true if the appointment was added successfully, returns false otherwise
        Throws:
        fr.paris.lutece.util.httpaccess.HttpAccessException
        IOException
      • buildAntsDeleteAppointmentUrl

        public static String buildAntsDeleteAppointmentUrl​(String baseUrl,
                                                           String deleteAppointmentUrl,
                                                           String applicationId,
                                                           String meetingPoint,
                                                           String dateTime)
        Build the URL used to delete an appointment from the ANTS DB
        Parameters:
        baseUrl - The base URL of the ANTS API
        deleteAppointmentUrl - The ANTS API's endpoint used to delete an appointment
        applicationId - The ANTS application number used to identify the appointment to delete
        meetingPoint - The location of the appointment
        dateTime - The date and time of the appointment
        Returns:
        The complete URL used to delete this specific appointment from the ANTS database
      • deleteAntsAppointmentRestCall

        public static boolean deleteAntsAppointmentRestCall​(String antsUrl)
                                                     throws fr.paris.lutece.util.httpaccess.HttpAccessException,
                                                            IOException
        Use the ANTS API to delete an appointment from their database
        Parameters:
        antsUrl - URL used to make the REST call
        Returns:
        true if the appointment was deleted successfully, returns false otherwise
        Throws:
        fr.paris.lutece.util.httpaccess.HttpAccessException
        IOException
      • getAppointmentData

        public static Map<String,​String> getAppointmentData​(javax.servlet.http.HttpServletRequest request,
                                                                  int idAppointment,
                                                                  boolean isDeletingAppointment)
        Retrieve the details of the current appointment (user name, email, date, etc.)
        Parameters:
        request - The request from the current context
        idAppointment - The ID of the appointment to process
        isDeletingAntsAppointment - Whether the appointment is getting deleted (true) or if it is being created (false)
        Returns:
        A list of the current appointment's URL, location and date
      • getAntsStatusResponseAsObjects

        public static List<AntsStatusResponsePOJO> getAntsStatusResponseAsObjects​(List<String> applicationNumberList)
                                                                           throws fr.paris.lutece.util.httpaccess.HttpAccessException
        Get the status of every ANTS application numbers given as parameter
        Parameters:
        applicationNumberList - List of the application numbers for which the status will be retrieved
        Returns:
        A list of Objects representing the status of the given ANTS application numbers, returns an empty List if no element was found
        Throws:
        fr.paris.lutece.util.httpaccess.HttpAccessException
      • buildAntsGetStatusAppointmentUrl

        public static String buildAntsGetStatusAppointmentUrl​(List<String> applicationIdsList)
        Build the URL used to get the status of specific ANTS appointments
        Parameters:
        applicationIdsList - The List of ANTS application numbers to use
        Returns:
        The complete URL used to check the status of appointments from the ANTS database
      • isApplicationNumberListValidForCreation

        public static boolean isApplicationNumberListValidForCreation​(int idAppointment,
                                                                      List<String> applicationNumberList)
        Check if the status of the given application numbers are valid and allow to add new appointments ('validated' status and empty list of appointments)
        Parameters:
        idAppointment - ID of the appointment being processed
        applicationNumberList - List of ANTS application numbers to check for validity
        Returns:
        true if all the application numbers are valid, false otherwise
      • isApplicationNumberListValidForDeletion

        public static boolean isApplicationNumberListValidForDeletion​(int idAppointment,
                                                                      List<String> applicationNumberList)
        Check if the status of the given application numbers are valid and allow to delete existing appointments ('validated' status and at least 1 element in their list of appointment)
        Parameters:
        idAppointment - ID of the appointment being processed
        applicationNumberList - List of ANTS application numbers to check for potential deletion
        Returns:
        true if the appointments with the given application numbers can be deleted, false otherwise
      • getStatusResponseAsObject

        public static List<AntsStatusResponsePOJO> getStatusResponseAsObject​(String response)
                                                                      throws IOException
        Creates a List of AntsStatusResponsePOJO Objects from a json String containing the status and appointments list that were returned by the ANTS API
        Parameters:
        response - The content of the HTTP response returned by the ANTS API after getting the status of one or more ANTS application number(s)
        Returns:
        A List of AntsStatusResponsePOJO Objects. Each item represents the status of one ANTS application number
        Throws:
        IOException
      • cleanUrl

        public static String cleanUrl​(String urlToClean)
        Properly encode a String containing a URL to make sure it has the proper format (special characters encoding...)
        Parameters:
        urlToClean - The URL to process
        Returns:
        A URL with encoded characters. Returns the initial URL if an error occurred
      • isAppointmentCreationSuccessful

        public static boolean isAppointmentCreationSuccessful​(String response)
                                                       throws IOException
        Check whether an HTTP response returned a successful result or not when trying to create an appointment with the ANTS API
        Parameters:
        response - The content of the HTTP response returned by the ANTS API
        Returns:
        true if the appointment was created successfully, returns false otherwise
        Throws:
        IOException
      • isAppointmentDeletionSuccessful

        public static boolean isAppointmentDeletionSuccessful​(String response)
                                                       throws IOException
        Check whether an HTTP response returned a positive result (number of appointments deleted > 0) or not (0), when trying to delete an appointment with the ANTS API
        Parameters:
        response - The content of the HTTP response returned by the ANTS API
        Returns:
        true if the appointment was deleted successfully, returns false otherwise
        Throws:
        IOException
      • getAntsApplicationValuesFromResponse

        public static String getAntsApplicationValuesFromResponse​(int idAppointment,
                                                                  int entryFieldId)
        Get the ANTS application numbers value tied to an appointment
        Parameters:
        idAppointment - ID of the appointment
        entryFieldId - ID of the Entry used to save ANTS application numbers
        Returns:
        The ANTS application numbers value as a String
      • splitAntsApplicationValues

        public static List<String> splitAntsApplicationValues​(String antsApplicationValues,
                                                              String separator)
        Split the values from a String with a specific separator
        Parameters:
        antsApplicationValues - The String containing the values to split
        separator - Character used to separate the different values
        Returns:
        A List containing the separated values
      • getAntsApplicationFieldId

        public int getAntsApplicationFieldId​(int idTask)
        Get the ID of the entry field where the ANTS application numbers of an appointment are saved
        Specified by:
        getAntsApplicationFieldId in interface ITaskAntsAppointmentService
        Parameters:
        idTask - ID of the task being executed
        Returns:
        The ID of the entry field