org.jbpm.formbuilder.client
Class XmlParseHelper

java.lang.Object
  extended by org.jbpm.formbuilder.client.XmlParseHelper

public class XmlParseHelper
extends Object

This class is to help FormBuilderModel to parse response messages and transform request bodies.


Constructor Summary
XmlParseHelper()
           
 
Method Summary
 String asXml(FormRepresentation form, Map<String,Object> inputs)
          Method to output xml from a form preview and its group of test input variables with the following format: <formPreview>
  <representation>${form.toJson()}</representation>
  <input key="${inputs[0].key}" value="${inputs[0].value}"/>
  <input key="${inputs[1].key}" value="${inputs[1].value}"/>
  ...
 String asXml(String groupName, FBMenuItem item)
          Method to output xml from a menu item and its group's name with the following format: <menuItem>
  <groupName>${groupName}</groupName>
  <name>${item.description.text}</name>
  <clone><!
 String asXml(String formItemName, FormItemRepresentation formItem)
          Method to output xml from a form item and is name with the following format: <formItem name="${formItemName}">
  <content>${formItem.asJson()}</content>
</formItem>
 String getFileName(String responseText)
          Parses and returns a file name from an XML response of the following format: <fileName>${response}</fileName>
 String getFormId(String responseText)
          Parses and returns a formItemId from an XML response of the following format: <formItemId>${response}</formItemId>
 String getFormItemId(String responseText)
          Parses and returns a formId from an XML response of the following format: <formId>${response}</formId>
 List<String> readFiles(String responseText)
          Ment to parse an XML response with the following format: <files>
  <file>${url}</file>
</files>
 List<FormRepresentation> readForms(String responseText)
          Ment to parse an XML response with the following format: <listForms>
  <form><json>${jsonFromFormRepresentation}</json></form>
</listForms>
 Map<String,List<FBMenuItem>> readMenuMap(String responseText)
          Ment to parse an XML response with the following format: <menuGroups>
  <menuGroup name="???"
 List<MainMenuOption> readMenuOptions(String responseText)
          Ment to parse an XML response with the following format: <menuOptions>
  <menuOption name="${option[0].html}" (commandClass="${option[0].command.class.name}")>
    <menuOption name="${option[0].subMenu[0].html}" commandClass="${option[0].subMenu[0].command.class.name}"/>
    ...
 Map<String,String> readPropertyMap(String responseText)
          Parses and returns a map of strings with string keys from an XML response of the following format: <properties>
  <property key="${key[0]}" value="${value[0]}"/>
  <property key="${key[1]}" value="${value[1]}"/>
  ...
 List<String> readRoles(String response)
           
 List<TaskRef> readTasks(String responseText)
          Ment to parse an XML response with the following format: <tasks>
  <task processId="${task.processId}" taskName="${task.taskId}">

    <input name="${task.inputs[0].name}" source="${task.inputs[0].sourceExpression}"/>
    <input name="${task.inputs[1].name}" source="${task.inputs[1].sourceExpression}"/>
    ...
 List<FBValidationItem> readValidations(String responseText)
          Parses and returns a validation dto list from an XML response of the following format: <validations>
  <validation className="${fbValidationItem[0].class.name}">
    <property key="${key[0]}" value="${value[0]}"/>
    <property key="${key[1]}" value="${value[1]}"/>
    ...
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XmlParseHelper

public XmlParseHelper()
Method Detail

asXml

public String asXml(String formItemName,
                    FormItemRepresentation formItem)
             throws FormEncodingException
Method to output xml from a form item and is name with the following format: <formItem name="${formItemName}">
  <content>${formItem.asJson()}</content>
</formItem>

Parameters:
formItemName - name of the form item
formItem - the form item to format
Returns:
XML request body
Throws:
FormEncodingException

asXml

public String asXml(String groupName,
                    FBMenuItem item)
Method to output xml from a menu item and its group's name with the following format: <menuItem>
  <groupName>${groupName}</groupName>
  <name>${item.description.text}</name>
  <clone><![CDATA[${item.asJson()}]]></clone>
  <effect>${item.formEffects[0].class.name}</effect>
  <effect>${item.formEffects[1].class.name}</effect>
  ...
  <effect>${item.formEffects[n].class.name}</effect>
</menuItem>

Parameters:
groupName - the menu item group's name
item - the menu item
Returns:
XML request body

readTasks

public List<TaskRef> readTasks(String responseText)
Ment to parse an XML response with the following format: <tasks>
  <task processId="${task.processId}" taskName="${task.taskId}">

    <input name="${task.inputs[0].name}" source="${task.inputs[0].sourceExpression}"/>
    <input name="${task.inputs[1].name}" source="${task.inputs[1].sourceExpression}"/>
    ...
    <input name="${task.inputs[n].name}" source="${task.inputs[n].sourceExpression}"/>

    <output name="${task.outputs[0].name}" source="${task.outputs[0].sourceExpression}"/>
    <output name="${task.outputs[1].name}" source="${task.outputs[1].sourceExpression}"/>
    ...
    <output name="${task.outputs[n].name}" source="${task.outputs[n].sourceExpression}"/>

    <metaData key="${task.metaData.entrySet[0].key}" value="${task.metaData.entrySet[0].value}"/>
    <metaData key="${task.metaData.entrySet[1].key}" value="${task.metaData.entrySet[1].value}"/>
    ...
    <metaData key="${task.metaData.entrySet[n].key}" value="${task.metaData.entrySet[n].value}"/>

  </task>
  ...
</tasks>

Parameters:
responseText - The XML response.
Returns:
a list of task definition references.

readMenuOptions

public List<MainMenuOption> readMenuOptions(String responseText)
Ment to parse an XML response with the following format: <menuOptions>
  <menuOption name="${option[0].html}" (commandClass="${option[0].command.class.name}")>
    <menuOption name="${option[0].subMenu[0].html}" commandClass="${option[0].subMenu[0].command.class.name}"/>
    ...
    <menuOption name="${option[0].subMenu[n].html}" (commandClass="${option[0].subMenu[n].command.class.name}")>
      <menuOption name="${option[0].subMenu[n].subMenu[0].html}" commandClass="${option[0].subMenu[n].subMenu[0].command.class.name}"/>
    </menuOption>
  </menuOption>
  ...
  <menuOption name="${option[m].html}" commandClass="${option[m].command.class.name}"/>
</menuOptions>

Parameters:
responseText - The XML response.
Returns:
a list of menuOptions.

readForms

public List<FormRepresentation> readForms(String responseText)
Ment to parse an XML response with the following format: <listForms>
  <form><json>${jsonFromFormRepresentation}</json></form>
</listForms>

Parameters:
responseText - the XML response.
Returns:
a list of FormRepresentation items.

readMenuMap

public Map<String,List<FBMenuItem>> readMenuMap(String responseText)
Ment to parse an XML response with the following format: <menuGroups>
  <menuGroup name="???">
    <menuItem className="???" optionName="???">
      <itemJson>???</itemJson>
      <effect className="???"/>
    </menuItem>
    ...
    <menuItem ...>
      ...
    </menuItem>
  </menuGroup>
  ...
  <menuGroup name="???">
    ...
  </menuGroup>
</menuGroups>

Parameters:
responseText - the XML response.
Returns:
a map of lists of FBMenuItem instances.

getFormItemId

public String getFormItemId(String responseText)
Parses and returns a formId from an XML response of the following format: <formId>${response}</formId>

Parameters:
responseText - XML response to parse
Returns:
a formId

getFormId

public String getFormId(String responseText)
Parses and returns a formItemId from an XML response of the following format: <formItemId>${response}</formItemId>

Parameters:
responseText - XML response to parse
Returns:
a formItemId

getFileName

public String getFileName(String responseText)
Parses and returns a file name from an XML response of the following format: <fileName>${response}</fileName>

Parameters:
responseText - XML response to parse
Returns:
a file name on the server

readPropertyMap

public Map<String,String> readPropertyMap(String responseText)
Parses and returns a map of strings with string keys from an XML response of the following format: <properties>
  <property key="${key[0]}" value="${value[0]}"/>
  <property key="${key[1]}" value="${value[1]}"/>
  ...
  <property key="${key[n]}" value="${value[n]}"/>
</properties>

Parameters:
responseText - XML response to parse
Returns:
a map of the string values indexed by property name

asXml

public String asXml(FormRepresentation form,
                    Map<String,Object> inputs)
             throws FormEncodingException
Method to output xml from a form preview and its group of test input variables with the following format: <formPreview>
  <representation>${form.toJson()}</representation>
  <input key="${inputs[0].key}" value="${inputs[0].value}"/>
  <input key="${inputs[1].key}" value="${inputs[1].value}"/>
  ...
  <input key="${inputs[n].key}" value="${inputs[n].value}"/>
</formPreview>

Parameters:
form - the form representation to transform on server side to a given language
inputs - the data inputs of the form representation to test it
Returns:
XML request body
Throws:
FormEncodingException - in case of error parsing the form representation

readValidations

public List<FBValidationItem> readValidations(String responseText)
                                       throws Exception
Parses and returns a validation dto list from an XML response of the following format: <validations>
  <validation className="${fbValidationItem[0].class.name}">
    <property key="${key[0]}" value="${value[0]}"/>
    <property key="${key[1]}" value="${value[1]}"/>
    ...
    <property key="${key[n]}" value="${value[n]}"/>
  </validation>
  ...
  <validation className="${fbValidationItem[m].class.name}">
    <property key="${key[0]}" value="${value[0]}"/>
    <property key="${key[1]}" value="${value[1]}"/>
    ...
    <property key="${key[p]}" value="${value[p]}"/>
  </validation>
</validations>

Parameters:
responseText - XML response to parse
Returns:
a list of validation items
Throws:
Exception

readRoles

public List<String> readRoles(String response)

readFiles

public List<String> readFiles(String responseText)
Ment to parse an XML response with the following format: <files>
  <file>${url}</file>
</files>

Parameters:
responseText - the XML response.
Returns:
a list of Strings representing names of files.


Copyright © 2001-2012 JBoss by Red Hat. All Rights Reserved.