Search

Home

Home

INPUT DATA

INPUT DATA

The INPUT DATA operator loads data from external systems into a GRAVITY project when the project is started as a Web Service or via database notification.

It works with triggers that invoke the application, such as:

  • WebService (REST API) – when the GRAVITY application is triggered as an HTTP service.
  • Database – when execution is initiated from a PostgreSQL database.

When data is sent in JSON format, the INPUT DATA operator:

  • receives the input data,
  • converts it into data bus records (in a row-and-column structure),
  • passes the data on for further processing in the GRAVITY project.

The INPUT DATA operator is therefore the entry point for incoming external data and plays a key role in integrating GRAVITY applications with other systems. It is usually paired with the OUTPUT DATAOUTPUT DATA operator, which sends the processed data back to external systems.

An example GRAVITY project using the INPUT DATA operator:

image

Processing for a WebService Trigger

The trigger receives data in JSON format, processes it, and if the parameters object includes an entry matching the operator’s Parameters name the data from that entry is passed to the operator.

Example

Suppose the WebService was triggered with the following body:

The body contains a parameters section. In a REST API call, the parameters section is used to pass parameters to the project being executed. The Input Data object acts as a special process parameter, available only to the trigger that runs a project with the name set in the operator’s Parameter name field in the operator’s properties.

image

When analyzing the parameters section in the REST API body, the trigger searches the system for a parameter whose name matches the properties of the parameters object. If it finds one, it passes the property’s value to that parameter. For Input Data, this is typically an object that the operator converts into data bus bits.

Processing for a Database (PostgreSQL) trigger

Processing for a Database (PostgreSQL) trigger works in a similar way as for a WebService trigger, except that the pg_notify function should send only the value of the parameters object as the message.

{
    "InputData1": 
    { 
        "index" : "FC985GFR55", 
        "index_name" : "Very important new article" , 
        "code" : "3434343434334343", 
        "unit" : "t"
    }
}

Converting a JSON Object into Data Bus Bits

For the operator to correctly convert a JSON object, it needs a template of the object it will receive during process execution. The data structure of the JSON object serves as this template.

You can provide the JSON template in two ways:

  • as a file (not recommended, because it requires a physical file on disk):
image
  1. set the Template source option to Template file,
  2. use the Choose button to select a file containing a sample JSON template.
icon
You can use the Use file content as entered json button to switch from a file-based template to Entered JSON.
  • as an entered template:
image
  1. in Template source, select Entered JSON,
  2. in the JSON Template field, enter the JSON object template,
  3. click Generate Tree to generate the JSON object tree.

On the JSON – node selection tab, you’ll see the JSON object tree generated from the template.

image

You can select the properties whose values you want included on the data bus.

Once the operator is connected to the next data bus, it will be built from the bits that correspond to the selected properties.

icon
If a JSON object contains child objects and you select properties from both the main object and the child objects, the data bus will create as many records as there are child objects. In this case, the values from the main object will be duplicated in each child record.
icon
In GRAVITY, many operators can group data on the data bus during processing, for example: OUTPUT DATAOUTPUT DATA, OUTPUT SQLOUTPUT SQL, OUTPUT FILEOUTPUT FILE, CONVERT BITS TO FORMATCONVERT BITS TO FORMAT, GROUPINGGROUPING, etc.