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

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.