Inject sensor data from an arbitrary database source into an i52n-sos using queries
1.8K
This project uses the sos-injector Java library to read station information and observation values from an arbitrary database and inject them into an i52n-sos server.
All deployment specific information (SOS URL, provider information, source database connection url, queries to retrieve data from source database) is external to the compiled jar, so users should be able to download a release jar, edit the configuration and query files, and run the application without having to edit or compile Java.
Download and unzip the sos-injector-db distribution (or clone the source code and use Maven to compile, mvn clean install)
Write configuration and SQL query files (see Configuration/SQL files section below)
Make sure your target SOS is running, that it has transactional support, and that the computer you are running the sos-injector-db application from has transactional operation authorization
Run the application
Specify your config file as the only argument:
java -jar sos-injector-db.jar myconfig.properties
Or name your config file config.properties and run the jar in the same directory with no arguments:
java -jar sos-injector-db.jar
To do a trial run (test your queries against your database without injecting data into an SOS), set the "mock" VM argument:
java -Dmock -jar sos-injector-db.jar myconfig.properties
To override the query directory specified in the configuration file (useful for temporary alterations), set the "query_path" VM argument:
java -Dquery_path=some/path/to/your/queries -jar sos-injector-db.jar \
myconfig.properties
To override observation query start or end dates, set "start_date" and/or "end_date" VM arguments with ISO8601 timestamp strings (start_date defaults to latest station/sensor/phenomenon time in SOS, end_date defaults to current time):
java -Dstart_date=2014-04-23T05:00:00Z -Dend_date=2014-04-23T08:00:00Z \
-jar sos-injector-db.jar myconfig.properties
To run the injector, you need to set up a configuration file and set of query files.
To view examples of these files, see the GCOOS test files.
The query files fall into four categories (italic fields = optionally null, data type text unless otherwise noted):
NOTE: The query parameters can either be normal JDBC parameters (using ?) in the order that they are specified, or named parameters (using :the_parameter). Named parameters can be reused multiple times in the query.
Queries all stations and associated metadata (provider, URLs, etc).
No parameters.
Expected result columns:
Queries all sensors for a station.
Parameters:
Expected result columns:
Queries all phenomena for a sensor.
Parameters:
Expected result columns:
Queries observations for a sensor phenomenon.
For get_observations queries, there are two options:
If your observations for all phenomena can be queried using a single query (usually if all your observations are in a single table), you can use a single query.
Parameters:
Alternatively, if you need to write a separate query for each phenomenon (usually if you store observations for each phenomenon in a separate table), you can create a query for each phenomenon using the filename format get_observations_{cf_standard_name}.sql (e.g. get_observations_air_temperature.sql).
Parameters:
Expected result columns:
The application will first look for a phenomenon specific get_observations_{cf_standard_name}.sql file, and then fall back to the generic get_observations.sql.
The project currently includes drivers for PostgreSQL, MySQL, and SQLite. If you need another database driver, you can:
Content type
Image
Digest
Size
394.3 MB
Last updated
almost 10 years ago
docker pull ioos/sos-injector-db