Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Removed translated content for 'zh'
Sv translation
languageen
Info
Connector SDK 1.0+ and BellaDati 2.9.7+ advanced connector behavior can be provided as metadata.


Metadata allows you to define:

  • Connector name and description
  • Connector logo
  • Wizard mode
    • Steps with name and description
    • Elements of various types: input fields, HTML code, links

Using metadata

Metadata are defined as org.json.JSONObject instance and are returned by static getMetadata() method defined in your custom connector DataProviderApi implementation class.

Code Block
languagejava
public class MyDataProvider extends DataProviderApi<RowsApi<? extends RowApi>> {
 
...
 
	public static org.json.JSONObject getMetadata() {
		...
	}
 
...
}

Metadata properties

FieldTypeDescriptionExample
name
StringName of the connector displayed on the data sources page. Overrides the value returned by getName() method.
description
StringDescription of the connector displayed on the data sources page
logo
StringPath to the logo 64x64px image file. Should be placed inside the same package as custom connector main class.
wizard
BooleanDetermines whether the connector settings should be displayed in wizard mode. If true, content of steps element are then used to define particular step content. Window with parameters otherwise.

Properties mode:

Wizard mode:




keysString

Keys support translations of names, descriptions, and values. The reference to the is defined by using message:prefix, e.g. message:key1.

Code Block
{
    "name" : "Custom connector",
    "description" : "This is custom data connector",
    "wizard" : true,
    "keys" : {
        "default" : { "key1" : "label 1", "key2 : "label 2" },
        "cs" : { "key1" : "cs label 1", "key2 : "cs label 2" },
		"de" : { "key1" : "de label 1", "key2 : "de label 2" }
    }
}

If no value is found, the default is used. If no default is specified, value with the prefix is displayed.

steps
Array of ObjectsContains steps of which the connector settings wizard is composed
steps[].index
IntegerIndex of the step
steps[].name
StringName of the step
steps[].description
StringDescription of the step
steps[].elements[]
Array of ObjectsContains elements that are displayed after each other inside the table with two columns. 
steps[].elements[].id
StringID of the element, is stored in data-id attribute.

Values of all elements are stored in hidden <span> elements below the step description:

Code Block
languagexml
<div style="display:none">
	<span data-value="false" data-id="el_9"></span>
	<span data-value="tests" data-id="el_5"></span>
	<span data-value="second value" data-id="el_2"></span>
	<span data-value="test" data-id="el_1"></span>
</div> 
steps[].elements[].label
StringLabel of the element. Content of <th> element
steps[].elements[].type
String

Type of the element. Available element types:

  • INPUT_SELECT
  • INPUT_RADIO
  • INPUT_TEXT
  • INPUT_TEXTAREA
  • INPUT_DATE
  • INPUT_NUMBER
  • INPUT_BOOLEAN
  • INPUT_PASSWORD
  • HTML
  • LINK
steps[].elements[].property
StringProperty corresponding to PropertyValueApi provided by DataProviderApi implementation. Collected input values from elements are stored to these properties. 
steps[].elements[].value
StringDefault value 
steps[].elements[].values
Array

Contains values that are displayed in the select and radio fields. Supported in element types:

  • INPUT_SELECT
  • INPUT_RADIO
Code Block
.. "values" : [ "a", "b" ], ..
steps[].elements[].required
Boolean(Optional) Determines whether the field is required or not. If true, the user required to enter the values in this field. Empty means false. 

 

Metadata JSON example

Code Block
languagegroovy
{ 
	"name" : "Custom connector", 
	"description" : "This is custom data connector", 
	"wizard" : true, 
	"steps" : [
		{
			"index":1,
			"name":"First step",
			"description":"Some description",
			"elements":[
				{"id":"el_1","label":"Text element","value":null,"type":"INPUT_TEXT", "required":"true"},
				{"id":"el_2","label":"Select element","values":["first value;second value"],"value": "first value","type":"INPUT_SELECT"},
				{"id":"el_3","label":"Link element","value":"http://www.belladati.com","type":"LINK"},
				{"id":"el_4","label":"HTML element","value":"<h2>This is html element</h2>","type":"HTML"}
			]
		},
		{
			"index":2,
			"name":"Second step",
			"description":"Some second step description",
			"elements":[
				{"id":"el_5","label":"Text element","value":null,"type":"INPUT_TEXT"},
				{"id":"el_6","value":"<h1>This is another html element</h1>","property":"HTML element","type":"HTML"},
				{"id":"el_7","label":"Date element","value":null,"type":"INPUT_DATE"},
				{"id":"el_8","label":"Number element","value":null,"type":"INPUT_NUMBER"},
				{"id":"el_9","label":"Boolean element","value":null,"type":"INPUT_BOOLEAN"}]
		}
	] 
}

Advanced implementation

Implementing AJAX callbacks

If you need external window (e.g. for authentication), you can use callback function provided by BellaDati:

  • put javascript code as HTML element (type = HTML) in appropriate step

    Code Block
    languagejs
    <script type="text/javascript">
        window.callback_SOMENAME = function(params) {
            //do something
        }
    </script>
  • use following callback URL: 

    Code Block
    http://your_host:port/auth/callback/SOMENAME

 

Sv translation
languageja


Info

Connector SDK 1.0以降およびBellaDati 2.9.7以降の、高度なコネクター動作をメタデータとして提供できます。


メタデータを使用すると、次のことを定義できます:

  • コネクターの名前と説明
  • コネクターのロゴ
  • ウィザードモード
    • 名前と説明を備えたsteps
    • さまざまなタイプの要素: 入力フィールド、HTMLコード、リンク

メタデータの使用

メタデータはorg.json.JSONObjectインスタンスとして定義され、カスタムコネクターのDataProviderApi実装クラスで定義された、静的getMetadata()メソッドによって返されます。

Code Block
languagejava
public class MyDataProvider extends DataProviderApi<RowsApi<? extends RowApi>> {
 
...
 
	public static org.json.JSONObject getMetadata() {
		...
	}
 
...
}

メタデータプロパティ

フィールドタイプ説明
name
String

データソースページに表示されるコネクターの名前。getName()メソッドによって返される値をオーバーライドします。

description
String

データソースページに表示されるコネクターの説明。

logo
String

64x64pxのロゴ画像ファイルへのパス。カスタムコネクターのメインクラスと同じパッケージ内に配置する必要があります。

wizard
Boolean

コネクター設定をウィザードモードで表示するかどうかを決定します。trueの場合、steps要素のコンテンツを使用して特定のstepコンテンツを定義します。それ以外の場合はパラメーター付きのウィンドウ。

プロパティモード:

ウィザードモード:




keysString

キーは、名前、説明、値の変換をサポートします。への参照は、message:prefixを使用して定義されます。例: message:key1

Code Block
{
    "name" : "Custom connector",
    "description" : "This is custom data connector",
    "wizard" : true,
    "keys" : {
        "default" : { "key1" : "label 1", "key2 : "label 2" },
        "cs" : { "key1" : "cs label 1", "key2 : "cs label 2" },
		"de" : { "key1" : "de label 1", "key2 : "de label 2" }
    }
}

値が見つからない場合は、デフォルトが使用されます。デフォルトが指定されていない場合、プレフィックス付きの値が表示されます。

steps
Array of Objects

コネクター設定ウィザードを構成するstepが含まれています。

steps[].index
Integerstepのインデックス。
steps[].name
Stringstepの名前。
steps[].description
String

stepの説明。

steps[].elements[]
Array of Objects

2列のテーブル内に次々に表示される要素が含まれます。


steps[].elements[].id
String

要素IDは、data-id属性に保存されます。

すべての要素の値は、stepの説明の下にある非表示の<span>要素に格納されます:

Code Block
languagexml
<div style="display:none">
	<span data-value="false" data-id="el_9"></span>
	<span data-value="tests" data-id="el_5"></span>
	<span data-value="second value" data-id="el_2"></span>
	<span data-value="test" data-id="el_1"></span>
</div> 


steps[].elements[].label
String

要素のラベル。 <th>要素の内容

steps[].elements[].type
String

要素のタイプ。使用可能な要素タイプ:

  • INPUT_SELECT
  • INPUT_RADIO
  • INPUT_TEXT
  • INPUT_TEXTAREA
  • INPUT_DATE
  • INPUT_NUMBER
  • INPUT_BOOLEAN
  • INPUT_PASSWORD
  • HTML
  • LINK
steps[].elements[].property
String

DataProviderApi実装によって提供される、PropertyValueApiに対応するプロパティ。要素から収集された入力値は、これらのプロパティに保存されます。


steps[].elements[].value
Stringデフォルト値
steps[].elements[].values
Array

選択フィールドとラジオフィールドに表示される値が含まれます。要素タイプでサポートされるのは:

  • INPUT_SELECT
  • INPUT_RADIO


Code Block
.. "values" : [ "a", "b" ], ..


steps[].elements[].required
Boolean

(オプション) フィールドが必須かどうかを決定します。 trueの場合、ユーザーはこのフィールドに値を入力する必要があります。空は偽を意味します。



メタデータJSONの例

Code Block
languagegroovy
{ 
	"name" : "Custom connector", 
	"description" : "This is custom data connector", 
	"wizard" : true, 
	"steps" : [
		{
			"index":1,
			"name":"First step",
			"description":"Some description",
			"elements":[
				{"id":"el_1","label":"Text element","value":null,"type":"INPUT_TEXT", "required":"true"},
				{"id":"el_2","label":"Select element","values":["first value;second value"],"value": "first value","type":"INPUT_SELECT"},
				{"id":"el_3","label":"Link element","value":"http://www.belladati.com","type":"LINK"},
				{"id":"el_4","label":"HTML element","value":"<h2>This is html element</h2>","type":"HTML"}
			]
		},
		{
			"index":2,
			"name":"Second step",
			"description":"Some second step description",
			"elements":[
				{"id":"el_5","label":"Text element","value":null,"type":"INPUT_TEXT"},
				{"id":"el_6","value":"<h1>This is another html element</h1>","property":"HTML element","type":"HTML"},
				{"id":"el_7","label":"Date element","value":null,"type":"INPUT_DATE"},
				{"id":"el_8","label":"Number element","value":null,"type":"INPUT_NUMBER"},
				{"id":"el_9","label":"Boolean element","value":null,"type":"INPUT_BOOLEAN"}]
		}
	] 
}

高度な実装

AJAXコールバックの実装

外部ウィンドウ(認証など)が必要な場合は、BellaDatiが提供するコールバック関数を使用できます:

  • javascriptコードをHTML要素(type = HTML)として適切な手順で配置します

    Code Block
    languagejs
    <script type="text/javascript">
        window.callback_SOMENAME = function(params) {
            //do something
        }
    </script>


  • 次のコールバックURLを使用します: 

    Code Block
    http://your_host:port/auth/callback/SOMENAME