Loading TapSchemaManagerAPI/pom.xml +0 −1 Original line number Diff line number Diff line Loading @@ -16,7 +16,6 @@ <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>5.1.37</version> <type>jar</type> </dependency> <dependency> <groupId>org.postgresql</groupId> Loading TapSchemaManagerAPI/src/main/java/it/inaf/ia2/tsm/api/DBWrapper.java +24 −18 Original line number Diff line number Diff line Loading @@ -22,13 +22,15 @@ */ package it.inaf.ia2.tsm.api; import it.inaf.ia2.tsm.api.contract.DatabaseType; import com.mysql.jdbc.jdbc2.optional.MysqlDataSource; import it.inaf.ia2.tsm.api.contract.DatabaseType; import java.io.Serializable; import java.sql.Connection; import java.sql.SQLException; import javax.sql.DataSource; import org.postgresql.ds.PGPoolingDataSource; import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** * This class is used to silently manage the possibility to have separate data Loading @@ -44,6 +46,7 @@ import org.postgresql.ds.PGPoolingDataSource; public class DBWrapper implements Serializable { private static final long serialVersionUID = 1721030677924066695L; private final static Logger log = LoggerFactory.getLogger(DBWrapper.class); // Same credentials private Credentials credentials; Loading Loading @@ -182,30 +185,33 @@ public class DBWrapper implements Serializable { } private DataSource createDataSource(Credentials credentials) { if (credentials.getDatabaseType() == DatabaseType.MYSQL) { MysqlDataSource ds = new MysqlDataSource(); switch (credentials.getDatabaseType()) { ds.setServerName(credentials.getHostname()); ds.setPortNumber(credentials.getPort()); ds.setUser(credentials.getUsername()); ds.setPassword(credentials.getPassword()); case MYSQL: MysqlDataSource myds = new MysqlDataSource(); return ds; } else if (credentials.getDatabaseType() == DatabaseType.POSTGRES) { myds.setServerName(credentials.getHostname()); myds.setPortNumber(credentials.getPort()); myds.setUser(credentials.getUsername()); myds.setPassword(credentials.getPassword()); PGPoolingDataSource ds = new PGPoolingDataSource(); return myds; ds.setServerName(credentials.getHostname()); ds.setPortNumber(credentials.getPort()); ds.setUser(credentials.getUsername()); ds.setPassword(credentials.getPassword()); ds.setDatabaseName("postgres"); case POSTGRES: PGPoolingDataSource pgds = new PGPoolingDataSource(); return ds; } pgds.setServerName(credentials.getHostname()); pgds.setPortNumber(credentials.getPort()); pgds.setUser(credentials.getUsername()); pgds.setPassword(credentials.getPassword()); pgds.setDatabaseName(credentials.getDatabase()); return pgds; default: throw new UnsupportedOperationException(credentials.getDatabaseType() + " not supported yet."); } } } } TapSchemaManagerAPI/src/main/java/it/inaf/ia2/tsm/api/DaoKey.java +4 −2 Original line number Diff line number Diff line Loading @@ -40,7 +40,6 @@ import java.util.List; import java.util.Map; import java.util.regex.Pattern; import javax.sql.DataSource; import org.postgresql.ds.PGPoolingDataSource; import org.slf4j.Logger; import org.slf4j.LoggerFactory; Loading Loading @@ -113,7 +112,10 @@ public class DaoKey { } else if (dbType == DatabaseType.POSTGRES) { String databaseName = ((PGPoolingDataSource) dataSource).getDatabaseName(); String databaseName = schemaName.equals(tapSchema.getName()) ? dbWrapper.getTapSchemaCredentials().getDatabase() : dbWrapper.getSourceCredentials().getDatabase(); List<Key> schemaKeys = new ArrayList<>(); Loading TapSchemaManagerAPI/src/main/resources/log4j.properties +2 −0 Original line number Diff line number Diff line Loading @@ -11,6 +11,8 @@ log4j.appender.IA2.layout.ConversionPattern=[%c{1}]: %m%n # Root Logger log4j.rootLogger=WARN,AD log4j.logger.org.apache.commons.dbcp2=DEBUG,AD # IA2 Logger log4j.logger.it.inaf.ia2=TRACE,IA2 log4j.additivity.it.inaf.ia2=false TapSchemaManagerAPI/src/test/java/it/inaf/ia2/tsm/api/TestAll.java +1 −6 Original line number Diff line number Diff line Loading @@ -22,11 +22,6 @@ */ package it.inaf.ia2.tsm.api; import it.inaf.ia2.tsm.api.TapSchemaFactory; import it.inaf.ia2.tsm.api.TapSchemaImpl; import it.inaf.ia2.tsm.api.UpdateOperations; import it.inaf.ia2.tsm.api.DBWrapper; import it.inaf.ia2.tsm.api.Credentials; import it.inaf.ia2.tsm.api.contract.DatabaseType; import it.inaf.ia2.tsm.api.contract.Column; import it.inaf.ia2.tsm.api.contract.Key; Loading Loading
TapSchemaManagerAPI/pom.xml +0 −1 Original line number Diff line number Diff line Loading @@ -16,7 +16,6 @@ <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>5.1.37</version> <type>jar</type> </dependency> <dependency> <groupId>org.postgresql</groupId> Loading
TapSchemaManagerAPI/src/main/java/it/inaf/ia2/tsm/api/DBWrapper.java +24 −18 Original line number Diff line number Diff line Loading @@ -22,13 +22,15 @@ */ package it.inaf.ia2.tsm.api; import it.inaf.ia2.tsm.api.contract.DatabaseType; import com.mysql.jdbc.jdbc2.optional.MysqlDataSource; import it.inaf.ia2.tsm.api.contract.DatabaseType; import java.io.Serializable; import java.sql.Connection; import java.sql.SQLException; import javax.sql.DataSource; import org.postgresql.ds.PGPoolingDataSource; import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** * This class is used to silently manage the possibility to have separate data Loading @@ -44,6 +46,7 @@ import org.postgresql.ds.PGPoolingDataSource; public class DBWrapper implements Serializable { private static final long serialVersionUID = 1721030677924066695L; private final static Logger log = LoggerFactory.getLogger(DBWrapper.class); // Same credentials private Credentials credentials; Loading Loading @@ -182,30 +185,33 @@ public class DBWrapper implements Serializable { } private DataSource createDataSource(Credentials credentials) { if (credentials.getDatabaseType() == DatabaseType.MYSQL) { MysqlDataSource ds = new MysqlDataSource(); switch (credentials.getDatabaseType()) { ds.setServerName(credentials.getHostname()); ds.setPortNumber(credentials.getPort()); ds.setUser(credentials.getUsername()); ds.setPassword(credentials.getPassword()); case MYSQL: MysqlDataSource myds = new MysqlDataSource(); return ds; } else if (credentials.getDatabaseType() == DatabaseType.POSTGRES) { myds.setServerName(credentials.getHostname()); myds.setPortNumber(credentials.getPort()); myds.setUser(credentials.getUsername()); myds.setPassword(credentials.getPassword()); PGPoolingDataSource ds = new PGPoolingDataSource(); return myds; ds.setServerName(credentials.getHostname()); ds.setPortNumber(credentials.getPort()); ds.setUser(credentials.getUsername()); ds.setPassword(credentials.getPassword()); ds.setDatabaseName("postgres"); case POSTGRES: PGPoolingDataSource pgds = new PGPoolingDataSource(); return ds; } pgds.setServerName(credentials.getHostname()); pgds.setPortNumber(credentials.getPort()); pgds.setUser(credentials.getUsername()); pgds.setPassword(credentials.getPassword()); pgds.setDatabaseName(credentials.getDatabase()); return pgds; default: throw new UnsupportedOperationException(credentials.getDatabaseType() + " not supported yet."); } } } }
TapSchemaManagerAPI/src/main/java/it/inaf/ia2/tsm/api/DaoKey.java +4 −2 Original line number Diff line number Diff line Loading @@ -40,7 +40,6 @@ import java.util.List; import java.util.Map; import java.util.regex.Pattern; import javax.sql.DataSource; import org.postgresql.ds.PGPoolingDataSource; import org.slf4j.Logger; import org.slf4j.LoggerFactory; Loading Loading @@ -113,7 +112,10 @@ public class DaoKey { } else if (dbType == DatabaseType.POSTGRES) { String databaseName = ((PGPoolingDataSource) dataSource).getDatabaseName(); String databaseName = schemaName.equals(tapSchema.getName()) ? dbWrapper.getTapSchemaCredentials().getDatabase() : dbWrapper.getSourceCredentials().getDatabase(); List<Key> schemaKeys = new ArrayList<>(); Loading
TapSchemaManagerAPI/src/main/resources/log4j.properties +2 −0 Original line number Diff line number Diff line Loading @@ -11,6 +11,8 @@ log4j.appender.IA2.layout.ConversionPattern=[%c{1}]: %m%n # Root Logger log4j.rootLogger=WARN,AD log4j.logger.org.apache.commons.dbcp2=DEBUG,AD # IA2 Logger log4j.logger.it.inaf.ia2=TRACE,IA2 log4j.additivity.it.inaf.ia2=false
TapSchemaManagerAPI/src/test/java/it/inaf/ia2/tsm/api/TestAll.java +1 −6 Original line number Diff line number Diff line Loading @@ -22,11 +22,6 @@ */ package it.inaf.ia2.tsm.api; import it.inaf.ia2.tsm.api.TapSchemaFactory; import it.inaf.ia2.tsm.api.TapSchemaImpl; import it.inaf.ia2.tsm.api.UpdateOperations; import it.inaf.ia2.tsm.api.DBWrapper; import it.inaf.ia2.tsm.api.Credentials; import it.inaf.ia2.tsm.api.contract.DatabaseType; import it.inaf.ia2.tsm.api.contract.Column; import it.inaf.ia2.tsm.api.contract.Key; Loading