Like what you see? Have a play with our trial version.

Error rendering macro 'rw-search'

null

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 7 Next »

The user interface of Yellowfin plug-ins are built by using or extending classes in the Parameter API.

There are four levels of hierarchy for building UI. The diagram below explains these levels:





Parameter Panel Collection

This is the outermost container of the UI and is described by abstract class ParameterPanelCollection. This usually represents a collection of tabs. Implementing classes must override a few methods and are described in the javadoc. The important methods in this collection are listed below:


Parameter Panel Collection MembersDescription
public List<ParameterPanel> getPanels()

Override this method to return a list of panels (tabs) within the ParameterPanelCollection.

public String getParameterPanelCollectionClassName()This method returns a CSS class name to be applied to the Panel Collection.
protected Map<String, Map<String, ?>> dataThis member variable is meant for holding data from the Panels within the Panel Collection. The toJSON() method populates it. Implementations may change what’s in this object by overriding getData().
public Map<String, ?> getData()The default implementation returns the member variable data. A subclass of ParameterPanelCollection may override to modify it. toJSON()converts whatever getData() returns to JSON.

public JSONObject toJSON()


This method converts everything in the Panel Collection to a org.json.JSONObject (Jackson). The object attributes are name, description, panels, data and parameterPanelCollectionClassName.

  • The panels attribute holds a JSONArray of JSONObjects returned by each ParameterPanel.
protected byte[] getFile(Integer fileId)

protected String getText(Integer textId)

If the ID is known, these methods allow a file or a CLOB to be read from the Yellowfin configuration database. The ID may be stored in the component’s configuration. In case of Data Transformations, this would be a Step Option.

public List<ParameterDisplayRule> getDisplayRules()

This method need not be implemented at this level. Yellowfin currently does not use these rules, but may do so in a future release.


Implementation

Yellowfin includes an implementation of ParameterPanelCollection for use with Data Transformation steps. ETLStepPanels is easy to use. It has a method addPanels() for adding ParameterPanel objects.

 

ETLStepPanels panels = new ETLStepPanels();
panels.addPanel(panel);

 




Parameter Panel

This is the second level of the UI and is described by abstract class ParameterPanel. A panel is usually implemented as a tab. Implementing classes must override a few methods and are described in the javadoc. The important members in the Panel API are listed below:

Parameter Panel membersDescription
public String getPanelKey()

This method returns a unique identifier for the Panel within a Panel Collection.

public String getName()This is used to provide a name to the Panel or tab.
public String getParameterPanelClassName()This returns a CSS class to be applied to the Panel. This should be overridden as the default implementation returns null.
public List<ParameterSection> getSections()Implementations should return a list of ParameterSection objects within this Panel.

public String getDynamicKey()

public void setDynamicKey(String dynamicKey)
These methods are used for working with Dynamic Parameters, which is discussed in the section on Helper Objects.
public GeneralPanelOptions getGeneralOptions()General Options are discussed in the section on Helper Objects. These options control how the UI is rendered.

public List<ParameterDisplayRule> getDisplayRules()

Display Rules are discussed in the section on Helper Objects. They are used to determine whether a panel should be displayed or not based on user input.

public Map<String, ?> getData()

As with ParameterPanelCollection, the default implementation returns the member variable data. Subclasses may override to modify it. This is used by the ParameterPanelCollection’s toJSON() method to construct its data object.
public JSONObject toJSON()

This method converts everything in the Panel Collection to a org.json.JSONObject (Jackson). The main attributes of the object are name, description, panelKey, parameterPanelClassName, sections, displayRules, dynamicKey and generalOptions.

    • sections holds a JSONArray of JSONObjects returned by each ParameterSection.
    • displayRules holds a list of ParameterDisplayRule, the details of which are discussed in the section on Helper Objects.
    • generalOptions holds an instance of GeneralPanelOptions, discussed in the section on Helper Objects.


Implementation

Yellowfin ships with an implementation of ParameterPanel for use with Data Transformation steps. ETLStepConfigPanel is easy to use. It has a method called addSection() for adding ParameterSection objects. Its implementation of getGeneralOptions() adds an “Apply” button to the bottom of the panel using standard styling from Data Transformations.

 

String stepName = getETLStepBean().getStepName();
ETLStepConfigPanel panel = new ETLStepConfigPanel(PANEL_KEY, stepName);
panel.addSection(section);

 




Parameter Section

This is the third level and is described by the abstract class ParameterSection. Implementing classes must override a few methods and are described in the javadoc. The important members in the API are listed below:


 

Parameter Section MembersDescription
public String getSectionKey()This returns a unique identifier for the Section within a Panel.
public String getName()The name of the Section. This is rendered as the heading of a section.
public String getParameterSectionClassName()This returns a CSS class to be applied to the Section. This should be overridden as the default implementation returns null.
public List<Parameter> getParameters()Implement this method to get a list of ParameterSection objects within this Panel. This should never return a null value.

public String getDynamicKey()

public void setDynamicKey(String dynamicKey)
These methods are used for working with Dynamic Parameters, which is discussed in the section on Helper Objects.
public GeneralPanelOptions getSectionOptions()General Options are discussed in the section on Helper Objects. These options control how the UI is rendered.
public List<ParameterDisplayRule> getDisplayRules()Display Rules are discussed in the section on Helper Objects. They are used to determine whether a panel should be displayed or not based on user input.
public Map<String, ?> getData()This method is abstract at this level. Implementations should return the data object for the level, containing data relevant to the Parameters. This is used by ParameterPanel’s toJSON() method to construct its data object.
protected ParameterValueLoader parameterValueLoaderThis protected member variable contains the Value Loader associated with this section. It is used to load option values of a Parameter, when the user selected a related parameter. For example, reloading a country dropdown, based on the user’s selection of region. Value Loaders are discussed in detail in the section on Helper Objects.
public JSONObject toJSON()

This method converts everything in the Section to a org.json.JSONObject (Jackson). The main attributes of the object are name, sectionKey,  parameterSectionClassName, parameters, displayRules, dynamicKey and generalOptions.

  • parameters holds a JSONArray of Parameter instances returned by getParameters(). Each item is converted to a JSONObject before it is put into the JSONArray.
  • displayRules holds a list of ParameterDisplayRule, the details of which are discussed in the section on Helper Objects.
  • generalOptions holds an instance of GeneralPanelOptions, discussed in the section on Helper Objects. If a value loader is set, the JSON object will also contain the classname of the loader object in the attribute valueLoaderClassName.

 

Implementation

Yellowfin comes included with ETLStepConfigSection, an implementation of ParameterSection which can be used with Data Transformation steps. Related methods of use include:

MethodsDescription
public Map<String, ?> getData()Returns member variable data which contains data from the parameters in this section.
public void setData(Map<String, ?> data)Replaces the class member data with the object passed with this method.
public void setMappedParameterDataObject(String key, Object value)Adds the specified key and value to the data object.
public void setMappedParameterData(String key, String value)

Adds the key and value to the data object. When the value is a JSON String, it is converted to an equivalent Java object. For example:

  • "{key1: value1, key2: value2}" is converted to Map<String, Object>
  • "[1, 2, 3]" is converted to List<Object>
  • "true" is converted to a Boolean.

This is done using the method convertParameterToJSON() in the ParameterSection class.


When this implementation is used, it applies some standard Yellowfin styling to the section.

 

ETLStepConfigSection section = new ETLStepConfigSection("SECTION_KEY", "SectionName");
section.addParameter(rowCountParam); // Parameter containing option key ROW_COUNT_KEY
section.setMappedParameterDataObject("ROW_COUNT_KEY", rowCountInteger);

 





Parameter

This is the fourth and lowest level, and is described by the Parameter interface. User input widgets are rendered by implementation classes. Yellowfin has a number of implementations, most of which can be used by instantiating the ParameterImpl class and setting the correct input type. Yellowfin uses this information to generate html using its view engine.

The important methods of the ParameterImpl class are listed below:

MethodsDescription
public void setInputType(InputType type)

This is used to set the parameter type to one defined in enum InputType. For example, InputType.SELECT renders a dropdown.

public void setName(String name)The name of the Parameter gets rendered as a label to the left of the input element.
public void setDescription(String desc)The description gets rendered below the label.
public void setProperty(String property)User input is set in this property of a JSON object and sent back to the server when submitted.

public void setMinAllowed(int min)

public void setMaxAllowed(int max)
Shows an error message if the input is outside of the min or max bounds. This is applicable for numeric input values.

public void addViewOption(String property, Object value)

public void setViewOptions(Map<String, Object> viewOptions)

The rendered input widget can be customized by setting up options using these methods. The available views and their options are listed in the section on Input Types.

public void addDisplayRule(ParameterDisplayRule rule)

public void setDisplayRules(List<ParameterDisplayRule> displayRules)
Display Rules are used to determine whether a panel should be displayed or not, based on user input. There’s more on this in the section on Helper Objects.

public void addPossibleValue(String val, String desc)

public void addPossibleValue(String val, String desc, String colour)

public void setPossibleValues(List<CustomValue<?>> possibleValues)

These methods are used to set up the available option values for an input type such as Dropdown List. addPossibleValue  is also overloaded to accept an integer value. The value, description and colour are used to build a CustomValue object which is then used to render an option. The string in the value field will be saved to the database as the selected option. The description is for display purposes only.


public void setParameterClassName(String className)Set a CSS class to be applied to the parameter.
public void setCssRules(Set<CssRule> cssRules)

Define CSS rules which can be used for fine-grained control over styling of a parameter. This is described in detail in the section on Helper Objects.


public void addParameterValueDisplay(String key, ParameterValueDisplay pvd)


The ParameterValueDisplay object is used to define how a parameter is rendered for a specific input value. The input value is specified in the “key” attribute. For example, in case of a toggle switch, this could be used to change the image and colour of the switch when the current selection is “false”. ParameterValueDisplay is discussed in detail in the section on Helper Objects.

public void setList(boolean)

public void setListOptions(ListOptions listOptions)
setList is used to determine whether or not to generate a list of parameters of a specified type. For example, when set to true for a TEXTBOX type, it will generate a list of textboxes that can be accumulated to indefinitely using an “add” button. Options for rendering the list are defined using a ListOptions object. This is described in detail in the section on Helper Objects.

public void setValidationRules(ParameterValidation rules)

public void setObjectValidationRules(Map<String, ParameterValidation> rules)


These methods are used to set up front-end validation rules. For example, this can be used to ensure that an input field is not empty. Object validation is used to validate JSON objects. For example, a field matching parameter may hold the mapping between two fields as a JSON object

{
  "from": "field1",
    "to": "field2"
}

The keys in the map passed to setObjectValidationRules, should be the object properties “from” and “to”. The values should be the ParameterValidation objects for validating “field1” and “field2” respectively. For more details, see the section on Helper Objects.

public void setValueDependencies(List<ValueDependent> deps)

public void addValueDependency(String prop, PropertyLocation loc)

public void addValueDependency(ValueDependent dep)
This is used if the Parameter being set up is dependent on another. When the value of one parameter changes, dependent parameters get re-rendered. For more information, see the section on Helper Objects.

public void setEvent(String event)

public void setEventParameters(List<ValueDependent> eventParameters)

 public void addEventParameter(ValueDependent parameter)         

 public void addEventParameter(String prop, PropertyLocation loc)

 public void setEventData(Map<String, Object> eventData)

public void addEventData(String key, Object value)

Events are similar to Value Dependencies, except in reverse. This is used to trigger an event when the parameter’s value changes. This may be used to change the values of “child” parameters. Event Data is used to send any associated data along with the triggered events. For more information, see the section on Helper Objects.

public String getDynamicKey()

public void setDynamicKey(String dynamicKey)

These methods are used for working with Dynamic Parameters, which is discussed in the section on Helper Objects.


 





  • No labels