Interface YFormFacade

All Known Implementing Classes:
DefaultYFormFacade

public interface YFormFacade
Form Facade to handle yForm definitions and yForm data.
  • Method Details

    • getNewFormDataId

      String getNewFormDataId()
      Generates a new form Data id.
      Returns:
      generated form data id as string.
    • getYFormDefinition

      YFormDefinitionData getYFormDefinition(String applicationId, String formId) throws YFormServiceException
      For a given application id and form id a form definition is returned.
      Parameters:
      applicationId - the application id to search form definition for
      formId - the form id to search form definition for
      Returns:
      form definition with given form id and application id
      Throws:
      YFormServiceException - if form definition cannot with specified parameters be resolved
    • getYFormDefinition

      YFormDefinitionData getYFormDefinition(String applicationId, String formId, int version) throws YFormServiceException
      This method is available for testing purposes, to get the latest YFormDefinition use other method.
      Parameters:
      applicationId - the application id to search form definition for
      formId - the form id to search form definition for
      version - form definition version
      Returns:
      form definition with specific parameters
      Throws:
      YFormServiceException - if form definition cannot with specified parameters be resolved
    • getYFormDefinition

      YFormDefinitionData getYFormDefinition(String documentId) throws YFormServiceException
      For a given document id a form definition is returned.
      Parameters:
      documentId - the document id to search form definition for
      Returns:
      form definition with given document id
      Throws:
      YFormServiceException - if form definition cannot with specified parameters be resolved
    • createYFormDefinition

      YFormDefinitionData createYFormDefinition(String applicationId, String formId, String content, String documentId) throws YFormServiceException
      Create a new YFormDefinition with specific parameters.
      Parameters:
      applicationId - the application id of the form definition
      formId - the form id of the form definition
      content - the content of the form definition
      documentId - the document id of the form definition
      Returns:
      created form definition POJO
      Throws:
      YFormServiceException - if form definition cannot be created
    • updateYFormDefinition

      YFormDefinitionData updateYFormDefinition(String applicationId, String formId, String content, String documentId) throws YFormServiceException
      Update YFormDefinition if it exists in the database.
      Parameters:
      applicationId - the application id of the form definition
      formId - the form id of the form definition
      content - the content of the form definition
      documentId - the document id of the form definition
      Returns:
      YFormDefinitionData updated form definition POJO
      Throws:
      YFormServiceException - if form definition cannot be updated
    • getYFormData

      YFormDataData getYFormData(String formDataId) throws YFormServiceException
      For a given id a form data is returned. First the DRAFT version if there one, else the DATA version of it.
      Parameters:
      formDataId - the form data id to get data for
      Returns:
      form data with given id
      Throws:
      YFormServiceException - if form data cannot be found
    • getYFormData

      YFormDataData getYFormData(String formDataId, YFormDataTypeEnum type) throws YFormServiceException
      For a given id and type a form data is returned.
      Parameters:
      formDataId - the form data id to get data for
      type - the type of the form data
      Returns:
      form data POJO with given id and type
      Throws:
      YFormServiceException - if form data cannot be found
    • getYFormData

      YFormDataData getYFormData(String applicationId, String formId, String refId, YFormDataTypeEnum type) throws YFormServiceException
      For the given application id, form id, reference id and form type a form data is returned.
      Parameters:
      applicationId - the application id of the form data
      formId - the form id to get data for
      refId - the reference id
      type - the type of the form data
      Returns:
      form data POJO with given application id, form id, reference id and type
      Throws:
      YFormServiceException - if form data cannot be found
    • getYFormData

      YFormDataData getYFormData(String applicationId, String formId, String refId) throws YFormServiceException
      For the given application id, form id and reference id a form data is returned.
      Parameters:
      applicationId - the application id of the form data
      formId - the form id to get data for
      refId - the reference id
      Returns:
      form data POJO with given application id, form id and reference id
      Throws:
      YFormServiceException - if form data cannot be found
    • createEmptyYFormData

      String createEmptyYFormData(String applicationId, String formId) throws YFormServiceException
      Creates empty YFormData and assigns it to the corresponding YFormDefinition via orbeon background API.
      Parameters:
      applicationId - the application id of the form data
      formId - the form id of the form data
      Returns:
      new Id for YFormData
      Throws:
      YFormServiceException - if form data cannot be created
    • createYFormData

      YFormDataData createYFormData(String applicationId, String formId, String formDataId, YFormDataTypeEnum type, String refId, String content) throws YFormServiceException
      Creates YFormData if it doesn't exist and assigns it to the corresponding YFormDefinition.
      Parameters:
      applicationId - the application id of the form data
      formId - the form id of the form data
      formDataId - the form data id of the form data
      type - the type of the form data
      refId - the reference id of the form data
      content - the content of the form data
      Returns:
      form data POJO with given parameters
      Throws:
      YFormServiceException - if form data cannot be created
    • updateYFormData

      YFormDataData updateYFormData(String formDataId, YFormDataTypeEnum type, String content) throws YFormServiceException
      Update YFormData content of form data with specific id and type.
      Parameters:
      formDataId - the id of the form data
      type - the type of the form data
      content - new content of the form data
      Returns:
      updated form data POJO
      Throws:
      YFormServiceException - if form data cannot be updated
    • createOrUpdateYFormData

      YFormDataData createOrUpdateYFormData(String applicationId, String formId, String formDataId, YFormDataTypeEnum type, String refId, String formDataContent) throws YFormServiceException
      Create or Update YFormDataModel.
      Parameters:
      applicationId - the application id of the form data
      formId - the form id of the form data
      formDataId - the form data id of the form data
      type - the type of the form data
      refId - the reference id of the form data
      formDataContent - the content of the form data
      Returns:
      created or updated form data POJO
      Throws:
      YFormServiceException - if form data cannot be created or updated
    • createOrUpdateYFormData

      YFormDataData createOrUpdateYFormData(String applicationId, String formId, String formDataId, YFormDataTypeEnum type, String formDataContent) throws YFormServiceException
      Create or Update YFormDataModel.
      Parameters:
      applicationId - the application id of the form data
      formId - the form id of the form data
      formDataId - the form data id of the form data
      type - the type of the form data
      formDataContent - the content of the form data
      Returns:
      created or updated form data POJO
      Throws:
      YFormServiceException - if form data cannot be created or updated
    • getInlineFormHtml

      String getInlineFormHtml(String applicationId, String formId, String formDataId) throws YFormServiceException
      For a given application id, form id and form data id an inline form definition is returned.
      The inline form definition can be injected in to a page instead of getting entire xform tagged between
      Parameters:
      applicationId - the application id of the definition
      formId - the form id of the definition
      formDataId - the form data id of the definition
      Returns:
      the inline form definition as string
      Throws:
      YFormServiceException - if inline definition cannot be returned
    • getInlineFormHtml

      String getInlineFormHtml(String applicationId, String formId) throws YFormServiceException
      For a given application id and form id an inline form definition is returned.
      The inline form definition can be injected in to a page instead of getting entire xform tagged between
      Parameters:
      applicationId - the application id of the definition
      formId - the form id of the definition
      Returns:
      the inline form definition as string
      Throws:
      YFormServiceException - if inline definition cannot be returned
    • getInlineFormHtml

      String getInlineFormHtml(String applicationId, String formId, YFormDataActionEnum action, String formDataId) throws YFormServiceException
      For a given application id, form id, form data id and action an inline form definition is returned.
      The inline form definition can be injected in to a page instead of getting entire xform tagged between
      Parameters:
      applicationId - the application id of the definition
      formId - the form id of the definition
      action - the action on the definition
      formDataId - the form data id of the definition
      Returns:
      the inline form definition as string
      Throws:
      YFormServiceException - if inline definition cannot be returned
    • getInlineFormHtml

      String getInlineFormHtml(String applicationId, String formId, YFormDataActionEnum action, String formDataId, YFormPreprocessorStrategy strategy) throws YFormServiceException
      For a given application id, form id, form data id, action and strategy an inline form definition is returned.
      The inline form definition can be injected in to a page instead of getting entire xform tagged between
      Parameters:
      applicationId - the application id of the definition
      formId - the form id of the definition
      action - the action on the definition
      formDataId - the form data id of the definition
      strategy - form preprocessor strategy
      Returns:
      the inline form definition as string
      Throws:
      YFormServiceException - if inline definition cannot be returned
    • getInlineFormHtml

      String getInlineFormHtml(String applicationId, String formId, YFormDataActionEnum action, String formDataId, YFormPreprocessorStrategy strategy, Map<String,Object> params) throws YFormServiceException
      For a given application id, form id, form data id, action and strategy (plus parameters) an inline form definition is returned.
      The inline form definition can be injected in to a page instead of getting entire xform tagged between
      Parameters:
      applicationId - the application id of the definition
      formId - the form id of the definition
      action - the action on the definition
      formDataId - the form data id of the definition
      strategy - form preprocessor strategy
      params - map with parameters for preprocessor strategy
      Returns:
      the inline form definition as string
      Throws:
      YFormServiceException - if inline definition cannot be returned
    • getFormDataContent

      String getFormDataContent(String applicationId, String formId, String formDataId) throws YFormServiceException
      Returns the content of form data with specific application id, form id and form data id.
      Parameters:
      applicationId - the application id of the form data
      formId - the form id of the form data
      formDataId - the id of the form data
      Returns:
      the content of form data
      Throws:
      YFormServiceException - if form data was not found or its content is invalid
    • getFormDataContentTemplate

      String getFormDataContentTemplate(String applicationId, String formId) throws YFormServiceException
      For a given application id and form id a form data content template (an empty form data via createEmptyYFormData) is returned.
      Parameters:
      applicationId - the application id of the form definition
      formId - the form id of the form definition
      Returns:
      form data content template for definition with specified parameters
      Throws:
      YFormServiceException - if there is no YFormDefinition with given applicationId and formId or YFormDefinition has wrong content
    • recreateYFormDefinitionCounterpart

      String recreateYFormDefinitionCounterpart(String applicationId, String formId, int version) throws YFormServiceException
      Creates the form data counterpart form definition with specific application id, form id and version number.
      Parameters:
      applicationId - the application id of the form definition
      formId - the form id of the form definition
      version - the version number of the form definition
      Returns:
      the form id of created form data
      Throws:
      YFormServiceException - if form definition cannot be found or updated or form data cannot be created
    • setFormDefinitionStatus

      void setFormDefinitionStatus(String applicationId, String formId, YFormDefinitionStatusEnum status) throws YFormServiceException
      Changes the state of a form definition. This will include all related versions.
      Parameters:
      applicationId - the application id of the form definition
      formId - the form id of the form definition
      status - new status of the form definition
      Throws:
      YFormServiceException - if form definition cannot be found or updated
    • validate

      boolean validate(String applicationId, String formId, String formDataId) throws YFormServiceException
      Indicates if the given Form Data is valid or not.
      Parameters:
      applicationId - the application id of the form data
      formId - the form id of the form data
      formDataId - the id of the form data
      Returns:
      true if form data is valid, false otherwise
      Throws:
      YFormServiceException - if form data cannot be found