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