Class 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) $
    • Constructor Detail

      • FormBuilderManager

        public FormBuilderManager()
    • 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 the Answer with the specified identifier
        Parameters:
        answerId - the identifier
        Returns:
        the Answer or null
        Since:
        8.2.0
      • getFormAnswers

        public static List<Answer> getFormAnswers​(String formId)
        Get the answers for the desired Form
        Parameters:
        formId - the identifier of the Form
        Returns:
        the list of answers belonging to the Form
        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 comma
        pageWebResource - the PageWebResource 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 form
        formTitle - The title of the form that was answered
        answersValues - The JSONObject generated with all answers
        pageWebResource - 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 to processed.
        Parameters:
        answerId - the identifier of the answer to change status
        Since:
        8.2.0
      • unProcessAnswer

        public static void unProcessAnswer​(String answerId)
        Change answer status to not 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 the form field with the specified fieldId and formId
        Parameters:
        fieldId - the fieldId
        formId - the identifier of the Form to find the field from
        Returns:
        the FormField that has the specified fieldId or null if there is no FormField with the passed fieldId for the passed formId.
        Since:
        8.2.0
      • parseHtmlForm

        public static Collection<lumis.service.formbuilder.FormElement> parseHtmlForm​(String htmlFragment)
                                                                               throws PortalException
        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.
        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