Skip to content

Commit

Permalink
Removing oracle driver and associated tests (#3381)
Browse files Browse the repository at this point in the history
* Removing oracle driver and associated tests

* Removing Oracle container

* Removing oracle enum and script
  • Loading branch information
fjtirado authored Feb 8, 2024
1 parent a8b1de3 commit 2e15b49
Show file tree
Hide file tree
Showing 11 changed files with 17 additions and 375 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
*/
package org.kie.kogito.persistence.jdbc.correlation;

import java.sql.Connection;
import java.sql.SQLException;
import java.util.Optional;

import javax.sql.DataSource;
Expand All @@ -29,25 +27,13 @@
import org.kie.kogito.correlation.CorrelationInstance;
import org.kie.kogito.correlation.CorrelationService;
import org.kie.kogito.event.correlation.MD5CorrelationEncoder;
import org.kie.kogito.persistence.jdbc.DatabaseType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class JDBCCorrelationService implements CorrelationService {

private static final Logger LOGGER = LoggerFactory.getLogger(JDBCCorrelationService.class);
public class PostgreSQLCorrelationService implements CorrelationService {

private PostgreSQLCorrelationRepository repository;
private CorrelationEncoder correlationEncoder;

public JDBCCorrelationService(DataSource dataSource) {
try (Connection connection = dataSource.getConnection()) {
if (!DatabaseType.POSTGRES.equals(DatabaseType.getDataBaseType(connection))) {
throw new IllegalArgumentException("Only PostgreSQL is supported for correlation");
}
} catch (SQLException e) {
LOGGER.error("Error getting connection for {}", dataSource);
}
public PostgreSQLCorrelationService(DataSource dataSource) {
this.repository = new PostgreSQLCorrelationRepository(dataSource);
this.correlationEncoder = new MD5CorrelationEncoder();
}
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import org.kie.kogito.correlation.CompositeCorrelation;
import org.kie.kogito.correlation.CorrelationInstance;
import org.kie.kogito.correlation.SimpleCorrelation;
import org.kie.kogito.persistence.jdbc.correlation.JDBCCorrelationService;
import org.kie.kogito.persistence.jdbc.correlation.PostgreSQLCorrelationService;
import org.kie.kogito.testcontainers.KogitoPostgreSqlContainer;
import org.postgresql.ds.PGSimpleDataSource;
import org.testcontainers.containers.JdbcDatabaseContainer;
Expand All @@ -42,15 +42,15 @@ public class JDBCCorrelationServiceIT {
@Container
private static final KogitoPostgreSqlContainer PG_CONTAINER = new KogitoPostgreSqlContainer();
private static PGSimpleDataSource dataSource;
private static JDBCCorrelationService correlationService;
private static PostgreSQLCorrelationService correlationService;

@BeforeAll
public static void setUp() {
dataSource = new PGSimpleDataSource();
dataSource.setUrl(PG_CONTAINER.getJdbcUrl());
dataSource.setUser(PG_CONTAINER.getUsername());
dataSource.setPassword(PG_CONTAINER.getPassword());
correlationService = new JDBCCorrelationService(dataSource);
correlationService = new PostgreSQLCorrelationService(dataSource);
//create table
// DDLRunner.init(new GenericRepository(dataSource), true);
initMigration(PG_CONTAINER, "postgresql");
Expand Down
5 changes: 0 additions & 5 deletions kogito-test-utils/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,6 @@
<version>${version.org.testcontainers}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.oracle.database.jdbc</groupId>
<artifactId>ojdbc11</artifactId>
<version>${version.com.oracle.database.jdbc}</version>
</dependency>

<dependency>
<groupId>org.testcontainers</groupId>
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -18,33 +18,29 @@
*/
package org.kie.kogito.persistence.quarkus;

import java.sql.Connection;
import java.sql.SQLException;
import java.util.Optional;

import javax.sql.DataSource;

import org.eclipse.microprofile.config.inject.ConfigProperty;
import org.kie.kogito.correlation.CorrelationService;
import org.kie.kogito.event.correlation.DefaultCorrelationService;
import org.kie.kogito.persistence.jdbc.DatabaseType;
import org.kie.kogito.persistence.jdbc.correlation.JDBCCorrelationService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.kie.kogito.persistence.jdbc.correlation.PostgreSQLCorrelationService;

import jakarta.enterprise.inject.Produces;
import jakarta.inject.Inject;

import static org.kie.kogito.persistence.quarkus.KogitoAddOnPersistenceJDBCConfigSourceFactory.DATASOURCE_DB_KIND;
import static org.kie.kogito.persistence.quarkus.KogitoAddOnPersistenceJDBCConfigSourceFactory.POSTGRESQL;

public class JDBCorrelationServiceProducer {

private static final Logger LOGGER = LoggerFactory.getLogger(JDBCorrelationServiceProducer.class);
@Inject
@ConfigProperty(name = DATASOURCE_DB_KIND)
Optional<String> dbKind;

@Produces
public CorrelationService jdbcCorrelationService(DataSource dataSource) {
try (Connection connection = dataSource.getConnection()) {
if (!DatabaseType.POSTGRES.equals(DatabaseType.getDataBaseType(connection))) {
return new DefaultCorrelationService();
}
} catch (SQLException e) {
LOGGER.error("Error getting connection for {}", dataSource);
}
return new JDBCCorrelationService(dataSource);
return dbKind.filter(POSTGRESQL::equals).isPresent() ? new PostgreSQLCorrelationService(dataSource) : new DefaultCorrelationService();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,9 @@ public class KogitoAddOnPersistenceJDBCConfigSourceFactory implements ConfigSour
private static final Logger LOGGER = LoggerFactory.getLogger(KogitoAddOnPersistenceJDBCConfigSourceFactory.class);

static final String FLYWAY_LOCATIONS = "quarkus.flyway.locations";
private static final String DATASOURCE_DB_KIND = "quarkus.datasource.db-kind";
static final String DATASOURCE_DB_KIND = "quarkus.datasource.db-kind";
private static final String LOCATION_PREFIX = "classpath:/db/";
static final String POSTGRESQL = "postgresql";
private static final String ORACLE = "oracle";
private static final String ANSI = "ansi";

@Override
Expand Down Expand Up @@ -77,8 +76,6 @@ public OptionalInt getPriority() {
private String getDBName(final String dbKind) {
if (POSTGRESQL.equals(dbKind)) {
return POSTGRESQL;
} else if (ORACLE.equals(dbKind)) {
return ORACLE;
} else {
return ANSI;
}
Expand Down
Loading

0 comments on commit 2e15b49

Please sign in to comment.