Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Specification Audit

Active Version

v2.0

CDAP >= v3.0Initial Version
Dev Versionv2.1CDAP > 3.4Adding label to metadata section to display better plugin names. CDAP-5340

...

Groups’ refers to collection of configurations of a plugin. An example structure of a configuration JSON would look like this - Sample JSON

Code Block
languagejs
titleCustomPlugin.json
linenumberstrue
{
 "metadata": {...},
 "inputs": null,
 "configuration-groups": [
   {group1},
   {group2},
   ...
 ],
 "output": [
   {configuration-output-1},
   {configuration-output-2},
   ...
 ]
}

...

In the above mentioned sample JSON, fields 1 & 2 are configurations of CustomPlugin defined in the backend. We could now configure them in the JSON so that it gets easier to use view/edit them in hydrator.

Configurations for a field

Configurations of a field are the set of properties that we define in the JSON, that governs what/how that particular plugin field gets rendered in hydrator. 

...

Code Block
languagejs
titleCustomPlugin.json
linenumberstrue
{
 "configuration-groups": [
   {
     "label": "My Group Title",
     "properties": [
       {
         "name": "Field1",
         "widget-type": "numberbox",
         "widget-attributes": {
           "default": "1"
         },
		 "plugin-function": {
		   "method": "POST",
		   "endpoint": "getSchema",
		   "output-property": "schema"
		 }
       },
       {
         "name": "Field2",
         "widget-type": "json-editor"
       }
     ]
   }
 ],
 "output": [
   {output-property1} 
   {output-property2}
   ...
 ]
}

Widgets

A widget in UI represents a component that we could use to set the value of a property of a plugin. It could be anything representable in HTML. For instance if our CustomPlugin has a property that requires a JSON value, we could use a json-editor to set value to it. A widget, in general, is a component that we can use to represent a property of a plugin to attach a value to it. The following are the list of widgets that we right now have in CDAP that could be readily be used.

 

Widget-type

Description

Attributes

Output data type

Sample JSON

textbox

Default html textbox to enter any string

default

string

 

Code Block
linenumberstrue
{
  "name": "Property1",
  "label": "My A1 Property",
  "widget-type": "textbox",
  "widget-attributes": {
    "default": "Some Text"
  }
}

 

number

Default html number textbox. Can enter only valid numbers.

default, min, max. (default should be between min and max)

int

 

Code Block
languagejs
linenumberstrue
{
  "name": "Property1",
  "label": "My A1 Property",
  "widget-type": "number",
  "widget-attributes": {
    "default": 1,
    "min": 1,
    "max": 100
  }
}

 

passwordbox

Default html password box.

NA

string

 

Code Block
linenumberstrue
{
  "name": "Property1",
  "label": "My A1 Property",
  "widget-type": "password",
}

 

datetime

Date time picker. Used to set date (in string) for any property

default, format (format could be ISO, long, short or full format dates.Reference

string

 

Code Block
linenumberstrue
{
  "name": "Property1",
  "label": "My Date Property",
  "widget-type": "datetime",
  "widget-attributes": {
    "default": "current",
    "format": "MM-DD-YYYY"
  }
}

 

csv

Comma separated values. Each value is entered in a separate box

delimiter (allows to change the delimiter to be any other symbol apart from ‘,’)

comma-separated string

 

Code Block
linenumberstrue
{
  "name": "Property1",
  "label": "My Date Property",
  "widget-type": "csv",
  "widget-attributes": {
    "delimiter": ","
  }
}

 

json-editor

Json editor to pretty-print and auto format JSON while typing

default

string

 

Code Block
linenumberstrue
{
  "name": "Property1",
  "label": "My Date Property",
  "widget-type": "json-editor",
  "widget-attributes": {
    "default": "{ p1: value1}"
  }
}

 

 

javascript-editor,

python-editor

An editor to write Javscript or Python as a value for a property.

default

string

 

Code Block
linenumberstrue
{
  "name": "Property1",
  "label": "My Date Property",
  "widget-type": "json-editor",
  "widget-attributes": {
    "default": "function shouldFilter(input, context) {\n  return false;\n}"
  }
}

 

keyvalue

A key-value editor which allows you to construct map.

 

string

 

Code Block
linenumberstrue
{
  "name": "Property1",
  "label": "My Date Property",
  "widget-type": "keyvalue"
}

 

select

A html dropdown with a list of values. Allows to choose one from the list.

values, default

string

 

Code Block
linenumberstrue
{
  "name": "Property1",
  "label": "My Date Property",
  "widget-type": "keyvalue",
  "widget-attributes": {
    "values": ["Apples", "Oranges", "Bananas"],
    "default": "Bananas"
  }
}

Versioning

...

Code Block
linenumberstrue
{
 "configurations": [
   {group1}
   {group2}
   ...
 ],
 "output": [
   {
     "widget-type": "noneditable-schema-editor",
     "widget-attributes": {
       "schema": {
         "id": { "type": "long" },
         "message": { "type": "string" },
         "lang": { "type": "string", "isNullable": true },
         "time": { "type": "long", "isNullable": true },
         "favCount": {"type": "int"},
         "rtCount": {"type": "int"},
         "source": { "type":"string", "isNullable": true },
         "geoLat": { "type":"double", "isNullable": true },
         "geoLong": { "type":"double", "isNullable": true},
         "isRetweet": { "type": "boolean" }
       }
     }
   }
 ]
}
 

Here

we

have

an

output

configuration

which

uses

a noneditable-schema-editor

widget.

In

hydrator

Hydrator, this

will

show

as a

schema

editor

that

is

not

editable

and

it

will

have

the schema

mentioned

under

‘widget-attributes’.