Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move database vendor prop to runtime props #185

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ private void executeStatements(Connection connection, String sqlScript, MambaETL
statement.setInt(5, props.getIncremental());
statement.setInt(6, props.getAutomated());
statement.setInt(7, props.getInterval());
statement.setString(8, props.getDatabaseVendor());
} else if (props != null && sql.contains("CREATE EVENT IF NOT EXISTS _mamba_etl_scheduler_event")) {
statement.setInt(1, props.getInterval());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ public class MambaETLProperties {
private final String openmrsDatabase;

private final String etlDatababase;

private final String databaseVendor;

private final int connectionInitialSize = 4;

Expand All @@ -54,6 +56,7 @@ private MambaETLProperties() {
this.incremental = getIntProperty(properties, "mambaetl.analysis.incremental_mode", 1);
this.automated = getIntProperty(properties, "mambaetl.analysis.automated_flattening", 0);
this.interval = getIntProperty(properties, "mambaetl.analysis.etl_interval", 300);
this.databaseVendor = getProperty(properties, "mambaetl.analysis.db_vendor", "mysql");
}

public static synchronized MambaETLProperties getInstance() {
Expand Down Expand Up @@ -98,6 +101,10 @@ public String getMambaETLuser() {
public String getMambaETLuserPassword() {
return mambaETLuserPassword;
}

public String getDatabaseVendor() {
return databaseVendor;
}

public String getOpenmrsDatabase() {
return openmrsDatabase;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ DROP EVENT IF EXISTS _mamba_etl_scheduler_event;
~-~-

-- Setup ETL configurations
CALL sp_mamba_etl_setup(?, ?, ?, ?, ?, ?, ?, ?, ?);
CALL sp_mamba_etl_setup(?, ?, ?, ?, ?, ?, ?, ?);
-- pass them from the runtime properties file

~-~-
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ CREATE PROCEDURE sp_mamba_etl_user_settings(
IN table_partition_number INT,
IN incremental_mode_switch TINYINT(1),
IN automatic_flattening_mode_switch TINYINT(1),
IN etl_interval_seconds INT
IN etl_interval_seconds INT,
IN database_vendor VARCHAR(256) CHARACTER SET UTF8MB4
)
BEGIN

Expand All @@ -23,7 +24,8 @@ BEGIN
table_partition_number,
incremental_mode_switch,
automatic_flattening_mode_switch,
etl_interval_seconds);
etl_interval_seconds,
database_vendor);
END //

DELIMITER ;
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ CREATE TABLE _mamba_etl_user_settings
automatic_flattening_mode_switch TINYINT(1) NOT NULL COMMENT 'If MambaETL should/not automatically flatten ALL encounter types',
etl_interval_seconds INT NOT NULL COMMENT 'ETL Runs every 60 seconds',
incremental_mode_switch_cascaded TINYINT(1) NOT NULL DEFAULT 0 COMMENT 'This is a computed Incremental Mode (1 or 0) for the ETL that is cascaded down to the implementer scripts',
last_etl_schedule_insert_id INT NOT NULL DEFAULT 1 COMMENT 'Insert ID of the last ETL that ran'
last_etl_schedule_insert_id INT NOT NULL DEFAULT 1 COMMENT 'Insert ID of the last ETL that ran',
database_vendor VARCHAR(256) NOT NULL COMMENT 'Name of the database vendor e.g. mysql'

) CHARSET = UTF8MB4;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@ CREATE PROCEDURE sp_mamba_etl_user_settings_insert(
IN table_partition_number INT,
IN incremental_mode_switch TINYINT(1),
IN automatic_flattening_mode_switch TINYINT(1),
IN etl_interval_seconds INT
IN etl_interval_seconds INT,
IN database_vendor VARCHAR(256) CHARACTER SET UTF8MB4
)
BEGIN

SET @insert_stmt = CONCAT(
'INSERT INTO _mamba_etl_user_settings (`openmrs_database`, `etl_database`, `concepts_locale`, `table_partition_number`, `incremental_mode_switch`, `automatic_flattening_mode_switch`, `etl_interval_seconds`) VALUES (''',
openmrs_database, ''', ''', etl_database, ''', ''', concepts_locale, ''', ', table_partition_number, ', ', incremental_mode_switch, ', ', automatic_flattening_mode_switch, ', ', etl_interval_seconds, ');');
'INSERT INTO _mamba_etl_user_settings (`openmrs_database`, `etl_database`, `concepts_locale`, `table_partition_number`, `incremental_mode_switch`, `automatic_flattening_mode_switch`, `etl_interval_seconds`, `database_vendor`) VALUES (''',
openmrs_database, ''', ''', etl_database, ''', ''', concepts_locale, ''', ', table_partition_number, ', ', incremental_mode_switch, ', ', automatic_flattening_mode_switch, ', ', etl_interval_seconds, ', ', database_vendor,');');

PREPARE inserttbl FROM @insert_stmt;
EXECUTE inserttbl;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ CREATE PROCEDURE sp_mamba_etl_setup(
IN table_partition_number INT,
IN incremental_mode_switch TINYINT(1),
IN automatic_flattening_mode_switch TINYINT(1),
IN etl_interval_seconds INT
IN etl_interval_seconds INT,
IN database_vendor VARCHAR(256) CHARACTER SET UTF8MB4
)
BEGIN

Expand Down