Class FormUtils

java.lang.Object
fr.paris.lutece.plugins.form.utils.FormUtils

public final class FormUtils extends Object
class FormUtils
  • Field Details

  • Method Details

    • sendNotificationMailEndDisponibility

      public static void sendNotificationMailEndDisponibility(Form form, Locale locale)
      sendMail to the mailing list associate to the form a mail of end disponibility
      Parameters:
      form - the form
      locale - the locale
    • sendNotificationMailFormSubmit

      public static void sendNotificationMailFormSubmit(Form form, Locale locale)
      sendMail to the mailing list associate to the form a mail of new form submit
      Parameters:
      form - the form
      locale - the locale
    • getDateLastMinute

      public static Timestamp getDateLastMinute(Date date, Locale locale)
      return a timestamp Object which correspond with the string specified in parameter.
      Parameters:
      date - the date who must convert
      locale - the locale
      Returns:
      a timestamp Object which correspond with the string specified in parameter.
    • getDateFirstMinute

      public static Timestamp getDateFirstMinute(Date date, Locale locale)
      return a timestamp Object which correspond with the string specified in parameter.
      Parameters:
      date - the date who must convert
      locale - the locale
      Returns:
      a timestamp Object which correspond with the string specified in parameter.
    • getDay

      public static int getDay(Timestamp timestamp)
      return the day of the timestamp in parameter
      Parameters:
      timestamp - date
      Returns:
      the day of the timestamp in parameter
    • getWeek

      public static int getWeek(Timestamp timestamp)
      return the week of the timestamp in parameter
      Parameters:
      timestamp - date
      Returns:
      the week of the timestamp in parameter
    • getMonth

      public static int getMonth(Timestamp timestamp)
      return the month of the timestamp in parameter
      Parameters:
      timestamp - date
      Returns:
      the month of the timestamp in parameter
    • getYear

      public static int getYear(Timestamp timestamp)
      return the year of the timestamp in parameter
      Parameters:
      timestamp - date
      Returns:
      the year of the timestamp in parameter
    • addStatisticInterval

      public static Timestamp addStatisticInterval(Timestamp timestamp, String strTimesUnit, int nDecal)
      return a timestamp Object which correspond to the timestamp in parameter add with a number of times unit (day,week,month)specify in strTimesUnit .
      Parameters:
      timestamp - date
      strTimesUnit - (day,week,month)
      nDecal - the number of timesUnit
      Returns:
      a timestamp Object which correspond with the string specified in parameter add with a number of times unit (day,week,month)specify in strTimesUnit.
    • sameDate

      public static boolean sameDate(Timestamp timestamp1, Timestamp timestamp2, String strTimesUnit)
      Compare two timestamp and return true if they have the same times unit(Day,week,month)
      Parameters:
      timestamp1 - timestamp1
      timestamp2 - timestamp2
      strTimesUnit - (day,week,month)
      Returns:
      Compare two timestamp and return true if they have the same times unit(Day,week,month)
    • getDateString

      public static String getDateString(Timestamp date, Locale locale)
      Deprecated.
      Converts une java.sql.Timestamp date in a String date in a "jj/mm/aaaa" format
      Parameters:
      date - java.sql.Timestamp date to convert
      locale - the locale
      Returns:
      strDate The String date in the short locale format or the emmpty String if the date is null
    • getCurrentTimestamp

      public static Timestamp getCurrentTimestamp()
      return current Timestamp
      Returns:
      return current Timestamp
    • getCurrentDate

      public static Date getCurrentDate()
      return current date without hours, minutes and milliseconds
      Returns:
      return current date
    • createEntryByType

      public static IEntry createEntryByType(javax.servlet.http.HttpServletRequest request, fr.paris.lutece.portal.service.plugin.Plugin plugin)
      return an instance of IEntry function of type entry
      Parameters:
      request - the request
      plugin - the plugin
      Returns:
      an instance of IEntry function of type entry
    • getIndexEntryInTheEntryList

      public static int getIndexEntryInTheEntryList(int nIdEntry, List<IEntry> listEntry)
      return the index in the list of the entry whose key is specified in parameter
      Parameters:
      nIdEntry - the key of the entry
      listEntry - the list of the entry
      Returns:
      the index in the list of the entry whose key is specified in parameter
    • getIndexFieldInTheFieldList

      public static int getIndexFieldInTheFieldList(int nIdField, List<Field> listField)
      return the index in the list of the field whose key is specified in parameter
      Parameters:
      nIdField - the key of the field
      listField - the list of field
      Returns:
      the index in the list of the field whose key is specified in parameter
    • getHtmlForm

      public static String getHtmlForm(Form form, String strUrlAction, fr.paris.lutece.portal.service.plugin.Plugin plugin, Locale locale)
      return the html code of the form
      Parameters:
      form - the form which html code must be return
      strUrlAction - the url who must be call after the form submit
      plugin - the plugin
      locale - the locale
      Returns:
      the html code of the form
    • getHtmlEntry

      public static void getHtmlEntry(int nIdEntry, fr.paris.lutece.portal.service.plugin.Plugin plugin, StringBuffer stringBuffer, Locale locale)
      insert in the string buffer the content of the html code of the entry
      Parameters:
      nIdEntry - the key of the entry which html code must be insert in the stringBuffer
      plugin - the plugin
      stringBuffer - the buffer which contains the html code
      locale - the locale
    • getResponseEntry

      public static FormError getResponseEntry(javax.servlet.http.HttpServletRequest request, int nIdEntry, fr.paris.lutece.portal.service.plugin.Plugin plugin, FormSubmit formSubmit, boolean bResponseNull, Locale locale)
      perform in the object formSubmit the responses associates with a entry specify in parameter. return null if there is no error in the response else return a FormError Object
      Parameters:
      request - the request
      nIdEntry - the key of the entry
      plugin - the plugin
      formSubmit - Form Submit Object
      bResponseNull - true if the response create must be null
      locale - the locale
      Returns:
      null if there is no error in the response else return a FormError Object
    • findFieldByIdInTheList

      public static Field findFieldByIdInTheList(int nIdField, List<Field> listField)
      return the field which key is specified in parameter
      Parameters:
      nIdField - the id of the field who is search
      listField - the list of field
      Returns:
      the field which key is specified in parameter
    • isFieldInTheResponseList

      public static Boolean isFieldInTheResponseList(int nIdField, List<Response> listResponse)
      return true if the field which key is specified in parameter is in the response list
      Parameters:
      nIdField - the id of the field who is search
      listResponse - the list of object Response
      Returns:
      true if the field which key is specified in parameter is in the response list
    • getXmlResponses

      public static String getXmlResponses(javax.servlet.http.HttpServletRequest request, Form form, List<FormSubmit> listFormSubmit, Locale locale, fr.paris.lutece.portal.service.plugin.Plugin plugin)
      return the xml of form's response
      Parameters:
      request - the request
      form - the form
      listFormSubmit - the form submit list
      locale - the locale
      plugin - the plugin
      Returns:
      the xml of the response of a form
    • addHeaderResponse

      public static void addHeaderResponse(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, String strFileName, String strFileExtension)
      write the http header in the response
      Parameters:
      request - the httpServletRequest
      response - the http response
      strFileName - the name of the file who must insert in the response
      strFileExtension - the file extension
    • createXYGraph

      public static org.jfree.chart.JFreeChart createXYGraph(List<StatisticFormSubmit> listStatistic, String strLabelX, String strLableY, String strTimesUnit)
      create a JFreeChart Graph function of the statistic form submit
      Parameters:
      listStatistic - the list of statistic of form submit
      strLabelX - the label of axis x
      strLableY - the label of axis x
      strTimesUnit - the times unit of axis x(Day,Week,Month)
      Returns:
      a JFreeChart Graph function of the statistic form submit
    • getFormList

      public static fr.paris.lutece.util.ReferenceList getFormList(fr.paris.lutece.portal.service.plugin.Plugin plugin, fr.paris.lutece.portal.business.user.AdminUser user)
      Load the data of all form that the user is authorized to see depends workgroups user
      Parameters:
      plugin - the plugin
      user - the current user
      Returns:
      a reference list of form
    • getRefListAllQuestions

      public static fr.paris.lutece.util.ReferenceList getRefListAllQuestions(int nIdForm, fr.paris.lutece.portal.service.plugin.Plugin plugin)
    • getAllQuestionList

      public static List<IEntry> getAllQuestionList(int nIdForm, fr.paris.lutece.portal.service.plugin.Plugin plugin)
      return the questions list
      Parameters:
      nIdForm - the form id
      plugin - the plugin
      Returns:
      the questions list
    • getEntriesList

      public static List<IEntry> getEntriesList(int nIdForm, fr.paris.lutece.portal.service.plugin.Plugin plugin)
      return all entries of form
      Parameters:
      nIdForm - the form id
      plugin - the plugin
      Returns:
      the all entries of form
    • buildRequestWithFilter

      public static String buildRequestWithFilter(String strSelect, List<String> listStrFilter, List<String> listStrGroupBy, String strOrder)
      Builds a query with filters placed in parameters
      Parameters:
      strSelect - the select of the query
      listStrFilter - the list of filter to add in the query
      listStrGroupBy - the list of group by to add in the query
      strOrder - the order by of the query
      Returns:
      a query