Database Plugin - Macros - Refresh DbUnit¶
Contents :
# REFRESH_DBUNIT {dataset} INTO {database}¶
What ?
This macro will refresh all the data listed in the ‘dataset file’ into the ‘database’. Refresh operation means that data of existing rows are updated and non-existing row get inserted. Any rows which exist in the database but not in dataset stay unaffected.
Underlying instructions :
LOAD {dataset} AS __temp{%%rand1}.file
CONVERT __temp{%%rand1}.file TO file(param.relativedate) AS __temp_{%%rand2}.file
CONVERT __temp_{%%rand2}.file TO xml(structured) AS __temp_{%%rand3}.xml
CONVERT __temp_{%%rand3}.xml TO dataset.dbunit(dataset) AS __temp_{%%rand4}.dbu
EXECUTE insert WITH __temp_{%%rand4}.dbu ON {database} USING $(operation:refresh) AS __temp_{%%rand5}.result
> Input :
{dataset}
: A flat xml dbunit dataset file.{database}
: The name (in the context) of the database to use (database
type target).
Remark : The file designed by {dataset}
must respect the same rules than a file which would serve to create an SKF dataset.dbunit
type resource via the converter (From xml to dataset.dbunit).
Example :
# REFRESH_DBUNIT path/to/dataset.xml INTO my_database Database overview :
In the dataset, we update employees’ information and add a new one :
SKF script :
The employees are updated and the new one is inserted in the database :
# REFRESH_DBUNIT {dataset} INTO {database} WITH CONFIG {config}¶
What ?
This macro will refresh all the data listed in the ‘dataset file’ into the ‘database’ using a DbUnit configuration file. Refresh operation means that data of existing rows are updated and non-existing row get inserted. Any rows which exist in the database but not in dataset stay unaffected.
Underlying instructions :
LOAD {config} AS __temp{config}{%%rand1}.file
CONVERT __temp{config}{%%rand1}.file TO conf.dbunit AS __temp{config}{%%rand2}.conf
LOAD {dataset} AS __temp{%%rand3}.file
CONVERT __temp{%%rand3}.file TO file(param.relativedate) AS __temp_{%%rand4}.file
CONVERT __temp_{%%rand4}.file TO xml(structured) AS __temp_{%%rand5}.xml
CONVERT __temp_{%%rand5}.xml TO dataset.dbunit(dataset) AS __temp_{%%rand6}.dbu
EXECUTE insert WITH __temp_{%%rand6}.dbu ON {database} USING $(operation:refresh),__temp{config}{%%rand2}.conf AS __temp_{%%rand7}.result
> Input :
{dataset}
: A flat xml dbunit dataset file.{database}
: The name (in the context) of the database to use (database
type target).{config}
: A configuration file for DbUnit (‘.properties’).
Remarks :
- The file designed by
{dataset}
must respect the same rules than a file which would serve to create an SKFdataset.dbunit
type resource via the converter (From xml to dataset.dbunit).- The file designed by
{config}
must respect the same rules than a file which would serve to create an SKFconf.dbunit
type resource via the converter (From file to conf.dbunit).
Example :
# REFRESH_DBUNIT path/to/dataset.xml INTO my_database WITH CONFIG path/to/my_config_dbunit.properties |
# REFRESH_DBUNIT {dataset} INTO {database} USING {ppkfilter}¶
What ?
This macro will refresh all datas listed in the ‘dataset file’ into the ‘database’ using a DbUnit filter. Refresh operation means that data of existing rows are updated and non-existing row get inserted. Any rows which exist in the database but not in dataset stay unaffected.
Underlying instructions :
LOAD {dataset} AS __temp{%%rand1}.file
CONVERT __temp{%%rand1}.file TO file(param.relativedate) AS __temp{%%rand2}.file
CONVERT __temp{%%rand2}.file TO xml(structured) AS __temp{%%rand3}.xml
CONVERT __temp{%%rand3}.xml TO dataset.dbunit(dataset) AS __temp{%%rand4}.dbu
LOAD {ppkfilter} AS __temp{%%rand5}.file
CONVERT __temp{%%rand5}.file TO properties(structured) AS __temp{%%rand6}.props
CONVERT __temp{%%rand6}.props TO conf.dbunit.ppk(from.properties) AS __temp{%%rand7}.ppk
EXECUTE insert WITH __temp{%%rand4}.dbu ON {database} USING __temp{%%rand7}.ppk,$(operation:refresh) AS __temp_{%%rand8}.result
> Input :
{dataset}
: A flat xml dbunit dataset file.{database}
: The name (in the context) of the database to use (database
type target).{ppkfilter}
: A DbUnit filter referring to pseudo primary keys (‘.properties’).
Example :
# REFRESH_DBUNIT path/to/dataset.xml INTO my_database USING path/to/my_filter_dbunit.properties |
# REFRESH_DBUNIT {dataset} INTO {database} WITH CONFIG {config} USING {ppkfilter}¶
What ?
This macro will refresh all the data listed in the ‘dataset file’ into the ‘database’ using a DbUnit configuration file and a DbUnit filter. Refresh operation means that data of existing rows are updated and non-existing row get inserted. Any rows which exist in the database but not in dataset stay unaffected.
Underlying instructions :
LOAD {config} AS __temp{config}{%%rand1}.file
CONVERT __temp{config}{%%rand1}.file TO conf.dbunit AS __temp{config}{%%rand2}.conf
LOAD {dataset} AS __temp{%%rand3}.file
CONVERT __temp{%%rand3}.file TO file(param.relativedate) AS __temp_{%%rand4}.file
CONVERT __temp_{%%rand4}.file TO xml(structured) AS __temp_{%%rand5}.xml
CONVERT __temp_{%%rand5}.xml TO dataset.dbunit(dataset) AS __temp_{%%rand6}.dbu
LOAD {ppkfilter} AS __temp{%%rand7}.file
CONVERT __temp{%%rand7}.file TO properties(structured) AS __temp{%%rand8}.props
CONVERT __temp{%%rand8}.props TO conf.dbunit.ppk(from.properties) AS __temp{%%rand9}.ppk
EXECUTE insert WITH __temp_{%%rand6}.dbu ON {database} USING __temp{%%rand9}.ppk,$(operation:refresh),__temp{config}{%%rand2}.conf AS __temp_{%%rand10}.result
> Input :
{dataset}
: A flat xml dbunit dataset file.{database}
: The name (in the context) of the database to use (database
type target).{config}
: A configuration file for DbUnit (‘.properties’).{ppkfilter}
: A DbUnit filter referring to pseudo primary keys (‘.properties’).
Example :
# REFRESH_DBUNIT path/to/dataset.xml INTO my_database WITH CONFIG path/to/my_config_dbunit.properties USING path/to/my_filter_dbunit.properties |