Package lumis.service.formbuilder
Class FormBuilderManager
- java.lang.Object
-
- lumis.service.formbuilder.FormBuilderManager
-
public class FormBuilderManager extends Object
Form framework manager implementation.- Since:
- 8.2.0
- Version:
- $Revision: 22816 $ $Date: 2019-06-05 16:37:27 -0300 (Wed, 05 Jun 2019) $
-
-
Field Summary
Fields Modifier and Type Field Description static 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 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 formstatic Answer
getAnswer(String answerId)
Get theAnswer
with the specified identifierstatic Form
getForm(String formId)
Get the Form with the specified identifierstatic List<Answer>
getFormAnswers(String formId)
static FormField
getFormField(String fieldId, String formId)
Get theform field
with the specified fieldId and formIdstatic List<FormField>
getFormFields(String formId)
static Collection<lumis.service.formbuilder.FormElement>
parseHtmlForm(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(String answerId)
Change answer status toprocessed
.static void
unProcessAnswer(String answerId)
Change answer status tonot 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
-
-
-
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 String FORMBUILDER_FORM_SOURCE
- See Also:
- Constant Field Values
-
-
Method Detail
-
getForm
public static Form getForm(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(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, 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 bigNumberFormatException
- 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 List<FormField> getFormFields(String formId) throws PortalException
- Parameters:
formId
- the identifier of theForm
- Returns:
- the list of
FormField
belonging to theForm
- Throws:
PortalException
- Since:
- 8.2.0
-
formatMailingList
public static String formatMailingList(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 String generateMailBody(String formId, String userName, 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(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(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(String fieldId, String formId)
Get theform field
with the specified fieldId and formId
-
parseHtmlForm
public static Collection<lumis.service.formbuilder.FormElement> parseHtmlForm(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(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
-
-