Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Sv translation
languageen

This tutorial explains how to use Import templates when using the BellaDati Rest Action in the sender. It covers the following topics:

  1. Preparation of the source file
  2. Preparation of the import template
  3. Usage of the import template

Preparation of the source file

To be able to prepare the import template, it is necessary to prepare a sample CSV file with the same structure the data which are being sent from the sender to BellaDati.

In this example, the data sent from the sensor have the following structure:

Code Block
languagetext
sensor01,2018/9/28 20:17,26.55,42

The data are sent via MQTT Publisher to the MQTT Broker running on the receiver. When processed in the BellaDati IoT Data Collector, the values will be transformed into JSON and additional information is added to the message. The same structure has to be used in the sample CSV file:

Code Block
languagetext
"L_ID","L_RECEIVER","L_JSON","L_TIMESTAMP"
"99","Receiver12","{""sensorId"":""sensor01"",""values"":[""sensor01"",""2018/9/28 18:17"",""26.55"",""42""],""mqttTopic"":""belladati"",""mqttMessageId"":-1}","1536317563496"

The file has the following structure:

 

  • L_ID - ID of the record, which is added automatically by the IoT Data Collector
  • L_RECEIVER - ID of the Receiver
  • L_JSON - JSON containing the actual values (JSONArray values)
  • L_TIMESTAMP - timestamp of the record.

 

You can download the CSV file from here.

Preparation of the import template

This file has to imported to the destination data set. On the import settings page, it is necessary to map the values to correct columns:

  • L_ID - create attribute ID
  • L_RECEIVER - create attribute Receiver
  • L_JSON - create Long text column JSON
  • L_TIMESTAMP - create attribute Timestamp

Next, it is possible to add additional columns which will contain the parsed values from the JSON.

  1. Add a new column and choose the correct type and name (e.g. Attribute and sensorID)
  2. Apply following transformation script, to parse the JSON and read the sensorId value:

    Code Block
    languagejava
    JSONElement e = parseJSON(value(3))
    return e.getString('sensorId')
  3. Repeat previous steps for additional columns. Below, you can find examples of the transformation scripts:

To get the date, use this formula:

Code Block
languagejava
JSONElement e = parseJSON(value(3))
JSONArray a = e.getJSONArray('values') as JSONArray
a.getString(1)

To get the MQTT topic, use this formula.

Code Block
languagejava
JSONElement e = parseJSON(value(3))
return e.getString('mqttTopic')

To learn how to work with JSON, please read the following article: http://support.belladati.com/doc/Importing+from+File

Once the import settings are finished, click on Continue and import the data.

After the import, make sure that the ETL names of attributes are correctly set. If they are not correct, change them to match the code of the attribute.

You can download the XML backup of the final data set from here. Please note that you need to import the data to create the import template.

Usage of the import template

  1. Make sure you have the developer mode enabled. If not, enable it in the user profile (see http://support.belladati.com/doc/Managing+User+Profile - Chapter Appearance settings)
  2. Go to Data set summary and open the Import history.

  3. Copy the ID of the import, which will serve as the Import template.
  4. Open the IoT Console and configure the BellaDati REST action.
    1. Data Set ID - ID of the Data Set. The ID can be found in the URL

    2. Import Template ID - ID of the Import template

    3. ID attribute - Code of the attribute ID (e.g. L_ID)

    4. Receiver Attribute - Code of the attribute Receiver (e.g. L_RECEIVER)

    5. Content Attribute - Code of the attribute JSON (e.g. L_JSON)

    6. Timestamp Attribute - Code of the attribute Timestamp (e.g. L_TIMESTAMP)

  5. Save the action and Apply the changes.
  6. Data sent via from the sensor will now be correctly stored in the BellaDati Data set.

 

Sv translation
languageja

このチュートリアルでは、SenderでBellaDati Restアクションを使用するときにインポートテンプレートを使用する方法について説明します。次のトピックについて説明します:

  1. ソースファイルの準備
  2. インポートテンプレートの準備
  3. インポートテンプレートの使用

ソースファイルの準備

インポートテンプレートを準備するには、SenderからBellaDatiに送信されるデータと同じ構造のサンプルCSVファイルを準備する必要があります。

この例では、センサーから送信されるデータの構造は次の通りです

This tutorial explains how to use Import templates when using the BellaDati Rest Action in the sender. It covers the following topics:

  1. Preparation of the source file
  2. Preparation of the import template
  3. Usage of the import template

Preparation of the source file

To be able to prepare the import template, it is necessary to prepare a sample CSV file with the same structure the data which are being sent from the sender to BellaDati.

In this example, the data sent from the sensor have the following structure

:

Code Block
languagetext
sensor01,2018/9/28 20:17,26.55,42

The data are sent via MQTT Publisher to the MQTT Broker running on the receiver. When processed in the BellaDati IoT Data Collector, the values will be transformed into JSON and additional information is added to the message. The same structure has to be used in the sample CSV fileデータは、MQTTパブリッシャーを介して、Receiverで実行されているMQTTブローカーに送信されます。 BellaDati IoTデータコレクターで処理されると、値はJSONに変換され、追加情報がメッセージに追加されます。同じ構造をサンプルCSVファイルで使用する必要があります:

Code Block
languagetext
"L_ID","L_RECEIVER","L_JSON","L_TIMESTAMP"
"99","Receiver12","{""sensorId"":""sensor01"",""values"":[""sensor01"",""2018/9/28 18:17"",""26.55"",""42""],""mqttTopic"":""belladati"",""mqttMessageId"":-1}","1536317563496"

The file has the following structureファイル構造は次の通りです:


  • L_ID - ID of the record, which is added automatically by the IoT Data CollectorIoTデータコレクターによって自動的に追加されるレコードID
  • L_RECEIVER - Receiver ID of the Receiver
  • L_JSON - JSON containing the actual values (JSONArray values実際の値を含むJSON (JSONArray値)
  • L_TIMESTAMP - timestamp of the record.

You can download the CSV file from here.

Preparation of the import template

  • レコードのタイムスタンプ


ここからCSVファイルをダウンロードできます。

インポートテンプレートの準備

このファイルは、宛先データセットにインポートする必要があります。インポート設定ページで、値を正しい列にマップする必要がありますThis file has to imported to the destination data set. On the import settings page, it is necessary to map the values to correct columns:

  • L_ID - create attribute ID属性IDの作成
  • L_RECEIVER - create attribute Receiver属性Receiverの作成
  • L_JSON - create Long text column JSON長いテキスト列のJSONの作成する
  • L_TIMESTAMP - create attribute Timestamp

Next, it is possible to add additional columns which will contain the parsed values from the JSON.

  • 属性タイムスタンプの作成

次に、JSONからの解析された値を含む追加列を追加することが可能です。

  1. 新しい列を追加し、正しいタイプと名前を選択します(例: 属性とsensorID)
    Image Added
  2. 次の変換スクリプトを適用して、JSONを解析しsensorId値を読み取ります

  3. Add a new column and choose the correct type and name (e.g. Attribute and sensorID)
    Image Removed
  4. Apply following transformation script, to parse the JSON and read the sensorId value:

    Code Block
    languagejava
    JSONElement e = parseJSON(value(3))
    return e.getString('sensorId')
  5. Repeat previous steps for additional columns. Below, you can find examples of the transformation scripts:

  6. 追加列について前の手順を繰り返します。以下に、変換スクリプトの例を示します:

日付を取得するには、次の式を使用しますTo get the date, use this formula:

Code Block
languagejava
JSONElement e = parseJSON(value(3))
JSONArray a = e.getJSONArray('values') as JSONArray
a.getString(1)

To get the MQTT topic, use this formula.トピックを取得するには、次の式を使用します。

Code Block
languagejava
JSONElement e = parseJSON(value(3))
return e.getString('mqttTopic')
To learn how to work with JSON, please read the following article: 

JSONの操作方法については、次の文章をご覧ください: http://support.belladati.com/doc/Importing+from+File

Once the import settings are finished, click on Continue and import the data.

After the import, make sure that the ETL names of attributes are correctly set. If they are not correct, change them to match the code of the attribute.

Image Removed

You can download the XML backup of the final data set from here. Please note that you need to import the data to create the import template.

Usage of the import template

インポート設定が完了したら、[続行]をクリックしてデータをインポートします。

インポート後、属性のETL名が正しく設定されていることを確認してください。正しくない場合は、属性のコードと一致するように変更してください。

Image Added

ここから、最終的なデータセットのXMLバックアップをダウンロードできます。インポートテンプレートを作成するには、データをインポートする必要があることに注意してください。

インポートテンプレートの使用

  1. 開発者モードが有効になっていることを確認してください。有効になっていない場合は、ユーザープロファイルで有効にします (Make sure you have the developer mode enabled. If not, enable it in the user profile (see http://support.belladati.com/doc/Managing+User+Profile  -Chapter Appearance settings を参照)
  2. データセットの概要に移動し、インポート履歴を開きます。Go to Data set summary and open the Import history.

  3. Copy the ID of the import, which will serve as the Import template.
  4. インポートテンプレートとして機能するインポートIDをコピーします。
  5. IoTコンソールを開き、BellaDati RESTアクションを構成します。Open the IoT Console and configure the BellaDati REST action.
    1. Data Set ID - ID of the Data Set. The ID can be found in the URLデータセットID。 IDはURL内にあります。

    2. Import Template ID - ID of the Import templateインポートテンプレートID

    3. ID attribute - Code of the attribute ID (e.g. 属性IDのコード (例: L_ID)

    4. Receiver Attribute - Code of the attribute Receiver (e.g. 属性Receiverのコード (例: L_RECEIVER)

    5. Content Attribute - Code of the attribute JSON (e.g. 属性JSONのコード (例: L_JSON)

    6. Timestamp Attribute - Code of the attribute Timestamp (e.g. 属性タイムスタンプのコード (例: L_TIMESTAMP)

  6. Save the action and Apply the changes.
  7. アクションを保存し、変更を適用します。
  8. センサーから送信されたデータは、BellaDatiデータセットに適切に格納されます。Data sent via from the sensor will now be correctly stored in the BellaDati Data set.