Skip to end of metadata
Go to start of metadata

 

Datachooser

Datachoosers are user components that allow you to retrieve data from a server and display it on a form using appropriate mappings of results to variables.

Created datachoosers are available in the process editor and can be easily used in a business process enabling the execution of business logic. Their behavior can be further configured using parameters.

Defining datachooser

Datachoosers are created based on their user-created definition. Such a definition must contain the following elements:

  1. Annotation @DataChooser (if datachooser is not defined in the plugin, it must come from the com.suncode package)
  2. A public method annotated @Define with one parameter DataChooserDefinitionBuilder
  3. A public method called data, which is responsible for transferring the data to be displayed.

Datachooser can also provide a script that builds the appearance of parameters when it is defined in the PWE. To do this, add another annotation @ComponentsFormScript for the class with the path to the script passed in (from classpath).

An example definition is shown below. Datachooser sets 2 mappings.

@DataChooser
@ComponentsFormScript( "path/example-form.js" )
public class DatachooserExample
{
    @Define
    public void definition( DataChooserDefinitionBuilder builder )
    {
        builder
            .id( "datachooser-example" )
            .name( "datachooser.example.name" )
            .description( "datachooser.example.desc" )
            .category( Categories.TEST )
            .parameter().id( "param1" ).name( "Param1" ).description( "ParamDesc" ).type( Types.STRING ).create()
            .mapping().id( "mapping1" ).name( "Mapping1" ).description( "MappingDesc" ).create();
    }
    public void data( ComponentQueryData queryData, DataChooserResult result )
    {
        result.row()
            .value( "value", "A" )
            .value( "mapping1", "B" );
        result.row()
            .value( "value", "AA" )
            .value( "mapping1", "BB" );
        result.setTotal( 2 );
    }
}

Implementation of datachooser

Datachooser must have a method named data. The method can have the following types of parameters:

  • single datachooser parameter - the parameter type must conform to the defined type and must be preceded by the annotation @Param,
  • parameter mapping two array parameters (key, value) - the type of the parameter must be of type java.util.Map<K,V>, where K is the defined type of the component parameter being the key, and V is the defined type of the component parameter being the value for the key. The parameter must be annotatedPairedParam with defined properties (key - id of the parameter being the key, value - id of the parameter being the value).
  • single parameter of type DataSourceInstance annotated @Param - if you have such a type, the DataSourceInstance object will be injected based on the value of this parameter, which must be the id of the data source.
  • Parameters - contains all the defined datachooser parameters with their values, this is an alternative to retrieving a parameter using the aforementioned annotation @Param,
  • DataChooserContext - datachooser call context, you can read the process and task identifier and mapping declaration from it.
  • ComponentQueryData - object containing information about the paging and filtering of the datachooser. The query field contains the filtering value passed from the datachooser of type List, while the filters field contains the mapping of filtering values from the datachooser of type Window.
  • DataChooserResult - object, in which all the data to be returned to the form is stored. The number of rows cannot exceed the limit of one page
  • ActivityContextMap - an object that stores the variables of the form with their current values, as well as the process and task ID; all variables can be set to values.
  • ContextVariables - context variables available in this datachooser. More information here,
  • Translator - a translator for this component, so that messages returned by the datachooser can be translated. More information here,
  • UserInfo - object containing information about the user triggering the datachooser.

Registration of datachooser in the plugin

If the automatic task is defined in the plugin, then you must additionally indicate that the plugin provides components. To do this, add an entry in the suncode-plugin.xml file:

<!-- Sharing datachooser-->.
<workflow-components key="components" />

  • No labels