fr.paris.lutece.plugins.form.utils
Class FormUtils

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

public final class FormUtils
extends java.lang.Object

class FormUtils


Field Summary
static java.lang.String BEAN_ENTRY_TYPE_SERVICE
           
static java.lang.String BEAN_EXPORT_DAEMON_TYPE_FACTORY
           
static java.lang.String BEAN_FORM_RESPONSE_SERVICE
           
static java.lang.String CONSTANT_EQUAL
           
static java.lang.String CONSTANT_GROUP_BY_DAY
           
static java.lang.String CONSTANT_GROUP_BY_MONTH
           
static java.lang.String CONSTANT_GROUP_BY_WEEK
           
static int CONSTANT_ID_NULL
           
static java.lang.String CONSTANT_UNDERSCORE
           
static java.lang.String EMPTY_STRING
           
static java.lang.String PARAMETER_DELETE_PREFIX
           
static java.lang.String PARAMETER_ID_ENTRY
           
static java.lang.String SESSION_FORM_LIST_SUBMITTED_RESPONSES
           
static java.lang.String SESSION_VALIDATE_REQUIREMENT
           
 
Method Summary
static void activateMyLuteceAuthentification(Form form, fr.paris.lutece.portal.service.plugin.Plugin plugin, java.util.Locale locale, javax.servlet.http.HttpServletRequest request)
          Activate mylutece authentification for the form
static void addHeaderResponse(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, java.lang.String strFileName, java.lang.String strFileExtension)
          write the http header in the response
static java.sql.Timestamp addStatisticInterval(java.sql.Timestamp timestamp, java.lang.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 .
static java.lang.String buildRequestWithFilter(java.lang.String strSelect, java.util.List<java.lang.String> listStrFilter, java.util.List<java.lang.String> listStrGroupBy, java.lang.String strOrder)
          Builds a query with filters placed in parameters
static int convertStringToInt(java.lang.String strParameter)
          convert a string to int
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
static org.jfree.chart.JFreeChart createXYGraph(java.util.List<StatisticFormSubmit> listStatistic, java.lang.String strLabelX, java.lang.String strLableY, java.lang.String strTimesUnit)
          create a JFreeChart Graph function of the statistic form submit
static void deactivateMyLuteceAuthentification(Form form, fr.paris.lutece.portal.service.plugin.Plugin plugin)
          Deactivate mylutece authentification for the form
static Field findFieldByIdInTheList(int nIdField, java.util.List<Field> listField)
          return the field which key is specified in parameter
static Field findFieldByTitleInTheList(java.lang.String strTitle, java.util.List<Field> listFields)
          Return the field which title is specified in parameter
static java.lang.String getAdminBaseUrl(javax.servlet.http.HttpServletRequest request)
          Get the base url
static java.util.List<IEntry> getAllQuestionList(int nIdForm, fr.paris.lutece.portal.service.plugin.Plugin plugin)
          return the questions list
static java.util.Date getCurrentDate()
          return current date without hours, minutes and milliseconds
static java.sql.Timestamp getCurrentTimestamp()
          return current Timestamp
static java.sql.Timestamp getDateFirstMinute(java.util.Date date, java.util.Locale locale)
          return a timestamp Object which correspond with the string specified in parameter.
static java.sql.Timestamp getDateLastMinute(java.util.Date date, java.util.Locale locale)
          return a timestamp Object which correspond with the string specified in parameter.
static java.lang.String getDateString(java.sql.Timestamp date, java.util.Locale locale)
          Deprecated.  
static int getDay(java.sql.Timestamp timestamp)
          return the day of the timestamp in parameter
static java.util.List<IEntry> getEntriesList(int nIdForm, fr.paris.lutece.portal.service.plugin.Plugin plugin)
          return all entries of form
static EntryType getEntryTypeMyLuteceUser(fr.paris.lutece.portal.service.plugin.Plugin plugin)
          Get entry type mylutece user
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
static void getHtmlEntry(int nIdEntry, fr.paris.lutece.portal.service.plugin.Plugin plugin, java.lang.StringBuffer stringBuffer, java.util.Locale locale)
          insert in the string buffer the content of the html code of the entry
static void getHtmlEntry(int nIdEntry, fr.paris.lutece.portal.service.plugin.Plugin plugin, java.lang.StringBuffer stringBuffer, java.util.Locale locale, javax.servlet.http.HttpServletRequest request)
          insert in the string buffer the content of the html code of the entry
static java.lang.String getHtmlForm(Form form, java.lang.String strUrlAction, fr.paris.lutece.portal.service.plugin.Plugin plugin, java.util.Locale locale)
          return the html code of the form
static java.lang.String getHtmlForm(Form form, java.lang.String strUrlAction, fr.paris.lutece.portal.service.plugin.Plugin plugin, java.util.Locale locale, javax.servlet.http.HttpServletRequest request)
          return the html code of the form
static int getIndexEntryInTheEntryList(int nIdEntry, java.util.List<IEntry> listEntry)
          return the index in the list of the entry whose key is specified in parameter
static int getIndexFieldInTheFieldList(int nIdField, java.util.List<Field> listField)
          return the index in the list of the field whose key is specified in parameter
static int getMonth(java.sql.Timestamp timestamp)
          return the month of the timestamp in parameter
static fr.paris.lutece.portal.service.plugin.Plugin getPlugin()
          Gets the form plugin
static fr.paris.lutece.util.ReferenceList getRefListAllQuestions(int nIdForm, fr.paris.lutece.portal.service.plugin.Plugin plugin)
          Get the ReferenceList associated to all questions
static fr.paris.lutece.util.ReferenceList getRefListCategory(java.util.List<Category> listCategories)
          Init reference list with the different categories
static FormError getResponseEntry(javax.servlet.http.HttpServletRequest request, int nIdEntry, fr.paris.lutece.portal.service.plugin.Plugin plugin, FormSubmit formSubmit, boolean bResponseNull, java.util.Locale locale)
          perform in the object formSubmit the responses associates with a entry specify in parameter.
static java.util.Map<java.lang.Integer,java.util.List<Response>> getResponses(javax.servlet.http.HttpSession session)
          Gets the responses bound to the session
static int getWeek(java.sql.Timestamp timestamp)
          return the week of the timestamp in parameter
static java.lang.String getXmlResponses(javax.servlet.http.HttpServletRequest request, Form form, java.util.List<FormSubmit> listFormSubmit, java.util.Locale locale, fr.paris.lutece.portal.service.plugin.Plugin plugin)
          return the xml of form's response
static int getYear(java.sql.Timestamp timestamp)
          return the year of the timestamp in parameter
static java.lang.Boolean isFieldInTheResponseList(int nIdField, java.util.List<Response> listResponse)
          return true if the field which key is specified in parameter is in the response list
static void removeResponses(javax.servlet.http.HttpSession session)
          Removes submitted responses
static void restoreResponses(javax.servlet.http.HttpSession session, java.util.Map<java.lang.Integer,java.util.List<Response>> mapResponses)
          Restores submitted responses
static boolean sameDate(java.sql.Timestamp timestamp1, java.sql.Timestamp timestamp2, java.lang.String strTimesUnit)
          Compare two timestamp and return true if they have the same times unit(Day,week,month)
static void sendNotificationMailEndDisponibility(Form form, java.util.Locale locale)
          sendMail to the mailing list associate to the form a mail of end disponibility
static void sendNotificationMailFormSubmit(Form form, java.util.Locale locale)
          sendMail to the mailing list associate to the form a mail of new form submit
static void sendNotificationMailFormSubmit(FormSubmit formSubmit, java.util.Locale locale)
          SendMail to the mailing list associate to the form a mail of new form submit.
static java.lang.String trim(java.lang.String strParameter)
          Returns a copy of the string , with leading and trailing whitespace omitted.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CONSTANT_GROUP_BY_DAY

public static final java.lang.String CONSTANT_GROUP_BY_DAY
See Also:
Constant Field Values

CONSTANT_GROUP_BY_WEEK

public static final java.lang.String CONSTANT_GROUP_BY_WEEK
See Also:
Constant Field Values

CONSTANT_GROUP_BY_MONTH

public static final java.lang.String CONSTANT_GROUP_BY_MONTH
See Also:
Constant Field Values

EMPTY_STRING

public static final java.lang.String EMPTY_STRING
See Also:
Constant Field Values

CONSTANT_EQUAL

public static final java.lang.String CONSTANT_EQUAL
See Also:
Constant Field Values

PARAMETER_ID_ENTRY

public static final java.lang.String PARAMETER_ID_ENTRY
See Also:
Constant Field Values

PARAMETER_DELETE_PREFIX

public static final java.lang.String PARAMETER_DELETE_PREFIX
See Also:
Constant Field Values

BEAN_ENTRY_TYPE_SERVICE

public static final java.lang.String BEAN_ENTRY_TYPE_SERVICE
See Also:
Constant Field Values

BEAN_FORM_RESPONSE_SERVICE

public static final java.lang.String BEAN_FORM_RESPONSE_SERVICE
See Also:
Constant Field Values

BEAN_EXPORT_DAEMON_TYPE_FACTORY

public static final java.lang.String BEAN_EXPORT_DAEMON_TYPE_FACTORY
See Also:
Constant Field Values

CONSTANT_ID_NULL

public static final int CONSTANT_ID_NULL
See Also:
Constant Field Values

CONSTANT_UNDERSCORE

public static final java.lang.String CONSTANT_UNDERSCORE
See Also:
Constant Field Values

SESSION_FORM_LIST_SUBMITTED_RESPONSES

public static final java.lang.String SESSION_FORM_LIST_SUBMITTED_RESPONSES
See Also:
Constant Field Values

SESSION_VALIDATE_REQUIREMENT

public static final java.lang.String SESSION_VALIDATE_REQUIREMENT
See Also:
Constant Field Values
Method Detail

sendNotificationMailEndDisponibility

public static void sendNotificationMailEndDisponibility(Form form,
                                                        java.util.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,
                                                  java.util.Locale locale)
sendMail to the mailing list associate to the form a mail of new form submit

Parameters:
form - the form
locale - the locale

sendNotificationMailFormSubmit

public static void sendNotificationMailFormSubmit(FormSubmit formSubmit,
                                                  java.util.Locale locale)
SendMail to the mailing list associate to the form a mail of new form submit. It will also display the anwsers submitted by the user.

Parameters:
formSubmit - the submit form
locale - Locale

getDateLastMinute

public static java.sql.Timestamp getDateLastMinute(java.util.Date date,
                                                   java.util.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 java.sql.Timestamp getDateFirstMinute(java.util.Date date,
                                                    java.util.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(java.sql.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(java.sql.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(java.sql.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(java.sql.Timestamp timestamp)
return the year of the timestamp in parameter

Parameters:
timestamp - date
Returns:
the year of the timestamp in parameter

addStatisticInterval

public static java.sql.Timestamp addStatisticInterval(java.sql.Timestamp timestamp,
                                                      java.lang.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(java.sql.Timestamp timestamp1,
                               java.sql.Timestamp timestamp2,
                               java.lang.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 java.lang.String getDateString(java.sql.Timestamp date,
                                             java.util.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 java.sql.Timestamp getCurrentTimestamp()
return current Timestamp

Returns:
return current Timestamp

getCurrentDate

public static java.util.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,
                                              java.util.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,
                                              java.util.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 java.lang.String getHtmlForm(Form form,
                                           java.lang.String strUrlAction,
                                           fr.paris.lutece.portal.service.plugin.Plugin plugin,
                                           java.util.Locale locale,
                                           javax.servlet.http.HttpServletRequest request)
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
request - HttpServletRequest
Returns:
the html code of the form

getRefListCategory

public static fr.paris.lutece.util.ReferenceList getRefListCategory(java.util.List<Category> listCategories)
Init reference list with the different categories

Parameters:
listCategories - the list of categories
Returns:
reference list of category

getHtmlForm

public static java.lang.String getHtmlForm(Form form,
                                           java.lang.String strUrlAction,
                                           fr.paris.lutece.portal.service.plugin.Plugin plugin,
                                           java.util.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,
                                java.lang.StringBuffer stringBuffer,
                                java.util.Locale locale,
                                javax.servlet.http.HttpServletRequest request)
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
request - HttpServletRequest

getHtmlEntry

public static void getHtmlEntry(int nIdEntry,
                                fr.paris.lutece.portal.service.plugin.Plugin plugin,
                                java.lang.StringBuffer stringBuffer,
                                java.util.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,
                                         java.util.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,
                                           java.util.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 java.lang.Boolean isFieldInTheResponseList(int nIdField,
                                                         java.util.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 java.lang.String getXmlResponses(javax.servlet.http.HttpServletRequest request,
                                               Form form,
                                               java.util.List<FormSubmit> listFormSubmit,
                                               java.util.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,
                                     java.lang.String strFileName,
                                     java.lang.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(java.util.List<StatisticFormSubmit> listStatistic,
                                                       java.lang.String strLabelX,
                                                       java.lang.String strLableY,
                                                       java.lang.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)
Get the ReferenceList associated to all questions

Parameters:
nIdForm - the id form
plugin - the Plugin
Returns:
a ReferenceList

getAllQuestionList

public static java.util.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 java.util.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 java.lang.String buildRequestWithFilter(java.lang.String strSelect,
                                                      java.util.List<java.lang.String> listStrFilter,
                                                      java.util.List<java.lang.String> listStrGroupBy,
                                                      java.lang.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

getEntryTypeMyLuteceUser

public static EntryType getEntryTypeMyLuteceUser(fr.paris.lutece.portal.service.plugin.Plugin plugin)
Get entry type mylutece user

Parameters:
plugin - Plugin
Returns:
entry type

activateMyLuteceAuthentification

public static void activateMyLuteceAuthentification(Form form,
                                                    fr.paris.lutece.portal.service.plugin.Plugin plugin,
                                                    java.util.Locale locale,
                                                    javax.servlet.http.HttpServletRequest request)
Activate mylutece authentification for the form

Parameters:
form - form
plugin - Plugin
locale - Locale
request - HttpServletRequest

deactivateMyLuteceAuthentification

public static void deactivateMyLuteceAuthentification(Form form,
                                                      fr.paris.lutece.portal.service.plugin.Plugin plugin)
Deactivate mylutece authentification for the form

Parameters:
form - Form
plugin - Plugin

restoreResponses

public static void restoreResponses(javax.servlet.http.HttpSession session,
                                    java.util.Map<java.lang.Integer,java.util.List<Response>> mapResponses)
Restores submitted responses

Parameters:
session - the session
mapResponses - response list, key is entry id

removeResponses

public static void removeResponses(javax.servlet.http.HttpSession session)
Removes submitted responses

Parameters:
session - the session

getResponses

public static java.util.Map<java.lang.Integer,java.util.List<Response>> getResponses(javax.servlet.http.HttpSession session)
Gets the responses bound to the session

Parameters:
session - the session
Returns:
the responses if any, null otherwise.

convertStringToInt

public static int convertStringToInt(java.lang.String strParameter)
convert a string to int

Parameters:
strParameter - the string parameter to convert
Returns:
the conversion

getPlugin

public static fr.paris.lutece.portal.service.plugin.Plugin getPlugin()
Gets the form plugin

Returns:
the plugin

trim

public static java.lang.String trim(java.lang.String strParameter)
Returns a copy of the string , with leading and trailing whitespace omitted.

Parameters:
strParameter - the string parameter to convert
Returns:
null if the strParameter is null other return with leading and trailing whitespace omitted.

findFieldByTitleInTheList

public static Field findFieldByTitleInTheList(java.lang.String strTitle,
                                              java.util.List<Field> listFields)
Return the field which title is specified in parameter

Parameters:
strTitle - the title
listFields - the list of fields
Returns:
the field which title is specified in parameter

getAdminBaseUrl

public static java.lang.String getAdminBaseUrl(javax.servlet.http.HttpServletRequest request)
Get the base url

Parameters:
request - the HTTP request
Returns:
the base url


Copyright © 2012 Mairie de Paris. All Rights Reserved.