Skip to content

Examples of how to connect external data sources to Sirius Web

License

Notifications You must be signed in to change notification settings

ObeoNetwork/SiriusWebConnectors

Repository files navigation

Sirius Web Connectors

Eclipse Sirius Web is a framework to easily create and deploy studios to the web.

This repository, SiriusWebConnectors, contains connectors allowing to bind Sirius Web to external data sources:

MySQL Connector

The MySQL connector for Sirius Web is compatible with MySQL 8.x. It relies on the Java SQL standard library.

Start Sirius Web with the MySQL connector

In the chapter below, we assume you already have followed the Sirius Web page showing how to build and start a Sirius Web server, and how to generate a Github Access Token.

If you want to add the MySQL connector to your Sirius Web application, please follow these steps:

Modify your Sirius Web spring boot application

In the Maven pom.xml file of your application, please add the SiriusWebConnectors repository and the MySQL connector dependency:

...
<repositories>
    ...
    <repository>
        <id>github-sirius-web-connectors</id>
        <url>https://maven.pkg.github.com/ObeoNetwork/SiriusWebConnectors</url>
    </repository>
    ...
</repositories>
...
<dependencies>
    ...
    <dependency>
        <groupId>org.obeonetwork</groupId>
        <artifactId>sirius-web-db-connector-mysql</artifactId>
        <version>0.9.2</version>
    </dependency>
    ...
<dependencies>
...

Please check the last version of the dependency here.

Modify your Maven settings file

Edit your $HOME/.m2/settings.xml to tell Maven to use your Github token when accessing the SiriusWebConnectors repository:

...
<servers>
    ...
    <server>
      <id>github-sirius-web-connectors</id>
      <username>$GITHUB_USERNAME</username>
      <password>$GITHUB_ACCESS_TOKEN</password>
    </server>
    ...
</servers>
...

Add the MySQL services class to your Sirius Web spring boot application

Your application should already contains a IJavaServicesProvider implementation.

You just have to add MySQLServices as a service class of your IJavaServiceProvider:

import org.eclipse.sirius.components.emf.view.IJavaServiceProvider;
import org.eclipse.sirius.ext.emf.edit.EditingDomainServices;
import org.obeonetwork.siriusweb.db.connector.mysql.MySQLServices;
import org.springframework.stereotype.Service;
...
@Service
public class YourServicesProvider implements IJavaServiceProvider {
    @Override
    public List<Class<?>> getServiceClasses(View view) {
        return List.of(EditingDomainServices.class, MySQLServices.class);
    }
}

Start your Sirius Web spring boot application with MySQL connector properties

When you start your Sirius Web application, the following variables must have been added to your environment variables:

    DB_CONNECTOR_MYSQL_URL=YOUR_MYSQL_DB_IP_ADDRESS
    DB_CONNECTOR_MYSQL_USER=YOUR_MYSQL_USER_NAME
    DB_CONNECTOR_MYSQL_PASSWORD=YOUR_MYSQL_PASSWORD

For example:

    DB_CONNECTOR_MYSQL_URL=localhost
    DB_CONNECTOR_MYSQL_USER=root
    DB_CONNECTOR_MYSQL_PASSWORD=mySuperPassword

Use MySQL Java services with AQL

The MySQL Java services class only supports a subset of the MySQL language. For each service it also only supports some of the options of the MySQL equivalent statement/optimization/clause.

AQL service MySQL equivalent Note

from('table_references')

FROM table_references

fullJoin('join_clause')

FULL JOIN join_clause

groupBy('groupBy_expression')

GROUP BY groupBy_expression

innerJoin('join_clause')

INNER JOIN join_clause

join('join_clause')

JOIN join_clause

leftJoin('join_clause')

LEFT JOIN join_clause

on('on_expression')

ON on_expression

Works only with after the call of join.

rightJoin('join_clause')

RIGHT JOIN join_clause

sqlSelect('select_expression')

SELECT select_expression

select service already exists in AQL so we chose sqlSelect instead.

where('where_condition')

WHERE where_condition

mySQL('dB_name')

N/A

Service used to initialize a query. Must be call on an object and with the name of the database on which the query will be executed.

fetch()

N/A

Service used to execute the query. Returns a list of Objects, depending on the query itself.

Example

aql:self.mySQL('myDB').sqlSelect('*').from('myTable').where('field > 3').fetch()

InfluxDB Connector

The InfluxDB connector for Sirius Web is compatible with InfluxDB 2.x. It relies on the influxdb-client-java library.

Start Sirius Web with the InfluxDB connector

In the chapter below, we assume you already have followed the Sirius Web page showing how to build and start a Sirius Web server, and how to generate a Github Access Token.

If you want to add the InfluxDB connector to your Sirius Web application, please follow these steps:

Modify your Sirius Web spring boot application

In the Maven pom.xml file of your application, please add the SiriusWebConnectors repository and the InfluxDB connector dependency:

...
<repositories>
    ...
    <repository>
        <id>github-sirius-web-connectors</id>
        <url>https://maven.pkg.github.com/ObeoNetwork/SiriusWebConnectors</url>
    </repository>
    ...
</repositories>
...
<dependencies>
    ...
    <dependency>
        <groupId>org.obeonetwork</groupId>
        <artifactId>sirius-web-db-connector-influxdb</artifactId>
        <version>0.9.1</version>
    </dependency>
    ...
<dependencies>
...

Please check the last version of the dependency here.

Modify your Maven settings file

Edit your $HOME/.m2/settings.xml to tell Maven to use your Github token when accessing the SiriusWebConnectors repository:

...
<servers>
    ...
    <server>
      <id>github-sirius-web-connectors</id>
      <username>$GITHUB_USERNAME</username>
      <password>$GITHUB_ACCESS_TOKEN</password>
    </server>
    ...
</servers>
...

Add the InfluxDB services class to your Sirius Web spring boot application

Your application should already contains a IJavaServicesProvider implementation.

You just have to add InfluxDBServices as a service class of your IJavaServiceProvider:

import org.eclipse.sirius.components.emf.view.IJavaServiceProvider;
import org.eclipse.sirius.ext.emf.edit.EditingDomainServices;
import org.obeonetwork.siriusweb.db.connector.influxdb.InfluxDBServices;
import org.springframework.stereotype.Service;
...
@Service
public class YourServicesProvider implements IJavaServiceProvider {
    @Override
    public List<Class<?>> getServiceClasses(View view) {
        return List.of(EditingDomainServices.class, InfluxDBServices.class);
    }
}

Start your Sirius Web spring boot application with InfluxDB connector properties

When you start your Sirius Web application, the following variables must have been added to your environment variables:

    DB_CONNECTOR_INFLUXDB_URL=YOUR_INFLUX_DB_SERVER_ADDRESS
    DB_CONNECTOR_INFLUXDB_ORG=YOUR_INFLUX_DB_ORGANISATION
    DB_CONNECTOR_INFLUXDB_TOKEN=YOUR_INFLUX_DB_TOKEN

For example:

    DB_CONNECTOR_INFLUXDB_URL=http://localhost:8086
    DB_CONNECTOR_INFLUXDB_ORG=obeo
    DB_CONNECTOR_INFLUXDB_TOKEN=F0BQRD-McfOqWIJFqGxJ3QwEGCJpnlxwIRPlhX-c2sJQHqjOaQqgImslF1ug_nw4gDqlqBwBIVj9ZgKL28NpPc==

Use InfluxDB Java services with AQL

AQL service InfluxDB equivalent Note

aggregateWindow('parameters')

aggregateWindow(parameters)

cumulativeSum()

cumulativeSum()

derivative('parameters')

derivative(parameters)

keep('parameters')

keep(parameters)

fill('parameters')

fill(parameters)

fluxFilter('parameters')

filter(parameters)

filter service already exists in AQL so we chose fluxFilter instead.

fluxFirst()

first()

first service already exists in AQL so we chose fluxFirst instead.

fluxLast()

last()

last service already exists in AQL so we chose fluxLast instead.

group('parameters')

group(parameters)

group()

group()

Merge all tables into a single table

histogram('parameters')

histogram(parameters)

increase()

increase()

limit('parameters')

limit(parameters)

map('parameters')

map(parameters)

median()

median()

movingAverage('parameters')

movingAverage(parameters)

pivot('parameters')

pivot(parameters)

quantile('parameters')

quantile(parameters)

range('parameters')

range(parameters)

sort('parameters')

sort(parameters)

timedMovingAverage('parameters')

timedMovingAverage(parameters)

bucket('bucket_name')

N/A

Service used to initialize a query. Must be call on an object and with the name of the bucket on which the query will be executed.

yield('field')

yield

Service used to execute the query. Returns a list of Objects, depending on the query itself.

Example

aql:self.bucket('myBucket').range('start: 2022-07-08T07:26:06Z, stop: 2022-07-08T09:26:16Z').fluxFilter('fn: (r) => r._measurement == "airSensors"').fluxFilter('fn: (r) => r._field == "co"').median().yield('_value')

About

Examples of how to connect external data sources to Sirius Web

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Languages