diff --git a/build.gradle b/build.gradle index f2e431a3..0d2a5c08 100644 --- a/build.gradle +++ b/build.gradle @@ -1,6 +1,6 @@ buildscript { ext { - springBootVersion = '1.5.22.RELEASE' + springBootVersion = '2.5.15' dependencyCheckVersion = '3.1.2' } repositories { @@ -13,11 +13,12 @@ buildscript { } plugins { - id "nebula.ospackage" version "4.5.1" + id "nebula.ospackage" version "8.4.2" } apply plugin: 'java' apply plugin: 'org.springframework.boot' +apply plugin: 'io.spring.dependency-management' apply plugin: 'jacoco' apply plugin: 'checkstyle' apply plugin: 'org.owasp.dependencycheck' @@ -72,39 +73,40 @@ jacocoTestCoverageVerification { check.dependsOn jacocoTestCoverageVerification dependencies { - compile('org.springframework.boot:spring-boot-starter') - compile group: 'ch.qos.logback', name: 'logback-classic', version: '1.2.13' - compile group: 'ch.qos.logback', name: 'logback-core', version: '1.2.13' - compile group: 'org.yaml', name: 'snakeyaml', version: '2.0' - compile("org.springframework.boot:spring-boot-starter-batch") - compile group: 'org.springframework', name: 'spring-beans', version: '5.3.20' - compile group: 'org.springframework', name: 'spring-core', version: '5.3.27' - compile group: 'org.springframework', name: 'spring-expression', version: '5.3.27' - compile group: 'org.codehaus.jettison', name: 'jettison', version: '1.5.4' - compile group: 'com.thoughtworks.xstream', name: 'xstream', version: '1.4.20' - compile group: 'com.google.protobuf', name: 'protobuf-java', version: '3.21.7' - compile("org.springframework.batch:spring-batch-test") - compile group: 'junit', name: 'junit', version: '4.13.1' - compile group: 'mysql', name: 'mysql-connector-java', version: '5.1.42' - compile group: 'org.postgresql', name: 'postgresql', version: '42.3.9' - compile group: 'org.apache.commons', name: 'commons-dbcp2', version: '2.3.0' - compile group: 'commons-io', name: 'commons-io', version: '2.7' - compile group: 'org.apache.commons', name: 'commons-lang3', version: '3.7' - compile group: 'org.freemarker', name: 'freemarker', version: '2.3.23' - compile group: 'com.google.code.gson', name: 'gson', version: '2.8.9' - compile "com.github.jsqlparser:jsqlparser:1.1" - compile 'org.springframework.cloud:spring-cloud-starter-task:1.2.2.RELEASE' - compile group: 'org.liquibase', name: 'liquibase-core', version: '4.8.0' - compile group: 'org.json', name: 'json', version: '20231013' - - testCompile('org.springframework.boot:spring-boot-starter-test') - testCompile group: 'junit', name: 'junit', version: '4.13.1' - testCompile group: 'org.mockito', name: 'mockito-core', version: '1.10.19' - testCompile group: 'org.powermock', name: 'powermock-core', version: '1.6.4' - testCompile "org.powermock:powermock-module-junit4:1.6.4" - testCompile "org.powermock:powermock-module-junit4-rule:1.6.4" - testCompile "org.powermock:powermock-api-mockito:1.6.4" - testCompile group: 'org.hamcrest', name: 'hamcrest-all', version: '1.3' + implementation('org.springframework.boot:spring-boot-starter') + implementation group: 'ch.qos.logback', name: 'logback-classic', version: '1.2.13' + implementation group: 'ch.qos.logback', name: 'logback-core', version: '1.2.13' + implementation group: 'org.yaml', name: 'snakeyaml', version: '2.0' + implementation("org.springframework.boot:spring-boot-starter-batch") + implementation group: 'org.springframework', name: 'spring-beans', version: '5.3.20' + implementation group: 'org.springframework', name: 'spring-core', version: '5.3.27' + implementation group: 'org.springframework', name: 'spring-expression', version: '5.3.27' + implementation group: 'org.codehaus.jettison', name: 'jettison', version: '1.5.4' + implementation group: 'com.thoughtworks.xstream', name: 'xstream', version: '1.4.20' + implementation group: 'com.google.protobuf', name: 'protobuf-java', version: '3.21.7' + implementation("org.springframework.batch:spring-batch-test") + implementation group: 'junit', name: 'junit', version: '4.13.1' + implementation group: 'mysql', name: 'mysql-connector-java', version: '8.0.28' + implementation group: 'org.postgresql', name: 'postgresql', version: '42.3.9' + implementation group: 'org.apache.commons', name: 'commons-dbcp2', version: '2.3.0' + implementation group: 'commons-io', name: 'commons-io', version: '2.7' + implementation group: 'org.apache.commons', name: 'commons-lang3', version: '3.7' + implementation group: 'org.freemarker', name: 'freemarker', version: '2.3.23' + implementation group: 'com.google.code.gson', name: 'gson', version: '2.8.9' + implementation group: 'commons-collections', name: 'commons-collections', version: '3.2.2' + implementation "com.github.jsqlparser:jsqlparser:1.1" + implementation 'org.springframework.cloud:spring-cloud-starter-task:1.2.2.RELEASE' + implementation group: 'org.liquibase', name: 'liquibase-core', version: '4.8.0' + implementation group: 'org.json', name: 'json', version: '20231013' + + testImplementation('org.springframework.boot:spring-boot-starter-test') + testImplementation group: 'junit', name: 'junit', version: '4.13.1' + testImplementation group: 'org.mockito', name: 'mockito-core', version: '1.10.19' + testImplementation group: 'org.powermock', name: 'powermock-core', version: '1.6.4' + testImplementation "org.powermock:powermock-module-junit4:1.6.4" + testImplementation "org.powermock:powermock-module-junit4-rule:1.6.4" + testImplementation "org.powermock:powermock-api-mockito:1.6.4" + testImplementation group: 'org.hamcrest', name: 'hamcrest-all', version: '1.3' } jar { @@ -165,8 +167,8 @@ buildRpm { postUninstall file("${projectDir}/scripts/builds/postuninstall.sh") } -task wrapper(type: Wrapper) { - gradleVersion = '4.5.1' +wrapper { + gradleVersion = '6.8.3' } checkstyle { diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index ca78035e..28861d27 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 86884194..442d9132 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,5 @@ -#Tue May 24 11:00:15 IST 2016 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.3-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.5.1-bin.zip diff --git a/gradlew b/gradlew index 91a7e269..cccdd3d5 100755 --- a/gradlew +++ b/gradlew @@ -1,4 +1,4 @@ -#!/usr/bin/env bash +#!/usr/bin/env sh ############################################################################## ## @@ -6,20 +6,38 @@ ## ############################################################################## -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS="" +# Attempt to set APP_HOME +# Resolve links: $0 may be a link +PRG="$0" +# Need this for relative symlinks. +while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`"/$link" + fi +done +SAVED="`pwd`" +cd "`dirname \"$PRG\"`/" >/dev/null +APP_HOME="`pwd -P`" +cd "$SAVED" >/dev/null APP_NAME="Gradle" APP_BASE_NAME=`basename "$0"` +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS="" + # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD="maximum" -warn ( ) { +warn () { echo "$*" } -die ( ) { +die () { echo echo "$*" echo @@ -30,6 +48,7 @@ die ( ) { cygwin=false msys=false darwin=false +nonstop=false case "`uname`" in CYGWIN* ) cygwin=true @@ -40,31 +59,11 @@ case "`uname`" in MINGW* ) msys=true ;; + NONSTOP* ) + nonstop=true + ;; esac -# For Cygwin, ensure paths are in UNIX format before anything is touched. -if $cygwin ; then - [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` -fi - -# Attempt to set APP_HOME -# Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi -done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >&- -APP_HOME="`pwd -P`" -cd "$SAVED" >&- - CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -90,7 +89,7 @@ location of your Java installation." fi # Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then +if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then MAX_FD_LIMIT=`ulimit -H -n` if [ $? -eq 0 ] ; then if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then @@ -114,6 +113,7 @@ fi if $cygwin ; then APP_HOME=`cygpath --path --mixed "$APP_HOME"` CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + JAVACMD=`cygpath --unix "$JAVACMD"` # We build the pattern for arguments to be converted via cygpath ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` @@ -154,11 +154,19 @@ if $cygwin ; then esac fi -# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules -function splitJvmOpts() { - JVM_OPTS=("$@") +# Escape application args +save () { + for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done + echo " " } -eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS -JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" +APP_ARGS=$(save "$@") + +# Collect all arguments for the java command, following the shell quoting and substitution rules +eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" + +# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong +if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then + cd "$(dirname "$0")" +fi -exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" +exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat index aec99730..e95643d6 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -8,14 +8,14 @@ @rem Set local scope for the variables with windows NT shell if "%OS%"=="Windows_NT" setlocal -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS= - set DIRNAME=%~dp0 if "%DIRNAME%" == "" set DIRNAME=. set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS= + @rem Find java.exe if defined JAVA_HOME goto findJavaFromJavaHome @@ -46,10 +46,9 @@ echo location of your Java installation. goto fail :init -@rem Get command-line arguments, handling Windowz variants +@rem Get command-line arguments, handling Windows variants if not "%OS%" == "Windows_NT" goto win9xME_args -if "%@eval[2+2]" == "4" goto 4NT_args :win9xME_args @rem Slurp the command line arguments. @@ -60,11 +59,6 @@ set _SKIP=2 if "x%~1" == "x" goto execute set CMD_LINE_ARGS=%* -goto execute - -:4NT_args -@rem Get arguments from the 4NT Shell from JP Software -set CMD_LINE_ARGS=%$ :execute @rem Setup the command line diff --git a/package/docker/files/application.properties b/package/docker/files/application.properties index 1e45217f..973104d7 100644 --- a/package/docker/files/application.properties +++ b/package/docker/files/application.properties @@ -1,18 +1,20 @@ - -spring.datasource.url=jdbc:postgresql://${MART_DB_HOST}/${MART_DB_NAME} +spring.datasource.jdbc-url=jdbc:postgresql://${MART_DB_HOST}/${MART_DB_NAME} spring.datasource.username=${MART_DB_USERNAME} spring.datasource.password=${MART_DB_PASSWORD} spring.datasource.driver-class-name=org.postgresql.Driver -spring.ds_openmrs.url=jdbc:mysql://${OPENMRS_DB_HOST}/${OPENMRS_DB_NAME} -spring.ds_openmrs.username=${OPENMRS_DB_USERNAME} -spring.ds_openmrs.password=${OPENMRS_DB_PASSWORD} -spring.ds_openmrs.driver-class-name=com.mysql.jdbc.Driver +spring.ds-openmrs.jdbc-url=jdbc:mysql://${OPENMRS_DB_HOST}/${OPENMRS_DB_NAME} +spring.ds-openmrs.username=${OPENMRS_DB_USERNAME} +spring.ds-openmrs.password=${OPENMRS_DB_PASSWORD} +spring.ds-openmrs.driver-class-name=com.mysql.cj.jdbc.Driver + +spring.ds-mart.jdbc-url=jdbc:postgresql://${MART_DB_HOST}/${MART_DB_NAME} +spring.ds-mart.username=${MART_DB_USERNAME} +spring.ds-mart.password=${MART_DB_PASSWORD} +spring.ds-mart.driver-class-name=org.postgresql.Driver -spring.ds_mart.url=jdbc:postgresql://${MART_DB_HOST}/${MART_DB_NAME} -spring.ds_mart.username=${MART_DB_USERNAME} -spring.ds_mart.password=${MART_DB_PASSWORD} -spring.ds_mart.driver-class-name=org.postgresql.Driver +spring.batch.initialize-schema=always +spring.main.allow-bean-definition-overriding=true bahmniMartConfigFile=file:/bahmni-mart/conf/bahmni-mart.json defaultConfigPath=/bahmni-mart/conf/app.json @@ -21,11 +23,11 @@ defaultExtensionConfigPath=/bahmni-mart/conf/extension.json implementationExtensionConfigPath="" logging.level.org.bahmni=INFO -liquibase.enabled=true -liquibase.change-log=file:/bahmni-mart/conf/liquibase.xml -liquibase.url=jdbc:postgresql://${MART_DB_HOST}/${MART_DB_NAME} -liquibase.user=${MART_DB_USERNAME} -liquibase.password=${MART_DB_PASSWORD} +spring.liquibase.enabled=true +spring.liquibase.change-log=file:/bahmni-mart/conf/liquibase.xml +spring.liquibase.url=jdbc:postgresql://${MART_DB_HOST}/${MART_DB_NAME} +spring.liquibase.user=${MART_DB_USERNAME} +spring.liquibase.password=${MART_DB_PASSWORD} # Notifications config bahmni-mart.mail.subject="" diff --git a/src/main/java/org/bahmni/mart/BatchUtils.java b/src/main/java/org/bahmni/mart/BatchUtils.java index c44ac35d..28979e79 100644 --- a/src/main/java/org/bahmni/mart/BatchUtils.java +++ b/src/main/java/org/bahmni/mart/BatchUtils.java @@ -33,6 +33,12 @@ public static String getPostgresCompatibleValue(String value, String dataType) { case "timestamp": case "time": return getStringForPsql(value); + case "BIT": + if ("true".equalsIgnoreCase(value)) { + return "B'1'"; + } else { + return "B'0'"; + } default: return value; } diff --git a/src/main/java/org/bahmni/mart/dbconfig/DatabaseConfiguration.java b/src/main/java/org/bahmni/mart/dbconfig/DatabaseConfiguration.java index 56b86f61..4af8bb4b 100644 --- a/src/main/java/org/bahmni/mart/dbconfig/DatabaseConfiguration.java +++ b/src/main/java/org/bahmni/mart/dbconfig/DatabaseConfiguration.java @@ -4,9 +4,9 @@ import org.postgresql.copy.CopyManager; import org.postgresql.core.BaseConnection; import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.boot.autoconfigure.batch.BatchDatabaseInitializer; +import org.springframework.boot.autoconfigure.batch.BatchDataSourceInitializer; import org.springframework.boot.autoconfigure.batch.BatchProperties; -import org.springframework.boot.autoconfigure.jdbc.DataSourceBuilder; +import org.springframework.boot.jdbc.DataSourceBuilder; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -23,7 +23,7 @@ public class DatabaseConfiguration { @Primary @Bean(name = "openmrsDb") - @ConfigurationProperties(prefix = "spring.ds_openmrs") + @ConfigurationProperties(prefix = "spring.ds-openmrs") public DataSource openmrsDataSource() { return DataSourceBuilder.create().build(); } @@ -34,7 +34,7 @@ public JdbcTemplate openmrsJdbcTemplate(@Qualifier("openmrsDb") DataSource dsOpe } @Bean(name = "martDb") - @ConfigurationProperties(prefix = "spring.ds_mart") + @ConfigurationProperties(prefix = "spring.ds-mart") public DataSource martDataSource() { return DataSourceBuilder.create().build(); } @@ -66,9 +66,9 @@ public DataSource dataSource() { } @Bean - public BatchDatabaseInitializer batchDatabaseInitializer(final BatchProperties properties, + public BatchDataSourceInitializer batchDataSourceInitializer(final BatchProperties properties, @Qualifier("scdfDb") final DataSource dataSource, final ResourceLoader resourceLoader) { - return new BatchDatabaseInitializer(dataSource, resourceLoader, properties); + return new BatchDataSourceInitializer(dataSource, resourceLoader, properties); } } \ No newline at end of file diff --git a/src/main/java/org/bahmni/mart/helper/Constants.java b/src/main/java/org/bahmni/mart/helper/Constants.java index de370b78..22263df0 100644 --- a/src/main/java/org/bahmni/mart/helper/Constants.java +++ b/src/main/java/org/bahmni/mart/helper/Constants.java @@ -25,6 +25,7 @@ public class Constants { put("int", "integer"); put("float8", "double precision"); put("bigint", "integer"); + put("mediumtext", "text"); } }; diff --git a/src/main/resources/application-dev.properties b/src/main/resources/application-dev.properties index dc71c696..9d8efd99 100644 --- a/src/main/resources/application-dev.properties +++ b/src/main/resources/application-dev.properties @@ -1,20 +1,23 @@ -spring.datasource.url=jdbc:postgresql://192.168.33.10/analytics +spring.datasource.jdbc-url=jdbc:postgresql://192.168.33.10/analytics spring.datasource.username=analytics spring.datasource.password=${ANALYTICS_DB_PASSWORD} spring.datasource.driver-class-name=org.postgresql.Driver -spring.ds_openmrs.url=jdbc:mysql://192.168.33.10/openmrs -spring.ds_openmrs.username=root -spring.ds_openmrs.password=${OPENMRS_DB_PASSWORD} -spring.ds_openmrs.driver-class-name=com.mysql.jdbc.Driver +spring.ds-openmrs.jdbc-url=jdbc:mysql://192.168.33.10/openmrs +spring.ds-openmrs.username=root +spring.ds-openmrs.password=${OPENMRS_DB_PASSWORD} +spring.ds-openmrs.driver-class-name=com.mysql.cj.jdbc.Driver logging.level.org.bahmni=INFO #logging.level.org.springframework.jdbc=DEBUG -spring.ds_mart.url=jdbc:postgresql://192.168.33.10/analytics -spring.ds_mart.username=analytics -spring.ds_mart.password=${ANALYTICS_DB_PASSWORD} -spring.ds_mart.driver-class-name=org.postgresql.Driver +spring.ds-mart.jdbc-url=jdbc:postgresql://192.168.33.10/analytics +spring.ds-mart.username=analytics +spring.ds-mart.password=${ANALYTICS_DB_PASSWORD} +spring.ds-mart.driver-class-name=org.postgresql.Driver + +spring.batch.initialize-schema=always +spring.main.allow-bean-definition-overriding=true bahmniMartConfigFile=file:conf/bahmni-mart.json @@ -23,7 +26,7 @@ implementationConfigPath="" defaultExtensionConfigPath=conf/extension.json implementationExtensionConfigPath="" -liquibase.enabled=false +spring.liquibase.enabled=false # Notifications config bahmni-mart.mail.subject= diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index ee584542..01754ea3 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -1,17 +1,20 @@ -spring.datasource.url=jdbc:postgresql://${ANALYTICS_DB_SERVER}/${POSTGRES_DB_NAME}?currentSchema=${CURRENT_SCHEMA_NAME} +spring.datasource.jdbc-url=jdbc:postgresql://${ANALYTICS_DB_SERVER}/${POSTGRES_DB_NAME}?currentSchema=${CURRENT_SCHEMA_NAME} spring.datasource.username=${ANALYTICS_DB_USER} spring.datasource.password=${ANALYTICS_DB_PASSWORD} spring.datasource.driver-class-name=org.postgresql.Driver -spring.ds_openmrs.url=jdbc:mysql://${OPENMRS_DB_SERVER}/${MYSQL_DB_NAME} -spring.ds_openmrs.username=${OPENMRS_DB_USER} -spring.ds_openmrs.password=${OPENMRS_DB_PASSWORD} -spring.ds_openmrs.driver-class-name=com.mysql.jdbc.Driver +spring.ds-openmrs.jdbc-url=jdbc:mysql://${OPENMRS_DB_SERVER}/${MYSQL_DB_NAME} +spring.ds-openmrs.username=${OPENMRS_DB_USER} +spring.ds-openmrs.password=${OPENMRS_DB_PASSWORD} +spring.ds-openmrs.driver-class-name=com.mysql.cj.jdbc.Driver -spring.ds_mart.url=jdbc:postgresql://${ANALYTICS_DB_SERVER}/${POSTGRES_DB_NAME} -spring.ds_mart.username=${ANALYTICS_DB_USER} -spring.ds_mart.password=${ANALYTICS_DB_PASSWORD} -spring.ds_mart.driver-class-name=org.postgresql.Driver +spring.ds-mart.jdbc-url=jdbc:postgresql://${ANALYTICS_DB_SERVER}/${POSTGRES_DB_NAME} +spring.ds-mart.username=${ANALYTICS_DB_USER} +spring.ds-mart.password=${ANALYTICS_DB_PASSWORD} +spring.ds-mart.driver-class-name=org.postgresql.Driver + +spring.batch.initialize-schema=always +spring.main.allow-bean-definition-overriding=true bahmniMartConfigFile=file:${BAHMNI_MART_CONFIG_FILE} defaultConfigPath=${DEFAULT_CONFIG_FILE_PATH} @@ -19,7 +22,7 @@ implementationConfigPath=${IMPLEMENTATION_CONFIG_FILE_PATH} defaultExtensionConfigPath=${DEFAULT_EXTENSION_CONFIG_FILE_PATH} implementationExtensionConfigPath=${IMPLEMENTATION_EXTENSION_CONFIG_FILE_PATH} logging.file=/opt/bahmni-mart/log/bahmni-mart.log -liquibase.enabled=false +spring.liquibase.enabled=false # Notifications config bahmni-mart.mail.subject=${MAIL_SUBJECT} diff --git a/src/main/resources/viewSql/patientInformationView.sql b/src/main/resources/viewSql/patientInformationView.sql index 92658b78..f0e38023 100644 --- a/src/main/resources/viewSql/patientInformationView.sql +++ b/src/main/resources/viewSql/patientInformationView.sql @@ -34,4 +34,4 @@ SELECT pa.* FROM person_details_default pd LEFT JOIN person_attributes pa ON pa.person_id = pd.person_id - LEFT JOIN person_address_default pad ON pad.person_id = pd.person_id and pad.preferred = 'true' + LEFT JOIN person_address_default pad ON pad.person_id = pd.person_id and pad.preferred = B'1' diff --git a/src/test/java/org/bahmni/mart/config/stepconfigurer/OrderStepConfigurerTest.java b/src/test/java/org/bahmni/mart/config/stepconfigurer/OrderStepConfigurerTest.java index 36b2b2cb..892e6beb 100644 --- a/src/test/java/org/bahmni/mart/config/stepconfigurer/OrderStepConfigurerTest.java +++ b/src/test/java/org/bahmni/mart/config/stepconfigurer/OrderStepConfigurerTest.java @@ -27,6 +27,7 @@ import org.springframework.batch.core.step.builder.SimpleStepBuilder; import org.springframework.batch.core.step.builder.StepBuilder; import org.springframework.batch.core.step.tasklet.TaskletStep; +import org.springframework.batch.item.ItemProcessor; import org.springframework.beans.factory.ObjectFactory; import java.util.ArrayList; @@ -258,7 +259,7 @@ public void shouldRegisterStepsforAllOrderables() throws InvalidOrderTypeExcepti when(simpleStepBuilder.reader(any())).thenReturn(simpleStepBuilder); when(tableDataGenerator.getTableDataFromOpenmrs(orderable, sql)).thenReturn(tableData); - when(simpleStepBuilder.processor(any())).thenReturn(simpleStepBuilder); + when(simpleStepBuilder.processor(any(ItemProcessor.class))).thenReturn(simpleStepBuilder); when(recordWriterObjectFactory.getObject()).thenReturn(new TableRecordWriter()); when(simpleStepBuilder.writer(any())).thenReturn(simpleStepBuilder); when(simpleStepBuilder.build()).thenReturn(expectedBaseExportStep); @@ -279,7 +280,7 @@ public void shouldRegisterStepsforAllOrderables() throws InvalidOrderTypeExcepti BatchUtils.constructSqlWithParameter(sql, "orderTypeId", "1"); verify(simpleStepBuilder, times(1)).reader(any()); verify(tableDataGenerator, times(2)).getTableDataFromOpenmrs(orderable, sql); - verify(simpleStepBuilder, times(1)).processor(any()); + verify(simpleStepBuilder, times(1)).processor(any(ItemProcessor.class)); verify(recordWriterObjectFactory, times(1)).getObject(); verify(simpleStepBuilder, times(1)).writer(any()); verify(simpleStepBuilder, times(1)).build(); diff --git a/src/test/java/org/bahmni/mart/exports/Form1ObservationExportStepTest.java b/src/test/java/org/bahmni/mart/exports/Form1ObservationExportStepTest.java index 64c62530..b0889556 100644 --- a/src/test/java/org/bahmni/mart/exports/Form1ObservationExportStepTest.java +++ b/src/test/java/org/bahmni/mart/exports/Form1ObservationExportStepTest.java @@ -21,6 +21,7 @@ import org.springframework.batch.core.step.builder.SimpleStepBuilder; import org.springframework.batch.core.step.builder.StepBuilder; import org.springframework.batch.core.step.tasklet.TaskletStep; +import org.springframework.batch.item.ItemProcessor; import org.springframework.beans.factory.ObjectFactory; import javax.sql.DataSource; @@ -119,7 +120,7 @@ public void shouldGetTheBatchStepForBaseExport() { when(simpleStepBuilder.reader(any())).thenReturn(simpleStepBuilder); when(observationProcessorFactory.getObject()).thenReturn(new ObservationProcessor()); when(obsWriterObjectFactory.getObject()).thenReturn(new DatabaseObsWriter()); - when(simpleStepBuilder.processor(any())).thenReturn(simpleStepBuilder); + when(simpleStepBuilder.processor(any(ItemProcessor.class))).thenReturn(simpleStepBuilder); when(simpleStepBuilder.writer(any())).thenReturn(simpleStepBuilder); when(simpleStepBuilder.build()).thenReturn(expectedBaseExportStep); @@ -173,7 +174,7 @@ private void setUpStepConfig(String formName, BahmniForm form) { when(simpleStepBuilder.reader(any())).thenReturn(simpleStepBuilder); when(observationProcessorFactory.getObject()).thenReturn(new ObservationProcessor()); when(obsWriterObjectFactory.getObject()).thenReturn(new DatabaseObsWriter()); - when(simpleStepBuilder.processor(any())).thenReturn(simpleStepBuilder); + when(simpleStepBuilder.processor(any(ItemProcessor.class))).thenReturn(simpleStepBuilder); when(simpleStepBuilder.writer(any())).thenReturn(simpleStepBuilder); when(freeMarkerEvaluator.evaluate("obsWithParentSql.ftl", form, false)).thenReturn("some sql"); } diff --git a/src/test/java/org/bahmni/mart/exports/Form2ObservationExportStepTest.java b/src/test/java/org/bahmni/mart/exports/Form2ObservationExportStepTest.java index abe36149..29bb92f4 100644 --- a/src/test/java/org/bahmni/mart/exports/Form2ObservationExportStepTest.java +++ b/src/test/java/org/bahmni/mart/exports/Form2ObservationExportStepTest.java @@ -22,6 +22,7 @@ import org.springframework.batch.core.step.builder.SimpleStepBuilder; import org.springframework.batch.core.step.builder.StepBuilder; import org.springframework.batch.core.step.tasklet.TaskletStep; +import org.springframework.batch.item.ItemProcessor; import org.springframework.beans.factory.ObjectFactory; import javax.sql.DataSource; @@ -131,7 +132,7 @@ public void shouldGetTheBatchStepForBaseExport() { when(simpleStepBuilder.reader(any())).thenReturn(simpleStepBuilder); when(observationProcessorFactory.getObject()).thenReturn(new Form2ObservationProcessor()); when(obsWriterObjectFactory.getObject()).thenReturn(new DatabaseObsWriter()); - when(simpleStepBuilder.processor(any())).thenReturn(simpleStepBuilder); + when(simpleStepBuilder.processor(any(ItemProcessor.class))).thenReturn(simpleStepBuilder); when(simpleStepBuilder.writer(any())).thenReturn(simpleStepBuilder); when(simpleStepBuilder.build()).thenReturn(expectedBaseExportStep); @@ -278,7 +279,7 @@ private void setUpStepConfig(String formName, BahmniForm form) { when(stepBuilderFactory.get("Insertion Step-1 " + formName)).thenReturn(stepBuilder); when(stepBuilder.chunk(500)).thenReturn(simpleStepBuilder); when(simpleStepBuilder.reader(any())).thenReturn(simpleStepBuilder); - when(simpleStepBuilder.processor(any())).thenReturn(simpleStepBuilder); + when(simpleStepBuilder.processor(any(ItemProcessor.class))).thenReturn(simpleStepBuilder); when(simpleStepBuilder.writer(any())).thenReturn(simpleStepBuilder); } } diff --git a/src/test/java/org/bahmni/mart/exports/MetaDataExportStepTest.java b/src/test/java/org/bahmni/mart/exports/MetaDataExportStepTest.java index 750222b1..5500cbc4 100644 --- a/src/test/java/org/bahmni/mart/exports/MetaDataExportStepTest.java +++ b/src/test/java/org/bahmni/mart/exports/MetaDataExportStepTest.java @@ -16,6 +16,7 @@ import org.springframework.batch.core.step.builder.SimpleStepBuilder; import org.springframework.batch.core.step.builder.StepBuilder; import org.springframework.batch.core.step.tasklet.TaskletStep; +import org.springframework.batch.item.ItemProcessor; import org.springframework.beans.factory.ObjectFactory; import org.springframework.core.io.ByteArrayResource; @@ -68,7 +69,7 @@ public void shouldGetTheBatchStepForMetaData() throws Exception { when(stepBuilder.chunk(100)).thenReturn(simpleStepBuilder); when(simpleStepBuilder.reader(any())).thenReturn(simpleStepBuilder); when(recordWriterObjectFactory.getObject()).thenReturn(new TableRecordWriter()); - when(simpleStepBuilder.processor(any())).thenReturn(simpleStepBuilder); + when(simpleStepBuilder.processor(any(ItemProcessor.class))).thenReturn(simpleStepBuilder); when(simpleStepBuilder.writer(any())).thenReturn(simpleStepBuilder); when(simpleStepBuilder.build()).thenReturn(expectedBaseExportStep); diff --git a/src/test/java/org/bahmni/mart/exports/template/JobTemplateTest.java b/src/test/java/org/bahmni/mart/exports/template/JobTemplateTest.java index 76a0cf0e..32ddda9b 100644 --- a/src/test/java/org/bahmni/mart/exports/template/JobTemplateTest.java +++ b/src/test/java/org/bahmni/mart/exports/template/JobTemplateTest.java @@ -24,6 +24,7 @@ import org.springframework.batch.core.launch.support.RunIdIncrementer; import org.springframework.batch.core.step.builder.SimpleStepBuilder; import org.springframework.batch.core.step.builder.StepBuilder; +import org.springframework.batch.item.ItemProcessor; import org.springframework.batch.item.database.JdbcCursorItemReader; import org.springframework.beans.factory.ObjectFactory; @@ -130,7 +131,7 @@ public void setUp() throws Exception { when(stepBuilderFactory.get(any())).thenReturn(stepBuilder); when(stepBuilder.chunk(100)).thenReturn(simpleStepBuilder); when(simpleStepBuilder.reader(any())).thenReturn(simpleStepBuilder); - when(simpleStepBuilder.processor(any())).thenReturn(simpleStepBuilderWithProcessor); + when(simpleStepBuilder.processor(any(ItemProcessor.class))).thenReturn(simpleStepBuilderWithProcessor); when(simpleStepBuilderWithProcessor.writer(any())).thenReturn(simpleStepBuilderWithProcessor); when(flowJobBuilder.build()).thenReturn(job); @@ -173,7 +174,7 @@ public void shouldBuildAndReturnAJob() throws Exception { verify(incrementalUpdateStrategy).isMetaDataChanged(TABLE_NAME, TEST_JOB_NAME); verify(simpleStepBuilder).reader(any()); - verify(simpleStepBuilder).processor(any()); + verify(simpleStepBuilder).processor(any(ItemProcessor.class)); verify(simpleStepBuilder, never()).writer(any()); verify(simpleStepBuilderWithProcessor).writer(any()); verifyNew(JdbcCursorItemReader.class).withNoArguments(); @@ -216,7 +217,7 @@ public void shouldAddRemovalStepIfMetadataIsSame() throws Exception { verify(simpleStepBuilder, times(2)).reader(any()); - verify(simpleStepBuilder).processor(any()); + verify(simpleStepBuilder).processor(any(ItemProcessor.class)); verify(simpleStepBuilder).writer(any()); verify(simpleStepBuilderWithProcessor).writer(any()); verifyNew(JdbcCursorItemReader.class, times(2)).withNoArguments(); diff --git a/src/test/resources/application-ci.properties b/src/test/resources/application-ci.properties index 257c4a9d..7f89bcc5 100644 --- a/src/test/resources/application-ci.properties +++ b/src/test/resources/application-ci.properties @@ -1,24 +1,26 @@ spring.batch.job.enabled=false spring.cloud.task.closecontext_enable=false -liquibase.enabled=false +spring.liquibase.enabled=false +spring.batch.initialize-schema=always +spring.main.allow-bean-definition-overriding=true -spring.datasource.url=jdbc:postgresql://127.0.0.1/test_analytics?currentSchema=bahmni_mart_scdf +spring.datasource.jdbc-url=jdbc:postgresql://127.0.0.1/test_analytics?currentSchema=bahmni_mart_scdf spring.datasource.username=test_user spring.datasource.password=password spring.datasource.driver-class-name=org.postgresql.Driver -spring.ds_openmrs.url=jdbc:mysql://localhost/test_openmrs -spring.ds_openmrs.username=test_user -spring.ds_openmrs.password=P@ssw0rd123 -spring.ds_openmrs.driver-class-name=com.mysql.jdbc.Driver +spring.ds-openmrs.jdbc-url=jdbc:mysql://localhost/test_openmrs +spring.ds-openmrs.username=test_user +spring.ds-openmrs.password=P@ssw0rd123 +spring.ds-openmrs.driver-class-name=com.mysql.cj.jdbc.Driver logging.level.org.bahmni=DEBUG #logging.level.org.springframework.jdbc=DEBUG -spring.ds_mart.url=jdbc:postgresql://127.0.0.1/test_analytics -spring.ds_mart.username=test_user -spring.ds_mart.password=password -spring.ds_mart.driver-class-name=org.postgresql.Driver +spring.ds-mart.jdbc-url=jdbc:postgresql://127.0.0.1/test_analytics +spring.ds-mart.username=test_user +spring.ds-mart.password=password +spring.ds-mart.driver-class-name=org.postgresql.Driver multiSelectConcepts="" bahmniMartConfigFile=classpath:bahmni-mart.json diff --git a/src/test/resources/application-test.properties b/src/test/resources/application-test.properties index ba6ca42c..c7bb76d7 100644 --- a/src/test/resources/application-test.properties +++ b/src/test/resources/application-test.properties @@ -1,24 +1,26 @@ spring.batch.job.enabled=false spring.cloud.task.closecontext_enable=false -liquibase.enabled=false +spring.liquibase.enabled=false +spring.batch.initialize-schema=always +spring.main.allow-bean-definition-overriding=true -spring.datasource.url=jdbc:postgresql://192.168.33.10/test_analytics?currentSchema=bahmni_mart_scdf +spring.datasource.jdbc-url=jdbc:postgresql://192.168.33.10/test_analytics?currentSchema=bahmni_mart_scdf spring.datasource.username=test_user spring.datasource.password=password spring.datasource.driver-class-name=org.postgresql.Driver -spring.ds_openmrs.url=jdbc:mysql://192.168.33.10/test_openmrs -spring.ds_openmrs.username=test_user -spring.ds_openmrs.password=password -spring.ds_openmrs.driver-class-name=com.mysql.jdbc.Driver +spring.ds-openmrs.jdbc-url=jdbc:mysql://192.168.33.10/test_openmrs +spring.ds-openmrs.username=test_user +spring.ds-openmrs.password=password +spring.ds-openmrs.driver-class-name=com.mysql.cj.jdbc.Driver logging.level.org.bahmni=DEBUG #logging.level.org.springframework.jdbc=DEBUG -spring.ds_mart.url=jdbc:postgresql://192.168.33.10/test_analytics -spring.ds_mart.username=test_user -spring.ds_mart.password=password -spring.ds_mart.driver-class-name=org.postgresql.Driver +spring.ds-mart.jdbc-url=jdbc:postgresql://192.168.33.10/test_analytics +spring.ds-mart.username=test_user +spring.ds-mart.password=password +spring.ds-mart.driver-class-name=org.postgresql.Driver multiSelectConcepts="" bahmniMartConfigFile=classpath:bahmni-mart.json