public class FormBuilderManager extends Object
Modifier and Type | Field and Description |
---|---|
static String |
FORMBUILDER_FORM_SOURCE |
static int |
MAX_SHORT_TEXT_LENGTH |
Constructor and Description |
---|
FormBuilderManager() |
Modifier and Type | Method and Description |
---|---|
static String |
formatMailingList(String mailingList,
PageWebResource pageWebResource)
Format the mailing list string into a JSONArray string.
|
static String |
generateMailBody(String formId,
String userName,
String formTitle,
Answer answer,
PageWebResource pageWebResource)
Generate the HTML body of the e-mail to be sent as a notification when someone answers a form
|
static Answer |
getAnswer(String answerId)
Get the
Answer with the specified identifier |
static Form |
getForm(String formId)
Get the Form with the specified identifier
|
static List<Answer> |
getFormAnswers(String formId)
|
static FormField |
getFormField(String fieldId,
String formId)
Get the
form field with the specified fieldId and formId |
static List<FormField> |
getFormFields(String formId)
|
static Collection<lumis.service.formbuilder.FormElement> |
parseHtmlForm(String htmlFragment)
Returns a collection of
form 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(String answerId)
Change answer status to
processed . |
static void |
unProcessAnswer(String answerId)
Change answer status to
not processed . |
static void |
validateFieldOptions(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
|
public static final int MAX_SHORT_TEXT_LENGTH
public static final String FORMBUILDER_FORM_SOURCE
public static Form getForm(String formId)
formId
- the form identifierForm
or nullpublic static Answer getAnswer(String answerId)
Answer
with the specified identifieranswerId
- the identifierAnswer
or nullpublic static void validateFormFieldType(FormField formField, org.json.simple.JSONObject answersJson) throws AnswerInvalidLengthException, PortalException, NumberFormatException, RequiredAnswerException
formField
- the FormField
used to validate the answer JSONanswersJson
- a JSONObject
with the answersAnswerInvalidLengthException
- if the answer length is to bigNumberFormatException
- if an answer defined as number only contains something elseRequiredAnswerException
- if an answer is defined as required but wasn't answeredPortalException
public static List<FormField> getFormFields(String formId) throws PortalException
formId
- the identifier of the Form
FormField
belonging to the Form
PortalException
public static String formatMailingList(String mailingList, PageWebResource pageWebResource) throws PortalException
mailingList
- the list of e-mails separated by commapageWebResource
- the PageWebResource
used for error localization.PortalException
public static String generateMailBody(String formId, String userName, String formTitle, Answer answer, PageWebResource pageWebResource) throws PortalException
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 resourcePortalException
public static void processAnswer(String answerId)
processed
.answerId
- the identifier of the answer to change statuspublic static void unProcessAnswer(String answerId)
not processed
.answerId
- the identifier of the answer to change statuspublic static FormField getFormField(String fieldId, String formId)
form field
with the specified fieldId and formIdpublic static Collection<lumis.service.formbuilder.FormElement> parseHtmlForm(String htmlFragment) throws PortalException
form elements
from a HTML fragment, each element will be related to
input, select or textarea HTML tags that has a label related to it.htmlFragment
- the HTML fragment to be analyzed.form elements
from a HTML fragment.PortalException
public static void validateFieldOptions(String formFieldOptionsJsonString, int formFieldOptionsCount) throws PortalException
formFieldOptionsJsonString
- the json string.formFieldOptionsCount
- the numbe of expected options.PortalException
LumisXP 12.0.0.190809 - Copyright © 2006–2019 Lumis EIP Tecnologia da Informação LTDA. All Rights Reserved.