Class FormBuilderManager


  • public class FormBuilderManager
    extends java.lang.Object
    Form framework manager implementation.
    Since:
    8.2.0
    Version:
    $Revision$ $Date$
    • 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 form
      static Answer getAnswer​(java.lang.String answerId)
      Get the Answer with the specified identifier
      static Form getForm​(java.lang.String formId)
      Get the Form with the specified identifier
      static java.util.List<Answer> getFormAnswers​(java.lang.String formId)
      Get the answers for the desired Form
      static FormField getFormField​(java.lang.String fieldId, java.lang.String formId)
      Get the form field with the specified fieldId and formId
      static java.util.List<FormField> getFormFields​(java.lang.String formId)
      Get the FormField for the desired Form
      static java.util.Collection<lumis.service.formbuilder.FormElement> parseHtmlForm​(java.lang.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​(java.lang.String answerId)
      Change answer status to processed.
      static void unProcessAnswer​(java.lang.String answerId)
      Change answer status to not 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
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • FORMBUILDER_FORM_SOURCE

        public static final java.lang.String FORMBUILDER_FORM_SOURCE
        See Also:
        Constant Field Values
    • Constructor Detail

      • FormBuilderManager

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

        public static java.util.List<Answer> getFormAnswers​(java.lang.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 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 comma
        pageWebResource - the PageWebResource 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 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​(java.lang.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​(java.lang.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​(java.lang.String fieldId,
                                             java.lang.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 java.util.Collection<lumis.service.formbuilder.FormElement> parseHtmlForm​(java.lang.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​(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