-
Notifications
You must be signed in to change notification settings - Fork 11
Task Definitions
A TaskDefinition is a JSON data structure that represents the workflow (consisting of pages with various inputs and outputs) for a given task. The android client will parse a given TaskDefinition and render the appropriate native UI components such as spinners and text inputs.
A TaskDefinition consists of one or more "page" elements, each containing one or more "item" elements. Each item may have a number of metadata attributes such as name or description. In addition, there are attributes to define the path through the task and for the conditional viewing and setting of data items.
The root element.
Must contain:
- id - This will be generated by the server
- name - a unique name for the task. It will be used when mapping TaskDefinitions to DataConnectors
- description
- pages - a list of one or more page elements
Must contain:
- name - a unique (within the task definition) identifier for the page
- title - A user-visible label for the page. Will be displayed in the application's title bar
- items - a list of one or more item elements
May contain:
- nextPages - a list of PageSelector elements used to provide conditional flow through the TaskDefintion. See Expression Language for details.
- attributes - a map of page specific attributes, in the form of a key:value string pairing. Currently only the "visibility" attribute is supported for pages, to determine if a page is visible during an ad-hoc task or not.
Must contain:
- name - a unique (within the page) identifier for the item
- label - a User-visible label for the item. Will be displayed
- type - one of the following values:
- LABEL - A read-only section header
- TEXT - A text input. Defaults to a single line but will accept an attribute of "lines" detailing the number of lines to display. Also accepts an attribute of "readonly"
- DIGITS - A numeric input. Sets the appropriate keyboard input.
- NUMERIC - Same as DIGITS
- DATETIME - A Date input - uses standard android widgets for entering a date.
- YESNO - A labelled check box.
- SELECT - A ingle or multi selectable list (Determined by value of attribute "multiselect").
- one of either:
- value - a single pre-set value
- values - a list of pre-set values
May contain:
- attributes - a list of item specific attributes. In addition to those listed next to the item type, the following attributes are applicable to all page items:
- readonly - true|false - indicates if item is editable or not
- hidden - true|false - indicated if item should be visible on screen or not
- required - true|false - indicates if user must enter a value for this item. Will trigger validation error when moving to next page if value is not entered by user
- condition - expression to determine if page item is displayed or not. See Expression Language for details.
- expression - expression to evaluate for setting the value of the item. See Expression Language for details.
{
"id": 3,
"description":"Hello world example",
"name":"hello_world",
"pages":[
{
"name":"page1",
"title":"Page 1",
"items":[
{
"name":"label",
"label":"Hello World!",
"type":"LABEL"
}
]
}
]
}
This Hello World example is one of the most basic workflows possible. This will result in a single page (with the title "Page 1") being displayed. On that page, there will be a single line of text "Hello World!".
As there are no further pages, there will be a single Finish button displayed on screen to end the workflow.
{
"id": 4,
"description":"Another Hello world example",
"name":"hello_name",
"pages":[
{
"name":"page1",
"title":"Hello",
"items":[
{
"name":"label",
"label":"Howdy",
"type":"TEXT",
"value":"Stranger",
"attributes":{"readonly":"true"}
}
]
}
]
}
In this version of the Hellow World workflow, the item has been changed to a readonly TEXT item instead of a label and has been given a default value of "Stranger", meaing that by default the message on screen will read "Howdy Stranger". However, if the task definition and dataconnector mappings are set up accordingly, then value of the "label" item could be read from a datasource such as a row in a database, meaning that the message on screen could ready "Howdy John Smith" for the user John Smith.
{
"id": 2,
"description":"Three Page Test",
"name":"three_page",
"pages":[
{
"name":"page1",
"title":"Page 1",
"items":[
{
"name":"label",
"label":"This is page 1. The next page should be page 3.",
"type":"LABEL"
}
],
"nextPages":[
{
"pageName":"page3",
"condition":""
}
]
},
{
"name":"page2",
"title":"Page 3",
"items":[
{
"name":"label",
"label":"This is page 2. You should never see this page.",
"type":"LABEL"
}
]
},
{
"name":"page3",
"title":"Page 3",
"items":[
{
"name":"label",
"label":"This is page 3. The previous page should be page 1.",
"type":"LABEL"
}
]
}
]
}
This workflow defines three pages, so on first launching page one will be displayed, with a "Next" button to progress through the workflow to the next page.
The nextPages section of "page1" indicates that instead of going to "page2" (the default behaviour when no nextPage section is present), the user should be directed to "page3" instead. So, although 3 pages are defined, only 2 will be visible to the user.
A condition could be places on the nextPage entry if required, to allow for page2 to be displayed under certain circumstances.