From d1866d70cf679208d5552fdca113fcf02b080635 Mon Sep 17 00:00:00 2001 From: grabdoc Date: Tue, 2 Apr 2024 08:51:32 -0500 Subject: [PATCH 1/2] #417 - work on oracle9i release --- .../workflows/dockerhub-github-publish.yml | 4 +- .github/workflows/oracle9i-github-publish.yml | 50 +++++++++++++++ pom.xml | 48 ++++++++++++-- .../db2rest/core/config/DataSource.java | 12 +++- .../jdbc/sql/JdbcMetaDataProvider.java | 64 ++++++++++++++----- src/main/resources/application.yml | 2 +- 6 files changed, 152 insertions(+), 28 deletions(-) create mode 100644 .github/workflows/oracle9i-github-publish.yml diff --git a/.github/workflows/dockerhub-github-publish.yml b/.github/workflows/dockerhub-github-publish.yml index 7d4b1f40..7f472e3c 100644 --- a/.github/workflows/dockerhub-github-publish.yml +++ b/.github/workflows/dockerhub-github-publish.yml @@ -26,10 +26,10 @@ jobs: settings-path: ${{ github.workspace }} # location for the settings.xml file - name: Build with Maven - run: ./mvnw -B package --file pom.xml -DskipTests + run: ./mvnw -B package --file pom.xml -DskipTests -P db2rest - name: Publish to GitHub Packages Apache Maven - run: ./mvnw deploy -s $GITHUB_WORKSPACE/settings.xml -DskipTests + run: ./mvnw deploy -s $GITHUB_WORKSPACE/settings.xml -DskipTests -P db2rest env: GITHUB_TOKEN: ${{ github.token }} diff --git a/.github/workflows/oracle9i-github-publish.yml b/.github/workflows/oracle9i-github-publish.yml new file mode 100644 index 00000000..cd49bed9 --- /dev/null +++ b/.github/workflows/oracle9i-github-publish.yml @@ -0,0 +1,50 @@ +# This workflow will build a package using Maven and then publish it to GitHub packages when a release is created +# For more information see: https://github.com/actions/setup-java/blob/main/docs/advanced-usage.md#apache-maven-with-a-settings-path + +name: Maven Package + +on: + release: + types: [created] + +jobs: + build: + + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + + steps: + - uses: actions/checkout@v3 + - name: Set up JDK 21 + uses: actions/setup-java@v3 + with: + java-version: '21' + distribution: 'liberica' + server-id: github # Value of the distributionManagement/repository/id field of the pom.xml + settings-path: ${{ github.workspace }} # location for the settings.xml file + + - name: Build with Maven + run: ./mvnw -B package --file pom.xml -DskipTests -P oracle9i + + - name: Publish to GitHub Packages Apache Maven + run: ./mvnw deploy -s $GITHUB_WORKSPACE/settings.xml -DskipTests -P oracle9i + env: + GITHUB_TOKEN: ${{ github.token }} + + + + - name: Login to DockerHub + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Build and push Docker images + uses: docker/build-push-action@v3.2.0 + with: + context: ./ + file: ./Dockerfile + push: true + tags: kdhrubo/db2rest:v${{github.run_number}}, kdhrubo/db2rest:latest diff --git a/pom.xml b/pom.xml index b033d7a4..87776457 100644 --- a/pom.xml +++ b/pom.xml @@ -10,7 +10,7 @@ com.github db2rest - 0.2.4 + 0.2.5-SNAPSHOT db2rest db2rest @@ -18,6 +18,45 @@ 3.0.1 + + + oracle9i + + + + + com.oracle.database.jdbc + ojdbc6 + 11.2.0.4 + + + + + + db2rest-oracle9i + + + + + db2rest + + + + com.oracle.database.jdbc + ojdbc11 + runtime + + + + + + db2rest + + + + + + github @@ -114,11 +153,8 @@ mysql-connector-j - - com.oracle.database.jdbc - ojdbc11 - runtime - + + + + com.github + db2rest-oracle9i + 0.2.5-SNAPSHOT + db2rest-oracle9i + DB2Rest support for older Oracle9i database. + + 21 + 3.0.1 + + + + + github + GitHub Packages + https://maven.pkg.github.com/kdhrubo/db2rest + + + + + + + + org.springframework.boot + spring-boot-starter-thymeleaf + + + + + org.springdoc + springdoc-openapi-starter-webmvc-ui + 2.3.0 + + + + org.springdoc + springdoc-openapi-starter-webmvc-api + 2.3.0 + + + + + com.fasterxml.jackson.dataformat + jackson-dataformat-csv + 2.16.1 + + + + commons-io + commons-io + 2.15.1 + + + + io.github.nstdio + rsql-parser + 2.2.1 + + + + + org.apache.commons + commons-lang3 + 3.12.0 + + + + org.springframework.boot + spring-boot-starter-actuator + + + + org.springframework.boot + spring-boot-starter-jdbc + + + org.springframework.boot + spring-boot-starter-web + + + + + org.springframework.boot + spring-boot-starter-validation + + + + + + + + com.mysql + mysql-connector-j + + + + com.oracle.database.jdbc + ojdbc6 + 11.2.0.4 + + + + org.postgresql + postgresql + + + + + + + + + org.springframework.boot + spring-boot-configuration-processor + true + + + + org.projectlombok + lombok + true + + + + org.springframework.boot + spring-boot-starter-test + test + + + + org.springframework.boot + spring-boot-testcontainers + test + + + + org.testcontainers + junit-jupiter + test + + + + org.testcontainers + postgresql + test + + + + org.testcontainers + mysql + test + + + + org.testcontainers + oracle-xe + 1.19.7 + test + + + + + + org.springframework.restdocs + spring-restdocs-mockmvc + test + + + + org.springframework.boot + spring-boot-test-autoconfigure + test + + + + + io.hosuaby + inject-resources-junit-jupiter + 0.3.3 + test + + + + + io.hypersistence + tsid + 1.1.0 + + + + com.auth0 + java-jwt + 4.4.0 + + + + + + db2rest-oracle9i + + + src/main/resources + true + + + + + org.asciidoctor + asciidoctor-maven-plugin + 2.2.4 + + + generate-docs + prepare-package + + process-asciidoc + + + html + book + + + + + + org.springframework.restdocs + spring-restdocs-asciidoctor + ${spring-restdocs.version} + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + org.projectlombok + lombok + + + + + + + + diff --git a/pom.xml b/pom.xml index 87776457..7edfa736 100644 --- a/pom.xml +++ b/pom.xml @@ -18,44 +18,6 @@ 3.0.1 - - - oracle9i - - - - - com.oracle.database.jdbc - ojdbc6 - 11.2.0.4 - - - - - - db2rest-oracle9i - - - - - db2rest - - - - com.oracle.database.jdbc - ojdbc11 - runtime - - - - - - db2rest - - - - - @@ -127,7 +89,6 @@ - org.springframework.boot spring-boot-starter-validation @@ -153,7 +114,17 @@ mysql-connector-j + + com.oracle.database.jdbc + ojdbc11 + runtime + + + + org.postgresql + postgresql + - - org.postgresql - postgresql - + org.springframework.boot diff --git a/src/main/java/com/homihq/db2rest/core/config/DataSource.java b/src/main/java/com/homihq/db2rest/core/config/DataSource.java index 0fa075f7..fc18883c 100644 --- a/src/main/java/com/homihq/db2rest/core/config/DataSource.java +++ b/src/main/java/com/homihq/db2rest/core/config/DataSource.java @@ -7,26 +7,9 @@ @Data @Slf4j public class DataSource { - String type; - String includeSchemas; - String includeTables; - String includeCatalogs; - public String [] getSchemas(){ - log.info("Included schemas - {}", includeSchemas); - return - StringUtils.isNotBlank(includeSchemas) ? includeSchemas.split(",") : null; - } - - public String getTablePattern(){ - return StringUtils.equals(includeTables,"") ? null : includeTables; - } - - public String getCatalogPattern(){ - return StringUtils.equals(includeCatalogs,"") ? null : includeCatalogs; - } } diff --git a/src/main/java/com/homihq/db2rest/core/config/Db2RestConfigProperties.java b/src/main/java/com/homihq/db2rest/core/config/Db2RestConfigProperties.java index 56ede959..60864e05 100644 --- a/src/main/java/com/homihq/db2rest/core/config/Db2RestConfigProperties.java +++ b/src/main/java/com/homihq/db2rest/core/config/Db2RestConfigProperties.java @@ -23,9 +23,6 @@ public class Db2RestConfigProperties { private boolean allowSafeDelete; private int defaultFetchLimit; - @Deprecated - private List schemas; //TODO validate - private DataSource datasource; private MultiTenancy multiTenancy; diff --git a/src/main/java/com/homihq/db2rest/jdbc/sql/JdbcMetaDataProvider.java b/src/main/java/com/homihq/db2rest/jdbc/sql/JdbcMetaDataProvider.java index f9846db9..b46750d3 100644 --- a/src/main/java/com/homihq/db2rest/jdbc/sql/JdbcMetaDataProvider.java +++ b/src/main/java/com/homihq/db2rest/jdbc/sql/JdbcMetaDataProvider.java @@ -6,8 +6,9 @@ import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Value; import org.springframework.jdbc.support.DatabaseMetaDataCallback; -import org.springframework.jdbc.support.MetaDataAccessException; + import java.sql.*; import java.util.ArrayList; @@ -22,12 +23,14 @@ public class JdbcMetaDataProvider implements DatabaseMetaDataCallback { private final Db2RestConfigProperties db2RestConfigProperties; + @Value("${INCLUDE_SCHEMAS}") + private String includedSchemas; + //TODO include schemas , tables , view, filters filters @Override - public DbMeta processMetaData(DatabaseMetaData databaseMetaData) throws SQLException, MetaDataAccessException { + public DbMeta processMetaData(DatabaseMetaData databaseMetaData) throws SQLException { log.info("Preparing database meta-data - {}", databaseMetaData); - log.debug("Properties - {}", db2RestConfigProperties.getDatasource()); String productName = databaseMetaData.getDatabaseProductName(); int majorVersion = databaseMetaData.getDatabaseMajorVersion(); @@ -41,20 +44,23 @@ public DbMeta processMetaData(DatabaseMetaData databaseMetaData) throws SQLExcep log.info("Driver Name - {}", driverName); log.info("Driver Version - {}", driverVersion); + log.info("IncludedSchemas - {}", includedSchemas); - String [] schemas = this.db2RestConfigProperties.getDatasource().getSchemas(); List dbTables = new ArrayList<>(); - if(Objects.isNull(schemas)) { + if(StringUtils.isBlank(includedSchemas)) { + log.info("Fetching all schema meta data."); List tables = getDbTables(databaseMetaData, null, productName, majorVersion); dbTables.addAll(tables); } else{ + String [] schemas = StringUtils.split(includedSchemas, ","); + for(String schema : schemas) { - log.info("Loading schema meta data - {}", schema); + log.info("Loading meta data for schema - {}", schema); List tables = getDbTables(databaseMetaData, schema, productName, majorVersion); @@ -63,7 +69,6 @@ public DbMeta processMetaData(DatabaseMetaData databaseMetaData) throws SQLExcep } - log.info("Completed loading database meta-data : {} tables", dbTables.size()); return new DbMeta(productName, majorVersion, driverName, driverVersion, dbTables); diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 34c2c8d6..3a52ac68 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -35,8 +35,8 @@ db2rest: datasource: type: ${DATASOURCE_TYPE:jdbc} includeSchemas: ${INCLUDE_SCHEMAS} - includeTables: ${INCLUDE_TABLES:""} - includeCatalogs: ${INCLUDE_CATALOGS:""} + includeTables: ${INCLUDE_TABLES:#{null}} + includeCatalogs: ${INCLUDE_CATALOGS:#{null}} auth: type: ${AUTH_TYPE:none}