Class TaskAntsAppointmentService
java.lang.Object
fr.paris.lutece.plugins.workflow.modules.appointmentants.service.TaskAntsAppointmentService
- All Implemented Interfaces:
ITaskAntsAppointmentService
Class containing useful methods to handle ANTS related tasks
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanaddAntsAppointmentRestCall(String antsUrl) Use the ANTS API to add an appointment to their databasestatic StringbuildAntsAddAppointmentUrl(String baseUrl, String addAppointmentUrl, String applicationId, String managementUrl, String meetingPoint, String strMeetingPointId, String dateTime) Build the URL used to add an appointment in the ANTS DBstatic StringbuildAntsDeleteAppointmentUrl(String baseUrl, String deleteAppointmentUrl, String applicationId, String meetingPoint, String strMeetingPointId, String dateTime) Build the URL used to delete an appointment from the ANTS DBstatic StringbuildAntsGetStatusAppointmentUrl(List<String> applicationIdsList, String strMeetingPointId) Build the URL used to get the status of specific ANTS appointmentsstatic StringProperly encode a String containing a URL to make sure it has the proper format (special characters encoding...)booleancreateAntsAppointment(javax.servlet.http.HttpServletRequest request, int idAppointment, int idTask, TaskAntsAppointmentHistory antsAppointmentHistory) Create an appointment in the ANTS databasebooleandeleteAntsAppointment(javax.servlet.http.HttpServletRequest request, int idAppointment, int idTask, TaskAntsAppointmentHistory antsAppointmentHistory) Remove an appointment from the ANTS databasestatic booleandeleteAntsAppointmentRestCall(String antsUrl) Use the ANTS API to delete an appointment from their databaseintgetAntsApplicationFieldId(int idTask) Get the ID of the entry field where the ANTS application numbers of an appointment are savedstatic StringgetAntsApplicationValuesFromResponse(int idAppointment, int entryFieldId) Get the ANTS application numbers value tied to an appointmentstatic List<AntsStatusResponsePOJO>getAntsStatusResponseAsObjects(List<String> applicationNumberList, String strMeetingPointId) Get the status of every ANTS application numbers given as parametergetAppointmentData(javax.servlet.http.HttpServletRequest request, int idAppointment, boolean isDeletingAppointment) Retrieve the details of the current appointment (user name, email, date, etc.)static List<AntsStatusResponsePOJO>getStatusResponseAsObject(String response) Creates a List ofAntsStatusResponsePOJOObjects from a json String containing the status and appointments list that were returned by the ANTS APIstatic booleanisApplicationNumberListValidForCreation(int idAppointment, List<String> applicationNumberList, String strMeetingPointId) Check if the status of the given application numbers are valid and allow to add new appointments ('validated' status and empty list of appointments)static booleanisApplicationNumberListValidForDeletion(int idAppointment, List<String> applicationNumberList, String strMeetingPointId) 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)static booleanisAppointmentCreatedInFrontOffice(fr.paris.lutece.plugins.appointment.business.appointment.Appointment appointment) Check if an appointment was created from the front office or from the back officestatic booleanisAppointmentCreationSuccessful(String response) Check whether an HTTP response returned a successful result or not when trying to create an appointment with the ANTS APIstatic booleanisAppointmentDeletionSuccessful(String response) 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 APIsplitAntsApplicationValues(String antsApplicationValues, String separator) Split the values from a String with a specific separator
-
Field Details
-
BEAN_SERVICE
- See Also:
-
KEY_URL
Variables used to save / retrieve specific details of an appointment- See Also:
-
KEY_LOCATION
- See Also:
-
KEY_DATE
- See Also:
-
KEY_FORM_ID
- See Also:
-
-
Method Details
-
createAntsAppointment
public boolean createAntsAppointment(javax.servlet.http.HttpServletRequest request, int idAppointment, int idTask, TaskAntsAppointmentHistory antsAppointmentHistory) Create an appointment in the ANTS database- Specified by:
createAntsAppointmentin interfaceITaskAntsAppointmentService- Parameters:
request- request to useidAppointment- ID of the appointment that will be processedidTask- ID of the workflow task calling this methodantsAppointmentHistory- 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:
deleteAntsAppointmentin interfaceITaskAntsAppointmentService- Parameters:
request- request to useidAppointment- ID of the appointment that will be processedidTask- ID of the workflow task calling this methodantsAppointmentHistory- 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 strMeetingPointId, String dateTime) Build the URL used to add an appointment in the ANTS DB- Parameters:
baseUrl- The base URL of the ANTS APIaddAppointmentUrl- The ANTS API's endpoint used to add appointmentsapplicationId- The ANTS application number used to create the appointmentmanagementUrl- The URL used to access the appointment's web pagemeetingPoint- The location of the appointmentstrMeetingPointId- The value of the "meeting_point_id" for the appointment's FormdateTime- 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.HttpAccessExceptionIOException
-
buildAntsDeleteAppointmentUrl
public static String buildAntsDeleteAppointmentUrl(String baseUrl, String deleteAppointmentUrl, String applicationId, String meetingPoint, String strMeetingPointId, String dateTime) Build the URL used to delete an appointment from the ANTS DB- Parameters:
baseUrl- The base URL of the ANTS APIdeleteAppointmentUrl- The ANTS API's endpoint used to delete an appointmentapplicationId- The ANTS application number used to identify the appointment to deletemeetingPoint- The location of the appointmentstrMeetingPointId- The value of the "meeting_point_id" for the appointment's FormdateTime- 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.HttpAccessExceptionIOException
-
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 contextidAppointment- The ID of the appointment to processisDeletingAntsAppointment- Whether the appointment is getting deleted (true) or if it is being created (false)- Returns:
- A <Key, Value> list of the current appointment's URL, location and date
-
getAntsStatusResponseAsObjects
public static List<AntsStatusResponsePOJO> getAntsStatusResponseAsObjects(List<String> applicationNumberList, String strMeetingPointId) 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 retrievedstrMeetingPointId- The value of the "meeting_point_id" parameter- 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, String strMeetingPointId) Build the URL used to get the status of specific ANTS appointments- Parameters:
applicationIdsList- The List of ANTS application numbers to usestrMeetingPointId- The value of the "meeting_point_id" for the current appointment's Form- 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, String strMeetingPointId) 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 processedapplicationNumberList- List of ANTS application numbers to check for validitystrMeetingPointId- The value of the "meeting_point_id" parameter- Returns:
- true if all the application numbers are valid, false otherwise
-
isApplicationNumberListValidForDeletion
public static boolean isApplicationNumberListValidForDeletion(int idAppointment, List<String> applicationNumberList, String strMeetingPointId) 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 processedapplicationNumberList- List of ANTS application numbers to check for potential deletionstrMeetingPointId- The value of the "meeting_point_id" parameter- 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 ofAntsStatusResponsePOJOObjects 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
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
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
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
Get the ANTS application numbers value tied to an appointment- Parameters:
idAppointment- ID of the appointmententryFieldId- 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 splitseparator- 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:
getAntsApplicationFieldIdin interfaceITaskAntsAppointmentService- Parameters:
idTask- ID of the task being executed- Returns:
- The ID of the entry field
-