public final class FormUtils extends Object
Modifier and Type | Field and Description |
---|---|
static String |
BEAN_ENTRY_TYPE_SERVICE |
static String |
BEAN_EXPORT_DAEMON_TYPE_FACTORY |
static String |
BEAN_FORM_RESPONSE_SERVICE |
static String |
CONSTANT_GROUP_BY_DAY |
static String |
CONSTANT_GROUP_BY_MONTH |
static String |
CONSTANT_GROUP_BY_WEEK |
static String |
CONSTANT_UNDERSCORE |
static String |
PARAMETER_ID_ENTRY |
static String |
PARAMETER_KEY |
static String |
PROPERTY_CLEAN_FORM_ANSWERS_KEY |
static String |
PROPERTY_CLEAN_FORM_ANSWERS_RETURN_CODE_KO |
static String |
PROPERTY_CLEAN_FORM_ANSWERS_RETURN_CODE_OK |
static String |
PROPERTY_CLEAN_FORM_ANSWERS_RETURN_CODE_UNAUTHORIZED |
static String |
SESSION_FORM_ERRORS |
static String |
SESSION_FORM_LIST_SUBMITTED_RESPONSES |
static String |
SESSION_VALIDATE_REQUIREMENT |
Modifier and Type | Method and Description |
---|---|
static void |
activateMyLuteceAuthentification(Form form,
fr.paris.lutece.portal.service.plugin.Plugin plugin,
Locale locale,
javax.servlet.http.HttpServletRequest request)
Activate MyLutece authentication for the form
|
static void |
addHeaderResponse(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
String strFileName,
String strFileExtension)
Write the HTTP header in the response
|
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 .
|
static String |
buildRequestWithFilter(String strSelect,
List<String> listStrFilter,
List<String> listStrGroupBy,
String strOrder)
Builds a query with filters placed in parameters
|
static fr.paris.lutece.plugins.genericattributes.business.Entry |
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(List<StatisticFormSubmit> listStatistic,
String strLabelX,
String strLableY,
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 authentication for the form
|
static String |
getAdminBaseUrl(javax.servlet.http.HttpServletRequest request)
Get the base URL
|
static List<fr.paris.lutece.plugins.genericattributes.business.Entry> |
getAllQuestionList(int nIdForm,
fr.paris.lutece.portal.service.plugin.Plugin plugin)
Return the questions list
|
static List<fr.paris.lutece.plugins.genericattributes.business.Field> |
getAuthorizedFieldsByRole(javax.servlet.http.HttpServletRequest request,
List<fr.paris.lutece.plugins.genericattributes.business.Field> listField)
Filter a list of field for a given user
|
static Date |
getCurrentDate()
Return current date without hours, minutes and milliseconds
|
static Timestamp |
getCurrentTimestamp()
Return current Timestamp
|
static Timestamp |
getDateFirstMinute(Date date,
Locale locale)
Return a timestamp Object which correspond with the string specified in
parameter.
|
static Timestamp |
getDateLastMinute(Date date,
Locale locale)
Return a timestamp Object which correspond with the string specified in
parameter.
|
static String |
getDateString(Timestamp date,
Locale locale)
Deprecated.
Deprecated
|
static int |
getDay(Timestamp timestamp)
Return the day of the timestamp in parameter
|
static List<fr.paris.lutece.plugins.genericattributes.business.Entry> |
getEntriesList(int nIdForm,
fr.paris.lutece.portal.service.plugin.Plugin plugin)
Return all entries of form
|
static fr.paris.lutece.plugins.genericattributes.business.EntryType |
getEntryTypeMyLuteceUser(fr.paris.lutece.portal.service.plugin.Plugin plugin)
Get entry type mylutece user
|
static String |
getEntryUrl(fr.paris.lutece.plugins.genericattributes.business.Entry entry)
Get the url to modify an entry of the form in front office
|
static List<fr.paris.lutece.plugins.genericattributes.business.GenericAttributeError> |
getFormErrors(javax.servlet.http.HttpSession session)
Gets the form errors bound to the session
|
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,
StringBuffer stringBuffer,
Locale locale,
boolean bDisplayFront,
javax.servlet.http.HttpServletRequest request)
Insert in the string buffer the content of the HTML code of the entry
|
static String |
getHtmlForm(Form form,
String strUrlAction,
Locale locale,
boolean bDisplayFront)
Return the HTML code of the form
|
static String |
getHtmlForm(Form form,
String strUrlAction,
Locale locale,
boolean bDisplayFront,
javax.servlet.http.HttpServletRequest request)
Return the HTML code of the form
|
static int |
getIndexFieldInTheFieldList(int nIdField,
List<fr.paris.lutece.plugins.genericattributes.business.Field> listField)
Return the index in the list of the field whose key is specified in
parameter
|
static int |
getMonth(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(List<Category> listCategories)
Initialize a reference list with the different categories
|
static List<fr.paris.lutece.plugins.genericattributes.business.GenericAttributeError> |
getResponseEntry(javax.servlet.http.HttpServletRequest request,
int nIdEntry,
fr.paris.lutece.portal.service.plugin.Plugin plugin,
FormSubmit formSubmit,
boolean bResponseNull,
boolean bReturnErrors,
Locale locale)
Perform in the object formSubmit the responses associates with a entry
specify in parameter.
|
static Map<Integer,List<fr.paris.lutece.plugins.genericattributes.business.Response>> |
getResponses(javax.servlet.http.HttpSession session)
Gets the responses bound to the session
|
static int |
getWeek(Timestamp timestamp)
Return the week of the timestamp in parameter
|
static String |
getXmlResponses(javax.servlet.http.HttpServletRequest request,
Form form,
FormSubmit formSubmit,
Locale locale,
fr.paris.lutece.portal.service.plugin.Plugin plugin)
Get the XML responses for a single form submit
|
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
|
static int |
getYear(Timestamp timestamp)
Return the year of the timestamp in parameter
|
static Boolean |
isFieldInTheResponseList(int nIdField,
List<fr.paris.lutece.plugins.genericattributes.business.Response> listResponse)
Return true if the field which key is specified in parameter is in the
response list
|
static void |
removeFormErrors(javax.servlet.http.HttpSession session)
Removes submitted responses
|
static void |
removeResponses(javax.servlet.http.HttpSession session)
Removes submitted responses
|
static void |
restoreFormErrors(javax.servlet.http.HttpSession session,
List<fr.paris.lutece.plugins.genericattributes.business.GenericAttributeError> listFormErrors)
Restores form errors
|
static void |
restoreResponses(javax.servlet.http.HttpSession session,
Map<Integer,List<fr.paris.lutece.plugins.genericattributes.business.Response>> mapResponses)
Restores submitted responses
|
static boolean |
sameDate(Timestamp timestamp1,
Timestamp timestamp2,
String strTimesUnit)
Compare two timestamps and return true if they have the same times
unit(Day,week,month)
|
static void |
sendNotificationMailEndDisponibility(Form form,
Locale locale)
Send a mail of end of availability to the mailing list associate with
the form
|
static void |
sendNotificationMailFormSubmit(FormSubmit formSubmit,
Locale locale)
SendMail to the mailing list associate to the form a mail of new form
submit.
|
static String |
trim(String strParameter)
Returns a copy of the string , with leading and trailing whitespace
omitted.
|
public static final String CONSTANT_GROUP_BY_DAY
public static final String CONSTANT_GROUP_BY_WEEK
public static final String CONSTANT_GROUP_BY_MONTH
public static final String BEAN_ENTRY_TYPE_SERVICE
public static final String BEAN_FORM_RESPONSE_SERVICE
public static final String BEAN_EXPORT_DAEMON_TYPE_FACTORY
public static final String CONSTANT_UNDERSCORE
public static final String SESSION_FORM_LIST_SUBMITTED_RESPONSES
public static final String SESSION_VALIDATE_REQUIREMENT
public static final String SESSION_FORM_ERRORS
public static final String PARAMETER_ID_ENTRY
public static final String PARAMETER_KEY
public static final String PROPERTY_CLEAN_FORM_ANSWERS_KEY
public static final String PROPERTY_CLEAN_FORM_ANSWERS_RETURN_CODE_UNAUTHORIZED
public static final String PROPERTY_CLEAN_FORM_ANSWERS_RETURN_CODE_OK
public static final String PROPERTY_CLEAN_FORM_ANSWERS_RETURN_CODE_KO
public static void sendNotificationMailEndDisponibility(Form form, Locale locale)
form
- the formlocale
- the localepublic static void sendNotificationMailFormSubmit(FormSubmit formSubmit, Locale locale)
formSubmit
- the submit formlocale
- Locale
public static Timestamp getDateLastMinute(Date date, Locale locale)
date
- the date who must convertlocale
- the localepublic static Timestamp getDateFirstMinute(Date date, Locale locale)
date
- the date who must convertlocale
- the localepublic static int getDay(Timestamp timestamp)
timestamp
- datepublic static int getWeek(Timestamp timestamp)
timestamp
- datepublic static int getMonth(Timestamp timestamp)
timestamp
- datepublic static int getYear(Timestamp timestamp)
timestamp
- datepublic static Timestamp addStatisticInterval(Timestamp timestamp, String strTimesUnit, int nDecal)
timestamp
- datestrTimesUnit
- (day,week,month)nDecal
- the number of timesUnitpublic static boolean sameDate(Timestamp timestamp1, Timestamp timestamp2, String strTimesUnit)
timestamp1
- timestamp1timestamp2
- timestamp2strTimesUnit
- (day,week,month)public static String getDateString(Timestamp date, Locale locale)
date
- java.sql.Timestamp date to convertlocale
- the localepublic static Timestamp getCurrentTimestamp()
public static Date getCurrentDate()
public static fr.paris.lutece.plugins.genericattributes.business.Entry createEntryByType(javax.servlet.http.HttpServletRequest request, fr.paris.lutece.portal.service.plugin.Plugin plugin)
request
- the requestplugin
- the pluginpublic static int getIndexFieldInTheFieldList(int nIdField, List<fr.paris.lutece.plugins.genericattributes.business.Field> listField)
nIdField
- the key of the fieldlistField
- the list of fieldpublic static String getHtmlForm(Form form, String strUrlAction, Locale locale, boolean bDisplayFront, javax.servlet.http.HttpServletRequest request)
form
- the form which HTML code must be returnstrUrlAction
- the URL who must be call after the form submitlocale
- the localebDisplayFront
- True if the entry will be displayed in Front Office,
false if it will be displayed in Back Office.request
- HttpServletRequestpublic static fr.paris.lutece.util.ReferenceList getRefListCategory(List<Category> listCategories)
listCategories
- the list of categoriespublic static String getHtmlForm(Form form, String strUrlAction, Locale locale, boolean bDisplayFront)
form
- the form which HTML code must be returnstrUrlAction
- the URL who must be call after the form submitlocale
- the localebDisplayFront
- True if the entry will be displayed in Front Office,
false if it will be displayed in Back Office.public static void getHtmlEntry(int nIdEntry, StringBuffer stringBuffer, Locale locale, boolean bDisplayFront, javax.servlet.http.HttpServletRequest request)
nIdEntry
- the key of the entry which HTML code must be insert in
the stringBufferstringBuffer
- the buffer which contains the HTML codelocale
- the localebDisplayFront
- True if the entry will be displayed in Front Office,
false if it will be displayed in Back Office.request
- HttpServletRequestpublic static List<fr.paris.lutece.plugins.genericattributes.business.GenericAttributeError> getResponseEntry(javax.servlet.http.HttpServletRequest request, int nIdEntry, fr.paris.lutece.portal.service.plugin.Plugin plugin, FormSubmit formSubmit, boolean bResponseNull, boolean bReturnErrors, Locale locale)
request
- the requestnIdEntry
- the key of the entryplugin
- the pluginformSubmit
- Form Submit ObjectbResponseNull
- true if the response create must be nullbReturnErrors
- true if errors must be returnedlocale
- the localepublic static String getEntryUrl(fr.paris.lutece.plugins.genericattributes.business.Entry entry)
entry
- the entrypublic static Boolean isFieldInTheResponseList(int nIdField, List<fr.paris.lutece.plugins.genericattributes.business.Response> listResponse)
nIdField
- the id of the field who is searchlistResponse
- the list of object Responsepublic static String getXmlResponses(javax.servlet.http.HttpServletRequest request, Form form, List<FormSubmit> listFormSubmit, Locale locale, fr.paris.lutece.portal.service.plugin.Plugin plugin)
request
- the requestform
- the formlistFormSubmit
- the form submit listlocale
- the localeplugin
- the pluginpublic static String getXmlResponses(javax.servlet.http.HttpServletRequest request, Form form, FormSubmit formSubmit, Locale locale, fr.paris.lutece.portal.service.plugin.Plugin plugin)
request
- the HTTP requestform
- the formformSubmit
- the form submitlocale
- the localeplugin
- the pluginpublic static void addHeaderResponse(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, String strFileName, String strFileExtension)
request
- the httpServletRequestresponse
- the HTTP responsestrFileName
- the name of the file who must insert in the responsestrFileExtension
- the file extensionpublic static org.jfree.chart.JFreeChart createXYGraph(List<StatisticFormSubmit> listStatistic, String strLabelX, String strLableY, String strTimesUnit)
listStatistic
- the list of statistic of form submitstrLabelX
- the label of axis xstrLableY
- the label of axis xstrTimesUnit
- the times unit of axis x(Day,Week,Month)public static fr.paris.lutece.util.ReferenceList getFormList(fr.paris.lutece.portal.service.plugin.Plugin plugin, fr.paris.lutece.portal.business.user.AdminUser user)
plugin
- the pluginuser
- the current userpublic static fr.paris.lutece.util.ReferenceList getRefListAllQuestions(int nIdForm, fr.paris.lutece.portal.service.plugin.Plugin plugin)
nIdForm
- the id formplugin
- the Plugin
ReferenceList
public static List<fr.paris.lutece.plugins.genericattributes.business.Entry> getAllQuestionList(int nIdForm, fr.paris.lutece.portal.service.plugin.Plugin plugin)
nIdForm
- the form idplugin
- the pluginpublic static List<fr.paris.lutece.plugins.genericattributes.business.Entry> getEntriesList(int nIdForm, fr.paris.lutece.portal.service.plugin.Plugin plugin)
nIdForm
- the form idplugin
- the pluginpublic static String buildRequestWithFilter(String strSelect, List<String> listStrFilter, List<String> listStrGroupBy, String strOrder)
strSelect
- the select of the querylistStrFilter
- the list of filter to add in the querylistStrGroupBy
- the list of group by to add in the querystrOrder
- the order by of the querypublic static fr.paris.lutece.plugins.genericattributes.business.EntryType getEntryTypeMyLuteceUser(fr.paris.lutece.portal.service.plugin.Plugin plugin)
plugin
- Pluginpublic static void activateMyLuteceAuthentification(Form form, fr.paris.lutece.portal.service.plugin.Plugin plugin, Locale locale, javax.servlet.http.HttpServletRequest request)
form
- formplugin
- Pluginlocale
- Localerequest
- HttpServletRequestpublic static void deactivateMyLuteceAuthentification(Form form, fr.paris.lutece.portal.service.plugin.Plugin plugin)
form
- Formplugin
- Pluginpublic static void restoreResponses(javax.servlet.http.HttpSession session, Map<Integer,List<fr.paris.lutece.plugins.genericattributes.business.Response>> mapResponses)
session
- the sessionmapResponses
- response list, key is entry idpublic static void removeResponses(javax.servlet.http.HttpSession session)
session
- the sessionpublic static Map<Integer,List<fr.paris.lutece.plugins.genericattributes.business.Response>> getResponses(javax.servlet.http.HttpSession session)
session
- the sessionnull
otherwise.public static void restoreFormErrors(javax.servlet.http.HttpSession session, List<fr.paris.lutece.plugins.genericattributes.business.GenericAttributeError> listFormErrors)
session
- the sessionlistFormErrors
- the form errosrpublic static void removeFormErrors(javax.servlet.http.HttpSession session)
session
- the sessionpublic static List<fr.paris.lutece.plugins.genericattributes.business.GenericAttributeError> getFormErrors(javax.servlet.http.HttpSession session)
session
- the sessionpublic static fr.paris.lutece.portal.service.plugin.Plugin getPlugin()
public static String trim(String strParameter)
strParameter
- the string parameter to convertpublic static String getAdminBaseUrl(javax.servlet.http.HttpServletRequest request)
request
- the HTTP requestpublic static List<fr.paris.lutece.plugins.genericattributes.business.Field> getAuthorizedFieldsByRole(javax.servlet.http.HttpServletRequest request, List<fr.paris.lutece.plugins.genericattributes.business.Field> listField)
listField
- a list of fieldrequest
- The http requestCopyright © 2016 City of Paris. All rights reserved.