Repository navigation
Functions Importer AutomateImports
Imports can be automated useing SmartDataJobs. SmartDataJobs can configure recurring jobs and do them in defined intervals. Calling SmartDataPorter is done by a WriteDataAction that calls the SmartDataPorter import API giving the import configuration.
This example defines an import of a simple json file into a simple table recurring every 10 seconds.
Setup the tables for SmartDataJobs. (datajobs, datajobs_params, datajobs_log, etc.)
Examples can be found in: C:\SmartDeveloper\projects\SmartDataPorter\test\database\Automate Imports\
Configuration dataset in SmartDataJobs:
INSERT INTO smartdataporter_datajobs ("name","desc","action",active,"start",stop,repeatsecs) VALUES('importExampleData','Exports example data from file','WriteData',true,'2025-12-01 13:01:24.351',NULL,10);The job for import uses a WriteAction and is executed every 10 seconds.
Datajob params:
INSERT INTO smartdataporter_datajobs_params ("key",value,datajob_id,"type") VALUES
('url','http://localhost:8080/SmartDataPorter/smartdataporter/import',1,'url'),
('requestmethod','POST',1,'string'),
('urlparams','{
"storage": "smartmonitoring",
"collection": "smartdataporter_importtarget"
}',1,'string'),
('body','{
"server": "http://localhost:8080",
"smartdata": "SmartDataTest",
"storage": "smartmonitoring",
"collection": "smartdataporter_datajobs_testtarget",
"importer": "FilesImporter",
"parser": "JSONParser",
"sourcedir": "/SmartDeveloper/projects/SmartDataPorter/test/data/Automate Imports/",
"json_mapping": [
{
"collection": "smartdataporter_datajobs_testtarget",
"mappingdata": [
{
"dbcolumn": "str_value",
"path": "/str_value"
},
{
"dbcolumn": "int_value",
"path": "/int_value"
}
]
}
]
}
',1,'string');The "body" contians all neccessery configuration for SmartDataPorter. Here a JSON mapping is used because our example file is in JSON format. The file to import is used from the SmartDeveloper project test directory.
The import job is started like every other DataJob.
Send a GET Request to:
http://localhost:8080/SmartDataJobs/smartdatajobs/jobexecution/start?smartdataurl=/SmartDataTest&storage=smartmonitoring&collection=smartdataporter_datajobs&id=1