Package lumis.service.formbuilder
Class FormBuilderManager
- java.lang.Object
-
- lumis.service.formbuilder.FormBuilderManager
-
public class FormBuilderManager extends java.lang.Object
Form framework manager implementation.- Since:
- 8.2.0
- Version:
- $Revision$ $Date$
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
FORMBUILDER_FORM_SOURCE
static int
MAX_SHORT_TEXT_LENGTH
-
Constructor Summary
Constructors Constructor Description FormBuilderManager()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.String
formatMailingList(java.lang.String mailingList, PageWebResource pageWebResource)
Format the mailing list string into a JSONArray string.static java.lang.String
generateMailBody(java.lang.String formId, java.lang.String userName, java.lang.String formTitle, Answer answer, PageWebResource pageWebResource)
Generate the HTML body of the e-mail to be sent as a notification when someone answers a formstatic Answer
getAnswer(java.lang.String answerId)
Get theAnswer
with the specified identifierstatic Form
getForm(java.lang.String formId)
Get the Form with the specified identifierstatic java.util.List<Answer>
getFormAnswers(java.lang.String formId)
static FormField
getFormField(java.lang.String fieldId, java.lang.String formId)
Get theform field
with the specified fieldId and formIdstatic java.util.List<FormField>
getFormFields(java.lang.String formId)
static java.util.Collection<lumis.service.formbuilder.FormElement>
parseHtmlForm(java.lang.String htmlFragment)
Returns a collection ofform elements
from a HTML fragment, each element will be related to input, select or textarea HTML tags that has a label related to it.static void
processAnswer(java.lang.String answerId)
Change answer status toprocessed
.static void
unProcessAnswer(java.lang.String answerId)
Change answer status tonot processed
.static void
validateFieldOptions(java.lang.String formFieldOptionsJsonString, int formFieldOptionsCount)
Validates the json for a field options.static void
validateFormFieldType(FormField formField, org.json.simple.JSONObject answersJson)
Validate Answers by formField type
-
-
-
Field Detail
-
MAX_SHORT_TEXT_LENGTH
public static final int MAX_SHORT_TEXT_LENGTH
- See Also:
- Constant Field Values
-
FORMBUILDER_FORM_SOURCE
public static final java.lang.String FORMBUILDER_FORM_SOURCE
- See Also:
- Constant Field Values
-
-
Method Detail
-
getForm
public static Form getForm(java.lang.String formId)
Get the Form with the specified identifier- Parameters:
formId
- the form identifier- Returns:
- the
Form
or null - Since:
- 8.2.0
-
getAnswer
public static Answer getAnswer(java.lang.String answerId)
Get theAnswer
with the specified identifier- Parameters:
answerId
- the identifier- Returns:
- the
Answer
or null - Since:
- 8.2.0
-
validateFormFieldType
public static void validateFormFieldType(FormField formField, org.json.simple.JSONObject answersJson) throws AnswerInvalidLengthException, PortalException, java.lang.NumberFormatException, RequiredAnswerException
Validate Answers by formField type- Parameters:
formField
- theFormField
used to validate the answer JSONanswersJson
- aJSONObject
with the answers- Throws:
AnswerInvalidLengthException
- if the answer length is to bigjava.lang.NumberFormatException
- if an answer defined as number only contains something elseRequiredAnswerException
- if an answer is defined as required but wasn't answeredPortalException
- Since:
- 8.2.0
-
getFormFields
public static java.util.List<FormField> getFormFields(java.lang.String formId) throws PortalException
- Parameters:
formId
- the identifier of theForm
- Returns:
- the list of
FormField
belonging to theForm
- Throws:
PortalException
- Since:
- 8.2.0
-
getFormAnswers
public static java.util.List<Answer> getFormAnswers(java.lang.String formId)
-
formatMailingList
public static java.lang.String formatMailingList(java.lang.String mailingList, PageWebResource pageWebResource) throws PortalException
Format the mailing list string into a JSONArray string. E-mails are validated during the process- Parameters:
mailingList
- the list of e-mails separated by commapageWebResource
- thePageWebResource
used for error localization.- Returns:
- a formated list of e-mails
- Throws:
PortalException
- Since:
- 8.2.0
-
generateMailBody
public static java.lang.String generateMailBody(java.lang.String formId, java.lang.String userName, java.lang.String formTitle, Answer answer, PageWebResource pageWebResource) throws PortalException
Generate the HTML body of the e-mail to be sent as a notification when someone answers a form- Parameters:
userName
- Name of the user that answered the formformTitle
- The title of the form that was answeredanswersValues
- The JSONObject generated with all answerspageWebResource
- The page web resource- Returns:
- The HTML of the e-mail body
- Throws:
PortalException
- Since:
- 8.2.0
-
processAnswer
public static void processAnswer(java.lang.String answerId)
Change answer status toprocessed
.- Parameters:
answerId
- the identifier of the answer to change status- Since:
- 8.2.0
-
unProcessAnswer
public static void unProcessAnswer(java.lang.String answerId)
Change answer status tonot processed
.- Parameters:
answerId
- the identifier of the answer to change status- Since:
- 8.2.0
-
getFormField
public static FormField getFormField(java.lang.String fieldId, java.lang.String formId)
Get theform field
with the specified fieldId and formId
-
parseHtmlForm
public static java.util.Collection<lumis.service.formbuilder.FormElement> parseHtmlForm(java.lang.String htmlFragment) throws PortalException
Returns a collection ofform elements
from a HTML fragment, each element will be related to input, select or textarea HTML tags that has a label related to it.- Parameters:
htmlFragment
- the HTML fragment to be analyzed.- Returns:
- a collection of
form elements
from a HTML fragment. - Throws:
PortalException
- Since:
- 9.0.0
-
validateFieldOptions
public static void validateFieldOptions(java.lang.String formFieldOptionsJsonString, int formFieldOptionsCount) throws PortalException
Validates the json for a field options. Throws an exception if the validation fails.- Parameters:
formFieldOptionsJsonString
- the json string.formFieldOptionsCount
- the numbe of expected options.- Throws:
PortalException
- Since:
- 9.0.0
-
-